Enable set literals by default in the front-end tests.
Set literals can be disabled in individual suites by putting
"enableSetLiterals": "false" into the environment given to
FastaContext.create.
Also fixed a missing file offset on inferred empty set literals
which would trip up the front-end tests.
Change-Id: I76ad03e6ed03eb80045055f83fa0ab9acd62eed6
Reviewed-on: https://dart-review.googlesource.com/c/88722
Reviewed-by: Peter von der Ahé <ahe@google.com>
diff --git a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
index 08834e4..6b4093c 100644
--- a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
@@ -746,8 +746,8 @@
.isSubclassOf(inferrer.coreTypes.mapClass, context.classNode)) {
// Set literal
SetLiteralJudgment setLiteral = new SetLiteralJudgment([],
- typeArgument: const ImplicitTypeArgument(),
- isConst: node.isConst);
+ typeArgument: const ImplicitTypeArgument(), isConst: node.isConst)
+ ..fileOffset = node.fileOffset;
node.replaceWith(setLiteral);
visitSetLiteralJudgment(setLiteral, typeContext);
node.inferredType = setLiteral.inferredType;
diff --git a/pkg/front_end/test/fasta/testing/suite.dart b/pkg/front_end/test/fasta/testing/suite.dart
index 8a89ddc..2934b93 100644
--- a/pkg/front_end/test/fasta/testing/suite.dart
+++ b/pkg/front_end/test/fasta/testing/suite.dart
@@ -36,6 +36,9 @@
import 'package:front_end/src/api_prototype/compiler_options.dart'
show CompilerOptions, DiagnosticMessage;
+import 'package:front_end/src/api_prototype/experimental_flags.dart'
+ show ExperimentalFlag;
+
import 'package:front_end/src/api_prototype/standard_file_system.dart'
show StandardFileSystem;
@@ -118,6 +121,7 @@
final Uri vm;
final bool legacyMode;
final bool onlyCrashes;
+ final bool enableSetLiterals;
final Map<Component, KernelTarget> componentToTarget =
<Component, KernelTarget>{};
final Map<Component, StringBuffer> componentToDiagnostics =
@@ -135,6 +139,7 @@
this.legacyMode,
this.platformBinaries,
this.onlyCrashes,
+ this.enableSetLiterals,
bool ignoreExpectations,
bool updateExpectations,
bool updateComments,
@@ -211,13 +216,17 @@
Uri sdk = Uri.base.resolve("sdk/");
Uri vm = Uri.base.resolveUri(new Uri.file(Platform.resolvedExecutable));
Uri packages = Uri.base.resolve(".packages");
+ bool enableSetLiterals = environment["enableSetLiterals"] != "false";
var options = new ProcessedOptions(
options: new CompilerOptions()
..onDiagnostic = (DiagnosticMessage message) {
throw message.plainTextFormatted.join("\n");
}
..sdkRoot = sdk
- ..packagesFileUri = packages);
+ ..packagesFileUri = packages
+ ..experimentalFlags = <ExperimentalFlag, bool>{
+ ExperimentalFlag.setLiterals: enableSetLiterals
+ });
UriTranslator uriTranslator = await options.getUriTranslator();
bool legacyMode = environment.containsKey(LEGACY_MODE);
bool onlyCrashes = environment["onlyCrashes"] == "true";
@@ -238,6 +247,7 @@
? computePlatformBinariesLocation(forceBuildDir: true)
: Uri.base.resolve(platformBinaries),
onlyCrashes,
+ enableSetLiterals,
ignoreExpectations,
updateExpectations,
updateComments,
@@ -302,6 +312,9 @@
errors.write("\n\n");
}
errors.writeAll(message.plainTextFormatted, "\n");
+ }
+ ..experimentalFlags = <ExperimentalFlag, bool>{
+ ExperimentalFlag.setLiterals: context.enableSetLiterals
},
inputs: <Uri>[description.uri]);
return await CompilerContext.runWithOptions(options, (_) async {
diff --git a/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart b/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart
index 3796335..aafc9ff 100644
--- a/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart
+++ b/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart
@@ -12,16 +12,16 @@
}
Stream<List<int>> foo() async* {
- yield /*@typeArgs=int*/ [];
+ yield new /*@typeArgs=int*/ List();
yield /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic*/ MyStream();
- yield* /*error:YIELD_OF_INVALID_TYPE*/ /*@typeArgs=dynamic*/ [];
+ yield* /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic*/ List();
yield* new /*@typeArgs=List<int>*/ MyStream();
}
Iterable<Map<int, int>> bar() sync* {
- yield /*@typeArgs=int, int*/ {};
+ yield new /*@typeArgs=int, int*/ Map();
yield /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic*/ List();
- yield* /*error:YIELD_OF_INVALID_TYPE*/ /*@typeArgs=dynamic, dynamic*/ {};
+ yield* /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic, dynamic*/ Map();
yield* new /*@typeArgs=Map<int, int>*/ List();
}
diff --git a/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.legacy.expect b/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.legacy.expect
index bbe604f..4a22da5 100644
--- a/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.legacy.expect
+++ b/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.legacy.expect
@@ -8,15 +8,15 @@
return null;
}
static method foo() → asy::Stream<core::List<core::int>> async* {
- yield<dynamic>[];
+ yield core::List::•<dynamic>();
yield self::MyStream::•<dynamic>();
- yield*<dynamic>[];
+ yield* core::List::•<dynamic>();
yield* self::MyStream::•<dynamic>();
}
static method bar() → core::Iterable<core::Map<core::int, core::int>> sync* {
- yield<dynamic, dynamic>{};
+ yield core::Map::•<dynamic, dynamic>();
yield core::List::•<dynamic>();
- yield*<dynamic, dynamic>{};
+ yield* core::Map::•<dynamic, dynamic>();
yield* core::List::•<dynamic>();
}
static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.legacy.transformed.expect b/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.legacy.transformed.expect
index 3c303a7..4d12a56 100644
--- a/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.legacy.transformed.expect
+++ b/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.legacy.transformed.expect
@@ -22,7 +22,7 @@
try {
#L1:
{
- if(:controller.{asy::_AsyncStarStreamController::add}(<dynamic>[]))
+ if(:controller.{asy::_AsyncStarStreamController::add}(core::_GrowableList::•<dynamic>(0)))
return null;
else
[yield] null;
@@ -30,7 +30,7 @@
return null;
else
[yield] null;
- if(:controller.{asy::_AsyncStarStreamController::addStream}(<dynamic>[]))
+ if(:controller.{asy::_AsyncStarStreamController::addStream}(core::_GrowableList::•<dynamic>(0)))
return null;
else
[yield] null;
@@ -60,7 +60,7 @@
function :sync_op(core::_SyncIterator<core::Map<core::int, core::int>> :iterator) → core::bool yielding {
{
{
- :iterator.{core::_SyncIterator::_current} = <dynamic, dynamic>{};
+ :iterator.{core::_SyncIterator::_current} = core::Map::•<dynamic, dynamic>();
[yield] true;
}
{
@@ -68,7 +68,7 @@
[yield] true;
}
{
- :iterator.{core::_SyncIterator::_yieldEachIterable} = <dynamic, dynamic>{};
+ :iterator.{core::_SyncIterator::_yieldEachIterable} = core::Map::•<dynamic, dynamic>();
[yield] true;
}
{
diff --git a/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.strong.expect b/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.strong.expect
index ea7b44c..5504acd 100644
--- a/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.strong.expect
+++ b/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.strong.expect
@@ -7,12 +7,12 @@
// yield /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic*/ MyStream();
// ^
//
-// pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:17:64: Error: A value of type 'List<dynamic>' can't be assigned to a variable of type 'Stream<List<int>>'.
+// pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:17:68: Error: A value of type 'List<dynamic>' can't be assigned to a variable of type 'Stream<List<int>>'.
// - 'List' is from 'dart:core'.
// - 'Stream' is from 'dart:async'.
// Try changing the type of the left hand side, or casting the right hand side to 'Stream<List<int>>'.
-// yield* /*error:YIELD_OF_INVALID_TYPE*/ /*@typeArgs=dynamic*/ [];
-// ^
+// yield* /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic*/ List();
+// ^
//
// pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:23:67: Error: A value of type 'List<dynamic>' can't be assigned to a variable of type 'Map<int, int>'.
// - 'List' is from 'dart:core'.
@@ -21,12 +21,12 @@
// yield /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic*/ List();
// ^
//
-// pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:24:73: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Iterable<Map<int, int>>'.
+// pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:24:77: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Iterable<Map<int, int>>'.
// - 'Map' is from 'dart:core'.
// - 'Iterable' is from 'dart:core'.
// Try changing the type of the left hand side, or casting the right hand side to 'Iterable<Map<int, int>>'.
-// yield* /*error:YIELD_OF_INVALID_TYPE*/ /*@typeArgs=dynamic, dynamic*/ {};
-// ^
+// yield* /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic, dynamic*/ Map();
+// ^
library test;
import self as self;
@@ -38,35 +38,35 @@
return null;
}
static method foo() → asy::Stream<core::List<core::int>> async* {
- yield<core::int>[];
+ yield core::List::•<core::int>();
yield let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:16:67: Error: A value of type 'MyStream<dynamic>' can't be assigned to a variable of type 'List<int>'.
- 'MyStream' is from 'pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart'.
- 'List' is from 'dart:core'.
Try changing the type of the left hand side, or casting the right hand side to 'List<int>'.
yield /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic*/ MyStream();
^" in self::MyStream::•<dynamic>() as{TypeError} core::List<core::int>;
- yield* let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:17:64: Error: A value of type 'List<dynamic>' can't be assigned to a variable of type 'Stream<List<int>>'.
+ yield* let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:17:68: Error: A value of type 'List<dynamic>' can't be assigned to a variable of type 'Stream<List<int>>'.
- 'List' is from 'dart:core'.
- 'Stream' is from 'dart:async'.
Try changing the type of the left hand side, or casting the right hand side to 'Stream<List<int>>'.
- yield* /*error:YIELD_OF_INVALID_TYPE*/ /*@typeArgs=dynamic*/ [];
- ^" in <dynamic>[] as{TypeError} asy::Stream<core::List<core::int>>;
+ yield* /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic*/ List();
+ ^" in core::List::•<dynamic>() as{TypeError} asy::Stream<core::List<core::int>>;
yield* self::MyStream::•<core::List<core::int>>();
}
static method bar() → core::Iterable<core::Map<core::int, core::int>> sync* {
- yield<core::int, core::int>{};
+ yield core::Map::•<core::int, core::int>();
yield let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:23:67: Error: A value of type 'List<dynamic>' can't be assigned to a variable of type 'Map<int, int>'.
- 'List' is from 'dart:core'.
- 'Map' is from 'dart:core'.
Try changing the type of the left hand side, or casting the right hand side to 'Map<int, int>'.
yield /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic*/ List();
^" in core::List::•<dynamic>() as{TypeError} core::Map<core::int, core::int>;
- yield* let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:24:73: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Iterable<Map<int, int>>'.
+ yield* let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:24:77: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Iterable<Map<int, int>>'.
- 'Map' is from 'dart:core'.
- 'Iterable' is from 'dart:core'.
Try changing the type of the left hand side, or casting the right hand side to 'Iterable<Map<int, int>>'.
- yield* /*error:YIELD_OF_INVALID_TYPE*/ /*@typeArgs=dynamic, dynamic*/ {};
- ^" in <dynamic, dynamic>{} as{TypeError} core::Iterable<core::Map<core::int, core::int>>;
+ yield* /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic, dynamic*/ Map();
+ ^" in core::Map::•<dynamic, dynamic>() as{TypeError} core::Iterable<core::Map<core::int, core::int>>;
yield* core::List::•<core::Map<core::int, core::int>>();
}
static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.strong.transformed.expect
index 85ffbbc7..4ff259f 100644
--- a/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart.strong.transformed.expect
@@ -22,7 +22,7 @@
try {
#L1:
{
- if(:controller.{asy::_AsyncStarStreamController::add}(<core::int>[]))
+ if(:controller.{asy::_AsyncStarStreamController::add}(core::_GrowableList::•<core::int>(0)))
return null;
else
[yield] null;
@@ -35,12 +35,12 @@
return null;
else
[yield] null;
- if(:controller.{asy::_AsyncStarStreamController::addStream}(let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:17:64: Error: A value of type 'List<dynamic>' can't be assigned to a variable of type 'Stream<List<int>>'.
+ if(:controller.{asy::_AsyncStarStreamController::addStream}(let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:17:68: Error: A value of type 'List<dynamic>' can't be assigned to a variable of type 'Stream<List<int>>'.
- 'List' is from 'dart:core'.
- 'Stream' is from 'dart:async'.
Try changing the type of the left hand side, or casting the right hand side to 'Stream<List<int>>'.
- yield* /*error:YIELD_OF_INVALID_TYPE*/ /*@typeArgs=dynamic*/ [];
- ^" in <dynamic>[] as{TypeError} asy::Stream<core::List<core::int>>))
+ yield* /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic*/ List();
+ ^" in core::_GrowableList::•<dynamic>(0) as{TypeError} asy::Stream<core::List<core::int>>))
return null;
else
[yield] null;
@@ -70,7 +70,7 @@
function :sync_op(core::_SyncIterator<core::Map<core::int, core::int>> :iterator) → core::bool yielding {
{
{
- :iterator.{core::_SyncIterator::_current} = <core::int, core::int>{};
+ :iterator.{core::_SyncIterator::_current} = core::Map::•<core::int, core::int>();
[yield] true;
}
{
@@ -83,12 +83,12 @@
[yield] true;
}
{
- :iterator.{core::_SyncIterator::_yieldEachIterable} = let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:24:73: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Iterable<Map<int, int>>'.
+ :iterator.{core::_SyncIterator::_yieldEachIterable} = let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_yield_yield_star.dart:24:77: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Iterable<Map<int, int>>'.
- 'Map' is from 'dart:core'.
- 'Iterable' is from 'dart:core'.
Try changing the type of the left hand side, or casting the right hand side to 'Iterable<Map<int, int>>'.
- yield* /*error:YIELD_OF_INVALID_TYPE*/ /*@typeArgs=dynamic, dynamic*/ {};
- ^" in <dynamic, dynamic>{} as{TypeError} core::Iterable<core::Map<core::int, core::int>>;
+ yield* /*error:YIELD_OF_INVALID_TYPE*/ new /*@typeArgs=dynamic, dynamic*/ Map();
+ ^" in core::Map::•<dynamic, dynamic>() as{TypeError} core::Iterable<core::Map<core::int, core::int>>;
[yield] true;
}
{