Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6681,17 +6681,12 @@ export class Compiler extends DiagnosticEmitter {
if (instanceMembers && instanceMembers.has(instance.declaration.name.text)) {
continue; // skip those not inheriting
}
if (mostRecentInheritanceMapping.has(extender)) {
let currentRecentParent = assert(mostRecentInheritanceMapping.get(extender));
if (currentRecentParent.extends(classInstance)) {
// already find recent parent, keep old stmt
} else {
mostRecentInheritanceMapping.set(extender, classInstance);
builder.replaceCase(extender.id, stmts);
}
} else {
if (
!mostRecentInheritanceMapping.has(extender) ||
!assert(mostRecentInheritanceMapping.get(extender)).extends(classInstance)
) {
mostRecentInheritanceMapping.set(extender, classInstance);
builder.addCase(extender.id, stmts);
builder.addOrReplaceCase(extender.id, stmts);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3418,11 +3418,11 @@ export class SwitchBuilder {
this.condition = condition;
}

/** Replace case to the specified branch. */
replaceCase(value: i32, code: ExpressionRef[]): void {
/** Links a case to the specified branch, replace old case if it is linked. */
addOrReplaceCase(value: i32, code: ExpressionRef[]): void {
let valueIndex = this.values.indexOf(value);
assert(valueIndex >= 0);
this.indexes[valueIndex] = this.addCode(code);
if (valueIndex >= 0) this.indexes[valueIndex] = this.addCode(code);
else this.addCase(value, code);
}

/** Links a case to the specified branch. */
Expand Down