2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
12 type t
= GlobalOptions.t
[@@deriving eq
, show
]
14 let num_local_workers t
= t
.GlobalOptions.tco_num_local_workers
16 let parallel_type_checking_threshold t
=
17 t
.GlobalOptions.tco_parallel_type_checking_threshold
19 let max_typechecker_worker_memory_mb t
=
20 t
.GlobalOptions.tco_max_typechecker_worker_memory_mb
22 let defer_class_declaration_threshold t
=
23 t
.GlobalOptions.tco_defer_class_declaration_threshold
25 let prefetch_deferred_files t
= t
.GlobalOptions.tco_prefetch_deferred_files
27 let remote_type_check_threshold t
=
28 t
.GlobalOptions.tco_remote_type_check_threshold
30 let remote_type_check t
= t
.GlobalOptions.tco_remote_type_check
32 let remote_worker_key t
= t
.GlobalOptions.tco_remote_worker_key
34 let remote_check_id t
= t
.GlobalOptions.tco_remote_check_id
36 let remote_max_batch_size t
= t
.GlobalOptions.tco_remote_max_batch_size
38 let remote_min_batch_size t
= t
.GlobalOptions.tco_remote_min_batch_size
40 let num_remote_workers t
= t
.GlobalOptions.tco_num_remote_workers
42 let remote_version_specifier = GlobalOptions.so_remote_version_specifier
44 let language_feature_logging t
= t
.GlobalOptions.tco_language_feature_logging
46 let experimental_feature_enabled t feature
=
47 SSet.mem feature t
.GlobalOptions.tco_experimental_features
49 let migration_flag_enabled t flag
=
50 SSet.mem flag t
.GlobalOptions.tco_migration_flags
52 let log_inference_constraints t
= t
.GlobalOptions.tco_log_inference_constraints
54 let default = GlobalOptions.default
56 (* TYPECHECKER-SPECIFIC OPTIONS *)
59 * Insist on instantiations for all generic types, even in non-strict files
61 let experimental_generics_arity = "generics_arity"
64 * Forbid casting nullable values, since they have unexpected semantics. For
65 * example, casting `null` to an int results in `0`, which may or may not be
66 * what you were expecting.
68 let experimental_forbid_nullable_cast = "forbid_nullable_cast"
71 * Allow typechecker to do global inference and infer IFC flows
72 * with the <<InferFlows>> flag
74 let experimental_infer_flows = "ifc_infer_flows"
77 * Disallow static memoized functions in non-final classes
79 let experimental_disallow_static_memoized = "disallow_static_memoized"
82 * Enable abstract const type with default syntax, i.e.
83 * abstract const type T as num = int;
85 let experimental_abstract_type_const_with_default =
86 "abstract_type_const_with_default"
88 let experimental_supportdynamic_type_hint = "supportdynamic_type_hint"
90 let experimental_all =
95 experimental_generics_arity;
96 experimental_forbid_nullable_cast;
97 experimental_disallow_static_memoized;
98 experimental_abstract_type_const_with_default;
99 experimental_infer_flows;
100 experimental_supportdynamic_type_hint;
103 let experimental_from_flags ~disallow_static_memoized
=
104 if disallow_static_memoized
then
105 SSet.singleton
experimental_disallow_static_memoized
109 let enable_experimental t feature
=
110 SSet.add feature t
.GlobalOptions.tco_experimental_features
112 let migration_flags_all = List.fold_right ~init
:SSet.empty ~f
:SSet.add
[]
114 let timeout t
= t
.GlobalOptions.tco_timeout
116 let disallow_invalid_arraykey t
= t
.GlobalOptions.tco_disallow_invalid_arraykey
118 let disallow_byref_dynamic_calls t
=
119 t
.GlobalOptions.tco_disallow_byref_dynamic_calls
121 let disallow_byref_calls t
= t
.GlobalOptions.tco_disallow_byref_calls
123 let log_levels t
= t
.GlobalOptions.log_levels
125 let shallow_class_decl t
= t
.GlobalOptions.tco_shallow_class_decl
127 let force_shallow_decl_fanout t
= t
.GlobalOptions.tco_force_shallow_decl_fanout
129 let remote_old_decls_no_limit t
= t
.GlobalOptions.tco_remote_old_decls_no_limit
131 let fetch_remote_old_decls t
= t
.GlobalOptions.tco_fetch_remote_old_decls
133 let force_load_hot_shallow_decls t
=
134 t
.GlobalOptions.tco_force_load_hot_shallow_decls
136 let populate_member_heaps t
= t
.GlobalOptions.tco_populate_member_heaps
138 let skip_hierarchy_checks t
= t
.GlobalOptions.tco_skip_hierarchy_checks
140 let skip_tast_checks t
= t
.GlobalOptions.tco_skip_tast_checks
142 let call_coeffects t
= t
.GlobalOptions.tco_coeffects
144 let local_coeffects t
= t
.GlobalOptions.tco_coeffects_local
146 let any_coeffects t
= call_coeffects t
|| local_coeffects t
148 let strict_contexts t
= t
.GlobalOptions.tco_strict_contexts
150 (* Fully enable IFC on the tcopt *)
151 let enable_ifc t
= GlobalOptions.{ t
with tco_ifc_enabled
= ["/"] }
153 let ifc_enabled t
= t
.GlobalOptions.tco_ifc_enabled
155 let enable_global_write_check t
=
156 GlobalOptions.{ t
with tco_global_write_check_enabled
= ["/"] }
158 let global_write_check_enabled t
=
159 t
.GlobalOptions.tco_global_write_check_enabled
161 let global_write_check_functions_enabled t
=
162 t
.GlobalOptions.tco_global_write_check_functions_enabled
164 let like_type_hints t
= t
.GlobalOptions.tco_like_type_hints
166 let like_casts t
= t
.GlobalOptions.tco_like_casts
168 let simple_pessimize t
= t
.GlobalOptions.tco_simple_pessimize
170 let complex_coercion t
= t
.GlobalOptions.tco_complex_coercion
172 let check_xhp_attribute t
= t
.GlobalOptions.tco_check_xhp_attribute
174 let check_redundant_generics t
= t
.GlobalOptions.tco_check_redundant_generics
176 let disallow_unresolved_type_variables t
=
177 t
.GlobalOptions.tco_disallow_unresolved_type_variables
179 let const_static_props t
= t
.GlobalOptions.tco_const_static_props
181 let global_inference t
= t
.GlobalOptions.tco_global_inference
183 let gi_reinfer_types t
= t
.GlobalOptions.tco_gi_reinfer_types
185 let const_attribute t
= t
.GlobalOptions.tco_const_attribute
187 let set_global_inference t
=
188 GlobalOptions.{ t
with tco_global_inference
= true }
190 let check_attribute_locations t
= t
.GlobalOptions.tco_check_attribute_locations
192 let error_php_lambdas t
= t
.GlobalOptions.tco_error_php_lambdas
194 let disallow_discarded_nullable_awaitables t
=
195 t
.GlobalOptions.tco_disallow_discarded_nullable_awaitables
197 let is_systemlib t
= t
.GlobalOptions.tco_is_systemlib
199 let higher_kinded_types t
= t
.GlobalOptions.tco_higher_kinded_types
201 let method_call_inference t
= t
.GlobalOptions.tco_method_call_inference
203 let report_pos_from_reason t
= t
.GlobalOptions.tco_report_pos_from_reason
205 let enable_sound_dynamic t
= t
.GlobalOptions.tco_enable_sound_dynamic
207 let use_direct_decl_parser t
= t
.GlobalOptions.tco_use_direct_decl_parser
209 let interpret_soft_types_as_like_types t
=
210 t
.GlobalOptions.po_interpret_soft_types_as_like_types
212 let enable_strict_string_concat_interp t
=
213 t
.GlobalOptions.tco_enable_strict_string_concat_interp
215 let ignore_unsafe_cast t
= t
.GlobalOptions.tco_ignore_unsafe_cast
217 let set_tco_no_parser_readonly_check t b
=
218 GlobalOptions.{ t
with tco_no_parser_readonly_check
= b
}
220 let tco_no_parser_readonly_check t
=
221 t
.GlobalOptions.tco_no_parser_readonly_check
223 let set_tco_enable_expression_trees t b
=
224 GlobalOptions.{ t
with tco_enable_expression_trees
= b
}
226 let expression_trees_enabled t
= t
.GlobalOptions.tco_enable_expression_trees
228 let enable_modules t
= t
.GlobalOptions.tco_enable_modules
230 let set_modules t b
= GlobalOptions.{ t
with tco_enable_modules
= b
}
232 let allowed_expression_tree_visitors t
=
233 t
.GlobalOptions.tco_allowed_expression_tree_visitors
235 let math_new_code t
= t
.GlobalOptions.tco_math_new_code
237 let typeconst_concrete_concrete_error t
=
238 t
.GlobalOptions.tco_typeconst_concrete_concrete_error
240 let enable_strict_const_semantics t
=
241 t
.GlobalOptions.tco_enable_strict_const_semantics
243 let strict_wellformedness t
= t
.GlobalOptions.tco_strict_wellformedness
245 let meth_caller_only_public_visibility t
=
246 t
.GlobalOptions.tco_meth_caller_only_public_visibility
248 let require_extends_implements_ancestors t
=
249 t
.GlobalOptions.tco_require_extends_implements_ancestors
251 let strict_value_equality t
= t
.GlobalOptions.tco_strict_value_equality
253 let enforce_sealed_subclasses t
= t
.GlobalOptions.tco_enforce_sealed_subclasses
255 let enable_enum_supertyping t
= t
.GlobalOptions.po_enable_enum_supertyping
257 let everything_sdt t
= t
.GlobalOptions.tco_everything_sdt
259 let pessimise_builtins t
= t
.GlobalOptions.tco_pessimise_builtins
261 let explicit_consistent_constructors t
=
262 t
.GlobalOptions.tco_explicit_consistent_constructors
264 let require_types_class_consts t
=
265 t
.GlobalOptions.tco_require_types_class_consts
267 let type_printer_fuel t
= t
.GlobalOptions.tco_type_printer_fuel
269 let log_saved_state_age_and_distance t
=
270 t
.GlobalOptions.tco_log_saved_state_age_and_distance
272 let specify_manifold_api_key t
= t
.GlobalOptions.tco_specify_manifold_api_key
274 let saved_state_manifold_api_key t
=
275 t
.GlobalOptions.tco_saved_state_manifold_api_key
277 let profile_top_level_definitions t
=
278 t
.GlobalOptions.tco_profile_top_level_definitions
280 let allow_all_files_for_module_declarations t
=
281 t
.GlobalOptions.tco_allow_all_files_for_module_declarations
283 let allowed_files_for_module_declarations t
=
284 t
.GlobalOptions.tco_allowed_files_for_module_declarations
286 let use_manifold_cython_client t
=
287 t
.GlobalOptions.tco_use_manifold_cython_client
289 let record_fine_grained_dependencies t
=
290 t
.GlobalOptions.tco_record_fine_grained_dependencies
292 let loop_iteration_upper_bound t
=
293 t
.GlobalOptions.tco_loop_iteration_upper_bound
295 let set_ordered_solving t b
= GlobalOptions.{ t
with tco_ordered_solving
= b
}
297 let ordered_solving t
= t
.GlobalOptions.tco_ordered_solving
299 let typecheck_sample_rate t
= t
.GlobalOptions.tco_typecheck_sample_rate
301 let log_fanout t ~fanout_cardinal
=
302 match t
.GlobalOptions.tco_log_large_fanouts_threshold
with
304 | Some threshold
-> Int.(fanout_cardinal
>= threshold
)
306 let substitution_mutation t
= t
.GlobalOptions.tco_substitution_mutation
308 let use_type_alias_heap t
= t
.GlobalOptions.tco_use_type_alias_heap