Skip to content

fix: select correct override function #2822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 8, 2024
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