Skip to content

Commit c6d7493

Browse files
authored
Adjusted generalized type alias feature spec to indicate ongoing discussion (#88)
1 parent 5c6b6d3 commit c6d7493

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

accepted/future-releases/generalized-typedef-2018/feature-specification.md

+30-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Author: [email protected] (@eernst).
44

5-
Version: 0.1.
5+
Version: 0.2.
66

77

88
## Motivation and Scope
@@ -114,14 +114,32 @@ evaluated as an expression, it is subject to instantiation to bound.
114114
*This treatment of generic type aliases is again the same as it was
115115
previously, but it involves a larger set of types.*
116116

117-
*Note that type aliases introduce types and not classes. Consequently, a
118-
type alias can **not** be used in a position where a class is expected: in the
119-
`extends`, `with`, `implements`, or `on` clause of a class or mixin
120-
declaration; for a static member access; or in an instance creation
121-
expression (`new F()`, `const F<int>()`). On the other hand, it **can** be
122-
used as a type annotation, as a type argument, as part of a function type
123-
or function signature, as a type literal, in an `on` clause of a `try`
124-
statement, in a type test (`e is F`), and in a type cast (`e as F`).*
117+
A type alias application of the form _F_ or the form
118+
_F&lt;T<sub>1</sub>..T<sub>k</sub>&gt;_ can be used as a type annotation,
119+
as a type argument, as part of a function type or a function signature, as
120+
a type literal, in an `on` clause of a `try` statement, in a type test
121+
(`e is F`), and in a type cast (`e as F`).
122+
123+
**The following is under discussion. Exactly one rule will be confirmed.
124+
The following two variants are considered, along with small variations or
125+
hybrids thereof:**
126+
127+
* A type alias can _not_ be used in a position where a class is
128+
expected: in the `extends`, `with`, `implements`, or `on` clause of a
129+
class or mixin declaration; for a static member access; or in an
130+
instance creation expression (`new F()`, `const F<int>()`). OR
131+
132+
* A type alias can _not_ be used for static member accesses. When a type
133+
alias _F_ resp. _F&lt;T<sub>1</sub>..T<sub>k</sub>&gt;_ occurs as the
134+
entity that a class `extends` and when it occurs in a `with` clause or
135+
`implements` clause of a class or an `on` clause of a mixin, or it is
136+
used in an instance creation expression, it is a compile-time error
137+
unless it denotes a class, otherwise it is treated as if that class had
138+
been specified explicitly.
139+
(*E.g., `class C extends myPrefix.F<int> {}` would be equivalent to
140+
`class C extends D<List<int>, int> {}` if the library imported as
141+
`myPrefix` contains `typedef F<X> = D<List<X>, X>;`, assuming that
142+
`D` is accessible to the current library and has no prefix.*)
125143

126144

127145
### Dynamic Semantics
@@ -146,4 +164,7 @@ fresh type variable bound to the denoted type.
146164

147165
## Versions
148166

167+
* Nov 8th, 2018, version 0.2: Marking the design decision of where to allow
168+
usages of type aliases denoting classes as under discussion.
169+
149170
* Nov 6th, 2018, version 0.1: Initial version of this document.

0 commit comments

Comments
 (0)