File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
accepted/future-releases/extension-types Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,7 @@ leaves, and nothing else.
274
274
``` dart
275
275
extension type TinyJson(Object it) {
276
276
Iterable<num> get leaves sync* {
277
+ final it = this.it; // To get promotion.
277
278
if (it is num) {
278
279
yield it;
279
280
} else if (it is List<dynamic>) {
@@ -293,9 +294,6 @@ void main() {
293
294
}
294
295
```
295
296
296
- Note that ` it ` is subject to promotion in the above example. This is safe
297
- because there is no way to override this would-be final instance variable.
298
-
299
297
An instance creation of an extension type, ` V<T>(o) ` , will evaluate to a
300
298
reference to the representation object, with the static type ` V<T> ` (and
301
299
there is no object at run time that represents the extension type itself).
@@ -356,11 +354,11 @@ class TinyJson {
356
354
TinyJson(this.it);
357
355
358
356
Iterable<num> get leaves sync* {
359
- var localIt = it; // To get promotion.
360
- if (localIt is num) {
361
- yield localIt ;
362
- } else if (localIt is List<dynamic>) {
363
- for (var element in localIt ) {
357
+ final it = this. it; // To get promotion.
358
+ if (it is num) {
359
+ yield it ;
360
+ } else if (it is List<dynamic>) {
361
+ for (var element in it ) {
364
362
yield* TinyJson(element).leaves;
365
363
}
366
364
} else {
You can’t perform that action at this time.
0 commit comments