|
| 1 | +# Implementation Plan for "Small Features 21Q1" |
| 2 | + |
| 3 | +Owner: [email protected] ( [@lrhn](https://github.com/lrhn/) on GitHub) |
| 4 | + |
| 5 | +Relevant links: |
| 6 | + |
| 7 | +* [Tracking issue](https://github.com/dart-lang/language/issues/) |
| 8 | +* [Proposal](https://github.com/dart-lang/language/blob/master/working/small-features-21q1/feature-specification.md) |
| 9 | + |
| 10 | +## Phase 0 (Prerequisite) |
| 11 | + |
| 12 | +### "generic-metadata" Experimental flag |
| 13 | + |
| 14 | +The implementation of parts of this feature ("generic metadata" and "generic function type arguments") should be developed behind an [experiment |
| 15 | +flag][]. Tools must be passed the flag |
| 16 | +`--enable-experiment=generic-metadata` to enable those features. |
| 17 | + |
| 18 | +[experiment flag]: https://github.com/dart-lang/sdk/blob/master/docs/process/experimental-flags.md |
| 19 | + |
| 20 | +While this feature is under development, individual tools may have incomplete or |
| 21 | +changing implementations behind the flag. When all tools have completely |
| 22 | +implemented the feature, the the feature will be enabled by default, and the |
| 23 | +flag removed in a stable release. |
| 24 | + |
| 25 | +### "triple-shift" Experimental flag |
| 26 | + |
| 27 | +The existing "triple-shift" experiment flag is already used for the partly implemented `>>>` operator. The flag is retained until we release the feature. |
| 28 | + |
| 29 | +### Tests |
| 30 | + |
| 31 | +The language team adds tests for the feature. |
| 32 | + |
| 33 | +## Phase 1 (Foundation) |
| 34 | + |
| 35 | +### CFE |
| 36 | + |
| 37 | +The CFE implements parsing the new syntax, type checking it, and compiling it to |
| 38 | +Kernel. Since the CFE performs constant evaluation, it also |
| 39 | +implements the evaluation of metadata annotations. |
| 40 | + |
| 41 | +The generic metadata feature can likely be implemented entirely in the front end and analyzer, with no back-end |
| 42 | +support needed. Since the front-end already evaluates the constants, and might infer type arguments, back-ends are likely used to seeing the filled-in result anyway. The analyzer deals with *source*, and must be able to make the distinction between an omitted-and-inferred type argument and an explicit type argument on a metadata constructor invocation. |
| 43 | + |
| 44 | +The generic function type argument feature can likely be *implemented* entirely in the front-end, by not disallowing generic function types as type arguments, but back-ends might need to find places where they assume that a type argument cannot be a generic function type. |
| 45 | + |
| 46 | +The `>>>` feature is already implemented in the CFE. |
| 47 | + |
| 48 | +### Analyzer |
| 49 | + |
| 50 | +For generic metadata, the analyzer needs to represent the *source*, and therefore must be able to make the distinction between an omitted-and-inferred type argument and an explicit type argument on a metadata constructor invocation. This is important for other source-manipulating tools like the formatter. The AST for metadata invocations need to have a place to store the type arguments, which isn't there now. |
| 51 | + |
| 52 | +If the analyzer assumes, and relies on the assumption, that type arguments cannot be generic function types, then it might need to fix that. |
| 53 | + |
| 54 | +The analyzer also needs to support `const Symbol(">>>")`, but otherwise seems to support the `>>>` feature (`operator>>>` and `#>>>` works). |
| 55 | + |
| 56 | +Otherwise the analyzer is unlikely to need significant change for any of the features. |
| 57 | + |
| 58 | +## Phase 2 (Tool Implementation) |
| 59 | + |
| 60 | +### dart2js |
| 61 | + |
| 62 | +If the feature is handled by the front end, there may be no dart2js work. |
| 63 | +Otherwise, dart2js may need to handle any Kernel changes |
| 64 | + |
| 65 | +Dart2js supports `>>>` except for `new Symbol(">>>")`. This can be fixed by a single RegExp update. |
| 66 | + |
| 67 | +### Dartfmt |
| 68 | + |
| 69 | +The only new syntax is metadata type arguments. They need to be supported, but should likely be treated like any other constructor invocation. Define and implement formatting rules for the new syntax. Add formatting tests. |
| 70 | + |
| 71 | +### DDC |
| 72 | + |
| 73 | +If these features can be implemented entirely in the front end with no Kernel |
| 74 | +changes, then no DDC changes may be needed. |
| 75 | +Otherwise, DDC may need to handle any Kernel changes or otherwise add support |
| 76 | +for this. |
| 77 | + |
| 78 | +### IntelliJ |
| 79 | + |
| 80 | +Update the IntelliJ parser to support the new syntax forms. |
| 81 | + |
| 82 | +### Grok |
| 83 | + |
| 84 | +Update Grok to handle the new AST. |
| 85 | + |
| 86 | +### Analysis server |
| 87 | + |
| 88 | +Update to use the latest analyzer with support for the feature. |
| 89 | + |
| 90 | +The analyzer should likely recognize the grammar even without the experiment flag, and report errors stating that the feature is not available yet, rather than trying to parse `>>>` as `>>` followed by `>`, which is never valid as an operator. |
| 91 | + |
| 92 | +There are no new quick-fixes needed. |
| 93 | + |
| 94 | +### Atom plug-in |
| 95 | + |
| 96 | +The [Dart Atom plug-in][atom] has a grammar for syntax highlighting Dart code in |
| 97 | +Atom. This same grammar is also used for syntax highlighting on GitHub. Update |
| 98 | +this to handle the new syntax. |
| 99 | + |
| 100 | +[atom]: https://github.com/dart-atom/dart |
| 101 | + |
| 102 | +### VS Code |
| 103 | + |
| 104 | +Update the syntax highlighting grammar to support the control flow syntax (and, |
| 105 | +likely apply a very similar diff to the Atom grammar above). |
| 106 | + |
| 107 | +### VM |
| 108 | + |
| 109 | +If the feature is handled by the front end, there may be no VM work. The VM already fully supports `>>>`, but it is possible that generic functions as type arguments may trigger some unused code paths. |
| 110 | + |
| 111 | +### Co19 tests |
| 112 | + |
| 113 | +The co19 team can start implementing tests early using the experimental flags. |
| 114 | +Those tests should not be run by default until the feature has been released. |
| 115 | + |
| 116 | +### Usability validation |
| 117 | + |
| 118 | +No usability testing is planned. There is nothing *new* in these features (deliberately), just allowing existing syntax in new places, or one more operators which also exist in other languages. |
| 119 | + |
| 120 | +## Phase 3 (Release) |
| 121 | + |
| 122 | +### Enabling |
| 123 | + |
| 124 | +The language team updates the experimental flags `generic-metadata` and `triple-shift` to |
| 125 | +always be enabled and no longer be available to users, and releases this update |
| 126 | +in the next stable Dart release. |
| 127 | + |
| 128 | +### Use |
| 129 | + |
| 130 | +The Dart library team introduces `int.operator>>>` as soon as possible. |
| 131 | + |
| 132 | +### Documentation |
| 133 | + |
| 134 | +The language team adds the feature to the CHANGELOG. They write some sort of |
| 135 | +announcement email or blog post. |
| 136 | + |
| 137 | +The language tour needs to be updated to mention `>>>` as a user definable |
| 138 | +operator. |
| 139 | + |
| 140 | +## Phase 4 (Clean-up) |
| 141 | + |
| 142 | +### Remove flag |
| 143 | + |
| 144 | +All tools may now remove the dependencies on the flag in the experiments flag |
| 145 | +definition file. When all SDK tools have done so, the flag is removed from the |
| 146 | +experiments flag definition file. |
| 147 | + |
| 148 | +## Timeline |
| 149 | + |
| 150 | +Completion goals for the phases: |
| 151 | + |
| 152 | +* Phase 0 (Prerequisite): Mostly done, tests by end of January. |
| 153 | +* Phase 1 (Foundation): Early February 2021. |
| 154 | +* Phase 2 (Tool Implementation): Mid March, 2021 |
| 155 | +* Phase 3 (Release): TODO |
| 156 | +* Phase 4 (Clean-up): TODO |
0 commit comments