-
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.
fix: check for duplicate bounds if type parameters occur as right ope…
…rand (#882) Closes #881 ### Summary of Changes We now correctly show an error if a type parameter has multiple lower/upper bounds but occurs as the right operand in subsequent bounds.
- Loading branch information
1 parent
f1420a2
commit 8776ce0
Showing
4 changed files
with
143 additions
and
73 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
120 changes: 82 additions & 38 deletions
120
...ests/resources/validation/other/declarations/type parameters/multiple bounds/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 |
---|---|---|
@@ -1,94 +1,138 @@ | ||
package tests.validation.other.typeParameters.multipleBounds | ||
|
||
class MyGlobalClass<T1, T2> where { | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
class MyGlobalClass<T1, T2, T3, T4, T5, T6, T7, T8> where { | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 sub Int«, | ||
// $TEST$ error "A type parameter can only have a single upper bound." | ||
// $TEST$ error "The type parameter 'T1' can only have a single upper bound." | ||
»T1 sub Number«, | ||
// $TEST$ no error "A type parameter can only have a single lower bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 super Int«, | ||
// $TEST$ error "A type parameter can only have a single lower bound." | ||
// $TEST$ error "The type parameter 'T1' can only have a single lower bound." | ||
»T1 super Number«, | ||
|
||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T2 sub Int«, | ||
// $TEST$ error "A type parameter can only have a single upper bound." | ||
// $TEST$ error "The type parameter 'T2' can only have a single upper bound." | ||
»T2 sub Number«, | ||
// $TEST$ no error "A type parameter can only have a single lower bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T2 super Int«, | ||
// $TEST$ error "A type parameter can only have a single lower bound." | ||
// $TEST$ error "The type parameter 'T2' can only have a single lower bound." | ||
»T2 super Number«, | ||
|
||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T3 sub Int«, | ||
// $TEST$ error "The type parameter 'T3' can only have a single upper bound." | ||
»T4 super T3«, | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T5 super Int«, | ||
// $TEST$ error "The type parameter 'T5' can only have a single lower bound." | ||
»T6 sub T5«, | ||
|
||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T7 sub Int«, | ||
// $TEST$ error "The type parameter 'T7' can only have a single upper bound." | ||
»T7 sub T7«, | ||
// $TEST$ error "The type parameter 'T7' can only have a single upper bound." | ||
»T7 super T7«, | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T8 super Int«, | ||
// $TEST$ error "The type parameter 'T8' can only have a single lower bound." | ||
»T8 super T8«, | ||
// $TEST$ error "The type parameter 'T8' can only have a single lower bound." | ||
»T8 sub T8«, | ||
|
||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»Unresolved sub Int«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»Unresolved sub Number«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»Unresolved super Int«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»Unresolved super Number«, | ||
} { | ||
class MyNestedClass where { | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 sub Int«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 sub Number«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 super Int«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 super Number«, | ||
} | ||
|
||
enum MyNestedEnum { | ||
MyNestedEnumVariant where { | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 sub Int«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 sub Number«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 super Int«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 super Number«, | ||
} | ||
} | ||
|
||
@Pure fun myMethod() where { | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 sub Int«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 sub Number«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 super Int«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 super Number«, | ||
} | ||
} | ||
|
||
@Pure fun myGlobalFunction<T1, T2>() where { | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
@Pure fun myGlobalFunction<T1, T2, T3, T4, T5, T6, T7, T8>() where { | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 sub Int«, | ||
// $TEST$ error "A type parameter can only have a single upper bound." | ||
// $TEST$ error "The type parameter 'T1' can only have a single upper bound." | ||
»T1 sub Number«, | ||
// $TEST$ no error "A type parameter can only have a single lower bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T1 super Int«, | ||
// $TEST$ error "A type parameter can only have a single lower bound." | ||
// $TEST$ error "The type parameter 'T1' can only have a single lower bound." | ||
»T1 super Number«, | ||
|
||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T2 sub Int«, | ||
// $TEST$ error "A type parameter can only have a single upper bound." | ||
// $TEST$ error "The type parameter 'T2' can only have a single upper bound." | ||
»T2 sub Number«, | ||
// $TEST$ no error "A type parameter can only have a single lower bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T2 super Int«, | ||
// $TEST$ error "A type parameter can only have a single lower bound." | ||
// $TEST$ error "The type parameter 'T2' can only have a single lower bound." | ||
»T2 super Number«, | ||
|
||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T3 sub Int«, | ||
// $TEST$ error "The type parameter 'T3' can only have a single upper bound." | ||
»T4 super T3«, | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T5 super Int«, | ||
// $TEST$ error "The type parameter 'T5' can only have a single lower bound." | ||
»T6 sub T5«, | ||
|
||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T7 sub Int«, | ||
// $TEST$ error "The type parameter 'T7' can only have a single upper bound." | ||
»T7 sub T7«, | ||
// $TEST$ error "The type parameter 'T7' can only have a single upper bound." | ||
»T7 super T7«, | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»T8 super Int«, | ||
// $TEST$ error "The type parameter 'T8' can only have a single lower bound." | ||
»T8 super T8«, | ||
// $TEST$ error "The type parameter 'T8' can only have a single lower bound." | ||
»T8 sub T8«, | ||
|
||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»Unresolved sub Int«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»Unresolved sub Number«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»Unresolved super Int«, | ||
// $TEST$ no error "A type parameter can only have a single upper bound." | ||
// $TEST$ no error r"The type parameter .* can only have a single .* bound\." | ||
»Unresolved super Number«, | ||
} |