Skip to content

Commit 1a95134

Browse files
committed
Include new types
1 parent bc065f1 commit 1a95134

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/typing/gc_js.ml

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ let rec gc cx state = function
6767
(** def types **)
6868

6969
| AbstractT (_, t) -> gc cx state t
70+
| AbstractsT (_, _) -> ()
7071
| AnnotT t -> gc cx state t
7172
| DefT (_, AnyFunT) -> ()
7273
| DefT (_, AnyObjT) -> ()
@@ -79,6 +80,7 @@ let rec gc cx state = function
7980
| BoundT typeparam -> gc_typeparam cx state typeparam
8081
| ChoiceKitT _ -> ()
8182
| DefT (_, ClassT t) -> gc cx state t
83+
| DefT (_, NonabstractClassT t) -> gc cx state t
8284
| CustomFunT _ -> ()
8385
| DefT (_, NumT _)
8486
| DefT (_, StrT _)
@@ -199,6 +201,7 @@ and gc_use cx state = function
199201
| AssertBinaryInRHST _ -> ()
200202
| AssertForInRHST _ -> ()
201203
| AssertImportIsValueT _ -> ()
204+
| AssertNonabstractT _ -> ()
202205
| AssertRestParamT _ -> ()
203206
| BecomeT (_, t) -> gc cx state t
204207
| BindT(_, funcalltype, _) -> gc_funcalltype cx state funcalltype
@@ -233,6 +236,7 @@ and gc_use cx state = function
233236
| ExportTypeT (_, _, _, t, t_out) ->
234237
gc cx state t;
235238
gc cx state t_out
239+
| GatherAbstractsT (_, i, _, t) -> gc_insttype cx state i; gc cx state t
236240
| GetElemT(_, i, t) -> gc cx state i; gc cx state t
237241
| GetKeysT (_, t) -> gc cx state t
238242
| GetValuesT (_, t) -> gc cx state t

src/typing/type_mapper.ml

+18-4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class t = object(self)
104104
let t'' = self#type_ cx t' in
105105
if t'' == t' then t
106106
else AbstractT (r, t'')
107+
| AbstractsT _ -> t
107108
| AnnotT t' ->
108109
let t'' = self#type_ cx t' in
109110
if t'' == t' then t
@@ -169,6 +170,10 @@ class t = object(self)
169170
let t'' = self#type_ cx t' in
170171
if t'' == t' then t
171172
else ClassT t''
173+
| NonabstractClassT t' ->
174+
let t'' = self#type_ cx t' in
175+
if t'' == t' then t
176+
else NonabstractClassT t''
172177
| InstanceT (st, su, impl, instt) ->
173178
let st' = self#type_ cx st in
174179
let su' = self#type_ cx su in
@@ -257,7 +262,8 @@ class t = object(self)
257262
initialized_field_names;
258263
methods_tmap;
259264
mixins;
260-
structural } as t) =
265+
structural;
266+
abstracts } as t) =
261267
let type_args' = SMap.ident_map (self#type_ cx) type_args in
262268
let f_tmap = Context.find_props cx fields_tmap in
263269
let f_tmap' = SMap.ident_map (Property.ident_map_t (self#type_ cx)) f_tmap in
@@ -269,11 +275,13 @@ class t = object(self)
269275
let methods_tmap' =
270276
if m_tmap == m_tmap' then methods_tmap
271277
else Context.make_property_map cx m_tmap in
272-
if type_args == type_args' && methods_tmap == methods_tmap' && fields_tmap == fields_tmap'
278+
let abstracts' = self#type_ cx abstracts in
279+
if type_args == type_args' && methods_tmap == methods_tmap'
280+
&& fields_tmap == fields_tmap' && abstracts == abstracts'
273281
then t
274282
else
275283
{class_id; type_args = type_args'; arg_polarities; fields_tmap = fields_tmap';
276-
initialized_field_names; methods_tmap = methods_tmap'; mixins; structural}
284+
initialized_field_names; methods_tmap = methods_tmap'; mixins; structural; abstracts}
277285

278286
method type_param cx ({reason; name; bound; polarity; default} as t) =
279287
let bound' = self#type_ cx bound in
@@ -472,7 +480,8 @@ class t = object(self)
472480
| AssertBinaryInLHST _
473481
| AssertBinaryInRHST _
474482
| AssertForInRHST _
475-
| AssertRestParamT _ -> t
483+
| AssertRestParamT _
484+
| AssertNonabstractT _ -> t
476485
| PredicateT (p, t') ->
477486
let p' = self#predicate cx p in
478487
let t'' = self#type_ cx t' in
@@ -640,6 +649,11 @@ class t = object(self)
640649
let t2' = self#type_ cx t2 in
641650
if t1' == t1 && t2' == t2 then t
642651
else ExportTypeT (r, skip, name, t1', t2')
652+
| GatherAbstractsT (r, instt, r_map, t') ->
653+
let instt' = self#inst_type cx instt in
654+
let t'' = self#type_ cx t' in
655+
if instt' == instt && t'' == t' then t
656+
else GatherAbstractsT (r, instt', r_map, t'')
643657
| MapTypeT (r, typemap, t', cont) ->
644658
let t'' = self#type_ cx t' in
645659
let cont' = self#cont cx cont in

0 commit comments

Comments
 (0)