Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[extension types] Relax rule on representation/implements type relati…
…on (#3405) Based on the discussion in #3397, this PR introduces a relaxation in the rule about the required typing relationship between the representation type `R2` of an extension type `E2` and an implemented extension type `E1` with instantiated representation type `R1`: The existing rule requires that `R2` is a subtype of `R1`. The new rule includes the old rule, but also allows the situation where `R2` is a subtype of `E1`. Example, allowed before and now: ```dart extension type FancyWidget(Widget _) { // Something } extension type FancyListWidget(ListWidget _) implements FancyWidget { // Something } ``` Example, allowed now (but used to be an error): ```dart extension type FancyString(String it) implements String { // Something } extension type EvenFancierString(FancyString it) implements FancyString { // Something } ``` The point is that this allows us to use the same idiom for superinterfaces that are extension types and superinterfaces that are non-extension types: Both `FancyString` and `EvenFancierString` use the following template: ```dart extension type B(A it) implements A {} ```
- Loading branch information