-
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: check whether type parameter bounds are named types (#878)
Closes #876 ### Summary of Changes Add a check to ensure that the bound of a type parameter is a named type.
- Loading branch information
1 parent
aa444d4
commit d8b4168
Showing
4 changed files
with
151 additions
and
23 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
2 changes: 1 addition & 1 deletion
2
...ns/constraints/type parameter bounds/left operand must be own type parameter/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
102 changes: 102 additions & 0 deletions
102
...urces/validation/other/declarations/type parameters/bound must be named type/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,102 @@ | ||
package tests.validation.other.declarations.typeParameters.boundMustBeNamedType | ||
|
||
class C | ||
enum E { | ||
V | ||
} | ||
|
||
class MyClass1<T> where { | ||
// $TEST$ error "Bounds of type parameters must be named types." | ||
T sub »() -> ()«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »() -> ()«, | ||
|
||
// $TEST$ error "Bounds of type parameters must be named types." | ||
T super »() -> ()«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »() -> ()«, | ||
} | ||
|
||
class MyClass2<T> where { | ||
// $TEST$ error "Bounds of type parameters must be named types." | ||
T sub »literal<1>«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »literal<1>«, | ||
|
||
// $TEST$ error "Bounds of type parameters must be named types." | ||
T super »literal<1>«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »literal<1>«, | ||
} | ||
|
||
class MyClass3<T> where { | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »C«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »C«, | ||
|
||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »C«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »C«, | ||
} | ||
|
||
class MyClass4<T> where { | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »E«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »E«, | ||
|
||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »E«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »E«, | ||
} | ||
|
||
class MyClass5<T> where { | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »E.V«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »E.V«, | ||
|
||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »E.V«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »E.V«, | ||
} | ||
|
||
class MyClass6<T1, T2> where { | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T1 sub »T2«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T1 sub »T2«, | ||
|
||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T1 super »T2«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T1 super »T2«, | ||
} | ||
|
||
class MyClass7<T> where { | ||
// $TEST$ error "Bounds of type parameters must be named types." | ||
T sub »union<C, E>«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »union<C, E>«, | ||
|
||
// $TEST$ error "Bounds of type parameters must be named types." | ||
T super »union<C, E>«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »union<C, E>«, | ||
} | ||
|
||
class MyClass8<T> where { | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »Unresolved«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T sub »Unresolved«, | ||
|
||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »Unresolved«, | ||
// $TEST$ no error "Bounds of type parameters must be named types." | ||
T super »Unresolved«, | ||
} |