-
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 lower and upper bounds of a type parameter are co…
…mpatible (#885) Closes #875 ### Summary of Changes Show an error if the lower bound of a type parameter is not assignable to its upper bound. In this case, there is no valid substitution for the type parameter.
- Loading branch information
1 parent
6b6f738
commit 2fc7fe6
Showing
4 changed files
with
81 additions
and
12 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
28 changes: 28 additions & 0 deletions
28
...r/declarations/type parameters/lower bound must be assignable to upper bound/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,28 @@ | ||
package tests.validation.other.declarations.typeParameters.lowerBoundMustBeAssignableToUpperBound | ||
|
||
class C< | ||
// $TEST$ no error r"The lower bound .* is not assignable to the upper bound .*\." | ||
»OnlyLowerBound«, | ||
// $TEST$ no error r"The lower bound .* is not assignable to the upper bound .*\." | ||
»OnlyUpperBound«, | ||
// $TEST$ no error r"The lower bound .* is not assignable to the upper bound .*\." | ||
»CompatibleBounds«, | ||
// $TEST$ error "The lower bound 'Number' is not assignable to the upper bound 'String'." | ||
»IncompatibleBounds«, | ||
// $TEST$ no error r"The lower bound .* is not assignable to the upper bound .*\." | ||
»UnresolvedLowerBound«, | ||
// $TEST$ no error r"The lower bound .* is not assignable to the upper bound .*\." | ||
»UnresolvedUpperBound«, | ||
> where { | ||
OnlyLowerBound super Number, | ||
OnlyUpperBound sub Number, | ||
|
||
CompatibleBounds super Number, | ||
CompatibleBounds sub Number, | ||
|
||
IncompatibleBounds super Number, | ||
IncompatibleBounds sub String, | ||
|
||
UnresolvedLowerBound super unknown, | ||
UnresolvedUpperBound sub unknown, | ||
} |