Skip to content

Commit 2ec0ca2

Browse files
kallentuCommit Queue
authored and
Commit Queue
committed
[cfe] isWildcard set only with experiment on.
Only set `isWildcard` on variables when the experiment for wildcards is enabled. Bug: #55655 Change-Id: I54a1f0ba1b9192df6c86e44e92d5ff4bebc9a232 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371020 Commit-Queue: Kallen Tu <[email protected]> Reviewed-by: Chloe Stefantsova <[email protected]>
1 parent 726f9f1 commit 2ec0ca2

19 files changed

+26
-25
lines changed

pkg/front_end/lib/src/fasta/kernel/body_builder.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -3885,7 +3885,8 @@ class BodyBuilder extends StackListenerImpl
38853885
isRequired: isRequired,
38863886
hasDeclaredInitializer: initializer != null,
38873887
isStaticLate: isFinal && initializer == null,
3888-
isWildcard: identifier.name == '_')
3888+
isWildcard: identifier.name == '_' &&
3889+
libraryFeatures.wildcardVariables.isEnabled)
38893890
..fileOffset = identifier.nameOffset
38903891
..fileEqualsOffset = offsetForToken(equalsToken);
38913892
typeInferrer.assignedVariables.declare(variable);

pkg/front_end/testcases/general/arithmetic.dart.strong.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ static method foo(core::int x, core::int y) → core::int {
77
return z.{core::int::<<}(4){(core::int) → core::int};
88
}
99
static method loop(core::List<dynamic> xs) → void {
10-
wildcard core::int _ = xs.{core::List::length}{core::int};
10+
core::int _ = xs.{core::List::length}{core::int};
1111
for (core::int i = 0; i.{core::num::<}(xs.{core::List::length}{core::int}){(core::num) → core::bool}; i = i.{core::num::+}(1){(core::num) → core::int}) {
1212
}
1313
}

pkg/front_end/testcases/general/arithmetic.dart.strong.modular.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ static method foo(core::int x, core::int y) → core::int {
77
return z.{core::int::<<}(4){(core::int) → core::int};
88
}
99
static method loop(core::List<dynamic> xs) → void {
10-
wildcard core::int _ = xs.{core::List::length}{core::int};
10+
core::int _ = xs.{core::List::length}{core::int};
1111
for (core::int i = 0; i.{core::num::<}(xs.{core::List::length}{core::int}){(core::num) → core::bool}; i = i.{core::num::+}(1){(core::num) → core::int}) {
1212
}
1313
}

pkg/front_end/testcases/general/arithmetic.dart.strong.transformed.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ static method foo(core::int x, core::int y) → core::int {
77
return z.{core::int::<<}(4){(core::int) → core::int};
88
}
99
static method loop(core::List<dynamic> xs) → void {
10-
wildcard core::int _ = xs.{core::List::length}{core::int};
10+
core::int _ = xs.{core::List::length}{core::int};
1111
for (core::int i = 0; i.{core::num::<}(xs.{core::List::length}{core::int}){(core::num) → core::bool}; i = i.{core::num::+}(1){(core::num) → core::int}) {
1212
}
1313
}

pkg/front_end/testcases/general/closure.dart.strong.expect

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Bar extends core::Object {
1414
;
1515
}
1616
static method useCallback(dynamic callback) → dynamic {
17-
wildcard dynamic _ = callback{dynamic}();
17+
dynamic _ = callback{dynamic}();
1818
}
1919
static method main() → dynamic {
2020
dynamic x;
@@ -23,5 +23,5 @@ static method main() → dynamic {
2323
return new self::Foo::•();
2424
}
2525
self::useCallback(inner);
26-
wildcard self::Bar _ = inner(){() → self::Foo}.{self::Foo::_field}{self::Bar};
26+
self::Bar _ = inner(){() → self::Foo}.{self::Foo::_field}{self::Bar};
2727
}

pkg/front_end/testcases/general/closure.dart.strong.modular.expect

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Bar extends core::Object {
1414
;
1515
}
1616
static method useCallback(dynamic callback) → dynamic {
17-
wildcard dynamic _ = callback{dynamic}();
17+
dynamic _ = callback{dynamic}();
1818
}
1919
static method main() → dynamic {
2020
dynamic x;
@@ -23,5 +23,5 @@ static method main() → dynamic {
2323
return new self::Foo::•();
2424
}
2525
self::useCallback(inner);
26-
wildcard self::Bar _ = inner(){() → self::Foo}.{self::Foo::_field}{self::Bar};
26+
self::Bar _ = inner(){() → self::Foo}.{self::Foo::_field}{self::Bar};
2727
}

