Skip to content

Commit 3ecf3a7

Browse files
authored
Make it an error for the representation type of an extension type to be a bottom type (#3393)
Make it an error for the representation type of an extension type declaration to be a bottom type. Note that it is still possible for the _instantiated_ representation type of an extension type to be a bottom type: ```dart extension type E<X>(X x) {} late E<Never> v; // Instantiated representation type is `Never`. ```
1 parent ed8f940 commit 3ecf3a7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,20 @@ the treatment of expressions like `e as V`.*
767767
A compile-time error occurs if a type parameter of an extension type
768768
declaration occurs in a non-covariant position in the representation type.
769769

770+
A compile-time error occurs if the representation type of an extension type
771+
declaration is a bottom type.
772+
773+
*Note that it is still possible for the instantiated representation type
774+
of a given extension type to be a bottom type. For example, assuming
775+
`extension type E<X>(X x) {}`, `E<Never>` would be an extension type whose
776+
instantiated representation type is `Never`. The reason for this error is that
777+
we could otherwise have, for example, an extension type that `implements int,
778+
double`, and the ability to have such subtypes of arbitrary sets of interface
779+
types would make other parts of the type system more complex. Such types could
780+
never be the type of an actual object anyway because the representation object
781+
would have to have type `Never`. If these types turn out to be useful in some
782+
way then they could still be added to a future version of the language.*
783+
770784
When `s` is zero *(that is, the declaration of `V` is not generic)*,
771785
<code>V\<T<sub>1</sub>, .. T<sub>s</sub>&gt;</code>
772786
simply stands for `V`, a non-generic extension type.
@@ -1005,7 +1019,7 @@ has any compile-time errors.
10051019
which is an error.*
10061020

10071021

1008-
#### Extension Type Constructors and Their Static Analysis
1022+
### Extension Type Constructors and Their Static Analysis
10091023

10101024
An extension type declaration _DV_ named `Name` may declare one or
10111025
more constructors. A constructor which is declared in an extension type

0 commit comments

Comments
 (0)