Skip to content

Commit 4d1e996

Browse files
authored
Removed incorrect claim about promotability (#3339)
1 parent 6daaa2e commit 4d1e996

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

accepted/future-releases/extension-types/feature-specification.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ leaves, and nothing else.
274274
```dart
275275
extension type TinyJson(Object it) {
276276
Iterable<num> get leaves sync* {
277+
final it = this.it; // To get promotion.
277278
if (it is num) {
278279
yield it;
279280
} else if (it is List<dynamic>) {
@@ -293,9 +294,6 @@ void main() {
293294
}
294295
```
295296

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-
299297
An instance creation of an extension type, `V<T>(o)`, will evaluate to a
300298
reference to the representation object, with the static type `V<T>` (and
301299
there is no object at run time that represents the extension type itself).
@@ -356,11 +354,11 @@ class TinyJson {
356354
TinyJson(this.it);
357355
358356
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) {
364362
yield* TinyJson(element).leaves;
365363
}
366364
} else {

0 commit comments

Comments
 (0)