Skip to content

Commit 7206f91

Browse files
authored
Add error for non-covariant type variable in superinterface (#3412)
Add compile-time error for non-covariant type variable in superinterface, just like the rule we have for classes, mixins, etc. It may be sound to allow this, but for now we prefer the simplicity and consistency of having the same rule everywhere. Also, the ability to violate this constraint does not seem to allow for anything useful.
1 parent 80ae9fc commit 7206f91

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

accepted/future-releases/extension-types/feature-specification.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ information about the process, including in their change logs.
1616
[2]: https://github.com/dart-lang/language/blob/master/working/extension_structs/overview.md
1717

1818
2023.10.18
19+
- Add error for non-covariant occurrence of a type variable in a
20+
superinterface.
1921
- Specify how to promote the representation variable of an extension
2022
type.
2123

@@ -1142,6 +1144,16 @@ representation type of _DV_.
11421144
non-extension type, it must be sound to consider the representation object
11431145
as having type `T`.*
11441146

1147+
A compile-time error occurs if a type variable declared by _DV_ occurs in a
1148+
non-covariant position in `V1`.
1149+
1150+
*This error corresponds to a similar error for class, mixin, mixin class,
1151+
and enum declarations. It might be possible to relax the rule for extension
1152+
types without jeopardizing soundness, but at this time we prefer the
1153+
simplicity and consistency of having the same rule for all kinds of
1154+
declarations. Also, it seems unlikely that a relaxation of the rule would
1155+
open the door for anything particularly useful.*
1156+
11451157
A compile-time error occurs if any direct or indirect superinterface of
11461158
_DV_ denotes the declaration _DV_. *As usual, subtype cycles are not
11471159
allowed.*

0 commit comments

Comments
 (0)