-
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 parameters of functions are variant (#869)
### Summary of Changes Variant type parameters may only occur on classes. This PR adds validation for this.
- Loading branch information
1 parent
091b2c8
commit 9bf5fec
Showing
7 changed files
with
55 additions
and
4 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
6 changes: 5 additions & 1 deletion
6
...ions/type parameters/usage of variant type parameter/contravariant type parameter.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
6 changes: 5 additions & 1 deletion
6
...arations/type parameters/usage of variant type parameter/covariant type parameter.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
6 changes: 5 additions & 1 deletion
6
...arations/type parameters/usage of variant type parameter/invariant type parameter.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
7 changes: 7 additions & 0 deletions
7
.../validation/other/declarations/type parameters/variance only on classes/invariant.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,7 @@ | ||
package tests.validation.other.declarations.typeParameters.varianceOnlyOnClasses | ||
|
||
// $TEST$ no error "Only type parameters of classes can be variant." | ||
|
||
class C1<T> | ||
|
||
fun f1<T>() |
11 changes: 11 additions & 0 deletions
11
...es/validation/other/declarations/type parameters/variance only on classes/variant.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,11 @@ | ||
package tests.validation.other.declarations.typeParameters.varianceOnlyOnClasses | ||
|
||
// $TEST$ no error "Only type parameters of classes can be variant." | ||
class C2<»in« T> | ||
// $TEST$ no error "Only type parameters of classes can be variant." | ||
class C3<»out« T> | ||
|
||
// $TEST$ error "Only type parameters of classes can be variant." | ||
fun f2<»in« T>() | ||
// $TEST$ error "Only type parameters of classes can be variant." | ||
fun f3<»out« T>() |