-
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 has multiple lower/upper bounds (#870)
Closes #867 ### Summary of Changes Just like we don't have multiple inheritance or intersection types, we only want to deal with a single lower and a single upper bound for type parameters. We currently don't have a use-case for multiple bounds, so we may as well simplify the implementation of the DSL. This PR adds a check to ensure that type parameters have a single lower and a single upper bound.
- Loading branch information
1 parent
9bf5fec
commit 6035b76
Showing
15 changed files
with
193 additions
and
39 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
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
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
...er constraints/in annotation/main.sdstest → ...rameter bounds/in annotation/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
2 changes: 1 addition & 1 deletion
2
... enum variant in nested enum/main.sdstest → ... enum variant in nested enum/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
2 changes: 1 addition & 1 deletion
2
... constraints/in global class/main.sdstest → ...meter bounds/in global class/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
2 changes: 1 addition & 1 deletion
2
...nstraints/in global function/main.sdstest → ...er bounds/in global function/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
2 changes: 1 addition & 1 deletion
2
...ameter constraints/in method/main.sdstest → ...e parameter bounds/in method/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
2 changes: 1 addition & 1 deletion
2
... constraints/in nested class/main.sdstest → ...meter bounds/in nested class/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
30 changes: 15 additions & 15 deletions
30
...d must be own type parameter/main.sdstest → ...d 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
package tests.validation.other.declarations.constraints.typeParameterConstraints.typeParameterOnContainer | ||
package tests.validation.other.declarations.constraints.typeParameterBounds.typeParameterOnContainer | ||
|
||
annotation MyAnnotation where { | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»Unresolved« sub MyGlobalClass, | ||
} | ||
|
||
class MyGlobalClass<T1> where { | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»T1« sub MyGlobalClass, | ||
|
||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»Unresolved« sub MyGlobalClass | ||
} { | ||
class MyNestedClass<T2> where { | ||
// $TEST$ error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»T1« sub MyGlobalClass, | ||
|
||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»T2« sub MyGlobalClass, | ||
|
||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»Unresolved« sub MyGlobalClass, | ||
} | ||
|
||
enum MyNestedEnum { | ||
MyEnumVariant where { | ||
// $TEST$ error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»T1« sub MyGlobalClass, | ||
|
||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»Unresolved« sub MyGlobalClass, | ||
} | ||
} | ||
|
||
fun myMethod<T2>() where { | ||
// $TEST$ error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»T1« sub MyGlobalClass, | ||
|
||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»T2« sub MyGlobalClass, | ||
|
||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»Unresolved« sub MyGlobalClass, | ||
} | ||
} | ||
|
||
enum MyGlobalEnum { | ||
MyEnumVariant where { | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»Unresolved« sub MyGlobalClass, | ||
} | ||
} | ||
|
||
fun myGlobalFunction<T1>() where { | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»T1« sub MyGlobalClass, | ||
|
||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the constraint." | ||
// $TEST$ no error "The left operand must refer to a type parameter of the declaration with the bound." | ||
»Unresolved« sub MyGlobalClass, | ||
} |
Oops, something went wrong.