From d53501fb01b240ed066e4176d2d87d87beaa34b3 Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Tue, 12 Sep 2023 09:21:43 +0200 Subject: [PATCH] Removed incorrect claim about promotability --- .../extension-types/feature-specification.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/accepted/future-releases/extension-types/feature-specification.md b/accepted/future-releases/extension-types/feature-specification.md index e47c7bfebb..e2894a5ae9 100644 --- a/accepted/future-releases/extension-types/feature-specification.md +++ b/accepted/future-releases/extension-types/feature-specification.md @@ -274,6 +274,7 @@ leaves, and nothing else. ```dart extension type TinyJson(Object it) { Iterable get leaves sync* { + final it = this.it; // To get promotion. if (it is num) { yield it; } else if (it is List) { @@ -293,9 +294,6 @@ void main() { } ``` -Note that `it` is subject to promotion in the above example. This is safe -because there is no way to override this would-be final instance variable. - An instance creation of an extension type, `V(o)`, will evaluate to a reference to the representation object, with the static type `V` (and there is no object at run time that represents the extension type itself). @@ -356,11 +354,11 @@ class TinyJson { TinyJson(this.it); Iterable get leaves sync* { - var localIt = it; // To get promotion. - if (localIt is num) { - yield localIt; - } else if (localIt is List) { - for (var element in localIt) { + final it = this.it; // To get promotion. + if (it is num) { + yield it; + } else if (it is List) { + for (var element in it) { yield* TinyJson(element).leaves; } } else {