Skip to content

Commit

Permalink
Add error for non-covariant type variable in superinterface (#3412)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eernstg authored Oct 18, 2023
1 parent 80ae9fc commit 7206f91
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions accepted/future-releases/extension-types/feature-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ information about the process, including in their change logs.
[2]: https://github.com/dart-lang/language/blob/master/working/extension_structs/overview.md

2023.10.18
- Add error for non-covariant occurrence of a type variable in a
superinterface.
- Specify how to promote the representation variable of an extension
type.

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

A compile-time error occurs if a type variable declared by _DV_ occurs in a
non-covariant position in `V1`.

*This error corresponds to a similar error for class, mixin, mixin class,
and enum declarations. It might be possible to relax the rule for extension
types without jeopardizing soundness, but at this time we prefer the
simplicity and consistency of having the same rule for all kinds of
declarations. Also, it seems unlikely that a relaxation of the rule would
open the door for anything particularly useful.*

A compile-time error occurs if any direct or indirect superinterface of
_DV_ denotes the declaration _DV_. *As usual, subtype cycles are not
allowed.*
Expand Down

0 comments on commit 7206f91

Please sign in to comment.