|
| 1 | +# Implementation Plan for the Q1 2019 Generalized Type Alias Feature |
| 2 | + |
| 3 | +Relevant documents: |
| 4 | + - [Tracking issue](https://github.com/dart-lang/language/issues/115) |
| 5 | + - [Feature specification](https://github.com/dart-lang/language/blob/master/accepted/future-releases/generalized-typedef-2018/feature-specification.md) |
| 6 | + |
| 7 | +## Implementation and Release plan |
| 8 | + |
| 9 | +This feature is non-breaking, because it is concerned with the introduction of |
| 10 | +support for new syntactic forms. |
| 11 | +Still, we will introduce it using an |
| 12 | +[experiments flag](https://github.com/dart-lang/sdk/blob/master/docs/process/experimental-flags.md) |
| 13 | +in order to enable a controlled deployment. |
| 14 | + |
| 15 | + |
| 16 | +### Phase 0 (Preliminaries) |
| 17 | + |
| 18 | +#### Release Flag |
| 19 | + |
| 20 | +The flag |
| 21 | +`--enable-experiment=nonfunction-type-aliases` |
| 22 | +must be passed for the changes to be enabled. |
| 23 | +In this phase, support for that flag is added to all tools. |
| 24 | + |
| 25 | +#### Tests |
| 26 | + |
| 27 | +The language team adds a set of tests for the new feature, in terms of |
| 28 | +declarations and usages in the following situations: |
| 29 | + |
| 30 | +- A type alias with and without type arguments is used |
| 31 | + - as a type annotation for a variable of various kinds. |
| 32 | + - as a type argument of a class or another type alias. |
| 33 | + - as part of a function type. |
| 34 | + - in a function declaration as return type or parameter type. |
| 35 | + - as an expression. |
| 36 | + - as the type in an `on` clause. |
| 37 | + - in a type test (`is`). |
| 38 | + - in a type cast (`as`). |
| 39 | +- A type alias whose body is a class with or without type arguments, is used in |
| 40 | + - the `extends` clause of a class. |
| 41 | + - the `with` clause of a class. |
| 42 | + - the `implements` clause of a class or mixin. |
| 43 | + - the `on` clause of a mixin. |
| 44 | + - instance creation expressions, constant and non-constant. |
| 45 | + - an invocation of a static method, getter, setter, and a tear-off of a |
| 46 | + static method; note that the provision of type arguments |
| 47 | + (`F<int>.m()`) is an error here. |
| 48 | + |
| 49 | +The co19 team start creating tests early, such that those tests can be |
| 50 | +used during implementation as well. |
| 51 | + |
| 52 | +### Phase 1 (Implementation) |
| 53 | + |
| 54 | +All tools implement syntactic support for type aliases of the form |
| 55 | + |
| 56 | +```dart |
| 57 | +typedef F<TypeArguments> = type; |
| 58 | +``` |
| 59 | + |
| 60 | +where `type` can be any type, rather than just a function type. |
| 61 | + |
| 62 | +All tools implement support for using such type aliases, in all situations |
| 63 | +mentioned under phase 0. |
| 64 | + |
| 65 | +### Phase 2 (Release) |
| 66 | + |
| 67 | +The feature is released as part of the next stable Dart release. |
| 68 | + |
| 69 | +## Timeline |
| 70 | + |
| 71 | +Completion goals for the phases: |
| 72 | + |
| 73 | +- Phase 0: (TODO) |
| 74 | +- Phase 1: (TODO) |
| 75 | +- Phase 2: (TODO) |
0 commit comments