File tree Expand file tree Collapse file tree 6 files changed +4472
-3
lines changed Expand file tree Collapse file tree 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 {
66186618 ) ;
66196619 let overrideInstances = this . resolver . resolveOverrides ( instance ) ;
66206620 if ( overrideInstances ) {
6621+ let mostRecentInheritanceMapping = new Map < Class , Class > ( ) ;
66216622 for ( let i = 0 , k = overrideInstances . length ; i < k ; ++ i ) {
66226623 let overrideInstance = overrideInstances [ i ] ;
66236624 if ( ! overrideInstance . is ( CommonFlags . Compiled ) ) continue ; // errored
@@ -6680,7 +6681,13 @@ export class Compiler extends DiagnosticEmitter {
66806681 if ( instanceMembers && instanceMembers . has ( instance . declaration . name . text ) ) {
66816682 continue ; // skip those not inheriting
66826683 }
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+ }
66846691 }
66856692 }
66866693 }
Original file line number Diff line number Diff line change @@ -3418,16 +3418,32 @@ export class SwitchBuilder {
34183418 this . condition = condition ;
34193419 }
34203420
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+
34213433 /** Links a case to the specified branch. */
34223434 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 {
34233440 let cases = this . cases ;
34243441 let index = cases . indexOf ( code ) ;
34253442 if ( index < 0 ) {
34263443 index = cases . length ;
34273444 cases . push ( code ) ;
34283445 }
3429- this . values . push ( value ) ;
3430- this . indexes . push ( index ) ;
3446+ return index ;
34313447 }
34323448
34333449 /** Links the default branch. */
You can’t perform that action at this time.
0 commit comments