File tree 6 files changed +4472
-3
lines changed
6 files changed +4472
-3
lines changed Original file line number Diff line number Diff line change @@ -6618,6 +6618,7 @@ export class Compiler extends DiagnosticEmitter {
6618
6618
) ;
6619
6619
let overrideInstances = this . resolver . resolveOverrides ( instance ) ;
6620
6620
if ( overrideInstances ) {
6621
+ let mostRecentInheritanceMapping = new Map < Class , Class > ( ) ;
6621
6622
for ( let i = 0 , k = overrideInstances . length ; i < k ; ++ i ) {
6622
6623
let overrideInstance = overrideInstances [ i ] ;
6623
6624
if ( ! overrideInstance . is ( CommonFlags . Compiled ) ) continue ; // errored
@@ -6680,7 +6681,13 @@ export class Compiler extends DiagnosticEmitter {
6680
6681
if ( instanceMembers && instanceMembers . has ( instance . declaration . name . text ) ) {
6681
6682
continue ; // skip those not inheriting
6682
6683
}
6683
- builder . addCase ( extender . id , stmts ) ;
6684
+ if (
6685
+ ! mostRecentInheritanceMapping . has ( extender ) ||
6686
+ ! assert ( mostRecentInheritanceMapping . get ( extender ) ) . extends ( classInstance )
6687
+ ) {
6688
+ mostRecentInheritanceMapping . set ( extender , classInstance ) ;
6689
+ builder . addOrReplaceCase ( extender . id , stmts ) ;
6690
+ }
6684
6691
}
6685
6692
}
6686
6693
}
Original file line number Diff line number Diff line change @@ -3418,16 +3418,32 @@ export class SwitchBuilder {
3418
3418
this . condition = condition ;
3419
3419
}
3420
3420
3421
+ /** Links a case to the specified branch, replace old case if it is linked. */
3422
+ addOrReplaceCase ( value : i32 , code : ExpressionRef [ ] ) : void {
3423
+ const valueIndex = this . values . indexOf ( value ) ;
3424
+ const codeIndex = this . addCode ( code ) ;
3425
+ if ( valueIndex >= 0 ) {
3426
+ this . indexes [ valueIndex ] = codeIndex ;
3427
+ } else {
3428
+ this . values . push ( value ) ;
3429
+ this . indexes . push ( codeIndex ) ;
3430
+ }
3431
+ }
3432
+
3421
3433
/** Links a case to the specified branch. */
3422
3434
addCase ( value : i32 , code : ExpressionRef [ ] ) : void {
3435
+ this . values . push ( value ) ;
3436
+ this . indexes . push ( this . addCode ( code ) ) ;
3437
+ }
3438
+
3439
+ private addCode ( code : ExpressionRef [ ] ) : i32 {
3423
3440
let cases = this . cases ;
3424
3441
let index = cases . indexOf ( code ) ;
3425
3442
if ( index < 0 ) {
3426
3443
index = cases . length ;
3427
3444
cases . push ( code ) ;
3428
3445
}
3429
- this . values . push ( value ) ;
3430
- this . indexes . push ( index ) ;
3446
+ return index ;
3431
3447
}
3432
3448
3433
3449
/** Links the default branch. */
You can’t perform that action at this time.
0 commit comments