fix: select correct override function#2822
Merged
HerrCai0907 merged 4 commits intoAssemblyScript:mainfrom Mar 8, 2024
Merged
Conversation
MaxGraey
reviewed
Mar 1, 2024
src/module.ts
Outdated
Comment on lines
+3421
to
+3432
| /** Replace case to the specified branch. */ | ||
| replaceCase(value: i32, code: ExpressionRef[]): void { | ||
| let valueIndex = this.values.indexOf(value); | ||
| assert(valueIndex >= 0); | ||
| this.indexes[valueIndex] = this.addCode(code); | ||
| } | ||
|
|
||
| /** Links a case to the specified branch. */ | ||
| addCase(value: i32, code: ExpressionRef[]): void { | ||
| this.values.push(value); | ||
| this.indexes.push(this.addCode(code)); | ||
| } |
Member
There was a problem hiding this comment.
How about merge replaceCase and addCase into one upsertCase method? This will simplify code above to something like:
const hasInheritance = mostRecentInheritanceMapping.has(extender);
if (!hasInheritance || !mostRecentInheritanceMapping.get(extender).extends(classInstance)) {
mostRecentInheritanceMapping.set(extender, classInstance);
builder.upsertCase(extender.id, stmts);
}bbd3811 to
1611141
Compare
MaxGraey
reviewed
Mar 1, 2024
MaxGraey
reviewed
Mar 7, 2024
| } | ||
|
|
||
| /** Links a case to the specified branch. */ | ||
| addCase(value: i32, code: ExpressionRef[]): void { |
Member
There was a problem hiding this comment.
addCase quite small and uses only once. I guess better to remove it and use their body's code in addOrReplaceCase directly.
MaxGraey
reviewed
Mar 7, 2024
Co-authored-by: Max Graey <maxgraey@gmail.com>
MaxGraey
approved these changes
Mar 8, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #2819