pkg/front_end/testcases/general/closure.dart.strong.transformed.expect

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Bar extends core::Object {
1414
;
1515
}
1616
static method useCallback(dynamic callback) → dynamic {
17-
wildcard dynamic _ = callback{dynamic}();
17+
dynamic _ = callback{dynamic}();
1818
}
1919
static method main() → dynamic {
2020
dynamic x;
@@ -23,5 +23,5 @@ static method main() → dynamic {
2323
return new self::Foo::•();
2424
}
2525
self::useCallback(inner);
26-
wildcard self::Bar _ = inner(){() → self::Foo}.{self::Foo::_field}{self::Bar};
26+
self::Bar _ = inner(){() → self::Foo}.{self::Foo::_field}{self::Bar};
2727
}

pkg/front_end/testcases/general/escape.dart.strong.expect

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class X extends core::Object implements self::A, self::B {
2828
;
2929
}
3030
static method useAsA(self::A object) → void {
31-
wildcard dynamic _ = object.{self::A::field}{dynamic};
31+
dynamic _ = object.{self::A::field}{dynamic};
3232
}
3333
static method useAsB(self::B object) → void {
34-
wildcard dynamic _ = object.{self::B::field}{dynamic};
34+
dynamic _ = object.{self::B::field}{dynamic};
3535
self::escape(object);
3636
}
3737
static method escape(dynamic x) → void {

pkg/front_end/testcases/general/escape.dart.strong.modular.expect

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class X extends core::Object implements self::A, self::B {
2828
;
2929
}
3030
static method useAsA(self::A object) → void {
31-
wildcard dynamic _ = object.{self::A::field}{dynamic};
31+
dynamic _ = object.{self::A::field}{dynamic};
3232
}
3333
static method useAsB(self::B object) → void {
34-
wildcard dynamic _ = object.{self::B::field}{dynamic};
34+
dynamic _ = object.{self::B::field}{dynamic};
3535
self::escape(object);
3636
}
3737
static method escape(dynamic x) → void {

pkg/front_end/testcases/general/escape.dart.strong.transformed.expect

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class X extends core::Object implements self::A, self::B {
2828
;
2929
}
3030
static method useAsA(self::A object) → void {
31-
wildcard dynamic _ = object.{self::A::field}{dynamic};
31+
dynamic _ = object.{self::A::field}{dynamic};
3232
}
3333
static method useAsB(self::B object) → void {
34-
wildcard dynamic _ = object.{self::B::field}{dynamic};
34+
dynamic _ = object.{self::B::field}{dynamic};
3535
self::escape(object);
3636
}
3737
static method escape(dynamic x) → void {

pkg/front_end/testcases/general/issue48347.dart.strong.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "dart:async" as asy;
55
import "dart:async";
66

77
static method test(asy::StreamController<void> _eventStreamController) → dynamic async /* emittedValueType= dynamic */ {
8-
await for (final wildcard void _ in _eventStreamController.{asy::StreamController::stream}{asy::Stream<void>}) {
8+
await for (final void _ in _eventStreamController.{asy::StreamController::stream}{asy::Stream<void>}) {
99
}
1010
}
1111
static method main() → dynamic {}

pkg/front_end/testcases/general/issue48347.dart.strong.modular.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "dart:async" as asy;
55
import "dart:async";
66

77
static method test(asy::StreamController<void> _eventStreamController) → dynamic async /* emittedValueType= dynamic */ {
8-
await for (final wildcard void _ in _eventStreamController.{asy::StreamController::stream}{asy::Stream<void>}) {
8+
await for (final void _ in _eventStreamController.{asy::StreamController::stream}{asy::Stream<void>}) {
99
}
1010
}
1111
static method main() → dynamic {}

pkg/front_end/testcases/general/issue48347.dart.strong.transformed.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static method test(asy::StreamController<void> _eventStreamController) → dynam
1111
synthesized asy::_StreamIterator<void>? :for-iterator = new asy::_StreamIterator::•<void>(:stream);
1212
try
1313
while (let dynamic #t1 = asy::_asyncStarMoveNextHelper(:stream) in await :for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}) {
14-
final wildcard void _ = :for-iterator.{asy::_StreamIterator::current}{void};
14+
final void _ = :for-iterator.{asy::_StreamIterator::current}{void};
1515
{}
1616
}
1717
finally

pkg/front_end/testcases/patterns/issue52345.dart.strong.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ static method main() → void {
66
final core::List<core::String> works = <core::String>["b", "l"];
77
final core::List<core::String> fails = <core::String>["c"];
88
for (final core::List<core::String> test in <core::List<core::String>>[works, fails]) {
9-
final wildcard void _ = block {
9+
final void _ = block {
1010
void #t1;
1111
final synthesized core::List<core::String> #0#0 = test;
1212
synthesized core::int #0#1;

pkg/front_end/testcases/patterns/issue52345.dart.strong.modular.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ static method main() → void {
66
final core::List<core::String> works = <core::String>["b", "l"];
77
final core::List<core::String> fails = <core::String>["c"];
88
for (final core::List<core::String> test in <core::List<core::String>>[works, fails]) {
9-
final wildcard void _ = block {
9+
final void _ = block {
1010
void #t1;
1111
final synthesized core::List<core::String> #0#0 = test;
1212
synthesized core::int #0#1;

pkg/front_end/testcases/patterns/issue52345.dart.strong.transformed.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ static method main() → void {
1010
for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) {
1111
final core::List<core::String> test = :sync-for-iterator.{core::Iterator::current}{core::List<core::String>};
1212
{
13-
final wildcard void _ = block {
13+
final void _ = block {
1414
void #t1;
1515
final synthesized core::List<core::String> #0#0 = test;
1616
synthesized core::int #0#1;

pkg/front_end/testcases/records/block_combine_statements.dart.strong.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "dart:core" as core;
44
import "dart:_internal" as _in;
55

66
static method main() → void {
7-
for (wildcard(core::Iterable<core::int>, core::Iterable<core::int>) _ in self::split<core::int>(<core::int>[1, 2, 3])) {
7+
for ((core::Iterable<core::int>, core::Iterable<core::int>) _ in self::split<core::int>(<core::int>[1, 2, 3])) {
88
}
99
}
1010
static method split<A extends core::Object? = dynamic>(core::Iterable<self::split::A%> it) → core::Iterable<(core::Iterable<self::split::A%>, core::Iterable<self::split::A%>)>

pkg/front_end/testcases/records/block_combine_statements.dart.strong.modular.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "dart:core" as core;
44
import "dart:_internal" as _in;
55

66
static method main() → void {
7-
for (wildcard(core::Iterable<core::int>, core::Iterable<core::int>) _ in self::split<core::int>(<core::int>[1, 2, 3])) {
7+
for ((core::Iterable<core::int>, core::Iterable<core::int>) _ in self::split<core::int>(<core::int>[1, 2, 3])) {
88
}
99
}
1010
static method split<A extends core::Object? = dynamic>(core::Iterable<self::split::A%> it) → core::Iterable<(core::Iterable<self::split::A%>, core::Iterable<self::split::A%>)>

pkg/front_end/testcases/records/block_combine_statements.dart.strong.transformed.expect

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ static method main() → void {
77
{
88
synthesized core::Iterator<(core::Iterable<core::int>, core::Iterable<core::int>)> :sync-for-iterator = self::split<core::int>(core::_GrowableList::_literal3<core::int>(1, 2, 3)).{core::Iterable::iterator}{core::Iterator<(core::Iterable<core::int>, core::Iterable<core::int>)>};
99
for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) {
10-
wildcard(core::Iterable<core::int>, core::Iterable<core::int>) _ = :sync-for-iterator.{core::Iterator::current}{(core::Iterable<core::int>, core::Iterable<core::int>)};
10+
(core::Iterable<core::int>, core::Iterable<core::int>) _ = :sync-for-iterator.{core::Iterator::current}{(core::Iterable<core::int>, core::Iterable<core::int>)};
1111
{}
1212
}
1313
}

0 commit comments

Comments
 (0)