@@ -41,6 +41,10 @@ As mentioned, alternative proposals should have their own issue and writeup.
4141All proposals should be linked from and link to the 'request' for
4242the user problem/feature request they are trying to address.
4343
44+ For smaller and non-controversial features, we will sometimes skip this step and
45+ proceed directly to the [ Acceptance and
46+ implementation] ( #acceptance-and-implementation ) phase.
47+
4448### External (outside of the language team) feedback
4549
4650We expect to use the github issue tracker as the primary place for accepting
@@ -55,57 +59,176 @@ significant changes.
5559
5660If consensus is reached on a specific proposal and we decide to accept it, a
5761member of the language team will be chosen to shepherd the implementation.
58- The implementation will be tracked via three artifacts:
59-
60- - An implementation plan document
61-
62- - A 'implementation' issue.
62+ The implementation will be tracked via two artifacts:
6363
6464 - A feature specification document
6565
66- The implementation plan must be located in a sub-directory with the name of the
67- feature (` /[feature-name]/ ` ) located inside the ` accepted/future-releases/ `
68- folder. The filename should be ` implementation-plan.md ` . The implementation
69- plan should generally include at least:
70-
71- - Affected implementation teams.
72-
73- - Schedule and release milestones.
74-
75- - Release flag if required, plan for shipping.
66+ - A 'implementation' issue.
7667
7768The 'feature specification' is ** a single canonical writeup of the language
7869feature** which is to serve as the implementation reference. Feature
7970specifications use Markdown format. The file name should be
80- ` feature-specification.md ` , and the feature specification should
81- be located in the same sub-directory as the implementation plan.
82-
83- A meta-issue (labelled ` implementation ` ) will be filed in the language
84- repository for tracking the implementation process. This top of this issue must
85- contain links to:
86-
87- - The related ` request ` issue
71+ ` feature-specification.md ` , and the feature specification should be located
72+ inside the ` accepted/future-releases/ ` folder.
8873
89- - The related ` feature ` issue
74+ The implementation issue (labelled ` implementation ` ) will be filed in the
75+ language repository for tracking the implementation process. This top of this
76+ issue must contain links to:
9077
91- - A link to the implementation plan
78+ - The related ` request ` and ` feature ` issues (if they exist)
9279
9380 - A link to the feature specification
9481
82+ ### Kick-off meetings
83+
9584The next step of the implementation issue is to get sign-off from all of the
9685relevant implementation teams indicating that they understand the proposal,
9786believe that it can reasonably be implemented, and feel that they have
98- sufficient details to proceed. There may be further iteration on the proposal
87+ sufficient details to proceed.
88+
89+ Consider getting sign-off from the following teams:
90+
91+ - The analyzer team.
92+
93+ - The CFE team.
94+
95+ - Back-end teams:
96+
97+ - Dart native runtime
98+
99+ - Dart for web
100+
101+ - Wasm
102+
103+ Note that if a feature consists entirely of a new piece of syntactic sugar, it
104+ can be tempting to assume that it's not necessary to consult with any back-end
105+ teams (since the CFE will lower the new syntax into a kernel form that is
106+ already supported). But this can be a dangerous assumption. It's easy to forget
107+ that even in features that appear to consist purely of syntactic sugar, some
108+ back-end support may be needed in order to properly support single-step
109+ debugging or hot reload. Also, some work may need to be done on back-end code
110+ generators in order to make sure that the new feature is lowered into a form
111+ that can be well optimized. To avoid missing things, we prefer to err on the
112+ side of asking teams whether they're affected, rather than assuming they won't
113+ be.
114+
115+ Since feature specification documents are usually long and very detailed, we
116+ like to begin this sign-off process with a set of kick-off meetings, typically
117+ one for each affected implementation team. These meetings are on opportunity for
118+ a language team representative to present a broad outline of the new feature,
119+ give some concrete examples, and collect insights from the implementation teams
120+ about what aspects of the implementation might need special attention.
121+
122+ There may be further iteration on the proposal
99123in this phase. This sign-off must be recorded in the implementation issue.
100124Changes will be done in place on the writeup.
101125
102- ## Testing
126+ ### Implementation issues
127+
128+ A typical outcome of the kick-off meetings will be a set of implementaiton
129+ issues in the SDK repo, to track specific pieces of work that need to be
130+ done.
131+
132+ Additionally, Kevin Chisholm has a script for generating the core set of
133+ implementation issues for a feature:
134+ https://github.com/itsjustkevin/flutter_release_scripts/blob/main/languageFeatures.js . We
135+ like to use this script for larger features. It creates a large number of
136+ issues, though, so we will sometimes skip it for smaller features that only
137+ require a small amount of work.
138+
139+ Some teams have checklists that they consult when creating implementation
140+ issues, to make sure important areas of work aren't forgotten. For example:
141+
142+ - [ Implementing a new language feature
143+ (analyzer)] ( https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/doc/process/new_language_feature.md )
144+
145+ - [ Implementing a new language feature (analysis
146+ server)] ( https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/doc/process/new_language_feature.md )
147+
148+ ### Feature flag
149+
150+ Most new language features should be implemented using a feature flag. The
151+ feature flag serves several purposes:
152+
153+ - It allows the feature to be implemented over a series of CLs without
154+ destabilizing the SDK. If it comes time to ship a new release of the SDK
155+ before the feature is ready, the feature flag can remain off, so users won't
156+ be exposed to a partially-implemented or buggy feature before it's ready.
157+
158+ - It allows users to opt in to trying out features that have not yet been
159+ released, by turning on the feature flag locally.
160+
161+ - Once the feature is enabled, the feature flag logic ensures that it will only
162+ affect users who have set their language version to a version that includes
163+ the new feature. This is especially important for package developers who may
164+ want to support a range of versions of the Dart SDK.
165+
166+ Note that implementing a language feature using a feature flag is frequently
167+ more work that implementing it without a feature flag, since the compiler and
168+ analyzer must faithfully implement both the old and new behaviors. Occasionally
169+ the language team may decide that the benefits of using a feature flag don't
170+ justify this extra work. But this is a rare senario. If you are working on a
171+ feature and believe you don't need to use a feature flag, please consult with
172+ the language team to be sure.
173+
174+ Creating the feature flag should be one of the first implementation
175+ tasks. Here's how to do it:
176+
177+ - Add an entry to ` tools/experimental_features.yaml ` describing the feature, in
178+ the top section (above the line that says `Flags below this line are
179+ shipped`).
180+
181+ - Run ` dart pkg/front_end/tool/fasta.dart generate-experimental-flags ` to update
182+ ` pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart ` and
183+ ` pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart ` .
184+
185+ - Run ` dart pkg/analyzer/tool/experiments/generate.dart ` to update
186+ ` pkg/analyzer/lib/src/dart/analysis/experiments.g.dart ` .
187+
188+ - Add a static final declaration to the ` Feature ` class in
189+ ` pkg/analyzer/lib/dart/analysis/features.dart ` .
190+
191+ - Increment the value of ` AnalysisDriver.DATA_VERSION ` in
192+ ` pkg/analyzer/lib/src/dart/analysis/driver.dart ` .
193+
194+ - Example CL: https://dart-review.googlesource.com/c/sdk/+/365545
195+
196+ ### Language testing
103197
104198The language team will generally write a preliminary set of language tests for a
105- feature. These tests are not intended to be exhaustive, but should illustrate
106- and exercise important and non-obvious features. Implementation teams are
107- encouraged to write additional language or unit tests. The language team may
108- also coordinate the writing of additional tests.
199+ feature, in the SDK's ` tests/language ` subdirectory. These tests are not
200+ intended to be exhaustive, but should illustrate and exercise important and
201+ non-obvious features. Implementation teams are encouraged to write additional
202+ language or unit tests. The language team may also coordinate the writing of
203+ additional tests.
204+
205+ An important use case for any new language feature is to ensure that the feature
206+ isn't accidentally used by package authors that have not yet opted into a
207+ language version that supports it. So in addition to testing that the new
208+ language feature works when the feature flag is turned on, the tests added to
209+ ` tests/language ` should verify that when the feature flag is turned off, the
210+ previous behavior of the SDK is preserved.
211+
212+ One important exception to preserving previous SDK behavior is that it's
213+ permissible (and even encouraged) to improve error messages so that if the user
214+ tries to use a disabled language feature, they receive an error explaining that
215+ they need to enable it, rather than, say, a confusing set of parse errors.
216+
217+ To enable the feature in a language test, include the line `//
218+ SharedOptions=--enable-experiment=$FEATURE` near the top of the test (before the
219+ first directive), where ` $FEATURE ` is replaced with the feature name. To disable
220+ the feature in a language test, include the line ` // @dart=$VERSION ` near the
221+ top of the test (before the first directive), where ` $VERSION ` is the current
222+ stable release of Dart (and therefore is the largest version that is guaranteed
223+ _ not_ to contain the feature).
224+
225+ ### Google3 testing
226+
227+ New features should be tested in Google's internal code base before they are
228+ switched on.
229+
230+ Details of how to do this will be described in a separate (Google internal)
231+ document.
109232
110233## Shipping
111234
@@ -145,11 +268,9 @@ shipped (e.g. `2.1`).
145268 2.0/
146269 2.1/
147270 super-mixins/
148- implementation-plan.md
149271 feature-specification.md
150272 future-releases/
151273 spread-operator/
152- implementation-plan.md
153274 feature-specification.md
154275 /resources/
155276 [various supporting documents and resources]
0 commit comments