Skip to content

Commit ae3ed8e

Browse files
SamChou19815meta-codesync[bot]
authored andcommitted
[flow] Strip nominal identity of InstanceT going through ObjKitT
Summary: This diff strips the nominal identity of `InstanceT` that's going through a `ObjKitT` transform, which includes operations like `Readonly`, `Partial`. It's a long standing unsoundness issue, and it could also complicate nominal records work, if we want to reuse the `InstanceT` infra. Changelog: [internal] Gated and default disabled for now Reviewed By: gkz Differential Revision: D85611050 fbshipit-source-id: ab8aa785c616c65b1e538fd73c4455ca57244d90
1 parent 9b143be commit ae3ed8e

11 files changed

Lines changed: 39 additions & 1 deletion

File tree

src/commands/commandUtils.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,7 @@ let make_options
14681468
opt_facebook_fbt = FlowConfig.facebook_fbt flowconfig;
14691469
opt_facebook_module_interop = FlowConfig.facebook_module_interop flowconfig;
14701470
opt_ignore_non_literal_requires = FlowConfig.ignore_non_literal_requires flowconfig;
1471+
opt_instance_t_objkit_fix = FlowConfig.instance_t_objkit_fix flowconfig;
14711472
opt_include_warnings =
14721473
options_flags.include_warnings
14731474
|| options_flags.max_warnings <> None

src/commands/config/flowConfig.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ module Opts = struct
8686
hook_compatibility_includes: string list;
8787
hook_compatibility_excludes: string list;
8888
ignore_non_literal_requires: bool;
89+
instance_t_objkit_fix: bool;
8990
include_warnings: bool;
9091
jest_integration: bool;
9192
lazy_mode: lazy_mode option;
@@ -232,6 +233,7 @@ module Opts = struct
232233
hook_compatibility_includes = [];
233234
hook_compatibility_excludes = [];
234235
ignore_non_literal_requires = false;
236+
instance_t_objkit_fix = false;
235237
include_warnings = false;
236238
jest_integration = false;
237239
lazy_mode = None;
@@ -706,6 +708,9 @@ module Opts = struct
706708
let ignore_non_literal_requires_parser =
707709
boolean (fun opts v -> Ok { opts with ignore_non_literal_requires = v })
708710

711+
let instance_t_objkit_fix_parser =
712+
boolean (fun opts v -> Ok { opts with instance_t_objkit_fix = v })
713+
709714
let lazy_mode_parser =
710715
enum
711716
[
@@ -1056,6 +1061,7 @@ module Opts = struct
10561061
hook_compatibility_excludes_parser
10571062
);
10581063
("experimental.facebook_module_interop", facebook_module_interop_parser);
1064+
("experimental.instance_t_objkit_fix", instance_t_objkit_fix_parser);
10591065
("experimental.channel_mode", channel_mode_parser ~enabled:true);
10601066
("experimental.channel_mode.windows", channel_mode_parser ~enabled:Sys.win32);
10611067
("experimental.long_lived_workers", long_lived_workers_parser ~enabled:true);
@@ -1920,6 +1926,8 @@ let hook_compatibility c = c.options.Opts.hook_compatibility
19201926

19211927
let ignore_non_literal_requires c = c.options.Opts.ignore_non_literal_requires
19221928

1929+
let instance_t_objkit_fix c = c.options.Opts.instance_t_objkit_fix
1930+
19231931
let include_warnings c = c.options.Opts.include_warnings
19241932

19251933
let jest_integration c = c.options.Opts.jest_integration

src/commands/config/flowConfig.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ val hook_compatibility : config -> bool
150150

151151
val ignore_non_literal_requires : config -> bool
152152

153+
val instance_t_objkit_fix : config -> bool
154+
153155
val include_warnings : config -> bool
154156

155157
val jest_integration : config -> bool

src/common/options.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ type t = {
137137
opt_gc_worker: gc_control;
138138
opt_haste_module_ref_prefix: string option;
139139
opt_ignore_non_literal_requires: bool;
140+
opt_instance_t_objkit_fix: bool;
140141
opt_include_suppressions: bool;
141142
opt_include_warnings: bool;
142143
opt_lazy_mode: bool;
@@ -377,6 +378,8 @@ let saved_state_verify opts = opts.opt_saved_state_verify
377378

378379
let should_ignore_non_literal_requires opts = opts.opt_ignore_non_literal_requires
379380

381+
let instance_t_objkit_fix opts = opts.opt_instance_t_objkit_fix
382+
380383
let should_include_warnings opts = opts.opt_include_warnings
381384

382385
let should_munge_underscores opts = opts.opt_munge_underscores

src/flow_dot_js.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ let stub_metadata ~root ~checked =
124124
facebook_module_interop = false;
125125
file_options = Files.default_options;
126126
ignore_non_literal_requires = false;
127+
instance_t_objkit_fix = false;
127128
max_workers = 0;
128129
missing_module_generators = [];
129130
no_unchecked_indexed_access = false;

src/services/code_action/__tests__/refactor_extract_utils_tests.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ let stub_metadata ~root ~checked =
5151
facebook_module_interop = false;
5252
file_options;
5353
ignore_non_literal_requires = false;
54+
instance_t_objkit_fix = false;
5455
max_workers = 0;
5556
missing_module_generators = [];
5657
no_unchecked_indexed_access = false;

src/typing/__tests__/type_hint_test.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ let metadata =
4646
facebook_module_interop = false;
4747
file_options = Files.default_options;
4848
ignore_non_literal_requires = false;
49+
instance_t_objkit_fix = false;
4950
max_workers = 0;
5051
missing_module_generators = [];
5152
no_unchecked_indexed_access = false;

src/typing/__tests__/typed_ast_test.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ let metadata =
4444
facebook_module_interop = false;
4545
file_options = Files.default_options;
4646
ignore_non_literal_requires = false;
47+
instance_t_objkit_fix = false;
4748
max_workers = 0;
4849
missing_module_generators = [];
4950
no_unchecked_indexed_access = false;

src/typing/context.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type metadata = {
5656
facebook_module_interop: bool;
5757
file_options: Files.options;
5858
ignore_non_literal_requires: bool;
59+
instance_t_objkit_fix: bool;
5960
max_workers: int;
6061
missing_module_generators: (Str.regexp * string) list;
6162
no_unchecked_indexed_access: bool;
@@ -294,6 +295,7 @@ let metadata_of_options options =
294295
hook_compatibility_excludes = Options.hook_compatibility_excludes options;
295296
hook_compatibility_includes = Options.hook_compatibility_includes options;
296297
hook_compatibility = Options.hook_compatibility options;
298+
instance_t_objkit_fix = Options.instance_t_objkit_fix options;
297299
react_rules = Options.react_rules options;
298300
dev_only_refinement_info_as_errors = Options.dev_only_refinement_info_as_errors options;
299301
enable_const_params = Options.enable_const_params options;

src/typing/context.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ type metadata = {
106106
facebook_module_interop: bool;
107107
file_options: Files.options;
108108
ignore_non_literal_requires: bool;
109+
instance_t_objkit_fix: bool;
109110
max_workers: int;
110111
missing_module_generators: (Str.regexp * string) list;
111112
no_unchecked_indexed_access: bool;

0 commit comments

Comments
 (0)