@@ -220,9 +220,10 @@ impl<R: Reason> Inherited<R> {
220
220
fn add_type_consts (
221
221
& mut self ,
222
222
opts : & GlobalOptions ,
223
+ child : & ShallowClass < R > ,
223
224
other_type_consts : TypeConstNameIndexMap < TypeConst < R > > ,
224
225
) {
225
- let strict_const_semantics = opts. tco_enable_strict_const_semantics > 2 ;
226
+ let fix_synthesized = opts. tco_enable_strict_const_semantics > 3 ;
226
227
227
228
for ( name, mut new_const) in other_type_consts {
228
229
match self . type_consts . entry ( name) {
@@ -239,15 +240,20 @@ impl<R: Reason> Inherited<R> {
239
240
e. get_mut ( ) . enforceable = new_const. enforceable . clone ( ) ;
240
241
}
241
242
let old_const = e. get ( ) ;
243
+ let is_class = || match child. kind {
244
+ ClassishKind :: Cclass ( _) => true ,
245
+ ClassishKind :: Ctrait
246
+ | ClassishKind :: Cinterface
247
+ | ClassishKind :: Cenum
248
+ | ClassishKind :: CenumClass ( _) => false ,
249
+ } ;
242
250
match (
243
251
old_const. is_synthesized ,
244
252
new_const. is_synthesized ,
245
253
& old_const. kind ,
246
254
& new_const. kind ,
247
255
) {
248
- // TODO(T125402906) Re-enable this after fixing inheritance
249
- // (false, true, _, _) => {}
250
- ( false , true , _, _) if strict_const_semantics => { }
256
+ ( false , true , _, _) if is_class ( ) && fix_synthesized => { }
251
257
// This covers the following case
252
258
// ```
253
259
// interface I1 { abstract const type T; }
@@ -308,7 +314,7 @@ impl<R: Reason> Inherited<R> {
308
314
}
309
315
}
310
316
311
- fn add_inherited ( & mut self , opts : & GlobalOptions , other : Self ) {
317
+ fn add_inherited ( & mut self , opts : & GlobalOptions , child : & ShallowClass < R > , other : Self ) {
312
318
let Self {
313
319
substs,
314
320
props,
@@ -326,7 +332,7 @@ impl<R: Reason> Inherited<R> {
326
332
self . add_static_methods ( static_methods) ;
327
333
self . add_constructor ( constructor) ;
328
334
self . add_consts ( consts) ;
329
- self . add_type_consts ( opts, type_consts) ;
335
+ self . add_type_consts ( opts, child , type_consts) ;
330
336
}
331
337
332
338
fn mark_as_synthesized ( & mut self ) {
@@ -506,7 +512,7 @@ impl<'a, R: Reason> MemberFolder<'a, R> {
506
512
fn add_from_interface_constants ( & mut self ) -> Result < ( ) > {
507
513
for ty in self . child . req_implements . iter ( ) {
508
514
self . members
509
- . add_inherited ( self . opts , self . class_constants_from_class ( ty) ?)
515
+ . add_inherited ( self . opts , self . child , self . class_constants_from_class ( ty) ?)
510
516
}
511
517
512
518
Ok ( ( ) )
@@ -515,7 +521,7 @@ impl<'a, R: Reason> MemberFolder<'a, R> {
515
521
fn add_from_implements_constants ( & mut self ) -> Result < ( ) > {
516
522
for ty in self . child . implements . iter ( ) {
517
523
self . members
518
- . add_inherited ( self . opts , self . class_constants_from_class ( ty) ?)
524
+ . add_inherited ( self . opts , self . child , self . class_constants_from_class ( ty) ?)
519
525
}
520
526
521
527
Ok ( ( ) )
@@ -524,7 +530,7 @@ impl<'a, R: Reason> MemberFolder<'a, R> {
524
530
fn add_from_xhp_attr_uses ( & mut self ) -> Result < ( ) > {
525
531
for ty in self . child . xhp_attr_uses . iter ( ) {
526
532
self . members
527
- . add_inherited ( self . opts , self . xhp_attrs_from_class ( ty) ?)
533
+ . add_inherited ( self . opts , self . child , self . xhp_attrs_from_class ( ty) ?)
528
534
}
529
535
530
536
Ok ( ( ) )
@@ -554,7 +560,7 @@ impl<'a, R: Reason> MemberFolder<'a, R> {
554
560
// be implemented.
555
561
for ty in tys. iter ( ) . rev ( ) {
556
562
self . members
557
- . add_inherited ( self . opts , self . members_from_class ( ty) ?) ;
563
+ . add_inherited ( self . opts , self . child , self . members_from_class ( ty) ?) ;
558
564
}
559
565
560
566
Ok ( ( ) )
@@ -564,7 +570,7 @@ impl<'a, R: Reason> MemberFolder<'a, R> {
564
570
for ty in self . child . req_extends . iter ( ) {
565
571
let mut inherited = self . members_from_class ( ty) ?;
566
572
inherited. mark_as_synthesized ( ) ;
567
- self . members . add_inherited ( self . opts , inherited) ;
573
+ self . members . add_inherited ( self . opts , self . child , inherited) ;
568
574
}
569
575
570
576
Ok ( ( ) )
@@ -573,7 +579,7 @@ impl<'a, R: Reason> MemberFolder<'a, R> {
573
579
fn add_from_traits ( & mut self ) -> Result < ( ) > {
574
580
for ty in self . child . uses . iter ( ) {
575
581
self . members
576
- . add_inherited ( self . opts , self . members_from_class ( ty) ?) ;
582
+ . add_inherited ( self . opts , self . child , self . members_from_class ( ty) ?) ;
577
583
}
578
584
579
585
Ok ( ( ) )
@@ -582,8 +588,11 @@ impl<'a, R: Reason> MemberFolder<'a, R> {
582
588
fn add_from_included_enums_constants ( & mut self ) -> Result < ( ) > {
583
589
if let Some ( et) = self . child . enum_type . as_ref ( ) {
584
590
for ty in et. includes . iter ( ) {
585
- self . members
586
- . add_inherited ( self . opts , self . class_constants_from_class ( ty) ?) ;
591
+ self . members . add_inherited (
592
+ self . opts ,
593
+ self . child ,
594
+ self . class_constants_from_class ( ty) ?,
595
+ ) ;
587
596
}
588
597
}
589
598
0 commit comments