-
-
Notifications
You must be signed in to change notification settings - Fork 688
fix: report error when generic method attempts to implement non-generic interface method #3007
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
Open
Changqing-JING
wants to merge
5
commits into
AssemblyScript:main
Choose a base branch
from
Changqing-JING:bugfix/interface-template-type
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6fce518
fix: report error when generic method attempts to implement non-gener…
Changqing-JING c1f84f8
Fix
Changqing-JING fae279c
Add test
Changqing-JING dda9bbc
add testcase
Changqing-JING 54dd10a
forbidden interface function and generic function to be generic
Changqing-JING File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "asc_flags": [], | ||
| "stderr": [ | ||
| "AS241: An interface or abstract method 'foo' cannot have type parameters.", | ||
| "AS241: An interface or abstract method 'baz' cannot have type parameters.", | ||
| "TS2515: Non-abstract class 'override-typeparam-mismatch/CC' does not implement inherited abstract member 'foo' from 'override-typeparam-mismatch/I'.", | ||
| "TS2515: Non-abstract class 'override-typeparam-mismatch/DD' does not implement inherited abstract member 'bar' from 'override-typeparam-mismatch/J'.", | ||
| "TS2515: Non-abstract class 'override-typeparam-mismatch/C2' does not implement inherited abstract member 'foo' from 'override-typeparam-mismatch/I2'.", | ||
| "TS2515: Non-abstract class 'override-typeparam-mismatch/FF' does not implement inherited abstract member 'baz' from 'override-typeparam-mismatch/A1'.", | ||
| "TS2515: Non-abstract class 'override-typeparam-mismatch/GG' does not implement inherited abstract member 'qux' from 'override-typeparam-mismatch/A2'.", | ||
| "EOF" | ||
| ] | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| interface I { | ||
| foo(x: i32): i32; | ||
| } | ||
|
|
||
| class CC implements I { | ||
| foo<T>(x: i32): i32 { | ||
| return x; | ||
| } | ||
| } | ||
|
|
||
| let c:I = new CC(); | ||
| c.foo(1); | ||
|
|
||
| interface J { | ||
| bar(x: i32): i32; | ||
| } | ||
|
|
||
| class DD implements J { | ||
| bar<T>(x: i32): i32 { | ||
| return x; | ||
| } | ||
| } | ||
|
|
||
| let dd:DD = new DD(); | ||
| dd.bar<i32>(1); | ||
|
|
||
| interface I2 { | ||
| foo<T, U>(x: i32): i32; | ||
| } | ||
|
|
||
| class C2 implements I2 { | ||
| foo<T>(x: i32): i32 { | ||
| return x; | ||
| } | ||
| } | ||
|
|
||
| new C2().foo<i32>(1); | ||
|
|
||
| // abstract method cannot be generic (AS241) | ||
| abstract class A1 { | ||
| abstract baz<T>(x: i32): i32; | ||
| } | ||
|
|
||
| class FF extends A1 { | ||
| baz<T>(x: i32): i32 { | ||
| return x; | ||
| } | ||
| } | ||
|
|
||
| new FF().baz<i32>(1); | ||
|
|
||
| // generic method cannot implement non-generic abstract method (TS2515) | ||
| abstract class A2 { | ||
| abstract qux(x: i32): i32; | ||
| } | ||
|
|
||
| class GG extends A2 { | ||
| qux<T>(x: i32): i32 { | ||
| return x; | ||
| } | ||
| } | ||
|
|
||
| let a: A2 = new GG(); | ||
| a.qux(1); | ||
|
|
||
| ERROR("EOF"); | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.