@@ -50,12 +50,12 @@ void main() {
50
50
51
51
In the case where the on-type of an extension declaration satisfies some
52
52
constraints, we say that the class/mixin/etc. which is referred in the
53
- on-type is the _ on-class _ of the extension.
53
+ on-type is the _ on-declaration _ of the extension.
54
54
55
55
The enhancements specified for ` extension ` declarations in this document
56
- are only applicable to extensions that have an on-class , all other
56
+ are only applicable to extensions that have an on-declaration , all other
57
57
extensions will continue to work exactly as they do today. In the example
58
- above, the on-class of ` E1 ` is ` Distance ` .
58
+ above, the on-declaration of ` E1 ` is ` Distance ` .
59
59
60
60
For example:
61
61
@@ -131,38 +131,39 @@ The grammar remains unchanged.
131
131
132
132
However, it is no longer an error to declare a factory constructor
133
133
(redirecting or not) or a redirecting generative constructor in an
134
- extension declaration that has an on-class, possibly constant. * Such
135
- declarations may of course give rise to errors as usual, e.g., if a
134
+ extension declaration that has an on-declaration, possibly constant.
135
+
136
+ * Such declarations may of course give rise to errors as usual, e.g., if a
136
137
redirecting factory constructor redirects to a constructor that does not
137
138
exist, or there is a redirection cycle.*
138
139
139
140
In an extension declaration of the form ` extension E on C {...} ` where ` C `
140
141
is an identifier or an identifier with an import prefix that denotes a
141
142
class, mixin, enum, or extension type declaration, we say that the
142
- _ on-class _ of the extension is ` C ` . If ` C ` denotes a non-generic class,
143
- mixin, mixin class, or extension type then we say that the _ constructor
144
- return type_ of the extension is ` C ` .
143
+ _ on-declaration _ of the extension is ` C ` . If ` C ` denotes a non-generic
144
+ class, mixin, mixin class, or extension type then we say that the
145
+ _ constructor return type_ of the extension is ` C ` .
145
146
146
147
If ` C ` denotes a generic class then ` E ` is treated as
147
148
` extension E on C<T1 .. Tk> {...} ` where ` T1 .. Tk ` are obtained by
148
149
instantiation to bound.
149
150
150
- In an extension of the form ` extension E on C<T1 .. Tk> {...} `
151
- where ` C ` is an identifier or prefixed identifier that denotes a class,
152
- mixin, enum, or extension type declaration, we say that the _ on-class _
153
- of ` E ` is ` C ` , and the _ constructor return type_ of ` E ` is ` C<T1 .. Tk> ` .
151
+ In an extension of the form ` extension E on C<T1 .. Tk> {...} ` where ` C `
152
+ is an identifier or prefixed identifier that denotes a class, mixin, enum ,
153
+ or extension type declaration, we say that the _ on-declaration _ of ` E ` is
154
+ ` C ` , and the _ constructor return type_ of ` E ` is ` C<T1 .. Tk> ` .
154
155
155
156
In an extension of the form ` extension E on F<T1 .. Tk> {...} ` where ` F ` is
156
157
a type alias whose transitive alias expansion denotes a class, mixin, enum,
157
- or extension type ` C ` , we say that the _ on-class _ of ` E ` is ` C ` , and the
158
- _ constructor return type_ of ` E ` is the transitive alias expansion of
158
+ or extension type ` C ` , we say that the _ on-declaration _ of ` E ` is ` C ` , and
159
+ the _ constructor return type_ of ` E ` is the transitive alias expansion of
159
160
` F<T1 .. Tk> ` .
160
161
161
- In all other cases, an extension declaration does not have an on-class nor a
162
- constructor return type.
162
+ In all other cases, an extension declaration does not have an
163
+ on-declaration nor a constructor return type.
163
164
164
- For the purpose of identifying the on-class and constructor return type of
165
- a given extension, the types ` void ` , ` dynamic ` , and ` Never ` are not
165
+ For the purpose of identifying the on-declaration and constructor return
166
+ type of a given extension, the types ` void ` , ` dynamic ` , and ` Never ` are not
166
167
considered to be classes, and neither are record types or function types.
167
168
168
169
* Also note that none of the following types are classes:*
@@ -192,13 +193,13 @@ recommended message:
192
193
193
194
A compile-time diagnostic is emitted if an extension _ D_ declares a
194
195
constructor or a static member with the same basename as a constructor or a
195
- static member in the on-class of _ D_ . A similar diagnostic is emitted when
196
- _ D_ is an enum, mixin, mixin class, or extension type declaration.
196
+ static member in the on-declaration of _ D_ . A similar diagnostic is emitted
197
+ when _ D_ is an enum, mixin, mixin class, or extension type declaration.
197
198
198
199
* In other words, an extension should not have name clashes with its
199
- on-class . The warning above is aimed at static members and constructors,
200
- but a similar warning would probably be useful for instance members as
201
- well.*
200
+ on-declaration . The warning above is aimed at static members and
201
+ constructors, but a similar warning would probably be useful for instance
202
+ members as well.*
202
203
203
204
#### Invocation of a static member
204
205
@@ -242,7 +243,7 @@ pre-feature Dart.*
242
243
In the case where ` C ` does not declare any static members whose basename is
243
244
the basename of ` m ` , and ` C ` does not declare any constructors named ` C.m2 `
244
245
where ` m2 ` is the basename of ` m ` , let _ M_ be the set containing each
245
- accessible extension whose on-class is ` C ` , and whose static members
246
+ accessible extension whose on-declaration is ` C ` , and whose static members
246
247
include one with the name ` m ` , or which declares a constructor named ` C.m ` .
247
248
248
249
* If ` C ` does declare a constructor with such a name ` C.m2 ` then the given
@@ -322,8 +323,8 @@ member invocations, but they need more detailed rules because they can use
322
323
the formal type parameters declared by an extension.
323
324
324
325
An _ explicitly resolved invocation_ of a constructor named ` C.name ` in a
325
- extension declaration _ D_ named ` E ` with ` s ` type parameters and on-class
326
- ` C ` can be expressed as ` E<S1 .. Ss>.C.name(args) ` ,
326
+ extension declaration _ D_ named ` E ` with ` s ` type parameters and
327
+ on-declaration ` C ` can be expressed as ` E<S1 .. Ss>.C.name(args) ` ,
327
328
` E.C<U1 .. Uk>.name(args) ` , or ` E<S1 .. Ss>.C<U1 .. Uk>.name(args) ` (and
328
329
similarly for a constructor named ` C ` using ` E<S1 .. Ss>.C(args) ` , etc).
329
330
@@ -355,7 +356,7 @@ them to explicitly resolved ones.*
355
356
356
357
A constructor invocation of the form ` C<T1 .. Tm>.name(args) ` is partially
357
358
resolved by looking up a constructor named ` C.name ` in the class ` C ` and in
358
- every accessible extension with on-class ` C ` . A compile-time error
359
+ every accessible extension with on-declaration ` C ` . A compile-time error
359
360
occurs if no such constructor is found. Similarly, an invocation of the
360
361
form ` C<T1 ... Tm>(args) ` uses a lookup for constructors named ` C ` .
361
362
@@ -367,14 +368,14 @@ Otherwise, the invocation is partially resolved to a set _M_ of candidate
367
368
constructors and static members found in extensions. Each of the candidates
368
369
_ kj_ is vetted as follows:
369
370
370
- If ` m ` is zero and ` E ` is an accessible extension with on-class ` C `
371
+ If ` m ` is zero and ` E ` is an accessible extension with on-declaration ` C `
371
372
that declares a static member whose basename is ` name ` then the invocation
372
373
is a static member invocation * (which is specified in an earlier section)* .
373
374
374
375
Otherwise, assume that _ kj_ is a constructor declared by an extension _ D_
375
- named ` E ` with type parameters ` X1 extends B1 .. Xs extends Bs ` , on-class
376
- ` C ` , and on-type ` C<S1 .. Sm> ` . Find actual values ` U1 .. Us ` for
377
- ` X1 .. Xs ` satisfying the bounds ` B1 .. Bs ` , such that
376
+ named ` E ` with type parameters ` X1 extends B1 .. Xs extends Bs ` ,
377
+ on-declaration ` C ` , and on-type ` C<S1 .. Sm> ` . Find actual values
378
+ ` U1 .. Us ` for ` X1 .. Xs ` satisfying the bounds ` B1 .. Bs ` , such that
378
379
` ([U1/X1 .. Us/Xs]C<S1 .. Sm>) == C<T1 .. Tm> ` . This may determine the
379
380
value of some of the actual type arguments ` U1 .. Us ` , and others may be
380
381
unconstrained (because they do not occur in ` C<T1 .. Tm> ` ). Actual type
@@ -406,7 +407,8 @@ unconstrained actual type arguments are given as `_` and inferred later).
406
407
The expression is then treated as described above.
407
408
408
409
Next, we construct a set _ M_ containing all accessible extensions with
409
- on-class ` C ` that declare a constructor named ` C.name ` (respectively ` C ` ).
410
+ on-declaration ` C ` that declare a constructor named ` C.name ` (respectively
411
+ ` C ` ).
410
412
411
413
In the case where _ M_ contains exactly one extension ` E ` that declares a
412
414
constructor named ` C.name ` (or ` C ` ), the invocation is treated as
0 commit comments