-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CFE] Fix setter from extension used in for loop
Change-Id: I6cfbd7b8c5d72ea508dcdb7f0b15ddaab1e0700d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398062 Commit-Queue: Jens Johansen <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
- Loading branch information
Showing
9 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
pkg/front_end/testcases/regress/extension_setter_in_for_in_loop.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
extension on String { | ||
set foo(int value) {} | ||
bar(List<int> input) { | ||
foo = 42; | ||
for (foo in input) { | ||
print("inside loop"); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
pkg/front_end/testcases/regress/extension_setter_in_for_in_loop.dart.strong.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension /* unnamed */ _extension#0 on core::String { | ||
method bar = self::_extension#0|bar; | ||
method tearoff bar = self::_extension#0|get#bar; | ||
set foo = self::_extension#0|set#foo; | ||
} | ||
static extension-member method _extension#0|set#foo(lowered final core::String #this, core::int value) → void {} | ||
static extension-member method _extension#0|bar(lowered final core::String #this, core::List<core::int> input) → dynamic { | ||
self::_extension#0|set#foo(#this, 42); | ||
for (final core::int #t1 in input) { | ||
self::_extension#0|set#foo(#this, #t1); | ||
core::print("inside loop"); | ||
} | ||
} | ||
static extension-member method _extension#0|get#bar(lowered final core::String #this) → (core::List<core::int>) → dynamic | ||
return (core::List<core::int> input) → dynamic => self::_extension#0|bar(#this, input); |
19 changes: 19 additions & 0 deletions
19
pkg/front_end/testcases/regress/extension_setter_in_for_in_loop.dart.strong.modular.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension /* unnamed */ _extension#0 on core::String { | ||
method bar = self::_extension#0|bar; | ||
method tearoff bar = self::_extension#0|get#bar; | ||
set foo = self::_extension#0|set#foo; | ||
} | ||
static extension-member method _extension#0|set#foo(lowered final core::String #this, core::int value) → void {} | ||
static extension-member method _extension#0|bar(lowered final core::String #this, core::List<core::int> input) → dynamic { | ||
self::_extension#0|set#foo(#this, 42); | ||
for (final core::int #t1 in input) { | ||
self::_extension#0|set#foo(#this, #t1); | ||
core::print("inside loop"); | ||
} | ||
} | ||
static extension-member method _extension#0|get#bar(lowered final core::String #this) → (core::List<core::int>) → dynamic | ||
return (core::List<core::int> input) → dynamic => self::_extension#0|bar(#this, input); |
15 changes: 15 additions & 0 deletions
15
pkg/front_end/testcases/regress/extension_setter_in_for_in_loop.dart.strong.outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension /* unnamed */ _extension#0 on core::String { | ||
method bar = self::_extension#0|bar; | ||
method tearoff bar = self::_extension#0|get#bar; | ||
set foo = self::_extension#0|set#foo; | ||
} | ||
static extension-member method _extension#0|set#foo(lowered final core::String #this, core::int value) → void | ||
; | ||
static extension-member method _extension#0|bar(lowered final core::String #this, core::List<core::int> input) → dynamic | ||
; | ||
static extension-member method _extension#0|get#bar(lowered final core::String #this) → (core::List<core::int>) → dynamic | ||
return (core::List<core::int> input) → dynamic => self::_extension#0|bar(#this, input); |
25 changes: 25 additions & 0 deletions
25
...ront_end/testcases/regress/extension_setter_in_for_in_loop.dart.strong.transformed.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension /* unnamed */ _extension#0 on core::String { | ||
method bar = self::_extension#0|bar; | ||
method tearoff bar = self::_extension#0|get#bar; | ||
set foo = self::_extension#0|set#foo; | ||
} | ||
static extension-member method _extension#0|set#foo(lowered final core::String #this, core::int value) → void {} | ||
static extension-member method _extension#0|bar(lowered final core::String #this, core::List<core::int> input) → dynamic { | ||
self::_extension#0|set#foo(#this, 42); | ||
{ | ||
synthesized core::Iterator<core::int> :sync-for-iterator = input.{core::Iterable::iterator}{core::Iterator<core::int>}; | ||
for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { | ||
final core::int #t1 = :sync-for-iterator.{core::Iterator::current}{core::int}; | ||
{ | ||
self::_extension#0|set#foo(#this, #t1); | ||
core::print("inside loop"); | ||
} | ||
} | ||
} | ||
} | ||
static extension-member method _extension#0|get#bar(lowered final core::String #this) → (core::List<core::int>) → dynamic | ||
return (core::List<core::int> input) → dynamic => self::_extension#0|bar(#this, input); |
4 changes: 4 additions & 0 deletions
4
pkg/front_end/testcases/regress/extension_setter_in_for_in_loop.dart.textual_outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extension on String { | ||
set foo(int value) {} | ||
bar(List<int> input) {} | ||
} |
4 changes: 4 additions & 0 deletions
4
...nd/testcases/regress/extension_setter_in_for_in_loop.dart.textual_outline_modelled.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extension on String { | ||
bar(List<int> input) {} | ||
set foo(int value) {} | ||
} |