-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: error if type parameter of class is used in static context (#830)
Closes #809 ### Summary of Changes Show an error if a type parameter of a class is used to denote * the type of a static attribute * the type of a parameter/result of a static method.
- Loading branch information
1 parent
0e9f67a
commit d5cf420
Showing
5 changed files
with
73 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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 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 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
43 changes: 43 additions & 0 deletions
43
...validation/other/declarations/type parameters/usage of class type parameters/main.sdstest
This file contains 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,43 @@ | ||
package tests.validation.other.declarations.typeParameters.usageOfClassTypeParameters | ||
|
||
// $TEST$ no error "This type parameter of a containing class cannot be used here." | ||
class MyClass<T>(p: »T«) { | ||
// $TEST$ no error "This type parameter of a containing class cannot be used here." | ||
attr a: »T« | ||
|
||
// $TEST$ error "This type parameter of a containing class cannot be used here." | ||
static attr a: »T« | ||
|
||
// $TEST$ no error "This type parameter of a containing class cannot be used here." | ||
// $TEST$ no error "This type parameter of a containing class cannot be used here." | ||
// $TEST$ no error "This type parameter of a containing class cannot be used here." | ||
// $TEST$ no error "This type parameter of a containing class cannot be used here." | ||
fun f<S>(p1: »T«, p2: »S«) -> (r1: »T«, r2: »S«) | ||
|
||
// $TEST$ error "This type parameter of a containing class cannot be used here." | ||
// $TEST$ no error "This type parameter of a containing class cannot be used here." | ||
// $TEST$ error "This type parameter of a containing class cannot be used here." | ||
// $TEST$ no error "This type parameter of a containing class cannot be used here." | ||
static fun f<S>(p1: »T«, p2: »S«) -> (r1: »T«, r2: »S«) | ||
|
||
// $TEST$ error "This type parameter of a containing class cannot be used here." | ||
// $TEST$ no error "This type parameter of a containing class cannot be used here." | ||
class MyInnerClass<S>(p1: »T«, p2: »S«) { | ||
// $TEST$ error "This type parameter of a containing class cannot be used here." | ||
attr a: »T« | ||
|
||
// $TEST$ error "This type parameter of a containing class cannot be used here." | ||
static attr a: »T« | ||
|
||
// $TEST$ error "This type parameter of a containing class cannot be used here." | ||
fun f(p: »T«) | ||
|
||
// $TEST$ error "This type parameter of a containing class cannot be used here." | ||
static fun f(p: »T«) | ||
} | ||
|
||
enum MyInnerEnum { | ||
// $TEST$ error "This type parameter of a containing class cannot be used here." | ||
MyEnumVariant(p1: »T«) | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
...-ds-lang/tests/resources/validation/other/declarations/type parameters/usage/main.sdstest
This file was deleted.
Oops, something went wrong.