@@ -16,7 +16,7 @@ expressive than constructors in current Dart.
16
16
17
17
This document specifies generic constructors. This is a feature that
18
18
supports the declaration of constructors whose treatment of type parameters
19
- is more flexible and expressive than constructors in current Dart.
19
+ is more flexible and expressive than constructors in current Dart.
20
20
21
21
In particular, it allows the constructor to have type parameters that are
22
22
not used in the return type (that is, the type of the newly created
@@ -165,16 +165,16 @@ class Map<K, V> {
165
165
}
166
166
```
167
167
168
- However, that is a compile-time error because it returns a
168
+ However, that is a compile-time error because it returns a
169
169
` Map<Object?, List<Object?>> ` where the return type is ` Map<K, V> ` .
170
170
But we don't know ` K ` or ` V ` , and we can't assume that ` V ` is of the form
171
171
` List<K> ` or a supertype thereof. We might try to cast the map literal to
172
- ` Map<K, V> ` , and that might work, but an invocation like
172
+ ` Map<K, V> ` , and that might work, but an invocation like
173
173
` Map<int, String>.keyToList(xs) ` will then throw at run time because the
174
174
map literal isn't going to have the required type no matter which iterable
175
175
we are passing as ` keys ` .
176
176
177
- With the generic constructor and with an invocation like
177
+ With the generic constructor and with an invocation like
178
178
` Map<int, String>.keyToList(xs) ` , the actual type arguments will be used as
179
179
a context type for the constructor invocation. The generic constructor
180
180
` Map.keyToList ` fails to infer actual type arguments such that the
@@ -226,19 +226,19 @@ The grammar is adjusted as follows:
226
226
227
227
``` ebnf
228
228
<constructorSignature> ::= <constructorName> <formalParameterList>
229
- | <typeIdentifier> <typeArguments>? '.' <identifierOrNew>
229
+ | <typeIdentifier> <typeArguments>? '.' <identifierOrNew>
230
230
<typeParameters> <formalParameterList>
231
- | <typeIdentifier> <typeArguments> '.' <identifierOrNew>
231
+ | <typeIdentifier> <typeArguments> '.' <identifierOrNew>
232
232
<formalParameterList>
233
233
234
- <factoryConstructorSignature> ::=
234
+ <factoryConstructorSignature> ::=
235
235
'const'? 'factory' <constructorSignature>
236
236
237
237
<redirectingFactoryConstructorSignature> ::=
238
- 'const'? 'factory' <constructorSignature> '='
238
+ 'const'? 'factory' <constructorSignature> '='
239
239
<constructorDesignation>
240
240
241
- <constantConstructorSignature> ::=
241
+ <constantConstructorSignature> ::=
242
242
'const' <constructorSignature>
243
243
```
244
244
@@ -253,7 +253,7 @@ declaration.
253
253
254
254
### Static Analysis
255
255
256
- A generic constructor declaration occurs as a member of a type introducing
256
+ A generic constructor declaration occurs as a member of a type introducing
257
257
declaration or an extension declaration. Its current scope is the body
258
258
scope of the enclosing declaration. It introduces a type parameter scope
259
259
whose enclosing scope is the current scope of the generic constructor
@@ -317,11 +317,11 @@ non-generic class).
317
317
In this case, the super-initializer of the constructor (explicit or
318
318
implicit, and excepting ` Object ` that does not have a super-initializer)
319
319
will invoke the superconstructor with actual type arguments that correspond
320
- to the type ` C<T1 .. Tk> ` of the current constructor invocation.
320
+ to the type ` C<T1 .. Tk> ` of the current constructor invocation.
321
321
322
322
That is, if ` C ` is declared with ` k ` type parameters ` X1 .. Xk ` and
323
323
superclass ` B<U1 .. Us> ` then the ` j ` th actual type argument to the super
324
- constructor invocation is obtained as ` [T1/X1 .. Tk/Xk]Uj ` , for ` j ` in
324
+ constructor invocation is obtained as ` [T1/X1 .. Tk/Xk]Uj ` , for ` j ` in
325
325
` 1 .. s ` .
326
326
327
327
Moreover, in the body of _ D_ , the reserved word ` this ` has static type
@@ -359,7 +359,7 @@ whose constructor signature applies a list of actual type arguments to the
359
359
` <typeIdentifier> ` , of the form ` C<T1 .. Tk> ` . (This includes the case
360
360
where ` k ` is zero, which again implies that ` C ` is a non-generic class).
361
361
362
- In this case, the redirectee must have a type which is a subtype of
362
+ In this case, the redirectee must have a type which is a subtype of
363
363
` C<T1 .. Tk> ` . Similarly, if the redirectee denotes a generic constructor
364
364
and no actual type arguments are provided then ` C<T1 .. Tk> ` is used as the
365
365
type to match when such type arguments are inferred.
@@ -396,7 +396,7 @@ inferred exactly like invocations of that static method.*
396
396
Consider an invocation of this generic constructor of the form
397
397
` C<S1 .. Sk>.name(args) ` , with context type ` T ` . This invocation is
398
398
subjected to type inference as if the generic constructor had been the same
399
- static method of ` C ` as in the previous case, but with context type
399
+ static method of ` C ` as in the previous case, but with context type
400
400
` C<S1 .. Sk> ` .
401
401
402
402
Warnings are not language specified entities, but the following warning is
0 commit comments