Version 2.8.0-dev.0.0
Merge commit '0bca6aaf106b1d2752df8134d745743d52b6a78b' into dev
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 367fbca..b04a23f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,35 @@
+## Next release
+(Add new changes here, and they will be copied to the change section for the
+ next release)
+
+### Language
+
+### Core libraries
+
+#### `dart:io`
+
+### Dart VM
+
+### Tools
+
+#### Linter
+
+The Linter was updated to `0.1.105+1`, which includes:
+
+* hardened checks for lib dir location (fixing crashes in `avoid_renaming_method_parameters`,
+ `prefer_relative_imports` and `public_member_api_docs`)
+* improved performance for `always_require_non_null_named_parameters`
+
+#### Pub
+
## 2.7.0 - 2019-12-11
+**Extension methods** -- which we shipped in preview in 2.6.0 -- are no longer
+in preview, and are now officially supported as of 2.7.0. Learn more about them
+here:
+
+https://medium.com/dartlang/extension-methods-2d466cd8b308
+
### Language
* **Breaking Change**: [Static extension members][] are accessible when
@@ -46,11 +76,11 @@
#### Linter
-The Linter was updated to `0.1.104`, which includes:
+The Linter was updated to `0.1.105+1`, which includes:
-* updated `unnecessary_overrides` to allow overrides when annotations (besides `@override` are specified)
-* updated `file_names` to allow names w/ leading `_`'s (and improved performance)
-* new lint: `unnecessary_final`
+* hardened checks for lib dir location (fixing crashes in `avoid_renaming_method_parameters`,
+ `prefer_relative_imports` and `public_member_api_docs`)
+* improved performance for `always_require_non_null_named_parameters`
#### Pub
diff --git a/DEPS b/DEPS
index 8583d7a..d865ae4 100644
--- a/DEPS
+++ b/DEPS
@@ -36,9 +36,11 @@
"chromium_git": "https://chromium.googlesource.com",
"fuchsia_git": "https://fuchsia.googlesource.com",
- # co19 is a cipd package. Use tests/co19_2/update.sh to update this hash.
- # It requires access to the dart-build-access group, which EngProd has.
- "co19_2_rev": "a8f7aa15ab860a309667168243bda01fda0794df",
+ # co19 is a cipd package. Use update.sh in tests/co19[_2] to update these
+ # hashes. It requires access to the dart-build-access group, which EngProd
+ # has.
+ "co19_rev": "8767031866e8243eafdb46011d4d8a7b5705019d",
+ "co19_2_rev": "368bfa9e877a2df003547f64bb17e30596af10c7",
# As Flutter does, we use Fuchsia's GN and Clang toolchain. These revision
# should be kept up to date with the revisions pulled by the Flutter engine.
@@ -84,7 +86,7 @@
# For more details, see https://github.com/dart-lang/sdk/issues/30164
"dart_style_tag": "1.3.2", # Please see the note above before updating.
- "dartdoc_tag" : "v0.29.1",
+ "dartdoc_tag" : "v0.29.2",
"ffi_tag": "ea88d71b043ee14b268c3aedff14e9eb32e20959",
"fixnum_tag": "0.10.9",
"glob_tag": "1.1.7",
@@ -100,7 +102,7 @@
"intl_tag": "0.15.7",
"jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1",
"json_rpc_2_tag": "2.0.9",
- "linter_tag": "0.1.104",
+ "linter_tag": "0.1.105+1",
"logging_tag": "0.11.3+2",
"markupsafe_rev": "8f45f5cfa0009d2a70589bcda0349b8cb2b72783",
"markdown_tag": "2.1.1",
@@ -117,7 +119,7 @@
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
"pool_tag": "1.3.6",
"protobuf_rev": "3746c8fd3f2b0147623a8e3db89c3ff4330de760",
- "pub_rev": "d15067931a6b671a1c9dcc98b5923347676269cf",
+ "pub_rev": "ff5ad1eab1649a8eee6cc593302d3624d9853049",
"pub_semver_tag": "1.4.2",
"quiver-dart_tag": "2.0.0+1",
"resource_rev": "f8e37558a1c4f54550aa463b88a6a831e3e33cd6",
@@ -186,9 +188,16 @@
}],
"dep_type": "cipd",
},
- Var("dart_root") + "/tests/co19_2/src": {
+ Var("dart_root") + "/tests/co19/src": {
"packages": [{
"package": "dart/third_party/co19",
+ "version": "git_revision:" + Var("co19_rev"),
+ }],
+ "dep_type": "cipd",
+ },
+ Var("dart_root") + "/tests/co19_2/src": {
+ "packages": [{
+ "package": "dart/third_party/co19/legacy",
"version": "git_revision:" + Var("co19_2_rev"),
}],
"dep_type": "cipd",
diff --git a/benchmarks/IsolateSpawnMemory/dart/IsolateSpawnMemory.dart b/benchmarks/IsolateSpawnMemory/dart/IsolateSpawnMemory.dart
index 7969877..322f1af 100644
--- a/benchmarks/IsolateSpawnMemory/dart/IsolateSpawnMemory.dart
+++ b/benchmarks/IsolateSpawnMemory/dart/IsolateSpawnMemory.dart
@@ -6,11 +6,14 @@
import 'dart:developer';
import 'dart:io';
import 'dart:isolate';
+import 'dart:math' as math;
import 'package:compiler/src/dart2js.dart' as dart2js_main;
import 'package:vm_service/vm_service.dart' as vm_service;
import 'package:vm_service/vm_service_io.dart' as vm_service_io;
+const String compilerIsolateName = 'isolate-compiler';
+
class Result {
const Result(
this.rssOnStart, this.rssOnEnd, this.heapOnStart, this.heapOnEnd);
@@ -22,56 +25,96 @@
}
class StartMessage {
- const StartMessage(this.wsUri, this.groupRefId, this.sendPort);
+ const StartMessage(this.wsUri, this.sendPort);
final String wsUri;
- final String groupRefId;
final SendPort sendPort;
}
class SpawnMemory {
- SpawnMemory(this.name, this.wsUri, this.groupRefId);
+ SpawnMemory(this.name, this.wsUri);
Future<void> report() async {
- const numberOfRuns = 3;
+ int maxProcessRss = 0;
+ final timer = Timer.periodic(const Duration(microseconds: 100), (_) {
+ maxProcessRss = math.max(maxProcessRss, ProcessInfo.currentRss);
+ });
- int sumDeltaRssOnStart = 0;
- int sumDeltaRssOnEnd = 0;
- int sumDeltaHeapOnStart = 0;
- int sumDeltaHeapOnEnd = 0;
- for (int i = 0; i < numberOfRuns; i++) {
+ const numberOfBenchmarks = 3;
+
+ final beforeRss = ProcessInfo.currentRss;
+ final beforeHeap = await currentHeapUsage(wsUri);
+
+ final iterators = <StreamIterator>[];
+ final continuations = <SendPort>[];
+
+ // Start all isolates & make them wait.
+ for (int i = 0; i < numberOfBenchmarks; i++) {
final receivePort = ReceivePort();
- final beforeRss = ProcessInfo.currentRss;
- final beforeHeap = await currentHeapUsage(wsUri, groupRefId);
+ final startMessage = StartMessage(wsUri, receivePort.sendPort);
+ await Isolate.spawn(isolateCompiler, startMessage,
+ debugName: compilerIsolateName);
+ final iterator = StreamIterator(receivePort);
- final startMessage =
- StartMessage(wsUri, groupRefId, receivePort.sendPort);
- await Isolate.spawn(isolateCompiler, startMessage);
+ if (!await iterator.moveNext()) throw 'failed';
+ continuations.add(iterator.current as SendPort);
- final Result result = await receivePort.first;
- sumDeltaRssOnStart += result.rssOnStart - beforeRss;
- sumDeltaRssOnEnd += result.rssOnEnd - beforeRss;
- sumDeltaHeapOnStart += result.heapOnStart - beforeHeap;
- sumDeltaHeapOnEnd += result.heapOnEnd - beforeHeap;
+ iterators.add(iterator);
}
- print(
- "${name}RssOnStart(MemoryUse): ${sumDeltaRssOnStart ~/ numberOfRuns}");
- print("${name}RssOnEnd(MemoryUse): ${sumDeltaRssOnEnd ~/ numberOfRuns}");
- print(
- "${name}HeapOnStart(MemoryUse): ${sumDeltaHeapOnStart ~/ numberOfRuns}");
- print("${name}HeapOnEnd(MemoryUse): ${sumDeltaHeapOnEnd ~/ numberOfRuns}");
+
+ final readyRss = ProcessInfo.currentRss;
+ final readyHeap = await currentHeapUsage(wsUri);
+
+ // Let all isolates do the dart2js compilation.
+ for (int i = 0; i < numberOfBenchmarks; i++) {
+ final iterator = iterators[i];
+ final continuation = continuations[i];
+ continuation.send(null);
+ if (!await iterator.moveNext()) throw 'failed';
+ if (iterator.current != 'done') throw 'failed';
+ }
+
+ final doneRss = ProcessInfo.currentRss;
+ final doneHeap = await currentHeapUsage(wsUri);
+
+ // Shut down helper isolates
+ for (int i = 0; i < numberOfBenchmarks; i++) {
+ final iterator = iterators[i];
+ final continuation = continuations[i];
+ continuation.send(null);
+ if (!await iterator.moveNext()) throw 'failed';
+ if (iterator.current != 'shutdown') throw 'failed';
+ await iterator.cancel();
+ }
+ timer.cancel();
+
+ final readyDiffRss =
+ math.max(0, readyRss - beforeRss) ~/ numberOfBenchmarks;
+ final readyDiffHeap =
+ math.max(0, readyHeap - beforeHeap) ~/ numberOfBenchmarks;
+ final doneDiffRss = math.max(0, doneRss - beforeRss) ~/ numberOfBenchmarks;
+ final doneDiffHeap =
+ math.max(0, doneHeap - beforeHeap) ~/ numberOfBenchmarks;
+
+ print("${name}RssOnStart(MemoryUse): $readyDiffRss");
+ print("${name}RssOnEnd(MemoryUse): $doneDiffRss");
+ print("${name}HeapOnStart(MemoryUse): $readyDiffHeap");
+ print("${name}HeapOnEnd(MemoryUse): $doneDiffHeap");
+ print("${name}PeakProcessRss(MemoryUse): $maxProcessRss");
}
final String name;
final String wsUri;
- final String groupRefId;
- RawReceivePort receivePort;
}
Future<void> isolateCompiler(StartMessage startMessage) async {
- final rssOnStart = ProcessInfo.currentRss;
- final heapOnStart =
- await currentHeapUsage(startMessage.wsUri, startMessage.groupRefId);
+ final port = ReceivePort();
+ final iterator = StreamIterator(port);
+
+ // Let main isolate know we're ready.
+ startMessage.sendPort.send(port.sendPort);
+ await iterator.moveNext();
+
await runZoned(
() => dart2js_main.internalMain(<String>[
"benchmarks/IsolateSpawnMemory/dart/helloworld.dart",
@@ -79,38 +122,57 @@
]),
zoneSpecification: ZoneSpecification(
print: (Zone self, ZoneDelegate parent, Zone zone, String line) {}));
- startMessage.sendPort.send(Result(
- rssOnStart,
- ProcessInfo.currentRss,
- heapOnStart,
- await currentHeapUsage(startMessage.wsUri, startMessage.groupRefId)));
- ReceivePort(); // prevent isolate from exiting to ensure Rss monotonically grows
+
+ // Let main isolate know we're done.
+ startMessage.sendPort.send('done');
+ await iterator.moveNext();
+
+ // Closes the port.
+ startMessage.sendPort.send('shutdown');
+ await iterator.cancel();
}
-Future<int> currentHeapUsage(String wsUri, String groupRefId) async {
+Future<int> currentHeapUsage(String wsUri) async {
final vm_service.VmService vmService =
await vm_service_io.vmServiceConnectUri(wsUri);
- final vm_service.MemoryUsage usage =
- await vmService.getIsolateGroupMemoryUsage(groupRefId);
+ final groupIds = await getGroupIds(vmService);
+ int sum = 0;
+ for (final groupId in groupIds) {
+ final vm_service.MemoryUsage usage =
+ await vmService.getIsolateGroupMemoryUsage(groupId);
+ sum += usage.heapUsage + usage.externalUsage;
+ }
vmService.dispose();
- return usage.heapUsage + usage.externalUsage;
+ return sum;
}
Future<void> main() async {
+ // Only if we successfully reach the end will we set 0 exit code.
+ exitCode = 255;
+
final ServiceProtocolInfo info = await Service.controlWebServer(enable: true);
final Uri observatoryUri = info.serverUri;
final String wsUri =
'ws://${observatoryUri.authority}${observatoryUri.path}ws';
- final vm_service.VmService vmService =
- await vm_service_io.vmServiceConnectUri(wsUri);
- final String mainGroupRefId = await getMainGroupRefId(vmService);
- vmService.dispose();
+ await SpawnMemory("IsolateSpawnMemory.Dart2JSDelta", wsUri).report();
- await SpawnMemory("IsolateSpawnMemory.Dart2JSDelta", wsUri, mainGroupRefId)
- .report();
+ // Only if we successfully reach the end will we set 0 exit code.
+ exitCode = 0;
}
-Future<String> getMainGroupRefId(vm_service.VmService vmService) async {
+// Returns the set of isolate groups for which we should count the heap usage.
+//
+// We have two cases
+//
+// a) --enable-isolate-groups: All isolates will be within the same isolate
+// group.
+//
+// b) --no-enable-isolate-groups: All isolates will be within their own,
+// separate isolate group.
+//
+// In both cases we want to sum up the heap sizes of all isolate groups.
+Future<List<String>> getGroupIds(vm_service.VmService vmService) async {
+ final groupIds = <String>{};
final vm = await vmService.getVM();
for (vm_service.IsolateGroupRef groupRef in vm.isolateGroups) {
final vm_service.IsolateGroup group =
@@ -118,12 +180,12 @@
for (vm_service.IsolateRef isolateRef in group.isolates) {
final isolateOrSentinel = await vmService.getIsolate(isolateRef.id);
if (isolateOrSentinel is vm_service.Isolate) {
- final vm_service.Isolate isolate = isolateOrSentinel;
- if (isolate.name == 'main') {
- return groupRef.id;
- }
+ groupIds.add(groupRef.id);
}
}
}
- throw "Could not find main isolate";
+ if (groupIds.isEmpty) {
+ throw "Could not find main isolate";
+ }
+ return groupIds.toList();
}
diff --git a/pkg/_fe_analyzer_shared/PRESUBMIT.py b/pkg/_fe_analyzer_shared/PRESUBMIT.py
new file mode 100644
index 0000000..1a4331d
--- /dev/null
+++ b/pkg/_fe_analyzer_shared/PRESUBMIT.py
@@ -0,0 +1,64 @@
+# Copyright (c) 2019, 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.
+"""Shared front-end analyzer specific presubmit script.
+
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
+for more details about the presubmit API built into gcl.
+"""
+
+import imp
+import os.path
+import subprocess
+
+
+def runSmokeTest(input_api, output_api):
+ hasChangedFiles = False
+ for git_file in input_api.AffectedTextFiles():
+ filename = git_file.AbsoluteLocalPath()
+ if filename.endswith(".dart"):
+ hasChangedFiles = True
+ break
+
+ if hasChangedFiles:
+ local_root = input_api.change.RepositoryRoot()
+ utils = imp.load_source('utils',
+ os.path.join(local_root, 'tools', 'utils.py'))
+ dart = os.path.join(utils.CheckedInSdkPath(), 'bin', 'dart')
+ smoke_test = os.path.join(local_root, 'pkg', '_fe_analyzer_shared',
+ 'tool', 'smoke_test_quick.dart')
+
+ windows = utils.GuessOS() == 'win32'
+ if windows:
+ dart += '.exe'
+
+ if not os.path.isfile(dart):
+ print('WARNING: dart not found: %s' % dart)
+ return []
+
+ if not os.path.isfile(smoke_test):
+ print('WARNING: _fe_analyzer_shared smoke test not found: %s' %
+ smoke_test)
+ return []
+
+ args = [dart, smoke_test]
+ process = subprocess.Popen(
+ args, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
+ outs, _ = process.communicate()
+
+ if process.returncode != 0:
+ return [
+ output_api.PresubmitError(
+ '_fe_analyzer_shared smoke test failure(s):',
+ long_text=outs)
+ ]
+
+ return []
+
+
+def CheckChangeOnCommit(input_api, output_api):
+ return runSmokeTest(input_api, output_api)
+
+
+def CheckChangeOnUpload(input_api, output_api):
+ return runSmokeTest(input_api, output_api)
diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
index 75251f5..189b756 100644
--- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
@@ -103,6 +103,16 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Code<Null> codeAnnotationOnFunctionTypeTypeVariable =
+ messageAnnotationOnFunctionTypeTypeVariable;
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const MessageCode messageAnnotationOnFunctionTypeTypeVariable =
+ const MessageCode("AnnotationOnFunctionTypeTypeVariable",
+ message:
+ r"""A type variable on a function type can't have annotations.""");
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeAnonymousBreakTargetOutsideFunction =
messageAnonymousBreakTargetOutsideFunction;
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/definite_assignment/data/assignment.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/definite_assignment/data/assignment.dart
index d76d643..f4f7394 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/definite_assignment/data/assignment.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/definite_assignment/data/assignment.dart
@@ -42,5 +42,5 @@
late int v;
int? i;
/*cfe.unassigned*/ i ??= (v = 0);
- /*analyzer.unassigned*/ v;
+ /*unassigned*/ v;
}
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/nullability/data/null_aware_access.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/nullability/data/null_aware_access.dart
index 3dd6da9..d50373b 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/nullability/data/null_aware_access.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/nullability/data/null_aware_access.dart
@@ -104,13 +104,13 @@
// holds the result of evaluating the cascade target. So
// effectively, no promotion happens (because there is no way to
// observe a change to the type of that variable).
- c?..setter = c;
- c?..getterSetter += c;
- c?..getterSetter ??= c;
- c?..[c];
- c?..[c] = c;
- c?..[c] += c;
- c?..[c] ??= c;
+ c?..setter = /*cfe.nonNullable*/ c;
+ c?..getterSetter += /*cfe.nonNullable*/ c;
+ c?..getterSetter ??= /*cfe.nonNullable*/ c;
+ c?..[/*cfe.nonNullable*/ c];
+ c?..[/*cfe.nonNullable*/ c] = /*cfe.nonNullable*/ c;
+ c?..[/*cfe.nonNullable*/ c] += /*cfe.nonNullable*/ c;
+ c?..[/*cfe.nonNullable*/ c] ??= /*cfe.nonNullable*/ c;
}
void null_aware_cascades_do_not_promote_others(C? c, int? i, int? j) {
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/null_check.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/null_check.dart
index e8c4389..9dcfa11 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/null_check.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/null_check.dart
@@ -17,3 +17,11 @@
x;
}
}
+
+promotesNullType(Null x) {
+ if (x != null) {
+ /*Never*/ x;
+ } else {
+ x;
+ }
+}
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/type_parameter.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/type_parameter.dart
index 48fdaca..d750821 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/type_parameter.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/type_parameter.dart
@@ -9,6 +9,13 @@
}
}
+ void promoteNullable(T? t) {
+ T? s;
+ if (t is int) {
+ s = /*T & int*/ t;
+ }
+ }
+
void doesNotPromote(T t) {
if (t is String) {
t;
@@ -39,3 +46,11 @@
}
}
}
+
+class F<S, T extends S> {
+ void nonNull(T t) {
+ if (t != null) {
+ /*T & S*/ t;
+ }
+ }
+}
diff --git a/pkg/_fe_analyzer_shared/tool/smoke_test_quick.dart b/pkg/_fe_analyzer_shared/tool/smoke_test_quick.dart
new file mode 100644
index 0000000..14c65da
--- /dev/null
+++ b/pkg/_fe_analyzer_shared/tool/smoke_test_quick.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2019, 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.
+
+import 'dart:io';
+
+final String repoDir = _computeRepoDir();
+
+String get dartVm => Platform.executable;
+
+main(List<String> args) async {
+ Stopwatch stopwatch = new Stopwatch()..start();
+ List<Future> futures = new List<Future>();
+ futures.add(run("pkg/front_end/test/spelling_test_src_suite.dart",
+ ["--", "spelling_test_src/_fe_analyzer_shared/..."]));
+ await Future.wait(futures);
+ print("\n-----------------------\n");
+ print("Done with exitcode $exitCode in ${stopwatch.elapsedMilliseconds} ms");
+}
+
+Future<void> run(String script, List<String> scriptArguments,
+ {bool filter: true}) async {
+ List<String> arguments = [];
+ arguments.add("$script");
+ arguments.addAll(scriptArguments);
+
+ Stopwatch stopwatch = new Stopwatch()..start();
+ ProcessResult result =
+ await Process.run(dartVm, arguments, workingDirectory: repoDir);
+ String runWhat = "${dartVm} ${arguments.join(' ')}";
+ if (result.exitCode != 0) {
+ exitCode = result.exitCode;
+ print("-----");
+ print("Running: $runWhat: "
+ "Failed with exit code ${result.exitCode} "
+ "in ${stopwatch.elapsedMilliseconds} ms.");
+ String stdout = result.stdout.toString();
+ if (filter) {
+ List<String> lines = stdout.split("\n");
+ int lastIgnored = -1;
+ for (int i = 0; i < lines.length; i++) {
+ if (lines[i].startsWith("[ ")) lastIgnored = i;
+ }
+ lines.removeRange(0, lastIgnored + 1);
+ stdout = lines.join("\n");
+ }
+ stdout = stdout.trim();
+ if (stdout.isNotEmpty) {
+ print(stdout);
+ print("-----");
+ }
+ } else {
+ print("Running: $runWhat: Done in ${stopwatch.elapsedMilliseconds} ms.");
+ }
+}
+
+String _computeRepoDir() {
+ ProcessResult result = Process.runSync(
+ 'git', ['rev-parse', '--show-toplevel'],
+ runInShell: true,
+ workingDirectory: new File.fromUri(Platform.script).parent.path);
+ return (result.stdout as String).trim();
+}
diff --git a/pkg/analysis_server/benchmark/perf/memory_tests.dart b/pkg/analysis_server/benchmark/perf/memory_tests.dart
index 84385b6..998f7b2 100644
--- a/pkg/analysis_server/benchmark/perf/memory_tests.dart
+++ b/pkg/analysis_server/benchmark/perf/memory_tests.dart
@@ -3,10 +3,10 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
+import 'dart:convert' show jsonDecode, jsonEncode;
import 'dart:io';
import 'package:analysis_server/protocol/protocol_generated.dart';
-import 'package:analysis_server/src/status/diagnostics.dart';
import 'package:test/test.dart';
import '../../test/integration/support/integration_tests.dart';
@@ -97,3 +97,49 @@
}
}
}
+
+class ServiceProtocol {
+ final WebSocket socket;
+
+ int _id = 0;
+ final Map<String, Completer<Map>> _completers = {};
+
+ ServiceProtocol._(this.socket) {
+ socket.listen(_handleMessage);
+ }
+
+ Future<Map> call(String method, [Map args]) {
+ String id = '${++_id}';
+ Completer<Map> completer = new Completer();
+ _completers[id] = completer;
+ Map m = {'id': id, 'method': method};
+ if (args != null) m['params'] = args;
+ String message = jsonEncode(m);
+ socket.add(message);
+ return completer.future;
+ }
+
+ Future dispose() => socket.close();
+
+ void _handleMessage(dynamic message) {
+ if (message is! String) {
+ return;
+ }
+
+ try {
+ dynamic json = jsonDecode(message);
+ if (json.containsKey('id')) {
+ dynamic id = json['id'];
+ _completers[id]?.complete(json['result']);
+ _completers.remove(id);
+ }
+ } catch (e) {
+ // ignore
+ }
+ }
+
+ static Future<ServiceProtocol> connect(Uri uri) async {
+ WebSocket socket = await WebSocket.connect(uri.toString());
+ return new ServiceProtocol._(socket);
+ }
+}
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 1c6f2de..e704c30 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -356,7 +356,7 @@
});
}, onError: (exception, stackTrace) {
AnalysisEngine.instance.instrumentationService.logException(
- FatalException('Failed to handle request: ${request.toJson()}',
+ FatalException('Failed to handle request: ${request.method}',
exception, stackTrace));
});
}
@@ -416,26 +416,20 @@
/*StackTrace*/ stackTrace, {
bool fatal = false,
}) {
- StringBuffer buffer = new StringBuffer();
- buffer.write(exception ?? 'null exception');
- if (stackTrace != null) {
- buffer.writeln();
- buffer.write(stackTrace);
- } else if (exception is! CaughtException) {
+ String msg = exception == null ? message : '$message: $exception';
+ if (stackTrace != null && exception is! CaughtException) {
stackTrace = StackTrace.current;
- buffer.writeln();
- buffer.write(stackTrace);
}
// send the notification
channel.sendNotification(
- new ServerErrorParams(fatal, message, buffer.toString())
- .toNotification());
+ new ServerErrorParams(fatal, msg, '$stackTrace').toNotification());
// remember the last few exceptions
if (exception is CaughtException) {
stackTrace ??= exception.stackTrace;
}
+
exceptions.add(new ServerException(
message,
exception,
diff --git a/pkg/analysis_server/lib/src/domain_completion.dart b/pkg/analysis_server/lib/src/domain_completion.dart
index 258e444..8a94e68 100644
--- a/pkg/analysis_server/lib/src/domain_completion.dart
+++ b/pkg/analysis_server/lib/src/domain_completion.dart
@@ -258,7 +258,7 @@
}, onError: (exception, stackTrace) {
AnalysisEngine.instance.instrumentationService.logException(
CaughtException.withMessage(
- 'Failed to handle completion domain request: ${request.toJson()}',
+ 'Failed to handle completion domain request: ${request.method}',
exception,
stackTrace));
});
diff --git a/pkg/analysis_server/lib/src/edit/nnbd_migration/info_builder.dart b/pkg/analysis_server/lib/src/edit/nnbd_migration/info_builder.dart
index 611c890..f1945c4 100644
--- a/pkg/analysis_server/lib/src/edit/nnbd_migration/info_builder.dart
+++ b/pkg/analysis_server/lib/src/edit/nnbd_migration/info_builder.dart
@@ -111,8 +111,8 @@
return edges;
}
- /// Return detail text for a fix built from an edge with [node] as a
- /// destination.
+ /// Return detail text for a fix built from an edge with origin info [origin]
+ /// and [fixKind].
String _baseDescriptionForOrigin(
EdgeOriginInfo origin, NullabilityFixKind fixKind) {
AstNode node = origin.node;
@@ -160,12 +160,7 @@
CompilationUnit unit = node.thisOrAncestorOfType<CompilationUnit>();
int lineNumber = unit.lineInfo.getLocation(node.offset).lineNumber;
- if (origin.kind == EdgeOriginKind.parameterInheritance) {
- return "The corresponding parameter in the overridden method is "
- "nullable";
- } else if (origin.kind == EdgeOriginKind.returnTypeInheritance) {
- return "An overridding method has a nullable return value";
- } else if (origin.kind == EdgeOriginKind.uninitializedRead) {
+ if (origin.kind == EdgeOriginKind.uninitializedRead) {
return "Used on line $lineNumber, when it is possibly uninitialized";
}
@@ -260,6 +255,7 @@
EdgeOriginInfo origin, EdgeInfo edge, NullabilityFixKind fixKind) {
AstNode node = origin.node;
NavigationTarget target;
+
// Some nodes don't need a target; default formal parameters
// without explicit default values, for example.
if (node is DefaultFormalParameter && node.defaultValue == null) {
@@ -276,6 +272,9 @@
CompilationUnit unit = type.thisOrAncestorOfType<CompilationUnit>();
target = _targetForNode(unit.declaredElement.source.fullName, type);
}
+ String description =
+ _buildInheritanceDescriptionForOrigin(origin, type);
+ return RegionDetail(description, target);
} else {
target = _targetForNode(origin.source.fullName, node);
}
@@ -283,6 +282,30 @@
return RegionDetail(_buildDescriptionForOrigin(origin, fixKind), target);
}
+ String _buildInheritanceDescriptionForOrigin(
+ EdgeOriginInfo origin, TypeAnnotation type) {
+ if (origin.kind == EdgeOriginKind.parameterInheritance) {
+ String overriddenName = "the overridden method";
+ if (type != null && type.parent is FormalParameter) {
+ FormalParameter parameter = type.parent;
+ if (parameter.parent is DefaultFormalParameter) {
+ parameter = parameter.parent;
+ }
+ if (parameter.parent is FormalParameterList &&
+ parameter.parent.parent is MethodDeclaration) {
+ MethodDeclaration method = parameter.parent.parent;
+ String methodName = method.name.name;
+ ClassOrMixinDeclaration cls = method.parent;
+ String className = cls.name.name;
+ overriddenName += ", $className.$methodName,";
+ }
+ }
+ return "The corresponding parameter in $overriddenName is nullable";
+ } else {
+ return "An overridding method has a nullable return value";
+ }
+ }
+
/// Compute the details for the fix with the given [fixInfo].
List<RegionDetail> _computeDetails(FixInfo fixInfo) {
List<RegionDetail> details = [];
@@ -329,7 +352,8 @@
if (destination != info.never && destination != info.always) {
target = _targetForNode(nodeInfo.filePath, nodeInfo.astNode);
}
- details.add(RegionDetail(nodeInfo.descriptionForDestination, target));
+ EdgeOriginInfo edge = info.edgeOrigin[reason];
+ details.add(RegionDetail(_describeNonNullEdge(edge), target));
} else {
details.add(RegionDetail('node with no info ($destination)', null));
}
@@ -411,6 +435,23 @@
return details;
}
+ /// Describe why an edge may have gotten a '!'.
+ String _describeNonNullEdge(EdgeOriginInfo edge) {
+ // TODO(mfairhurst/paulberry): Do NOT use astNode/parent to create this
+ // description, as we are just duplicating work if we do so.
+ final astNode = edge.node;
+ final parent = astNode.parent;
+ if (parent is PropertyAccess && parent.target == astNode ||
+ parent is PrefixedIdentifier && parent.prefix == astNode) {
+ return "This value must be null-checked before accessing its properties.";
+ }
+ if (parent is MethodInvocation && parent.target == astNode) {
+ return "This value must be null-checked before calling its methods.";
+ }
+
+ return "This value must be null-checked before use here.";
+ }
+
/// Explain the type annotations that were not changed because they were
/// determined to be non-nullable.
void _explainNonNullableTypes(SourceInformation sourceInfo,
diff --git a/pkg/analysis_server/lib/src/edit/nnbd_migration/instrumentation_renderer.dart b/pkg/analysis_server/lib/src/edit/nnbd_migration/instrumentation_renderer.dart
index e3070f9..bb98968 100644
--- a/pkg/analysis_server/lib/src/edit/nnbd_migration/instrumentation_renderer.dart
+++ b/pkg/analysis_server/lib/src/edit/nnbd_migration/instrumentation_renderer.dart
@@ -53,18 +53,19 @@
</script>
<link rel="stylesheet" href="{{ highlightStylePath }}">
<style>
-a:link {
+.code a:link {
color: inherit;
text-decoration-line: none;
}
-a:visited {
+.code a:visited {
color: inherit;
text-decoration-line: none;
}
-a:hover {
+.code a:hover {
text-decoration-line: underline;
+ font-weight: bold;
}
body {
@@ -188,6 +189,16 @@
visibility: visible;
}
+.region .tooltip::after {
+ /* Make a larger hover target once the tooltip appears. */
+ content: '';
+ position: absolute;
+ top: -1em;
+ height: 2em;
+ left: -1ch;
+ width: 3ch;
+}
+
.selectedFile {
font-weight: bold;
}
@@ -501,7 +512,7 @@
}
// Files that aren't within the [includedRoot] are written to the top-level
// of the output directory, next to the Javascript file.
- return 'highlight.pack.js';
+ return pathContext.join('..', 'highlight.pack.js');
}
/// The path to the highlight.js stylesheet, relative to [unitInfo].
@@ -513,7 +524,7 @@
}
// Files that aren't within the [includedRoot] are written to the top-level
// of the output directory, next to the CSS file.
- return 'androidstudio.css';
+ return pathContext.join('..', 'androidstudio.css');
}
/// Generate mustache context for unit links, for navigation in the
diff --git a/pkg/analysis_server/lib/src/edit/nnbd_migration/path_mapper.dart b/pkg/analysis_server/lib/src/edit/nnbd_migration/path_mapper.dart
index f6939c0..111a95c 100644
--- a/pkg/analysis_server/lib/src/edit/nnbd_migration/path_mapper.dart
+++ b/pkg/analysis_server/lib/src/edit/nnbd_migration/path_mapper.dart
@@ -48,6 +48,6 @@
// a more readable URI. For example, have other packages and the sdk be
// parallel to the directory containing the files for the library being
// migrated.
- return context.join(outputFolder, 'f${nextIndex++}.html');
+ return context.join(outputFolder, 'aux', 'f${nextIndex++}.html');
}
}
diff --git a/pkg/analysis_server/lib/src/lsp/mapping.dart b/pkg/analysis_server/lib/src/lsp/mapping.dart
index eea32fe..cf8ae51 100644
--- a/pkg/analysis_server/lib/src/lsp/mapping.dart
+++ b/pkg/analysis_server/lib/src/lsp/mapping.dart
@@ -47,6 +47,34 @@
_asMarkup(preferredFormats, content));
}
+/// Builds an LSP snippet string that uses a $1 tabstop to set the selected text
+/// after insertion.
+String buildSnippetStringWithSelection(
+ String text,
+ int selectionOffset,
+ int selectionLength,
+) {
+ String escape(String input) => input.replaceAllMapped(
+ RegExp(r'[$}\\]'), // Replace any of $ } \
+ (c) => '\\${c[0]}', // Prefix with a backslash
+ );
+ // Snippets syntax is documented in the LSP spec:
+ // https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#snippet-syntax
+ //
+ // $1, $2, etc. are used for tab stops and ${1:foo} inserts a placeholder of foo.
+ // Since we only need to support a single tab stop, our string is constructed of three parts:
+ // - Anything before the selection
+ // - The selection (which may or may not include text, depending on selectionLength)
+ // - Anything after the selection
+ final prefix = escape(text.substring(0, selectionOffset));
+ final selectionText = escape(
+ text.substring(selectionOffset, selectionOffset + selectionLength));
+ final selection = '\${1:$selectionText}';
+ final suffix = escape(text.substring(selectionOffset + selectionLength));
+
+ return '$prefix$selection$suffix';
+}
+
/// Note: This code will fetch the version of each document being modified so
/// it's important to call this immediately after computing edits to ensure
/// the document is not modified before the version number is read.
@@ -576,31 +604,30 @@
// Build display labels and text to insert. insertText and filterText may
// differ from label (for ex. if the label includes things like (…)). If
// either are missing then label will be used by the client.
- String label;
- String insertText;
- String filterText;
- if (suggestion.displayText != null) {
- label = suggestion.displayText;
- insertText = suggestion.completion;
- } else {
+ String label = suggestion.displayText ?? suggestion.completion;
+ String insertText = suggestion.completion;
+ String filterText = suggestion.completion;
+
+ // Trim any trailing comma from the (displayed) label.
+ if (label.endsWith(',')) {
+ label = label.substring(0, label.length - 1);
+ }
+
+ if (suggestion.displayText == null) {
switch (suggestion.element?.kind) {
case server.ElementKind.CONSTRUCTOR:
case server.ElementKind.FUNCTION:
case server.ElementKind.METHOD:
- label = suggestion.completion;
- // Label is the insert text plus the parens to indicate it's callable.
- insertText = label;
- filterText = label;
label += suggestion.parameterNames?.isNotEmpty ?? false ? '(…)' : '()';
break;
- default:
- label = suggestion.completion;
}
}
final useDeprecated =
completionCapabilities?.completionItem?.deprecatedSupport == true;
final formats = completionCapabilities?.completionItem?.documentationFormat;
+ final supportsSnippets =
+ completionCapabilities?.completionItem?.snippetSupport == true;
final completionKind = suggestion.element != null
? elementKindToCompletionItemKind(
@@ -608,6 +635,16 @@
: suggestionKindToCompletionItemKind(
supportedCompletionItemKinds, suggestion.kind, label);
+ lsp.InsertTextFormat insertTextFormat = lsp.InsertTextFormat.PlainText;
+ if (supportsSnippets && suggestion.selectionOffset != 0) {
+ insertTextFormat = lsp.InsertTextFormat.Snippet;
+ insertText = buildSnippetStringWithSelection(
+ suggestion.completion,
+ suggestion.selectionOffset,
+ suggestion.selectionLength,
+ );
+ }
+
// Because we potentially send thousands of these items, we should minimise
// the generated JSON as much as possible - for example using nulls in place
// of empty lists/false where possible.
@@ -626,12 +663,12 @@
(1000000 - suggestion.relevance).toString(),
filterText != label ? filterText : null, // filterText uses label if not set
insertText != label ? insertText : null, // insertText uses label if not set
- null, // insertTextFormat (we always use plain text so can ommit this)
+ insertTextFormat != lsp.InsertTextFormat.PlainText
+ ? insertTextFormat
+ : null, // Defaults to PlainText if not supplied
new lsp.TextEdit(
- // TODO(dantup): If `clientSupportsSnippets == true` then we should map
- // `selection` in to a snippet (see how Dart Code does this).
toRange(lineInfo, replacementOffset, replacementLength),
- suggestion.completion,
+ insertText,
),
null, // additionalTextEdits, used for adding imports, etc.
null, // commitCharacters
diff --git a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
index de2cccf..a038870 100644
--- a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
+++ b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
@@ -13,6 +13,7 @@
import 'package:analyzer/instrumentation/instrumentation.dart';
import 'package:analyzer/src/context/context_root.dart' as analyzer;
import 'package:analyzer/src/generated/source.dart';
+import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/util/glob.dart';
import 'package:analyzer/src/workspace/bazel.dart';
import 'package:analyzer/src/workspace/gn.dart';
@@ -438,7 +439,11 @@
Map<PluginInfo, Future<Response>> responseMap =
<PluginInfo, Future<Response>>{};
for (PluginInfo plugin in plugins) {
- responseMap[plugin] = plugin.currentSession?.sendRequest(params);
+ final request = plugin.currentSession?.sendRequest(params);
+ // Only add an entry to the map if we have sent a request.
+ if (request != null) {
+ responseMap[plugin] = request;
+ }
}
return responseMap;
}
@@ -675,7 +680,13 @@
* Stop all of the plugins that are currently running.
*/
Future<List<void>> stopAll() {
- return Future.wait(_pluginMap.values.map((PluginInfo info) => info.stop()));
+ return Future.wait(_pluginMap.values.map((PluginInfo info) async {
+ try {
+ await info.stop();
+ } catch (e, st) {
+ AnalysisEngine.instance.instrumentationService.logException(e, st);
+ }
+ }));
}
/**
diff --git a/pkg/analysis_server/lib/src/server/crash_reporting.dart b/pkg/analysis_server/lib/src/server/crash_reporting.dart
index 44e4c66..0aa3d73 100644
--- a/pkg/analysis_server/lib/src/server/crash_reporting.dart
+++ b/pkg/analysis_server/lib/src/server/crash_reporting.dart
@@ -16,24 +16,32 @@
void logException(dynamic exception, [StackTrace stackTrace]) {
if (exception is CaughtException) {
// Get the root CaughtException, which matters most for debugging.
- exception = exception.rootCaughtException;
- // Report the root exception stack trace.
- stackTrace = exception.stackTrace;
- // Report the dynamic exception object that the CaughtException holds.
- exception = exception.exception;
+ CaughtException root = exception.rootCaughtException;
+
+ reporter
+ .sendReport(root.exception, root.stackTrace, comment: root.message)
+ .catchError((error) {
+ // We silently ignore errors sending crash reports (network issues, ...).
+ });
+ } else {
+ reporter
+ .sendReport(exception, stackTrace ?? StackTrace.current)
+ .catchError((error) {
+ // We silently ignore errors sending crash reports (network issues, ...).
+ });
}
- reporter
- .sendReport(exception, stackTrace: stackTrace ?? StackTrace.current)
- .catchError((error) {
- // We silently ignore errors sending crash reports (network issues, ...).
- });
}
@override
void logPluginException(
- PluginData plugin, dynamic exception, StackTrace stackTrace) {
- // TODO(mfairhurst): send plugin information too.
- reporter.sendReport(exception, stackTrace: stackTrace).catchError((error) {
+ PluginData plugin,
+ dynamic exception,
+ StackTrace stackTrace,
+ ) {
+ String comment = 'plugin: ${plugin.name}';
+ reporter
+ .sendReport(exception, stackTrace, comment: comment)
+ .catchError((error) {
// We silently ignore errors sending crash reports (network issues, ...).
});
}
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
index 11b9e48..9a8a9f6 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
@@ -76,11 +76,20 @@
/// relevance than other included suggestions.
final List<IncludedSuggestionRelevanceTag> includedSuggestionRelevanceTags;
+ /// Initialize a newly created completion manager. The parameters
+ /// [includedElementKinds], [includedElementNames], and
+ /// [includedSuggestionRelevanceTags] must either all be `null` or must all be
+ /// non-`null`.
DartCompletionManager({
this.includedElementKinds,
this.includedElementNames,
this.includedSuggestionRelevanceTags,
- });
+ }) : assert((includedElementKinds != null &&
+ includedElementNames != null &&
+ includedSuggestionRelevanceTags != null) ||
+ (includedElementKinds == null &&
+ includedElementNames == null &&
+ includedSuggestionRelevanceTags == null));
@override
Future<List<CompletionSuggestion>> computeSuggestions(
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/completion_ranking.dart b/pkg/analysis_server/lib/src/services/completion/dart/completion_ranking.dart
index 7a41cc9..242e229 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/completion_ranking.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/completion_ranking.dart
@@ -13,17 +13,17 @@
import 'package:analysis_server/src/services/completion/dart/language_model.dart';
import 'package:analyzer/dart/analysis/features.dart';
+/// Number of code completion isolates.
+// TODO(devoncarew): We need to explore the memory costs of running multiple ML
+// isolates.
+const int _ISOLATE_COUNT = 2;
+
/// Number of lookback tokens.
const int _LOOKBACK = 100;
/// Minimum probability to prioritize model-only suggestion.
const double _MODEL_RELEVANCE_CUTOFF = 0.5;
-// TODO(devoncarew): We need to explore the memory costs of running multiple ML
-// isolates.
-/// Number of code completion isolates.
-const int _ISOLATE_COUNT = 2;
-
/// Prediction service run by the model isolate.
void entrypoint(SendPort sendPort) {
LanguageModel model;
@@ -62,17 +62,31 @@
CompletionRanking(this._directory);
- /// Send an RPC to the isolate worker and wait for it to respond.
- Future<Map<String, Map<String, double>>> makeRequest(
- String method, List<String> args) async {
- final port = ReceivePort();
- _writes[_index].send({
- 'method': method,
+ /// Send an RPC to the isolate worker requesting that it load the model and
+ /// wait for it to respond.
+ Future<Map<String, Map<String, double>>> makeLoadRequest(
+ SendPort sendPort, List<String> args) async {
+ final receivePort = ReceivePort();
+ sendPort.send({
+ 'method': 'load',
'args': args,
- 'port': port.sendPort,
+ 'port': receivePort.sendPort,
});
- this._index = (_index + 1) % _ISOLATE_COUNT;
- return await port.first;
+ return await receivePort.first;
+ }
+
+ /// Send an RPC to the isolate worker requesting that it make a prediction and
+ /// wait for it to respond.
+ Future<Map<String, Map<String, double>>> makePredictRequest(
+ List<String> args) async {
+ final receivePort = ReceivePort();
+ _writes[_index].send({
+ 'method': 'predict',
+ 'args': args,
+ 'port': receivePort.sendPort,
+ });
+ _index = (_index + 1) % _writes.length;
+ return await receivePort.first;
}
/// Makes a next-token prediction starting at the completion request cursor
@@ -88,7 +102,7 @@
performanceMetrics._incrementPredictionRequestCount();
final Stopwatch timer = Stopwatch()..start();
- final response = await makeRequest('predict', query);
+ final response = await makePredictRequest(query);
timer.stop();
final Map<String, double> result = response['data'];
@@ -113,6 +127,10 @@
List<IncludedSuggestionRelevanceTag> includedSuggestionRelevanceTags,
DartCompletionRequest request,
FeatureSet featureSet) async {
+ assert((includedElementNames != null &&
+ includedSuggestionRelevanceTags != null) ||
+ (includedElementNames == null &&
+ includedSuggestionRelevanceTags == null));
final probability = await probabilityFuture
.timeout(const Duration(seconds: 1), onTimeout: () => null);
if (probability == null || probability.isEmpty) {
@@ -153,13 +171,14 @@
var allowModelOnlySuggestions =
!testNamedArgument(suggestions) && !testFollowingDot(request);
- entries.forEach((MapEntry entry) {
+ for (MapEntry entry in entries) {
// There may be multiple like
// CompletionSuggestion and CompletionSuggestion().
final completionSuggestions = suggestions.where((suggestion) =>
areCompletionsEquivalent(suggestion.completion, entry.key));
List<IncludedSuggestionRelevanceTag> includedSuggestions;
- final isIncludedElementName = includedElementNames.contains(entry.key);
+ final isIncludedElementName = includedElementNames != null &&
+ includedElementNames.contains(entry.key);
if (includedSuggestionRelevanceTags != null) {
includedSuggestions = includedSuggestionRelevanceTags
.where((tag) => areCompletionsEquivalent(
@@ -211,15 +230,14 @@
.add(IncludedSuggestionRelevanceTag(entry.key, relevance));
}
}
- });
-
+ }
return suggestions;
}
/// Spin up the model isolates and load the tflite model.
Future<void> start() async {
- this._writes = [];
- this._index = 0;
+ _writes = [];
+ _index = 0;
final initializations = <Future<void>>[];
// Start the first isolate.
@@ -237,10 +255,11 @@
final Stopwatch timer = Stopwatch()..start();
final port = ReceivePort();
await Isolate.spawn(entrypoint, port.sendPort);
- this._writes.add(await port.first);
- return makeRequest('load', [_directory]).whenComplete(() {
+ SendPort sendPort = await port.first;
+ return makeLoadRequest(sendPort, [_directory]).whenComplete(() {
timer.stop();
performanceMetrics._isolateInitTimes.add(timer.elapsed);
+ _writes.add(sendPort);
});
}
}
@@ -256,12 +275,12 @@
List<Duration> get isolateInitTimes => _isolateInitTimes;
- /// An iterable of the last `n` prediction results;
- Iterable<PredictionResult> get predictionResults => _predictionResults;
-
/// The total prediction requests to ML Complete.
int get predictionRequestCount => _predictionRequestCount;
+ /// An iterable of the last `n` prediction results;
+ Iterable<PredictionResult> get predictionResults => _predictionResults;
+
void _addPredictionResult(PredictionResult request) {
_predictionResults.addFirst(request);
if (_predictionResults.length > _maxResultBuffer) {
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/extension_member_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/extension_member_contributor.dart
index 4b21997..7c2f8d7 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/extension_member_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/extension_member_contributor.dart
@@ -65,8 +65,8 @@
}
LibraryScope nameScope = new LibraryScope(containingLibrary);
for (var extension in nameScope.extensions) {
- var typeSystem = containingLibrary.context.typeSystem;
- var typeProvider = containingLibrary.context.typeProvider;
+ var typeSystem = containingLibrary.typeSystem;
+ var typeProvider = containingLibrary.typeProvider;
var extendedType =
_resolveExtendedType(typeSystem, typeProvider, extension, type);
if (extendedType != null &&
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart
index 4332192..e25ee62 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_constructor_contributor.dart
@@ -168,7 +168,7 @@
var typeParameters = element.typeParameters;
var typeArguments = const <DartType>[];
if (typeParameters.isNotEmpty) {
- var typeProvider = request.libraryElement.context.typeProvider;
+ var typeProvider = request.libraryElement.typeProvider;
typeArguments = typeParameters.map((t) {
return typeProvider.dynamicType;
}).toList();
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
index 0aeeb94..1fdf88a 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
@@ -194,7 +194,7 @@
var typeParameters = element.typeParameters;
var typeArguments = const <DartType>[];
if (typeParameters.isNotEmpty) {
- var typeProvider = request.libraryElement.context.typeProvider;
+ var typeProvider = request.libraryElement.typeProvider;
typeArguments = typeParameters.map((t) {
return typeProvider.dynamicType;
}).toList();
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
index c1b1a69..c7cc319 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
@@ -118,7 +118,7 @@
List<CompletionSuggestion> get suggestions => suggestionMap.values.toList();
- TypeProvider get typeProvider => request.libraryElement.context.typeProvider;
+ TypeProvider get typeProvider => request.libraryElement.typeProvider;
@override
void declaredClass(ClassDeclaration declaration) {
diff --git a/pkg/analysis_server/lib/src/services/correction/base_processor.dart b/pkg/analysis_server/lib/src/services/correction/base_processor.dart
index 5fcfaf4..187d744 100644
--- a/pkg/analysis_server/lib/src/services/correction/base_processor.dart
+++ b/pkg/analysis_server/lib/src/services/correction/base_processor.dart
@@ -1094,8 +1094,28 @@
VariableDeclarationList declarationList =
node.thisOrAncestorOfType<VariableDeclarationList>();
if (declarationList == null) {
- _coverageMarker();
- return null;
+ DeclaredIdentifier declaration = node.thisOrAncestorOfType();
+ if (declaration == null) {
+ _coverageMarker();
+ return null;
+ }
+ TypeAnnotation typeNode = declaration.type;
+ if (typeNode == null) {
+ _coverageMarker();
+ return null;
+ }
+ Token keyword = declaration.keyword;
+ var variableName = declaration.identifier;
+ var changeBuilder = _newDartChangeBuilder();
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
+ SourceRange typeRange = range.startStart(typeNode, variableName);
+ if (keyword != null && keyword.lexeme != 'var') {
+ builder.addSimpleReplacement(typeRange, '');
+ } else {
+ builder.addSimpleReplacement(typeRange, 'var ');
+ }
+ });
+ return changeBuilder;
}
// we need a type
TypeAnnotation typeNode = declarationList.type;
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index b2f83d2..ea103cd 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -2168,6 +2168,9 @@
// prepare target declaration
var targetDeclarationResult =
await sessionHelper.getElementDeclaration(targetElement);
+ if (targetDeclarationResult == null) {
+ return;
+ }
if (targetDeclarationResult.node is! ClassOrMixinDeclaration &&
targetDeclarationResult.node is! ExtensionDeclaration) {
return;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
index dc4ebf4..f873558 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart
@@ -758,7 +758,7 @@
}
// maybe ends with "return" statement
if (_selectionStatements != null) {
- TypeSystem typeSystem = await resolveResult.session.typeSystem;
+ TypeSystem typeSystem = await resolveResult.typeSystem;
_ReturnTypeComputer returnTypeComputer =
new _ReturnTypeComputer(typeSystem);
_selectionStatements.forEach((statement) {
@@ -799,7 +799,7 @@
Future<void> _initializeReturnType() async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
- TypeProvider typeProvider = await resolveResult.session.typeProvider;
+ TypeProvider typeProvider = await resolveResult.typeProvider;
if (_selectionFunctionExpression != null) {
variableType = '';
returnType = '';
diff --git a/pkg/analysis_server/lib/src/status/diagnostics.dart b/pkg/analysis_server/lib/src/status/diagnostics.dart
index 938cb49..d61a7cf 100644
--- a/pkg/analysis_server/lib/src/status/diagnostics.dart
+++ b/pkg/analysis_server/lib/src/status/diagnostics.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
-import 'dart:convert';
import 'dart:developer' as developer;
import 'dart:io';
@@ -1123,39 +1122,16 @@
if (serviceProtocolInfo.serverUri == null) {
p('Service protocol not enabled.');
} else {
- p(serviceProtocolInfo.toString());
-
- // http://127.0.0.1:8181/ ==> ws://127.0.0.1:8181/ws
- Uri uri = serviceProtocolInfo.serverUri;
- uri = uri.replace(scheme: 'ws', path: 'ws');
-
- final ServiceProtocol service = await ServiceProtocol.connect(uri);
- final Map vm = await service.call('getVM');
-
- h3('Isolates');
-
- List isolateRefs = vm['isolates'];
- for (Map isolateRef in isolateRefs) {
- Map isolate =
- await service.call('getIsolate', {'isolateId': isolateRef['id']});
-
- Map _heaps = isolate['_heaps'];
-
- int used = 0;
- used = _heaps['new']['used'] + _heaps['new']['external'];
- used = _heaps['old']['used'] + _heaps['old']['external'];
- double usedMB = used / (1024.0 * 1024.0);
-
- int capacity = 0;
- capacity = _heaps['new']['capacity'] + _heaps['new']['external'];
- capacity = _heaps['old']['capacity'] + _heaps['old']['external'];
- double capacityMB = capacity / (1024.0 * 1024.0);
-
- buf.writeln(writeOption(isolate['name'],
- '${usedMB.round()} MB of ${capacityMB.round()} MB'));
- }
-
- service.dispose();
+ buf.writeln(writeOption('Service protocol connection available at',
+ '${serviceProtocolInfo.serverUri}'));
+ buf.writeln('<br>');
+ p(
+ 'To get detailed performance data on the analysis server, we '
+ 'recommend using Dart DevTools. For instructions on installing and '
+ 'using DevTools, see '
+ '<a href="https://dart.dev/tools/dart-devtools">dart.dev/tools/dart-devtools</a>.',
+ raw: true,
+ );
}
} else {
p('Error retrieving the memory and cpu usage information.');
@@ -1351,52 +1327,6 @@
}
}
-class ServiceProtocol {
- final WebSocket socket;
-
- int _id = 0;
- final Map<String, Completer<Map>> _completers = {};
-
- ServiceProtocol._(this.socket) {
- socket.listen(_handleMessage);
- }
-
- Future<Map> call(String method, [Map args]) {
- String id = '${++_id}';
- Completer<Map> completer = new Completer();
- _completers[id] = completer;
- Map m = {'id': id, 'method': method};
- if (args != null) m['params'] = args;
- String message = jsonEncode(m);
- socket.add(message);
- return completer.future;
- }
-
- Future dispose() => socket.close();
-
- void _handleMessage(dynamic message) {
- if (message is! String) {
- return;
- }
-
- try {
- dynamic json = jsonDecode(message);
- if (json.containsKey('id')) {
- dynamic id = json['id'];
- _completers[id]?.complete(json['result']);
- _completers.remove(id);
- }
- } catch (e) {
- // ignore
- }
- }
-
- static Future<ServiceProtocol> connect(Uri uri) async {
- WebSocket socket = await WebSocket.connect(uri.toString());
- return new ServiceProtocol._(socket);
- }
-}
-
class StatusPage extends DiagnosticPageWithNav {
StatusPage(DiagnosticsSite site)
: super(site, 'status', 'Status',
diff --git a/pkg/analysis_server/test/analysis/get_hover_test.dart b/pkg/analysis_server/test/analysis/get_hover_test.dart
index b340cfe..e4ef005 100644
--- a/pkg/analysis_server/test/analysis/get_hover_test.dart
+++ b/pkg/analysis_server/test/analysis/get_hover_test.dart
@@ -54,7 +54,7 @@
expect(
hover.elementDescription,
'class B<T> extends A<T> with M1, M2<int> '
- 'implements I1<int, String>, I2');
+ 'implements I1<int, String>, I2<dynamic>');
expect(hover.staticType, isNull);
expect(hover.propagatedType, isNull);
}
diff --git a/pkg/analysis_server/test/domain_edit_dartfix_test.dart b/pkg/analysis_server/test/domain_edit_dartfix_test.dart
index 8360a1f..c3fa84f 100644
--- a/pkg/analysis_server/test/domain_edit_dartfix_test.dart
+++ b/pkg/analysis_server/test/domain_edit_dartfix_test.dart
@@ -190,9 +190,7 @@
''');
}
- @failingTest
test_dartfix_nonNullable() async {
- // Failing because this contains a side-cast from Null to int.
createAnalysisOptionsFile(experiments: ['non-nullable']);
addTestFile('''
int f(int i) => 0;
diff --git a/pkg/analysis_server/test/lsp/completion_test.dart b/pkg/analysis_server/test/lsp/completion_test.dart
index 83d63ff..9b1ad13 100644
--- a/pkg/analysis_server/test/lsp/completion_test.dart
+++ b/pkg/analysis_server/test/lsp/completion_test.dart
@@ -202,6 +202,50 @@
expect(item.detail, isNot(contains('deprecated')));
}
+ test_namedArg_plainText() async {
+ final content = '''
+ class A { const A({int one}); }
+ @A(^)
+ main() { }
+ ''';
+
+ await initialize();
+ await openFile(mainFileUri, withoutMarkers(content));
+ final res = await getCompletion(mainFileUri, positionFromMarker(content));
+ expect(res.any((c) => c.label == 'one: '), isTrue);
+ final item = res.singleWhere((c) => c.label == 'one: ');
+ expect(item.insertTextFormat,
+ anyOf(equals(InsertTextFormat.PlainText), isNull));
+ expect(item.insertText, anyOf(equals('test'), isNull));
+ final updated = applyTextEdits(withoutMarkers(content), [item.textEdit]);
+ expect(updated, contains('one: '));
+ }
+
+ test_namedArg_snippetStringSelection() async {
+ final content = '''
+ class A { const A({int one}); }
+ @A(^)
+ main() { }
+ ''';
+
+ await initialize(
+ textDocumentCapabilities: withCompletionItemSnippetSupport(
+ emptyTextDocumentClientCapabilities));
+ await openFile(mainFileUri, withoutMarkers(content));
+ final res = await getCompletion(mainFileUri, positionFromMarker(content));
+ expect(res.any((c) => c.label == 'one: '), isTrue);
+ final item = res.singleWhere((c) => c.label == 'one: ');
+ // Ensure the snippet comes through in the expected format with the expected
+ // placeholder.
+ expect(item.insertTextFormat, equals(InsertTextFormat.Snippet));
+ expect(item.insertText, equals(r'one: ${1:}'));
+ expect(item.textEdit.newText, equals(r'one: ${1:}'));
+ expect(
+ item.textEdit.range,
+ equals(Range(positionFromMarker(content), positionFromMarker(content))),
+ );
+ }
+
test_nonDartFile() async {
newFile(pubspecFilePath, content: simplePubspecContent);
await initialize();
diff --git a/pkg/analysis_server/test/lsp/mapping_test.dart b/pkg/analysis_server/test/lsp/mapping_test.dart
index d0d25b8..1cbb017 100644
--- a/pkg/analysis_server/test/lsp/mapping_test.dart
+++ b/pkg/analysis_server/test/lsp/mapping_test.dart
@@ -73,4 +73,19 @@
);
expect(result, isNull);
}
+
+ test_selectionsInSnippets_empty() async {
+ var result = lsp.buildSnippetStringWithSelection('teststring', 4, 0);
+ expect(result, equals(r'test${1:}string'));
+ }
+
+ test_selectionsInSnippets_escaping() async {
+ var result = lsp.buildSnippetStringWithSelection(r'te$tstri}ng', 4, 3);
+ expect(result, equals(r'te\$t${1:str}i\}ng'));
+ }
+
+ test_selectionsInSnippets_selection() async {
+ var result = lsp.buildSnippetStringWithSelection('teststring', 4, 3);
+ expect(result, equals(r'test${1:str}ing'));
+ }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_ranking_test.dart b/pkg/analysis_server/test/services/completion/dart/completion_ranking_test.dart
index a876f51..e1aa937 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_ranking_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_ranking_test.dart
@@ -19,7 +19,7 @@
test('make request to isolate', () async {
final tokens =
tokenize('if (list == null) { return; } for (final i = 0; i < list.');
- final response = await ranking.makeRequest('predict', tokens);
+ final response = await ranking.makePredictRequest(tokens);
expect(response['data']['length'], greaterThan(0.9));
});
}
diff --git a/pkg/analysis_server/test/src/edit/nnbd_migration/info_builder_test.dart b/pkg/analysis_server/test/src/edit/nnbd_migration/info_builder_test.dart
index 7b42502..8501d96 100644
--- a/pkg/analysis_server/test/src/edit/nnbd_migration/info_builder_test.dart
+++ b/pkg/analysis_server/test/src/edit/nnbd_migration/info_builder_test.dart
@@ -500,6 +500,37 @@
assertDetail(detail: regions[2].details[0], offset: 128, length: 1);
}
+ test_namedParameterWithDefault_fromOverridden_explicit() async {
+ UnitInfo unit = await buildInfoForSingleTestFile('''
+class A {
+ void m({int p = 0}) {}
+}
+class B extends A {
+ void m({num p = 0}) {}
+}
+void f(A a) {
+ a.m(p: null);
+}
+''', migratedContent: '''
+class A {
+ void m({int? p = 0}) {}
+}
+class B extends A {
+ void m({num? p = 0}) {}
+}
+void f(A a) {
+ a.m(p: null);
+}
+''');
+ List<RegionInfo> regions = unit.fixRegions;
+ expect(regions, hasLength(2));
+ // regions[0] is "an explicit null is passed..."
+ assertRegion(region: regions[1], offset: 71, details: [
+ "The corresponding parameter in the overridden method, A.m, is nullable"
+ ]);
+ assertDetail(detail: regions[1].details[0], offset: 20, length: 3);
+ }
+
test_nonNullableType_assert() async {
UnitInfo unit = await buildInfoForSingleTestFile('''
void f(String s) {
@@ -549,7 +580,33 @@
]);
}
- test_nullCheck_onFunctionArgument() async {
+ test_nullCheck_onMemberAccess() async {
+ UnitInfo unit = await buildInfoForSingleTestFile('''
+class C {
+ int value;
+ C([this.value]);
+ void f() {
+ value.sign;
+ }
+}
+''', migratedContent: '''
+class C {
+ int? value;
+ C([this.value]);
+ void f() {
+ value!.sign;
+ }
+}
+''');
+ List<RegionInfo> regions = unit.regions;
+ expect(regions, hasLength(2));
+ // regions[0] is `int?`.
+ assertRegion(region: regions[1], offset: 65, details: [
+ "This value must be null-checked before accessing its properties."
+ ]);
+ }
+
+ test_nullCheck_onMethodCall() async {
UnitInfo unit = await buildInfoForSingleTestFile('''
class C {
int value;
@@ -570,10 +627,9 @@
List<RegionInfo> regions = unit.regions;
expect(regions, hasLength(2));
// regions[0] is `int?`.
- assertRegion(
- region: regions[1],
- offset: 65,
- details: ["A nullable value can't be used here"]);
+ assertRegion(region: regions[1], offset: 65, details: [
+ "This value must be null-checked before calling its methods."
+ ]);
}
test_parameter_fromInvocation_explicit() async {
@@ -620,12 +676,15 @@
details: ["A nullable value is explicitly passed as an argument"]);
}
- test_parameter_fromOverriden_explicit() async {
+ test_parameter_fromMultipleOverridden_explicit() async {
UnitInfo unit = await buildInfoForSingleTestFile('''
class A {
void m(int p) {}
}
class B extends A {
+ void m(num p) {}
+}
+class C extends B {
void m(Object p) {}
}
void f(A a) {
@@ -636,6 +695,50 @@
void m(int? p) {}
}
class B extends A {
+ void m(num? p) {}
+}
+class C extends B {
+ void m(Object? p) {}
+}
+void f(A a) {
+ a.m(null);
+}
+''');
+ List<RegionInfo> regions = unit.fixRegions;
+ expect(regions, hasLength(3));
+ // regions[0] is "an explicit null is passed..."
+ assertRegion(region: regions[1], offset: 64, details: [
+ "The corresponding parameter in the overridden method, A.m, is nullable"
+ ]);
+ assertRegion(region: regions[2], offset: 109, details: [
+ "The corresponding parameter in the overridden method, B.m, is nullable"
+ ]);
+ assertDetail(detail: regions[1].details[0], offset: 19, length: 3);
+ assertDetail(detail: regions[2].details[0], offset: 60, length: 3);
+ }
+
+ test_parameter_fromMultipleOverridden_implicit() async {
+ UnitInfo unit = await buildInfoForSingleTestFile('''
+class A {
+ void m(int p) {}
+}
+class B extends A {
+ void m(p) {}
+}
+class C extends B {
+ void m(Object p) {}
+}
+void f(A a) {
+ a.m(null);
+}
+''', migratedContent: '''
+class A {
+ void m(int? p) {}
+}
+class B extends A {
+ void m(p) {}
+}
+class C extends B {
void m(Object? p) {}
}
void f(A a) {
@@ -644,17 +747,14 @@
''');
List<RegionInfo> regions = unit.fixRegions;
expect(regions, hasLength(2));
- assertRegion(
- region: regions[0],
- offset: 22,
- details: ["An explicit 'null' is passed as an argument"]);
- assertRegion(region: regions[1], offset: 67, details: [
+ // regions[0] is "an explicit null is passed..."
+ assertRegion(region: regions[1], offset: 104, details: [
"The corresponding parameter in the overridden method is nullable"
]);
}
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/39378')
- test_parameter_fromOverriden_implicit() async {
+ test_parameter_fromOverridden_implicit() async {
UnitInfo unit = await buildInfoForSingleTestFile('''
class A {
void m(p) {}
@@ -680,6 +780,37 @@
details: ["A nullable value is assigned"]);
}
+ @FailingTest(
+ reason: "Currently crashes with: Bad state: A decorated type for void "
+ "set m(int _m) should have been stored by the NodeBuilder via "
+ "recordDecoratedElementType")
+ test_parameter_fromOverriddenField_explicit() async {
+ await buildInfoForSingleTestFile('''
+class A {
+ int m;
+}
+class B extends A {
+ void set m(Object p) {}
+}
+void f(A a) {
+ a.m = null;
+}
+''', migratedContent: '''
+class A {
+ int? m;
+}
+class B extends A {
+ void set m(Object? p) {}
+}
+void f(A a) {
+ a.m = null;
+}
+''');
+ // TODO(srawlins): Write expectations similar to
+ // test_parameter_fromMultipleOverridden_explicit above, once the test stops
+ // crashing.
+ }
+
test_parameter_named_omittedInCall() async {
UnitInfo unit = await buildInfoForSingleTestFile('''
void f() { g(); }
diff --git a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
index 384cafc..f505673 100644
--- a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
+++ b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
@@ -295,6 +295,31 @@
@SkippedTest(
reason: 'flaky timeouts',
issue: 'https://github.com/dart-lang/sdk/issues/38629')
+ test_broadcastRequest_noCurrentSession() async {
+ io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1');
+ String pkgPath = pkg1Dir.resolveSymbolicLinksSync();
+ await withPlugin(
+ pluginName: 'plugin1',
+ content: '(invalid content here)',
+ test: (String plugin1Path) async {
+ ContextRoot contextRoot = _newContextRoot(pkgPath);
+ await manager.addPluginToContextRoot(contextRoot, plugin1Path);
+
+ Map<PluginInfo, Future<Response>> responses =
+ manager.broadcastRequest(
+ new CompletionGetSuggestionsParams(
+ '/pkg1/lib/pkg1.dart', 100),
+ contextRoot: contextRoot);
+ expect(responses, hasLength(0));
+
+ await manager.stopAll();
+ });
+ pkg1Dir.deleteSync(recursive: true);
+ }
+
+ @SkippedTest(
+ reason: 'flaky timeouts',
+ issue: 'https://github.com/dart-lang/sdk/issues/38629')
test_broadcastWatchEvent() async {
io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1');
String pkgPath = pkg1Dir.resolveSymbolicLinksSync();
diff --git a/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart b/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart
index 194ec58..e28cc89 100644
--- a/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart
+++ b/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart
@@ -8,6 +8,7 @@
import 'package:analysis_server/src/plugin/plugin_locator.dart';
import 'package:analysis_server/src/plugin/plugin_manager.dart';
import 'package:analysis_server/src/plugin/plugin_watcher.dart';
+import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/file_system/memory_file_system.dart';
@@ -143,6 +144,7 @@
'contextName',
sourceFactory,
new AnalysisOptionsImpl(),
+ DeclaredVariables(),
new Uint32List(0),
new Uint32List(0));
currentSession = new AnalysisSessionImpl(this);
diff --git a/pkg/analysis_server/test/src/services/correction/assist/remove_type_annotation_test.dart b/pkg/analysis_server/test/src/services/correction/assist/remove_type_annotation_test.dart
index f57eee3..869da1a 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/remove_type_annotation_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/remove_type_annotation_test.dart
@@ -54,24 +54,6 @@
await assertNoAssistAt('v;');
}
- test_localVariable_noInitializer() async {
- await resolveTestUnit('''
-main() {
- int v;
-}
-''');
- await assertNoAssistAt('v;');
- }
-
- test_localVariable_onInitializer() async {
- await resolveTestUnit('''
-main() {
- final int v = 1;
-}
-''');
- await assertNoAssistAt('1;');
- }
-
test_localVariable() async {
await resolveTestUnit('''
main() {
@@ -111,20 +93,44 @@
''');
}
- test_topLevelVariable_noInitializer() async {
- verifyNoTestUnitErrors = false;
+ test_localVariable_noInitializer() async {
await resolveTestUnit('''
-int v;
+main() {
+ int v;
+}
''');
await assertNoAssistAt('v;');
}
- test_topLevelVariable_syntheticName() async {
- verifyNoTestUnitErrors = false;
+ test_localVariable_onInitializer() async {
await resolveTestUnit('''
-MyType
+main() {
+ final int v = 1;
+}
''');
- await assertNoAssistAt('MyType');
+ await assertNoAssistAt('1;');
+ }
+
+ test_loopVariable() async {
+ await resolveTestUnit('''
+main() {
+ for(int i = 0; i < 3; i++) {}
+}
+''');
+ await assertHasAssistAt('int ', '''
+main() {
+ for(var i = 0; i < 3; i++) {}
+}
+''');
+ }
+
+ test_loopVariable_noType() async {
+ await resolveTestUnit('''
+main() {
+ for(var i = 0; i < 3; i++) {}
+}
+''');
+ await assertNoAssistAt('var ');
}
test_topLevelVariable() async {
@@ -144,4 +150,20 @@
final V = 1;
''');
}
+
+ test_topLevelVariable_noInitializer() async {
+ verifyNoTestUnitErrors = false;
+ await resolveTestUnit('''
+int v;
+''');
+ await assertNoAssistAt('v;');
+ }
+
+ test_topLevelVariable_syntheticName() async {
+ verifyNoTestUnitErrors = false;
+ await resolveTestUnit('''
+MyType
+''');
+ await assertNoAssistAt('MyType');
+ }
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart
index 7656709..20e87d0 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart
@@ -115,7 +115,7 @@
class Test extends IterableMixin<int> {
@override
// TODO: implement iterator
- Iterator<int> get iterator => null;
+ Iterator<int> get iterator => throw UnimplementedError();
}
''');
}
@@ -138,7 +138,7 @@
@override
List<V> getItems() {
// TODO: implement getItems
- return null;
+ throw UnimplementedError();
}
}
''');
@@ -163,11 +163,11 @@
class B extends A {
@override
// TODO: implement g1
- get g1 => null;
+ get g1 => throw UnimplementedError();
@override
// TODO: implement g2
- int get g2 => null;
+ int get g2 => throw UnimplementedError();
}
''');
}
@@ -192,7 +192,7 @@
@override
Map<aaa.Future, List<aaa.Future>> g(aaa.Future p) {
// TODO: implement g
- return null;
+ throw UnimplementedError();
}
}
''');
@@ -264,31 +264,31 @@
@override
int m2() {
// TODO: implement m2
- return null;
+ throw UnimplementedError();
}
@override
String m3(int p1, double p2, Map<int, List<String>> p3) {
// TODO: implement m3
- return null;
+ throw UnimplementedError();
}
@override
String m4(p1, p2) {
// TODO: implement m4
- return null;
+ throw UnimplementedError();
}
@override
String m5(p1, [int p2 = 2, int p3, p4 = 4]) {
// TODO: implement m5
- return null;
+ throw UnimplementedError();
}
@override
String m6(p1, {int p2 = 2, int p3, p4 = 4}) {
// TODO: implement m6
- return null;
+ throw UnimplementedError();
}
}
''';
@@ -355,7 +355,7 @@
@override
E1 foo<E1, E2 extends C<int>>(V<E2> v) {
// TODO: implement foo
- return null;
+ throw UnimplementedError();
}
}
''');
@@ -380,7 +380,7 @@
@override
List<T> foo<T extends V>(K key) {
// TODO: implement foo
- return null;
+ throw UnimplementedError();
}
}
''');
@@ -412,13 +412,13 @@
@override
bool bar(double b) {
// TODO: implement bar
- return null;
+ throw UnimplementedError();
}
@override
bool foo(int a) {
// TODO: implement foo
- return null;
+ throw UnimplementedError();
}
}
''');
@@ -470,7 +470,7 @@
@override
int operator [](int index) {
// TODO: implement []
- return null;
+ throw UnimplementedError();
}
@override
diff --git a/pkg/analyzer/analysis_options.yaml b/pkg/analyzer/analysis_options.yaml
index 59199b3..fa9d320 100644
--- a/pkg/analyzer/analysis_options.yaml
+++ b/pkg/analyzer/analysis_options.yaml
@@ -10,13 +10,8 @@
# Ignoring "style" lint rules from pedantic for now. There are pre-existing
# violations that need to be cleaned up. Each one can be cleaned up and
# enabled according to the value provided.
- avoid_return_types_on_setters: ignore
- curly_braces_in_flow_control_structures: ignore
empty_catches: ignore
prefer_iterable_wheretype: ignore
- # TODO(srawlins): At the time of writing, 230 violations in lib/. The fix
- # is mechanical, via `dartfmt --fix-named-default-separator`.
- prefer_equal_for_default_values: ignore
# TODO(srawlins): At the time of writing, 2600 violations in lib/. The fix
# is mechanical, via `dartfmt --fix-doc-comments`, but not worth the churn
# today.
@@ -25,10 +20,6 @@
# is mechanical, via `dartfmt --fix-optional-const`, but not worth the
# churn today.
unnecessary_const: ignore
- # TODO(srawlins): At the time of writing, 3200 violations in lib/. The fix
- # is mechanical, via `dartfmt --fix-optional-new`, but not worth the churn
- # today.
- unnecessary_new: ignore
linter:
rules:
diff --git a/pkg/analyzer/lib/analyzer.dart b/pkg/analyzer/lib/analyzer.dart
index d01db71..d5adede 100644
--- a/pkg/analyzer/lib/analyzer.dart
+++ b/pkg/analyzer/lib/analyzer.dart
@@ -49,12 +49,12 @@
@Deprecated('Please use parseString instead')
CompilationUnit parseCompilationUnit(String contents,
{String name,
- bool suppressErrors: false,
- bool parseFunctionBodies: true,
+ bool suppressErrors = false,
+ bool parseFunctionBodies = true,
FeatureSet featureSet}) {
// TODO(paulberry): make featureSet a required parameter
featureSet ??= FeatureSet.fromEnableFlags([]);
- Source source = new StringSource(contents, name);
+ Source source = StringSource(contents, name);
return _parseSource(contents, source, featureSet,
suppressErrors: suppressErrors, parseFunctionBodies: parseFunctionBodies);
}
@@ -74,22 +74,22 @@
/// callers that don't require function bodies should simply ignore them.
@Deprecated('Please use parseFile2 instead')
CompilationUnit parseDartFile(String path,
- {bool suppressErrors: false,
- bool parseFunctionBodies: true,
+ {bool suppressErrors = false,
+ bool parseFunctionBodies = true,
FeatureSet featureSet}) {
// TODO(paulberry): Make featureSet a required parameter
featureSet ??= FeatureSet.fromEnableFlags([]);
- String contents = new File(path).readAsStringSync();
- var sourceFactory = new SourceFactory(
- [new ResourceUriResolver(PhysicalResourceProvider.INSTANCE)]);
+ String contents = File(path).readAsStringSync();
+ var sourceFactory =
+ SourceFactory([ResourceUriResolver(PhysicalResourceProvider.INSTANCE)]);
var absolutePath = pathos.absolute(path);
var source = sourceFactory.forUri(pathos.toUri(absolutePath).toString());
if (source == null) {
- throw new ArgumentError("Can't get source for path $path");
+ throw ArgumentError("Can't get source for path $path");
}
if (!source.exists()) {
- throw new ArgumentError("Source $source doesn't exist");
+ throw ArgumentError("Source $source doesn't exist");
}
return _parseSource(contents, source, featureSet,
@@ -115,18 +115,18 @@
/// directives should simply ignore the rest of the parse result.
@Deprecated('Please use parseString instead')
CompilationUnit parseDirectives(String contents,
- {String name, bool suppressErrors: false, FeatureSet featureSet}) {
+ {String name, bool suppressErrors = false, FeatureSet featureSet}) {
// TODO(paulberry): make featureSet a required parameter.
featureSet ??= FeatureSet.fromEnableFlags([]);
- var source = new StringSource(contents, name);
- var errorCollector = new _ErrorCollector();
- var reader = new CharSequenceReader(contents);
- var scanner = new Scanner(source, reader, errorCollector)
+ var source = StringSource(contents, name);
+ var errorCollector = _ErrorCollector();
+ var reader = CharSequenceReader(contents);
+ var scanner = Scanner(source, reader, errorCollector)
..configureFeatures(featureSet);
var token = scanner.tokenize();
- var parser = new Parser(source, errorCollector, featureSet: featureSet);
+ var parser = Parser(source, errorCollector, featureSet: featureSet);
var unit = parser.parseDirectives(token);
- unit.lineInfo = new LineInfo(scanner.lineStarts);
+ unit.lineInfo = LineInfo(scanner.lineStarts);
if (errorCollector.hasErrors && !suppressErrors) throw errorCollector.group;
@@ -141,16 +141,16 @@
CompilationUnit _parseSource(
String contents, Source source, FeatureSet featureSet,
- {bool suppressErrors: false, bool parseFunctionBodies: true}) {
- var reader = new CharSequenceReader(contents);
- var errorCollector = new _ErrorCollector();
- var scanner = new Scanner(source, reader, errorCollector)
+ {bool suppressErrors = false, bool parseFunctionBodies = true}) {
+ var reader = CharSequenceReader(contents);
+ var errorCollector = _ErrorCollector();
+ var scanner = Scanner(source, reader, errorCollector)
..configureFeatures(featureSet);
var token = scanner.tokenize();
- var parser = new Parser(source, errorCollector, featureSet: featureSet)
+ var parser = Parser(source, errorCollector, featureSet: featureSet)
..parseFunctionBodies = parseFunctionBodies;
var unit = parser.parseCompilationUnit(token)
- ..lineInfo = new LineInfo(scanner.lineStarts);
+ ..lineInfo = LineInfo(scanner.lineStarts);
if (errorCollector.hasErrors && !suppressErrors) throw errorCollector.group;
@@ -165,7 +165,7 @@
/// The group of errors collected.
AnalyzerErrorGroup get group =>
- new AnalyzerErrorGroup.fromAnalysisErrors(_errors);
+ AnalyzerErrorGroup.fromAnalysisErrors(_errors);
/// Whether any errors where collected.
bool get hasErrors => _errors.isNotEmpty;
diff --git a/pkg/analyzer/lib/dart/analysis/context_locator.dart b/pkg/analyzer/lib/dart/analysis/context_locator.dart
index 2211439..9ee427d 100644
--- a/pkg/analyzer/lib/dart/analysis/context_locator.dart
+++ b/pkg/analyzer/lib/dart/analysis/context_locator.dart
@@ -38,7 +38,7 @@
@deprecated
List<AnalysisContext> locateContexts(
{@required List<String> includedPaths,
- List<String> excludedPaths: const <String>[],
+ List<String> excludedPaths = const <String>[],
String optionsFile,
String packagesFile,
String sdkPath});
diff --git a/pkg/analyzer/lib/dart/analysis/declared_variables.dart b/pkg/analyzer/lib/dart/analysis/declared_variables.dart
index bcd0d74..8d6b694 100644
--- a/pkg/analyzer/lib/dart/analysis/declared_variables.dart
+++ b/pkg/analyzer/lib/dart/analysis/declared_variables.dart
@@ -52,14 +52,14 @@
DartObject getBool(TypeProvider typeProvider, String name) {
String value = _declaredVariables[name];
if (value == null) {
- return new DartObjectImpl(typeProvider.boolType, BoolState.UNKNOWN_VALUE);
+ return DartObjectImpl(typeProvider.boolType, BoolState.UNKNOWN_VALUE);
}
if (value == "true") {
- return new DartObjectImpl(typeProvider.boolType, BoolState.TRUE_STATE);
+ return DartObjectImpl(typeProvider.boolType, BoolState.TRUE_STATE);
} else if (value == "false") {
- return new DartObjectImpl(typeProvider.boolType, BoolState.FALSE_STATE);
+ return DartObjectImpl(typeProvider.boolType, BoolState.FALSE_STATE);
}
- return new DartObjectImpl(typeProvider.nullType, NullState.NULL_STATE);
+ return DartObjectImpl(typeProvider.nullType, NullState.NULL_STATE);
}
/// Return the value of the variable with the given [name] interpreted as an
@@ -69,15 +69,15 @@
DartObject getInt(TypeProvider typeProvider, String name) {
String value = _declaredVariables[name];
if (value == null) {
- return new DartObjectImpl(typeProvider.intType, IntState.UNKNOWN_VALUE);
+ return DartObjectImpl(typeProvider.intType, IntState.UNKNOWN_VALUE);
}
int bigInteger;
try {
bigInteger = int.parse(value);
} on FormatException {
- return new DartObjectImpl(typeProvider.nullType, NullState.NULL_STATE);
+ return DartObjectImpl(typeProvider.nullType, NullState.NULL_STATE);
}
- return new DartObjectImpl(typeProvider.intType, new IntState(bigInteger));
+ return DartObjectImpl(typeProvider.intType, IntState(bigInteger));
}
/// Return the value of the variable with the given [name] interpreted as a
@@ -89,9 +89,8 @@
DartObject getString(TypeProvider typeProvider, String name) {
String value = _declaredVariables[name];
if (value == null) {
- return new DartObjectImpl(
- typeProvider.stringType, StringState.UNKNOWN_VALUE);
+ return DartObjectImpl(typeProvider.stringType, StringState.UNKNOWN_VALUE);
}
- return new DartObjectImpl(typeProvider.stringType, new StringState(value));
+ return DartObjectImpl(typeProvider.stringType, StringState(value));
}
}
diff --git a/pkg/analyzer/lib/dart/analysis/session.dart b/pkg/analyzer/lib/dart/analysis/session.dart
index 111b153..669d7b8 100644
--- a/pkg/analyzer/lib/dart/analysis/session.dart
+++ b/pkg/analyzer/lib/dart/analysis/session.dart
@@ -39,9 +39,11 @@
/// Return a type provider that is consistent with the results returned by
/// this session.
+ @Deprecated('Use LibraryElement.typeProvider')
Future<TypeProvider> get typeProvider;
/// Return the type system being used by this session.
+ @Deprecated('Use LibraryElement.typeSystem')
Future<TypeSystem> get typeSystem;
/// Return the URI converter used to convert between URI's and file paths.
diff --git a/pkg/analyzer/lib/dart/analysis/utilities.dart b/pkg/analyzer/lib/dart/analysis/utilities.dart
index bddafbd..2da102e 100644
--- a/pkg/analyzer/lib/dart/analysis/utilities.dart
+++ b/pkg/analyzer/lib/dart/analysis/utilities.dart
@@ -43,7 +43,7 @@
{@required String path,
ResourceProvider resourceProvider,
@required FeatureSet featureSet,
- bool throwIfDiagnostics: true}) {
+ bool throwIfDiagnostics = true}) {
if (featureSet == null) {
throw ArgumentError('A non-null feature set must be provided.');
}
@@ -81,7 +81,7 @@
{@required String path,
ResourceProvider resourceProvider,
@required FeatureSet featureSet,
- bool throwIfDiagnostics: true}) {
+ bool throwIfDiagnostics = true}) {
return parseFile(
path: path,
resourceProvider: resourceProvider,
@@ -110,7 +110,7 @@
{@required String content,
FeatureSet featureSet,
String path,
- bool throwIfDiagnostics: true}) {
+ bool throwIfDiagnostics = true}) {
featureSet ??= FeatureSet.fromEnableFlags([]);
var source = StringSource(content, path);
var reader = CharSequenceReader(content);
@@ -124,7 +124,7 @@
ParseStringResult result =
ParseStringResultImpl(content, unit, errorCollector.errors);
if (throwIfDiagnostics && result.errors.isNotEmpty) {
- throw new ArgumentError('Content produced diagnostics when parsed');
+ throw ArgumentError('Content produced diagnostics when parsed');
}
return result;
}
@@ -149,13 +149,13 @@
/// If a [resourceProvider] is given, it will be used to access the file system.
AnalysisContext _createAnalysisContext(
{@required String path, ResourceProvider resourceProvider}) {
- AnalysisContextCollection collection = new AnalysisContextCollection(
+ AnalysisContextCollection collection = AnalysisContextCollection(
includedPaths: <String>[path],
resourceProvider: resourceProvider ?? PhysicalResourceProvider.INSTANCE,
);
List<AnalysisContext> contexts = collection.contexts;
if (contexts.length != 1) {
- throw new ArgumentError('path must be an absolute path to a single file');
+ throw ArgumentError('path must be an absolute path to a single file');
}
return contexts[0];
}
diff --git a/pkg/analyzer/lib/dart/ast/ast.dart b/pkg/analyzer/lib/dart/ast/ast.dart
index 41ef7cc..3020a23 100644
--- a/pkg/analyzer/lib/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/dart/ast/ast.dart
@@ -70,7 +70,7 @@
/// Set the documentation comment associated with this node to the given
/// [comment].
- void set documentationComment(Comment comment);
+ set documentationComment(Comment comment);
/// Return the first token following the comment and metadata.
Token get firstTokenAfterCommentAndMetadata;
@@ -99,20 +99,20 @@
/// Set the arguments to the constructor being invoked to the given
/// [arguments].
- void set arguments(ArgumentList arguments);
+ set arguments(ArgumentList arguments);
/// Return the at sign that introduced the annotation.
Token get atSign;
/// Set the at sign that introduced the annotation to the given [token].
- void set atSign(Token token);
+ set atSign(Token token);
/// Return the name of the constructor being invoked, or `null` if this
/// annotation is not the invocation of a named constructor.
SimpleIdentifier get constructorName;
/// Set the name of the constructor being invoked to the given [name].
- void set constructorName(SimpleIdentifier name);
+ set constructorName(SimpleIdentifier name);
/// Return the element associated with this annotation, or `null` if the AST
/// structure has not been resolved or if this annotation could not be
@@ -120,7 +120,7 @@
Element get element;
/// Set the element associated with this annotation to the given [element].
- void set element(Element element);
+ set element(Element element);
/// Return the element annotation representing this annotation in the element
/// model.
@@ -128,7 +128,7 @@
/// Set the element annotation representing this annotation in the element
/// model to the given [annotation].
- void set elementAnnotation(ElementAnnotation annotation);
+ set elementAnnotation(ElementAnnotation annotation);
/// Return the name of the class defining the constructor that is being
/// invoked or the name of the field that is being referenced.
@@ -136,14 +136,14 @@
/// Set the name of the class defining the constructor that is being invoked
/// or the name of the field that is being referenced to the given [name].
- void set name(Identifier name);
+ set name(Identifier name);
/// Return the period before the constructor name, or `null` if this
/// annotation is not the invocation of a named constructor.
Token get period;
/// Set the period before the constructor name to the given [token].
- void set period(Token token);
+ set period(Token token);
}
/// A list of arguments in the invocation of an executable element (that is, a
@@ -168,19 +168,19 @@
/// list to the given list of [parameters]. The list of parameters must be the
/// same length as the number of arguments, but can contain `null` entries if
/// a given argument does not correspond to a formal parameter.
- void set correspondingStaticParameters(List<ParameterElement> parameters);
+ set correspondingStaticParameters(List<ParameterElement> parameters);
/// Return the left parenthesis.
Token get leftParenthesis;
/// Set the left parenthesis to the given [token].
- void set leftParenthesis(Token token);
+ set leftParenthesis(Token token);
/// Return the right parenthesis.
Token get rightParenthesis;
/// Set the right parenthesis to the given [token].
- void set rightParenthesis(Token token);
+ set rightParenthesis(Token token);
}
/// An as expression.
@@ -194,20 +194,20 @@
Token get asOperator;
/// Set the 'as' operator to the given [token].
- void set asOperator(Token token);
+ set asOperator(Token token);
/// Return the expression used to compute the value being cast.
Expression get expression;
/// Set the expression used to compute the value being cast to the given
/// [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the type being cast to.
TypeAnnotation get type;
/// Set the type being cast to to the given [type].
- void set type(TypeAnnotation type);
+ set type(TypeAnnotation type);
}
/// An assert in the initializer list of a constructor.
@@ -226,7 +226,7 @@
Token get assertKeyword;
/// Set the token representing the 'assert' keyword to the given [token].
- void set assertKeyword(Token token);
+ set assertKeyword(Token token);
/// Return the comma between the [condition] and the [message], or `null` if
/// no message was supplied.
@@ -234,20 +234,20 @@
/// Set the comma between the [condition] and the [message] to the given
/// [token].
- void set comma(Token token);
+ set comma(Token token);
/// Return the condition that is being asserted to be `true`.
Expression get condition;
/// Set the condition that is being asserted to be `true` to the given
/// [condition].
- void set condition(Expression condition);
+ set condition(Expression condition);
/// Return the left parenthesis.
Token get leftParenthesis;
/// Set the left parenthesis to the given [token].
- void set leftParenthesis(Token token);
+ set leftParenthesis(Token token);
/// Return the message to report if the assertion fails, or `null` if no
/// message was supplied.
@@ -255,13 +255,13 @@
/// Set the message to report if the assertion fails to the given
/// [expression].
- void set message(Expression expression);
+ set message(Expression expression);
/// Return the right parenthesis.
Token get rightParenthesis;
/// Set the right parenthesis to the given [token].
- void set rightParenthesis(Token token);
+ set rightParenthesis(Token token);
}
/// An assert statement.
@@ -275,7 +275,7 @@
Token get semicolon;
/// Set the semicolon terminating the statement to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
}
/// An assignment expression.
@@ -290,20 +290,20 @@
Expression get leftHandSide;
/// Return the expression used to compute the left hand side.
- void set leftHandSide(Expression expression);
+ set leftHandSide(Expression expression);
/// Return the assignment operator being applied.
Token get operator;
/// Set the assignment operator being applied to the given [token].
- void set operator(Token token);
+ set operator(Token token);
/// Return the expression used to compute the right hand side.
Expression get rightHandSide;
/// Set the expression used to compute the left hand side to the given
/// [expression].
- void set rightHandSide(Expression expression);
+ set rightHandSide(Expression expression);
}
/// A node in the AST structure for a Dart program.
@@ -671,14 +671,14 @@
Token get awaitKeyword;
/// Set the 'await' keyword to the given [token].
- void set awaitKeyword(Token token);
+ set awaitKeyword(Token token);
/// Return the expression whose value is being waited on.
Expression get expression;
/// Set the expression whose value is being waited on to the given
/// [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
}
/// A binary (infix) expression.
@@ -694,27 +694,27 @@
/// Set the expression used to compute the left operand to the given
/// [expression].
- void set leftOperand(Expression expression);
+ set leftOperand(Expression expression);
/// Return the binary operator being applied.
Token get operator;
/// Set the binary operator being applied to the given [token].
- void set operator(Token token);
+ set operator(Token token);
/// Return the expression used to compute the right operand.
Expression get rightOperand;
/// Set the expression used to compute the right operand to the given
/// [expression].
- void set rightOperand(Expression expression);
+ set rightOperand(Expression expression);
/// The function type of the invocation, or `null` if the AST structure has
/// not been resolved, or if the invocation could not be resolved.
FunctionType get staticInvokeType;
/// Sets the function type of the invocation.
- void set staticInvokeType(FunctionType value);
+ set staticInvokeType(FunctionType value);
}
/// A sequence of statements.
@@ -728,13 +728,13 @@
Token get leftBracket;
/// Set the left curly bracket to the given [token].
- void set leftBracket(Token token);
+ set leftBracket(Token token);
/// Return the right curly bracket.
Token get rightBracket;
/// Set the right curly bracket to the given [token].
- void set rightBracket(Token token);
+ set rightBracket(Token token);
/// Return the statements contained in the block.
NodeList<Statement> get statements;
@@ -751,13 +751,13 @@
Block get block;
/// Set the block representing the body of the function to the given [block].
- void set block(Block block);
+ set block(Block block);
/// Set token representing the 'async' or 'sync' keyword to the given [token].
- void set keyword(Token token);
+ set keyword(Token token);
/// Set the star following the 'async' or 'sync' keyword to the given [token].
- void set star(Token token);
+ set star(Token token);
}
/// A boolean literal expression.
@@ -771,7 +771,7 @@
Token get literal;
/// Set the token representing the literal to the given [token].
- void set literal(Token token);
+ set literal(Token token);
/// Return the value of the literal.
bool get value;
@@ -788,20 +788,20 @@
Token get breakKeyword;
/// Set the token representing the 'break' keyword to the given [token].
- void set breakKeyword(Token token);
+ set breakKeyword(Token token);
/// Return the label associated with the statement, or `null` if there is no
/// label.
SimpleIdentifier get label;
/// Set the label associated with the statement to the given [identifier].
- void set label(SimpleIdentifier identifier);
+ set label(SimpleIdentifier identifier);
/// Return the semicolon terminating the statement.
Token get semicolon;
/// Set the semicolon terminating the statement to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
/// Return the node from which this break statement is breaking.
///
@@ -815,7 +815,7 @@
/// Set the node from which this break statement is breaking to the given
/// [node].
- void set target(AstNode node);
+ set target(AstNode node);
}
/// A sequence of cascaded expressions: expressions that share a common target.
@@ -844,7 +844,7 @@
Expression get target;
/// Set the target of the cascade sections to the given [target].
- void set target(Expression target);
+ set target(Expression target);
}
/// A catch clause within a try statement.
@@ -862,14 +862,14 @@
Block get body;
/// Set the body of the catch block to the given [block].
- void set body(Block block);
+ set body(Block block);
/// Return the token representing the 'catch' keyword, or `null` if there is
/// no 'catch' keyword.
Token get catchKeyword;
/// Set the token representing the 'catch' keyword to the given [token].
- void set catchKeyword(Token token);
+ set catchKeyword(Token token);
/// Return the comma separating the exception parameter from the stack trace
/// parameter, or `null` if there is no stack trace parameter.
@@ -877,7 +877,7 @@
/// Set the comma separating the exception parameter from the stack trace
/// parameter to the given [token].
- void set comma(Token token);
+ set comma(Token token);
/// Return the parameter whose value will be the exception that was thrown, or
/// `null` if there is no 'catch' keyword.
@@ -885,7 +885,7 @@
/// Set the parameter whose value will be the exception that was thrown to the
/// given [parameter].
- void set exceptionParameter(SimpleIdentifier parameter);
+ set exceptionParameter(SimpleIdentifier parameter);
/// Return the type of exceptions caught by this catch clause, or `null` if
/// this catch clause catches every type of exception.
@@ -893,26 +893,26 @@
/// Set the type of exceptions caught by this catch clause to the given
/// [exceptionType].
- void set exceptionType(TypeAnnotation exceptionType);
+ set exceptionType(TypeAnnotation exceptionType);
/// Return the left parenthesis, or `null` if there is no 'catch' keyword.
Token get leftParenthesis;
/// Set the left parenthesis to the given [token].
- void set leftParenthesis(Token token);
+ set leftParenthesis(Token token);
/// Return the token representing the 'on' keyword, or `null` if there is no
/// 'on' keyword.
Token get onKeyword;
/// Set the token representing the 'on' keyword to the given [token].
- void set onKeyword(Token token);
+ set onKeyword(Token token);
/// Return the right parenthesis, or `null` if there is no 'catch' keyword.
Token get rightParenthesis;
/// Set the right parenthesis to the given [token].
- void set rightParenthesis(Token token);
+ set rightParenthesis(Token token);
/// Return the parameter whose value will be the stack trace associated with
/// the exception, or `null` if there is no stack trace parameter.
@@ -920,7 +920,7 @@
/// Set the parameter whose value will be the stack trace associated with the
/// exception to the given [parameter].
- void set stackTraceParameter(SimpleIdentifier parameter);
+ set stackTraceParameter(SimpleIdentifier parameter);
}
/// The declaration of a class.
@@ -937,50 +937,50 @@
Token get abstractKeyword;
/// Set the 'abstract' keyword to the given [token].
- void set abstractKeyword(Token token);
+ set abstractKeyword(Token token);
/// Return the token representing the 'class' keyword.
Token get classKeyword;
/// Set the token representing the 'class' keyword.
- void set classKeyword(Token token);
+ set classKeyword(Token token);
/// Return the extends clause for this class, or `null` if the class does not
/// extend any other class.
ExtendsClause get extendsClause;
/// Set the extends clause for this class to the given [extendsClause].
- void set extendsClause(ExtendsClause extendsClause);
+ set extendsClause(ExtendsClause extendsClause);
/// Set the implements clause for the class to the given [implementsClause].
- void set implementsClause(ImplementsClause implementsClause);
+ set implementsClause(ImplementsClause implementsClause);
/// Return `true` if this class is declared to be an abstract class.
bool get isAbstract;
/// Set the left curly bracket to the given [token].
- void set leftBracket(Token token);
+ set leftBracket(Token token);
/// Return the native clause for this class, or `null` if the class does not
/// have a native clause.
NativeClause get nativeClause;
/// Set the native clause for this class to the given [nativeClause].
- void set nativeClause(NativeClause nativeClause);
+ set nativeClause(NativeClause nativeClause);
/// Set the right curly bracket to the given [token].
- void set rightBracket(Token token);
+ set rightBracket(Token token);
/// Set the type parameters for the class to the given list of
/// [typeParameters].
- void set typeParameters(TypeParameterList typeParameters);
+ set typeParameters(TypeParameterList typeParameters);
/// Return the with clause for the class, or `null` if the class does not have
/// a with clause.
WithClause get withClause;
/// Set the with clause for the class to the given [withClause].
- void set withClause(WithClause withClause);
+ set withClause(WithClause withClause);
/// Return the constructor declared in the class with the given [name], or
/// `null` if there is no such constructor.
@@ -1046,7 +1046,7 @@
Token get abstractKeyword;
/// Set the token for the 'abstract' keyword to the given [token].
- void set abstractKeyword(Token token);
+ set abstractKeyword(Token token);
@override
ClassElement get declaredElement;
@@ -1056,14 +1056,14 @@
/// Set the token for the '=' separating the name from the definition to the
/// given [token].
- void set equals(Token token);
+ set equals(Token token);
/// Return the implements clause for this class, or `null` if there is no
/// implements clause.
ImplementsClause get implementsClause;
/// Set the implements clause for this class to the given [implementsClause].
- void set implementsClause(ImplementsClause implementsClause);
+ set implementsClause(ImplementsClause implementsClause);
/// Return `true` if this class is declared to be an abstract class.
bool get isAbstract;
@@ -1073,7 +1073,7 @@
/// Set the name of the superclass of the class being declared to the given
/// [superclass] name.
- void set superclass(TypeName superclass);
+ set superclass(TypeName superclass);
/// Return the type parameters for the class, or `null` if the class does not
/// have any type parameters.
@@ -1081,13 +1081,13 @@
/// Set the type parameters for the class to the given list of
/// [typeParameters].
- void set typeParameters(TypeParameterList typeParameters);
+ set typeParameters(TypeParameterList typeParameters);
/// Return the with clause for this class.
WithClause get withClause;
/// Set the with clause for this class to the given with [withClause].
- void set withClause(WithClause withClause);
+ set withClause(WithClause withClause);
}
/// An element in a list, map or set literal.
@@ -1116,7 +1116,7 @@
/// Set the 'hide' or 'show' keyword specifying what kind of processing is
/// to be done on the names to the given [token].
- void set keyword(Token token);
+ set keyword(Token token);
}
/// A comment within the source code.
@@ -1165,14 +1165,14 @@
Identifier get identifier;
/// Set the identifier being referenced to the given [identifier].
- void set identifier(Identifier identifier);
+ set identifier(Identifier identifier);
/// Return the token representing the 'new' keyword, or `null` if there was no
/// 'new' keyword.
Token get newKeyword;
/// Set the token representing the 'new' keyword to the given [token].
- void set newKeyword(Token token);
+ set newKeyword(Token token);
}
/// A compilation unit.
@@ -1201,7 +1201,7 @@
abstract class CompilationUnit implements AstNode {
/// Set the first token included in this node's source range to the given
/// [token].
- void set beginToken(Token token);
+ set beginToken(Token token);
/// Return the declarations contained in this compilation unit.
NodeList<CompilationUnitMember> get declarations;
@@ -1215,11 +1215,11 @@
/// Set the element associated with this compilation unit to the given
/// [element].
- void set element(CompilationUnitElement element);
+ set element(CompilationUnitElement element);
/// Set the last token included in this node's source range to the given
/// [token].
- void set endToken(Token token);
+ set endToken(Token token);
/// The set of features available to this compilation unit, or `null` if
/// unknown.
@@ -1236,7 +1236,7 @@
LineInfo get lineInfo;
/// Set the line information for this compilation unit to the given [info].
- void set lineInfo(LineInfo info);
+ set lineInfo(LineInfo info);
/// Return the script tag at the beginning of the compilation unit, or `null`
/// if there is no script tag in this compilation unit.
@@ -1244,7 +1244,7 @@
/// Set the script tag at the beginning of the compilation unit to the given
/// [scriptTag].
- void set scriptTag(ScriptTag scriptTag);
+ set scriptTag(ScriptTag scriptTag);
/// Return a list containing all of the directives and declarations in this
/// compilation unit, sorted in lexical order.
@@ -1279,7 +1279,7 @@
/// Set the token used to separate the then expression from the else
/// expression to the given [token].
- void set colon(Token token);
+ set colon(Token token);
/// Return the condition used to determine which of the expressions is
/// executed next.
@@ -1287,7 +1287,7 @@
/// Set the condition used to determine which of the expressions is executed
/// next to the given [expression].
- void set condition(Expression expression);
+ set condition(Expression expression);
/// Return the expression that is executed if the condition evaluates to
/// `false`.
@@ -1295,14 +1295,14 @@
/// Set the expression that is executed if the condition evaluates to `false`
/// to the given [expression].
- void set elseExpression(Expression expression);
+ set elseExpression(Expression expression);
/// Return the token used to separate the condition from the then expression.
Token get question;
/// Set the token used to separate the condition from the then expression to
/// the given [token].
- void set question(Token token);
+ set question(Token token);
/// Return the expression that is executed if the condition evaluates to
/// `true`.
@@ -1310,7 +1310,7 @@
/// Set the expression that is executed if the condition evaluates to `true`
/// to the given [expression].
- void set thenExpression(Expression expression);
+ set thenExpression(Expression expression);
}
/// A configuration in either an import or export directive.
@@ -1331,19 +1331,19 @@
Token get equalToken;
/// Set the token for the equal operator to the given [token].
- void set equalToken(Token token);
+ set equalToken(Token token);
/// Return the token for the 'if' keyword.
Token get ifKeyword;
/// Set the token for the 'if' keyword to the given [token].
- void set ifKeyword(Token token);
+ set ifKeyword(Token token);
/// Return the token for the left parenthesis.
Token get leftParenthesis;
/// Set the token for the left parenthesis to the given [token].
- void set leftParenthesis(Token token);
+ set leftParenthesis(Token token);
/// Return the URI of the implementation library to be used if the condition
/// is true.
@@ -1353,7 +1353,7 @@
/// Set the URI of the implementation library to be used if the condition is
/// true to the given [uri].
@deprecated
- void set libraryUri(StringLiteral uri);
+ set libraryUri(StringLiteral uri);
/// Return the name of the declared variable whose value is being used in the
/// condition.
@@ -1361,13 +1361,13 @@
/// Set the name of the declared variable whose value is being used in the
/// condition to the given [name].
- void set name(DottedName name);
+ set name(DottedName name);
/// Return the token for the right parenthesis.
Token get rightParenthesis;
/// Set the token for the right parenthesis to the given [token].
- void set rightParenthesis(Token token);
+ set rightParenthesis(Token token);
/// Return the URI of the implementation library to be used if the condition
/// is true.
@@ -1375,13 +1375,13 @@
/// Set the URI of the implementation library to be used if the condition is
/// true to the given [uri].
- void set uri(StringLiteral uri);
+ set uri(StringLiteral uri);
/// Return the source to which the [uri] was resolved.
Source get uriSource;
/// Set the source to which the [uri] was resolved to the given [source].
- void set uriSource(Source source);
+ set uriSource(Source source);
/// Return the value to which the value of the declared variable will be
/// compared, or `null` if the condition does not include an equality test.
@@ -1389,7 +1389,7 @@
/// Set the value to which the value of the declared variable will be
/// compared to the given [value].
- void set value(StringLiteral value);
+ set value(StringLiteral value);
}
/// A constructor declaration.
@@ -1419,34 +1419,34 @@
FunctionBody get body;
/// Set the body of the constructor to the given [functionBody].
- void set body(FunctionBody functionBody);
+ set body(FunctionBody functionBody);
/// Return the token for the 'const' keyword, or `null` if the constructor is
/// not a const constructor.
Token get constKeyword;
/// Set the token for the 'const' keyword to the given [token].
- void set constKeyword(Token token);
+ set constKeyword(Token token);
@override
ConstructorElement get declaredElement;
/// Set the element associated with this constructor to the given [element].
- void set element(ConstructorElement element);
+ set element(ConstructorElement element);
/// Return the token for the 'external' keyword to the given [token].
Token get externalKeyword;
/// Set the token for the 'external' keyword, or `null` if the constructor
/// is not external.
- void set externalKeyword(Token token);
+ set externalKeyword(Token token);
/// Return the token for the 'factory' keyword, or `null` if the constructor
/// is not a factory constructor.
Token get factoryKeyword;
/// Set the token for the 'factory' keyword to the given [token].
- void set factoryKeyword(Token token);
+ set factoryKeyword(Token token);
/// Return the initializers associated with the constructor.
NodeList<ConstructorInitializer> get initializers;
@@ -1456,14 +1456,14 @@
SimpleIdentifier get name;
/// Set the name of the constructor to the given [identifier].
- void set name(SimpleIdentifier identifier);
+ set name(SimpleIdentifier identifier);
/// Return the parameters associated with the constructor.
FormalParameterList get parameters;
/// Set the parameters associated with the constructor to the given list of
/// [parameters].
- void set parameters(FormalParameterList parameters);
+ set parameters(FormalParameterList parameters);
/// Return the token for the period before the constructor name, or `null` if
/// the constructor being declared is unnamed.
@@ -1471,7 +1471,7 @@
/// Set the token for the period before the constructor name to the given
/// [token].
- void set period(Token token);
+ set period(Token token);
/// Return the name of the constructor to which this constructor will be
/// redirected, or `null` if this is not a redirecting factory constructor.
@@ -1479,7 +1479,7 @@
/// Set the name of the constructor to which this constructor will be
/// redirected to the given [redirectedConstructor] name.
- void set redirectedConstructor(ConstructorName redirectedConstructor);
+ set redirectedConstructor(ConstructorName redirectedConstructor);
/// Return the type of object being created.
///
@@ -1489,7 +1489,7 @@
Identifier get returnType;
/// Set the type of object being created to the given [typeName].
- void set returnType(Identifier typeName);
+ set returnType(Identifier typeName);
/// Return the token for the separator (colon or equals) before the
/// initializer list or redirection, or `null` if there are no initializers.
@@ -1497,7 +1497,7 @@
/// Set the token for the separator (colon or equals) before the initializer
/// list or redirection to the given [token].
- void set separator(Token token);
+ set separator(Token token);
}
/// The initialization of a field within a constructor's initialization list.
@@ -1513,7 +1513,7 @@
/// Set the token for the equal sign between the field name and the
/// expression to the given [token].
- void set equals(Token token);
+ set equals(Token token);
/// Return the expression computing the value to which the field will be
/// initialized.
@@ -1521,13 +1521,13 @@
/// Set the expression computing the value to which the field will be
/// initialized to the given [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the name of the field being initialized.
SimpleIdentifier get fieldName;
/// Set the name of the field being initialized to the given [identifier].
- void set fieldName(SimpleIdentifier identifier);
+ set fieldName(SimpleIdentifier identifier);
/// Return the token for the period after the 'this' keyword, or `null` if
/// there is no 'this' keyword.
@@ -1535,14 +1535,14 @@
/// Set the token for the period after the 'this' keyword to the given
/// [token].
- void set period(Token token);
+ set period(Token token);
/// Return the token for the 'this' keyword, or `null` if there is no 'this'
/// keyword.
Token get thisKeyword;
/// Set the token for the 'this' keyword to the given [token].
- void set thisKeyword(Token token);
+ set thisKeyword(Token token);
}
/// A node that can occur in the initializer list of a constructor declaration.
@@ -1567,7 +1567,7 @@
SimpleIdentifier get name;
/// Set the name of the constructor to the given [name].
- void set name(SimpleIdentifier name);
+ set name(SimpleIdentifier name);
/// Return the token for the period before the constructor name, or `null` if
/// the specified constructor is the unnamed constructor.
@@ -1575,14 +1575,14 @@
/// Set the token for the period before the constructor name to the given
/// [token].
- void set period(Token token);
+ set period(Token token);
/// Return the name of the type defining the constructor.
TypeName get type;
/// Set the name of the type defining the constructor to the given [type]
/// name.
- void set type(TypeName type);
+ set type(TypeName type);
}
/// An AST node that makes reference to a constructor.
@@ -1596,7 +1596,7 @@
/// Set the element associated with the referenced constructor based on static
/// type information to the given [element].
- void set staticElement(ConstructorElement element);
+ set staticElement(ConstructorElement element);
}
/// A continue statement.
@@ -1610,20 +1610,20 @@
Token get continueKeyword;
/// Set the token representing the 'continue' keyword to the given [token].
- void set continueKeyword(Token token);
+ set continueKeyword(Token token);
/// Return the label associated with the statement, or `null` if there is no
/// label.
SimpleIdentifier get label;
/// Set the label associated with the statement to the given [identifier].
- void set label(SimpleIdentifier identifier);
+ set label(SimpleIdentifier identifier);
/// Return the semicolon terminating the statement.
Token get semicolon;
/// Set the semicolon terminating the statement to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
/// Return the node to which this continue statement is continuing.
///
@@ -1637,7 +1637,7 @@
/// Set the node to which this continue statement is continuing to the given
/// [node].
- void set target(AstNode node);
+ set target(AstNode node);
}
/// A node that represents the declaration of one or more names.
@@ -1666,7 +1666,7 @@
SimpleIdentifier get identifier;
/// Set the name of the variable being declared to the given [identifier].
- void set identifier(SimpleIdentifier identifier);
+ set identifier(SimpleIdentifier identifier);
/// Return `true` if this variable was declared with the 'const' modifier.
bool get isConst;
@@ -1682,14 +1682,14 @@
/// Set the token representing either the 'final', 'const' or 'var' keyword to
/// the given [token].
- void set keyword(Token token);
+ set keyword(Token token);
/// Return the name of the declared type of the parameter, or `null` if the
/// parameter does not have a declared type.
TypeAnnotation get type;
/// Set the declared type of the parameter to the given [type].
- void set type(TypeAnnotation type);
+ set type(TypeAnnotation type);
}
/// A formal parameter with a default value.
@@ -1711,17 +1711,17 @@
/// Set the expression computing the default value for the parameter to the
/// given [expression].
- void set defaultValue(Expression expression);
+ set defaultValue(Expression expression);
/// Set the kind of this parameter to the given [kind].
- void set kind(ParameterKind kind);
+ set kind(ParameterKind kind);
/// Return the formal parameter with which the default value is associated.
NormalFormalParameter get parameter;
/// Set the formal parameter with which the default value is associated to the
/// given [formalParameter].
- void set parameter(NormalFormalParameter formalParameter);
+ set parameter(NormalFormalParameter formalParameter);
/// Return the token separating the parameter from the default value, or
/// `null` if there is no default value.
@@ -1729,7 +1729,7 @@
/// Set the token separating the parameter from the default value to the given
/// [token].
- void set separator(Token token);
+ set separator(Token token);
}
/// A node that represents a directive.
@@ -1749,7 +1749,7 @@
Element get element;
/// Set the element associated with this directive to the given [element].
- void set element(Element element);
+ set element(Element element);
/// Return the token representing the keyword that introduces this directive
/// ('import', 'export', 'library' or 'part').
@@ -1767,44 +1767,44 @@
Statement get body;
/// Set the body of the loop to the given [statement].
- void set body(Statement statement);
+ set body(Statement statement);
/// Return the condition that determines when the loop will terminate.
Expression get condition;
/// Set the condition that determines when the loop will terminate to the
/// given [expression].
- void set condition(Expression expression);
+ set condition(Expression expression);
/// Return the token representing the 'do' keyword.
Token get doKeyword;
/// Set the token representing the 'do' keyword to the given [token].
- void set doKeyword(Token token);
+ set doKeyword(Token token);
/// Return the left parenthesis.
Token get leftParenthesis;
/// Set the left parenthesis to the given [token].
- void set leftParenthesis(Token token);
+ set leftParenthesis(Token token);
/// Return the right parenthesis.
Token get rightParenthesis;
/// Set the right parenthesis to the given [token].
- void set rightParenthesis(Token token);
+ set rightParenthesis(Token token);
/// Return the semicolon terminating the statement.
Token get semicolon;
/// Set the semicolon terminating the statement to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
/// Return the token representing the 'while' keyword.
Token get whileKeyword;
/// Set the token representing the 'while' keyword to the given [token].
- void set whileKeyword(Token token);
+ set whileKeyword(Token token);
}
/// A dotted name, used in a configuration within an import or export directive.
@@ -1833,13 +1833,13 @@
Token get literal;
/// Set the token representing the literal to the given [token].
- void set literal(Token token);
+ set literal(Token token);
/// Return the value of the literal.
double get value;
/// Set the value of the literal to the given [value].
- void set value(double value);
+ set value(double value);
}
/// An empty function body, which can only appear in constructors or abstract
@@ -1856,7 +1856,7 @@
/// Set the token representing the semicolon that marks the end of the
/// function body to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
}
/// An empty statement.
@@ -1870,7 +1870,7 @@
Token get semicolon;
/// Set the semicolon terminating the statement to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
}
/// The declaration of an enum constant.
@@ -1881,7 +1881,7 @@
SimpleIdentifier get name;
/// Set the name of the constant to the given [name].
- void set name(SimpleIdentifier name);
+ set name(SimpleIdentifier name);
}
/// The declaration of an enumeration.
@@ -1901,19 +1901,19 @@
Token get enumKeyword;
/// Set the 'enum' keyword to the given [token].
- void set enumKeyword(Token token);
+ set enumKeyword(Token token);
/// Return the left curly bracket.
Token get leftBracket;
/// Set the left curly bracket to the given [token].
- void set leftBracket(Token token);
+ set leftBracket(Token token);
/// Return the right curly bracket.
Token get rightBracket;
/// Set the right curly bracket to the given [token].
- void set rightBracket(Token token);
+ set rightBracket(Token token);
}
/// An export directive.
@@ -1957,7 +1957,7 @@
DartType get staticType;
/// Set the static type of this expression to the given [type].
- void set staticType(DartType type);
+ set staticType(DartType type);
/// If this expression is a parenthesized expression, return the result of
/// unwrapping the expression inside the parentheses. Otherwise, return this
@@ -1977,7 +1977,7 @@
/// Set the expression representing the body of the function to the given
/// [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the token introducing the expression that represents the body of the
/// function.
@@ -1985,16 +1985,16 @@
/// Set the token introducing the expression that represents the body of the
/// function to the given [token].
- void set functionDefinition(Token token);
+ set functionDefinition(Token token);
/// Set token representing the 'async' or 'sync' keyword to the given [token].
- void set keyword(Token token);
+ set keyword(Token token);
/// Return the semicolon terminating the statement.
Token get semicolon;
/// Set the semicolon terminating the statement to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
}
/// An expression used as a statement.
@@ -2008,7 +2008,7 @@
Expression get expression;
/// Set the expression that comprises the statement to the given [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the semicolon terminating the statement, or `null` if the
/// expression is a function expression and therefore isn't followed by a
@@ -2016,7 +2016,7 @@
Token get semicolon;
/// Set the semicolon terminating the statement to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
}
/// The "extends" clause in a class declaration.
@@ -2030,13 +2030,13 @@
Token get extendsKeyword;
/// Set the token representing the 'extends' keyword to the given [token].
- void set extendsKeyword(Token token);
+ set extendsKeyword(Token token);
/// Return the name of the class that is being extended.
TypeName get superclass;
/// Set the name of the class that is being extended to the given [name].
- void set superclass(TypeName name);
+ set superclass(TypeName name);
}
/// The declaration of an extension of a type.
@@ -2132,13 +2132,13 @@
Token get covariantKeyword;
/// Set the token for the 'covariant' keyword to the given [token].
- void set covariantKeyword(Token token);
+ set covariantKeyword(Token token);
/// Return the fields being declared.
VariableDeclarationList get fields;
/// Set the fields being declared to the given list of [fields].
- void set fields(VariableDeclarationList fields);
+ set fields(VariableDeclarationList fields);
/// Return `true` if the fields are declared to be static.
bool get isStatic;
@@ -2147,14 +2147,14 @@
Token get semicolon;
/// Set the semicolon terminating the declaration to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
/// Return the token representing the 'static' keyword, or `null` if the
/// fields are not static.
Token get staticKeyword;
/// Set the token representing the 'static' keyword to the given [token].
- void set staticKeyword(Token token);
+ set staticKeyword(Token token);
}
/// A field formal parameter.
@@ -2171,7 +2171,7 @@
/// Set the token representing either the 'final', 'const' or 'var' keyword to
/// the given [token].
- void set keyword(Token token);
+ set keyword(Token token);
/// Return the parameters of the function-typed parameter, or `null` if this
/// is not a function-typed field formal parameter.
@@ -2179,13 +2179,13 @@
/// Set the parameters of the function-typed parameter to the given
/// [parameters].
- void set parameters(FormalParameterList parameters);
+ set parameters(FormalParameterList parameters);
/// Return the token representing the period.
Token get period;
/// Set the token representing the period to the given [token].
- void set period(Token token);
+ set period(Token token);
/// If the parameter is function-typed, and has the question mark, then its
/// function type is nullable. Having a nullable function type means that the
@@ -2196,7 +2196,7 @@
Token get thisKeyword;
/// Set the token representing the 'this' keyword to the given [token].
- void set thisKeyword(Token token);
+ set thisKeyword(Token token);
/// Return the declared type of the parameter, or `null` if the parameter does
/// not have a declared type.
@@ -2206,7 +2206,7 @@
TypeAnnotation get type;
/// Set the declared type of the parameter to the given [type].
- void set type(TypeAnnotation type);
+ set type(TypeAnnotation type);
/// Return the type parameters associated with this method, or `null` if this
/// method is not a generic method.
@@ -2214,7 +2214,7 @@
/// Set the type parameters associated with this method to the given
/// [typeParameters].
- void set typeParameters(TypeParameterList typeParameters);
+ set typeParameters(TypeParameterList typeParameters);
}
/// The parts of a for-each loop that control the iteration.
@@ -2403,13 +2403,13 @@
/// Set the left square bracket ('[') or left curly brace ('{') introducing
/// the optional parameters to the given [token].
- void set leftDelimiter(Token token);
+ set leftDelimiter(Token token);
/// Return the left parenthesis.
Token get leftParenthesis;
/// Set the left parenthesis to the given [token].
- void set leftParenthesis(Token token);
+ set leftParenthesis(Token token);
/// Return a list containing the elements representing the parameters in this
/// list.
@@ -2428,13 +2428,13 @@
/// Set the right square bracket (']') or right curly brace ('}') terminating
/// the optional parameters to the given [token].
- void set rightDelimiter(Token token);
+ set rightDelimiter(Token token);
/// Return the right parenthesis.
Token get rightParenthesis;
/// Set the right parenthesis to the given [token].
- void set rightParenthesis(Token token);
+ set rightParenthesis(Token token);
}
/// The parts of a for loop that control the iteration.
@@ -2590,14 +2590,14 @@
Token get externalKeyword;
/// Set the token representing the 'external' keyword to the given [token].
- void set externalKeyword(Token token);
+ set externalKeyword(Token token);
/// Return the function expression being wrapped.
FunctionExpression get functionExpression;
/// Set the function expression being wrapped to the given
/// [functionExpression].
- void set functionExpression(FunctionExpression functionExpression);
+ set functionExpression(FunctionExpression functionExpression);
/// Return `true` if this function declares a getter.
bool get isGetter;
@@ -2611,14 +2611,14 @@
/// Set the token representing the 'get' or 'set' keyword to the given
/// [token].
- void set propertyKeyword(Token token);
+ set propertyKeyword(Token token);
/// Return the return type of the function, or `null` if no return type was
/// declared.
TypeAnnotation get returnType;
/// Set the return type of the function to the given [type].
- void set returnType(TypeAnnotation type);
+ set returnType(TypeAnnotation type);
}
/// A [FunctionDeclaration] used as a statement.
@@ -2630,7 +2630,7 @@
/// Set the function declaration being wrapped to the given
/// [functionDeclaration].
- void set functionDeclaration(FunctionDeclaration functionDeclaration);
+ set functionDeclaration(FunctionDeclaration functionDeclaration);
}
/// A function expression.
@@ -2645,14 +2645,14 @@
FunctionBody get body;
/// Set the body of the function to the given [functionBody].
- void set body(FunctionBody functionBody);
+ set body(FunctionBody functionBody);
/// Return the element associated with the function, or `null` if the AST
/// structure has not been resolved.
ExecutableElement get declaredElement;
/// Set the element associated with the function to the given [element].
- void set element(ExecutableElement element);
+ set element(ExecutableElement element);
/// Return the parameters associated with the function, or `null` if the
/// function is part of a top-level getter.
@@ -2660,7 +2660,7 @@
/// Set the parameters associated with the function to the given list of
/// [parameters].
- void set parameters(FormalParameterList parameters);
+ set parameters(FormalParameterList parameters);
/// Return the type parameters associated with this method, or `null` if this
/// method is not a generic method.
@@ -2668,7 +2668,7 @@
/// Set the type parameters associated with this method to the given
/// [typeParameters].
- void set typeParameters(TypeParameterList typeParameters);
+ set typeParameters(TypeParameterList typeParameters);
}
/// The invocation of a function resulting from evaluating an expression.
@@ -2683,7 +2683,7 @@
/// Clients may not extend, implement or mix-in this class.
abstract class FunctionExpressionInvocation implements InvocationExpression {
/// Set the list of arguments to the method to the given [argumentList].
- void set argumentList(ArgumentList argumentList);
+ set argumentList(ArgumentList argumentList);
/// Return the expression producing the function being invoked.
@override
@@ -2691,7 +2691,7 @@
/// Set the expression producing the function being invoked to the given
/// [expression].
- void set function(Expression expression);
+ set function(Expression expression);
/// Return the element associated with the function being invoked based on
/// static type information, or `null` if the AST structure has not been
@@ -2700,11 +2700,11 @@
/// Set the element associated with the function being invoked based on static
/// type information to the given [element].
- void set staticElement(ExecutableElement element);
+ set staticElement(ExecutableElement element);
/// Set the type arguments to be applied to the method being invoked to the
/// given [typeArguments].
- void set typeArguments(TypeArgumentList typeArguments);
+ set typeArguments(TypeArgumentList typeArguments);
}
/// A function type alias.
@@ -2725,7 +2725,7 @@
/// Set the parameters associated with the function type to the given list of
/// [parameters].
- void set parameters(FormalParameterList parameters);
+ set parameters(FormalParameterList parameters);
/// Return the return type of the function type being defined, or `null` if no
/// return type was given.
@@ -2733,7 +2733,7 @@
/// Set the return type of the function type being defined to the given
/// [type].
- void set returnType(TypeAnnotation type);
+ set returnType(TypeAnnotation type);
/// Return the type parameters for the function type, or `null` if the
/// function type does not have any type parameters.
@@ -2741,7 +2741,7 @@
/// Set the type parameters for the function type to the given list of
/// [typeParameters].
- void set typeParameters(TypeParameterList typeParameters);
+ set typeParameters(TypeParameterList typeParameters);
}
/// A function-typed formal parameter.
@@ -2757,7 +2757,7 @@
/// Set the parameters of the function-typed parameter to the given
/// [parameters].
- void set parameters(FormalParameterList parameters);
+ set parameters(FormalParameterList parameters);
/// Return the question mark indicating that the function type is nullable, or
/// `null` if there is no question mark. Having a nullable function type means
@@ -2769,7 +2769,7 @@
TypeAnnotation get returnType;
/// Set the return type of the function to the given [type].
- void set returnType(TypeAnnotation type);
+ set returnType(TypeAnnotation type);
/// Return the type parameters associated with this function, or `null` if
/// this function is not a generic function.
@@ -2777,7 +2777,7 @@
/// Set the type parameters associated with this method to the given
/// [typeParameters].
- void set typeParameters(TypeParameterList typeParameters);
+ set typeParameters(TypeParameterList typeParameters);
}
/// An anonymous function type.
@@ -2815,25 +2815,25 @@
Token get functionKeyword;
/// Set the keyword 'Function' to the given [token].
- void set functionKeyword(Token token);
+ set functionKeyword(Token token);
/// Return the parameters associated with the function type.
FormalParameterList get parameters;
/// Set the parameters associated with the function type to the given list of
/// [parameters].
- void set parameters(FormalParameterList parameters);
+ set parameters(FormalParameterList parameters);
/// Set the question mark indicating that the type is nullable to the given
/// [token].
- void set question(Token token);
+ set question(Token token);
/// Return the return type of the function type being defined, or `null` if
/// no return type was given.
TypeAnnotation get returnType;
/// Set the return type of the function type being defined to the given[type].
- void set returnType(TypeAnnotation type);
+ set returnType(TypeAnnotation type);
/// Return the type parameters for the function type, or `null` if the
/// function type does not have any type parameters.
@@ -2841,7 +2841,7 @@
/// Set the type parameters for the function type to the given list of
/// [typeParameters].
- void set typeParameters(TypeParameterList typeParameters);
+ set typeParameters(TypeParameterList typeParameters);
}
/// A generic type alias.
@@ -2857,14 +2857,14 @@
/// Set the equal sign separating the name being defined from the function
/// type to the given [token].
- void set equals(Token token);
+ set equals(Token token);
/// Return the type of function being defined by the alias.
GenericFunctionType get functionType;
/// Set the type of function being defined by the alias to the given
/// [functionType].
- void set functionType(GenericFunctionType functionType);
+ set functionType(GenericFunctionType functionType);
/// Return the type parameters for the function type, or `null` if the
/// function type does not have any type parameters.
@@ -2872,7 +2872,7 @@
/// Set the type parameters for the function type to the given list of
/// [typeParameters].
- void set typeParameters(TypeParameterList typeParameters);
+ set typeParameters(TypeParameterList typeParameters);
}
/// A combinator that restricts the names being imported to those that are not
@@ -2956,14 +2956,14 @@
/// Set the condition used to determine which of the statements is executed
/// next to the given [expression].
- void set condition(Expression expression);
+ set condition(Expression expression);
/// Return the token representing the 'else' keyword, or `null` if there is no
/// else statement.
Token get elseKeyword;
/// Set the token representing the 'else' keyword to the given [token].
- void set elseKeyword(Token token);
+ set elseKeyword(Token token);
/// Return the statement that is executed if the condition evaluates to
/// `false`, or `null` if there is no else statement.
@@ -2971,25 +2971,25 @@
/// Set the statement that is executed if the condition evaluates to `false`
/// to the given [statement].
- void set elseStatement(Statement statement);
+ set elseStatement(Statement statement);
/// Return the token representing the 'if' keyword.
Token get ifKeyword;
/// Set the token representing the 'if' keyword to the given [token].
- void set ifKeyword(Token token);
+ set ifKeyword(Token token);
/// Return the left parenthesis.
Token get leftParenthesis;
/// Set the left parenthesis to the given [token].
- void set leftParenthesis(Token token);
+ set leftParenthesis(Token token);
/// Return the right parenthesis.
Token get rightParenthesis;
/// Set the right parenthesis to the given [token].
- void set rightParenthesis(Token token);
+ set rightParenthesis(Token token);
/// Return the statement that is executed if the condition evaluates to
/// `true`.
@@ -2997,7 +2997,7 @@
/// Set the statement that is executed if the condition evaluates to `true` to
/// the given [statement].
- void set thenStatement(Statement statement);
+ set thenStatement(Statement statement);
}
/// The "implements" clause in an class declaration.
@@ -3011,7 +3011,7 @@
Token get implementsKeyword;
/// Set the token representing the 'implements' keyword to the given [token].
- void set implementsKeyword(Token token);
+ set implementsKeyword(Token token);
/// Return the list of the interfaces that are being implemented.
NodeList<TypeName> get interfaces;
@@ -3069,8 +3069,8 @@
// hides and shows
//
NodeList<Combinator> combinators1 = import1.combinators;
- List<String> allHides1 = new List<String>();
- List<String> allShows1 = new List<String>();
+ List<String> allHides1 = List<String>();
+ List<String> allShows1 = List<String>();
int length1 = combinators1.length;
for (int i = 0; i < length1; i++) {
Combinator combinator = combinators1[i];
@@ -3092,8 +3092,8 @@
}
}
NodeList<Combinator> combinators2 = import2.combinators;
- List<String> allHides2 = new List<String>();
- List<String> allShows2 = new List<String>();
+ List<String> allHides2 = List<String>();
+ List<String> allShows2 = List<String>();
int length2 = combinators2.length;
for (int i = 0; i < length2; i++) {
Combinator combinator = combinators2[i];
@@ -3136,14 +3136,14 @@
Token get asKeyword;
/// Set the token representing the 'as' keyword to the given [token].
- void set asKeyword(Token token);
+ set asKeyword(Token token);
/// Return the token representing the 'deferred' keyword, or `null` if the
/// imported URI is not deferred.
Token get deferredKeyword;
/// Set the token representing the 'deferred' keyword to the given [token].
- void set deferredKeyword(Token token);
+ set deferredKeyword(Token token);
/// Return the prefix to be used with the imported names, or `null` if the
/// imported names are not prefixed.
@@ -3151,7 +3151,7 @@
/// Set the prefix to be used with the imported names to the given
/// [identifier].
- void set prefix(SimpleIdentifier identifier);
+ set prefix(SimpleIdentifier identifier);
}
/// An index expression.
@@ -3173,13 +3173,13 @@
/// Set the auxiliary elements associated with this identifier to the given
/// [elements].
// TODO(brianwilkerson) Replace this API.
- void set auxiliaryElements(AuxiliaryElements elements);
+ set auxiliaryElements(AuxiliaryElements elements);
/// Return the expression used to compute the index.
Expression get index;
/// Set the expression used to compute the index to the given [expression].
- void set index(Expression expression);
+ set index(Expression expression);
/// Return `true` if this expression is cascaded.
///
@@ -3194,7 +3194,7 @@
Token get leftBracket;
/// Set the left square bracket to the given [token].
- void set leftBracket(Token token);
+ set leftBracket(Token token);
/// Return the period ("..") before a cascaded index expression, or `null` if
/// this index expression is not part of a cascade expression.
@@ -3202,7 +3202,7 @@
/// Set the period ("..") before a cascaded index expression to the given
/// [token].
- void set period(Token token);
+ set period(Token token);
/// Return the expression used to compute the object being indexed.
///
@@ -3224,7 +3224,7 @@
/// Set the expression used to compute the object being indexed to the given
/// [expression].
- void set target(Expression expression);
+ set target(Expression expression);
/// Return `true` if this expression is computing a right-hand value (that is,
/// if this expression is in a context where the operator '[]' will be
@@ -3259,13 +3259,13 @@
ArgumentList get argumentList;
/// Set the list of arguments to the constructor to the given [argumentList].
- void set argumentList(ArgumentList argumentList);
+ set argumentList(ArgumentList argumentList);
/// Return the name of the constructor to be invoked.
ConstructorName get constructorName;
/// Set the name of the constructor to be invoked to the given [name].
- void set constructorName(ConstructorName name);
+ set constructorName(ConstructorName name);
/// Return `true` if this creation expression is used to invoke a constant
/// constructor, either because the keyword `const` was explicitly provided or
@@ -3279,7 +3279,7 @@
/// Set the 'new' or 'const' keyword used to indicate how an object should be
/// created to the given [token].
- void set keyword(Token token);
+ set keyword(Token token);
}
/// An integer literal expression.
@@ -3301,13 +3301,13 @@
Token get literal;
/// Set the token representing the literal to the given [token].
- void set literal(Token token);
+ set literal(Token token);
/// Return the value of the literal.
int get value;
/// Set the value of the literal to the given [value].
- void set value(int value);
+ set value(int value);
}
/// A node within a [StringInterpolation].
@@ -3333,7 +3333,7 @@
/// Set the expression to be evaluated for the value to be converted into a
/// string to the given [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the token used to introduce the interpolation expression; either
/// '$' if the expression is a simple identifier or '${' if the expression is
@@ -3343,14 +3343,14 @@
/// Set the token used to introduce the interpolation expression; either '$'
/// if the expression is a simple identifier or '${' if the expression is a
/// full expression to the given [token].
- void set leftBracket(Token token);
+ set leftBracket(Token token);
/// Return the right curly bracket, or `null` if the expression is an
/// identifier without brackets.
Token get rightBracket;
/// Set the right curly bracket to the given [token].
- void set rightBracket(Token token);
+ set rightBracket(Token token);
}
/// A non-empty substring of an interpolated string.
@@ -3364,7 +3364,7 @@
Token get contents;
/// Set the characters that will be added to the string to the given [token].
- void set contents(Token token);
+ set contents(Token token);
/// Return the offset of the after-last contents character.
int get contentsEnd;
@@ -3376,7 +3376,7 @@
String get value;
/// Set the value of the literal to the given [value].
- void set value(String value);
+ set value(String value);
}
/// The invocation of a function or method; either a
@@ -3408,7 +3408,7 @@
/// Sets the function type of the invocation based on the static type
/// information.
- void set staticInvokeType(DartType value);
+ set staticInvokeType(DartType value);
/// Return the type arguments to be applied to the method being invoked, or
/// `null` if no type arguments were provided.
@@ -3437,26 +3437,26 @@
/// Set the expression used to compute the value whose type is being tested to
/// the given [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the is operator.
Token get isOperator;
/// Set the is operator to the given [token].
- void set isOperator(Token token);
+ set isOperator(Token token);
/// Return the not operator, or `null` if the sense of the test is not
/// negated.
Token get notOperator;
/// Set the not operator to the given [token].
- void set notOperator(Token token);
+ set notOperator(Token token);
/// Return the type being tested for.
TypeAnnotation get type;
/// Set the type being tested for to the given [type].
- void set type(TypeAnnotation type);
+ set type(TypeAnnotation type);
}
/// A label on either a [LabeledStatement] or a [NamedExpression].
@@ -3471,13 +3471,13 @@
/// Set the colon that separates the label from the statement to the given
/// [token].
- void set colon(Token token);
+ set colon(Token token);
/// Return the label being associated with the statement.
SimpleIdentifier get label;
/// Set the label being associated with the statement to the given [label].
- void set label(SimpleIdentifier label);
+ set label(SimpleIdentifier label);
}
/// A statement that has a label associated with them.
@@ -3495,7 +3495,7 @@
/// Set the statement with which the labels are being associated to the given
/// [statement].
- void set statement(Statement statement);
+ set statement(Statement statement);
}
/// A library directive.
@@ -3509,19 +3509,19 @@
Token get libraryKeyword;
/// Set the token representing the 'library' keyword to the given [token].
- void set libraryKeyword(Token token);
+ set libraryKeyword(Token token);
/// Return the name of the library being defined.
LibraryIdentifier get name;
/// Set the name of the library being defined to the given [name].
- void set name(LibraryIdentifier name);
+ set name(LibraryIdentifier name);
/// Return the semicolon terminating the directive.
Token get semicolon;
/// Set the semicolon terminating the directive to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
}
/// The identifier for a library.
@@ -3552,13 +3552,13 @@
Token get leftBracket;
/// Set the left square bracket to the given [token].
- void set leftBracket(Token token);
+ set leftBracket(Token token);
/// Return the right square bracket.
Token get rightBracket;
/// Set the right square bracket to the given [token].
- void set rightBracket(Token token);
+ set rightBracket(Token token);
}
/// A node that represents a literal expression.
@@ -3588,13 +3588,13 @@
/// Set the expression computing the key with which the value will be
/// associated to the given [string].
- void set key(Expression string);
+ set key(Expression string);
/// Return the colon that separates the key from the value.
Token get separator;
/// Set the colon that separates the key from the value to the given [token].
- void set separator(Token token);
+ set separator(Token token);
/// Return the expression computing the value that will be associated with the
/// key.
@@ -3602,7 +3602,7 @@
/// Set the expression computing the value that will be associated with the
/// key to the given [expression].
- void set value(Expression expression);
+ set value(Expression expression);
}
/// A method declaration.
@@ -3628,7 +3628,7 @@
FunctionBody get body;
/// Set the body of the method to the given [functionBody].
- void set body(FunctionBody functionBody);
+ set body(FunctionBody functionBody);
@override
ExecutableElement get declaredElement;
@@ -3638,7 +3638,7 @@
Token get externalKeyword;
/// Set the token for the 'external' keyword to the given [token].
- void set externalKeyword(Token token);
+ set externalKeyword(Token token);
/// Return `true` if this method is declared to be an abstract method.
bool get isAbstract;
@@ -3661,20 +3661,20 @@
/// Set the token representing the 'abstract' or 'static' keyword to the given
/// [token].
- void set modifierKeyword(Token token);
+ set modifierKeyword(Token token);
/// Return the name of the method.
SimpleIdentifier get name;
/// Set the name of the method to the given [identifier].
- void set name(SimpleIdentifier identifier);
+ set name(SimpleIdentifier identifier);
/// Return the token representing the 'operator' keyword, or `null` if this
/// method does not declare an operator.
Token get operatorKeyword;
/// Set the token representing the 'operator' keyword to the given [token].
- void set operatorKeyword(Token token);
+ set operatorKeyword(Token token);
/// Return the parameters associated with the method, or `null` if this method
/// declares a getter.
@@ -3682,7 +3682,7 @@
/// Set the parameters associated with the method to the given list of
/// [parameters].
- void set parameters(FormalParameterList parameters);
+ set parameters(FormalParameterList parameters);
/// Return the token representing the 'get' or 'set' keyword, or `null` if
/// this is a method declaration rather than a property declaration.
@@ -3690,14 +3690,14 @@
/// Set the token representing the 'get' or 'set' keyword to the given
/// [token].
- void set propertyKeyword(Token token);
+ set propertyKeyword(Token token);
/// Return the return type of the method, or `null` if no return type was
/// declared.
TypeAnnotation get returnType;
/// Set the return type of the method to the given [type].
- void set returnType(TypeAnnotation type);
+ set returnType(TypeAnnotation type);
/// Return the type parameters associated with this method, or `null` if this
/// method is not a generic method.
@@ -3705,7 +3705,7 @@
/// Set the type parameters associated with this method to the given
/// [typeParameters].
- void set typeParameters(TypeParameterList typeParameters);
+ set typeParameters(TypeParameterList typeParameters);
}
/// The invocation of either a function or a method.
@@ -3721,7 +3721,7 @@
/// Clients may not extend, implement or mix-in this class.
abstract class MethodInvocation implements InvocationExpression {
/// Set the list of arguments to the method to the given [argumentList].
- void set argumentList(ArgumentList argumentList);
+ set argumentList(ArgumentList argumentList);
/// Return `true` if this expression is cascaded.
///
@@ -3736,7 +3736,7 @@
SimpleIdentifier get methodName;
/// Set the name of the method being invoked to the given [identifier].
- void set methodName(SimpleIdentifier identifier);
+ set methodName(SimpleIdentifier identifier);
/// Return the operator that separates the target from the method name, or
/// `null` if there is no target.
@@ -3747,7 +3747,7 @@
/// Set the operator that separates the target from the method name to the
/// given [token].
- void set operator(Token token);
+ set operator(Token token);
/// Return the expression used to compute the receiver of the invocation.
///
@@ -3766,11 +3766,11 @@
/// Set the expression producing the object on which the method is defined to
/// the given [expression].
- void set target(Expression expression);
+ set target(Expression expression);
/// Set the type arguments to be applied to the method being invoked to the
/// given [typeArguments].
- void set typeArguments(TypeArgumentList typeArguments);
+ set typeArguments(TypeArgumentList typeArguments);
}
/// An expression that implicitly makes reference to a method.
@@ -3786,7 +3786,7 @@
/// Set the element associated with the expression based on static types to
/// the given [element].
- void set staticElement(MethodElement element);
+ set staticElement(MethodElement element);
}
/// The declaration of a mixin.
@@ -3813,7 +3813,7 @@
SimpleIdentifier get name;
/// Set the name of the member being declared to the given [identifier].
- void set name(SimpleIdentifier identifier);
+ set name(SimpleIdentifier identifier);
}
/// An expression that has a name associated with it. They are used in method
@@ -3834,13 +3834,13 @@
/// Set the expression with which the name is associated to the given
/// [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the name associated with the expression.
Label get name;
/// Set the name associated with the expression to the given [identifier].
- void set name(Label identifier);
+ set name(Label identifier);
}
/// A named type, which can optionally include type arguments.
@@ -3860,14 +3860,14 @@
Identifier get name;
/// Set the name of the type to the given [identifier].
- void set name(Identifier identifier);
+ set name(Identifier identifier);
/// Set the question mark indicating that the type is nullable to the given
/// [token].
- void set question(Token token);
+ set question(Token token);
/// Set the type being named to the given [type].
- void set type(DartType type);
+ set type(DartType type);
/// Return the type arguments associated with the type, or `null` if there are
/// no type arguments.
@@ -3875,7 +3875,7 @@
/// Set the type arguments associated with the type to the given
/// [typeArguments].
- void set typeArguments(TypeArgumentList typeArguments);
+ set typeArguments(TypeArgumentList typeArguments);
}
/// A node that represents a directive that impacts the namespace of a library.
@@ -3895,7 +3895,7 @@
/// Set the token representing the keyword that introduces this directive
/// ('import', 'export', 'library' or 'part') to the given [token].
- void set keyword(Token token);
+ set keyword(Token token);
/// Return the source that was selected based on the declared variables.
///
@@ -3916,7 +3916,7 @@
Token get semicolon;
/// Set the semicolon terminating the directive to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
}
/// The "native" clause in an class declaration.
@@ -3931,13 +3931,13 @@
/// Set the name of the native object that implements the class to the given
/// [name].
- void set name(StringLiteral name);
+ set name(StringLiteral name);
/// Return the token representing the 'native' keyword.
Token get nativeKeyword;
/// Set the token representing the 'native' keyword to the given [token].
- void set nativeKeyword(Token token);
+ set nativeKeyword(Token token);
}
/// A function body that consists of a native keyword followed by a string
@@ -3954,7 +3954,7 @@
/// Set the token representing 'native' that marks the start of the function
/// body to the given [token].
- void set nativeKeyword(Token token);
+ set nativeKeyword(Token token);
/// Return the token representing the semicolon that marks the end of the
/// function body.
@@ -3962,7 +3962,7 @@
/// Set the token representing the semicolon that marks the end of the
/// function body to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
/// Return the string literal representing the string after the 'native'
/// token.
@@ -3970,7 +3970,7 @@
/// Set the string literal representing the string after the 'native' token to
/// the given [stringLiteral].
- void set stringLiteral(StringLiteral stringLiteral);
+ set stringLiteral(StringLiteral stringLiteral);
}
/// A list of AST nodes that have a common parent.
@@ -3991,7 +3991,7 @@
/// Set the node that is the parent of each of the elements in the list to the
/// given [node].
@deprecated // Never intended for public use.
- void set owner(AstNode node);
+ set owner(AstNode node);
/// Return the node at the given [index] in the list or throw a [RangeError]
/// if [index] is out of bounds.
@@ -4017,7 +4017,7 @@
/// Clients may not extend, implement or mix-in this class.
abstract class NormalFormalParameter implements FormalParameter {
/// Set the token for the 'covariant' keyword to the given [token].
- void set covariantKeyword(Token token);
+ set covariantKeyword(Token token);
/// Return the documentation comment associated with this parameter, or `null`
/// if this parameter does not have a documentation comment associated with
@@ -4026,13 +4026,13 @@
/// Set the documentation comment associated with this parameter to the given
/// [comment].
- void set documentationComment(Comment comment);
+ set documentationComment(Comment comment);
/// Set the name of the parameter being declared to the given [identifier].
- void set identifier(SimpleIdentifier identifier);
+ set identifier(SimpleIdentifier identifier);
/// Set the metadata associated with this node to the given [metadata].
- void set metadata(List<Annotation> metadata);
+ set metadata(List<Annotation> metadata);
/// Return a list containing the comment and annotations associated with this
/// parameter, sorted in lexical order.
@@ -4050,7 +4050,7 @@
Token get literal;
/// Set the token representing the literal to the given [token].
- void set literal(Token token);
+ set literal(Token token);
}
/// Abstract interface for expressions that may participate in null-shorting.
@@ -4096,19 +4096,19 @@
Expression get expression;
/// Set the expression within the parentheses to the given [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the left parenthesis.
Token get leftParenthesis;
/// Set the left parenthesis to the given [token].
- void set leftParenthesis(Token token);
+ set leftParenthesis(Token token);
/// Return the right parenthesis.
Token get rightParenthesis;
/// Set the right parenthesis to the given [token].
- void set rightParenthesis(Token token);
+ set rightParenthesis(Token token);
}
/// A part directive.
@@ -4122,13 +4122,13 @@
Token get partKeyword;
/// Set the token representing the 'part' keyword to the given [token].
- void set partKeyword(Token token);
+ set partKeyword(Token token);
/// Return the semicolon terminating the directive.
Token get semicolon;
/// Set the semicolon terminating the directive to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
}
/// A part-of directive.
@@ -4144,25 +4144,25 @@
/// Set the name of the library that the containing compilation unit is part
/// of to the given [libraryName].
- void set libraryName(LibraryIdentifier libraryName);
+ set libraryName(LibraryIdentifier libraryName);
/// Return the token representing the 'of' keyword.
Token get ofKeyword;
/// Set the token representing the 'of' keyword to the given [token].
- void set ofKeyword(Token token);
+ set ofKeyword(Token token);
/// Return the token representing the 'part' keyword.
Token get partKeyword;
/// Set the token representing the 'part' keyword to the given [token].
- void set partKeyword(Token token);
+ set partKeyword(Token token);
/// Return the semicolon terminating the directive.
Token get semicolon;
/// Set the semicolon terminating the directive to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
/// Return the URI of the library that the containing compilation unit is part
/// of, or `null` if no URI was given (typically because a library name was
@@ -4172,7 +4172,7 @@
/// Return the URI of the library that the containing compilation unit is part
/// of, or `null` if no URI was given (typically because a library name was
/// provided).
- void set uri(StringLiteral uri);
+ set uri(StringLiteral uri);
}
/// A postfix unary expression.
@@ -4188,14 +4188,14 @@
/// Set the expression computing the operand for the operator to the given
/// [expression].
- void set operand(Expression expression);
+ set operand(Expression expression);
/// Return the postfix operator being applied to the operand.
Token get operator;
/// Set the postfix operator being applied to the operand to the given
/// [token].
- void set operator(Token token);
+ set operator(Token token);
}
/// An identifier that is prefixed or an access to an object property where the
@@ -4210,7 +4210,7 @@
SimpleIdentifier get identifier;
/// Set the identifier being prefixed to the given [identifier].
- void set identifier(SimpleIdentifier identifier);
+ set identifier(SimpleIdentifier identifier);
/// Return `true` if this type is a deferred type. If the AST structure has
/// not been resolved, then return `false`.
@@ -4224,7 +4224,7 @@
/// Set the period used to separate the prefix from the identifier to the
/// given [token].
- void set period(Token token);
+ set period(Token token);
/// Return the prefix associated with the library in which the identifier is
/// defined.
@@ -4232,7 +4232,7 @@
/// Set the prefix associated with the library in which the identifier is
/// defined to the given [identifier].
- void set prefix(SimpleIdentifier identifier);
+ set prefix(SimpleIdentifier identifier);
}
/// A prefix unary expression.
@@ -4248,13 +4248,13 @@
/// Set the expression computing the operand for the operator to the given
/// [expression].
- void set operand(Expression expression);
+ set operand(Expression expression);
/// Return the prefix operator being applied to the operand.
Token get operator;
/// Set the prefix operator being applied to the operand to the given [token].
- void set operator(Token token);
+ set operator(Token token);
}
/// The access of a property of an object.
@@ -4281,13 +4281,13 @@
Token get operator;
/// Set the property access operator to the given [token].
- void set operator(Token token);
+ set operator(Token token);
/// Return the name of the property being accessed.
SimpleIdentifier get propertyName;
/// Set the name of the property being accessed to the given [identifier].
- void set propertyName(SimpleIdentifier identifier);
+ set propertyName(SimpleIdentifier identifier);
/// Return the expression used to compute the receiver of the invocation.
///
@@ -4306,7 +4306,7 @@
/// Set the expression computing the object defining the property being
/// accessed to the given [expression].
- void set target(Expression expression);
+ set target(Expression expression);
}
/// The invocation of a constructor in the same class from within a
@@ -4322,7 +4322,7 @@
ArgumentList get argumentList;
/// Set the list of arguments to the constructor to the given [argumentList].
- void set argumentList(ArgumentList argumentList);
+ set argumentList(ArgumentList argumentList);
/// Return the name of the constructor that is being invoked, or `null` if the
/// unnamed constructor is being invoked.
@@ -4330,7 +4330,7 @@
/// Set the name of the constructor that is being invoked to the given
/// [identifier].
- void set constructorName(SimpleIdentifier identifier);
+ set constructorName(SimpleIdentifier identifier);
/// Return the token for the period before the name of the constructor that is
/// being invoked, or `null` if the unnamed constructor is being invoked.
@@ -4338,13 +4338,13 @@
/// Set the token for the period before the name of the constructor that is
/// being invoked to the given [token].
- void set period(Token token);
+ set period(Token token);
/// Return the token for the 'this' keyword.
Token get thisKeyword;
/// Set the token for the 'this' keyword to the given [token].
- void set thisKeyword(Token token);
+ set thisKeyword(Token token);
}
/// A rethrow expression.
@@ -4358,7 +4358,7 @@
Token get rethrowKeyword;
/// Set the token representing the 'rethrow' keyword to the given [token].
- void set rethrowKeyword(Token token);
+ set rethrowKeyword(Token token);
}
/// A return statement.
@@ -4374,19 +4374,19 @@
/// Set the expression computing the value to be returned to the given
/// [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the token representing the 'return' keyword.
Token get returnKeyword;
/// Set the token representing the 'return' keyword to the given [token].
- void set returnKeyword(Token token);
+ set returnKeyword(Token token);
/// Return the semicolon terminating the statement.
Token get semicolon;
/// Set the semicolon terminating the statement to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
}
/// A script tag that can optionally occur at the beginning of a compilation
@@ -4401,7 +4401,7 @@
Token get scriptTag;
/// Set the token representing this script tag to the given [token].
- void set scriptTag(Token token);
+ set scriptTag(Token token);
}
/// A set or map literal.
@@ -4492,14 +4492,14 @@
/// Set the token representing either the 'final', 'const' or 'var' keyword to
/// the given [token].
- void set keyword(Token token);
+ set keyword(Token token);
/// Return the declared type of the parameter, or `null` if the parameter does
/// not have a declared type.
TypeAnnotation get type;
/// Set the declared type of the parameter to the given [type].
- void set type(TypeAnnotation type);
+ set type(TypeAnnotation type);
}
/// A simple identifier.
@@ -4524,7 +4524,7 @@
/// Set the auxiliary elements associated with this identifier to the given
/// [elements].
// TODO(brianwilkerson) Replace this API.
- void set auxiliaryElements(AuxiliaryElements elements);
+ set auxiliaryElements(AuxiliaryElements elements);
/// Return `true` if this identifier is the "name" part of a prefixed
/// identifier or a method invocation.
@@ -4532,7 +4532,7 @@
/// Set the element associated with this identifier based on static type
/// information to the given [element].
- void set staticElement(Element element);
+ set staticElement(Element element);
/// If the identifier is a tear-off, return the inferred type arguments
/// applied to the function type of the element to produce its [staticType].
@@ -4550,7 +4550,7 @@
Token get token;
/// Set the token representing the identifier to the given [token].
- void set token(Token token);
+ set token(Token token);
/// Return `true` if this identifier is the name being declared in a
/// declaration.
@@ -4601,13 +4601,13 @@
Token get literal;
/// Set the token representing the literal to the given [token].
- void set literal(Token token);
+ set literal(Token token);
/// Return the value of the literal.
String get value;
/// Set the value of the literal to the given [string].
- void set value(String string);
+ set value(String string);
}
/// A single string literal expression.
@@ -4718,7 +4718,7 @@
ArgumentList get argumentList;
/// Set the list of arguments to the constructor to the given [argumentList].
- void set argumentList(ArgumentList argumentList);
+ set argumentList(ArgumentList argumentList);
/// Return the name of the constructor that is being invoked, or `null` if the
/// unnamed constructor is being invoked.
@@ -4726,7 +4726,7 @@
/// Set the name of the constructor that is being invoked to the given
/// [identifier].
- void set constructorName(SimpleIdentifier identifier);
+ set constructorName(SimpleIdentifier identifier);
/// Return the token for the period before the name of the constructor that is
/// being invoked, or `null` if the unnamed constructor is being invoked.
@@ -4734,13 +4734,13 @@
/// Set the token for the period before the name of the constructor that is
/// being invoked to the given [token].
- void set period(Token token);
+ set period(Token token);
/// Return the token for the 'super' keyword.
Token get superKeyword;
/// Set the token for the 'super' keyword to the given [token].
- void set superKeyword(Token token);
+ set superKeyword(Token token);
}
/// A super expression.
@@ -4754,7 +4754,7 @@
Token get superKeyword;
/// Set the token representing the 'super' keyword to the given [token].
- void set superKeyword(Token token);
+ set superKeyword(Token token);
}
/// A case in a switch statement.
@@ -4769,7 +4769,7 @@
/// Set the expression controlling whether the statements will be executed to
/// the given [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
}
/// The default case in a switch statement.
@@ -4794,14 +4794,14 @@
/// Set the colon separating the keyword or the expression from the
/// statements to the given [token].
- void set colon(Token token);
+ set colon(Token token);
/// Return the token representing the 'case' or 'default' keyword.
Token get keyword;
/// Set the token representing the 'case' or 'default' keyword to the given
/// [token].
- void set keyword(Token token);
+ set keyword(Token token);
/// Return the labels associated with the switch member.
NodeList<Label> get labels;
@@ -4824,19 +4824,19 @@
/// Set the expression used to determine which of the switch members will be
/// selected to the given [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the left curly bracket.
Token get leftBracket;
/// Set the left curly bracket to the given [token].
- void set leftBracket(Token token);
+ set leftBracket(Token token);
/// Return the left parenthesis.
Token get leftParenthesis;
/// Set the left parenthesis to the given [token].
- void set leftParenthesis(Token token);
+ set leftParenthesis(Token token);
/// Return the switch members that can be selected by the expression.
NodeList<SwitchMember> get members;
@@ -4845,19 +4845,19 @@
Token get rightBracket;
/// Set the right curly bracket to the given [token].
- void set rightBracket(Token token);
+ set rightBracket(Token token);
/// Return the right parenthesis.
Token get rightParenthesis;
/// Set the right parenthesis to the given [token].
- void set rightParenthesis(Token token);
+ set rightParenthesis(Token token);
/// Return the token representing the 'switch' keyword.
Token get switchKeyword;
/// Set the token representing the 'switch' keyword to the given [token].
- void set switchKeyword(Token token);
+ set switchKeyword(Token token);
}
/// A symbol literal expression.
@@ -4874,7 +4874,7 @@
Token get poundSign;
/// Set the token introducing the literal to the given [token].
- void set poundSign(Token token);
+ set poundSign(Token token);
}
/// A this expression.
@@ -4888,7 +4888,7 @@
Token get thisKeyword;
/// Set the token representing the 'this' keyword to the given [token].
- void set thisKeyword(Token token);
+ set thisKeyword(Token token);
}
/// A throw expression.
@@ -4903,13 +4903,13 @@
/// Set the expression computing the exception to be thrown to the given
/// [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the token representing the 'throw' keyword.
Token get throwKeyword;
/// Set the token representing the 'throw' keyword to the given [token].
- void set throwKeyword(Token token);
+ set throwKeyword(Token token);
}
/// The declaration of one or more top-level variables of the same type.
@@ -4924,14 +4924,14 @@
Token get semicolon;
/// Set the semicolon terminating the declaration to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
/// Return the top-level variables being declared.
VariableDeclarationList get variables;
/// Set the top-level variables being declared to the given list of
/// [variables].
- void set variables(VariableDeclarationList variables);
+ set variables(VariableDeclarationList variables);
}
/// A try statement.
@@ -4948,7 +4948,7 @@
Block get body;
/// Set the body of the statement to the given [block].
- void set body(Block block);
+ set body(Block block);
/// Return the catch clauses contained in the try statement.
NodeList<CatchClause> get catchClauses;
@@ -4958,20 +4958,20 @@
Block get finallyBlock;
/// Set the finally block contained in the try statement to the given [block].
- void set finallyBlock(Block block);
+ set finallyBlock(Block block);
/// Return the token representing the 'finally' keyword, or `null` if the
/// statement does not contain a finally clause.
Token get finallyKeyword;
/// Set the token representing the 'finally' keyword to the given [token].
- void set finallyKeyword(Token token);
+ set finallyKeyword(Token token);
/// Return the token representing the 'try' keyword.
Token get tryKeyword;
/// Set the token representing the 'try' keyword to the given [token].
- void set tryKeyword(Token token);
+ set tryKeyword(Token token);
}
/// The declaration of a type alias.
@@ -4989,13 +4989,13 @@
Token get semicolon;
/// Set the semicolon terminating the declaration to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
/// Return the token representing the 'typedef' keyword.
Token get typedefKeyword;
/// Set the token representing the 'typedef' keyword to the given [token].
- void set typedefKeyword(Token token);
+ set typedefKeyword(Token token);
}
/// A type annotation.
@@ -5029,13 +5029,13 @@
Token get leftBracket;
/// Set the left bracket to the given [token].
- void set leftBracket(Token token);
+ set leftBracket(Token token);
/// Return the right bracket.
Token get rightBracket;
/// Set the right bracket to the given [token].
- void set rightBracket(Token token);
+ set rightBracket(Token token);
}
/// A literal that has a type associated with it.
@@ -5051,7 +5051,7 @@
Token get constKeyword;
/// Set the token representing the 'const' keyword to the given [token].
- void set constKeyword(Token token);
+ set constKeyword(Token token);
/// Return `true` if this literal is a constant expression, either because the
/// keyword `const` was explicitly provided or because no keyword was provided
@@ -5064,7 +5064,7 @@
/// Set the type argument associated with this literal to the given
/// [typeArguments].
- void set typeArguments(TypeArgumentList typeArguments);
+ set typeArguments(TypeArgumentList typeArguments);
}
/// The name of a type, which can optionally include type arguments.
@@ -5087,7 +5087,7 @@
TypeAnnotation get bound;
/// Set the upper bound for legal arguments to the given [type].
- void set bound(TypeAnnotation type);
+ set bound(TypeAnnotation type);
@override
TypeParameterElement get declaredElement;
@@ -5097,13 +5097,13 @@
Token get extendsKeyword;
/// Set the token representing the 'extends' keyword to the given [token].
- void set extendsKeyword(Token token);
+ set extendsKeyword(Token token);
/// Return the name of the type parameter.
SimpleIdentifier get name;
/// Set the name of the type parameter to the given [identifier].
- void set name(SimpleIdentifier identifier);
+ set name(SimpleIdentifier identifier);
}
/// Type parameters within a declaration.
@@ -5138,19 +5138,19 @@
/// Set the source to which the URI was resolved to the given [source].
@deprecated
- void set source(Source source);
+ set source(Source source);
/// Return the URI referenced by this directive.
StringLiteral get uri;
/// Set the URI referenced by this directive to the given [uri].
- void set uri(StringLiteral uri);
+ set uri(StringLiteral uri);
/// Return the content of the [uri].
String get uriContent;
/// Set the content of the [uri] to the given [content].
- void set uriContent(String content);
+ set uriContent(String content);
/// Return the element associated with the [uri] of this directive, or `null`
/// if the AST structure has not been resolved or if the URI could not be
@@ -5164,7 +5164,7 @@
Source get uriSource;
/// Set the source to which the [uri] was resolved to the given [source].
- void set uriSource(Source source);
+ set uriSource(Source source);
}
/// An identifier that has an initial value associated with it.
@@ -5190,7 +5190,7 @@
/// Set the equal sign separating the variable name from the initial value to
/// the given [token].
- void set equals(Token token);
+ set equals(Token token);
/// Return the expression used to compute the initial value for the variable,
/// or `null` if the initial value was not specified.
@@ -5198,7 +5198,7 @@
/// Set the expression used to compute the initial value for the variable to
/// the given [expression].
- void set initializer(Expression expression);
+ set initializer(Expression expression);
/// Return `true` if this variable was declared with the 'const' modifier.
bool get isConst;
@@ -5216,7 +5216,7 @@
SimpleIdentifier get name;
/// Set the name of the variable being declared to the given [identifier].
- void set name(SimpleIdentifier identifier);
+ set name(SimpleIdentifier identifier);
}
/// The declaration of one or more variables of the same type.
@@ -5254,7 +5254,7 @@
/// Set the token representing the 'final', 'const' or 'var' keyword to the
/// given [token].
- void set keyword(Token token);
+ set keyword(Token token);
/// Return the token representing the 'late' keyword, or `null` if the late
/// modifier was not included.
@@ -5265,7 +5265,7 @@
TypeAnnotation get type;
/// Set the type of the variables being declared to the given [type].
- void set type(TypeAnnotation type);
+ set type(TypeAnnotation type);
/// Return a list containing the individual variables being declared.
NodeList<VariableDeclaration> get variables;
@@ -5283,13 +5283,13 @@
Token get semicolon;
/// Set the semicolon terminating the statement to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
/// Return the variables being declared.
VariableDeclarationList get variables;
/// Set the variables being declared to the given list of [variables].
- void set variables(VariableDeclarationList variables);
+ set variables(VariableDeclarationList variables);
}
/// A while statement.
@@ -5303,7 +5303,7 @@
Statement get body;
/// Set the body of the loop to the given [statement].
- void set body(Statement statement);
+ set body(Statement statement);
/// Return the expression used to determine whether to execute the body of the
/// loop.
@@ -5311,25 +5311,25 @@
/// Set the expression used to determine whether to execute the body of the
/// loop to the given [expression].
- void set condition(Expression expression);
+ set condition(Expression expression);
/// Return the left parenthesis.
Token get leftParenthesis;
/// Set the left parenthesis to the given [token].
- void set leftParenthesis(Token token);
+ set leftParenthesis(Token token);
/// Return the right parenthesis.
Token get rightParenthesis;
/// Set the right parenthesis to the given [token].
- void set rightParenthesis(Token token);
+ set rightParenthesis(Token token);
/// Return the token representing the 'while' keyword.
Token get whileKeyword;
/// Set the token representing the 'while' keyword to the given [token].
- void set whileKeyword(Token token);
+ set whileKeyword(Token token);
}
/// The with clause in a class declaration.
@@ -5346,7 +5346,7 @@
Token get withKeyword;
/// Set the token representing the 'with' keyword to the given [token].
- void set withKeyword(Token token);
+ set withKeyword(Token token);
}
/// A yield statement.
@@ -5360,24 +5360,24 @@
Expression get expression;
/// Set the expression whose value will be yielded to the given [expression].
- void set expression(Expression expression);
+ set expression(Expression expression);
/// Return the semicolon following the expression.
Token get semicolon;
/// Return the semicolon following the expression to the given [token].
- void set semicolon(Token token);
+ set semicolon(Token token);
/// Return the star optionally following the 'yield' keyword.
Token get star;
/// Return the star optionally following the 'yield' keyword to the given
/// [token].
- void set star(Token token);
+ set star(Token token);
/// Return the 'yield' keyword.
Token get yieldKeyword;
/// Return the 'yield' keyword to the given [token].
- void set yieldKeyword(Token token);
+ set yieldKeyword(Token token);
}
diff --git a/pkg/analyzer/lib/dart/ast/ast_factory.dart b/pkg/analyzer/lib/dart/ast/ast_factory.dart
index c26c895..ac3b825 100644
--- a/pkg/analyzer/lib/dart/ast/ast_factory.dart
+++ b/pkg/analyzer/lib/dart/ast/ast_factory.dart
@@ -826,7 +826,7 @@
@required SimpleIdentifier identifier});
/// Returns a newly created identifier.
- SimpleIdentifier simpleIdentifier(Token token, {bool isDeclaration: false});
+ SimpleIdentifier simpleIdentifier(Token token, {bool isDeclaration = false});
/// Returns a newly created simple string literal.
SimpleStringLiteral simpleStringLiteral(Token literal, String value);
diff --git a/pkg/analyzer/lib/dart/ast/standard_ast_factory.dart b/pkg/analyzer/lib/dart/ast/standard_ast_factory.dart
index acb1366..0b7a130 100644
--- a/pkg/analyzer/lib/dart/ast/standard_ast_factory.dart
+++ b/pkg/analyzer/lib/dart/ast/standard_ast_factory.dart
@@ -6,4 +6,4 @@
import 'package:analyzer/src/dart/ast/ast_factory.dart';
/// Gets an instance of [AstFactory] based on the standard AST implementation.
-final AstFactory astFactory = new AstFactoryImpl();
+final AstFactory astFactory = AstFactoryImpl();
diff --git a/pkg/analyzer/lib/dart/ast/visitor.dart b/pkg/analyzer/lib/dart/ast/visitor.dart
index abd4c10..9f92c49 100644
--- a/pkg/analyzer/lib/dart/ast/visitor.dart
+++ b/pkg/analyzer/lib/dart/ast/visitor.dart
@@ -49,7 +49,7 @@
class BreadthFirstVisitor<R> extends GeneralizingAstVisitor<R> {
/// A queue holding the nodes that have not yet been visited in the order in
/// which they ought to be visited.
- Queue<AstNode> _queue = new Queue<AstNode>();
+ Queue<AstNode> _queue = Queue<AstNode>();
/// A visitor, used to visit the children of the current node, that will add
/// the nodes it visits to the [_queue].
@@ -57,7 +57,7 @@
/// Initialize a newly created visitor.
BreadthFirstVisitor() {
- _childVisitor = new _BreadthFirstChildVisitor(this);
+ _childVisitor = _BreadthFirstChildVisitor(this);
}
/// Visit all nodes in the tree starting at the given [root] node, in
@@ -2096,7 +2096,7 @@
R visitYieldStatement(YieldStatement node) => _throw(node);
R _throw(AstNode node) {
- throw new Exception('Missing implementation of visit${node.runtimeType}');
+ throw Exception('Missing implementation of visit${node.runtimeType}');
}
}
@@ -2113,7 +2113,7 @@
/// Initialize a newly created visitor to time calls to the given base
/// visitor's visits.
TimedAstVisitor(this._baseVisitor, [Stopwatch watch])
- : stopwatch = watch ?? new Stopwatch();
+ : stopwatch = watch ?? Stopwatch();
@override
T visitAdjacentStrings(AdjacentStrings node) {
diff --git a/pkg/analyzer/lib/dart/element/type.dart b/pkg/analyzer/lib/dart/element/type.dart
index d80c7b4..0e20a37 100644
--- a/pkg/analyzer/lib/dart/element/type.dart
+++ b/pkg/analyzer/lib/dart/element/type.dart
@@ -115,6 +115,20 @@
/// Return the nullability suffix of this type.
NullabilitySuffix get nullabilitySuffix;
+ /// Return the presentation of this type as it should appear when presented
+ /// to users in contexts such as error messages.
+ ///
+ /// If [withNullability] is `true`, then [NullabilitySuffix.question] and
+ /// [NullabilitySuffix.star] will be be represented as `?` and `*`.
+ /// [NullabilitySuffix.none] does not have any explicit presentation.
+ ///
+ /// If [withNullability] is `false`, nullability suffixes will not be
+ /// included into the presentation.
+ ///
+ /// Clients should not depend on the content of the returned value as it will
+ /// be changed if doing so would improve the UX.
+ String getDisplayString({bool withNullability = false});
+
/// If this type is a [TypeParameterType], returns its bound if it has one, or
/// [objectType] otherwise.
///
@@ -339,7 +353,7 @@
/// The [library] determines if a private member name is visible, and does not
/// need to be supplied for public names.
PropertyAccessorElement lookUpInheritedGetter(String name,
- {LibraryElement library, bool thisType: true});
+ {LibraryElement library, bool thisType = true});
/// Look up the member with the given [name] in this type and all extended
/// and mixed in classes, starting from this type. If the search fails,
@@ -363,7 +377,7 @@
/// The [library] determines if a private member name is visible, and does not
/// need to be supplied for public names.
MethodElement lookUpInheritedMethod(String name,
- {LibraryElement library, bool thisType: true});
+ {LibraryElement library, bool thisType = true});
/// Look up the member with the given [name] in this type and all extended
/// and mixed in classes, and by default including [thisType]. If the search
@@ -375,7 +389,7 @@
/// The [library] determines if a private member name is visible, and does not
/// need to be supplied for public names.
PropertyAccessorElement lookUpInheritedSetter(String name,
- {LibraryElement library, bool thisType: true});
+ {LibraryElement library, bool thisType = true});
/// Return the element representing the method that results from looking up
/// the method with the given [name] in this class with respect to the given
diff --git a/pkg/analyzer/lib/dart/element/visitor.dart b/pkg/analyzer/lib/dart/element/visitor.dart
index f1543ad..3119637 100644
--- a/pkg/analyzer/lib/dart/element/visitor.dart
+++ b/pkg/analyzer/lib/dart/element/visitor.dart
@@ -469,7 +469,6 @@
R visitTypeParameterElement(TypeParameterElement element) => _throw(element);
R _throw(Element element) {
- throw new Exception(
- 'Missing implementation of visit${element.runtimeType}');
+ throw Exception('Missing implementation of visit${element.runtimeType}');
}
}
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index 8e471b0..75ca1a6 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -76,6 +76,7 @@
CompileTimeErrorCode.ANNOTATION_WITH_TYPE_ARGUMENTS,
CompileTimeErrorCode.ASSERT_IN_REDIRECTING_CONSTRUCTOR,
CompileTimeErrorCode.ASYNC_FOR_IN_WRONG_CONTEXT,
+ CompileTimeErrorCode.AWAIT_IN_LATE_LOCAL_VARIABLE_INITIALIZER,
CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT,
CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_EXTENSION_NAME,
CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_PREFIX_NAME,
@@ -204,6 +205,7 @@
CompileTimeErrorCode.INVOCATION_OF_EXTENSION_WITHOUT_CALL,
CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE,
CompileTimeErrorCode.LABEL_UNDEFINED,
+ CompileTimeErrorCode.LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR,
CompileTimeErrorCode.MAP_ENTRY_NOT_IN_MAP,
CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME,
CompileTimeErrorCode.MISSING_CONST_IN_LIST_LITERAL,
@@ -373,6 +375,13 @@
HintCode.INVALID_FACTORY_METHOD_DECL,
HintCode.INVALID_FACTORY_METHOD_IMPL,
HintCode.INVALID_IMMUTABLE_ANNOTATION,
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN,
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS,
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE,
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER,
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_PREFIX,
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS,
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_TWO_SLASHES,
HintCode.INVALID_LITERAL_ANNOTATION,
HintCode.INVALID_NON_VIRTUAL_ANNOTATION,
HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER,
@@ -707,6 +716,7 @@
StaticWarningCode.CASE_BLOCK_NOT_TERMINATED,
StaticWarningCode.CAST_TO_NON_TYPE,
StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER,
+ // ignore: deprecated_member_use_from_same_package
StaticWarningCode.CONST_WITH_ABSTRACT_CLASS,
StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED,
// ignore: deprecated_member_use_from_same_package
@@ -724,6 +734,7 @@
StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED,
// ignore: deprecated_member_use_from_same_package
StaticWarningCode.IMPORT_OF_NON_LIBRARY,
+ StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS,
StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED,
StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL,
StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE,
@@ -731,7 +742,9 @@
StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES,
StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH,
+ // ignore: deprecated_member_use_from_same_package
StaticWarningCode.MIXED_RETURN_TYPES,
+ // ignore: deprecated_member_use_from_same_package
StaticWarningCode.NEW_WITH_ABSTRACT_CLASS,
StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS,
StaticWarningCode.NEW_WITH_NON_TYPE,
@@ -831,7 +844,7 @@
*/
ErrorCode errorCodeByUniqueName(String uniqueName) {
if (_uniqueNameToCodeMap == null) {
- _uniqueNameToCodeMap = new HashMap<String, ErrorCode>();
+ _uniqueNameToCodeMap = HashMap<String, ErrorCode>();
for (ErrorCode errorCode in errorCodeValues) {
_uniqueNameToCodeMap[errorCode.uniqueName] = errorCode;
}
@@ -919,7 +932,7 @@
if (correctionTemplate != null) {
this._correction = formatList(correctionTemplate, arguments);
}
- _problemMessage = new DiagnosticMessageImpl(
+ _problemMessage = DiagnosticMessageImpl(
filePath: source?.fullName,
length: length,
message: message,
@@ -933,7 +946,7 @@
AnalysisError.forValues(this.source, int offset, int length, this.errorCode,
String message, this._correction,
{List<DiagnosticMessage> contextMessages = const []}) {
- _problemMessage = new DiagnosticMessageImpl(
+ _problemMessage = DiagnosticMessageImpl(
filePath: source?.fullName,
length: length,
message: message,
@@ -992,8 +1005,7 @@
case ErrorSeverity.INFO:
return Severity.info;
default:
- throw new StateError(
- 'Invalid error severity: ${errorCode.errorSeverity}');
+ throw StateError('Invalid error severity: ${errorCode.errorSeverity}');
}
}
@@ -1026,7 +1038,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write((source != null) ? source.fullName : "<unknown source>");
buffer.write("(");
buffer.write(offset);
@@ -1043,7 +1055,7 @@
* a single list of errors.
*/
static List<AnalysisError> mergeLists(List<List<AnalysisError>> errorLists) {
- Set<AnalysisError> errors = new HashSet<AnalysisError>();
+ Set<AnalysisError> errors = HashSet<AnalysisError>();
for (List<AnalysisError> errorList in errorLists) {
errors.addAll(errorList);
}
diff --git a/pkg/analyzer/lib/error/listener.dart b/pkg/analyzer/lib/error/listener.dart
index 19235f8..68fc28b 100644
--- a/pkg/analyzer/lib/error/listener.dart
+++ b/pkg/analyzer/lib/error/listener.dart
@@ -22,7 +22,7 @@
/**
* An error listener that ignores errors that are reported to it.
*/
- static final AnalysisErrorListener NULL_LISTENER = new _NullErrorListener();
+ static final AnalysisErrorListener NULL_LISTENER = _NullErrorListener();
/**
* This method is invoked when an [error] has been found by the analysis
@@ -79,9 +79,9 @@
*/
ErrorReporter(this._errorListener, this._defaultSource) {
if (_errorListener == null) {
- throw new ArgumentError("An error listener must be provided");
+ throw ArgumentError("An error listener must be provided");
} else if (_defaultSource == null) {
- throw new ArgumentError("A default source must be provided");
+ throw ArgumentError("A default source must be provided");
}
this._source = _defaultSource;
}
@@ -92,7 +92,7 @@
* Set the source to be used when reporting errors to the given [source].
* Setting the source to `null` will cause the default source to be used.
*/
- void set source(Source source) {
+ set source(Source source) {
this._source = source ?? _defaultSource;
}
@@ -139,8 +139,8 @@
*/
void reportErrorForOffset(ErrorCode errorCode, int offset, int length,
[List<Object> arguments]) {
- _errorListener.onError(
- new AnalysisError(_source, offset, length, errorCode, arguments));
+ _errorListener
+ .onError(AnalysisError(_source, offset, length, errorCode, arguments));
}
/**
@@ -167,7 +167,7 @@
*/
void reportErrorMessage(
ErrorCode errorCode, int offset, int length, Message message) {
- _errorListener.onError(new AnalysisError.forValues(
+ _errorListener.onError(AnalysisError.forValues(
_source, offset, length, errorCode, message.message, message.tip));
}
@@ -200,9 +200,9 @@
if (type is FunctionType) {
String name = type.name;
if (name != null && name.isNotEmpty) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write(name);
- (type as TypeImpl).appendTo(buffer);
+ (type as TypeImpl).appendTo(buffer, withNullability: false);
return buffer.toString();
}
}
@@ -216,7 +216,7 @@
String displayName = computeDisplayName(argument);
List<_TypeToConvert> types =
typeGroups.putIfAbsent(displayName, () => <_TypeToConvert>[]);
- types.add(new _TypeToConvert(i, argument, displayName));
+ types.add(_TypeToConvert(i, argument, displayName));
}
}
for (List<_TypeToConvert> typeGroup in typeGroups.values) {
@@ -230,7 +230,7 @@
for (_TypeToConvert typeToConvert in typeGroup) {
for (Element element in typeToConvert.allElements()) {
Set<Element> elements = nameToElementMap.putIfAbsent(
- element.name, () => new Set<Element>());
+ element.name, () => Set<Element>());
elements.add(element);
}
}
@@ -243,7 +243,7 @@
String name = element.name;
if (nameToElementMap[name].length > 1) {
if (buffer == null) {
- buffer = new StringBuffer();
+ buffer = StringBuffer();
buffer.write('where ');
} else {
buffer.write(', ');
@@ -293,7 +293,7 @@
@override
void onError(AnalysisError error) {
- _errors ??= new HashSet<AnalysisError>();
+ _errors ??= HashSet<AnalysisError>();
_errors.add(error);
}
}
@@ -323,7 +323,7 @@
List<Element> allElements() {
if (_allElements == null) {
- Set<Element> elements = new Set<Element>();
+ Set<Element> elements = Set<Element>();
void addElementsFrom(DartType type) {
if (type is FunctionType) {
diff --git a/pkg/analyzer/lib/exception/exception.dart b/pkg/analyzer/lib/exception/exception.dart
index 779f27a..93d743f 100644
--- a/pkg/analyzer/lib/exception/exception.dart
+++ b/pkg/analyzer/lib/exception/exception.dart
@@ -24,7 +24,7 @@
AnalysisException([this.message = 'Exception', this.cause]);
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write('$runtimeType: ');
buffer.writeln(message);
if (cause != null) {
@@ -83,7 +83,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
_writeOn(buffer);
return buffer.toString();
}
diff --git a/pkg/analyzer/lib/file_system/memory_file_system.dart b/pkg/analyzer/lib/file_system/memory_file_system.dart
index 414ab6c..412d5ce 100644
--- a/pkg/analyzer/lib/file_system/memory_file_system.dart
+++ b/pkg/analyzer/lib/file_system/memory_file_system.dart
@@ -19,22 +19,22 @@
*/
class MemoryResourceProvider implements ResourceProvider {
final Map<String, _MemoryResource> _pathToResource =
- new HashMap<String, _MemoryResource>();
- final Map<String, Uint8List> _pathToBytes = new HashMap<String, Uint8List>();
- final Map<String, int> _pathToTimestamp = new HashMap<String, int>();
+ HashMap<String, _MemoryResource>();
+ final Map<String, Uint8List> _pathToBytes = HashMap<String, Uint8List>();
+ final Map<String, int> _pathToTimestamp = HashMap<String, int>();
final Map<String, List<StreamController<WatchEvent>>> _pathToWatchers =
- new HashMap<String, List<StreamController<WatchEvent>>>();
+ HashMap<String, List<StreamController<WatchEvent>>>();
int nextStamp = 0;
final pathos.Context _pathContext;
MemoryResourceProvider(
- {pathos.Context context, @deprecated bool isWindows: false})
+ {pathos.Context context, @deprecated bool isWindows = false})
: _pathContext = (context ??= pathos.style == pathos.Style.windows
// On Windows, ensure that the current drive matches
// the drive inserted by MemoryResourceProvider.convertPath
// so that packages are mapped to the correct drive
- ? new pathos.Context(current: 'C:\\')
+ ? pathos.Context(current: 'C:\\')
: pathos.context);
@override
@@ -92,13 +92,13 @@
@override
File getFile(String path) {
_ensureAbsoluteAndNormalized(path);
- return new _MemoryFile(this, path);
+ return _MemoryFile(this, path);
}
@override
Folder getFolder(String path) {
_ensureAbsoluteAndNormalized(path);
- return new _MemoryFolder(this, path);
+ return _MemoryFolder(this, path);
}
@override
@@ -116,7 +116,7 @@
_ensureAbsoluteAndNormalized(path);
Resource resource = _pathToResource[path];
if (resource == null) {
- resource = new _MemoryFile(this, path);
+ resource = _MemoryFile(this, path);
}
return resource;
}
@@ -141,7 +141,7 @@
File newDummyLink(String path) {
_ensureAbsoluteAndNormalized(path);
newFolder(pathContext.dirname(path));
- _MemoryDummyLink link = new _MemoryDummyLink(this, path);
+ _MemoryDummyLink link = _MemoryDummyLink(this, path);
_pathToResource[path] = link;
_pathToTimestamp[path] = nextStamp++;
_notifyWatchers(path, ChangeType.ADD);
@@ -169,7 +169,7 @@
Folder newFolder(String path) {
_ensureAbsoluteAndNormalized(path);
if (!pathContext.isAbsolute(path)) {
- throw new ArgumentError("Path must be absolute : $path");
+ throw ArgumentError("Path must be absolute : $path");
}
_MemoryResource resource = _pathToResource[path];
if (resource == null) {
@@ -177,7 +177,7 @@
if (parentPath != path) {
newFolder(parentPath);
}
- _MemoryFolder folder = new _MemoryFolder(this, path);
+ _MemoryFolder folder = _MemoryFolder(this, path);
_pathToResource[path] = folder;
_pathToTimestamp[path] = nextStamp++;
_notifyWatchers(path, ChangeType.ADD);
@@ -188,14 +188,14 @@
} else {
String message =
'Folder expected at ' "'$path'" 'but ${resource.runtimeType} found';
- throw new ArgumentError(message);
+ throw ArgumentError(message);
}
}
File updateFile(String path, String content, [int stamp]) {
_ensureAbsoluteAndNormalized(path);
newFolder(pathContext.dirname(path));
- _MemoryFile file = new _MemoryFile(this, path);
+ _MemoryFile file = _MemoryFile(this, path);
_pathToResource[path] = file;
_pathToBytes[path] = utf8.encode(content) as Uint8List;
_pathToTimestamp[path] = stamp ?? nextStamp++;
@@ -218,9 +218,9 @@
_MemoryResource resource = _pathToResource[path];
if (resource is! _MemoryFile) {
if (resource == null) {
- throw new ArgumentError('File expected at "$path" but does not exist');
+ throw ArgumentError('File expected at "$path" but does not exist');
}
- throw new ArgumentError(
+ throw ArgumentError(
'File expected at "$path" but ${resource.runtimeType} found');
}
}
@@ -230,7 +230,7 @@
// an ArgumentError.
_MemoryResource resource = _pathToResource[path];
if (resource is! _MemoryFolder) {
- throw new ArgumentError(
+ throw ArgumentError(
'Folder expected at "$path" but ${resource.runtimeType} found');
}
}
@@ -241,10 +241,10 @@
*/
void _ensureAbsoluteAndNormalized(String path) {
if (!pathContext.isAbsolute(path)) {
- throw new ArgumentError("Path must be absolute : $path");
+ throw ArgumentError("Path must be absolute : $path");
}
if (pathContext.normalize(path) != path) {
- throw new ArgumentError("Path must be normalized : $path");
+ throw ArgumentError("Path must be normalized : $path");
}
}
@@ -257,9 +257,9 @@
if (folder == null) {
newFolder(folderPath);
} else if (folder is! Folder) {
- throw new ArgumentError('Cannot create file ($path) as child of file');
+ throw ArgumentError('Cannot create file ($path) as child of file');
}
- _MemoryFile file = new _MemoryFile(this, path);
+ _MemoryFile file = _MemoryFile(this, path);
_pathToResource[path] = file;
return file;
}
@@ -270,7 +270,7 @@
if (watcherPath == path || pathContext.isWithin(watcherPath, path)) {
for (StreamController<WatchEvent> streamController
in streamControllers) {
- streamController.add(new WatchEvent(changeType, path));
+ streamController.add(WatchEvent(changeType, path));
}
}
});
@@ -283,7 +283,7 @@
}
_MemoryResource existingNewResource = _pathToResource[newPath];
if (existingNewResource is _MemoryFolder) {
- throw new FileSystemException(
+ throw FileSystemException(
path, 'Could not be renamed: $newPath is a folder.');
}
_MemoryFile newFile = _newFile(newPath);
@@ -317,7 +317,7 @@
@override
Stream<WatchEvent> get changes {
- throw new FileSystemException(path, "File does not exist");
+ throw FileSystemException(path, "File does not exist");
}
@override
@@ -325,31 +325,31 @@
@override
int get lengthSync {
- throw new FileSystemException(path, 'File could not be read');
+ throw FileSystemException(path, 'File could not be read');
}
@override
int get modificationStamp {
int stamp = _provider._pathToTimestamp[path];
if (stamp == null) {
- throw new FileSystemException(path, "File does not exist");
+ throw FileSystemException(path, "File does not exist");
}
return stamp;
}
@override
File copyTo(Folder parentFolder) {
- throw new FileSystemException(path, 'File could not be copied');
+ throw FileSystemException(path, 'File could not be copied');
}
@override
Source createSource([Uri uri]) {
- throw new FileSystemException(path, 'File could not be read');
+ throw FileSystemException(path, 'File could not be read');
}
@override
void delete() {
- throw new FileSystemException(path, 'File could not be deleted');
+ throw FileSystemException(path, 'File could not be deleted');
}
@override
@@ -359,32 +359,32 @@
@override
Uint8List readAsBytesSync() {
- throw new FileSystemException(path, 'File could not be read');
+ throw FileSystemException(path, 'File could not be read');
}
@override
String readAsStringSync() {
- throw new FileSystemException(path, 'File could not be read');
+ throw FileSystemException(path, 'File could not be read');
}
@override
File renameSync(String newPath) {
- throw new FileSystemException(path, 'File could not be renamed');
+ throw FileSystemException(path, 'File could not be renamed');
}
@override
File resolveSymbolicLinksSync() {
- return throw new FileSystemException(path, "File does not exist");
+ return throw FileSystemException(path, "File does not exist");
}
@override
void writeAsBytesSync(List<int> bytes) {
- throw new FileSystemException(path, 'File could not be written');
+ throw FileSystemException(path, 'File could not be written');
}
@override
void writeAsStringSync(String content) {
- throw new FileSystemException(path, 'File could not be written');
+ throw FileSystemException(path, 'File could not be written');
}
}
@@ -407,7 +407,7 @@
int get modificationStamp {
int stamp = _provider._pathToTimestamp[path];
if (stamp == null) {
- throw new FileSystemException(path, 'File "$path" does not exist.');
+ throw FileSystemException(path, 'File "$path" does not exist.');
}
return stamp;
}
@@ -423,7 +423,7 @@
@override
Source createSource([Uri uri]) {
uri ??= _provider.pathContext.toUri(path);
- return new FileSource(this, uri);
+ return FileSource(this, uri);
}
@override
@@ -440,7 +440,7 @@
Uint8List readAsBytesSync() {
Uint8List content = _provider._pathToBytes[path];
if (content == null) {
- throw new FileSystemException(path, 'File "$path" does not exist.');
+ throw FileSystemException(path, 'File "$path" does not exist.');
}
return content;
}
@@ -449,7 +449,7 @@
String readAsStringSync() {
Uint8List content = _provider._pathToBytes[path];
if (content == null) {
- throw new FileSystemException(path, 'File "$path" does not exist.');
+ throw FileSystemException(path, 'File "$path" does not exist.');
}
return utf8.decode(content);
}
@@ -521,7 +521,7 @@
String childPath = canonicalizePath(relPath);
_MemoryResource resource = _provider._pathToResource[childPath];
if (resource == null) {
- resource = new _MemoryFile(_provider, childPath);
+ resource = _MemoryFile(_provider, childPath);
}
return resource;
}
@@ -533,7 +533,7 @@
if (resource is _MemoryFile) {
return resource;
}
- return new _MemoryFile(_provider, childPath);
+ return _MemoryFile(_provider, childPath);
}
@override
@@ -543,13 +543,13 @@
if (resource is _MemoryFolder) {
return resource;
}
- return new _MemoryFolder(_provider, childPath);
+ return _MemoryFolder(_provider, childPath);
}
@override
List<Resource> getChildren() {
if (!exists) {
- throw new FileSystemException(path, 'Folder does not exist.');
+ throw FileSystemException(path, 'Folder does not exist.');
}
List<Resource> children = <Resource>[];
_provider._pathToResource.forEach((resourcePath, resource) {
@@ -587,7 +587,7 @@
Stream<WatchEvent> get changes {
StreamController<WatchEvent> streamController =
- new StreamController<WatchEvent>();
+ StreamController<WatchEvent>();
if (!_provider._pathToWatchers.containsKey(path)) {
_provider._pathToWatchers[path] = <StreamController<WatchEvent>>[];
}
diff --git a/pkg/analyzer/lib/file_system/overlay_file_system.dart b/pkg/analyzer/lib/file_system/overlay_file_system.dart
index 216a886..f8ec96b 100644
--- a/pkg/analyzer/lib/file_system/overlay_file_system.dart
+++ b/pkg/analyzer/lib/file_system/overlay_file_system.dart
@@ -52,12 +52,11 @@
pathos.Context get pathContext => baseProvider.pathContext;
@override
- File getFile(String path) =>
- new _OverlayFile(this, baseProvider.getFile(path));
+ File getFile(String path) => _OverlayFile(this, baseProvider.getFile(path));
@override
Folder getFolder(String path) =>
- new _OverlayFolder(this, baseProvider.getFolder(path));
+ _OverlayFolder(this, baseProvider.getFolder(path));
@override
Future<List<int>> getModificationTimes(List<Source> sources) async {
@@ -73,16 +72,16 @@
@override
Resource getResource(String path) {
if (hasOverlay(path)) {
- return new _OverlayResource._from(this, baseProvider.getFile(path));
+ return _OverlayResource._from(this, baseProvider.getFile(path));
} else if (_hasOverlayIn(path)) {
- return new _OverlayResource._from(this, baseProvider.getFolder(path));
+ return _OverlayResource._from(this, baseProvider.getFolder(path));
}
- return new _OverlayResource._from(this, baseProvider.getResource(path));
+ return _OverlayResource._from(this, baseProvider.getResource(path));
}
@override
Folder getStateLocation(String pluginId) =>
- new _OverlayFolder(this, baseProvider.getStateLocation(pluginId));
+ _OverlayFolder(this, baseProvider.getStateLocation(pluginId));
/**
* Return `true` if there is an overlay associated with the file at the given
@@ -109,10 +108,10 @@
void setOverlay(String path,
{@required String content, @required int modificationStamp}) {
if (content == null) {
- throw new ArgumentError(
+ throw ArgumentError(
'OverlayResourceProvider.setOverlay: content cannot be null');
} else if (modificationStamp == null) {
- throw new ArgumentError(
+ throw ArgumentError(
'OverlayResourceProvider.setOverlay: modificationStamp cannot be null');
}
_overlayContent[path] = content;
@@ -208,18 +207,17 @@
_provider._copyOverlay(path, newPath);
if (_file.exists) {
if (parentFolder is _OverlayFolder) {
- return new _OverlayFile(_provider, _file.copyTo(parentFolder._folder));
+ return _OverlayFile(_provider, _file.copyTo(parentFolder._folder));
}
- return new _OverlayFile(_provider, _file.copyTo(parentFolder));
+ return _OverlayFile(_provider, _file.copyTo(parentFolder));
} else {
- return new _OverlayFile(
- _provider, _provider.baseProvider.getFile(newPath));
+ return _OverlayFile(_provider, _provider.baseProvider.getFile(newPath));
}
}
@override
Source createSource([Uri uri]) =>
- new FileSource(this, uri ?? _provider.pathContext.toUri(path));
+ FileSource(this, uri ?? _provider.pathContext.toUri(path));
@override
void delete() {
@@ -227,7 +225,7 @@
if (_resource.exists) {
_resource.delete();
} else if (!hadOverlay) {
- throw new FileSystemException(path, 'does not exist');
+ throw FileSystemException(path, 'does not exist');
}
}
@@ -258,19 +256,18 @@
modificationStamp: _provider._getOverlayModificationStamp(path));
_provider.removeOverlay(path);
}
- return new _OverlayFile(_provider, newFile);
+ return _OverlayFile(_provider, newFile);
}
@override
void writeAsBytesSync(List<int> bytes) {
- writeAsStringSync(new String.fromCharCodes(bytes));
+ writeAsStringSync(String.fromCharCodes(bytes));
}
@override
void writeAsStringSync(String content) {
if (_provider.hasOverlay(path)) {
- throw new FileSystemException(
- path, 'Cannot write a file with an overlay');
+ throw FileSystemException(path, 'Cannot write a file with an overlay');
}
_file.writeAsStringSync(content);
}
@@ -329,22 +326,22 @@
@override
Resource getChild(String relPath) =>
- new _OverlayResource._from(_provider, _folder.getChild(relPath));
+ _OverlayResource._from(_provider, _folder.getChild(relPath));
@override
File getChildAssumingFile(String relPath) =>
- new _OverlayFile(_provider, _folder.getChildAssumingFile(relPath));
+ _OverlayFile(_provider, _folder.getChildAssumingFile(relPath));
@override
Folder getChildAssumingFolder(String relPath) =>
- new _OverlayFolder(_provider, _folder.getChildAssumingFolder(relPath));
+ _OverlayFolder(_provider, _folder.getChildAssumingFolder(relPath));
@override
List<Resource> getChildren() {
Map<String, Resource> children = {};
try {
for (final child in _folder.getChildren()) {
- children[child.path] = new _OverlayResource._from(_provider, child);
+ children[child.path] = _OverlayResource._from(_provider, child);
}
} on FileSystemException {
// We don't want to throw if we're a folder that only exists in the overlay
@@ -395,11 +392,11 @@
factory _OverlayResource._from(
OverlayResourceProvider provider, Resource resource) {
if (resource is Folder) {
- return new _OverlayFolder(provider, resource);
+ return _OverlayFolder(provider, resource);
} else if (resource is File) {
- return new _OverlayFile(provider, resource);
+ return _OverlayFile(provider, resource);
}
- throw new ArgumentError('Unknown resource type: ${resource.runtimeType}');
+ throw ArgumentError('Unknown resource type: ${resource.runtimeType}');
}
@override
@@ -411,7 +408,7 @@
if (parent == null) {
return null;
}
- return new _OverlayFolder(_provider, parent);
+ return _OverlayFolder(_provider, parent);
}
@override
@@ -439,8 +436,8 @@
}
@override
- Resource resolveSymbolicLinksSync() => new _OverlayResource._from(
- _provider, _resource.resolveSymbolicLinksSync());
+ Resource resolveSymbolicLinksSync() =>
+ _OverlayResource._from(_provider, _resource.resolveSymbolicLinksSync());
@override
Uri toUri() => _resource.toUri();
diff --git a/pkg/analyzer/lib/file_system/physical_file_system.dart b/pkg/analyzer/lib/file_system/physical_file_system.dart
index fa9ce48..b6d6eca 100644
--- a/pkg/analyzer/lib/file_system/physical_file_system.dart
+++ b/pkg/analyzer/lib/file_system/physical_file_system.dart
@@ -49,7 +49,7 @@
return paths.map((path) {
if (path != null) {
try {
- io.File file = new io.File(path);
+ io.File file = io.File(path);
return file.lastModifiedSync().millisecondsSinceEpoch;
} catch (_) {
return -1;
@@ -65,10 +65,10 @@
*/
class PhysicalResourceProvider implements ResourceProvider {
static final String Function(String) NORMALIZE_EOL_ALWAYS =
- (String string) => string.replaceAll(new RegExp('\r\n?'), '\n');
+ (String string) => string.replaceAll(RegExp('\r\n?'), '\n');
static final PhysicalResourceProvider INSTANCE =
- new PhysicalResourceProvider(null);
+ PhysicalResourceProvider(null);
/**
* The path to the base folder where state is stored.
@@ -89,13 +89,13 @@
@override
File getFile(String path) {
_ensureAbsoluteAndNormalized(path);
- return new _PhysicalFile(new io.File(path));
+ return _PhysicalFile(io.File(path));
}
@override
Folder getFolder(String path) {
_ensureAbsoluteAndNormalized(path);
- return new _PhysicalFolder(new io.Directory(path));
+ return _PhysicalFolder(io.Directory(path));
}
@override
@@ -119,9 +119,9 @@
@override
Folder getStateLocation(String pluginId) {
if (_stateLocation != null) {
- io.Directory directory = new io.Directory(join(_stateLocation, pluginId));
+ io.Directory directory = io.Directory(join(_stateLocation, pluginId));
directory.createSync(recursive: true);
- return new _PhysicalFolder(directory);
+ return _PhysicalFolder(directory);
}
return null;
}
@@ -133,10 +133,10 @@
void _ensureAbsoluteAndNormalized(String path) {
assert(() {
if (!pathContext.isAbsolute(path)) {
- throw new ArgumentError("Path must be absolute : $path");
+ throw ArgumentError("Path must be absolute : $path");
}
if (pathContext.normalize(path) != path) {
- throw new ArgumentError("Path must be normalized : $path");
+ throw ArgumentError("Path must be normalized : $path");
}
return true;
}());
@@ -150,14 +150,14 @@
_PhysicalFile(io.File file) : super(file);
@override
- Stream<WatchEvent> get changes => new FileWatcher(_entry.path).events;
+ Stream<WatchEvent> get changes => FileWatcher(_entry.path).events;
@override
int get lengthSync {
try {
return _file.lengthSync();
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
@@ -166,7 +166,7 @@
try {
return _file.lastModifiedSync().millisecondsSinceEpoch;
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
@@ -185,7 +185,7 @@
@override
Source createSource([Uri uri]) {
- return new FileSource(this, uri ?? pathContext.toUri(path));
+ return FileSource(this, uri ?? pathContext.toUri(path));
}
@override
@@ -199,7 +199,7 @@
try {
return _file.readAsBytesSync();
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
@@ -209,37 +209,37 @@
try {
return FileBasedSource.fileReadMode(_file.readAsStringSync());
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
@override
File renameSync(String newPath) {
try {
- return new _PhysicalFile(_file.renameSync(newPath));
+ return _PhysicalFile(_file.renameSync(newPath));
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
@override
File resolveSymbolicLinksSync() {
try {
- return new _PhysicalFile(new io.File(_file.resolveSymbolicLinksSync()));
+ return _PhysicalFile(io.File(_file.resolveSymbolicLinksSync()));
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
@override
- Uri toUri() => new Uri.file(path);
+ Uri toUri() => Uri.file(path);
@override
void writeAsBytesSync(List<int> bytes) {
try {
_file.writeAsBytesSync(bytes);
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
@@ -248,7 +248,7 @@
try {
_file.writeAsStringSync(content);
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
}
@@ -261,7 +261,7 @@
@override
Stream<WatchEvent> get changes =>
- new DirectoryWatcher(_entry.path).events.handleError((error) {},
+ DirectoryWatcher(_entry.path).events.handleError((error) {},
test: (error) =>
error is io.FileSystemException &&
// Don't suppress "Directory watcher closed," so the outer
@@ -309,15 +309,15 @@
@override
_PhysicalFile getChildAssumingFile(String relPath) {
String canonicalPath = canonicalizePath(relPath);
- io.File file = new io.File(canonicalPath);
- return new _PhysicalFile(file);
+ io.File file = io.File(canonicalPath);
+ return _PhysicalFile(file);
}
@override
_PhysicalFolder getChildAssumingFolder(String relPath) {
String canonicalPath = canonicalizePath(relPath);
- io.Directory directory = new io.Directory(canonicalPath);
- return new _PhysicalFolder(directory);
+ io.Directory directory = io.Directory(canonicalPath);
+ return _PhysicalFolder(directory);
}
@override
@@ -330,14 +330,14 @@
for (int i = 0; i < numEntries; i++) {
io.FileSystemEntity entity = entries[i];
if (entity is io.Directory) {
- children.add(new _PhysicalFolder(entity));
+ children.add(_PhysicalFolder(entity));
} else if (entity is io.File) {
- children.add(new _PhysicalFile(entity));
+ children.add(_PhysicalFile(entity));
}
}
return children;
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
@@ -352,15 +352,15 @@
@override
Folder resolveSymbolicLinksSync() {
try {
- return new _PhysicalFolder(
- new io.Directory(_directory.resolveSymbolicLinksSync()));
+ return _PhysicalFolder(
+ io.Directory(_directory.resolveSymbolicLinksSync()));
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
@override
- Uri toUri() => new Uri.directory(path);
+ Uri toUri() => Uri.directory(path);
}
/**
@@ -383,7 +383,7 @@
if (parentPath == path) {
return null;
}
- return new _PhysicalFolder(new io.Directory(parentPath));
+ return _PhysicalFolder(io.Directory(parentPath));
}
@override
@@ -410,7 +410,7 @@
try {
_entry.deleteSync(recursive: true);
} on io.FileSystemException catch (exception) {
- throw new FileSystemException(exception.path, exception.message);
+ throw FileSystemException(exception.path, exception.message);
}
}
@@ -438,7 +438,7 @@
shortName == r'COM2' ||
shortName == r'COM3' ||
shortName == r'COM4') {
- throw new FileSystemException(
+ throw FileSystemException(
path, 'Windows device drivers cannot be read.');
}
}
diff --git a/pkg/analyzer/lib/instrumentation/file_instrumentation.dart b/pkg/analyzer/lib/instrumentation/file_instrumentation.dart
index 5de75d8..47d50e6 100644
--- a/pkg/analyzer/lib/instrumentation/file_instrumentation.dart
+++ b/pkg/analyzer/lib/instrumentation/file_instrumentation.dart
@@ -14,7 +14,7 @@
IOSink _sink;
FileInstrumentationLogger(this.filePath) {
- File file = new File(filePath);
+ File file = File(filePath);
_sink = file.openWrite();
}
diff --git a/pkg/analyzer/lib/instrumentation/log_adapter.dart b/pkg/analyzer/lib/instrumentation/log_adapter.dart
index ff85100..f00bc49 100644
--- a/pkg/analyzer/lib/instrumentation/log_adapter.dart
+++ b/pkg/analyzer/lib/instrumentation/log_adapter.dart
@@ -32,7 +32,7 @@
InstrumentationLogAdapter(this._instrumentationLogger);
/// The current time, expressed as a decimal encoded number of milliseconds.
- String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString();
+ String get _timestamp => DateTime.now().millisecondsSinceEpoch.toString();
@override
void logError(String message) => _log(TAG_ERROR, message);
@@ -190,7 +190,7 @@
/// Return the result of joining the values of the given fields, escaping the
/// separator character by doubling it.
String _join(List<String> fields) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write(_timestamp);
int length = fields.length;
for (int i = 0; i < length; i++) {
diff --git a/pkg/analyzer/lib/source/embedder.dart b/pkg/analyzer/lib/source/embedder.dart
index a1af355..4d57d49 100644
--- a/pkg/analyzer/lib/source/embedder.dart
+++ b/pkg/analyzer/lib/source/embedder.dart
@@ -32,7 +32,7 @@
/// An SDK backed by URI mappings derived from an `_embedder.yaml` file.
@deprecated
class EmbedderSdk extends AbstractDartSdk {
- final Map<String, String> _urlMappings = new HashMap<String, String>();
+ final Map<String, String> _urlMappings = HashMap<String, String>();
EmbedderSdk([Map<Folder, YamlMap> embedderYamls]) {
embedderYamls?.forEach(_processEmbedderYaml);
@@ -88,8 +88,8 @@
}
String filePath = srcPath.replaceAll('/', io.Platform.pathSeparator);
try {
- JavaFile file = new JavaFile(filePath);
- return new FileBasedSource(file, Uri.parse(dartUri));
+ JavaFile file = JavaFile(filePath);
+ return FileBasedSource(file, Uri.parse(dartUri));
} on FormatException {
return null;
}
@@ -103,7 +103,7 @@
}
String libPath = libDir.canonicalizePath(file);
_urlMappings[name] = libPath;
- SdkLibraryImpl library = new SdkLibraryImpl(name);
+ SdkLibraryImpl library = SdkLibraryImpl(name);
library.path = libPath;
libraryMap.setLibrary(name, library);
}
@@ -157,11 +157,11 @@
/// Construct a [EmbedderUriResolver] from a package map
/// (see [PackageMapProvider]).
EmbedderUriResolver(Map<Folder, YamlMap> embedderMap)
- : this._forSdk(new EmbedderSdk(embedderMap));
+ : this._forSdk(EmbedderSdk(embedderMap));
/// (Provisional API.)
EmbedderUriResolver._forSdk(this._embedderSdk) {
- _dartUriResolver = new DartUriResolver(_embedderSdk);
+ _dartUriResolver = DartUriResolver(_embedderSdk);
}
@override
diff --git a/pkg/analyzer/lib/source/error_processor.dart b/pkg/analyzer/lib/source/error_processor.dart
index f2efaba..ad9bbd6 100644
--- a/pkg/analyzer/lib/source/error_processor.dart
+++ b/pkg/analyzer/lib/source/error_processor.dart
@@ -33,11 +33,11 @@
code = toUpperCase(code);
action = toLowerCase(action);
if (AnalyzerOptions.ignoreSynonyms.contains(action)) {
- processors.add(new ErrorProcessor.ignore(code));
+ processors.add(ErrorProcessor.ignore(code));
} else {
ErrorSeverity severity = _toSeverity(action);
if (severity != null) {
- processors.add(new ErrorProcessor(code, severity));
+ processors.add(ErrorProcessor(code, severity));
}
}
}
@@ -72,7 +72,7 @@
ErrorProcessor(this.code, [this.severity]);
/// Create an error processor that ignores the given error by [code].
- factory ErrorProcessor.ignore(String code) => new ErrorProcessor(code);
+ factory ErrorProcessor.ignore(String code) => ErrorProcessor(code);
/// The string that unique describes the processor.
String get description => '$code -> ${severity?.name}';
diff --git a/pkg/analyzer/lib/source/line_info.dart b/pkg/analyzer/lib/source/line_info.dart
index 457f38e..da03c3b 100644
--- a/pkg/analyzer/lib/source/line_info.dart
+++ b/pkg/analyzer/lib/source/line_info.dart
@@ -42,9 +42,9 @@
*/
LineInfo(this.lineStarts) {
if (lineStarts == null) {
- throw new ArgumentError("lineStarts must be non-null");
+ throw ArgumentError("lineStarts must be non-null");
} else if (lineStarts.isEmpty) {
- throw new ArgumentError("lineStarts must be non-empty");
+ throw ArgumentError("lineStarts must be non-empty");
}
}
@@ -53,7 +53,7 @@
* given file [content].
*/
factory LineInfo.fromContent(String content) =>
- new LineInfo(StringUtilities.computeLineStarts(content));
+ LineInfo(StringUtilities.computeLineStarts(content));
/**
* The number of lines.
@@ -82,7 +82,7 @@
// Before kicking off a full binary search, do a quick check here to see
// if the new offset is on that exact line.
if (min == lineStarts.length - 1 || offset < lineStarts[min + 1]) {
- return new CharacterLocation(min + 1, offset - lineStarts[min] + 1);
+ return CharacterLocation(min + 1, offset - lineStarts[min] + 1);
}
}
@@ -99,7 +99,7 @@
_previousLine = min;
- return new CharacterLocation(min + 1, offset - lineStarts[min] + 1);
+ return CharacterLocation(min + 1, offset - lineStarts[min] + 1);
}
/**
@@ -108,7 +108,7 @@
*/
int getOffsetOfLine(int lineNumber) {
if (lineNumber < 0 || lineNumber >= lineCount) {
- throw new ArgumentError(
+ throw ArgumentError(
'Invalid line number: $lineNumber; must be between 0 and ${lineCount - 1}');
}
return lineStarts[lineNumber];
diff --git a/pkg/analyzer/lib/source/source_range.dart b/pkg/analyzer/lib/source/source_range.dart
index b2d3069..3f1daeb 100644
--- a/pkg/analyzer/lib/source/source_range.dart
+++ b/pkg/analyzer/lib/source/source_range.dart
@@ -79,20 +79,19 @@
* source range and [delta] characters after the end of this source range.
*/
SourceRange getExpanded(int delta) =>
- new SourceRange(offset - delta, delta + length + delta);
+ SourceRange(offset - delta, delta + length + delta);
/**
* Return a source range with the same offset as this source range but whose
* length is [delta] characters longer than this source range.
*/
- SourceRange getMoveEnd(int delta) => new SourceRange(offset, length + delta);
+ SourceRange getMoveEnd(int delta) => SourceRange(offset, length + delta);
/**
* Return a source range with the same length as this source range but whose
* offset is [delta] characters after the offset of this source range.
*/
- SourceRange getTranslated(int delta) =>
- new SourceRange(offset + delta, length);
+ SourceRange getTranslated(int delta) => SourceRange(offset + delta, length);
/**
* Return the minimal source range that covers both this and the [otherRange].
@@ -101,7 +100,7 @@
int newOffset = math.min(offset, otherRange.offset);
int newEnd =
math.max(offset + length, otherRange.offset + otherRange.length);
- return new SourceRange(newOffset, newEnd - newOffset);
+ return SourceRange(newOffset, newEnd - newOffset);
}
/**
diff --git a/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart b/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart
index 2566e22..41ffce6 100644
--- a/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart
+++ b/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart
@@ -27,10 +27,10 @@
/// Recursively merge options referenced by an include directive
/// and remove the include directive from the resulting options map.
/// Return an empty options map if the file does not exist.
- YamlMap getOptions(Folder root, {bool crawlUp: false}) {
+ YamlMap getOptions(Folder root, {bool crawlUp = false}) {
File optionsFile = getOptionsFile(root, crawlUp: crawlUp);
if (optionsFile == null) {
- return new YamlMap();
+ return YamlMap();
}
return getOptionsFromFile(optionsFile);
}
@@ -40,7 +40,7 @@
///
/// The given [root] directory will be searched first. If no file is found and
/// if [crawlUp] is `true`, then enclosing directories will be searched.
- File getOptionsFile(Folder root, {bool crawlUp: false}) {
+ File getOptionsFile(Folder root, {bool crawlUp = false}) {
Resource resource;
for (Folder folder = root; folder != null; folder = folder.parent) {
resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_FILE);
@@ -63,7 +63,7 @@
/// and remove the include directive from the resulting options map.
/// Return an empty options map if the file does not exist.
YamlMap getOptionsFromFile(File file) {
- return getOptionsFromSource(new FileSource(file));
+ return getOptionsFromSource(FileSource(file));
}
/// Provide the options found in [source].
@@ -89,18 +89,18 @@
/// Return an empty options map if the source is null.
YamlMap getOptionsFromString(String optionsSource) {
if (optionsSource == null) {
- return new YamlMap();
+ return YamlMap();
}
try {
YamlNode doc = loadYamlNode(optionsSource);
if (doc is YamlMap) {
return doc;
}
- return new YamlMap();
+ return YamlMap();
} on YamlException catch (e) {
- throw new OptionsFormatException(e.message, e.span);
+ throw OptionsFormatException(e.message, e.span);
} catch (e) {
- throw new OptionsFormatException('Unable to parse YAML document.');
+ throw OptionsFormatException('Unable to parse YAML document.');
}
}
@@ -117,7 +117,7 @@
/// * if map values cannot be merged, the overriding value is taken.
///
YamlMap merge(YamlMap defaults, YamlMap overrides) =>
- new Merger().mergeMap(defaults, overrides);
+ Merger().mergeMap(defaults, overrides);
/// Read the contents of [source] as a string.
/// Returns null if source is null or does not exist.
diff --git a/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart b/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart
index a82fb5e..ff8c3df 100644
--- a/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart
+++ b/pkg/analyzer/lib/src/analysis_options/error/option_codes.dart
@@ -60,7 +60,7 @@
const AnalysisOptionsHintCode(
'DEPRECATED_ANALYSIS_OPTIONS_FILE_NAME',
"The name of the analysis options file {0} is deprecated;"
- " consider renaming it to analysis_options.yaml.");
+ " consider renaming it to analysis_options.yaml.");
/**
* An error code indicating that the enablePreviewDart2 setting is deprecated.
@@ -192,7 +192,7 @@
const AnalysisOptionsWarningCode(
'UNSUPPORTED_OPTION_WITH_LEGAL_VALUE',
"The option '{1}' isn't supported by '{0}'. "
- "Try using the only supported option: '{2}'.");
+ "Try using the only supported option: '{2}'.");
/**
* An error code indicating that a plugin is being configured with an
diff --git a/pkg/analyzer/lib/src/command_line/arguments.dart b/pkg/analyzer/lib/src/command_line/arguments.dart
index 91a13f0..b237970 100644
--- a/pkg/analyzer/lib/src/command_line/arguments.dart
+++ b/pkg/analyzer/lib/src/command_line/arguments.dart
@@ -66,7 +66,7 @@
*/
ContextBuilderOptions createContextBuilderOptions(ArgResults args,
{bool trackCacheDependencies}) {
- ContextBuilderOptions builderOptions = new ContextBuilderOptions();
+ ContextBuilderOptions builderOptions = ContextBuilderOptions();
builderOptions.argResults = args;
//
// File locations.
@@ -79,7 +79,7 @@
//
// Analysis options.
//
- AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl defaultOptions = AnalysisOptionsImpl();
applyAnalysisOptionFlags(defaultOptions, args);
if (trackCacheDependencies != null) {
defaultOptions.trackCacheDependencies = trackCacheDependencies;
@@ -127,7 +127,7 @@
sourcePath = context.normalize(sourcePath);
return !context.isWithin(sdkPath, sourcePath);
});
- return new DartSdkManager(
+ return DartSdkManager(
sdkPath ?? FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)?.path,
canUseSummaries);
}
@@ -140,7 +140,8 @@
* TODO(danrubel) Update DDC to support all the options defined in this method
* then remove the [ddc] named argument from this method.
*/
-void defineAnalysisArguments(ArgParser parser, {bool hide: true, ddc: false}) {
+void defineAnalysisArguments(ArgParser parser,
+ {bool hide = true, ddc = false}) {
parser.addOption(sdkPathOption,
help: 'The path to the Dart SDK.', hide: ddc && hide);
parser.addOption(analysisOptionsFileOption,
@@ -245,8 +246,8 @@
* '--ignore-unrecognized-flags' option.
*/
List<String> filterUnknownArguments(List<String> args, ArgParser parser) {
- Set<String> knownOptions = new HashSet<String>();
- Set<String> knownAbbreviations = new HashSet<String>();
+ Set<String> knownOptions = HashSet<String>();
+ Set<String> knownAbbreviations = HashSet<String>();
parser.options.forEach((String name, Option option) {
knownOptions.add(name);
String abbreviation = option.abbr;
@@ -303,7 +304,7 @@
* Always returns a new modifiable list.
*/
List<String> preprocessArgs(ResourceProvider provider, List<String> args) {
- args = new List.from(args);
+ args = List.from(args);
if (args.isEmpty) {
return args;
}
@@ -319,7 +320,7 @@
.split('\n')
.where((String line) => line.isNotEmpty));
} on FileSystemException catch (e) {
- throw new Exception('Failed to read file specified by $lastArg : $e');
+ throw Exception('Failed to read file specified by $lastArg : $e');
}
}
return args;
diff --git a/pkg/analyzer/lib/src/context/builder.dart b/pkg/analyzer/lib/src/context/builder.dart
index bb0b380..26ad5807 100644
--- a/pkg/analyzer/lib/src/context/builder.dart
+++ b/pkg/analyzer/lib/src/context/builder.dart
@@ -147,7 +147,7 @@
*/
ContextBuilder(this.resourceProvider, this.sdkManager, this.contentCache,
{ContextBuilderOptions options})
- : builderOptions = options ?? new ContextBuilderOptions();
+ : builderOptions = options ?? ContextBuilderOptions();
/**
* Return an analysis driver that is configured correctly to analyze code in
@@ -164,7 +164,7 @@
}
final sf = createSourceFactory(path, options, summaryData: summaryData);
- AnalysisDriver driver = new AnalysisDriver(
+ AnalysisDriver driver = AnalysisDriver(
analysisDriverScheduler,
performanceLog,
resourceProvider,
@@ -199,7 +199,7 @@
}
Map<String, List<Folder>> convertPackagesToMap(Packages packages) {
- Map<String, List<Folder>> folderMap = new HashMap<String, List<Folder>>();
+ Map<String, List<Folder>> folderMap = HashMap<String, List<Folder>>();
if (packages != null && packages != Packages.noPackages) {
var pathContext = resourceProvider.pathContext;
packages.asMap().forEach((String packageName, Uri uri) {
@@ -239,9 +239,9 @@
AnalysisOptions createDefaultOptions() {
AnalysisOptions defaultOptions = builderOptions.defaultOptions;
if (defaultOptions == null) {
- return new AnalysisOptionsImpl();
+ return AnalysisOptionsImpl();
}
- return new AnalysisOptionsImpl.from(defaultOptions);
+ return AnalysisOptionsImpl.from(defaultOptions);
}
Packages createPackageMap(String rootDirectoryPath) {
@@ -251,7 +251,7 @@
List<int> bytes = configFile.readAsBytesSync();
Map<String, Uri> map = parse(bytes, configFile.toUri());
resolveSymbolicLinks(map);
- return new MapPackages(map);
+ return MapPackages(map);
}
String directoryPath = builderOptions.defaultPackagesDirectoryPath;
if (directoryPath != null) {
@@ -279,7 +279,8 @@
void declareVariablesInDriver(AnalysisDriver driver) {
Map<String, String> variables = builderOptions.declaredVariables;
if (variables != null && variables.isNotEmpty) {
- driver.declaredVariables = new DeclaredVariables.fromMap(variables);
+ driver.declaredVariables = DeclaredVariables.fromMap(variables);
+ driver.configure();
}
}
@@ -307,7 +308,7 @@
return Packages.noPackages;
}
resolveSymbolicLinks(map);
- return new MapPackages(map);
+ return MapPackages(map);
} else if (location is Folder) {
return getPackagesFromFolder(location);
}
@@ -322,15 +323,14 @@
Map<String, List<Folder>> packageMap, AnalysisOptions analysisOptions) {
String summaryPath = builderOptions.dartSdkSummaryPath;
if (summaryPath != null) {
- return new SummaryBasedDartSdk(summaryPath, true,
+ return SummaryBasedDartSdk(summaryPath, true,
resourceProvider: resourceProvider);
} else if (packageMap != null) {
- SdkExtensionFinder extFinder = new SdkExtensionFinder(packageMap);
+ SdkExtensionFinder extFinder = SdkExtensionFinder(packageMap);
List<String> extFilePaths = extFinder.extensionFilePaths;
- EmbedderYamlLocator locator = new EmbedderYamlLocator(packageMap);
+ EmbedderYamlLocator locator = EmbedderYamlLocator(packageMap);
Map<Folder, YamlMap> embedderYamls = locator.embedderYamls;
- EmbedderSdk embedderSdk =
- new EmbedderSdk(resourceProvider, embedderYamls);
+ EmbedderSdk embedderSdk = EmbedderSdk(resourceProvider, embedderYamls);
if (embedderSdk.sdkLibraries.isNotEmpty) {
//
// There is an embedder file that defines the content of the SDK and
@@ -343,7 +343,7 @@
.path);
}
paths.addAll(extFilePaths);
- SdkDescription description = new SdkDescription(paths, analysisOptions);
+ SdkDescription description = SdkDescription(paths, analysisOptions);
DartSdk dartSdk = sdkManager.getSdk(description, () {
if (extFilePaths.isNotEmpty) {
embedderSdk.addExtensions(extFinder.urlMappings);
@@ -360,9 +360,9 @@
String sdkPath = sdkManager.defaultSdkDirectory;
List<String> paths = <String>[sdkPath];
paths.addAll(extFilePaths);
- SdkDescription description = new SdkDescription(paths, analysisOptions);
+ SdkDescription description = SdkDescription(paths, analysisOptions);
return sdkManager.getSdk(description, () {
- FolderBasedDartSdk sdk = new FolderBasedDartSdk(
+ FolderBasedDartSdk sdk = FolderBasedDartSdk(
resourceProvider, resourceProvider.getFolder(sdkPath));
if (extFilePaths.isNotEmpty) {
sdk.addExtensions(extFinder.urlMappings);
@@ -375,7 +375,7 @@
}
String sdkPath = sdkManager.defaultSdkDirectory;
SdkDescription description =
- new SdkDescription(<String>[sdkPath], analysisOptions);
+ SdkDescription(<String>[sdkPath], analysisOptions);
return sdkManager.getSdk(description, () {
var sdk = FolderBasedDartSdk(
resourceProvider,
@@ -406,7 +406,7 @@
ContextBuilder.createWorkspace(resourceProvider, path, this);
SourceFactory sourceFactory = workspace.createSourceFactory(null, null);
AnalysisOptionsProvider optionsProvider =
- new AnalysisOptionsProvider(sourceFactory);
+ AnalysisOptionsProvider(sourceFactory);
AnalysisOptionsImpl options = createDefaultOptions();
File optionsFile = getOptionsFile(path);
@@ -460,7 +460,7 @@
var pubspecFile = _findPubspecFile(path);
if (pubspecFile != null) {
- var extractor = new SdkConstraintExtractor(pubspecFile);
+ var extractor = SdkConstraintExtractor(pubspecFile);
var sdkVersionConstraint = extractor.constraint();
if (sdkVersionConstraint != null) {
options.sdkVersionConstraint = sdkVersionConstraint;
@@ -478,7 +478,7 @@
* path. This allows cli to locate what *would* have been the analysis options
* file path, and super-impose the defaults over it in-place.
*/
- File getOptionsFile(String path, {bool forceSearch: false}) {
+ File getOptionsFile(String path, {bool forceSearch = false}) {
if (!forceSearch) {
String filePath = builderOptions.defaultAnalysisOptionsFilePath;
if (filePath != null) {
@@ -509,7 +509,7 @@
*/
Packages getPackagesFromFolder(Folder folder) {
Context pathContext = resourceProvider.pathContext;
- Map<String, Uri> map = new HashMap<String, Uri>();
+ Map<String, Uri> map = HashMap<String, Uri>();
for (Resource child in folder.getChildren()) {
if (child is Folder) {
// Inline resolveSymbolicLinks for performance reasons.
@@ -519,7 +519,7 @@
map[packageName] = pathContext.toUri(uriPath);
}
}
- return new MapPackages(map);
+ return MapPackages(map);
}
/**
@@ -733,7 +733,7 @@
/**
* A mapping from a package's library directory to the parsed YamlMap.
*/
- final Map<Folder, YamlMap> embedderYamls = new HashMap<Folder, YamlMap>();
+ final Map<Folder, YamlMap> embedderYamls = HashMap<Folder, YamlMap>();
/**
* Initialize a newly created locator by processing the packages in the given
diff --git a/pkg/analyzer/lib/src/context/context.dart b/pkg/analyzer/lib/src/context/context.dart
index 405869e..62588c6 100644
--- a/pkg/analyzer/lib/src/context/context.dart
+++ b/pkg/analyzer/lib/src/context/context.dart
@@ -14,7 +14,7 @@
/**
* An [AnalysisContext] in which analysis can be performed.
*/
-class AnalysisContextImpl implements InternalAnalysisContext {
+class AnalysisContextImpl implements AnalysisContext {
final SynchronousSession _synchronousSession;
@override
@@ -28,7 +28,7 @@
}
@override
- void set analysisOptions(AnalysisOptions options) {
+ set analysisOptions(AnalysisOptions options) {
throw StateError('Cannot be changed.');
}
@@ -38,10 +38,11 @@
}
@override
- void set sourceFactory(SourceFactory factory) {
+ set sourceFactory(SourceFactory factory) {
throw StateError('Cannot be changed.');
}
+ @Deprecated('Use LibraryElement.typeProvider')
@override
TypeProvider get typeProvider {
return _synchronousSession.typeProvider;
@@ -55,6 +56,7 @@
return _synchronousSession.typeProviderNonNullableByDefault;
}
+ @Deprecated('Use LibraryElement.typeSystem')
@override
TypeSystemImpl get typeSystem {
return _synchronousSession.typeSystem;
@@ -72,7 +74,6 @@
_synchronousSession.clearTypeProvider();
}
- @override
void setTypeProviders({
@required TypeProvider legacy,
@required TypeProvider nonNullableByDefault,
diff --git a/pkg/analyzer/lib/src/context/source.dart b/pkg/analyzer/lib/src/context/source.dart
index dd56ff4b..6468915 100644
--- a/pkg/analyzer/lib/src/context/source.dart
+++ b/pkg/analyzer/lib/src/context/source.dart
@@ -40,8 +40,7 @@
/**
* Cache of mapping of absolute [Uri]s to [Source]s.
*/
- final HashMap<Uri, Source> _absoluteUriToSourceCache =
- new HashMap<Uri, Source>();
+ final HashMap<Uri, Source> _absoluteUriToSourceCache = HashMap<Uri, Source>();
/**
* Initialize a newly created source factory with the given absolute URI
@@ -112,7 +111,7 @@
} catch (exception, stackTrace) {
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(
+ SilentException(
"Could not resolve URI: $absoluteUri", exception, stackTrace));
}
return null;
@@ -126,7 +125,7 @@
} on AnalysisException catch (exception, stackTrace) {
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(
+ SilentException(
"Could not resolve URI: $absoluteUri", exception, stackTrace));
}
}
@@ -148,7 +147,7 @@
containingSource != null ? containingSource.fullName : '<null>';
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService
- .logException(new SilentException(
+ .logException(SilentException(
"Could not resolve URI ($containedUri) "
"relative to source ($containingFullName)",
exception,
@@ -196,7 +195,7 @@
if (utils.startsWith(sourceUri, uri)) {
String relativePath = sourceUri.path
.substring(min(uri.path.length, sourceUri.path.length));
- return new Uri(scheme: 'package', path: '$name/$relativePath');
+ return Uri(scheme: 'package', path: '$name/$relativePath');
}
}
@@ -218,7 +217,7 @@
Source _internalResolveUri(Source containingSource, Uri containedUri) {
if (!containedUri.isAbsolute) {
if (containingSource == null) {
- throw new AnalysisException(
+ throw AnalysisException(
"Cannot resolve a relative URI without a containing source: "
"$containedUri");
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart b/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart
index 6360b32..31bd2c8 100644
--- a/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart
@@ -7,9 +7,7 @@
import 'package:analyzer/dart/analysis/context_locator.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
-import 'package:analyzer/src/dart/analysis/byte_store.dart';
import 'package:analyzer/src/dart/analysis/context_builder.dart';
-import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:meta/meta.dart';
/// An implementation of [AnalysisContextCollection].
@@ -22,9 +20,7 @@
/// Initialize a newly created analysis context manager.
AnalysisContextCollectionImpl(
- {bool enableIndex: false,
- @deprecated ByteStore byteStore,
- @deprecated FileContentOverlay fileContentOverlay,
+ {bool enableIndex = false,
@required List<String> includedPaths,
List<String> excludedPaths,
ResourceProvider resourceProvider,
@@ -36,7 +32,7 @@
_throwIfNotAbsoluteNormalizedPath(sdkPath);
}
- var contextLocator = new ContextLocator(
+ var contextLocator = ContextLocator(
resourceProvider: this.resourceProvider,
);
var roots = contextLocator.locateRoots(
@@ -44,14 +40,12 @@
excludedPaths: excludedPaths,
);
for (var root in roots) {
- var contextBuilder = new ContextBuilderImpl(
+ var contextBuilder = ContextBuilderImpl(
resourceProvider: this.resourceProvider,
);
var context = contextBuilder.createContext(
- byteStore: byteStore,
contextRoot: root,
enableIndex: enableIndex,
- fileContentOverlay: fileContentOverlay,
sdkPath: sdkPath,
);
contexts.add(context);
@@ -68,7 +62,7 @@
}
}
- throw new StateError('Unable to find the context to $path');
+ throw StateError('Unable to find the context to $path');
}
/// Check every element with [_throwIfNotAbsoluteNormalizedPath].
@@ -83,7 +77,7 @@
void _throwIfNotAbsoluteNormalizedPath(String path) {
var pathContext = resourceProvider.pathContext;
if (!pathContext.isAbsolute(path) || pathContext.normalize(path) != path) {
- throw new ArgumentError(
+ throw ArgumentError(
'Only absolute normalized paths are supported: $path');
}
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/byte_store.dart b/pkg/analyzer/lib/src/dart/analysis/byte_store.dart
index 6e7c301..b73493e 100644
--- a/pkg/analyzer/lib/src/dart/analysis/byte_store.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/byte_store.dart
@@ -54,7 +54,7 @@
final Cache<String, List<int>> _cache;
MemoryCachingByteStore(this._store, int maxSizeBytes)
- : _cache = new Cache<String, List<int>>(maxSizeBytes, (v) => v.length);
+ : _cache = Cache<String, List<int>>(maxSizeBytes, (v) => v.length);
@override
List<int> get(String key) {
diff --git a/pkg/analyzer/lib/src/dart/analysis/cache.dart b/pkg/analyzer/lib/src/dart/analysis/cache.dart
index 58a7253..19703fa 100644
--- a/pkg/analyzer/lib/src/dart/analysis/cache.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/cache.dart
@@ -11,7 +11,7 @@
final int _maxSizeBytes;
final int Function(V) _meter;
- final _map = new LinkedHashMap<K, V>();
+ final _map = LinkedHashMap<K, V>();
int _currentSizeBytes = 0;
Cache(this._maxSizeBytes, this._meter);
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
index 074d46d..ee087db 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
@@ -12,7 +12,7 @@
show ContextBuilder, ContextBuilderOptions;
import 'package:analyzer/src/context/context_root.dart' as old;
import 'package:analyzer/src/dart/analysis/byte_store.dart'
- show ByteStore, MemoryByteStore;
+ show MemoryByteStore;
import 'package:analyzer/src/dart/analysis/driver.dart'
show AnalysisDriver, AnalysisDriverScheduler;
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
@@ -52,34 +52,32 @@
@override
AnalysisContext createContext(
- {@deprecated ByteStore byteStore,
- @required ContextRoot contextRoot,
+ {@required ContextRoot contextRoot,
DeclaredVariables declaredVariables,
- bool enableIndex: false,
- @deprecated FileContentOverlay fileContentOverlay,
+ bool enableIndex = false,
List<String> librarySummaryPaths,
@deprecated PerformanceLog performanceLog,
@deprecated AnalysisDriverScheduler scheduler,
String sdkPath,
String sdkSummaryPath}) {
- byteStore ??= new MemoryByteStore();
- fileContentOverlay ??= new FileContentOverlay();
- performanceLog ??= new PerformanceLog(new StringBuffer());
+ var byteStore = MemoryByteStore();
+ var fileContentOverlay = FileContentOverlay();
+ performanceLog ??= PerformanceLog(StringBuffer());
sdkPath ??= _defaultSdkPath;
if (sdkPath == null) {
- throw new ArgumentError('Cannot find path to the SDK');
+ throw ArgumentError('Cannot find path to the SDK');
}
- DartSdkManager sdkManager = new DartSdkManager(sdkPath, true);
+ DartSdkManager sdkManager = DartSdkManager(sdkPath, true);
if (scheduler == null) {
- scheduler = new AnalysisDriverScheduler(performanceLog);
+ scheduler = AnalysisDriverScheduler(performanceLog);
scheduler.start();
}
// TODO(brianwilkerson) Move the required implementation from the old
// ContextBuilder to this class and remove the old class.
- old.ContextBuilderOptions options = new old.ContextBuilderOptions();
+ old.ContextBuilderOptions options = old.ContextBuilderOptions();
if (declaredVariables != null) {
options.declaredVariables = _toMap(declaredVariables);
}
@@ -91,8 +89,8 @@
}
options.defaultPackageFilePath = contextRoot.packagesFile?.path;
- old.ContextBuilder builder = new old.ContextBuilder(
- resourceProvider, sdkManager, new ContentCache(),
+ old.ContextBuilder builder = old.ContextBuilder(
+ resourceProvider, sdkManager, ContentCache(),
options: options);
builder.analysisDriverScheduler = scheduler;
builder.byteStore = byteStore;
@@ -100,7 +98,7 @@
builder.enableIndex = enableIndex;
builder.performanceLog = performanceLog;
- old.ContextRoot oldContextRoot = new old.ContextRoot(
+ old.ContextRoot oldContextRoot = old.ContextRoot(
contextRoot.root.path, contextRoot.excludedPaths.toList(),
pathContext: resourceProvider.pathContext);
AnalysisDriver driver = builder.buildDriver(oldContextRoot);
@@ -111,7 +109,7 @@
driver.exceptions.drain();
DriverBasedAnalysisContext context =
- new DriverBasedAnalysisContext(resourceProvider, contextRoot, driver);
+ DriverBasedAnalysisContext(resourceProvider, contextRoot, driver);
return context;
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
index 1f6826a..7edff35 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
@@ -75,7 +75,7 @@
@override
List<AnalysisContext> locateContexts(
{@required List<String> includedPaths,
- List<String> excludedPaths: const <String>[],
+ List<String> excludedPaths = const <String>[],
String optionsFile,
String packagesFile,
String sdkPath}) {
@@ -87,31 +87,29 @@
if (roots.isEmpty) {
return const <AnalysisContext>[];
}
- PerformanceLog performanceLog = new PerformanceLog(new StringBuffer());
- AnalysisDriverScheduler scheduler =
- new AnalysisDriverScheduler(performanceLog);
+ PerformanceLog performanceLog = PerformanceLog(StringBuffer());
+ AnalysisDriverScheduler scheduler = AnalysisDriverScheduler(performanceLog);
DartSdkManager sdkManager =
- new DartSdkManager(sdkPath ?? _defaultSdkPath, true);
+ DartSdkManager(sdkPath ?? _defaultSdkPath, true);
scheduler.start();
- ContextBuilderOptions options = new ContextBuilderOptions();
- ContextBuilder builder = new ContextBuilder(
- resourceProvider, sdkManager, null,
- options: options);
+ ContextBuilderOptions options = ContextBuilderOptions();
+ ContextBuilder builder =
+ ContextBuilder(resourceProvider, sdkManager, null, options: options);
if (packagesFile != null) {
options.defaultPackageFilePath = packagesFile;
}
builder.analysisDriverScheduler = scheduler;
- builder.byteStore = new MemoryByteStore();
- builder.fileContentOverlay = new FileContentOverlay();
+ builder.byteStore = MemoryByteStore();
+ builder.fileContentOverlay = FileContentOverlay();
builder.performanceLog = performanceLog;
List<AnalysisContext> contextList = <AnalysisContext>[];
for (ContextRoot root in roots) {
- old.ContextRoot contextRoot = new old.ContextRoot(
+ old.ContextRoot contextRoot = old.ContextRoot(
root.root.path, root.excludedPaths.toList(),
pathContext: resourceProvider.pathContext);
AnalysisDriver driver = builder.buildDriver(contextRoot);
DriverBasedAnalysisContext context =
- new DriverBasedAnalysisContext(resourceProvider, root, driver);
+ DriverBasedAnalysisContext(resourceProvider, root, driver);
contextList.add(context);
}
return contextList;
@@ -173,7 +171,7 @@
}
List<ContextRoot> roots = <ContextRoot>[];
for (Folder folder in includedFolders) {
- ContextRootImpl root = new ContextRootImpl(resourceProvider, folder);
+ ContextRootImpl root = ContextRootImpl(resourceProvider, folder);
root.packagesFile = defaultPackagesFile ?? _findPackagesFile(folder);
root.optionsFile = defaultOptionsFile ?? _findOptionsFile(folder);
root.included.add(folder);
@@ -185,7 +183,7 @@
for (File file in includedFiles) {
Folder parent = file.parent;
ContextRoot root = rootMap.putIfAbsent(parent, () {
- ContextRootImpl root = new ContextRootImpl(resourceProvider, parent);
+ ContextRootImpl root = ContextRootImpl(resourceProvider, parent);
root.packagesFile = defaultPackagesFile ?? _findPackagesFile(parent);
root.optionsFile = defaultOptionsFile ?? _findOptionsFile(parent);
roots.add(root);
@@ -247,7 +245,7 @@
if (packagesFile != null) {
localPackagesFile = packagesFile;
}
- ContextRootImpl root = new ContextRootImpl(resourceProvider, folder);
+ ContextRootImpl root = ContextRootImpl(resourceProvider, folder);
root.packagesFile = localPackagesFile ?? containingRoot.packagesFile;
root.optionsFile = localOptionsFile ?? containingRoot.optionsFile;
root.included.add(folder);
@@ -368,7 +366,7 @@
excludedPath =
context.join(optionsFile.parent.path, excludedPath);
}
- patterns.add(new Glob(excludedPath, context: context));
+ patterns.add(Glob(excludedPath, context: context));
}
}
}
@@ -434,7 +432,7 @@
* given list of [paths], sorted such that shorter paths are first.
*/
List<String> _uniqueSortedPaths(List<String> paths) {
- Set<String> uniquePaths = new HashSet<String>.from(paths);
+ Set<String> uniquePaths = HashSet<String>.from(paths);
List<String> sortedPaths = uniquePaths.toList();
sortedPaths.sort((a, b) => a.length - b.length);
return sortedPaths;
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_root.dart b/pkg/analyzer/lib/src/dart/analysis/context_root.dart
index 349da1b..88d085a 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_root.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_root.dart
@@ -60,7 +60,7 @@
yield* _includedFilesInFolder(resource);
} else {
Type type = resource.runtimeType;
- throw new StateError('Unknown resource at path "$path" ($type)');
+ throw StateError('Unknown resource at path "$path" ($type)');
}
}
}
@@ -85,7 +85,7 @@
yield* _includedFilesInFolder(resource);
} else {
Type type = resource.runtimeType;
- throw new StateError('Unknown resource at path "$path" ($type)');
+ throw StateError('Unknown resource at path "$path" ($type)');
}
}
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/crc32.dart b/pkg/analyzer/lib/src/dart/analysis/crc32.dart
index e571bfc..ca07e9f 100644
--- a/pkg/analyzer/lib/src/dart/analysis/crc32.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/crc32.dart
@@ -280,9 +280,10 @@
crc = _CRC32_TABLE[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
len -= 8;
}
- if (len > 0)
+ if (len > 0) {
do {
crc = _CRC32_TABLE[(crc ^ array[ip++]) & 0xff] ^ (crc >> 8);
} while (--len > 0);
+ }
return crc ^ 0xffffffff;
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/defined_names.dart b/pkg/analyzer/lib/src/dart/analysis/defined_names.dart
index 589f93a..63d3f98 100644
--- a/pkg/analyzer/lib/src/dart/analysis/defined_names.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/defined_names.dart
@@ -8,7 +8,7 @@
* Compute the [DefinedNames] for the given [unit].
*/
DefinedNames computeDefinedNames(CompilationUnit unit) {
- DefinedNames names = new DefinedNames();
+ DefinedNames names = DefinedNames();
void appendName(Set<String> names, SimpleIdentifier node) {
String name = node?.name;
@@ -51,6 +51,6 @@
* Defined top-level and class member names.
*/
class DefinedNames {
- final Set<String> topLevelNames = new Set<String>();
- final Set<String> classMemberNames = new Set<String>();
+ final Set<String> topLevelNames = Set<String>();
+ final Set<String> classMemberNames = Set<String>();
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart b/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
index 98c9a8a..bb308384 100644
--- a/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
@@ -314,7 +314,7 @@
_visitConstructor(node.type, node.name);
}
- void _visitExpression(Expression node, {bool get: true, bool set: false}) {
+ void _visitExpression(Expression node, {bool get = true, bool set = false}) {
if (node == null) return;
if (node is AdjacentStrings) {
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 709e2acf..391aacf 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -38,7 +38,6 @@
AnalysisOptions,
AnalysisOptionsImpl,
PerformanceStatistics;
-import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/utilities_general.dart';
import 'package:analyzer/src/lint/registry.dart' as linter;
@@ -89,7 +88,10 @@
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
class AnalysisDriver implements AnalysisDriverGeneric {
/// The version of data format, should be incremented on every format change.
- static const int DATA_VERSION = 90;
+ static const int DATA_VERSION = 91;
+
+ /// The length of the list returned by [_computeDeclaredVariablesSignature].
+ static const int _declaredVariablesSignatureLength = 4;
/// The number of exception contexts allowed to write. Once this field is
/// zero, we stop writing any new exception contexts in this process.
@@ -132,7 +134,7 @@
SourceFactory _sourceFactory;
/// The declared environment variables.
- DeclaredVariables declaredVariables = new DeclaredVariables();
+ DeclaredVariables declaredVariables = DeclaredVariables();
/// Information about the context root being analyzed by this driver.
final ContextRoot contextRoot;
@@ -142,14 +144,14 @@
/// The salt to mix into all hashes used as keys for unlinked data.
final Uint32List _unlinkedSalt =
- new Uint32List(2 + AnalysisOptionsImpl.unlinkedSignatureLength);
+ Uint32List(2 + AnalysisOptionsImpl.unlinkedSignatureLength);
/// The salt to mix into all hashes used as keys for linked data.
- final Uint32List _linkedSalt =
- new Uint32List(2 + AnalysisOptions.signatureLength);
+ final Uint32List _linkedSalt = Uint32List(
+ 2 + AnalysisOptions.signatureLength + _declaredVariablesSignatureLength);
/// The set of priority files, that should be analyzed sooner.
- final _priorityFiles = new LinkedHashSet<String>();
+ final _priorityFiles = LinkedHashSet<String>();
/// The mapping from the files for which analysis was requested using
/// [getResult] to the [Completer]s to report the result.
@@ -202,10 +204,10 @@
final _requestedParts = <String, List<Completer<ResolvedUnitResult>>>{};
/// The set of part files that are currently scheduled for analysis.
- final _partsToAnalyze = new LinkedHashSet<String>();
+ final _partsToAnalyze = LinkedHashSet<String>();
/// The controller for the [results] stream.
- final _resultController = new StreamController<ResolvedUnitResult>();
+ final _resultController = StreamController<ResolvedUnitResult>();
/// The stream that will be written to when analysis results are produced.
Stream<ResolvedUnitResult> _onResults;
@@ -218,7 +220,7 @@
/// The controller for the [exceptions] stream.
final StreamController<ExceptionResult> _exceptionController =
- new StreamController<ExceptionResult>();
+ StreamController<ExceptionResult>();
/// The instance of the [Search] helper.
Search _search;
@@ -282,20 +284,20 @@
this.contextRoot,
SourceFactory sourceFactory,
this._analysisOptions,
- {this.disableChangesAndCacheAllResults: false,
- this.enableIndex: false,
+ {this.disableChangesAndCacheAllResults = false,
+ this.enableIndex = false,
SummaryDataStore externalSummaries,
- bool retainDataForTesting: false})
+ bool retainDataForTesting = false})
: _logger = logger,
_sourceFactory = sourceFactory,
_externalSummaries = externalSummaries,
testingData = retainDataForTesting ? TestingData() : null {
_createNewSession(null);
_onResults = _resultController.stream.asBroadcastStream();
- _testView = new AnalysisDriverTestView(this);
+ _testView = AnalysisDriverTestView(this);
_createFileTracker();
_scheduler.add(this);
- _search = new Search(this);
+ _search = Search(this);
}
/// Return the set of files explicitly added to analysis using [addFile].
@@ -337,7 +339,7 @@
List<String> get priorityFiles => _priorityFiles.toList(growable: false);
@override
- void set priorityFiles(List<String> priorityPaths) {
+ set priorityFiles(List<String> priorityPaths) {
_priorityResults.keys
.toSet()
.difference(priorityPaths.toSet())
@@ -502,7 +504,7 @@
Future<void> discoverAvailableFiles() {
if (_discoverAvailableFilesTask != null &&
_discoverAvailableFilesTask.isCompleted) {
- return new Future.value();
+ return Future.value();
}
_discoverAvailableFiles();
_scheduler.notify(this);
@@ -554,7 +556,7 @@
return null;
}
- return new ErrorsResultImpl(currentSession, path, analysisResult.uri,
+ return ErrorsResultImpl(currentSession, path, analysisResult.uri,
analysisResult.lineInfo, analysisResult.isPart, analysisResult.errors);
}
@@ -562,7 +564,7 @@
/// define a class member with the given [name].
Future<List<String>> getFilesDefiningClassMemberName(String name) {
_discoverAvailableFiles();
- var task = new _FilesDefiningClassMemberNameTask(this, name);
+ var task = _FilesDefiningClassMemberNameTask(this, name);
_definingClassMemberNameTasks.add(task);
_scheduler.notify(this);
return task.completer.future;
@@ -572,7 +574,7 @@
/// reference the given external [name].
Future<List<String>> getFilesReferencingName(String name) {
_discoverAvailableFiles();
- var task = new _FilesReferencingNameTask(this, name);
+ var task = _FilesReferencingNameTask(this, name);
_referencingNameTasks.add(task);
_scheduler.notify(this);
return task.completer.future;
@@ -584,7 +586,7 @@
FileResult getFileSync(String path) {
_throwIfNotAbsolutePath(path);
FileState file = _fileTracker.verifyApiSignature(path);
- return new FileResultImpl(
+ return FileResultImpl(
_currentSession, path, file.uri, file.lineInfo, file.isPart);
}
@@ -594,12 +596,12 @@
Future<AnalysisDriverUnitIndex> getIndex(String path) {
_throwIfNotAbsolutePath(path);
if (!enableIndex) {
- throw new ArgumentError('Indexing is not enabled.');
+ throw ArgumentError('Indexing is not enabled.');
}
if (!_fsState.hasUri(path)) {
- return new Future.value();
+ return Future.value();
}
- var completer = new Completer<AnalysisDriverUnitIndex>();
+ var completer = Completer<AnalysisDriverUnitIndex>();
_indexRequestedFiles
.putIfAbsent(path, () => <Completer<AnalysisDriverUnitIndex>>[])
.add(completer);
@@ -702,7 +704,7 @@
Future<ResolvedLibraryResult> getResolvedLibrary(String path) {
_throwIfNotAbsolutePath(path);
if (!_fsState.hasUri(path)) {
- return new Future.value();
+ return Future.value();
}
FileState file = _fsState.getFileForPath(path);
@@ -718,7 +720,7 @@
}
// Schedule analysis.
- var completer = new Completer<ResolvedLibraryResult>();
+ var completer = Completer<ResolvedLibraryResult>();
_requestedLibraries
.putIfAbsent(path, () => <Completer<ResolvedLibraryResult>>[])
.add(completer);
@@ -781,10 +783,10 @@
/// of the files previously reported using [changeFile]), prior to the next
/// time the analysis state transitions to "idle".
Future<ResolvedUnitResult> getResult(String path,
- {bool sendCachedToStream: false}) {
+ {bool sendCachedToStream = false}) {
_throwIfNotAbsolutePath(path);
if (!_fsState.hasUri(path)) {
- return new Future.value();
+ return Future.value();
}
// Return the cached result.
@@ -794,12 +796,12 @@
if (sendCachedToStream) {
_resultController.add(result);
}
- return new Future.value(result);
+ return Future.value(result);
}
}
// Schedule analysis.
- var completer = new Completer<ResolvedUnitResult>();
+ var completer = Completer<ResolvedUnitResult>();
_requestedFiles
.putIfAbsent(path, () => <Completer<ResolvedUnitResult>>[])
.add(completer);
@@ -828,9 +830,9 @@
Future<UnitElementResult> getUnitElement(String path) {
_throwIfNotAbsolutePath(path);
if (!_fsState.hasUri(path)) {
- return new Future.value();
+ return Future.value();
}
- var completer = new Completer<UnitElementResult>();
+ var completer = Completer<UnitElementResult>();
_unitElementRequestedFiles
.putIfAbsent(path, () => <Completer<UnitElementResult>>[])
.add(completer);
@@ -848,9 +850,9 @@
Future<String> getUnitElementSignature(String path) {
_throwIfNotAbsolutePath(path);
if (!_fsState.hasUri(path)) {
- return new Future.value();
+ return Future.value();
}
- var completer = new Completer<String>();
+ var completer = Completer<String>();
_unitElementSignatureFiles
.putIfAbsent(path, () => <Completer<String>>[])
.add(completer);
@@ -861,7 +863,7 @@
ApiSignature getUnitKeyByPath(String path) {
_throwIfNotAbsolutePath(path);
var file = fsState.getFileForPath(path);
- ApiSignature signature = new ApiSignature();
+ ApiSignature signature = ApiSignature();
signature.addUint32List(_linkedSalt);
signature.addString(file.transitiveSignature);
return signature;
@@ -908,9 +910,9 @@
ParsedUnitResult parseFileSync(String path) {
_throwIfNotAbsolutePath(path);
FileState file = _fileTracker.verifyApiSignature(path);
- RecordingErrorListener listener = new RecordingErrorListener();
+ RecordingErrorListener listener = RecordingErrorListener();
CompilationUnit unit = file.parse(listener);
- return new ParsedUnitResultImpl(currentSession, file.path, file.uri,
+ return ParsedUnitResultImpl(currentSession, file.path, file.uri,
file.content, file.lineInfo, file.isPart, unit, listener.errors);
}
@@ -1210,9 +1212,9 @@
/// the resolved signature of the file in its library is the same as the one
/// that was the most recently produced to the client.
AnalysisResult _computeAnalysisResult(String path,
- {bool withUnit: false,
- bool asIsIfPartWithoutLibrary: false,
- bool skipIfSameSignature: false}) {
+ {bool withUnit = false,
+ bool asIsIfPartWithoutLibrary = false,
+ bool skipIfSameSignature = false}) {
FileState file = _fsState.getFileForPath(path);
// Prepare the library - the file itself, or the known library.
@@ -1261,7 +1263,7 @@
}
var libraryContext = _createLibraryContext(library);
- LibraryAnalyzer analyzer = new LibraryAnalyzer(
+ LibraryAnalyzer analyzer = LibraryAnalyzer(
analysisOptions,
declaredVariables,
sourceFactory,
@@ -1308,11 +1310,27 @@
} catch (exception, stackTrace) {
String contextKey =
_storeExceptionContext(path, library, exception, stackTrace);
- throw new _ExceptionState(exception, stackTrace, contextKey);
+ throw _ExceptionState(exception, stackTrace, contextKey);
}
});
}
+ Uint32List _computeDeclaredVariablesSignature() {
+ var buffer = ApiSignature();
+
+ var variableNames = declaredVariables.variableNames;
+ buffer.addInt(variableNames.length);
+
+ for (var name in variableNames) {
+ var value = declaredVariables.get(name);
+ buffer.addString(name);
+ buffer.addString(value);
+ }
+
+ var bytes = buffer.toByteList();
+ return Uint8List.fromList(bytes).buffer.asUint32List();
+ }
+
AnalysisDriverUnitIndex _computeIndex(String path) {
AnalysisResult analysisResult = _computeAnalysisResult(path,
withUnit: false, asIsIfPartWithoutLibrary: true);
@@ -1328,7 +1346,7 @@
_testView.numOfAnalyzedLibraries++;
var libraryContext = _createLibraryContext(library);
- LibraryAnalyzer analyzer = new LibraryAnalyzer(
+ LibraryAnalyzer analyzer = LibraryAnalyzer(
analysisOptions,
declaredVariables,
sourceFactory,
@@ -1346,9 +1364,8 @@
if (unitFile.path != null) {
var unitResult = unitResults[unitFile];
resolvedUnits.add(
- new AnalysisResult(
+ AnalysisResult(
currentSession,
- _sourceFactory,
unitFile.path,
unitFile.uri,
unitFile.exists,
@@ -1364,19 +1381,18 @@
}
}
- return new ResolvedLibraryResultImpl(
+ return ResolvedLibraryResultImpl(
currentSession,
library.path,
library.uri,
resolvedUnits.first.libraryElement,
- libraryContext.typeProvider,
resolvedUnits,
);
});
}
UnitElementResult _computeUnitElement(String path,
- {bool asIsIfPartWithoutLibrary: false}) {
+ {bool asIsIfPartWithoutLibrary = false}) {
FileState file = _fsState.getFileForPath(path);
// Prepare the library - the file itself, or the known library.
@@ -1393,7 +1409,7 @@
_logger.writeln('Work in $name');
var libraryContext = _createLibraryContext(library);
var element = libraryContext.computeUnitElement(library, file);
- return new UnitElementResultImpl(
+ return UnitElementResultImpl(
currentSession,
path,
file.uri,
@@ -1404,7 +1420,7 @@
}
String _computeUnitElementSignature(String path,
- {bool asIsIfPartWithoutLibrary: false}) {
+ {bool asIsIfPartWithoutLibrary = false}) {
FileState file = _fsState.getFileForPath(path);
// Prepare the library - the file itself, or the known library.
@@ -1426,7 +1442,7 @@
/// changes.
void _createFileTracker() {
_fillSalt();
- _fsState = new FileSystemState(
+ _fsState = FileSystemState(
_logger,
_byteStore,
_contentOverlay,
@@ -1434,11 +1450,12 @@
name,
sourceFactory,
analysisOptions,
+ declaredVariables,
_unlinkedSalt,
_linkedSalt,
externalSummaries: _externalSummaries,
);
- _fileTracker = new FileTracker(_logger, _fsState, _changeHook);
+ _fileTracker = FileTracker(_logger, _fsState, _changeHook);
}
/// Return the context in which the [library] should be analyzed.
@@ -1450,7 +1467,7 @@
}
if (_libraryContext == null) {
- _libraryContext = new LibraryContext(
+ _libraryContext = LibraryContext(
session: currentSession,
logger: _logger,
fsState: fsState,
@@ -1472,13 +1489,13 @@
if (onCurrentSessionAboutToBeDiscarded != null) {
onCurrentSessionAboutToBeDiscarded(path);
}
- _currentSession = new AnalysisSessionImpl(this);
+ _currentSession = AnalysisSessionImpl(this);
}
/// If this has not been done yet, schedule discovery of all files that are
/// potentially available, so that they are included in [knownFiles].
void _discoverAvailableFiles() {
- _discoverAvailableFilesTask ??= new _DiscoverAvailableFilesTask(this);
+ _discoverAvailableFilesTask ??= _DiscoverAvailableFilesTask(this);
}
/// Fill [_unlinkedSalt] and [_linkedSalt] with data.
@@ -1487,9 +1504,23 @@
_unlinkedSalt[1] = enableIndex ? 1 : 0;
_unlinkedSalt.setAll(2, _analysisOptions.unlinkedSignature);
- _linkedSalt[0] = DATA_VERSION;
- _linkedSalt[1] = enableIndex ? 1 : 0;
- _linkedSalt.setAll(2, _analysisOptions.signature);
+ _fillSaltLinked();
+ }
+
+ void _fillSaltLinked() {
+ var index = 0;
+
+ _linkedSalt[index] = DATA_VERSION;
+ index++;
+
+ _linkedSalt[index] = enableIndex ? 1 : 0;
+ index++;
+
+ _linkedSalt.setAll(index, _analysisOptions.signature);
+ index += AnalysisOptionsImpl.unlinkedSignatureLength;
+
+ _linkedSalt.setAll(index, _computeDeclaredVariablesSignature());
+ index += _declaredVariablesSignatureLength;
}
/// Load the [AnalysisResult] for the given [file] from the [bytes]. Set
@@ -1497,12 +1528,11 @@
AnalysisResult _getAnalysisResultFromBytes(
FileState file, String signature, List<int> bytes,
{String content, CompilationUnit resolvedUnit}) {
- var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes);
+ var unit = AnalysisDriverResolvedUnit.fromBuffer(bytes);
List<AnalysisError> errors = _getErrorsFromSerialized(file, unit.errors);
_updateHasErrorOrWarningFlag(file, errors);
- return new AnalysisResult(
+ return AnalysisResult(
currentSession,
- _sourceFactory,
file.path,
file.uri,
file.exists,
@@ -1541,7 +1571,7 @@
offset: message.offset));
}
}
- errors.add(new AnalysisError.forValues(
+ errors.add(AnalysisError.forValues(
file.source,
error.offset,
error.length,
@@ -1562,7 +1592,7 @@
/// Return the signature that identifies fully resolved results for the [file]
/// in the [library], e.g. element model, errors, index, etc.
String _getResolvedUnitSignature(FileState library, FileState file) {
- ApiSignature signature = new ApiSignature();
+ ApiSignature signature = ApiSignature();
signature.addUint32List(_linkedSalt);
signature.addString(library.transitiveSignature);
signature.addString(file.contentHash);
@@ -1592,9 +1622,8 @@
AnalysisResult _newMissingDartLibraryResult(
FileState file, String missingUri) {
// TODO(scheglov) Find a better way to report this.
- return new AnalysisResult(
+ return AnalysisResult(
currentSession,
- _sourceFactory,
file.path,
file.uri,
file.exists,
@@ -1604,7 +1633,7 @@
null,
null,
[
- new AnalysisError(file.source, 0, 0,
+ AnalysisError(file.source, 0, 0,
CompileTimeErrorCode.MISSING_DART_LIBRARY, [missingUri])
],
null);
@@ -1618,8 +1647,8 @@
stackTrace = state.stackTrace;
contextKey = state.contextKey;
}
- CaughtException caught = new CaughtException(exception, stackTrace);
- _exceptionController.add(new ExceptionResult(path, caught, contextKey));
+ CaughtException caught = CaughtException(exception, stackTrace);
+ _exceptionController.add(ExceptionResult(path, caught, contextKey));
}
/// Serialize the given [resolvedUnit] errors and index into bytes.
@@ -1627,8 +1656,8 @@
CompilationUnit resolvedUnit, List<AnalysisError> errors) {
AnalysisDriverUnitIndexBuilder index = enableIndex
? indexUnit(resolvedUnit)
- : new AnalysisDriverUnitIndexBuilder();
- return new AnalysisDriverResolvedUnitBuilder(
+ : AnalysisDriverUnitIndexBuilder();
+ return AnalysisDriverResolvedUnitBuilder(
errors: errors.map((error) {
List<DiagnosticMessageBuilder> contextMessages;
if (error.contextMessages != null) {
@@ -1641,7 +1670,7 @@
offset: message.offset));
}
}
- return new AnalysisDriverUnitErrorBuilder(
+ return AnalysisDriverUnitErrorBuilder(
offset: error.offset,
length: error.length,
uniqueName: error.errorCode.uniqueName,
@@ -1663,12 +1692,12 @@
try {
List<AnalysisDriverExceptionFileBuilder> contextFiles = libraryFile
.transitiveFiles
- .map((file) => new AnalysisDriverExceptionFileBuilder(
+ .map((file) => AnalysisDriverExceptionFileBuilder(
path: file.path, content: file.content))
.toList();
contextFiles.sort((a, b) => a.path.compareTo(b.path));
AnalysisDriverExceptionContextBuilder contextBuilder =
- new AnalysisDriverExceptionContextBuilder(
+ AnalysisDriverExceptionContextBuilder(
path: path,
exception: exception.toString(),
stackTrace: stackTrace.toString(),
@@ -1686,7 +1715,7 @@
return '00$n';
}
- DateTime time = new DateTime.now();
+ DateTime time = DateTime.now();
String m = _twoDigits(time.month);
String d = _twoDigits(time.day);
String h = _twoDigits(time.hour);
@@ -1706,7 +1735,7 @@
/// we should not allow invocations that change files.
void _throwIfChangesAreNotAllowed() {
if (disableChangesAndCacheAllResults) {
- throw new StateError('Changing files is not allowed for this driver.');
+ throw StateError('Changing files is not allowed for this driver.');
}
}
@@ -1714,7 +1743,7 @@
/// any input paths to prevent errors later.
void _throwIfNotAbsolutePath(String path) {
if (!_resourceProvider.pathContext.isAbsolute(path)) {
- throw new ArgumentError('Only absolute paths are supported: $path');
+ throw ArgumentError('Only absolute paths are supported: $path');
}
}
@@ -1749,7 +1778,7 @@
/// The driver will produce the results through the [results] stream. The
/// exact order in which results are produced is not defined, neither
/// between priority files, nor between priority and non-priority files.
- void set priorityFiles(List<String> priorityPaths);
+ set priorityFiles(List<String> priorityPaths);
/// Return the priority of work that the driver needs to perform.
AnalysisDriverPriority get workPriority;
@@ -1809,8 +1838,8 @@
final DriverWatcher driverWatcher;
final List<AnalysisDriverGeneric> _drivers = [];
- final Monitor _hasWork = new Monitor();
- final StatusSupport _statusSupport = new StatusSupport();
+ final Monitor _hasWork = Monitor();
+ final StatusSupport _statusSupport = StatusSupport();
bool _started = false;
@@ -1868,7 +1897,7 @@
/// after will be asked to perform work.
void start() {
if (_started) {
- throw new StateError('The scheduler has already been started.');
+ throw StateError('The scheduler has already been started.');
}
_started = true;
_run();
@@ -1885,7 +1914,7 @@
Future<void> _run() async {
// Give other microtasks the time to run before doing the analysis cycle.
await null;
- Stopwatch timer = new Stopwatch()..start();
+ Stopwatch timer = Stopwatch()..start();
PerformanceLogSection analysisSection;
while (true) {
// Pump the event queue.
@@ -1948,9 +1977,9 @@
/// the event queue.
static Future _pumpEventQueue(int times) {
if (times == 0) {
- return new Future.value();
+ return Future.value();
}
- return new Future.delayed(Duration.zero, () => _pumpEventQueue(times - 1));
+ return Future.delayed(Duration.zero, () => _pumpEventQueue(times - 1));
}
}
@@ -1985,11 +2014,8 @@
/// Every result is independent, and is not guaranteed to be consistent with
/// any previously returned result, even inside of the same library.
class AnalysisResult extends ResolvedUnitResultImpl {
- static final _UNCHANGED = new AnalysisResult(
- null, null, null, null, null, null, null, null, null, null, null, null);
-
- /// The [SourceFactory] with which the file was analyzed.
- final SourceFactory sourceFactory;
+ static final _UNCHANGED = AnalysisResult(
+ null, null, null, null, null, null, null, null, null, null, null);
/// The signature of the result based on the content of the file, and the
/// transitive closure of files imported and exported by the library of
@@ -2001,7 +2027,6 @@
AnalysisResult(
AnalysisSession session,
- this.sourceFactory,
String path,
Uri uri,
bool exists,
@@ -2014,15 +2039,6 @@
this._index)
: super(session, path, uri, exists, content, lineInfo, isPart, unit,
errors);
-
- @override
- LibraryElement get libraryElement => unit.declaredElement.library;
-
- @override
- TypeProvider get typeProvider => unit.declaredElement.context.typeProvider;
-
- @override
- TypeSystemImpl get typeSystem => unit.declaredElement.context.typeSystem;
}
class DriverPerformance {
@@ -2080,7 +2096,7 @@
final AnalysisDriver driver;
bool isCompleted = false;
- Completer<void> completer = new Completer<void>();
+ Completer<void> completer = Completer<void>();
Iterator<Folder> folderIterator;
List<String> files = [];
@@ -2114,7 +2130,7 @@
}
// List each package/lib folder recursively.
- Stopwatch timer = new Stopwatch()..start();
+ Stopwatch timer = Stopwatch()..start();
while (folderIterator.moveNext()) {
var folder = folderIterator.current;
_appendFilesRecursively(folder);
@@ -2183,10 +2199,10 @@
final AnalysisDriver driver;
final String name;
- final Completer<List<String>> completer = new Completer<List<String>>();
+ final Completer<List<String>> completer = Completer<List<String>>();
final List<String> definingFiles = <String>[];
- final Set<String> checkedFiles = new Set<String>();
+ final Set<String> checkedFiles = Set<String>();
final List<String> filesToCheck = <String>[];
_FilesDefiningClassMemberNameTask(this.driver, this.name);
@@ -2200,7 +2216,7 @@
/// scenarios. Instead we use a fixed length of time, so we can spend less time
/// overall and keep quick enough response time.
bool perform() {
- Stopwatch timer = new Stopwatch()..start();
+ Stopwatch timer = Stopwatch()..start();
while (timer.elapsedMilliseconds < _MS_WORK_INTERVAL) {
// Prepare files to check.
if (filesToCheck.isEmpty) {
@@ -2237,7 +2253,7 @@
final AnalysisDriver driver;
final String name;
- final Completer<List<String>> completer = new Completer<List<String>>();
+ final Completer<List<String>> completer = Completer<List<String>>();
int fileStamp = -1;
List<FileState> filesToCheck;
@@ -2268,7 +2284,7 @@
filesToCheckIndex = 0;
}
- Stopwatch timer = new Stopwatch()..start();
+ Stopwatch timer = Stopwatch()..start();
while (filesToCheckIndex < filesToCheck.length) {
if (filesToCheckIndex % _WORK_FILES == 0 &&
timer.elapsedMilliseconds > _MS_WORK_INTERVAL) {
diff --git a/pkg/analyzer/lib/src/dart/analysis/experiments.dart b/pkg/analyzer/lib/src/dart/analysis/experiments.dart
index cb17efa..caa7d35 100644
--- a/pkg/analyzer/lib/src/dart/analysis/experiments.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/experiments.dart
@@ -45,7 +45,7 @@
/// enabled features is used as the starting point.
@visibleForTesting
ExperimentStatus.forTesting(
- {String sdkVersion, List<Feature> additionalFeatures: const []})
+ {String sdkVersion, List<Feature> additionalFeatures = const []})
: this._(enableFlagsForTesting(
sdkVersion: sdkVersion, additionalFeatures: additionalFeatures));
diff --git a/pkg/analyzer/lib/src/dart/analysis/experiments_impl.dart b/pkg/analyzer/lib/src/dart/analysis/experiments_impl.dart
index 81a437b..9f08f78 100644
--- a/pkg/analyzer/lib/src/dart/analysis/experiments_impl.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/experiments_impl.dart
@@ -35,7 +35,7 @@
/// If [sdkVersion] is not supplied (or is `null`), then the current set of
/// enabled features is used as the starting point.
List<bool> enableFlagsForTesting(
- {String sdkVersion, List<Feature> additionalFeatures: const []}) {
+ {String sdkVersion, List<Feature> additionalFeatures = const []}) {
var flags = decodeFlags([]);
if (sdkVersion != null) {
flags = restrictEnableFlagsToVersion(flags, Version.parse(sdkVersion));
@@ -123,7 +123,7 @@
var flag2Map = _flagStringsToMap(flags2);
for (var entry in flag2Map.entries) {
if (flag1Map[entry.key] != null && flag1Map[entry.key] != entry.value) {
- yield new ConflictingFlagLists(
+ yield ConflictingFlagLists(
_featureIndexToFeature(entry.key), !entry.value);
}
}
@@ -172,7 +172,7 @@
for (var feature in _knownFeatures.values) {
if (feature.index == index) return feature;
}
- throw new ArgumentError('Unrecognized feature index');
+ throw ArgumentError('Unrecognized feature index');
}
Map<int, bool> _flagStringsToMap(List<String> flags) {
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart b/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart
index eecc2ca..b057a4e 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart
@@ -42,7 +42,7 @@
bool _evictionIsolateIsRunning = false;
EvictingFileByteStore(this._cachePath, this._maxSizeBytes)
- : _fileByteStore = new FileByteStore(_cachePath) {
+ : _fileByteStore = FileByteStore(_cachePath) {
_requestCacheCleanUp();
}
@@ -65,21 +65,21 @@
Future<void> _requestCacheCleanUp() async {
if (_cleanUpSendPortShouldBePrepared) {
_cleanUpSendPortShouldBePrepared = false;
- ReceivePort response = new ReceivePort();
+ ReceivePort response = ReceivePort();
await Isolate.spawn(_cacheCleanUpFunction, response.sendPort);
_cleanUpSendPort = await response.first as SendPort;
} else {
while (_cleanUpSendPort == null) {
- await new Future.delayed(new Duration(milliseconds: 100), () {});
+ await Future.delayed(Duration(milliseconds: 100), () {});
}
}
if (!_evictionIsolateIsRunning) {
_evictionIsolateIsRunning = true;
try {
- ReceivePort response = new ReceivePort();
- _cleanUpSendPort.send(new CacheCleanUpRequest(
- _cachePath, _maxSizeBytes, response.sendPort));
+ ReceivePort response = ReceivePort();
+ _cleanUpSendPort.send(
+ CacheCleanUpRequest(_cachePath, _maxSizeBytes, response.sendPort));
await response.first;
} finally {
_evictionIsolateIsRunning = false;
@@ -94,7 +94,7 @@
*/
static void _cacheCleanUpFunction(message) {
SendPort initialReplyTo = message;
- ReceivePort port = new ReceivePort();
+ ReceivePort port = ReceivePort();
initialReplyTo.send(port.sendPort);
port.listen((request) {
if (request is CacheCleanUpRequest) {
@@ -111,7 +111,7 @@
Map<File, FileStat> fileStatMap = {};
int currentSizeBytes = 0;
List<FileSystemEntity> resources =
- new Directory(cachePath).listSync(recursive: true);
+ Directory(cachePath).listSync(recursive: true);
for (FileSystemEntity resource in resources) {
if (resource is File) {
try {
@@ -148,19 +148,19 @@
* [ByteStore] that stores values as files.
*/
class FileByteStore implements ByteStore {
- static final FileByteStoreValidator _validator = new FileByteStoreValidator();
+ static final FileByteStoreValidator _validator = FileByteStoreValidator();
static final _dotCodeUnit = '.'.codeUnitAt(0);
final String _cachePath;
final String _tempSuffix;
final Map<String, List<int>> _writeInProgress = {};
- final FuturePool _pool = new FuturePool(20);
+ final FuturePool _pool = FuturePool(20);
/**
* If the same cache path is used from more than one isolate of the same
* process, then a unique [tempNameSuffix] must be provided for each isolate.
*/
- FileByteStore(this._cachePath, {String tempNameSuffix: ''})
+ FileByteStore(this._cachePath, {String tempNameSuffix = ''})
: _tempSuffix =
'-temp-$pid${tempNameSuffix.isEmpty ? '' : '-$tempNameSuffix'}';
@@ -176,7 +176,7 @@
try {
var shardPath = _getShardPath(key);
var path = join(shardPath, key);
- var bytes = new File(path).readAsBytesSync();
+ var bytes = File(path).readAsBytesSync();
return _validator.getData(bytes);
} catch (_) {
// ignore exceptions
@@ -195,7 +195,7 @@
// We don't wait for the write and rename to complete.
_pool.execute(() {
var tempPath = join(_cachePath, '$key$_tempSuffix');
- var tempFile = new File(tempPath);
+ var tempFile = File(tempPath);
return tempFile.writeAsBytes(wrappedBytes).then((_) {
var shardPath = _getShardPath(key);
return Directory(shardPath).create(recursive: true).then((_) {
@@ -269,7 +269,7 @@
*/
List<int> wrapData(List<int> data) {
int len = data.length;
- var bytes = new Uint8List(len + 4);
+ var bytes = Uint8List(len + 4);
// Put the data.
bytes.setRange(0, len, data);
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index 4f2d73a..37dead8 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -6,6 +6,7 @@
import 'dart:typed_data';
import 'package:_fe_analyzer_shared/src/scanner/token_impl.dart';
+import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/standard_ast_factory.dart';
@@ -147,8 +148,8 @@
path = null,
source = null,
_exists = true {
- _apiSignature = new Uint8List(16);
- _libraryCycle = new LibraryCycle.external();
+ _apiSignature = Uint8List(16);
+ _libraryCycle = LibraryCycle.external();
}
/**
@@ -295,14 +296,14 @@
}
@visibleForTesting
- FileStateTestView get test => new FileStateTestView(this);
+ FileStateTestView get test => FileStateTestView(this);
/**
* Return the set of transitive files - the file itself and all of the
* directly or indirectly referenced files.
*/
Set<FileState> get transitiveFiles {
- var transitiveFiles = new Set<FileState>();
+ var transitiveFiles = Set<FileState>();
void appendReferenced(FileState file) {
if (transitiveFiles.add(file)) {
@@ -383,7 +384,7 @@
*
* Return `true` if the API signature changed since the last refresh.
*/
- bool refresh({bool allowCached: false}) {
+ bool refresh({bool allowCached = false}) {
counterFileStateRefresh++;
var timerWasRunning = timerFileStateRefresh.isRunning;
@@ -403,7 +404,7 @@
// Prepare the unlinked bundle key.
List<int> contentSignature;
{
- var signature = new ApiSignature();
+ var signature = ApiSignature();
signature.addUint32List(_fsState._unlinkedSalt);
signature.addString(_contentHash);
signature.addBool(_exists);
@@ -422,7 +423,7 @@
var definedNames = computeDefinedNames(unit);
var referencedNames = computeReferencedNames(unit).toList();
var subtypedNames = computeSubtypedNames(unit).toList();
- bytes = new AnalysisDriverUnlinkedUnitBuilder(
+ bytes = AnalysisDriverUnlinkedUnitBuilder(
unit2: unlinkedUnit,
definedTopLevelNames: definedNames.topLevelNames.toList(),
definedClassMemberNames: definedNames.classMemberNames.toList(),
@@ -435,12 +436,12 @@
}
// Read the unlinked bundle.
- _driverUnlinkedUnit = new AnalysisDriverUnlinkedUnit.fromBuffer(bytes);
+ _driverUnlinkedUnit = AnalysisDriverUnlinkedUnit.fromBuffer(bytes);
_unlinked2 = _driverUnlinkedUnit.unit2;
- _lineInfo = new LineInfo(_unlinked2.lineStarts);
+ _lineInfo = LineInfo(_unlinked2.lineStarts);
// Prepare API signature.
- var newApiSignature = new Uint8List.fromList(_unlinked2.apiSignature);
+ var newApiSignature = Uint8List.fromList(_unlinked2.apiSignature);
bool apiSignatureChanged = _apiSignature != null &&
!_equalByteLists(_apiSignature, newApiSignature);
_apiSignature = newApiSignature;
@@ -472,11 +473,13 @@
_exportedFiles = <FileState>[];
_partedFiles = <FileState>[];
_exportFilters = <NameFilter>[];
- for (var uri in _unlinked2.imports) {
+ for (var directive in _unlinked2.imports) {
+ var uri = _selectRelativeUri(directive);
var file = _fileForRelativeUri(uri);
_importedFiles.add(file);
}
- for (var uri in _unlinked2.exports) {
+ for (var directive in _unlinked2.exports) {
+ var uri = _selectRelativeUri(directive);
var file = _fileForRelativeUri(uri);
_exportedFiles.add(file);
// TODO(scheglov) implement
@@ -492,7 +495,7 @@
_libraryFiles = [this]..addAll(_partedFiles);
// Compute referenced files.
- _directReferencedFiles = new Set<FileState>()
+ _directReferencedFiles = Set<FileState>()
..addAll(_importedFiles)
..addAll(_exportedFiles)
..addAll(_partedFiles);
@@ -504,7 +507,7 @@
for (var name in _driverUnlinkedUnit.subtypedNames) {
var files = _fsState._subtypedNameToFiles[name];
if (files == null) {
- files = new Set<FileState>();
+ files = Set<FileState>();
_fsState._subtypedNameToFiles[name] = files;
}
files.add(this);
@@ -522,10 +525,10 @@
String toString() => path ?? '<unresolved>';
CompilationUnit _createEmptyCompilationUnit(FeatureSet featureSet) {
- var token = new Token.eof(0);
+ var token = Token.eof(0);
return astFactory.compilationUnit(
beginToken: token, endToken: token, featureSet: featureSet)
- ..lineInfo = new LineInfo(const <int>[0]);
+ ..lineInfo = LineInfo(const <int>[0]);
}
/**
@@ -572,19 +575,19 @@
return _createEmptyCompilationUnit(featureSet);
}
- CharSequenceReader reader = new CharSequenceReader(content);
- Scanner scanner = new Scanner(source, reader, errorListener)
+ CharSequenceReader reader = CharSequenceReader(content);
+ Scanner scanner = Scanner(source, reader, errorListener)
..configureFeatures(featureSet);
Token token = PerformanceStatistics.scan.makeCurrentWhile(() {
return scanner.tokenize(reportScannerErrors: false);
});
- LineInfo lineInfo = new LineInfo(scanner.lineStarts);
+ LineInfo lineInfo = LineInfo(scanner.lineStarts);
bool useFasta = analysisOptions.useFastaParser;
// Pass the feature set from the scanner to the parser
// because the scanner may have detected a language version comment
// and downgraded the feature set it holds.
- Parser parser = new Parser(source, errorListener,
+ Parser parser = Parser(source, errorListener,
featureSet: scanner.featureSet, useFasta: useFasta);
parser.enableOptionalNewAndConst = true;
CompilationUnit unit = parser.parseCompilationUnit(token);
@@ -597,21 +600,35 @@
return unit;
}
+ String _selectRelativeUri(UnlinkedNamespaceDirective directive) {
+ for (var configuration in directive.configurations) {
+ var name = configuration.name;
+ var value = configuration.value;
+ if (value.isEmpty) {
+ value = 'true';
+ }
+ if (_fsState._declaredVariables.get(name) == value) {
+ return configuration.uri;
+ }
+ }
+ return directive.uri;
+ }
+
static UnlinkedUnit2Builder serializeAstUnlinked2(CompilationUnit unit) {
- var exports = <String>[];
- var imports = <String>[];
+ var exports = <UnlinkedNamespaceDirectiveBuilder>[];
+ var imports = <UnlinkedNamespaceDirectiveBuilder>[];
var parts = <String>[];
var hasDartCoreImport = false;
var hasLibraryDirective = false;
var hasPartOfDirective = false;
for (var directive in unit.directives) {
if (directive is ExportDirective) {
- var uriStr = directive.uri.stringValue;
- exports.add(uriStr ?? '');
+ var builder = _serializeNamespaceDirective(directive);
+ exports.add(builder);
} else if (directive is ImportDirective) {
- var uriStr = directive.uri.stringValue;
- imports.add(uriStr ?? '');
- if (uriStr == 'dart:core') {
+ var builder = _serializeNamespaceDirective(directive);
+ imports.add(builder);
+ if (builder.uri == 'dart:core') {
hasDartCoreImport = true;
}
} else if (directive is LibraryDirective) {
@@ -624,7 +641,11 @@
}
}
if (!hasDartCoreImport) {
- imports.add('dart:core');
+ imports.add(
+ UnlinkedNamespaceDirectiveBuilder(
+ uri: 'dart:core',
+ ),
+ );
}
var informativeData = createInformativeData(unit);
return UnlinkedUnit2Builder(
@@ -658,6 +679,22 @@
}
return true;
}
+
+ static UnlinkedNamespaceDirectiveBuilder _serializeNamespaceDirective(
+ NamespaceDirective directive) {
+ return UnlinkedNamespaceDirectiveBuilder(
+ configurations: directive.configurations.map((configuration) {
+ var name = configuration.name.components.join('.');
+ var value = configuration.value?.stringValue ?? '';
+ return UnlinkedNamespaceDirectiveConfigurationBuilder(
+ name: name,
+ value: value,
+ uri: configuration.uri.stringValue ?? '',
+ );
+ }).toList(),
+ uri: directive.uri.stringValue ?? '',
+ );
+ }
}
@visibleForTesting
@@ -680,6 +717,7 @@
final FileContentOverlay _contentOverlay;
final SourceFactory _sourceFactory;
final AnalysisOptions _analysisOptions;
+ final DeclaredVariables _declaredVariables;
final Uint32List _unlinkedSalt;
final Uint32List _linkedSalt;
@@ -702,7 +740,7 @@
/**
* All known file paths.
*/
- final Set<String> knownFilePaths = new Set<String>();
+ final Set<String> knownFilePaths = Set<String>();
/**
* All known files.
@@ -760,6 +798,7 @@
this.contextName,
this._sourceFactory,
this._analysisOptions,
+ this._declaredVariables,
this._unlinkedSalt,
this._linkedSalt, {
this.externalSummaries,
@@ -768,7 +807,7 @@
_resourceProvider,
_contentOverlay,
);
- _testView = new FileSystemStateTestView(this);
+ _testView = FileSystemStateTestView(this);
}
@visibleForTesting
@@ -779,7 +818,7 @@
*/
FileState get unresolvedFile {
if (_unresolvedFile == null) {
- _unresolvedFile = new FileState._(this, null, null, null);
+ _unresolvedFile = FileState._(this, null, null, null);
_unresolvedFile.refresh();
}
return _unresolvedFile;
@@ -806,8 +845,8 @@
return file;
}
// Create a new file.
- FileSource uriSource = new FileSource(resource, uri);
- file = new FileState._(this, path, uri, uriSource);
+ FileSource uriSource = FileSource(resource, uri);
+ file = FileState._(this, path, uri, uriSource);
_uriToFile[uri] = file;
_addFileWithPath(path, file);
_pathToCanonicalFile[path] = file;
@@ -830,7 +869,7 @@
if (externalSummaries != null) {
String uriStr = uri.toString();
if (externalSummaries.hasLinkedLibrary(uriStr)) {
- file = new FileState._external(this, uri);
+ file = FileState._external(this, uri);
_uriToFile[uri] = file;
return file;
}
@@ -847,8 +886,8 @@
String path = uriSource.fullName;
File resource = _resourceProvider.getFile(path);
- FileSource source = new FileSource(resource, uri);
- file = new FileState._(this, path, uri, source);
+ FileSource source = FileSource(resource, uri);
+ file = FileState._(this, path, uri, source);
_uriToFile[uri] = file;
_addFileWithPath(path, file);
file.refresh(allowCached: true);
@@ -985,14 +1024,14 @@
* Outer key is a [FileContentOverlay].
* Inner key is a [ResourceProvider].
*/
- static final _instances = new Expando<Expando<_FileContentCache>>();
+ static final _instances = Expando<Expando<_FileContentCache>>();
/**
* Weak map of cache instances.
*
* Key is a [ResourceProvider].
*/
- static final _instances2 = new Expando<_FileContentCache>();
+ static final _instances2 = Expando<_FileContentCache>();
final ResourceProvider _resourceProvider;
final FileContentOverlay _contentOverlay;
@@ -1031,7 +1070,7 @@
List<int> contentHashBytes = md5.convert(contentBytes).bytes;
String contentHash = hex.encode(contentHashBytes);
- file = new _FileContent(path, exists, content, contentHash);
+ file = _FileContent(path, exists, content, contentHash);
_pathToFile[path] = file;
}
return file;
@@ -1050,7 +1089,7 @@
if (contentOverlay != null) {
providerToInstance = _instances[contentOverlay];
if (providerToInstance == null) {
- providerToInstance = new Expando<_FileContentCache>();
+ providerToInstance = Expando<_FileContentCache>();
_instances[contentOverlay] = providerToInstance;
}
} else {
@@ -1059,7 +1098,7 @@
var instance = providerToInstance[resourceProvider];
if (instance == null) {
- instance = new _FileContentCache(resourceProvider, contentOverlay);
+ instance = _FileContentCache(resourceProvider, contentOverlay);
providerToInstance[resourceProvider] = instance;
}
return instance;
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_tracker.dart b/pkg/analyzer/lib/src/dart/analysis/file_tracker.dart
index e6ac6f1..3a5b937 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_tracker.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_tracker.dart
@@ -47,37 +47,37 @@
/**
* The set of added files.
*/
- final addedFiles = new LinkedHashSet<String>();
+ final addedFiles = LinkedHashSet<String>();
/**
* The set of files were reported as changed through [changeFile] and not
* checked for actual changes yet.
*/
- final _changedFiles = new LinkedHashSet<String>();
+ final _changedFiles = LinkedHashSet<String>();
/**
* The set of files that are currently scheduled for analysis, which were
* reported as changed through [changeFile].
*/
- var _pendingChangedFiles = new LinkedHashSet<String>();
+ var _pendingChangedFiles = LinkedHashSet<String>();
/**
* The set of files that are currently scheduled for analysis, which directly
* import a changed file.
*/
- var _pendingImportFiles = new LinkedHashSet<String>();
+ var _pendingImportFiles = LinkedHashSet<String>();
/**
* The set of files that are currently scheduled for analysis, which have an
* error or a warning, which might be fixed by a changed file.
*/
- var _pendingErrorFiles = new LinkedHashSet<String>();
+ var _pendingErrorFiles = LinkedHashSet<String>();
/**
* The set of files that are currently scheduled for analysis, and don't
* have any special relation with changed files.
*/
- var _pendingFiles = new LinkedHashSet<String>();
+ var _pendingFiles = LinkedHashSet<String>();
FileTracker(this._logger, this._fsState, this._changeHook);
@@ -238,10 +238,10 @@
if (anyApiChanged) {
_logger.writeln('API signatures mismatch found.');
// TODO(scheglov) schedule analysis of only affected files
- var pendingChangedFiles = new LinkedHashSet<String>();
- var pendingImportFiles = new LinkedHashSet<String>();
- var pendingErrorFiles = new LinkedHashSet<String>();
- var pendingFiles = new LinkedHashSet<String>();
+ var pendingChangedFiles = LinkedHashSet<String>();
+ var pendingImportFiles = LinkedHashSet<String>();
+ var pendingErrorFiles = LinkedHashSet<String>();
+ var pendingFiles = LinkedHashSet<String>();
// Add the changed file.
if (addedFiles.contains(path)) {
diff --git a/pkg/analyzer/lib/src/dart/analysis/index.dart b/pkg/analyzer/lib/src/dart/analysis/index.dart
index e2856fc..9561c1a 100644
--- a/pkg/analyzer/lib/src/dart/analysis/index.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/index.dart
@@ -23,14 +23,14 @@
return e.definingCompilationUnit;
}
}
- throw new StateError('Element not contained in compilation unit: $element');
+ throw StateError('Element not contained in compilation unit: $element');
}
/**
* Index the [unit] into a new [AnalysisDriverUnitIndexBuilder].
*/
AnalysisDriverUnitIndexBuilder indexUnit(CompilationUnit unit) {
- return new _IndexAssembler().assemble(unit);
+ return _IndexAssembler().assemble(unit);
}
/**
@@ -89,11 +89,11 @@
kind = IndexSyntheticElementKind.topLevelVariable;
element = property.getter ?? property.setter;
} else {
- throw new ArgumentError(
+ throw ArgumentError(
'Unsupported synthetic element ${element.runtimeType}');
}
}
- return new IndexElementInfo._(element, kind);
+ return IndexElementInfo._(element, kind);
}
IndexElementInfo._(this.element, this.kind);
@@ -231,20 +231,20 @@
void addElementRelation(Element element, IndexRelationKind kind, int offset,
int length, bool isQualified) {
_ElementInfo elementInfo = _getElementInfo(element);
- elementRelations.add(new _ElementRelationInfo(
- elementInfo, kind, offset, length, isQualified));
+ elementRelations.add(
+ _ElementRelationInfo(elementInfo, kind, offset, length, isQualified));
}
void addNameRelation(
String name, IndexRelationKind kind, int offset, bool isQualified) {
_StringInfo nameId = _getStringInfo(name);
- nameRelations.add(new _NameRelationInfo(nameId, kind, offset, isQualified));
+ nameRelations.add(_NameRelationInfo(nameId, kind, offset, isQualified));
}
void addSubtype(String name, List<String> members, List<String> supertypes) {
for (var supertype in supertypes) {
subtypes.add(
- new _SubtypeInfo(
+ _SubtypeInfo(
_getStringInfo(supertype),
_getStringInfo(name),
members.map(_getStringInfo).toList(),
@@ -257,7 +257,7 @@
* Index the [unit] and assemble a new [AnalysisDriverUnitIndexBuilder].
*/
AnalysisDriverUnitIndexBuilder assemble(CompilationUnit unit) {
- unit.accept(new _IndexContributor(this));
+ unit.accept(_IndexContributor(this));
// Sort strings and set IDs.
List<_StringInfo> stringInfoList = stringMap.values.toList();
@@ -299,7 +299,7 @@
return a.supertype.id - b.supertype.id;
});
- return new AnalysisDriverUnitIndexBuilder(
+ return AnalysisDriverUnitIndexBuilder(
strings: stringInfoList.map((s) => s.value).toList(),
nullStringId: nullString.id,
unitLibraryUris: unitLibraryUris.map((s) => s.id).toList(),
@@ -325,7 +325,7 @@
nameRelations.map((r) => r.isQualified).toList(),
supertypes: subtypes.map((subtype) => subtype.supertype.id).toList(),
subtypes: subtypes.map((subtype) {
- return new AnalysisDriverSubtypeBuilder(
+ return AnalysisDriverSubtypeBuilder(
name: subtype.name.id,
members: subtype.members.map((member) => member.id).toList(),
);
@@ -351,7 +351,7 @@
*/
_StringInfo _getStringInfo(String string) {
return stringMap.putIfAbsent(string, () {
- return new _StringInfo(string);
+ return _StringInfo(string);
});
}
@@ -384,7 +384,7 @@
* This method is static, so it cannot add any information to the index.
*/
_ElementInfo _newElementInfo(int unitId, Element element) {
- IndexElementInfo info = new IndexElementInfo(element);
+ IndexElementInfo info = IndexElementInfo(element);
element = info.element;
// Prepare name identifiers.
_StringInfo nameIdParameter = nullString;
@@ -402,7 +402,7 @@
if (element?.enclosingElement is CompilationUnitElement) {
nameIdUnitMember = _getStringInfo(element.name);
}
- return new _ElementInfo(unitId, nameIdUnitMember, nameIdClassMember,
+ return _ElementInfo(unitId, nameIdUnitMember, nameIdClassMember,
nameIdParameter, info.kind);
}
}
@@ -884,7 +884,7 @@
*/
ConstructorElement _getActualConstructorElement(
ConstructorElement constructor) {
- Set<ConstructorElement> seenConstructors = new Set<ConstructorElement>();
+ Set<ConstructorElement> seenConstructors = Set<ConstructorElement>();
while (constructor != null &&
constructor.isSynthetic &&
constructor.redirectedConstructor != null) {
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index 10b10fb..fd7ad79 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -11,6 +11,13 @@
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/context/builder.dart';
+import 'package:analyzer/src/error/best_practices_verifier.dart';
+import 'package:analyzer/src/error/dart2js_verifier.dart';
+import 'package:analyzer/src/error/dead_code_verifier.dart';
+import 'package:analyzer/src/error/invalid_language_version_override_finder.dart';
+import 'package:analyzer/src/error/override_verifier.dart';
+import 'package:analyzer/src/error/todo_finder.dart';
+import 'package:analyzer/src/error/unused_local_elements_verifier.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:analyzer/src/dart/analysis/testing_data.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
@@ -58,7 +65,7 @@
/// A marker object used to prevent the initialization of
/// [_versionConstraintFromPubspec] when the previous initialization attempt
/// failed.
- static final VersionRange noSpecifiedRange = new VersionRange();
+ static final VersionRange noSpecifiedRange = VersionRange();
final AnalysisOptionsImpl _analysisOptions;
final DeclaredVariables _declaredVariables;
final SourceFactory _sourceFactory;
@@ -69,9 +76,7 @@
final bool Function(Uri) _isLibraryUri;
final AnalysisContext _context;
final LinkedElementFactory _elementFactory;
- TypeProviderImpl _typeProvider;
- final TypeSystemImpl _typeSystem;
LibraryElement _libraryElement;
LibraryScope _libraryScope;
@@ -89,9 +94,9 @@
*
* TODO(scheglov) Remove after https://github.com/dart-lang/sdk/issues/31925
*/
- final Set<ConstantEvaluationTarget> _libraryConstants = new Set();
+ final Set<ConstantEvaluationTarget> _libraryConstants = Set();
- final Set<ConstantEvaluationTarget> _constants = new Set();
+ final Set<ConstantEvaluationTarget> _constants = Set();
LibraryAnalyzer(
this._analysisOptions,
@@ -104,8 +109,11 @@
this._library,
this._resourceProvider,
{TestingData testingData})
- : _typeSystem = _context.typeSystem,
- _testingData = testingData;
+ : _testingData = testingData;
+
+ TypeProviderImpl get _typeProvider => _libraryElement.typeProvider;
+
+ TypeSystemImpl get _typeSystem => _libraryElement.typeSystem;
/**
* Compute analysis results for all units of the library.
@@ -132,19 +140,13 @@
// Resolve URIs in directives to corresponding sources.
FeatureSet featureSet = units[_library].featureSet;
- _typeProvider = _context.typeProvider;
- if (featureSet.isEnabled(Feature.non_nullable)) {
- _typeProvider = _typeProvider.asNonNullableByDefault;
- } else {
- _typeProvider = _typeProvider.asLegacy;
- }
units.forEach((file, unit) {
_validateFeatureSet(unit, featureSet);
_resolveUriBasedDirectives(file, unit);
});
_libraryElement = _elementFactory.libraryOfUri(_library.uriStr);
- _libraryScope = new LibraryScope(_libraryElement);
+ _libraryScope = LibraryScope(_libraryElement);
timerLibraryAnalyzerResolve.start();
_resolveDirectives(units);
@@ -171,13 +173,12 @@
PerformanceStatistics.hints.makeCurrentWhile(() {
units.forEach((file, unit) {
{
- var visitor = new GatherUsedLocalElementsVisitor(_libraryElement);
+ var visitor = GatherUsedLocalElementsVisitor(_libraryElement);
unit.accept(visitor);
_usedLocalElementsList.add(visitor.usedElements);
}
{
- var visitor =
- new GatherUsedImportedElementsVisitor(_libraryElement);
+ var visitor = GatherUsedImportedElementsVisitor(_libraryElement);
unit.accept(visitor);
_usedImportedElementsList.add(visitor.usedElements);
}
@@ -208,7 +209,7 @@
units.forEach((file, unit) {
List<AnalysisError> errors = _getErrorListener(file).errors;
errors = _filterIgnoredErrors(file, errors);
- results[file] = new UnitAnalysisResult(file, unit, errors);
+ results[file] = UnitAnalysisResult(file, unit, errors);
});
timerLibraryAnalyzer.stop();
return results;
@@ -234,7 +235,7 @@
void _computeConstantErrors(
ErrorReporter errorReporter, CompilationUnit unit) {
- ConstantVerifier constantVerifier = new ConstantVerifier(
+ ConstantVerifier constantVerifier = ConstantVerifier(
errorReporter, _libraryElement, _typeProvider, _declaredVariables,
featureSet: unit.featureSet, forAnalysisDriver: true);
unit.accept(constantVerifier);
@@ -244,7 +245,7 @@
* Compute [_constants] in all units.
*/
void _computeConstants() {
- computeConstants(_typeProvider, _context.typeSystem, _declaredVariables,
+ computeConstants(_typeProvider, _typeSystem, _declaredVariables,
_constants.toList(), _analysisOptions.experimentStatus);
}
@@ -256,32 +257,33 @@
AnalysisErrorListener errorListener = _getErrorListener(file);
ErrorReporter errorReporter = _getErrorReporter(file);
- unit.accept(new DeadCodeVerifier(errorReporter, unit.featureSet,
- typeSystem: _context.typeSystem));
+ unit.accept(DeadCodeVerifier(errorReporter, unit.featureSet,
+ typeSystem: _typeSystem));
// Dart2js analysis.
if (_analysisOptions.dart2jsHint) {
- unit.accept(new Dart2JSVerifier(errorReporter));
+ unit.accept(Dart2JSVerifier(errorReporter));
}
- unit.accept(new BestPracticesVerifier(
+ unit.accept(BestPracticesVerifier(
errorReporter, _typeProvider, _libraryElement, unit, file.content,
- typeSystem: _context.typeSystem,
+ typeSystem: _typeSystem,
inheritanceManager: _inheritance,
resourceProvider: _resourceProvider,
analysisOptions: _context.analysisOptions));
- unit.accept(new OverrideVerifier(
+ unit.accept(OverrideVerifier(
_inheritance,
_libraryElement,
errorReporter,
));
- new ToDoFinder(errorReporter).findIn(unit);
+ TodoFinder(errorReporter).findIn(unit);
+ InvalidLanguageVersionOverrideFinder(errorReporter).findIn(unit);
// Verify imports.
{
- ImportsVerifier verifier = new ImportsVerifier();
+ ImportsVerifier verifier = ImportsVerifier();
verifier.addImports(unit);
_usedImportedElementsList.forEach(verifier.removeUsedElements);
verifier.generateDuplicateImportHints(errorReporter);
@@ -293,8 +295,8 @@
// Unused local elements.
{
UsedLocalElements usedElements =
- new UsedLocalElements.merge(_usedLocalElementsList);
- UnusedLocalElementsVerifier visitor = new UnusedLocalElementsVerifier(
+ UsedLocalElements.merge(_usedLocalElementsList);
+ UnusedLocalElementsVerifier visitor = UnusedLocalElementsVerifier(
errorListener, usedElements, _inheritance, _libraryElement);
unit.accept(visitor);
}
@@ -305,7 +307,7 @@
//
var sdkVersionConstraint = _analysisOptions.sdkVersionConstraint;
if (sdkVersionConstraint != null) {
- SdkConstraintVerifier verifier = new SdkConstraintVerifier(
+ SdkConstraintVerifier verifier = SdkConstraintVerifier(
errorReporter, _libraryElement, _typeProvider, sdkVersionConstraint);
unit.accept(verifier);
}
@@ -320,7 +322,7 @@
ErrorReporter errorReporter = _getErrorReporter(file);
- var nodeRegistry = new NodeLintRegistry(_analysisOptions.enableTiming);
+ var nodeRegistry = NodeLintRegistry(_analysisOptions.enableTiming);
var visitors = <AstVisitor>[];
final workspacePackage = _getPackage(currentUnit.unit);
@@ -344,7 +346,7 @@
if (visitor != null) {
if (_analysisOptions.enableTiming) {
var timer = lintRegistry.getTimer(linter);
- visitor = new TimedAstVisitor(visitor, timer);
+ visitor = TimedAstVisitor(visitor, timer);
}
visitors.add(visitor);
}
@@ -352,12 +354,12 @@
}
// Run lints that handle specific node types.
- unit.accept(new LinterVisitor(
+ unit.accept(LinterVisitor(
nodeRegistry, ExceptionHandlingDelegatingAstVisitor.logException));
// Run visitor based lints.
if (visitors.isNotEmpty) {
- AstVisitor visitor = new ExceptionHandlingDelegatingAstVisitor(
+ AstVisitor visitor = ExceptionHandlingDelegatingAstVisitor(
visitors, ExceptionHandlingDelegatingAstVisitor.logException);
unit.accept(visitor);
}
@@ -370,9 +372,9 @@
RecordingErrorListener errorListener = _getErrorListener(file);
- CodeChecker checker = new CodeChecker(
+ CodeChecker checker = CodeChecker(
_typeProvider,
- _context.typeSystem,
+ _typeSystem,
_inheritance,
errorListener,
_analysisOptions,
@@ -394,14 +396,14 @@
//
// Compute inheritance and override errors.
//
- var inheritanceOverrideVerifier = new InheritanceOverrideVerifier(
- _context.typeSystem, _inheritance, errorReporter);
+ var inheritanceOverrideVerifier =
+ InheritanceOverrideVerifier(_typeSystem, _inheritance, errorReporter);
inheritanceOverrideVerifier.verifyUnit(unit);
//
// Use the ErrorVerifier to compute errors.
//
- ErrorVerifier errorVerifier = new ErrorVerifier(
+ ErrorVerifier errorVerifier = ErrorVerifier(
errorReporter, _libraryElement, _typeProvider, _inheritance, false);
unit.accept(errorVerifier);
@@ -447,23 +449,23 @@
/// Find constants to compute.
void _findConstants(CompilationUnit unit) {
- ConstantFinder constantFinder = new ConstantFinder();
+ ConstantFinder constantFinder = ConstantFinder();
unit.accept(constantFinder);
_libraryConstants.addAll(constantFinder.constantsToCompute);
_constants.addAll(constantFinder.constantsToCompute);
- var dependenciesFinder = new ConstantExpressionsDependenciesFinder();
+ var dependenciesFinder = ConstantExpressionsDependenciesFinder();
unit.accept(dependenciesFinder);
_constants.addAll(dependenciesFinder.dependencies);
}
RecordingErrorListener _getErrorListener(FileState file) =>
- _errorListeners.putIfAbsent(file, () => new RecordingErrorListener());
+ _errorListeners.putIfAbsent(file, () => RecordingErrorListener());
ErrorReporter _getErrorReporter(FileState file) {
return _errorReporters.putIfAbsent(file, () {
RecordingErrorListener listener = _getErrorListener(file);
- return new ErrorReporter(listener, file.source);
+ return ErrorReporter(listener, file.source);
});
}
@@ -495,13 +497,13 @@
directivesToResolve.add(directive);
LibraryIdentifier libraryName = directive.libraryName;
if (libraryName != null) {
- return new _NameOrSource(libraryName.name, null);
+ return _NameOrSource(libraryName.name, null);
}
String uri = directive.uri?.stringValue;
if (uri != null) {
Source librarySource = _sourceFactory.resolveUri(partSource, uri);
if (librarySource != null) {
- return new _NameOrSource(null, librarySource);
+ return _NameOrSource(null, librarySource);
}
}
}
@@ -551,7 +553,7 @@
ErrorReporter libraryErrorReporter = _getErrorReporter(_library);
LibraryIdentifier libraryNameNode;
- var seenPartSources = new Set<Source>();
+ var seenPartSources = Set<Source>();
var directivesToResolve = <Directive>[];
int partIndex = 0;
for (Directive directive in definingCompilationUnit.directives) {
@@ -690,17 +692,12 @@
),
);
- unit.accept(new VariableResolverVisitor(
+ unit.accept(VariableResolverVisitor(
_libraryElement, source, _typeProvider, errorListener,
nameScope: _libraryScope));
- unit.accept(new PartialResolverVisitor(
- _inheritance,
- _libraryElement,
- source,
- _typeProvider,
- AnalysisErrorListener.NULL_LISTENER,
- unit.featureSet));
+ unit.accept(PartialResolverVisitor(_inheritance, _libraryElement, source,
+ _typeProvider, AnalysisErrorListener.NULL_LISTENER, unit.featureSet));
// Nothing for RESOLVED_UNIT8?
// Nothing for RESOLVED_UNIT9?
@@ -709,12 +706,12 @@
FlowAnalysisHelper flowAnalysisHelper;
if (unit.featureSet.isEnabled(Feature.non_nullable)) {
flowAnalysisHelper =
- FlowAnalysisHelper(_context.typeSystem, _testingData != null);
+ FlowAnalysisHelper(_typeSystem, _testingData != null);
_testingData?.recordFlowAnalysisDataForTesting(
file.uri, flowAnalysisHelper.dataForTesting);
}
- unit.accept(new ResolverVisitor(
+ unit.accept(ResolverVisitor(
_inheritance, _libraryElement, source, _typeProvider, errorListener,
featureSet: unit.featureSet, flowAnalysisHelper: flowAnalysisHelper));
}
@@ -758,9 +755,28 @@
file, directive is ImportDirective, uriLiteral, uriContent);
directive.uriSource = defaultSource;
}
+ if (directive is NamespaceDirectiveImpl) {
+ var relativeUri = _selectRelativeUri(directive);
+ directive.selectedUriContent = relativeUri;
+ directive.selectedSource = _sourceFactory.resolveUri(
+ _library.source,
+ relativeUri,
+ );
+ }
}
}
+ String _selectRelativeUri(NamespaceDirective directive) {
+ for (var configuration in directive.configurations) {
+ var name = configuration.name.components.join('.');
+ var value = configuration.value?.stringValue ?? 'true';
+ if (_declaredVariables.get(name) == value) {
+ return configuration.uri.stringValue ?? '';
+ }
+ }
+ return directive.uri?.stringValue ?? '';
+ }
+
/// Validate that the feature set associated with the compilation [unit] is
/// the same as the [expectedSet] of features supported by the library.
void _validateFeatureSet(CompilationUnit unit, FeatureSet expectedSet) {
@@ -776,7 +792,15 @@
*/
void _validateUriBasedDirective(
FileState file, UriBasedDirectiveImpl directive) {
- Source source = directive.uriSource;
+ String uriContent;
+ Source source;
+ if (directive is NamespaceDirectiveImpl) {
+ uriContent = directive.selectedUriContent;
+ source = directive.selectedSource;
+ } else {
+ uriContent = directive.uriContent;
+ source = directive.uriSource;
+ }
if (source != null) {
if (_isExistingSource(source)) {
return;
@@ -794,7 +818,7 @@
errorCode = CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED;
}
_getErrorReporter(file)
- .reportErrorForNode(errorCode, uriLiteral, [directive.uriContent]);
+ .reportErrorForNode(errorCode, uriLiteral, [uriContent]);
}
/**
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index 4bb8489..f9affc9 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -16,7 +16,6 @@
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
import 'package:analyzer/src/generated/engine.dart'
show AnalysisContext, AnalysisOptions;
-import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/package_bundle_reader.dart';
@@ -46,7 +45,7 @@
final ByteStore byteStore;
final AnalysisSession analysisSession;
final SummaryDataStore externalSummaries;
- final SummaryDataStore store = new SummaryDataStore([]);
+ final SummaryDataStore store = SummaryDataStore([]);
/// The size of the linked data that is loaded by this context.
/// When it reaches [_maxLinkedDataInBytes] the whole context is thrown away.
@@ -79,15 +78,10 @@
_createElementFactory();
load2(targetLibrary);
- inheritanceManager = new InheritanceManager3();
+ inheritanceManager = InheritanceManager3();
}
/**
- * The type provider used in this context.
- */
- TypeProvider get typeProvider => analysisContext.typeProvider;
-
- /**
* Computes a [CompilationUnitElement] for the given library/unit pair.
*/
CompilationUnitElement computeUnitElement(FileState library, FileState unit) {
@@ -273,10 +267,10 @@
/// Ensure that type provider is created.
void _createElementFactoryTypeProvider() {
- if (analysisContext.typeProvider != null) return;
-
- var dartCore = elementFactory.libraryOfUri('dart:core');
- var dartAsync = elementFactory.libraryOfUri('dart:async');
- elementFactory.createTypeProviders(dartCore, dartAsync);
+ if (analysisContext.typeProviderNonNullableByDefault == null) {
+ var dartCore = elementFactory.libraryOfUri('dart:core');
+ var dartAsync = elementFactory.libraryOfUri('dart:async');
+ elementFactory.createTypeProviders(dartCore, dartAsync);
+ }
}
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_graph.dart b/pkg/analyzer/lib/src/dart/analysis/library_graph.dart
index 9232da87..551c312 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_graph.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_graph.dart
@@ -12,7 +12,7 @@
/// Ensure that the [FileState.libraryCycle] for the [file] and anything it
/// depends on is computed.
void computeLibraryCycle(Uint32List linkedSalt, FileState file) {
- var libraryWalker = new _LibraryWalker(linkedSalt);
+ var libraryWalker = _LibraryWalker(linkedSalt);
libraryWalker.walk(libraryWalker.getNode(file));
}
@@ -22,7 +22,7 @@
final List<FileState> libraries = [];
/// The library cycles that this cycle references directly.
- final Set<LibraryCycle> directDependencies = new Set<LibraryCycle>();
+ final Set<LibraryCycle> directDependencies = Set<LibraryCycle>();
/// The cycles that use this cycle, used to [invalidate] transitively.
final List<LibraryCycle> _directUsers = [];
@@ -100,9 +100,9 @@
@override
void evaluateScc(List<_LibraryNode> scc) {
- var cycle = new LibraryCycle();
+ var cycle = LibraryCycle();
- var signature = new ApiSignature();
+ var signature = ApiSignature();
signature.addUint32List(_linkedSalt);
// Sort libraries to produce stable signatures.
@@ -137,7 +137,7 @@
// Compute library specific signatures.
for (var node in scc) {
- var librarySignatureBuilder = new ApiSignature()
+ var librarySignatureBuilder = ApiSignature()
..addString(node.file.uriStr)
..addString(cycle.transitiveSignature);
var librarySignature = librarySignatureBuilder.toHex();
@@ -150,7 +150,7 @@
}
_LibraryNode getNode(FileState file) {
- return nodesOfFiles.putIfAbsent(file, () => new _LibraryNode(this, file));
+ return nodesOfFiles.putIfAbsent(file, () => _LibraryNode(this, file));
}
void _appendDirectlyReferenced(
diff --git a/pkg/analyzer/lib/src/dart/analysis/mutex.dart b/pkg/analyzer/lib/src/dart/analysis/mutex.dart
index bf7532a..0324bf5 100644
--- a/pkg/analyzer/lib/src/dart/analysis/mutex.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/mutex.dart
@@ -29,7 +29,7 @@
while (_lock != null) {
await _lock.future;
}
- _lock = new Completer<void>();
+ _lock = Completer<void>();
}
/// Run the given [criticalSection] with acquired mutex.
@@ -49,7 +49,7 @@
/// Release a lock that has been acquired.
void release() {
if (_lock == null) {
- throw new StateError('No lock to release.');
+ throw StateError('No lock to release.');
}
_lock.complete();
_lock = null;
diff --git a/pkg/analyzer/lib/src/dart/analysis/performance_logger.dart b/pkg/analyzer/lib/src/dart/analysis/performance_logger.dart
index 6c265db..737651c 100644
--- a/pkg/analyzer/lib/src/dart/analysis/performance_logger.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/performance_logger.dart
@@ -18,7 +18,7 @@
PerformanceLogSection enter(String msg) {
writeln('+++ $msg.');
_level++;
- return new PerformanceLogSection(this, msg);
+ return PerformanceLogSection(this, msg);
}
/// Return the result of the function [f] invocation and log the elapsed time.
@@ -27,7 +27,7 @@
/// which begins with printing [msg], then any log output produced during
/// [f] invocation, and ends with printing [msg] with the elapsed time.
T run<T>(String msg, T f()) {
- Stopwatch timer = new Stopwatch()..start();
+ Stopwatch timer = Stopwatch()..start();
try {
writeln('+++ $msg.');
_level++;
@@ -45,7 +45,7 @@
/// which begins with printing [msg], then any log output produced during
/// [f] invocation, and ends with printing [msg] with the elapsed time.
Future<T> runAsync<T>(String msg, Future<T> f()) async {
- Stopwatch timer = new Stopwatch()..start();
+ Stopwatch timer = Stopwatch()..start();
try {
writeln('+++ $msg.');
_level++;
@@ -75,7 +75,7 @@
class PerformanceLogSection {
final PerformanceLog _logger;
final String _msg;
- final Stopwatch _timer = new Stopwatch()..start();
+ final Stopwatch _timer = Stopwatch()..start();
PerformanceLogSection(this._logger, this._msg);
diff --git a/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart b/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart
index ab09542..b13105c 100644
--- a/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart
@@ -9,7 +9,7 @@
* Compute the set of external names referenced in the [unit].
*/
Set<String> computeReferencedNames(CompilationUnit unit) {
- _ReferencedNamesComputer computer = new _ReferencedNamesComputer();
+ _ReferencedNamesComputer computer = _ReferencedNamesComputer();
unit.accept(computer);
return computer.names;
}
@@ -19,7 +19,7 @@
* clauses in the file. Import prefixes and type arguments are not included.
*/
Set<String> computeSubtypedNames(CompilationUnit unit) {
- Set<String> subtypedNames = new Set<String>();
+ Set<String> subtypedNames = Set<String>();
void _addSubtypedName(TypeName type) {
if (type != null) {
@@ -64,7 +64,7 @@
_LocalNameScope(this.enclosing);
factory _LocalNameScope.forBlock(_LocalNameScope enclosing, Block node) {
- _LocalNameScope scope = new _LocalNameScope(enclosing);
+ _LocalNameScope scope = _LocalNameScope(enclosing);
for (Statement statement in node.statements) {
if (statement is FunctionDeclarationStatement) {
scope.add(statement.functionDeclaration.name);
@@ -77,7 +77,7 @@
factory _LocalNameScope.forClass(
_LocalNameScope enclosing, ClassDeclaration node) {
- _LocalNameScope scope = new _LocalNameScope(enclosing);
+ _LocalNameScope scope = _LocalNameScope(enclosing);
scope.addTypeParameters(node.typeParameters);
for (ClassMember member in node.members) {
if (member is FieldDeclaration) {
@@ -91,21 +91,21 @@
factory _LocalNameScope.forClassTypeAlias(
_LocalNameScope enclosing, ClassTypeAlias node) {
- _LocalNameScope scope = new _LocalNameScope(enclosing);
+ _LocalNameScope scope = _LocalNameScope(enclosing);
scope.addTypeParameters(node.typeParameters);
return scope;
}
factory _LocalNameScope.forConstructor(
_LocalNameScope enclosing, ConstructorDeclaration node) {
- _LocalNameScope scope = new _LocalNameScope(enclosing);
+ _LocalNameScope scope = _LocalNameScope(enclosing);
scope.addFormalParameters(node.parameters);
return scope;
}
factory _LocalNameScope.forFunction(
_LocalNameScope enclosing, FunctionDeclaration node) {
- _LocalNameScope scope = new _LocalNameScope(enclosing);
+ _LocalNameScope scope = _LocalNameScope(enclosing);
scope.addTypeParameters(node.functionExpression.typeParameters);
scope.addFormalParameters(node.functionExpression.parameters);
return scope;
@@ -113,21 +113,21 @@
factory _LocalNameScope.forFunctionTypeAlias(
_LocalNameScope enclosing, FunctionTypeAlias node) {
- _LocalNameScope scope = new _LocalNameScope(enclosing);
+ _LocalNameScope scope = _LocalNameScope(enclosing);
scope.addTypeParameters(node.typeParameters);
return scope;
}
factory _LocalNameScope.forMethod(
_LocalNameScope enclosing, MethodDeclaration node) {
- _LocalNameScope scope = new _LocalNameScope(enclosing);
+ _LocalNameScope scope = _LocalNameScope(enclosing);
scope.addTypeParameters(node.typeParameters);
scope.addFormalParameters(node.parameters);
return scope;
}
factory _LocalNameScope.forUnit(CompilationUnit node) {
- _LocalNameScope scope = new _LocalNameScope(null);
+ _LocalNameScope scope = _LocalNameScope(null);
for (CompilationUnitMember declaration in node.declarations) {
if (declaration is NamedCompilationUnitMember) {
scope.add(declaration.name);
@@ -140,7 +140,7 @@
void add(SimpleIdentifier identifier) {
if (identifier != null) {
- names ??= new Set<String>();
+ names ??= Set<String>();
names.add(identifier.name);
}
}
@@ -177,16 +177,16 @@
}
class _ReferencedNamesComputer extends GeneralizingAstVisitor {
- final Set<String> names = new Set<String>();
- final Set<String> importPrefixNames = new Set<String>();
+ final Set<String> names = Set<String>();
+ final Set<String> importPrefixNames = Set<String>();
- _LocalNameScope localScope = new _LocalNameScope(null);
+ _LocalNameScope localScope = _LocalNameScope(null);
@override
visitBlock(Block node) {
_LocalNameScope outerScope = localScope;
try {
- localScope = new _LocalNameScope.forBlock(localScope, node);
+ localScope = _LocalNameScope.forBlock(localScope, node);
super.visitBlock(node);
} finally {
localScope = outerScope;
@@ -197,7 +197,7 @@
visitClassDeclaration(ClassDeclaration node) {
_LocalNameScope outerScope = localScope;
try {
- localScope = new _LocalNameScope.forClass(localScope, node);
+ localScope = _LocalNameScope.forClass(localScope, node);
super.visitClassDeclaration(node);
} finally {
localScope = outerScope;
@@ -208,7 +208,7 @@
visitClassTypeAlias(ClassTypeAlias node) {
_LocalNameScope outerScope = localScope;
try {
- localScope = new _LocalNameScope.forClassTypeAlias(localScope, node);
+ localScope = _LocalNameScope.forClassTypeAlias(localScope, node);
super.visitClassTypeAlias(node);
} finally {
localScope = outerScope;
@@ -217,7 +217,7 @@
@override
visitCompilationUnit(CompilationUnit node) {
- localScope = new _LocalNameScope.forUnit(node);
+ localScope = _LocalNameScope.forUnit(node);
super.visitCompilationUnit(node);
}
@@ -225,7 +225,7 @@
visitConstructorDeclaration(ConstructorDeclaration node) {
_LocalNameScope outerScope = localScope;
try {
- localScope = new _LocalNameScope.forConstructor(localScope, node);
+ localScope = _LocalNameScope.forConstructor(localScope, node);
super.visitConstructorDeclaration(node);
} finally {
localScope = outerScope;
@@ -243,7 +243,7 @@
visitFunctionDeclaration(FunctionDeclaration node) {
_LocalNameScope outerScope = localScope;
try {
- localScope = new _LocalNameScope.forFunction(localScope, node);
+ localScope = _LocalNameScope.forFunction(localScope, node);
super.visitFunctionDeclaration(node);
} finally {
localScope = outerScope;
@@ -254,7 +254,7 @@
visitFunctionTypeAlias(FunctionTypeAlias node) {
_LocalNameScope outerScope = localScope;
try {
- localScope = new _LocalNameScope.forFunctionTypeAlias(localScope, node);
+ localScope = _LocalNameScope.forFunctionTypeAlias(localScope, node);
super.visitFunctionTypeAlias(node);
} finally {
localScope = outerScope;
@@ -273,7 +273,7 @@
visitMethodDeclaration(MethodDeclaration node) {
_LocalNameScope outerScope = localScope;
try {
- localScope = new _LocalNameScope.forMethod(localScope, node);
+ localScope = _LocalNameScope.forMethod(localScope, node);
super.visitMethodDeclaration(node);
} finally {
localScope = outerScope;
diff --git a/pkg/analyzer/lib/src/dart/analysis/results.dart b/pkg/analyzer/lib/src/dart/analysis/results.dart
index 0011291..b4b90a5 100644
--- a/pkg/analyzer/lib/src/dart/analysis/results.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/results.dart
@@ -152,17 +152,14 @@
final LibraryElement element;
@override
- final TypeProvider typeProvider;
-
- @override
final List<ResolvedUnitResult> units;
- ResolvedLibraryResultImpl(AnalysisSession session, String path, Uri uri,
- this.element, this.typeProvider, this.units)
+ ResolvedLibraryResultImpl(
+ AnalysisSession session, String path, Uri uri, this.element, this.units)
: super(session, path, uri);
ResolvedLibraryResultImpl.external(AnalysisSession session, Uri uri)
- : this(session, null, uri, null, null, null);
+ : this(session, null, uri, null, null);
@override
ResultState get state {
@@ -172,6 +169,8 @@
return ResultState.VALID;
}
+ TypeProvider get typeProvider => element.typeProvider;
+
@override
ElementDeclarationResult getElementDeclaration(Element element) {
if (state != ResultState.VALID) {
@@ -232,10 +231,10 @@
ResultState get state => exists ? ResultState.VALID : ResultState.NOT_A_FILE;
@override
- TypeProvider get typeProvider => unit.declaredElement.context.typeProvider;
+ TypeProvider get typeProvider => libraryElement.typeProvider;
@override
- TypeSystemImpl get typeSystem => unit.declaredElement.context.typeSystem;
+ TypeSystemImpl get typeSystem => libraryElement.typeSystem;
}
class UnitElementResultImpl extends AnalysisResultImpl
diff --git a/pkg/analyzer/lib/src/dart/analysis/search.dart b/pkg/analyzer/lib/src/dart/analysis/search.dart
index 1eadd80..385f6c7 100644
--- a/pkg/analyzer/lib/src/dart/analysis/search.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/search.dart
@@ -18,7 +18,7 @@
import 'package:collection/collection.dart';
Element _getEnclosingElement(CompilationUnitElement unitElement, int offset) {
- var finder = new _ContainingElementFinder(offset);
+ var finder = _ContainingElementFinder(offset);
unitElement.accept(finder);
Element element = finder.containingElement;
assert(element != null,
@@ -164,7 +164,7 @@
if (searchedFiles.add(file.path, this)) {
AnalysisDriverUnitIndex index = await _driver.getIndex(file.path);
if (index != null) {
- var request = new _IndexRequest(index);
+ var request = _IndexRequest(index);
request.addSubtypes(id, results, file);
}
}
@@ -226,7 +226,7 @@
if (searchedFiles.add(file, this)) {
AnalysisDriverUnitIndex index = await _driver.getIndex(file);
if (index != null) {
- _IndexRequest request = new _IndexRequest(index);
+ _IndexRequest request = _IndexRequest(index);
var fileResults = await request.getUnresolvedMemberReferences(
name,
const {
@@ -298,7 +298,7 @@
await null;
AnalysisDriverUnitIndex index = await _driver.getIndex(file);
if (index != null) {
- _IndexRequest request = new _IndexRequest(index);
+ _IndexRequest request = _IndexRequest(index);
int elementId = request.findElementId(element);
if (elementId != -1) {
List<SearchResult> fileResults = await request.getRelations(
@@ -418,7 +418,7 @@
String unitPath = unitElement.source.fullName;
ResolvedUnitResult unitResult = await _driver.getResult(unitPath);
_ImportElementReferencesVisitor visitor =
- new _ImportElementReferencesVisitor(element, unitElement);
+ _ImportElementReferencesVisitor(element, unitElement);
unitResult.unit.accept(visitor);
results.addAll(visitor.results);
}
@@ -441,7 +441,7 @@
CompilationUnit unit = unitResult.unit;
for (Directive directive in unit.directives) {
if (directive is PartOfDirective && directive.element == element) {
- results.add(new SearchResult._(
+ results.add(SearchResult._(
unit.declaredElement,
SearchResultKind.REFERENCE,
directive.libraryName.offset,
@@ -471,7 +471,7 @@
}
// Prepare the node.
- AstNode node = new NodeLocator(element.nameOffset).searchWithin(unit);
+ AstNode node = NodeLocator(element.nameOffset).searchWithin(unit);
if (node == null) {
return const <SearchResult>[];
}
@@ -484,7 +484,7 @@
// Find the matches.
_LocalReferencesVisitor visitor =
- new _LocalReferencesVisitor(element, unit.declaredElement);
+ _LocalReferencesVisitor(element, unit.declaredElement);
enclosingNode.accept(visitor);
return visitor.results;
}
@@ -523,7 +523,7 @@
String unitPath = unitElement.source.fullName;
ResolvedUnitResult unitResult = await _driver.getResult(unitPath);
_LocalReferencesVisitor visitor =
- new _LocalReferencesVisitor(element, unitElement);
+ _LocalReferencesVisitor(element, unitElement);
unitResult.unit.accept(visitor);
results.addAll(visitor.results);
}
@@ -597,7 +597,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write("SearchResult(kind=");
buffer.write(kind);
buffer.write(", enclosingElement=");
@@ -723,7 +723,7 @@
void _addResult(int offset, int length) {
Element enclosingElement =
_getEnclosingElement(enclosingUnitElement, offset);
- results.add(new SearchResult._(enclosingElement, SearchResultKind.REFERENCE,
+ results.add(SearchResult._(enclosingElement, SearchResultKind.REFERENCE,
offset, length, true, false));
}
@@ -755,7 +755,7 @@
var subtype = index.subtypes[superIndex];
var name = index.strings[subtype.name];
var subId = '${library.uriStr};${file.uriStr};$name';
- results.add(new SubtypeResult(
+ results.add(SubtypeResult(
library.uriStr,
subId,
name,
@@ -769,7 +769,7 @@
* [element] is not referenced in the [index].
*/
int findElementId(Element element) {
- IndexElementInfo info = new IndexElementInfo(element);
+ IndexElementInfo info = IndexElementInfo(element);
element = info.element;
// Find the id of the element's unit.
int unitId = getUnitId(element);
@@ -882,7 +882,7 @@
if (enclosingUnitElement != null) {
Element enclosingElement =
_getEnclosingElement(enclosingUnitElement, offset);
- results.add(new SearchResult._(
+ results.add(SearchResult._(
enclosingElement,
resultKind,
offset,
@@ -960,7 +960,7 @@
if (enclosingUnitElement != null) {
Element enclosingElement =
_getEnclosingElement(enclosingUnitElement, offset);
- results.add(new SearchResult._(enclosingElement, resultKind, offset,
+ results.add(SearchResult._(enclosingElement, resultKind, offset,
name.length, false, index.usedNameIsQualifiedFlags[i]));
}
}
@@ -1044,7 +1044,7 @@
bool isQualified = node.parent is Label;
Element enclosingElement =
_getEnclosingElement(enclosingUnitElement, node.offset);
- results.add(new SearchResult._(
+ results.add(SearchResult._(
enclosingElement, kind, node.offset, node.length, true, isQualified));
}
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/session.dart b/pkg/analyzer/lib/src/dart/analysis/session.dart
index f4139fe..1df5098 100644
--- a/pkg/analyzer/lib/src/dart/analysis/session.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/session.dart
@@ -51,6 +51,7 @@
@override
SourceFactory get sourceFactory => _driver.sourceFactory;
+ @Deprecated('Use LibraryElement.typeProvider')
@override
Future<TypeProvider> get typeProvider async {
// TODO(brianwilkerson) Determine whether this await is necessary.
@@ -59,7 +60,7 @@
if (_typeProvider == null) {
LibraryElement coreLibrary = await _driver.getLibraryByUri('dart:core');
LibraryElement asyncLibrary = await _driver.getLibraryByUri('dart:async');
- _typeProvider = new TypeProviderImpl(
+ _typeProvider = TypeProviderImpl(
coreLibrary: coreLibrary,
asyncLibrary: asyncLibrary,
isNonNullableByDefault: false,
@@ -68,6 +69,7 @@
return _typeProvider;
}
+ @Deprecated('Use LibraryElement.typeSystem')
@override
Future<TypeSystemImpl> get typeSystem async {
// TODO(brianwilkerson) Determine whether this await is necessary.
@@ -87,7 +89,7 @@
@override
UriConverter get uriConverter {
- return _uriConverter ??= new DriverBasedUriConverter(_driver);
+ return _uriConverter ??= DriverBasedUriConverter(_driver);
}
@deprecated
@@ -191,13 +193,13 @@
/// an [InconsistentAnalysisException] if they might not be.
void _checkConsistency() {
if (_driver.currentSession != this) {
- throw new InconsistentAnalysisException();
+ throw InconsistentAnalysisException();
}
}
void _checkElementOfThisSession(Element element) {
if (element.session != this) {
- throw new ArgumentError(
+ throw ArgumentError(
'(${element.runtimeType}) $element was not produced by '
'this session.');
}
@@ -219,6 +221,7 @@
SynchronousSession(this.analysisOptions, this.declaredVariables);
+ @Deprecated('Use LibraryElement.typeProvider')
TypeProvider get typeProvider => _typeProviderLegacy;
TypeProvider get typeProviderLegacy {
@@ -229,6 +232,7 @@
return _typeProviderNonNullableByDefault;
}
+ @Deprecated('Use LibraryElement.typeSystem')
TypeSystemImpl get typeSystem {
return typeSystemLegacy;
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/status.dart b/pkg/analyzer/lib/src/dart/analysis/status.dart
index 383de26..aa11c22 100644
--- a/pkg/analyzer/lib/src/dart/analysis/status.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/status.dart
@@ -37,7 +37,7 @@
* after completion and will not complete until [notify] is called next time.
*/
class Monitor {
- Completer<void> _completer = new Completer<void>();
+ Completer<void> _completer = Completer<void>();
/**
* Return a [Future] that completes when [notify] is called at least once.
@@ -46,7 +46,7 @@
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
await _completer.future;
- _completer = new Completer<void>();
+ _completer = Completer<void>();
}
/**
@@ -67,7 +67,7 @@
/**
* The controller for the [stream].
*/
- final _statusController = new StreamController<AnalysisStatus>();
+ final _statusController = StreamController<AnalysisStatus>();
/**
* The last status sent to the [stream].
@@ -98,7 +98,7 @@
* as a call to [transitionToAnalyzing], but it has no effect on the [stream].
*/
void preTransitionToAnalyzing() {
- _idleCompleter ??= new Completer<void>();
+ _idleCompleter ??= Completer<void>();
}
/**
@@ -131,6 +131,6 @@
* immediately.
*/
Future<void> waitForIdle() {
- return _idleCompleter?.future ?? new Future<void>.value();
+ return _idleCompleter?.future ?? Future<void>.value();
}
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/uri_converter.dart b/pkg/analyzer/lib/src/dart/analysis/uri_converter.dart
index a05c39c..04e200b 100644
--- a/pkg/analyzer/lib/src/dart/analysis/uri_converter.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/uri_converter.dart
@@ -34,7 +34,7 @@
String relativePath =
context.relative(path, from: context.dirname(containingPath));
if (context.isRelative(relativePath)) {
- return new Uri.file(relativePath);
+ return Uri.file(relativePath);
}
}
}
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index b6c1232..f38e169 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -43,7 +43,7 @@
/// Initialize a newly created list of adjacent strings. To be syntactically
/// valid, the list of [strings] must contain at least two elements.
AdjacentStringsImpl(List<StringLiteral> strings) {
- _strings = new NodeListImpl<StringLiteral>(this, strings);
+ _strings = NodeListImpl<StringLiteral>(this, strings);
}
@override
@@ -51,7 +51,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..addAll(_strings);
+ ChildEntities()..addAll(_strings);
@override
Token get endToken => _strings.endToken;
@@ -92,7 +92,7 @@
/// attribute.
AnnotatedNodeImpl(CommentImpl comment, List<Annotation> metadata) {
_comment = _becomeParentOf(comment);
- _metadata = new NodeListImpl<Annotation>(this, metadata);
+ _metadata = NodeListImpl<Annotation>(this, metadata);
}
@override
@@ -117,7 +117,7 @@
Comment get documentationComment => _comment;
@override
- void set documentationComment(Comment comment) {
+ set documentationComment(Comment comment) {
_comment = _becomeParentOf(comment as CommentImpl);
}
@@ -134,7 +134,7 @@
/// Return a holder of child entities that subclasses can add to.
ChildEntities get _childEntities {
- ChildEntities result = new ChildEntities();
+ ChildEntities result = ChildEntities();
if (_commentIsBeforeAnnotations()) {
result
..add(_comment)
@@ -224,7 +224,7 @@
ArgumentList get arguments => _arguments;
@override
- void set arguments(ArgumentList arguments) {
+ set arguments(ArgumentList arguments) {
_arguments = _becomeParentOf(arguments as ArgumentListImpl);
}
@@ -232,7 +232,7 @@
Token get beginToken => atSign;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(atSign)
..add(_name)
..add(period)
@@ -243,7 +243,7 @@
SimpleIdentifier get constructorName => _constructorName;
@override
- void set constructorName(SimpleIdentifier name) {
+ set constructorName(SimpleIdentifier name) {
_constructorName = _becomeParentOf(name as SimpleIdentifierImpl);
}
@@ -258,7 +258,7 @@
}
@override
- void set element(Element element) {
+ set element(Element element) {
_element = element;
}
@@ -276,7 +276,7 @@
Identifier get name => _name;
@override
- void set name(Identifier name) {
+ set name(Identifier name) {
_name = _becomeParentOf(name as IdentifierImpl);
}
@@ -324,7 +324,7 @@
/// be `null` if there are no arguments.
ArgumentListImpl(
this.leftParenthesis, List<Expression> arguments, this.rightParenthesis) {
- _arguments = new NodeListImpl<Expression>(this, arguments);
+ _arguments = NodeListImpl<Expression>(this, arguments);
}
@override
@@ -335,7 +335,7 @@
@override
// TODO(paulberry): Add commas.
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(leftParenthesis)
..addAll(_arguments)
..add(rightParenthesis);
@@ -344,9 +344,9 @@
_correspondingStaticParameters;
@override
- void set correspondingStaticParameters(List<ParameterElement> parameters) {
+ set correspondingStaticParameters(List<ParameterElement> parameters) {
if (parameters != null && parameters.length != _arguments.length) {
- throw new ArgumentError(
+ throw ArgumentError(
"Expected ${_arguments.length} parameters, not ${parameters.length}");
}
_correspondingStaticParameters = parameters;
@@ -416,7 +416,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_expression)..add(asOperator)..add(_type);
+ ChildEntities()..add(_expression)..add(asOperator)..add(_type);
@override
Token get endToken => _type.endToken;
@@ -425,7 +425,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -436,7 +436,7 @@
TypeAnnotation get type => _type;
@override
- void set type(TypeAnnotation type) {
+ set type(TypeAnnotation type) {
_type = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -491,7 +491,7 @@
Token get beginToken => assertKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(assertKeyword)
..add(leftParenthesis)
..add(_condition)
@@ -503,7 +503,7 @@
Expression get condition => _condition;
@override
- void set condition(Expression condition) {
+ set condition(Expression condition) {
_condition = _becomeParentOf(condition as ExpressionImpl);
}
@@ -514,7 +514,7 @@
Expression get message => _message;
@override
- void set message(Expression expression) {
+ set message(Expression expression) {
_message = _becomeParentOf(expression as ExpressionImpl);
}
@@ -572,7 +572,7 @@
Token get beginToken => assertKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(assertKeyword)
..add(leftParenthesis)
..add(_condition)
@@ -585,7 +585,7 @@
Expression get condition => _condition;
@override
- void set condition(Expression condition) {
+ set condition(Expression condition) {
_condition = _becomeParentOf(condition as ExpressionImpl);
}
@@ -596,7 +596,7 @@
Expression get message => _message;
@override
- void set message(Expression expression) {
+ set message(Expression expression) {
_message = _becomeParentOf(expression as ExpressionImpl);
}
@@ -650,7 +650,7 @@
}
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(message, new AnalysisException(message), null),
+ SilentException(message, AnalysisException(message), null),
StackTrace.current);
}
_leftHandSide = _becomeParentOf(leftHandSide);
@@ -661,10 +661,8 @@
Token get beginToken => _leftHandSide.beginToken;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
- ..add(_leftHandSide)
- ..add(operator)
- ..add(_rightHandSide);
+ Iterable<SyntacticEntity> get childEntities =>
+ ChildEntities()..add(_leftHandSide)..add(operator)..add(_rightHandSide);
@override
Token get endToken => _rightHandSide.endToken;
@@ -673,7 +671,7 @@
Expression get leftHandSide => _leftHandSide;
@override
- void set leftHandSide(Expression expression) {
+ set leftHandSide(Expression expression) {
_leftHandSide = _becomeParentOf(expression as ExpressionImpl);
}
@@ -684,7 +682,7 @@
Expression get rightHandSide => _rightHandSide;
@override
- void set rightHandSide(Expression expression) {
+ set rightHandSide(Expression expression) {
_rightHandSide = _becomeParentOf(expression as ExpressionImpl);
}
@@ -808,7 +806,7 @@
}
} else {
if (_propertyMap == null) {
- _propertyMap = new HashMap<String, Object>();
+ _propertyMap = HashMap<String, Object>();
}
_propertyMap[name] = value;
}
@@ -835,8 +833,8 @@
@override
String toSource() {
- StringBuffer buffer = new StringBuffer();
- accept(new ToSourceVisitor(buffer));
+ StringBuffer buffer = StringBuffer();
+ accept(ToSourceVisitor(buffer));
return buffer.toString();
}
@@ -880,7 +878,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(awaitKeyword)..add(_expression);
+ ChildEntities()..add(awaitKeyword)..add(_expression);
@override
Token get endToken => _expression.endToken;
@@ -889,7 +887,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -941,7 +939,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_leftOperand)..add(operator)..add(_rightOperand);
+ ChildEntities()..add(_leftOperand)..add(operator)..add(_rightOperand);
@override
Token get endToken => _rightOperand.endToken;
@@ -950,7 +948,7 @@
Expression get leftOperand => _leftOperand;
@override
- void set leftOperand(Expression expression) {
+ set leftOperand(Expression expression) {
_leftOperand = _becomeParentOf(expression as ExpressionImpl);
}
@@ -961,7 +959,7 @@
Expression get rightOperand => _rightOperand;
@override
- void set rightOperand(Expression expression) {
+ set rightOperand(Expression expression) {
_rightOperand = _becomeParentOf(expression as ExpressionImpl);
}
@@ -1014,13 +1012,13 @@
Block get block => _block;
@override
- void set block(Block block) {
+ set block(Block block) {
_block = _becomeParentOf(block as BlockImpl);
}
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(keyword)..add(star)..add(_block);
+ ChildEntities()..add(keyword)..add(star)..add(_block);
@override
Token get endToken => _block.endToken;
@@ -1061,14 +1059,14 @@
/// Initialize a newly created block of code.
BlockImpl(this.leftBracket, List<Statement> statements, this.rightBracket) {
- _statements = new NodeListImpl<Statement>(this, statements);
+ _statements = NodeListImpl<Statement>(this, statements);
}
@override
Token get beginToken => leftBracket;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(leftBracket)
..addAll(_statements)
..add(rightBracket);
@@ -1108,8 +1106,7 @@
Token get beginToken => literal;
@override
- Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(literal);
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()..add(literal);
@override
Token get endToken => literal;
@@ -1164,7 +1161,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(breakKeyword)..add(_label)..add(semicolon);
+ ChildEntities()..add(breakKeyword)..add(_label)..add(semicolon);
@override
Token get endToken => semicolon;
@@ -1173,7 +1170,7 @@
SimpleIdentifier get label => _label;
@override
- void set label(SimpleIdentifier identifier) {
+ set label(SimpleIdentifier identifier) {
_label = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -1213,7 +1210,7 @@
CascadeExpressionImpl(
ExpressionImpl target, List<Expression> cascadeSections) {
_target = _becomeParentOf(target);
- _cascadeSections = new NodeListImpl<Expression>(this, cascadeSections);
+ _cascadeSections = NodeListImpl<Expression>(this, cascadeSections);
}
@override
@@ -1223,7 +1220,7 @@
NodeList<Expression> get cascadeSections => _cascadeSections;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_target)
..addAll(_cascadeSections);
@@ -1237,7 +1234,7 @@
Expression get target => _target;
@override
- void set target(Expression target) {
+ set target(Expression target) {
_target = _becomeParentOf(target as ExpressionImpl);
}
@@ -1330,12 +1327,12 @@
Block get body => _body;
@override
- void set body(Block block) {
+ set body(Block block) {
_body = _becomeParentOf(block as BlockImpl);
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(onKeyword)
..add(_exceptionType)
..add(catchKeyword)
@@ -1353,7 +1350,7 @@
SimpleIdentifier get exceptionParameter => _exceptionParameter;
@override
- void set exceptionParameter(SimpleIdentifier parameter) {
+ set exceptionParameter(SimpleIdentifier parameter) {
_exceptionParameter = _becomeParentOf(parameter as SimpleIdentifierImpl);
}
@@ -1361,7 +1358,7 @@
TypeAnnotation get exceptionType => _exceptionType;
@override
- void set exceptionType(TypeAnnotation exceptionType) {
+ set exceptionType(TypeAnnotation exceptionType) {
_exceptionType = _becomeParentOf(exceptionType as TypeAnnotationImpl);
}
@@ -1369,7 +1366,7 @@
SimpleIdentifier get stackTraceParameter => _stackTraceParameter;
@override
- void set stackTraceParameter(SimpleIdentifier parameter) {
+ set stackTraceParameter(SimpleIdentifier parameter) {
_stackTraceParameter = _becomeParentOf(parameter as SimpleIdentifierImpl);
}
@@ -1487,7 +1484,7 @@
ExtendsClause get extendsClause => _extendsClause;
@override
- void set extendsClause(ExtendsClause extendsClause) {
+ set extendsClause(ExtendsClause extendsClause) {
_extendsClause = _becomeParentOf(extendsClause as ExtendsClauseImpl);
}
@@ -1506,7 +1503,7 @@
NativeClause get nativeClause => _nativeClause;
@override
- void set nativeClause(NativeClause nativeClause) {
+ set nativeClause(NativeClause nativeClause) {
_nativeClause = _becomeParentOf(nativeClause as NativeClauseImpl);
}
@@ -1514,7 +1511,7 @@
WithClause get withClause => _withClause;
@override
- void set withClause(WithClause withClause) {
+ set withClause(WithClause withClause) {
_withClause = _becomeParentOf(withClause as WithClauseImpl);
}
@@ -1593,14 +1590,14 @@
: super(comment, metadata, name) {
_typeParameters = _becomeParentOf(typeParameters);
_implementsClause = _becomeParentOf(implementsClause);
- _members = new NodeListImpl<ClassMember>(this, members);
+ _members = NodeListImpl<ClassMember>(this, members);
}
Token get endToken => rightBracket;
ImplementsClause get implementsClause => _implementsClause;
- void set implementsClause(ImplementsClause implementsClause) {
+ set implementsClause(ImplementsClause implementsClause) {
_implementsClause =
_becomeParentOf(implementsClause as ImplementsClauseImpl);
}
@@ -1609,7 +1606,7 @@
TypeParameterList get typeParameters => _typeParameters;
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -1734,7 +1731,7 @@
ImplementsClause get implementsClause => _implementsClause;
@override
- void set implementsClause(ImplementsClause implementsClause) {
+ set implementsClause(ImplementsClause implementsClause) {
_implementsClause =
_becomeParentOf(implementsClause as ImplementsClauseImpl);
}
@@ -1746,7 +1743,7 @@
TypeName get superclass => _superclass;
@override
- void set superclass(TypeName superclass) {
+ set superclass(TypeName superclass) {
_superclass = _becomeParentOf(superclass as TypeNameImpl);
}
@@ -1754,7 +1751,7 @@
TypeParameterList get typeParameters => _typeParameters;
@override
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -1762,7 +1759,7 @@
WithClause get withClause => _withClause;
@override
- void set withClause(WithClause withClause) {
+ set withClause(WithClause withClause) {
_withClause = _becomeParentOf(withClause as WithClauseImpl);
}
@@ -1835,7 +1832,7 @@
/// [references] can be empty if the comment does not contain any embedded
/// references.
CommentImpl(this.tokens, this._type, List<CommentReference> references) {
- _references = new NodeListImpl<CommentReference>(this, references);
+ _references = NodeListImpl<CommentReference>(this, references);
}
@override
@@ -1843,7 +1840,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..addAll(tokens);
+ ChildEntities()..addAll(tokens);
@override
Token get endToken => tokens[tokens.length - 1];
@@ -1870,22 +1867,21 @@
/// Create a block comment consisting of the given [tokens].
static Comment createBlockComment(List<Token> tokens) =>
- new CommentImpl(tokens, CommentType.BLOCK, null);
+ CommentImpl(tokens, CommentType.BLOCK, null);
/// Create a documentation comment consisting of the given [tokens].
static Comment createDocumentationComment(List<Token> tokens) =>
- new CommentImpl(
- tokens, CommentType.DOCUMENTATION, new List<CommentReference>());
+ CommentImpl(tokens, CommentType.DOCUMENTATION, List<CommentReference>());
/// Create a documentation comment consisting of the given [tokens] and having
/// the given [references] embedded within it.
static Comment createDocumentationCommentWithReferences(
List<Token> tokens, List<CommentReference> references) =>
- new CommentImpl(tokens, CommentType.DOCUMENTATION, references);
+ CommentImpl(tokens, CommentType.DOCUMENTATION, references);
/// Create an end-of-line comment consisting of the given [tokens].
static Comment createEndOfLineComment(List<Token> tokens) =>
- new CommentImpl(tokens, CommentType.END_OF_LINE, null);
+ CommentImpl(tokens, CommentType.END_OF_LINE, null);
}
/// A reference to a Dart element that is found within a documentation comment.
@@ -1912,7 +1908,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(newKeyword)..add(_identifier);
+ ChildEntities()..add(newKeyword)..add(_identifier);
@override
Token get endToken => _identifier.endToken;
@@ -1921,7 +1917,7 @@
Identifier get identifier => _identifier;
@override
- void set identifier(Identifier identifier) {
+ set identifier(Identifier identifier) {
_identifier = _becomeParentOf(identifier as IdentifierImpl);
}
@@ -2022,13 +2018,13 @@
this.endToken,
this.featureSet) {
_scriptTag = _becomeParentOf(scriptTag);
- _directives = new NodeListImpl<Directive>(this, directives);
- _declarations = new NodeListImpl<CompilationUnitMember>(this, declarations);
+ _directives = NodeListImpl<Directive>(this, directives);
+ _declarations = NodeListImpl<CompilationUnitMember>(this, declarations);
}
@override
Iterable<SyntacticEntity> get childEntities {
- ChildEntities result = new ChildEntities()..add(_scriptTag);
+ ChildEntities result = ChildEntities()..add(_scriptTag);
if (_directivesAreBeforeDeclarations) {
result..addAll(_directives)..addAll(_declarations);
} else {
@@ -2064,7 +2060,7 @@
ScriptTag get scriptTag => _scriptTag;
@override
- void set scriptTag(ScriptTag scriptTag) {
+ set scriptTag(ScriptTag scriptTag) {
_scriptTag = _becomeParentOf(scriptTag as ScriptTagImpl);
}
@@ -2166,7 +2162,7 @@
Token get beginToken => _condition.beginToken;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_condition)
..add(question)
..add(_thenExpression)
@@ -2177,7 +2173,7 @@
Expression get condition => _condition;
@override
- void set condition(Expression expression) {
+ set condition(Expression expression) {
_condition = _becomeParentOf(expression as ExpressionImpl);
}
@@ -2185,7 +2181,7 @@
Expression get elseExpression => _elseExpression;
@override
- void set elseExpression(Expression expression) {
+ set elseExpression(Expression expression) {
_elseExpression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -2199,7 +2195,7 @@
Expression get thenExpression => _thenExpression;
@override
- void set thenExpression(Expression expression) {
+ set thenExpression(Expression expression) {
_thenExpression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -2264,7 +2260,7 @@
Token get beginToken => ifKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(ifKeyword)
..add(leftParenthesis)
..add(_name)
@@ -2282,7 +2278,7 @@
@deprecated
@override
- void set libraryUri(StringLiteral libraryUri) {
+ set libraryUri(StringLiteral libraryUri) {
_uri = _becomeParentOf(libraryUri as StringLiteralImpl);
}
@@ -2290,7 +2286,7 @@
DottedName get name => _name;
@override
- void set name(DottedName name) {
+ set name(DottedName name) {
_name = _becomeParentOf(name as DottedNameImpl);
}
@@ -2298,7 +2294,7 @@
StringLiteral get uri => _uri;
@override
- void set uri(StringLiteral uri) {
+ set uri(StringLiteral uri) {
_uri = _becomeParentOf(uri as StringLiteralImpl);
}
@@ -2306,7 +2302,7 @@
StringLiteral get value => _value;
@override
- void set value(StringLiteral value) {
+ set value(StringLiteral value) {
_value = _becomeParentOf(value as StringLiteralImpl);
}
@@ -2464,8 +2460,7 @@
_returnType = _becomeParentOf(returnType);
_name = _becomeParentOf(name);
_parameters = _becomeParentOf(parameters);
- _initializers =
- new NodeListImpl<ConstructorInitializer>(this, initializers);
+ _initializers = NodeListImpl<ConstructorInitializer>(this, initializers);
_redirectedConstructor = _becomeParentOf(redirectedConstructor);
_body = _becomeParentOf(body);
}
@@ -2474,7 +2469,7 @@
FunctionBody get body => _body;
@override
- void set body(FunctionBody functionBody) {
+ set body(FunctionBody functionBody) {
_body = _becomeParentOf(functionBody as FunctionBodyImpl);
}
@@ -2525,7 +2520,7 @@
SimpleIdentifier get name => _name;
@override
- void set name(SimpleIdentifier identifier) {
+ set name(SimpleIdentifier identifier) {
_name = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -2533,7 +2528,7 @@
FormalParameterList get parameters => _parameters;
@override
- void set parameters(FormalParameterList parameters) {
+ set parameters(FormalParameterList parameters) {
_parameters = _becomeParentOf(parameters as FormalParameterListImpl);
}
@@ -2541,7 +2536,7 @@
ConstructorName get redirectedConstructor => _redirectedConstructor;
@override
- void set redirectedConstructor(ConstructorName redirectedConstructor) {
+ set redirectedConstructor(ConstructorName redirectedConstructor) {
_redirectedConstructor =
_becomeParentOf(redirectedConstructor as ConstructorNameImpl);
}
@@ -2550,7 +2545,7 @@
Identifier get returnType => _returnType;
@override
- void set returnType(Identifier typeName) {
+ set returnType(Identifier typeName) {
_returnType = _becomeParentOf(typeName as IdentifierImpl);
}
@@ -2613,7 +2608,7 @@
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(thisKeyword)
..add(period)
..add(_fieldName)
@@ -2627,7 +2622,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -2635,7 +2630,7 @@
SimpleIdentifier get fieldName => _fieldName;
@override
- void set fieldName(SimpleIdentifier identifier) {
+ set fieldName(SimpleIdentifier identifier) {
_fieldName = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -2695,7 +2690,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_type)..add(period)..add(_name);
+ ChildEntities()..add(_type)..add(period)..add(_name);
@override
Token get endToken {
@@ -2709,7 +2704,7 @@
SimpleIdentifier get name => _name;
@override
- void set name(SimpleIdentifier name) {
+ set name(SimpleIdentifier name) {
_name = _becomeParentOf(name as SimpleIdentifierImpl);
}
@@ -2717,7 +2712,7 @@
TypeName get type => _type;
@override
- void set type(TypeName type) {
+ set type(TypeName type) {
_type = _becomeParentOf(type as TypeNameImpl);
}
@@ -2767,7 +2762,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(continueKeyword)..add(_label)..add(semicolon);
+ ChildEntities()..add(continueKeyword)..add(_label)..add(semicolon);
@override
Token get endToken => semicolon;
@@ -2776,7 +2771,7 @@
SimpleIdentifier get label => _label;
@override
- void set label(SimpleIdentifier identifier) {
+ set label(SimpleIdentifier identifier) {
_label = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -2858,7 +2853,7 @@
SimpleIdentifier get identifier => _identifier;
@override
- void set identifier(SimpleIdentifier identifier) {
+ set identifier(SimpleIdentifier identifier) {
_identifier = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -2872,7 +2867,7 @@
TypeAnnotation get type => _type;
@override
- void set type(TypeAnnotation type) {
+ set type(TypeAnnotation type) {
_type = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -2943,7 +2938,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_parameter)..add(separator)..add(_defaultValue);
+ ChildEntities()..add(_parameter)..add(separator)..add(_defaultValue);
@override
Token get covariantKeyword => null;
@@ -2955,7 +2950,7 @@
Expression get defaultValue => _defaultValue;
@override
- void set defaultValue(Expression expression) {
+ set defaultValue(Expression expression) {
_defaultValue = _becomeParentOf(expression as ExpressionImpl);
}
@@ -2983,7 +2978,7 @@
NormalFormalParameter get parameter => _parameter;
@override
- void set parameter(NormalFormalParameter formalParameter) {
+ set parameter(NormalFormalParameter formalParameter) {
_parameter = _becomeParentOf(formalParameter as NormalFormalParameterImpl);
}
@@ -3024,7 +3019,7 @@
Element get element => _element;
/// Set the element associated with this directive to be the given [element].
- void set element(Element element) {
+ set element(Element element) {
_element = element;
}
}
@@ -3079,12 +3074,12 @@
Statement get body => _body;
@override
- void set body(Statement statement) {
+ set body(Statement statement) {
_body = _becomeParentOf(statement as StatementImpl);
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(doKeyword)
..add(_body)
..add(whileKeyword)
@@ -3097,7 +3092,7 @@
Expression get condition => _condition;
@override
- void set condition(Expression expression) {
+ set condition(Expression expression) {
_condition = _becomeParentOf(expression as ExpressionImpl);
}
@@ -3124,7 +3119,7 @@
/// Initialize a newly created dotted name.
DottedNameImpl(List<SimpleIdentifier> components) {
- _components = new NodeListImpl<SimpleIdentifier>(this, components);
+ _components = NodeListImpl<SimpleIdentifier>(this, components);
}
@override
@@ -3133,7 +3128,7 @@
@override
// TODO(paulberry): add "." tokens.
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..addAll(_components);
+ ChildEntities()..addAll(_components);
@override
NodeList<SimpleIdentifier> get components => _components;
@@ -3174,8 +3169,7 @@
Token get beginToken => literal;
@override
- Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(literal);
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()..add(literal);
@override
Token get endToken => literal;
@@ -3209,7 +3203,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(semicolon);
+ ChildEntities()..add(semicolon);
@override
Token get endToken => semicolon;
@@ -3239,7 +3233,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(semicolon);
+ ChildEntities()..add(semicolon);
@override
Token get endToken => semicolon;
@@ -3289,7 +3283,7 @@
SimpleIdentifier get name => _name;
@override
- void set name(SimpleIdentifier name) {
+ set name(SimpleIdentifier name) {
_name = _becomeParentOf(name as SimpleIdentifierImpl);
}
@@ -3339,7 +3333,7 @@
List<EnumConstantDeclaration> constants,
this.rightBracket)
: super(comment, metadata, name) {
- _constants = new NodeListImpl<EnumConstantDeclaration>(this, constants);
+ _constants = NodeListImpl<EnumConstantDeclaration>(this, constants);
}
@override
@@ -3378,7 +3372,7 @@
/// empty identifier.
class EphemeralIdentifier extends SimpleIdentifierImpl {
EphemeralIdentifier(AstNode parent, int location)
- : super(new StringToken(TokenType.IDENTIFIER, "", location)) {
+ : super(StringToken(TokenType.IDENTIFIER, "", location)) {
(parent as AstNodeImpl)._becomeParentOf(this);
}
}
@@ -3472,7 +3466,7 @@
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(keyword)
..add(functionDefinition)
..add(_expression)
@@ -3490,7 +3484,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -3637,7 +3631,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_expression)..add(semicolon);
+ ChildEntities()..add(_expression)..add(semicolon);
@override
Token get endToken {
@@ -3651,7 +3645,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -3689,7 +3683,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(extendsKeyword)..add(_superclass);
+ ChildEntities()..add(extendsKeyword)..add(_superclass);
@override
Token get endToken => _superclass.endToken;
@@ -3698,7 +3692,7 @@
TypeName get superclass => _superclass;
@override
- void set superclass(TypeName name) {
+ set superclass(TypeName name) {
_superclass = _becomeParentOf(name as TypeNameImpl);
}
@@ -3763,11 +3757,11 @@
_name = _becomeParentOf(name);
_typeParameters = _becomeParentOf(typeParameters);
_extendedType = _becomeParentOf(extendedType);
- _members = new NodeListImpl<ClassMember>(this, members);
+ _members = NodeListImpl<ClassMember>(this, members);
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(extensionKeyword)
..add(name)
..add(typeParameters)
@@ -3791,7 +3785,7 @@
@override
TypeAnnotation get extendedType => _extendedType;
- void set extendedType(TypeAnnotation extendedClass) {
+ set extendedType(TypeAnnotation extendedClass) {
_extendedType = _becomeParentOf(extendedClass as TypeAnnotationImpl);
}
@@ -3804,14 +3798,14 @@
@override
SimpleIdentifier get name => _name;
- void set name(SimpleIdentifier identifier) {
+ set name(SimpleIdentifier identifier) {
_name = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@override
TypeParameterList get typeParameters => _typeParameters;
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -3862,7 +3856,7 @@
@override
ArgumentList get argumentList => _argumentList;
- void set argumentList(ArgumentList argumentList) {
+ set argumentList(ArgumentList argumentList) {
_argumentList = _becomeParentOf(argumentList as ArgumentListImpl);
}
@@ -3870,7 +3864,7 @@
Token get beginToken => _extensionName?.beginToken;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_extensionName)
..add(_typeArguments)
..add(_argumentList);
@@ -3881,7 +3875,7 @@
@override
Identifier get extensionName => _extensionName;
- void set extensionName(Identifier extensionName) {
+ set extensionName(Identifier extensionName) {
_extensionName = _becomeParentOf(extensionName as IdentifierImpl);
}
@@ -3894,7 +3888,7 @@
@override
TypeArgumentList get typeArguments => _typeArguments;
- void set typeArguments(TypeArgumentList typeArguments) {
+ set typeArguments(TypeArgumentList typeArguments) {
_typeArguments = _becomeParentOf(typeArguments as TypeArgumentListImpl);
}
@@ -3961,7 +3955,7 @@
VariableDeclarationList get fields => _fieldList;
@override
- void set fields(VariableDeclarationList fields) {
+ set fields(VariableDeclarationList fields) {
_fieldList = _becomeParentOf(fields as VariableDeclarationListImpl);
}
@@ -4093,7 +4087,7 @@
FormalParameterList get parameters => _parameters;
@override
- void set parameters(FormalParameterList parameters) {
+ set parameters(FormalParameterList parameters) {
_parameters = _becomeParentOf(parameters as FormalParameterListImpl);
}
@@ -4101,7 +4095,7 @@
TypeAnnotation get type => _type;
@override
- void set type(TypeAnnotation type) {
+ set type(TypeAnnotation type) {
_type = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -4109,7 +4103,7 @@
TypeParameterList get typeParameters => _typeParameters;
@override
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -4146,7 +4140,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(inKeyword)..add(_iterable);
+ ChildEntities()..add(inKeyword)..add(_iterable);
@override
Token get endToken => _iterable.endToken;
@@ -4154,7 +4148,7 @@
@override
Expression get iterable => _iterable;
- void set iterable(Expression expression) {
+ set iterable(Expression expression) {
_iterable = _becomeParentOf(expression as ExpressionImpl);
}
@@ -4181,14 +4175,14 @@
Token get beginToken => _loopVariable.beginToken;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_loopVariable)
..addAll(super.childEntities);
@override
DeclaredIdentifier get loopVariable => _loopVariable;
- void set loopVariable(DeclaredIdentifier variable) {
+ set loopVariable(DeclaredIdentifier variable) {
_loopVariable = _becomeParentOf(variable as DeclaredIdentifierImpl);
}
@@ -4220,14 +4214,14 @@
Token get beginToken => _identifier.beginToken;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_identifier)
..addAll(super.childEntities);
@override
SimpleIdentifier get identifier => _identifier;
- void set identifier(SimpleIdentifier identifier) {
+ set identifier(SimpleIdentifier identifier) {
_identifier = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -4267,12 +4261,12 @@
@override
CollectionElement get body => _body;
- void set body(CollectionElement statement) {
+ set body(CollectionElement statement) {
_body = _becomeParentOf(statement as CollectionElementImpl);
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..addAll(super.childEntities)
..add(_body);
@@ -4398,7 +4392,7 @@
this.leftDelimiter,
this.rightDelimiter,
this.rightParenthesis) {
- _parameters = new NodeListImpl<FormalParameter>(this, parameters);
+ _parameters = NodeListImpl<FormalParameter>(this, parameters);
}
@override
@@ -4407,7 +4401,7 @@
@override
Iterable<SyntacticEntity> get childEntities {
// TODO(paulberry): include commas.
- ChildEntities result = new ChildEntities()..add(leftParenthesis);
+ ChildEntities result = ChildEntities()..add(leftParenthesis);
bool leftDelimiterNeeded = leftDelimiter != null;
int length = _parameters.length;
for (int i = 0; i < length; i++) {
@@ -4427,7 +4421,7 @@
@override
List<ParameterElement> get parameterElements {
int count = _parameters.length;
- List<ParameterElement> types = new List<ParameterElement>(count);
+ List<ParameterElement> types = List<ParameterElement>(count);
for (int i = 0; i < count; i++) {
types[i] = _parameters[i].declaredElement;
}
@@ -4461,7 +4455,7 @@
Token get beginToken => awaitKeyword ?? forKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(awaitKeyword)
..add(forKeyword)
..add(leftParenthesis)
@@ -4470,7 +4464,7 @@
ForLoopParts get forLoopParts => _forLoopParts;
- void set forLoopParts(ForLoopParts forLoopParts) {
+ set forLoopParts(ForLoopParts forLoopParts) {
_forLoopParts = _becomeParentOf(forLoopParts as ForLoopPartsImpl);
}
}
@@ -4496,14 +4490,14 @@
ForPartsImpl(this.leftSeparator, ExpressionImpl condition,
this.rightSeparator, List<Expression> updaters) {
_condition = _becomeParentOf(condition);
- _updaters = new NodeListImpl<Expression>(this, updaters);
+ _updaters = NodeListImpl<Expression>(this, updaters);
}
@override
Token get beginToken => leftSeparator;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(leftSeparator)
..add(_condition)
..add(rightSeparator)
@@ -4512,7 +4506,7 @@
@override
Expression get condition => _condition;
- void set condition(Expression expression) {
+ set condition(Expression expression) {
_condition = _becomeParentOf(expression as ExpressionImpl);
}
@@ -4553,14 +4547,14 @@
Token get beginToken => _variableList?.beginToken ?? super.beginToken;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_variableList)
..addAll(super.childEntities);
@override
VariableDeclarationList get variables => _variableList;
- void set variables(VariableDeclarationList variableList) {
+ set variables(VariableDeclarationList variableList) {
_variableList =
_becomeParentOf(variableList as VariableDeclarationListImpl);
}
@@ -4596,14 +4590,14 @@
Token get beginToken => initialization?.beginToken ?? super.beginToken;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_initialization)
..addAll(super.childEntities);
@override
Expression get initialization => _initialization;
- void set initialization(Expression initialization) {
+ set initialization(Expression initialization) {
_initialization = _becomeParentOf(initialization as ExpressionImpl);
}
@@ -4644,12 +4638,12 @@
Statement get body => _body;
- void set body(Statement statement) {
+ set body(Statement statement) {
_body = _becomeParentOf(statement as StatementImpl);
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..addAll(super.childEntities)
..add(_body);
@@ -4703,7 +4697,7 @@
@override
bool isPotentiallyMutatedInClosure(VariableElement variable) {
if (localVariableInfo == null) {
- throw new StateError('Resolution has not yet been performed');
+ throw StateError('Resolution has not yet been performed');
}
return localVariableInfo.potentiallyMutatedInClosure.contains(variable);
}
@@ -4711,7 +4705,7 @@
@override
bool isPotentiallyMutatedInScope(VariableElement variable) {
if (localVariableInfo == null) {
- throw new StateError('Resolution has not yet been performed');
+ throw StateError('Resolution has not yet been performed');
}
return localVariableInfo.potentiallyMutatedInScope.contains(variable);
}
@@ -4795,7 +4789,7 @@
FunctionExpression get functionExpression => _functionExpression;
@override
- void set functionExpression(FunctionExpression functionExpression) {
+ set functionExpression(FunctionExpression functionExpression) {
_functionExpression =
_becomeParentOf(functionExpression as FunctionExpressionImpl);
}
@@ -4810,7 +4804,7 @@
TypeAnnotation get returnType => _returnType;
@override
- void set returnType(TypeAnnotation type) {
+ set returnType(TypeAnnotation type) {
_returnType = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -4843,7 +4837,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_functionDeclaration);
+ ChildEntities()..add(_functionDeclaration);
@override
Token get endToken => _functionDeclaration.endToken;
@@ -4852,7 +4846,7 @@
FunctionDeclaration get functionDeclaration => _functionDeclaration;
@override
- void set functionDeclaration(FunctionDeclaration functionDeclaration) {
+ set functionDeclaration(FunctionDeclaration functionDeclaration) {
_functionDeclaration =
_becomeParentOf(functionDeclaration as FunctionDeclarationImpl);
}
@@ -4906,20 +4900,20 @@
}
// This should never be reached because external functions must be named,
// hence either the body or the name should be non-null.
- throw new StateError("Non-external functions must have a body");
+ throw StateError("Non-external functions must have a body");
}
@override
FunctionBody get body => _body;
@override
- void set body(FunctionBody functionBody) {
+ set body(FunctionBody functionBody) {
_body = _becomeParentOf(functionBody as FunctionBodyImpl);
}
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_parameters)..add(_body);
+ ChildEntities()..add(_parameters)..add(_body);
@deprecated
@override
@@ -4936,14 +4930,14 @@
}
// This should never be reached because external functions must be named,
// hence either the body or the name should be non-null.
- throw new StateError("Non-external functions must have a body");
+ throw StateError("Non-external functions must have a body");
}
@override
FormalParameterList get parameters => _parameters;
@override
- void set parameters(FormalParameterList parameters) {
+ set parameters(FormalParameterList parameters) {
_parameters = _becomeParentOf(parameters as FormalParameterListImpl);
}
@@ -4954,7 +4948,7 @@
TypeParameterList get typeParameters => _typeParameters;
@override
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -4999,7 +4993,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_function)..add(_argumentList);
+ ChildEntities()..add(_function)..add(_argumentList);
@override
Token get endToken => _argumentList.endToken;
@@ -5008,7 +5002,7 @@
Expression get function => _function;
@override
- void set function(Expression expression) {
+ set function(Expression expression) {
_function = _becomeParentOf(expression as ExpressionImpl);
}
@@ -5083,7 +5077,7 @@
FormalParameterList get parameters => _parameters;
@override
- void set parameters(FormalParameterList parameters) {
+ set parameters(FormalParameterList parameters) {
_parameters = _becomeParentOf(parameters as FormalParameterListImpl);
}
@@ -5091,7 +5085,7 @@
TypeAnnotation get returnType => _returnType;
@override
- void set returnType(TypeAnnotation type) {
+ set returnType(TypeAnnotation type) {
_returnType = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -5099,7 +5093,7 @@
TypeParameterList get typeParameters => _typeParameters;
@override
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -5182,7 +5176,7 @@
FormalParameterList get parameters => _parameters;
@override
- void set parameters(FormalParameterList parameters) {
+ set parameters(FormalParameterList parameters) {
_parameters = _becomeParentOf(parameters as FormalParameterListImpl);
}
@@ -5190,7 +5184,7 @@
TypeAnnotation get returnType => _returnType;
@override
- void set returnType(TypeAnnotation type) {
+ set returnType(TypeAnnotation type) {
_returnType = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -5198,7 +5192,7 @@
TypeParameterList get typeParameters => _typeParameters;
@override
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -5283,7 +5277,7 @@
Token get beginToken => _returnType?.beginToken ?? functionKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_returnType)
..add(functionKeyword)
..add(_typeParameters)
@@ -5297,7 +5291,7 @@
FormalParameterList get parameters => _parameters;
@override
- void set parameters(FormalParameterList parameters) {
+ set parameters(FormalParameterList parameters) {
_parameters = _becomeParentOf(parameters as FormalParameterListImpl);
}
@@ -5305,7 +5299,7 @@
TypeAnnotation get returnType => _returnType;
@override
- void set returnType(TypeAnnotation type) {
+ set returnType(TypeAnnotation type) {
_returnType = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -5315,7 +5309,7 @@
/// Set the type parameters for the function type to the given list of
/// [typeParameters].
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -5368,7 +5362,7 @@
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..addAll(metadata)
..add(typedefKeyword)
..add(name)
@@ -5383,7 +5377,7 @@
GenericFunctionType get functionType => _functionType;
@override
- void set functionType(GenericFunctionType functionType) {
+ set functionType(GenericFunctionType functionType) {
_functionType = _becomeParentOf(functionType as GenericFunctionTypeImpl);
}
@@ -5391,7 +5385,7 @@
TypeParameterList get typeParameters => _typeParameters;
@override
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -5421,11 +5415,11 @@
/// Initialize a newly created import show combinator.
HideCombinatorImpl(Token keyword, List<SimpleIdentifier> hiddenNames)
: super(keyword) {
- _hiddenNames = new NodeListImpl<SimpleIdentifier>(this, hiddenNames);
+ _hiddenNames = NodeListImpl<SimpleIdentifier>(this, hiddenNames);
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(keyword)
..addAll(_hiddenNames);
@@ -5483,7 +5477,7 @@
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..addAll(super.childEntities)
..add(_thenElement)
..add(elseKeyword)
@@ -5533,7 +5527,7 @@
Token get beginToken => ifKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(ifKeyword)
..add(leftParenthesis)
..add(_condition)
@@ -5541,7 +5535,7 @@
Expression get condition => _condition;
- void set condition(Expression expression) {
+ set condition(Expression expression) {
_condition = _becomeParentOf(expression as ExpressionImpl);
}
@@ -5588,7 +5582,7 @@
Token get beginToken => ifKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..addAll(super.childEntities)
..add(_thenStatement)
..add(elseKeyword)
@@ -5598,7 +5592,7 @@
Statement get elseStatement => _elseStatement;
@override
- void set elseStatement(Statement statement) {
+ set elseStatement(Statement statement) {
_elseStatement = _becomeParentOf(statement as StatementImpl);
}
@@ -5614,7 +5608,7 @@
Statement get thenStatement => _thenStatement;
@override
- void set thenStatement(Statement statement) {
+ set thenStatement(Statement statement) {
_thenStatement = _becomeParentOf(statement as StatementImpl);
}
@@ -5643,7 +5637,7 @@
/// Initialize a newly created implements clause.
ImplementsClauseImpl(this.implementsKeyword, List<TypeName> interfaces) {
- _interfaces = new NodeListImpl<TypeName>(this, interfaces);
+ _interfaces = NodeListImpl<TypeName>(this, interfaces);
}
@override
@@ -5651,7 +5645,7 @@
@override
// TODO(paulberry): add commas.
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(implementsKeyword)
..addAll(interfaces);
@@ -5731,7 +5725,7 @@
SimpleIdentifier get prefix => _prefix;
@override
- void set prefix(SimpleIdentifier identifier) {
+ set prefix(SimpleIdentifier identifier) {
_prefix = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -5815,7 +5809,7 @@
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_target)
..add(period)
..add(leftBracket)
@@ -5829,7 +5823,7 @@
Expression get index => _index;
@override
- void set index(Expression expression) {
+ set index(Expression expression) {
_index = _becomeParentOf(expression as ExpressionImpl);
}
@@ -5868,7 +5862,7 @@
Expression get target => _target;
@override
- void set target(Expression expression) {
+ set target(Expression expression) {
_target = _becomeParentOf(expression as ExpressionImpl);
}
@@ -5978,7 +5972,7 @@
ArgumentList get argumentList => _argumentList;
@override
- void set argumentList(ArgumentList argumentList) {
+ set argumentList(ArgumentList argumentList) {
_argumentList = _becomeParentOf(argumentList as ArgumentListImpl);
}
@@ -5986,7 +5980,7 @@
Token get beginToken => keyword ?? _constructorName.beginToken;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(keyword)
..add(_constructorName)
..add(_typeArguments)
@@ -5996,7 +5990,7 @@
ConstructorName get constructorName => _constructorName;
@override
- void set constructorName(ConstructorName name) {
+ set constructorName(ConstructorName name) {
_constructorName = _becomeParentOf(name as ConstructorNameImpl);
}
@@ -6028,7 +6022,7 @@
/// with the class in which the constructor is defined. It is always an error
/// if there are type arguments because Dart doesn't currently support generic
/// constructors, but we capture them in the AST in order to recover better.
- void set typeArguments(TypeArgumentList typeArguments) {
+ set typeArguments(TypeArgumentList typeArguments) {
_typeArguments = _becomeParentOf(typeArguments as TypeArgumentListImpl);
}
@@ -6072,8 +6066,7 @@
Token get beginToken => literal;
@override
- Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(literal);
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()..add(literal);
@override
Token get endToken => literal;
@@ -6191,10 +6184,8 @@
Token get beginToken => leftBracket;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
- ..add(leftBracket)
- ..add(_expression)
- ..add(rightBracket);
+ Iterable<SyntacticEntity> get childEntities =>
+ ChildEntities()..add(leftBracket)..add(_expression)..add(rightBracket);
@override
Token get endToken {
@@ -6208,7 +6199,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -6244,20 +6235,19 @@
Token get beginToken => contents;
@override
- Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(contents);
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()..add(contents);
@override
int get contentsEnd {
String lexeme = contents.lexeme;
- return offset + new StringLexemeHelper(lexeme, true, true).end;
+ return offset + StringLexemeHelper(lexeme, true, true).end;
}
@override
int get contentsOffset {
int offset = contents.offset;
String lexeme = contents.lexeme;
- return offset + new StringLexemeHelper(lexeme, true, true).start;
+ return offset + StringLexemeHelper(lexeme, true, true).start;
}
@override
@@ -6297,14 +6287,14 @@
@override
ArgumentList get argumentList => _argumentList;
- void set argumentList(ArgumentList argumentList) {
+ set argumentList(ArgumentList argumentList) {
_argumentList = _becomeParentOf(argumentList as ArgumentListImpl);
}
@override
TypeArgumentList get typeArguments => _typeArguments;
- void set typeArguments(TypeArgumentList typeArguments) {
+ set typeArguments(TypeArgumentList typeArguments) {
_typeArguments = _becomeParentOf(typeArguments as TypeArgumentListImpl);
}
}
@@ -6340,7 +6330,7 @@
Token get beginToken => _expression.beginToken;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_expression)
..add(isOperator)
..add(notOperator)
@@ -6353,7 +6343,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -6364,7 +6354,7 @@
TypeAnnotation get type => _type;
@override
- void set type(TypeAnnotation type) {
+ set type(TypeAnnotation type) {
_type = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -6391,7 +6381,7 @@
/// Initialize a newly created labeled statement.
LabeledStatementImpl(List<Label> labels, StatementImpl statement) {
- _labels = new NodeListImpl<Label>(this, labels);
+ _labels = NodeListImpl<Label>(this, labels);
_statement = _becomeParentOf(statement);
}
@@ -6404,7 +6394,7 @@
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..addAll(_labels)
..add(_statement);
@@ -6418,7 +6408,7 @@
Statement get statement => _statement;
@override
- void set statement(Statement statement) {
+ set statement(Statement statement) {
_statement = _becomeParentOf(statement as StatementImpl);
}
@@ -6457,7 +6447,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_label)..add(colon);
+ ChildEntities()..add(_label)..add(colon);
@override
Token get endToken => colon;
@@ -6466,7 +6456,7 @@
SimpleIdentifier get label => _label;
@override
- void set label(SimpleIdentifier label) {
+ set label(SimpleIdentifier label) {
_label = _becomeParentOf(label as SimpleIdentifierImpl);
}
@@ -6521,7 +6511,7 @@
LibraryIdentifier get name => _name;
@override
- void set name(LibraryIdentifier name) {
+ set name(LibraryIdentifier name) {
_name = _becomeParentOf(name as LibraryIdentifierImpl);
}
@@ -6546,7 +6536,7 @@
/// Initialize a newly created prefixed identifier.
LibraryIdentifierImpl(List<SimpleIdentifier> components) {
- _components = new NodeListImpl<SimpleIdentifier>(this, components);
+ _components = NodeListImpl<SimpleIdentifier>(this, components);
}
@override
@@ -6555,7 +6545,7 @@
@override
// TODO(paulberry): add "." tokens.
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..addAll(_components);
+ ChildEntities()..addAll(_components);
@override
NodeList<SimpleIdentifier> get components => _components;
@@ -6565,7 +6555,7 @@
@override
String get name {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
bool needsPeriod = false;
int length = _components.length;
for (int i = 0; i < length; i++) {
@@ -6614,7 +6604,7 @@
ListLiteralImpl(Token constKeyword, TypeArgumentListImpl typeArguments,
this.leftBracket, List<Expression> elements, this.rightBracket)
: super(constKeyword, typeArguments) {
- _elements = new NodeListImpl<Expression>(this, elements);
+ _elements = NodeListImpl<Expression>(this, elements);
}
/// Initialize a newly created list literal.
@@ -6629,7 +6619,7 @@
List<CollectionElement> elements,
this.rightBracket)
: super(constKeyword, typeArguments) {
- _elements = new NodeListImpl<CollectionElement>(this, elements);
+ _elements = NodeListImpl<CollectionElement>(this, elements);
}
@override
@@ -6689,12 +6679,11 @@
/// within a local function other than the function in which they are
/// declared.
final Set<VariableElement> potentiallyMutatedInClosure =
- new Set<VariableElement>();
+ Set<VariableElement>();
/// The set of local variables and parameters that are potentially mutated
/// within the scope of their declarations.
- final Set<VariableElement> potentiallyMutatedInScope =
- new Set<VariableElement>();
+ final Set<VariableElement> potentiallyMutatedInScope = Set<VariableElement>();
}
/// A single key/value pair in a map literal.
@@ -6725,7 +6714,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_key)..add(separator)..add(_value);
+ ChildEntities()..add(_key)..add(separator)..add(_value);
@override
Token get endToken => _value.endToken;
@@ -6734,7 +6723,7 @@
Expression get key => _key;
@override
- void set key(Expression string) {
+ set key(Expression string) {
_key = _becomeParentOf(string as ExpressionImpl);
}
@@ -6742,7 +6731,7 @@
Expression get value => _value;
@override
- void set value(Expression expression) {
+ set value(Expression expression) {
_value = _becomeParentOf(expression as ExpressionImpl);
}
@@ -6840,7 +6829,7 @@
FunctionBody get body => _body;
@override
- void set body(FunctionBody functionBody) {
+ set body(FunctionBody functionBody) {
_body = _becomeParentOf(functionBody as FunctionBodyImpl);
}
@@ -6906,7 +6895,7 @@
SimpleIdentifier get name => _name;
@override
- void set name(SimpleIdentifier identifier) {
+ set name(SimpleIdentifier identifier) {
_name = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -6914,7 +6903,7 @@
FormalParameterList get parameters => _parameters;
@override
- void set parameters(FormalParameterList parameters) {
+ set parameters(FormalParameterList parameters) {
_parameters = _becomeParentOf(parameters as FormalParameterListImpl);
}
@@ -6922,7 +6911,7 @@
TypeAnnotation get returnType => _returnType;
@override
- void set returnType(TypeAnnotation type) {
+ set returnType(TypeAnnotation type) {
_returnType = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -6930,7 +6919,7 @@
TypeParameterList get typeParameters => _typeParameters;
@override
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -7000,7 +6989,7 @@
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(_target)
..add(operator)
..add(_methodName)
@@ -7028,7 +7017,7 @@
SimpleIdentifier get methodName => _methodName;
@override
- void set methodName(SimpleIdentifier identifier) {
+ set methodName(SimpleIdentifier identifier) {
_methodName = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -7070,7 +7059,7 @@
Expression get target => _target;
@override
- void set target(Expression expression) {
+ set target(Expression expression) {
_target = _becomeParentOf(expression as ExpressionImpl);
}
@@ -7145,7 +7134,7 @@
@override
ImplementsClause get implementsClause => _implementsClause;
- void set implementsClause(ImplementsClause implementsClause) {
+ set implementsClause(ImplementsClause implementsClause) {
_implementsClause =
_becomeParentOf(implementsClause as ImplementsClauseImpl);
}
@@ -7156,14 +7145,14 @@
@override
OnClause get onClause => _onClause;
- void set onClause(OnClause onClause) {
+ set onClause(OnClause onClause) {
_onClause = _becomeParentOf(onClause as OnClauseImpl);
}
@override
TypeParameterList get typeParameters => _typeParameters;
- void set typeParameters(TypeParameterList typeParameters) {
+ set typeParameters(TypeParameterList typeParameters) {
_typeParameters = _becomeParentOf(typeParameters as TypeParameterListImpl);
}
@@ -7200,7 +7189,7 @@
SimpleIdentifier get name => _name;
@override
- void set name(SimpleIdentifier identifier) {
+ set name(SimpleIdentifier identifier) {
_name = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
}
@@ -7228,7 +7217,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_name)..add(_expression);
+ ChildEntities()..add(_name)..add(_expression);
@override
ParameterElement get element {
@@ -7246,7 +7235,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -7254,7 +7243,7 @@
Label get name => _name;
@override
- void set name(Label identifier) {
+ set name(Label identifier) {
_name = _becomeParentOf(identifier as LabelImpl);
}
@@ -7312,8 +7301,8 @@
List<Combinator> combinators,
this.semicolon)
: super(comment, metadata, libraryUri) {
- _configurations = new NodeListImpl<Configuration>(this, configurations);
- _combinators = new NodeListImpl<Combinator>(this, combinators);
+ _configurations = NodeListImpl<Configuration>(this, configurations);
+ _combinators = NodeListImpl<Combinator>(this, combinators);
}
@override
@@ -7334,7 +7323,7 @@
@deprecated
@override
- void set source(Source source) {
+ set source(Source source) {
selectedSource = source;
}
@@ -7364,7 +7353,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(nativeKeyword)..add(_name);
+ ChildEntities()..add(nativeKeyword)..add(_name);
@override
Token get endToken => _name.endToken;
@@ -7373,7 +7362,7 @@
StringLiteral get name => _name;
@override
- void set name(StringLiteral name) {
+ set name(StringLiteral name) {
_name = _becomeParentOf(name as StringLiteralImpl);
}
@@ -7416,10 +7405,8 @@
Token get beginToken => nativeKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
- ..add(nativeKeyword)
- ..add(_stringLiteral)
- ..add(semicolon);
+ Iterable<SyntacticEntity> get childEntities =>
+ ChildEntities()..add(nativeKeyword)..add(_stringLiteral)..add(semicolon);
@override
Token get endToken => semicolon;
@@ -7428,7 +7415,7 @@
StringLiteral get stringLiteral => _stringLiteral;
@override
- void set stringLiteral(StringLiteral stringLiteral) {
+ set stringLiteral(StringLiteral stringLiteral) {
_stringLiteral = _becomeParentOf(stringLiteral as StringLiteralImpl);
}
@@ -7477,28 +7464,28 @@
@deprecated // Never intended for public use.
@override
- void set length(int newLength) {
- throw new UnsupportedError("Cannot resize NodeList.");
+ set length(int newLength) {
+ throw UnsupportedError("Cannot resize NodeList.");
}
@override
AstNode get owner => _owner;
@override
- void set owner(AstNode value) {
+ set owner(AstNode value) {
_owner = value as AstNodeImpl;
}
E operator [](int index) {
if (index < 0 || index >= _elements.length) {
- throw new RangeError("Index: $index, Size: ${_elements.length}");
+ throw RangeError("Index: $index, Size: ${_elements.length}");
}
return _elements[index];
}
void operator []=(int index, E node) {
if (index < 0 || index >= _elements.length) {
- throw new RangeError("Index: $index, Size: ${_elements.length}");
+ throw RangeError("Index: $index, Size: ${_elements.length}");
}
_owner._becomeParentOf(node as AstNodeImpl);
_elements[index] = node;
@@ -7547,7 +7534,7 @@
void insert(int index, E node) {
int length = _elements.length;
if (index < 0 || index > length) {
- throw new RangeError("Index: $index, Size: ${_elements.length}");
+ throw RangeError("Index: $index, Size: ${_elements.length}");
}
_owner._becomeParentOf(node as AstNodeImpl);
if (length == 0) {
@@ -7560,7 +7547,7 @@
@override
E removeAt(int index) {
if (index < 0 || index >= _elements.length) {
- throw new RangeError("Index: $index, Size: ${_elements.length}");
+ throw RangeError("Index: $index, Size: ${_elements.length}");
}
E removedNode = _elements[index];
_elements.removeAt(index);
@@ -7615,7 +7602,7 @@
this.requiredKeyword,
SimpleIdentifierImpl identifier) {
_comment = _becomeParentOf(comment);
- _metadata = new NodeListImpl<Annotation>(this, metadata);
+ _metadata = NodeListImpl<Annotation>(this, metadata);
_identifier = _becomeParentOf(identifier);
}
@@ -7623,7 +7610,7 @@
Comment get documentationComment => _comment;
@override
- void set documentationComment(Comment comment) {
+ set documentationComment(Comment comment) {
_comment = _becomeParentOf(comment as CommentImpl);
}
@@ -7631,7 +7618,7 @@
SimpleIdentifier get identifier => _identifier;
@override
- void set identifier(SimpleIdentifier identifier) {
+ set identifier(SimpleIdentifier identifier) {
_identifier = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -7649,7 +7636,7 @@
NodeList<Annotation> get metadata => _metadata;
@override
- void set metadata(List<Annotation> metadata) {
+ set metadata(List<Annotation> metadata) {
_metadata.clear();
_metadata.addAll(metadata);
}
@@ -7663,7 +7650,7 @@
}
ChildEntities get _childEntities {
- ChildEntities result = new ChildEntities();
+ ChildEntities result = ChildEntities();
if (_commentIsBeforeAnnotations()) {
result
..add(_comment)
@@ -7720,8 +7707,7 @@
Token get beginToken => literal;
@override
- Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(literal);
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()..add(literal);
@override
Token get endToken => literal;
@@ -7776,7 +7762,7 @@
/// Initialize a newly created on clause.
OnClauseImpl(this.onKeyword, List<TypeName> superclassConstraints) {
_superclassConstraints =
- new NodeListImpl<TypeName>(this, superclassConstraints);
+ NodeListImpl<TypeName>(this, superclassConstraints);
}
@override
@@ -7784,7 +7770,7 @@
@override
// TODO(paulberry): add commas.
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(onKeyword)
..addAll(superclassConstraints);
@@ -7828,7 +7814,7 @@
Token get beginToken => leftParenthesis;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(leftParenthesis)
..add(_expression)
..add(rightParenthesis);
@@ -7840,7 +7826,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -7970,7 +7956,7 @@
LibraryIdentifier get libraryName => _libraryName;
@override
- void set libraryName(LibraryIdentifier libraryName) {
+ set libraryName(LibraryIdentifier libraryName) {
_libraryName = _becomeParentOf(libraryName as LibraryIdentifierImpl);
}
@@ -7978,7 +7964,7 @@
StringLiteral get uri => _uri;
@override
- void set uri(StringLiteral uri) {
+ set uri(StringLiteral uri) {
_uri = _becomeParentOf(uri as StringLiteralImpl);
}
@@ -8022,7 +8008,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_operand)..add(operator);
+ ChildEntities()..add(_operand)..add(operator);
@override
Token get endToken => operator;
@@ -8031,7 +8017,7 @@
Expression get operand => _operand;
@override
- void set operand(Expression expression) {
+ set operand(Expression expression) {
_operand = _becomeParentOf(expression as ExpressionImpl);
}
@@ -8095,7 +8081,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_prefix)..add(period)..add(_identifier);
+ ChildEntities()..add(_prefix)..add(period)..add(_identifier);
@override
Token get endToken => _identifier.endToken;
@@ -8104,7 +8090,7 @@
SimpleIdentifier get identifier => _identifier;
@override
- void set identifier(SimpleIdentifier identifier) {
+ set identifier(SimpleIdentifier identifier) {
_identifier = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -8132,7 +8118,7 @@
SimpleIdentifier get prefix => _prefix;
@override
- void set prefix(SimpleIdentifier identifier) {
+ set prefix(SimpleIdentifier identifier) {
_prefix = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -8180,7 +8166,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(operator)..add(_operand);
+ ChildEntities()..add(operator)..add(_operand);
@override
Token get endToken => _operand.endToken;
@@ -8189,7 +8175,7 @@
Expression get operand => _operand;
@override
- void set operand(Expression expression) {
+ set operand(Expression expression) {
_operand = _becomeParentOf(expression as ExpressionImpl);
}
@@ -8257,7 +8243,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_target)..add(operator)..add(_propertyName);
+ ChildEntities()..add(_target)..add(operator)..add(_propertyName);
@override
Token get endToken => _propertyName.endToken;
@@ -8284,7 +8270,7 @@
SimpleIdentifier get propertyName => _propertyName;
@override
- void set propertyName(SimpleIdentifier identifier) {
+ set propertyName(SimpleIdentifier identifier) {
_propertyName = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -8307,7 +8293,7 @@
Expression get target => _target;
@override
- void set target(Expression expression) {
+ set target(Expression expression) {
_target = _becomeParentOf(expression as ExpressionImpl);
}
@@ -8367,7 +8353,7 @@
ArgumentList get argumentList => _argumentList;
@override
- void set argumentList(ArgumentList argumentList) {
+ set argumentList(ArgumentList argumentList) {
_argumentList = _becomeParentOf(argumentList as ArgumentListImpl);
}
@@ -8375,7 +8361,7 @@
Token get beginToken => thisKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(thisKeyword)
..add(period)
..add(_constructorName)
@@ -8385,7 +8371,7 @@
SimpleIdentifier get constructorName => _constructorName;
@override
- void set constructorName(SimpleIdentifier identifier) {
+ set constructorName(SimpleIdentifier identifier) {
_constructorName = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -8420,7 +8406,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(rethrowKeyword);
+ ChildEntities()..add(rethrowKeyword);
@override
Token get endToken => rethrowKeyword;
@@ -8464,7 +8450,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(returnKeyword)..add(_expression)..add(semicolon);
+ ChildEntities()..add(returnKeyword)..add(_expression)..add(semicolon);
@override
Token get endToken => semicolon;
@@ -8473,7 +8459,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -8503,7 +8489,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(scriptTag);
+ ChildEntities()..add(scriptTag);
@override
Token get endToken => scriptTag;
@@ -8551,7 +8537,7 @@
SetOrMapLiteralImpl(Token constKeyword, TypeArgumentListImpl typeArguments,
this.leftBracket, List<CollectionElement> elements, this.rightBracket)
: super(constKeyword, typeArguments) {
- _elements = new NodeListImpl<CollectionElement>(this, elements);
+ _elements = NodeListImpl<CollectionElement>(this, elements);
_resolvedKind = _SetOrMapKind.unresolved;
}
@@ -8621,12 +8607,12 @@
/// Initialize a newly created import show combinator.
ShowCombinatorImpl(Token keyword, List<SimpleIdentifier> shownNames)
: super(keyword) {
- _shownNames = new NodeListImpl<SimpleIdentifier>(this, shownNames);
+ _shownNames = NodeListImpl<SimpleIdentifier>(this, shownNames);
}
@override
// TODO(paulberry): add commas.
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(keyword)
..addAll(_shownNames);
@@ -8714,7 +8700,7 @@
TypeAnnotation get type => _type;
@override
- void set type(TypeAnnotation type) {
+ set type(TypeAnnotation type) {
_type = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -8762,8 +8748,7 @@
Token get beginToken => token;
@override
- Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(token);
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()..add(token);
@override
Token get endToken => token;
@@ -8796,7 +8781,7 @@
Element get staticElement => _staticElement;
@override
- void set staticElement(Element element) {
+ set staticElement(Element element) {
_staticElement = element;
}
@@ -8936,8 +8921,7 @@
Token get beginToken => literal;
@override
- Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(literal);
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()..add(literal);
@override
int get contentsEnd => offset + _helper.end;
@@ -8964,12 +8948,12 @@
String get value => _value;
@override
- void set value(String string) {
+ set value(String string) {
_value = StringUtilities.intern(_value);
}
StringLexemeHelper get _helper {
- return new StringLexemeHelper(literal.lexeme, true, true);
+ return StringLexemeHelper(literal.lexeme, true, true);
}
@override
@@ -9009,7 +8993,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(spreadOperator)..add(_expression);
+ ChildEntities()..add(spreadOperator)..add(_expression);
@override
Token get endToken => _expression.endToken;
@@ -9070,7 +9054,7 @@
/// Initialize a newly created string interpolation expression.
StringInterpolationImpl(List<InterpolationElement> elements) {
- _elements = new NodeListImpl<InterpolationElement>(this, elements);
+ _elements = NodeListImpl<InterpolationElement>(this, elements);
}
@override
@@ -9078,7 +9062,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..addAll(_elements);
+ ChildEntities()..addAll(_elements);
@override
int get contentsEnd {
@@ -9110,7 +9094,7 @@
StringLexemeHelper get _firstHelper {
InterpolationString lastString = _elements.first;
String lexeme = lastString.contents.lexeme;
- return new StringLexemeHelper(lexeme, true, false);
+ return StringLexemeHelper(lexeme, true, false);
}
@override
@@ -9123,7 +9107,7 @@
@override
void _appendStringValue(StringBuffer buffer) {
- throw new ArgumentError();
+ throw ArgumentError();
}
}
@@ -9227,7 +9211,7 @@
abstract class StringLiteralImpl extends LiteralImpl implements StringLiteral {
@override
String get stringValue {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
try {
_appendStringValue(buffer);
} on ArgumentError {
@@ -9282,7 +9266,7 @@
ArgumentList get argumentList => _argumentList;
@override
- void set argumentList(ArgumentList argumentList) {
+ set argumentList(ArgumentList argumentList) {
_argumentList = _becomeParentOf(argumentList as ArgumentListImpl);
}
@@ -9290,7 +9274,7 @@
Token get beginToken => superKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(superKeyword)
..add(period)
..add(_constructorName)
@@ -9300,7 +9284,7 @@
SimpleIdentifier get constructorName => _constructorName;
@override
- void set constructorName(SimpleIdentifier identifier) {
+ set constructorName(SimpleIdentifier identifier) {
_constructorName = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -9334,7 +9318,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(superKeyword);
+ ChildEntities()..add(superKeyword);
@override
Token get endToken => superKeyword;
@@ -9368,7 +9352,7 @@
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..addAll(labels)
..add(keyword)
..add(_expression)
@@ -9379,7 +9363,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -9406,7 +9390,7 @@
: super(labels, keyword, colon, statements);
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..addAll(labels)
..add(keyword)
..add(colon)
@@ -9444,8 +9428,8 @@
/// `null` if there are no labels.
SwitchMemberImpl(List<Label> labels, this.keyword, this.colon,
List<Statement> statements) {
- _labels = new NodeListImpl<Label>(this, labels);
- _statements = new NodeListImpl<Statement>(this, statements);
+ _labels = NodeListImpl<Label>(this, labels);
+ _statements = NodeListImpl<Statement>(this, statements);
}
@override
@@ -9509,14 +9493,14 @@
List<SwitchMember> members,
this.rightBracket) {
_expression = _becomeParentOf(expression);
- _members = new NodeListImpl<SwitchMember>(this, members);
+ _members = NodeListImpl<SwitchMember>(this, members);
}
@override
Token get beginToken => switchKeyword;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(switchKeyword)
..add(leftParenthesis)
..add(_expression)
@@ -9532,7 +9516,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -9568,7 +9552,7 @@
@override
// TODO(paulberry): add "." tokens.
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(poundSign)
..addAll(components);
@@ -9600,7 +9584,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(thisKeyword);
+ ChildEntities()..add(thisKeyword);
@override
Token get endToken => thisKeyword;
@@ -9638,7 +9622,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(throwKeyword)..add(_expression);
+ ChildEntities()..add(throwKeyword)..add(_expression);
@override
Token get endToken {
@@ -9652,7 +9636,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
@@ -9710,7 +9694,7 @@
VariableDeclarationList get variables => _variableList;
@override
- void set variables(VariableDeclarationList variables) {
+ set variables(VariableDeclarationList variables) {
_variableList = _becomeParentOf(variables as VariableDeclarationListImpl);
}
@@ -9760,7 +9744,7 @@
this.finallyKeyword,
BlockImpl finallyBlock) {
_body = _becomeParentOf(body);
- _catchClauses = new NodeListImpl<CatchClause>(this, catchClauses);
+ _catchClauses = NodeListImpl<CatchClause>(this, catchClauses);
_finallyBlock = _becomeParentOf(finallyBlock);
}
@@ -9771,7 +9755,7 @@
Block get body => _body;
@override
- void set body(Block block) {
+ set body(Block block) {
_body = _becomeParentOf(block as BlockImpl);
}
@@ -9779,7 +9763,7 @@
NodeList<CatchClause> get catchClauses => _catchClauses;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(tryKeyword)
..add(_body)
..addAll(_catchClauses)
@@ -9802,7 +9786,7 @@
Block get finallyBlock => _finallyBlock;
@override
- void set finallyBlock(Block block) {
+ set finallyBlock(Block block) {
_finallyBlock = _becomeParentOf(block as BlockImpl);
}
@@ -9872,7 +9856,7 @@
/// Initialize a newly created list of type arguments.
TypeArgumentListImpl(
this.leftBracket, List<TypeAnnotation> arguments, this.rightBracket) {
- _arguments = new NodeListImpl<TypeAnnotation>(this, arguments);
+ _arguments = NodeListImpl<TypeAnnotation>(this, arguments);
}
@override
@@ -9883,7 +9867,7 @@
@override
// TODO(paulberry): Add commas.
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(leftBracket)
..addAll(_arguments)
..add(rightBracket);
@@ -9930,12 +9914,12 @@
TypeArgumentList get typeArguments => _typeArguments;
@override
- void set typeArguments(TypeArgumentList typeArguments) {
+ set typeArguments(TypeArgumentList typeArguments) {
_typeArguments = _becomeParentOf(typeArguments as TypeArgumentListImpl);
}
ChildEntities get _childEntities =>
- new ChildEntities()..add(constKeyword)..add(_typeArguments);
+ ChildEntities()..add(constKeyword)..add(_typeArguments);
@override
void visitChildren(AstVisitor visitor) {
@@ -9975,7 +9959,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_name)..add(_typeArguments)..add(question);
+ ChildEntities()..add(_name)..add(_typeArguments)..add(question);
@override
Token get endToken => question ?? _typeArguments?.endToken ?? _name.endToken;
@@ -9996,7 +9980,7 @@
Identifier get name => _name;
@override
- void set name(Identifier identifier) {
+ set name(Identifier identifier) {
_name = _becomeParentOf(identifier as IdentifierImpl);
}
@@ -10004,7 +9988,7 @@
TypeArgumentList get typeArguments => _typeArguments;
@override
- void set typeArguments(TypeArgumentList typeArguments) {
+ set typeArguments(TypeArgumentList typeArguments) {
_typeArguments = _becomeParentOf(typeArguments as TypeArgumentListImpl);
}
@@ -10055,7 +10039,7 @@
TypeAnnotation get bound => _bound;
@override
- void set bound(TypeAnnotation type) {
+ set bound(TypeAnnotation type) {
_bound = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -10082,7 +10066,7 @@
SimpleIdentifier get name => _name;
@override
- void set name(SimpleIdentifier identifier) {
+ set name(SimpleIdentifier identifier) {
_name = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -10114,14 +10098,14 @@
/// Initialize a newly created list of type parameters.
TypeParameterListImpl(
this.leftBracket, List<TypeParameter> typeParameters, this.rightBracket) {
- _typeParameters = new NodeListImpl<TypeParameter>(this, typeParameters);
+ _typeParameters = NodeListImpl<TypeParameter>(this, typeParameters);
}
@override
Token get beginToken => leftBracket;
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(leftBracket)
..addAll(_typeParameters)
..add(rightBracket);
@@ -10177,7 +10161,7 @@
@deprecated
@override
- void set source(Source source) {
+ set source(Source source) {
uriSource = source;
}
@@ -10185,7 +10169,7 @@
StringLiteral get uri => _uri;
@override
- void set uri(StringLiteral uri) {
+ set uri(StringLiteral uri) {
_uri = _becomeParentOf(uri as StringLiteralImpl);
}
@@ -10316,7 +10300,7 @@
Expression get initializer => _initializer;
@override
- void set initializer(Expression expression) {
+ set initializer(Expression expression) {
_initializer = _becomeParentOf(expression as ExpressionImpl);
}
@@ -10342,7 +10326,7 @@
SimpleIdentifier get name => _name;
@override
- void set name(SimpleIdentifier identifier) {
+ set name(SimpleIdentifier identifier) {
_name = _becomeParentOf(identifier as SimpleIdentifierImpl);
}
@@ -10398,7 +10382,7 @@
List<VariableDeclaration> variables)
: super(comment, metadata) {
_type = _becomeParentOf(type);
- _variables = new NodeListImpl<VariableDeclaration>(this, variables);
+ _variables = NodeListImpl<VariableDeclaration>(this, variables);
}
@override
@@ -10434,7 +10418,7 @@
TypeAnnotation get type => _type;
@override
- void set type(TypeAnnotation type) {
+ set type(TypeAnnotation type) {
_type = _becomeParentOf(type as TypeAnnotationImpl);
}
@@ -10477,7 +10461,7 @@
@override
Iterable<SyntacticEntity> get childEntities =>
- new ChildEntities()..add(_variableList)..add(semicolon);
+ ChildEntities()..add(_variableList)..add(semicolon);
@override
Token get endToken => semicolon;
@@ -10486,7 +10470,7 @@
VariableDeclarationList get variables => _variableList;
@override
- void set variables(VariableDeclarationList variables) {
+ set variables(VariableDeclarationList variables) {
_variableList = _becomeParentOf(variables as VariableDeclarationListImpl);
}
@@ -10534,12 +10518,12 @@
Statement get body => _body;
@override
- void set body(Statement statement) {
+ set body(Statement statement) {
_body = _becomeParentOf(statement as StatementImpl);
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(whileKeyword)
..add(leftParenthesis)
..add(_condition)
@@ -10550,7 +10534,7 @@
Expression get condition => _condition;
@override
- void set condition(Expression expression) {
+ set condition(Expression expression) {
_condition = _becomeParentOf(expression as ExpressionImpl);
}
@@ -10580,7 +10564,7 @@
/// Initialize a newly created with clause.
WithClauseImpl(this.withKeyword, List<TypeName> mixinTypes) {
- _mixinTypes = new NodeListImpl<TypeName>(this, mixinTypes);
+ _mixinTypes = NodeListImpl<TypeName>(this, mixinTypes);
}
@override
@@ -10588,7 +10572,7 @@
@override
// TODO(paulberry): add commas.
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(withKeyword)
..addAll(_mixinTypes);
@@ -10640,7 +10624,7 @@
}
@override
- Iterable<SyntacticEntity> get childEntities => new ChildEntities()
+ Iterable<SyntacticEntity> get childEntities => ChildEntities()
..add(yieldKeyword)
..add(star)
..add(_expression)
@@ -10658,7 +10642,7 @@
Expression get expression => _expression;
@override
- void set expression(Expression expression) {
+ set expression(Expression expression) {
_expression = _becomeParentOf(expression as ExpressionImpl);
}
diff --git a/pkg/analyzer/lib/src/dart/ast/ast_factory.dart b/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
index a4aba0d..d39b8e9 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast_factory.dart
@@ -17,22 +17,22 @@
class AstFactoryImpl extends AstFactory {
@override
AdjacentStrings adjacentStrings(List<StringLiteral> strings) =>
- new AdjacentStringsImpl(strings);
+ AdjacentStringsImpl(strings);
@override
Annotation annotation(Token atSign, Identifier name, Token period,
SimpleIdentifier constructorName, ArgumentList arguments) =>
- new AnnotationImpl(atSign, name, period, constructorName, arguments);
+ AnnotationImpl(atSign, name, period, constructorName, arguments);
@override
ArgumentList argumentList(Token leftParenthesis, List<Expression> arguments,
Token rightParenthesis) =>
- new ArgumentListImpl(leftParenthesis, arguments, rightParenthesis);
+ ArgumentListImpl(leftParenthesis, arguments, rightParenthesis);
@override
AsExpression asExpression(
Expression expression, Token asOperator, TypeAnnotation type) =>
- new AsExpressionImpl(expression, asOperator, type);
+ AsExpressionImpl(expression, asOperator, type);
@override
AssertInitializer assertInitializer(
@@ -42,8 +42,8 @@
Token comma,
Expression message,
Token rightParenthesis) =>
- new AssertInitializerImpl(assertKeyword, leftParenthesis, condition,
- comma, message, rightParenthesis);
+ AssertInitializerImpl(assertKeyword, leftParenthesis, condition, comma,
+ message, rightParenthesis);
@override
AssertStatement assertStatement(
@@ -54,27 +54,27 @@
Expression message,
Token rightParenthesis,
Token semicolon) =>
- new AssertStatementImpl(assertKeyword, leftParenthesis, condition, comma,
+ AssertStatementImpl(assertKeyword, leftParenthesis, condition, comma,
message, rightParenthesis, semicolon);
@override
AssignmentExpression assignmentExpression(
Expression leftHandSide, Token operator, Expression rightHandSide) =>
- new AssignmentExpressionImpl(leftHandSide, operator, rightHandSide);
+ AssignmentExpressionImpl(leftHandSide, operator, rightHandSide);
@override
AwaitExpression awaitExpression(Token awaitKeyword, Expression expression) =>
- new AwaitExpressionImpl(awaitKeyword, expression);
+ AwaitExpressionImpl(awaitKeyword, expression);
@override
BinaryExpression binaryExpression(
Expression leftOperand, Token operator, Expression rightOperand) =>
- new BinaryExpressionImpl(leftOperand, operator, rightOperand);
+ BinaryExpressionImpl(leftOperand, operator, rightOperand);
@override
Block block(
Token leftBracket, List<Statement> statements, Token rightBracket) =>
- new BlockImpl(leftBracket, statements, rightBracket);
+ BlockImpl(leftBracket, statements, rightBracket);
@override
Comment blockComment(List<Token> tokens) =>
@@ -82,21 +82,21 @@
@override
BlockFunctionBody blockFunctionBody(Token keyword, Token star, Block block) =>
- new BlockFunctionBodyImpl(keyword, star, block);
+ BlockFunctionBodyImpl(keyword, star, block);
@override
BooleanLiteral booleanLiteral(Token literal, bool value) =>
- new BooleanLiteralImpl(literal, value);
+ BooleanLiteralImpl(literal, value);
@override
BreakStatement breakStatement(
Token breakKeyword, SimpleIdentifier label, Token semicolon) =>
- new BreakStatementImpl(breakKeyword, label, semicolon);
+ BreakStatementImpl(breakKeyword, label, semicolon);
@override
CascadeExpression cascadeExpression(
Expression target, List<Expression> cascadeSections) =>
- new CascadeExpressionImpl(target, cascadeSections);
+ CascadeExpressionImpl(target, cascadeSections);
@override
CatchClause catchClause(
@@ -109,7 +109,7 @@
SimpleIdentifier stackTraceParameter,
Token rightParenthesis,
Block body) =>
- new CatchClauseImpl(
+ CatchClauseImpl(
onKeyword,
exceptionType,
catchKeyword,
@@ -134,7 +134,7 @@
Token leftBracket,
List<ClassMember> members,
Token rightBracket) =>
- new ClassDeclarationImpl(
+ ClassDeclarationImpl(
comment,
metadata,
abstractKeyword,
@@ -161,7 +161,7 @@
WithClause withClause,
ImplementsClause implementsClause,
Token semicolon) =>
- new ClassTypeAliasImpl(
+ ClassTypeAliasImpl(
comment,
metadata,
keyword,
@@ -176,7 +176,7 @@
@override
CommentReference commentReference(Token newKeyword, Identifier identifier) =>
- new CommentReferenceImpl(newKeyword, identifier);
+ CommentReferenceImpl(newKeyword, identifier);
@override
CompilationUnit compilationUnit(
@@ -186,7 +186,7 @@
List<CompilationUnitMember> declarations,
Token endToken,
FeatureSet featureSet}) =>
- new CompilationUnitImpl(beginToken, scriptTag, directives, declarations,
+ CompilationUnitImpl(beginToken, scriptTag, directives, declarations,
endToken, featureSet);
@override
@@ -196,7 +196,7 @@
Expression thenExpression,
Token colon,
Expression elseExpression) =>
- new ConditionalExpressionImpl(
+ ConditionalExpressionImpl(
condition, question, thenExpression, colon, elseExpression);
@override
@@ -208,7 +208,7 @@
StringLiteral value,
Token rightParenthesis,
StringLiteral libraryUri) =>
- new ConfigurationImpl(ifKeyword, leftParenthesis, name, equalToken, value,
+ ConfigurationImpl(ifKeyword, leftParenthesis, name, equalToken, value,
rightParenthesis, libraryUri);
@override
@@ -226,7 +226,7 @@
List<ConstructorInitializer> initializers,
ConstructorName redirectedConstructor,
FunctionBody body) =>
- new ConstructorDeclarationImpl(
+ ConstructorDeclarationImpl(
comment,
metadata,
externalKeyword,
@@ -248,18 +248,18 @@
SimpleIdentifier fieldName,
Token equals,
Expression expression) =>
- new ConstructorFieldInitializerImpl(
+ ConstructorFieldInitializerImpl(
thisKeyword, period, fieldName, equals, expression);
@override
ConstructorName constructorName(
TypeName type, Token period, SimpleIdentifier name) =>
- new ConstructorNameImpl(type, period, name);
+ ConstructorNameImpl(type, period, name);
@override
ContinueStatement continueStatement(
Token continueKeyword, SimpleIdentifier label, Token semicolon) =>
- new ContinueStatementImpl(continueKeyword, label, semicolon);
+ ContinueStatementImpl(continueKeyword, label, semicolon);
@override
DeclaredIdentifier declaredIdentifier(
@@ -268,12 +268,12 @@
Token keyword,
TypeAnnotation type,
SimpleIdentifier identifier) =>
- new DeclaredIdentifierImpl(comment, metadata, keyword, type, identifier);
+ DeclaredIdentifierImpl(comment, metadata, keyword, type, identifier);
@override
DefaultFormalParameter defaultFormalParameter(NormalFormalParameter parameter,
ParameterKind kind, Token separator, Expression defaultValue) =>
- new DefaultFormalParameterImpl(parameter, kind, separator, defaultValue);
+ DefaultFormalParameterImpl(parameter, kind, separator, defaultValue);
@override
Comment documentationComment(List<Token> tokens,
@@ -290,24 +290,24 @@
Expression condition,
Token rightParenthesis,
Token semicolon) =>
- new DoStatementImpl(doKeyword, body, whileKeyword, leftParenthesis,
- condition, rightParenthesis, semicolon);
+ DoStatementImpl(doKeyword, body, whileKeyword, leftParenthesis, condition,
+ rightParenthesis, semicolon);
@override
DottedName dottedName(List<SimpleIdentifier> components) =>
- new DottedNameImpl(components);
+ DottedNameImpl(components);
@override
DoubleLiteral doubleLiteral(Token literal, double value) =>
- new DoubleLiteralImpl(literal, value);
+ DoubleLiteralImpl(literal, value);
@override
EmptyFunctionBody emptyFunctionBody(Token semicolon) =>
- new EmptyFunctionBodyImpl(semicolon);
+ EmptyFunctionBodyImpl(semicolon);
@override
EmptyStatement emptyStatement(Token semicolon) =>
- new EmptyStatementImpl(semicolon);
+ EmptyStatementImpl(semicolon);
@override
Comment endOfLineComment(List<Token> tokens) =>
@@ -316,7 +316,7 @@
@override
EnumConstantDeclaration enumConstantDeclaration(
Comment comment, List<Annotation> metadata, SimpleIdentifier name) =>
- new EnumConstantDeclarationImpl(comment, metadata, name);
+ EnumConstantDeclarationImpl(comment, metadata, name);
@override
EnumDeclaration enumDeclaration(
@@ -327,7 +327,7 @@
Token leftBracket,
List<EnumConstantDeclaration> constants,
Token rightBracket) =>
- new EnumDeclarationImpl(comment, metadata, enumKeyword, name, leftBracket,
+ EnumDeclarationImpl(comment, metadata, enumKeyword, name, leftBracket,
constants, rightBracket);
@override
@@ -339,23 +339,23 @@
List<Configuration> configurations,
List<Combinator> combinators,
Token semicolon) =>
- new ExportDirectiveImpl(comment, metadata, keyword, libraryUri,
+ ExportDirectiveImpl(comment, metadata, keyword, libraryUri,
configurations, combinators, semicolon);
@override
ExpressionFunctionBody expressionFunctionBody(Token keyword,
Token functionDefinition, Expression expression, Token semicolon) =>
- new ExpressionFunctionBodyImpl(
+ ExpressionFunctionBodyImpl(
keyword, functionDefinition, expression, semicolon);
@override
ExpressionStatement expressionStatement(
Expression expression, Token semicolon) =>
- new ExpressionStatementImpl(expression, semicolon);
+ ExpressionStatementImpl(expression, semicolon);
@override
ExtendsClause extendsClause(Token extendsKeyword, TypeName superclass) =>
- new ExtendsClauseImpl(extendsKeyword, superclass);
+ ExtendsClauseImpl(extendsKeyword, superclass);
@override
ExtensionDeclaration extensionDeclaration(
@@ -369,7 +369,7 @@
Token leftBracket,
List<ClassMember> members,
Token rightBracket}) =>
- new ExtensionDeclarationImpl(
+ ExtensionDeclarationImpl(
comment,
metadata,
extensionKeyword,
@@ -395,7 +395,7 @@
Token staticKeyword,
VariableDeclarationList fieldList,
Token semicolon) =>
- new FieldDeclarationImpl(
+ FieldDeclarationImpl(
comment, metadata, null, staticKeyword, fieldList, semicolon);
@override
@@ -406,8 +406,8 @@
Token staticKeyword,
@required VariableDeclarationList fieldList,
@required Token semicolon}) =>
- new FieldDeclarationImpl(comment, metadata, covariantKeyword,
- staticKeyword, fieldList, semicolon);
+ FieldDeclarationImpl(comment, metadata, covariantKeyword, staticKeyword,
+ fieldList, semicolon);
@override
FieldFormalParameter fieldFormalParameter(
@@ -420,7 +420,7 @@
SimpleIdentifier identifier,
TypeParameterList typeParameters,
FormalParameterList parameters) =>
- new FieldFormalParameterImpl(comment, metadata, null, null, keyword, type,
+ FieldFormalParameterImpl(comment, metadata, null, null, keyword, type,
thisKeyword, period, identifier, typeParameters, parameters, null);
@override
@@ -437,7 +437,7 @@
TypeParameterList typeParameters,
FormalParameterList parameters,
Token question}) =>
- new FieldFormalParameterImpl(
+ FieldFormalParameterImpl(
comment,
metadata,
covariantKeyword,
@@ -456,14 +456,14 @@
{DeclaredIdentifier loopVariable,
Token inKeyword,
Expression iterable}) =>
- new ForEachPartsWithDeclarationImpl(loopVariable, inKeyword, iterable);
+ ForEachPartsWithDeclarationImpl(loopVariable, inKeyword, iterable);
@override
ForEachPartsWithIdentifier forEachPartsWithIdentifier(
{SimpleIdentifier identifier,
Token inKeyword,
Expression iterable}) =>
- new ForEachPartsWithIdentifierImpl(identifier, inKeyword, iterable);
+ ForEachPartsWithIdentifierImpl(identifier, inKeyword, iterable);
@override
ForElement forElement(
@@ -473,8 +473,8 @@
ForLoopParts forLoopParts,
Token rightParenthesis,
CollectionElement body}) =>
- new ForElementImpl(awaitKeyword, forKeyword, leftParenthesis,
- forLoopParts, rightParenthesis, body);
+ ForElementImpl(awaitKeyword, forKeyword, leftParenthesis, forLoopParts,
+ rightParenthesis, body);
@override
FormalParameterList formalParameterList(
@@ -483,7 +483,7 @@
Token leftDelimiter,
Token rightDelimiter,
Token rightParenthesis) =>
- new FormalParameterListImpl(leftParenthesis, parameters, leftDelimiter,
+ FormalParameterListImpl(leftParenthesis, parameters, leftDelimiter,
rightDelimiter, rightParenthesis);
@override
@@ -493,7 +493,7 @@
Expression condition,
Token rightSeparator,
List<Expression> updaters}) =>
- new ForPartsWithDeclarationsImpl(
+ ForPartsWithDeclarationsImpl(
variables, leftSeparator, condition, rightSeparator, updaters);
@override
@@ -503,7 +503,7 @@
Expression condition,
Token rightSeparator,
List<Expression> updaters}) =>
- new ForPartsWithExpressionImpl(
+ ForPartsWithExpressionImpl(
initialization, leftSeparator, condition, rightSeparator, updaters);
@override
@@ -527,24 +527,23 @@
Token propertyKeyword,
SimpleIdentifier name,
FunctionExpression functionExpression) =>
- new FunctionDeclarationImpl(comment, metadata, externalKeyword,
- returnType, propertyKeyword, name, functionExpression);
+ FunctionDeclarationImpl(comment, metadata, externalKeyword, returnType,
+ propertyKeyword, name, functionExpression);
@override
FunctionDeclarationStatement functionDeclarationStatement(
FunctionDeclaration functionDeclaration) =>
- new FunctionDeclarationStatementImpl(functionDeclaration);
+ FunctionDeclarationStatementImpl(functionDeclaration);
@override
FunctionExpression functionExpression(TypeParameterList typeParameters,
FormalParameterList parameters, FunctionBody body) =>
- new FunctionExpressionImpl(typeParameters, parameters, body);
+ FunctionExpressionImpl(typeParameters, parameters, body);
@override
FunctionExpressionInvocation functionExpressionInvocation(Expression function,
TypeArgumentList typeArguments, ArgumentList argumentList) =>
- new FunctionExpressionInvocationImpl(
- function, typeArguments, argumentList);
+ FunctionExpressionInvocationImpl(function, typeArguments, argumentList);
@override
FunctionTypeAlias functionTypeAlias(
@@ -556,7 +555,7 @@
TypeParameterList typeParameters,
FormalParameterList parameters,
Token semicolon) =>
- new FunctionTypeAliasImpl(comment, metadata, keyword, returnType, name,
+ FunctionTypeAliasImpl(comment, metadata, keyword, returnType, name,
typeParameters, parameters, semicolon);
@override
@@ -567,7 +566,7 @@
SimpleIdentifier identifier,
TypeParameterList typeParameters,
FormalParameterList parameters) =>
- new FunctionTypedFormalParameterImpl(comment, metadata, null, null,
+ FunctionTypedFormalParameterImpl(comment, metadata, null, null,
returnType, identifier, typeParameters, parameters, null);
@override
@@ -581,7 +580,7 @@
TypeParameterList typeParameters,
@required FormalParameterList parameters,
Token question}) =>
- new FunctionTypedFormalParameterImpl(
+ FunctionTypedFormalParameterImpl(
comment,
metadata,
covariantKeyword,
@@ -599,7 +598,7 @@
TypeParameterList typeParameters,
FormalParameterList parameters,
{Token question}) =>
- new GenericFunctionTypeImpl(
+ GenericFunctionTypeImpl(
returnType, functionKeyword, typeParameters, parameters,
question: question);
@@ -613,13 +612,13 @@
Token equals,
GenericFunctionType functionType,
Token semicolon) =>
- new GenericTypeAliasImpl(comment, metadata, typedefKeyword, name,
+ GenericTypeAliasImpl(comment, metadata, typedefKeyword, name,
typeParameters, equals, functionType, semicolon);
@override
HideCombinator hideCombinator(
Token keyword, List<SimpleIdentifier> hiddenNames) =>
- new HideCombinatorImpl(keyword, hiddenNames);
+ HideCombinatorImpl(keyword, hiddenNames);
@override
IfElement ifElement(
@@ -630,7 +629,7 @@
CollectionElement thenElement,
Token elseKeyword,
CollectionElement elseElement}) =>
- new IfElementImpl(ifKeyword, leftParenthesis, condition, rightParenthesis,
+ IfElementImpl(ifKeyword, leftParenthesis, condition, rightParenthesis,
thenElement, elseKeyword, elseElement);
@override
@@ -642,13 +641,13 @@
Statement thenStatement,
Token elseKeyword,
Statement elseStatement) =>
- new IfStatementImpl(ifKeyword, leftParenthesis, condition,
- rightParenthesis, thenStatement, elseKeyword, elseStatement);
+ IfStatementImpl(ifKeyword, leftParenthesis, condition, rightParenthesis,
+ thenStatement, elseKeyword, elseStatement);
@override
ImplementsClause implementsClause(
Token implementsKeyword, List<TypeName> interfaces) =>
- new ImplementsClauseImpl(implementsKeyword, interfaces);
+ ImplementsClauseImpl(implementsKeyword, interfaces);
@override
ImportDirective importDirective(
@@ -662,7 +661,7 @@
SimpleIdentifier prefix,
List<Combinator> combinators,
Token semicolon) =>
- new ImportDirectiveImpl(
+ ImportDirectiveImpl(
comment,
metadata,
keyword,
@@ -677,73 +676,69 @@
@override
IndexExpression indexExpressionForCascade(Token period, Token leftBracket,
Expression index, Token rightBracket) =>
- new IndexExpressionImpl.forCascade(
- period, leftBracket, index, rightBracket);
+ IndexExpressionImpl.forCascade(period, leftBracket, index, rightBracket);
@override
IndexExpression indexExpressionForTarget(Expression target, Token leftBracket,
Expression index, Token rightBracket) =>
- new IndexExpressionImpl.forTarget(
- target, leftBracket, index, rightBracket);
+ IndexExpressionImpl.forTarget(target, leftBracket, index, rightBracket);
@override
InstanceCreationExpression instanceCreationExpression(Token keyword,
ConstructorName constructorName, ArgumentList argumentList,
{TypeArgumentList typeArguments}) =>
- new InstanceCreationExpressionImpl(keyword, constructorName, argumentList,
+ InstanceCreationExpressionImpl(keyword, constructorName, argumentList,
typeArguments: typeArguments);
@override
IntegerLiteral integerLiteral(Token literal, int value) =>
- new IntegerLiteralImpl(literal, value);
+ IntegerLiteralImpl(literal, value);
@override
InterpolationExpression interpolationExpression(
Token leftBracket, Expression expression, Token rightBracket) =>
- new InterpolationExpressionImpl(leftBracket, expression, rightBracket);
+ InterpolationExpressionImpl(leftBracket, expression, rightBracket);
@override
InterpolationString interpolationString(Token contents, String value) =>
- new InterpolationStringImpl(contents, value);
+ InterpolationStringImpl(contents, value);
@override
IsExpression isExpression(Expression expression, Token isOperator,
Token notOperator, TypeAnnotation type) =>
- new IsExpressionImpl(expression, isOperator, notOperator, type);
+ IsExpressionImpl(expression, isOperator, notOperator, type);
@override
- Label label(SimpleIdentifier label, Token colon) =>
- new LabelImpl(label, colon);
+ Label label(SimpleIdentifier label, Token colon) => LabelImpl(label, colon);
@override
LabeledStatement labeledStatement(List<Label> labels, Statement statement) =>
- new LabeledStatementImpl(labels, statement);
+ LabeledStatementImpl(labels, statement);
@override
LibraryDirective libraryDirective(Comment comment, List<Annotation> metadata,
Token libraryKeyword, LibraryIdentifier name, Token semicolon) =>
- new LibraryDirectiveImpl(
- comment, metadata, libraryKeyword, name, semicolon);
+ LibraryDirectiveImpl(comment, metadata, libraryKeyword, name, semicolon);
@override
LibraryIdentifier libraryIdentifier(List<SimpleIdentifier> components) =>
- new LibraryIdentifierImpl(components);
+ LibraryIdentifierImpl(components);
@override
ListLiteral listLiteral(Token constKeyword, TypeArgumentList typeArguments,
Token leftBracket, List<CollectionElement> elements, Token rightBracket) {
if (elements == null || elements is List<Expression>) {
- return new ListLiteralImpl(
+ return ListLiteralImpl(
constKeyword, typeArguments, leftBracket, elements, rightBracket);
}
- return new ListLiteralImpl.experimental(
+ return ListLiteralImpl.experimental(
constKeyword, typeArguments, leftBracket, elements, rightBracket);
}
@override
MapLiteralEntry mapLiteralEntry(
Expression key, Token separator, Expression value) =>
- new MapLiteralEntryImpl(key, separator, value);
+ MapLiteralEntryImpl(key, separator, value);
@override
MethodDeclaration methodDeclaration(
@@ -758,7 +753,7 @@
TypeParameterList typeParameters,
FormalParameterList parameters,
FunctionBody body) =>
- new MethodDeclarationImpl(
+ MethodDeclarationImpl(
comment,
metadata,
externalKeyword,
@@ -778,7 +773,7 @@
SimpleIdentifier methodName,
TypeArgumentList typeArguments,
ArgumentList argumentList) =>
- new MethodInvocationImpl(
+ MethodInvocationImpl(
target, operator, methodName, typeArguments, argumentList);
@override
@@ -793,7 +788,7 @@
Token leftBracket,
List<ClassMember> members,
Token rightBracket) =>
- new MixinDeclarationImpl(
+ MixinDeclarationImpl(
comment,
metadata,
mixinKeyword,
@@ -807,38 +802,38 @@
@override
NamedExpression namedExpression(Label name, Expression expression) =>
- new NamedExpressionImpl(name, expression);
+ NamedExpressionImpl(name, expression);
@override
NativeClause nativeClause(Token nativeKeyword, StringLiteral name) =>
- new NativeClauseImpl(nativeKeyword, name);
+ NativeClauseImpl(nativeKeyword, name);
@override
NativeFunctionBody nativeFunctionBody(
Token nativeKeyword, StringLiteral stringLiteral, Token semicolon) =>
- new NativeFunctionBodyImpl(nativeKeyword, stringLiteral, semicolon);
+ NativeFunctionBodyImpl(nativeKeyword, stringLiteral, semicolon);
@override
NodeList<E> nodeList<E extends AstNode>(AstNode owner, [List<E> elements]) =>
- new NodeListImpl<E>(owner as AstNodeImpl, elements);
+ NodeListImpl<E>(owner as AstNodeImpl, elements);
@override
- NullLiteral nullLiteral(Token literal) => new NullLiteralImpl(literal);
+ NullLiteral nullLiteral(Token literal) => NullLiteralImpl(literal);
@override
OnClause onClause(Token onKeyword, List<TypeName> superclassConstraints) =>
- new OnClauseImpl(onKeyword, superclassConstraints);
+ OnClauseImpl(onKeyword, superclassConstraints);
@override
ParenthesizedExpression parenthesizedExpression(Token leftParenthesis,
Expression expression, Token rightParenthesis) =>
- new ParenthesizedExpressionImpl(
+ ParenthesizedExpressionImpl(
leftParenthesis, expression, rightParenthesis);
@override
PartDirective partDirective(Comment comment, List<Annotation> metadata,
Token partKeyword, StringLiteral partUri, Token semicolon) =>
- new PartDirectiveImpl(comment, metadata, partKeyword, partUri, semicolon);
+ PartDirectiveImpl(comment, metadata, partKeyword, partUri, semicolon);
@override
PartOfDirective partOfDirective(
@@ -849,26 +844,26 @@
StringLiteral uri,
LibraryIdentifier libraryName,
Token semicolon) =>
- new PartOfDirectiveImpl(comment, metadata, partKeyword, ofKeyword, uri,
+ PartOfDirectiveImpl(comment, metadata, partKeyword, ofKeyword, uri,
libraryName, semicolon);
@override
PostfixExpression postfixExpression(Expression operand, Token operator) =>
- new PostfixExpressionImpl(operand, operator);
+ PostfixExpressionImpl(operand, operator);
@override
PrefixedIdentifier prefixedIdentifier(
SimpleIdentifier prefix, Token period, SimpleIdentifier identifier) =>
- new PrefixedIdentifierImpl(prefix, period, identifier);
+ PrefixedIdentifierImpl(prefix, period, identifier);
@override
PrefixExpression prefixExpression(Token operator, Expression operand) =>
- new PrefixExpressionImpl(operator, operand);
+ PrefixExpressionImpl(operator, operand);
@override
PropertyAccess propertyAccess(
Expression target, Token operator, SimpleIdentifier propertyName) =>
- new PropertyAccessImpl(target, operator, propertyName);
+ PropertyAccessImpl(target, operator, propertyName);
@override
RedirectingConstructorInvocation redirectingConstructorInvocation(
@@ -876,20 +871,20 @@
Token period,
SimpleIdentifier constructorName,
ArgumentList argumentList) =>
- new RedirectingConstructorInvocationImpl(
+ RedirectingConstructorInvocationImpl(
thisKeyword, period, constructorName, argumentList);
@override
RethrowExpression rethrowExpression(Token rethrowKeyword) =>
- new RethrowExpressionImpl(rethrowKeyword);
+ RethrowExpressionImpl(rethrowKeyword);
@override
ReturnStatement returnStatement(
Token returnKeyword, Expression expression, Token semicolon) =>
- new ReturnStatementImpl(returnKeyword, expression, semicolon);
+ ReturnStatementImpl(returnKeyword, expression, semicolon);
@override
- ScriptTag scriptTag(Token scriptTag) => new ScriptTagImpl(scriptTag);
+ ScriptTag scriptTag(Token scriptTag) => ScriptTagImpl(scriptTag);
@override
SetOrMapLiteral setOrMapLiteral(
@@ -898,13 +893,13 @@
Token leftBracket,
List<CollectionElement> elements,
Token rightBracket}) =>
- new SetOrMapLiteralImpl(
+ SetOrMapLiteralImpl(
constKeyword, typeArguments, leftBracket, elements, rightBracket);
@override
ShowCombinator showCombinator(
Token keyword, List<SimpleIdentifier> shownNames) =>
- new ShowCombinatorImpl(keyword, shownNames);
+ ShowCombinatorImpl(keyword, shownNames);
@override
SimpleFormalParameter simpleFormalParameter(
@@ -913,7 +908,7 @@
Token keyword,
TypeAnnotation type,
SimpleIdentifier identifier) =>
- new SimpleFormalParameterImpl(
+ SimpleFormalParameterImpl(
comment, metadata, null, null, keyword, type, identifier);
@override
@@ -925,29 +920,29 @@
Token keyword,
TypeAnnotation type,
@required SimpleIdentifier identifier}) =>
- new SimpleFormalParameterImpl(comment, metadata, covariantKeyword,
+ SimpleFormalParameterImpl(comment, metadata, covariantKeyword,
requiredKeyword, keyword, type, identifier);
@override
- SimpleIdentifier simpleIdentifier(Token token, {bool isDeclaration: false}) {
+ SimpleIdentifier simpleIdentifier(Token token, {bool isDeclaration = false}) {
if (isDeclaration) {
- return new DeclaredSimpleIdentifier(token);
+ return DeclaredSimpleIdentifier(token);
}
- return new SimpleIdentifierImpl(token);
+ return SimpleIdentifierImpl(token);
}
@override
SimpleStringLiteral simpleStringLiteral(Token literal, String value) =>
- new SimpleStringLiteralImpl(literal, value);
+ SimpleStringLiteralImpl(literal, value);
@override
SpreadElement spreadElement({Token spreadOperator, Expression expression}) =>
- new SpreadElementImpl(spreadOperator, expression);
+ SpreadElementImpl(spreadOperator, expression);
@override
StringInterpolation stringInterpolation(
List<InterpolationElement> elements) =>
- new StringInterpolationImpl(elements);
+ StringInterpolationImpl(elements);
@override
SuperConstructorInvocation superConstructorInvocation(
@@ -955,22 +950,22 @@
Token period,
SimpleIdentifier constructorName,
ArgumentList argumentList) =>
- new SuperConstructorInvocationImpl(
+ SuperConstructorInvocationImpl(
superKeyword, period, constructorName, argumentList);
@override
SuperExpression superExpression(Token superKeyword) =>
- new SuperExpressionImpl(superKeyword);
+ SuperExpressionImpl(superKeyword);
@override
SwitchCase switchCase(List<Label> labels, Token keyword,
Expression expression, Token colon, List<Statement> statements) =>
- new SwitchCaseImpl(labels, keyword, expression, colon, statements);
+ SwitchCaseImpl(labels, keyword, expression, colon, statements);
@override
SwitchDefault switchDefault(List<Label> labels, Token keyword, Token colon,
List<Statement> statements) =>
- new SwitchDefaultImpl(labels, keyword, colon, statements);
+ SwitchDefaultImpl(labels, keyword, colon, statements);
@override
SwitchStatement switchStatement(
@@ -981,20 +976,20 @@
Token leftBracket,
List<SwitchMember> members,
Token rightBracket) =>
- new SwitchStatementImpl(switchKeyword, leftParenthesis, expression,
+ SwitchStatementImpl(switchKeyword, leftParenthesis, expression,
rightParenthesis, leftBracket, members, rightBracket);
@override
SymbolLiteral symbolLiteral(Token poundSign, List<Token> components) =>
- new SymbolLiteralImpl(poundSign, components);
+ SymbolLiteralImpl(poundSign, components);
@override
ThisExpression thisExpression(Token thisKeyword) =>
- new ThisExpressionImpl(thisKeyword);
+ ThisExpressionImpl(thisKeyword);
@override
ThrowExpression throwExpression(Token throwKeyword, Expression expression) =>
- new ThrowExpressionImpl(throwKeyword, expression);
+ ThrowExpressionImpl(throwKeyword, expression);
@override
TopLevelVariableDeclaration topLevelVariableDeclaration(
@@ -1002,7 +997,7 @@
List<Annotation> metadata,
VariableDeclarationList variableList,
Token semicolon) =>
- new TopLevelVariableDeclarationImpl(
+ TopLevelVariableDeclarationImpl(
comment, metadata, variableList, semicolon);
@override
@@ -1012,23 +1007,23 @@
List<CatchClause> catchClauses,
Token finallyKeyword,
Block finallyBlock) =>
- new TryStatementImpl(
+ TryStatementImpl(
tryKeyword, body, catchClauses, finallyKeyword, finallyBlock);
@override
TypeArgumentList typeArgumentList(Token leftBracket,
List<TypeAnnotation> arguments, Token rightBracket) =>
- new TypeArgumentListImpl(leftBracket, arguments, rightBracket);
+ TypeArgumentListImpl(leftBracket, arguments, rightBracket);
@override
TypeName typeName(Identifier name, TypeArgumentList typeArguments,
{Token question}) =>
- new TypeNameImpl(name, typeArguments, question: question);
+ TypeNameImpl(name, typeArguments, question: question);
@override
TypeParameter typeParameter(Comment comment, List<Annotation> metadata,
SimpleIdentifier name, Token extendsKeyword, TypeAnnotation bound) =>
- new TypeParameterImpl(comment, metadata, name, extendsKeyword, bound);
+ TypeParameterImpl(comment, metadata, name, extendsKeyword, bound);
TypeParameter typeParameter2(
{Comment comment,
@@ -1037,18 +1032,18 @@
Token extendsKeyword,
TypeAnnotation bound,
Token varianceKeyword}) =>
- new TypeParameterImpl(comment, metadata, name, extendsKeyword, bound)
+ TypeParameterImpl(comment, metadata, name, extendsKeyword, bound)
..varianceKeyword = varianceKeyword;
@override
TypeParameterList typeParameterList(Token leftBracket,
List<TypeParameter> typeParameters, Token rightBracket) =>
- new TypeParameterListImpl(leftBracket, typeParameters, rightBracket);
+ TypeParameterListImpl(leftBracket, typeParameters, rightBracket);
@override
VariableDeclaration variableDeclaration(
SimpleIdentifier name, Token equals, Expression initializer) =>
- new VariableDeclarationImpl(name, equals, initializer);
+ VariableDeclarationImpl(name, equals, initializer);
@override
VariableDeclarationList variableDeclarationList(
@@ -1057,7 +1052,7 @@
Token keyword,
TypeAnnotation type,
List<VariableDeclaration> variables) =>
- new VariableDeclarationListImpl(
+ VariableDeclarationListImpl(
comment, metadata, null, keyword, type, variables);
@override
@@ -1068,27 +1063,27 @@
Token keyword,
TypeAnnotation type,
List<VariableDeclaration> variables}) {
- return new VariableDeclarationListImpl(
+ return VariableDeclarationListImpl(
comment, metadata, lateKeyword, keyword, type, variables);
}
@override
VariableDeclarationStatement variableDeclarationStatement(
VariableDeclarationList variableList, Token semicolon) =>
- new VariableDeclarationStatementImpl(variableList, semicolon);
+ VariableDeclarationStatementImpl(variableList, semicolon);
@override
WhileStatement whileStatement(Token whileKeyword, Token leftParenthesis,
Expression condition, Token rightParenthesis, Statement body) =>
- new WhileStatementImpl(
+ WhileStatementImpl(
whileKeyword, leftParenthesis, condition, rightParenthesis, body);
@override
WithClause withClause(Token withKeyword, List<TypeName> mixinTypes) =>
- new WithClauseImpl(withKeyword, mixinTypes);
+ WithClauseImpl(withKeyword, mixinTypes);
@override
YieldStatement yieldStatement(Token yieldKeyword, Token star,
Expression expression, Token semicolon) =>
- new YieldStatementImpl(yieldKeyword, star, expression, semicolon);
+ YieldStatementImpl(yieldKeyword, star, expression, semicolon);
}
diff --git a/pkg/analyzer/lib/src/dart/ast/constant_evaluator.dart b/pkg/analyzer/lib/src/dart/ast/constant_evaluator.dart
index 430631f..cea54db 100644
--- a/pkg/analyzer/lib/src/dart/ast/constant_evaluator.dart
+++ b/pkg/analyzer/lib/src/dart/ast/constant_evaluator.dart
@@ -98,11 +98,11 @@
* The value returned for expressions (or non-expression nodes) that are not
* compile-time constant expressions.
*/
- static Object NOT_A_CONSTANT = new Object();
+ static Object NOT_A_CONSTANT = Object();
@override
Object visitAdjacentStrings(AdjacentStrings node) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
for (StringLiteral string in node.strings) {
Object value = string.accept(this);
if (identical(value, NOT_A_CONSTANT)) {
@@ -260,7 +260,7 @@
@override
Object visitListLiteral(ListLiteral node) {
- List<Object> list = new List<Object>();
+ List<Object> list = List<Object>();
for (CollectionElement element in node.elements) {
if (element is Expression) {
Object value = element.accept(this);
@@ -331,7 +331,7 @@
// There are a lot of constants that this class does not support, so we
// didn't add support for set literals. As a result, this assumes that we're
// looking at a map literal until we prove otherwise.
- Map<String, Object> map = new HashMap<String, Object>();
+ Map<String, Object> map = HashMap<String, Object>();
for (CollectionElement element in node.elements) {
if (element is MapLiteralEntry) {
Object key = element.key.accept(this);
@@ -359,7 +359,7 @@
@override
Object visitStringInterpolation(StringInterpolation node) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
for (InterpolationElement element in node.elements) {
Object value = element.accept(this);
if (identical(value, NOT_A_CONSTANT)) {
@@ -373,7 +373,7 @@
@override
Object visitSymbolLiteral(SymbolLiteral node) {
// TODO(brianwilkerson) This isn't optimal because a Symbol is not a String.
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
for (Token component in node.components) {
if (buffer.length > 0) {
buffer.writeCharCode(0x2E);
diff --git a/pkg/analyzer/lib/src/dart/ast/element_locator.dart b/pkg/analyzer/lib/src/dart/ast/element_locator.dart
index 9761144..432f8f1 100644
--- a/pkg/analyzer/lib/src/dart/ast/element_locator.dart
+++ b/pkg/analyzer/lib/src/dart/ast/element_locator.dart
@@ -13,7 +13,7 @@
static Element locate(AstNode node) {
if (node == null) return null;
- var mapper = new _ElementMapper();
+ var mapper = _ElementMapper();
return node.accept(mapper);
}
}
diff --git a/pkg/analyzer/lib/src/dart/ast/utilities.dart b/pkg/analyzer/lib/src/dart/ast/utilities.dart
index 284ccb1..5abb82e 100644
--- a/pkg/analyzer/lib/src/dart/ast/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/ast/utilities.dart
@@ -39,7 +39,7 @@
/**
* Mapping from original tokes to cloned.
*/
- final Map<Token, Token> _clonedTokens = new Map<Token, Token>.identity();
+ final Map<Token, Token> _clonedTokens = Map<Token, Token>.identity();
/**
* The next original token to clone.
@@ -80,7 +80,7 @@
*/
List<E> cloneNodeList<E extends AstNode>(List<E> nodes) {
int count = nodes.length;
- List<E> clonedNodes = new List<E>();
+ List<E> clonedNodes = List<E>();
for (int i = 0; i < count; i++) {
clonedNodes.add((nodes[i]).accept(this) as E);
}
@@ -265,7 +265,7 @@
// Clone the tokens in that stream here and add them to _clondedTokens
// for use when cloning the comment reference.
Token token = node.beginToken;
- Token lastCloned = new Token.eof(-1);
+ Token lastCloned = Token.eof(-1);
while (token != null) {
Token clone = token.copy();
_clonedTokens[token] = clone;
@@ -1097,7 +1097,7 @@
token = nonComment(token);
if (_lastCloned == null) {
- _lastCloned = new Token.eof(-1);
+ _lastCloned = Token.eof(-1);
}
while (token != null) {
Token clone = token.copy();
@@ -1129,7 +1129,7 @@
* Return a clone of the given [node].
*/
static AstNode clone(AstNode node) {
- return node.accept(new AstCloner());
+ return node.accept(AstCloner());
}
}
@@ -2391,7 +2391,7 @@
* Return `true` if the [first] and [second] nodes are equal.
*/
static bool equalNodes(AstNode first, AstNode second) {
- AstComparator comparator = new AstComparator();
+ AstComparator comparator = AstComparator();
return comparator.isEqualNodes(first, second);
}
}
@@ -2448,7 +2448,7 @@
Iterable<AstVisitor<T>> delegates, this.handler)
: super(delegates) {
if (handler == null) {
- throw new ArgumentError('A handler must be provided');
+ throw ArgumentError('A handler must be provided');
}
}
@@ -2471,7 +2471,7 @@
*/
static void logException(
AstNode node, Object visitor, dynamic exception, StackTrace stackTrace) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write('Exception while using a ${visitor.runtimeType} to visit a ');
AstNode currentNode = node;
bool first = true;
@@ -2486,7 +2486,7 @@
}
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(buffer.toString(), exception, stackTrace));
+ SilentException(buffer.toString(), exception, stackTrace));
}
}
@@ -2542,7 +2542,7 @@
} catch (exception, stackTrace) {
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(
+ SilentException(
"Unable to locate element at offset ($_startOffset - $_endOffset)",
exception,
stackTrace));
@@ -2583,10 +2583,8 @@
// structure.
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(
- "Exception caught while traversing an AST structure.",
- exception,
- stackTrace));
+ SilentException("Exception caught while traversing an AST structure.",
+ exception, stackTrace));
}
// Found a child.
if (_foundNode != null) {
@@ -2644,7 +2642,7 @@
} catch (exception, stackTrace) {
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(
+ SilentException(
"Unable to locate element at offset ($_startOffset - $_endOffset)",
exception,
stackTrace));
@@ -2685,10 +2683,8 @@
// structure.
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(
- "Exception caught while traversing an AST structure.",
- exception,
- stackTrace));
+ SilentException("Exception caught while traversing an AST structure.",
+ exception, stackTrace));
}
// Found a child.
if (_foundNode != null) {
@@ -3676,7 +3672,7 @@
}
bool visitNode(AstNode node) {
- throw new ArgumentError("The old node is not a child of it's parent");
+ throw ArgumentError("The old node is not a child of it's parent");
}
bool visitNormalFormalParameter(NormalFormalParameter node) {
@@ -4064,15 +4060,15 @@
*/
static bool replace(AstNode oldNode, AstNode newNode) {
if (oldNode == null || newNode == null) {
- throw new ArgumentError("The old and new nodes must be non-null");
+ throw ArgumentError("The old and new nodes must be non-null");
} else if (identical(oldNode, newNode)) {
return true;
}
AstNode parent = oldNode.parent;
if (parent == null) {
- throw new ArgumentError("The old node is not a child of another node");
+ throw ArgumentError("The old node is not a child of another node");
}
- NodeReplacer replacer = new NodeReplacer(oldNode, newNode);
+ NodeReplacer replacer = NodeReplacer(oldNode, newNode);
return parent.accept(replacer);
}
}
@@ -5620,7 +5616,7 @@
* Copy resolution data from the [fromNode] to the [toNode].
*/
static void copyResolutionData(AstNode fromNode, AstNode toNode) {
- ResolutionCopier copier = new ResolutionCopier();
+ ResolutionCopier copier = ResolutionCopier();
copier._isEqualNodes(fromNode, toNode);
}
}
@@ -5639,8 +5635,7 @@
AstNode _immediateChild;
- Map<String, SimpleIdentifier> _locals =
- new HashMap<String, SimpleIdentifier>();
+ Map<String, SimpleIdentifier> _locals = HashMap<String, SimpleIdentifier>();
final int _position;
diff --git a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
index 7b91b96..93e9e9a 100644
--- a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
+++ b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
@@ -61,7 +61,7 @@
currentLibrary,
typeProvider,
declaredVariables,
- currentLibrary.context.typeSystem,
+ currentLibrary.typeSystem,
featureSet ??
(currentLibrary.context.analysisOptions as AnalysisOptionsImpl)
.contextFeatures);
@@ -76,7 +76,7 @@
: _constantUpdate2018Enabled =
featureSet.isEnabled(Feature.constant_update_2018),
_intType = _typeProvider.intType,
- _evaluationEngine = new ConstantEvaluationEngine(
+ _evaluationEngine = ConstantEvaluationEngine(
_typeProvider, declaredVariables,
typeSystem: typeSystem, experimentStatus: featureSet);
@@ -131,7 +131,7 @@
ConstructorElement constructor = node.staticElement;
if (constructor != null) {
ConstantVisitor constantVisitor =
- new ConstantVisitor(_evaluationEngine, _errorReporter);
+ ConstantVisitor(_evaluationEngine, _errorReporter);
_evaluationEngine.evaluateConstructorCall(
node,
node.argumentList.arguments,
@@ -377,7 +377,7 @@
void _reportErrorIfFromDeferredLibrary(
Expression expression, ErrorCode errorCode) {
DeferredLibraryReferenceDetector referenceDetector =
- new DeferredLibraryReferenceDetector();
+ DeferredLibraryReferenceDetector();
expression.accept(referenceDetector);
if (referenceDetector.result) {
_errorReporter.reportErrorForNode(errorCode, expression);
@@ -419,8 +419,8 @@
CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH)) {
_errorReporter.reportError(data);
} else if (errorCode != null) {
- _errorReporter.reportError(new AnalysisError(
- data.source, data.offset, data.length, errorCode));
+ _errorReporter.reportError(
+ AnalysisError(data.source, data.offset, data.length, errorCode));
}
}
}
@@ -457,11 +457,11 @@
/// compile time constant
/// @return the value of the compile time constant
DartObjectImpl _validate(Expression expression, ErrorCode errorCode) {
- RecordingErrorListener errorListener = new RecordingErrorListener();
+ RecordingErrorListener errorListener = RecordingErrorListener();
ErrorReporter subErrorReporter =
- new ErrorReporter(errorListener, _errorReporter.source);
- DartObjectImpl result = expression
- .accept(new ConstantVisitor(_evaluationEngine, subErrorReporter));
+ ErrorReporter(errorListener, _errorReporter.source);
+ DartObjectImpl result =
+ expression.accept(ConstantVisitor(_evaluationEngine, subErrorReporter));
_reportErrors(errorListener.errors, errorCode);
return result;
}
@@ -512,8 +512,7 @@
Expression defaultValue = parameter.defaultValue;
DartObjectImpl result;
if (defaultValue == null) {
- result =
- new DartObjectImpl(_typeProvider.nullType, NullState.NULL_STATE);
+ result = DartObjectImpl(_typeProvider.nullType, NullState.NULL_STATE);
} else {
result = _validate(
defaultValue, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE);
@@ -526,7 +525,7 @@
}
VariableElementImpl element =
parameter.declaredElement as VariableElementImpl;
- element.evaluationResult = new EvaluationResultImpl(result);
+ element.evaluationResult = EvaluationResultImpl(result);
}
}
}
@@ -552,9 +551,9 @@
AnalysisErrorListener errorListener =
AnalysisErrorListener.NULL_LISTENER;
ErrorReporter subErrorReporter =
- new ErrorReporter(errorListener, _errorReporter.source);
- DartObjectImpl result = initializer.accept(
- new ConstantVisitor(_evaluationEngine, subErrorReporter));
+ ErrorReporter(errorListener, _errorReporter.source);
+ DartObjectImpl result = initializer
+ .accept(ConstantVisitor(_evaluationEngine, subErrorReporter));
if (result == null) {
_errorReporter.reportErrorForNode(
CompileTimeErrorCode
@@ -685,7 +684,7 @@
return true;
}
- throw new UnsupportedError(
+ throw UnsupportedError(
'Unhandled type of collection element: ${element.runtimeType}',
);
}
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index ffae190..937979f 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -56,7 +56,7 @@
/// RegExp that validates a non-empty non-private symbol.
/// From sdk/lib/internal/symbol.dart.
- static RegExp _PUBLIC_SYMBOL_PATTERN = new RegExp(
+ static RegExp _PUBLIC_SYMBOL_PATTERN = RegExp(
"^(?:$_OPERATOR_RE\$|$_PUBLIC_IDENTIFIER_RE(?:=?\$|[.](?!\$)))+?\$");
/// The type provider used to access the known types.
@@ -88,8 +88,7 @@
// TODO(brianwilkerson) Remove the unused parameter `forAnalysisDriver`.
@deprecated bool forAnalysisDriver})
: typeProvider = typeProvider,
- validator =
- validator ?? new ConstantEvaluationValidator_ForProduction(),
+ validator = validator ?? ConstantEvaluationValidator_ForProduction(),
typeSystem = typeSystem ??
TypeSystemImpl(
implicitCasts: true,
@@ -97,7 +96,7 @@
strictInference: false,
typeProvider: typeProvider,
),
- experimentStatus = experimentStatus ?? new ExperimentStatus();
+ experimentStatus = experimentStatus ?? ExperimentStatus();
/// Check that the arguments to a call to fromEnvironment() are correct. The
/// [arguments] are the AST nodes of the arguments. The [argumentValues] are
@@ -169,13 +168,13 @@
if (constant.isOptional) {
Expression defaultValue = constant.constantInitializer;
if (defaultValue != null) {
- RecordingErrorListener errorListener = new RecordingErrorListener();
+ RecordingErrorListener errorListener = RecordingErrorListener();
ErrorReporter errorReporter =
- new ErrorReporter(errorListener, constant.source);
+ ErrorReporter(errorListener, constant.source);
DartObjectImpl dartObject =
- defaultValue.accept(new ConstantVisitor(this, errorReporter));
+ defaultValue.accept(ConstantVisitor(this, errorReporter));
constant.evaluationResult =
- new EvaluationResultImpl(dartObject, errorListener.errors);
+ EvaluationResultImpl(dartObject, errorListener.errors);
} else {
constant.evaluationResult =
EvaluationResultImpl(typeProvider.nullObject);
@@ -184,25 +183,28 @@
} else if (constant is VariableElementImpl) {
Expression constantInitializer = constant.constantInitializer;
if (constantInitializer != null) {
- RecordingErrorListener errorListener = new RecordingErrorListener();
+ RecordingErrorListener errorListener = RecordingErrorListener();
ErrorReporter errorReporter =
- new ErrorReporter(errorListener, constant.source);
- DartObjectImpl dartObject = constantInitializer
- .accept(new ConstantVisitor(this, errorReporter));
+ ErrorReporter(errorListener, constant.source);
+ DartObjectImpl dartObject =
+ constantInitializer.accept(ConstantVisitor(this, errorReporter));
// Only check the type for truly const declarations (don't check final
// fields with initializers, since their types may be generic. The type
// of the final field will be checked later, when the constructor is
// invoked).
if (dartObject != null && constant.isConst) {
if (!runtimeTypeMatch(dartObject, constant.type)) {
- errorReporter.reportErrorForElement(
+ // TODO(brianwilkerson) This should not be reported if
+ // StaticTypeWarningCode.INVALID_ASSIGNMENT has already been
+ // reported (that is, if the static types are also wrong).
+ errorReporter.reportErrorForNode(
CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
- constant,
+ constantInitializer,
[dartObject.type, constant.type]);
}
}
constant.evaluationResult =
- new EvaluationResultImpl(dartObject, errorListener.errors);
+ EvaluationResultImpl(dartObject, errorListener.errors);
}
} else if (constant is ConstructorElementImpl) {
if (constant.isConst) {
@@ -227,16 +229,15 @@
// This could happen in the event that the annotation refers to a
// non-constant. The error is detected elsewhere, so just silently
// ignore it here.
- constant.evaluationResult = new EvaluationResultImpl(null);
+ constant.evaluationResult = EvaluationResultImpl(null);
}
} else if (element is ConstructorElement &&
element.isConst &&
constNode.arguments != null) {
- RecordingErrorListener errorListener = new RecordingErrorListener();
+ RecordingErrorListener errorListener = RecordingErrorListener();
ErrorReporter errorReporter =
- new ErrorReporter(errorListener, constant.source);
- ConstantVisitor constantVisitor =
- new ConstantVisitor(this, errorReporter);
+ ErrorReporter(errorListener, constant.source);
+ ConstantVisitor constantVisitor = ConstantVisitor(this, errorReporter);
DartObjectImpl result = evaluateConstructorCall(
constNode,
constNode.arguments.arguments,
@@ -244,12 +245,12 @@
constantVisitor,
errorReporter);
constant.evaluationResult =
- new EvaluationResultImpl(result, errorListener.errors);
+ EvaluationResultImpl(result, errorListener.errors);
} else {
// This may happen for invalid code (e.g. failing to pass arguments
// to an annotation which references a const constructor). The error
// is detected elsewhere, so just silently ignore it here.
- constant.evaluationResult = new EvaluationResultImpl(null);
+ constant.evaluationResult = EvaluationResultImpl(null);
}
} else if (constant is VariableElement) {
// constant is a VariableElement but not a VariableElementImpl. This can
@@ -272,7 +273,7 @@
/// [callback].
void computeDependencies(
ConstantEvaluationTarget constant, ReferenceFinderCallback callback) {
- ReferenceFinder referenceFinder = new ReferenceFinder(callback);
+ ReferenceFinder referenceFinder = ReferenceFinder(callback);
if (constant is ConstructorElement) {
constant = (constant as ConstructorElement).declaration;
}
@@ -423,8 +424,13 @@
ErrorReporter errorReporter,
{ConstructorInvocation invocation}) {
if (!constructor.isConst) {
- errorReporter.reportErrorForNode(
- CompileTimeErrorCode.CONST_WITH_NON_CONST, node);
+ if (node is InstanceCreationExpression && node.keyword != null) {
+ errorReporter.reportErrorForToken(
+ CompileTimeErrorCode.CONST_WITH_NON_CONST, node.keyword);
+ } else {
+ errorReporter.reportErrorForNode(
+ CompileTimeErrorCode.CONST_WITH_NON_CONST, node);
+ }
return null;
}
@@ -434,18 +440,18 @@
// in this case, as well as other cases involving constant expression
// circularities (e.g. "compile-time constant expression depends on
// itself")
- return new DartObjectImpl.validWithUnknownValue(constructor.returnType);
+ return DartObjectImpl.validWithUnknownValue(constructor.returnType);
}
int argumentCount = arguments.length;
- var argumentValues = new List<DartObjectImpl>(argumentCount);
+ var argumentValues = List<DartObjectImpl>(argumentCount);
Map<String, NamedExpression> namedNodes;
Map<String, DartObjectImpl> namedValues;
for (int i = 0; i < argumentCount; i++) {
Expression argument = arguments[i];
if (argument is NamedExpression) {
- namedNodes ??= new HashMap<String, NamedExpression>();
- namedValues ??= new HashMap<String, DartObjectImpl>();
+ namedNodes ??= HashMap<String, NamedExpression>();
+ namedValues ??= HashMap<String, DartObjectImpl>();
String name = argument.name.label.name;
namedNodes[name] = argument;
namedValues[name] = constantVisitor._valueOf(argument.expression);
@@ -458,7 +464,7 @@
namedValues ??= const {};
if (invocation == null) {
- invocation = new ConstructorInvocation(
+ invocation = ConstructorInvocation(
constructor,
argumentValues,
namedValues,
@@ -486,7 +492,7 @@
_declaredVariables.getBool(typeProvider, variableName);
return computeValueFromEnvironment(
valueFromEnvironment,
- new DartObjectImpl(typeProvider.boolType, BoolState.FALSE_STATE),
+ DartObjectImpl(typeProvider.boolType, BoolState.FALSE_STATE),
namedValues);
} else if (definingClass == typeProvider.intType) {
DartObject valueFromEnvironment;
@@ -494,7 +500,7 @@
_declaredVariables.getInt(typeProvider, variableName);
return computeValueFromEnvironment(
valueFromEnvironment,
- new DartObjectImpl(typeProvider.nullType, NullState.NULL_STATE),
+ DartObjectImpl(typeProvider.nullType, NullState.NULL_STATE),
namedValues);
} else if (definingClass == typeProvider.stringType) {
DartObject valueFromEnvironment;
@@ -502,7 +508,7 @@
_declaredVariables.getString(typeProvider, variableName);
return computeValueFromEnvironment(
valueFromEnvironment,
- new DartObjectImpl(typeProvider.nullType, NullState.NULL_STATE),
+ DartObjectImpl(typeProvider.nullType, NullState.NULL_STATE),
namedValues);
}
} else if (constructor.name == "" &&
@@ -514,8 +520,7 @@
return null;
}
String argumentValue = argumentValues[0].toStringValue();
- return new DartObjectImpl(
- definingClass, new SymbolState(argumentValue));
+ return DartObjectImpl(definingClass, SymbolState(argumentValue));
}
// Either it's an external const factory constructor that we can't
// emulate, or an error occurred (a cycle, or a const constructor trying
@@ -523,7 +528,7 @@
// In the former case, the best we can do is consider it an unknown value.
// In the latter case, the error has already been reported, so considering
// it an unknown value will suppress further errors.
- return new DartObjectImpl.validWithUnknownValue(definingClass);
+ return DartObjectImpl.validWithUnknownValue(definingClass);
}
ConstructorElementImpl constructorBase = constructor.declaration;
validator.beforeGetConstantInitializers(constructorBase);
@@ -535,19 +540,19 @@
// const instance using a non-const constructor, or the node we're
// visiting is involved in a cycle). The error has already been reported,
// so consider it an unknown value to suppress further errors.
- return new DartObjectImpl.validWithUnknownValue(definingClass);
+ return DartObjectImpl.validWithUnknownValue(definingClass);
}
- var fieldMap = new HashMap<String, DartObjectImpl>();
+ var fieldMap = HashMap<String, DartObjectImpl>();
// The errors reported while computing values for field initializers, or
// default values for the constructor parameters, cannot be reported
// into the current ErrorReporter, because they usually happen in a
// different source. But they still should cause a constant evaluation
// error for the current node.
- var externalErrorListener = new BooleanErrorListener();
+ var externalErrorListener = BooleanErrorListener();
var externalErrorReporter =
- new ErrorReporter(externalErrorListener, constructor.source);
+ ErrorReporter(externalErrorListener, constructor.source);
// Start with final fields that are initialized at their declaration site.
List<FieldElement> fields = constructor.enclosingElement.fields;
@@ -581,7 +586,7 @@
}
// Now evaluate the constructor declaration.
Map<String, DartObjectImpl> parameterMap =
- new HashMap<String, DartObjectImpl>();
+ HashMap<String, DartObjectImpl>();
List<ParameterElement> parameters = constructor.parameters;
int parameterCount = parameters.length;
@@ -652,7 +657,7 @@
parameterMap[name] = argumentValue;
}
}
- ConstantVisitor initializerVisitor = new ConstantVisitor(
+ ConstantVisitor initializerVisitor = ConstantVisitor(
this, externalErrorReporter,
lexicalEnvironment: parameterMap);
String superName;
@@ -746,8 +751,8 @@
errorReporter.reportErrorForNode(
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, node);
}
- return new DartObjectImpl(
- definingClass, new GenericState(fieldMap, invocation: invocation));
+ return DartObjectImpl(
+ definingClass, GenericState(fieldMap, invocation: invocation));
}
void evaluateSuperConstructorCall(
@@ -775,7 +780,7 @@
ConstructorElement followConstantRedirectionChain(
ConstructorElement constructor) {
HashSet<ConstructorElement> constructorsVisited =
- new HashSet<ConstructorElement>();
+ HashSet<ConstructorElement>();
while (true) {
ConstructorElement redirectedConstructor =
getConstRedirectedConstructor(constructor);
@@ -805,16 +810,16 @@
void generateCycleError(Iterable<ConstantEvaluationTarget> cycle,
ConstantEvaluationTarget constant) {
if (constant is VariableElement) {
- RecordingErrorListener errorListener = new RecordingErrorListener();
+ RecordingErrorListener errorListener = RecordingErrorListener();
ErrorReporter errorReporter =
- new ErrorReporter(errorListener, constant.source);
+ ErrorReporter(errorListener, constant.source);
// TODO(paulberry): It would be really nice if we could extract enough
// information from the 'cycle' argument to provide the user with a
// description of the cycle.
errorReporter.reportErrorForElement(
CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT, constant, []);
(constant as VariableElementImpl).evaluationResult =
- new EvaluationResultImpl(null, errorListener.errors);
+ EvaluationResultImpl(null, errorListener.errors);
} else if (constant is ConstructorElement) {
// We don't report cycle errors on constructor declarations since there
// is nowhere to put the error information.
@@ -960,7 +965,7 @@
{Map<String, DartObjectImpl> lexicalEnvironment})
: _lexicalEnvironment = lexicalEnvironment {
this._dartObjectComputer =
- new DartObjectComputer(_errorReporter, evaluationEngine);
+ DartObjectComputer(_errorReporter, evaluationEngine);
}
/// Return the object representing the state of active experiments.
@@ -1075,7 +1080,7 @@
@override
DartObjectImpl visitBooleanLiteral(BooleanLiteral node) =>
- new DartObjectImpl(_typeProvider.boolType, BoolState.from(node.value));
+ DartObjectImpl(_typeProvider.boolType, BoolState.from(node.value));
@override
DartObjectImpl visitConditionalExpression(ConditionalExpression node) {
@@ -1132,13 +1137,13 @@
}
ParameterizedType thenType = thenResult.type;
ParameterizedType elseType = elseResult.type;
- return new DartObjectImpl.validWithUnknownValue(
+ return DartObjectImpl.validWithUnknownValue(
typeSystem.leastUpperBound(thenType, elseType) as ParameterizedType);
}
@override
DartObjectImpl visitDoubleLiteral(DoubleLiteral node) =>
- new DartObjectImpl(_typeProvider.doubleType, new DoubleState(node.value));
+ DartObjectImpl(_typeProvider.doubleType, DoubleState(node.value));
@override
DartObjectImpl visitInstanceCreationExpression(
@@ -1162,10 +1167,10 @@
@override
DartObjectImpl visitIntegerLiteral(IntegerLiteral node) {
if (node.staticType == _typeProvider.doubleType) {
- return new DartObjectImpl(
- _typeProvider.doubleType, new DoubleState(node.value?.toDouble()));
+ return DartObjectImpl(
+ _typeProvider.doubleType, DoubleState(node.value?.toDouble()));
}
- return new DartObjectImpl(_typeProvider.intType, new IntState(node.value));
+ return DartObjectImpl(_typeProvider.intType, IntState(node.value));
}
@override
@@ -1180,7 +1185,7 @@
@override
DartObjectImpl visitInterpolationString(InterpolationString node) =>
- new DartObjectImpl(_typeProvider.stringType, new StringState(node.value));
+ DartObjectImpl(_typeProvider.stringType, StringState(node.value));
@override
DartObjectImpl visitIsExpression(IsExpression node) {
@@ -1215,7 +1220,7 @@
? nodeType.typeArguments[0]
: _typeProvider.dynamicType;
InterfaceType listType = _typeProvider.listType2(elementType);
- return new DartObjectImpl(listType, new ListState(list));
+ return DartObjectImpl(listType, ListState(list));
}
@override
@@ -1351,7 +1356,7 @@
}
}
InterfaceType mapType = _typeProvider.mapType2(keyType, valueType);
- return new DartObjectImpl(mapType, new MapState(map));
+ return DartObjectImpl(mapType, MapState(map));
} else {
if (!node.isConst) {
_errorReporter.reportErrorForNode(
@@ -1359,7 +1364,7 @@
return null;
}
bool errorOccurred = false;
- Set<DartObjectImpl> set = new Set<DartObjectImpl>();
+ Set<DartObjectImpl> set = Set<DartObjectImpl>();
for (CollectionElement element in node.elements) {
errorOccurred = errorOccurred | _addElementsToSet(set, element);
}
@@ -1372,7 +1377,7 @@
? nodeType.typeArguments[0]
: _typeProvider.dynamicType;
InterfaceType setType = _typeProvider.setType2(elementType);
- return new DartObjectImpl(setType, new SetState(set));
+ return DartObjectImpl(setType, SetState(set));
}
}
@@ -1387,7 +1392,7 @@
@override
DartObjectImpl visitSimpleStringLiteral(SimpleStringLiteral node) =>
- new DartObjectImpl(_typeProvider.stringType, new StringState(node.value));
+ DartObjectImpl(_typeProvider.stringType, StringState(node.value));
@override
DartObjectImpl visitStringInterpolation(StringInterpolation node) {
@@ -1407,7 +1412,7 @@
@override
DartObjectImpl visitSymbolLiteral(SymbolLiteral node) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
List<Token> components = node.components;
for (int i = 0; i < components.length; i++) {
if (i > 0) {
@@ -1415,8 +1420,8 @@
}
buffer.write(components[i].lexeme);
}
- return new DartObjectImpl(
- _typeProvider.symbolType, new SymbolState(buffer.toString()));
+ return DartObjectImpl(
+ _typeProvider.symbolType, SymbolState(buffer.toString()));
}
@override
@@ -2059,13 +2064,13 @@
Expression node, EvaluationResultImpl evaluationResult) {
if (evaluationResult.value != null) {
try {
- return new EvaluationResultImpl(
+ return EvaluationResultImpl(
evaluationResult.value.stringLength(_typeProvider));
} on EvaluationException catch (exception) {
_errorReporter.reportErrorForNode(exception.errorCode, node);
}
}
- return new EvaluationResultImpl(null);
+ return EvaluationResultImpl(null);
}
DartObjectImpl times(BinaryExpression node, DartObjectImpl leftOperand,
@@ -2128,13 +2133,13 @@
/// expression that is not a compile-time constant because of the given
/// [errors].
static EvaluationResult forErrors(List<AnalysisError> errors) =>
- new EvaluationResult(null, errors);
+ EvaluationResult(null, errors);
/// Return an evaluation result representing the result of evaluating an
/// expression that is a compile-time constant that evaluates to the given
/// [value].
static EvaluationResult forValue(DartObject value) =>
- new EvaluationResult(value, null);
+ EvaluationResult(value, null);
}
/// The result of attempting to evaluate a expression.
diff --git a/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart b/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart
index 65e2023..ba05758 100644
--- a/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart
+++ b/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart
@@ -9,7 +9,7 @@
/// Some [ConstructorElement]s can be temporary marked as "const" to check
/// if doing this is valid.
-final temporaryConstConstructorElements = new Expando<bool>();
+final temporaryConstConstructorElements = Expando<bool>();
/// Check if the [node] and all its sub-nodes are potentially constant.
///
diff --git a/pkg/analyzer/lib/src/dart/constant/utilities.dart b/pkg/analyzer/lib/src/dart/constant/utilities.dart
index fc81e96..8d681ae 100644
--- a/pkg/analyzer/lib/src/dart/constant/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/constant/utilities.dart
@@ -49,9 +49,9 @@
super.visitInstanceCreationExpression(node);
if (node.keyword == null) {
if (node.isConst) {
- expression.keyword = new KeywordToken(Keyword.CONST, node.offset);
+ expression.keyword = KeywordToken(Keyword.CONST, node.offset);
} else {
- expression.keyword = new KeywordToken(Keyword.NEW, node.offset);
+ expression.keyword = KeywordToken(Keyword.NEW, node.offset);
}
}
expression.staticElement = node.staticElement;
@@ -70,7 +70,7 @@
ListLiteral literal = super.visitListLiteral(node);
literal.staticType = node.staticType;
if (node.constKeyword == null && node.isConst) {
- literal.constKeyword = new KeywordToken(Keyword.CONST, node.offset);
+ literal.constKeyword = KeywordToken(Keyword.CONST, node.offset);
}
return literal;
}
@@ -103,7 +103,7 @@
SetOrMapLiteral literal = super.visitSetOrMapLiteral(node);
literal.staticType = node.staticType;
if (node.constKeyword == null && node.isConst) {
- literal.constKeyword = new KeywordToken(Keyword.CONST, node.offset);
+ literal.constKeyword = KeywordToken(Keyword.CONST, node.offset);
}
return literal;
}
@@ -140,7 +140,7 @@
class ConstantExpressionsDependenciesFinder extends RecursiveAstVisitor {
/// The constants whose values need to be computed.
HashSet<ConstantEvaluationTarget> dependencies =
- new HashSet<ConstantEvaluationTarget>();
+ HashSet<ConstantEvaluationTarget>();
@override
void visitInstanceCreationExpression(InstanceCreationExpression node) {
@@ -191,7 +191,7 @@
/// of [CollectionElement]).
void _find(CollectionElement node) {
if (node != null) {
- ReferenceFinder referenceFinder = new ReferenceFinder(dependencies.add);
+ ReferenceFinder referenceFinder = ReferenceFinder(dependencies.add);
node.accept(referenceFinder);
}
}
diff --git a/pkg/analyzer/lib/src/dart/constant/value.dart b/pkg/analyzer/lib/src/dart/constant/value.dart
index c3bbde2..d2b1fea 100644
--- a/pkg/analyzer/lib/src/dart/constant/value.dart
+++ b/pkg/analyzer/lib/src/dart/constant/value.dart
@@ -17,13 +17,13 @@
/// The state of an object representing a boolean value.
class BoolState extends InstanceState {
/// An instance representing the boolean value 'false'.
- static BoolState FALSE_STATE = new BoolState(false);
+ static BoolState FALSE_STATE = BoolState(false);
/// An instance representing the boolean value 'true'.
- static BoolState TRUE_STATE = new BoolState(true);
+ static BoolState TRUE_STATE = BoolState(true);
/// A state that can be used to represent a boolean whose value is not known.
- static BoolState UNKNOWN_VALUE = new BoolState(null);
+ static BoolState UNKNOWN_VALUE = BoolState(null);
/// The value of this instance.
final bool value;
@@ -58,7 +58,7 @@
if (value == null) {
return StringState.UNKNOWN_VALUE;
}
- return new StringState(value ? "true" : "false");
+ return StringState(value ? "true" : "false");
}
@override
@@ -166,16 +166,16 @@
if (type.element.library.isDartCore) {
String typeName = type.name;
if (typeName == "bool") {
- return new DartObjectImpl(type, BoolState.UNKNOWN_VALUE);
+ return DartObjectImpl(type, BoolState.UNKNOWN_VALUE);
} else if (typeName == "double") {
- return new DartObjectImpl(type, DoubleState.UNKNOWN_VALUE);
+ return DartObjectImpl(type, DoubleState.UNKNOWN_VALUE);
} else if (typeName == "int") {
- return new DartObjectImpl(type, IntState.UNKNOWN_VALUE);
+ return DartObjectImpl(type, IntState.UNKNOWN_VALUE);
} else if (typeName == "String") {
- return new DartObjectImpl(type, StringState.UNKNOWN_VALUE);
+ return DartObjectImpl(type, StringState.UNKNOWN_VALUE);
}
}
- return new DartObjectImpl(type, GenericState.UNKNOWN_VALUE);
+ return DartObjectImpl(type, GenericState.UNKNOWN_VALUE);
}
Map<String, DartObjectImpl> get fields => _state.fields;
@@ -224,14 +224,14 @@
DartObjectImpl add(TypeProvider typeProvider, DartObjectImpl rightOperand) {
InstanceState result = _state.add(rightOperand._state);
if (result is IntState) {
- return new DartObjectImpl(typeProvider.intType, result);
+ return DartObjectImpl(typeProvider.intType, result);
} else if (result is DoubleState) {
- return new DartObjectImpl(typeProvider.doubleType, result);
+ return DartObjectImpl(typeProvider.doubleType, result);
} else if (result is StringState) {
- return new DartObjectImpl(typeProvider.stringType, result);
+ return DartObjectImpl(typeProvider.stringType, result);
}
// We should never get here.
- throw new StateError("add returned a ${result.runtimeType}");
+ throw StateError("add returned a ${result.runtimeType}");
}
/// Return the result of invoking the '~' operator on this object. The
@@ -240,7 +240,7 @@
/// Throws an [EvaluationException] if the operator is not appropriate for an
/// object of this kind.
DartObjectImpl bitNot(TypeProvider typeProvider) =>
- new DartObjectImpl(typeProvider.intType, _state.bitNot());
+ DartObjectImpl(typeProvider.intType, _state.bitNot());
/// Return the result of casting this object to the given [castType].
DartObjectImpl castToType(TypeProvider typeProvider, TypeSystem typeSystem,
@@ -250,7 +250,7 @@
return this;
}
if (!typeSystem.isSubtypeOf(type, (castType._state as TypeState)._type)) {
- throw new EvaluationException(
+ throw EvaluationException(
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
return this;
@@ -264,7 +264,7 @@
/// object of this kind.
DartObjectImpl concatenate(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
- new DartObjectImpl(
+ DartObjectImpl(
typeProvider.stringType, _state.concatenate(rightOperand._state));
/// Return the result of applying boolean conversion to this object. The
@@ -277,7 +277,7 @@
if (identical(type, boolType)) {
return this;
}
- return new DartObjectImpl(boolType, _state.convertToBool());
+ return DartObjectImpl(boolType, _state.convertToBool());
}
/// Return the result of invoking the '/' operator on this object with the
@@ -290,12 +290,12 @@
TypeProvider typeProvider, DartObjectImpl rightOperand) {
InstanceState result = _state.divide(rightOperand._state);
if (result is IntState) {
- return new DartObjectImpl(typeProvider.intType, result);
+ return DartObjectImpl(typeProvider.intType, result);
} else if (result is DoubleState) {
- return new DartObjectImpl(typeProvider.doubleType, result);
+ return DartObjectImpl(typeProvider.doubleType, result);
}
// We should never get here.
- throw new StateError("divide returned a ${result.runtimeType}");
+ throw StateError("divide returned a ${result.runtimeType}");
}
/// Return the result of invoking the '&' operator on this object with the
@@ -307,14 +307,13 @@
DartObjectImpl eagerAnd(
TypeProvider typeProvider, DartObjectImpl rightOperand, bool allowBool) {
if (allowBool && isBool && rightOperand.isBool) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.boolType, _state.logicalAnd(rightOperand._state));
} else if (isInt && rightOperand.isInt) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.intType, _state.bitAnd(rightOperand._state));
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT);
}
/// Return the result of invoking the '|' operator on this object with the
@@ -326,14 +325,13 @@
DartObjectImpl eagerOr(
TypeProvider typeProvider, DartObjectImpl rightOperand, bool allowBool) {
if (allowBool && isBool && rightOperand.isBool) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.boolType, _state.logicalOr(rightOperand._state));
} else if (isInt && rightOperand.isInt) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.intType, _state.bitOr(rightOperand._state));
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT);
}
/// Return the result of invoking the '^' operator on this object with the
@@ -345,14 +343,13 @@
DartObjectImpl eagerXor(
TypeProvider typeProvider, DartObjectImpl rightOperand, bool allowBool) {
if (allowBool && isBool && rightOperand.isBool) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.boolType, _state.logicalXor(rightOperand._state));
} else if (isInt && rightOperand.isInt) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.intType, _state.bitXor(rightOperand._state));
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT);
}
/// Return the result of invoking the '==' operator on this object with the
@@ -364,17 +361,17 @@
DartObjectImpl equalEqual(
TypeProvider typeProvider, DartObjectImpl rightOperand) {
if (isNull || rightOperand.isNull) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.boolType,
isNull && rightOperand.isNull
? BoolState.TRUE_STATE
: BoolState.FALSE_STATE);
}
if (isBoolNumStringOrNull) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.boolType, _state.equalEqual(rightOperand._state));
}
- throw new EvaluationException(
+ throw EvaluationException(
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING);
}
@@ -405,7 +402,7 @@
/// object of this kind.
DartObjectImpl greaterThan(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
- new DartObjectImpl(
+ DartObjectImpl(
typeProvider.boolType, _state.greaterThan(rightOperand._state));
/// Return the result of invoking the '>=' operator on this object with the
@@ -416,7 +413,7 @@
/// object of this kind.
DartObjectImpl greaterThanOrEqual(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
- new DartObjectImpl(typeProvider.boolType,
+ DartObjectImpl(typeProvider.boolType,
_state.greaterThanOrEqual(rightOperand._state));
/// Return the result of testing whether this object has the given
@@ -437,7 +434,7 @@
} else {
state = BoolState.from(typeSystem.isSubtypeOf(type, typeType));
}
- return new DartObjectImpl(typeProvider.boolType, state);
+ return DartObjectImpl(typeProvider.boolType, state);
}
/// Return the result of invoking the '~/' operator on this object with the
@@ -448,7 +445,7 @@
/// object of this kind.
DartObjectImpl integerDivide(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
- new DartObjectImpl(
+ DartObjectImpl(
typeProvider.intType, _state.integerDivide(rightOperand._state));
/// Indicates whether `this` is equal to [other], ignoring types both in this
@@ -471,7 +468,7 @@
/// known types.
DartObjectImpl isIdentical(
TypeProvider typeProvider, DartObjectImpl rightOperand) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.boolType, _state.isIdentical(rightOperand._state));
}
@@ -483,7 +480,7 @@
/// object of this kind.
DartObjectImpl lazyAnd(
TypeProvider typeProvider, DartObjectImpl rightOperandComputer()) =>
- new DartObjectImpl(typeProvider.boolType,
+ DartObjectImpl(typeProvider.boolType,
_state.lazyAnd(() => rightOperandComputer()?._state));
/// Return the result of invoking the '==' operator on this object with the
@@ -495,17 +492,17 @@
DartObjectImpl lazyEqualEqual(
TypeProvider typeProvider, DartObjectImpl rightOperand) {
if (isNull || rightOperand.isNull) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.boolType,
isNull && rightOperand.isNull
? BoolState.TRUE_STATE
: BoolState.FALSE_STATE);
}
if (isBoolNumStringOrNull) {
- return new DartObjectImpl(
+ return DartObjectImpl(
typeProvider.boolType, _state.lazyEqualEqual(rightOperand._state));
}
- throw new EvaluationException(
+ throw EvaluationException(
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING);
}
@@ -517,7 +514,7 @@
/// object of this kind.
DartObjectImpl lazyOr(
TypeProvider typeProvider, DartObjectImpl rightOperandComputer()) =>
- new DartObjectImpl(typeProvider.boolType,
+ DartObjectImpl(typeProvider.boolType,
_state.lazyOr(() => rightOperandComputer()?._state));
/// Return the result of invoking the '<' operator on this object with the
@@ -528,7 +525,7 @@
/// object of this kind.
DartObjectImpl lessThan(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
- new DartObjectImpl(
+ DartObjectImpl(
typeProvider.boolType, _state.lessThan(rightOperand._state));
/// Return the result of invoking the '<=' operator on this object with the
@@ -539,7 +536,7 @@
/// object of this kind.
DartObjectImpl lessThanOrEqual(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
- new DartObjectImpl(
+ DartObjectImpl(
typeProvider.boolType, _state.lessThanOrEqual(rightOperand._state));
/// Return the result of invoking the '!' operator on this object. The
@@ -548,7 +545,7 @@
/// Throws an [EvaluationException] if the operator is not appropriate for an
/// object of this kind.
DartObjectImpl logicalNot(TypeProvider typeProvider) =>
- new DartObjectImpl(typeProvider.boolType, _state.logicalNot());
+ DartObjectImpl(typeProvider.boolType, _state.logicalNot());
/// Return the result of invoking the '>>>' operator on this object
/// with the [rightOperand]. The [typeProvider] is the type provider used to
@@ -558,7 +555,7 @@
/// object of this kind.
DartObjectImpl logicalShiftRight(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
- new DartObjectImpl(
+ DartObjectImpl(
typeProvider.intType, _state.logicalShiftRight(rightOperand._state));
/// Return the result of invoking the '-' operator on this object with the
@@ -570,12 +567,12 @@
DartObjectImpl minus(TypeProvider typeProvider, DartObjectImpl rightOperand) {
InstanceState result = _state.minus(rightOperand._state);
if (result is IntState) {
- return new DartObjectImpl(typeProvider.intType, result);
+ return DartObjectImpl(typeProvider.intType, result);
} else if (result is DoubleState) {
- return new DartObjectImpl(typeProvider.doubleType, result);
+ return DartObjectImpl(typeProvider.doubleType, result);
}
// We should never get here.
- throw new StateError("minus returned a ${result.runtimeType}");
+ throw StateError("minus returned a ${result.runtimeType}");
}
/// Return the result of invoking the '-' operator on this object. The
@@ -586,12 +583,12 @@
DartObjectImpl negated(TypeProvider typeProvider) {
InstanceState result = _state.negated();
if (result is IntState) {
- return new DartObjectImpl(typeProvider.intType, result);
+ return DartObjectImpl(typeProvider.intType, result);
} else if (result is DoubleState) {
- return new DartObjectImpl(typeProvider.doubleType, result);
+ return DartObjectImpl(typeProvider.doubleType, result);
}
// We should never get here.
- throw new StateError("negated returned a ${result.runtimeType}");
+ throw StateError("negated returned a ${result.runtimeType}");
}
/// Return the result of invoking the '!=' operator on this object with the
@@ -615,7 +612,7 @@
if (identical(type, stringType)) {
return this;
}
- return new DartObjectImpl(stringType, _state.convertToString());
+ return DartObjectImpl(stringType, _state.convertToString());
}
/// Return the result of invoking the '%' operator on this object with the
@@ -628,12 +625,12 @@
TypeProvider typeProvider, DartObjectImpl rightOperand) {
InstanceState result = _state.remainder(rightOperand._state);
if (result is IntState) {
- return new DartObjectImpl(typeProvider.intType, result);
+ return DartObjectImpl(typeProvider.intType, result);
} else if (result is DoubleState) {
- return new DartObjectImpl(typeProvider.doubleType, result);
+ return DartObjectImpl(typeProvider.doubleType, result);
}
// We should never get here.
- throw new StateError("remainder returned a ${result.runtimeType}");
+ throw StateError("remainder returned a ${result.runtimeType}");
}
/// Return the result of invoking the '<<' operator on this object with
@@ -644,7 +641,7 @@
/// object of this kind.
DartObjectImpl shiftLeft(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
- new DartObjectImpl(
+ DartObjectImpl(
typeProvider.intType, _state.shiftLeft(rightOperand._state));
/// Return the result of invoking the '>>' operator on this object with
@@ -655,7 +652,7 @@
/// object of this kind.
DartObjectImpl shiftRight(
TypeProvider typeProvider, DartObjectImpl rightOperand) =>
- new DartObjectImpl(
+ DartObjectImpl(
typeProvider.intType, _state.shiftRight(rightOperand._state));
/// Return the result of invoking the 'length' getter on this object. The
@@ -664,7 +661,7 @@
/// Throws an [EvaluationException] if the operator is not appropriate for an
/// object of this kind.
DartObjectImpl stringLength(TypeProvider typeProvider) =>
- new DartObjectImpl(typeProvider.intType, _state.stringLength());
+ DartObjectImpl(typeProvider.intType, _state.stringLength());
/// Return the result of invoking the '*' operator on this object with the
/// [rightOperand]. The [typeProvider] is the type provider used to find known
@@ -675,12 +672,12 @@
DartObjectImpl times(TypeProvider typeProvider, DartObjectImpl rightOperand) {
InstanceState result = _state.times(rightOperand._state);
if (result is IntState) {
- return new DartObjectImpl(typeProvider.intType, result);
+ return DartObjectImpl(typeProvider.intType, result);
} else if (result is DoubleState) {
- return new DartObjectImpl(typeProvider.doubleType, result);
+ return DartObjectImpl(typeProvider.doubleType, result);
}
// We should never get here.
- throw new StateError("times returned a ${result.runtimeType}");
+ throw StateError("times returned a ${result.runtimeType}");
}
@override
@@ -777,7 +774,7 @@
/// value.
void _assertType(DartObjectImpl object) {
if (object._state is! TypeState) {
- throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_TYPE);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_TYPE);
}
}
}
@@ -785,7 +782,7 @@
/// The state of an object representing a double.
class DoubleState extends NumState {
/// A state that can be used to represent a double whose value is not known.
- static DoubleState UNKNOWN_VALUE = new DoubleState(null);
+ static DoubleState UNKNOWN_VALUE = DoubleState(null);
/// The value of this instance.
final double value;
@@ -818,16 +815,15 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(value + rightValue.toDouble());
+ return DoubleState(value + rightValue.toDouble());
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(value + rightValue);
+ return DoubleState(value + rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -835,7 +831,7 @@
if (value == null) {
return StringState.UNKNOWN_VALUE;
}
- return new StringState(value.toString());
+ return StringState(value.toString());
}
@override
@@ -849,16 +845,15 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(value / rightValue.toDouble());
+ return DoubleState(value / rightValue.toDouble());
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(value / rightValue);
+ return DoubleState(value / rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -880,8 +875,7 @@
}
return BoolState.from(value > rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -903,8 +897,7 @@
}
return BoolState.from(value >= rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -919,17 +912,16 @@
return IntState.UNKNOWN_VALUE;
}
double result = value / rightValue.toDouble();
- return new IntState(result.toInt());
+ return IntState(result.toInt());
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return IntState.UNKNOWN_VALUE;
}
double result = value / rightValue;
- return new IntState(result.toInt());
+ return IntState(result.toInt());
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -977,8 +969,7 @@
}
return BoolState.from(value < rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1000,8 +991,7 @@
}
return BoolState.from(value <= rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1015,16 +1005,15 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(value - rightValue.toDouble());
+ return DoubleState(value - rightValue.toDouble());
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(value - rightValue);
+ return DoubleState(value - rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1032,7 +1021,7 @@
if (value == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(-(value));
+ return DoubleState(-(value));
}
@override
@@ -1046,16 +1035,15 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(value % rightValue.toDouble());
+ return DoubleState(value % rightValue.toDouble());
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(value % rightValue);
+ return DoubleState(value % rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1069,16 +1057,15 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(value * rightValue.toDouble());
+ return DoubleState(value * rightValue.toDouble());
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new DoubleState(value * rightValue);
+ return DoubleState(value * rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1118,7 +1105,7 @@
if (_element == null) {
return StringState.UNKNOWN_VALUE;
}
- return new StringState(_element.name);
+ return StringState(_element.name);
}
@override
@@ -1158,7 +1145,7 @@
/// A state that can be used to represent an object whose state is not known.
static GenericState UNKNOWN_VALUE =
- new GenericState(new HashMap<String, DartObjectImpl>());
+ GenericState(HashMap<String, DartObjectImpl>());
/// The values of the fields of this instance.
final Map<String, DartObjectImpl> _fieldMap;
@@ -1192,7 +1179,7 @@
bool operator ==(Object object) {
if (object is GenericState) {
HashSet<String> otherFields =
- new HashSet<String>.from(object._fieldMap.keys.toSet());
+ HashSet<String>.from(object._fieldMap.keys.toSet());
for (String fieldName in _fieldMap.keys.toSet()) {
if (_fieldMap[fieldName] != object._fieldMap[fieldName]) {
return false;
@@ -1230,7 +1217,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
List<String> fieldNames = _fieldMap.keys.toList();
fieldNames.sort();
bool first = true;
@@ -1284,14 +1271,13 @@
}
assertNumOrNull(this);
assertNumOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Throw an exception if the given [state] does not represent a boolean value.
void assertBool(InstanceState state) {
if (state is! BoolState) {
- throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL);
}
}
@@ -1302,7 +1288,7 @@
state is NumState ||
state is StringState ||
state is NullState)) {
- throw new EvaluationException(
+ throw EvaluationException(
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING);
}
}
@@ -1311,7 +1297,7 @@
/// null value.
void assertIntOrNull(InstanceState state) {
if (!(state is IntState || state is NullState)) {
- throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_INT);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_INT);
}
}
@@ -1319,14 +1305,14 @@
/// numeric, string or null value.
void assertNumOrNull(InstanceState state) {
if (!(state is NumState || state is NullState)) {
- throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_NUM);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_NUM);
}
}
/// Throw an exception if the given [state] does not represent a String value.
void assertString(InstanceState state) {
if (state is! StringState) {
- throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL);
}
}
@@ -1338,8 +1324,7 @@
IntState bitAnd(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '~' operator on this object.
@@ -1348,8 +1333,7 @@
/// object of this kind.
IntState bitNot() {
assertIntOrNull(this);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '|' operator on this object with the
@@ -1360,8 +1344,7 @@
IntState bitOr(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '^' operator on this object with the
@@ -1372,8 +1355,7 @@
IntState bitXor(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the ' ' operator on this object with the
@@ -1383,8 +1365,7 @@
/// object of this kind.
StringState concatenate(InstanceState rightOperand) {
assertString(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of applying boolean conversion to this object.
@@ -1407,8 +1388,7 @@
NumState divide(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '==' operator on this object with the
@@ -1426,8 +1406,7 @@
BoolState greaterThan(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '>=' operator on this object with the
@@ -1438,8 +1417,7 @@
BoolState greaterThanOrEqual(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '~/' operator on this object with the
@@ -1450,8 +1428,7 @@
IntState integerDivide(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the identical function on this object with
@@ -1503,8 +1480,7 @@
BoolState lessThan(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '<=' operator on this object with the
@@ -1515,8 +1491,7 @@
BoolState lessThanOrEqual(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '&' operator on this object with the
@@ -1568,8 +1543,7 @@
IntState logicalShiftRight(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '^' operator on this object with the
@@ -1596,8 +1570,7 @@
NumState minus(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '-' operator on this object.
@@ -1606,8 +1579,7 @@
/// object of this kind.
NumState negated() {
assertNumOrNull(this);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '%' operator on this object with the
@@ -1618,8 +1590,7 @@
NumState remainder(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '<<' operator on this object with
@@ -1630,8 +1601,7 @@
IntState shiftLeft(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '>>' operator on this object with
@@ -1642,8 +1612,7 @@
IntState shiftRight(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the 'length' getter on this object.
@@ -1652,8 +1621,7 @@
/// object of this kind.
IntState stringLength() {
assertString(this);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
/// Return the result of invoking the '*' operator on this object with the
@@ -1664,15 +1632,14 @@
NumState times(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
}
/// The state of an object representing an int.
class IntState extends NumState {
/// A state that can be used to represent an int whose value is not known.
- static IntState UNKNOWN_VALUE = new IntState(null);
+ static IntState UNKNOWN_VALUE = IntState(null);
/// The value of this instance.
final int value;
@@ -1711,16 +1678,15 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new IntState(value + rightValue);
+ return IntState(value + rightValue);
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return DoubleState.UNKNOWN_VALUE;
}
- return new DoubleState(value.toDouble() + rightValue);
+ return DoubleState(value.toDouble() + rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1734,10 +1700,9 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new IntState(value & rightValue);
+ return IntState(value & rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1745,7 +1710,7 @@
if (value == null) {
return UNKNOWN_VALUE;
}
- return new IntState(~value);
+ return IntState(~value);
}
@override
@@ -1759,10 +1724,9 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new IntState(value | rightValue);
+ return IntState(value | rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1776,10 +1740,9 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new IntState(value ^ rightValue);
+ return IntState(value ^ rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1787,7 +1750,7 @@
if (value == null) {
return StringState.UNKNOWN_VALUE;
}
- return new StringState(value.toString());
+ return StringState(value.toString());
}
@override
@@ -1801,17 +1764,16 @@
if (rightValue == null) {
return DoubleState.UNKNOWN_VALUE;
} else {
- return new DoubleState(value.toDouble() / rightValue.toDouble());
+ return DoubleState(value.toDouble() / rightValue.toDouble());
}
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return DoubleState.UNKNOWN_VALUE;
}
- return new DoubleState(value.toDouble() / rightValue);
+ return DoubleState(value.toDouble() / rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1833,8 +1795,7 @@
}
return BoolState.from(value.toDouble() > rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1856,8 +1817,7 @@
}
return BoolState.from(value.toDouble() >= rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1871,20 +1831,18 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
} else if (rightValue == 0) {
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE);
}
- return new IntState(value ~/ rightValue);
+ return IntState(value ~/ rightValue);
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return UNKNOWN_VALUE;
}
double result = value.toDouble() / rightValue;
- return new IntState(result.toInt());
+ return IntState(result.toInt());
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1932,8 +1890,7 @@
}
return BoolState.from(value.toDouble() < rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1955,8 +1912,7 @@
}
return BoolState.from(value.toDouble() <= rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -1981,13 +1937,12 @@
if (divisor == 0) {
// The `rightValue` is large enough to cause all of the non-zero bits
// in the left operand to be shifted out of the value.
- return new IntState(0);
+ return IntState(0);
}
- return new IntState(value ~/ divisor);
+ return IntState(value ~/ divisor);
}
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -2004,16 +1959,15 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new IntState(value - rightValue);
+ return IntState(value - rightValue);
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return DoubleState.UNKNOWN_VALUE;
}
- return new DoubleState(value.toDouble() - rightValue);
+ return DoubleState(value.toDouble() - rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -2021,7 +1975,7 @@
if (value == null) {
return UNKNOWN_VALUE;
}
- return new IntState(-value);
+ return IntState(-value);
}
@override
@@ -2039,17 +1993,16 @@
return UNKNOWN_VALUE;
}
if (rightValue != 0) {
- return new IntState(value % rightValue);
+ return IntState(value % rightValue);
}
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return DoubleState.UNKNOWN_VALUE;
}
- return new DoubleState(value.toDouble() % rightValue);
+ return DoubleState(value.toDouble() % rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -2066,11 +2019,10 @@
return UNKNOWN_VALUE;
}
if (rightValue >= 0) {
- return new IntState(value << rightValue);
+ return IntState(value << rightValue);
}
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -2087,11 +2039,10 @@
return UNKNOWN_VALUE;
}
if (rightValue >= 0) {
- return new IntState(value >> rightValue);
+ return IntState(value >> rightValue);
}
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -2108,16 +2059,15 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new IntState(value * rightValue);
+ return IntState(value * rightValue);
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
return DoubleState.UNKNOWN_VALUE;
}
- return new DoubleState(value.toDouble() * rightValue);
+ return DoubleState(value.toDouble() * rightValue);
}
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -2187,7 +2137,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write('[');
bool first = true;
_elements.forEach((DartObjectImpl element) {
@@ -2267,7 +2217,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write('{');
bool first = true;
_entries.forEach((DartObjectImpl key, DartObjectImpl value) {
@@ -2288,7 +2238,7 @@
/// The state of an object representing the value 'null'.
class NullState extends InstanceState {
/// An instance representing the boolean value 'null'.
- static NullState NULL_STATE = new NullState();
+ static NullState NULL_STATE = NullState();
@override
int get hashCode => 0;
@@ -2307,12 +2257,11 @@
@override
BoolState convertToBool() {
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
- StringState convertToString() => new StringState("null");
+ StringState convertToString() => StringState("null");
@override
BoolState equalEqual(InstanceState rightOperand) {
@@ -2332,8 +2281,7 @@
@override
BoolState logicalNot() {
- throw new EvaluationException(
- CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
+ throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
}
@override
@@ -2415,7 +2363,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write('{');
bool first = true;
_elements.forEach((DartObjectImpl element) {
@@ -2434,7 +2382,7 @@
/// The state of an object representing a string.
class StringState extends InstanceState {
/// A state that can be used to represent a double whose value is not known.
- static StringState UNKNOWN_VALUE = new StringState(null);
+ static StringState UNKNOWN_VALUE = StringState(null);
/// The value of this instance.
final String value;
@@ -2468,7 +2416,7 @@
if (rightValue == null) {
return UNKNOWN_VALUE;
}
- return new StringState("$value$rightValue");
+ return StringState("$value$rightValue");
}
return super.concatenate(rightOperand);
}
@@ -2507,7 +2455,7 @@
if (value == null) {
return IntState.UNKNOWN_VALUE;
}
- return new IntState(value.length);
+ return IntState(value.length);
}
@override
@@ -2537,7 +2485,7 @@
if (value == null) {
return StringState.UNKNOWN_VALUE;
}
- return new StringState(value);
+ return StringState(value);
}
@override
@@ -2593,7 +2541,7 @@
if (_type == null) {
return StringState.UNKNOWN_VALUE;
}
- return new StringState(_type.displayName);
+ return StringState(_type.displayName);
}
@override
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 3de7141..347265e 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -70,7 +70,7 @@
}
/// Set the accessors contained in this class to the given [accessors].
- void set accessors(List<PropertyAccessorElement> accessors) {
+ set accessors(List<PropertyAccessorElement> accessors) {
for (PropertyAccessorElement accessor in accessors) {
(accessor as PropertyAccessorElementImpl).enclosingElement = this;
}
@@ -84,7 +84,7 @@
List<FieldElement> get fields => _fields ?? const <FieldElement>[];
/// Set the fields contained in this class to the given [fields].
- void set fields(List<FieldElement> fields) {
+ set fields(List<FieldElement> fields) {
for (FieldElement field in fields) {
(field as FieldElementImpl).enclosingElement = this;
}
@@ -295,7 +295,7 @@
Iterable<PropertyAccessorElement> _implementationsOfGetter(
String getterName) sync* {
ClassElement classElement = this;
- HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
+ HashSet<ClassElement> visitedClasses = HashSet<ClassElement>();
while (classElement != null && visitedClasses.add(classElement)) {
PropertyAccessorElement getter = classElement.getGetter(getterName);
if (getter != null) {
@@ -325,7 +325,7 @@
Iterable<PropertyAccessorElement> _implementationsOfSetter(
String setterName) sync* {
ClassElement classElement = this;
- HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
+ HashSet<ClassElement> visitedClasses = HashSet<ClassElement>();
while (classElement != null && visitedClasses.add(classElement)) {
PropertyAccessorElement setter = classElement.getSetter(setterName);
if (setter != null) {
@@ -354,7 +354,7 @@
/// Object contains a definition of the method it will occur last.
static Iterable<MethodElement> getImplementationsOfMethod(
ClassElement classElement, String methodName) sync* {
- HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
+ HashSet<ClassElement> visitedClasses = HashSet<ClassElement>();
while (classElement != null && visitedClasses.add(classElement)) {
MethodElement method = classElement.getMethod(methodName);
if (method != null) {
@@ -473,7 +473,7 @@
@override
List<InterfaceType> get allSupertypes {
- List<InterfaceType> list = new List<InterfaceType>();
+ List<InterfaceType> list = List<InterfaceType>();
collectAllSupertypes(list, thisType, thisType);
return list;
}
@@ -531,7 +531,7 @@
}
if (_constructors.isEmpty) {
- var constructor = new ConstructorElementImpl('', -1);
+ var constructor = ConstructorElementImpl('', -1);
constructor.isSynthetic = true;
constructor.enclosingElement = this;
_constructors = <ConstructorElement>[constructor];
@@ -543,7 +543,7 @@
/// Set the constructors contained in this class to the given [constructors].
///
/// Should only be used for class elements that are not mixin applications.
- void set constructors(List<ConstructorElement> constructors) {
+ set constructors(List<ConstructorElement> constructors) {
assert(!isMixinApplication);
for (ConstructorElement constructor in constructors) {
(constructor as ConstructorElementImpl).enclosingElement = this;
@@ -585,7 +585,7 @@
return _hasBeenInferred;
}
- void set hasBeenInferred(bool hasBeenInferred) {
+ set hasBeenInferred(bool hasBeenInferred) {
if (linkedNode != null) {
return linkedContext.setOverrideInferenceDone(linkedNode);
}
@@ -594,8 +594,8 @@
@override
bool get hasNonFinalField {
- List<ClassElement> classesToVisit = new List<ClassElement>();
- HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
+ List<ClassElement> classesToVisit = List<ClassElement>();
+ HashSet<ClassElement> visitedClasses = HashSet<ClassElement>();
classesToVisit.add(this);
while (classesToVisit.isNotEmpty) {
ClassElement currentElement = classesToVisit.removeAt(0);
@@ -642,7 +642,7 @@
bool get hasReferenceToSuper => hasModifier(Modifier.REFERENCES_SUPER);
/// Set whether this class references 'super'.
- void set hasReferenceToSuper(bool isReferencedSuper) {
+ set hasReferenceToSuper(bool isReferencedSuper) {
setModifier(Modifier.REFERENCES_SUPER, isReferencedSuper);
}
@@ -683,7 +683,7 @@
return _interfaces = const <InterfaceType>[];
}
- void set interfaces(List<InterfaceType> interfaces) {
+ set interfaces(List<InterfaceType> interfaces) {
_interfaces = interfaces;
}
@@ -696,7 +696,7 @@
}
/// Set whether this class is abstract.
- void set isAbstract(bool isAbstract) {
+ set isAbstract(bool isAbstract) {
setModifier(Modifier.ABSTRACT, isAbstract);
}
@@ -713,7 +713,7 @@
@override
bool get isOrInheritsProxy =>
- _safeIsOrInheritsProxy(this, new HashSet<ClassElement>());
+ _safeIsOrInheritsProxy(this, HashSet<ClassElement>());
@override
bool get isProxy {
@@ -775,7 +775,7 @@
}
/// Set the methods contained in this class to the given [methods].
- void set methods(List<MethodElement> methods) {
+ set methods(List<MethodElement> methods) {
for (MethodElement method in methods) {
(method as MethodElementImpl).enclosingElement = this;
}
@@ -783,7 +783,7 @@
}
/// Set whether this class is a mixin application.
- void set mixinApplication(bool isMixinApplication) {
+ set mixinApplication(bool isMixinApplication) {
setModifier(Modifier.MIXIN_APPLICATION, isMixinApplication);
}
@@ -813,7 +813,7 @@
return _mixins = const <InterfaceType>[];
}
- void set mixins(List<InterfaceType> mixins) {
+ set mixins(List<InterfaceType> mixins) {
_mixins = mixins;
}
@@ -854,12 +854,12 @@
if (_isInterfaceTypeClass(type)) {
return _supertype = type;
}
- return _supertype = this.context.typeProvider.objectType;
+ return _supertype = library.typeProvider.objectType;
}
return _supertype;
}
- void set supertype(InterfaceType supertype) {
+ set supertype(InterfaceType supertype) {
_supertype = supertype;
}
@@ -877,7 +877,7 @@
/// Set the type parameters defined for this class to the given
/// [typeParameters].
- void set typeParameters(List<TypeParameterElement> typeParameters) {
+ set typeParameters(List<TypeParameterElement> typeParameters) {
for (TypeParameterElement typeParameter in typeParameters) {
(typeParameter as TypeParameterElementImpl).enclosingElement = this;
}
@@ -1023,7 +1023,7 @@
// face of errors, so drop any extra type arguments and fill in any missing
// ones with `dynamic`.
var superClassParameters = superElement.typeParameters;
- List<DartType> argumentTypes = new List<DartType>.filled(
+ List<DartType> argumentTypes = List<DartType>.filled(
superClassParameters.length, DynamicTypeImpl.instance);
for (int i = 0; i < supertype.typeArguments.length; i++) {
if (i >= argumentTypes.length) {
@@ -1039,24 +1039,23 @@
return constructorsToForward
.map((ConstructorElement superclassConstructor) {
ConstructorElementImpl implicitConstructor =
- new ConstructorElementImpl(superclassConstructor.name, -1);
+ ConstructorElementImpl(superclassConstructor.name, -1);
implicitConstructor.isSynthetic = true;
implicitConstructor.redirectedConstructor = superclassConstructor;
List<ParameterElement> superParameters = superclassConstructor.parameters;
int count = superParameters.length;
if (count > 0) {
List<ParameterElement> implicitParameters =
- new List<ParameterElement>(count);
+ List<ParameterElement>(count);
for (int i = 0; i < count; i++) {
ParameterElement superParameter = superParameters[i];
ParameterElementImpl implicitParameter;
if (superParameter is DefaultParameterElementImpl) {
implicitParameter =
- new DefaultParameterElementImpl(superParameter.name, -1)
+ DefaultParameterElementImpl(superParameter.name, -1)
..constantInitializer = superParameter.constantInitializer;
} else {
- implicitParameter =
- new ParameterElementImpl(superParameter.name, -1);
+ implicitParameter = ParameterElementImpl(superParameter.name, -1);
}
implicitParameter.isConst = superParameter.isConst;
implicitParameter.isFinal = superParameter.isFinal;
@@ -1119,7 +1118,7 @@
var fieldRef = reference.getChild('@field').getChild(name);
FieldElementImpl field = fieldRef.element;
if (field == null) {
- field = new FieldElementImpl(name, -1);
+ field = FieldElementImpl(name, -1);
fieldRef.element = field;
field.enclosingElement = this;
field.isSynthetic = true;
@@ -1187,8 +1186,8 @@
static void collectAllSupertypes(List<InterfaceType> supertypes,
InterfaceType startingType, InterfaceType excludeType) {
- List<InterfaceType> typesToVisit = new List<InterfaceType>();
- List<ClassElement> visitedClasses = new List<ClassElement>();
+ List<InterfaceType> typesToVisit = List<InterfaceType>();
+ List<ClassElement> visitedClasses = List<ClassElement>();
typesToVisit.add(startingType);
while (typesToVisit.isNotEmpty) {
InterfaceType currentType = typesToVisit.removeAt(0);
@@ -1301,7 +1300,7 @@
/// Set the top-level accessors (getters and setters) contained in this
/// compilation unit to the given [accessors].
- void set accessors(List<PropertyAccessorElement> accessors) {
+ set accessors(List<PropertyAccessorElement> accessors) {
for (PropertyAccessorElement accessor in accessors) {
(accessor as PropertyAccessorElementImpl).enclosingElement = this;
}
@@ -1354,7 +1353,7 @@
}
/// Set the enums contained in this compilation unit to the given [enums].
- void set enums(List<ClassElement> enums) {
+ set enums(List<ClassElement> enums) {
for (ClassElement enumDeclaration in enums) {
(enumDeclaration as EnumElementImpl).enclosingElement = this;
}
@@ -1391,7 +1390,7 @@
/// Set the extensions contained in this compilation unit to the given
/// [extensions].
- void set extensions(List<ExtensionElement> extensions) {
+ set extensions(List<ExtensionElement> extensions) {
for (ExtensionElement extension in extensions) {
(extension as ExtensionElementImpl).enclosingElement = this;
}
@@ -1422,7 +1421,7 @@
/// Set the top-level functions contained in this compilation unit to the
/// given[functions].
- void set functions(List<FunctionElement> functions) {
+ set functions(List<FunctionElement> functions) {
for (FunctionElement function in functions) {
(function as FunctionElementImpl).enclosingElement = this;
}
@@ -1499,7 +1498,7 @@
}
/// Set the mixins contained in this compilation unit to the given [mixins].
- void set mixins(List<ClassElement> mixins) {
+ set mixins(List<ClassElement> mixins) {
for (MixinElementImpl type in mixins) {
type.enclosingElement = this;
}
@@ -1519,7 +1518,7 @@
/// Set the top-level variables contained in this compilation unit to the
/// given[variables].
- void set topLevelVariables(List<TopLevelVariableElement> variables) {
+ set topLevelVariables(List<TopLevelVariableElement> variables) {
for (TopLevelVariableElement field in variables) {
(field as TopLevelVariableElementImpl).enclosingElement = this;
}
@@ -1528,7 +1527,7 @@
/// Set the function type aliases contained in this compilation unit to the
/// given [typeAliases].
- void set typeAliases(List<FunctionTypeAliasElement> typeAliases) {
+ set typeAliases(List<FunctionTypeAliasElement> typeAliases) {
for (FunctionTypeAliasElement typeAlias in typeAliases) {
(typeAlias as ElementImpl).enclosingElement = this;
}
@@ -1571,7 +1570,7 @@
}
/// Set the types contained in this compilation unit to the given [types].
- void set types(List<ClassElement> types) {
+ set types(List<ClassElement> types) {
for (ClassElement type in types) {
// Another implementation of ClassElement is _DeferredClassElement,
// which is used to resynthesize classes lazily. We cannot cast it
@@ -1739,7 +1738,7 @@
var fieldRef = unit.reference.getChild('@field').getChild(name);
TopLevelVariableElementImpl field = fieldRef.element;
if (field == null) {
- field = new TopLevelVariableElementImpl(name, -1);
+ field = TopLevelVariableElementImpl(name, -1);
fieldRef.element = field;
field.enclosingElement = unit;
field.isSynthetic = true;
@@ -1812,12 +1811,10 @@
EvaluationResultImpl get evaluationResult {
if (_evaluationResult == null) {
Map<String, DartObjectImpl> fieldMap = <String, DartObjectImpl>{
- name: new DartObjectImpl(
- context.typeProvider.intType, new IntState(_index))
+ name: DartObjectImpl(library.typeProvider.intType, IntState(_index))
};
- DartObjectImpl value =
- new DartObjectImpl(type, new GenericState(fieldMap));
- _evaluationResult = new EvaluationResultImpl(value);
+ DartObjectImpl value = DartObjectImpl(type, GenericState(fieldMap));
+ _evaluationResult = EvaluationResultImpl(value);
}
return _evaluationResult;
}
@@ -1858,8 +1855,8 @@
constantValues.add(field.evaluationResult.value);
}
}
- _evaluationResult = new EvaluationResultImpl(
- new DartObjectImpl(type, new ListState(constantValues)));
+ _evaluationResult =
+ EvaluationResultImpl(DartObjectImpl(type, ListState(constantValues)));
}
return _evaluationResult;
}
@@ -1870,7 +1867,7 @@
@override
InterfaceType get type {
if (_type == null) {
- return _type = context.typeProvider.listType2(_enum.thisType);
+ return _type = library.typeProvider.listType2(_enum.thisType);
}
return _type;
}
@@ -1889,7 +1886,7 @@
: super.forLinkedNode(_enum, reference, linkedNode);
@override
- void set evaluationResult(_) {
+ set evaluationResult(_) {
assert(false);
}
@@ -1897,7 +1894,7 @@
bool get isConst => true;
@override
- void set isConst(bool isConst) {
+ set isConst(bool isConst) {
assert(false);
}
@@ -1905,7 +1902,7 @@
bool get isConstantEvaluated => true;
@override
- void set isFinal(bool isFinal) {
+ set isFinal(bool isFinal) {
assert(false);
}
@@ -1913,11 +1910,11 @@
bool get isStatic => true;
@override
- void set isStatic(bool isStatic) {
+ set isStatic(bool isStatic) {
assert(false);
}
- void set type(DartType type) {
+ set type(DartType type) {
assert(false);
}
}
@@ -1978,8 +1975,7 @@
return _constantInitializers;
}
- void set constantInitializers(
- List<ConstructorInitializer> constantInitializers) {
+ set constantInitializers(List<ConstructorInitializer> constantInitializers) {
_constantInitializers = constantInitializers;
}
@@ -1999,7 +1995,7 @@
super.enclosingElement as ClassElementImpl;
/// Set whether this constructor represents a factory method.
- void set factory(bool isFactory) {
+ set factory(bool isFactory) {
setModifier(Modifier.FACTORY, isFactory);
}
@@ -2013,7 +2009,7 @@
}
/// Set whether this constructor represents a 'const' constructor.
- void set isConst(bool isConst) {
+ set isConst(bool isConst) {
setModifier(Modifier.CONST, isConst);
}
@@ -2021,7 +2017,7 @@
return _isCycleFree;
}
- void set isCycleFree(bool isCycleFree) {
+ set isCycleFree(bool isCycleFree) {
// This property is updated in ConstantEvaluationEngine even for
// resynthesized constructors, so we don't have the usual assert here.
_isCycleFree = isCycleFree;
@@ -2081,7 +2077,7 @@
return _nameEnd;
}
- void set nameEnd(int nameEnd) {
+ set nameEnd(int nameEnd) {
_nameEnd = nameEnd;
}
@@ -2095,7 +2091,7 @@
return _periodOffset;
}
- void set periodOffset(int periodOffset) {
+ set periodOffset(int periodOffset) {
_periodOffset = periodOffset;
}
@@ -2122,7 +2118,7 @@
return _redirectedConstructor;
}
- void set redirectedConstructor(ConstructorElement redirectedConstructor) {
+ set redirectedConstructor(ConstructorElement redirectedConstructor) {
_redirectedConstructor = redirectedConstructor;
}
@@ -2138,7 +2134,7 @@
);
}
- void set returnType(DartType returnType) {
+ set returnType(DartType returnType) {
assert(false);
}
@@ -2154,7 +2150,7 @@
);
}
- void set type(FunctionType type) {
+ set type(FunctionType type) {
assert(false);
}
@@ -2190,7 +2186,7 @@
void computeConstantDependencies() {
if (!isConstantEvaluated) {
AnalysisOptionsImpl analysisOptions = context.analysisOptions;
- computeConstants(context.typeProvider, context.typeSystem,
+ computeConstants(library.typeProvider, library.typeSystem,
context.declaredVariables, [this], analysisOptions.experimentStatus);
}
}
@@ -2242,13 +2238,13 @@
return _constantInitializer;
}
- void set constantInitializer(Expression constantInitializer) {
+ set constantInitializer(Expression constantInitializer) {
_constantInitializer = constantInitializer;
}
EvaluationResultImpl get evaluationResult => _evaluationResult;
- void set evaluationResult(EvaluationResultImpl evaluationResult) {
+ set evaluationResult(EvaluationResultImpl evaluationResult) {
_evaluationResult = evaluationResult;
}
@@ -2262,7 +2258,7 @@
DartObject computeConstantValue() {
if (evaluationResult == null) {
AnalysisOptionsImpl analysisOptions = context.analysisOptions;
- computeConstants(context.typeProvider, context.typeSystem,
+ computeConstants(library.typeProvider, library.typeSystem,
context.declaredVariables, [this], analysisOptions.experimentStatus);
}
return evaluationResult?.value;
@@ -2566,7 +2562,8 @@
DartObject computeConstantValue() {
if (evaluationResult == null) {
AnalysisOptionsImpl analysisOptions = context.analysisOptions;
- computeConstants(context.typeProvider, context.typeSystem,
+ LibraryElement library = compilationUnit.library;
+ computeConstants(library.typeProvider, library.typeSystem,
context.declaredVariables, [this], analysisOptions.experimentStatus);
}
return constantValue;
@@ -2669,7 +2666,7 @@
String get documentationComment => _docComment;
/// The documentation comment source for this element.
- void set documentationComment(String doc) {
+ set documentationComment(String doc) {
_docComment = doc?.replaceAll('\r\n', '\n');
}
@@ -2677,7 +2674,7 @@
Element get enclosingElement => _enclosingElement;
/// Set the enclosing element of this element to the given [element].
- void set enclosingElement(Element element) {
+ set enclosingElement(Element element) {
_enclosingElement = element as ElementImpl;
}
@@ -2914,7 +2911,7 @@
}
/// Set whether this element is synthetic.
- void set isSynthetic(bool isSynthetic) {
+ set isSynthetic(bool isSynthetic) {
setModifier(Modifier.SYNTHETIC, isSynthetic);
}
@@ -2933,9 +2930,9 @@
ElementLocation get location {
if (_cachedLocation == null) {
if (library == null) {
- return new ElementLocationImpl.con1(this);
+ return ElementLocationImpl.con1(this);
}
- _cachedLocation = new ElementLocationImpl.con1(this);
+ _cachedLocation = ElementLocationImpl.con1(this);
}
return _cachedLocation;
}
@@ -2949,7 +2946,7 @@
return _metadata ?? const <ElementAnnotation>[];
}
- void set metadata(List<ElementAnnotation> metadata) {
+ set metadata(List<ElementAnnotation> metadata) {
_metadata = metadata;
}
@@ -2957,7 +2954,7 @@
String get name => _name;
/// Changes the name of this element.
- void set name(String name) {
+ set name(String name) {
this._name = name;
}
@@ -2969,7 +2966,7 @@
/// Sets the offset of the name of this element in the file that contains the
/// declaration of this element.
- void set nameOffset(int offset) {
+ set nameOffset(int offset) {
_nameOffset = offset;
}
@@ -3092,7 +3089,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
appendTo(buffer);
return buffer.toString();
}
@@ -3110,7 +3107,7 @@
return const <ElementAnnotation>[];
}
- var annotations = new List<ElementAnnotation>(length);
+ var annotations = List<ElementAnnotation>(length);
for (int i = 0; i < length; i++) {
var ast = nodeList[i];
annotations[i] = ElementAnnotationImpl(unit)
@@ -3163,7 +3160,7 @@
/// Initialize a newly created location to represent the given [element].
ElementLocationImpl.con1(Element element) {
- List<String> components = new List<String>();
+ List<String> components = List<String>();
Element ancestor = element;
while (ancestor != null) {
components.insert(0, (ancestor as ElementImpl).identifier);
@@ -3187,7 +3184,7 @@
@override
String get encoding {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
int length = _components.length;
for (int i = 0; i < length; i++) {
if (i > 0) {
@@ -3235,8 +3232,8 @@
/// Decode the [encoding] of a location into a list of components and return
/// the components.
List<String> _decode(String encoding) {
- List<String> components = new List<String>();
- StringBuffer buffer = new StringBuffer();
+ List<String> components = List<String>();
+ StringBuffer buffer = StringBuffer();
int index = 0;
int length = encoding.length;
while (index < length) {
@@ -3248,7 +3245,7 @@
index += 2;
} else {
components.add(buffer.toString());
- buffer = new StringBuffer();
+ buffer = StringBuffer();
index++;
}
} else {
@@ -3297,7 +3294,7 @@
}
@override
- void set accessors(List<PropertyAccessorElement> accessors) {
+ set accessors(List<PropertyAccessorElement> accessors) {
super.accessors = accessors;
}
@@ -3350,7 +3347,7 @@
}
@override
- void set fields(List<FieldElement> fields) {
+ set fields(List<FieldElement> fields) {
super.fields = fields;
}
@@ -3418,7 +3415,7 @@
}
@override
- InterfaceType get supertype => context.typeProvider.objectType;
+ InterfaceType get supertype => library.typeProvider.objectType;
@override
@deprecated
@@ -3451,11 +3448,11 @@
/// Create the only method enums have - `toString()`.
void createToStringMethodElement() {
- var method = new MethodElementImpl('toString', -1);
+ var method = MethodElementImpl('toString', -1);
method.isSynthetic = true;
method.enclosingElement = this;
if (linkedNode != null) {
- method.returnType = context.typeProvider.stringType;
+ method.returnType = library.typeProvider.stringType;
method.reference = reference.getChild('@method').getChild('toString');
}
_methods = <MethodElement>[method];
@@ -3474,7 +3471,7 @@
..enclosingElement = this
..isSynthetic = true
..isFinal = true
- ..type = context.typeProvider.intType;
+ ..type = library.typeProvider.intType;
fields.add(field);
getters.add(PropertyAccessorElementImpl_ImplicitGetter(field,
reference: reference.getChild('@getter').getChild('index'))
@@ -3497,7 +3494,7 @@
var constant = constants[i];
var name = constant.name.name;
var reference = containerRef.getChild(name);
- var field = new ConstFieldElementImpl_EnumValue.forLinkedNode(
+ var field = ConstFieldElementImpl_EnumValue.forLinkedNode(
this, reference, constant, i);
fields.add(field);
getters.add(field.getter);
@@ -3534,7 +3531,7 @@
: super.forLinkedNode(enclosing, reference, linkedNode);
/// Set whether this executable element's body is asynchronous.
- void set asynchronous(bool isAsynchronous) {
+ set asynchronous(bool isAsynchronous) {
setModifier(Modifier.ASYNCHRONOUS, isAsynchronous);
}
@@ -3573,12 +3570,12 @@
}
/// Set whether this executable element is external.
- void set external(bool isExternal) {
+ set external(bool isExternal) {
setModifier(Modifier.EXTERNAL, isExternal);
}
/// Set whether this method's body is a generator.
- void set generator(bool isGenerator) {
+ set generator(bool isGenerator) {
setModifier(Modifier.GENERATOR, isGenerator);
}
@@ -3591,7 +3588,7 @@
}
/// Set whether this executable element has an implicit return type.
- void set hasImplicitReturnType(bool hasImplicitReturnType) {
+ set hasImplicitReturnType(bool hasImplicitReturnType) {
setModifier(Modifier.IMPLICIT_TYPE, hasImplicitReturnType);
}
@@ -3671,7 +3668,7 @@
/// Set the parameters defined by this executable element to the given
/// [parameters].
- void set parameters(List<ParameterElement> parameters) {
+ set parameters(List<ParameterElement> parameters) {
for (ParameterElement parameter in parameters) {
(parameter as ParameterElementImpl).enclosingElement = this;
}
@@ -3689,7 +3686,7 @@
return _returnType;
}
- void set returnType(DartType returnType) {
+ set returnType(DartType returnType) {
if (linkedNode != null) {
linkedContext.setReturnType(linkedNode, returnType);
}
@@ -3718,13 +3715,13 @@
);
}
- void set type(FunctionType type) {
+ set type(FunctionType type) {
_type = type;
}
/// Set the type parameters defined by this executable element to the given
/// [typeParameters].
- void set typeParameters(List<TypeParameterElement> typeParameters) {
+ set typeParameters(List<TypeParameterElement> typeParameters) {
for (TypeParameterElement parameter in typeParameters) {
(parameter as TypeParameterElementImpl).enclosingElement = this;
}
@@ -3852,7 +3849,7 @@
return _combinators ?? const <NamespaceCombinator>[];
}
- void set combinators(List<NamespaceCombinator> combinators) {
+ set combinators(List<NamespaceCombinator> combinators) {
_combinators = combinators;
}
@@ -3873,7 +3870,7 @@
return _exportedLibrary;
}
- void set exportedLibrary(LibraryElement exportedLibrary) {
+ set exportedLibrary(LibraryElement exportedLibrary) {
_exportedLibrary = exportedLibrary;
}
@@ -3883,7 +3880,7 @@
@override
ElementKind get kind => ElementKind.EXPORT;
- void set metadata(List<ElementAnnotation> metadata) {
+ set metadata(List<ElementAnnotation> metadata) {
super.metadata = metadata;
}
@@ -3962,7 +3959,7 @@
return _accessors ??= const <PropertyAccessorElement>[];
}
- void set accessors(List<PropertyAccessorElement> accessors) {
+ set accessors(List<PropertyAccessorElement> accessors) {
for (PropertyAccessorElement accessor in accessors) {
(accessor as PropertyAccessorElementImpl).enclosingElement = this;
}
@@ -4009,7 +4006,7 @@
return _extendedType;
}
- void set extendedType(DartType extendedType) {
+ set extendedType(DartType extendedType) {
_extendedType = extendedType;
}
@@ -4032,7 +4029,7 @@
return _fields ?? const <FieldElement>[];
}
- void set fields(List<FieldElement> fields) {
+ set fields(List<FieldElement> fields) {
for (FieldElement field in fields) {
(field as FieldElementImpl).enclosingElement = this;
}
@@ -4078,7 +4075,7 @@
}
/// Set the methods contained in this extension to the given [methods].
- void set methods(List<MethodElement> methods) {
+ set methods(List<MethodElement> methods) {
for (MethodElement method in methods) {
(method as MethodElementImpl).enclosingElement = this;
}
@@ -4104,7 +4101,7 @@
/// Set the type parameters defined by this extension to the given
/// [typeParameters].
- void set typeParameters(List<TypeParameterElement> typeParameters) {
+ set typeParameters(List<TypeParameterElement> typeParameters) {
for (TypeParameterElement typeParameter in typeParameters) {
(typeParameter as TypeParameterElementImpl).enclosingElement = this;
}
@@ -4227,7 +4224,7 @@
var fieldRef = reference.getChild('@field').getChild(name);
FieldElementImpl field = fieldRef.element;
if (field == null) {
- field = new FieldElementImpl(name, -1);
+ field = FieldElementImpl(name, -1);
fieldRef.element = field;
field.enclosingElement = this;
field.isSynthetic = true;
@@ -4306,7 +4303,7 @@
}
/// Set whether this field is explicitly marked as being covariant.
- void set isCovariant(bool isCovariant) {
+ set isCovariant(bool isCovariant) {
setModifier(Modifier.COVARIANT, isCovariant);
}
@@ -4325,7 +4322,7 @@
}
/// Set whether this field is static.
- void set isStatic(bool isStatic) {
+ set isStatic(bool isStatic) {
setModifier(Modifier.STATIC, isStatic);
}
@@ -4375,7 +4372,7 @@
return _field;
}
- void set field(FieldElement field) {
+ set field(FieldElement field) {
_field = field;
}
@@ -4383,7 +4380,7 @@
bool get isInitializingFormal => true;
@override
- void set type(DartType type) {
+ set type(DartType type) {
_type = type;
}
@@ -4466,7 +4463,7 @@
/// Clients may not extend, implement or mix-in this class.
abstract class FunctionTypedElementImpl
implements ElementImpl, FunctionTypedElement {
- void set returnType(DartType returnType);
+ set returnType(DartType returnType);
}
/// The element used for a generic function type.
@@ -4481,6 +4478,9 @@
/// The elements representing the parameters of the function.
List<ParameterElement> _parameters;
+ /// Is `true` if the type has the question mark, so is nullable.
+ bool _isNullable = false;
+
/// The type defined by this element.
FunctionType _type;
@@ -4496,6 +4496,22 @@
@override
String get identifier => '-';
+ bool get isNullable {
+ if (linkedNode != null) {
+ var node = linkedNode;
+ if (node is GenericFunctionType) {
+ return _isNullable = node.question != null;
+ } else {
+ return _isNullable = false;
+ }
+ }
+ return _isNullable;
+ }
+
+ set isNullable(bool isNullable) {
+ _isNullable = isNullable;
+ }
+
@override
ElementKind get kind => ElementKind.GENERIC_FUNCTION_TYPE;
@@ -4517,7 +4533,7 @@
/// Set the parameters defined by this function type element to the given
/// [parameters].
- void set parameters(List<ParameterElement> parameters) {
+ set parameters(List<ParameterElement> parameters) {
for (ParameterElement parameter in parameters) {
(parameter as ParameterElementImpl).enclosingElement = this;
}
@@ -4537,7 +4553,7 @@
/// Set the return type defined by this function type element to the given
/// [returnType].
- void set returnType(DartType returnType) {
+ set returnType(DartType returnType) {
_returnType = _checkElementOfType(returnType);
}
@@ -4550,14 +4566,15 @@
typeFormals: typeParameters,
parameters: parameters,
returnType: returnType,
- nullabilitySuffix: _noneOrStarSuffix,
+ nullabilitySuffix:
+ isNullable ? NullabilitySuffix.question : _noneOrStarSuffix,
element: this,
);
}
/// Set the function type defined by this function type element to the given
/// [type].
- void set type(FunctionType type) {
+ set type(FunctionType type) {
_type = type;
}
@@ -4573,7 +4590,7 @@
/// Set the type parameters defined by this function type element to the given
/// [typeParameters].
- void set typeParameters(List<TypeParameterElement> typeParameters) {
+ set typeParameters(List<TypeParameterElement> typeParameters) {
for (TypeParameterElement parameter in typeParameters) {
(parameter as TypeParameterElementImpl).enclosingElement = this;
}
@@ -4589,7 +4606,7 @@
void appendTo(StringBuffer buffer) {
DartType type = returnType;
if (type is TypeImpl) {
- type.appendTo(buffer);
+ type.appendTo(buffer, withNullability: false);
buffer.write(' Function');
} else {
buffer.write('Function');
@@ -4718,7 +4735,7 @@
/// Set the function element representing the generic function type on the
/// right side of the equals to the given [function].
- void set function(GenericFunctionTypeElementImpl function) {
+ set function(GenericFunctionTypeElementImpl function) {
if (function != null) {
function.enclosingElement = this;
}
@@ -4769,8 +4786,7 @@
@override
DartType get returnType {
if (function == null) {
- // TODO(scheglov) The context is null in unit tests.
- return context?.typeProvider?.dynamicType;
+ return DynamicTypeImpl.instance;
}
return function?.returnType;
}
@@ -4793,13 +4809,13 @@
return _type;
}
- void set type(FunctionType type) {
+ set type(FunctionType type) {
_type = type;
}
/// Set the type parameters defined for this type to the given
/// [typeParameters].
- void set typeParameters(List<TypeParameterElement> typeParameters) {
+ set typeParameters(List<TypeParameterElement> typeParameters) {
for (TypeParameterElement typeParameter in typeParameters) {
(typeParameter as TypeParameterElementImpl).enclosingElement = this;
}
@@ -4853,18 +4869,22 @@
}
if (typeArguments.length != typeParameters.length) {
- throw new ArgumentError(
- "typeArguments.length (${typeArguments.length}) != "
+ throw ArgumentError("typeArguments.length (${typeArguments.length}) != "
"typeParameters.length (${typeParameters.length})");
}
var substitution = Substitution.fromPairs(typeParameters, typeArguments);
var type = substitution.substituteType(function.type) as FunctionType;
+
+ var resultNullability = type.nullabilitySuffix == NullabilitySuffix.question
+ ? NullabilitySuffix.question
+ : nullabilitySuffix;
+
return FunctionTypeImpl(
typeFormals: type.typeFormals,
parameters: type.parameters,
returnType: type.returnType,
- nullabilitySuffix: nullabilitySuffix,
+ nullabilitySuffix: resultNullability,
element: this,
typeArguments: typeArguments,
);
@@ -4916,13 +4936,13 @@
return _hiddenNames ?? const <String>[];
}
- void set hiddenNames(List<String> hiddenNames) {
+ set hiddenNames(List<String> hiddenNames) {
_hiddenNames = hiddenNames;
}
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write("show ");
int count = hiddenNames.length;
for (int i = 0; i < count; i++) {
@@ -4979,12 +4999,12 @@
return _combinators ?? const <NamespaceCombinator>[];
}
- void set combinators(List<NamespaceCombinator> combinators) {
+ set combinators(List<NamespaceCombinator> combinators) {
_combinators = combinators;
}
/// Set whether this import is for a deferred library.
- void set deferred(bool isDeferred) {
+ set deferred(bool isDeferred) {
setModifier(Modifier.DEFERRED, isDeferred);
}
@@ -5008,7 +5028,7 @@
return _importedLibrary;
}
- void set importedLibrary(LibraryElement importedLibrary) {
+ set importedLibrary(LibraryElement importedLibrary) {
_importedLibrary = importedLibrary;
}
@@ -5024,7 +5044,7 @@
@override
ElementKind get kind => ElementKind.IMPORT;
- void set metadata(List<ElementAnnotation> metadata) {
+ set metadata(List<ElementAnnotation> metadata) {
super.metadata = metadata;
}
@@ -5040,7 +5060,7 @@
@override
Namespace get namespace {
return _namespace ??=
- new NamespaceBuilder().createImportNamespaceForDirective(this);
+ NamespaceBuilder().createImportNamespaceForDirective(this);
}
PrefixElement get prefix {
@@ -5052,7 +5072,7 @@
if (prefix != null) {
var name = prefix.name;
var library = enclosingElement as LibraryElementImpl;
- _prefix = new PrefixElementImpl.forLinkedNode(
+ _prefix = PrefixElementImpl.forLinkedNode(
library,
library.reference.getChild('@prefix').getChild(name),
prefix,
@@ -5063,7 +5083,7 @@
return _prefix;
}
- void set prefix(PrefixElement prefix) {
+ set prefix(PrefixElement prefix) {
_prefix = prefix;
}
@@ -5076,7 +5096,7 @@
return _prefixOffset;
}
- void set prefixOffset(int prefixOffset) {
+ set prefixOffset(int prefixOffset) {
_prefixOffset = prefixOffset;
}
@@ -5091,7 +5111,7 @@
}
@override
- void set uri(String uri) {
+ set uri(String uri) {
super.uri = uri;
}
@@ -5276,7 +5296,7 @@
/// Set the compilation unit that defines this library to the given
/// compilation[unit].
- void set definingCompilationUnit(CompilationUnitElement unit) {
+ set definingCompilationUnit(CompilationUnitElement unit) {
assert((unit as CompilationUnitElementImpl).librarySource == unit.source);
(unit as CompilationUnitElementImpl).enclosingElement = this;
this._definingCompilationUnit = unit;
@@ -5306,13 +5326,13 @@
return _entryPoint;
}
- void set entryPoint(FunctionElement entryPoint) {
+ set entryPoint(FunctionElement entryPoint) {
_entryPoint = entryPoint;
}
@override
List<LibraryElement> get exportedLibraries {
- HashSet<LibraryElement> libraries = new HashSet<LibraryElement>();
+ HashSet<LibraryElement> libraries = HashSet<LibraryElement>();
for (ExportElement element in exports) {
LibraryElement library = element.exportedLibrary;
if (library != null) {
@@ -5334,7 +5354,7 @@
return _exportNamespace;
}
- void set exportNamespace(Namespace exportNamespace) {
+ set exportNamespace(Namespace exportNamespace) {
_exportNamespace = exportNamespace;
}
@@ -5355,7 +5375,7 @@
/// Set the specifications of all of the exports defined in this library to
/// the given list of [exports].
- void set exports(List<ExportElement> exports) {
+ set exports(List<ExportElement> exports) {
for (ExportElement exportElement in exports) {
(exportElement as ExportElementImpl).enclosingElement = this;
}
@@ -5381,7 +5401,7 @@
}
/// Set whether this library has an import of a "dart-ext" URI.
- void set hasExtUri(bool hasExtUri) {
+ set hasExtUri(bool hasExtUri) {
setModifier(Modifier.HAS_EXT_URI, hasExtUri);
}
@@ -5403,7 +5423,7 @@
@override
List<LibraryElement> get importedLibraries {
- HashSet<LibraryElement> libraries = new HashSet<LibraryElement>();
+ HashSet<LibraryElement> libraries = HashSet<LibraryElement>();
for (ImportElement element in imports) {
LibraryElement library = element.importedLibrary;
if (library != null) {
@@ -5440,7 +5460,7 @@
/// Set the specifications of all of the imports defined in this library to
/// the given list of [imports].
- void set imports(List<ImportElement> imports) {
+ set imports(List<ImportElement> imports) {
for (ImportElement importElement in imports) {
(importElement as ImportElementImpl).enclosingElement = this;
PrefixElementImpl prefix = importElement.prefix as PrefixElementImpl;
@@ -5474,7 +5494,7 @@
/// Return `true` if the receiver directly or indirectly imports the
/// 'dart:html' libraries.
bool get isOrImportsBrowserLibrary {
- List<LibraryElement> visited = new List<LibraryElement>();
+ List<LibraryElement> visited = List<LibraryElement>();
Source htmlLibSource = context.sourceFactory.forUri(DartSdk.DART_HTML);
visited.add(this);
for (int index = 0; index < visited.length; index++) {
@@ -5534,7 +5554,7 @@
/// Set the compilation units that are included in this library using a `part`
/// directive to the given list of [parts].
- void set parts(List<CompilationUnitElement> parts) {
+ set parts(List<CompilationUnitElement> parts) {
for (CompilationUnitElement compilationUnit in parts) {
assert((compilationUnit as CompilationUnitElementImpl).librarySource ==
source);
@@ -5559,7 +5579,7 @@
return _publicNamespace;
}
- void set publicNamespace(Namespace publicNamespace) {
+ set publicNamespace(Namespace publicNamespace) {
_publicNamespace = publicNamespace;
}
@@ -5587,7 +5607,7 @@
@override
List<CompilationUnitElement> get units {
- List<CompilationUnitElement> units = new List<CompilationUnitElement>();
+ List<CompilationUnitElement> units = List<CompilationUnitElement>();
units.add(_definingCompilationUnit);
units.addAll(_parts);
return units;
@@ -5596,11 +5616,14 @@
@override
T accept<T>(ElementVisitor<T> visitor) => visitor.visitLibraryElement(this);
- /// Create the [FunctionElement] to be returned by [loadLibraryFunction],
- /// using types provided by [typeProvider].
- void createLoadLibraryFunction(TypeProvider typeProvider) {
+ /// Create the [FunctionElement] to be returned by [loadLibraryFunction].
+ /// The [typeProvider] must be already set.
+ void createLoadLibraryFunction() {
_loadLibraryFunction =
- createLoadLibraryFunctionForLibrary(typeProvider, this);
+ FunctionElementImpl(FunctionElement.LOAD_LIBRARY_NAME, -1)
+ ..enclosingElement = library
+ ..isSynthetic = true
+ ..returnType = typeProvider.futureDynamicType;
}
@override
@@ -5673,7 +5696,7 @@
static List<PrefixElement> buildPrefixesFromImports(
List<ImportElement> imports) {
- HashSet<PrefixElement> prefixes = new HashSet<PrefixElement>();
+ HashSet<PrefixElement> prefixes = HashSet<PrefixElement>();
for (ImportElement element in imports) {
PrefixElement prefix = element.prefix;
if (prefix != null) {
@@ -5683,20 +5706,10 @@
return prefixes.toList(growable: false);
}
- static FunctionElementImpl createLoadLibraryFunctionForLibrary(
- TypeProvider typeProvider, LibraryElement library) {
- FunctionElementImpl function =
- new FunctionElementImpl(FunctionElement.LOAD_LIBRARY_NAME, -1);
- function.isSynthetic = true;
- function.enclosingElement = library;
- function.returnType = typeProvider.futureDynamicType;
- return function;
- }
-
static List<ImportElement> getImportsWithPrefixFromImports(
PrefixElement prefixElement, List<ImportElement> imports) {
int count = imports.length;
- List<ImportElement> importList = new List<ImportElement>();
+ List<ImportElement> importList = List<ImportElement>();
for (int i = 0; i < count; i++) {
if (identical(imports[i].prefix, prefixElement)) {
importList.add(imports[i]);
@@ -5758,7 +5771,7 @@
}
/// Set whether this variable is late.
- void set isLate(bool isLate) {
+ set isLate(bool isLate) {
setModifier(Modifier.LATE, isLate);
}
@@ -5800,7 +5813,7 @@
}
/// Set whether this class is abstract.
- void set isAbstract(bool isAbstract) {
+ set isAbstract(bool isAbstract) {
setModifier(Modifier.ABSTRACT, isAbstract);
}
@@ -5843,7 +5856,7 @@
}
/// Set whether this method is static.
- void set isStatic(bool isStatic) {
+ set isStatic(bool isStatic) {
setModifier(Modifier.STATIC, isStatic);
}
@@ -5910,7 +5923,7 @@
.toList();
}
if (constraints == null || constraints.isEmpty) {
- constraints = [context.typeProvider.objectType];
+ constraints = [library.typeProvider.objectType];
}
return _superclassConstraints = constraints;
}
@@ -5918,7 +5931,7 @@
return _superclassConstraints ?? const <InterfaceType>[];
}
- void set superclassConstraints(List<InterfaceType> superclassConstraints) {
+ set superclassConstraints(List<InterfaceType> superclassConstraints) {
_superclassConstraints = superclassConstraints;
}
@@ -5934,7 +5947,7 @@
return _superInvokedNames ?? const <String>[];
}
- void set superInvokedNames(List<String> superInvokedNames) {
+ set superInvokedNames(List<String> superInvokedNames) {
_superInvokedNames = superInvokedNames;
}
@@ -5942,8 +5955,8 @@
InterfaceType get supertype => null;
@override
- void set supertype(InterfaceType supertype) {
- throw new StateError('Attempt to set a supertype for a mixin declaratio.');
+ set supertype(InterfaceType supertype) {
+ throw StateError('Attempt to set a supertype for a mixin declaratio.');
}
@override
@@ -6246,7 +6259,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
bool needsSeparator = false;
void writeList(List<Element> elements) {
for (Element element in elements) {
@@ -6361,7 +6374,7 @@
}
@override
- void set hasImplicitType(bool hasImplicitType) {
+ set hasImplicitType(bool hasImplicitType) {
super.hasImplicitType = hasImplicitType;
}
@@ -6370,7 +6383,7 @@
if (_initializer == null) {
if (linkedNode != null) {
if (linkedContext.hasInitializer(linkedNode)) {
- _initializer = new FunctionElementImpl('', -1)
+ _initializer = FunctionElementImpl('', -1)
..isSynthetic = true
.._type = FunctionTypeImpl(
typeFormals: const [],
@@ -6403,7 +6416,7 @@
}
@override
- void set type(DartType type) {
+ set type(DartType type) {
if (linkedNode != null) {
return linkedContext.setVariableType(linkedNode, type);
}
@@ -6470,7 +6483,7 @@
/// Creates a synthetic parameter with [name], [type] and [kind].
factory ParameterElementImpl.synthetic(
String name, DartType type, ParameterKind kind) {
- ParameterElementImpl element = new ParameterElementImpl(name, -1);
+ ParameterElementImpl element = ParameterElementImpl(name, -1);
element.type = type;
element.isSynthetic = true;
element.parameterKind = kind;
@@ -6506,7 +6519,7 @@
}
/// Set Dart code of the default value.
- void set defaultValueCode(String defaultValueCode) {
+ set defaultValueCode(String defaultValueCode) {
this._defaultValueCode = StringUtilities.intern(defaultValueCode);
}
@@ -6519,7 +6532,7 @@
}
@override
- void set hasImplicitType(bool hasImplicitType) {
+ set hasImplicitType(bool hasImplicitType) {
super.hasImplicitType = hasImplicitType;
}
@@ -6534,7 +6547,7 @@
}
/// Record whether or not this parameter inherits from a covariant parameter.
- void set inheritsCovariant(bool value) {
+ set inheritsCovariant(bool value) {
if (linkedNode != null) {
linkedContext.setInheritsCovariant(linkedNode, value);
return;
@@ -6559,7 +6572,7 @@
/// Set the function representing this variable's initializer to the given
/// [function].
- void set initializer(FunctionElement function) {
+ set initializer(FunctionElement function) {
super.initializer = function;
}
@@ -6581,7 +6594,7 @@
/// Set whether this variable parameter is explicitly marked as being
/// covariant.
- void set isExplicitlyCovariant(bool isCovariant) {
+ set isExplicitlyCovariant(bool isCovariant) {
setModifier(Modifier.COVARIANT, isCovariant);
}
@@ -6632,7 +6645,7 @@
return _parameterKind;
}
- void set parameterKind(ParameterKind parameterKind) {
+ set parameterKind(ParameterKind parameterKind) {
_parameterKind = parameterKind;
}
@@ -6661,7 +6674,7 @@
/// Set the parameters defined by this executable element to the given
/// [parameters].
- void set parameters(List<ParameterElement> parameters) {
+ set parameters(List<ParameterElement> parameters) {
for (ParameterElement parameter in parameters) {
(parameter as ParameterElementImpl).enclosingElement = this;
}
@@ -6713,7 +6726,7 @@
/// Set the type parameters defined by this parameter element to the given
/// [typeParameters].
- void set typeParameters(List<TypeParameterElement> typeParameters) {
+ set typeParameters(List<TypeParameterElement> typeParameters) {
for (TypeParameterElement parameter in typeParameters) {
(parameter as TypeParameterElementImpl).enclosingElement = this;
}
@@ -6825,7 +6838,7 @@
}
@override
- void set inheritsCovariant(bool value) {
+ set inheritsCovariant(bool value) {
PropertyInducingElement variable = setter.variable;
if (variable is FieldElementImpl) {
if (variable.linkedNode != null) {
@@ -6856,7 +6869,7 @@
DartType get type => setter.variable.type;
@override
- void set type(DartType type) {
+ set type(DartType type) {
assert(false); // Should never be called.
}
}
@@ -7002,7 +7015,7 @@
PropertyAccessorElement get declaration => this;
/// Set whether this accessor is a getter.
- void set getter(bool isGetter) {
+ set getter(bool isGetter) {
setModifier(Modifier.GETTER, isGetter);
}
@@ -7014,7 +7027,7 @@
}
/// Set whether this class is abstract.
- void set isAbstract(bool isAbstract) {
+ set isAbstract(bool isAbstract) {
setModifier(Modifier.ABSTRACT, isAbstract);
}
@@ -7043,7 +7056,7 @@
}
/// Set whether this accessor is static.
- void set isStatic(bool isStatic) {
+ set isStatic(bool isStatic) {
setModifier(Modifier.STATIC, isStatic);
}
@@ -7071,7 +7084,7 @@
}
/// Set whether this accessor is a setter.
- void set setter(bool isSetter) {
+ set setter(bool isSetter) {
setModifier(Modifier.SETTER, isSetter);
}
@@ -7108,7 +7121,7 @@
DartType get returnType => variable.type;
@override
- void set returnType(DartType returnType) {
+ set returnType(DartType returnType) {
assert(false); // Should never be called.
}
@@ -7136,7 +7149,7 @@
}
@override
- void set type(FunctionType type) {
+ set type(FunctionType type) {
assert(false); // Should never be called.
}
}
@@ -7159,7 +7172,7 @@
@override
List<ParameterElement> get parameters {
return _parameters ??= <ParameterElement>[
- new ParameterElementImpl_ofImplicitSetter(this)
+ ParameterElementImpl_ofImplicitSetter(this)
];
}
@@ -7167,7 +7180,7 @@
DartType get returnType => VoidTypeImpl.instance;
@override
- void set returnType(DartType returnType) {
+ set returnType(DartType returnType) {
assert(false); // Should never be called.
}
@@ -7195,7 +7208,7 @@
}
@override
- void set type(FunctionType type) {
+ set type(FunctionType type) {
assert(false); // Should never be called.
}
}
@@ -7282,7 +7295,7 @@
return _end;
}
- void set end(int end) {
+ set end(int end) {
_end = end;
}
@@ -7294,7 +7307,7 @@
return _offset;
}
- void set offset(int offset) {
+ set offset(int offset) {
_offset = offset;
}
@@ -7309,13 +7322,13 @@
return _shownNames ?? const <String>[];
}
- void set shownNames(List<String> shownNames) {
+ set shownNames(List<String> shownNames) {
_shownNames = shownNames;
}
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write("show ");
int count = shownNames.length;
for (int i = 0; i < count; i++) {
@@ -7429,7 +7442,7 @@
return _bound;
}
- void set bound(DartType bound) {
+ set bound(DartType bound) {
_bound = _checkElementOfType(bound);
}
@@ -7506,10 +7519,10 @@
// of whether it appears in a migrated library. This is because for type
// parameters of synthetic function types, the ancestor chain is broken and
// we can't find the enclosing library to tell whether it is migrated.
- return _type ??= new TypeParameterTypeImpl(this);
+ return _type ??= TypeParameterTypeImpl(this);
}
- void set type(TypeParameterType type) {
+ set type(TypeParameterType type) {
_type = type;
}
@@ -7526,7 +7539,7 @@
return _variance ?? Variance.covariant;
}
- void set variance(Variance newVariance) => _variance = newVariance;
+ set variance(Variance newVariance) => _variance = newVariance;
@override
bool operator ==(Object other) {
@@ -7630,7 +7643,7 @@
String get uri => _uri;
/// Set the URI that is specified by this directive to be the given [uri].
- void set uri(String uri) {
+ set uri(String uri) {
_uri = uri;
}
@@ -7640,7 +7653,7 @@
/// Set the offset of the character immediately following the last character
/// of this node's URI to the given [offset].
- void set uriEnd(int offset) {
+ set uriEnd(int offset) {
_uriEnd = offset;
}
@@ -7649,7 +7662,7 @@
int get uriOffset => _uriOffset;
/// Set the offset of the URI in the file to the given [offset].
- void set uriOffset(int offset) {
+ set uriOffset(int offset) {
_uriOffset = offset;
}
}
@@ -7702,9 +7715,8 @@
/// Set the result of evaluating this variable's initializer as a compile-time
/// constant expression to the given [result].
- void set evaluationResult(EvaluationResultImpl result) {
- throw new StateError(
- "Invalid attempt to set a compile-time constant result");
+ set evaluationResult(EvaluationResultImpl result) {
+ throw StateError("Invalid attempt to set a compile-time constant result");
}
@override
@@ -7713,7 +7725,7 @@
}
/// Set whether this variable element has an implicit type.
- void set hasImplicitType(bool hasImplicitType) {
+ set hasImplicitType(bool hasImplicitType) {
setModifier(Modifier.IMPLICIT_TYPE, hasImplicitType);
}
@@ -7722,7 +7734,7 @@
/// Set the function representing this variable's initializer to the given
/// [function].
- void set initializer(FunctionElement function) {
+ set initializer(FunctionElement function) {
if (function != null) {
(function as FunctionElementImpl).enclosingElement = this;
}
@@ -7738,7 +7750,7 @@
}
/// Set whether this variable is const.
- void set isConst(bool isConst) {
+ set isConst(bool isConst) {
setModifier(Modifier.CONST, isConst);
}
@@ -7754,7 +7766,7 @@
}
/// Set whether this variable is final.
- void set isFinal(bool isFinal) {
+ set isFinal(bool isFinal) {
setModifier(Modifier.FINAL, isFinal);
}
@@ -7764,7 +7776,7 @@
@override
DartType get type => _type;
- void set type(DartType type) {
+ set type(DartType type) {
if (linkedNode != null) {
return linkedContext.setVariableType(linkedNode, type);
}
diff --git a/pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart b/pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart
index c80aa0f..065878af 100644
--- a/pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart
+++ b/pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart
@@ -38,7 +38,7 @@
/// The set of classes that are currently being processed, used to detect
/// self-referencing cycles.
- final Set<ClassElement> _processingClasses = new Set<ClassElement>();
+ final Set<ClassElement> _processingClasses = Set<ClassElement>();
InheritanceManager3([@deprecated TypeSystem typeSystem]);
@@ -176,7 +176,7 @@
// super-interfaces that is a valid override of all the other
// super-interface signatures with the same name. That "most specific"
// signature becomes the signature of the class's interface.
- Map<Name, ExecutableElement> map = new Map.of(declared);
+ Map<Name, ExecutableElement> map = Map.of(declared);
List<Conflict> conflicts = _findMostSpecificFromNamedCandidates(
typeSystem,
map,
@@ -202,7 +202,7 @@
}
}
- var interface = new Interface._(
+ var interface = Interface._(
map,
declared,
implemented,
@@ -230,9 +230,9 @@
ExecutableElement getMember(
InterfaceType type,
Name name, {
- bool concrete: false,
- int forMixinIndex: -1,
- bool forSuper: false,
+ bool concrete = false,
+ int forMixinIndex = -1,
+ bool forSuper = false,
}) {
var interface = getInterface(type);
if (forSuper) {
@@ -287,7 +287,7 @@
void addMember(ExecutableElement member) {
if (!member.isAbstract && !member.isStatic) {
- var name = new Name(libraryUri, member.name);
+ var name = Name(libraryUri, member.name);
implemented[name] = member;
}
}
@@ -338,7 +338,7 @@
method ??= candidate;
}
}
- return new Conflict(name, candidates, getter, method);
+ return Conflict(name, candidates, getter, method);
}
/// The given [namedCandidates] maps names to candidates from direct
@@ -397,7 +397,7 @@
map[name] = validOverride;
} else {
conflicts ??= <Conflict>[];
- conflicts.add(new Conflict(name, candidates));
+ conflicts.add(Conflict(name, candidates));
}
}
@@ -412,7 +412,7 @@
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
if (!method.isStatic) {
- var name = new Name(libraryUri, method.name);
+ var name = Name(libraryUri, method.name);
declared[name] = method;
}
}
@@ -421,7 +421,7 @@
for (var i = 0; i < accessors.length; i++) {
var accessor = accessors[i];
if (!accessor.isStatic) {
- var name = new Name(libraryUri, accessor.name);
+ var name = Name(libraryUri, accessor.name);
declared[name] = accessor;
}
}
@@ -522,9 +522,9 @@
factory Name(Uri libraryUri, String name) {
if (name.startsWith('_')) {
var hashCode = JenkinsSmiHash.hash2(libraryUri.hashCode, name.hashCode);
- return new Name._internal(libraryUri, name, false, hashCode);
+ return Name._internal(libraryUri, name, false, hashCode);
} else {
- return new Name._internal(null, name, true, name.hashCode);
+ return Name._internal(null, name, true, name.hashCode);
}
}
diff --git a/pkg/analyzer/lib/src/dart/element/member.dart b/pkg/analyzer/lib/src/dart/element/member.dart
index a086001..849d97a 100644
--- a/pkg/analyzer/lib/src/dart/element/member.dart
+++ b/pkg/analyzer/lib/src/dart/element/member.dart
@@ -706,8 +706,9 @@
var typeParameter = typeParameters[i];
if (typeParameter is TypeParameterElementImpl) {
typeParameter.appendTo(buffer);
- } else
+ } else {
(typeParameter as TypeParameterMember).appendTo(buffer);
+ }
}
buffer.write('>');
}
@@ -1074,6 +1075,9 @@
@override
bool operator ==(Object other) {
+ if (other is TypeParameterMember) {
+ return declaration == other.declaration;
+ }
return declaration == other;
}
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index 14581cc..1544af6 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -11,8 +11,7 @@
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/member.dart';
import 'package:analyzer/src/dart/element/type_algebra.dart';
-import 'package:analyzer/src/generated/engine.dart'
- show AnalysisContext, AnalysisEngine;
+import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine;
import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
import 'package:analyzer/src/generated/type_system.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
@@ -46,12 +45,12 @@
/**
* The unique instance of this class.
*/
- static final DynamicTypeImpl instance = new DynamicTypeImpl._();
+ static final DynamicTypeImpl instance = DynamicTypeImpl._();
/**
* Prevent the creation of instances of this class.
*/
- DynamicTypeImpl._() : super(new DynamicElementImpl(), Keyword.DYNAMIC.lexeme);
+ DynamicTypeImpl._() : super(DynamicElementImpl(), Keyword.DYNAMIC.lexeme);
@override
int get hashCode => 1;
@@ -66,6 +65,11 @@
bool operator ==(Object object) => identical(object, this);
@override
+ void appendTo(StringBuffer buffer, {@required bool withNullability}) {
+ buffer.write('dynamic');
+ }
+
+ @override
DartType replaceTopAndBottom(TypeProvider typeProvider,
{bool isCovariant = true}) {
if (isCovariant) {
@@ -144,50 +148,6 @@
List<TypeParameterElement> get boundTypeParameters => typeFormals;
@override
- String get displayName {
- if (name == null || name.isEmpty) {
- // Function types have an empty name when they are defined implicitly by
- // either a closure or as part of a parameter declaration.
- StringBuffer buffer = new StringBuffer();
- appendTo(buffer);
- if (nullabilitySuffix == NullabilitySuffix.question) {
- buffer.write('?');
- }
- return buffer.toString();
- }
-
- List<DartType> typeArguments = this.typeArguments;
-
- bool allTypeArgumentsAreDynamic() {
- for (DartType type in typeArguments) {
- if (type != null && !type.isDynamic) {
- return false;
- }
- }
- return true;
- }
-
- StringBuffer buffer = new StringBuffer();
- buffer.write(name);
- // If there is at least one non-dynamic type, then list them out.
- if (!allTypeArgumentsAreDynamic()) {
- buffer.write("<");
- for (int i = 0; i < typeArguments.length; i++) {
- if (i != 0) {
- buffer.write(", ");
- }
- DartType typeArg = typeArguments[i];
- buffer.write(typeArg.displayName);
- }
- buffer.write(">");
- }
- if (nullabilitySuffix == NullabilitySuffix.question) {
- buffer.write('?');
- }
- return buffer.toString();
- }
-
- @override
FunctionTypedElement get element {
var element = super.element;
// TODO(scheglov) Can we just construct it with the right element?
@@ -295,9 +255,7 @@
}
@override
- void appendTo(StringBuffer buffer, {bool withNullability = false}) {
- // TODO(paulberry): eliminate code duplication with
- // _ElementWriter.writeType. See issue #35818.
+ void appendTo(StringBuffer buffer, {@required bool withNullability}) {
if (typeFormals.isNotEmpty) {
StringBuffer typeParametersBuffer = StringBuffer();
// To print a type with type variables, first make sure we have unique
@@ -329,14 +287,14 @@
while (!namesToAvoid.add(name)) {
// Unicode subscript-zero is U+2080, zero is U+0030. Other digits
// are sequential from there. Thus +0x2050 will get us the subscript.
- String subscript = new String.fromCharCodes(
+ String subscript = String.fromCharCodes(
counter.toString().codeUnits.map((n) => n + 0x2050));
name = e.name + subscript;
counter++;
}
- TypeParameterTypeImpl t = new TypeParameterTypeImpl(
- new TypeParameterElementImpl(name, -1),
+ TypeParameterTypeImpl t = TypeParameterTypeImpl(
+ TypeParameterElementImpl(name, -1),
nullabilitySuffix: NullabilitySuffix.none);
t.appendTo(typeParametersBuffer, withNullability: withNullability);
instantiateTypeArgs.add(t);
@@ -363,8 +321,7 @@
@override
FunctionTypeImpl instantiate(List<DartType> argumentTypes) {
if (argumentTypes.length != typeFormals.length) {
- throw new ArgumentError(
- "argumentTypes.length (${argumentTypes.length}) != "
+ throw ArgumentError("argumentTypes.length (${argumentTypes.length}) != "
"typeFormals.length (${typeFormals.length})");
}
if (argumentTypes.isEmpty) {
@@ -377,7 +334,7 @@
var type = p.type;
var newType = substitution.substituteType(type);
if (identical(newType, type)) return p;
- return new ParameterElementImpl.synthetic(
+ return ParameterElementImpl.synthetic(
p.name,
newType,
// ignore: deprecated_member_use_from_same_package
@@ -395,7 +352,7 @@
@override
DartType replaceTopAndBottom(TypeProvider typeProvider,
- {bool isCovariant: true}) {
+ {bool isCovariant = true}) {
var returnType = (this.returnType as TypeImpl)
.replaceTopAndBottom(typeProvider, isCovariant: isCovariant);
ParameterElement transformParameter(ParameterElement p) {
@@ -403,7 +360,7 @@
var newType =
type.replaceTopAndBottom(typeProvider, isCovariant: !isCovariant);
if (identical(newType, type)) return p;
- return new ParameterElementImpl.synthetic(
+ return ParameterElementImpl.synthetic(
p.name,
newType,
// ignore: deprecated_member_use_from_same_package
@@ -428,8 +385,7 @@
FunctionType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes) {
if (argumentTypes.length != parameterTypes.length) {
- throw new ArgumentError(
- "argumentTypes.length (${argumentTypes.length}) != "
+ throw ArgumentError("argumentTypes.length (${argumentTypes.length}) != "
"parameterTypes.length (${parameterTypes.length})");
}
@@ -772,7 +728,7 @@
TypeParameterElement p1 = params1[i];
TypeParameterElement p2 = params2[i];
TypeParameterElementImpl pFresh =
- new TypeParameterElementImpl.synthetic(p2.name);
+ TypeParameterElementImpl.synthetic(p2.name);
DartType variableFresh = pFresh.instantiate(
nullabilitySuffix: NullabilitySuffix.none,
@@ -922,7 +878,7 @@
if (_accessors == null) {
List<PropertyAccessorElement> accessors = element.accessors;
List<PropertyAccessorElement> members =
- new List<PropertyAccessorElement>(accessors.length);
+ List<PropertyAccessorElement>(accessors.length);
for (int i = 0; i < accessors.length; i++) {
members[i] = PropertyAccessorMember.from(accessors[i], this);
}
@@ -936,7 +892,7 @@
if (_constructors == null) {
List<ConstructorElement> constructors = element.constructors;
List<ConstructorElement> members =
- new List<ConstructorElement>(constructors.length);
+ List<ConstructorElement>(constructors.length);
for (int i = 0; i < constructors.length; i++) {
members[i] = ConstructorMember.from(constructors[i], this);
}
@@ -946,39 +902,6 @@
}
@override
- String get displayName {
- List<DartType> typeArguments = this.typeArguments;
-
- bool allTypeArgumentsAreDynamic() {
- for (DartType type in typeArguments) {
- if (type != null && !type.isDynamic) {
- return false;
- }
- }
- return true;
- }
-
- StringBuffer buffer = new StringBuffer();
- buffer.write(name);
- // If there is at least one non-dynamic type, then list them out.
- if (!allTypeArgumentsAreDynamic()) {
- buffer.write("<");
- for (int i = 0; i < typeArguments.length; i++) {
- if (i != 0) {
- buffer.write(", ");
- }
- DartType typeArg = typeArguments[i];
- buffer.write(typeArg.displayName);
- }
- buffer.write(">");
- }
- if (nullabilitySuffix == NullabilitySuffix.question) {
- buffer.write('?');
- }
- return buffer.toString();
- }
-
- @override
ClassElement get element => super.element;
@override
@@ -1128,7 +1051,7 @@
List<MethodElement> get methods {
if (_methods == null) {
List<MethodElement> methods = element.methods;
- List<MethodElement> members = new List<MethodElement>(methods.length);
+ List<MethodElement> members = List<MethodElement>(methods.length);
for (int i = 0; i < methods.length; i++) {
members[i] = MethodMember.from(methods[i], this);
}
@@ -1176,8 +1099,8 @@
}
@override
- void appendTo(StringBuffer buffer, {bool withNullability = false}) {
- buffer.write(name);
+ void appendTo(StringBuffer buffer, {@required bool withNullability}) {
+ buffer.write(element.name);
int argumentCount = typeArguments.length;
if (argumentCount > 0) {
buffer.write("<");
@@ -1212,7 +1135,7 @@
* return the type `A<String>`.
*/
InterfaceType asInstanceOf(ClassElement targetElement) {
- return _asInstanceOf(targetElement, new Set<ClassElement>());
+ return _asInstanceOf(targetElement, Set<ClassElement>());
}
@override
@@ -1276,7 +1199,7 @@
return element;
}
}
- HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
+ HashSet<ClassElement> visitedClasses = HashSet<ClassElement>();
InterfaceType supertype = superclass;
ClassElement supertypeElement = supertype?.element;
while (supertype != null && !visitedClasses.contains(supertypeElement)) {
@@ -1299,7 +1222,7 @@
@override
PropertyAccessorElement lookUpInheritedGetter(String name,
- {LibraryElement library, bool thisType: true}) {
+ {LibraryElement library, bool thisType = true}) {
PropertyAccessorElement result;
if (thisType) {
result = lookUpGetter(name, library);
@@ -1310,7 +1233,7 @@
return result;
}
return _lookUpMemberInInterfaces(this, false, library,
- new HashSet<ClassElement>(), (InterfaceType t) => t.getGetter(name));
+ HashSet<ClassElement>(), (InterfaceType t) => t.getGetter(name));
}
@override
@@ -1326,24 +1249,24 @@
this,
false,
library,
- new HashSet<ClassElement>(),
+ HashSet<ClassElement>(),
(InterfaceType t) => t.getGetter(name) ?? t.getMethod(name));
}
ExecutableElement lookUpInheritedMember(String name, LibraryElement library,
- {bool concrete: false,
- bool forSuperInvocation: false,
+ {bool concrete = false,
+ bool forSuperInvocation = false,
int startMixinIndex,
- bool setter: false,
- bool thisType: false}) {
- HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
+ bool setter = false,
+ bool thisType = false}) {
+ HashSet<ClassElement> visitedClasses = HashSet<ClassElement>();
/// TODO(scheglov) Remove [includeSupers]. It is used only to work around
/// the problem with Flutter code base (using old super-mixins).
ExecutableElement lookUpImpl(InterfaceTypeImpl type,
- {bool acceptAbstract: false,
- bool includeType: true,
- bool inMixin: false,
+ {bool acceptAbstract = false,
+ bool includeType = true,
+ bool inMixin = false,
int startMixinIndex}) {
if (type == null || !visitedClasses.add(type.element)) {
return null;
@@ -1419,7 +1342,7 @@
@override
MethodElement lookUpInheritedMethod(String name,
- {LibraryElement library, bool thisType: true}) {
+ {LibraryElement library, bool thisType = true}) {
MethodElement result;
if (thisType) {
result = lookUpMethod(name, library);
@@ -1430,12 +1353,12 @@
return result;
}
return _lookUpMemberInInterfaces(this, false, library,
- new HashSet<ClassElement>(), (InterfaceType t) => t.getMethod(name));
+ HashSet<ClassElement>(), (InterfaceType t) => t.getMethod(name));
}
@override
PropertyAccessorElement lookUpInheritedSetter(String name,
- {LibraryElement library, bool thisType: true}) {
+ {LibraryElement library, bool thisType = true}) {
PropertyAccessorElement result;
if (thisType) {
result = lookUpSetter(name, library);
@@ -1446,7 +1369,7 @@
return result;
}
return _lookUpMemberInInterfaces(this, false, library,
- new HashSet<ClassElement>(), (t) => t.getSetter(name));
+ HashSet<ClassElement>(), (t) => t.getSetter(name));
}
@override
@@ -1473,7 +1396,7 @@
return element;
}
}
- HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
+ HashSet<ClassElement> visitedClasses = HashSet<ClassElement>();
InterfaceType supertype = superclass;
ClassElement supertypeElement = supertype?.element;
while (supertype != null && !visitedClasses.contains(supertypeElement)) {
@@ -1519,7 +1442,7 @@
return element;
}
}
- HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
+ HashSet<ClassElement> visitedClasses = HashSet<ClassElement>();
InterfaceType supertype = superclass;
ClassElement supertypeElement = supertype?.element;
while (supertype != null && !visitedClasses.contains(supertypeElement)) {
@@ -1542,7 +1465,7 @@
@override
DartType replaceTopAndBottom(TypeProvider typeProvider,
- {bool isCovariant: true}) {
+ {bool isCovariant = true}) {
// First check if this is actually an instance of Bottom
if (this.isDartCoreNull) {
if (isCovariant) {
@@ -1560,7 +1483,7 @@
if (identical(typeArguments, this.typeArguments)) {
return this;
} else {
- return new InterfaceTypeImpl.explicit(element, typeArguments,
+ return InterfaceTypeImpl.explicit(element, typeArguments,
nullabilitySuffix: nullabilitySuffix);
}
}
@@ -1570,7 +1493,7 @@
InterfaceTypeImpl substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes) {
if (argumentTypes.length != parameterTypes.length) {
- throw new ArgumentError(
+ throw ArgumentError(
"argumentTypes.length (${argumentTypes.length}) != parameterTypes.length (${parameterTypes.length})");
}
if (argumentTypes.isEmpty || typeArguments.isEmpty) {
@@ -1580,7 +1503,7 @@
List<DartType> newTypeArguments =
TypeImpl.substitute(typeArguments, argumentTypes, parameterTypes);
- InterfaceTypeImpl newType = new InterfaceTypeImpl.explicit(
+ InterfaceTypeImpl newType = InterfaceTypeImpl.explicit(
element, newTypeArguments,
nullabilitySuffix: nullabilitySuffix);
return newType;
@@ -1721,8 +1644,8 @@
if (first.element == second.element) {
return _leastUpperBound(first, second);
}
- AnalysisContext context = first.element.context;
- return context.typeSystem.getLeastUpperBound(first, second);
+ TypeSystemImpl typeSystem = first.element.library.typeSystem;
+ return typeSystem.getLeastUpperBound(first, second);
}
/**
@@ -1739,7 +1662,7 @@
ClassElement firstElement = firstType.element;
ClassElement secondElement = secondType.element;
if (firstElement != secondElement) {
- throw new ArgumentError('The same elements expected, but '
+ throw ArgumentError('The same elements expected, but '
'$firstElement and $secondElement are given.');
}
if (firstType == secondType) {
@@ -1751,7 +1674,7 @@
if (argumentCount == 0) {
return firstType;
}
- List<DartType> lubArguments = new List<DartType>(argumentCount);
+ List<DartType> lubArguments = List<DartType>(argumentCount);
for (int i = 0; i < argumentCount; i++) {
//
// Ideally we would take the least upper bound of the two argument types,
@@ -1781,7 +1704,7 @@
return NullabilitySuffix.none;
}
- return new InterfaceTypeImpl.explicit(firstElement, lubArguments,
+ return InterfaceTypeImpl.explicit(firstElement, lubArguments,
nullabilitySuffix: computeNullability());
}
@@ -1859,7 +1782,7 @@
* in diagnostic messages (this is TBD).
*/
static final NeverTypeImpl instanceNullable =
- new NeverTypeImpl._(NullabilitySuffix.question);
+ NeverTypeImpl._(NullabilitySuffix.question);
/**
* The unique instance of this class, starred.
@@ -1871,13 +1794,12 @@
* not.
*/
static final NeverTypeImpl instanceLegacy =
- new NeverTypeImpl._(NullabilitySuffix.star);
+ NeverTypeImpl._(NullabilitySuffix.star);
/**
* The unique instance of this class, non-nullable.
*/
- static final NeverTypeImpl instance =
- new NeverTypeImpl._(NullabilitySuffix.none);
+ static final NeverTypeImpl instance = NeverTypeImpl._(NullabilitySuffix.none);
@override
final NullabilitySuffix nullabilitySuffix;
@@ -1885,8 +1807,7 @@
/**
* Prevent the creation of instances of this class.
*/
- NeverTypeImpl._(this.nullabilitySuffix)
- : super(new NeverElementImpl(), 'Never');
+ NeverTypeImpl._(this.nullabilitySuffix) : super(NeverElementImpl(), 'Never');
@override
int get hashCode => 0;
@@ -1904,6 +1825,14 @@
bool operator ==(Object object) => identical(object, this);
@override
+ void appendTo(StringBuffer buffer, {@required bool withNullability}) {
+ buffer.write('Never');
+ if (withNullability) {
+ _appendNullability(buffer);
+ }
+ }
+
+ @override
DartType replaceTopAndBottom(TypeProvider typeProvider,
{bool isCovariant = true}) {
if (isCovariant) {
@@ -1964,7 +1893,9 @@
TypeImpl(this._element, this.name);
@override
- String get displayName => name;
+ String get displayName {
+ return getDisplayString(withNullability: false);
+ }
@override
Element get element => _element;
@@ -2029,15 +1960,13 @@
/**
* Append a textual representation of this type to the given [buffer].
*/
- void appendTo(StringBuffer buffer, {bool withNullability = false}) {
- if (name == null) {
- buffer.write("<unnamed type>");
- } else {
- buffer.write(name);
- }
- if (withNullability) {
- _appendNullability(buffer);
- }
+ void appendTo(StringBuffer buffer, {@required bool withNullability});
+
+ @override
+ String getDisplayString({bool withNullability = false}) {
+ var buffer = StringBuffer();
+ appendTo(buffer, withNullability: withNullability);
+ return buffer.toString();
}
/// Replaces all covariant occurrences of `dynamic`, `Object`, and `void` with
@@ -2062,9 +1991,7 @@
@override
String toString({bool withNullability = false}) {
- StringBuffer buffer = new StringBuffer();
- appendTo(buffer, withNullability: withNullability);
- return buffer.toString();
+ return getDisplayString(withNullability: withNullability);
}
/**
@@ -2082,11 +2009,6 @@
TypeImpl withNullability(NullabilitySuffix nullabilitySuffix);
void _appendNullability(StringBuffer buffer) {
- if (isDynamic || isVoid) {
- // These types don't have nullability variations, so don't append
- // anything.
- return;
- }
switch (nullabilitySuffix) {
case NullabilitySuffix.question:
buffer.write('?');
@@ -2135,7 +2057,7 @@
if (length == 0) {
return types;
}
- List<DartType> newTypes = new List<DartType>(length);
+ List<DartType> newTypes = List<DartType>(length);
for (int i = 0; i < length; i++) {
newTypes[i] =
(types[i] as TypeImpl).substitute2(argumentTypes, parameterTypes);
@@ -2183,6 +2105,14 @@
}
@override
+ void appendTo(StringBuffer buffer, {@required bool withNullability}) {
+ buffer.write(element.name);
+ if (withNullability) {
+ _appendNullability(buffer);
+ }
+ }
+
+ @override
DartType replaceTopAndBottom(TypeProvider typeProvider,
{bool isCovariant = true}) {
return this;
@@ -2250,7 +2180,7 @@
}
} else {
// We should never be substituting for `T?`.
- throw new StateError('Tried to substitute for T?');
+ throw StateError('Tried to substitute for T?');
}
return argumentType.withNullability(resultNullability);
@@ -2276,7 +2206,7 @@
if (count == 0) {
return const <TypeParameterType>[];
}
- List<TypeParameterType> types = new List<TypeParameterType>(count);
+ List<TypeParameterType> types = List<TypeParameterType>(count);
for (int i = 0; i < count; i++) {
types[i] = typeParameters[i].type;
}
@@ -2301,7 +2231,7 @@
/**
* The unique instance of this class, with indeterminate nullability.
*/
- static final VoidTypeImpl instance = new VoidTypeImpl._();
+ static final VoidTypeImpl instance = VoidTypeImpl._();
/**
* Prevent the creation of instances of this class.
@@ -2321,6 +2251,11 @@
bool operator ==(Object object) => identical(object, this);
@override
+ void appendTo(StringBuffer buffer, {@required bool withNullability}) {
+ buffer.write('void');
+ }
+
+ @override
DartType replaceTopAndBottom(TypeProvider typeProvider,
{bool isCovariant = true}) {
if (isCovariant) {
diff --git a/pkg/analyzer/lib/src/dart/element/type_algebra.dart b/pkg/analyzer/lib/src/dart/element/type_algebra.dart
index 2cab0ed..1aea9c2 100644
--- a/pkg/analyzer/lib/src/dart/element/type_algebra.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_algebra.dart
@@ -19,15 +19,15 @@
/// mapping to be used for replacing other types to use the new type parameters.
FreshTypeParameters getFreshTypeParameters(
List<TypeParameterElement> typeParameters) {
- var freshParameters = new List<TypeParameterElementImpl>.generate(
+ var freshParameters = List<TypeParameterElementImpl>.generate(
typeParameters.length,
- (i) => new TypeParameterElementImpl(typeParameters[i].name, -1),
+ (i) => TypeParameterElementImpl(typeParameters[i].name, -1),
growable: true,
);
var map = <TypeParameterElement, DartType>{};
for (int i = 0; i < typeParameters.length; ++i) {
- map[typeParameters[i]] = new TypeParameterTypeImpl(
+ map[typeParameters[i]] = TypeParameterTypeImpl(
freshParameters[i],
nullabilitySuffix: NullabilitySuffix.none,
);
@@ -50,7 +50,7 @@
}
}
- return new FreshTypeParameters(freshParameters, substitution);
+ return FreshTypeParameters(freshParameters, substitution);
}
/// Given a generic function [type] of a class member (so that it does not
@@ -116,7 +116,7 @@
FreshTypeParameters(this.freshTypeParameters, this.substitution);
FunctionType applyToFunctionType(FunctionType type) {
- return new FunctionTypeImpl(
+ return FunctionTypeImpl(
typeFormals: freshTypeParameters,
parameters: type.parameters.map((parameter) {
return ParameterElementImpl.synthetic(
@@ -148,8 +148,8 @@
DartType getSubstitute(TypeParameterElement parameter, bool upperBound);
- DartType substituteType(DartType type, {bool contravariant: false}) {
- return new _TopSubstitutor(this, contravariant).visit(type);
+ DartType substituteType(DartType type, {bool contravariant = false}) {
+ return _TopSubstitutor(this, contravariant).visit(type);
}
/// Substitutes both variables from [first] and [second], favoring those from
@@ -163,7 +163,7 @@
static Substitution combine(Substitution first, Substitution second) {
if (first == _NullSubstitution.instance) return second;
if (second == _NullSubstitution.instance) return first;
- return new _CombinedSubstitution(first, second);
+ return _CombinedSubstitution(first, second);
}
/// Substitutes the type parameters on the class of [type] with the
@@ -180,7 +180,7 @@
if (map.isEmpty) {
return _NullSubstitution.instance;
}
- return new _MapSubstitution(map);
+ return _MapSubstitution(map);
}
/// Substitutes the Nth parameter in [parameters] with the Nth type in
@@ -194,7 +194,7 @@
return _NullSubstitution.instance;
}
return fromMap(
- new Map<TypeParameterElement, DartType>.fromIterables(
+ Map<TypeParameterElement, DartType>.fromIterables(
parameters,
types,
),
@@ -218,7 +218,7 @@
if (upper.isEmpty && lower.isEmpty) {
return _NullSubstitution.instance;
}
- return new _UpperLowerBoundsSubstitution(upper, lower);
+ return _UpperLowerBoundsSubstitution(upper, lower);
}
}
@@ -303,11 +303,11 @@
Map<TypeParameterElement, DartType> get map => const {};
DartType getSubstitute(TypeParameterElement parameter, bool upperBound) {
- return new TypeParameterTypeImpl(parameter);
+ return TypeParameterTypeImpl(parameter);
}
@override
- DartType substituteType(DartType type, {bool contravariant: false}) => type;
+ DartType substituteType(DartType type, {bool contravariant = false}) => type;
@override
String toString() => "Substitution.empty";
@@ -381,7 +381,7 @@
DartType lookup(TypeParameterElement parameter, bool upperBound);
_FreshTypeParametersSubstitutor newInnerEnvironment() {
- return new _FreshTypeParametersSubstitutor(this);
+ return _FreshTypeParametersSubstitutor(this);
}
DartType visit(DartType type) {
@@ -494,7 +494,7 @@
return type;
}
- return new InterfaceTypeImpl.explicit(type.element, typeArguments,
+ return InterfaceTypeImpl.explicit(type.element, typeArguments,
nullabilitySuffix: (type as TypeImpl).nullabilitySuffix);
}
@@ -510,7 +510,7 @@
return type;
}
- return new NamedTypeBuilder(
+ return NamedTypeBuilder(
type.isNNBD,
type.element,
arguments,
diff --git a/pkg/analyzer/lib/src/dart/element/type_provider.dart b/pkg/analyzer/lib/src/dart/element/type_provider.dart
index 8884f1b..46a3e42 100644
--- a/pkg/analyzer/lib/src/dart/element/type_provider.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_provider.dart
@@ -362,7 +362,7 @@
@override
DartObjectImpl get nullObject {
if (_nullObject == null) {
- _nullObject = new DartObjectImpl(nullType, NullState.NULL_STATE);
+ _nullObject = DartObjectImpl(nullType, NullState.NULL_STATE);
}
return _nullObject;
}
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
index 75008d4..36372e59 100644
--- a/pkg/analyzer/lib/src/dart/error/hint_codes.dart
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
@@ -74,7 +74,8 @@
// ```
static const HintCode DEAD_CODE = const HintCode('DEAD_CODE', "Dead code.",
correction: "Try removing the code, or "
- "fixing the code before it so that it can be reached.");
+ "fixing the code before it so that it can be reached.",
+ hasPublishedDocs: true);
/**
* Dead code is code that is never reached. This case covers cases where the
@@ -132,7 +133,8 @@
"'on Object catch (e)' are never reached.",
correction:
"Try reordering the catch clauses so that they can be reached, or "
- "removing the unreachable catch clauses.");
+ "removing the unreachable catch clauses.",
+ hasPublishedDocs: true);
/**
* Dead code is code that is never reached. This case covers cases where the
@@ -194,7 +196,8 @@
"subtype of '{1}' and hence will have been caught already.",
correction:
"Try reordering the catch clauses so that this block can be reached, "
- "or removing the unreachable catch clause.");
+ "or removing the unreachable catch clause.",
+ hasPublishedDocs: true);
/**
* Users should not create a class named `Function` anymore.
@@ -348,7 +351,8 @@
// ```
static const HintCode DUPLICATE_IMPORT = const HintCode(
'DUPLICATE_IMPORT', "Duplicate import.",
- correction: "Try removing all but one import of the library.");
+ correction: "Try removing all but one import of the library.",
+ hasPublishedDocs: true);
/**
* Duplicate hidden names.
@@ -690,6 +694,138 @@
const HintCode('INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER',
"The member '{0}' can only be used within '{1}' or a test.");
+ /// Invalid Dart language version comments don't follow the specification [1].
+ /// If a comment begins with "@dart" or "dart" (letters in any case),
+ /// followed by optional whitespace, followed by optional non-alphanumeric,
+ /// non-whitespace characters, followed by optional whitespace, followed by
+ /// an optional alphabetical character, followed by a digit, then the
+ /// comment is considered to be an attempt at a language version override
+ /// comment. If this attempted language version override comment is not a
+ /// valid language version override comment, it is reported.
+ ///
+ /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN =
+ const HintCodeWithUniqueName(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ 'HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN',
+ "The Dart language version override number must begin with '@dart'",
+ correction: "Specify a Dart language version override with a comment "
+ "like '// @dart = 2.0'.");
+
+ /// Invalid Dart language version comments don't follow the specification [1].
+ /// If a comment begins with "@dart" or "dart" (letters in any case),
+ /// followed by optional whitespace, followed by optional non-alphanumeric,
+ /// non-whitespace characters, followed by optional whitespace, followed by
+ /// an optional alphabetical character, followed by a digit, then the
+ /// comment is considered to be an attempt at a language version override
+ /// comment. If this attempted language version override comment is not a
+ /// valid language version override comment, it is reported.
+ ///
+ /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS =
+ const HintCodeWithUniqueName(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ 'HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS',
+ "The Dart language version override comment must be specified with "
+ "an '=' character",
+ correction: "Specify a Dart language version override with a comment "
+ "like '// @dart = 2.0'.");
+
+ /// Invalid Dart language version comments don't follow the specification [1].
+ /// If a comment begins with "@dart" or "dart" (letters in any case),
+ /// followed by optional whitespace, followed by optional non-alphanumeric,
+ /// non-whitespace characters, followed by optional whitespace, followed by
+ /// an optional alphabetical character, followed by a digit, then the
+ /// comment is considered to be an attempt at a language version override
+ /// comment. If this attempted language version override comment is not a
+ /// valid language version override comment, it is reported.
+ ///
+ /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE =
+ const HintCodeWithUniqueName(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ 'HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE',
+ "The Dart language version override comment must be specified with "
+ "the word 'dart' in all lower case",
+ correction: "Specify a Dart language version override with a comment "
+ "like '// @dart = 2.0'.");
+
+ /// Invalid Dart language version comments don't follow the specification [1].
+ /// If a comment begins with "@dart" or "dart" (letters in any case),
+ /// followed by optional whitespace, followed by optional non-alphanumeric,
+ /// non-whitespace characters, followed by optional whitespace, followed by
+ /// an optional alphabetical character, followed by a digit, then the
+ /// comment is considered to be an attempt at a language version override
+ /// comment. If this attempted language version override comment is not a
+ /// valid language version override comment, it is reported.
+ ///
+ /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER =
+ const HintCodeWithUniqueName(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ 'HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER',
+ "The Dart language version override comment must be specified with a "
+ "version number, like '2.0', after the '=' character.",
+ correction: "Specify a Dart language version override with a comment "
+ "like '// @dart = 2.0'.");
+
+ /// Invalid Dart language version comments don't follow the specification [1].
+ /// If a comment begins with "@dart" or "dart" (letters in any case),
+ /// followed by optional whitespace, followed by optional non-alphanumeric,
+ /// non-whitespace characters, followed by optional whitespace, followed by
+ /// an optional alphabetical character, followed by a digit, then the
+ /// comment is considered to be an attempt at a language version override
+ /// comment. If this attempted language version override comment is not a
+ /// valid language version override comment, it is reported.
+ ///
+ /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_PREFIX =
+ const HintCodeWithUniqueName(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ 'HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_PREFIX',
+ "The Dart language version override number can't be prefixed with "
+ "a letter",
+ correction: "Specify a Dart language version override with a comment "
+ "like '// @dart = 2.0'.");
+
+ /// Invalid Dart language version comments don't follow the specification [1].
+ /// If a comment begins with "@dart" or "dart" (letters in any case),
+ /// followed by optional whitespace, followed by optional non-alphanumeric,
+ /// non-whitespace characters, followed by optional whitespace, followed by
+ /// an optional alphabetical character, followed by a digit, then the
+ /// comment is considered to be an attempt at a language version override
+ /// comment. If this attempted language version override comment is not a
+ /// valid language version override comment, it is reported.
+ ///
+ /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS =
+ const HintCodeWithUniqueName(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ 'HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS',
+ "The Dart language version override comment can't be followed by "
+ "any non-whitespace characters",
+ correction: "Specify a Dart language version override with a comment "
+ "like '// @dart = 2.0'.");
+
+ /// Invalid Dart language version comments don't follow the specification [1].
+ /// If a comment begins with "@dart" or "dart" (letters in any case),
+ /// followed by optional whitespace, followed by optional non-alphanumeric,
+ /// non-whitespace characters, followed by optional whitespace, followed by
+ /// an optional alphabetical character, followed by a digit, then the
+ /// comment is considered to be an attempt at a language version override
+ /// comment. If this attempted language version override comment is not a
+ /// valid language version override comment, it is reported.
+ ///
+ /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ static const HintCode INVALID_LANGUAGE_VERSION_OVERRIDE_TWO_SLASHES =
+ const HintCodeWithUniqueName(
+ 'INVALID_LANGUAGE_VERSION_OVERRIDE',
+ 'HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_TWO_SLASHES',
+ 'The Dart language version override comment must be specified with '
+ 'exactly two slashes.',
+ correction: "Specify a Dart language version override with a comment "
+ "like '// @dart = 2.0'.");
+
/**
* This hint is generated anywhere where a private declaration is annotated
* with `@visibleForTemplate` or `@visibleForTesting`.
@@ -740,7 +876,8 @@
static const HintCode INVALID_VISIBILITY_ANNOTATION = const HintCode(
'INVALID_VISIBILITY_ANNOTATION',
"The member '{0}' is annotated with '{1}', but this annotation is only "
- "meaningful on declarations of public members.");
+ "meaningful on declarations of public members.",
+ hasPublishedDocs: true);
/**
* Hint for the `x is double` type checks.
@@ -834,7 +971,8 @@
// }
// ```
static const HintCode MISSING_REQUIRED_PARAM = const HintCode(
- 'MISSING_REQUIRED_PARAM', "The parameter '{0}' is required.");
+ 'MISSING_REQUIRED_PARAM', "The parameter '{0}' is required.",
+ hasPublishedDocs: true);
/**
* Generate a hint for a constructor, function or method invocation where a
@@ -848,7 +986,8 @@
const HintCodeWithUniqueName(
'MISSING_REQUIRED_PARAM',
'HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS',
- "The parameter '{0}' is required. {1}.");
+ "The parameter '{0}' is required. {1}.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -932,7 +1071,8 @@
"superclass.",
correction:
"Try composing with this class, or refer to its documentation for "
- "more information.");
+ "more information.",
+ hasPublishedDocs: true);
/**
* Generate a hint for classes that inherit from classes annotated with
@@ -1004,7 +1144,8 @@
'NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR',
"This instance creation must be 'const', because the {0} constructor is "
"marked as '@literal'.",
- correction: "Try adding a 'const' keyword.");
+ correction: "Try adding a 'const' keyword.",
+ hasPublishedDocs: true);
/**
* Generate a hint for non-const instance creation (with the `new` keyword)
@@ -1019,7 +1160,8 @@
'HintCode.NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR_USING_NEW',
"This instance creation must be 'const', because the {0} constructor "
"is marked as '@literal'.",
- correction: "Try replacing the 'new' keyword with 'const'.");
+ correction: "Try replacing the 'new' keyword with 'const'.",
+ hasPublishedDocs: true);
/**
* When the left operand of a binary expression uses '?.' operator, it can be
@@ -1074,7 +1216,8 @@
'HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER',
"The getter doesn't override an inherited getter.",
correction: "Try updating this class to match the superclass, or "
- "removing the override annotation.");
+ "removing the override annotation.",
+ hasPublishedDocs: true);
/**
* A field with the override annotation does not override a getter or setter.
@@ -1087,7 +1230,8 @@
'HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD',
"The field doesn't override an inherited getter or setter.",
correction: "Try updating this class to match the superclass, or "
- "removing the override annotation.");
+ "removing the override annotation.",
+ hasPublishedDocs: true);
/**
* A method with the override annotation does not override an existing method.
@@ -1134,7 +1278,8 @@
'HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD',
"The method doesn't override an inherited method.",
correction: "Try updating this class to match the superclass, or "
- "removing the override annotation.");
+ "removing the override annotation.",
+ hasPublishedDocs: true);
/**
* A setter with the override annotation does not override an existing setter.
@@ -1147,7 +1292,8 @@
'HintCode.OVERRIDE_ON_NON_OVERRIDING_SETTER',
"The setter doesn't override an inherited setter.",
correction: "Try updating this class to match the superclass, or "
- "removing the override annotation.");
+ "removing the override annotation.",
+ hasPublishedDocs: true);
/**
* It is a bad practice for a package import to reference anything outside the
@@ -2051,6 +2197,8 @@
ErrorType get type => ErrorType.HINT;
}
+/// A [HintCode] class in which a [uniqueName] can be given which is not just
+/// derived from [name].
class HintCodeWithUniqueName extends HintCode {
@override
final String uniqueName;
diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
index 7aad143..33d4f8c 100644
--- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
@@ -403,7 +403,7 @@
const ParserErrorCode _INVALID_USE_OF_COVARIANT_IN_EXTENSION =
const ParserErrorCode('INVALID_USE_OF_COVARIANT_IN_EXTENSION',
r"Can't have modifier '#lexeme' in an extension.",
- correction: "Try removing '#lexeme'.");
+ correction: "Try removing '#lexeme'.", hasPublishedDocs: true);
const ParserErrorCode _LIBRARY_DIRECTIVE_NOT_FIRST = const ParserErrorCode(
'LIBRARY_DIRECTIVE_NOT_FIRST',
diff --git a/pkg/analyzer/lib/src/dart/error/todo_codes.dart b/pkg/analyzer/lib/src/dart/error/todo_codes.dart
index b671114..4fa2f31 100644
--- a/pkg/analyzer/lib/src/dart/error/todo_codes.dart
+++ b/pkg/analyzer/lib/src/dart/error/todo_codes.dart
@@ -28,7 +28,7 @@
* * TODOS
*/
static RegExp TODO_REGEX =
- new RegExp("([\\s/\\*])((TODO[^\\w\\d][^\\r\\n]*)|(TODO:?\$))");
+ RegExp("([\\s/\\*])((TODO[^\\w\\d][^\\r\\n]*)|(TODO:?\$))");
/**
* Initialize a newly created error code to have the given [name].
diff --git a/pkg/analyzer/lib/src/dart/resolver/exit_detector.dart b/pkg/analyzer/lib/src/dart/resolver/exit_detector.dart
index 5e43500..a6228b9 100644
--- a/pkg/analyzer/lib/src/dart/resolver/exit_detector.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/exit_detector.dart
@@ -21,7 +21,7 @@
bool _enclosingBlockContainsContinue = false;
/// Add node when a labelled `break` is encountered.
- Set<AstNode> _enclosingBlockBreaksLabel = new Set<AstNode>();
+ Set<AstNode> _enclosingBlockBreaksLabel = Set<AstNode>();
@override
bool visitArgumentList(ArgumentList node) =>
@@ -435,7 +435,7 @@
@override
bool visitNode(AstNode node) {
- throw new StateError(
+ throw StateError(
'Missing a visit method for a node of type ${node.runtimeType}');
}
@@ -658,6 +658,6 @@
/// Return `true` if the given [node] exits.
static bool exits(AstNode node) {
- return new ExitDetector()._nodeExits(node);
+ return ExitDetector()._nodeExits(node);
}
}
diff --git a/pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart b/pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
index 6916281..1d84eba 100644
--- a/pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
@@ -491,7 +491,7 @@
} else if (forLoopParts is ForPartsWithDeclarations) {
forLoopParts.variables?.accept(this);
} else {
- throw new StateError('Unrecognized for loop parts');
+ throw StateError('Unrecognized for loop parts');
}
assignedVariables.beginNode();
@@ -514,13 +514,13 @@
assignedVariables.declare(variable);
assignedVariables.write(variable);
} else {
- throw new StateError('Unrecognized for loop parts');
+ throw StateError('Unrecognized for loop parts');
}
assignedVariables.beginNode();
body.accept(this);
assignedVariables.endNode(node);
} else {
- throw new StateError('Unrecognized for loop parts');
+ throw StateError('Unrecognized for loop parts');
}
}
}
diff --git a/pkg/analyzer/lib/src/dart/resolver/legacy_type_asserter.dart b/pkg/analyzer/lib/src/dart/resolver/legacy_type_asserter.dart
index c109df6..36d864f 100644
--- a/pkg/analyzer/lib/src/dart/resolver/legacy_type_asserter.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/legacy_type_asserter.dart
@@ -149,7 +149,7 @@
}
static bool assertLegacyTypes(CompilationUnit compilationUnit) {
- new LegacyTypeAsserter().visitCompilationUnit(compilationUnit);
+ LegacyTypeAsserter().visitCompilationUnit(compilationUnit);
return true;
}
}
diff --git a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
index 6ac99e7..b78d13d 100644
--- a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
@@ -19,7 +19,7 @@
import 'package:analyzer/src/generated/variable_type_provider.dart';
class MethodInvocationResolver {
- static final _nameCall = new Name(null, 'call');
+ static final _nameCall = Name(null, 'call');
/// Resolver visitor is separated from the elements resolver, which calls
/// this method resolver. If we rewrite a [MethodInvocation] node, we put
@@ -479,7 +479,7 @@
// We can invoke Object methods on Function.
var member = _inheritance.getMember(
_resolver.typeProvider.functionType,
- new Name(null, name),
+ Name(null, name),
);
if (member != null) {
nameNode.staticElement = member;
@@ -655,7 +655,7 @@
// TODO(scheglov) I don't like how we resolve prefixed names.
// But maybe this is the only one solution.
- var prefixedName = new PrefixedIdentifierImpl.temp(receiver, nameNode);
+ var prefixedName = PrefixedIdentifierImpl.temp(receiver, nameNode);
var element = nameScope.lookup(prefixedName, _definingLibrary);
element = _resolver.toLegacyElement(element);
nameNode.staticElement = element;
@@ -840,7 +840,7 @@
}
void _setDynamicResolution(MethodInvocation node,
- {bool setNameTypeToDynamic: true}) {
+ {bool setNameTypeToDynamic = true}) {
if (setNameTypeToDynamic) {
node.methodName.staticType = _dynamicType;
}
diff --git a/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart b/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
index bef6eac..8c5d1a8 100644
--- a/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
@@ -94,13 +94,13 @@
ElementWalker elementWalker,
}) {
var libraryElement = unitElement.library;
- var typeProvider = libraryElement.context.typeProvider;
+ var typeProvider = libraryElement.typeProvider;
var unitSource = unitElement.source;
var nonNullableEnabled = featureSet.isEnabled(Feature.non_nullable);
var errorReporter = ErrorReporter(errorListener, unitSource);
var typeNameResolver = TypeNameResolver(
- unitElement.context.typeSystem,
+ libraryElement.typeSystem,
typeProvider,
nonNullableEnabled,
libraryElement,
@@ -283,7 +283,7 @@
node.returnType.accept(this);
_withElementWalker(
- ElementWalker.forExecutable(element, _unitElement),
+ ElementWalker.forExecutable(element),
() {
node.parameters.accept(this);
},
@@ -525,9 +525,7 @@
var holder = ElementHolder(element);
_withElementHolder(holder, () {
_withElementWalker(
- _elementWalker != null
- ? ElementWalker.forExecutable(element, _unitElement)
- : null,
+ _elementWalker != null ? ElementWalker.forExecutable(element) : null,
() {
_withNameScope(() {
_buildTypeParameterElements(expression.typeParameters);
@@ -623,7 +621,7 @@
if (_elementWalker != null) {
element = _elementWalker.getParameter();
} else {
- element = new ParameterElementImpl(nameNode.name, nameNode.offset);
+ element = ParameterElementImpl(nameNode.name, nameNode.offset);
_elementHolder.addParameter(element);
element.isConst = node.isConst;
element.isExplicitlyCovariant = node.covariantKeyword != null;
@@ -676,6 +674,8 @@
_unitElement.encloseElement(element);
(node as GenericFunctionTypeImpl).declaredElement = element;
+ element.isNullable = node.question != null;
+
_setCodeRange(element, node);
var holder = ElementHolder(element);
@@ -778,7 +778,7 @@
node.metadata.accept(this);
_setElementAnnotations(node.metadata, element.metadata);
- _withElementWalker(ElementWalker.forExecutable(element, _unitElement), () {
+ _withElementWalker(ElementWalker.forExecutable(element), () {
node.metadata.accept(this);
_withNameScope(() {
_buildTypeParameterElements(node.typeParameters);
@@ -1170,7 +1170,7 @@
/// declarations are not valid (they declare interfaces and mixins, but not
/// classes).
void _resolveType(TypeName typeName, ErrorCode errorCode,
- {bool asClass: false}) {
+ {bool asClass = false}) {
visitTypeName(typeName);
DartType type = typeName.type;
diff --git a/pkg/analyzer/lib/src/dart/resolver/scope.dart b/pkg/analyzer/lib/src/dart/resolver/scope.dart
index d59b9ba..4941813 100644
--- a/pkg/analyzer/lib/src/dart/resolver/scope.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/scope.dart
@@ -22,7 +22,7 @@
*/
BlockScope(Scope enclosingScope, Block block) : super(enclosingScope) {
if (block == null) {
- throw new ArgumentError("block cannot be null");
+ throw ArgumentError("block cannot be null");
}
_defineElements(block);
}
@@ -66,7 +66,7 @@
ClassScope(Scope enclosingScope, ClassElement classElement)
: super(enclosingScope) {
if (classElement == null) {
- throw new ArgumentError("class element cannot be null");
+ throw ArgumentError("class element cannot be null");
}
_defineMembers(classElement);
}
@@ -192,9 +192,9 @@
* that represents the given [_functionElement].
*/
FunctionScope(Scope enclosingScope, this._functionElement)
- : super(new EnclosedScope(new EnclosedScope(enclosingScope))) {
+ : super(EnclosedScope(EnclosedScope(enclosingScope))) {
if (_functionElement == null) {
- throw new ArgumentError("function element cannot be null");
+ throw ArgumentError("function element cannot be null");
}
_defineTypeParameters();
}
@@ -246,7 +246,7 @@
* that represents the given [_typeElement].
*/
FunctionTypeScope(Scope enclosingScope, this._typeElement)
- : super(new EnclosedScope(enclosingScope)) {
+ : super(EnclosedScope(enclosingScope)) {
_defineTypeParameters();
}
@@ -323,7 +323,7 @@
* with the newly created scope.
*/
ImplicitLabelScope nest(Statement statement) =>
- new ImplicitLabelScope._(this, statement);
+ ImplicitLabelScope._(this, statement);
}
/**
@@ -506,7 +506,7 @@
void _createImportedNamespaces() {
List<ImportElement> imports = _definingLibrary.imports;
int count = imports.length;
- _importedNamespaces = new List<Namespace>(count);
+ _importedNamespaces = List<Namespace>(count);
for (int i = 0; i < count; i++) {
_importedNamespaces[i] = imports[i].namespace;
}
@@ -518,9 +518,9 @@
*/
void _definePrefixedNameWithoutChecking(
String prefix, String name, Element element) {
- _definedPrefixedNames ??= new HashMap<String, Map<String, Element>>();
+ _definedPrefixedNames ??= HashMap<String, Map<String, Element>>();
Map<String, Element> unprefixedNames = _definedPrefixedNames.putIfAbsent(
- prefix, () => new HashMap<String, Element>());
+ prefix, () => HashMap<String, Element>());
unprefixedNames[name] = element;
}
@@ -570,8 +570,8 @@
}
if (hasPotentialConflict) {
- var sdkElements = new Set<Element>();
- var nonSdkElements = new Set<Element>();
+ var sdkElements = Set<Element>();
+ var nonSdkElements = Set<Element>();
for (int i = 0; i < _importedNamespaces.length; i++) {
Element element = lookup(_importedNamespaces[i]);
if (element != null) {
@@ -586,7 +586,7 @@
var conflictingElements = <Element>[]
..addAll(sdkElements)
..addAll(nonSdkElements);
- return new MultiplyDefinedElementImpl(
+ return MultiplyDefinedElementImpl(
_definingLibrary.context,
_definingLibrary.session,
conflictingElements.first.name,
@@ -614,7 +614,7 @@
* [definingLibrary].
*/
LibraryScope(LibraryElement definingLibrary)
- : super(new LibraryImportScope(definingLibrary)) {
+ : super(LibraryImportScope(definingLibrary)) {
_defineTopLevelNames(definingLibrary);
// For `dart:core` to be able to pass analysis, it has to have `dynamic`
@@ -683,7 +683,7 @@
/**
* An empty namespace.
*/
- static Namespace EMPTY = new Namespace(new HashMap<String, Element>());
+ static Namespace EMPTY = Namespace(HashMap<String, Element>());
/**
* A table mapping names that are defined in this namespace to the element
@@ -735,7 +735,7 @@
}
Map<String, Element> exportedNames = _getExportMapping(exportedLibrary);
exportedNames = _applyCombinators(exportedNames, element.combinators);
- return new Namespace(exportedNames);
+ return Namespace(exportedNames);
}
/**
@@ -743,7 +743,7 @@
*/
Namespace createExportNamespaceForLibrary(LibraryElement library) {
Map<String, Element> exportedNames = _getExportMapping(library);
- return new Namespace(exportedNames);
+ return Namespace(exportedNames);
}
/**
@@ -762,9 +762,9 @@
exportedNames = _applyCombinators(exportedNames, element.combinators);
PrefixElement prefix = element.prefix;
if (prefix != null) {
- return new PrefixedNamespace(prefix.name, exportedNames);
+ return PrefixedNamespace(prefix.name, exportedNames);
}
- return new Namespace(exportedNames);
+ return Namespace(exportedNames);
}
/**
@@ -772,7 +772,7 @@
* [library].
*/
Namespace createPublicNamespaceForLibrary(LibraryElement library) {
- Map<String, Element> definedNames = new HashMap<String, Element>();
+ Map<String, Element> definedNames = HashMap<String, Element>();
_addPublicNames(definedNames, library.definingCompilationUnit);
for (CompilationUnitElement compilationUnit in library.parts) {
_addPublicNames(definedNames, compilationUnit);
@@ -787,7 +787,7 @@
definedNames['Never'] = NeverTypeImpl.instance.element;
}
- return new Namespace(definedNames);
+ return Namespace(definedNames);
}
/**
@@ -874,7 +874,7 @@
LibraryElement library, HashSet<LibraryElement> visitedElements) {
visitedElements.add(library);
try {
- Map<String, Element> definedNames = new HashMap<String, Element>();
+ Map<String, Element> definedNames = HashMap<String, Element>();
for (ExportElement element in library.exports) {
LibraryElement exportedLibrary = element.exportedLibrary;
if (exportedLibrary != null &&
@@ -905,11 +905,11 @@
}
if (library is LibraryElementImpl) {
Map<String, Element> exportMapping =
- _computeExportMapping(library, new HashSet<LibraryElement>());
- library.exportNamespace = new Namespace(exportMapping);
+ _computeExportMapping(library, HashSet<LibraryElement>());
+ library.exportNamespace = Namespace(exportMapping);
return exportMapping;
}
- return _computeExportMapping(library, new HashSet<LibraryElement>());
+ return _computeExportMapping(library, HashSet<LibraryElement>());
}
/**
@@ -918,8 +918,7 @@
*/
Map<String, Element> _hide(
Map<String, Element> definedNames, List<String> hiddenNames) {
- Map<String, Element> newNames =
- new HashMap<String, Element>.from(definedNames);
+ Map<String, Element> newNames = HashMap<String, Element>.from(definedNames);
for (String name in hiddenNames) {
newNames.remove(name);
newNames.remove("$name=");
@@ -932,7 +931,7 @@
*/
Map<String, Element> _show(
Map<String, Element> definedNames, List<String> shownNames) {
- Map<String, Element> newNames = new HashMap<String, Element>();
+ Map<String, Element> newNames = HashMap<String, Element>();
for (String name in shownNames) {
Element element = definedNames[name];
if (element != null) {
@@ -1054,7 +1053,7 @@
void define(Element element) {
String name = _getName(element);
if (name != null && name.isNotEmpty) {
- _definedNames ??= new HashMap<String, Element>();
+ _definedNames ??= HashMap<String, Element>();
_definedNames.putIfAbsent(name, () => element);
}
}
@@ -1064,7 +1063,7 @@
* hiding.
*/
void defineNameWithoutChecking(String name, Element element) {
- _definedNames ??= new HashMap<String, Element>();
+ _definedNames ??= HashMap<String, Element>();
_definedNames[name] = element;
}
@@ -1073,7 +1072,7 @@
* hiding.
*/
void defineWithoutChecking(Element element) {
- _definedNames ??= new HashMap<String, Element>();
+ _definedNames ??= HashMap<String, Element>();
_definedNames[_getName(element)] = element;
}
@@ -1189,7 +1188,7 @@
TypeParameterScope(Scope enclosingScope, TypeParameterizedElement element)
: super(enclosingScope) {
if (element == null) {
- throw new ArgumentError("element cannot be null");
+ throw ArgumentError("element cannot be null");
}
_defineTypeParameters(element);
}
diff --git a/pkg/analyzer/lib/src/dart/resolver/variance.dart b/pkg/analyzer/lib/src/dart/resolver/variance.dart
index ccb7fa8..e9565be 100644
--- a/pkg/analyzer/lib/src/dart/resolver/variance.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/variance.dart
@@ -87,7 +87,7 @@
case 3:
return invariant;
}
- throw new ArgumentError('Invalid encoding for variance: $encoding');
+ throw ArgumentError('Invalid encoding for variance: $encoding');
}
/// Return the variance associated with the string representation of variance.
@@ -101,8 +101,7 @@
} else if (varianceString == "unrelated") {
return unrelated;
}
- throw new ArgumentError(
- 'Invalid keyword string for variance: $varianceString');
+ throw ArgumentError('Invalid keyword string for variance: $varianceString');
}
/// Returns the associated keyword lexeme.
@@ -117,7 +116,7 @@
case unrelated:
return '';
default:
- throw new ArgumentError(
+ throw ArgumentError(
'Missing keyword lexeme representation for variance: $this');
}
}
diff --git a/pkg/analyzer/lib/src/dart/scanner/reader.dart b/pkg/analyzer/lib/src/dart/scanner/reader.dart
index 0a21e3b..1f1d266 100644
--- a/pkg/analyzer/lib/src/dart/scanner/reader.dart
+++ b/pkg/analyzer/lib/src/dart/scanner/reader.dart
@@ -39,7 +39,7 @@
int get offset => baseReader.offset;
@override
- void set offset(int offset) {
+ set offset(int offset) {
baseReader.offset = offset;
}
diff --git a/pkg/analyzer/lib/src/dart/scanner/scanner.dart b/pkg/analyzer/lib/src/dart/scanner/scanner.dart
index 4943680..ec2b621 100644
--- a/pkg/analyzer/lib/src/dart/scanner/scanner.dart
+++ b/pkg/analyzer/lib/src/dart/scanner/scanner.dart
@@ -81,12 +81,12 @@
*/
factory Scanner(Source source, CharacterReader reader,
AnalysisErrorListener errorListener) =>
- new Scanner.fasta(source, errorListener,
+ Scanner.fasta(source, errorListener,
contents: reader.getContents(), offset: reader.offset);
factory Scanner.fasta(Source source, AnalysisErrorListener errorListener,
- {String contents, int offset: -1}) {
- return new Scanner._(
+ {String contents, int offset = -1}) {
+ return Scanner._(
source, contents ?? source.contents.data, offset, errorListener);
}
@@ -125,7 +125,7 @@
void reportError(
ScannerErrorCode errorCode, int offset, List<Object> arguments) {
_errorListener
- .onError(new AnalysisError(source, offset, 1, errorCode, arguments));
+ .onError(AnalysisError(source, offset, 1, errorCode, arguments));
}
void setSourceStart(int line, int column) {
diff --git a/pkg/analyzer/lib/src/dart/sdk/patch.dart b/pkg/analyzer/lib/src/dart/sdk/patch.dart
index 72c191f..1e40752 100644
--- a/pkg/analyzer/lib/src/dart/sdk/patch.dart
+++ b/pkg/analyzer/lib/src/dart/sdk/patch.dart
@@ -40,7 +40,7 @@
{
Uri uri = source.uri;
if (uri.scheme != 'dart') {
- throw new ArgumentError(
+ throw ArgumentError(
'The URI of the unit to patch must have the "dart" scheme: $uri');
}
List<String> uriSegments = uri.pathSegments;
@@ -55,7 +55,7 @@
for (String path in patchPaths) {
File patchFile = resourceProvider.getFile(path);
if (!patchFile.exists) {
- throw new ArgumentError(
+ throw ArgumentError(
'The patch file ${patchFile.path} for $source does not exist.');
}
Source patchSource = patchFile.createSource();
@@ -75,7 +75,7 @@
}
void _failExternalKeyword(String name, int offset) {
- throw new ArgumentError(
+ throw ArgumentError(
'The keyword "external" was expected for "$name" in $_baseDesc @ $offset.');
}
@@ -90,7 +90,7 @@
void _failInPatch(String message, int offset) {
String loc = _getLocationDesc3(_patchUnit, offset);
- throw new ArgumentError(
+ throw ArgumentError(
'The patch file $_patchDesc for $_baseDesc $message at $loc.');
}
@@ -103,10 +103,10 @@
FormalParameterList patchParameters, String context()) {
if (baseParameters == null && patchParameters == null) return;
if (baseParameters == null || patchParameters == null) {
- throw new ArgumentError("${context()}, parameter lists don't match");
+ throw ArgumentError("${context()}, parameter lists don't match");
}
if (baseParameters.parameters.length != patchParameters.parameters.length) {
- throw new ArgumentError(
+ throw ArgumentError(
'${context()}, parameter lists have different lengths');
}
for (var i = 0; i < baseParameters.parameters.length; i++) {
@@ -118,7 +118,7 @@
void _matchParameters(FormalParameter baseParameter,
FormalParameter patchParameter, String whichParameter()) {
if (baseParameter.identifier.name != patchParameter.identifier.name) {
- throw new ArgumentError('${whichParameter()} has different name');
+ throw ArgumentError('${whichParameter()} has different name');
}
NormalFormalParameter baseParameterWithoutDefault =
_withoutDefault(baseParameter);
@@ -140,16 +140,16 @@
() => '${whichParameter()} parameters');
} else if (baseParameterWithoutDefault is FieldFormalParameter &&
patchParameter is FieldFormalParameter) {
- throw new ArgumentError(
+ throw ArgumentError(
'${whichParameter()} cannot be patched (field formal parameters are not supported)');
} else {
- throw new ArgumentError(
+ throw ArgumentError(
'${whichParameter()} mismatch (different parameter kinds)');
}
}
void _matchTypes(TypeName baseType, TypeName patchType, String whichType()) {
- error() => new ArgumentError("${whichType()} doesn't match");
+ error() => ArgumentError("${whichType()} doesn't match");
if (baseType == null && patchType == null) return;
if (baseType == null || patchType == null) throw error();
// Match up the types token by token; this is more restrictive than strictly
@@ -251,7 +251,7 @@
}
// The base constructor should not have initializers.
if (baseMember.initializers.isNotEmpty) {
- throw new ArgumentError(
+ throw ArgumentError(
'Cannot patch external constructors with initializers '
'in $_baseDesc.');
}
@@ -411,13 +411,13 @@
AnalysisErrorListener errorListener, FeatureSet featureSet) {
String code = source.contents.data;
- CharSequenceReader reader = new CharSequenceReader(code);
- Scanner scanner = new Scanner(source, reader, errorListener)
+ CharSequenceReader reader = CharSequenceReader(code);
+ Scanner scanner = Scanner(source, reader, errorListener)
..configureFeatures(featureSet);
Token token = scanner.tokenize();
- LineInfo lineInfo = new LineInfo(scanner.lineStarts);
+ LineInfo lineInfo = LineInfo(scanner.lineStarts);
- Parser parser = new Parser(source, errorListener, featureSet: featureSet);
+ Parser parser = Parser(source, errorListener, featureSet: featureSet);
CompilationUnit unit = parser.parseCompilationUnit(token);
unit.lineInfo = lineInfo;
return unit;
diff --git a/pkg/analyzer/lib/src/dart/sdk/sdk.dart b/pkg/analyzer/lib/src/dart/sdk/sdk.dart
index 2d46430..79a0329 100644
--- a/pkg/analyzer/lib/src/dart/sdk/sdk.dart
+++ b/pkg/analyzer/lib/src/dart/sdk/sdk.dart
@@ -38,7 +38,7 @@
/**
* A mapping from Dart library URI's to the library represented by that URI.
*/
- LibraryMap libraryMap = new LibraryMap();
+ LibraryMap libraryMap = LibraryMap();
/**
* The [AnalysisOptions] to use to create the [context].
@@ -54,12 +54,12 @@
/**
* The [AnalysisContext] which is used for all of the sources in this SDK.
*/
- InternalAnalysisContext _analysisContext;
+ SdkAnalysisContext _analysisContext;
/**
* The mapping from Dart URI's to the corresponding sources.
*/
- Map<String, Source> _uriToSourceMap = new HashMap<String, Source>();
+ Map<String, Source> _uriToSourceMap = HashMap<String, Source>();
PackageBundle _sdkBundle;
@@ -72,9 +72,9 @@
* Set the [options] for this SDK analysis context. Throw [StateError] if the
* context has been already created.
*/
- void set analysisOptions(AnalysisOptions options) {
+ set analysisOptions(AnalysisOptions options) {
if (_analysisContext != null) {
- throw new StateError(
+ throw StateError(
'Analysis options cannot be changed after context creation.');
}
_analysisOptions = options;
@@ -108,9 +108,9 @@
/**
* Specify whether SDK summary should be used.
*/
- void set useSummary(bool use) {
+ set useSummary(bool use) {
if (_analysisContext != null) {
- throw new StateError(
+ throw StateError(
'The "useSummary" flag cannot be changed after context creation.');
}
_useSummary = use;
@@ -123,7 +123,7 @@
*/
void addExtensions(Map<String, String> extensions) {
extensions.forEach((String uri, String path) {
- SdkLibraryImpl library = new SdkLibraryImpl(uri);
+ SdkLibraryImpl library = SdkLibraryImpl(uri);
library.path = path;
libraryMap.setLibrary(uri, library);
});
@@ -152,7 +152,7 @@
} on FormatException catch (exception, stackTrace) {
AnalysisEngine.instance.instrumentationService.logInfo(
"Failed to create URI: $path",
- new CaughtException(exception, stackTrace));
+ CaughtException(exception, stackTrace));
}
return null;
}
@@ -232,7 +232,7 @@
String _getPath(File file) {
List<SdkLibrary> libraries = libraryMap.sdkLibraries;
int length = libraries.length;
- List<String> paths = new List(length);
+ List<String> paths = List(length);
String filePath = getRelativePathFromFile(file);
if (filePath == null) {
return null;
@@ -269,7 +269,7 @@
static const String _DART_COLON_PREFIX = 'dart:';
static const String _EMBEDDED_LIB_MAP_KEY = 'embedded_libs';
- final Map<String, String> _urlMappings = new HashMap<String, String>();
+ final Map<String, String> _urlMappings = HashMap<String, String>();
Folder _embedderYamlLibFolder;
@@ -301,11 +301,11 @@
try {
if (file.exists) {
List<int> bytes = file.readAsBytesSync();
- return new PackageBundle.fromBuffer(bytes);
+ return PackageBundle.fromBuffer(bytes);
}
} catch (exception, stackTrace) {
AnalysisEngine.instance.instrumentationService.logException(
- new CaughtException.withMessage(
+ CaughtException.withMessage(
'Failed to load SDK analysis summary from $file',
exception,
stackTrace));
@@ -363,7 +363,7 @@
}
String libPath = libDir.canonicalizePath(file);
_urlMappings[name] = libPath;
- SdkLibraryImpl library = new SdkLibraryImpl(name);
+ SdkLibraryImpl library = SdkLibraryImpl(name);
library.path = libPath;
libraryMap.setLibrary(name, library);
}
@@ -599,11 +599,11 @@
File file = resourceProvider.getFile(path);
if (file.exists) {
List<int> bytes = file.readAsBytesSync();
- return new PackageBundle.fromBuffer(bytes);
+ return PackageBundle.fromBuffer(bytes);
}
} catch (exception, stackTrace) {
AnalysisEngine.instance.instrumentationService.logException(
- new CaughtException.withMessage(
+ CaughtException.withMessage(
'Failed to load SDK analysis summary from $path',
exception,
stackTrace));
@@ -629,15 +629,15 @@
lastStackTrace = stackTrace;
}
}
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.writeln('Could not initialize the library map from $searchedPaths');
if (resourceProvider is MemoryResourceProvider) {
(resourceProvider as MemoryResourceProvider).writeOn(buffer);
}
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(buffer.toString(), lastException, lastStackTrace));
- return new LibraryMap();
+ SilentException(buffer.toString(), lastException, lastStackTrace));
+ return LibraryMap();
}
@override
@@ -701,7 +701,7 @@
pathos.Context pathContext = resourceProvider.pathContext;
if (pathContext.style != pathos.context.style) {
// This will only happen when running tests.
- if (exec.startsWith(new RegExp('[a-zA-Z]:'))) {
+ if (exec.startsWith(RegExp('[a-zA-Z]:'))) {
exec = exec.substring(2);
} else if (resourceProvider is MemoryResourceProvider) {
exec = resourceProvider.convertPath(exec);
@@ -782,8 +782,7 @@
* Return a table mapping the names of extensions to the paths where those
* extensions can be found.
*/
- Map<String, String> get urlMappings =>
- new Map<String, String>.from(_urlMappings);
+ Map<String, String> get urlMappings => Map<String, String>.from(_urlMappings);
/**
* Given a package [name] and a list of folders ([libDirs]), add any found sdk
@@ -886,17 +885,17 @@
* of the file is already known to be [libraryFileContents].
*/
LibraryMap readFromSource(Source source, String libraryFileContents) {
- BooleanErrorListener errorListener = new BooleanErrorListener();
+ BooleanErrorListener errorListener = BooleanErrorListener();
// TODO(paulberry): initialize the feature set appropriately based on the
// version of the SDK we are reading, and enable flags.
var featureSet = FeatureSet.fromEnableFlags([]);
- Scanner scanner = new Scanner(
- source, new CharSequenceReader(libraryFileContents), errorListener)
- ..configureFeatures(featureSet);
- Parser parser = new Parser(source, errorListener, featureSet: featureSet);
+ Scanner scanner =
+ Scanner(source, CharSequenceReader(libraryFileContents), errorListener)
+ ..configureFeatures(featureSet);
+ Parser parser = Parser(source, errorListener, featureSet: featureSet);
CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize());
SdkLibrariesReader_LibraryBuilder libraryBuilder =
- new SdkLibrariesReader_LibraryBuilder();
+ SdkLibrariesReader_LibraryBuilder();
// If any syntactic errors were found then don't try to visit the AST
// structure.
if (!errorListener.errorReported) {
diff --git a/pkg/analyzer/lib/src/dartdoc/dartdoc_directive_info.dart b/pkg/analyzer/lib/src/dartdoc/dartdoc_directive_info.dart
index 1449906..79be2df 100644
--- a/pkg/analyzer/lib/src/dartdoc/dartdoc_directive_info.dart
+++ b/pkg/analyzer/lib/src/dartdoc/dartdoc_directive_info.dart
@@ -9,12 +9,12 @@
/// A regular expression used to match a macro directive. There is one group
/// that contains the name of the template.
- static final macroRegExp = new RegExp(r'{@macro\s+([^}]+)}');
+ static final macroRegExp = RegExp(r'{@macro\s+([^}]+)}');
/// A regular expression used to match a template directive. There are two
/// groups. The first contains the name of the template, the second contains
/// the body of the template.
- static final templateRegExp = new RegExp(
+ static final templateRegExp = RegExp(
r'[ ]*{@template\s+(.+?)}([\s\S]+?){@endtemplate}[ ]*\n?',
multiLine: true);
@@ -23,7 +23,7 @@
/// These are in the form:
/// `{@youtube 560 315 https://www.youtube.com/watch?v=2uaoEDOgk_I}`.
static final videoRegExp =
- new RegExp(r'{@(youtube|animation)\s+[^}]+\s+[^}]+\s+([^}]+)}');
+ RegExp(r'{@(youtube|animation)\s+[^}]+\s+[^}]+\s+([^}]+)}');
/// A table mapping the names of templates to the unprocessed bodies of the
/// templates.
diff --git a/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart b/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart
index f563ec7..450acc8 100644
--- a/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart
+++ b/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart
@@ -20,12 +20,12 @@
/// set) is a duplicate of the [originalElement].
AnalysisError equalElementsInConstSet(
Source source, Expression duplicateElement, Expression originalElement) {
- return new AnalysisError(
+ return AnalysisError(
source,
duplicateElement.offset,
duplicateElement.length,
CompileTimeErrorCode.EQUAL_ELEMENTS_IN_CONST_SET, [], [
- new DiagnosticMessageImpl(
+ DiagnosticMessageImpl(
filePath: source.fullName,
message: "The first element with this value.",
offset: originalElement.offset,
@@ -37,9 +37,9 @@
/// is a duplicate of the [originalKey].
AnalysisError equalKeysInConstMap(
Source source, Expression duplicateKey, Expression originalKey) {
- return new AnalysisError(source, duplicateKey.offset, duplicateKey.length,
+ return AnalysisError(source, duplicateKey.offset, duplicateKey.length,
CompileTimeErrorCode.EQUAL_KEYS_IN_CONST_MAP, [], [
- new DiagnosticMessageImpl(
+ DiagnosticMessageImpl(
filePath: source.fullName,
message: "The first key with this value.",
offset: originalKey.offset,
@@ -61,7 +61,7 @@
.getAncestor((element) => element is CompilationUnitElement);
CharacterLocation location = unit.lineInfo.getLocation(declarationOffset);
contextMessages = [
- new DiagnosticMessageImpl(
+ DiagnosticMessageImpl(
filePath: source.fullName,
message:
"The declaration of '$name' is on line ${location.lineNumber}.",
@@ -69,7 +69,7 @@
length: staticElement.nameLength)
];
}
- return new AnalysisError(
+ return AnalysisError(
source,
identifier.offset,
identifier.length,
diff --git a/pkg/analyzer/lib/src/error.dart b/pkg/analyzer/lib/src/error.dart
index 1892b81..1de5c30 100644
--- a/pkg/analyzer/lib/src/error.dart
+++ b/pkg/analyzer/lib/src/error.dart
@@ -17,7 +17,7 @@
@override
String toString() {
- var builder = new StringBuffer();
+ var builder = StringBuffer();
// Print a less friendly string representation to ensure that
// error.source.contents is not executed, as .contents it isn't async
@@ -80,11 +80,11 @@
/// Creates an [AnalyzerErrorGroup] from a list of lower-level
/// [AnalysisError]s.
AnalyzerErrorGroup.fromAnalysisErrors(Iterable<AnalysisError> errors)
- : this(errors.map((e) => new AnalyzerError(e)));
+ : this(errors.map((e) => AnalyzerError(e)));
/// The errors in this collection.
List<AnalyzerError> get errors =>
- new UnmodifiableListView<AnalyzerError>(_errors);
+ UnmodifiableListView<AnalyzerError>(_errors);
String get message => toString();
@override
diff --git a/pkg/analyzer/lib/src/error/best_practices_verifier.dart b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
new file mode 100644
index 0000000..deeeed2
--- /dev/null
+++ b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
@@ -0,0 +1,1574 @@
+// Copyright (c) 2019, 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.
+
+import 'dart:collection';
+
+import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/token.dart';
+import 'package:analyzer/dart/ast/visitor.dart';
+import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/dart/element/nullability_suffix.dart';
+import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/src/context/builder.dart';
+import 'package:analyzer/src/dart/element/element.dart';
+import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
+import 'package:analyzer/src/dart/element/type.dart';
+import 'package:analyzer/src/dart/resolver/exit_detector.dart';
+import 'package:analyzer/src/error/codes.dart';
+import 'package:analyzer/src/generated/constant.dart';
+import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/resolver.dart';
+import 'package:analyzer/src/generated/type_system.dart';
+import 'package:analyzer/src/lint/linter.dart';
+import 'package:analyzer/src/workspace/workspace.dart';
+import 'package:meta/meta.dart';
+import 'package:path/path.dart' as path;
+
+/// Instances of the class `BestPracticesVerifier` traverse an AST structure
+/// looking for violations of Dart best practices.
+class BestPracticesVerifier extends RecursiveAstVisitor<void> {
+// static String _HASHCODE_GETTER_NAME = "hashCode";
+
+ static String _NULL_TYPE_NAME = "Null";
+
+ static String _TO_INT_METHOD_NAME = "toInt";
+
+ /// The class containing the AST nodes being visited, or `null` if we are not
+ /// in the scope of a class.
+ ClassElementImpl _enclosingClass;
+
+ /// A flag indicating whether a surrounding member (compilation unit or class)
+ /// is deprecated.
+ bool _inDeprecatedMember;
+
+ /// The error reporter by which errors will be reported.
+ final ErrorReporter _errorReporter;
+
+ /// The type [Null].
+ final InterfaceType _nullType;
+
+ /// The type system primitives
+ final TypeSystemImpl _typeSystem;
+
+ /// The inheritance manager to access interface type hierarchy.
+ final InheritanceManager3 _inheritanceManager;
+
+ /// The current library
+ final LibraryElement _currentLibrary;
+
+ final _InvalidAccessVerifier _invalidAccessVerifier;
+
+ /// The [WorkspacePackage] in which [_currentLibrary] is declared.
+ WorkspacePackage _workspacePackage;
+
+ /// The [LinterContext] used for possible const calculations.
+ LinterContext _linterContext;
+
+ /// Is `true` if NNBD is enabled for the library being analyzed.
+ final bool _isNonNullable;
+
+ /// True if inference failures should be reported, otherwise false.
+ final bool _strictInference;
+
+ /// Create a new instance of the [BestPracticesVerifier].
+ ///
+ /// @param errorReporter the error reporter
+ BestPracticesVerifier(
+ this._errorReporter,
+ TypeProvider typeProvider,
+ this._currentLibrary,
+ CompilationUnit unit,
+ String content, {
+ TypeSystemImpl typeSystem,
+ @required InheritanceManager3 inheritanceManager,
+ ResourceProvider resourceProvider,
+ DeclaredVariables declaredVariables,
+ AnalysisOptions analysisOptions,
+ }) : _nullType = typeProvider.nullType,
+ _typeSystem = typeSystem ??
+ TypeSystemImpl(
+ implicitCasts: true,
+ isNonNullableByDefault: false,
+ strictInference: false,
+ typeProvider: typeProvider,
+ ),
+ _isNonNullable = unit.featureSet.isEnabled(Feature.non_nullable),
+ _strictInference =
+ (analysisOptions as AnalysisOptionsImpl).strictInference,
+ _inheritanceManager = inheritanceManager,
+ _invalidAccessVerifier =
+ _InvalidAccessVerifier(_errorReporter, _currentLibrary) {
+ _inDeprecatedMember = _currentLibrary.hasDeprecated;
+ String libraryPath = _currentLibrary.source.fullName;
+ _workspacePackage = _getPackage(libraryPath, resourceProvider);
+
+ _linterContext = LinterContextImpl(
+ null /* allUnits */,
+ LinterContextUnit(content, unit),
+ declaredVariables,
+ typeProvider,
+ _typeSystem,
+ _inheritanceManager,
+ analysisOptions,
+ _workspacePackage,
+ );
+ }
+
+ @override
+ void visitAnnotation(Annotation node) {
+ ElementAnnotation element = node.elementAnnotation;
+ AstNode parent = node.parent;
+ if (element?.isFactory == true) {
+ if (parent is MethodDeclaration) {
+ _checkForInvalidFactory(parent);
+ } else {
+ _errorReporter
+ .reportErrorForNode(HintCode.INVALID_FACTORY_ANNOTATION, node, []);
+ }
+ } else if (element?.isImmutable == true) {
+ if (parent is! ClassOrMixinDeclaration && parent is! ClassTypeAlias) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_IMMUTABLE_ANNOTATION, node, []);
+ }
+ } else if (element?.isLiteral == true) {
+ if (parent is! ConstructorDeclaration ||
+ (parent as ConstructorDeclaration).constKeyword == null) {
+ _errorReporter
+ .reportErrorForNode(HintCode.INVALID_LITERAL_ANNOTATION, node, []);
+ }
+ } else if (element?.isNonVirtual == true) {
+ if (parent is FieldDeclaration) {
+ if (parent.isStatic) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_NON_VIRTUAL_ANNOTATION,
+ node,
+ [node.element.name]);
+ }
+ } else if (parent is MethodDeclaration) {
+ if (parent.parent is ExtensionDeclaration ||
+ parent.isStatic ||
+ parent.isAbstract) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_NON_VIRTUAL_ANNOTATION,
+ node,
+ [node.element.name]);
+ }
+ } else {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_NON_VIRTUAL_ANNOTATION, node, [node.element.name]);
+ }
+ } else if (element?.isSealed == true) {
+ if (!(parent is ClassDeclaration || parent is ClassTypeAlias)) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_SEALED_ANNOTATION, node, [node.element.name]);
+ }
+ } else if (element?.isVisibleForTemplate == true ||
+ element?.isVisibleForTesting == true) {
+ if (parent is Declaration) {
+ reportInvalidAnnotation(Element declaredElement) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_VISIBILITY_ANNOTATION,
+ node,
+ [declaredElement.name, node.name.name]);
+ }
+
+ if (parent is TopLevelVariableDeclaration) {
+ for (VariableDeclaration variable in parent.variables.variables) {
+ if (Identifier.isPrivateName(variable.declaredElement.name)) {
+ reportInvalidAnnotation(variable.declaredElement);
+ }
+ }
+ } else if (parent is FieldDeclaration) {
+ for (VariableDeclaration variable in parent.fields.variables) {
+ if (Identifier.isPrivateName(variable.declaredElement.name)) {
+ reportInvalidAnnotation(variable.declaredElement);
+ }
+ }
+ } else if (parent.declaredElement != null &&
+ Identifier.isPrivateName(parent.declaredElement.name)) {
+ reportInvalidAnnotation(parent.declaredElement);
+ }
+ } else {
+ // Something other than a declaration was annotated. Whatever this is,
+ // it probably warrants a Hint, but this has not been specified on
+ // visibleForTemplate or visibleForTesting, so leave it alone for now.
+ }
+ }
+
+ super.visitAnnotation(node);
+ }
+
+ @override
+ void visitArgumentList(ArgumentList node) {
+ for (Expression argument in node.arguments) {
+ ParameterElement parameter = argument.staticParameterElement;
+ if (parameter?.isOptionalPositional == true) {
+ _checkForDeprecatedMemberUse(parameter, argument);
+ }
+ }
+ super.visitArgumentList(node);
+ }
+
+ @override
+ void visitAsExpression(AsExpression node) {
+ _checkForUnnecessaryCast(node);
+ super.visitAsExpression(node);
+ }
+
+ @override
+ void visitAssignmentExpression(AssignmentExpression node) {
+ TokenType operatorType = node.operator.type;
+ if (operatorType != TokenType.EQ) {
+ _checkForDeprecatedMemberUse(node.staticElement, node);
+ }
+ super.visitAssignmentExpression(node);
+ }
+
+ @override
+ void visitBinaryExpression(BinaryExpression node) {
+ _checkForDivisionOptimizationHint(node);
+ _checkForDeprecatedMemberUse(node.staticElement, node);
+ super.visitBinaryExpression(node);
+ }
+
+ @override
+ void visitClassDeclaration(ClassDeclaration node) {
+ ClassElementImpl element = node.declaredElement;
+ _enclosingClass = element;
+ _invalidAccessVerifier._enclosingClass = element;
+
+ bool wasInDeprecatedMember = _inDeprecatedMember;
+ if (element != null && element.hasDeprecated) {
+ _inDeprecatedMember = true;
+ }
+
+ try {
+ // Commented out until we decide that we want this hint in the analyzer
+ // checkForOverrideEqualsButNotHashCode(node);
+ _checkForImmutable(node);
+ _checkForInvalidSealedSuperclass(node);
+ super.visitClassDeclaration(node);
+ } finally {
+ _enclosingClass = null;
+ _invalidAccessVerifier._enclosingClass = null;
+ _inDeprecatedMember = wasInDeprecatedMember;
+ }
+ }
+
+ @override
+ void visitClassTypeAlias(ClassTypeAlias node) {
+ _checkForImmutable(node);
+ _checkForInvalidSealedSuperclass(node);
+ super.visitClassTypeAlias(node);
+ }
+
+ @override
+ void visitConstructorDeclaration(ConstructorDeclaration node) {
+ if (node.declaredElement.isFactory) {
+ if (node.body is BlockFunctionBody) {
+ // Check the block for a return statement, if not, create the hint.
+ if (!ExitDetector.exits(node.body)) {
+ _errorReporter.reportErrorForNode(
+ HintCode.MISSING_RETURN, node, [node.returnType.name]);
+ }
+ }
+ }
+ _checkStrictInferenceInParameters(node.parameters);
+ super.visitConstructorDeclaration(node);
+ }
+
+ @override
+ void visitExportDirective(ExportDirective node) {
+ _checkForDeprecatedMemberUse(node.uriElement, node);
+ super.visitExportDirective(node);
+ }
+
+ @override
+ void visitFieldDeclaration(FieldDeclaration node) {
+ bool wasInDeprecatedMember = _inDeprecatedMember;
+ if (_hasDeprecatedAnnotation(node.metadata)) {
+ _inDeprecatedMember = true;
+ }
+
+ try {
+ super.visitFieldDeclaration(node);
+ for (var field in node.fields.variables) {
+ ExecutableElement getOverriddenPropertyAccessor() {
+ final element = field.declaredElement;
+ if (element is PropertyAccessorElement || element is FieldElement) {
+ Name name = Name(_currentLibrary.source.uri, element.name);
+ Element enclosingElement = element.enclosingElement;
+ if (enclosingElement is ClassElement) {
+ InterfaceType classType = enclosingElement.thisType;
+ var overridden = _inheritanceManager.getMember(classType, name,
+ forSuper: true);
+ // Check for a setter.
+ if (overridden == null) {
+ Name setterName =
+ Name(_currentLibrary.source.uri, '${element.name}=');
+ overridden = _inheritanceManager
+ .getMember(classType, setterName, forSuper: true);
+ }
+ return overridden;
+ }
+ }
+ return null;
+ }
+
+ final overriddenElement = getOverriddenPropertyAccessor();
+ if (_hasNonVirtualAnnotation(overriddenElement)) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER,
+ field.name,
+ [field.name, overriddenElement.enclosingElement.name]);
+ }
+ }
+ } finally {
+ _inDeprecatedMember = wasInDeprecatedMember;
+ }
+ }
+
+ @override
+ void visitFormalParameterList(FormalParameterList node) {
+ _checkRequiredParameter(node);
+ super.visitFormalParameterList(node);
+ }
+
+ @override
+ void visitFunctionDeclaration(FunctionDeclaration node) {
+ bool wasInDeprecatedMember = _inDeprecatedMember;
+ ExecutableElement element = node.declaredElement;
+ if (element != null && element.hasDeprecated) {
+ _inDeprecatedMember = true;
+ }
+ try {
+ _checkForMissingReturn(
+ node.returnType, node.functionExpression.body, element, node);
+
+ // Return types are inferred only on non-recursive local functions.
+ if (node.parent is CompilationUnit && !node.isSetter) {
+ _checkStrictInferenceReturnType(node.returnType, node, node.name.name);
+ }
+ _checkStrictInferenceInParameters(node.functionExpression.parameters);
+ super.visitFunctionDeclaration(node);
+ } finally {
+ _inDeprecatedMember = wasInDeprecatedMember;
+ }
+ }
+
+ @override
+ void visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
+ // TODO(srawlins): Check strict-inference return type on recursive
+ // local functions.
+ super.visitFunctionDeclarationStatement(node);
+ }
+
+ @override
+ void visitFunctionExpression(FunctionExpression node) {
+ if (node.parent is! FunctionDeclaration) {
+ _checkForMissingReturn(null, node.body, node.declaredElement, node);
+ }
+ DartType functionType = InferenceContext.getContext(node);
+ if (functionType is! FunctionType) {
+ _checkStrictInferenceInParameters(node.parameters);
+ }
+ super.visitFunctionExpression(node);
+ }
+
+ @override
+ void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
+ var callElement = node.staticElement;
+ if (callElement is MethodElement &&
+ callElement.name == FunctionElement.CALL_METHOD_NAME) {
+ _checkForDeprecatedMemberUse(callElement, node);
+ }
+
+ super.visitFunctionExpressionInvocation(node);
+ }
+
+ @override
+ void visitFunctionTypeAlias(FunctionTypeAlias node) {
+ _checkStrictInferenceReturnType(node.returnType, node, node.name.name);
+ super.visitFunctionTypeAlias(node);
+ }
+
+ @override
+ void visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
+ _checkStrictInferenceReturnType(
+ node.returnType, node, node.identifier.name);
+ _checkStrictInferenceInParameters(node.parameters);
+ super.visitFunctionTypedFormalParameter(node);
+ }
+
+ @override
+ void visitGenericFunctionType(GenericFunctionType node) {
+ // GenericTypeAlias is handled in [visitGenericTypeAlias], where a proper
+ // name can be reported in any message.
+ if (node.parent is! GenericTypeAlias) {
+ _checkStrictInferenceReturnType(node.returnType, node, node.toString());
+ }
+ super.visitGenericFunctionType(node);
+ }
+
+ @override
+ void visitGenericTypeAlias(GenericTypeAlias node) {
+ if (node.functionType != null) {
+ _checkStrictInferenceReturnType(
+ node.functionType.returnType, node, node.name.name);
+ }
+ super.visitGenericTypeAlias(node);
+ }
+
+ @override
+ void visitImportDirective(ImportDirective node) {
+ _checkForDeprecatedMemberUse(node.uriElement, node);
+ ImportElement importElement = node.element;
+ if (importElement != null && importElement.isDeferred) {
+ _checkForLoadLibraryFunction(node, importElement);
+ }
+ super.visitImportDirective(node);
+ }
+
+ @override
+ void visitIndexExpression(IndexExpression node) {
+ _checkForDeprecatedMemberUse(node.staticElement, node);
+ super.visitIndexExpression(node);
+ }
+
+ @override
+ void visitInstanceCreationExpression(InstanceCreationExpression node) {
+ _checkForDeprecatedMemberUse(node.staticElement, node);
+ _checkForLiteralConstructorUse(node);
+ super.visitInstanceCreationExpression(node);
+ }
+
+ @override
+ void visitIsExpression(IsExpression node) {
+ _checkAllTypeChecks(node);
+ super.visitIsExpression(node);
+ }
+
+ @override
+ void visitMethodDeclaration(MethodDeclaration node) {
+ bool wasInDeprecatedMember = _inDeprecatedMember;
+ ExecutableElement element = node.declaredElement;
+ Element enclosingElement = element?.enclosingElement;
+
+ InterfaceType classType =
+ enclosingElement is ClassElement ? enclosingElement.thisType : null;
+ Name name = Name(_currentLibrary.source.uri, element?.name ?? '');
+
+ bool elementIsOverride() =>
+ element is ClassMemberElement && enclosingElement != null
+ ? _inheritanceManager.getOverridden(classType, name) != null
+ : false;
+ ExecutableElement getConcreteOverriddenElement() =>
+ element is ClassMemberElement && enclosingElement != null
+ ? _inheritanceManager.getMember(classType, name, forSuper: true)
+ : null;
+ ExecutableElement getOverriddenPropertyAccessor() =>
+ element is PropertyAccessorElement && enclosingElement != null
+ ? _inheritanceManager.getMember(classType, name, forSuper: true)
+ : null;
+
+ if (element != null && element.hasDeprecated) {
+ _inDeprecatedMember = true;
+ }
+ try {
+ // This was determined to not be a good hint, see: dartbug.com/16029
+ //checkForOverridingPrivateMember(node);
+ _checkForMissingReturn(node.returnType, node.body, element, node);
+ _checkForUnnecessaryNoSuchMethod(node);
+
+ if (!node.isSetter && !elementIsOverride()) {
+ _checkStrictInferenceReturnType(node.returnType, node, node.name.name);
+ }
+ _checkStrictInferenceInParameters(node.parameters);
+
+ ExecutableElement overriddenElement = getConcreteOverriddenElement();
+ if (overriddenElement == null && (node.isSetter || node.isGetter)) {
+ overriddenElement = getOverriddenPropertyAccessor();
+ }
+
+ if (_hasNonVirtualAnnotation(overriddenElement)) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER,
+ node.name,
+ [node.name, overriddenElement.enclosingElement.name]);
+ }
+
+ super.visitMethodDeclaration(node);
+ } finally {
+ _inDeprecatedMember = wasInDeprecatedMember;
+ }
+ }
+
+ @override
+ void visitMethodInvocation(MethodInvocation node) {
+ _checkForNullAwareHints(node, node.operator);
+ super.visitMethodInvocation(node);
+ }
+
+ @override
+ void visitMixinDeclaration(MixinDeclaration node) {
+ _enclosingClass = node.declaredElement;
+ _invalidAccessVerifier._enclosingClass = _enclosingClass;
+
+ bool wasInDeprecatedMember = _inDeprecatedMember;
+ if (_hasDeprecatedAnnotation(node.metadata)) {
+ _inDeprecatedMember = true;
+ }
+
+ try {
+ _checkForImmutable(node);
+ _checkForInvalidSealedSuperclass(node);
+ super.visitMixinDeclaration(node);
+ } finally {
+ _enclosingClass = null;
+ _invalidAccessVerifier._enclosingClass = null;
+ _inDeprecatedMember = wasInDeprecatedMember;
+ }
+ }
+
+ @override
+ void visitPostfixExpression(PostfixExpression node) {
+ _checkForDeprecatedMemberUse(node.staticElement, node);
+ super.visitPostfixExpression(node);
+ }
+
+ @override
+ void visitPrefixExpression(PrefixExpression node) {
+ _checkForDeprecatedMemberUse(node.staticElement, node);
+ super.visitPrefixExpression(node);
+ }
+
+ @override
+ void visitPropertyAccess(PropertyAccess node) {
+ _checkForNullAwareHints(node, node.operator);
+ super.visitPropertyAccess(node);
+ }
+
+ @override
+ void visitRedirectingConstructorInvocation(
+ RedirectingConstructorInvocation node) {
+ _checkForDeprecatedMemberUse(node.staticElement, node);
+ super.visitRedirectingConstructorInvocation(node);
+ }
+
+ @override
+ void visitSimpleIdentifier(SimpleIdentifier node) {
+ _checkForDeprecatedMemberUseAtIdentifier(node);
+ _invalidAccessVerifier.verify(node);
+ super.visitSimpleIdentifier(node);
+ }
+
+ @override
+ void visitSuperConstructorInvocation(SuperConstructorInvocation node) {
+ _checkForDeprecatedMemberUse(node.staticElement, node);
+ super.visitSuperConstructorInvocation(node);
+ }
+
+ @override
+ void visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
+ bool wasInDeprecatedMember = _inDeprecatedMember;
+ if (_hasDeprecatedAnnotation(node.metadata)) {
+ _inDeprecatedMember = true;
+ }
+
+ try {
+ super.visitTopLevelVariableDeclaration(node);
+ } finally {
+ _inDeprecatedMember = wasInDeprecatedMember;
+ }
+ }
+
+ /// Check for the passed is expression for the unnecessary type check hint
+ /// codes as well as null checks expressed using an is expression.
+ ///
+ /// @param node the is expression to check
+ /// @return `true` if and only if a hint code is generated on the passed node
+ /// See [HintCode.TYPE_CHECK_IS_NOT_NULL], [HintCode.TYPE_CHECK_IS_NULL],
+ /// [HintCode.UNNECESSARY_TYPE_CHECK_TRUE], and
+ /// [HintCode.UNNECESSARY_TYPE_CHECK_FALSE].
+ bool _checkAllTypeChecks(IsExpression node) {
+ Expression expression = node.expression;
+ TypeAnnotation typeName = node.type;
+ TypeImpl lhsType = expression.staticType;
+ TypeImpl rhsType = typeName.type;
+ if (lhsType == null || rhsType == null) {
+ return false;
+ }
+ String rhsNameStr = typeName is TypeName ? typeName.name.name : null;
+ // if x is dynamic
+ if (rhsType.isDynamic && rhsNameStr == Keyword.DYNAMIC.lexeme) {
+ if (node.notOperator == null) {
+ // the is case
+ _errorReporter.reportErrorForNode(
+ HintCode.UNNECESSARY_TYPE_CHECK_TRUE, node);
+ } else {
+ // the is not case
+ _errorReporter.reportErrorForNode(
+ HintCode.UNNECESSARY_TYPE_CHECK_FALSE, node);
+ }
+ return true;
+ }
+ Element rhsElement = rhsType.element;
+ LibraryElement libraryElement = rhsElement?.library;
+ if (libraryElement != null && libraryElement.isDartCore) {
+ // `is Null` or `is! Null`
+ if (rhsNameStr == _NULL_TYPE_NAME) {
+ if (expression is NullLiteral) {
+ if (node.notOperator == null) {
+ _errorReporter.reportErrorForNode(
+ HintCode.UNNECESSARY_TYPE_CHECK_TRUE,
+ node,
+ );
+ } else {
+ _errorReporter.reportErrorForNode(
+ HintCode.UNNECESSARY_TYPE_CHECK_FALSE,
+ node,
+ );
+ }
+ } else {
+ if (node.notOperator == null) {
+ _errorReporter.reportErrorForNode(
+ HintCode.TYPE_CHECK_IS_NULL,
+ node,
+ );
+ } else {
+ _errorReporter.reportErrorForNode(
+ HintCode.TYPE_CHECK_IS_NOT_NULL,
+ node,
+ );
+ }
+ }
+ return true;
+ }
+ // `is Object` or `is! Object`
+ if (rhsType.isObject) {
+ var nullability = rhsType.nullabilitySuffix;
+ if (nullability == NullabilitySuffix.star ||
+ nullability == NullabilitySuffix.question) {
+ if (node.notOperator == null) {
+ _errorReporter.reportErrorForNode(
+ HintCode.UNNECESSARY_TYPE_CHECK_TRUE,
+ node,
+ );
+ } else {
+ _errorReporter.reportErrorForNode(
+ HintCode.UNNECESSARY_TYPE_CHECK_FALSE,
+ node,
+ );
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /// Given some [element], look at the associated metadata and report the use
+ /// of the member if it is declared as deprecated. If a diagnostic is reported
+ /// it should be reported at the given [node].
+ void _checkForDeprecatedMemberUse(Element element, AstNode node) {
+ bool isDeprecated(Element element) {
+ if (element is PropertyAccessorElement && element.isSynthetic) {
+ // TODO(brianwilkerson) Why isn't this the implementation for PropertyAccessorElement?
+ Element variable = element.variable;
+ if (variable == null) {
+ return false;
+ }
+ return variable.hasDeprecated;
+ }
+ return element.hasDeprecated;
+ }
+
+ bool isLocalParameter(Element element, AstNode node) {
+ if (element is ParameterElement) {
+ ExecutableElement definingFunction = element.enclosingElement;
+ FunctionBody body = node.thisOrAncestorOfType<FunctionBody>();
+ while (body != null) {
+ ExecutableElement enclosingFunction;
+ AstNode parent = body.parent;
+ if (parent is ConstructorDeclaration) {
+ enclosingFunction = parent.declaredElement;
+ } else if (parent is FunctionExpression) {
+ enclosingFunction = parent.declaredElement;
+ } else if (parent is MethodDeclaration) {
+ enclosingFunction = parent.declaredElement;
+ }
+ if (enclosingFunction == definingFunction) {
+ return true;
+ }
+ body = parent?.thisOrAncestorOfType<FunctionBody>();
+ }
+ }
+ return false;
+ }
+
+ if (!_inDeprecatedMember &&
+ element != null &&
+ isDeprecated(element) &&
+ !isLocalParameter(element, node)) {
+ String displayName = element.displayName;
+ if (element is ConstructorElement) {
+ // TODO(jwren) We should modify ConstructorElement.getDisplayName(),
+ // or have the logic centralized elsewhere, instead of doing this logic
+ // here.
+ displayName = element.enclosingElement.displayName;
+ if (element.displayName.isNotEmpty) {
+ displayName = "$displayName.${element.displayName}";
+ }
+ } else if (element is LibraryElement) {
+ displayName = element.definingCompilationUnit.source.uri.toString();
+ } else if (displayName == FunctionElement.CALL_METHOD_NAME &&
+ node is MethodInvocation &&
+ node.staticInvokeType is InterfaceType) {
+ DartType staticInvokeType = node.staticInvokeType;
+ displayName = "${staticInvokeType.displayName}.${element.displayName}";
+ }
+ LibraryElement library =
+ element is LibraryElement ? element : element.library;
+ String message = _deprecatedMessage(element);
+ if (message == null || message.isEmpty) {
+ HintCode hintCode = _isLibraryInWorkspacePackage(library)
+ ? HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
+ : HintCode.DEPRECATED_MEMBER_USE;
+ _errorReporter.reportErrorForNode(hintCode, node, [displayName]);
+ } else {
+ HintCode hintCode = _isLibraryInWorkspacePackage(library)
+ ? HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE
+ : HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE;
+ _errorReporter
+ .reportErrorForNode(hintCode, node, [displayName, message]);
+ }
+ }
+ }
+
+ /// For [SimpleIdentifier]s, only call [checkForDeprecatedMemberUse]
+ /// if the node is not in a declaration context.
+ ///
+ /// Also, if the identifier is a constructor name in a constructor invocation,
+ /// then calls to the deprecated constructor will be caught by
+ /// [visitInstanceCreationExpression] and
+ /// [visitSuperConstructorInvocation], and can be ignored by
+ /// this visit method.
+ ///
+ /// @param identifier some simple identifier to check for deprecated use of
+ /// @return `true` if and only if a hint code is generated on the passed node
+ /// See [HintCode.DEPRECATED_MEMBER_USE].
+ void _checkForDeprecatedMemberUseAtIdentifier(SimpleIdentifier identifier) {
+ if (identifier.inDeclarationContext()) {
+ return;
+ }
+ AstNode parent = identifier.parent;
+ if ((parent is ConstructorName && identical(identifier, parent.name)) ||
+ (parent is ConstructorDeclaration &&
+ identical(identifier, parent.returnType)) ||
+ (parent is SuperConstructorInvocation &&
+ identical(identifier, parent.constructorName)) ||
+ parent is HideCombinator) {
+ return;
+ }
+ _checkForDeprecatedMemberUse(identifier.staticElement, identifier);
+ }
+
+ /// Check for the passed binary expression for the
+ /// [HintCode.DIVISION_OPTIMIZATION].
+ ///
+ /// @param node the binary expression to check
+ /// @return `true` if and only if a hint code is generated on the passed node
+ /// See [HintCode.DIVISION_OPTIMIZATION].
+ bool _checkForDivisionOptimizationHint(BinaryExpression node) {
+ // Return if the operator is not '/'
+ if (node.operator.type != TokenType.SLASH) {
+ return false;
+ }
+ // Return if the '/' operator is not defined in core, or if we don't know
+ // its static type
+ MethodElement methodElement = node.staticElement;
+ if (methodElement == null) {
+ return false;
+ }
+ LibraryElement libraryElement = methodElement.library;
+ if (libraryElement != null && !libraryElement.isDartCore) {
+ return false;
+ }
+ // Report error if the (x/y) has toInt() invoked on it
+ AstNode parent = node.parent;
+ if (parent is ParenthesizedExpression) {
+ ParenthesizedExpression parenthesizedExpression =
+ _wrapParenthesizedExpression(parent);
+ AstNode grandParent = parenthesizedExpression.parent;
+ if (grandParent is MethodInvocation) {
+ if (_TO_INT_METHOD_NAME == grandParent.methodName.name &&
+ grandParent.argumentList.arguments.isEmpty) {
+ _errorReporter.reportErrorForNode(
+ HintCode.DIVISION_OPTIMIZATION, grandParent);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /// Checks whether [node] violates the rules of [immutable].
+ ///
+ /// If [node] is marked with [immutable] or inherits from a class or mixin
+ /// marked with [immutable], this function searches the fields of [node] and
+ /// its superclasses, reporting a hint if any non-final instance fields are
+ /// found.
+ void _checkForImmutable(NamedCompilationUnitMember node) {
+ /// Return `true` if the given class [element] is annotated with the
+ /// `@immutable` annotation.
+ bool isImmutable(ClassElement element) {
+ for (ElementAnnotation annotation in element.metadata) {
+ if (annotation.isImmutable) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /// Return `true` if the given class [element] or any superclass of it is
+ /// annotated with the `@immutable` annotation.
+ bool isOrInheritsImmutable(
+ ClassElement element, HashSet<ClassElement> visited) {
+ if (visited.add(element)) {
+ if (isImmutable(element)) {
+ return true;
+ }
+ for (InterfaceType interface in element.mixins) {
+ if (isOrInheritsImmutable(interface.element, visited)) {
+ return true;
+ }
+ }
+ for (InterfaceType mixin in element.interfaces) {
+ if (isOrInheritsImmutable(mixin.element, visited)) {
+ return true;
+ }
+ }
+ if (element.supertype != null) {
+ return isOrInheritsImmutable(element.supertype.element, visited);
+ }
+ }
+ return false;
+ }
+
+ /// Return `true` if the given class [element] defines a non-final instance
+ /// field.
+ Iterable<String> nonFinalInstanceFields(ClassElement element) {
+ return element.fields
+ .where((FieldElement field) =>
+ !field.isSynthetic && !field.isFinal && !field.isStatic)
+ .map((FieldElement field) => '${element.name}.${field.name}');
+ }
+
+ /// Return `true` if the given class [element] defines or inherits a
+ /// non-final field.
+ Iterable<String> definedOrInheritedNonFinalInstanceFields(
+ ClassElement element, HashSet<ClassElement> visited) {
+ Iterable<String> nonFinalFields = [];
+ if (visited.add(element)) {
+ nonFinalFields = nonFinalInstanceFields(element);
+ nonFinalFields = nonFinalFields.followedBy(element.mixins.expand(
+ (InterfaceType mixin) => nonFinalInstanceFields(mixin.element)));
+ if (element.supertype != null) {
+ nonFinalFields = nonFinalFields.followedBy(
+ definedOrInheritedNonFinalInstanceFields(
+ element.supertype.element, visited));
+ }
+ }
+ return nonFinalFields;
+ }
+
+ ClassElement element = node.declaredElement;
+ if (isOrInheritsImmutable(element, HashSet<ClassElement>())) {
+ Iterable<String> nonFinalFields =
+ definedOrInheritedNonFinalInstanceFields(
+ element, HashSet<ClassElement>());
+ if (nonFinalFields.isNotEmpty) {
+ _errorReporter.reportErrorForNode(
+ HintCode.MUST_BE_IMMUTABLE, node.name, [nonFinalFields.join(', ')]);
+ }
+ }
+ }
+
+ void _checkForInvalidFactory(MethodDeclaration decl) {
+ // Check declaration.
+ // Note that null return types are expected to be flagged by other analyses.
+ DartType returnType = decl.returnType?.type;
+ if (returnType is VoidType) {
+ _errorReporter.reportErrorForNode(HintCode.INVALID_FACTORY_METHOD_DECL,
+ decl.name, [decl.name.toString()]);
+ return;
+ }
+
+ // Check implementation.
+
+ FunctionBody body = decl.body;
+ if (body is EmptyFunctionBody) {
+ // Abstract methods are OK.
+ return;
+ }
+
+ // `new Foo()` or `null`.
+ bool factoryExpression(Expression expression) =>
+ expression is InstanceCreationExpression || expression is NullLiteral;
+
+ if (body is ExpressionFunctionBody && factoryExpression(body.expression)) {
+ return;
+ } else if (body is BlockFunctionBody) {
+ NodeList<Statement> statements = body.block.statements;
+ if (statements.isNotEmpty) {
+ Statement last = statements.last;
+ if (last is ReturnStatement && factoryExpression(last.expression)) {
+ return;
+ }
+ }
+ }
+
+ _errorReporter.reportErrorForNode(HintCode.INVALID_FACTORY_METHOD_IMPL,
+ decl.name, [decl.name.toString()]);
+ }
+
+ void _checkForInvalidSealedSuperclass(NamedCompilationUnitMember node) {
+ bool currentPackageContains(Element element) {
+ return _isLibraryInWorkspacePackage(element.library);
+ }
+
+ // [NamedCompilationUnitMember.declaredElement] is not necessarily a
+ // ClassElement, but [_checkForInvalidSealedSuperclass] should only be
+ // called with a [ClassOrMixinDeclaration], or a [ClassTypeAlias]. The
+ // `declaredElement` of these specific classes is a [ClassElement].
+ ClassElement element = node.declaredElement;
+ // TODO(srawlins): Perhaps replace this with a getter on Element, like
+ // `Element.hasOrInheritsSealed`?
+ for (InterfaceType supertype in element.allSupertypes) {
+ ClassElement superclass = supertype.element;
+ if (superclass.hasSealed) {
+ if (!currentPackageContains(superclass)) {
+ if (element.superclassConstraints.contains(supertype)) {
+ // This is a special violation of the sealed class contract,
+ // requiring specific messaging.
+ _errorReporter.reportErrorForNode(HintCode.MIXIN_ON_SEALED_CLASS,
+ node, [superclass.name.toString()]);
+ } else {
+ // This is a regular violation of the sealed class contract.
+ _errorReporter.reportErrorForNode(HintCode.SUBTYPE_OF_SEALED_CLASS,
+ node, [superclass.name.toString()]);
+ }
+ }
+ }
+ }
+ }
+
+ /// Check that the instance creation node is const if the constructor is
+ /// marked with [literal].
+ void _checkForLiteralConstructorUse(InstanceCreationExpression node) {
+ ConstructorName constructorName = node.constructorName;
+ ConstructorElement constructor = constructorName.staticElement;
+ if (constructor == null) {
+ return;
+ }
+ if (!node.isConst &&
+ constructor.hasLiteral &&
+ _linterContext.canBeConst(node)) {
+ // Echoing jwren's TODO from _checkForDeprecatedMemberUse:
+ // TODO(jwren) We should modify ConstructorElement.getDisplayName(), or
+ // have the logic centralized elsewhere, instead of doing this logic
+ // here.
+ String fullConstructorName = constructorName.type.name.name;
+ if (constructorName.name != null) {
+ fullConstructorName = '$fullConstructorName.${constructorName.name}';
+ }
+ HintCode hint = node.keyword?.keyword == Keyword.NEW
+ ? HintCode.NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR_USING_NEW
+ : HintCode.NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR;
+ _errorReporter.reportErrorForNode(hint, node, [fullConstructorName]);
+ }
+ }
+
+ /// Check that the imported library does not define a loadLibrary function.
+ /// The import has already been determined to be deferred when this is called.
+ ///
+ /// @param node the import directive to evaluate
+ /// @param importElement the [ImportElement] retrieved from the node
+ /// @return `true` if and only if an error code is generated on the passed
+ /// node
+ /// See [CompileTimeErrorCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION].
+ bool _checkForLoadLibraryFunction(
+ ImportDirective node, ImportElement importElement) {
+ LibraryElement importedLibrary = importElement.importedLibrary;
+ if (importedLibrary == null) {
+ return false;
+ }
+ if (importedLibrary.hasLoadLibraryFunction) {
+ _errorReporter.reportErrorForNode(
+ HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION,
+ node,
+ [importedLibrary.name]);
+ return true;
+ }
+ return false;
+ }
+
+ /// Generate a hint for functions or methods that have a return type, but do
+ /// not have a return statement on all branches. At the end of blocks with no
+ /// return, Dart implicitly returns `null`. Avoiding these implicit returns
+ /// is considered a best practice.
+ ///
+ /// Note: for async functions/methods, this hint only applies when the
+ /// function has a return type that Future<Null> is not assignable to.
+ ///
+ /// See [HintCode.MISSING_RETURN].
+ void _checkForMissingReturn(TypeAnnotation returnNode, FunctionBody body,
+ ExecutableElement element, AstNode functionNode) {
+ if (body is BlockFunctionBody) {
+ // Prefer the type from the element model, in case we've inferred one.
+ DartType returnType = element?.returnType ?? returnNode?.type;
+
+ // Skip the check if we're missing a return type (e.g. erroneous code).
+ // Generators are never required to have a return statement.
+ if (returnType == null || body.isGenerator) {
+ return;
+ }
+
+ var flattenedType =
+ body.isAsynchronous ? _typeSystem.flatten(returnType) : returnType;
+
+ // Function expressions without a return will have their return type set
+ // to `Null` regardless of their context type. So we need to figure out
+ // if a return type was expected from the original downwards context.
+ //
+ // This helps detect hint cases like `int Function() f = () {}`.
+ // See https://github.com/dart-lang/sdk/issues/28233 for context.
+ if (flattenedType.isDartCoreNull && functionNode is FunctionExpression) {
+ var contextType = InferenceContext.getContext(functionNode);
+ if (contextType is FunctionType) {
+ returnType = contextType.returnType;
+ flattenedType = body.isAsynchronous
+ ? _typeSystem.flatten(returnType)
+ : returnType;
+ }
+ }
+
+ // dynamic, Null, void, and FutureOr<T> where T is (dynamic, Null, void)
+ // are allowed to omit a return.
+ if (flattenedType.isDartAsyncFutureOr) {
+ flattenedType = (flattenedType as InterfaceType).typeArguments[0];
+ }
+ if (flattenedType.isBottom ||
+ flattenedType.isDynamic ||
+ flattenedType.isDartCoreNull ||
+ flattenedType.isVoid) {
+ return;
+ }
+ // Otherwise issue a warning if the block doesn't have a return.
+ if (!ExitDetector.exits(body)) {
+ AstNode errorNode = functionNode is MethodDeclaration
+ ? functionNode.name
+ : functionNode is FunctionDeclaration
+ ? functionNode.name
+ : functionNode;
+ _errorReporter.reportErrorForNode(
+ HintCode.MISSING_RETURN, errorNode, [returnType.displayName]);
+ }
+ }
+ }
+
+ /// Produce several null-aware related hints.
+ void _checkForNullAwareHints(Expression node, Token operator) {
+ if (_isNonNullable) {
+ return;
+ }
+
+ if (operator == null || operator.type != TokenType.QUESTION_PERIOD) {
+ return;
+ }
+
+ // childOfParent is used to know from which branch node comes.
+ var childOfParent = node;
+ var parent = node.parent;
+ while (parent is ParenthesizedExpression) {
+ childOfParent = parent;
+ parent = parent.parent;
+ }
+
+ // CAN_BE_NULL_AFTER_NULL_AWARE
+ if (parent is MethodInvocation &&
+ !parent.isNullAware &&
+ _nullType.lookUpMethod(parent.methodName.name, _currentLibrary) ==
+ null) {
+ _errorReporter.reportErrorForNode(
+ HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, childOfParent);
+ return;
+ }
+ if (parent is PropertyAccess &&
+ !parent.isNullAware &&
+ _nullType.lookUpGetter(parent.propertyName.name, _currentLibrary) ==
+ null) {
+ _errorReporter.reportErrorForNode(
+ HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, childOfParent);
+ return;
+ }
+ if (parent is CascadeExpression && parent.target == childOfParent) {
+ _errorReporter.reportErrorForNode(
+ HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, childOfParent);
+ return;
+ }
+
+ // NULL_AWARE_IN_CONDITION
+ if (parent is IfStatement && parent.condition == childOfParent ||
+ parent is ForPartsWithDeclarations &&
+ parent.condition == childOfParent ||
+ parent is DoStatement && parent.condition == childOfParent ||
+ parent is WhileStatement && parent.condition == childOfParent ||
+ parent is ConditionalExpression && parent.condition == childOfParent ||
+ parent is AssertStatement && parent.condition == childOfParent) {
+ _errorReporter.reportErrorForNode(
+ HintCode.NULL_AWARE_IN_CONDITION, childOfParent);
+ return;
+ }
+
+ // NULL_AWARE_IN_LOGICAL_OPERATOR
+ if (parent is PrefixExpression && parent.operator.type == TokenType.BANG ||
+ parent is BinaryExpression &&
+ [TokenType.BAR_BAR, TokenType.AMPERSAND_AMPERSAND]
+ .contains(parent.operator.type)) {
+ _errorReporter.reportErrorForNode(
+ HintCode.NULL_AWARE_IN_LOGICAL_OPERATOR, childOfParent);
+ return;
+ }
+
+ // NULL_AWARE_BEFORE_OPERATOR
+ if (parent is BinaryExpression &&
+ ![TokenType.EQ_EQ, TokenType.BANG_EQ, TokenType.QUESTION_QUESTION]
+ .contains(parent.operator.type) &&
+ parent.leftOperand == childOfParent) {
+ _errorReporter.reportErrorForNode(
+ HintCode.NULL_AWARE_BEFORE_OPERATOR, childOfParent);
+ return;
+ }
+ }
+
+ /// Check for the passed as expression for the [HintCode.UNNECESSARY_CAST]
+ /// hint code.
+ ///
+ /// @param node the as expression to check
+ /// @return `true` if and only if a hint code is generated on the passed node
+ /// See [HintCode.UNNECESSARY_CAST].
+ bool _checkForUnnecessaryCast(AsExpression node) {
+ // TODO(jwren) After dartbug.com/13732, revisit this, we should be able to
+ // remove the (x is! TypeParameterType) checks.
+ AstNode parent = node.parent;
+ if (parent is ConditionalExpression &&
+ (node == parent.thenExpression || node == parent.elseExpression)) {
+ Expression thenExpression = parent.thenExpression;
+ DartType thenType;
+ if (thenExpression is AsExpression) {
+ thenType = thenExpression.expression.staticType;
+ } else {
+ thenType = thenExpression.staticType;
+ }
+ Expression elseExpression = parent.elseExpression;
+ DartType elseType;
+ if (elseExpression is AsExpression) {
+ elseType = elseExpression.expression.staticType;
+ } else {
+ elseType = elseExpression.staticType;
+ }
+ if (thenType != null &&
+ elseType != null &&
+ !thenType.isDynamic &&
+ !elseType.isDynamic &&
+ !_typeSystem.isSubtypeOf(thenType, elseType) &&
+ !_typeSystem.isSubtypeOf(elseType, thenType)) {
+ return false;
+ }
+ }
+ DartType lhsType = node.expression.staticType;
+ DartType rhsType = node.type.type;
+ if (lhsType != null &&
+ rhsType != null &&
+ !lhsType.isDynamic &&
+ !rhsType.isDynamic &&
+ _typeSystem.isSubtypeOf(lhsType, rhsType)) {
+ _errorReporter.reportErrorForNode(HintCode.UNNECESSARY_CAST, node);
+ return true;
+ }
+ return false;
+ }
+
+ /// Generate a hint for `noSuchMethod` methods that do nothing except of
+ /// calling another `noSuchMethod` that is not defined by `Object`.
+ ///
+ /// @return `true` if and only if a hint code is generated on the passed node
+ /// See [HintCode.UNNECESSARY_NO_SUCH_METHOD].
+ bool _checkForUnnecessaryNoSuchMethod(MethodDeclaration node) {
+ if (node.name.name != FunctionElement.NO_SUCH_METHOD_METHOD_NAME) {
+ return false;
+ }
+ bool isNonObjectNoSuchMethodInvocation(Expression invocation) {
+ if (invocation is MethodInvocation &&
+ invocation.target is SuperExpression &&
+ invocation.argumentList.arguments.length == 1) {
+ SimpleIdentifier name = invocation.methodName;
+ if (name.name == FunctionElement.NO_SUCH_METHOD_METHOD_NAME) {
+ Element methodElement = name.staticElement;
+ Element classElement = methodElement?.enclosingElement;
+ return methodElement is MethodElement &&
+ classElement is ClassElement &&
+ !classElement.isDartCoreObject;
+ }
+ }
+ return false;
+ }
+
+ FunctionBody body = node.body;
+ if (body is ExpressionFunctionBody) {
+ if (isNonObjectNoSuchMethodInvocation(body.expression)) {
+ _errorReporter.reportErrorForNode(
+ HintCode.UNNECESSARY_NO_SUCH_METHOD, node);
+ return true;
+ }
+ } else if (body is BlockFunctionBody) {
+ List<Statement> statements = body.block.statements;
+ if (statements.length == 1) {
+ Statement returnStatement = statements.first;
+ if (returnStatement is ReturnStatement &&
+ isNonObjectNoSuchMethodInvocation(returnStatement.expression)) {
+ _errorReporter.reportErrorForNode(
+ HintCode.UNNECESSARY_NO_SUCH_METHOD, node);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ void _checkRequiredParameter(FormalParameterList node) {
+ final requiredParameters =
+ node.parameters.where((p) => p.declaredElement?.hasRequired == true);
+ final nonNamedParamsWithRequired =
+ requiredParameters.where((p) => p.isPositional);
+ final namedParamsWithRequiredAndDefault = requiredParameters
+ .where((p) => p.isNamed)
+ .where((p) => p.declaredElement.defaultValueCode != null);
+ for (final param in nonNamedParamsWithRequired.where((p) => p.isOptional)) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_REQUIRED_OPTIONAL_POSITIONAL_PARAM,
+ param,
+ [param.identifier.name]);
+ }
+ for (final param in nonNamedParamsWithRequired.where((p) => p.isRequired)) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_REQUIRED_POSITIONAL_PARAM,
+ param,
+ [param.identifier.name]);
+ }
+ for (final param in namedParamsWithRequiredAndDefault) {
+ _errorReporter.reportErrorForNode(HintCode.INVALID_REQUIRED_NAMED_PARAM,
+ param, [param.identifier.name]);
+ }
+ }
+
+ /// In "strict-inference" mode, check that each of the [parameters]' type is
+ /// specified.
+ void _checkStrictInferenceInParameters(FormalParameterList parameters) {
+ void checkParameterTypeIsKnown(SimpleFormalParameter parameter) {
+ if (parameter.type == null) {
+ ParameterElement element = parameter.declaredElement;
+ _errorReporter.reportTypeErrorForNode(
+ HintCode.INFERENCE_FAILURE_ON_UNTYPED_PARAMETER,
+ parameter,
+ [element.displayName],
+ );
+ }
+ }
+
+ if (_strictInference && parameters != null) {
+ for (FormalParameter parameter in parameters.parameters) {
+ if (parameter is SimpleFormalParameter) {
+ checkParameterTypeIsKnown(parameter);
+ } else if (parameter is DefaultFormalParameter) {
+ if (parameter.parameter is SimpleFormalParameter) {
+ checkParameterTypeIsKnown(parameter.parameter);
+ }
+ }
+ }
+ }
+ }
+
+ /// In "strict-inference" mode, check that [returnNode]'s return type is
+ /// specified.
+ void _checkStrictInferenceReturnType(
+ AstNode returnType, AstNode reportNode, String displayName) {
+ if (!_strictInference) {
+ return;
+ }
+ if (returnType == null) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE,
+ reportNode,
+ [displayName]);
+ }
+ }
+
+ WorkspacePackage _getPackage(String root, ResourceProvider resourceProvider) {
+ Workspace workspace = _currentLibrary.session?.analysisContext?.workspace;
+ // If there is no driver setup (as in test environments), we need to create
+ // a workspace ourselves.
+ // todo (pq): fix tests or otherwise de-dup this logic shared w/ library_analyzer.
+ if (workspace == null) {
+ final builder = ContextBuilder(
+ resourceProvider, null /* sdkManager */, null /* contentCache */);
+ workspace =
+ ContextBuilder.createWorkspace(resourceProvider, root, builder);
+ }
+ return workspace?.findPackageFor(root);
+ }
+
+ bool _isLibraryInWorkspacePackage(LibraryElement library) {
+ if (_workspacePackage == null || library == null) {
+ // Better to not make a big claim that they _are_ in the same package,
+ // if we were unable to determine what package [_currentLibrary] is in.
+ return false;
+ }
+ return _workspacePackage.contains(library.source);
+ }
+
+ /// Return the message in the deprecated annotation on the given [element], or
+ /// `null` if the element doesn't have a deprecated annotation or if the
+ /// annotation does not have a message.
+ static String _deprecatedMessage(Element element) {
+ // Implicit getters/setters.
+ if (element.isSynthetic && element is PropertyAccessorElement) {
+ element = (element as PropertyAccessorElement).variable;
+ }
+ ElementAnnotationImpl annotation = element.metadata.firstWhere(
+ (e) => e.isDeprecated,
+ orElse: () => null,
+ );
+ if (annotation == null || annotation.element is PropertyAccessorElement) {
+ return null;
+ }
+ DartObject constantValue = annotation.computeConstantValue();
+ return constantValue?.getField('message')?.toStringValue() ??
+ constantValue?.getField('expires')?.toStringValue();
+ }
+
+ static bool _hasDeprecatedAnnotation(List<Annotation> annotations) {
+ for (var i = 0; i < annotations.length; i++) {
+ if (annotations[i].elementAnnotation.isDeprecated) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ static bool _hasNonVirtualAnnotation(ExecutableElement element) {
+ if (element == null) {
+ return false;
+ }
+ if (element is PropertyAccessorElement && element.isSynthetic) {
+ return element.variable.hasNonVirtual;
+ }
+ return element.hasNonVirtual;
+ }
+
+ /// Given a parenthesized expression, this returns the parent (or recursively
+ /// grand-parent) of the expression that is a parenthesized expression, but
+ /// whose parent is not a parenthesized expression.
+ ///
+ /// For example given the code `(((e)))`: `(e) -> (((e)))`.
+ ///
+ /// @param parenthesizedExpression some expression whose parent is a
+ /// parenthesized expression
+ /// @return the first parent or grand-parent that is a parenthesized
+ /// expression, that does not have a parenthesized expression parent
+ static ParenthesizedExpression _wrapParenthesizedExpression(
+ ParenthesizedExpression parenthesizedExpression) {
+ AstNode parent = parenthesizedExpression.parent;
+ if (parent is ParenthesizedExpression) {
+ return _wrapParenthesizedExpression(parent);
+ }
+ return parenthesizedExpression;
+ }
+}
+
+class _InvalidAccessVerifier {
+ static final _templateExtension = '.template';
+ static final _testDir = '${path.separator}test${path.separator}';
+ static final _testingDir = '${path.separator}testing${path.separator}';
+
+ final ErrorReporter _errorReporter;
+ final LibraryElement _library;
+
+ bool _inTemplateSource;
+ bool _inTestDirectory;
+
+ ClassElement _enclosingClass;
+
+ _InvalidAccessVerifier(this._errorReporter, this._library) {
+ var path = _library.source.fullName;
+ _inTemplateSource = path.contains(_templateExtension);
+ _inTestDirectory = path.contains(_testDir) || path.contains(_testingDir);
+ }
+
+ /// Produces a hint if [identifier] is accessed from an invalid location. In
+ /// particular:
+ ///
+ /// * if the given identifier is a protected closure, field or
+ /// getter/setter, method closure or invocation accessed outside a subclass,
+ /// or accessed outside the library wherein the identifier is declared, or
+ /// * if the given identifier is a closure, field, getter, setter, method
+ /// closure or invocation which is annotated with `visibleForTemplate`, and
+ /// is accessed outside of the defining library, and the current library
+ /// does not have the suffix '.template' in its source path, or
+ /// * if the given identifier is a closure, field, getter, setter, method
+ /// closure or invocation which is annotated with `visibleForTesting`, and
+ /// is accessed outside of the defining library, and the current library
+ /// does not have a directory named 'test' or 'testing' in its path.
+ void verify(SimpleIdentifier identifier) {
+ if (identifier.inDeclarationContext() || _inCommentReference(identifier)) {
+ return;
+ }
+
+ // This is the same logic used in [checkForDeprecatedMemberUseAtIdentifier]
+ // to avoid reporting an error twice for named constructors.
+ AstNode parent = identifier.parent;
+ if (parent is ConstructorName && identical(identifier, parent.name)) {
+ return;
+ }
+ AstNode grandparent = parent?.parent;
+ Element element = grandparent is ConstructorName
+ ? grandparent.staticElement
+ : identifier.staticElement;
+ if (element == null || _inCurrentLibrary(element)) {
+ return;
+ }
+
+ bool hasProtected = _hasProtected(element);
+ if (hasProtected) {
+ ClassElement definingClass = element.enclosingElement;
+ if (_hasTypeOrSuperType(_enclosingClass, definingClass)) {
+ return;
+ }
+ }
+
+ bool hasVisibleForTemplate = _hasVisibleForTemplate(element);
+ if (hasVisibleForTemplate) {
+ if (_inTemplateSource || _inExportDirective(identifier)) {
+ return;
+ }
+ }
+
+ bool hasVisibleForTesting = _hasVisibleForTesting(element);
+ if (hasVisibleForTesting) {
+ if (_inTestDirectory || _inExportDirective(identifier)) {
+ return;
+ }
+ }
+
+ // At this point, [identifier] was not cleared as protected access, nor
+ // cleared as access for templates or testing. Report the appropriate
+ // violation(s).
+ Element definingClass = element.enclosingElement;
+ if (hasProtected) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_USE_OF_PROTECTED_MEMBER,
+ identifier,
+ [identifier.name, definingClass.source.uri]);
+ }
+ if (hasVisibleForTemplate) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER,
+ identifier,
+ [identifier.name, definingClass.source.uri]);
+ }
+ if (hasVisibleForTesting) {
+ _errorReporter.reportErrorForNode(
+ HintCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER,
+ identifier,
+ [identifier.name, definingClass.source.uri]);
+ }
+ }
+
+ bool _hasProtected(Element element) {
+ if (element is PropertyAccessorElement &&
+ element.enclosingElement is ClassElement &&
+ (element.hasProtected || element.variable.hasProtected)) {
+ return true;
+ }
+ if (element is MethodElement &&
+ element.enclosingElement is ClassElement &&
+ element.hasProtected) {
+ return true;
+ }
+ return false;
+ }
+
+ bool _hasTypeOrSuperType(ClassElement element, ClassElement superElement) {
+ if (element == null) {
+ return false;
+ }
+ if (element == superElement) {
+ return true;
+ }
+ // TODO(scheglov) `allSupertypes` is very expensive
+ var allSupertypes = element.allSupertypes;
+ for (var i = 0; i < allSupertypes.length; i++) {
+ var supertype = allSupertypes[i];
+ if (supertype.element == superElement) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool _hasVisibleForTemplate(Element element) {
+ if (element == null) {
+ return false;
+ }
+ if (element.hasVisibleForTemplate) {
+ return true;
+ }
+ if (element is PropertyAccessorElement &&
+ element.enclosingElement is ClassElement &&
+ element.variable.hasVisibleForTemplate) {
+ return true;
+ }
+ return false;
+ }
+
+ bool _hasVisibleForTesting(Element element) {
+ if (element == null) {
+ return false;
+ }
+ if (element.hasVisibleForTesting) {
+ return true;
+ }
+ if (element is PropertyAccessorElement &&
+ element.enclosingElement is ClassElement &&
+ element.variable.hasVisibleForTesting) {
+ return true;
+ }
+ return false;
+ }
+
+ bool _inCommentReference(SimpleIdentifier identifier) {
+ var parent = identifier.parent;
+ return parent is CommentReference || parent?.parent is CommentReference;
+ }
+
+ bool _inCurrentLibrary(Element element) => element.library == _library;
+
+ bool _inExportDirective(SimpleIdentifier identifier) =>
+ identifier.parent is Combinator &&
+ identifier.parent.parent is ExportDirective;
+}
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index 4e41047..36bee0e 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -428,6 +428,19 @@
"or removing the 'await' before the for loop.");
/**
+ * nnbd/feature-specification.md
+ *
+ * It is an error for the initializer expression of a `late` local variable
+ * to use a prefix `await` expression.
+ */
+ static const CompileTimeErrorCode AWAIT_IN_LATE_LOCAL_VARIABLE_INITIALIZER =
+ const CompileTimeErrorCode('AWAIT_IN_LATE_LOCAL_VARIABLE_INITIALIZER',
+ "The await expression can't be used in a 'late' local variable.",
+ correction:
+ "Try removing the 'late' modifier, or rewriting the initializer "
+ "without using the 'await' expression.");
+
+ /**
* 16.30 Await Expressions: It is a compile-time error if the function
* immediately enclosing _a_ is not declared asynchronous. (Where _a_ is the
* await expression.)
@@ -964,7 +977,8 @@
static const CompileTimeErrorCode CONST_NOT_INITIALIZED =
const CompileTimeErrorCode(
'CONST_NOT_INITIALIZED', "The constant '{0}' must be initialized.",
- correction: "Try adding an initialization to the declaration.");
+ correction: "Try adding an initialization to the declaration.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -1569,7 +1583,8 @@
'EXTENDS_NON_CLASS', "Classes can only extend other classes.",
correction:
"Try specifying a different superclass, or removing the extends "
- "clause.");
+ "clause.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -2258,7 +2273,8 @@
// ```
static const CompileTimeErrorCode IMPLICIT_THIS_REFERENCE_IN_INITIALIZER =
const CompileTimeErrorCode('IMPLICIT_THIS_REFERENCE_IN_INITIALIZER',
- "Only static members can be accessed in initializers.");
+ "Only static members can be accessed in initializers.",
+ hasPublishedDocs: true);
/**
* SDK implementation libraries can be imported only by other SDK libraries.
@@ -2445,7 +2461,8 @@
const CompileTimeErrorCode('INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD',
"'{0}' isn't a field in the enclosing class.",
correction: "Try correcting the name to match an existing field, or "
- "defining a field named '{0}'.");
+ "defining a field named '{0}'.",
+ hasPublishedDocs: true);
/**
* 7.6.1 Generative Constructors: An initializing formal has the form
@@ -2749,7 +2766,8 @@
// ```
static const CompileTimeErrorCode INVALID_OVERRIDE =
const CompileTimeErrorCode('INVALID_OVERRIDE',
- "'{1}.{0}' ('{2}') isn't a valid override of '{3}.{0}' ('{4}').");
+ "'{1}.{0}' ('{2}') isn't a valid override of '{3}.{0}' ('{4}').",
+ hasPublishedDocs: true);
/**
* 12.10 This: It is a compile-time error if this appears in a top-level
@@ -2876,7 +2894,8 @@
const CompileTimeErrorCode(
'INVOCATION_OF_EXTENSION_WITHOUT_CALL',
"The extension '{0}' doesn't define a 'call' method so the override "
- "can't be used in an invocation.");
+ "can't be used in an invocation.",
+ hasPublishedDocs: true);
/**
* 13.13 Break: It is a compile-time error if no such statement
@@ -2913,6 +2932,18 @@
"correcting the name to match an existing label.");
/**
+ * nnbd/feature-specification.md
+ *
+ * It is an error for a class with a `const` constructor to have a
+ * `late final` field.
+ */
+ static const CompileTimeErrorCode LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR =
+ const CompileTimeErrorCode('LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR',
+ "Can't have a late final field in a class with a const constructor.",
+ correction: "Try removing the 'late' modifier, or don't declare "
+ "'const' constructors.");
+
+ /**
* No parameters.
*/
// #### Description
@@ -3277,7 +3308,8 @@
// Otherwise, remove the type from the on clause.
static const CompileTimeErrorCode MIXIN_SUPER_CLASS_CONSTRAINT_NON_INTERFACE =
const CompileTimeErrorCode('MIXIN_SUPER_CLASS_CONSTRAINT_NON_INTERFACE',
- "Only classes and mixins can be used as superclass constraints.");
+ "Only classes and mixins can be used as superclass constraints.",
+ hasPublishedDocs: true);
/**
* 9.1 Mixin Application: It is a compile-time error if <i>S</i> does not
@@ -3319,50 +3351,28 @@
correction: "Try adding an empty argument list.");
/**
- * This error is generated if a constructor declaration has an implicit
- * invocation of a zero argument super constructor (`super()`), but the
- * superclass does not define a zero argument constructor.
- *
- * 7.6.1 Generative Constructors: If no superinitializer is provided, an
- * implicit superinitializer of the form <b>super</b>() is added at the end of
- * <i>k</i>'s initializer list, unless the enclosing class is class
- * <i>Object</i>.
- *
- * 7.6.1 Generative constructors. It is a compile-time error if class <i>S</i>
- * does not declare a generative constructor named <i>S</i> (respectively
- * <i>S.id</i>)
- *
* Parameters:
- * 0: the name of the superclass that does not define the implicitly invoked
+ * 0: the name of the superclass that does not define an implicitly invoked
* constructor
*/
static const CompileTimeErrorCode NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT =
- const CompileTimeErrorCode('NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT',
+ const CompileTimeErrorCodeWithUniqueName(
+ 'NO_DEFAULT_SUPER_CONSTRUCTOR',
+ 'NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT',
"The superclass '{0}' doesn't have a zero argument constructor.",
correction: "Try declaring a zero argument constructor in '{0}', or "
"explicitly invoking a different constructor in '{0}'.");
/**
- * This error is generated if a class declaration has an implicit default
- * constructor, which implicitly invokes a zero argument super constructor
- * (`super()`), but the superclass does not define a zero argument
- * constructor.
- *
- * 7.6 Constructors: Iff no constructor is specified for a class <i>C</i>, it
- * implicitly has a default constructor C() : <b>super<b>() {}, unless
- * <i>C</i> is class <i>Object</i>.
- *
- * 7.6.1 Generative constructors. It is a compile-time error if class <i>S</i>
- * does not declare a generative constructor named <i>S</i> (respectively
- * <i>S.id</i>)
- *
* Parameters:
- * 0: the name of the superclass that does not define the implicitly invoked
+ * 0: the name of the superclass that does not define an implicitly invoked
* constructor
* 1: the name of the subclass that does not contain any explicit constructors
*/
static const CompileTimeErrorCode NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT =
- const CompileTimeErrorCode('NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT',
+ const CompileTimeErrorCodeWithUniqueName(
+ 'NO_DEFAULT_SUPER_CONSTRUCTOR',
+ 'NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT',
"The superclass '{0}' doesn't have a zero argument constructor.",
correction: "Try declaring a zero argument constructor in '{0}', or "
"declaring a constructor in {1} that explicitly invokes a "
@@ -3483,7 +3493,8 @@
// ```
static const CompileTimeErrorCode NON_CONSTANT_DEFAULT_VALUE =
const CompileTimeErrorCode('NON_CONSTANT_DEFAULT_VALUE',
- "The default value of an optional parameter must be constant.");
+ "The default value of an optional parameter must be constant.",
+ hasPublishedDocs: true);
/**
* 6.2.2 Optional Formals: It is a compile-time error if the default value of
@@ -5244,7 +5255,8 @@
const CompileTimeErrorCode(
'WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR',
"Operator '{0}' should declare exactly {1} parameters, but {2} "
- "found.");
+ "found.",
+ hasPublishedDocs: true);
/**
* 7.1.1 Operators: It is a compile time error if the arity of the
@@ -5368,7 +5380,7 @@
const CompileTimeErrorCode(String name, String message,
{String correction,
bool hasPublishedDocs,
- bool isUnresolvedIdentifier: false})
+ bool isUnresolvedIdentifier = false})
: super.temporary(name, message,
correction: correction,
hasPublishedDocs: hasPublishedDocs,
@@ -5381,6 +5393,17 @@
ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
}
+class CompileTimeErrorCodeWithUniqueName extends CompileTimeErrorCode {
+ @override
+ final String uniqueName;
+
+ const CompileTimeErrorCodeWithUniqueName(
+ String name, this.uniqueName, String message,
+ {String correction, bool hasPublishedDocs})
+ : super(name, message,
+ correction: correction, hasPublishedDocs: hasPublishedDocs);
+}
+
/**
* The error codes used for static type warnings. The convention for this class
* is for the name of the error code to indicate the problem that caused the
@@ -5616,7 +5639,7 @@
static const StaticTypeWarningCode NON_BOOL_CONDITION =
const StaticTypeWarningCode(
'NON_BOOL_CONDITION', "Conditions must have a static type of 'bool'.",
- correction: "Try changing the condition.");
+ correction: "Try changing the condition.", hasPublishedDocs: true);
/**
* 17.17 Assert: It is a static type warning if the type of <i>e</i> may not
@@ -5698,7 +5721,8 @@
const StaticTypeWarningCode(
'RETURN_OF_INVALID_TYPE',
"The return type '{0}' isn't a '{1}', as defined by the method "
- "'{2}'.");
+ "'{2}'.",
+ hasPublishedDocs: true);
/**
* 13.11 Return: It is a static type warning if the type of <i>e</i> may not
@@ -5753,8 +5777,9 @@
const StaticTypeWarningCodeWithUniqueName(
'RETURN_OF_INVALID_TYPE',
'StaticTypeWarningCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION',
- "A value of type '{0} can't be returned from function '{2}' because it "
- "has a return type of '{1}'.");
+ "A value of type '{0}' can't be returned from function '{2}' because "
+ "it has a return type of '{1}'.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -5766,8 +5791,9 @@
const StaticTypeWarningCodeWithUniqueName(
'RETURN_OF_INVALID_TYPE',
'StaticTypeWarningCode.RETURN_OF_INVALID_TYPE_FROM_METHOD',
- "A value of type '{0} can't be returned from method '{2}' because it has "
- "a return type of '{1}'.");
+ "A value of type '{0}' can't be returned from method '{2}' because "
+ "it has a return type of '{1}'.",
+ hasPublishedDocs: true);
/**
* 10 Generics: It is a static type warning if a type parameter is a supertype
@@ -5959,7 +5985,8 @@
static const StaticTypeWarningCode UNDEFINED_OPERATOR =
const StaticTypeWarningCode('UNDEFINED_OPERATOR',
"The operator '{0}' isn't defined for the class '{1}'.",
- correction: "Try defining the operator '{0}'.");
+ correction: "Try defining the operator '{0}'.",
+ hasPublishedDocs: true);
/**
* No parameters.
@@ -6202,7 +6229,8 @@
'WRONG_NUMBER_OF_TYPE_ARGUMENTS',
"The type '{0}' is declared with {1} type parameters, "
"but {2} type arguments were given.",
- correction: "Try adjusting the number of type arguments.");
+ correction: "Try adjusting the number of type arguments.",
+ hasPublishedDocs: true);
/**
* It will be a static type warning if <i>m</i> is not a generic method with
@@ -6295,7 +6323,7 @@
const StaticTypeWarningCode(String name, String message,
{String correction,
bool hasPublishedDocs,
- bool isUnresolvedIdentifier: false})
+ bool isUnresolvedIdentifier = false})
: super.temporary(name, message,
correction: correction,
hasPublishedDocs: hasPublishedDocs,
@@ -6398,7 +6426,8 @@
static const StaticWarningCode AMBIGUOUS_IMPORT = const StaticWarningCode(
'AMBIGUOUS_IMPORT', "The name '{0}' is defined in the libraries {1}.",
correction: "Try using 'as prefix' for one of the import directives, or "
- "hiding the name from all but one of the imports.");
+ "hiding the name from all but one of the imports.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -6552,7 +6581,8 @@
"There isn’t a setter named '{0}' in class '{1}'.",
correction:
"Try correcting the name to reference an existing setter, or "
- "declare the setter.");
+ "declare the setter.",
+ hasPublishedDocs: true);
/**
* 12.18 Assignment: It is as static warning if an assignment of the form
@@ -6672,18 +6702,12 @@
static const StaticWarningCode CONCRETE_CLASS_WITH_ABSTRACT_MEMBER =
const StaticWarningCode('CONCRETE_CLASS_WITH_ABSTRACT_MEMBER',
"'{0}' must have a method body because '{1}' isn't abstract.",
- correction: "Try making '{1}' abstract, or adding a body to '{0}'.");
+ correction: "Try making '{1}' abstract, or adding a body to '{0}'.",
+ hasPublishedDocs: true);
- /**
- * 16.12.2 Const: Given an instance creation expression of the form <i>const
- * q(a<sub>1</sub>, … a<sub>n</sub>)</i> it is a static warning if
- * <i>q</i> is the constructor of an abstract class but <i>q</i> is not a
- * factory constructor.
- */
+ @Deprecated('Use StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS')
static const StaticWarningCode CONST_WITH_ABSTRACT_CLASS =
- const StaticWarningCode('CONST_WITH_ABSTRACT_CLASS',
- "Abstract classes can't be created with a 'const' expression.",
- correction: "Try creating an instance of a subtype.");
+ INSTANTIATE_ABSTRACT_CLASS;
/**
* 14.2 Exports: It is a static warning to export two different libraries with
@@ -6923,7 +6947,8 @@
'FINAL_NOT_INITIALIZED_CONSTRUCTOR',
'StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1',
"All final variables must be initialized, but '{0}' is not.",
- correction: "Try adding an initializer for the field.");
+ correction: "Try adding an initializer for the field.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -6936,7 +6961,8 @@
'StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2',
"All final variables must be initialized, but '{0}' and '{1}' are "
"not.",
- correction: "Try adding initializers for the fields.");
+ correction: "Try adding initializers for the fields.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -6950,7 +6976,8 @@
'StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3',
"All final variables must be initialized, but '{0}', '{1}', and {2} "
"others are not.",
- correction: "Try adding initializers for the fields.");
+ correction: "Try adding initializers for the fields.",
+ hasPublishedDocs: true);
/**
* 14.1 Imports: It is a static warning to import two different libraries with
@@ -6973,6 +7000,14 @@
CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY;
/**
+ * No parameters.
+ */
+ static const StaticWarningCode INSTANTIATE_ABSTRACT_CLASS =
+ const StaticWarningCode('INSTANTIATE_ABSTRACT_CLASS',
+ "Abstract classes can't be instantiated.",
+ correction: "Try creating an instance of a concrete subtype.");
+
+ /**
* 7.1 Instance Methods: It is a static warning if an instance method
* <i>m1</i> overrides an instance member <i>m2</i>, the signature of
* <i>m2</i> explicitly specifies a default value for a formal parameter
@@ -7046,7 +7081,8 @@
// ```
static const StaticWarningCode LIST_ELEMENT_TYPE_NOT_ASSIGNABLE =
const StaticWarningCode('LIST_ELEMENT_TYPE_NOT_ASSIGNABLE',
- "The element type '{0}' can't be assigned to the list type '{1}'.");
+ "The element type '{0}' can't be assigned to the list type '{1}'.",
+ hasPublishedDocs: true);
/**
* 12.7 Map: A run-time map literal <<i>K</i>, <i>V</i>>
@@ -7134,14 +7170,9 @@
correction: "Try making all the return statements consistent "
"(either include a value or not).");
- /**
- * 12.11.1 New: It is a static warning if <i>q</i> is a constructor of an
- * abstract class and <i>q</i> is not a factory constructor.
- */
+ @Deprecated('Use StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS')
static const StaticWarningCode NEW_WITH_ABSTRACT_CLASS =
- const StaticWarningCode(
- 'NEW_WITH_ABSTRACT_CLASS', "Abstract classes can't be instantiated.",
- correction: "Try creating an instance of a subtype.");
+ INSTANTIATE_ABSTRACT_CLASS;
/**
* 15.8 Parameterized Types: Any use of a malbounded type gives rise to a
@@ -7226,7 +7257,8 @@
"Missing concrete implementations of '{0}', '{1}', '{2}', '{3}', and "
"{4} more.",
correction: "Try implementing the missing methods, or make the class "
- "abstract.");
+ "abstract.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -7242,7 +7274,8 @@
'StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR',
"Missing concrete implementations of '{0}', '{1}', '{2}', and '{3}'.",
correction: "Try implementing the missing methods, or make the class "
- "abstract.");
+ "abstract.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -7314,7 +7347,8 @@
'StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE',
"Missing concrete implementation of '{0}'.",
correction: "Try implementing the missing method, or make the class "
- "abstract.");
+ "abstract.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -7329,7 +7363,8 @@
'StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE',
"Missing concrete implementations of '{0}', '{1}', and '{2}'.",
correction: "Try implementing the missing methods, or make the class "
- "abstract.");
+ "abstract.",
+ hasPublishedDocs: true);
/**
* Parameters:
@@ -7343,7 +7378,8 @@
'StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO',
"Missing concrete implementations of '{0}' and '{1}'.",
correction: "Try implementing the missing methods, or make the class "
- "abstract.");
+ "abstract.",
+ hasPublishedDocs: true);
/**
* 13.11 Try: An on-catch clause of the form <i>on T catch (p<sub>1</sub>,
@@ -7765,7 +7801,7 @@
{String correction,
this.errorSeverity = ErrorSeverity.ERROR,
bool hasPublishedDocs,
- bool isUnresolvedIdentifier: false})
+ bool isUnresolvedIdentifier = false})
: super.temporary(name, message,
correction: correction,
hasPublishedDocs: hasPublishedDocs,
diff --git a/pkg/analyzer/lib/src/error/dart2js_verifier.dart b/pkg/analyzer/lib/src/error/dart2js_verifier.dart
new file mode 100644
index 0000000..66bf057
--- /dev/null
+++ b/pkg/analyzer/lib/src/error/dart2js_verifier.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/visitor.dart';
+import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/error/codes.dart';
+
+/// Instances of the class `Dart2JSVerifier` traverse an AST structure looking
+/// for hints for code that will be compiled to JS, such as
+/// [HintCode.IS_DOUBLE].
+class Dart2JSVerifier extends RecursiveAstVisitor<void> {
+ /// The name of the `double` type.
+ static String _DOUBLE_TYPE_NAME = "double";
+
+ /// The error reporter by which errors will be reported.
+ final ErrorReporter _errorReporter;
+
+ /// Create a new instance of the [Dart2JSVerifier].
+ ///
+ /// @param errorReporter the error reporter
+ Dart2JSVerifier(this._errorReporter);
+
+ @override
+ void visitIsExpression(IsExpression node) {
+ _checkForIsDoubleHints(node);
+ super.visitIsExpression(node);
+ }
+
+ /// Check for instances of `x is double`, `x is int`, `x is! double` and
+ /// `x is! int`.
+ ///
+ /// @param node the is expression to check
+ /// @return `true` if and only if a hint code is generated on the passed node
+ /// See [HintCode.IS_DOUBLE],
+ /// [HintCode.IS_INT],
+ /// [HintCode.IS_NOT_DOUBLE], and
+ /// [HintCode.IS_NOT_INT].
+ bool _checkForIsDoubleHints(IsExpression node) {
+ DartType type = node.type.type;
+ Element element = type?.element;
+ if (element != null) {
+ String typeNameStr = element.name;
+ LibraryElement libraryElement = element.library;
+ // if (typeNameStr.equals(INT_TYPE_NAME) && libraryElement != null
+ // && libraryElement.isDartCore()) {
+ // if (node.getNotOperator() == null) {
+ // errorReporter.reportError(HintCode.IS_INT, node);
+ // } else {
+ // errorReporter.reportError(HintCode.IS_NOT_INT, node);
+ // }
+ // return true;
+ // } else
+ if (typeNameStr == _DOUBLE_TYPE_NAME &&
+ libraryElement != null &&
+ libraryElement.isDartCore) {
+ if (node.notOperator == null) {
+ _errorReporter.reportErrorForNode(HintCode.IS_DOUBLE, node);
+ } else {
+ _errorReporter.reportErrorForNode(HintCode.IS_NOT_DOUBLE, node);
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/pkg/analyzer/lib/src/error/dead_code_verifier.dart b/pkg/analyzer/lib/src/error/dead_code_verifier.dart
new file mode 100644
index 0000000..80cc663
--- /dev/null
+++ b/pkg/analyzer/lib/src/error/dead_code_verifier.dart
@@ -0,0 +1,541 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/token.dart';
+import 'package:analyzer/dart/ast/visitor.dart';
+import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/error/error.dart';
+import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/element/type.dart';
+import 'package:analyzer/src/dart/resolver/exit_detector.dart';
+import 'package:analyzer/src/dart/resolver/scope.dart';
+import 'package:analyzer/src/error/codes.dart';
+import 'package:analyzer/src/generated/constant.dart';
+import 'package:analyzer/src/generated/resolver.dart';
+import 'package:analyzer/src/generated/type_system.dart';
+
+/// A visitor that finds dead code and unused labels.
+class DeadCodeVerifier extends RecursiveAstVisitor<void> {
+ /// The error reporter by which errors will be reported.
+ final ErrorReporter _errorReporter;
+
+ /// The type system for this visitor
+ final TypeSystemImpl _typeSystem;
+
+ /// The object used to track the usage of labels within a given label scope.
+ _LabelTracker labelTracker;
+
+ /// Is `true` if this unit has been parsed as non-nullable.
+ final bool _isNonNullableUnit;
+
+ /// Initialize a newly created dead code verifier that will report dead code
+ /// to the given [errorReporter] and will use the given [typeSystem] if one is
+ /// provided.
+ DeadCodeVerifier(this._errorReporter, FeatureSet featureSet,
+ {TypeSystemImpl typeSystem})
+ : this._typeSystem = typeSystem ??
+ TypeSystemImpl(
+ implicitCasts: true,
+ isNonNullableByDefault: false,
+ strictInference: false,
+ typeProvider: null,
+ ),
+ _isNonNullableUnit = featureSet.isEnabled(Feature.non_nullable);
+
+ @override
+ void visitAssignmentExpression(AssignmentExpression node) {
+ TokenType operatorType = node.operator.type;
+ if (operatorType == TokenType.QUESTION_QUESTION_EQ) {
+ _checkForDeadNullCoalesce(
+ node.leftHandSide.staticType, node.rightHandSide);
+ }
+ super.visitAssignmentExpression(node);
+ }
+
+ @override
+ void visitBinaryExpression(BinaryExpression node) {
+ Token operator = node.operator;
+ bool isAmpAmp = operator.type == TokenType.AMPERSAND_AMPERSAND;
+ bool isBarBar = operator.type == TokenType.BAR_BAR;
+ bool isQuestionQuestion = operator.type == TokenType.QUESTION_QUESTION;
+ if (isAmpAmp || isBarBar) {
+ Expression lhsCondition = node.leftOperand;
+ if (!_isDebugConstant(lhsCondition)) {
+ EvaluationResultImpl lhsResult = _getConstantBooleanValue(lhsCondition);
+ if (lhsResult != null) {
+ bool value = lhsResult.value.toBoolValue();
+ if (value == true && isBarBar) {
+ // Report error on "else" block: true || !e!
+ _errorReporter.reportErrorForNode(
+ HintCode.DEAD_CODE, node.rightOperand);
+ // Only visit the LHS:
+ lhsCondition?.accept(this);
+ return;
+ } else if (value == false && isAmpAmp) {
+ // Report error on "if" block: false && !e!
+ _errorReporter.reportErrorForNode(
+ HintCode.DEAD_CODE, node.rightOperand);
+ // Only visit the LHS:
+ lhsCondition?.accept(this);
+ return;
+ }
+ }
+ }
+ // How do we want to handle the RHS? It isn't dead code, but "pointless"
+ // or "obscure"...
+// Expression rhsCondition = node.getRightOperand();
+// ValidResult rhsResult = getConstantBooleanValue(rhsCondition);
+// if (rhsResult != null) {
+// if (rhsResult == ValidResult.RESULT_TRUE && isBarBar) {
+// // report error on else block: !e! || true
+// errorReporter.reportError(HintCode.DEAD_CODE, node.getRightOperand());
+// // only visit the RHS:
+// rhsCondition?.accept(this);
+// return null;
+// } else if (rhsResult == ValidResult.RESULT_FALSE && isAmpAmp) {
+// // report error on if block: !e! && false
+// errorReporter.reportError(HintCode.DEAD_CODE, node.getRightOperand());
+// // only visit the RHS:
+// rhsCondition?.accept(this);
+// return null;
+// }
+// }
+ } else if (isQuestionQuestion && _isNonNullableUnit) {
+ _checkForDeadNullCoalesce(node.leftOperand.staticType, node.rightOperand);
+ }
+ super.visitBinaryExpression(node);
+ }
+
+ /// For each block, this method reports and error on all statements between
+ /// the end of the block and the first return statement (assuming there it is
+ /// not at the end of the block.)
+ @override
+ void visitBlock(Block node) {
+ NodeList<Statement> statements = node.statements;
+ _checkForDeadStatementsInNodeList(statements);
+ }
+
+ @override
+ void visitBreakStatement(BreakStatement node) {
+ labelTracker?.recordUsage(node.label?.name);
+ }
+
+ @override
+ void visitConditionalExpression(ConditionalExpression node) {
+ Expression conditionExpression = node.condition;
+ conditionExpression?.accept(this);
+ if (!_isDebugConstant(conditionExpression)) {
+ EvaluationResultImpl result =
+ _getConstantBooleanValue(conditionExpression);
+ if (result != null) {
+ if (result.value.toBoolValue() == true) {
+ // Report error on "else" block: true ? 1 : !2!
+ _errorReporter.reportErrorForNode(
+ HintCode.DEAD_CODE, node.elseExpression);
+ node.thenExpression?.accept(this);
+ return;
+ } else {
+ // Report error on "if" block: false ? !1! : 2
+ _errorReporter.reportErrorForNode(
+ HintCode.DEAD_CODE, node.thenExpression);
+ node.elseExpression?.accept(this);
+ return;
+ }
+ }
+ }
+ super.visitConditionalExpression(node);
+ }
+
+ @override
+ void visitContinueStatement(ContinueStatement node) {
+ labelTracker?.recordUsage(node.label?.name);
+ }
+
+ @override
+ void visitExportDirective(ExportDirective node) {
+ ExportElement exportElement = node.element;
+ if (exportElement != null) {
+ // The element is null when the URI is invalid.
+ LibraryElement library = exportElement.exportedLibrary;
+ if (library != null && !library.isSynthetic) {
+ for (Combinator combinator in node.combinators) {
+ _checkCombinator(library, combinator);
+ }
+ }
+ }
+ super.visitExportDirective(node);
+ }
+
+ @override
+ void visitIfElement(IfElement node) {
+ Expression conditionExpression = node.condition;
+ conditionExpression?.accept(this);
+ if (!_isDebugConstant(conditionExpression)) {
+ EvaluationResultImpl result =
+ _getConstantBooleanValue(conditionExpression);
+ if (result != null) {
+ if (result.value.toBoolValue() == true) {
+ // Report error on else block: if(true) {} else {!}
+ CollectionElement elseElement = node.elseElement;
+ if (elseElement != null) {
+ _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, elseElement);
+ node.thenElement?.accept(this);
+ return;
+ }
+ } else {
+ // Report error on if block: if (false) {!} else {}
+ _errorReporter.reportErrorForNode(
+ HintCode.DEAD_CODE, node.thenElement);
+ node.elseElement?.accept(this);
+ return;
+ }
+ }
+ }
+ super.visitIfElement(node);
+ }
+
+ @override
+ void visitIfStatement(IfStatement node) {
+ Expression conditionExpression = node.condition;
+ conditionExpression?.accept(this);
+ if (!_isDebugConstant(conditionExpression)) {
+ EvaluationResultImpl result =
+ _getConstantBooleanValue(conditionExpression);
+ if (result != null) {
+ if (result.value.toBoolValue() == true) {
+ // Report error on else block: if(true) {} else {!}
+ Statement elseStatement = node.elseStatement;
+ if (elseStatement != null) {
+ _errorReporter.reportErrorForNode(
+ HintCode.DEAD_CODE, elseStatement);
+ node.thenStatement?.accept(this);
+ return;
+ }
+ } else {
+ // Report error on if block: if (false) {!} else {}
+ _errorReporter.reportErrorForNode(
+ HintCode.DEAD_CODE, node.thenStatement);
+ node.elseStatement?.accept(this);
+ return;
+ }
+ }
+ }
+ super.visitIfStatement(node);
+ }
+
+ @override
+ void visitImportDirective(ImportDirective node) {
+ ImportElement importElement = node.element;
+ if (importElement != null) {
+ // The element is null when the URI is invalid, but not when the URI is
+ // valid but refers to a non-existent file.
+ LibraryElement library = importElement.importedLibrary;
+ if (library != null && !library.isSynthetic) {
+ for (Combinator combinator in node.combinators) {
+ _checkCombinator(library, combinator);
+ }
+ }
+ }
+ super.visitImportDirective(node);
+ }
+
+ @override
+ void visitLabeledStatement(LabeledStatement node) {
+ _pushLabels(node.labels);
+ try {
+ super.visitLabeledStatement(node);
+ } finally {
+ _popLabels();
+ }
+ }
+
+ @override
+ void visitSwitchCase(SwitchCase node) {
+ _checkForDeadStatementsInNodeList(node.statements, allowMandated: true);
+ super.visitSwitchCase(node);
+ }
+
+ @override
+ void visitSwitchDefault(SwitchDefault node) {
+ _checkForDeadStatementsInNodeList(node.statements, allowMandated: true);
+ super.visitSwitchDefault(node);
+ }
+
+ @override
+ void visitSwitchStatement(SwitchStatement node) {
+ List<Label> labels = <Label>[];
+ for (SwitchMember member in node.members) {
+ labels.addAll(member.labels);
+ }
+ _pushLabels(labels);
+ try {
+ super.visitSwitchStatement(node);
+ } finally {
+ _popLabels();
+ }
+ }
+
+ @override
+ void visitTryStatement(TryStatement node) {
+ node.body?.accept(this);
+ node.finallyBlock?.accept(this);
+ NodeList<CatchClause> catchClauses = node.catchClauses;
+ int numOfCatchClauses = catchClauses.length;
+ List<DartType> visitedTypes = List<DartType>();
+ for (int i = 0; i < numOfCatchClauses; i++) {
+ CatchClause catchClause = catchClauses[i];
+ if (catchClause.onKeyword != null) {
+ // An on-catch clause was found; verify that the exception type is not a
+ // subtype of a previous on-catch exception type.
+ DartType currentType = catchClause.exceptionType?.type;
+ if (currentType != null) {
+ if (currentType.isObject) {
+ // Found catch clause clause that has Object as an exception type,
+ // this is equivalent to having a catch clause that doesn't have an
+ // exception type, visit the block, but generate an error on any
+ // following catch clauses (and don't visit them).
+ catchClause?.accept(this);
+ if (i + 1 != numOfCatchClauses) {
+ // This catch clause is not the last in the try statement.
+ CatchClause nextCatchClause = catchClauses[i + 1];
+ CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1];
+ int offset = nextCatchClause.offset;
+ int length = lastCatchClause.end - offset;
+ _errorReporter.reportErrorForOffset(
+ HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH, offset, length);
+ return;
+ }
+ }
+ int length = visitedTypes.length;
+ for (int j = 0; j < length; j++) {
+ DartType type = visitedTypes[j];
+ if (_typeSystem.isSubtypeOf(currentType, type)) {
+ CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1];
+ int offset = catchClause.offset;
+ int length = lastCatchClause.end - offset;
+ _errorReporter.reportErrorForOffset(
+ HintCode.DEAD_CODE_ON_CATCH_SUBTYPE,
+ offset,
+ length,
+ [currentType.displayName, type.displayName]);
+ return;
+ }
+ }
+ visitedTypes.add(currentType);
+ }
+ catchClause?.accept(this);
+ } else {
+ // Found catch clause clause that doesn't have an exception type,
+ // visit the block, but generate an error on any following catch clauses
+ // (and don't visit them).
+ catchClause?.accept(this);
+ if (i + 1 != numOfCatchClauses) {
+ // This catch clause is not the last in the try statement.
+ CatchClause nextCatchClause = catchClauses[i + 1];
+ CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1];
+ int offset = nextCatchClause.offset;
+ int length = lastCatchClause.end - offset;
+ _errorReporter.reportErrorForOffset(
+ HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH, offset, length);
+ return;
+ }
+ }
+ }
+ }
+
+ @override
+ void visitWhileStatement(WhileStatement node) {
+ Expression conditionExpression = node.condition;
+ conditionExpression?.accept(this);
+ if (!_isDebugConstant(conditionExpression)) {
+ EvaluationResultImpl result =
+ _getConstantBooleanValue(conditionExpression);
+ if (result != null) {
+ if (result.value.toBoolValue() == false) {
+ // Report error on while block: while (false) {!}
+ _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.body);
+ return;
+ }
+ }
+ }
+ node.body?.accept(this);
+ }
+
+ /// Resolve the names in the given [combinator] in the scope of the given
+ /// [library].
+ void _checkCombinator(LibraryElement library, Combinator combinator) {
+ Namespace namespace =
+ NamespaceBuilder().createExportNamespaceForLibrary(library);
+ NodeList<SimpleIdentifier> names;
+ ErrorCode hintCode;
+ if (combinator is HideCombinator) {
+ names = combinator.hiddenNames;
+ hintCode = HintCode.UNDEFINED_HIDDEN_NAME;
+ } else {
+ names = (combinator as ShowCombinator).shownNames;
+ hintCode = HintCode.UNDEFINED_SHOWN_NAME;
+ }
+ for (SimpleIdentifier name in names) {
+ String nameStr = name.name;
+ Element element = namespace.get(nameStr);
+ if (element == null) {
+ element = namespace.get("$nameStr=");
+ }
+ if (element == null) {
+ _errorReporter
+ .reportErrorForNode(hintCode, name, [library.identifier, nameStr]);
+ }
+ }
+ }
+
+ void _checkForDeadNullCoalesce(TypeImpl lhsType, Expression rhs) {
+ if (_isNonNullableUnit && _typeSystem.isNonNullable(lhsType)) {
+ _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, rhs, []);
+ }
+ }
+
+ /// Given some list of [statements], loop through the list searching for dead
+ /// statements. If [allowMandated] is true, then allow dead statements that
+ /// are mandated by the language spec. This allows for a final break,
+ /// continue, return, or throw statement at the end of a switch case, that are
+ /// mandated by the language spec.
+ void _checkForDeadStatementsInNodeList(NodeList<Statement> statements,
+ {bool allowMandated = false}) {
+ bool statementExits(Statement statement) {
+ if (statement is BreakStatement) {
+ return statement.label == null;
+ } else if (statement is ContinueStatement) {
+ return statement.label == null;
+ }
+ return ExitDetector.exits(statement);
+ }
+
+ int size = statements.length;
+ for (int i = 0; i < size; i++) {
+ Statement currentStatement = statements[i];
+ currentStatement?.accept(this);
+ if (statementExits(currentStatement) && i != size - 1) {
+ Statement nextStatement = statements[i + 1];
+ Statement lastStatement = statements[size - 1];
+ // If mandated statements are allowed, and only the last statement is
+ // dead, and it's a BreakStatement, then assume it is a statement
+ // mandated by the language spec, there to avoid a
+ // CASE_BLOCK_NOT_TERMINATED error.
+ if (allowMandated && i == size - 2 && nextStatement is BreakStatement) {
+ return;
+ }
+ int offset = nextStatement.offset;
+ int length = lastStatement.end - offset;
+ _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE, offset, length);
+ return;
+ }
+ }
+ }
+
+ /// Given some [expression], return [ValidResult.RESULT_TRUE] if it is `true`,
+ /// [ValidResult.RESULT_FALSE] if it is `false`, or `null` if the expression
+ /// is not a constant boolean value.
+ EvaluationResultImpl _getConstantBooleanValue(Expression expression) {
+ if (expression is BooleanLiteral) {
+ if (expression.value) {
+ return EvaluationResultImpl(DartObjectImpl(null, BoolState.from(true)));
+ } else {
+ return EvaluationResultImpl(
+ DartObjectImpl(null, BoolState.from(false)));
+ }
+ }
+
+ // Don't consider situations where we could evaluate to a constant boolean
+ // expression with the ConstantVisitor
+ // else {
+ // EvaluationResultImpl result = expression.accept(new ConstantVisitor());
+ // if (result == ValidResult.RESULT_TRUE) {
+ // return ValidResult.RESULT_TRUE;
+ // } else if (result == ValidResult.RESULT_FALSE) {
+ // return ValidResult.RESULT_FALSE;
+ // }
+ // return null;
+ // }
+ return null;
+ }
+
+ /// Return `true` if the given [expression] is resolved to a constant
+ /// variable.
+ bool _isDebugConstant(Expression expression) {
+ Element element;
+ if (expression is Identifier) {
+ element = expression.staticElement;
+ } else if (expression is PropertyAccess) {
+ element = expression.propertyName.staticElement;
+ }
+ if (element is PropertyAccessorElement) {
+ PropertyInducingElement variable = element.variable;
+ return variable != null && variable.isConst;
+ }
+ return false;
+ }
+
+ /// Exit the most recently entered label scope after reporting any labels that
+ /// were not referenced within that scope.
+ void _popLabels() {
+ for (Label label in labelTracker.unusedLabels()) {
+ _errorReporter
+ .reportErrorForNode(HintCode.UNUSED_LABEL, label, [label.label.name]);
+ }
+ labelTracker = labelTracker.outerTracker;
+ }
+
+ /// Enter a new label scope in which the given [labels] are defined.
+ void _pushLabels(List<Label> labels) {
+ labelTracker = _LabelTracker(labelTracker, labels);
+ }
+}
+
+/// An object used to track the usage of labels within a single label scope.
+class _LabelTracker {
+ /// The tracker for the outer label scope.
+ final _LabelTracker outerTracker;
+
+ /// The labels whose usage is being tracked.
+ final List<Label> labels;
+
+ /// A list of flags corresponding to the list of [labels] indicating whether
+ /// the corresponding label has been used.
+ List<bool> used;
+
+ /// A map from the names of labels to the index of the label in [labels].
+ final Map<String, int> labelMap = <String, int>{};
+
+ /// Initialize a newly created label tracker.
+ _LabelTracker(this.outerTracker, this.labels) {
+ used = List.filled(labels.length, false);
+ for (int i = 0; i < labels.length; i++) {
+ labelMap[labels[i].label.name] = i;
+ }
+ }
+
+ /// Record that the label with the given [labelName] has been used.
+ void recordUsage(String labelName) {
+ if (labelName != null) {
+ int index = labelMap[labelName];
+ if (index != null) {
+ used[index] = true;
+ } else if (outerTracker != null) {
+ outerTracker.recordUsage(labelName);
+ }
+ }
+ }
+
+ /// Return the unused labels.
+ Iterable<Label> unusedLabels() sync* {
+ for (int i = 0; i < labels.length; i++) {
+ if (!used[i]) {
+ yield labels[i];
+ }
+ }
+ }
+}
diff --git a/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart b/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
index 2638c00..ef46572 100644
--- a/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
+++ b/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
@@ -39,8 +39,8 @@
void checkEnum(EnumDeclaration node) {
ClassElement element = node.declaredElement;
- Map<String, Element> instanceGetters = new HashMap<String, Element>();
- Map<String, Element> staticGetters = new HashMap<String, Element>();
+ Map<String, Element> instanceGetters = HashMap<String, Element>();
+ Map<String, Element> staticGetters = HashMap<String, Element>();
String indexName = 'index';
String valuesName = 'values';
@@ -127,7 +127,7 @@
/// Check that the given list of variable declarations does not define
/// multiple variables of the same name.
void checkForVariables(VariableDeclarationList node) {
- Map<String, Element> definedNames = new HashMap<String, Element>();
+ Map<String, Element> definedNames = HashMap<String, Element>();
for (VariableDeclaration variable in node.variables) {
_checkDuplicateIdentifier(definedNames, variable.name);
}
@@ -141,7 +141,7 @@
* Check that all of the parameters have unique names.
*/
void checkParameters(FormalParameterList node) {
- Map<String, Element> definedNames = new HashMap<String, Element>();
+ Map<String, Element> definedNames = HashMap<String, Element>();
for (FormalParameter parameter in node.parameters) {
SimpleIdentifier identifier = parameter.identifier;
if (identifier != null) {
@@ -154,7 +154,7 @@
/// Check that all of the variables have unique names.
void checkStatements(List<Statement> statements) {
- Map<String, Element> definedNames = new HashMap<String, Element>();
+ Map<String, Element> definedNames = HashMap<String, Element>();
for (Statement statement in statements) {
if (statement is VariableDeclarationStatement) {
for (VariableDeclaration variable in statement.variables.variables) {
@@ -169,7 +169,7 @@
/// Check that all of the parameters have unique names.
void checkTypeParameters(TypeParameterList node) {
- Map<String, Element> definedNames = new HashMap<String, Element>();
+ Map<String, Element> definedNames = HashMap<String, Element>();
for (TypeParameter parameter in node.typeParameters) {
_checkDuplicateIdentifier(definedNames, parameter.name);
}
@@ -177,8 +177,8 @@
/// Check that there are no members with the same name.
void checkUnit(CompilationUnit node) {
- Map<String, Element> definedGetters = new HashMap<String, Element>();
- Map<String, Element> definedSetters = new HashMap<String, Element>();
+ Map<String, Element> definedGetters = HashMap<String, Element>();
+ Map<String, Element> definedSetters = HashMap<String, Element>();
void addWithoutChecking(CompilationUnitElement element) {
for (PropertyAccessorElement accessor in element.accessors) {
@@ -245,11 +245,11 @@
/// Check that there are no members with the same name.
void _checkClassMembers(ClassElement element, List<ClassMember> members) {
- Set<String> constructorNames = new HashSet<String>();
- Map<String, Element> instanceGetters = new HashMap<String, Element>();
- Map<String, Element> instanceSetters = new HashMap<String, Element>();
- Map<String, Element> staticGetters = new HashMap<String, Element>();
- Map<String, Element> staticSetters = new HashMap<String, Element>();
+ Set<String> constructorNames = HashSet<String>();
+ Map<String, Element> instanceGetters = HashMap<String, Element>();
+ Map<String, Element> instanceSetters = HashMap<String, Element>();
+ Map<String, Element> staticGetters = HashMap<String, Element>();
+ Map<String, Element> staticSetters = HashMap<String, Element>();
for (ClassMember member in members) {
if (member is ConstructorDeclaration) {
diff --git a/pkg/analyzer/lib/src/error/imports_verifier.dart b/pkg/analyzer/lib/src/error/imports_verifier.dart
index ad45f0a..73e644aa 100644
--- a/pkg/analyzer/lib/src/error/imports_verifier.dart
+++ b/pkg/analyzer/lib/src/error/imports_verifier.dart
@@ -14,7 +14,7 @@
/// A visitor that visits ASTs and fills [UsedImportedElements].
class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor {
final LibraryElement library;
- final UsedImportedElements usedElements = new UsedImportedElements();
+ final UsedImportedElements usedElements = UsedImportedElements();
GatherUsedImportedElementsVisitor(this.library);
@@ -181,7 +181,7 @@
/// The cache of [Namespace]s for [ImportDirective]s.
final HashMap<ImportDirective, Namespace> _namespaceMap =
- new HashMap<ImportDirective, Namespace>();
+ HashMap<ImportDirective, Namespace>();
/// This is a map between prefix elements and the import directives from which
/// they are derived. In cases where a type is referenced via a prefix
@@ -194,7 +194,7 @@
/// situations where two imports use the same prefix and at least one import
/// directive is used.
final HashMap<PrefixElement, List<ImportDirective>> _prefixElementMap =
- new HashMap<PrefixElement, List<ImportDirective>>();
+ HashMap<PrefixElement, List<ImportDirective>>();
/// A map of identifiers that the current library's imports show, but that the
/// library does not use.
@@ -210,17 +210,17 @@
///
/// See [ImportsVerifier.generateUnusedShownNameHints].
final HashMap<ImportDirective, List<SimpleIdentifier>> _unusedShownNamesMap =
- new HashMap<ImportDirective, List<SimpleIdentifier>>();
+ HashMap<ImportDirective, List<SimpleIdentifier>>();
/// A map of names that are hidden more than once.
final HashMap<NamespaceDirective, List<SimpleIdentifier>>
_duplicateHiddenNamesMap =
- new HashMap<NamespaceDirective, List<SimpleIdentifier>>();
+ HashMap<NamespaceDirective, List<SimpleIdentifier>>();
/// A map of names that are shown more than once.
final HashMap<NamespaceDirective, List<SimpleIdentifier>>
_duplicateShownNamesMap =
- new HashMap<NamespaceDirective, List<SimpleIdentifier>>();
+ HashMap<NamespaceDirective, List<SimpleIdentifier>>();
void addImports(CompilationUnit node) {
for (Directive directive in node.directives) {
@@ -241,7 +241,7 @@
if (element is PrefixElement) {
List<ImportDirective> list = _prefixElementMap[element];
if (list == null) {
- list = new List<ImportDirective>();
+ list = List<ImportDirective>();
_prefixElementMap[element] = list;
}
list.add(directive);
@@ -259,7 +259,7 @@
// order the list of unusedImports to find duplicates in faster than
// O(n^2) time
List<ImportDirective> importDirectiveArray =
- new List<ImportDirective>.from(_unusedImports);
+ List<ImportDirective>.from(_unusedImports);
importDirectiveArray.sort(ImportDirective.COMPARATOR);
ImportDirective currentDirective = importDirectiveArray[0];
for (int i = 1; i < importDirectiveArray.length; i++) {
@@ -444,14 +444,14 @@
}
for (Combinator combinator in directive.combinators) {
// Use a Set to find duplicates in faster than O(n^2) time.
- Set<Element> identifiers = new Set<Element>();
+ Set<Element> identifiers = Set<Element>();
if (combinator is HideCombinator) {
for (SimpleIdentifier name in combinator.hiddenNames) {
if (name.staticElement != null) {
if (!identifiers.add(name.staticElement)) {
// [name] is a duplicate.
List<SimpleIdentifier> duplicateNames = _duplicateHiddenNamesMap
- .putIfAbsent(directive, () => new List<SimpleIdentifier>());
+ .putIfAbsent(directive, () => List<SimpleIdentifier>());
duplicateNames.add(name);
}
}
@@ -462,7 +462,7 @@
if (!identifiers.add(name.staticElement)) {
// [name] is a duplicate.
List<SimpleIdentifier> duplicateNames = _duplicateShownNamesMap
- .putIfAbsent(directive, () => new List<SimpleIdentifier>());
+ .putIfAbsent(directive, () => List<SimpleIdentifier>());
duplicateNames.add(name);
}
}
@@ -476,7 +476,7 @@
if (importDirective.combinators == null) {
return;
}
- List<SimpleIdentifier> identifiers = new List<SimpleIdentifier>();
+ List<SimpleIdentifier> identifiers = List<SimpleIdentifier>();
_unusedShownNamesMap[importDirective] = identifiers;
for (Combinator combinator in importDirective.combinators) {
if (combinator is ShowCombinator) {
diff --git a/pkg/analyzer/lib/src/error/inheritance_override.dart b/pkg/analyzer/lib/src/error/inheritance_override.dart
index fc45c4b..fea6ffc 100644
--- a/pkg/analyzer/lib/src/error/inheritance_override.dart
+++ b/pkg/analyzer/lib/src/error/inheritance_override.dart
@@ -33,7 +33,7 @@
var library = unit.declaredElement.library;
for (var declaration in unit.declarations) {
if (declaration is ClassDeclaration) {
- new _ClassVerifier(
+ _ClassVerifier(
typeSystem: _typeSystem,
typeProvider: _typeProvider,
inheritance: _inheritance,
@@ -47,7 +47,7 @@
withClause: declaration.withClause,
).verify();
} else if (declaration is ClassTypeAlias) {
- new _ClassVerifier(
+ _ClassVerifier(
typeSystem: _typeSystem,
typeProvider: _typeProvider,
inheritance: _inheritance,
@@ -60,7 +60,7 @@
withClause: declaration.withClause,
).verify();
} else if (declaration is MixinDeclaration) {
- new _ClassVerifier(
+ _ClassVerifier(
typeSystem: _typeSystem,
typeProvider: _typeProvider,
inheritance: _inheritance,
@@ -103,7 +103,7 @@
/// The set of unique supertypes of the current class.
/// It is used to decide when to add a new element to [allSuperinterfaces].
- final Set<InterfaceType> allSupertypes = new Set<InterfaceType>();
+ final Set<InterfaceType> allSupertypes = Set<InterfaceType>();
/// The list of all superinterfaces, collected so far.
final List<Interface> allSuperinterfaces = [];
@@ -117,7 +117,7 @@
this.library,
this.classNameNode,
this.implementsClause,
- this.members: const [],
+ this.members = const [],
this.onClause,
this.superclass,
this.withClause,
@@ -270,7 +270,7 @@
if (member == null) return;
if (member.isStatic) return;
- var name = new Name(libraryUri, member.name);
+ var name = Name(libraryUri, member.name);
for (var superInterface in allSuperinterfaces) {
var superMember = superInterface.declared[name];
if (superMember != null) {
@@ -392,12 +392,11 @@
var getter = interface.map[name];
if (getter.kind == ElementKind.GETTER) {
// TODO(scheglov) We should separate getters and setters.
- var setter = interface.map[new Name(libraryUri, '${name.name}=')];
+ var setter = interface.map[Name(libraryUri, '${name.name}=')];
if (setter != null && setter.parameters.length == 1) {
var getterType = getter.returnType;
var setterType = setter.parameters[0].type;
- if (!typeSystem.isAssignableTo(getterType, setterType,
- featureSet: featureSet)) {
+ if (!typeSystem.isAssignableTo(getterType, setterType)) {
Element errorElement;
if (getter.enclosingElement == classElement) {
errorElement = getter;
@@ -529,7 +528,7 @@
// Construct a string showing the cyclic implements path:
// "A, B, C, D, A"
String separator = ", ";
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
for (int i = 0; i < size; i++) {
buffer.write(path[i].displayName);
buffer.write(separator);
diff --git a/pkg/analyzer/lib/src/error/invalid_language_version_override_finder.dart b/pkg/analyzer/lib/src/error/invalid_language_version_override_finder.dart
new file mode 100644
index 0000000..2c18728
--- /dev/null
+++ b/pkg/analyzer/lib/src/error/invalid_language_version_override_finder.dart
@@ -0,0 +1,262 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/token.dart';
+import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/error/codes.dart';
+
+/// Instances of the class `InvalidLanguageVersionOverrideFinder` find invalid
+/// Dart language version override comments in Dart code.
+class InvalidLanguageVersionOverrideFinder {
+ /// The error reporter by which invalid Dart language version override
+ /// comments will be reported.
+ final ErrorReporter _errorReporter;
+
+ /// Initialize a finder to report invalid Dart language version override
+ /// comments to the given reporter.
+ InvalidLanguageVersionOverrideFinder(this._errorReporter);
+
+ /// Search the comments at the top of the given compilation unit for language
+ /// version override comments and report an error for each.
+ void findIn(CompilationUnit unit) {
+ Token beginToken = unit.beginToken;
+ if (beginToken.type == TokenType.SCRIPT_TAG) {
+ beginToken = beginToken.next;
+ }
+ Token commentToken = beginToken.precedingComments;
+ while (commentToken != null) {
+ if (_findLanguageVersionOverrideComment(commentToken)) {
+ // A valid language version override was found. Do not search for any
+ // later invalid language version comments.
+ return;
+ }
+ commentToken = commentToken.next;
+ }
+ }
+
+ /// Look for comments which look almost like a Dart language version override,
+ /// according to the spec [1].
+ ///
+ /// The idea of a comment which looks "almost" like a language version
+ /// override is a tricky dance. It is important that this function _not_
+ /// falsely report comment lines as an "invalid language version override"
+ /// when the user was likely not trying to override the language version. Here
+ /// is the general algorithm for deciding what to report:
+ ///
+ /// * When a comment begins with "@dart" or "dart" (letters in any case),
+ /// followed by optional whitespace, followed by optional non-alphanumeric,
+ /// non-whitespace characters, followed by optional whitespace, followed by
+ /// an optional alphabetical character, followed by a digit, followed by the
+ /// end of the line or a non-alphabetical character, then the comment is
+ /// considered to be an attempt at a language version override comment
+ /// (with one exception, below).
+ /// * If the "@" character is missing before "dart", _and_ the
+ /// non-alphabetical characters are not present, the comment is too
+ /// different from a valid language version override comment, and is not
+ /// considered to be an attempt. Examples include: "/// dart2 is great."
+ /// * If the comment began with more than two slashes, report the comment.
+ /// For example: "/// dart = 2".
+ /// * If the "@" character is missing before "dart", report the comment.
+ /// Examples include: "// dart = 2.0", "// dart @ 2.0".
+ /// * If the letters, "dart", are not all lower case, report the comment.
+ /// For example: "// @Dart = 2".
+ /// * If the non-alphabetical characters are not present or are not the
+ /// single character "=", report the comment. Examples include:
+ /// "// @dart: 2", "// @dart > 2.0", "// @dart >= 2.0", "// @dart 2.0".
+ /// * If the optional alphabetical letter is present, report the comment.
+ /// For example: "// @dart = v2".
+ /// * If the digit is not immediately followed by a "." character, then
+ /// another digit, then optional whitespace, then the end of the line,
+ /// report the comment. Examples include: "// @dart = 2",
+ /// "// @dart = 2,0", "// @dart = 2.15", "// @dart = 2.2.2",
+ /// "// @dart = 2.2 or so".
+ /// * Otherwise, the comment is a valid language version override comment.
+ /// * Otherwise, the comment is not considered to be an attempt at a language
+ /// version override comment. Nothing is reported. Examples include:
+ /// "/// dart", "/// dart is great", "// dartisans are great",
+ /// "// dart = java, basically".
+ ///
+ /// [1] https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/feature-specification.md#individual-library-language-version-override
+ bool _findLanguageVersionOverrideComment(Token commentToken) {
+ String comment = commentToken.lexeme;
+ int offset = commentToken.offset;
+ int length = comment.length;
+ int index = 0;
+
+ // TODO(srawlins): Actual whitespace.
+ bool isWhitespace(int character) => character == 0x09 || character == 0x20;
+
+ bool isNumeric(int character) => character >= 0x30 && character <= 0x39;
+
+ bool isAlphabetical(int character) =>
+ (character >= 0x41 && character <= 0x5A) ||
+ (character >= 0x61 && character <= 0x7A);
+
+ // Count the number of `/` characters at the beginning.
+ while (index < length && comment.codeUnitAt(index) == 0x2F) {
+ index++;
+ }
+ int slashCount = index;
+ while (index < length && isWhitespace(comment.codeUnitAt(index))) {
+ index++;
+ }
+ if (index == length) {
+ // This is not an attempted language version override comment.
+ return false;
+ }
+
+ bool atSignPresent = comment.codeUnitAt(index) == 0x40;
+ if (atSignPresent) {
+ index++;
+ }
+ if (length - index < 4) {
+ // This is not an attempted language version override comment.
+ return false;
+ }
+
+ String possibleDart = comment.substring(index, index + 4);
+ if (possibleDart.toLowerCase() != 'dart') {
+ // This is not an attempted language version override comment.
+ return false;
+ }
+
+ index += 4;
+ while (index < length && isWhitespace(comment.codeUnitAt(index))) {
+ index++;
+ }
+ if (index == length) {
+ // This is not an attempted language version override comment.
+ return false;
+ }
+
+ // The separator between "@dart" and the version number.
+ int dartVersionSeparatorStartIndex = index;
+ // Move through any other consecutive punctuation, whitespace,
+ while (index < length) {
+ int possibleSeparatorCharacter = comment.codeUnitAt(index);
+ if (isNumeric(possibleSeparatorCharacter) ||
+ isAlphabetical(possibleSeparatorCharacter) ||
+ isWhitespace(possibleSeparatorCharacter)) {
+ break;
+ }
+ index++;
+ }
+ if (index == length) {
+ // This is not an attempted language version override comment.
+ return false;
+ }
+
+ int dartVersionSeparatorLength = index - dartVersionSeparatorStartIndex;
+ while (index < length && isWhitespace(comment.codeUnitAt(index))) {
+ index++;
+ }
+ if (index == length) {
+ // This is not an attempted language version override comment.
+ return false;
+ }
+
+ bool containsInvalidVersionNumberPrefix = false;
+ if (isAlphabetical(comment.codeUnitAt(index))) {
+ containsInvalidVersionNumberPrefix = true;
+ index++;
+ if (index == length) {
+ // This is not an attempted language version override comment.
+ return false;
+ }
+ }
+
+ if (!isNumeric(comment.codeUnitAt(index))) {
+ // This is not an attempted language version override comment.
+ return false;
+ }
+
+ if (index + 1 < length && isAlphabetical(comment.codeUnitAt(index + 1))) {
+ // This is not an attempted language version override comment.
+ return false;
+ }
+
+ if (!atSignPresent && dartVersionSeparatorLength == 0) {
+ // The comment is too different from a valid language version override
+ // comment, like "/// dart2 is great".
+ return false;
+ }
+
+ // At this point, the comment is considered an "attempted" language version
+ // override comment. Check for all issues which would make it an invalid
+ // language version override comment.
+
+ if (slashCount > 2) {
+ _errorReporter.reportErrorForOffset(
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_TWO_SLASHES,
+ offset,
+ length);
+ return false;
+ }
+
+ if (!atSignPresent) {
+ _errorReporter.reportErrorForOffset(
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN, offset, length);
+ return false;
+ }
+
+ if (possibleDart != 'dart') {
+ // The 4 characters after `@` are "dart", but in the wrong case.
+ _errorReporter.reportErrorForOffset(
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE,
+ offset,
+ length);
+ return false;
+ }
+
+ if (dartVersionSeparatorLength != 1 ||
+ comment.codeUnitAt(dartVersionSeparatorStartIndex) != 0x3D) {
+ // The separator between "@dart" and the version number is either not
+ // present, or is not a single "=" character.
+ _errorReporter.reportErrorForOffset(
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS, offset, length);
+ return false;
+ }
+
+ if (containsInvalidVersionNumberPrefix) {
+ _errorReporter.reportErrorForOffset(
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_PREFIX, offset, length);
+ return false;
+ }
+
+ void reportInvalidNumber() {
+ _errorReporter.reportErrorForOffset(
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER, offset, length);
+ }
+
+ // Nothing preceding the version number makes this comment invalid. Check
+ // the format of the version number, and trailing characters.
+
+ index++;
+ if (index == length || comment.codeUnitAt(index) != 0x2E) {
+ reportInvalidNumber();
+ return false;
+ }
+ index++;
+ if (index == length || !isNumeric(comment.codeUnitAt(index))) {
+ reportInvalidNumber();
+ return false;
+ }
+ index++;
+ while (index < length && isWhitespace(comment.codeUnitAt(index))) {
+ index++;
+ }
+ if (index == length) {
+ // This is a valid language version override comment.
+ return true;
+ }
+ // This comment is a valid language version override, except for trailing
+ // characters.
+ _errorReporter.reportErrorForOffset(
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS,
+ offset,
+ length);
+ return false;
+ }
+}
diff --git a/pkg/analyzer/lib/src/error/literal_element_verifier.dart b/pkg/analyzer/lib/src/error/literal_element_verifier.dart
index 411e42a..85ccb24 100644
--- a/pkg/analyzer/lib/src/error/literal_element_verifier.dart
+++ b/pkg/analyzer/lib/src/error/literal_element_verifier.dart
@@ -47,7 +47,7 @@
/// Check that the given [type] is assignable to the [elementType], otherwise
/// report the list or set error on the [errorNode].
void _checkAssignableToElementType(DartType type, AstNode errorNode) {
- if (!typeSystem.isAssignableTo(type, elementType, featureSet: featureSet)) {
+ if (!typeSystem.isAssignableTo(type, elementType)) {
var errorCode = forList
? StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE
: StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE;
@@ -107,8 +107,7 @@
}
var keyType = entry.key.staticType;
- if (!typeSystem.isAssignableTo(keyType, mapKeyType,
- featureSet: featureSet)) {
+ if (!typeSystem.isAssignableTo(keyType, mapKeyType)) {
errorReporter.reportTypeErrorForNode(
StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE,
entry.key,
@@ -117,8 +116,7 @@
}
var valueType = entry.value.staticType;
- if (!typeSystem.isAssignableTo(valueType, mapValueType,
- featureSet: featureSet)) {
+ if (!typeSystem.isAssignableTo(valueType, mapValueType)) {
errorReporter.reportTypeErrorForNode(
StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
entry.value,
@@ -156,8 +154,7 @@
}
var iterableElementType = iterableType.typeArguments[0];
- if (!typeSystem.isAssignableTo(iterableElementType, elementType,
- featureSet: featureSet)) {
+ if (!typeSystem.isAssignableTo(iterableElementType, elementType)) {
var errorCode = forList
? StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE
: StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE;
@@ -198,8 +195,7 @@
}
var keyType = mapType.typeArguments[0];
- if (!typeSystem.isAssignableTo(keyType, mapKeyType,
- featureSet: featureSet)) {
+ if (!typeSystem.isAssignableTo(keyType, mapKeyType)) {
errorReporter.reportTypeErrorForNode(
StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE,
expression,
@@ -208,8 +204,7 @@
}
var valueType = mapType.typeArguments[1];
- if (!typeSystem.isAssignableTo(valueType, mapValueType,
- featureSet: featureSet)) {
+ if (!typeSystem.isAssignableTo(valueType, mapValueType)) {
errorReporter.reportTypeErrorForNode(
StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
expression,
diff --git a/pkg/analyzer/lib/src/error/override_verifier.dart b/pkg/analyzer/lib/src/error/override_verifier.dart
new file mode 100644
index 0000000..93723e2
--- /dev/null
+++ b/pkg/analyzer/lib/src/error/override_verifier.dart
@@ -0,0 +1,96 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/visitor.dart';
+import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
+import 'package:analyzer/src/error/codes.dart';
+
+/// Instances of the class `OverrideVerifier` visit all of the declarations in a
+/// compilation unit to verify that if they have an override annotation it is
+/// being used correctly.
+class OverrideVerifier extends RecursiveAstVisitor {
+ /// The inheritance manager used to find overridden methods.
+ final InheritanceManager3 _inheritance;
+
+ /// The URI of the library being verified.
+ final Uri _libraryUri;
+
+ /// The error reporter used to report errors.
+ final ErrorReporter _errorReporter;
+
+ /// The current class or mixin.
+ InterfaceType _currentType;
+
+ OverrideVerifier(
+ this._inheritance, LibraryElement library, this._errorReporter)
+ : _libraryUri = library.source.uri;
+
+ @override
+ visitClassDeclaration(ClassDeclaration node) {
+ _currentType = node.declaredElement.thisType;
+ super.visitClassDeclaration(node);
+ _currentType = null;
+ }
+
+ @override
+ visitFieldDeclaration(FieldDeclaration node) {
+ for (VariableDeclaration field in node.fields.variables) {
+ FieldElement fieldElement = field.declaredElement;
+ if (fieldElement.hasOverride) {
+ PropertyAccessorElement getter = fieldElement.getter;
+ if (getter != null && _isOverride(getter)) continue;
+
+ PropertyAccessorElement setter = fieldElement.setter;
+ if (setter != null && _isOverride(setter)) continue;
+
+ _errorReporter.reportErrorForNode(
+ HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD,
+ field.name,
+ );
+ }
+ }
+ }
+
+ @override
+ visitMethodDeclaration(MethodDeclaration node) {
+ ExecutableElement element = node.declaredElement;
+ if (element.hasOverride && !_isOverride(element)) {
+ if (element is MethodElement) {
+ _errorReporter.reportErrorForNode(
+ HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD,
+ node.name,
+ );
+ } else if (element is PropertyAccessorElement) {
+ if (element.isGetter) {
+ _errorReporter.reportErrorForNode(
+ HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER,
+ node.name,
+ );
+ } else {
+ _errorReporter.reportErrorForNode(
+ HintCode.OVERRIDE_ON_NON_OVERRIDING_SETTER,
+ node.name,
+ );
+ }
+ }
+ }
+ }
+
+ @override
+ visitMixinDeclaration(MixinDeclaration node) {
+ _currentType = node.declaredElement.thisType;
+ super.visitMixinDeclaration(node);
+ _currentType = null;
+ }
+
+ /// Return `true` if the [member] overrides a member from a superinterface.
+ bool _isOverride(ExecutableElement member) {
+ var name = Name(_libraryUri, member.name);
+ return _inheritance.getOverridden(_currentType, name) != null;
+ }
+}
diff --git a/pkg/analyzer/lib/src/error/todo_finder.dart b/pkg/analyzer/lib/src/error/todo_finder.dart
new file mode 100644
index 0000000..c971f1f
--- /dev/null
+++ b/pkg/analyzer/lib/src/error/todo_finder.dart
@@ -0,0 +1,62 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/token.dart';
+import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/error/codes.dart';
+
+/// Instances of the class `ToDoFinder` find to-do comments in Dart code.
+class TodoFinder {
+ /// The error reporter by which to-do comments will be reported.
+ final ErrorReporter _errorReporter;
+
+ /// Initialize a newly created to-do finder to report to-do comments to the
+ /// given reporter.
+ ///
+ /// @param errorReporter the error reporter by which to-do comments will be
+ /// reported
+ TodoFinder(this._errorReporter);
+
+ /// Search the comments in the given compilation unit for to-do comments and
+ /// report an error for each.
+ ///
+ /// @param unit the compilation unit containing the to-do comments
+ void findIn(CompilationUnit unit) {
+ _gatherTodoComments(unit.beginToken);
+ }
+
+ /// Search the comment tokens reachable from the given token and create errors
+ /// for each to-do comment.
+ ///
+ /// @param token the head of the list of tokens being searched
+ void _gatherTodoComments(Token token) {
+ while (token != null && token.type != TokenType.EOF) {
+ Token commentToken = token.precedingComments;
+ while (commentToken != null) {
+ if (commentToken.type == TokenType.SINGLE_LINE_COMMENT ||
+ commentToken.type == TokenType.MULTI_LINE_COMMENT) {
+ _scrapeTodoComment(commentToken);
+ }
+ commentToken = commentToken.next;
+ }
+ token = token.next;
+ }
+ }
+
+ /// Look for user defined tasks in comments and convert them into info level
+ /// analysis issues.
+ ///
+ /// @param commentToken the comment token to analyze
+ void _scrapeTodoComment(Token commentToken) {
+ Iterable<Match> matches =
+ TodoCode.TODO_REGEX.allMatches(commentToken.lexeme);
+ for (Match match in matches) {
+ int offset = commentToken.offset + match.start + match.group(1).length;
+ int length = match.group(2).length;
+ _errorReporter.reportErrorForOffset(
+ TodoCode.TODO, offset, length, [match.group(2)]);
+ }
+ }
+}
diff --git a/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart b/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart
new file mode 100644
index 0000000..71c46b4
--- /dev/null
+++ b/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart
@@ -0,0 +1,458 @@
+// Copyright (c) 2019, 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.
+
+import 'dart:collection';
+
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/token.dart';
+import 'package:analyzer/dart/ast/visitor.dart';
+import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/error/error.dart';
+import 'package:analyzer/error/listener.dart';
+import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
+import 'package:analyzer/src/dart/element/member.dart' show ExecutableMember;
+import 'package:analyzer/src/error/codes.dart';
+
+/// An [AstVisitor] that fills [UsedLocalElements].
+class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor {
+ final UsedLocalElements usedElements = UsedLocalElements();
+
+ final LibraryElement _enclosingLibrary;
+ ClassElement _enclosingClass;
+ ExecutableElement _enclosingExec;
+
+ GatherUsedLocalElementsVisitor(this._enclosingLibrary);
+
+ @override
+ visitCatchClause(CatchClause node) {
+ SimpleIdentifier exceptionParameter = node.exceptionParameter;
+ SimpleIdentifier stackTraceParameter = node.stackTraceParameter;
+ if (exceptionParameter != null) {
+ Element element = exceptionParameter.staticElement;
+ usedElements.addCatchException(element);
+ if (stackTraceParameter != null || node.onKeyword == null) {
+ usedElements.addElement(element);
+ }
+ }
+ if (stackTraceParameter != null) {
+ Element element = stackTraceParameter.staticElement;
+ usedElements.addCatchStackTrace(element);
+ }
+ super.visitCatchClause(node);
+ }
+
+ @override
+ visitClassDeclaration(ClassDeclaration node) {
+ ClassElement enclosingClassOld = _enclosingClass;
+ try {
+ _enclosingClass = node.declaredElement;
+ super.visitClassDeclaration(node);
+ } finally {
+ _enclosingClass = enclosingClassOld;
+ }
+ }
+
+ @override
+ visitFunctionDeclaration(FunctionDeclaration node) {
+ ExecutableElement enclosingExecOld = _enclosingExec;
+ try {
+ _enclosingExec = node.declaredElement;
+ super.visitFunctionDeclaration(node);
+ } finally {
+ _enclosingExec = enclosingExecOld;
+ }
+ }
+
+ @override
+ visitFunctionExpression(FunctionExpression node) {
+ if (node.parent is! FunctionDeclaration) {
+ usedElements.addElement(node.declaredElement);
+ }
+ super.visitFunctionExpression(node);
+ }
+
+ @override
+ visitMethodDeclaration(MethodDeclaration node) {
+ ExecutableElement enclosingExecOld = _enclosingExec;
+ try {
+ _enclosingExec = node.declaredElement;
+ super.visitMethodDeclaration(node);
+ } finally {
+ _enclosingExec = enclosingExecOld;
+ }
+ }
+
+ @override
+ visitSimpleIdentifier(SimpleIdentifier node) {
+ if (node.inDeclarationContext()) {
+ return;
+ }
+ Element element = node.staticElement;
+ // Store un-parameterized members.
+ if (element is ExecutableMember) {
+ element = element.declaration;
+ }
+ bool isIdentifierRead = _isReadIdentifier(node);
+ if (element is PropertyAccessorElement &&
+ element.isSynthetic &&
+ isIdentifierRead &&
+ element.variable is TopLevelVariableElement) {
+ usedElements.addElement(element.variable);
+ } else if (element is LocalVariableElement) {
+ if (isIdentifierRead) {
+ usedElements.addElement(element);
+ }
+ } else {
+ _useIdentifierElement(node);
+ if (element == null) {
+ if (isIdentifierRead) {
+ usedElements.unresolvedReadMembers.add(node.name);
+ }
+ } else if ((element.enclosingElement is ClassElement ||
+ element.enclosingElement is ExtensionElement) &&
+ !identical(element, _enclosingExec)) {
+ usedElements.members.add(element);
+ if (isIdentifierRead) {
+ // Store the corresponding getter.
+ if (element is PropertyAccessorElement && element.isSetter) {
+ element = (element as PropertyAccessorElement).correspondingGetter;
+ }
+ usedElements.members.add(element);
+ usedElements.readMembers.add(element);
+ }
+ }
+ }
+ }
+
+ /// Marks an [Element] of [node] as used in the library.
+ void _useIdentifierElement(Identifier node) {
+ Element element = node.staticElement;
+ if (element == null) {
+ return;
+ }
+ // check if a local element
+ if (!identical(element.library, _enclosingLibrary)) {
+ return;
+ }
+ // ignore references to an element from itself
+ if (identical(element, _enclosingClass)) {
+ return;
+ }
+ if (identical(element, _enclosingExec)) {
+ return;
+ }
+ // ignore places where the element is not actually used
+ if (node.parent is TypeName) {
+ if (element is ClassElement) {
+ AstNode parent2 = node.parent.parent;
+ if (parent2 is IsExpression) {
+ return;
+ }
+ if (parent2 is VariableDeclarationList) {
+ // If it's a field's type, it still counts as used.
+ if (parent2.parent is! FieldDeclaration) {
+ return;
+ }
+ }
+ }
+ }
+ // OK
+ usedElements.addElement(element);
+ }
+
+ static bool _isReadIdentifier(SimpleIdentifier node) {
+ // not reading at all
+ if (!node.inGetterContext()) {
+ return false;
+ }
+ // check if useless reading
+ AstNode parent = node.parent;
+ if (parent.parent is ExpressionStatement) {
+ if (parent is PrefixExpression || parent is PostfixExpression) {
+ // v++;
+ // ++v;
+ return false;
+ }
+ if (parent is AssignmentExpression && parent.leftHandSide == node) {
+ // v ??= doSomething();
+ // vs.
+ // v += 2;
+ TokenType operatorType = parent.operator?.type;
+ return operatorType == TokenType.QUESTION_QUESTION_EQ;
+ }
+ }
+ // OK
+ return true;
+ }
+}
+
+/// Instances of the class [UnusedLocalElementsVerifier] traverse an AST
+/// looking for cases of [HintCode.UNUSED_ELEMENT], [HintCode.UNUSED_FIELD],
+/// [HintCode.UNUSED_LOCAL_VARIABLE], etc.
+class UnusedLocalElementsVerifier extends RecursiveAstVisitor {
+ /// The error listener to which errors will be reported.
+ final AnalysisErrorListener _errorListener;
+
+ /// The elements know to be used.
+ final UsedLocalElements _usedElements;
+
+ /// The inheritance manager used to find overridden methods.
+ final InheritanceManager3 _inheritanceManager;
+
+ /// The URI of the library being verified.
+ final Uri _libraryUri;
+
+ /// Create a new instance of the [UnusedLocalElementsVerifier].
+ UnusedLocalElementsVerifier(this._errorListener, this._usedElements,
+ this._inheritanceManager, LibraryElement library)
+ : _libraryUri = library.source.uri;
+
+ visitSimpleIdentifier(SimpleIdentifier node) {
+ if (node.inDeclarationContext()) {
+ var element = node.staticElement;
+ if (element is ClassElement) {
+ _visitClassElement(element);
+ } else if (element is FieldElement) {
+ _visitFieldElement(element);
+ } else if (element is FunctionElement) {
+ _visitFunctionElement(element);
+ } else if (element is FunctionTypeAliasElement) {
+ _visitFunctionTypeAliasElement(element);
+ } else if (element is LocalVariableElement) {
+ _visitLocalVariableElement(element);
+ } else if (element is MethodElement) {
+ _visitMethodElement(element);
+ } else if (element is PropertyAccessorElement) {
+ _visitPropertyAccessorElement(element);
+ } else if (element is TopLevelVariableElement) {
+ _visitTopLevelVariableElement(element);
+ }
+ }
+ }
+
+ /// Returns whether the name of [element] consists only of underscore
+ /// characters.
+ bool _isNamedUnderscore(LocalVariableElement element) {
+ String name = element.name;
+ if (name != null) {
+ for (int index = name.length - 1; index >= 0; --index) {
+ if (name.codeUnitAt(index) != 0x5F) {
+ // 0x5F => '_'
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /// Returns whether [element] is a private element which is read somewhere in
+ /// the library.
+ bool _isReadMember(Element element) {
+ if (element.isPublic) {
+ return true;
+ }
+ if (element.isSynthetic) {
+ return true;
+ }
+ if (element is FieldElement) {
+ element = (element as FieldElement).getter;
+ }
+ if (_usedElements.readMembers.contains(element) ||
+ _usedElements.unresolvedReadMembers.contains(element.name)) {
+ return true;
+ }
+
+ return _overridesUsedElement(element);
+ }
+
+ bool _isUsedElement(Element element) {
+ if (element.isSynthetic) {
+ return true;
+ }
+ if (element is LocalVariableElement ||
+ element is FunctionElement && !element.isStatic) {
+ // local variable or function
+ } else {
+ if (element.isPublic) {
+ return true;
+ }
+ }
+ return _usedElements.elements.contains(element);
+ }
+
+ bool _isUsedMember(Element element) {
+ if (element.isPublic) {
+ return true;
+ }
+ if (element.isSynthetic) {
+ return true;
+ }
+ if (_usedElements.members.contains(element)) {
+ return true;
+ }
+ if (_usedElements.elements.contains(element)) {
+ return true;
+ }
+
+ return _overridesUsedElement(element);
+ }
+
+ // Check if this is a class member which overrides a super class's class
+ // member which is used.
+ bool _overridesUsedElement(Element element) {
+ Element enclosingElement = element.enclosingElement;
+ if (enclosingElement is ClassElement) {
+ Name name = Name(_libraryUri, element.name);
+ Iterable<ExecutableElement> overriddenElements = _inheritanceManager
+ .getOverridden(enclosingElement.thisType, name)
+ ?.map((ExecutableElement e) =>
+ (e is ExecutableMember) ? e.declaration : e);
+ if (overriddenElements != null) {
+ return overriddenElements.any((ExecutableElement e) =>
+ _usedElements.members.contains(e) || _overridesUsedElement(e));
+ }
+ }
+ return false;
+ }
+
+ void _reportErrorForElement(
+ ErrorCode errorCode, Element element, List<Object> arguments) {
+ if (element != null) {
+ _errorListener.onError(AnalysisError(element.source, element.nameOffset,
+ element.nameLength, errorCode, arguments));
+ }
+ }
+
+ _visitClassElement(ClassElement element) {
+ if (!_isUsedElement(element)) {
+ _reportErrorForElement(
+ HintCode.UNUSED_ELEMENT, element, [element.displayName]);
+ }
+ }
+
+ _visitFieldElement(FieldElement element) {
+ if (!_isReadMember(element)) {
+ _reportErrorForElement(
+ HintCode.UNUSED_FIELD, element, [element.displayName]);
+ }
+ }
+
+ _visitFunctionElement(FunctionElement element) {
+ if (!_isUsedElement(element)) {
+ _reportErrorForElement(
+ HintCode.UNUSED_ELEMENT, element, [element.displayName]);
+ }
+ }
+
+ _visitFunctionTypeAliasElement(FunctionTypeAliasElement element) {
+ if (!_isUsedElement(element)) {
+ _reportErrorForElement(
+ HintCode.UNUSED_ELEMENT, element, [element.displayName]);
+ }
+ }
+
+ _visitLocalVariableElement(LocalVariableElement element) {
+ if (!_isUsedElement(element) && !_isNamedUnderscore(element)) {
+ HintCode errorCode;
+ if (_usedElements.isCatchException(element)) {
+ errorCode = HintCode.UNUSED_CATCH_CLAUSE;
+ } else if (_usedElements.isCatchStackTrace(element)) {
+ errorCode = HintCode.UNUSED_CATCH_STACK;
+ } else {
+ errorCode = HintCode.UNUSED_LOCAL_VARIABLE;
+ }
+ _reportErrorForElement(errorCode, element, [element.displayName]);
+ }
+ }
+
+ _visitMethodElement(MethodElement element) {
+ if (!_isUsedMember(element)) {
+ _reportErrorForElement(
+ HintCode.UNUSED_ELEMENT, element, [element.displayName]);
+ }
+ }
+
+ _visitPropertyAccessorElement(PropertyAccessorElement element) {
+ if (!_isUsedMember(element)) {
+ _reportErrorForElement(
+ HintCode.UNUSED_ELEMENT, element, [element.displayName]);
+ }
+ }
+
+ _visitTopLevelVariableElement(TopLevelVariableElement element) {
+ if (!_isUsedElement(element)) {
+ _reportErrorForElement(
+ HintCode.UNUSED_ELEMENT, element, [element.displayName]);
+ }
+ }
+}
+
+/// A container with sets of used [Element]s.
+/// All these elements are defined in a single compilation unit or a library.
+class UsedLocalElements {
+ /// Resolved, locally defined elements that are used or potentially can be
+ /// used.
+ final HashSet<Element> elements = HashSet<Element>();
+
+ /// [LocalVariableElement]s that represent exceptions in [CatchClause]s.
+ final HashSet<LocalVariableElement> catchExceptionElements =
+ HashSet<LocalVariableElement>();
+
+ /// [LocalVariableElement]s that represent stack traces in [CatchClause]s.
+ final HashSet<LocalVariableElement> catchStackTraceElements =
+ HashSet<LocalVariableElement>();
+
+ /// Resolved class members that are referenced in the library.
+ final HashSet<Element> members = HashSet<Element>();
+
+ /// Resolved class members that are read in the library.
+ final HashSet<Element> readMembers = HashSet<Element>();
+
+ /// Unresolved class members that are read in the library.
+ final HashSet<String> unresolvedReadMembers = HashSet<String>();
+
+ UsedLocalElements();
+
+ factory UsedLocalElements.merge(List<UsedLocalElements> parts) {
+ UsedLocalElements result = UsedLocalElements();
+ int length = parts.length;
+ for (int i = 0; i < length; i++) {
+ UsedLocalElements part = parts[i];
+ result.elements.addAll(part.elements);
+ result.catchExceptionElements.addAll(part.catchExceptionElements);
+ result.catchStackTraceElements.addAll(part.catchStackTraceElements);
+ result.members.addAll(part.members);
+ result.readMembers.addAll(part.readMembers);
+ result.unresolvedReadMembers.addAll(part.unresolvedReadMembers);
+ }
+ return result;
+ }
+
+ void addCatchException(LocalVariableElement element) {
+ if (element != null) {
+ catchExceptionElements.add(element);
+ }
+ }
+
+ void addCatchStackTrace(LocalVariableElement element) {
+ if (element != null) {
+ catchStackTraceElements.add(element);
+ }
+ }
+
+ void addElement(Element element) {
+ if (element != null) {
+ elements.add(element);
+ }
+ }
+
+ bool isCatchException(LocalVariableElement element) {
+ return catchExceptionElements.contains(element);
+ }
+
+ bool isCatchStackTrace(LocalVariableElement element) {
+ return catchStackTraceElements.contains(element);
+ }
+}
diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
index feb7883..e7268bc 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -135,7 +135,7 @@
AstBuilder(ErrorReporter errorReporter, this.fileUri, this.isFullAst,
this._featureSet,
[Uri uri])
- : this.errorReporter = new FastaErrorReporter(errorReporter),
+ : this.errorReporter = FastaErrorReporter(errorReporter),
this.enableNonNullable = _featureSet.isEnabled(Feature.non_nullable),
this.enableSpreadCollections =
_featureSet.isEnabled(Feature.spread_collections),
@@ -167,7 +167,7 @@
@override
void addProblem(Message message, int charOffset, int length,
- {bool wasHandled: false, List<LocatedMessage> context}) {
+ {bool wasHandled = false, List<LocatedMessage> context}) {
if (directives.isEmpty &&
(message.code.analyzerCodes
?.contains('NON_PART_OF_DIRECTIVE_IN_PART') ??
@@ -196,7 +196,7 @@
assert(classDeclaration == null &&
mixinDeclaration == null &&
extensionDeclaration == null);
- push(new _Modifiers()..abstractKeyword = abstractToken);
+ push(_Modifiers()..abstractKeyword = abstractToken);
}
@override
@@ -236,7 +236,7 @@
@override
void beginFactoryMethod(
Token lastConsumed, Token externalToken, Token constToken) {
- push(new _Modifiers()
+ push(_Modifiers()
..externalKeyword = externalToken
..finalConstOrVarKeyword = constToken);
}
@@ -244,7 +244,7 @@
@override
void beginFormalParameter(Token token, MemberKind kind, Token requiredToken,
Token covariantToken, Token varFinalOrConst) {
- push(new _Modifiers()
+ push(_Modifiers()
..covariantKeyword = covariantToken
..finalConstOrVarKeyword = varFinalOrConst
..requiredToken = requiredToken);
@@ -272,7 +272,7 @@
@override
void beginMethod(Token externalToken, Token staticToken, Token covariantToken,
Token varFinalOrConst, Token getOrSet, Token name) {
- _Modifiers modifiers = new _Modifiers();
+ _Modifiers modifiers = _Modifiers();
if (externalToken != null) {
assert(externalToken.isModifier);
modifiers.externalKeyword = externalToken;
@@ -309,11 +309,11 @@
@override
void beginNamedMixinApplication(
Token begin, Token abstractToken, Token name) {
- push(new _Modifiers()..abstractKeyword = abstractToken);
+ push(_Modifiers()..abstractKeyword = abstractToken);
}
void beginTopLevelMethod(Token lastConsumed, Token externalToken) {
- push(new _Modifiers()..externalKeyword = externalToken);
+ push(_Modifiers()..externalKeyword = externalToken);
}
@override
@@ -332,7 +332,7 @@
Token token, Token lateToken, Token varFinalOrConst) {
debugEvent("beginVariablesDeclaration");
if (varFinalOrConst != null || lateToken != null) {
- push(new _Modifiers()
+ push(_Modifiers()
..finalConstOrVarKeyword = varFinalOrConst
..lateToken = lateToken);
} else {
@@ -633,7 +633,7 @@
} else {
// TODO(danrubel): Skip the block rather than parsing it.
push(ast.emptyFunctionBody(
- new SyntheticToken(TokenType.SEMICOLON, leftBracket.charOffset)));
+ SyntheticToken(TokenType.SEMICOLON, leftBracket.charOffset)));
}
}
@@ -694,7 +694,7 @@
period = name.period;
nameOrNull = name.identifier;
} else {
- throw new UnimplementedError(
+ throw UnimplementedError(
'name is an instance of ${name.runtimeType} in endClassConstructor');
}
@@ -882,7 +882,7 @@
operatorKeyword = name.operatorKeyword;
nameId = name.name;
} else {
- throw new UnimplementedError(
+ throw UnimplementedError(
'name is an instance of ${name.runtimeType} in endClassMethod');
}
@@ -1853,7 +1853,7 @@
(optional('{', leftDelimeter) && optional('}', rightDelimeter)));
debugEvent("OptionalFormalParameters");
- push(new _OptionalFormalParameters(
+ push(_OptionalFormalParameters(
popTypedList(count), leftDelimeter, rightDelimeter));
}
@@ -1899,7 +1899,7 @@
ConstructorName constructorName = pop();
Token starToken = pop();
Token asyncToken = pop();
- push(new _RedirectingFactoryBody(
+ push(_RedirectingFactoryBody(
asyncToken, starToken, equalToken, constructorName));
}
@@ -1943,7 +1943,7 @@
List<SwitchMember> members =
membersList?.expand((members) => members)?.toList() ?? <SwitchMember>[];
- Set<String> labels = new Set<String>();
+ Set<String> labels = Set<String>();
for (SwitchMember member in members) {
for (Label label in member.labels) {
if (!labels.add(label.label.name)) {
@@ -1991,10 +1991,10 @@
member.labels.insert(0, pop());
--labelCount;
}
- members = new List<SwitchMember>(expressionCount + 1);
+ members = List<SwitchMember>(expressionCount + 1);
members[expressionCount] = member;
} else {
- members = new List<SwitchMember>(expressionCount);
+ members = List<SwitchMember>(expressionCount);
}
for (int index = expressionCount - 1; index >= 0; --index) {
SwitchMember member = pop();
@@ -2725,7 +2725,7 @@
assert(optional('operator', operatorKeyword));
debugEvent("InvalidOperatorName");
- push(new _OperatorName(
+ push(_OperatorName(
operatorKeyword, ast.simpleIdentifier(token, isDeclaration: true)));
}
@@ -2750,9 +2750,9 @@
TypeArgumentList invalidTypeArgs = pop();
var node = pop();
if (node is ConstructorName) {
- push(new _ConstructorNameWithInvalidTypeArgs(node, invalidTypeArgs));
+ push(_ConstructorNameWithInvalidTypeArgs(node, invalidTypeArgs));
} else {
- throw new UnimplementedError(
+ throw UnimplementedError(
'node is an instance of ${node.runtimeType} in handleInvalidTypeArguments');
}
}
@@ -3077,7 +3077,7 @@
assert(token.type.isUserDefinableOperator);
debugEvent("OperatorName");
- push(new _OperatorName(
+ push(_OperatorName(
operatorKeyword, ast.simpleIdentifier(token, isDeclaration: true)));
}
@@ -3308,7 +3308,7 @@
void handleTypeVariablesDefined(Token token, int count) {
debugEvent("handleTypeVariablesDefined");
assert(count > 0);
- push(popTypedList(count, new List<TypeParameter>(count)));
+ push(popTypedList(count, List<TypeParameter>(count)));
}
void handleUnaryPostfixAssignmentExpression(Token operator) {
@@ -3349,7 +3349,7 @@
debugEvent("ValuedFormalParameter");
Expression value = pop();
- push(new _ParameterDefaultValue(equals, value));
+ push(_ParameterDefaultValue(equals, value));
}
@override
@@ -3373,7 +3373,7 @@
List<CommentReference> parseCommentReferences(Token dartdoc) {
// Parse dartdoc into potential comment reference source/offset pairs
int count = parser.parseCommentReferences(dartdoc);
- List sourcesAndOffsets = new List(count * 2);
+ List sourcesAndOffsets = List(count * 2);
popList(count * 2, sourcesAndOffsets);
// Parse each of the source/offset pairs into actual comment references
@@ -3391,13 +3391,13 @@
}
}
- final references = new List<CommentReference>(count);
+ final references = List<CommentReference>(count);
popTypedList(count, references);
return references;
}
List<CollectionElement> popCollectionElements(int count) {
- final elements = new List<CollectionElement>()..length = count;
+ final elements = List<CollectionElement>()..length = count;
for (int index = count - 1; index >= 0; --index) {
var element = pop();
elements[index] = element as CollectionElement;
@@ -3414,7 +3414,7 @@
if (count == 0) return null;
assert(stack.length >= count);
- final tailList = list ?? new List<T>.filled(count, null, growable: true);
+ final tailList = list ?? List<T>.filled(count, null, growable: true);
stack.popList(count, tailList, null);
return tailList;
}
diff --git a/pkg/analyzer/lib/src/fasta/error_converter.dart b/pkg/analyzer/lib/src/fasta/error_converter.dart
index eb81df0..e82aa1a 100644
--- a/pkg/analyzer/lib/src/fasta/error_converter.dart
+++ b/pkg/analyzer/lib/src/fasta/error_converter.dart
@@ -346,13 +346,8 @@
if (index != null && index > 0 && index < fastaAnalyzerErrorCodes.length) {
ErrorCode errorCode = fastaAnalyzerErrorCodes[index];
if (errorCode != null) {
- errorReporter.reportError(new AnalysisError.forValues(
- errorReporter.source,
- offset,
- length,
- errorCode,
- message.message,
- message.tip));
+ errorReporter.reportError(AnalysisError.forValues(errorReporter.source,
+ offset, length, errorCode, message.message, message.tip));
return;
}
}
@@ -369,13 +364,8 @@
void _reportByCode(
ErrorCode errorCode, Message message, int offset, int length) {
if (errorReporter != null) {
- errorReporter.reportError(new AnalysisError.forValues(
- errorReporter.source,
- offset,
- length,
- errorCode,
- message.message,
- null));
+ errorReporter.reportError(AnalysisError.forValues(errorReporter.source,
+ offset, length, errorCode, message.message, null));
}
}
}
diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart
index 2cf8f0e..d768b47 100644
--- a/pkg/analyzer/lib/src/generated/constant.dart
+++ b/pkg/analyzer/lib/src/generated/constant.dart
@@ -128,10 +128,10 @@
_typeProvider = typeProvider;
EvaluationResult evaluate(Expression expression) {
- RecordingErrorListener errorListener = new RecordingErrorListener();
- ErrorReporter errorReporter = new ErrorReporter(errorListener, _source);
- DartObjectImpl result = expression.accept(new ConstantVisitor(
- new ConstantEvaluationEngine(_typeProvider, new DeclaredVariables(),
+ RecordingErrorListener errorListener = RecordingErrorListener();
+ ErrorReporter errorReporter = ErrorReporter(errorListener, _source);
+ DartObjectImpl result = expression.accept(ConstantVisitor(
+ ConstantEvaluationEngine(_typeProvider, DeclaredVariables(),
typeSystem: _typeSystem),
errorReporter));
List<AnalysisError> errors = errorListener.errors;
diff --git a/pkg/analyzer/lib/src/generated/declaration_resolver.dart b/pkg/analyzer/lib/src/generated/declaration_resolver.dart
index 8b07563..8c9f8b8 100644
--- a/pkg/analyzer/lib/src/generated/declaration_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/declaration_resolver.dart
@@ -48,23 +48,24 @@
/// Creates an [ElementWalker] which walks the child elements of a compilation
/// unit element.
- ElementWalker.forCompilationUnit(CompilationUnitElement compilationUnit)
- : element = compilationUnit,
- _accessors = compilationUnit.accessors.where(_isNotSynthetic).toList(),
- _classes = compilationUnit.types,
- _enums = compilationUnit.enums,
- _extensions = compilationUnit.extensions,
- _functions = compilationUnit.functions,
- _mixins = compilationUnit.mixins,
- _typedefs = compilationUnit.functionTypeAliases,
- _variables =
- compilationUnit.topLevelVariables.where(_isNotSynthetic).toList();
+ ElementWalker.forCompilationUnit(CompilationUnitElement element)
+ : element = element,
+ _accessors = element.accessors.where(_isNotSynthetic).toList(),
+ _classes = element.types,
+ _enums = element.enums,
+ _extensions = element.extensions,
+ _functions = element.functions,
+ _mixins = element.mixins,
+ _typedefs = element.functionTypeAliases,
+ _variables = element.topLevelVariables.where(_isNotSynthetic).toList();
/// Creates an [ElementWalker] which walks the child elements of a compilation
/// unit element.
- ElementWalker.forExecutable(
- ExecutableElement element, CompilationUnitElement compilationUnit)
- : this._forExecutable(element, compilationUnit);
+ ElementWalker.forExecutable(ExecutableElement element)
+ : element = element,
+ _functions = const <ExecutableElement>[],
+ _parameters = element.parameters,
+ _typeParameters = element.typeParameters;
/// Creates an [ElementWalker] which walks the child elements of an extension
/// element.
@@ -102,13 +103,6 @@
_parameters = element.function.parameters,
_typeParameters = element.typeParameters;
- ElementWalker._forExecutable(
- ExecutableElement element, CompilationUnitElement compilationUnit)
- : element = element,
- _functions = const <ExecutableElement>[],
- _parameters = element.parameters,
- _typeParameters = element.typeParameters;
-
void consumeLocalElements() {
_functionIndex = _functions.length;
}
@@ -168,7 +162,7 @@
void validate() {
void check(List<Element> elements, int index) {
if (elements != null && elements.length != index) {
- throw new StateError(
+ throw StateError(
'Unmatched ${elements[index].runtimeType} ${elements[index]}');
}
}
diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
index 4f3f96f..f357a0d 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -120,10 +120,10 @@
* Initialize a newly created visitor to work for the given [_resolver] to
* resolve the nodes in a compilation unit.
*/
- ElementResolver(this._resolver, {this.reportConstEvaluationErrors: true})
+ ElementResolver(this._resolver, {this.reportConstEvaluationErrors = true})
: _definingLibrary = _resolver.definingLibrary,
_extensionResolver = _resolver.extensionResolver,
- _methodInvocationResolver = new MethodInvocationResolver(_resolver) {
+ _methodInvocationResolver = MethodInvocationResolver(_resolver) {
_dynamicType = _resolver.typeProvider.dynamicType;
_typeType = _resolver.typeProvider.typeType;
}
@@ -589,9 +589,9 @@
if (prefixElement is PrefixElement) {
Element element = _resolver.nameScope.lookup(node, _definingLibrary);
if (element == null && identifier.inSetterContext()) {
- Identifier setterName = new PrefixedIdentifierImpl.temp(
+ Identifier setterName = PrefixedIdentifierImpl.temp(
node.prefix,
- new SimpleIdentifierImpl(new StringToken(TokenType.STRING,
+ SimpleIdentifierImpl(StringToken(TokenType.STRING,
"${node.identifier.name}=", node.identifier.offset - 1)));
element = _resolver.nameScope.lookup(setterName, _definingLibrary);
}
@@ -1071,7 +1071,7 @@
} else if (expression.operator.type == TokenType.MINUS_MINUS) {
return TokenType.MINUS.lexeme;
} else {
- throw new UnsupportedError(
+ throw UnsupportedError(
'Unsupported postfix operator ${expression.operator.lexeme}');
}
}
@@ -1097,7 +1097,7 @@
* Return the static type of the given [expression] that is to be used for
* type analysis.
*/
- DartType _getStaticType(Expression expression, {bool read: false}) {
+ DartType _getStaticType(Expression expression, {bool read = false}) {
if (expression is NullLiteral) {
return _resolver.typeProvider.nullType;
}
@@ -1499,7 +1499,7 @@
return;
}
Namespace namespace =
- new NamespaceBuilder().createExportNamespaceForLibrary(library);
+ NamespaceBuilder().createExportNamespaceForLibrary(library);
for (Combinator combinator in combinators) {
NodeList<SimpleIdentifier> names;
if (combinator is HideCombinator) {
@@ -1829,7 +1829,7 @@
(identifier.inSetterContext() ||
identifier.parent is CommentReference)) {
Identifier setterId =
- new SyntheticIdentifier('${identifier.name}=', identifier);
+ SyntheticIdentifier('${identifier.name}=', identifier);
element = _resolver.nameScope.lookup(setterId, _definingLibrary);
}
if (element == null) {
@@ -1983,7 +1983,7 @@
// Should never be called, since a SyntheticIdentifier never appears in the
// AST--it is just used for lookup.
assert(false);
- return new ChildEntities();
+ return ChildEntities();
}
@override
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart
index 81081ba..eca2b9f 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -18,7 +18,6 @@
import 'package:analyzer/src/generated/utilities_general.dart';
import 'package:analyzer/src/services/lint.dart';
import 'package:analyzer/src/summary/api_signature.dart';
-import 'package:meta/meta.dart';
import 'package:path/path.dart' as pathos;
import 'package:pub_semver/pub_semver.dart';
@@ -75,7 +74,7 @@
/// Set the set of analysis options controlling the behavior of this context to
/// the given [options]. Clients can safely assume that all necessary analysis
/// results have been invalidated.
- void set analysisOptions(AnalysisOptions options);
+ set analysisOptions(AnalysisOptions options);
/// Return the set of declared variables used when computing constant values.
DeclaredVariables get declaredVariables;
@@ -87,13 +86,15 @@
/// Set the source factory used to create the sources that can be analyzed in
/// this context to the given source [factory]. Clients can safely assume that
/// all analysis results have been invalidated.
- void set sourceFactory(SourceFactory factory);
+ set sourceFactory(SourceFactory factory);
/// Return a type provider for this context or throw [AnalysisException] if
/// either `dart:core` or `dart:async` cannot be resolved.
+ @Deprecated('Use LibraryElement.typeProvider')
TypeProvider get typeProvider;
/// Return a type system for this context.
+ @Deprecated('Use LibraryElement.typeSystem')
TypeSystem get typeSystem;
}
@@ -122,7 +123,7 @@
static const String ANDROID_MANIFEST_FILE = 'AndroidManifest.xml';
/// The unique instance of this class.
- static final AnalysisEngine instance = new AnalysisEngine._();
+ static final AnalysisEngine instance = AnalysisEngine._();
/// The instrumentation service that is to be used by this analysis engine.
InstrumentationService _instrumentationService =
@@ -136,7 +137,7 @@
/// Set the instrumentation service that is to be used by this analysis engine
/// to the given [service].
- void set instrumentationService(InstrumentationService service) {
+ set instrumentationService(InstrumentationService service) {
if (service == null) {
_instrumentationService = InstrumentationService.NULL_SERVICE;
} else {
@@ -559,7 +560,7 @@
analyzeFunctionBodiesPredicate, _analyzeNoFunctionBodies)) {
return false;
} else {
- throw new StateError('analyzeFunctionBodiesPredicate in use');
+ throw StateError('analyzeFunctionBodiesPredicate in use');
}
}
@@ -577,7 +578,7 @@
set analyzeFunctionBodiesPredicate(AnalyzeFunctionBodiesPredicate value) {
if (value == null) {
- throw new ArgumentError.notNull('analyzeFunctionBodiesPredicate');
+ throw ArgumentError.notNull('analyzeFunctionBodiesPredicate');
}
_analyzeFunctionBodiesPredicate = value;
}
@@ -595,27 +596,27 @@
bool get enableAssertInitializer => true;
@deprecated
- void set enableAssertInitializer(bool enable) {}
+ set enableAssertInitializer(bool enable) {}
@override
@deprecated
bool get enableAssertMessage => true;
@deprecated
- void set enableAssertMessage(bool enable) {}
+ set enableAssertMessage(bool enable) {}
@deprecated
@override
bool get enableAsync => true;
@deprecated
- void set enableAsync(bool enable) {}
+ set enableAsync(bool enable) {}
/// A flag indicating whether interface libraries are to be supported (DEP 40).
bool get enableConditionalDirectives => true;
@deprecated
- void set enableConditionalDirectives(_) {}
+ set enableConditionalDirectives(_) {}
@override
List<String> get enabledExperiments => _enabledExperiments;
@@ -630,21 +631,21 @@
bool get enableGenericMethods => true;
@deprecated
- void set enableGenericMethods(bool enable) {}
+ set enableGenericMethods(bool enable) {}
@deprecated
@override
bool get enableInitializingFormalAccess => true;
@deprecated
- void set enableInitializingFormalAccess(bool enable) {}
+ set enableInitializingFormalAccess(bool enable) {}
@override
@deprecated
bool get enableSuperMixins => false;
@deprecated
- void set enableSuperMixins(bool enable) {
+ set enableSuperMixins(bool enable) {
// Ignored.
}
@@ -653,7 +654,7 @@
bool get enableUriInPartOf => true;
@deprecated
- void set enableUriInPartOf(bool enable) {}
+ set enableUriInPartOf(bool enable) {}
@override
List<ErrorProcessor> get errorProcessors =>
@@ -661,7 +662,7 @@
/// Set the list of error [processors] that are to be used when reporting
/// errors in some analysis context.
- void set errorProcessors(List<ErrorProcessor> processors) {
+ set errorProcessors(List<ErrorProcessor> processors) {
_errorProcessors = processors;
}
@@ -670,7 +671,7 @@
/// Set the exclude patterns used to exclude some sources from analysis to
/// those in the given list of [patterns].
- void set excludePatterns(List<String> patterns) {
+ set excludePatterns(List<String> patterns) {
_excludePatterns = patterns;
}
@@ -690,7 +691,7 @@
/// Set the lint rules that are to be run in an analysis context if [lint]
/// returns `true`.
- void set lintRules(List<Linter> rules) {
+ set lintRules(List<Linter> rules) {
_lintRules = rules;
}
@@ -704,7 +705,7 @@
@override
Uint32List get signature {
if (_signature == null) {
- ApiSignature buffer = new ApiSignature();
+ ApiSignature buffer = ApiSignature();
// Append environment.
if (sdkVersionConstraint != null) {
@@ -747,7 +748,7 @@
// Hash and convert to Uint32List.
List<int> bytes = buffer.toByteList();
- _signature = new Uint8List.fromList(bytes).buffer.asUint32List();
+ _signature = Uint8List.fromList(bytes).buffer.asUint32List();
}
return _signature;
}
@@ -764,7 +765,7 @@
/// The length of the list is guaranteed to equal [unlinkedSignatureLength].
Uint32List get unlinkedSignature {
if (_unlinkedSignature == null) {
- ApiSignature buffer = new ApiSignature();
+ ApiSignature buffer = ApiSignature();
// Append boolean flags.
buffer.addBool(enableLazyAssignmentOperators);
@@ -778,7 +779,7 @@
// Hash and convert to Uint32List.
List<int> bytes = buffer.toByteList();
- _unlinkedSignature = new Uint8List.fromList(bytes).buffer.asUint32List();
+ _unlinkedSignature = Uint8List.fromList(bytes).buffer.asUint32List();
}
return _unlinkedSignature;
}
@@ -845,20 +846,10 @@
static bool _analyzeNoFunctionBodies(Source _) => false;
}
-/// Additional behavior for an analysis context that is required by internal
-/// users of the context.
-abstract class InternalAnalysisContext implements AnalysisContext {
- /// Sets the [TypeProvider]s for this context.
- void setTypeProviders({
- @required TypeProvider legacy,
- @required TypeProvider nonNullableByDefault,
- });
-}
-
/// Container with global [AnalysisContext] performance statistics.
class PerformanceStatistics {
/// The [PerformanceTag] for `package:analyzer`.
- static PerformanceTag analyzer = new PerformanceTag('analyzer');
+ static PerformanceTag analyzer = PerformanceTag('analyzer');
/// The [PerformanceTag] for time spent in reading files.
static PerformanceTag io = analyzer.createChild('io');
@@ -873,7 +864,7 @@
static PerformanceTag parse = analyzer.createChild('parse');
/// The [PerformanceTag] for time spent in resolving.
- static PerformanceTag resolve = new PerformanceTag('resolve');
+ static PerformanceTag resolve = PerformanceTag('resolve');
/// The [PerformanceTag] for time spent in error verifier.
static PerformanceTag errors = analysis.createChild('errors');
@@ -885,7 +876,7 @@
static PerformanceTag lints = analysis.createChild('lints');
/// The [PerformanceTag] for time spent computing cycles.
- static PerformanceTag cycles = new PerformanceTag('cycles');
+ static PerformanceTag cycles = PerformanceTag('cycles');
/// The [PerformanceTag] for time spent in summaries support.
static PerformanceTag summary = analyzer.createChild('summary');
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 341e266..802caf6 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -127,6 +127,14 @@
bool _isInConstInstanceCreation = false;
/**
+ * The stack of flags, where `true` at the top (last) of the stack indicates
+ * that the visitor is in the initializer of a lazy local variable. When the
+ * top is `false`, we might be not in a local variable, or it is not `lazy`,
+ * etc.
+ */
+ List<bool> _isInLateLocalVariable = [false];
+
+ /**
* A flag indicating whether the visitor is currently within a native class
* declaration.
*/
@@ -209,13 +217,13 @@
* The return statements found in the method or function that we are currently
* visiting that have a return value.
*/
- List<ReturnStatement> _returnsWith = new List<ReturnStatement>();
+ List<ReturnStatement> _returnsWith = List<ReturnStatement>();
/**
* The return statements found in the method or function that we are currently
* visiting that do not have a return value.
*/
- List<ReturnStatement> _returnsWithout = new List<ReturnStatement>();
+ List<ReturnStatement> _returnsWithout = List<ReturnStatement>();
/**
* This map is initialized when visiting the contents of a class declaration.
@@ -238,25 +246,25 @@
* this library.
*/
Map<String, LibraryElement> _nameToExportElement =
- new HashMap<String, LibraryElement>();
+ HashMap<String, LibraryElement>();
/**
* A table mapping name of the library to the import directive which import
* this library.
*/
Map<String, LibraryElement> _nameToImportElement =
- new HashMap<String, LibraryElement>();
+ HashMap<String, LibraryElement>();
/**
* A table mapping names to the exported elements.
*/
- Map<String, Element> _exportedElements = new HashMap<String, Element>();
+ Map<String, Element> _exportedElements = HashMap<String, Element>();
/**
* A set of the names of the variable initializers we are visiting now.
*/
HashSet<String> _namesForReferenceToDeclaredVariableInInitializer =
- new HashSet<String>();
+ HashSet<String>();
/**
* The elements that will be defined later in the current scope, but right
@@ -286,10 +294,10 @@
*/
ErrorVerifier(ErrorReporter errorReporter, this._currentLibrary,
this._typeProvider, this._inheritanceManager, bool enableSuperMixins,
- {this.disableConflictingGenericsCheck: false})
+ {this.disableConflictingGenericsCheck = false})
: _errorReporter = errorReporter,
_uninstantiatedBoundChecker =
- new _UninstantiatedBoundChecker(errorReporter),
+ _UninstantiatedBoundChecker(errorReporter),
_requiredParametersVerifier = RequiredParametersVerifier(errorReporter),
_duplicateDefinitionVerifier =
DuplicateDefinitionVerifier(_currentLibrary, errorReporter) {
@@ -302,7 +310,7 @@
_isInStaticMethod = false;
_boolType = _typeProvider.boolType;
_intType = _typeProvider.intType;
- _typeSystem = _currentLibrary.context.typeSystem;
+ _typeSystem = _currentLibrary.typeSystem;
_options = _currentLibrary.context.analysisOptions;
_typeArgumentsVerifier =
TypeArgumentsVerifier(_options, _typeSystem, _errorReporter);
@@ -393,6 +401,7 @@
_errorReporter.reportErrorForToken(
CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT, node.awaitKeyword);
}
+ _checkForAwaitInLateLocalVariableInitializer(node);
super.visitAwaitExpression(node);
}
@@ -424,7 +433,7 @@
@override
void visitBlock(Block node) {
- _hiddenElements = new HiddenElements(_hiddenElements, node);
+ _hiddenElements = HiddenElements(_hiddenElements, node);
try {
_duplicateDefinitionVerifier.checkStatements(node.statements);
super.visitBlock(node);
@@ -442,8 +451,8 @@
try {
_inAsync = node.isAsynchronous;
_inGenerator = node.isGenerator;
- _returnsWith = new List<ReturnStatement>();
- _returnsWithout = new List<ReturnStatement>();
+ _returnsWith = List<ReturnStatement>();
+ _returnsWithout = List<ReturnStatement>();
super.visitBlockFunctionBody(node);
} finally {
_inAsync = wasInAsync;
@@ -708,6 +717,7 @@
try {
_checkForNotInitializedNonNullableStaticField(node);
_checkForWrongTypeParameterVarianceInField(node);
+ _checkForLateFinalFieldWithConstConstructor(node);
super.visitFieldDeclaration(node);
} finally {
_isInStaticVariableDeclaration = false;
@@ -823,6 +833,7 @@
@override
void visitFunctionExpression(FunctionExpression node) {
+ _isInLateLocalVariable.add(false);
// If this function expression is wrapped in a function declaration, don't
// change the enclosingFunction field.
if (node.parent is! FunctionDeclaration) {
@@ -836,6 +847,7 @@
} else {
super.visitFunctionExpression(node);
}
+ _isInLateLocalVariable.removeLast();
}
@override
@@ -1380,8 +1392,12 @@
@override
void visitVariableDeclarationStatement(VariableDeclarationStatement node) {
+ _isInLateLocalVariable.add(node.variables.isLate);
+
_checkForFinalNotInitialized(node.variables);
super.visitVariableDeclarationStatement(node);
+
+ _isInLateLocalVariable.removeLast();
}
@override
@@ -1510,7 +1526,7 @@
}
Map<FieldElement, INIT_STATE> fieldElementsMap =
- new HashMap<FieldElement, INIT_STATE>.from(_initialFieldElementsMap);
+ HashMap<FieldElement, INIT_STATE>.from(_initialFieldElementsMap);
// Visit all of the field formal parameters
NodeList<FormalParameter> formalParameters =
constructor.parameters.parameters;
@@ -1738,8 +1754,8 @@
// Report specific problem when return type is incompatible
FunctionType constructorType = declaration.declaredElement.type;
DartType constructorReturnType = constructorType.returnType;
- if (!_typeSystem.isAssignableTo(redirectedReturnType, constructorReturnType,
- featureSet: _featureSet)) {
+ if (!_typeSystem.isAssignableTo(
+ redirectedReturnType, constructorReturnType)) {
_errorReporter.reportErrorForNode(
StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE,
redirectedConstructor,
@@ -1817,7 +1833,7 @@
}
// check exported names
Namespace namespace =
- new NamespaceBuilder().createExportNamespaceForDirective(exportElement);
+ NamespaceBuilder().createExportNamespaceForDirective(exportElement);
Map<String, Element> definedNames = namespace.definedNames;
for (String name in definedNames.keys) {
Element element = definedNames[name];
@@ -1846,7 +1862,7 @@
String name = element.displayName;
List<Element> conflictingMembers = element.conflictingElements;
int count = conflictingMembers.length;
- List<String> libraryNames = new List<String>(count);
+ List<String> libraryNames = List<String>(count);
for (int i = 0; i < count; i++) {
libraryNames[i] = _getLibraryName(conflictingMembers[i]);
}
@@ -1958,8 +1974,7 @@
if (expressionType == null) {
return;
}
- if (_typeSystem.isAssignableTo(expressionType, type,
- featureSet: _featureSet)) {
+ if (_typeSystem.isAssignableTo(expressionType, type)) {
return;
}
if (expressionType.element == type.element) {
@@ -1983,8 +1998,7 @@
DartType actualStaticType,
DartType expectedStaticType,
ErrorCode errorCode) {
- if (!_typeSystem.isAssignableTo(actualStaticType, expectedStaticType,
- featureSet: _featureSet)) {
+ if (!_typeSystem.isAssignableTo(actualStaticType, expectedStaticType)) {
_errorReporter.reportTypeErrorForNode(
errorCode, expression, [actualStaticType, expectedStaticType]);
return false;
@@ -2056,6 +2070,15 @@
}
}
+ void _checkForAwaitInLateLocalVariableInitializer(AwaitExpression node) {
+ if (_isInLateLocalVariable.last) {
+ _errorReporter.reportErrorForToken(
+ CompileTimeErrorCode.AWAIT_IN_LATE_LOCAL_VARIABLE_INITIALIZER,
+ node.awaitKeyword,
+ );
+ }
+ }
+
/**
* Verifies that the class is not named `Function` and that it doesn't
* extends/implements/mixes in `Function`.
@@ -2189,9 +2212,9 @@
// find inherited property accessor
ExecutableElement inherited = _inheritanceManager.getInherited(
- enclosingType, new Name(libraryUri, name));
+ enclosingType, Name(libraryUri, name));
inherited ??= _inheritanceManager.getInherited(
- enclosingType, new Name(libraryUri, '$name='));
+ enclosingType, Name(libraryUri, '$name='));
if (method.isStatic && inherited != null) {
_errorReporter.reportErrorForElement(
@@ -2216,9 +2239,9 @@
// find inherited method or property accessor
ExecutableElement inherited = _inheritanceManager.getInherited(
- enclosingType, new Name(libraryUri, name));
+ enclosingType, Name(libraryUri, name));
inherited ??= _inheritanceManager.getInherited(
- enclosingType, new Name(libraryUri, '$name='));
+ enclosingType, Name(libraryUri, '$name='));
if (accessor.isStatic && inherited != null) {
_errorReporter.reportErrorForElement(
@@ -2446,9 +2469,6 @@
* [ConstructorName] from the [InstanceCreationExpression], this is the AST
* node that the error is attached to. The [type] is the type being
* constructed with this [InstanceCreationExpression].
- *
- * See [StaticWarningCode.CONST_WITH_ABSTRACT_CLASS], and
- * [StaticWarningCode.NEW_WITH_ABSTRACT_CLASS].
*/
void _checkForConstOrNewWithAbstractClass(
InstanceCreationExpression expression,
@@ -2461,15 +2481,10 @@
(expression as InstanceCreationExpressionImpl).isImplicit;
if (!isImplicit) {
_errorReporter.reportErrorForNode(
- expression.isConst
- ? StaticWarningCode.CONST_WITH_ABSTRACT_CLASS
- : StaticWarningCode.NEW_WITH_ABSTRACT_CLASS,
- typeName);
+ StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS, typeName);
} else {
- // TODO(brianwilkerson/jwren) Create a new different StaticWarningCode
- // which does not call out the new keyword so explicitly.
_errorReporter.reportErrorForNode(
- StaticWarningCode.NEW_WITH_ABSTRACT_CLASS, typeName);
+ StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS, typeName);
}
}
}
@@ -2515,8 +2530,13 @@
void _checkForConstWithNonConst(InstanceCreationExpression expression) {
ConstructorElement constructorElement = expression.staticElement;
if (constructorElement != null && !constructorElement.isConst) {
- _errorReporter.reportErrorForNode(
- CompileTimeErrorCode.CONST_WITH_NON_CONST, expression);
+ if (expression.keyword != null) {
+ _errorReporter.reportErrorForToken(
+ CompileTimeErrorCode.CONST_WITH_NON_CONST, expression.keyword);
+ } else {
+ _errorReporter.reportErrorForNode(
+ CompileTimeErrorCode.CONST_WITH_NON_CONST, expression);
+ }
}
}
@@ -2633,7 +2653,7 @@
int count = directives.length;
if (count > 0) {
Map<PrefixElement, List<ImportDirective>> prefixToDirectivesMap =
- new HashMap<PrefixElement, List<ImportDirective>>();
+ HashMap<PrefixElement, List<ImportDirective>>();
for (int i = 0; i < count; i++) {
Directive directive = directives[i];
if (directive is ImportDirective) {
@@ -2643,7 +2663,7 @@
if (element is PrefixElement) {
List<ImportDirective> elements = prefixToDirectivesMap[element];
if (elements == null) {
- elements = new List<ImportDirective>();
+ elements = List<ImportDirective>();
prefixToDirectivesMap[element] = elements;
}
elements.add(directive);
@@ -2725,8 +2745,7 @@
StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE,
node.iterable,
[iterableType, loopTypeName]);
- } else if (!_typeSystem.isAssignableTo(bestIterableType, variableType,
- featureSet: _featureSet)) {
+ } else if (!_typeSystem.isAssignableTo(bestIterableType, variableType)) {
_errorReporter.reportTypeErrorForNode(
StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE,
node.iterable,
@@ -2917,8 +2936,7 @@
if (staticType == null) {
return;
}
- if (_typeSystem.isAssignableTo(staticType, fieldType,
- featureSet: _featureSet)) {
+ if (_typeSystem.isAssignableTo(staticType, fieldType)) {
return;
}
// report problem
@@ -3502,6 +3520,25 @@
}
}
+ void _checkForLateFinalFieldWithConstConstructor(FieldDeclaration node) {
+ if (node.isStatic) return;
+
+ var variableList = node.fields;
+ if (!variableList.isFinal) return;
+
+ var lateKeyword = variableList.lateKeyword;
+ if (lateKeyword == null) return;
+
+ var hasConstConstructor =
+ _enclosingClass.constructors.any((c) => c.isConst);
+ if (!hasConstConstructor) return;
+
+ _errorReporter.reportErrorForToken(
+ CompileTimeErrorCode.LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR,
+ lateKeyword,
+ );
+ }
+
void _checkForListConstructor(
InstanceCreationExpression node, InterfaceType type) {
if (!_isNonNullable) return;
@@ -3655,8 +3692,7 @@
// (if the getter is null, it is dynamic which is assignable to everything).
if (setterType != null &&
getterType != null &&
- !_typeSystem.isAssignableTo(getterType, setterType,
- featureSet: _featureSet)) {
+ !_typeSystem.isAssignableTo(getterType, setterType)) {
_errorReporter.reportTypeErrorForNode(
StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES,
accessorDeclaration,
@@ -3681,8 +3717,7 @@
DartType setterType = _getSetterType(setterElement);
if (setterType != null &&
getterType != null &&
- !_typeSystem.isAssignableTo(getterType, setterType,
- featureSet: _featureSet)) {
+ !_typeSystem.isAssignableTo(getterType, setterType)) {
SimpleIdentifier nameNode = member.name;
String name = nameNode.name;
_errorReporter.reportTypeErrorForNode(
@@ -3827,8 +3862,12 @@
bool _checkForMixinSuperclassConstraints(int mixinIndex, TypeName mixinName) {
InterfaceType mixinType = mixinName.type;
for (var constraint in mixinType.superclassConstraints) {
- bool isSatisfied =
- _typeSystem.isSubtypeOf(_enclosingClass.supertype, constraint);
+ var superType = _enclosingClass.supertype as InterfaceTypeImpl;
+ if (_currentLibrary.isNonNullableByDefault) {
+ superType = superType.withNullability(NullabilitySuffix.none);
+ }
+
+ bool isSatisfied = _typeSystem.isSubtypeOf(superType, constraint);
if (!isSatisfied) {
for (int i = 0; i < mixinIndex && !isSatisfied; i++) {
isSatisfied =
@@ -3837,12 +3876,14 @@
}
if (!isSatisfied) {
_errorReporter.reportErrorForNode(
- CompileTimeErrorCode.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE,
- mixinName.name, [
- mixinName.type.displayName,
- _enclosingClass.supertype,
- constraint.displayName
- ]);
+ CompileTimeErrorCode.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE,
+ mixinName.name,
+ [
+ mixinName.type.displayName,
+ superType,
+ constraint.displayName,
+ ],
+ );
return true;
}
}
@@ -3862,7 +3903,7 @@
InterfaceTypeImpl enclosingType = _enclosingClass.thisType;
Uri mixinLibraryUri = mixinElement.librarySource.uri;
for (var name in mixinElementImpl.superInvokedNames) {
- var nameObject = new Name(mixinLibraryUri, name);
+ var nameObject = Name(mixinLibraryUri, name);
var superMember = _inheritanceManager.getMember(enclosingType, nameObject,
forMixinIndex: mixinIndex, concrete: true, forSuper: true);
@@ -3989,7 +4030,7 @@
}
MethodElement element = _findOverriddenMemberThatMustCallSuper(node);
if (element != null && _hasConcreteSuperMethod(node)) {
- _InvocationCollector collector = new _InvocationCollector();
+ _InvocationCollector collector = _InvocationCollector();
node.accept(collector);
if (!collector.superCalls.contains(element.name)) {
_errorReporter.reportErrorForNode(HintCode.MUST_CALL_SUPER, node.name,
@@ -4114,7 +4155,7 @@
{@required ErrorCode errorCode}) {
DartType type = getStaticType(expression);
if (!_checkForUseOfVoidResult(expression) &&
- !_typeSystem.isAssignableTo(type, _boolType, featureSet: _featureSet)) {
+ !_typeSystem.isAssignableTo(type, _boolType)) {
if (type.element == _boolType.element) {
_errorReporter.reportErrorForNode(
StaticWarningCode.UNCHECKED_USE_OF_NULLABLE_VALUE, expression);
@@ -4594,7 +4635,7 @@
_hiddenElements != null &&
_hiddenElements.contains(node.staticElement) &&
node.parent is! CommentReference) {
- _errorReporter.reportError(new DiagnosticFactory()
+ _errorReporter.reportError(DiagnosticFactory()
.referencedBeforeDeclaration(_errorReporter.source, node));
}
}
@@ -4605,7 +4646,7 @@
}
int count = typeNames.length;
- List<bool> detectedRepeatOnIndex = new List<bool>.filled(count, false);
+ List<bool> detectedRepeatOnIndex = List<bool>.filled(count, false);
for (int i = 0; i < detectedRepeatOnIndex.length; i++) {
detectedRepeatOnIndex[i] = false;
}
@@ -4683,6 +4724,13 @@
DartType expressionType = getStaticType(returnExpression);
+ var toType = expectedType;
+ var fromType = expressionType;
+ if (_inAsync) {
+ toType = _typeSystem.flatten(toType);
+ fromType = _typeSystem.flatten(fromType);
+ }
+
void reportTypeError() {
String displayName = _enclosingFunction.displayName;
@@ -4690,27 +4738,20 @@
_errorReporter.reportTypeErrorForNode(
StaticTypeWarningCode.RETURN_OF_INVALID_TYPE_FROM_CLOSURE,
returnExpression,
- [expressionType, expectedType]);
+ [fromType, toType]);
} else if (_enclosingFunction is MethodElement) {
_errorReporter.reportTypeErrorForNode(
StaticTypeWarningCode.RETURN_OF_INVALID_TYPE_FROM_METHOD,
returnExpression,
- [expressionType, expectedType, displayName]);
+ [fromType, toType, displayName]);
} else {
_errorReporter.reportTypeErrorForNode(
StaticTypeWarningCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION,
returnExpression,
- [expressionType, expectedType, displayName]);
+ [fromType, toType, displayName]);
}
}
- var toType = expectedType;
- var fromType = expressionType;
- if (_inAsync) {
- toType = _typeSystem.flatten(toType);
- fromType = _typeSystem.flatten(fromType);
- }
-
// Anything can be returned to `void` in an arrow bodied function
// or to `Future<void>` in an async arrow bodied function.
if (isArrowFunction && toType.isVoid) {
@@ -4732,8 +4773,7 @@
if (!expectedType.isVoid && !fromType.isVoid) {
var checkWithType =
!_inAsync ? fromType : _typeProvider.futureType2(fromType);
- if (_typeSystem.isAssignableTo(checkWithType, expectedType,
- featureSet: _featureSet)) {
+ if (_typeSystem.isAssignableTo(checkWithType, expectedType)) {
return;
}
}
@@ -4838,8 +4878,7 @@
DartType caseType = getStaticType(caseExpression);
// check types
- if (!_typeSystem.isAssignableTo(expressionType, caseType,
- featureSet: _featureSet)) {
+ if (!_typeSystem.isAssignableTo(expressionType, caseType)) {
_errorReporter.reportErrorForNode(
StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE,
expression,
@@ -5137,8 +5176,7 @@
[parameter.identifier.name]);
} else if (declaredType != null &&
fieldType != null &&
- !_typeSystem.isAssignableTo(declaredType, fieldType,
- featureSet: _featureSet)) {
+ !_typeSystem.isAssignableTo(declaredType, fieldType)) {
_errorReporter.reportTypeErrorForNode(
StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE,
parameter,
@@ -5434,8 +5472,7 @@
} else {
requiredReturnType = _typeProvider.iterableDynamicType;
}
- if (!_typeSystem.isAssignableTo(impliedReturnType, requiredReturnType,
- featureSet: _featureSet)) {
+ if (!_typeSystem.isAssignableTo(impliedReturnType, requiredReturnType)) {
_errorReporter.reportTypeErrorForNode(
StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
yieldExpression,
@@ -5579,13 +5616,10 @@
if (!_isNonNullable) return;
AstNode parent = node.parent;
- if (parent is FieldFormalParameter ||
- parent is FunctionTypeAlias ||
- parent is FunctionTypedFormalParameter ||
- parent is GenericFunctionType) {
- // These locations are not allowed to have default values.
- return;
- }
+ var defaultValuesAreAllowed = parent is ConstructorDeclaration ||
+ parent is FunctionExpression ||
+ parent is MethodDeclaration;
+
NodeList<FormalParameter> parameters = node.parameters;
int length = parameters.length;
for (int i = 0; i < length; i++) {
@@ -5595,7 +5629,7 @@
if ((parameter as DefaultFormalParameter).defaultValue == null) {
if (_typeSystem.isPotentiallyNonNullable(type)) {
SimpleIdentifier parameterName = _parameterName(parameter);
- if (type is TypeParameterType) {
+ if (!defaultValuesAreAllowed || type is TypeParameterType) {
_errorReporter.reportErrorForNode(
CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE,
parameterName ?? parameter,
@@ -5607,15 +5641,6 @@
[parameterName?.name ?? '?']);
}
}
- } else if (!_typeSystem.isNonNullable(type) &&
- _typeSystem.isPotentiallyNonNullable(type)) {
- // If the type is both potentially non-nullable and not
- // non-nullable, then it cannot be used for an optional parameter.
- SimpleIdentifier parameterName = _parameterName(parameter);
- _errorReporter.reportErrorForNode(
- CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE,
- parameterName ?? parameter,
- [parameterName?.name ?? '?']);
}
} else if (parameter.isRequiredNamed) {
if ((parameter as DefaultFormalParameter).defaultValue != null) {
@@ -5693,7 +5718,7 @@
Queue.of(classElement.mixins.map((i) => i.element))
..addAll(classElement.superclassConstraints.map((i) => i.element))
..add(classElement.supertype?.element);
- Set<ClassElement> visitedClasses = new Set<ClassElement>();
+ Set<ClassElement> visitedClasses = Set<ClassElement>();
while (superclasses.isNotEmpty) {
ClassElement ancestor = superclasses.removeFirst();
if (ancestor == null || !visitedClasses.add(ancestor)) {
@@ -5786,7 +5811,7 @@
return library.definingCompilationUnit.source.uri.toString();
}
}
- List<String> indirectSources = new List<String>();
+ List<String> indirectSources = List<String>();
for (int i = 0; i < count; i++) {
LibraryElement importedLibrary = imports[i].importedLibrary;
if (importedLibrary != null) {
@@ -5800,7 +5825,7 @@
}
}
int indirectCount = indirectSources.length;
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write(library.definingCompilationUnit.source.uri.toString());
if (indirectCount > 0) {
buffer.write(" (via ");
@@ -5848,7 +5873,7 @@
* indirectly.
*/
bool _hasRedirectingFactoryConstructorCycle(ConstructorElement constructor) {
- Set<ConstructorElement> constructors = new HashSet<ConstructorElement>();
+ Set<ConstructorElement> constructors = HashSet<ConstructorElement>();
ConstructorElement current = constructor;
while (current != null) {
if (constructors.contains(current)) {
@@ -5861,7 +5886,7 @@
}
void _initializeInitialFieldElementsMap(List<FieldElement> fields) {
- _initialFieldElementsMap = new HashMap<FieldElement, INIT_STATE>();
+ _initialFieldElementsMap = HashMap<FieldElement, INIT_STATE>();
for (FieldElement fieldElement in fields) {
if (!fieldElement.isSynthetic) {
_initialFieldElementsMap[fieldElement] =
@@ -5968,7 +5993,7 @@
*/
static List<FieldElement> computeNotInitializedFields(
ConstructorDeclaration constructor) {
- Set<FieldElement> fields = new Set<FieldElement>();
+ Set<FieldElement> fields = Set<FieldElement>();
var classDeclaration = constructor.parent as ClassDeclaration;
for (ClassMember fieldDeclaration in classDeclaration.members) {
if (fieldDeclaration is FieldDeclaration) {
@@ -6044,7 +6069,7 @@
* A set containing the elements that will be declared in this scope, but are
* not yet declared.
*/
- Set<Element> _elements = new HashSet<Element>();
+ Set<Element> _elements = HashSet<Element>();
/**
* Initialize a newly created set of hidden elements to include all of the
diff --git a/pkg/analyzer/lib/src/generated/incremental_resolver.dart b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
index b1ac17b..52f9122 100644
--- a/pkg/analyzer/lib/src/generated/incremental_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
@@ -46,7 +46,7 @@
}
AstNode parent = node.parent;
if (parent == null) {
- throw new AnalysisException(
+ throw AnalysisException(
"Cannot create scope: node is not part of a CompilationUnit");
}
return _scopeForAstNode(parent);
@@ -69,7 +69,7 @@
}
AstNode parent = node.parent;
if (parent == null) {
- throw new AnalysisException(
+ throw AnalysisException(
"Cannot create scope: node is not part of a CompilationUnit");
}
Scope scope = _scopeForAstNode(parent);
@@ -77,45 +77,44 @@
_enclosingClassDeclaration = node;
_enclosingClass = node.declaredElement;
if (_enclosingClass == null) {
- throw new AnalysisException(
- "Cannot build a scope for an unresolved class");
+ throw AnalysisException("Cannot build a scope for an unresolved class");
}
- scope = new ClassScope(
- new TypeParameterScope(scope, _enclosingClass), _enclosingClass);
+ scope = ClassScope(
+ TypeParameterScope(scope, _enclosingClass), _enclosingClass);
} else if (node is ClassTypeAlias) {
ClassElement element = node.declaredElement;
if (element == null) {
- throw new AnalysisException(
+ throw AnalysisException(
"Cannot build a scope for an unresolved class type alias");
}
- scope = new ClassScope(new TypeParameterScope(scope, element), element);
+ scope = ClassScope(TypeParameterScope(scope, element), element);
} else if (node is ConstructorDeclaration) {
ConstructorElement element = node.declaredElement;
if (element == null) {
- throw new AnalysisException(
+ throw AnalysisException(
"Cannot build a scope for an unresolved constructor");
}
- FunctionScope functionScope = new FunctionScope(scope, element);
+ FunctionScope functionScope = FunctionScope(scope, element);
functionScope.defineParameters();
scope = functionScope;
} else if (node is FunctionDeclaration) {
ExecutableElement element = node.declaredElement;
if (element == null) {
- throw new AnalysisException(
+ throw AnalysisException(
"Cannot build a scope for an unresolved function");
}
- FunctionScope functionScope = new FunctionScope(scope, element);
+ FunctionScope functionScope = FunctionScope(scope, element);
functionScope.defineParameters();
scope = functionScope;
} else if (node is FunctionTypeAlias) {
- scope = new FunctionTypeScope(scope, node.declaredElement);
+ scope = FunctionTypeScope(scope, node.declaredElement);
} else if (node is MethodDeclaration) {
ExecutableElement element = node.declaredElement;
if (element == null) {
- throw new AnalysisException(
+ throw AnalysisException(
"Cannot build a scope for an unresolved method");
}
- FunctionScope functionScope = new FunctionScope(scope, element);
+ FunctionScope functionScope = FunctionScope(scope, element);
functionScope.defineParameters();
scope = functionScope;
}
@@ -125,15 +124,15 @@
Scope _scopeForCompilationUnit(CompilationUnit node) {
_enclosingUnit = node.declaredElement;
if (_enclosingUnit == null) {
- throw new AnalysisException(
+ throw AnalysisException(
"Cannot create scope: compilation unit is not resolved");
}
LibraryElement libraryElement = _enclosingUnit.library;
if (libraryElement == null) {
- throw new AnalysisException(
+ throw AnalysisException(
"Cannot create scope: compilation unit is not part of a library");
}
- return new LibraryScope(libraryElement);
+ return LibraryScope(libraryElement);
}
/**
@@ -146,13 +145,13 @@
*/
static ResolutionContext contextFor(AstNode node) {
if (node == null) {
- throw new AnalysisException("Cannot create context: node is null");
+ throw AnalysisException("Cannot create context: node is null");
}
// build scope
- ResolutionContextBuilder builder = new ResolutionContextBuilder();
+ ResolutionContextBuilder builder = ResolutionContextBuilder();
Scope scope = builder._scopeFor(node);
// prepare context
- ResolutionContext context = new ResolutionContext();
+ ResolutionContext context = ResolutionContext();
context.scope = scope;
context.enclosingUnit = builder._enclosingUnit;
context.enclosingClassDeclaration = builder._enclosingClassDeclaration;
diff --git a/pkg/analyzer/lib/src/generated/interner.dart b/pkg/analyzer/lib/src/generated/interner.dart
index 1f0ea1d..2b19286 100644
--- a/pkg/analyzer/lib/src/generated/interner.dart
+++ b/pkg/analyzer/lib/src/generated/interner.dart
@@ -17,7 +17,7 @@
/**
* A table mapping strings to themselves.
*/
- Map<String, String> _table = new HashMap<String, String>();
+ Map<String, String> _table = HashMap<String, String>();
@override
String intern(String string) {
diff --git a/pkg/analyzer/lib/src/generated/java_core.dart b/pkg/analyzer/lib/src/generated/java_core.dart
index 8fc7fc2..94f2d83 100644
--- a/pkg/analyzer/lib/src/generated/java_core.dart
+++ b/pkg/analyzer/lib/src/generated/java_core.dart
@@ -25,11 +25,11 @@
*/
String formatList(String pattern, List<Object> arguments) {
if (arguments == null || arguments.isEmpty) {
- assert(!pattern.contains(new RegExp(r'\{(\d+)\}')),
+ assert(!pattern.contains(RegExp(r'\{(\d+)\}')),
'Message requires arguments, but none were provided.');
return pattern;
}
- return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) {
+ return pattern.replaceAllMapped(RegExp(r'\{(\d+)\}'), (match) {
String indexStr = match.group(1);
int index = int.parse(indexStr);
Object arg = arguments[index];
@@ -42,7 +42,7 @@
* Very limited printf implementation, supports only %s and %d.
*/
String _printf(String fmt, List args) {
- StringBuffer sb = new StringBuffer();
+ StringBuffer sb = StringBuffer();
bool markFound = false;
int argIndex = 0;
for (int i = 0; i < fmt.length; i++) {
@@ -69,7 +69,7 @@
continue;
}
// unknown
- throw new ArgumentError('[$fmt][$i] = 0x${c.toRadixString(16)}');
+ throw ArgumentError('[$fmt][$i] = 0x${c.toRadixString(16)}');
} else {
sb.writeCharCode(c);
}
@@ -86,7 +86,7 @@
static int digit(int codePoint, int radix) {
if (radix != 16) {
- throw new ArgumentError("only radix == 16 is supported");
+ throw ArgumentError("only radix == 16 is supported");
}
if (0x30 <= codePoint && codePoint <= 0x39) {
return codePoint - 0x30;
@@ -112,15 +112,15 @@
static String toChars(int codePoint) {
if (codePoint < 0 || codePoint > MAX_CODE_POINT) {
- throw new ArgumentError();
+ throw ArgumentError();
}
if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) {
- return new String.fromCharCode(codePoint);
+ return String.fromCharCode(codePoint);
}
int offset = codePoint - MIN_SUPPLEMENTARY_CODE_POINT;
int c0 = ((offset & 0x7FFFFFFF) >> 10) + MIN_HIGH_SURROGATE;
int c1 = (offset & 0x3ff) + MIN_LOW_SURROGATE;
- return new String.fromCharCodes([c0, c1]);
+ return String.fromCharCodes([c0, c1]);
}
}
@@ -139,7 +139,7 @@
@deprecated
class PrintStringWriter extends PrintWriter {
- final StringBuffer _sb = new StringBuffer();
+ final StringBuffer _sb = StringBuffer();
void print(x) {
_sb.write(x);
diff --git a/pkg/analyzer/lib/src/generated/java_engine.dart b/pkg/analyzer/lib/src/generated/java_engine.dart
index b02b79e..139a2c9 100644
--- a/pkg/analyzer/lib/src/generated/java_engine.dart
+++ b/pkg/analyzer/lib/src/generated/java_engine.dart
@@ -29,7 +29,7 @@
static const String EMPTY = '';
static const List<String> EMPTY_ARRAY = const <String>[];
- static Interner INTERNER = new NullInterner();
+ static Interner INTERNER = NullInterner();
/**
* Compute line starts for the given [content].
@@ -179,13 +179,13 @@
*/
static String printListOfQuotedNames(List<String> names) {
if (names == null) {
- throw new ArgumentError("The list must not be null");
+ throw ArgumentError("The list must not be null");
}
int count = names.length;
if (count < 2) {
- throw new ArgumentError("The list must contain at least two names");
+ throw ArgumentError("The list must contain at least two names");
}
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write("'");
buffer.write(names[0]);
buffer.write("'");
@@ -277,5 +277,5 @@
final String id;
UUID(this.id);
String toString() => id;
- static UUID randomUUID() => new UUID((__nextId).toString());
+ static UUID randomUUID() => UUID((__nextId).toString());
}
diff --git a/pkg/analyzer/lib/src/generated/java_engine_io.dart b/pkg/analyzer/lib/src/generated/java_engine_io.dart
index 365a0fd..5ee3c34 100644
--- a/pkg/analyzer/lib/src/generated/java_engine_io.dart
+++ b/pkg/analyzer/lib/src/generated/java_engine_io.dart
@@ -8,7 +8,7 @@
class FileUtilities2 {
static JavaFile createFile(String path) {
- return new JavaFile(path).getAbsoluteFile();
+ return JavaFile(path).getAbsoluteFile();
}
}
diff --git a/pkg/analyzer/lib/src/generated/java_io.dart b/pkg/analyzer/lib/src/generated/java_io.dart
index 1549dd3..0b5371f 100644
--- a/pkg/analyzer/lib/src/generated/java_io.dart
+++ b/pkg/analyzer/lib/src/generated/java_io.dart
@@ -40,14 +40,14 @@
return false;
}
- JavaFile getAbsoluteFile() => new JavaFile(getAbsolutePath());
+ JavaFile getAbsoluteFile() => JavaFile(getAbsolutePath());
String getAbsolutePath() {
String abolutePath = path.context.absolute(_path);
abolutePath = path.context.normalize(abolutePath);
return abolutePath;
}
- JavaFile getCanonicalFile() => new JavaFile(getCanonicalPath());
+ JavaFile getCanonicalFile() => JavaFile(getCanonicalPath());
String getCanonicalPath() {
return _newFile().resolveSymbolicLinksSync();
}
@@ -63,7 +63,7 @@
JavaFile getParentFile() {
var parent = getParent();
if (parent == null) return null;
- return new JavaFile(parent);
+ return JavaFile(parent);
}
String getPath() => _path;
@@ -91,7 +91,7 @@
var files = <JavaFile>[];
var entities = _newDirectory().listSync();
for (FileSystemEntity entity in entities) {
- files.add(new JavaFile(entity.path));
+ files.add(JavaFile(entity.path));
}
return files;
}
@@ -104,13 +104,13 @@
return path.context.toUri(absolutePath);
}
- Directory _newDirectory() => new Directory(_path);
- File _newFile() => new File(_path);
+ Directory _newDirectory() => Directory(_path);
+ File _newFile() => File(_path);
}
@Deprecated("Only used by `DirectoryBasedDartSdk`, which is also deprecated.")
class JavaSystemIO {
- static Map<String, String> _properties = new Map();
+ static Map<String, String> _properties = Map();
static String getenv(String name) => Platform.environment[name];
static String getProperty(String name) {
{
@@ -136,7 +136,7 @@
{
var outDir = path.context.dirname(path.context.dirname(exec));
sdkPath = path.context.join(path.context.dirname(outDir), "sdk");
- if (new Directory(sdkPath).existsSync()) {
+ if (Directory(sdkPath).existsSync()) {
_properties[name] = sdkPath;
return sdkPath;
}
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart
index 621d1ee..2e11661 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -101,7 +101,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
bool needsSpace = _appendKeyword(buffer, false, abstractKeyword);
needsSpace = _appendKeyword(buffer, needsSpace, constKeyword);
needsSpace = _appendKeyword(buffer, needsSpace, externalKeyword);
@@ -204,11 +204,10 @@
{bool useFasta, @required FeatureSet featureSet}) {
featureSet ??= FeatureSet.fromEnableFlags([]);
if (useFasta ?? Parser.useFasta) {
- return new _Parser2(source, errorListener, featureSet,
+ return _Parser2(source, errorListener, featureSet,
allowNativeClause: true);
} else {
- return new Parser.withoutFasta(source, errorListener,
- featureSet: featureSet);
+ return Parser.withoutFasta(source, errorListener, featureSet: featureSet);
}
}
@@ -227,7 +226,7 @@
Token get currentToken => _currentToken;
/// Set the token with which the parse is to begin to the given [token].
- void set currentToken(Token token) {
+ set currentToken(Token token) {
this._currentToken = token;
}
@@ -239,7 +238,7 @@
/// Set whether the parser is to parse asserts in the initializer list of a
/// constructor to match the given [enable] flag.
@deprecated
- void set enableAssertInitializer(bool enable) {}
+ set enableAssertInitializer(bool enable) {}
/// Return `true` if the parser should parse instance creation expressions
/// that lack either the `new` or `const` keyword.
@@ -247,12 +246,12 @@
/// Set whether the parser should parse instance creation expressions that
/// lack either the `new` or `const` keyword.
- void set enableOptionalNewAndConst(bool enable) {
+ set enableOptionalNewAndConst(bool enable) {
_enableOptionalNewAndConst = enable;
}
/// Enables or disables parsing of set literals.
- void set enableSetLiterals(bool value) {
+ set enableSetLiterals(bool value) {
// TODO(danrubel): Remove this method once the reference to this flag
// has been removed from dartfmt.
}
@@ -264,7 +263,7 @@
/// Set whether the parser is to allow URI's in part-of directives to the
/// given [enable] flag.
@deprecated
- void set enableUriInPartOf(bool enable) {}
+ set enableUriInPartOf(bool enable) {}
/// Return `true` if the current token is the first token of a return type
/// that is followed by an identifier, possibly followed by a list of type
@@ -284,16 +283,16 @@
///
/// Support for removing the 'async' library has been removed.
@deprecated
- void set parseAsync(bool parseAsync) {}
+ set parseAsync(bool parseAsync) {}
@deprecated
bool get parseConditionalDirectives => true;
@deprecated
- void set parseConditionalDirectives(bool value) {}
+ set parseConditionalDirectives(bool value) {}
/// Set whether parser is to parse function bodies.
- void set parseFunctionBodies(bool parseFunctionBodies) {
+ set parseFunctionBodies(bool parseFunctionBodies) {
this._parseFunctionBodies = parseFunctionBodies;
}
@@ -302,7 +301,7 @@
/// is `true` if this is the first token in a string literal. The flag
/// [isLast] is `true` if this is the last token in a string literal.
String computeStringValue(String lexeme, bool isFirst, bool isLast) {
- StringLexemeHelper helper = new StringLexemeHelper(lexeme, isFirst, isLast);
+ StringLexemeHelper helper = StringLexemeHelper(lexeme, isFirst, isLast);
int start = helper.start;
int end = helper.end;
bool stringEndsAfterStart = end >= start;
@@ -315,7 +314,7 @@
if (helper.isRaw) {
return lexeme.substring(start, end);
}
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
int index = start;
while (index < end) {
index = _translateCharacter(buffer, lexeme, index);
@@ -324,7 +323,7 @@
}
/// Return a synthetic identifier.
- SimpleIdentifier createSyntheticIdentifier({bool isDeclaration: false}) {
+ SimpleIdentifier createSyntheticIdentifier({bool isDeclaration = false}) {
Token syntheticToken;
if (_currentToken.type.isKeyword) {
// Consider current keyword token as an identifier.
@@ -332,7 +331,7 @@
// synthetic identifier. By creating SyntheticStringToken we can
// distinguish a real identifier from synthetic. In the code completion
// behavior will depend on a cursor position - before or on "is".
- syntheticToken = _injectToken(new SyntheticStringToken(
+ syntheticToken = _injectToken(SyntheticStringToken(
TokenType.IDENTIFIER, _currentToken.lexeme, _currentToken.offset));
} else {
syntheticToken = _createSyntheticToken(TokenType.IDENTIFIER);
@@ -778,7 +777,7 @@
/// unconditionalAssignableSelector
/// | '?.' identifier
Expression parseAssignableSelector(Expression prefix, bool optional,
- {bool allowConditional: true}) {
+ {bool allowConditional = true}) {
TokenType type = _currentToken.type;
if (type == TokenType.OPEN_SQUARE_BRACKET) {
Token leftBracket = getAndAdvance();
@@ -1518,7 +1517,7 @@
_validateModifiersForGetterOrSetterOrMethod(modifiers);
_reportErrorForCurrentToken(ParserErrorCode.MISSING_GET);
_currentToken = _injectToken(
- new SyntheticKeywordToken(Keyword.GET, _currentToken.offset));
+ SyntheticKeywordToken(Keyword.GET, _currentToken.offset));
return parseGetter(commentAndMetadata, modifiers.externalKeyword,
modifiers.staticKeyword, type);
}
@@ -1586,7 +1585,7 @@
tokens = optionalTokens;
}
}
- return new CommentAndMetadata(parseDocumentationComment(tokens), metadata);
+ return CommentAndMetadata(parseDocumentationComment(tokens), metadata);
}
/// Parse a comment reference from the source between square brackets. The
@@ -1602,9 +1601,9 @@
// TODO(brianwilkerson) The errors are not getting the right offset/length
// and are being duplicated.
try {
- BooleanErrorListener listener = new BooleanErrorListener();
- Scanner scanner = new Scanner(
- null, new SubSequenceReader(referenceSource, sourceOffset), listener)
+ BooleanErrorListener listener = BooleanErrorListener();
+ Scanner scanner = Scanner(
+ null, SubSequenceReader(referenceSource, sourceOffset), listener)
..configureFeatures(_featureSet);
scanner.setSourceStart(1, 1);
Token firstToken = scanner.tokenize();
@@ -1613,7 +1612,7 @@
}
if (firstToken.type == TokenType.EOF) {
Token syntheticToken =
- new SyntheticStringToken(TokenType.IDENTIFIER, "", sourceOffset);
+ SyntheticStringToken(TokenType.IDENTIFIER, "", sourceOffset);
syntheticToken.setNext(firstToken);
return astFactory.commentReference(
null, astFactory.simpleIdentifier(syntheticToken));
@@ -1756,13 +1755,12 @@
int nameEnd = StringUtilities.indexOfFirstNotLetterDigit(
comment, leftIndex + 1);
String name = comment.substring(leftIndex + 1, nameEnd);
- nameToken =
- new StringToken(TokenType.IDENTIFIER, name, nameOffset);
+ nameToken = StringToken(TokenType.IDENTIFIER, name, nameOffset);
} else {
- nameToken = new SyntheticStringToken(
- TokenType.IDENTIFIER, '', nameOffset);
+ nameToken =
+ SyntheticStringToken(TokenType.IDENTIFIER, '', nameOffset);
}
- nameToken.setNext(new Token.eof(nameToken.end));
+ nameToken.setNext(Token.eof(nameToken.end));
references.add(astFactory.commentReference(
null, astFactory.simpleIdentifier(nameToken)));
// next character
@@ -1865,7 +1863,7 @@
} else {
// Internal error: this method should not have been invoked if the
// current token was something other than one of the above.
- throw new StateError(
+ throw StateError(
"parseDirective invoked in an invalid state (currentToken = $_currentToken)");
}
}
@@ -1890,7 +1888,7 @@
member = parseCompilationUnitMember(commentAndMetadata);
} on _TooDeepTreeError {
_reportErrorForToken(ParserErrorCode.STACK_OVERFLOW, _currentToken);
- Token eof = new Token.eof(0);
+ Token eof = Token.eof(0);
return astFactory.compilationUnit(
beginToken: eof, endToken: eof, featureSet: _featureSet);
}
@@ -2352,7 +2350,7 @@
} else {
// Internal error: this method should not have been invoked if the current
// token was something other than one of the above.
- throw new StateError(
+ throw StateError(
"parseDirective invoked in an invalid state; currentToken = $_currentToken");
}
}
@@ -2616,7 +2614,7 @@
/// | throwExpression
Expression parseExpression2() {
if (_treeDepth > _MAX_TREE_DEPTH) {
- throw new _TooDeepTreeError();
+ throw _TooDeepTreeError();
}
_treeDepth++;
try {
@@ -2720,7 +2718,7 @@
/// | 'var'
/// | type
FinalConstVarOrType parseFinalConstVarOrType(bool optional,
- {bool inFunctionType: false}) {
+ {bool inFunctionType = false}) {
Token keywordToken;
TypeAnnotation type;
Keyword keyword = _currentToken.keyword;
@@ -2758,7 +2756,7 @@
// This is not supported if the type is required.
type;
}
- return new FinalConstVarOrType(keywordToken, type);
+ return FinalConstVarOrType(keywordToken, type);
}
/// Parse a formal parameter. At most one of `isOptional` and `isNamed` can be
@@ -2773,7 +2771,7 @@
/// normalFormalParameter ('=' expression)?
/// normalFormalParameter (':' expression)?
FormalParameter parseFormalParameter(ParameterKind kind,
- {bool inFunctionType: false}) {
+ {bool inFunctionType = false}) {
NormalFormalParameter parameter =
parseNormalFormalParameter(inFunctionType: inFunctionType);
TokenType type = _currentToken.type;
@@ -2854,7 +2852,7 @@
///
/// namedFormalParameters ::=
/// '{' defaultNamedParameter (',' defaultNamedParameter)* '}'
- FormalParameterList parseFormalParameterList({bool inFunctionType: false}) {
+ FormalParameterList parseFormalParameterList({bool inFunctionType = false}) {
if (_matches(TokenType.OPEN_PAREN)) {
return _parseFormalParameterListUnchecked(inFunctionType: inFunctionType);
}
@@ -3542,7 +3540,7 @@
///
/// label ::=
/// identifier ':'
- Label parseLabel({bool isDeclaration: false}) {
+ Label parseLabel({bool isDeclaration = false}) {
SimpleIdentifier label =
_parseSimpleIdentifierUnchecked(isDeclaration: isDeclaration);
Token colon = getAndAdvance();
@@ -3740,7 +3738,7 @@
/// modifiers ::=
/// ('abstract' | 'const' | 'external' | 'factory' | 'final' | 'static' | 'var')*
Modifiers parseModifiers() {
- Modifiers modifiers = new Modifiers();
+ Modifiers modifiers = Modifiers();
bool progress = true;
while (progress) {
TokenType nextType = _peek().type;
@@ -4086,7 +4084,7 @@
/// declaredIdentifier
/// | metadata identifier
NormalFormalParameter parseNormalFormalParameter(
- {bool inFunctionType: false}) {
+ {bool inFunctionType = false}) {
Token covariantKeyword;
CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
if (_matchesKeyword(Keyword.COVARIANT)) {
@@ -4588,7 +4586,7 @@
/// identifier ::=
/// IDENTIFIER
SimpleIdentifier parseSimpleIdentifier(
- {bool allowKeyword: false, bool isDeclaration: false}) {
+ {bool allowKeyword = false, bool isDeclaration = false}) {
if (_matchesIdentifier() ||
(allowKeyword && _tokenMatchesIdentifierOrKeyword(_currentToken))) {
return _parseSimpleIdentifierUnchecked(isDeclaration: isDeclaration);
@@ -4611,7 +4609,7 @@
/// label* nonLabeledStatement
Statement parseStatement2() {
if (_treeDepth > _MAX_TREE_DEPTH) {
- throw new _TooDeepTreeError();
+ throw _TooDeepTreeError();
}
_treeDepth++;
try {
@@ -4690,7 +4688,7 @@
bool wasInSwitch = _inSwitch;
_inSwitch = true;
try {
- HashSet<String> definedLabels = new HashSet<String>();
+ HashSet<String> definedLabels = HashSet<String>();
Token keyword = _expectKeyword(Keyword.SWITCH);
Token leftParenthesis = _expect(TokenType.OPEN_PAREN);
Expression expression = parseExpression2();
@@ -5108,8 +5106,7 @@
//
if (type == TokenType.MINUS_MINUS) {
Token firstOperator = _createToken(operator, TokenType.MINUS);
- Token secondOperator =
- new Token(TokenType.MINUS, operator.offset + 1);
+ Token secondOperator = Token(TokenType.MINUS, operator.offset + 1);
secondOperator.setNext(_currentToken);
firstOperator.setNext(secondOperator);
operator.previous.setNext(firstOperator);
@@ -5441,7 +5438,7 @@
if (token.type == TokenType.GT) {
return token.next;
} else if (token.type == TokenType.GT_GT) {
- Token second = new Token(TokenType.GT, token.offset + 1);
+ Token second = Token(TokenType.GT, token.offset + 1);
second.setNextWithoutSettingPrevious(token.next);
return second;
}
@@ -5552,19 +5549,19 @@
void _configureFeatures(FeatureSet featureSet) {
if (featureSet.isEnabled(Feature.control_flow_collections)) {
- throw new UnimplementedError('control_flow_collections experiment'
+ throw UnimplementedError('control_flow_collections experiment'
' not supported by analyzer parser');
}
if (featureSet.isEnabled(Feature.non_nullable)) {
- throw new UnimplementedError(
+ throw UnimplementedError(
'non-nullable experiment not supported by analyzer parser');
}
if (featureSet.isEnabled(Feature.spread_collections)) {
- throw new UnimplementedError(
+ throw UnimplementedError(
'spread_collections experiment not supported by analyzer parser');
}
if (featureSet.isEnabled(Feature.triple_shift)) {
- throw new UnimplementedError('triple_shift experiment'
+ throw UnimplementedError('triple_shift experiment'
' not supported by analyzer parser');
}
_featureSet = featureSet;
@@ -5636,26 +5633,26 @@
/// Return a synthetic token representing the given [keyword].
Token _createSyntheticKeyword(Keyword keyword) =>
- _injectToken(new SyntheticKeywordToken(keyword, _currentToken.offset));
+ _injectToken(SyntheticKeywordToken(keyword, _currentToken.offset));
/// Return a synthetic token with the given [type].
Token _createSyntheticToken(TokenType type) =>
- _injectToken(new StringToken(type, "", _currentToken.offset));
+ _injectToken(StringToken(type, "", _currentToken.offset));
/// Create and return a new token with the given [type]. The token will
/// replace the first portion of the given [token], so it will have the same
/// offset and will have any comments that might have preceded the token.
- Token _createToken(Token token, TokenType type, {bool isBegin: false}) {
+ Token _createToken(Token token, TokenType type, {bool isBegin = false}) {
CommentToken comments = token.precedingComments;
if (comments == null) {
if (isBegin) {
- return new BeginToken(type, token.offset);
+ return BeginToken(type, token.offset);
}
- return new Token(type, token.offset);
+ return Token(type, token.offset);
} else if (isBegin) {
- return new BeginToken(type, token.offset, comments);
+ return BeginToken(type, token.offset, comments);
}
- return new Token(type, token.offset, comments);
+ return Token(type, token.offset, comments);
}
/// Check that the given [expression] is assignable and report an error if it
@@ -5976,7 +5973,7 @@
return true;
} else if (currentType == TokenType.GT_GT) {
Token first = _createToken(_currentToken, TokenType.GT);
- Token second = new Token(TokenType.GT, _currentToken.offset + 1);
+ Token second = Token(TokenType.GT, _currentToken.offset + 1);
second.setNext(_currentToken.next);
first.setNext(second);
_currentToken.previous.setNext(first);
@@ -5984,7 +5981,7 @@
return true;
} else if (currentType == TokenType.GT_EQ) {
Token first = _createToken(_currentToken, TokenType.GT);
- Token second = new Token(TokenType.EQ, _currentToken.offset + 1);
+ Token second = Token(TokenType.EQ, _currentToken.offset + 1);
second.setNext(_currentToken.next);
first.setNext(second);
_currentToken.previous.setNext(first);
@@ -5993,8 +5990,8 @@
} else if (currentType == TokenType.GT_GT_EQ) {
int offset = _currentToken.offset;
Token first = _createToken(_currentToken, TokenType.GT);
- Token second = new Token(TokenType.GT, offset + 1);
- Token third = new Token(TokenType.EQ, offset + 2);
+ Token second = Token(TokenType.GT, offset + 1);
+ Token third = Token(TokenType.EQ, offset + 2);
third.setNext(_currentToken.next);
second.setNext(third);
first.setNext(second);
@@ -6322,7 +6319,7 @@
/// Parse a list of formal parameters given that the list starts with the
/// given [leftParenthesis]. Return the formal parameters that were parsed.
FormalParameterList _parseFormalParameterListAfterParen(Token leftParenthesis,
- {bool inFunctionType: false}) {
+ {bool inFunctionType = false}) {
if (_matches(TokenType.CLOSE_PAREN)) {
return astFactory.formalParameterList(
leftParenthesis, null, null, null, getAndAdvance());
@@ -6496,7 +6493,7 @@
///
/// This method assumes that the current token matches `TokenType.OPEN_PAREN`.
FormalParameterList _parseFormalParameterListUnchecked(
- {bool inFunctionType: false}) {
+ {bool inFunctionType = false}) {
return _parseFormalParameterListAfterParen(getAndAdvance(),
inFunctionType: inFunctionType);
}
@@ -6928,7 +6925,7 @@
/// identifier ::=
/// IDENTIFIER
SimpleIdentifier _parseSimpleIdentifierUnchecked(
- {bool isDeclaration: false}) {
+ {bool isDeclaration = false}) {
String lexeme = _currentToken.lexeme;
if ((_inAsync || _inGenerator) && (lexeme == _AWAIT || lexeme == _YIELD)) {
_reportErrorForCurrentToken(
@@ -7099,7 +7096,7 @@
Token endToken = token.previous;
token = _currentToken;
int endOffset = token.end;
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write(token.lexeme);
while (token != endToken) {
token = token.next;
@@ -7111,7 +7108,7 @@
}
String value = buffer.toString();
Token newToken =
- new StringToken(TokenType.STRING, "'$value'", _currentToken.offset);
+ StringToken(TokenType.STRING, "'$value'", _currentToken.offset);
_reportErrorForToken(
ParserErrorCode.NON_STRING_LITERAL_AS_URI, newToken);
_currentToken = endToken.next;
@@ -7194,8 +7191,8 @@
/// the given [node].
void _reportErrorForNode(ParserErrorCode errorCode, AstNode node,
[List<Object> arguments]) {
- _reportError(new AnalysisError(
- _source, node.offset, node.length, errorCode, arguments));
+ _reportError(
+ AnalysisError(_source, node.offset, node.length, errorCode, arguments));
}
/// Report an error with the given [errorCode] and [arguments] associated with
@@ -7205,8 +7202,8 @@
if (token.type == TokenType.EOF) {
token = token.previous;
}
- _reportError(new AnalysisError(_source, token.offset,
- math.max(token.length, 1), errorCode, arguments));
+ _reportError(AnalysisError(_source, token.offset, math.max(token.length, 1),
+ errorCode, arguments));
}
/// Skips a block with all containing blocks.
@@ -7452,7 +7449,7 @@
depth--;
} else if (_tokenMatches(next, TokenType.GT_EQ)) {
if (depth == 1) {
- Token fakeEquals = new Token(TokenType.EQ, next.offset + 2);
+ Token fakeEquals = Token(TokenType.EQ, next.offset + 2);
fakeEquals.setNextWithoutSettingPrevious(next.next);
return fakeEquals;
}
@@ -7463,7 +7460,7 @@
if (depth < 2) {
return null;
} else if (depth == 2) {
- Token fakeEquals = new Token(TokenType.EQ, next.offset + 2);
+ Token fakeEquals = Token(TokenType.EQ, next.offset + 2);
fakeEquals.setNextWithoutSettingPrevious(next.next);
return fakeEquals;
}
@@ -7482,7 +7479,7 @@
_currentToken, TokenType.OPEN_SQUARE_BRACKET,
isBegin: true);
Token rightBracket =
- new Token(TokenType.CLOSE_SQUARE_BRACKET, _currentToken.offset + 1);
+ Token(TokenType.CLOSE_SQUARE_BRACKET, _currentToken.offset + 1);
leftBracket.endToken = rightBracket;
rightBracket.setNext(_currentToken.next);
leftBracket.setNext(rightBracket);
@@ -7656,7 +7653,7 @@
/// [reportError] wont report any error.
void _unlockErrorListener() {
if (_errorListenerLock == 0) {
- throw new StateError("Attempt to unlock not locked error listener.");
+ throw StateError("Attempt to unlock not locked error listener.");
}
_errorListenerLock--;
}
diff --git a/pkg/analyzer/lib/src/generated/parser_fasta.dart b/pkg/analyzer/lib/src/generated/parser_fasta.dart
index 40d68b3..e5986a0 100644
--- a/pkg/analyzer/lib/src/generated/parser_fasta.dart
+++ b/pkg/analyzer/lib/src/generated/parser_fasta.dart
@@ -25,9 +25,9 @@
ParserAdapter(this.currentToken, ErrorReporter errorReporter, Uri fileUri,
FeatureSet featureSet,
- {bool allowNativeClause: false})
- : fastaParser = new fasta.Parser(null),
- astBuilder = new AstBuilder(errorReporter, fileUri, true, featureSet) {
+ {bool allowNativeClause = false})
+ : fastaParser = fasta.Parser(null),
+ astBuilder = AstBuilder(errorReporter, fileUri, true, featureSet) {
fastaParser.listener = astBuilder;
astBuilder.parser = fastaParser;
astBuilder.allowNativeClause = allowNativeClause;
@@ -42,16 +42,16 @@
bool get enableOptionalNewAndConst => false;
@override
- void set enableOptionalNewAndConst(bool enable) {}
+ set enableOptionalNewAndConst(bool enable) {}
@override
- void set enableSetLiterals(bool value) {
+ set enableSetLiterals(bool value) {
// TODO(danrubel): Remove this method once the reference to this flag
// has been removed from dartfmt.
}
@override
- void set parseFunctionBodies(bool parseFunctionBodies) {
+ set parseFunctionBodies(bool parseFunctionBodies) {
astBuilder.parseFunctionBodies = parseFunctionBodies;
}
@@ -83,9 +83,8 @@
@override
Expression parseArgument() {
- currentToken = new SimpleToken(TokenType.OPEN_PAREN, 0)
- ..setNext(currentToken);
- appendToken(currentToken, new SimpleToken(TokenType.CLOSE_PAREN, 0));
+ currentToken = SimpleToken(TokenType.OPEN_PAREN, 0)..setNext(currentToken);
+ appendToken(currentToken, SimpleToken(TokenType.CLOSE_PAREN, 0));
currentToken = fastaParser
.parseArguments(fastaParser.syntheticPreviousToken(currentToken))
.next;
@@ -121,9 +120,9 @@
null,
null,
null,
- new Token(Keyword.CLASS, 0),
+ Token(Keyword.CLASS, 0),
astFactory.simpleIdentifier(
- new fasta.StringToken.fromString(TokenType.IDENTIFIER, className, 6)),
+ fasta.StringToken.fromString(TokenType.IDENTIFIER, className, 6)),
null,
null,
null,
@@ -215,7 +214,7 @@
Expression parseExpressionWithoutCascade() => parseExpression2();
@override
- FormalParameterList parseFormalParameterList({bool inFunctionType: false}) {
+ FormalParameterList parseFormalParameterList({bool inFunctionType = false}) {
currentToken = fastaParser
.parseFormalParametersRequiredOpt(
fastaParser.syntheticPreviousToken(currentToken),
@@ -277,7 +276,7 @@
@override
SimpleIdentifier parseSimpleIdentifier(
- {bool allowKeyword: false, bool isDeclaration: false}) =>
+ {bool allowKeyword = false, bool isDeclaration = false}) =>
parseExpression2();
@override
@@ -344,8 +343,8 @@
@override
TypeParameter parseTypeParameter() {
- currentToken = new SyntheticBeginToken(TokenType.LT, 0)
- ..endGroup = new SyntheticToken(TokenType.GT, 0)
+ currentToken = SyntheticBeginToken(TokenType.LT, 0)
+ ..endGroup = SyntheticToken(TokenType.GT, 0)
..setNext(currentToken);
appendToken(currentToken, currentToken.endGroup);
TypeParameterList typeParams = parseTypeParameterList();
@@ -380,14 +379,14 @@
factory _Parser2(
Source source, AnalysisErrorListener errorListener, FeatureSet featureSet,
- {bool allowNativeClause: false}) {
- var errorReporter = new ErrorReporter(errorListener, source);
- return new _Parser2._(source, errorReporter, source.uri, featureSet,
+ {bool allowNativeClause = false}) {
+ var errorReporter = ErrorReporter(errorListener, source);
+ return _Parser2._(source, errorReporter, source.uri, featureSet,
allowNativeClause: allowNativeClause);
}
_Parser2._(this._source, ErrorReporter errorReporter, Uri fileUri,
- FeatureSet featureSet, {bool allowNativeClause: false})
+ FeatureSet featureSet, {bool allowNativeClause = false})
: super(null, errorReporter, fileUri, featureSet,
allowNativeClause: allowNativeClause);
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 08aaa19..43709ea 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -15,18 +15,15 @@
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/exception/exception.dart';
-import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/src/context/builder.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
import 'package:analyzer/src/dart/element/member.dart'
- show ConstructorMember, ExecutableMember, Member;
+ show ConstructorMember, Member;
import 'package:analyzer/src/dart/element/nullability_eliminator.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/dart/element/type_provider.dart';
-import 'package:analyzer/src/dart/resolver/exit_detector.dart';
import 'package:analyzer/src/dart/resolver/extension_member_resolver.dart';
import 'package:analyzer/src/dart/resolver/flow_analysis_visitor.dart';
import 'package:analyzer/src/dart/resolver/method_invocation_resolver.dart';
@@ -41,2137 +38,13 @@
import 'package:analyzer/src/generated/type_promotion_manager.dart';
import 'package:analyzer/src/generated/type_system.dart';
import 'package:analyzer/src/generated/variable_type_provider.dart';
-import 'package:analyzer/src/lint/linter.dart';
-import 'package:analyzer/src/workspace/workspace.dart';
import 'package:meta/meta.dart';
-import 'package:path/path.dart' as path;
export 'package:analyzer/src/dart/constant/constant_verifier.dart';
export 'package:analyzer/src/dart/resolver/exit_detector.dart';
export 'package:analyzer/src/dart/resolver/scope.dart';
export 'package:analyzer/src/generated/type_system.dart';
-/// Instances of the class `BestPracticesVerifier` traverse an AST structure
-/// looking for violations of Dart best practices.
-class BestPracticesVerifier extends RecursiveAstVisitor<void> {
-// static String _HASHCODE_GETTER_NAME = "hashCode";
-
- static String _NULL_TYPE_NAME = "Null";
-
- static String _TO_INT_METHOD_NAME = "toInt";
-
- /// The class containing the AST nodes being visited, or `null` if we are not
- /// in the scope of a class.
- ClassElementImpl _enclosingClass;
-
- /// A flag indicating whether a surrounding member (compilation unit or class)
- /// is deprecated.
- bool _inDeprecatedMember;
-
- /// The error reporter by which errors will be reported.
- final ErrorReporter _errorReporter;
-
- /// The type [Null].
- final InterfaceType _nullType;
-
- /// The type system primitives
- final TypeSystemImpl _typeSystem;
-
- /// The inheritance manager to access interface type hierarchy.
- final InheritanceManager3 _inheritanceManager;
-
- /// The current library
- final LibraryElement _currentLibrary;
-
- final _InvalidAccessVerifier _invalidAccessVerifier;
-
- /// The [WorkspacePackage] in which [_currentLibrary] is declared.
- WorkspacePackage _workspacePackage;
-
- /// The [LinterContext] used for possible const calculations.
- LinterContext _linterContext;
-
- /// Is `true` if NNBD is enabled for the library being analyzed.
- final bool _isNonNullable;
-
- /// True if inference failures should be reported, otherwise false.
- final bool _strictInference;
-
- /// Create a new instance of the [BestPracticesVerifier].
- ///
- /// @param errorReporter the error reporter
- BestPracticesVerifier(
- this._errorReporter,
- TypeProvider typeProvider,
- this._currentLibrary,
- CompilationUnit unit,
- String content, {
- TypeSystemImpl typeSystem,
- @required InheritanceManager3 inheritanceManager,
- ResourceProvider resourceProvider,
- DeclaredVariables declaredVariables,
- AnalysisOptions analysisOptions,
- }) : _nullType = typeProvider.nullType,
- _typeSystem = typeSystem ??
- TypeSystemImpl(
- implicitCasts: true,
- isNonNullableByDefault: false,
- strictInference: false,
- typeProvider: typeProvider,
- ),
- _isNonNullable = unit.featureSet.isEnabled(Feature.non_nullable),
- _strictInference =
- (analysisOptions as AnalysisOptionsImpl).strictInference,
- _inheritanceManager = inheritanceManager,
- _invalidAccessVerifier =
- new _InvalidAccessVerifier(_errorReporter, _currentLibrary) {
- _inDeprecatedMember = _currentLibrary.hasDeprecated;
- String libraryPath = _currentLibrary.source.fullName;
- _workspacePackage = _getPackage(libraryPath, resourceProvider);
-
- _linterContext = LinterContextImpl(
- null /* allUnits */,
- new LinterContextUnit(content, unit),
- declaredVariables,
- typeProvider,
- _typeSystem,
- _inheritanceManager,
- analysisOptions,
- _workspacePackage,
- );
- }
-
- @override
- void visitAnnotation(Annotation node) {
- ElementAnnotation element = node.elementAnnotation;
- AstNode parent = node.parent;
- if (element?.isFactory == true) {
- if (parent is MethodDeclaration) {
- _checkForInvalidFactory(parent);
- } else {
- _errorReporter
- .reportErrorForNode(HintCode.INVALID_FACTORY_ANNOTATION, node, []);
- }
- } else if (element?.isImmutable == true) {
- if (parent is! ClassOrMixinDeclaration && parent is! ClassTypeAlias) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_IMMUTABLE_ANNOTATION, node, []);
- }
- } else if (element?.isLiteral == true) {
- if (parent is! ConstructorDeclaration ||
- (parent as ConstructorDeclaration).constKeyword == null) {
- _errorReporter
- .reportErrorForNode(HintCode.INVALID_LITERAL_ANNOTATION, node, []);
- }
- } else if (element?.isNonVirtual == true) {
- if (parent is FieldDeclaration) {
- if (parent.isStatic) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_NON_VIRTUAL_ANNOTATION,
- node,
- [node.element.name]);
- }
- } else if (parent is MethodDeclaration) {
- if (parent.parent is ExtensionDeclaration ||
- parent.isStatic ||
- parent.isAbstract) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_NON_VIRTUAL_ANNOTATION,
- node,
- [node.element.name]);
- }
- } else {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_NON_VIRTUAL_ANNOTATION, node, [node.element.name]);
- }
- } else if (element?.isSealed == true) {
- if (!(parent is ClassDeclaration || parent is ClassTypeAlias)) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_SEALED_ANNOTATION, node, [node.element.name]);
- }
- } else if (element?.isVisibleForTemplate == true ||
- element?.isVisibleForTesting == true) {
- if (parent is Declaration) {
- reportInvalidAnnotation(Element declaredElement) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_VISIBILITY_ANNOTATION,
- node,
- [declaredElement.name, node.name.name]);
- }
-
- if (parent is TopLevelVariableDeclaration) {
- for (VariableDeclaration variable in parent.variables.variables) {
- if (Identifier.isPrivateName(variable.declaredElement.name)) {
- reportInvalidAnnotation(variable.declaredElement);
- }
- }
- } else if (parent is FieldDeclaration) {
- for (VariableDeclaration variable in parent.fields.variables) {
- if (Identifier.isPrivateName(variable.declaredElement.name)) {
- reportInvalidAnnotation(variable.declaredElement);
- }
- }
- } else if (parent.declaredElement != null &&
- Identifier.isPrivateName(parent.declaredElement.name)) {
- reportInvalidAnnotation(parent.declaredElement);
- }
- } else {
- // Something other than a declaration was annotated. Whatever this is,
- // it probably warrants a Hint, but this has not been specified on
- // visibleForTemplate or visibleForTesting, so leave it alone for now.
- }
- }
-
- super.visitAnnotation(node);
- }
-
- @override
- void visitArgumentList(ArgumentList node) {
- for (Expression argument in node.arguments) {
- ParameterElement parameter = argument.staticParameterElement;
- if (parameter?.isOptionalPositional == true) {
- _checkForDeprecatedMemberUse(parameter, argument);
- }
- }
- super.visitArgumentList(node);
- }
-
- @override
- void visitAsExpression(AsExpression node) {
- _checkForUnnecessaryCast(node);
- super.visitAsExpression(node);
- }
-
- @override
- void visitAssignmentExpression(AssignmentExpression node) {
- TokenType operatorType = node.operator.type;
- if (operatorType != TokenType.EQ) {
- _checkForDeprecatedMemberUse(node.staticElement, node);
- }
- super.visitAssignmentExpression(node);
- }
-
- @override
- void visitBinaryExpression(BinaryExpression node) {
- _checkForDivisionOptimizationHint(node);
- _checkForDeprecatedMemberUse(node.staticElement, node);
- super.visitBinaryExpression(node);
- }
-
- @override
- void visitClassDeclaration(ClassDeclaration node) {
- ClassElementImpl element = node.declaredElement;
- _enclosingClass = element;
- _invalidAccessVerifier._enclosingClass = element;
-
- bool wasInDeprecatedMember = _inDeprecatedMember;
- if (element != null && element.hasDeprecated) {
- _inDeprecatedMember = true;
- }
-
- try {
- // Commented out until we decide that we want this hint in the analyzer
- // checkForOverrideEqualsButNotHashCode(node);
- _checkForImmutable(node);
- _checkForInvalidSealedSuperclass(node);
- super.visitClassDeclaration(node);
- } finally {
- _enclosingClass = null;
- _invalidAccessVerifier._enclosingClass = null;
- _inDeprecatedMember = wasInDeprecatedMember;
- }
- }
-
- @override
- void visitClassTypeAlias(ClassTypeAlias node) {
- _checkForImmutable(node);
- _checkForInvalidSealedSuperclass(node);
- super.visitClassTypeAlias(node);
- }
-
- @override
- void visitConstructorDeclaration(ConstructorDeclaration node) {
- if (node.declaredElement.isFactory) {
- if (node.body is BlockFunctionBody) {
- // Check the block for a return statement, if not, create the hint.
- if (!ExitDetector.exits(node.body)) {
- _errorReporter.reportErrorForNode(
- HintCode.MISSING_RETURN, node, [node.returnType.name]);
- }
- }
- }
- _checkStrictInferenceInParameters(node.parameters);
- super.visitConstructorDeclaration(node);
- }
-
- @override
- void visitExportDirective(ExportDirective node) {
- _checkForDeprecatedMemberUse(node.uriElement, node);
- super.visitExportDirective(node);
- }
-
- @override
- void visitFieldDeclaration(FieldDeclaration node) {
- bool wasInDeprecatedMember = _inDeprecatedMember;
- if (_hasDeprecatedAnnotation(node.metadata)) {
- _inDeprecatedMember = true;
- }
-
- try {
- super.visitFieldDeclaration(node);
- for (var field in node.fields.variables) {
- ExecutableElement getOverriddenPropertyAccessor() {
- final element = field.declaredElement;
- if (element is PropertyAccessorElement || element is FieldElement) {
- Name name = new Name(_currentLibrary.source.uri, element.name);
- Element enclosingElement = element.enclosingElement;
- if (enclosingElement is ClassElement) {
- InterfaceType classType = enclosingElement.thisType;
- var overridden = _inheritanceManager.getMember(classType, name,
- forSuper: true);
- // Check for a setter.
- if (overridden == null) {
- Name setterName =
- new Name(_currentLibrary.source.uri, '${element.name}=');
- overridden = _inheritanceManager
- .getMember(classType, setterName, forSuper: true);
- }
- return overridden;
- }
- }
- return null;
- }
-
- final overriddenElement = getOverriddenPropertyAccessor();
- if (_hasNonVirtualAnnotation(overriddenElement)) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER,
- field.name,
- [field.name, overriddenElement.enclosingElement.name]);
- }
- }
- } finally {
- _inDeprecatedMember = wasInDeprecatedMember;
- }
- }
-
- @override
- void visitFormalParameterList(FormalParameterList node) {
- _checkRequiredParameter(node);
- super.visitFormalParameterList(node);
- }
-
- @override
- void visitFunctionDeclaration(FunctionDeclaration node) {
- bool wasInDeprecatedMember = _inDeprecatedMember;
- ExecutableElement element = node.declaredElement;
- if (element != null && element.hasDeprecated) {
- _inDeprecatedMember = true;
- }
- try {
- _checkForMissingReturn(
- node.returnType, node.functionExpression.body, element, node);
-
- // Return types are inferred only on non-recursive local functions.
- if (node.parent is CompilationUnit && !node.isSetter) {
- _checkStrictInferenceReturnType(node.returnType, node, node.name.name);
- }
- _checkStrictInferenceInParameters(node.functionExpression.parameters);
- super.visitFunctionDeclaration(node);
- } finally {
- _inDeprecatedMember = wasInDeprecatedMember;
- }
- }
-
- @override
- void visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
- // TODO(srawlins): Check strict-inference return type on recursive
- // local functions.
- super.visitFunctionDeclarationStatement(node);
- }
-
- @override
- void visitFunctionExpression(FunctionExpression node) {
- if (node.parent is! FunctionDeclaration) {
- _checkForMissingReturn(null, node.body, node.declaredElement, node);
- }
- DartType functionType = InferenceContext.getContext(node);
- if (functionType is! FunctionType) {
- _checkStrictInferenceInParameters(node.parameters);
- }
- super.visitFunctionExpression(node);
- }
-
- @override
- void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
- var callElement = node.staticElement;
- if (callElement is MethodElement &&
- callElement.name == FunctionElement.CALL_METHOD_NAME) {
- _checkForDeprecatedMemberUse(callElement, node);
- }
-
- super.visitFunctionExpressionInvocation(node);
- }
-
- @override
- void visitFunctionTypeAlias(FunctionTypeAlias node) {
- _checkStrictInferenceReturnType(node.returnType, node, node.name.name);
- super.visitFunctionTypeAlias(node);
- }
-
- @override
- void visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
- _checkStrictInferenceReturnType(
- node.returnType, node, node.identifier.name);
- _checkStrictInferenceInParameters(node.parameters);
- super.visitFunctionTypedFormalParameter(node);
- }
-
- @override
- void visitGenericFunctionType(GenericFunctionType node) {
- // GenericTypeAlias is handled in [visitGenericTypeAlias], where a proper
- // name can be reported in any message.
- if (node.parent is! GenericTypeAlias) {
- _checkStrictInferenceReturnType(node.returnType, node, node.toString());
- }
- super.visitGenericFunctionType(node);
- }
-
- @override
- void visitGenericTypeAlias(GenericTypeAlias node) {
- if (node.functionType != null) {
- _checkStrictInferenceReturnType(
- node.functionType.returnType, node, node.name.name);
- }
- super.visitGenericTypeAlias(node);
- }
-
- @override
- void visitImportDirective(ImportDirective node) {
- _checkForDeprecatedMemberUse(node.uriElement, node);
- ImportElement importElement = node.element;
- if (importElement != null && importElement.isDeferred) {
- _checkForLoadLibraryFunction(node, importElement);
- }
- super.visitImportDirective(node);
- }
-
- @override
- void visitIndexExpression(IndexExpression node) {
- _checkForDeprecatedMemberUse(node.staticElement, node);
- super.visitIndexExpression(node);
- }
-
- @override
- void visitInstanceCreationExpression(InstanceCreationExpression node) {
- _checkForDeprecatedMemberUse(node.staticElement, node);
- _checkForLiteralConstructorUse(node);
- super.visitInstanceCreationExpression(node);
- }
-
- @override
- void visitIsExpression(IsExpression node) {
- _checkAllTypeChecks(node);
- super.visitIsExpression(node);
- }
-
- @override
- void visitMethodDeclaration(MethodDeclaration node) {
- bool wasInDeprecatedMember = _inDeprecatedMember;
- ExecutableElement element = node.declaredElement;
- Element enclosingElement = element?.enclosingElement;
-
- InterfaceType classType =
- enclosingElement is ClassElement ? enclosingElement.thisType : null;
- Name name = Name(_currentLibrary.source.uri, element?.name ?? '');
-
- bool elementIsOverride() =>
- element is ClassMemberElement && enclosingElement != null
- ? _inheritanceManager.getOverridden(classType, name) != null
- : false;
- ExecutableElement getConcreteOverriddenElement() =>
- element is ClassMemberElement && enclosingElement != null
- ? _inheritanceManager.getMember(classType, name, forSuper: true)
- : null;
- ExecutableElement getOverriddenPropertyAccessor() =>
- element is PropertyAccessorElement && enclosingElement != null
- ? _inheritanceManager.getMember(classType, name, forSuper: true)
- : null;
-
- if (element != null && element.hasDeprecated) {
- _inDeprecatedMember = true;
- }
- try {
- // This was determined to not be a good hint, see: dartbug.com/16029
- //checkForOverridingPrivateMember(node);
- _checkForMissingReturn(node.returnType, node.body, element, node);
- _checkForUnnecessaryNoSuchMethod(node);
-
- if (!node.isSetter && !elementIsOverride()) {
- _checkStrictInferenceReturnType(node.returnType, node, node.name.name);
- }
- _checkStrictInferenceInParameters(node.parameters);
-
- ExecutableElement overriddenElement = getConcreteOverriddenElement();
- if (overriddenElement == null && (node.isSetter || node.isGetter)) {
- overriddenElement = getOverriddenPropertyAccessor();
- }
-
- if (_hasNonVirtualAnnotation(overriddenElement)) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER,
- node.name,
- [node.name, overriddenElement.enclosingElement.name]);
- }
-
- super.visitMethodDeclaration(node);
- } finally {
- _inDeprecatedMember = wasInDeprecatedMember;
- }
- }
-
- @override
- void visitMethodInvocation(MethodInvocation node) {
- _checkForNullAwareHints(node, node.operator);
- super.visitMethodInvocation(node);
- }
-
- @override
- void visitMixinDeclaration(MixinDeclaration node) {
- _enclosingClass = node.declaredElement;
- _invalidAccessVerifier._enclosingClass = _enclosingClass;
-
- bool wasInDeprecatedMember = _inDeprecatedMember;
- if (_hasDeprecatedAnnotation(node.metadata)) {
- _inDeprecatedMember = true;
- }
-
- try {
- _checkForImmutable(node);
- _checkForInvalidSealedSuperclass(node);
- super.visitMixinDeclaration(node);
- } finally {
- _enclosingClass = null;
- _invalidAccessVerifier._enclosingClass = null;
- _inDeprecatedMember = wasInDeprecatedMember;
- }
- }
-
- @override
- void visitPostfixExpression(PostfixExpression node) {
- _checkForDeprecatedMemberUse(node.staticElement, node);
- super.visitPostfixExpression(node);
- }
-
- @override
- void visitPrefixExpression(PrefixExpression node) {
- _checkForDeprecatedMemberUse(node.staticElement, node);
- super.visitPrefixExpression(node);
- }
-
- @override
- void visitPropertyAccess(PropertyAccess node) {
- _checkForNullAwareHints(node, node.operator);
- super.visitPropertyAccess(node);
- }
-
- @override
- void visitRedirectingConstructorInvocation(
- RedirectingConstructorInvocation node) {
- _checkForDeprecatedMemberUse(node.staticElement, node);
- super.visitRedirectingConstructorInvocation(node);
- }
-
- @override
- void visitSimpleIdentifier(SimpleIdentifier node) {
- _checkForDeprecatedMemberUseAtIdentifier(node);
- _invalidAccessVerifier.verify(node);
- super.visitSimpleIdentifier(node);
- }
-
- @override
- void visitSuperConstructorInvocation(SuperConstructorInvocation node) {
- _checkForDeprecatedMemberUse(node.staticElement, node);
- super.visitSuperConstructorInvocation(node);
- }
-
- @override
- void visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
- bool wasInDeprecatedMember = _inDeprecatedMember;
- if (_hasDeprecatedAnnotation(node.metadata)) {
- _inDeprecatedMember = true;
- }
-
- try {
- super.visitTopLevelVariableDeclaration(node);
- } finally {
- _inDeprecatedMember = wasInDeprecatedMember;
- }
- }
-
- /// Check for the passed is expression for the unnecessary type check hint
- /// codes as well as null checks expressed using an is expression.
- ///
- /// @param node the is expression to check
- /// @return `true` if and only if a hint code is generated on the passed node
- /// See [HintCode.TYPE_CHECK_IS_NOT_NULL], [HintCode.TYPE_CHECK_IS_NULL],
- /// [HintCode.UNNECESSARY_TYPE_CHECK_TRUE], and
- /// [HintCode.UNNECESSARY_TYPE_CHECK_FALSE].
- bool _checkAllTypeChecks(IsExpression node) {
- Expression expression = node.expression;
- TypeAnnotation typeName = node.type;
- TypeImpl lhsType = expression.staticType;
- TypeImpl rhsType = typeName.type;
- if (lhsType == null || rhsType == null) {
- return false;
- }
- String rhsNameStr = typeName is TypeName ? typeName.name.name : null;
- // if x is dynamic
- if (rhsType.isDynamic && rhsNameStr == Keyword.DYNAMIC.lexeme) {
- if (node.notOperator == null) {
- // the is case
- _errorReporter.reportErrorForNode(
- HintCode.UNNECESSARY_TYPE_CHECK_TRUE, node);
- } else {
- // the is not case
- _errorReporter.reportErrorForNode(
- HintCode.UNNECESSARY_TYPE_CHECK_FALSE, node);
- }
- return true;
- }
- Element rhsElement = rhsType.element;
- LibraryElement libraryElement = rhsElement?.library;
- if (libraryElement != null && libraryElement.isDartCore) {
- // `is Null` or `is! Null`
- if (rhsNameStr == _NULL_TYPE_NAME) {
- if (expression is NullLiteral) {
- if (node.notOperator == null) {
- _errorReporter.reportErrorForNode(
- HintCode.UNNECESSARY_TYPE_CHECK_TRUE,
- node,
- );
- } else {
- _errorReporter.reportErrorForNode(
- HintCode.UNNECESSARY_TYPE_CHECK_FALSE,
- node,
- );
- }
- } else {
- if (node.notOperator == null) {
- _errorReporter.reportErrorForNode(
- HintCode.TYPE_CHECK_IS_NULL,
- node,
- );
- } else {
- _errorReporter.reportErrorForNode(
- HintCode.TYPE_CHECK_IS_NOT_NULL,
- node,
- );
- }
- }
- return true;
- }
- // `is Object` or `is! Object`
- if (rhsType.isObject) {
- var nullability = rhsType.nullabilitySuffix;
- if (nullability == NullabilitySuffix.star ||
- nullability == NullabilitySuffix.question) {
- if (node.notOperator == null) {
- _errorReporter.reportErrorForNode(
- HintCode.UNNECESSARY_TYPE_CHECK_TRUE,
- node,
- );
- } else {
- _errorReporter.reportErrorForNode(
- HintCode.UNNECESSARY_TYPE_CHECK_FALSE,
- node,
- );
- }
- return true;
- }
- }
- }
- return false;
- }
-
- /// Given some [element], look at the associated metadata and report the use
- /// of the member if it is declared as deprecated. If a diagnostic is reported
- /// it should be reported at the given [node].
- void _checkForDeprecatedMemberUse(Element element, AstNode node) {
- bool isDeprecated(Element element) {
- if (element is PropertyAccessorElement && element.isSynthetic) {
- // TODO(brianwilkerson) Why isn't this the implementation for PropertyAccessorElement?
- Element variable = element.variable;
- if (variable == null) {
- return false;
- }
- return variable.hasDeprecated;
- }
- return element.hasDeprecated;
- }
-
- bool isLocalParameter(Element element, AstNode node) {
- if (element is ParameterElement) {
- ExecutableElement definingFunction = element.enclosingElement;
- FunctionBody body = node.thisOrAncestorOfType<FunctionBody>();
- while (body != null) {
- ExecutableElement enclosingFunction;
- AstNode parent = body.parent;
- if (parent is ConstructorDeclaration) {
- enclosingFunction = parent.declaredElement;
- } else if (parent is FunctionExpression) {
- enclosingFunction = parent.declaredElement;
- } else if (parent is MethodDeclaration) {
- enclosingFunction = parent.declaredElement;
- }
- if (enclosingFunction == definingFunction) {
- return true;
- }
- body = parent?.thisOrAncestorOfType<FunctionBody>();
- }
- }
- return false;
- }
-
- if (!_inDeprecatedMember &&
- element != null &&
- isDeprecated(element) &&
- !isLocalParameter(element, node)) {
- String displayName = element.displayName;
- if (element is ConstructorElement) {
- // TODO(jwren) We should modify ConstructorElement.getDisplayName(),
- // or have the logic centralized elsewhere, instead of doing this logic
- // here.
- displayName = element.enclosingElement.displayName;
- if (element.displayName.isNotEmpty) {
- displayName = "$displayName.${element.displayName}";
- }
- } else if (element is LibraryElement) {
- displayName = element.definingCompilationUnit.source.uri.toString();
- } else if (displayName == FunctionElement.CALL_METHOD_NAME &&
- node is MethodInvocation &&
- node.staticInvokeType is InterfaceType) {
- DartType staticInvokeType = node.staticInvokeType;
- displayName = "${staticInvokeType.displayName}.${element.displayName}";
- }
- LibraryElement library =
- element is LibraryElement ? element : element.library;
- String message = _deprecatedMessage(element);
- if (message == null || message.isEmpty) {
- HintCode hintCode = _isLibraryInWorkspacePackage(library)
- ? HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
- : HintCode.DEPRECATED_MEMBER_USE;
- _errorReporter.reportErrorForNode(hintCode, node, [displayName]);
- } else {
- HintCode hintCode = _isLibraryInWorkspacePackage(library)
- ? HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE
- : HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE;
- _errorReporter
- .reportErrorForNode(hintCode, node, [displayName, message]);
- }
- }
- }
-
- /// For [SimpleIdentifier]s, only call [checkForDeprecatedMemberUse]
- /// if the node is not in a declaration context.
- ///
- /// Also, if the identifier is a constructor name in a constructor invocation,
- /// then calls to the deprecated constructor will be caught by
- /// [visitInstanceCreationExpression] and
- /// [visitSuperConstructorInvocation], and can be ignored by
- /// this visit method.
- ///
- /// @param identifier some simple identifier to check for deprecated use of
- /// @return `true` if and only if a hint code is generated on the passed node
- /// See [HintCode.DEPRECATED_MEMBER_USE].
- void _checkForDeprecatedMemberUseAtIdentifier(SimpleIdentifier identifier) {
- if (identifier.inDeclarationContext()) {
- return;
- }
- AstNode parent = identifier.parent;
- if ((parent is ConstructorName && identical(identifier, parent.name)) ||
- (parent is ConstructorDeclaration &&
- identical(identifier, parent.returnType)) ||
- (parent is SuperConstructorInvocation &&
- identical(identifier, parent.constructorName)) ||
- parent is HideCombinator) {
- return;
- }
- _checkForDeprecatedMemberUse(identifier.staticElement, identifier);
- }
-
- /// Check for the passed binary expression for the
- /// [HintCode.DIVISION_OPTIMIZATION].
- ///
- /// @param node the binary expression to check
- /// @return `true` if and only if a hint code is generated on the passed node
- /// See [HintCode.DIVISION_OPTIMIZATION].
- bool _checkForDivisionOptimizationHint(BinaryExpression node) {
- // Return if the operator is not '/'
- if (node.operator.type != TokenType.SLASH) {
- return false;
- }
- // Return if the '/' operator is not defined in core, or if we don't know
- // its static type
- MethodElement methodElement = node.staticElement;
- if (methodElement == null) {
- return false;
- }
- LibraryElement libraryElement = methodElement.library;
- if (libraryElement != null && !libraryElement.isDartCore) {
- return false;
- }
- // Report error if the (x/y) has toInt() invoked on it
- AstNode parent = node.parent;
- if (parent is ParenthesizedExpression) {
- ParenthesizedExpression parenthesizedExpression =
- _wrapParenthesizedExpression(parent);
- AstNode grandParent = parenthesizedExpression.parent;
- if (grandParent is MethodInvocation) {
- if (_TO_INT_METHOD_NAME == grandParent.methodName.name &&
- grandParent.argumentList.arguments.isEmpty) {
- _errorReporter.reportErrorForNode(
- HintCode.DIVISION_OPTIMIZATION, grandParent);
- return true;
- }
- }
- }
- return false;
- }
-
- /// Checks whether [node] violates the rules of [immutable].
- ///
- /// If [node] is marked with [immutable] or inherits from a class or mixin
- /// marked with [immutable], this function searches the fields of [node] and
- /// its superclasses, reporting a hint if any non-final instance fields are
- /// found.
- void _checkForImmutable(NamedCompilationUnitMember node) {
- /// Return `true` if the given class [element] is annotated with the
- /// `@immutable` annotation.
- bool isImmutable(ClassElement element) {
- for (ElementAnnotation annotation in element.metadata) {
- if (annotation.isImmutable) {
- return true;
- }
- }
- return false;
- }
-
- /// Return `true` if the given class [element] or any superclass of it is
- /// annotated with the `@immutable` annotation.
- bool isOrInheritsImmutable(
- ClassElement element, HashSet<ClassElement> visited) {
- if (visited.add(element)) {
- if (isImmutable(element)) {
- return true;
- }
- for (InterfaceType interface in element.mixins) {
- if (isOrInheritsImmutable(interface.element, visited)) {
- return true;
- }
- }
- for (InterfaceType mixin in element.interfaces) {
- if (isOrInheritsImmutable(mixin.element, visited)) {
- return true;
- }
- }
- if (element.supertype != null) {
- return isOrInheritsImmutable(element.supertype.element, visited);
- }
- }
- return false;
- }
-
- /// Return `true` if the given class [element] defines a non-final instance
- /// field.
- Iterable<String> nonFinalInstanceFields(ClassElement element) {
- return element.fields
- .where((FieldElement field) =>
- !field.isSynthetic && !field.isFinal && !field.isStatic)
- .map((FieldElement field) => '${element.name}.${field.name}');
- }
-
- /// Return `true` if the given class [element] defines or inherits a
- /// non-final field.
- Iterable<String> definedOrInheritedNonFinalInstanceFields(
- ClassElement element, HashSet<ClassElement> visited) {
- Iterable<String> nonFinalFields = [];
- if (visited.add(element)) {
- nonFinalFields = nonFinalInstanceFields(element);
- nonFinalFields = nonFinalFields.followedBy(element.mixins.expand(
- (InterfaceType mixin) => nonFinalInstanceFields(mixin.element)));
- if (element.supertype != null) {
- nonFinalFields = nonFinalFields.followedBy(
- definedOrInheritedNonFinalInstanceFields(
- element.supertype.element, visited));
- }
- }
- return nonFinalFields;
- }
-
- ClassElement element = node.declaredElement;
- if (isOrInheritsImmutable(element, new HashSet<ClassElement>())) {
- Iterable<String> nonFinalFields =
- definedOrInheritedNonFinalInstanceFields(
- element, new HashSet<ClassElement>());
- if (nonFinalFields.isNotEmpty) {
- _errorReporter.reportErrorForNode(
- HintCode.MUST_BE_IMMUTABLE, node.name, [nonFinalFields.join(', ')]);
- }
- }
- }
-
- void _checkForInvalidFactory(MethodDeclaration decl) {
- // Check declaration.
- // Note that null return types are expected to be flagged by other analyses.
- DartType returnType = decl.returnType?.type;
- if (returnType is VoidType) {
- _errorReporter.reportErrorForNode(HintCode.INVALID_FACTORY_METHOD_DECL,
- decl.name, [decl.name.toString()]);
- return;
- }
-
- // Check implementation.
-
- FunctionBody body = decl.body;
- if (body is EmptyFunctionBody) {
- // Abstract methods are OK.
- return;
- }
-
- // `new Foo()` or `null`.
- bool factoryExpression(Expression expression) =>
- expression is InstanceCreationExpression || expression is NullLiteral;
-
- if (body is ExpressionFunctionBody && factoryExpression(body.expression)) {
- return;
- } else if (body is BlockFunctionBody) {
- NodeList<Statement> statements = body.block.statements;
- if (statements.isNotEmpty) {
- Statement last = statements.last;
- if (last is ReturnStatement && factoryExpression(last.expression)) {
- return;
- }
- }
- }
-
- _errorReporter.reportErrorForNode(HintCode.INVALID_FACTORY_METHOD_IMPL,
- decl.name, [decl.name.toString()]);
- }
-
- void _checkForInvalidSealedSuperclass(NamedCompilationUnitMember node) {
- bool currentPackageContains(Element element) {
- return _isLibraryInWorkspacePackage(element.library);
- }
-
- // [NamedCompilationUnitMember.declaredElement] is not necessarily a
- // ClassElement, but [_checkForInvalidSealedSuperclass] should only be
- // called with a [ClassOrMixinDeclaration], or a [ClassTypeAlias]. The
- // `declaredElement` of these specific classes is a [ClassElement].
- ClassElement element = node.declaredElement;
- // TODO(srawlins): Perhaps replace this with a getter on Element, like
- // `Element.hasOrInheritsSealed`?
- for (InterfaceType supertype in element.allSupertypes) {
- ClassElement superclass = supertype.element;
- if (superclass.hasSealed) {
- if (!currentPackageContains(superclass)) {
- if (element.superclassConstraints.contains(supertype)) {
- // This is a special violation of the sealed class contract,
- // requiring specific messaging.
- _errorReporter.reportErrorForNode(HintCode.MIXIN_ON_SEALED_CLASS,
- node, [superclass.name.toString()]);
- } else {
- // This is a regular violation of the sealed class contract.
- _errorReporter.reportErrorForNode(HintCode.SUBTYPE_OF_SEALED_CLASS,
- node, [superclass.name.toString()]);
- }
- }
- }
- }
- }
-
- /// Check that the instance creation node is const if the constructor is
- /// marked with [literal].
- _checkForLiteralConstructorUse(InstanceCreationExpression node) {
- ConstructorName constructorName = node.constructorName;
- ConstructorElement constructor = constructorName.staticElement;
- if (constructor == null) {
- return;
- }
- if (!node.isConst &&
- constructor.hasLiteral &&
- _linterContext.canBeConst(node)) {
- // Echoing jwren's TODO from _checkForDeprecatedMemberUse:
- // TODO(jwren) We should modify ConstructorElement.getDisplayName(), or
- // have the logic centralized elsewhere, instead of doing this logic
- // here.
- String fullConstructorName = constructorName.type.name.name;
- if (constructorName.name != null) {
- fullConstructorName = '$fullConstructorName.${constructorName.name}';
- }
- HintCode hint = node.keyword?.keyword == Keyword.NEW
- ? HintCode.NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR_USING_NEW
- : HintCode.NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR;
- _errorReporter.reportErrorForNode(hint, node, [fullConstructorName]);
- }
- }
-
- /// Check that the imported library does not define a loadLibrary function.
- /// The import has already been determined to be deferred when this is called.
- ///
- /// @param node the import directive to evaluate
- /// @param importElement the [ImportElement] retrieved from the node
- /// @return `true` if and only if an error code is generated on the passed
- /// node
- /// See [CompileTimeErrorCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION].
- bool _checkForLoadLibraryFunction(
- ImportDirective node, ImportElement importElement) {
- LibraryElement importedLibrary = importElement.importedLibrary;
- if (importedLibrary == null) {
- return false;
- }
- if (importedLibrary.hasLoadLibraryFunction) {
- _errorReporter.reportErrorForNode(
- HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION,
- node,
- [importedLibrary.name]);
- return true;
- }
- return false;
- }
-
- /// Generate a hint for functions or methods that have a return type, but do
- /// not have a return statement on all branches. At the end of blocks with no
- /// return, Dart implicitly returns `null`. Avoiding these implicit returns
- /// is considered a best practice.
- ///
- /// Note: for async functions/methods, this hint only applies when the
- /// function has a return type that Future<Null> is not assignable to.
- ///
- /// See [HintCode.MISSING_RETURN].
- void _checkForMissingReturn(TypeAnnotation returnNode, FunctionBody body,
- ExecutableElement element, AstNode functionNode) {
- if (body is BlockFunctionBody) {
- // Prefer the type from the element model, in case we've inferred one.
- DartType returnType = element?.returnType ?? returnNode?.type;
-
- // Skip the check if we're missing a return type (e.g. erroneous code).
- // Generators are never required to have a return statement.
- if (returnType == null || body.isGenerator) {
- return;
- }
-
- var flattenedType =
- body.isAsynchronous ? _typeSystem.flatten(returnType) : returnType;
-
- // Function expressions without a return will have their return type set
- // to `Null` regardless of their context type. So we need to figure out
- // if a return type was expected from the original downwards context.
- //
- // This helps detect hint cases like `int Function() f = () {}`.
- // See https://github.com/dart-lang/sdk/issues/28233 for context.
- if (flattenedType.isDartCoreNull && functionNode is FunctionExpression) {
- var contextType = InferenceContext.getContext(functionNode);
- if (contextType is FunctionType) {
- returnType = contextType.returnType;
- flattenedType = body.isAsynchronous
- ? _typeSystem.flatten(returnType)
- : returnType;
- }
- }
-
- // dynamic, Null, void, and FutureOr<T> where T is (dynamic, Null, void)
- // are allowed to omit a return.
- if (flattenedType.isDartAsyncFutureOr) {
- flattenedType = (flattenedType as InterfaceType).typeArguments[0];
- }
- if (flattenedType.isBottom ||
- flattenedType.isDynamic ||
- flattenedType.isDartCoreNull ||
- flattenedType.isVoid) {
- return;
- }
- // Otherwise issue a warning if the block doesn't have a return.
- if (!ExitDetector.exits(body)) {
- AstNode errorNode = functionNode is MethodDeclaration
- ? functionNode.name
- : functionNode is FunctionDeclaration
- ? functionNode.name
- : functionNode;
- _errorReporter.reportErrorForNode(
- HintCode.MISSING_RETURN, errorNode, [returnType.displayName]);
- }
- }
- }
-
- /// Produce several null-aware related hints.
- void _checkForNullAwareHints(Expression node, Token operator) {
- if (_isNonNullable) {
- return;
- }
-
- if (operator == null || operator.type != TokenType.QUESTION_PERIOD) {
- return;
- }
-
- // childOfParent is used to know from which branch node comes.
- var childOfParent = node;
- var parent = node.parent;
- while (parent is ParenthesizedExpression) {
- childOfParent = parent;
- parent = parent.parent;
- }
-
- // CAN_BE_NULL_AFTER_NULL_AWARE
- if (parent is MethodInvocation &&
- !parent.isNullAware &&
- _nullType.lookUpMethod(parent.methodName.name, _currentLibrary) ==
- null) {
- _errorReporter.reportErrorForNode(
- HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, childOfParent);
- return;
- }
- if (parent is PropertyAccess &&
- !parent.isNullAware &&
- _nullType.lookUpGetter(parent.propertyName.name, _currentLibrary) ==
- null) {
- _errorReporter.reportErrorForNode(
- HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, childOfParent);
- return;
- }
- if (parent is CascadeExpression && parent.target == childOfParent) {
- _errorReporter.reportErrorForNode(
- HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, childOfParent);
- return;
- }
-
- // NULL_AWARE_IN_CONDITION
- if (parent is IfStatement && parent.condition == childOfParent ||
- parent is ForPartsWithDeclarations &&
- parent.condition == childOfParent ||
- parent is DoStatement && parent.condition == childOfParent ||
- parent is WhileStatement && parent.condition == childOfParent ||
- parent is ConditionalExpression && parent.condition == childOfParent ||
- parent is AssertStatement && parent.condition == childOfParent) {
- _errorReporter.reportErrorForNode(
- HintCode.NULL_AWARE_IN_CONDITION, childOfParent);
- return;
- }
-
- // NULL_AWARE_IN_LOGICAL_OPERATOR
- if (parent is PrefixExpression && parent.operator.type == TokenType.BANG ||
- parent is BinaryExpression &&
- [TokenType.BAR_BAR, TokenType.AMPERSAND_AMPERSAND]
- .contains(parent.operator.type)) {
- _errorReporter.reportErrorForNode(
- HintCode.NULL_AWARE_IN_LOGICAL_OPERATOR, childOfParent);
- return;
- }
-
- // NULL_AWARE_BEFORE_OPERATOR
- if (parent is BinaryExpression &&
- ![TokenType.EQ_EQ, TokenType.BANG_EQ, TokenType.QUESTION_QUESTION]
- .contains(parent.operator.type) &&
- parent.leftOperand == childOfParent) {
- _errorReporter.reportErrorForNode(
- HintCode.NULL_AWARE_BEFORE_OPERATOR, childOfParent);
- return;
- }
- }
-
- /// Check for the passed as expression for the [HintCode.UNNECESSARY_CAST]
- /// hint code.
- ///
- /// @param node the as expression to check
- /// @return `true` if and only if a hint code is generated on the passed node
- /// See [HintCode.UNNECESSARY_CAST].
- bool _checkForUnnecessaryCast(AsExpression node) {
- // TODO(jwren) After dartbug.com/13732, revisit this, we should be able to
- // remove the (x is! TypeParameterType) checks.
- AstNode parent = node.parent;
- if (parent is ConditionalExpression &&
- (node == parent.thenExpression || node == parent.elseExpression)) {
- Expression thenExpression = parent.thenExpression;
- DartType thenType;
- if (thenExpression is AsExpression) {
- thenType = thenExpression.expression.staticType;
- } else {
- thenType = thenExpression.staticType;
- }
- Expression elseExpression = parent.elseExpression;
- DartType elseType;
- if (elseExpression is AsExpression) {
- elseType = elseExpression.expression.staticType;
- } else {
- elseType = elseExpression.staticType;
- }
- if (thenType != null &&
- elseType != null &&
- !thenType.isDynamic &&
- !elseType.isDynamic &&
- !_typeSystem.isSubtypeOf(thenType, elseType) &&
- !_typeSystem.isSubtypeOf(elseType, thenType)) {
- return false;
- }
- }
- DartType lhsType = node.expression.staticType;
- DartType rhsType = node.type.type;
- if (lhsType != null &&
- rhsType != null &&
- !lhsType.isDynamic &&
- !rhsType.isDynamic &&
- _typeSystem.isSubtypeOf(lhsType, rhsType)) {
- _errorReporter.reportErrorForNode(HintCode.UNNECESSARY_CAST, node);
- return true;
- }
- return false;
- }
-
- /// Generate a hint for `noSuchMethod` methods that do nothing except of
- /// calling another `noSuchMethod` that is not defined by `Object`.
- ///
- /// @return `true` if and only if a hint code is generated on the passed node
- /// See [HintCode.UNNECESSARY_NO_SUCH_METHOD].
- bool _checkForUnnecessaryNoSuchMethod(MethodDeclaration node) {
- if (node.name.name != FunctionElement.NO_SUCH_METHOD_METHOD_NAME) {
- return false;
- }
- bool isNonObjectNoSuchMethodInvocation(Expression invocation) {
- if (invocation is MethodInvocation &&
- invocation.target is SuperExpression &&
- invocation.argumentList.arguments.length == 1) {
- SimpleIdentifier name = invocation.methodName;
- if (name.name == FunctionElement.NO_SUCH_METHOD_METHOD_NAME) {
- Element methodElement = name.staticElement;
- Element classElement = methodElement?.enclosingElement;
- return methodElement is MethodElement &&
- classElement is ClassElement &&
- !classElement.isDartCoreObject;
- }
- }
- return false;
- }
-
- FunctionBody body = node.body;
- if (body is ExpressionFunctionBody) {
- if (isNonObjectNoSuchMethodInvocation(body.expression)) {
- _errorReporter.reportErrorForNode(
- HintCode.UNNECESSARY_NO_SUCH_METHOD, node);
- return true;
- }
- } else if (body is BlockFunctionBody) {
- List<Statement> statements = body.block.statements;
- if (statements.length == 1) {
- Statement returnStatement = statements.first;
- if (returnStatement is ReturnStatement &&
- isNonObjectNoSuchMethodInvocation(returnStatement.expression)) {
- _errorReporter.reportErrorForNode(
- HintCode.UNNECESSARY_NO_SUCH_METHOD, node);
- return true;
- }
- }
- }
- return false;
- }
-
- void _checkRequiredParameter(FormalParameterList node) {
- final requiredParameters =
- node.parameters.where((p) => p.declaredElement?.hasRequired == true);
- final nonNamedParamsWithRequired =
- requiredParameters.where((p) => p.isPositional);
- final namedParamsWithRequiredAndDefault = requiredParameters
- .where((p) => p.isNamed)
- .where((p) => p.declaredElement.defaultValueCode != null);
- for (final param in nonNamedParamsWithRequired.where((p) => p.isOptional)) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_REQUIRED_OPTIONAL_POSITIONAL_PARAM,
- param,
- [param.identifier.name]);
- }
- for (final param in nonNamedParamsWithRequired.where((p) => p.isRequired)) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_REQUIRED_POSITIONAL_PARAM,
- param,
- [param.identifier.name]);
- }
- for (final param in namedParamsWithRequiredAndDefault) {
- _errorReporter.reportErrorForNode(HintCode.INVALID_REQUIRED_NAMED_PARAM,
- param, [param.identifier.name]);
- }
- }
-
- /// In "strict-inference" mode, check that each of the [parameters]' type is
- /// specified.
- _checkStrictInferenceInParameters(FormalParameterList parameters) {
- void checkParameterTypeIsKnown(SimpleFormalParameter parameter) {
- if (parameter.type == null) {
- ParameterElement element = parameter.declaredElement;
- _errorReporter.reportTypeErrorForNode(
- HintCode.INFERENCE_FAILURE_ON_UNTYPED_PARAMETER,
- parameter,
- [element.displayName],
- );
- }
- }
-
- if (_strictInference && parameters != null) {
- for (FormalParameter parameter in parameters.parameters) {
- if (parameter is SimpleFormalParameter) {
- checkParameterTypeIsKnown(parameter);
- } else if (parameter is DefaultFormalParameter) {
- if (parameter.parameter is SimpleFormalParameter) {
- checkParameterTypeIsKnown(parameter.parameter);
- }
- }
- }
- }
- }
-
- /// In "strict-inference" mode, check that [returnNode]'s return type is
- /// specified.
- void _checkStrictInferenceReturnType(
- AstNode returnType, AstNode reportNode, String displayName) {
- if (!_strictInference) {
- return;
- }
- if (returnType == null) {
- _errorReporter.reportErrorForNode(
- HintCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE,
- reportNode,
- [displayName]);
- }
- }
-
- WorkspacePackage _getPackage(String root, ResourceProvider resourceProvider) {
- Workspace workspace = _currentLibrary.session?.analysisContext?.workspace;
- // If there is no driver setup (as in test environments), we need to create
- // a workspace ourselves.
- // todo (pq): fix tests or otherwise de-dup this logic shared w/ library_analyzer.
- if (workspace == null) {
- final builder = ContextBuilder(
- resourceProvider, null /* sdkManager */, null /* contentCache */);
- workspace =
- ContextBuilder.createWorkspace(resourceProvider, root, builder);
- }
- return workspace?.findPackageFor(root);
- }
-
- bool _isLibraryInWorkspacePackage(LibraryElement library) {
- if (_workspacePackage == null || library == null) {
- // Better to not make a big claim that they _are_ in the same package,
- // if we were unable to determine what package [_currentLibrary] is in.
- return false;
- }
- return _workspacePackage.contains(library.source);
- }
-
- /// Return the message in the deprecated annotation on the given [element], or
- /// `null` if the element doesn't have a deprecated annotation or if the
- /// annotation does not have a message.
- static String _deprecatedMessage(Element element) {
- // Implicit getters/setters.
- if (element.isSynthetic && element is PropertyAccessorElement) {
- element = (element as PropertyAccessorElement).variable;
- }
- ElementAnnotationImpl annotation = element.metadata.firstWhere(
- (e) => e.isDeprecated,
- orElse: () => null,
- );
- if (annotation == null || annotation.element is PropertyAccessorElement) {
- return null;
- }
- DartObject constantValue = annotation.computeConstantValue();
- return constantValue?.getField('message')?.toStringValue() ??
- constantValue?.getField('expires')?.toStringValue();
- }
-
- /// Check for the passed class declaration for the
- /// [HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE] hint code.
- ///
- /// @param node the class declaration to check
- /// @return `true` if and only if a hint code is generated on the passed node
- /// See [HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE].
-// bool _checkForOverrideEqualsButNotHashCode(ClassDeclaration node) {
-// ClassElement classElement = node.element;
-// if (classElement == null) {
-// return false;
-// }
-// MethodElement equalsOperatorMethodElement =
-// classElement.getMethod(sc.TokenType.EQ_EQ.lexeme);
-// if (equalsOperatorMethodElement != null) {
-// PropertyAccessorElement hashCodeElement =
-// classElement.getGetter(_HASHCODE_GETTER_NAME);
-// if (hashCodeElement == null) {
-// _errorReporter.reportErrorForNode(
-// HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE,
-// node.name,
-// [classElement.displayName]);
-// return true;
-// }
-// }
-// return false;
-// }
-//
-// /// Return `true` if the given [type] represents `Future<void>`.
-// bool _isFutureVoid(DartType type) {
-// if (type.isDartAsyncFuture) {
-// List<DartType> typeArgs = (type as InterfaceType).typeArguments;
-// if (typeArgs.length == 1 && typeArgs[0].isVoid) {
-// return true;
-// }
-// }
-// return false;
-// }
-
- static bool _hasDeprecatedAnnotation(List<Annotation> annotations) {
- for (var i = 0; i < annotations.length; i++) {
- if (annotations[i].elementAnnotation.isDeprecated) {
- return true;
- }
- }
- return false;
- }
-
- static bool _hasNonVirtualAnnotation(ExecutableElement element) {
- if (element == null) {
- return false;
- }
- if (element is PropertyAccessorElement && element.isSynthetic) {
- return element.variable.hasNonVirtual;
- }
- return element.hasNonVirtual;
- }
-
- /// Given a parenthesized expression, this returns the parent (or recursively
- /// grand-parent) of the expression that is a parenthesized expression, but
- /// whose parent is not a parenthesized expression.
- ///
- /// For example given the code `(((e)))`: `(e) -> (((e)))`.
- ///
- /// @param parenthesizedExpression some expression whose parent is a
- /// parenthesized expression
- /// @return the first parent or grand-parent that is a parenthesized
- /// expression, that does not have a parenthesized expression parent
- static ParenthesizedExpression _wrapParenthesizedExpression(
- ParenthesizedExpression parenthesizedExpression) {
- AstNode parent = parenthesizedExpression.parent;
- if (parent is ParenthesizedExpression) {
- return _wrapParenthesizedExpression(parent);
- }
- return parenthesizedExpression;
- }
-}
-
-/// Instances of the class `Dart2JSVerifier` traverse an AST structure looking
-/// for hints for code that will be compiled to JS, such as
-/// [HintCode.IS_DOUBLE].
-class Dart2JSVerifier extends RecursiveAstVisitor<void> {
- /// The name of the `double` type.
- static String _DOUBLE_TYPE_NAME = "double";
-
- /// The error reporter by which errors will be reported.
- final ErrorReporter _errorReporter;
-
- /// Create a new instance of the [Dart2JSVerifier].
- ///
- /// @param errorReporter the error reporter
- Dart2JSVerifier(this._errorReporter);
-
- @override
- void visitIsExpression(IsExpression node) {
- _checkForIsDoubleHints(node);
- super.visitIsExpression(node);
- }
-
- /// Check for instances of `x is double`, `x is int`, `x is! double` and
- /// `x is! int`.
- ///
- /// @param node the is expression to check
- /// @return `true` if and only if a hint code is generated on the passed node
- /// See [HintCode.IS_DOUBLE],
- /// [HintCode.IS_INT],
- /// [HintCode.IS_NOT_DOUBLE], and
- /// [HintCode.IS_NOT_INT].
- bool _checkForIsDoubleHints(IsExpression node) {
- DartType type = node.type.type;
- Element element = type?.element;
- if (element != null) {
- String typeNameStr = element.name;
- LibraryElement libraryElement = element.library;
- // if (typeNameStr.equals(INT_TYPE_NAME) && libraryElement != null
- // && libraryElement.isDartCore()) {
- // if (node.getNotOperator() == null) {
- // errorReporter.reportError(HintCode.IS_INT, node);
- // } else {
- // errorReporter.reportError(HintCode.IS_NOT_INT, node);
- // }
- // return true;
- // } else
- if (typeNameStr == _DOUBLE_TYPE_NAME &&
- libraryElement != null &&
- libraryElement.isDartCore) {
- if (node.notOperator == null) {
- _errorReporter.reportErrorForNode(HintCode.IS_DOUBLE, node);
- } else {
- _errorReporter.reportErrorForNode(HintCode.IS_NOT_DOUBLE, node);
- }
- return true;
- }
- }
- return false;
- }
-}
-
-/// A visitor that finds dead code and unused labels.
-class DeadCodeVerifier extends RecursiveAstVisitor<void> {
- /// The error reporter by which errors will be reported.
- final ErrorReporter _errorReporter;
-
- /// The type system for this visitor
- final TypeSystemImpl _typeSystem;
-
- /// The object used to track the usage of labels within a given label scope.
- _LabelTracker labelTracker;
-
- /// Is `true` if this unit has been parsed as non-nullable.
- final bool _isNonNullableUnit;
-
- /// Initialize a newly created dead code verifier that will report dead code
- /// to the given [errorReporter] and will use the given [typeSystem] if one is
- /// provided.
- DeadCodeVerifier(this._errorReporter, FeatureSet featureSet,
- {TypeSystemImpl typeSystem})
- : this._typeSystem = typeSystem ??
- TypeSystemImpl(
- implicitCasts: true,
- isNonNullableByDefault: false,
- strictInference: false,
- typeProvider: null,
- ),
- _isNonNullableUnit = featureSet.isEnabled(Feature.non_nullable);
-
- @override
- void visitAssignmentExpression(AssignmentExpression node) {
- TokenType operatorType = node.operator.type;
- if (operatorType == TokenType.QUESTION_QUESTION_EQ) {
- _checkForDeadNullCoalesce(
- node.leftHandSide.staticType, node.rightHandSide);
- }
- super.visitAssignmentExpression(node);
- }
-
- @override
- void visitBinaryExpression(BinaryExpression node) {
- Token operator = node.operator;
- bool isAmpAmp = operator.type == TokenType.AMPERSAND_AMPERSAND;
- bool isBarBar = operator.type == TokenType.BAR_BAR;
- bool isQuestionQuestion = operator.type == TokenType.QUESTION_QUESTION;
- if (isAmpAmp || isBarBar) {
- Expression lhsCondition = node.leftOperand;
- if (!_isDebugConstant(lhsCondition)) {
- EvaluationResultImpl lhsResult = _getConstantBooleanValue(lhsCondition);
- if (lhsResult != null) {
- bool value = lhsResult.value.toBoolValue();
- if (value == true && isBarBar) {
- // Report error on "else" block: true || !e!
- _errorReporter.reportErrorForNode(
- HintCode.DEAD_CODE, node.rightOperand);
- // Only visit the LHS:
- lhsCondition?.accept(this);
- return;
- } else if (value == false && isAmpAmp) {
- // Report error on "if" block: false && !e!
- _errorReporter.reportErrorForNode(
- HintCode.DEAD_CODE, node.rightOperand);
- // Only visit the LHS:
- lhsCondition?.accept(this);
- return;
- }
- }
- }
- // How do we want to handle the RHS? It isn't dead code, but "pointless"
- // or "obscure"...
-// Expression rhsCondition = node.getRightOperand();
-// ValidResult rhsResult = getConstantBooleanValue(rhsCondition);
-// if (rhsResult != null) {
-// if (rhsResult == ValidResult.RESULT_TRUE && isBarBar) {
-// // report error on else block: !e! || true
-// errorReporter.reportError(HintCode.DEAD_CODE, node.getRightOperand());
-// // only visit the RHS:
-// rhsCondition?.accept(this);
-// return null;
-// } else if (rhsResult == ValidResult.RESULT_FALSE && isAmpAmp) {
-// // report error on if block: !e! && false
-// errorReporter.reportError(HintCode.DEAD_CODE, node.getRightOperand());
-// // only visit the RHS:
-// rhsCondition?.accept(this);
-// return null;
-// }
-// }
- } else if (isQuestionQuestion && _isNonNullableUnit) {
- _checkForDeadNullCoalesce(node.leftOperand.staticType, node.rightOperand);
- }
- super.visitBinaryExpression(node);
- }
-
- /// For each block, this method reports and error on all statements between
- /// the end of the block and the first return statement (assuming there it is
- /// not at the end of the block.)
- @override
- void visitBlock(Block node) {
- NodeList<Statement> statements = node.statements;
- _checkForDeadStatementsInNodeList(statements);
- }
-
- @override
- void visitBreakStatement(BreakStatement node) {
- labelTracker?.recordUsage(node.label?.name);
- }
-
- @override
- void visitConditionalExpression(ConditionalExpression node) {
- Expression conditionExpression = node.condition;
- conditionExpression?.accept(this);
- if (!_isDebugConstant(conditionExpression)) {
- EvaluationResultImpl result =
- _getConstantBooleanValue(conditionExpression);
- if (result != null) {
- if (result.value.toBoolValue() == true) {
- // Report error on "else" block: true ? 1 : !2!
- _errorReporter.reportErrorForNode(
- HintCode.DEAD_CODE, node.elseExpression);
- node.thenExpression?.accept(this);
- return;
- } else {
- // Report error on "if" block: false ? !1! : 2
- _errorReporter.reportErrorForNode(
- HintCode.DEAD_CODE, node.thenExpression);
- node.elseExpression?.accept(this);
- return;
- }
- }
- }
- super.visitConditionalExpression(node);
- }
-
- @override
- void visitContinueStatement(ContinueStatement node) {
- labelTracker?.recordUsage(node.label?.name);
- }
-
- @override
- void visitExportDirective(ExportDirective node) {
- ExportElement exportElement = node.element;
- if (exportElement != null) {
- // The element is null when the URI is invalid.
- LibraryElement library = exportElement.exportedLibrary;
- if (library != null && !library.isSynthetic) {
- for (Combinator combinator in node.combinators) {
- _checkCombinator(library, combinator);
- }
- }
- }
- super.visitExportDirective(node);
- }
-
- @override
- void visitIfElement(IfElement node) {
- Expression conditionExpression = node.condition;
- conditionExpression?.accept(this);
- if (!_isDebugConstant(conditionExpression)) {
- EvaluationResultImpl result =
- _getConstantBooleanValue(conditionExpression);
- if (result != null) {
- if (result.value.toBoolValue() == true) {
- // Report error on else block: if(true) {} else {!}
- CollectionElement elseElement = node.elseElement;
- if (elseElement != null) {
- _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, elseElement);
- node.thenElement?.accept(this);
- return;
- }
- } else {
- // Report error on if block: if (false) {!} else {}
- _errorReporter.reportErrorForNode(
- HintCode.DEAD_CODE, node.thenElement);
- node.elseElement?.accept(this);
- return;
- }
- }
- }
- super.visitIfElement(node);
- }
-
- @override
- void visitIfStatement(IfStatement node) {
- Expression conditionExpression = node.condition;
- conditionExpression?.accept(this);
- if (!_isDebugConstant(conditionExpression)) {
- EvaluationResultImpl result =
- _getConstantBooleanValue(conditionExpression);
- if (result != null) {
- if (result.value.toBoolValue() == true) {
- // Report error on else block: if(true) {} else {!}
- Statement elseStatement = node.elseStatement;
- if (elseStatement != null) {
- _errorReporter.reportErrorForNode(
- HintCode.DEAD_CODE, elseStatement);
- node.thenStatement?.accept(this);
- return;
- }
- } else {
- // Report error on if block: if (false) {!} else {}
- _errorReporter.reportErrorForNode(
- HintCode.DEAD_CODE, node.thenStatement);
- node.elseStatement?.accept(this);
- return;
- }
- }
- }
- super.visitIfStatement(node);
- }
-
- @override
- void visitImportDirective(ImportDirective node) {
- ImportElement importElement = node.element;
- if (importElement != null) {
- // The element is null when the URI is invalid, but not when the URI is
- // valid but refers to a non-existent file.
- LibraryElement library = importElement.importedLibrary;
- if (library != null && !library.isSynthetic) {
- for (Combinator combinator in node.combinators) {
- _checkCombinator(library, combinator);
- }
- }
- }
- super.visitImportDirective(node);
- }
-
- @override
- void visitLabeledStatement(LabeledStatement node) {
- _pushLabels(node.labels);
- try {
- super.visitLabeledStatement(node);
- } finally {
- _popLabels();
- }
- }
-
- @override
- void visitSwitchCase(SwitchCase node) {
- _checkForDeadStatementsInNodeList(node.statements, allowMandated: true);
- super.visitSwitchCase(node);
- }
-
- @override
- void visitSwitchDefault(SwitchDefault node) {
- _checkForDeadStatementsInNodeList(node.statements, allowMandated: true);
- super.visitSwitchDefault(node);
- }
-
- @override
- void visitSwitchStatement(SwitchStatement node) {
- List<Label> labels = <Label>[];
- for (SwitchMember member in node.members) {
- labels.addAll(member.labels);
- }
- _pushLabels(labels);
- try {
- super.visitSwitchStatement(node);
- } finally {
- _popLabels();
- }
- }
-
- @override
- void visitTryStatement(TryStatement node) {
- node.body?.accept(this);
- node.finallyBlock?.accept(this);
- NodeList<CatchClause> catchClauses = node.catchClauses;
- int numOfCatchClauses = catchClauses.length;
- List<DartType> visitedTypes = new List<DartType>();
- for (int i = 0; i < numOfCatchClauses; i++) {
- CatchClause catchClause = catchClauses[i];
- if (catchClause.onKeyword != null) {
- // An on-catch clause was found; verify that the exception type is not a
- // subtype of a previous on-catch exception type.
- DartType currentType = catchClause.exceptionType?.type;
- if (currentType != null) {
- if (currentType.isObject) {
- // Found catch clause clause that has Object as an exception type,
- // this is equivalent to having a catch clause that doesn't have an
- // exception type, visit the block, but generate an error on any
- // following catch clauses (and don't visit them).
- catchClause?.accept(this);
- if (i + 1 != numOfCatchClauses) {
- // This catch clause is not the last in the try statement.
- CatchClause nextCatchClause = catchClauses[i + 1];
- CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1];
- int offset = nextCatchClause.offset;
- int length = lastCatchClause.end - offset;
- _errorReporter.reportErrorForOffset(
- HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH, offset, length);
- return;
- }
- }
- int length = visitedTypes.length;
- for (int j = 0; j < length; j++) {
- DartType type = visitedTypes[j];
- if (_typeSystem.isSubtypeOf(currentType, type)) {
- CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1];
- int offset = catchClause.offset;
- int length = lastCatchClause.end - offset;
- _errorReporter.reportErrorForOffset(
- HintCode.DEAD_CODE_ON_CATCH_SUBTYPE,
- offset,
- length,
- [currentType.displayName, type.displayName]);
- return;
- }
- }
- visitedTypes.add(currentType);
- }
- catchClause?.accept(this);
- } else {
- // Found catch clause clause that doesn't have an exception type,
- // visit the block, but generate an error on any following catch clauses
- // (and don't visit them).
- catchClause?.accept(this);
- if (i + 1 != numOfCatchClauses) {
- // This catch clause is not the last in the try statement.
- CatchClause nextCatchClause = catchClauses[i + 1];
- CatchClause lastCatchClause = catchClauses[numOfCatchClauses - 1];
- int offset = nextCatchClause.offset;
- int length = lastCatchClause.end - offset;
- _errorReporter.reportErrorForOffset(
- HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH, offset, length);
- return;
- }
- }
- }
- }
-
- @override
- void visitWhileStatement(WhileStatement node) {
- Expression conditionExpression = node.condition;
- conditionExpression?.accept(this);
- if (!_isDebugConstant(conditionExpression)) {
- EvaluationResultImpl result =
- _getConstantBooleanValue(conditionExpression);
- if (result != null) {
- if (result.value.toBoolValue() == false) {
- // Report error on while block: while (false) {!}
- _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.body);
- return;
- }
- }
- }
- node.body?.accept(this);
- }
-
- /// Resolve the names in the given [combinator] in the scope of the given
- /// [library].
- void _checkCombinator(LibraryElement library, Combinator combinator) {
- Namespace namespace =
- new NamespaceBuilder().createExportNamespaceForLibrary(library);
- NodeList<SimpleIdentifier> names;
- ErrorCode hintCode;
- if (combinator is HideCombinator) {
- names = combinator.hiddenNames;
- hintCode = HintCode.UNDEFINED_HIDDEN_NAME;
- } else {
- names = (combinator as ShowCombinator).shownNames;
- hintCode = HintCode.UNDEFINED_SHOWN_NAME;
- }
- for (SimpleIdentifier name in names) {
- String nameStr = name.name;
- Element element = namespace.get(nameStr);
- if (element == null) {
- element = namespace.get("$nameStr=");
- }
- if (element == null) {
- _errorReporter
- .reportErrorForNode(hintCode, name, [library.identifier, nameStr]);
- }
- }
- }
-
- void _checkForDeadNullCoalesce(TypeImpl lhsType, Expression rhs) {
- if (_isNonNullableUnit && _typeSystem.isNonNullable(lhsType)) {
- _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, rhs, []);
- }
- }
-
- /// Given some list of [statements], loop through the list searching for dead
- /// statements. If [allowMandated] is true, then allow dead statements that
- /// are mandated by the language spec. This allows for a final break,
- /// continue, return, or throw statement at the end of a switch case, that are
- /// mandated by the language spec.
- void _checkForDeadStatementsInNodeList(NodeList<Statement> statements,
- {bool allowMandated: false}) {
- bool statementExits(Statement statement) {
- if (statement is BreakStatement) {
- return statement.label == null;
- } else if (statement is ContinueStatement) {
- return statement.label == null;
- }
- return ExitDetector.exits(statement);
- }
-
- int size = statements.length;
- for (int i = 0; i < size; i++) {
- Statement currentStatement = statements[i];
- currentStatement?.accept(this);
- if (statementExits(currentStatement) && i != size - 1) {
- Statement nextStatement = statements[i + 1];
- Statement lastStatement = statements[size - 1];
- // If mandated statements are allowed, and only the last statement is
- // dead, and it's a BreakStatement, then assume it is a statement
- // mandated by the language spec, there to avoid a
- // CASE_BLOCK_NOT_TERMINATED error.
- if (allowMandated && i == size - 2 && nextStatement is BreakStatement) {
- return;
- }
- int offset = nextStatement.offset;
- int length = lastStatement.end - offset;
- _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE, offset, length);
- return;
- }
- }
- }
-
- /// Given some [expression], return [ValidResult.RESULT_TRUE] if it is `true`,
- /// [ValidResult.RESULT_FALSE] if it is `false`, or `null` if the expression
- /// is not a constant boolean value.
- EvaluationResultImpl _getConstantBooleanValue(Expression expression) {
- if (expression is BooleanLiteral) {
- if (expression.value) {
- return new EvaluationResultImpl(
- new DartObjectImpl(null, BoolState.from(true)));
- } else {
- return new EvaluationResultImpl(
- new DartObjectImpl(null, BoolState.from(false)));
- }
- }
-
- // Don't consider situations where we could evaluate to a constant boolean
- // expression with the ConstantVisitor
- // else {
- // EvaluationResultImpl result = expression.accept(new ConstantVisitor());
- // if (result == ValidResult.RESULT_TRUE) {
- // return ValidResult.RESULT_TRUE;
- // } else if (result == ValidResult.RESULT_FALSE) {
- // return ValidResult.RESULT_FALSE;
- // }
- // return null;
- // }
- return null;
- }
-
- /// Return `true` if the given [expression] is resolved to a constant
- /// variable.
- bool _isDebugConstant(Expression expression) {
- Element element;
- if (expression is Identifier) {
- element = expression.staticElement;
- } else if (expression is PropertyAccess) {
- element = expression.propertyName.staticElement;
- }
- if (element is PropertyAccessorElement) {
- PropertyInducingElement variable = element.variable;
- return variable != null && variable.isConst;
- }
- return false;
- }
-
- /// Exit the most recently entered label scope after reporting any labels that
- /// were not referenced within that scope.
- void _popLabels() {
- for (Label label in labelTracker.unusedLabels()) {
- _errorReporter
- .reportErrorForNode(HintCode.UNUSED_LABEL, label, [label.label.name]);
- }
- labelTracker = labelTracker.outerTracker;
- }
-
- /// Enter a new label scope in which the given [labels] are defined.
- void _pushLabels(List<Label> labels) {
- labelTracker = new _LabelTracker(labelTracker, labels);
- }
-}
-
-/// An [AstVisitor] that fills [UsedLocalElements].
-class GatherUsedLocalElementsVisitor extends RecursiveAstVisitor {
- final UsedLocalElements usedElements = new UsedLocalElements();
-
- final LibraryElement _enclosingLibrary;
- ClassElement _enclosingClass;
- ExecutableElement _enclosingExec;
-
- GatherUsedLocalElementsVisitor(this._enclosingLibrary);
-
- @override
- visitCatchClause(CatchClause node) {
- SimpleIdentifier exceptionParameter = node.exceptionParameter;
- SimpleIdentifier stackTraceParameter = node.stackTraceParameter;
- if (exceptionParameter != null) {
- Element element = exceptionParameter.staticElement;
- usedElements.addCatchException(element);
- if (stackTraceParameter != null || node.onKeyword == null) {
- usedElements.addElement(element);
- }
- }
- if (stackTraceParameter != null) {
- Element element = stackTraceParameter.staticElement;
- usedElements.addCatchStackTrace(element);
- }
- super.visitCatchClause(node);
- }
-
- @override
- visitClassDeclaration(ClassDeclaration node) {
- ClassElement enclosingClassOld = _enclosingClass;
- try {
- _enclosingClass = node.declaredElement;
- super.visitClassDeclaration(node);
- } finally {
- _enclosingClass = enclosingClassOld;
- }
- }
-
- @override
- visitFunctionDeclaration(FunctionDeclaration node) {
- ExecutableElement enclosingExecOld = _enclosingExec;
- try {
- _enclosingExec = node.declaredElement;
- super.visitFunctionDeclaration(node);
- } finally {
- _enclosingExec = enclosingExecOld;
- }
- }
-
- @override
- visitFunctionExpression(FunctionExpression node) {
- if (node.parent is! FunctionDeclaration) {
- usedElements.addElement(node.declaredElement);
- }
- super.visitFunctionExpression(node);
- }
-
- @override
- visitMethodDeclaration(MethodDeclaration node) {
- ExecutableElement enclosingExecOld = _enclosingExec;
- try {
- _enclosingExec = node.declaredElement;
- super.visitMethodDeclaration(node);
- } finally {
- _enclosingExec = enclosingExecOld;
- }
- }
-
- @override
- visitSimpleIdentifier(SimpleIdentifier node) {
- if (node.inDeclarationContext()) {
- return;
- }
- Element element = node.staticElement;
- // Store un-parameterized members.
- if (element is ExecutableMember) {
- element = element.declaration;
- }
- bool isIdentifierRead = _isReadIdentifier(node);
- if (element is PropertyAccessorElement &&
- element.isSynthetic &&
- isIdentifierRead &&
- element.variable is TopLevelVariableElement) {
- usedElements.addElement(element.variable);
- } else if (element is LocalVariableElement) {
- if (isIdentifierRead) {
- usedElements.addElement(element);
- }
- } else {
- _useIdentifierElement(node);
- if (element == null) {
- if (isIdentifierRead) {
- usedElements.unresolvedReadMembers.add(node.name);
- }
- } else if (element.enclosingElement is ClassElement &&
- !identical(element, _enclosingExec)) {
- usedElements.members.add(element);
- if (isIdentifierRead) {
- // Store the corresponding getter.
- if (element is PropertyAccessorElement && element.isSetter) {
- element = (element as PropertyAccessorElement).correspondingGetter;
- }
- usedElements.members.add(element);
- usedElements.readMembers.add(element);
- }
- }
- }
- }
-
- /// Marks an [Element] of [node] as used in the library.
- void _useIdentifierElement(Identifier node) {
- Element element = node.staticElement;
- if (element == null) {
- return;
- }
- // check if a local element
- if (!identical(element.library, _enclosingLibrary)) {
- return;
- }
- // ignore references to an element from itself
- if (identical(element, _enclosingClass)) {
- return;
- }
- if (identical(element, _enclosingExec)) {
- return;
- }
- // ignore places where the element is not actually used
- if (node.parent is TypeName) {
- if (element is ClassElement) {
- AstNode parent2 = node.parent.parent;
- if (parent2 is IsExpression) {
- return;
- }
- if (parent2 is VariableDeclarationList) {
- // If it's a field's type, it still counts as used.
- if (parent2.parent is! FieldDeclaration) {
- return;
- }
- }
- }
- }
- // OK
- usedElements.addElement(element);
- }
-
- static bool _isReadIdentifier(SimpleIdentifier node) {
- // not reading at all
- if (!node.inGetterContext()) {
- return false;
- }
- // check if useless reading
- AstNode parent = node.parent;
- if (parent.parent is ExpressionStatement) {
- if (parent is PrefixExpression || parent is PostfixExpression) {
- // v++;
- // ++v;
- return false;
- }
- if (parent is AssignmentExpression && parent.leftHandSide == node) {
- // v ??= doSomething();
- // vs.
- // v += 2;
- TokenType operatorType = parent.operator?.type;
- return operatorType == TokenType.QUESTION_QUESTION_EQ;
- }
- }
- // OK
- return true;
- }
-}
-
/// Maintains and manages contextual type information used for
/// inferring types.
class InferenceContext {
@@ -2424,7 +297,7 @@
// Don't try to re-resolve the initializers if we cannot set up the
// right name scope for resolution.
} else {
- nameScope = new ClassScope(nameScope, enclosingClass);
+ nameScope = ClassScope(nameScope, enclosingClass);
NodeList<ClassMember> members = node.members;
int length = members.length;
for (int i = 0; i < length; i++) {
@@ -2459,91 +332,6 @@
}
}
-/// Instances of the class `OverrideVerifier` visit all of the declarations in a
-/// compilation unit to verify that if they have an override annotation it is
-/// being used correctly.
-class OverrideVerifier extends RecursiveAstVisitor {
- /// The inheritance manager used to find overridden methods.
- final InheritanceManager3 _inheritance;
-
- /// The URI of the library being verified.
- final Uri _libraryUri;
-
- /// The error reporter used to report errors.
- final ErrorReporter _errorReporter;
-
- /// The current class or mixin.
- InterfaceType _currentType;
-
- OverrideVerifier(
- this._inheritance, LibraryElement library, this._errorReporter)
- : _libraryUri = library.source.uri;
-
- @override
- visitClassDeclaration(ClassDeclaration node) {
- _currentType = node.declaredElement.thisType;
- super.visitClassDeclaration(node);
- _currentType = null;
- }
-
- @override
- visitFieldDeclaration(FieldDeclaration node) {
- for (VariableDeclaration field in node.fields.variables) {
- FieldElement fieldElement = field.declaredElement;
- if (fieldElement.hasOverride) {
- PropertyAccessorElement getter = fieldElement.getter;
- if (getter != null && _isOverride(getter)) continue;
-
- PropertyAccessorElement setter = fieldElement.setter;
- if (setter != null && _isOverride(setter)) continue;
-
- _errorReporter.reportErrorForNode(
- HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD,
- field.name,
- );
- }
- }
- }
-
- @override
- visitMethodDeclaration(MethodDeclaration node) {
- ExecutableElement element = node.declaredElement;
- if (element.hasOverride && !_isOverride(element)) {
- if (element is MethodElement) {
- _errorReporter.reportErrorForNode(
- HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD,
- node.name,
- );
- } else if (element is PropertyAccessorElement) {
- if (element.isGetter) {
- _errorReporter.reportErrorForNode(
- HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER,
- node.name,
- );
- } else {
- _errorReporter.reportErrorForNode(
- HintCode.OVERRIDE_ON_NON_OVERRIDING_SETTER,
- node.name,
- );
- }
- }
- }
- }
-
- @override
- visitMixinDeclaration(MixinDeclaration node) {
- _currentType = node.declaredElement.thisType;
- super.visitMixinDeclaration(node);
- _currentType = null;
- }
-
- /// Return `true` if the [member] overrides a member from a superinterface.
- bool _isOverride(ExecutableElement member) {
- var name = new Name(_libraryUri, member.name);
- return _inheritance.getOverridden(_currentType, name) != null;
- }
-}
-
/// An AST visitor that is used to resolve some of the nodes within a single
/// compilation unit. The nodes that are skipped are those that are within
/// function bodies.
@@ -2782,8 +570,8 @@
AnalysisErrorListener errorListener,
{FeatureSet featureSet,
Scope nameScope,
- bool propagateTypes: true,
- reportConstEvaluationErrors: true,
+ bool propagateTypes = true,
+ reportConstEvaluationErrors = true,
FlowAnalysisHelper flowAnalysisHelper})
: this._(
inheritanceManager,
@@ -2816,18 +604,18 @@
featureSet.isEnabled(Feature.spread_collections),
super(definingLibrary, source, typeProvider, errorListener,
nameScope: nameScope) {
- this.typeSystem = definingLibrary.context.typeSystem;
+ this.typeSystem = definingLibrary.typeSystem;
this._promoteManager = TypePromotionManager(typeSystem);
this.extensionResolver = ExtensionMemberResolver(this);
- this.elementResolver = new ElementResolver(this,
+ this.elementResolver = ElementResolver(this,
reportConstEvaluationErrors: reportConstEvaluationErrors);
bool strongModeHints = false;
AnalysisOptions options = _analysisOptions;
if (options is AnalysisOptionsImpl) {
strongModeHints = options.strongModeHints;
}
- this.inferenceContext = new InferenceContext._(this, strongModeHints);
- this.typeAnalyzer = new StaticTypeAnalyzer(this, featureSet, _flowAnalysis);
+ this.inferenceContext = InferenceContext._(this, strongModeHints);
+ this.typeAnalyzer = StaticTypeAnalyzer(this, featureSet, _flowAnalysis);
}
/// Return the element representing the function containing the current node,
@@ -3490,6 +1278,8 @@
inferenceContext.pushReturnContext(node);
super.visitExpressionFunctionBody(node);
+ _flowAnalysis?.flow?.handleExit();
+
DartType type = node.expression.staticType;
if (_enclosingFunction.isAsynchronous) {
type = typeSystem.flatten(type);
@@ -4472,11 +2262,11 @@
_fromTypeArguments(literal.typeArguments);
DartType contextType = InferenceContext.getContext(literal);
_LiteralResolution contextResolution = _fromContextType(contextType);
- _LeafElements elementCounts = new _LeafElements(literal.elements);
+ _LeafElements elementCounts = _LeafElements(literal.elements);
_LiteralResolution elementResolution = elementCounts.resolution;
List<_LiteralResolution> unambiguousResolutions = [];
- Set<_LiteralResolutionKind> kinds = new Set<_LiteralResolutionKind>();
+ Set<_LiteralResolutionKind> kinds = Set<_LiteralResolutionKind>();
if (typeArgumentsResolution.kind != _LiteralResolutionKind.ambiguous) {
unambiguousResolutions.add(typeArgumentsResolution);
kinds.add(typeArgumentsResolution.kind);
@@ -4525,7 +2315,7 @@
/// Return a newly created cloner that can be used to clone constant
/// expressions.
ConstantAstCloner _createCloner() {
- return new ConstantAstCloner();
+ return ConstantAstCloner();
}
/// Creates a union of `T | Future<T>`, unless `T` is already a
@@ -4604,7 +2394,7 @@
FunctionType _inferArgumentTypesForGeneric(AstNode inferenceNode,
DartType uninstantiatedType, TypeArgumentList typeArguments,
- {AstNode errorNode, bool isConst: false}) {
+ {AstNode errorNode, bool isConst = false}) {
errorNode ??= inferenceNode;
if (typeArguments == null &&
uninstantiatedType is FunctionType &&
@@ -4792,7 +2582,7 @@
}
int requiredParameterCount = 0;
int unnamedParameterCount = 0;
- List<ParameterElement> unnamedParameters = new List<ParameterElement>();
+ List<ParameterElement> unnamedParameters = List<ParameterElement>();
Map<String, ParameterElement> namedParameters;
int length = parameters.length;
for (int i = 0; i < length; i++) {
@@ -4805,7 +2595,7 @@
unnamedParameters.add(parameter);
unnamedParameterCount++;
} else {
- namedParameters ??= new HashMap<String, ParameterElement>();
+ namedParameters ??= HashMap<String, ParameterElement>();
namedParameters[parameter.name] = parameter;
}
}
@@ -4813,7 +2603,7 @@
NodeList<Expression> arguments = argumentList.arguments;
int argumentCount = arguments.length;
List<ParameterElement> resolvedParameters =
- new List<ParameterElement>(argumentCount);
+ List<ParameterElement>(argumentCount);
int positionalArgumentCount = 0;
HashSet<String> usedNames;
bool noBlankArguments = true;
@@ -4833,7 +2623,7 @@
resolvedParameters[i] = element;
nameNode.staticElement = element;
}
- usedNames ??= new HashSet<String>();
+ usedNames ??= HashSet<String>();
if (!usedNames.add(name)) {
if (onError != null) {
onError(CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT, nameNode,
@@ -4926,9 +2716,9 @@
AnalysisErrorListener errorListener,
{Scope nameScope})
: source = source,
- errorReporter = new ErrorReporter(errorListener, source) {
+ errorReporter = ErrorReporter(errorListener, source) {
if (nameScope == null) {
- this.nameScope = new LibraryScope(definingLibrary);
+ this.nameScope = LibraryScope(definingLibrary);
} else {
this.nameScope = nameScope;
}
@@ -4950,7 +2740,7 @@
///
/// @return the new [Scope].
Scope pushNameScope() {
- Scope newScope = new EnclosedScope(nameScope);
+ Scope newScope = EnclosedScope(nameScope);
nameScope = newScope;
return nameScope;
}
@@ -4959,7 +2749,7 @@
void visitBlock(Block node) {
Scope outerScope = nameScope;
try {
- EnclosedScope enclosedScope = new BlockScope(nameScope, node);
+ EnclosedScope enclosedScope = BlockScope(nameScope, node);
nameScope = enclosedScope;
super.visitBlock(node);
} finally {
@@ -4984,7 +2774,7 @@
if (exception != null) {
Scope outerScope = nameScope;
try {
- nameScope = new EnclosedScope(nameScope);
+ nameScope = EnclosedScope(nameScope);
nameScope.define(exception.staticElement);
SimpleIdentifier stackTrace = node.stackTraceParameter;
if (stackTrace != null) {
@@ -5008,15 +2798,15 @@
AnalysisEngine.instance.instrumentationService.logInfo(
"Missing element for class declaration ${node.name.name} in "
"${definingLibrary.source.fullName}",
- new CaughtException(new AnalysisException(), null));
+ CaughtException(AnalysisException(), null));
super.visitClassDeclaration(node);
} else {
ClassElement outerClass = enclosingClass;
try {
enclosingClass = node.declaredElement;
- nameScope = new TypeParameterScope(nameScope, classElement);
+ nameScope = TypeParameterScope(nameScope, classElement);
visitClassDeclarationInScope(node);
- nameScope = new ClassScope(nameScope, classElement);
+ nameScope = ClassScope(nameScope, classElement);
visitClassMembersInScope(node);
} finally {
enclosingClass = outerClass;
@@ -5047,8 +2837,7 @@
Scope outerScope = nameScope;
try {
ClassElement element = node.declaredElement;
- nameScope =
- new ClassScope(new TypeParameterScope(nameScope, element), element);
+ nameScope = ClassScope(TypeParameterScope(nameScope, element), element);
super.visitClassTypeAlias(node);
} finally {
nameScope = outerScope;
@@ -5059,7 +2848,7 @@
void visitConstructorDeclaration(ConstructorDeclaration node) {
ConstructorElement constructorElement = node.declaredElement;
if (constructorElement == null) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write("Missing element for constructor ");
buffer.write(node.returnType.name);
if (node.name != null) {
@@ -5073,7 +2862,7 @@
Scope outerScope = nameScope;
try {
if (constructorElement != null) {
- nameScope = new FunctionScope(nameScope, constructorElement);
+ nameScope = FunctionScope(nameScope, constructorElement);
}
node.documentationComment?.accept(this);
node.metadata.accept(this);
@@ -5084,7 +2873,7 @@
try {
if (constructorElement != null) {
nameScope =
- new ConstructorInitializerScope(nameScope, constructorElement);
+ ConstructorInitializerScope(nameScope, constructorElement);
}
node.initializers.accept(this);
} finally {
@@ -5140,7 +2929,7 @@
ClassElement outerClass = enclosingClass;
try {
enclosingClass = node.declaredElement;
- nameScope = new ClassScope(nameScope, classElement);
+ nameScope = ClassScope(nameScope, classElement);
visitEnumMembersInScope(node);
} finally {
enclosingClass = outerClass;
@@ -5171,7 +2960,7 @@
ExtensionElement outerExtension = enclosingExtension;
try {
enclosingExtension = extensionElement;
- nameScope = new TypeParameterScope(nameScope, extensionElement);
+ nameScope = TypeParameterScope(nameScope, extensionElement);
visitExtensionDeclarationInScope(node);
nameScope = ExtensionScope(nameScope, extensionElement);
visitExtensionMembersInScope(node);
@@ -5210,7 +2999,7 @@
void visitForElement(ForElement node) {
Scope outerNameScope = nameScope;
try {
- nameScope = new EnclosedScope(nameScope);
+ nameScope = EnclosedScope(nameScope);
visitForElementInScope(node);
} finally {
nameScope = outerNameScope;
@@ -5248,7 +3037,7 @@
Scope outerNameScope = nameScope;
ImplicitLabelScope outerImplicitScope = _implicitLabelScope;
try {
- nameScope = new EnclosedScope(nameScope);
+ nameScope = EnclosedScope(nameScope);
_implicitLabelScope = _implicitLabelScope.nest(node);
visitForStatementInScope(node);
} finally {
@@ -5281,7 +3070,7 @@
"Missing element for top-level function ${node.name.name} in "
"${definingLibrary.source.fullName}");
} else {
- nameScope = new FunctionScope(nameScope, functionElement);
+ nameScope = FunctionScope(nameScope, functionElement);
}
visitFunctionDeclarationInScope(node);
} finally {
@@ -5303,7 +3092,7 @@
try {
ExecutableElement functionElement = node.declaredElement;
if (functionElement == null) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write("Missing element for function ");
AstNode parent = node.parent;
while (parent != null) {
@@ -5320,7 +3109,7 @@
AnalysisEngine.instance.instrumentationService
.logInfo(buffer.toString());
} else {
- nameScope = new FunctionScope(nameScope, functionElement);
+ nameScope = FunctionScope(nameScope, functionElement);
}
super.visitFunctionExpression(node);
} finally {
@@ -5333,7 +3122,7 @@
void visitFunctionTypeAlias(FunctionTypeAlias node) {
Scope outerScope = nameScope;
try {
- nameScope = new FunctionTypeScope(nameScope, node.declaredElement);
+ nameScope = FunctionTypeScope(nameScope, node.declaredElement);
visitFunctionTypeAliasInScope(node);
} finally {
nameScope = outerScope;
@@ -5354,7 +3143,7 @@
"Missing element for function typed formal parameter "
"${node.identifier.name} in ${definingLibrary.source.fullName}");
} else {
- nameScope = new EnclosedScope(nameScope);
+ nameScope = EnclosedScope(nameScope);
var typeParameters = parameterElement.typeParameters;
int length = typeParameters.length;
for (int i = 0; i < length; i++) {
@@ -5386,7 +3175,7 @@
"${definingLibrary.source.fullName}");
super.visitGenericFunctionType(node);
} else {
- nameScope = new TypeParameterScope(nameScope, element);
+ nameScope = TypeParameterScope(nameScope, element);
super.visitGenericFunctionType(node);
}
} finally {
@@ -5405,12 +3194,12 @@
"${definingLibrary.source.fullName}");
super.visitGenericTypeAlias(node);
} else {
- nameScope = new TypeParameterScope(nameScope, element);
+ nameScope = TypeParameterScope(nameScope, element);
super.visitGenericTypeAlias(node);
GenericFunctionTypeElement functionElement = element.function;
if (functionElement != null) {
- nameScope = new FunctionScope(nameScope, functionElement)
+ nameScope = FunctionScope(nameScope, functionElement)
..defineParameters();
visitGenericTypeAliasInFunctionScope(node);
}
@@ -5449,7 +3238,7 @@
.logInfo("Missing element for method ${node.name.name} in "
"${definingLibrary.source.fullName}");
} else {
- nameScope = new FunctionScope(nameScope, methodElement);
+ nameScope = FunctionScope(nameScope, methodElement);
}
visitMethodDeclarationInScope(node);
} finally {
@@ -5470,10 +3259,10 @@
try {
enclosingClass = element;
- nameScope = new TypeParameterScope(nameScope, element);
+ nameScope = TypeParameterScope(nameScope, element);
visitMixinDeclarationInScope(node);
- nameScope = new ClassScope(nameScope, element);
+ nameScope = ClassScope(nameScope, element);
visitMixinMembersInScope(node);
} finally {
nameScope = outerScope;
@@ -5507,7 +3296,7 @@
} else if (node != null) {
Scope outerNameScope = nameScope;
try {
- nameScope = new EnclosedScope(nameScope);
+ nameScope = EnclosedScope(nameScope);
node.accept(this);
} finally {
nameScope = outerNameScope;
@@ -5520,7 +3309,7 @@
node.expression.accept(this);
Scope outerNameScope = nameScope;
try {
- nameScope = new EnclosedScope(nameScope);
+ nameScope = EnclosedScope(nameScope);
node.statements.accept(this);
} finally {
nameScope = outerNameScope;
@@ -5531,7 +3320,7 @@
void visitSwitchDefault(SwitchDefault node) {
Scope outerNameScope = nameScope;
try {
- nameScope = new EnclosedScope(nameScope);
+ nameScope = EnclosedScope(nameScope);
node.statements.accept(this);
} finally {
nameScope = outerNameScope;
@@ -5549,7 +3338,7 @@
SimpleIdentifier labelName = label.label;
LabelElement labelElement = labelName.staticElement as LabelElement;
labelScope =
- new LabelScope(labelScope, labelName.name, member, labelElement);
+ LabelScope(labelScope, labelName.name, member, labelElement);
}
}
visitSwitchStatementInScope(node);
@@ -5597,66 +3386,12 @@
SimpleIdentifier labelNameNode = label.label;
String labelName = labelNameNode.name;
LabelElement labelElement = labelNameNode.staticElement as LabelElement;
- labelScope = new LabelScope(labelScope, labelName, node, labelElement);
+ labelScope = LabelScope(labelScope, labelName, node, labelElement);
}
return outerScope;
}
}
-/// Instances of the class `ToDoFinder` find to-do comments in Dart code.
-class ToDoFinder {
- /// The error reporter by which to-do comments will be reported.
- final ErrorReporter _errorReporter;
-
- /// Initialize a newly created to-do finder to report to-do comments to the
- /// given reporter.
- ///
- /// @param errorReporter the error reporter by which to-do comments will be
- /// reported
- ToDoFinder(this._errorReporter);
-
- /// Search the comments in the given compilation unit for to-do comments and
- /// report an error for each.
- ///
- /// @param unit the compilation unit containing the to-do comments
- void findIn(CompilationUnit unit) {
- _gatherTodoComments(unit.beginToken);
- }
-
- /// Search the comment tokens reachable from the given token and create errors
- /// for each to-do comment.
- ///
- /// @param token the head of the list of tokens being searched
- void _gatherTodoComments(Token token) {
- while (token != null && token.type != TokenType.EOF) {
- Token commentToken = token.precedingComments;
- while (commentToken != null) {
- if (commentToken.type == TokenType.SINGLE_LINE_COMMENT ||
- commentToken.type == TokenType.MULTI_LINE_COMMENT) {
- _scrapeTodoComment(commentToken);
- }
- commentToken = commentToken.next;
- }
- token = token.next;
- }
- }
-
- /// Look for user defined tasks in comments and convert them into info level
- /// analysis issues.
- ///
- /// @param commentToken the comment token to analyze
- void _scrapeTodoComment(Token commentToken) {
- Iterable<Match> matches =
- TodoCode.TODO_REGEX.allMatches(commentToken.lexeme);
- for (Match match in matches) {
- int offset = commentToken.offset + match.start + match.group(1).length;
- int length = match.group(2).length;
- _errorReporter.reportErrorForOffset(
- TodoCode.TODO, offset, length, [match.group(2)]);
- }
- }
-}
-
/// Helper for resolving types.
///
/// The client must set [nameScope] before calling [resolveTypeName].
@@ -5692,7 +3427,7 @@
this.definingLibrary,
this.source,
this.errorListener,
- {this.shouldUseWithClauseInferredTypes: true})
+ {this.shouldUseWithClauseInferredTypes = true})
: dynamicType = typeProvider.dynamicType,
analysisOptions = definingLibrary.context.analysisOptions;
@@ -5708,8 +3443,8 @@
/// message
void reportErrorForNode(ErrorCode errorCode, AstNode node,
[List<Object> arguments]) {
- errorListener.onError(new AnalysisError(
- source, node.offset, node.length, errorCode, arguments));
+ errorListener.onError(
+ AnalysisError(source, node.offset, node.length, errorCode, arguments));
}
/// Resolve the given [TypeName] - set its element and static type. Only the
@@ -5974,7 +3709,7 @@
} else if (element is LocalVariableElement ||
(element is FunctionElement &&
element.enclosingElement is ExecutableElement)) {
- errorListener.onError(new DiagnosticFactory()
+ errorListener.onError(DiagnosticFactory()
.referencedBeforeDeclaration(source, typeName, element: element));
} else {
reportErrorForNode(
@@ -5995,7 +3730,7 @@
NodeList<TypeAnnotation> arguments = argumentList.arguments;
int argumentCount = arguments.length;
int parameterCount = parameters.length;
- List<DartType> typeArguments = new List<DartType>(parameterCount);
+ List<DartType> typeArguments = List<DartType>(parameterCount);
if (argumentCount == parameterCount) {
for (int i = 0; i < parameterCount; i++) {
typeArguments[i] = _getType(arguments[i]);
@@ -6015,10 +3750,10 @@
type ??= dynamicType;
} else {
type = typeSystem.instantiateType(type, typeArguments);
+ type = (type as TypeImpl).withNullability(
+ _getNullability(node.question != null),
+ );
}
- type = (type as TypeImpl).withNullability(
- _getNullability(node.question != null),
- );
} else {
if (element is GenericTypeAliasElementImpl) {
var typeArguments = typeSystem.instantiateTypeFormalsToBounds(
@@ -6243,7 +3978,7 @@
var argumentNodes = argumentList.arguments;
var argumentCount = argumentNodes.length;
- typeArguments = new List<DartType>(parameterCount);
+ typeArguments = List<DartType>(parameterCount);
if (argumentCount == parameterCount) {
for (int i = 0; i < parameterCount; i++) {
typeArguments[i] = _getType(argumentNodes[i]);
@@ -6537,276 +4272,6 @@
InterfaceType streamType2(DartType elementType);
}
-/// Instances of the class [UnusedLocalElementsVerifier] traverse an AST
-/// looking for cases of [HintCode.UNUSED_ELEMENT], [HintCode.UNUSED_FIELD],
-/// [HintCode.UNUSED_LOCAL_VARIABLE], etc.
-class UnusedLocalElementsVerifier extends RecursiveAstVisitor {
- /// The error listener to which errors will be reported.
- final AnalysisErrorListener _errorListener;
-
- /// The elements know to be used.
- final UsedLocalElements _usedElements;
-
- /// The inheritance manager used to find overridden methods.
- final InheritanceManager3 _inheritanceManager;
-
- /// The URI of the library being verified.
- final Uri _libraryUri;
-
- /// Create a new instance of the [UnusedLocalElementsVerifier].
- UnusedLocalElementsVerifier(this._errorListener, this._usedElements,
- this._inheritanceManager, LibraryElement library)
- : _libraryUri = library.source.uri;
-
- visitSimpleIdentifier(SimpleIdentifier node) {
- if (node.inDeclarationContext()) {
- var element = node.staticElement;
- if (element is ClassElement) {
- _visitClassElement(element);
- } else if (element is FieldElement) {
- _visitFieldElement(element);
- } else if (element is FunctionElement) {
- _visitFunctionElement(element);
- } else if (element is FunctionTypeAliasElement) {
- _visitFunctionTypeAliasElement(element);
- } else if (element is LocalVariableElement) {
- _visitLocalVariableElement(element);
- } else if (element is MethodElement) {
- _visitMethodElement(element);
- } else if (element is PropertyAccessorElement) {
- _visitPropertyAccessorElement(element);
- } else if (element is TopLevelVariableElement) {
- _visitTopLevelVariableElement(element);
- }
- }
- }
-
- /// Returns whether the name of [element] consists only of underscore
- /// characters.
- bool _isNamedUnderscore(LocalVariableElement element) {
- String name = element.name;
- if (name != null) {
- for (int index = name.length - 1; index >= 0; --index) {
- if (name.codeUnitAt(index) != 0x5F) {
- // 0x5F => '_'
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- /// Returns whether [element] is a private element which is read somewhere in
- /// the library.
- bool _isReadMember(Element element) {
- if (element.isPublic) {
- return true;
- }
- if (element.isSynthetic) {
- return true;
- }
- if (element is FieldElement) {
- element = (element as FieldElement).getter;
- }
- if (_usedElements.readMembers.contains(element) ||
- _usedElements.unresolvedReadMembers.contains(element.name)) {
- return true;
- }
-
- return _overridesUsedElement(element);
- }
-
- bool _isUsedElement(Element element) {
- if (element.isSynthetic) {
- return true;
- }
- if (element is LocalVariableElement ||
- element is FunctionElement && !element.isStatic) {
- // local variable or function
- } else {
- if (element.isPublic) {
- return true;
- }
- }
- return _usedElements.elements.contains(element);
- }
-
- bool _isUsedMember(Element element) {
- if (element.isPublic) {
- return true;
- }
- if (element.isSynthetic) {
- return true;
- }
- if (_usedElements.members.contains(element)) {
- return true;
- }
- if (_usedElements.elements.contains(element)) {
- return true;
- }
-
- return _overridesUsedElement(element);
- }
-
- // Check if this is a class member which overrides a super class's class
- // member which is used.
- bool _overridesUsedElement(Element element) {
- Element enclosingElement = element.enclosingElement;
- if (enclosingElement is ClassElement) {
- Name name = new Name(_libraryUri, element.name);
- Iterable<ExecutableElement> overriddenElements = _inheritanceManager
- .getOverridden(enclosingElement.thisType, name)
- ?.map((ExecutableElement e) =>
- (e is ExecutableMember) ? e.declaration : e);
- if (overriddenElements != null) {
- return overriddenElements.any((ExecutableElement e) =>
- _usedElements.members.contains(e) || _overridesUsedElement(e));
- }
- }
- return false;
- }
-
- void _reportErrorForElement(
- ErrorCode errorCode, Element element, List<Object> arguments) {
- if (element != null) {
- _errorListener.onError(new AnalysisError(element.source,
- element.nameOffset, element.nameLength, errorCode, arguments));
- }
- }
-
- _visitClassElement(ClassElement element) {
- if (!_isUsedElement(element)) {
- _reportErrorForElement(
- HintCode.UNUSED_ELEMENT, element, [element.displayName]);
- }
- }
-
- _visitFieldElement(FieldElement element) {
- if (!_isReadMember(element)) {
- _reportErrorForElement(
- HintCode.UNUSED_FIELD, element, [element.displayName]);
- }
- }
-
- _visitFunctionElement(FunctionElement element) {
- if (!_isUsedElement(element)) {
- _reportErrorForElement(
- HintCode.UNUSED_ELEMENT, element, [element.displayName]);
- }
- }
-
- _visitFunctionTypeAliasElement(FunctionTypeAliasElement element) {
- if (!_isUsedElement(element)) {
- _reportErrorForElement(
- HintCode.UNUSED_ELEMENT, element, [element.displayName]);
- }
- }
-
- _visitLocalVariableElement(LocalVariableElement element) {
- if (!_isUsedElement(element) && !_isNamedUnderscore(element)) {
- HintCode errorCode;
- if (_usedElements.isCatchException(element)) {
- errorCode = HintCode.UNUSED_CATCH_CLAUSE;
- } else if (_usedElements.isCatchStackTrace(element)) {
- errorCode = HintCode.UNUSED_CATCH_STACK;
- } else {
- errorCode = HintCode.UNUSED_LOCAL_VARIABLE;
- }
- _reportErrorForElement(errorCode, element, [element.displayName]);
- }
- }
-
- _visitMethodElement(MethodElement element) {
- if (!_isUsedMember(element)) {
- _reportErrorForElement(
- HintCode.UNUSED_ELEMENT, element, [element.displayName]);
- }
- }
-
- _visitPropertyAccessorElement(PropertyAccessorElement element) {
- if (!_isUsedMember(element)) {
- _reportErrorForElement(
- HintCode.UNUSED_ELEMENT, element, [element.displayName]);
- }
- }
-
- _visitTopLevelVariableElement(TopLevelVariableElement element) {
- if (!_isUsedElement(element)) {
- _reportErrorForElement(
- HintCode.UNUSED_ELEMENT, element, [element.displayName]);
- }
- }
-}
-
-/// A container with sets of used [Element]s.
-/// All these elements are defined in a single compilation unit or a library.
-class UsedLocalElements {
- /// Resolved, locally defined elements that are used or potentially can be
- /// used.
- final HashSet<Element> elements = new HashSet<Element>();
-
- /// [LocalVariableElement]s that represent exceptions in [CatchClause]s.
- final HashSet<LocalVariableElement> catchExceptionElements =
- new HashSet<LocalVariableElement>();
-
- /// [LocalVariableElement]s that represent stack traces in [CatchClause]s.
- final HashSet<LocalVariableElement> catchStackTraceElements =
- new HashSet<LocalVariableElement>();
-
- /// Resolved class members that are referenced in the library.
- final HashSet<Element> members = new HashSet<Element>();
-
- /// Resolved class members that are read in the library.
- final HashSet<Element> readMembers = new HashSet<Element>();
-
- /// Unresolved class members that are read in the library.
- final HashSet<String> unresolvedReadMembers = new HashSet<String>();
-
- UsedLocalElements();
-
- factory UsedLocalElements.merge(List<UsedLocalElements> parts) {
- UsedLocalElements result = new UsedLocalElements();
- int length = parts.length;
- for (int i = 0; i < length; i++) {
- UsedLocalElements part = parts[i];
- result.elements.addAll(part.elements);
- result.catchExceptionElements.addAll(part.catchExceptionElements);
- result.catchStackTraceElements.addAll(part.catchStackTraceElements);
- result.members.addAll(part.members);
- result.readMembers.addAll(part.readMembers);
- result.unresolvedReadMembers.addAll(part.unresolvedReadMembers);
- }
- return result;
- }
-
- void addCatchException(LocalVariableElement element) {
- if (element != null) {
- catchExceptionElements.add(element);
- }
- }
-
- void addCatchStackTrace(LocalVariableElement element) {
- if (element != null) {
- catchStackTraceElements.add(element);
- }
- }
-
- void addElement(Element element) {
- if (element != null) {
- elements.add(element);
- }
- }
-
- bool isCatchException(LocalVariableElement element) {
- return catchExceptionElements.contains(element);
- }
-
- bool isCatchStackTrace(LocalVariableElement element) {
- return catchStackTraceElements.contains(element);
- }
-}
-
/// Instances of the class `VariableResolverVisitor` are used to resolve
/// [SimpleIdentifier]s to local variables and formal parameters.
class VariableResolverVisitor extends ScopedVisitor {
@@ -6963,223 +4428,6 @@
void visitTypeName(TypeName node) {}
}
-class _InvalidAccessVerifier {
- static final _templateExtension = '.template';
- static final _testDir = '${path.separator}test${path.separator}';
- static final _testingDir = '${path.separator}testing${path.separator}';
-
- final ErrorReporter _errorReporter;
- final LibraryElement _library;
-
- bool _inTemplateSource;
- bool _inTestDirectory;
-
- ClassElement _enclosingClass;
-
- _InvalidAccessVerifier(this._errorReporter, this._library) {
- var path = _library.source.fullName;
- _inTemplateSource = path.contains(_templateExtension);
- _inTestDirectory = path.contains(_testDir) || path.contains(_testingDir);
- }
-
- /// Produces a hint if [identifier] is accessed from an invalid location. In
- /// particular:
- ///
- /// * if the given identifier is a protected closure, field or
- /// getter/setter, method closure or invocation accessed outside a subclass,
- /// or accessed outside the library wherein the identifier is declared, or
- /// * if the given identifier is a closure, field, getter, setter, method
- /// closure or invocation which is annotated with `visibleForTemplate`, and
- /// is accessed outside of the defining library, and the current library
- /// does not have the suffix '.template' in its source path, or
- /// * if the given identifier is a closure, field, getter, setter, method
- /// closure or invocation which is annotated with `visibleForTesting`, and
- /// is accessed outside of the defining library, and the current library
- /// does not have a directory named 'test' or 'testing' in its path.
- void verify(SimpleIdentifier identifier) {
- if (identifier.inDeclarationContext() || _inCommentReference(identifier)) {
- return;
- }
-
- // This is the same logic used in [checkForDeprecatedMemberUseAtIdentifier]
- // to avoid reporting an error twice for named constructors.
- AstNode parent = identifier.parent;
- if (parent is ConstructorName && identical(identifier, parent.name)) {
- return;
- }
- AstNode grandparent = parent?.parent;
- Element element = grandparent is ConstructorName
- ? grandparent.staticElement
- : identifier.staticElement;
- if (element == null || _inCurrentLibrary(element)) {
- return;
- }
-
- bool hasProtected = _hasProtected(element);
- if (hasProtected) {
- ClassElement definingClass = element.enclosingElement;
- if (_hasTypeOrSuperType(_enclosingClass, definingClass)) {
- return;
- }
- }
-
- bool hasVisibleForTemplate = _hasVisibleForTemplate(element);
- if (hasVisibleForTemplate) {
- if (_inTemplateSource || _inExportDirective(identifier)) {
- return;
- }
- }
-
- bool hasVisibleForTesting = _hasVisibleForTesting(element);
- if (hasVisibleForTesting) {
- if (_inTestDirectory || _inExportDirective(identifier)) {
- return;
- }
- }
-
- // At this point, [identifier] was not cleared as protected access, nor
- // cleared as access for templates or testing. Report the appropriate
- // violation(s).
- Element definingClass = element.enclosingElement;
- if (hasProtected) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_USE_OF_PROTECTED_MEMBER,
- identifier,
- [identifier.name, definingClass.source.uri]);
- }
- if (hasVisibleForTemplate) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER,
- identifier,
- [identifier.name, definingClass.source.uri]);
- }
- if (hasVisibleForTesting) {
- _errorReporter.reportErrorForNode(
- HintCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER,
- identifier,
- [identifier.name, definingClass.source.uri]);
- }
- }
-
- bool _hasProtected(Element element) {
- if (element is PropertyAccessorElement &&
- element.enclosingElement is ClassElement &&
- (element.hasProtected || element.variable.hasProtected)) {
- return true;
- }
- if (element is MethodElement &&
- element.enclosingElement is ClassElement &&
- element.hasProtected) {
- return true;
- }
- return false;
- }
-
- bool _hasTypeOrSuperType(ClassElement element, ClassElement superElement) {
- if (element == null) {
- return false;
- }
- if (element == superElement) {
- return true;
- }
- // TODO(scheglov) `allSupertypes` is very expensive
- var allSupertypes = element.allSupertypes;
- for (var i = 0; i < allSupertypes.length; i++) {
- var supertype = allSupertypes[i];
- if (supertype.element == superElement) {
- return true;
- }
- }
- return false;
- }
-
- bool _hasVisibleForTemplate(Element element) {
- if (element == null) {
- return false;
- }
- if (element.hasVisibleForTemplate) {
- return true;
- }
- if (element is PropertyAccessorElement &&
- element.enclosingElement is ClassElement &&
- element.variable.hasVisibleForTemplate) {
- return true;
- }
- return false;
- }
-
- bool _hasVisibleForTesting(Element element) {
- if (element == null) {
- return false;
- }
- if (element.hasVisibleForTesting) {
- return true;
- }
- if (element is PropertyAccessorElement &&
- element.enclosingElement is ClassElement &&
- element.variable.hasVisibleForTesting) {
- return true;
- }
- return false;
- }
-
- bool _inCommentReference(SimpleIdentifier identifier) {
- var parent = identifier.parent;
- return parent is CommentReference || parent?.parent is CommentReference;
- }
-
- bool _inCurrentLibrary(Element element) => element.library == _library;
-
- bool _inExportDirective(SimpleIdentifier identifier) =>
- identifier.parent is Combinator &&
- identifier.parent.parent is ExportDirective;
-}
-
-/// An object used to track the usage of labels within a single label scope.
-class _LabelTracker {
- /// The tracker for the outer label scope.
- final _LabelTracker outerTracker;
-
- /// The labels whose usage is being tracked.
- final List<Label> labels;
-
- /// A list of flags corresponding to the list of [labels] indicating whether
- /// the corresponding label has been used.
- List<bool> used;
-
- /// A map from the names of labels to the index of the label in [labels].
- final Map<String, int> labelMap = <String, int>{};
-
- /// Initialize a newly created label tracker.
- _LabelTracker(this.outerTracker, this.labels) {
- used = new List.filled(labels.length, false);
- for (int i = 0; i < labels.length; i++) {
- labelMap[labels[i].label.name] = i;
- }
- }
-
- /// Record that the label with the given [labelName] has been used.
- void recordUsage(String labelName) {
- if (labelName != null) {
- int index = labelMap[labelName];
- if (index != null) {
- used[index] = true;
- } else if (outerTracker != null) {
- outerTracker.recordUsage(labelName);
- }
- }
- }
-
- /// Return the unused labels.
- Iterable<Label> unusedLabels() sync* {
- for (int i = 0; i < labels.length; i++) {
- if (!used[i]) {
- yield labels[i];
- }
- }
- }
-}
-
/// A set of counts of the kinds of leaf elements in a collection, used to help
/// disambiguate map and set literals.
class _LeafElements {
diff --git a/pkg/analyzer/lib/src/generated/sdk.dart b/pkg/analyzer/lib/src/generated/sdk.dart
index 81ad574..2862d0a 100644
--- a/pkg/analyzer/lib/src/generated/sdk.dart
+++ b/pkg/analyzer/lib/src/generated/sdk.dart
@@ -112,7 +112,7 @@
* A table mapping (an encoding of) analysis options and SDK locations to the
* DartSdk from that location that has been configured with those options.
*/
- Map<SdkDescription, DartSdk> sdkMap = new HashMap<SdkDescription, DartSdk>();
+ Map<SdkDescription, DartSdk> sdkMap = HashMap<SdkDescription, DartSdk>();
/**
* Initialize a newly created manager.
@@ -160,7 +160,7 @@
/**
* Return a list containing all of the sdk libraries in this mapping.
*/
- List<SdkLibrary> get sdkLibraries => new List.from(_libraryMap.values);
+ List<SdkLibrary> get sdkLibraries => List.from(_libraryMap.values);
/**
* Return a list containing the library URI's for which a mapping is available.
@@ -257,7 +257,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
bool needsSeparator = false;
void add(String optionName) {
if (needsSeparator) {
@@ -327,7 +327,7 @@
* The library map that is populated by visiting the AST structure parsed from
* the contents of the libraries file.
*/
- LibraryMap _librariesMap = new LibraryMap();
+ LibraryMap _librariesMap = LibraryMap();
/**
* Return the library map that was populated by visiting the AST structure
@@ -362,7 +362,7 @@
}
Expression value = node.value;
if (value is InstanceCreationExpression) {
- SdkLibraryImpl library = new SdkLibraryImpl(libraryName);
+ SdkLibraryImpl library = SdkLibraryImpl(libraryName);
List<Expression> arguments = value.argumentList.arguments;
for (Expression argument in arguments) {
if (argument is SimpleStringLiteral) {
@@ -508,7 +508,7 @@
/**
* Set whether the library is documented.
*/
- void set documented(bool documented) {
+ set documented(bool documented) {
this._documented = documented;
}
diff --git a/pkg/analyzer/lib/src/generated/sdk_io.dart b/pkg/analyzer/lib/src/generated/sdk_io.dart
index c2c8506..ec3a590 100644
--- a/pkg/analyzer/lib/src/generated/sdk_io.dart
+++ b/pkg/analyzer/lib/src/generated/sdk_io.dart
@@ -25,7 +25,7 @@
/**
* A mapping from Dart library URI's to the library represented by that URI.
*/
- LibraryMap libraryMap = new LibraryMap();
+ LibraryMap libraryMap = LibraryMap();
/**
* The [AnalysisOptions] to use to create the [context].
@@ -41,20 +41,20 @@
/**
* The [AnalysisContext] which is used for all of the sources in this SDK.
*/
- InternalAnalysisContext _analysisContext;
+ SdkAnalysisContext _analysisContext;
/**
* The mapping from Dart URI's to the corresponding sources.
*/
- Map<String, Source> _uriToSourceMap = new HashMap<String, Source>();
+ Map<String, Source> _uriToSourceMap = HashMap<String, Source>();
/**
* Set the [options] for this SDK analysis context. Throw [StateError] if the
* context has been already created.
*/
- void set analysisOptions(AnalysisOptions options) {
+ set analysisOptions(AnalysisOptions options) {
if (_analysisContext != null) {
- throw new StateError(
+ throw StateError(
'Analysis options cannot be changed after context creation.');
}
_analysisOptions = options;
@@ -83,9 +83,9 @@
/**
* Specify whether SDK summary should be used.
*/
- void set useSummary(bool use) {
+ set useSummary(bool use) {
if (_analysisContext != null) {
- throw new StateError(
+ throw StateError(
'The "useSummary" flag cannot be changed after context creation.');
}
_useSummary = use;
@@ -99,7 +99,7 @@
void addExtensions(Map<String, String> extensions) {
extensions.forEach((String uri, String path) {
String shortName = uri.substring(uri.indexOf(':') + 1);
- SdkLibraryImpl library = new SdkLibraryImpl(shortName);
+ SdkLibraryImpl library = SdkLibraryImpl(shortName);
library.path = path;
libraryMap.setLibrary(uri, library);
});
@@ -107,14 +107,14 @@
@override
Source fromFileUri(Uri uri) {
- JavaFile file = new JavaFile.fromUri(uri);
+ JavaFile file = JavaFile.fromUri(uri);
String path = _getPath(file);
if (path == null) {
return null;
}
try {
- return new FileBasedSource(file, Uri.parse(path));
+ return FileBasedSource(file, Uri.parse(path));
} on FormatException catch (exception, stackTrace) {
AnalysisEngine.instance.instrumentationService.logInfo(
"Failed to create URI: $path",
@@ -170,8 +170,8 @@
}
String filePath = srcPath.replaceAll('/', JavaFile.separator);
try {
- JavaFile file = new JavaFile(filePath);
- return new FileBasedSource(file, Uri.parse(dartUri));
+ JavaFile file = JavaFile(filePath);
+ return FileBasedSource(file, Uri.parse(dartUri));
} on FormatException {
return null;
}
@@ -190,7 +190,7 @@
String _getPath(JavaFile file) {
List<SdkLibrary> libraries = libraryMap.sdkLibraries;
int length = libraries.length;
- List<String> paths = new List(length);
+ List<String> paths = List(length);
String filePath = getRelativePathFromFile(file);
if (filePath == null) {
return null;
diff --git a/pkg/analyzer/lib/src/generated/source.dart b/pkg/analyzer/lib/src/generated/source.dart
index 33af032..f7159c5 100644
--- a/pkg/analyzer/lib/src/generated/source.dart
+++ b/pkg/analyzer/lib/src/generated/source.dart
@@ -58,14 +58,14 @@
* A table mapping the full path of sources to the contents of those sources.
* This is used to override the default contents of a source.
*/
- Map<String, String> _contentMap = new HashMap<String, String>();
+ Map<String, String> _contentMap = HashMap<String, String>();
/**
* A table mapping the full path of sources to the modification stamps of
* those sources. This is used when the default contents of a source has been
* overridden.
*/
- Map<String, int> _stampMap = new HashMap<String, int>();
+ Map<String, int> _stampMap = HashMap<String, int>();
int _nextStamp = 0;
@@ -147,11 +147,11 @@
String mapping = _urlMappings[uri.toString()];
if (mapping == null) return null;
- Uri fileUri = new Uri.file(mapping);
+ Uri fileUri = Uri.file(mapping);
if (!fileUri.isAbsolute) return null;
- JavaFile javaFile = new JavaFile.fromUri(fileUri);
- return new FileBasedSource(javaFile, actualUri ?? uri);
+ JavaFile javaFile = JavaFile.fromUri(fileUri);
+ return FileBasedSource(javaFile, actualUri ?? uri);
}
}
@@ -251,7 +251,7 @@
* An implementation of an non-existing [Source].
*/
class NonExistingSource extends Source {
- static final unknown = new NonExistingSource(
+ static final unknown = NonExistingSource(
'/unknown.dart', pathos.toUri('/unknown.dart'), UriKind.FILE_URI);
@override
@@ -267,7 +267,7 @@
@override
TimestampedData<String> get contents {
- throw new UnsupportedError('$fullName does not exist.');
+ throw UnsupportedError('$fullName does not exist.');
}
@override
diff --git a/pkg/analyzer/lib/src/generated/source_io.dart b/pkg/analyzer/lib/src/generated/source_io.dart
index 6ed57e1..ea7e685 100644
--- a/pkg/analyzer/lib/src/generated/source_io.dart
+++ b/pkg/analyzer/lib/src/generated/source_io.dart
@@ -35,7 +35,7 @@
if (file == null) {
return null;
} else {
- return new FileBasedSource(file, actualUri);
+ return FileBasedSource(file, actualUri);
}
}
@@ -73,7 +73,7 @@
* The URI and filepath are joined into a pair by separating them with an '@'
* character.
*/
- static final Map<String, int> _idTable = new HashMap<String, int>();
+ static final Map<String, int> _idTable = HashMap<String, int>();
/**
* The URI from which this source was originally derived.
@@ -131,7 +131,7 @@
* See [contents].
*/
TimestampedData<String> get contentsFromFile {
- return new TimestampedData<String>(
+ return TimestampedData<String>(
file.lastModified(), fileReadMode(file.readAsStringSync()));
}
@@ -209,12 +209,12 @@
if (!isFileUri(uri)) {
return null;
}
- return new FileBasedSource(new JavaFile.fromUri(uri), actualUri ?? uri);
+ return FileBasedSource(JavaFile.fromUri(uri), actualUri ?? uri);
}
@override
Uri restoreAbsolute(Source source) {
- return new Uri.file(source.fullName);
+ return Uri.file(source.fullName);
}
/**
@@ -234,19 +234,18 @@
/**
* Instance of [LocalSourcePredicate] that always returns `false`.
*/
- static final LocalSourcePredicate FALSE = new LocalSourcePredicate_FALSE();
+ static final LocalSourcePredicate FALSE = LocalSourcePredicate_FALSE();
/**
* Instance of [LocalSourcePredicate] that always returns `true`.
*/
- static final LocalSourcePredicate TRUE = new LocalSourcePredicate_TRUE();
+ static final LocalSourcePredicate TRUE = LocalSourcePredicate_TRUE();
/**
* Instance of [LocalSourcePredicate] that returns `true` for all [Source]s
* except of SDK.
*/
- static final LocalSourcePredicate NOT_SDK =
- new LocalSourcePredicate_NOT_SDK();
+ static final LocalSourcePredicate NOT_SDK = LocalSourcePredicate_NOT_SDK();
/**
* Determines if the given [Source] is local.
@@ -306,8 +305,7 @@
*/
PackageUriResolver(this._packagesDirectories) {
if (_packagesDirectories.isEmpty) {
- throw new ArgumentError(
- "At least one package directory must be provided");
+ throw ArgumentError("At least one package directory must be provided");
}
}
@@ -318,7 +316,7 @@
String get packagesDirectory_forTesting {
int length = _packagesDirectories.length;
if (length != 1) {
- throw new Exception('Expected 1 package directory, found $length');
+ throw Exception('Expected 1 package directory, found $length');
}
return _packagesDirectories[0].getPath();
}
@@ -334,27 +332,25 @@
*/
JavaFile getCanonicalFile(
JavaFile packagesDirectory, String pkgName, String relPath) {
- JavaFile pkgDir = new JavaFile.relative(packagesDirectory, pkgName);
+ JavaFile pkgDir = JavaFile.relative(packagesDirectory, pkgName);
try {
pkgDir = pkgDir.getCanonicalFile();
} catch (exception, stackTrace) {
if (!exception.toString().contains("Required key not available")) {
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(
+ SilentException(
"Canonical failed: $pkgDir", exception, stackTrace));
} else if (_CanLogRequiredKeyIoException) {
_CanLogRequiredKeyIoException = false;
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
- new SilentException(
+ SilentException(
"Canonical failed: $pkgDir", exception, stackTrace));
}
}
- return new JavaFile.relative(
- pkgDir,
- relPath.replaceAll(
- '/', new String.fromCharCode(JavaFile.separatorChar)));
+ return JavaFile.relative(pkgDir,
+ relPath.replaceAll('/', String.fromCharCode(JavaFile.separatorChar)));
}
@override
@@ -385,20 +381,20 @@
relPath = path.substring(index + 1);
}
for (JavaFile packagesDirectory in _packagesDirectories) {
- JavaFile resolvedFile = new JavaFile.relative(packagesDirectory, path);
+ JavaFile resolvedFile = JavaFile.relative(packagesDirectory, path);
if (resolvedFile.exists()) {
JavaFile canonicalFile =
getCanonicalFile(packagesDirectory, pkgName, relPath);
if (actualUri != null) {
- return new FileBasedSource(canonicalFile, actualUri);
+ return FileBasedSource(canonicalFile, actualUri);
}
if (_isSelfReference(packagesDirectory, canonicalFile)) {
uri = canonicalFile.toURI();
}
- return new FileBasedSource(canonicalFile, uri);
+ return FileBasedSource(canonicalFile, uri);
}
}
- return new FileBasedSource(
+ return FileBasedSource(
getCanonicalFile(_packagesDirectories[0], pkgName, relPath),
actualUri ?? uri);
}
@@ -491,9 +487,9 @@
if (uriPath != null && uriPath.startsWith(rootPath)) {
String filePath = uri.path.substring(rootPath.length);
for (JavaFile dir in _relativeDirectories) {
- JavaFile file = new JavaFile.relative(dir, filePath);
+ JavaFile file = JavaFile.relative(dir, filePath);
if (file.exists()) {
- return new FileBasedSource(file, actualUri ?? uri);
+ return FileBasedSource(file, actualUri ?? uri);
}
}
}
diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
index f6872ad..5a367b1 100644
--- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
+++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
@@ -204,7 +204,7 @@
return inferred;
}
- DartType inferListType(ListLiteral node, {bool downwards: false}) {
+ DartType inferListType(ListLiteral node, {bool downwards = false}) {
DartType contextType = InferenceContext.getContext(node);
var element = _typeProvider.listElement;
@@ -403,13 +403,11 @@
operator,
node.rightHandSide.staticType,
type,
- _featureSet,
);
_recordStaticType(node, type);
var leftWriteType = _getStaticType(node.leftHandSide);
- if (!_typeSystem.isAssignableTo(type, leftWriteType,
- featureSet: _featureSet)) {
+ if (!_typeSystem.isAssignableTo(type, leftWriteType)) {
_resolver.errorReporter.reportTypeErrorForNode(
StaticTypeWarningCode.INVALID_ASSIGNMENT,
node.rightHandSide,
@@ -504,11 +502,11 @@
DartType staticType = node.staticInvokeType?.returnType ?? _dynamicType;
if (node.leftOperand is! ExtensionOverride) {
staticType = _typeSystem.refineBinaryExpressionType(
- node.leftOperand.staticType,
- node.operator.type,
- node.rightOperand.staticType,
- staticType,
- _featureSet);
+ node.leftOperand.staticType,
+ node.operator.type,
+ node.rightOperand.staticType,
+ staticType,
+ );
}
_recordStaticType(node, staticType);
}
@@ -699,10 +697,8 @@
var context = InferenceContext.getContext(
(node as IntegerLiteralImpl).immediatelyNegated ? node.parent : node);
if (context == null ||
- _typeSystem.isAssignableTo(_typeProvider.intType, context,
- featureSet: _featureSet) ||
- !_typeSystem.isAssignableTo(_typeProvider.doubleType, context,
- featureSet: _featureSet)) {
+ _typeSystem.isAssignableTo(_typeProvider.intType, context) ||
+ !_typeSystem.isAssignableTo(_typeProvider.doubleType, context)) {
_recordStaticType(node, _nonNullable(_typeProvider.intType));
} else {
_recordStaticType(node, _nonNullable(_typeProvider.doubleType));
@@ -1255,7 +1251,7 @@
*/
void _analyzeLeastUpperBound(
Expression node, Expression expr1, Expression expr2,
- {bool read: false}) {
+ {bool read = false}) {
DartType staticType1 = _getExpressionType(expr1, read: read);
DartType staticType2 = _getExpressionType(expr2, read: read);
@@ -1292,8 +1288,7 @@
void _checkForInvalidAssignmentIncDec(
AstNode node, Expression operand, DartType type) {
var operandWriteType = _getStaticType(operand);
- if (!_typeSystem.isAssignableTo(type, operandWriteType,
- featureSet: _featureSet)) {
+ if (!_typeSystem.isAssignableTo(type, operandWriteType)) {
_resolver.errorReporter.reportTypeErrorForNode(
StaticTypeWarningCode.INVALID_ASSIGNMENT,
node,
@@ -1464,7 +1459,7 @@
* See [getExpressionType] for more information. Without strong mode, this is
* equivalent to [_getStaticType].
*/
- DartType _getExpressionType(Expression expr, {bool read: false}) =>
+ DartType _getExpressionType(Expression expr, {bool read = false}) =>
getExpressionType(expr, _typeSystem, _typeProvider, read: read);
/**
@@ -1488,7 +1483,7 @@
/**
* Return the static type of the given [expression].
*/
- DartType _getStaticType(Expression expression, {bool read: false}) {
+ DartType _getStaticType(Expression expression, {bool read = false}) {
DartType type;
if (read) {
type = getReadType(expression);
@@ -1657,7 +1652,7 @@
TypeArgumentList typeArguments,
ArgumentList argumentList,
AstNode errorNode,
- {bool isConst: false}) {
+ {bool isConst = false}) {
if (typeArguments == null &&
fnType is FunctionType &&
fnType.typeFormals.isNotEmpty) {
diff --git a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
index a041a8a..6110c20 100644
--- a/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart
@@ -284,9 +284,9 @@
beginToken: TokenFactory.tokenFromType(TokenType.EOF),
scriptTag:
scriptTag == null ? null : AstTestFactory.scriptTag(scriptTag),
- directives: directives == null ? new List<Directive>() : directives,
+ directives: directives == null ? List<Directive>() : directives,
declarations: declarations == null
- ? new List<CompilationUnitMember>()
+ ? List<CompilationUnitMember>()
: declarations,
endToken: TokenFactory.tokenFromType(TokenType.EOF),
featureSet: null);
@@ -300,9 +300,9 @@
beginToken: TokenFactory.tokenFromType(TokenType.EOF),
scriptTag:
scriptTag == null ? null : AstTestFactory.scriptTag(scriptTag),
- directives: directives == null ? new List<Directive>() : directives,
+ directives: directives == null ? List<Directive>() : directives,
declarations: declarations == null
- ? new List<CompilationUnitMember>()
+ ? List<CompilationUnitMember>()
: declarations,
endToken: TokenFactory.tokenFromType(TokenType.EOF),
featureSet: featureSet);
@@ -334,9 +334,7 @@
initializers == null || initializers.isEmpty
? null
: TokenFactory.tokenFromType(TokenType.PERIOD),
- initializers == null
- ? new List<ConstructorInitializer>()
- : initializers,
+ initializers == null ? List<ConstructorInitializer>() : initializers,
null,
emptyFunctionBody());
@@ -365,9 +363,7 @@
initializers == null || initializers.isEmpty
? null
: TokenFactory.tokenFromType(TokenType.PERIOD),
- initializers == null
- ? new List<ConstructorInitializer>()
- : initializers,
+ initializers == null ? List<ConstructorInitializer>() : initializers,
null,
body);
@@ -453,7 +449,7 @@
String name, List<String> constantNames) {
int count = constantNames.length;
List<EnumConstantDeclaration> constants =
- new List<EnumConstantDeclaration>(count);
+ List<EnumConstantDeclaration>(count);
for (int i = 0; i < count; i++) {
constants[i] = astFactory.enumConstantDeclaration(
null, null, identifier3(constantNames[i]));
@@ -560,7 +556,7 @@
static ForElement forElement(
ForLoopParts forLoopParts, CollectionElement body,
- {bool hasAwait: false}) =>
+ {bool hasAwait = false}) =>
astFactory.forElement(
awaitKeyword:
hasAwait ? TokenFactory.tokenFromKeyword(Keyword.AWAIT) : null,
@@ -666,7 +662,7 @@
static GenericFunctionType genericFunctionType(TypeAnnotation returnType,
TypeParameterList typeParameters, FormalParameterList parameters,
- {bool question: false}) =>
+ {bool question = false}) =>
astFactory.genericFunctionType(returnType,
TokenFactory.tokenFromString("Function"), typeParameters, parameters,
question:
@@ -871,8 +867,7 @@
TokenFactory.tokenFromType(TokenType.SEMICOLON));
static LibraryDirective libraryDirective2(String libraryName) =>
- libraryDirective(
- new List<Annotation>(), libraryIdentifier2([libraryName]));
+ libraryDirective(List<Annotation>(), libraryIdentifier2([libraryName]));
static LibraryIdentifier libraryIdentifier(
List<SimpleIdentifier> components) =>
@@ -975,11 +970,11 @@
body);
static MethodDeclaration methodDeclaration4(
- {bool external: false,
+ {bool external = false,
Keyword modifier,
TypeAnnotation returnType,
Keyword property,
- bool operator: false,
+ bool operator = false,
String name,
FormalParameterList parameters,
FunctionBody body}) =>
@@ -1067,10 +1062,10 @@
TokenFactory.tokenFromType(TokenType.SEMICOLON));
static PartDirective partDirective2(String url) =>
- partDirective(new List<Annotation>(), url);
+ partDirective(List<Annotation>(), url);
static PartOfDirective partOfDirective(LibraryIdentifier libraryName) =>
- partOfDirective2(new List<Annotation>(), libraryName);
+ partOfDirective2(List<Annotation>(), libraryName);
static PartOfDirective partOfDirective2(
List<Annotation> metadata, LibraryIdentifier libraryName) =>
@@ -1204,7 +1199,7 @@
static SwitchCase switchCase(
Expression expression, List<Statement> statements) =>
- switchCase2(new List<Label>(), expression, statements);
+ switchCase2(List<Label>(), expression, statements);
static SwitchCase switchCase2(List<Label> labels, Expression expression,
List<Statement> statements) =>
@@ -1220,7 +1215,7 @@
statements);
static SwitchDefault switchDefault2(List<Statement> statements) =>
- switchDefault(new List<Label>(), statements);
+ switchDefault(List<Label>(), statements);
static SwitchStatement switchStatement(
Expression expression, List<SwitchMember> members) =>
@@ -1234,7 +1229,7 @@
TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET));
static SymbolLiteral symbolLiteral(List<String> components) {
- List<Token> identifierList = new List<Token>();
+ List<Token> identifierList = List<Token>();
for (String component in components) {
identifierList.add(
TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, component));
@@ -1285,7 +1280,7 @@
TokenFactory.tokenFromType(TokenType.SEMICOLON));
static TryStatement tryStatement(Block body, Block finallyClause) =>
- tryStatement3(body, new List<CatchClause>(), finallyClause);
+ tryStatement3(body, List<CatchClause>(), finallyClause);
static TryStatement tryStatement2(
Block body, List<CatchClause> catchClauses) =>
@@ -1375,7 +1370,7 @@
static TypeParameterList typeParameterList([List<String> typeNames]) {
List<TypeParameter> typeParameters;
if (typeNames != null && typeNames.isNotEmpty) {
- typeParameters = new List<TypeParameter>();
+ typeParameters = List<TypeParameter>();
for (String typeName in typeNames) {
typeParameters.add(typeParameter(typeName));
}
diff --git a/pkg/analyzer/lib/src/generated/testing/element_factory.dart b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
index 05ea5ae..287da16 100644
--- a/pkg/analyzer/lib/src/generated/testing/element_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
@@ -50,7 +50,7 @@
static ClassElementImpl classElement(
String typeName, InterfaceType superclassType,
[List<String> parameterNames]) {
- ClassElementImpl element = new ClassElementImpl(typeName, 0);
+ ClassElementImpl element = ClassElementImpl(typeName, 0);
element.constructors = const <ConstructorElement>[];
element.supertype = superclassType;
if (parameterNames != null) {
@@ -98,8 +98,8 @@
static CompilationUnitElementImpl compilationUnit(String fileName,
[Source librarySource]) {
Source source =
- new NonExistingSource(fileName, toUri(fileName), UriKind.FILE_URI);
- CompilationUnitElementImpl unit = new CompilationUnitElementImpl();
+ NonExistingSource(fileName, toUri(fileName), UriKind.FILE_URI);
+ CompilationUnitElementImpl unit = CompilationUnitElementImpl();
unit.source = source;
if (librarySource == null) {
librarySource = source;
@@ -109,14 +109,14 @@
}
static ConstLocalVariableElementImpl constLocalVariableElement(String name) =>
- new ConstLocalVariableElementImpl(name, 0);
+ ConstLocalVariableElementImpl(name, 0);
static ConstructorElementImpl constructorElement(
ClassElement definingClass, String name, bool isConst,
[List<DartType> argumentTypes]) {
ConstructorElementImpl constructor = name == null
- ? new ConstructorElementImpl("", -1)
- : new ConstructorElementImpl(name, 0);
+ ? ConstructorElementImpl("", -1)
+ : ConstructorElementImpl(name, 0);
if (name != null) {
if (name.isEmpty) {
constructor.nameEnd = definingClass.name.length;
@@ -129,9 +129,9 @@
constructor.isConst = isConst;
if (argumentTypes != null) {
int count = argumentTypes.length;
- List<ParameterElement> parameters = new List<ParameterElement>(count);
+ List<ParameterElement> parameters = List<ParameterElement>(count);
for (int i = 0; i < count; i++) {
- ParameterElementImpl parameter = new ParameterElementImpl("a$i", i);
+ ParameterElementImpl parameter = ParameterElementImpl("a$i", i);
parameter.type = argumentTypes[i];
parameter.parameterKind = ParameterKind.REQUIRED;
parameters[i] = parameter;
@@ -157,7 +157,7 @@
//
// Build the enum.
//
- EnumElementImpl enumElement = new EnumElementImpl(enumName, -1);
+ EnumElementImpl enumElement = EnumElementImpl(enumName, -1);
InterfaceTypeImpl enumType = enumElement.instantiate(
typeArguments: const [],
nullabilitySuffix: NullabilitySuffix.star,
@@ -165,20 +165,20 @@
//
// Populate the fields.
//
- List<FieldElement> fields = new List<FieldElement>();
+ List<FieldElement> fields = List<FieldElement>();
InterfaceType intType = typeProvider.intType;
InterfaceType stringType = typeProvider.stringType;
String indexFieldName = "index";
- FieldElementImpl indexField = new FieldElementImpl(indexFieldName, -1);
+ FieldElementImpl indexField = FieldElementImpl(indexFieldName, -1);
indexField.isFinal = true;
indexField.type = intType;
fields.add(indexField);
String nameFieldName = "_name";
- FieldElementImpl nameField = new FieldElementImpl(nameFieldName, -1);
+ FieldElementImpl nameField = FieldElementImpl(nameFieldName, -1);
nameField.isFinal = true;
nameField.type = stringType;
fields.add(nameField);
- FieldElementImpl valuesField = new FieldElementImpl("values", -1);
+ FieldElementImpl valuesField = FieldElementImpl("values", -1);
valuesField.isStatic = true;
valuesField.isConst = true;
valuesField.type = typeProvider.listType2(enumType);
@@ -191,18 +191,17 @@
for (int i = 0; i < constantCount; i++) {
String constantName = constantNames[i];
FieldElementImpl constantElement =
- new ConstFieldElementImpl(constantName, -1);
+ ConstFieldElementImpl(constantName, -1);
constantElement.isStatic = true;
constantElement.isConst = true;
constantElement.type = enumType;
Map<String, DartObjectImpl> fieldMap =
- new HashMap<String, DartObjectImpl>();
- fieldMap[indexFieldName] = new DartObjectImpl(intType, new IntState(i));
+ HashMap<String, DartObjectImpl>();
+ fieldMap[indexFieldName] = DartObjectImpl(intType, IntState(i));
fieldMap[nameFieldName] =
- new DartObjectImpl(stringType, new StringState(constantName));
- DartObjectImpl value =
- new DartObjectImpl(enumType, new GenericState(fieldMap));
- constantElement.evaluationResult = new EvaluationResultImpl(value);
+ DartObjectImpl(stringType, StringState(constantName));
+ DartObjectImpl value = DartObjectImpl(enumType, GenericState(fieldMap));
+ constantElement.evaluationResult = EvaluationResultImpl(value);
fields.add(constantElement);
}
}
@@ -216,7 +215,7 @@
static ExportElementImpl exportFor(LibraryElement exportedLibrary,
[List<NamespaceCombinator> combinators = const <NamespaceCombinator>[]]) {
- ExportElementImpl spec = new ExportElementImpl(-1);
+ ExportElementImpl spec = ExportElementImpl(-1);
spec.exportedLibrary = exportedLibrary;
spec.combinators = combinators;
return spec;
@@ -229,9 +228,8 @@
static FieldElementImpl fieldElement(
String name, bool isStatic, bool isFinal, bool isConst, DartType type,
{Expression initializer}) {
- FieldElementImpl field = isConst
- ? new ConstFieldElementImpl(name, 0)
- : new FieldElementImpl(name, 0);
+ FieldElementImpl field =
+ isConst ? ConstFieldElementImpl(name, 0) : FieldElementImpl(name, 0);
field.isConst = isConst;
field.isFinal = isFinal;
field.isStatic = isStatic;
@@ -239,16 +237,16 @@
if (isConst) {
(field as ConstFieldElementImpl).constantInitializer = initializer;
}
- new PropertyAccessorElementImpl_ImplicitGetter(field);
+ PropertyAccessorElementImpl_ImplicitGetter(field);
if (!isConst && !isFinal) {
- new PropertyAccessorElementImpl_ImplicitSetter(field);
+ PropertyAccessorElementImpl_ImplicitSetter(field);
}
return field;
}
static FieldFormalParameterElementImpl fieldFormalParameter(
Identifier name) =>
- new FieldFormalParameterElementImpl(name.name, name.offset);
+ FieldFormalParameterElementImpl(name.name, name.offset);
/**
* Destroy any static state retained by [ElementFactory]. This should be
@@ -272,17 +270,16 @@
List<TypeDefiningElement> normalParameters,
List<TypeDefiningElement> optionalParameters) {
// We don't create parameter elements because we don't have parameter names
- FunctionElementImpl functionElement =
- new FunctionElementImpl(functionName, 0);
+ FunctionElementImpl functionElement = FunctionElementImpl(functionName, 0);
functionElement.returnType = returnType ?? VoidTypeImpl.instance;
// parameters
int normalCount = normalParameters == null ? 0 : normalParameters.length;
int optionalCount =
optionalParameters == null ? 0 : optionalParameters.length;
int totalCount = normalCount + optionalCount;
- List<ParameterElement> parameters = new List<ParameterElement>(totalCount);
+ List<ParameterElement> parameters = List<ParameterElement>(totalCount);
for (int i = 0; i < totalCount; i++) {
- ParameterElementImpl parameter = new ParameterElementImpl("a$i", i);
+ ParameterElementImpl parameter = ParameterElementImpl("a$i", i);
if (i < normalCount) {
parameter.type = _typeDefiningElementType(normalParameters[i]);
parameter.parameterKind = ParameterKind.REQUIRED;
@@ -304,27 +301,26 @@
List<ClassElement> normalParameters,
List<String> names,
List<ClassElement> namedParameters) {
- FunctionElementImpl functionElement =
- new FunctionElementImpl(functionName, 0);
+ FunctionElementImpl functionElement = FunctionElementImpl(functionName, 0);
// parameters
int normalCount = normalParameters == null ? 0 : normalParameters.length;
int nameCount = names == null ? 0 : names.length;
int typeCount = namedParameters == null ? 0 : namedParameters.length;
if (names != null && nameCount != typeCount) {
- throw new StateError(
+ throw StateError(
"The passed String[] and ClassElement[] arrays had different lengths.");
}
int totalCount = normalCount + nameCount;
- List<ParameterElement> parameters = new List<ParameterElement>(totalCount);
+ List<ParameterElement> parameters = List<ParameterElement>(totalCount);
for (int i = 0; i < totalCount; i++) {
if (i < normalCount) {
- ParameterElementImpl parameter = new ParameterElementImpl("a$i", i);
+ ParameterElementImpl parameter = ParameterElementImpl("a$i", i);
parameter.type = _typeDefiningElementType(normalParameters[i]);
parameter.parameterKind = ParameterKind.REQUIRED;
parameters[i] = parameter;
} else {
ParameterElementImpl parameter =
- new ParameterElementImpl(names[i - normalCount], i);
+ ParameterElementImpl(names[i - normalCount], i);
parameter.type =
_typeDefiningElementType(namedParameters[i - normalCount]);
parameter.parameterKind = ParameterKind.NAMED;
@@ -363,10 +359,9 @@
static FunctionElementImpl functionElement8(
List<DartType> parameters, DartType returnType,
{List<DartType> optional, Map<String, DartType> named}) {
- List<ParameterElement> parameterElements = new List<ParameterElement>();
+ List<ParameterElement> parameterElements = List<ParameterElement>();
for (int i = 0; i < parameters.length; i++) {
- ParameterElementImpl parameterElement =
- new ParameterElementImpl("a$i", i);
+ ParameterElementImpl parameterElement = ParameterElementImpl("a$i", i);
parameterElement.type = parameters[i];
parameterElement.parameterKind = ParameterKind.REQUIRED;
parameterElements.add(parameterElement);
@@ -374,8 +369,7 @@
if (optional != null) {
int j = parameters.length;
for (int i = 0; i < optional.length; i++) {
- ParameterElementImpl parameterElement =
- new ParameterElementImpl("o$i", j);
+ ParameterElementImpl parameterElement = ParameterElementImpl("o$i", j);
parameterElement.type = optional[i];
parameterElement.parameterKind = ParameterKind.POSITIONAL;
parameterElements.add(parameterElement);
@@ -384,7 +378,7 @@
} else if (named != null) {
int j = parameters.length;
for (String s in named.keys) {
- ParameterElementImpl parameterElement = new ParameterElementImpl(s, j);
+ ParameterElementImpl parameterElement = ParameterElementImpl(s, j);
parameterElement.type = named[s];
parameterElement.parameterKind = ParameterKind.NAMED;
parameterElements.add(parameterElement);
@@ -396,8 +390,7 @@
static FunctionElementImpl functionElementWithParameters(String functionName,
DartType returnType, List<ParameterElement> parameters) {
- FunctionElementImpl functionElement =
- new FunctionElementImpl(functionName, 0);
+ FunctionElementImpl functionElement = FunctionElementImpl(functionName, 0);
functionElement.returnType =
returnType == null ? VoidTypeImpl.instance : returnType;
functionElement.parameters = parameters;
@@ -405,9 +398,9 @@
}
static GenericTypeAliasElementImpl genericTypeAliasElement(String name,
- {List<ParameterElement> parameters: const [], DartType returnType}) {
- var element = new GenericTypeAliasElementImpl(name, -1);
- element.function = new GenericFunctionTypeElementImpl.forOffset(-1)
+ {List<ParameterElement> parameters = const [], DartType returnType}) {
+ var element = GenericTypeAliasElementImpl(name, -1);
+ element.function = GenericFunctionTypeElementImpl.forOffset(-1)
..parameters = parameters
..returnType = returnType ?? DynamicTypeImpl.instance;
return element;
@@ -415,13 +408,12 @@
static PropertyAccessorElementImpl getterElement(
String name, bool isStatic, DartType type) {
- FieldElementImpl field = new FieldElementImpl(name, -1);
+ FieldElementImpl field = FieldElementImpl(name, -1);
field.isStatic = isStatic;
field.isSynthetic = true;
field.type = type;
field.isFinal = true;
- PropertyAccessorElementImpl getter =
- new PropertyAccessorElementImpl(name, 0);
+ PropertyAccessorElementImpl getter = PropertyAccessorElementImpl(name, 0);
getter.isSynthetic = false;
getter.getter = true;
getter.variable = field;
@@ -434,7 +426,7 @@
static ImportElementImpl importFor(
LibraryElement importedLibrary, PrefixElement prefix,
[List<NamespaceCombinator> combinators = const <NamespaceCombinator>[]]) {
- ImportElementImpl spec = new ImportElementImpl(0);
+ ImportElementImpl spec = ImportElementImpl(0);
spec.importedLibrary = importedLibrary;
spec.prefix = prefix;
spec.combinators = combinators;
@@ -442,31 +434,31 @@
}
static LibraryElementImpl library(AnalysisContext context, String libraryName,
- {bool isNonNullableByDefault: true}) {
+ {bool isNonNullableByDefault = true}) {
String fileName = "/$libraryName.dart";
CompilationUnitElementImpl unit = compilationUnit(fileName);
- LibraryElementImpl library = new LibraryElementImpl(context, null,
- libraryName, 0, libraryName.length, isNonNullableByDefault);
+ LibraryElementImpl library = LibraryElementImpl(context, null, libraryName,
+ 0, libraryName.length, isNonNullableByDefault);
library.definingCompilationUnit = unit;
return library;
}
static LocalVariableElementImpl localVariableElement(Identifier name) =>
- new LocalVariableElementImpl(name.name, name.offset);
+ LocalVariableElementImpl(name.name, name.offset);
static LocalVariableElementImpl localVariableElement2(String name) =>
- new LocalVariableElementImpl(name, 0);
+ LocalVariableElementImpl(name, 0);
static MethodElementImpl methodElement(String methodName, DartType returnType,
[List<DartType> argumentTypes]) {
- MethodElementImpl method = new MethodElementImpl(methodName, 0);
+ MethodElementImpl method = MethodElementImpl(methodName, 0);
if (argumentTypes == null) {
method.parameters = const <ParameterElement>[];
} else {
int count = argumentTypes.length;
- List<ParameterElement> parameters = new List<ParameterElement>(count);
+ List<ParameterElement> parameters = List<ParameterElement>(count);
for (int i = 0; i < count; i++) {
- ParameterElementImpl parameter = new ParameterElementImpl("a$i", i);
+ ParameterElementImpl parameter = ParameterElementImpl("a$i", i);
parameter.type = argumentTypes[i];
parameter.parameterKind = ParameterKind.REQUIRED;
parameters[i] = parameter;
@@ -482,7 +474,7 @@
String methodName,
DartType returnType,
List<ParameterElement> parameters) {
- MethodElementImpl method = new MethodElementImpl(methodName, 0);
+ MethodElementImpl method = MethodElementImpl(methodName, 0);
method.enclosingElement = enclosingElement;
method.parameters = parameters;
method.returnType = returnType;
@@ -511,13 +503,13 @@
}
static ParameterElementImpl namedParameter(String name) {
- ParameterElementImpl parameter = new ParameterElementImpl(name, 0);
+ ParameterElementImpl parameter = ParameterElementImpl(name, 0);
parameter.parameterKind = ParameterKind.NAMED;
return parameter;
}
static ParameterElementImpl namedParameter2(String name, DartType type) {
- ParameterElementImpl parameter = new ParameterElementImpl(name, 0);
+ ParameterElementImpl parameter = ParameterElementImpl(name, 0);
parameter.parameterKind = ParameterKind.NAMED;
parameter.type = type;
return parameter;
@@ -526,7 +518,7 @@
static ParameterElementImpl namedParameter3(String name,
{DartType type, Expression initializer, String initializerCode}) {
DefaultParameterElementImpl parameter =
- new DefaultParameterElementImpl(name, 0);
+ DefaultParameterElementImpl(name, 0);
parameter.parameterKind = ParameterKind.NAMED;
parameter.type = type;
parameter.constantInitializer = initializer;
@@ -535,29 +527,28 @@
}
static ParameterElementImpl positionalParameter(String name) {
- ParameterElementImpl parameter = new ParameterElementImpl(name, 0);
+ ParameterElementImpl parameter = ParameterElementImpl(name, 0);
parameter.parameterKind = ParameterKind.POSITIONAL;
return parameter;
}
static ParameterElementImpl positionalParameter2(String name, DartType type) {
- ParameterElementImpl parameter = new ParameterElementImpl(name, 0);
+ ParameterElementImpl parameter = ParameterElementImpl(name, 0);
parameter.parameterKind = ParameterKind.POSITIONAL;
parameter.type = type;
return parameter;
}
- static PrefixElementImpl prefix(String name) =>
- new PrefixElementImpl(name, 0);
+ static PrefixElementImpl prefix(String name) => PrefixElementImpl(name, 0);
static ParameterElementImpl requiredParameter(String name) {
- ParameterElementImpl parameter = new ParameterElementImpl(name, 0);
+ ParameterElementImpl parameter = ParameterElementImpl(name, 0);
parameter.parameterKind = ParameterKind.REQUIRED;
return parameter;
}
static ParameterElementImpl requiredParameter2(String name, DartType type) {
- ParameterElementImpl parameter = new ParameterElementImpl(name, 0);
+ ParameterElementImpl parameter = ParameterElementImpl(name, 0);
parameter.parameterKind = ParameterKind.REQUIRED;
parameter.type = type;
return parameter;
@@ -565,19 +556,17 @@
static PropertyAccessorElementImpl setterElement(
String name, bool isStatic, DartType type) {
- FieldElementImpl field = new FieldElementImpl(name, -1);
+ FieldElementImpl field = FieldElementImpl(name, -1);
field.isStatic = isStatic;
field.isSynthetic = true;
field.type = type;
- PropertyAccessorElementImpl getter =
- new PropertyAccessorElementImpl(name, -1);
+ PropertyAccessorElementImpl getter = PropertyAccessorElementImpl(name, -1);
getter.getter = true;
getter.variable = field;
getter.returnType = type;
field.getter = getter;
ParameterElementImpl parameter = requiredParameter2("a", type);
- PropertyAccessorElementImpl setter =
- new PropertyAccessorElementImpl(name, -1);
+ PropertyAccessorElementImpl setter = PropertyAccessorElementImpl(name, -1);
setter.setter = true;
setter.isSynthetic = true;
setter.variable = field;
@@ -589,7 +578,7 @@
}
static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) =>
- new TopLevelVariableElementImpl(name.name, name.offset);
+ TopLevelVariableElementImpl(name.name, name.offset);
static TopLevelVariableElementImpl topLevelVariableElement2(String name) =>
topLevelVariableElement3(name, false, false, null);
@@ -599,7 +588,7 @@
TopLevelVariableElementImpl variable;
if (isConst) {
ConstTopLevelVariableElementImpl constant =
- new ConstTopLevelVariableElementImpl(name, -1);
+ ConstTopLevelVariableElementImpl(name, -1);
InstanceCreationExpression initializer =
AstTestFactory.instanceCreationExpression2(
Keyword.CONST, AstTestFactory.typeName(type.element));
@@ -611,21 +600,21 @@
constant.constantInitializer = initializer;
variable = constant;
} else {
- variable = new TopLevelVariableElementImpl(name, -1);
+ variable = TopLevelVariableElementImpl(name, -1);
}
variable.isConst = isConst;
variable.isFinal = isFinal;
variable.isSynthetic = false;
variable.type = type;
- new PropertyAccessorElementImpl_ImplicitGetter(variable);
+ PropertyAccessorElementImpl_ImplicitGetter(variable);
if (!isConst && !isFinal) {
- new PropertyAccessorElementImpl_ImplicitSetter(variable);
+ PropertyAccessorElementImpl_ImplicitSetter(variable);
}
return variable;
}
static TypeParameterElementImpl typeParameterElement(String name) {
- return new TypeParameterElementImpl(name, 0);
+ return TypeParameterElementImpl(name, 0);
}
static List<TypeParameterElement> typeParameters(List<String> names) {
@@ -634,7 +623,7 @@
return const <TypeParameterElement>[];
}
List<TypeParameterElementImpl> typeParameters =
- new List<TypeParameterElementImpl>(count);
+ List<TypeParameterElementImpl>(count);
for (int i = 0; i < count; i++) {
typeParameters[i] = typeParameterWithType(names[i]);
}
diff --git a/pkg/analyzer/lib/src/generated/testing/element_search.dart b/pkg/analyzer/lib/src/generated/testing/element_search.dart
index c6c7a8f..053724e 100644
--- a/pkg/analyzer/lib/src/generated/testing/element_search.dart
+++ b/pkg/analyzer/lib/src/generated/testing/element_search.dart
@@ -10,7 +10,7 @@
* Search the [unit] for the [Element]s with the given [name].
*/
List<Element> findElementsByName(CompilationUnit unit, String name) {
- var finder = new _ElementsByNameFinder(name);
+ var finder = _ElementsByNameFinder(name);
unit.accept(finder);
return finder.elements;
}
diff --git a/pkg/analyzer/lib/src/generated/testing/node_search.dart b/pkg/analyzer/lib/src/generated/testing/node_search.dart
index e1fe5f6..92743c7 100644
--- a/pkg/analyzer/lib/src/generated/testing/node_search.dart
+++ b/pkg/analyzer/lib/src/generated/testing/node_search.dart
@@ -10,7 +10,7 @@
*/
List<SimpleIdentifier> findDeclaredIdentifiersByName(
CompilationUnit unit, String name) {
- var finder = new _DeclaredIdentifiersByNameFinder(name);
+ var finder = _DeclaredIdentifiersByNameFinder(name);
unit.accept(finder);
return finder.identifiers;
}
diff --git a/pkg/analyzer/lib/src/generated/testing/token_factory.dart b/pkg/analyzer/lib/src/generated/testing/token_factory.dart
index afea98e..4f10dfe 100644
--- a/pkg/analyzer/lib/src/generated/testing/token_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/token_factory.dart
@@ -9,14 +9,13 @@
* A set of utility methods that can be used to create tokens.
*/
class TokenFactory {
- static Token tokenFromKeyword(Keyword keyword) =>
- new KeywordToken(keyword, 0);
+ static Token tokenFromKeyword(Keyword keyword) => KeywordToken(keyword, 0);
static Token tokenFromString(String lexeme) =>
- new StringToken(TokenType.STRING, lexeme, 0);
+ StringToken(TokenType.STRING, lexeme, 0);
- static Token tokenFromType(TokenType type) => new Token(type, 0);
+ static Token tokenFromType(TokenType type) => Token(type, 0);
static Token tokenFromTypeAndString(TokenType type, String lexeme) =>
- new StringToken(type, lexeme, 0);
+ StringToken(type, lexeme, 0);
}
diff --git a/pkg/analyzer/lib/src/generated/type_promotion_manager.dart b/pkg/analyzer/lib/src/generated/type_promotion_manager.dart
index 8411dc2..0a0d380 100644
--- a/pkg/analyzer/lib/src/generated/type_promotion_manager.dart
+++ b/pkg/analyzer/lib/src/generated/type_promotion_manager.dart
@@ -155,13 +155,13 @@
/// Enter a new promotions scope.
void _enterScope() {
- _currentScope = new _TypePromoteScope(_currentScope);
+ _currentScope = _TypePromoteScope(_currentScope);
}
/// Exit the current promotion scope.
void _exitScope() {
if (_currentScope == null) {
- throw new StateError("No scope to exit");
+ throw StateError("No scope to exit");
}
_currentScope = _currentScope._outerScope;
}
@@ -207,7 +207,7 @@
/// given ASTNode
bool _isVariableAccessedInClosure(Element variable, AstNode target) {
_ResolverVisitor_isVariableAccessedInClosure visitor =
- new _ResolverVisitor_isVariableAccessedInClosure(variable);
+ _ResolverVisitor_isVariableAccessedInClosure(variable);
target.accept(visitor);
return visitor.result;
}
@@ -222,7 +222,7 @@
/// given ASTNode
bool _isVariablePotentiallyMutatedIn(Element variable, AstNode target) {
_ResolverVisitor_isVariablePotentiallyMutatedIn visitor =
- new _ResolverVisitor_isVariablePotentiallyMutatedIn(variable);
+ _ResolverVisitor_isVariablePotentiallyMutatedIn(variable);
target.accept(visitor);
return visitor.result;
}
@@ -283,7 +283,7 @@
/// @param type the promoted type of the given element
void _setType(Element element, DartType type) {
if (_currentScope == null) {
- throw new StateError("Cannot promote without a scope");
+ throw StateError("Cannot promote without a scope");
}
_currentScope.setType(element, type);
}
diff --git a/pkg/analyzer/lib/src/generated/type_system.dart b/pkg/analyzer/lib/src/generated/type_system.dart
index 74c495c..3b59742 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -5,7 +5,6 @@
import 'dart:collection';
import 'dart:math' as math;
-import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart' show AstNode, ConstructorName;
import 'package:analyzer/dart/ast/token.dart' show Keyword, TokenType;
import 'package:analyzer/dart/element/element.dart';
@@ -24,33 +23,6 @@
import 'package:analyzer/src/generated/utilities_dart.dart' show ParameterKind;
import 'package:meta/meta.dart';
-/**
- * `void`, `dynamic`, and `Object` are all equivalent. However, this makes
- * LUB/GLB indeterministic. Therefore, for the cases of LUB/GLB, we have some
- * types which are more top than others.
- *
- * So, `void` < `Object` < `dynamic` for the purposes of LUB and GLB.
- *
- * This is expressed by their topiness (higher = more toppy).
- */
-int _getTopiness(DartType t) {
- // TODO(mfairhurst): switch legacy Top checks to true Top checks
- assert(_isLegacyTop(t, orTrueTop: true), 'only Top types have a topiness');
-
- // Highest top
- if (t.isVoid) return 3;
- if (t.isDynamic) return 2;
- if (t.isObject) return 1;
- if (t.isDartAsyncFutureOr)
- return -3 + _getTopiness((t as InterfaceType).typeArguments[0]);
- // Lowest top
-
- assert(false, 'a Top type without a defined topiness');
-
- // Try to ensure that if this happens, its less toppy than an actual Top type.
- return -100000;
-}
-
bool _isBottom(DartType t) {
return (t.isBottom &&
(t as TypeImpl).nullabilitySuffix != NullabilitySuffix.question) ||
@@ -96,17 +68,12 @@
*/
class Dart2TypeSystem extends TypeSystem {
/**
- * False if implicit casts should always be disallowed, otherwise the
- * [FeatureSet] will be used.
+ * False if implicit casts should always be disallowed.
*
* This affects the behavior of [isAssignableTo].
*/
final bool implicitCasts;
- /// If `true`, then NNBD type rules should be used.
- /// If `false`, then legacy type rules should be used.
- final bool isNonNullableByDefault;
-
/// A flag indicating whether inference failures are allowed, off by default.
///
/// This option is experimental and subject to change.
@@ -125,10 +92,17 @@
Dart2TypeSystem({
@required this.implicitCasts,
- @required this.isNonNullableByDefault,
+ @required bool isNonNullableByDefault,
@required this.strictInference,
@required this.typeProvider,
- });
+ }) : super(isNonNullableByDefault: isNonNullableByDefault);
+
+ InterfaceType get _interfaceTypeFunctionNone {
+ return typeProvider.functionType.element.instantiate(
+ typeArguments: const [],
+ nullabilitySuffix: NullabilitySuffix.none,
+ );
+ }
InterfaceTypeImpl get _nullNone =>
_nullNoneCached ??= (typeProvider.nullType as TypeImpl)
@@ -173,61 +147,203 @@
return null;
}
- /// Computes the greatest lower bound of [type1] and [type2].
- DartType getGreatestLowerBound(DartType type1, DartType type2) {
- // The greatest lower bound relation is reflexive.
- if (identical(type1, type2)) {
- return type1;
+ /// Computes the greatest lower bound of [T1] and [T2].
+ DartType getGreatestLowerBound(DartType T1, DartType T2) {
+ // DOWN(T, T) = T
+ if (identical(T1, T2)) {
+ return T1;
}
- // For any type T, GLB(?, T) == T.
- if (identical(type1, UnknownInferredType.instance)) {
- return type2;
+ // For any type T, DOWN(?, T) == T.
+ if (identical(T1, UnknownInferredType.instance)) {
+ return T2;
}
- if (identical(type2, UnknownInferredType.instance)) {
- return type1;
+ if (identical(T2, UnknownInferredType.instance)) {
+ return T1;
}
- // For the purpose of GLB, we say some Tops are subtypes (less toppy) than
- // the others. Return the least toppy.
- // TODO(mfairhurst): switch legacy Top checks to true Top checks
- if (_isLegacyTop(type1, orTrueTop: true) &&
- _isLegacyTop(type2, orTrueTop: true)) {
- return _getTopiness(type1) < _getTopiness(type2) ? type1 : type2;
+ var T1_isTop = isTop(T1);
+ var T2_isTop = isTop(T2);
+
+ // DOWN(T1, T2) where TOP(T1) and TOP(T2)
+ if (T1_isTop && T2_isTop) {
+ // * T1 if MORETOP(T2, T1)
+ // * T2 otherwise
+ if (isMoreTop(T2, T1)) {
+ return T1;
+ } else {
+ return T2;
+ }
}
- // The GLB of top and any type is just that type.
- // Also GLB of bottom and any type is bottom.
- // TODO(mfairhurst): switch legacy Top checks to true Top checks
- // TODO(mfairhurst): switch legacy Bottom checks to true Bottom checks.
- if (_isLegacyTop(type1, orTrueTop: true) ||
- _isLegacyBottom(type2, orTrueBottom: true)) {
- return type2;
- }
- // TODO(mfairhurst): switch legacy Bottom checks to true Bottom checks
- if (_isLegacyTop(type2, orTrueTop: true) ||
- _isLegacyBottom(type1, orTrueBottom: true)) {
- return type1;
+ // DOWN(T1, T2) = T2 if TOP(T1)
+ if (T1_isTop) {
+ return T2;
}
- // Function types have structural GLB.
- if (type1 is FunctionType && type2 is FunctionType) {
- return _functionGreatestLowerBound(type1, type2);
+ // DOWN(T1, T2) = T1 if TOP(T2)
+ if (T2_isTop) {
+ return T1;
}
- // Otherwise, the GLB of two types is one of them it if it is a subtype of
- // the other.
- if (isSubtypeOf(type1, type2)) {
- return type1;
+ var T1_isBottom = isBottom(T1);
+ var T2_isBottom = isBottom(T2);
+
+ // DOWN(T1, T2) where BOTTOM(T1) and BOTTOM(T2)
+ if (T1_isBottom && T2_isBottom) {
+ // * T1 if MOREBOTTOM(T1, T2)
+ // * T2 otherwise
+ if (isMoreBottom(T1, T2)) {
+ return T1;
+ } else {
+ return T2;
+ }
}
- if (isSubtypeOf(type2, type1)) {
- return type2;
+ // DOWN(T1, T2) = T1 if BOTTOM(T1)
+ if (T1_isBottom) {
+ return T1;
}
- // No subtype relation, so no known GLB.
- // TODO(mfairhurst): implement fully NNBD GLB, and return Never (non-legacy)
- return NeverTypeImpl.instanceLegacy;
+ // DOWN(T1, T2) = T2 if BOTTOM(T2)
+ if (T2_isBottom) {
+ return T2;
+ }
+
+ var T1_isNull = isNull(T1);
+ var T2_isNull = isNull(T2);
+
+ // DOWN(T1, T2) where NULL(T1) and NULL(T2)
+ if (T1_isNull && T2_isNull) {
+ // * T1 if MOREBOTTOM(T1, T2)
+ // * T2 otherwise
+ if (isMoreBottom(T1, T2)) {
+ return T1;
+ } else {
+ return T2;
+ }
+ }
+
+ var T1_impl = T1 as TypeImpl;
+ var T2_impl = T2 as TypeImpl;
+
+ var T1_nullability = T1_impl.nullabilitySuffix;
+ var T2_nullability = T2_impl.nullabilitySuffix;
+
+ // DOWN(Null, T2)
+ if (T1_nullability == NullabilitySuffix.none && T1.isDartCoreNull) {
+ // * Null if Null <: T2
+ // * Never otherwise
+ if (isSubtypeOf(_nullNone, T2)) {
+ return _nullNone;
+ } else {
+ return NeverTypeImpl.instance;
+ }
+ }
+
+ // DOWN(T1, Null)
+ if (T2_nullability == NullabilitySuffix.none && T2.isDartCoreNull) {
+ // * Null if Null <: T1
+ // * Never otherwise
+ if (isSubtypeOf(_nullNone, T1)) {
+ return _nullNone;
+ } else {
+ return NeverTypeImpl.instance;
+ }
+ }
+
+ var T1_isObject = isObject(T1);
+ var T2_isObject = isObject(T2);
+
+ // DOWN(T1, T2) where OBJECT(T1) and OBJECT(T2)
+ if (T1_isObject && T2_isObject) {
+ // * T1 if MORETOP(T2, T1)
+ // * T2 otherwise
+ if (isMoreTop(T2, T1)) {
+ return T1;
+ } else {
+ return T2;
+ }
+ }
+
+ // DOWN(T1, T2) where OBJECT(T1)
+ if (T1_isObject) {
+ // * T2 if T2 is non-nullable
+ if (isNonNullable(T2)) {
+ return T2;
+ }
+
+ // * NonNull(T2) if NonNull(T2) is non-nullable
+ var T2_nonNull = promoteToNonNull(T2_impl);
+ if (isNonNullable(T2_nonNull)) {
+ return T2_nonNull;
+ }
+
+ // * Never otherwise
+ return NeverTypeImpl.instance;
+ }
+
+ // DOWN(T1, T2) where OBJECT(T2)
+ if (T2_isObject) {
+ // * T1 if T1 is non-nullable
+ if (isNonNullable(T1)) {
+ return T1;
+ }
+
+ // * NonNull(T1) if NonNull(T1) is non-nullable
+ var T1_nonNull = promoteToNonNull(T1_impl);
+ if (isNonNullable(T1_nonNull)) {
+ return T1_nonNull;
+ }
+
+ // * Never otherwise
+ return NeverTypeImpl.instance;
+ }
+
+ // DOWN(T1*, T2*) = S* where S is DOWN(T1, T2)
+ // DOWN(T1*, T2?) = S* where S is DOWN(T1, T2)
+ // DOWN(T1?, T2*) = S* where S is DOWN(T1, T2)
+ // DOWN(T1*, T2) = S where S is DOWN(T1, T2)
+ // DOWN(T1, T2*) = S where S is DOWN(T1, T2)
+ // DOWN(T1?, T2?) = S? where S is DOWN(T1, T2)
+ // DOWN(T1?, T2) = S where S is DOWN(T1, T2)
+ // DOWN(T1, T2?) = S where S is DOWN(T1, T2)
+ if (T1_nullability != NullabilitySuffix.none ||
+ T2_nullability != NullabilitySuffix.none) {
+ var resultNullability = NullabilitySuffix.question;
+ if (T1_nullability == NullabilitySuffix.none ||
+ T2_nullability == NullabilitySuffix.none) {
+ resultNullability = NullabilitySuffix.none;
+ } else if (T1_nullability == NullabilitySuffix.star ||
+ T2_nullability == NullabilitySuffix.star) {
+ resultNullability = NullabilitySuffix.star;
+ }
+ var T1_none = T1_impl.withNullability(NullabilitySuffix.none);
+ var T2_none = T2_impl.withNullability(NullabilitySuffix.none);
+ var S = getGreatestLowerBound(T1_none, T2_none);
+ return (S as TypeImpl).withNullability(resultNullability);
+ }
+
+ assert(T1_nullability == NullabilitySuffix.none);
+ assert(T2_nullability == NullabilitySuffix.none);
+
+ // TODO(scheglov) incomplete
+ if (T1 is FunctionType && T2 is FunctionType) {
+ return _functionGreatestLowerBound(T1, T2);
+ }
+
+ // DOWN(T1, T2) = T1 if T1 <: T2
+ if (isSubtypeOf(T1, T2)) {
+ return T1;
+ }
+
+ // DOWN(T1, T2) = T2 if T2 <: T1
+ if (isSubtypeOf(T2, T1)) {
+ return T2;
+ }
+
+ // DOWN(T1, T2) = Never otherwise
+ return NeverTypeImpl.instance;
}
/**
@@ -242,7 +358,7 @@
return T1;
}
- // For any type T, LUB(?, T) == T.
+ // For any type T, UP(?, T) == T.
if (identical(T1, UnknownInferredType.instance)) {
return T2;
}
@@ -312,12 +428,22 @@
}
}
+ var T1_impl = T1 as TypeImpl;
+ var T2_impl = T2 as TypeImpl;
+
+ var T1_nullability = T1_impl.nullabilitySuffix;
+ var T2_nullability = T2_impl.nullabilitySuffix;
+
// UP(T1, T2) where NULL(T1)
if (T1_isNull) {
// * T2 if T2 is nullable
+ // * T2* if Null <: T2 or T1 <: Object (that is, T1 or T2 is legacy)
// * T2? otherwise
if (isNullable(T2)) {
return T2;
+ } else if (T1_nullability == NullabilitySuffix.star ||
+ T2_nullability == NullabilitySuffix.star) {
+ return T2_impl.withNullability(NullabilitySuffix.star);
} else {
return makeNullable(T2);
}
@@ -326,9 +452,13 @@
// UP(T1, T2) where NULL(T2)
if (T2_isNull) {
// * T1 if T1 is nullable
+ // * T1* if Null <: T1 or T2 <: Object (that is, T1 or T2 is legacy)
// * T1? otherwise
if (isNullable(T1)) {
return T1;
+ } else if (T1_nullability == NullabilitySuffix.star ||
+ T2_nullability == NullabilitySuffix.star) {
+ return T1_impl.withNullability(NullabilitySuffix.star);
} else {
return makeNullable(T1);
}
@@ -370,12 +500,6 @@
}
}
- var T1_impl = T1 as TypeImpl;
- var T2_impl = T2 as TypeImpl;
-
- var T1_nullability = T1_impl.nullabilitySuffix;
- var T2_nullability = T2_impl.nullabilitySuffix;
-
// UP(T1*, T2*) = S* where S is UP(T1, T2)
// UP(T1*, T2?) = S? where S is UP(T1, T2)
// UP(T1?, T2*) = S? where S is UP(T1, T2)
@@ -487,7 +611,7 @@
// inferred. It will optimistically assume these type parameters can be
// subtypes (or supertypes) as necessary, and track the constraints that
// are implied by this.
- var inferrer = new GenericInferrer(typeProvider, this, fnType.typeFormals);
+ var inferrer = GenericInferrer(typeProvider, this, fnType.typeFormals);
inferrer.constrainGenericFunctionInContext(fnType, contextType);
// Infer and instantiate the resulting type.
@@ -529,8 +653,8 @@
@required bool isNonNullableByDefault,
ErrorReporter errorReporter,
AstNode errorNode,
- bool downwards: false,
- bool isConst: false,
+ bool downwards = false,
+ bool isConst = false,
}) {
if (typeParameters.isEmpty) {
return null;
@@ -540,7 +664,7 @@
// inferred. It will optimistically assume these type parameters can be
// subtypes (or supertypes) as necessary, and track the constraints that
// are implied by this.
- var inferrer = new GenericInferrer(
+ var inferrer = GenericInferrer(
typeProvider,
this,
typeParameters,
@@ -610,7 +734,7 @@
return const <DartType>[];
}
- Set<TypeParameterElement> all = new Set<TypeParameterElement>();
+ Set<TypeParameterElement> all = Set<TypeParameterElement>();
// all ground
Map<TypeParameterElement, DartType> defaults = knownTypes ?? {};
// not ground
@@ -629,7 +753,7 @@
List<TypeParameterElement> getFreeParameters(DartType rootType) {
List<TypeParameterElement> parameters;
- Set<DartType> visitedTypes = new HashSet<DartType>();
+ Set<DartType> visitedTypes = HashSet<DartType>();
void appendParameters(DartType type) {
if (type == null) {
@@ -731,8 +855,7 @@
}
@override
- bool isAssignableTo(DartType fromType, DartType toType,
- {FeatureSet featureSet}) {
+ bool isAssignableTo(DartType fromType, DartType toType) {
// An actual subtype
if (isSubtypeOf(fromType, toType)) {
return true;
@@ -741,8 +864,7 @@
// A call method tearoff
if (fromType is InterfaceType && acceptsFunctionType(toType)) {
var callMethodType = getCallMethodType(fromType);
- if (callMethodType != null &&
- isAssignableTo(callMethodType, toType, featureSet: featureSet)) {
+ if (callMethodType != null && isAssignableTo(callMethodType, toType)) {
return true;
}
}
@@ -754,7 +876,7 @@
}
// Now handle NNBD default behavior, where we disable non-dynamic downcasts.
- if (featureSet != null && featureSet.isEnabled(Feature.non_nullable)) {
+ if (isNonNullableByDefault) {
return fromType.isDynamic;
}
@@ -1395,7 +1517,7 @@
@override
DartType refineBinaryExpressionType(DartType leftType, TokenType operator,
- DartType rightType, DartType currentType, FeatureSet featureSet) {
+ DartType rightType, DartType currentType) {
if (leftType is TypeParameterType && leftType.bound.isDartCoreNum) {
if (rightType == leftType || rightType.isDartCoreInt) {
if (operator == TokenType.PLUS ||
@@ -1404,7 +1526,7 @@
operator == TokenType.PLUS_EQ ||
operator == TokenType.MINUS_EQ ||
operator == TokenType.STAR_EQ) {
- if (featureSet.isEnabled(Feature.non_nullable)) {
+ if (isNonNullableByDefault) {
return promoteToNonNull(leftType as TypeImpl);
}
return leftType;
@@ -1416,7 +1538,7 @@
operator == TokenType.STAR ||
operator == TokenType.SLASH) {
InterfaceTypeImpl doubleType = typeProvider.doubleType;
- if (featureSet.isEnabled(Feature.non_nullable)) {
+ if (isNonNullableByDefault) {
return promoteToNonNull(doubleType);
}
return doubleType;
@@ -1424,8 +1546,8 @@
}
return currentType;
}
- return super.refineBinaryExpressionType(
- leftType, operator, rightType, currentType, featureSet);
+ return super
+ .refineBinaryExpressionType(leftType, operator, rightType, currentType);
}
@override
@@ -1496,111 +1618,152 @@
/**
* Compute the greatest lower bound of function types [f] and [g].
*
- * The spec rules for GLB on function types, informally, are pretty simple:
- *
- * - If a parameter is required in both, it stays required.
- *
- * - If a positional parameter is optional or missing in one, it becomes
- * optional.
- *
- * - Named parameters are unioned together.
- *
- * - For any parameter that exists in both functions, use the LUB of them as
- * the resulting parameter type.
- *
- * - Use the GLB of their return types.
+ * https://github.com/dart-lang/language
+ * See `resources/type-system/upper-lower-bounds.md`
*/
DartType _functionGreatestLowerBound(FunctionType f, FunctionType g) {
- // Calculate the LUB of each corresponding pair of parameters.
- List<ParameterElement> parameters = [];
+ var fTypeFormals = f.typeFormals;
+ var gTypeFormals = g.typeFormals;
- bool hasPositional = false;
- bool hasNamed = false;
- addParameter(
- String name, DartType fType, DartType gType, ParameterKind kind) {
- DartType paramType;
- if (fType != null && gType != null) {
- // If both functions have this parameter, include both of their types.
- paramType = getLeastUpperBound(fType, gType);
+ // The number of type parameters must be the same.
+ // Otherwise the result is `Never`.
+ if (fTypeFormals.length != gTypeFormals.length) {
+ return NeverTypeImpl.instance;
+ }
+
+ // The bounds of type parameters must be equal.
+ // Otherwise the result is `Never`.
+ var freshTypeFormalTypes =
+ FunctionTypeImpl.relateTypeFormals(f, g, (t, s, _, __) => t == s);
+ if (freshTypeFormalTypes == null) {
+ return NeverTypeImpl.instance;
+ }
+
+ var typeFormals = freshTypeFormalTypes
+ .map<TypeParameterElement>((t) => t.element)
+ .toList();
+
+ f = f.instantiate(freshTypeFormalTypes);
+ g = g.instantiate(freshTypeFormalTypes);
+
+ var fParameters = f.parameters;
+ var gParameters = g.parameters;
+
+ var parameters = <ParameterElement>[];
+ var fIndex = 0;
+ var gIndex = 0;
+ while (fIndex < fParameters.length && gIndex < gParameters.length) {
+ var fParameter = fParameters[fIndex];
+ var gParameter = gParameters[gIndex];
+ if (fParameter.isPositional) {
+ if (gParameter.isPositional) {
+ fIndex++;
+ gIndex++;
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ fParameter.name,
+ getLeastUpperBound(fParameter.type, gParameter.type),
+ fParameter.isOptional || gParameter.isOptional
+ ? ParameterKind.POSITIONAL
+ : ParameterKind.REQUIRED,
+ ),
+ );
+ } else {
+ return NeverTypeImpl.instance;
+ }
+ } else if (fParameter.isNamed) {
+ if (gParameter.isNamed) {
+ var compareNames = fParameter.name.compareTo(gParameter.name);
+ if (compareNames == 0) {
+ fIndex++;
+ gIndex++;
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ fParameter.name,
+ getLeastUpperBound(fParameter.type, gParameter.type),
+ fParameter.isRequiredNamed && gParameter.isRequiredNamed
+ ? ParameterKind.NAMED_REQUIRED
+ : ParameterKind.NAMED,
+ ),
+ );
+ } else if (compareNames < 0) {
+ fIndex++;
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ fParameter.name,
+ fParameter.type,
+ ParameterKind.NAMED,
+ ),
+ );
+ } else {
+ assert(compareNames > 0);
+ gIndex++;
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ gParameter.name,
+ gParameter.type,
+ ParameterKind.NAMED,
+ ),
+ );
+ }
+ } else {
+ return NeverTypeImpl.instance;
+ }
+ }
+ }
+
+ while (fIndex < fParameters.length) {
+ var fParameter = fParameters[fIndex++];
+ if (fParameter.isPositional) {
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ fParameter.name,
+ fParameter.type,
+ ParameterKind.POSITIONAL,
+ ),
+ );
} else {
- paramType = fType ?? gType;
+ assert(fParameter.isNamed);
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ fParameter.name,
+ fParameter.type,
+ ParameterKind.NAMED,
+ ),
+ );
}
-
- parameters.add(new ParameterElementImpl.synthetic(name, paramType, kind));
}
- // TODO(rnystrom): Right now, this assumes f and g do not have any type
- // parameters. Revisit that in the presence of generic methods.
- List<DartType> fRequired = f.normalParameterTypes;
- List<DartType> gRequired = g.normalParameterTypes;
-
- // We need some parameter names for in the synthesized function type.
- List<String> fRequiredNames = f.normalParameterNames;
- List<String> gRequiredNames = g.normalParameterNames;
-
- // Parameters that are required in both functions are required in the
- // result.
- int requiredCount = math.min(fRequired.length, gRequired.length);
- for (int i = 0; i < requiredCount; i++) {
- addParameter(fRequiredNames[i], fRequired[i], gRequired[i],
- ParameterKind.REQUIRED);
- }
-
- // Parameters that are optional or missing in either end up optional.
- List<DartType> fPositional = f.optionalParameterTypes;
- List<DartType> gPositional = g.optionalParameterTypes;
- List<String> fPositionalNames = f.optionalParameterNames;
- List<String> gPositionalNames = g.optionalParameterNames;
-
- int totalPositional = math.max(fRequired.length + fPositional.length,
- gRequired.length + gPositional.length);
- for (int i = requiredCount; i < totalPositional; i++) {
- // Find the corresponding positional parameters (required or optional) at
- // this index, if there is one.
- DartType fType;
- String fName;
- if (i < fRequired.length) {
- fType = fRequired[i];
- fName = fRequiredNames[i];
- } else if (i < fRequired.length + fPositional.length) {
- fType = fPositional[i - fRequired.length];
- fName = fPositionalNames[i - fRequired.length];
+ while (gIndex < gParameters.length) {
+ var gParameter = gParameters[gIndex++];
+ if (gParameter.isPositional) {
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ gParameter.name,
+ gParameter.type,
+ ParameterKind.POSITIONAL,
+ ),
+ );
+ } else {
+ assert(gParameter.isNamed);
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ gParameter.name,
+ gParameter.type,
+ ParameterKind.NAMED,
+ ),
+ );
}
-
- DartType gType;
- String gName;
- if (i < gRequired.length) {
- gType = gRequired[i];
- gName = gRequiredNames[i];
- } else if (i < gRequired.length + gPositional.length) {
- gType = gPositional[i - gRequired.length];
- gName = gPositionalNames[i - gRequired.length];
- }
-
- // The loop should not let us go past both f and g's positional params.
- assert(fType != null || gType != null);
-
- addParameter(fName ?? gName, fType, gType, ParameterKind.POSITIONAL);
- hasPositional = true;
}
- // Union the named parameters together.
- // TODO(brianwilkerson) Handle the fact that named parameters can now be
- // required.
- Map<String, DartType> fNamed = f.namedParameterTypes;
- Map<String, DartType> gNamed = g.namedParameterTypes;
- for (String name in fNamed.keys.toSet()..addAll(gNamed.keys)) {
- addParameter(name, fNamed[name], gNamed[name], ParameterKind.NAMED);
- hasNamed = true;
- }
+ var returnType = getGreatestLowerBound(f.returnType, g.returnType);
- // Edge case. Dart does not support functions with both optional positional
- // and named parameters. If we would synthesize that, give up.
- if (hasPositional && hasNamed) return typeProvider.bottomType;
-
- // Calculate the GLB of the return type.
- DartType returnType = getGreatestLowerBound(f.returnType, g.returnType);
- return new FunctionElementImpl.synthetic(parameters, returnType).type;
+ return FunctionTypeImpl(
+ typeFormals: typeFormals,
+ parameters: parameters,
+ returnType: returnType,
+ nullabilitySuffix: NullabilitySuffix.none,
+ );
}
/**
@@ -1616,10 +1779,7 @@
// The number of type parameters must be the same.
// Otherwise the result is `Function`.
if (fTypeFormals.length != gTypeFormals.length) {
- return typeProvider.functionType.element.instantiate(
- typeArguments: const [],
- nullabilitySuffix: NullabilitySuffix.none,
- );
+ return _interfaceTypeFunctionNone;
}
// The bounds of type parameters must be equal.
@@ -1627,10 +1787,7 @@
var freshTypeFormalTypes =
FunctionTypeImpl.relateTypeFormals(f, g, (t, s, _, __) => t == s);
if (freshTypeFormalTypes == null) {
- return typeProvider.functionType.element.instantiate(
- typeArguments: const [],
- nullabilitySuffix: NullabilitySuffix.none,
- );
+ return _interfaceTypeFunctionNone;
}
var typeFormals = freshTypeFormalTypes
@@ -1640,64 +1797,92 @@
f = f.instantiate(freshTypeFormalTypes);
g = g.instantiate(freshTypeFormalTypes);
- List<DartType> fRequired = f.normalParameterTypes;
- List<DartType> gRequired = g.normalParameterTypes;
+ var fParameters = f.parameters;
+ var gParameters = g.parameters;
- // The number of required parameters must be the same.
- if (fRequired.length != gRequired.length) {
- return typeProvider.functionType.element.instantiate(
- typeArguments: const [],
- nullabilitySuffix: NullabilitySuffix.none,
- );
- }
-
- // We need some parameter names for the result, so arbitrarily use F's.
- var fRequiredNames = f.normalParameterNames;
- var fPositionalNames = f.optionalParameterNames;
-
- // Calculate the DOWN of each corresponding pair of parameters.
var parameters = <ParameterElement>[];
-
- for (int i = 0; i < fRequired.length; i++) {
- parameters.add(
- new ParameterElementImpl.synthetic(
- fRequiredNames[i],
- // TODO(scheglov) Update for NNBD aware DOWN.
- getGreatestLowerBound(fRequired[i], gRequired[i]),
- ParameterKind.REQUIRED,
- ),
- );
+ var fIndex = 0;
+ var gIndex = 0;
+ while (fIndex < fParameters.length && gIndex < gParameters.length) {
+ var fParameter = fParameters[fIndex];
+ var gParameter = gParameters[gIndex];
+ if (fParameter.isRequiredPositional) {
+ if (gParameter.isRequiredPositional) {
+ fIndex++;
+ gIndex++;
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ fParameter.name,
+ getGreatestLowerBound(fParameter.type, gParameter.type),
+ ParameterKind.REQUIRED,
+ ),
+ );
+ } else {
+ break;
+ }
+ } else if (fParameter.isOptionalPositional) {
+ if (gParameter.isOptionalPositional) {
+ fIndex++;
+ gIndex++;
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ fParameter.name,
+ getGreatestLowerBound(fParameter.type, gParameter.type),
+ ParameterKind.POSITIONAL,
+ ),
+ );
+ } else {
+ break;
+ }
+ } else if (fParameter.isNamed) {
+ if (gParameter.isNamed) {
+ var compareNames = fParameter.name.compareTo(gParameter.name);
+ if (compareNames == 0) {
+ fIndex++;
+ gIndex++;
+ parameters.add(
+ ParameterElementImpl.synthetic(
+ fParameter.name,
+ getGreatestLowerBound(fParameter.type, gParameter.type),
+ fParameter.isRequiredNamed || gParameter.isRequiredNamed
+ ? ParameterKind.NAMED_REQUIRED
+ : ParameterKind.NAMED,
+ ),
+ );
+ } else if (compareNames < 0) {
+ if (fParameter.isRequiredNamed) {
+ // We cannot skip required named.
+ return _interfaceTypeFunctionNone;
+ } else {
+ fIndex++;
+ }
+ } else {
+ assert(compareNames > 0);
+ if (gParameter.isRequiredNamed) {
+ // We cannot skip required named.
+ return _interfaceTypeFunctionNone;
+ } else {
+ gIndex++;
+ }
+ }
+ } else {
+ break;
+ }
+ }
}
- List<DartType> fPositional = f.optionalParameterTypes;
- List<DartType> gPositional = g.optionalParameterTypes;
-
- // Ignore any extra optional positional parameters.
- int length = math.min(fPositional.length, gPositional.length);
- for (int i = 0; i < length; i++) {
- parameters.add(
- new ParameterElementImpl.synthetic(
- fPositionalNames[i],
- // TODO(scheglov) Update for NNBD aware DOWN.
- getGreatestLowerBound(fPositional[i], gPositional[i]),
- ParameterKind.POSITIONAL,
- ),
- );
+ while (fIndex < fParameters.length) {
+ var fParameter = fParameters[fIndex++];
+ if (fParameter.isNotOptional) {
+ return _interfaceTypeFunctionNone;
+ }
}
- // TODO(brianwilkerson) Handle the fact that named parameters can now be
- // required.
- Map<String, DartType> fNamed = f.namedParameterTypes;
- Map<String, DartType> gNamed = g.namedParameterTypes;
- for (String name in fNamed.keys.toSet()..retainAll(gNamed.keys)) {
- parameters.add(
- new ParameterElementImpl.synthetic(
- name,
- // TODO(scheglov) Update for NNBD aware DOWN.
- getGreatestLowerBound(fNamed[name], gNamed[name]),
- ParameterKind.NAMED,
- ),
- );
+ while (gIndex < gParameters.length) {
+ var gParameter = gParameters[gIndex++];
+ if (gParameter.isNotOptional) {
+ return _interfaceTypeFunctionNone;
+ }
}
var returnType = getLeastUpperBound(f.returnType, g.returnType);
@@ -1710,23 +1895,108 @@
);
}
- /// Check that [f1] is a subtype of [f2].
- bool _isFunctionSubtypeOf(FunctionType f1, FunctionType f2) {
- return FunctionTypeImpl.relate(
- f1,
- f2,
- isSubtypeOf,
- parameterRelation: (p1, p2) {
- if (p1.isRequiredNamed && !p2.isRequiredNamed) {
+ /// Check that [f] is a subtype of [g].
+ bool _isFunctionSubtypeOf(FunctionType f, FunctionType g) {
+ var fTypeFormals = f.typeFormals;
+ var gTypeFormals = g.typeFormals;
+
+ // The number of type parameters must be the same.
+ if (fTypeFormals.length != gTypeFormals.length) {
+ return false;
+ }
+
+ // The bounds of type parameters must be equal.
+ var freshTypeFormalTypes =
+ FunctionTypeImpl.relateTypeFormals(f, g, (t, s, _, __) {
+ // Type parameter bounds are invariant.
+ // TODO(scheglov) We do this for top types, but the spec says explicitly.
+ return isSubtypeOf(t, s) && isSubtypeOf(s, t);
+ });
+ if (freshTypeFormalTypes == null) {
+ return false;
+ }
+
+ f = f.instantiate(freshTypeFormalTypes);
+ g = g.instantiate(freshTypeFormalTypes);
+
+ if (!isSubtypeOf(f.returnType, g.returnType)) {
+ return false;
+ }
+
+ var fParameters = f.parameters;
+ var gParameters = g.parameters;
+
+ var fIndex = 0;
+ var gIndex = 0;
+ while (fIndex < fParameters.length && gIndex < gParameters.length) {
+ var fParameter = fParameters[fIndex];
+ var gParameter = gParameters[gIndex];
+ if (fParameter.isRequiredPositional) {
+ if (gParameter.isRequiredPositional) {
+ if (isSubtypeOf(gParameter.type, fParameter.type)) {
+ fIndex++;
+ gIndex++;
+ } else {
+ return false;
+ }
+ } else {
return false;
}
- return isSubtypeOf(p2.type, p1.type);
- },
- boundsRelation: (t1, t2, p1, p2) {
- // Type parameter bounds are invariant.
- return isSubtypeOf(t1, t2) && isSubtypeOf(t2, t1);
- },
- );
+ } else if (fParameter.isOptionalPositional) {
+ if (gParameter.isPositional) {
+ if (isSubtypeOf(gParameter.type, fParameter.type)) {
+ fIndex++;
+ gIndex++;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else if (fParameter.isNamed) {
+ if (gParameter.isNamed) {
+ var compareNames = fParameter.name.compareTo(gParameter.name);
+ if (compareNames == 0) {
+ if (fParameter.isRequiredNamed && !gParameter.isRequiredNamed) {
+ return false;
+ } else if (isSubtypeOf(gParameter.type, fParameter.type)) {
+ fIndex++;
+ gIndex++;
+ } else {
+ return false;
+ }
+ } else if (compareNames < 0) {
+ if (fParameter.isRequiredNamed) {
+ return false;
+ } else {
+ fIndex++;
+ }
+ } else {
+ assert(compareNames > 0);
+ // The subtype must accept all parameters of the supertype.
+ return false;
+ }
+ } else {
+ break;
+ }
+ }
+ }
+
+ // The supertype must provide all required parameters to the subtype.
+ while (fIndex < fParameters.length) {
+ var fParameter = fParameters[fIndex++];
+ if (fParameter.isNotOptional) {
+ return false;
+ }
+ }
+
+ // The subtype must accept all parameters of the supertype.
+ assert(fIndex == fParameters.length);
+ if (gIndex < gParameters.length) {
+ return false;
+ }
+
+ return true;
}
bool _isInterfaceSubtypeOf(
@@ -1771,7 +2041,7 @@
return false;
}
} else {
- throw new StateError('Type parameter ${tParams[i]} has unknown '
+ throw StateError('Type parameter ${tParams[i]} has unknown '
'variance $variance for subtype checking.');
}
}
@@ -1788,7 +2058,7 @@
// Dart 2 does not allow multiple implementations of the same generic type
// with different type arguments. So we can track just the class element
// to find cycles, rather than tracking the full interface type.
- visitedTypes ??= new HashSet<ClassElement>();
+ visitedTypes ??= HashSet<ClassElement>();
if (!visitedTypes.add(i1Element)) return false;
InterfaceType superclass = i1.superclass;
@@ -1827,7 +2097,7 @@
* If [lowerBound] is true, this will return the "least closure", otherwise
* it returns the "greatest closure".
*/
- DartType _substituteForUnknownType(DartType type, {bool lowerBound: false}) {
+ DartType _substituteForUnknownType(DartType type, {bool lowerBound = false}) {
return _substituteType(type, lowerBound, (type, lowerBound) {
if (identical(type, UnknownInferredType.instance)) {
return lowerBound ? typeProvider.nullType : typeProvider.dynamicType;
@@ -1858,7 +2128,7 @@
var newTypeArgs = _transformList(
type.typeArguments, (t) => _substituteType(t, lowerBound, visitType));
if (identical(type.typeArguments, newTypeArgs)) return type;
- return new InterfaceTypeImpl.explicit(type.element, newTypeArgs,
+ return InterfaceTypeImpl.explicit(type.element, newTypeArgs,
nullabilitySuffix: type.nullabilitySuffix);
}
if (type is FunctionType) {
@@ -1867,7 +2137,7 @@
var newParameters = _transformList(parameters, (ParameterElement p) {
// Parameters are contravariant, so flip the constraint direction.
var newType = _substituteType(p.type, !lowerBound, visitType);
- return new ParameterElementImpl.synthetic(
+ return ParameterElementImpl.synthetic(
p.name,
newType,
// ignore: deprecated_member_use_from_same_package
@@ -1880,7 +2150,7 @@
return type;
}
- return new FunctionTypeImpl(
+ return FunctionTypeImpl(
typeFormals: type.typeFormals,
parameters: newParameters,
returnType: newReturnType,
@@ -1903,7 +2173,7 @@
var item = list[i];
var newItem = f(item);
if (!identical(item, newItem)) {
- newList ??= new List.from(list);
+ newList ??= List.from(list);
newList[i] = newItem;
}
}
@@ -1958,7 +2228,7 @@
void constrainArgument(
DartType argumentType, DartType parameterType, String parameterName,
{ClassElement genericClass}) {
- var origin = new _TypeConstraintFromArgument(
+ var origin = _TypeConstraintFromArgument(
argumentType, parameterType, parameterName,
genericClass: genericClass);
tryMatchSubtypeOf(argumentType, parameterType, origin, covariant: false);
@@ -1968,7 +2238,7 @@
/// [contextType].
void constrainGenericFunctionInContext(
FunctionType fnType, DartType contextType) {
- var origin = new _TypeConstraintFromFunctionContext(fnType, contextType);
+ var origin = _TypeConstraintFromFunctionContext(fnType, contextType);
// Since we're trying to infer the instantiation, we want to ignore type
// formals as we check the parameters and return type.
@@ -1984,7 +2254,7 @@
/// Apply a return type constraint, which asserts that the [declaredType]
/// is a subtype of the [contextType].
void constrainReturnType(DartType declaredType, DartType contextType) {
- var origin = new _TypeConstraintFromReturnType(declaredType, contextType);
+ var origin = _TypeConstraintFromReturnType(declaredType, contextType);
tryMatchSubtypeOf(declaredType, contextType, origin, covariant: true);
}
@@ -1998,17 +2268,17 @@
/// false, we are on our final inference pass, have all available information
/// including argument types, and must not conclude `?` for any type formal.
List<DartType> infer(List<TypeParameterElement> typeFormals,
- {bool considerExtendsClause: true,
+ {bool considerExtendsClause = true,
ErrorReporter errorReporter,
AstNode errorNode,
- bool failAtError: false,
- bool downwardsInferPhase: false}) {
+ bool failAtError = false,
+ bool downwardsInferPhase = false}) {
// Initialize the inferred type array.
//
// In the downwards phase, they all start as `?` to offer reasonable
// degradation for f-bounded type parameters.
- var inferredTypes = new List<DartType>.filled(
- typeFormals.length, UnknownInferredType.instance);
+ var inferredTypes =
+ List<DartType>.filled(typeFormals.length, UnknownInferredType.instance);
for (int i = 0; i < typeFormals.length; i++) {
// TODO (kallentu) : Clean up TypeParameterElementImpl casting once
@@ -2016,7 +2286,7 @@
TypeParameterElementImpl typeParam = typeFormals[i];
_TypeConstraint extendsClause;
if (considerExtendsClause && typeParam.bound != null) {
- extendsClause = new _TypeConstraint.fromExtends(
+ extendsClause = _TypeConstraint.fromExtends(
typeParam,
Substitution.fromPairs(typeFormals, inferredTypes)
.substituteType(typeParam.bound));
@@ -2052,7 +2322,7 @@
if (success && !typeParamBound.isDynamic) {
// If everything else succeeded, check the `extends` constraint.
var extendsConstraint =
- new _TypeConstraint.fromExtends(typeParam, typeParamBound);
+ _TypeConstraint.fromExtends(typeParam, typeParamBound);
constraints.add(extendsConstraint);
success = extendsConstraint.isSatisifedBy(_typeSystem, inferred);
}
@@ -2107,7 +2377,7 @@
}
// Use instantiate to bounds to finish things off.
- var hasError = new List<bool>.filled(typeFormals.length, false);
+ var hasError = List<bool>.filled(typeFormals.length, false);
var result = _typeSystem.instantiateTypeFormalsToBounds(typeFormals,
hasError: hasError, knownTypes: knownTypes);
@@ -2173,7 +2443,7 @@
/// type parameter which means we choose the upper bound rather than the
/// lower bound for normally covariant type parameters.
DartType _chooseTypeFromConstraints(Iterable<_TypeConstraint> constraints,
- {bool toKnownType: false, @required bool isContravariant}) {
+ {bool toKnownType = false, @required bool isContravariant}) {
DartType lower = UnknownInferredType.instance;
DartType upper = UnknownInferredType.instance;
for (var constraint in constraints) {
@@ -2376,28 +2646,24 @@
Variance parameterVariance =
(typeParameterElement as TypeParameterElementImpl).variance;
if (parameterVariance.isCovariant) {
- if (!_matchSubtypeOf(
- tArgs1[i], tArgs2[i], new HashSet<Element>(), origin,
+ if (!_matchSubtypeOf(tArgs1[i], tArgs2[i], HashSet<Element>(), origin,
covariant: covariant)) {
return false;
}
} else if (parameterVariance.isContravariant) {
- if (!_matchSubtypeOf(
- tArgs2[i], tArgs1[i], new HashSet<Element>(), origin,
+ if (!_matchSubtypeOf(tArgs2[i], tArgs1[i], HashSet<Element>(), origin,
covariant: !covariant)) {
return false;
}
} else if (parameterVariance.isInvariant) {
- if (!_matchSubtypeOf(
- tArgs1[i], tArgs2[i], new HashSet<Element>(), origin,
+ if (!_matchSubtypeOf(tArgs1[i], tArgs2[i], HashSet<Element>(), origin,
covariant: covariant) ||
- !_matchSubtypeOf(
- tArgs2[i], tArgs1[i], new HashSet<Element>(), origin,
+ !_matchSubtypeOf(tArgs2[i], tArgs1[i], HashSet<Element>(), origin,
covariant: !covariant)) {
return false;
}
} else {
- throw new StateError("Type parameter ${tParams[i]} has unknown "
+ throw StateError("Type parameter ${tParams[i]} has unknown "
"variance $parameterVariance for inference.");
}
}
@@ -2409,7 +2675,7 @@
// Guard against loops in the class hierarchy
bool guardedInterfaceSubtype(InterfaceType t1) {
- visited ??= new HashSet<Element>();
+ visited ??= HashSet<Element>();
if (visited.add(t1.element)) {
bool matched = _matchInterfaceSubtypeOf(t1, i2, visited, origin,
covariant: covariant);
@@ -2461,7 +2727,7 @@
var constraints = this.constraints[t1.element];
if (constraints != null) {
if (!identical(t2, UnknownInferredType.instance)) {
- var constraint = new _TypeConstraint(origin, t1.element, upper: t2);
+ var constraint = _TypeConstraint(origin, t1.element, upper: t2);
constraints.add(constraint);
_undoBuffer.add(constraint);
}
@@ -2472,7 +2738,7 @@
var constraints = this.constraints[t2.element];
if (constraints != null) {
if (!identical(t1, UnknownInferredType.instance)) {
- var constraint = new _TypeConstraint(origin, t2.element, lower: t1);
+ var constraint = _TypeConstraint(origin, t2.element, lower: t1);
constraints.add(constraint);
_undoBuffer.add(constraint);
}
@@ -2553,7 +2819,7 @@
// TODO(jmesserly): this function isn't guarding against anything (it's
// not passsing down `visitedSet`, so adding the element has no effect).
bool guardedSubtype(DartType t1, DartType t2) {
- var visitedSet = visited ?? new HashSet<Element>();
+ var visitedSet = visited ?? HashSet<Element>();
if (visitedSet.add(t1.element)) {
bool matched = matchSubtype(t1, t2);
visitedSet.remove(t1.element);
@@ -2627,7 +2893,7 @@
static String _formatConstraints(Iterable<_TypeConstraint> constraints) {
List<List<String>> lineParts =
- new Set<_TypeConstraintOrigin>.from(constraints.map((c) => c.origin))
+ Set<_TypeConstraintOrigin>.from(constraints.map((c) => c.origin))
.map((o) => o.formatError())
.toList();
@@ -2635,7 +2901,7 @@
// Use a set to prevent identical message lines.
// (It's not uncommon for the same constraint to show up in a few places.)
- var messageLines = new Set<String>.from(lineParts.map((parts) {
+ var messageLines = Set<String>.from(lineParts.map((parts) {
var prefix = parts[0];
var middle = parts[1];
var prefixPad = ' ' * (prefixMax - prefix.length);
@@ -2849,12 +3115,12 @@
// parameters.
args[i] = args1[i];
} else {
- throw new StateError('Type parameter ${params[i]} has unknown '
+ throw StateError('Type parameter ${params[i]} has unknown '
'variance $parameterVariance for bounds calculation.');
}
}
- return new InterfaceTypeImpl.explicit(
+ return InterfaceTypeImpl.explicit(
type1.element,
args,
nullabilitySuffix: nullability,
@@ -3014,7 +3280,7 @@
List<InstantiatedClass> types,
) {
// for each element in Set s, compute the largest inheritance path to Object
- List<int> depths = new List<int>.filled(types.length, 0);
+ List<int> depths = List<int>.filled(types.length, 0);
int maxDepth = 0;
for (int i = 0; i < types.length; i++) {
depths[i] = computeLongestInheritancePathToObject(types[i].element);
@@ -3089,6 +3355,12 @@
*/
// TODO(brianwilkerson) Rename this class to TypeSystemImpl.
abstract class TypeSystem implements public.TypeSystem {
+ /// If `true`, then NNBD type rules should be used.
+ /// If `false`, then legacy type rules should be used.
+ final bool isNonNullableByDefault;
+
+ TypeSystem({@required this.isNonNullableByDefault});
+
/**
* The provider of types for the system
*/
@@ -3188,11 +3460,9 @@
/**
* Return `true` if the [leftType] is assignable to the [rightType] (that is,
- * if leftType <==> rightType). Accepts a [FeatureSet] to correctly handle
- * NNBD implicit downcasts.
+ * if leftType <==> rightType).
*/
- bool isAssignableTo(DartType leftType, DartType rightType,
- {FeatureSet featureSet});
+ bool isAssignableTo(DartType leftType, DartType rightType);
/**
* Return `true` if the [leftType] is more specific than the [rightType]
@@ -3271,7 +3541,7 @@
List<DartType> destTypes,
) {
var typeParameters = mixinElement.typeParameters;
- var inferrer = new GenericInferrer(typeProvider, this, typeParameters);
+ var inferrer = GenericInferrer(typeProvider, this, typeParameters);
for (int i = 0; i < srcTypes.length; i++) {
inferrer.constrainReturnType(srcTypes[i], destTypes[i]);
inferrer.constrainReturnType(destTypes[i], srcTypes[i]);
@@ -3352,17 +3622,15 @@
* Determine the type of a binary expression with the given [operator] whose
* left operand has the type [leftType] and whose right operand has the type
* [rightType], given that resolution has so far produced the [currentType].
- * The [featureSet] is used to determine whether any features that effect the
- * computation have been enabled.
*/
DartType refineBinaryExpressionType(DartType leftType, TokenType operator,
- DartType rightType, DartType currentType, FeatureSet featureSet) {
+ DartType rightType, DartType currentType) {
// bool
if (operator == TokenType.AMPERSAND_AMPERSAND ||
operator == TokenType.BAR_BAR ||
operator == TokenType.EQ_EQ ||
operator == TokenType.BANG_EQ) {
- if (featureSet.isEnabled(Feature.non_nullable)) {
+ if (isNonNullableByDefault) {
return promoteToNonNull(typeProvider.boolType as TypeImpl);
}
return typeProvider.boolType;
@@ -3379,7 +3647,7 @@
operator == TokenType.STAR_EQ) {
if (rightType.isDartCoreDouble) {
InterfaceTypeImpl doubleType = typeProvider.doubleType;
- if (featureSet.isEnabled(Feature.non_nullable)) {
+ if (isNonNullableByDefault) {
return promoteToNonNull(doubleType);
}
return doubleType;
@@ -3398,7 +3666,7 @@
operator == TokenType.TILDE_SLASH_EQ) {
if (rightType.isDartCoreInt) {
InterfaceTypeImpl intType = typeProvider.intType;
- if (featureSet.isEnabled(Feature.non_nullable)) {
+ if (isNonNullableByDefault) {
return promoteToNonNull(intType);
}
return intType;
@@ -3467,7 +3735,7 @@
*/
List<DartType> _searchTypeHierarchyForFutureTypeParameters(DartType type) {
List<DartType> result = <DartType>[];
- HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
+ HashSet<ClassElement> visitedClasses = HashSet<ClassElement>();
void recurse(InterfaceTypeImpl type) {
if (type.isDartAsyncFuture && type.typeArguments.isNotEmpty) {
result.add(type.typeArguments[0]);
@@ -3512,7 +3780,7 @@
/// example `List<?>`. This is distinct from `List<dynamic>`. These types will
/// never appear in the final resolved AST.
class UnknownInferredType extends TypeImpl {
- static final UnknownInferredType instance = new UnknownInferredType._();
+ static final UnknownInferredType instance = UnknownInferredType._();
UnknownInferredType._()
: super(UnknownInferredTypeElement.instance, Keyword.DYNAMIC.lexeme);
@@ -3589,7 +3857,7 @@
class UnknownInferredTypeElement extends ElementImpl
implements TypeDefiningElement {
static final UnknownInferredTypeElement instance =
- new UnknownInferredTypeElement._();
+ UnknownInferredTypeElement._();
UnknownInferredTypeElement._() : super(Keyword.DYNAMIC.lexeme, -1) {
setModifier(Modifier.SYNTHETIC, true);
@@ -3621,8 +3889,7 @@
_TypeConstraint.fromExtends(
TypeParameterElement element, DartType extendsType)
- : this(
- new _TypeConstraintFromExtendsClause(element, extendsType), element,
+ : this(_TypeConstraintFromExtendsClause(element, extendsType), element,
upper: extendsType);
bool get isDownwards => origin is! _TypeConstraintFromArgument;
diff --git a/pkg/analyzer/lib/src/generated/utilities_collection.dart b/pkg/analyzer/lib/src/generated/utilities_collection.dart
index 7ed3c90..74fbeba 100644
--- a/pkg/analyzer/lib/src/generated/utilities_collection.dart
+++ b/pkg/analyzer/lib/src/generated/utilities_collection.dart
@@ -73,7 +73,7 @@
*/
static void _checkIndex(int index) {
if (index < 0 || index > 30) {
- throw new RangeError("Index not between 0 and 30: $index");
+ throw RangeError("Index not between 0 and 30: $index");
}
}
}
diff --git a/pkg/analyzer/lib/src/generated/utilities_general.dart b/pkg/analyzer/lib/src/generated/utilities_general.dart
index fab29a6..0510007 100644
--- a/pkg/analyzer/lib/src/generated/utilities_general.dart
+++ b/pkg/analyzer/lib/src/generated/utilities_general.dart
@@ -204,7 +204,7 @@
*/
static _PerformanceTagImpl current = unknown;
- static final _PerformanceTagImpl unknown = new _PerformanceTagImpl('unknown');
+ static final _PerformanceTagImpl unknown = _PerformanceTagImpl('unknown');
/**
* A list of all performance tags that have been created so far.
@@ -223,8 +223,8 @@
final Stopwatch stopwatch;
_PerformanceTagImpl(String label)
- : userTag = new UserTag(label),
- stopwatch = new Stopwatch() {
+ : userTag = UserTag(label),
+ stopwatch = Stopwatch() {
all.add(this);
}
@@ -236,7 +236,7 @@
@override
PerformanceTag createChild(String childTagName) {
- return new _PerformanceTagImpl('$label.$childTagName');
+ return _PerformanceTagImpl('$label.$childTagName');
}
@override
diff --git a/pkg/analyzer/lib/src/hint/sdk_constraint_extractor.dart b/pkg/analyzer/lib/src/hint/sdk_constraint_extractor.dart
index 0cd3180..c4942e4 100644
--- a/pkg/analyzer/lib/src/hint/sdk_constraint_extractor.dart
+++ b/pkg/analyzer/lib/src/hint/sdk_constraint_extractor.dart
@@ -39,7 +39,7 @@
String text = constraintText();
if (text != null) {
try {
- _constraint = new VersionConstraint.parse(text);
+ _constraint = VersionConstraint.parse(text);
} catch (e) {
// Ignore this, leaving [_constraint] unset.
}
diff --git a/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart b/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart
index 2e9c37f..4384331 100644
--- a/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart
+++ b/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart
@@ -66,23 +66,23 @@
/// Return a range covering every version up to, but not including, 2.1.0.
VersionRange get before_2_1_0 =>
- new VersionRange(max: Version.parse('2.1.0'), includeMax: false);
+ VersionRange(max: Version.parse('2.1.0'), includeMax: false);
/// Return a range covering every version up to, but not including, 2.2.0.
VersionRange get before_2_2_0 =>
- new VersionRange(max: Version.parse('2.2.0'), includeMax: false);
+ VersionRange(max: Version.parse('2.2.0'), includeMax: false);
/// Return a range covering every version up to, but not including, 2.2.2.
VersionRange get before_2_2_2 =>
- new VersionRange(max: Version.parse('2.2.2'), includeMax: false);
+ VersionRange(max: Version.parse('2.2.2'), includeMax: false);
/// Return a range covering every version up to, but not including, 2.5.0.
VersionRange get before_2_5_0 =>
- new VersionRange(max: Version.parse('2.5.0'), includeMax: false);
+ VersionRange(max: Version.parse('2.5.0'), includeMax: false);
/// Return a range covering every version up to, but not including, 2.6.0.
VersionRange get before_2_6_0 =>
- new VersionRange(max: Version.parse('2.6.0'), includeMax: false);
+ VersionRange(max: Version.parse('2.6.0'), includeMax: false);
/// Return `true` if references to the constant-update-2018 features need to
/// be checked.
diff --git a/pkg/analyzer/lib/src/ignore_comments/ignore_info.dart b/pkg/analyzer/lib/src/ignore_comments/ignore_info.dart
index f2fb192..93dabe2 100644
--- a/pkg/analyzer/lib/src/ignore_comments/ignore_info.dart
+++ b/pkg/analyzer/lib/src/ignore_comments/ignore_info.dart
@@ -11,7 +11,7 @@
/// within a source file.
class IgnoreInfo {
/// Instance shared by all cases without matches.
- static final IgnoreInfo _EMPTY_INFO = new IgnoreInfo();
+ static final IgnoreInfo _EMPTY_INFO = IgnoreInfo();
/// A regular expression for matching 'ignore' comments. Produces matches
/// containing 2 groups. For example:
@@ -20,7 +20,7 @@
///
/// Resulting codes may be in a list ('error_code_1,error_code2').
static final RegExp _IGNORE_MATCHER =
- new RegExp(r'//+[ ]*ignore:(.*)$', multiLine: true);
+ RegExp(r'//+[ ]*ignore:(.*)$', multiLine: true);
/// A regular expression for matching 'ignore_for_file' comments. Produces
/// matches containing 2 groups. For example:
@@ -29,18 +29,18 @@
///
/// Resulting codes may be in a list ('error_code_1,error_code2').
static final RegExp _IGNORE_FOR_FILE_MATCHER =
- new RegExp(r'//[ ]*ignore_for_file:(.*)$', multiLine: true);
+ RegExp(r'//[ ]*ignore_for_file:(.*)$', multiLine: true);
- final Map<int, List<String>> _ignoreMap = new HashMap<int, List<String>>();
+ final Map<int, List<String>> _ignoreMap = HashMap<int, List<String>>();
- final Set<String> _ignoreForFileSet = new HashSet<String>();
+ final Set<String> _ignoreForFileSet = HashSet<String>();
/// Whether this info object defines any ignores.
bool get hasIgnores => _ignoreMap.isNotEmpty || _ignoreForFileSet.isNotEmpty;
/// Ignore these [errorCodes] at [line].
void _addAll(int line, Iterable<String> errorCodes) {
- _ignoreMap.putIfAbsent(line, () => new List<String>()).addAll(errorCodes);
+ _ignoreMap.putIfAbsent(line, () => List<String>()).addAll(errorCodes);
}
/// Ignore these [errorCodes] in the whole file.
@@ -61,7 +61,7 @@
return _EMPTY_INFO;
}
- IgnoreInfo ignoreInfo = new IgnoreInfo();
+ IgnoreInfo ignoreInfo = IgnoreInfo();
for (Match match in matches) {
// See _IGNORE_MATCHER for format --- note the possibility of error lists.
Iterable<String> codes = match
diff --git a/pkg/analyzer/lib/src/lint/analysis.dart b/pkg/analyzer/lib/src/lint/analysis.dart
index 35114ca..ab42a6b 100644
--- a/pkg/analyzer/lib/src/lint/analysis.dart
+++ b/pkg/analyzer/lib/src/lint/analysis.dart
@@ -37,7 +37,7 @@
import 'package:path/path.dart' as p;
import 'package:yaml/yaml.dart';
-AnalysisOptionsProvider _optionsProvider = new AnalysisOptionsProvider();
+AnalysisOptionsProvider _optionsProvider = AnalysisOptionsProvider();
Source createSource(Uri sourceUri) {
return PhysicalResourceProvider.INSTANCE
@@ -46,13 +46,13 @@
}
/// Print the given message and exit with the given [exitCode]
-void printAndFail(String message, {int exitCode: 15}) {
+void printAndFail(String message, {int exitCode = 15}) {
print(message);
io.exit(exitCode);
}
AnalysisOptions _buildAnalyzerOptions(LinterOptions options) {
- AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl analysisOptions = AnalysisOptionsImpl();
if (options.analysisOptions != null) {
YamlMap map =
_optionsProvider.getOptionsFromString(options.analysisOptions);
@@ -104,7 +104,7 @@
/// Set whether the parser is able to parse asserts in the initializer list of
/// a constructor to match [enable].
@deprecated
- void set enableAssertInitializer(bool enable) {
+ set enableAssertInitializer(bool enable) {
// Ignored because the option is now always enabled.
}
@@ -113,14 +113,14 @@
bool get previewDart2 => true;
@deprecated
- void set previewDart2(bool value) {}
+ set previewDart2(bool value) {}
}
class LintDriver {
/// The sources which have been analyzed so far. This is used to avoid
/// analyzing a source more than once, and to compute the total number of
/// sources analyzed for statistics.
- Set<Source> _sourcesAnalyzed = new HashSet<Source>();
+ Set<Source> _sourcesAnalyzed = HashSet<Source>();
final LinterOptions options;
@@ -132,13 +132,13 @@
List<UriResolver> get resolvers {
// TODO(brianwilkerson) Use the context builder to compute all of the resolvers.
ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE;
- ContextBuilder builder = new ContextBuilder(resourceProvider, null, null);
+ ContextBuilder builder = ContextBuilder(resourceProvider, null, null);
DartSdk sdk = options.mockSdk ??
- new FolderBasedDartSdk(
+ FolderBasedDartSdk(
resourceProvider, resourceProvider.getFolder(sdkDir));
- List<UriResolver> resolvers = [new DartUriResolver(sdk)];
+ List<UriResolver> resolvers = [DartUriResolver(sdk)];
if (options.packageRootPath != null) {
// TODO(brianwilkerson) After 0.30.0 is published, clean up the following.
@@ -153,12 +153,12 @@
}
Map<String, List<Folder>> packageMap =
builder.convertPackagesToMap(builder.createPackageMap(null));
- resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap));
+ resolvers.add(PackageMapUriResolver(resourceProvider, packageMap));
}
// File URI resolver must come last so that files inside "/lib" are
// are analyzed via "package:" URI's.
- resolvers.add(new ResourceUriResolver(resourceProvider));
+ resolvers.add(ResourceUriResolver(resourceProvider));
return resolvers;
}
@@ -172,19 +172,18 @@
Future<List<AnalysisErrorInfo>> analyze(Iterable<io.File> files) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
- AnalysisEngine.instance.instrumentationService = new StdInstrumentation();
+ AnalysisEngine.instance.instrumentationService = StdInstrumentation();
- SourceFactory sourceFactory =
- new SourceFactory(resolvers, _getPackageConfig());
+ SourceFactory sourceFactory = SourceFactory(resolvers, _getPackageConfig());
- PerformanceLog log = new PerformanceLog(null);
- AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log);
- AnalysisDriver analysisDriver = new AnalysisDriver(
+ PerformanceLog log = PerformanceLog(null);
+ AnalysisDriverScheduler scheduler = AnalysisDriverScheduler(log);
+ AnalysisDriver analysisDriver = AnalysisDriver(
scheduler,
log,
resourceProvider,
- new MemoryByteStore(),
- new FileContentOverlay(),
+ MemoryByteStore(),
+ FileContentOverlay(),
null,
sourceFactory,
_buildAnalyzerOptions(options));
@@ -219,8 +218,8 @@
for (Source source in sources) {
ErrorsResult errorsResult =
await analysisDriver.getErrors(source.fullName);
- errors.add(new AnalysisErrorInfoImpl(
- errorsResult.errors, errorsResult.lineInfo));
+ errors.add(
+ AnalysisErrorInfoImpl(errorsResult.errors, errorsResult.lineInfo));
_sourcesAnalyzed.add(source);
}
@@ -236,12 +235,12 @@
Packages _getPackageConfig() {
if (options.packageConfigPath != null) {
String packageConfigPath = options.packageConfigPath;
- Uri fileUri = new Uri.file(packageConfigPath);
+ Uri fileUri = Uri.file(packageConfigPath);
try {
- io.File configFile = new io.File.fromUri(fileUri).absolute;
+ io.File configFile = io.File.fromUri(fileUri).absolute;
List<int> bytes = configFile.readAsBytesSync();
Map<String, Uri> map = pkgfile.parse(bytes, configFile.uri);
- return new MapPackages(map);
+ return MapPackages(map);
} catch (e) {
printAndFail(
'Unable to read package config data from $packageConfigPath: $e');
diff --git a/pkg/analyzer/lib/src/lint/config.dart b/pkg/analyzer/lib/src/lint/config.dart
index 1645b5a..159385c 100644
--- a/pkg/analyzer/lib/src/lint/config.dart
+++ b/pkg/analyzer/lib/src/lint/config.dart
@@ -13,7 +13,7 @@
var options = getValue(optionsMap, 'linter');
// Quick check of basic contract.
if (options is YamlMap) {
- return new LintConfig.parseMap(options);
+ return LintConfig.parseMap(options);
}
}
return null;
@@ -36,10 +36,9 @@
*/
abstract class LintConfig {
factory LintConfig.parse(String source, {String sourceUrl}) =>
- new _LintConfig().._parse(source, sourceUrl: sourceUrl);
+ _LintConfig().._parse(source, sourceUrl: sourceUrl);
- factory LintConfig.parseMap(YamlMap map) =>
- new _LintConfig().._parseYaml(map);
+ factory LintConfig.parseMap(YamlMap map) => _LintConfig().._parseYaml(map);
List<String> get fileExcludes;
List<String> get fileIncludes;
@@ -136,7 +135,7 @@
// - camel_case_types
if (v is YamlList) {
v.nodes.forEach((rule) {
- var config = new _RuleConfig();
+ var config = _RuleConfig();
config.name = asString(rule);
config.args = {'enabled': true};
ruleConfigs.add(config);
@@ -148,7 +147,7 @@
v.nodes.forEach((key, value) {
//{unnecessary_getters: false}
if (asBool(value) != null) {
- var config = new _RuleConfig();
+ var config = _RuleConfig();
config.name = asString(key);
config.args = {'enabled': asBool(value)};
ruleConfigs.add(config);
@@ -159,7 +158,7 @@
value.nodes.forEach((rule, args) {
// TODO: verify format
// unnecessary_getters: false
- var config = new _RuleConfig();
+ var config = _RuleConfig();
config.group = asString(key);
config.name = asString(rule);
config.args = parseArgs(args);
diff --git a/pkg/analyzer/lib/src/lint/io.dart b/pkg/analyzer/lib/src/lint/io.dart
index bd3e4a0..0abd586 100644
--- a/pkg/analyzer/lib/src/lint/io.dart
+++ b/pkg/analyzer/lib/src/lint/io.dart
@@ -8,7 +8,7 @@
import 'package:glob/glob.dart';
import 'package:path/path.dart' as p;
-final dartMatcher = new Glob('**.dart');
+final dartMatcher = Glob('**.dart');
/// Shared IO sink for standard error reporting.
/// Visible for testing
@@ -23,11 +23,11 @@
Iterable<File> collectFiles(String path) {
List<File> files = [];
- var file = new File(path);
+ var file = File(path);
if (file.existsSync()) {
files.add(file);
} else {
- var directory = new Directory(path);
+ var directory = Directory(path);
if (directory.existsSync()) {
for (var entry
in directory.listSync(recursive: true, followLinks: false)) {
@@ -59,4 +59,4 @@
isPubspecFileName(p.basename(entry.path));
/// Synchronously read the contents of the file at the given [path] as a string.
-String readFile(String path) => new File(path).readAsStringSync();
+String readFile(String path) => File(path).readAsStringSync();
diff --git a/pkg/analyzer/lib/src/lint/linter.dart b/pkg/analyzer/lib/src/lint/linter.dart
index 319b9e9..5a5c87c 100644
--- a/pkg/analyzer/lib/src/lint/linter.dart
+++ b/pkg/analyzer/lib/src/lint/linter.dart
@@ -46,14 +46,14 @@
/// Describes a String in valid camel case format.
@deprecated // Never intended for public use.
class CamelCaseString {
- static final _camelCaseMatcher = new RegExp(r'[A-Z][a-z]*');
- static final _camelCaseTester = new RegExp(r'^([_$]*)([A-Z?$]+[a-z0-9]*)+$');
+ static final _camelCaseMatcher = RegExp(r'[A-Z][a-z]*');
+ static final _camelCaseTester = RegExp(r'^([_$]*)([A-Z?$]+[a-z0-9]*)+$');
final String value;
CamelCaseString(this.value) {
if (!isCamelCase(value)) {
- throw new ArgumentError('$value is not CamelCase');
+ throw ArgumentError('$value is not CamelCase');
}
}
@@ -80,13 +80,13 @@
int numSourcesAnalyzed;
/// Creates a new linter.
- DartLinter(this.options, {this.reporter: const PrintingReporter()});
+ DartLinter(this.options, {this.reporter = const PrintingReporter()});
Future<Iterable<AnalysisErrorInfo>> lintFiles(List<File> files) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
List<AnalysisErrorInfo> errors = [];
- final lintDriver = new LintDriver(options);
+ final lintDriver = LintDriver(options);
errors.addAll(await lintDriver.analyze(files.where((f) => isDartFile(f))));
numSourcesAnalyzed = lintDriver.numSourcesAnalyzed;
files.where((f) => isPubspecFile(f)).forEach((p) {
@@ -102,7 +102,7 @@
Uri sourceUrl = sourcePath == null ? null : p.toUri(sourcePath);
- var spec = new Pubspec.parse(contents, sourceUrl: sourceUrl);
+ var spec = Pubspec.parse(contents, sourceUrl: sourceUrl);
for (Linter lint in options.enabledLints) {
if (lint is LintRule) {
@@ -114,12 +114,12 @@
// processing gets pushed down, this hack can go away.)
if (rule.reporter == null && sourceUrl != null) {
var source = createSource(sourceUrl);
- rule.reporter = new ErrorReporter(this, source);
+ rule.reporter = ErrorReporter(this, source);
}
try {
spec.accept(visitor);
} on Exception catch (e) {
- reporter.exception(new LinterException(e.toString()));
+ reporter.exception(LinterException(e.toString()));
}
if (rule._locationInfo != null && rule._locationInfo.isNotEmpty) {
results.addAll(rule._locationInfo);
@@ -147,8 +147,8 @@
Iterable<Glob> excludes;
FileGlobFilter([Iterable<String> includeGlobs, Iterable<String> excludeGlobs])
- : includes = includeGlobs.map((glob) => new Glob(glob)),
- excludes = excludeGlobs.map((glob) => new Glob(glob));
+ : includes = includeGlobs.map((glob) => Glob(glob)),
+ excludes = excludeGlobs.map((glob) => Glob(glob));
@override
bool filter(AnalysisError lint) {
@@ -180,14 +180,14 @@
final String description;
final Hyperlink link;
- factory Group(String name, {String description: '', Hyperlink link}) {
+ factory Group(String name, {String description = '', Hyperlink link}) {
var n = name.toLowerCase();
return builtin.firstWhere((g) => g.name == n,
- orElse: () => new Group._(name,
- custom: true, description: description, link: link));
+ orElse: () =>
+ Group._(name, custom: true, description: description, link: link));
}
- const Group._(this.name, {this.custom: false, this.description, this.link});
+ const Group._(this.name, {this.custom = false, this.description, this.link});
@override
int compareTo(Group other) => name.compareTo(other.name);
@@ -198,7 +198,7 @@
final String href;
final bool bold;
- const Hyperlink(this.label, this.href, {this.bold: false});
+ const Hyperlink(this.label, this.href, {this.bold = false});
String get html => '<a href="$href">${_emph(label)}</a>';
@@ -316,7 +316,7 @@
//
Token oldKeyword = expression.keyword;
try {
- expression.keyword = new KeywordToken(Keyword.CONST, expression.offset);
+ expression.keyword = KeywordToken(Keyword.CONST, expression.offset);
return !_hasConstantVerifierError(expression);
} finally {
expression.keyword = oldKeyword;
@@ -415,7 +415,7 @@
void configure(LintConfig config) {
enabledLints = Registry.ruleRegistry.where((LintRule rule) =>
!config.ruleConfigs.any((rc) => rc.disables(rule.name)));
- filter = new FileGlobFilter(config.fileIncludes, config.fileExcludes);
+ filter = FileGlobFilter(config.fileIncludes, config.fileExcludes);
}
}
@@ -453,9 +453,9 @@
this.group,
this.description,
this.details,
- this.maturity: Maturity.stable});
+ this.maturity = Maturity.stable});
- LintCode get lintCode => new _LintCode(name, description);
+ LintCode get lintCode => _LintCode(name, description);
@override
int compareTo(LintRule other) {
@@ -479,18 +479,18 @@
AstVisitor getVisitor() => null;
void reportLint(AstNode node,
- {List<Object> arguments: const [],
+ {List<Object> arguments = const [],
ErrorCode errorCode,
- bool ignoreSyntheticNodes: true}) {
+ bool ignoreSyntheticNodes = true}) {
if (node != null && (!node.isSynthetic || !ignoreSyntheticNodes)) {
reporter.reportErrorForNode(errorCode ?? lintCode, node, arguments);
}
}
void reportLintForToken(Token token,
- {List<Object> arguments: const [],
+ {List<Object> arguments = const [],
ErrorCode errorCode,
- bool ignoreSyntheticTokens: true}) {
+ bool ignoreSyntheticTokens = true}) {
if (token != null && (!token.isSynthetic || !ignoreSyntheticTokens)) {
reporter.reportErrorForToken(errorCode ?? lintCode, token, arguments);
}
@@ -500,11 +500,11 @@
Source source = createSource(node.span.sourceUrl);
// Cache error and location info for creating AnalysisErrorInfos
- AnalysisError error = new AnalysisError(
+ AnalysisError error = AnalysisError(
source, node.span.start.offset, node.span.length, lintCode);
- LineInfo lineInfo = new LineInfo.fromContent(source.contents.data);
+ LineInfo lineInfo = LineInfo.fromContent(source.contents.data);
- _locationInfo.add(new AnalysisErrorInfoImpl([error], lineInfo));
+ _locationInfo.add(AnalysisErrorInfoImpl([error], lineInfo));
// Then do the reporting
reporter?.reportError(error);
@@ -529,7 +529,7 @@
case 'deprecated':
return deprecated;
default:
- return new Maturity._(name, ordinal: ordinal);
+ return Maturity._(name, ordinal: ordinal);
}
}
@@ -593,14 +593,14 @@
@override
int numSourcesAnalyzed;
- SourceLinter(this.options, {this.reporter: const PrintingReporter()});
+ SourceLinter(this.options, {this.reporter = const PrintingReporter()});
@override
Future<Iterable<AnalysisErrorInfo>> lintFiles(List<File> files) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
List<AnalysisErrorInfo> errors = [];
- final lintDriver = new LintDriver(options);
+ final lintDriver = LintDriver(options);
errors.addAll(await lintDriver.analyze(files.where((f) => isDartFile(f))));
numSourcesAnalyzed = lintDriver.numSourcesAnalyzed;
files.where((f) => isPubspecFile(f)).forEach((p) {
@@ -617,7 +617,7 @@
Uri sourceUrl = sourcePath == null ? null : p.toUri(sourcePath);
- var spec = new Pubspec.parse(contents, sourceUrl: sourceUrl);
+ var spec = Pubspec.parse(contents, sourceUrl: sourceUrl);
for (Linter lint in options.enabledLints) {
if (lint is LintRule) {
@@ -629,12 +629,12 @@
// processing gets pushed down, this hack can go away.)
if (rule.reporter == null && sourceUrl != null) {
var source = createSource(sourceUrl);
- rule.reporter = new ErrorReporter(this, source);
+ rule.reporter = ErrorReporter(this, source);
}
try {
spec.accept(visitor);
} on Exception catch (e) {
- reporter.exception(new LinterException(e.toString()));
+ reporter.exception(LinterException(e.toString()));
}
if (rule._locationInfo != null && rule._locationInfo.isNotEmpty) {
results.addAll(rule._locationInfo);
@@ -659,8 +659,8 @@
class _LintCode extends LintCode {
static final registry = <String, LintCode>{};
- factory _LintCode(String name, String message) => registry.putIfAbsent(
- name + message, () => new _LintCode._(name, message));
+ factory _LintCode(String name, String message) =>
+ registry.putIfAbsent(name + message, () => _LintCode._(name, message));
_LintCode._(String name, String message) : super(name, message);
}
diff --git a/pkg/analyzer/lib/src/lint/linter_visitor.dart b/pkg/analyzer/lib/src/lint/linter_visitor.dart
index 9716aaf..fc96885 100644
--- a/pkg/analyzer/lib/src/lint/linter_visitor.dart
+++ b/pkg/analyzer/lib/src/lint/linter_visitor.dart
@@ -876,564 +876,516 @@
NodeLintRegistry(this.enableTiming);
void addAnnotation(LintRule linter, AstVisitor visitor) {
- _forAnnotation.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forAnnotation.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addAsExpression(LintRule linter, AstVisitor visitor) {
- _forAsExpression.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forAsExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addAssertInitializer(LintRule linter, AstVisitor visitor) {
_forAssertInitializer
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addAssertStatement(LintRule linter, AstVisitor visitor) {
- _forAssertStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forAssertStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addAssignmentExpression(LintRule linter, AstVisitor visitor) {
_forAssignmentExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addAwaitExpression(LintRule linter, AstVisitor visitor) {
- _forAwaitExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forAwaitExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addBinaryExpression(LintRule linter, AstVisitor visitor) {
- _forBinaryExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forBinaryExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addBlock(LintRule linter, AstVisitor visitor) {
- _forBlock.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forBlock.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addBlockFunctionBody(LintRule linter, AstVisitor visitor) {
_forBlockFunctionBody
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addBooleanLiteral(LintRule linter, AstVisitor visitor) {
- _forBooleanLiteral
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forBooleanLiteral.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addBreakStatement(LintRule linter, AstVisitor visitor) {
- _forBreakStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forBreakStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addCascadeExpression(LintRule linter, AstVisitor visitor) {
_forCascadeExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addCatchClause(LintRule linter, AstVisitor visitor) {
- _forCatchClause.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forCatchClause.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addClassDeclaration(LintRule linter, AstVisitor visitor) {
- _forClassDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forClassDeclaration.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addClassTypeAlias(LintRule linter, AstVisitor visitor) {
- _forClassTypeAlias
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forClassTypeAlias.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addComment(LintRule linter, AstVisitor visitor) {
- _forComment.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forComment.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addCommentReference(LintRule linter, AstVisitor visitor) {
- _forCommentReference
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forCommentReference.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addCompilationUnit(LintRule linter, AstVisitor visitor) {
- _forCompilationUnit
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forCompilationUnit.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addConditionalExpression(LintRule linter, AstVisitor visitor) {
_forConditionalExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addConfiguration(LintRule linter, AstVisitor visitor) {
- _forConfiguration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forConfiguration.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addConstructorDeclaration(LintRule linter, AstVisitor visitor) {
_forConstructorDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addConstructorFieldInitializer(LintRule linter, AstVisitor visitor) {
_forConstructorFieldInitializer
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addConstructorName(LintRule linter, AstVisitor visitor) {
- _forConstructorName
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forConstructorName.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addContinueStatement(LintRule linter, AstVisitor visitor) {
_forContinueStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addDeclaredIdentifier(LintRule linter, AstVisitor visitor) {
_forDeclaredIdentifier
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addDefaultFormalParameter(LintRule linter, AstVisitor visitor) {
_forDefaultFormalParameter
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addDoStatement(LintRule linter, AstVisitor visitor) {
- _forDoStatement.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forDoStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addDottedName(LintRule linter, AstVisitor visitor) {
- _forDottedName.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forDottedName.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addDoubleLiteral(LintRule linter, AstVisitor visitor) {
- _forDoubleLiteral
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forDoubleLiteral.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addEmptyFunctionBody(LintRule linter, AstVisitor visitor) {
_forEmptyFunctionBody
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addEmptyStatement(LintRule linter, AstVisitor visitor) {
- _forEmptyStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forEmptyStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addEnumConstantDeclaration(LintRule linter, AstVisitor visitor) {
_forEnumConstantDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addEnumDeclaration(LintRule linter, AstVisitor visitor) {
- _forEnumDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forEnumDeclaration.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addExportDirective(LintRule linter, AstVisitor visitor) {
- _forExportDirective
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forExportDirective.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addExpressionFunctionBody(LintRule linter, AstVisitor visitor) {
_forExpressionFunctionBody
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addExpressionStatement(LintRule linter, AstVisitor visitor) {
_forExpressionStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addExtendsClause(LintRule linter, AstVisitor visitor) {
- _forExtendsClause
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forExtendsClause.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addExtensionDeclaration(LintRule linter, AstVisitor visitor) {
_forExtensionDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addExtensionOverride(LintRule linter, AstVisitor visitor) {
_forExtensionOverride
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addFieldDeclaration(LintRule linter, AstVisitor visitor) {
- _forFieldDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forFieldDeclaration.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addFieldFormalParameter(LintRule linter, AstVisitor visitor) {
_forFieldFormalParameter
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addForEachPartsWithDeclaration(LintRule linter, AstVisitor visitor) {
_forForEachPartsWithDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addForEachPartsWithIdentifier(LintRule linter, AstVisitor visitor) {
_forForEachPartsWithIdentifier
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addForElement(LintRule linter, AstVisitor visitor) {
- _forForElement.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forForElement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addFormalParameterList(LintRule linter, AstVisitor visitor) {
_forFormalParameterList
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addForPartsWithDeclarations(LintRule linter, AstVisitor visitor) {
_forForPartsWithDeclarations
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addForPartsWithExpression(LintRule linter, AstVisitor visitor) {
_forForPartsWithExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addForStatement(LintRule linter, AstVisitor visitor) {
- _forForStatement.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forForStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addFunctionDeclaration(LintRule linter, AstVisitor visitor) {
_forFunctionDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addFunctionDeclarationStatement(LintRule linter, AstVisitor visitor) {
_forFunctionDeclarationStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addFunctionExpression(LintRule linter, AstVisitor visitor) {
_forFunctionExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addFunctionExpressionInvocation(LintRule linter, AstVisitor visitor) {
_forFunctionExpressionInvocation
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addFunctionTypeAlias(LintRule linter, AstVisitor visitor) {
_forFunctionTypeAlias
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addFunctionTypedFormalParameter(LintRule linter, AstVisitor visitor) {
_forFunctionTypedFormalParameter
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addGenericFunctionType(LintRule linter, AstVisitor visitor) {
_forGenericFunctionType
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addGenericTypeAlias(LintRule linter, AstVisitor visitor) {
- _forGenericTypeAlias
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forGenericTypeAlias.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addHideCombinator(LintRule linter, AstVisitor visitor) {
- _forHideCombinator
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forHideCombinator.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addIfElement(LintRule linter, AstVisitor visitor) {
- _forIfElement.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forIfElement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addIfStatement(LintRule linter, AstVisitor visitor) {
- _forIfStatement.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forIfStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addImplementsClause(LintRule linter, AstVisitor visitor) {
- _forImplementsClause
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forImplementsClause.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addImportDirective(LintRule linter, AstVisitor visitor) {
- _forImportDirective
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forImportDirective.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addIndexExpression(LintRule linter, AstVisitor visitor) {
- _forIndexExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forIndexExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addInstanceCreationExpression(LintRule linter, AstVisitor visitor) {
_forInstanceCreationExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addIntegerLiteral(LintRule linter, AstVisitor visitor) {
- _forIntegerLiteral
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forIntegerLiteral.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addInterpolationExpression(LintRule linter, AstVisitor visitor) {
_forInterpolationExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addInterpolationString(LintRule linter, AstVisitor visitor) {
_forInterpolationString
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addIsExpression(LintRule linter, AstVisitor visitor) {
- _forIsExpression.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forIsExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addLabel(LintRule linter, AstVisitor visitor) {
- _forLabel.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forLabel.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addLabeledStatement(LintRule linter, AstVisitor visitor) {
- _forLabeledStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forLabeledStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addLibraryDirective(LintRule linter, AstVisitor visitor) {
- _forLibraryDirective
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forLibraryDirective.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addLibraryIdentifier(LintRule linter, AstVisitor visitor) {
_forLibraryIdentifier
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addListLiteral(LintRule linter, AstVisitor visitor) {
- _forListLiteral.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forListLiteral.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addMapLiteralEntry(LintRule linter, AstVisitor visitor) {
- _forMapLiteralEntry
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forMapLiteralEntry.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addMethodDeclaration(LintRule linter, AstVisitor visitor) {
_forMethodDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addMethodInvocation(LintRule linter, AstVisitor visitor) {
- _forMethodInvocation
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forMethodInvocation.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addMixinDeclaration(LintRule linter, AstVisitor visitor) {
- _forMixinDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forMixinDeclaration.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addNamedExpression(LintRule linter, AstVisitor visitor) {
- _forNamedExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forNamedExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addNullLiteral(LintRule linter, AstVisitor visitor) {
- _forNullLiteral.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forNullLiteral.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addOnClause(LintRule linter, AstVisitor visitor) {
- _forOnClause.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forOnClause.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addParenthesizedExpression(LintRule linter, AstVisitor visitor) {
_forParenthesizedExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addPartDirective(LintRule linter, AstVisitor visitor) {
- _forPartDirective
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forPartDirective.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addPartOfDirective(LintRule linter, AstVisitor visitor) {
- _forPartOfDirective
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forPartOfDirective.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addPostfixExpression(LintRule linter, AstVisitor visitor) {
_forPostfixExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addPrefixedIdentifier(LintRule linter, AstVisitor visitor) {
_forPrefixedIdentifier
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addPrefixExpression(LintRule linter, AstVisitor visitor) {
- _forPrefixExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forPrefixExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addPropertyAccess(LintRule linter, AstVisitor visitor) {
- _forPropertyAccess
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forPropertyAccess.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addRedirectingConstructorInvocation(
LintRule linter, AstVisitor visitor) {
_forRedirectingConstructorInvocation
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addRethrowExpression(LintRule linter, AstVisitor visitor) {
_forRethrowExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addReturnStatement(LintRule linter, AstVisitor visitor) {
- _forReturnStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forReturnStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSetOrMapLiteral(LintRule linter, AstVisitor visitor) {
- _forSetOrMapLiteral
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forSetOrMapLiteral.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addShowCombinator(LintRule linter, AstVisitor visitor) {
- _forShowCombinator
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forShowCombinator.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSimpleFormalParameter(LintRule linter, AstVisitor visitor) {
_forSimpleFormalParameter
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSimpleIdentifier(LintRule linter, AstVisitor visitor) {
- _forSimpleIdentifier
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forSimpleIdentifier.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSimpleStringLiteral(LintRule linter, AstVisitor visitor) {
_forSimpleStringLiteral
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSpreadElement(LintRule linter, AstVisitor visitor) {
- _forSpreadElement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forSpreadElement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addStringInterpolation(LintRule linter, AstVisitor visitor) {
_forStringInterpolation
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSuperConstructorInvocation(LintRule linter, AstVisitor visitor) {
_forSuperConstructorInvocation
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSuperExpression(LintRule linter, AstVisitor visitor) {
- _forSuperExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forSuperExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSwitchCase(LintRule linter, AstVisitor visitor) {
- _forSwitchCase.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forSwitchCase.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSwitchDefault(LintRule linter, AstVisitor visitor) {
- _forSwitchDefault
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forSwitchDefault.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSwitchStatement(LintRule linter, AstVisitor visitor) {
- _forSwitchStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forSwitchStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addSymbolLiteral(LintRule linter, AstVisitor visitor) {
- _forSymbolLiteral
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forSymbolLiteral.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addThisExpression(LintRule linter, AstVisitor visitor) {
- _forThisExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forThisExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addThrowExpression(LintRule linter, AstVisitor visitor) {
- _forThrowExpression
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forThrowExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addTopLevelVariableDeclaration(LintRule linter, AstVisitor visitor) {
_forTopLevelVariableDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addTryStatement(LintRule linter, AstVisitor visitor) {
- _forTryStatement.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forTryStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addTypeArgumentList(LintRule linter, AstVisitor visitor) {
- _forTypeArgumentList
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forTypeArgumentList.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addTypeName(LintRule linter, AstVisitor visitor) {
- _forTypeName.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forTypeName.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addTypeParameter(LintRule linter, AstVisitor visitor) {
- _forTypeParameter
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forTypeParameter.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addTypeParameterList(LintRule linter, AstVisitor visitor) {
_forTypeParameterList
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addVariableDeclaration(LintRule linter, AstVisitor visitor) {
_forVariableDeclaration
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addVariableDeclarationList(LintRule linter, AstVisitor visitor) {
_forVariableDeclarationList
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addVariableDeclarationStatement(LintRule linter, AstVisitor visitor) {
_forVariableDeclarationStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addWhileStatement(LintRule linter, AstVisitor visitor) {
- _forWhileStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forWhileStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addWithClause(LintRule linter, AstVisitor visitor) {
- _forWithClause.add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forWithClause.add(_Subscription(linter, visitor, _getTimer(linter)));
}
void addYieldStatement(LintRule linter, AstVisitor visitor) {
- _forYieldStatement
- .add(new _Subscription(linter, visitor, _getTimer(linter)));
+ _forYieldStatement.add(_Subscription(linter, visitor, _getTimer(linter)));
}
/// Get the timer associated with the given [linter].
diff --git a/pkg/analyzer/lib/src/lint/options_rule_validator.dart b/pkg/analyzer/lib/src/lint/options_rule_validator.dart
index 593dee4..4606eff 100644
--- a/pkg/analyzer/lib/src/lint/options_rule_validator.dart
+++ b/pkg/analyzer/lib/src/lint/options_rule_validator.dart
@@ -77,7 +77,7 @@
validateRules(YamlNode rules, ErrorReporter reporter) {
if (rules is YamlList) {
- Set<String> seenRules = new HashSet<String>();
+ Set<String> seenRules = HashSet<String>();
rules.nodes.forEach((YamlNode ruleNode) {
Object value = ruleNode.value;
if (value != null) {
diff --git a/pkg/analyzer/lib/src/lint/project.dart b/pkg/analyzer/lib/src/lint/project.dart
index f76a03e..560e9b2 100644
--- a/pkg/analyzer/lib/src/lint/project.dart
+++ b/pkg/analyzer/lib/src/lint/project.dart
@@ -20,7 +20,7 @@
.listSync(followLinks: false)
.firstWhere((f) => isPubspecFile(f), orElse: () => null);
if (pubspec != null) {
- return new Pubspec.parse(pubspec.readAsStringSync(),
+ return Pubspec.parse(pubspec.readAsStringSync(),
sourceUrl: p.toUri(pubspec.path));
}
}
@@ -51,7 +51,7 @@
DartProject._(AnalysisDriver driver, List<Source> sources, {Directory dir})
: root = dir ?? Directory.current {
_pubspec = _findAndParsePubspec(root);
- _apiModel = new _ApiModel(driver, sources, root);
+ _apiModel = _ApiModel(driver, sources, root);
}
/// The project's name.
@@ -90,7 +90,7 @@
{Directory dir}) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
- DartProject project = new DartProject._(driver, sources, dir: dir);
+ DartProject project = DartProject._(driver, sources, dir: dir);
await project._apiModel._calculate();
return project;
}
@@ -106,7 +106,7 @@
final AnalysisDriver driver;
final List<Source> sources;
final Directory root;
- final Set<LibraryElement> elements = new Set();
+ final Set<LibraryElement> elements = Set();
_ApiModel(this.driver, this.sources, this.root) {
_calculate();
@@ -139,7 +139,7 @@
ResolvedUnitResult result = await driver.getResult(source.fullName);
LibraryElement library = result.libraryElement;
- NamespaceBuilder namespaceBuilder = new NamespaceBuilder();
+ NamespaceBuilder namespaceBuilder = NamespaceBuilder();
Namespace exports =
namespaceBuilder.createExportNamespaceForLibrary(library);
Namespace public =
diff --git a/pkg/analyzer/lib/src/lint/pub.dart b/pkg/analyzer/lib/src/lint/pub.dart
index 8e6deed..def9287 100644
--- a/pkg/analyzer/lib/src/lint/pub.dart
+++ b/pkg/analyzer/lib/src/lint/pub.dart
@@ -23,8 +23,8 @@
}
YamlMap depsMap = v;
- _PSDependencyList deps = new _PSDependencyList(new _PSNode(key));
- depsMap.nodes.forEach((k, v) => deps.add(new _PSDependency(k, v)));
+ _PSDependencyList deps = _PSDependencyList(_PSNode(key));
+ depsMap.nodes.forEach((k, v) => deps.add(_PSDependency(k, v)));
return deps;
}
@@ -35,8 +35,8 @@
YamlMap hostMap = v;
// url: git://github.com/munificent/kittens.git
// ref: some-branch
- _PSGitRepo repo = new _PSGitRepo();
- repo.token = new _PSNode(key);
+ _PSGitRepo repo = _PSGitRepo();
+ repo.token = _PSNode(key);
repo.ref = _findEntry(hostMap, 'ref');
repo.url = _findEntry(hostMap, 'url');
return repo;
@@ -49,8 +49,8 @@
YamlMap hostMap = v;
// name: transmogrify
// url: http://your-package-server.com
- _PSHost host = new _PSHost();
- host.token = new _PSNode(key);
+ _PSHost host = _PSHost();
+ host.token = _PSNode(key);
host.name = _findEntry(hostMap, 'name');
host.url = _findEntry(hostMap, 'url');
return host;
@@ -62,8 +62,7 @@
}
YamlList nodeList = v;
- return new _PSNodeList(
- new _PSNode(key), nodeList.nodes.map((n) => new _PSNode(n)));
+ return _PSNodeList(_PSNode(key), nodeList.nodes.map((n) => _PSNode(n)));
}
PSEntry _processScalar(YamlScalar key, YamlNode value) {
@@ -71,7 +70,7 @@
return null;
//WARN?
}
- return new PSEntry(new _PSNode(key), new _PSNode(value));
+ return PSEntry(_PSNode(key), _PSNode(value));
}
abstract class PSDependency {
@@ -117,7 +116,7 @@
abstract class Pubspec {
factory Pubspec.parse(String source, {Uri sourceUrl}) =>
- new _Pubspec(source, sourceUrl: sourceUrl);
+ _Pubspec(source, sourceUrl: sourceUrl);
PSEntry get author;
PSNodeList get authors;
PSDependencyList get dependencies;
@@ -163,13 +162,13 @@
}
YamlScalar key = k;
- _PSDependency dep = new _PSDependency._();
+ _PSDependency dep = _PSDependency._();
- dep.name = new _PSNode(key);
+ dep.name = _PSNode(key);
if (v is YamlScalar) {
// Simple version
- dep.version = new PSEntry(null, new _PSNode(v));
+ dep.version = PSEntry(null, _PSNode(v));
} else if (v is YamlMap) {
// hosted:
// name: transmogrify
@@ -201,7 +200,7 @@
@override
String toString() {
- var sb = new StringBuffer();
+ var sb = StringBuffer();
if (name != null) {
sb.write('$name:');
}
@@ -370,7 +369,7 @@
@override
String toString() {
- var sb = new _StringBuilder();
+ var sb = _StringBuilder();
sb.writelin(name);
sb.writelin(version);
sb.writelin(author);
@@ -431,7 +430,7 @@
}
class _StringBuilder {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
@override
String toString() => buffer.toString();
writelin(Object value) {
diff --git a/pkg/analyzer/lib/src/lint/registry.dart b/pkg/analyzer/lib/src/lint/registry.dart
index 3b4bbea..56adb5e 100644
--- a/pkg/analyzer/lib/src/lint/registry.dart
+++ b/pkg/analyzer/lib/src/lint/registry.dart
@@ -14,7 +14,7 @@
/**
* The default registry to be used by clients.
*/
- static final Registry ruleRegistry = new Registry();
+ static final Registry ruleRegistry = Registry();
/**
* A table mapping rule names to rules.
diff --git a/pkg/analyzer/lib/src/lint/util.dart b/pkg/analyzer/lib/src/lint/util.dart
index d78b531..6161c6b 100644
--- a/pkg/analyzer/lib/src/lint/util.dart
+++ b/pkg/analyzer/lib/src/lint/util.dart
@@ -17,19 +17,18 @@
import 'package:analyzer/src/string_source.dart' show StringSource;
import 'package:path/path.dart' as path;
-final _identifier = new RegExp(r'^([(_|$)a-zA-Z]+([_a-zA-Z0-9])*)$');
+final _identifier = RegExp(r'^([(_|$)a-zA-Z]+([_a-zA-Z0-9])*)$');
-final _lowerCamelCase =
- new RegExp(r'^(_)*[?$a-z][a-z0-9?$]*([A-Z][a-z0-9?$]*)*$');
+final _lowerCamelCase = RegExp(r'^(_)*[?$a-z][a-z0-9?$]*([A-Z][a-z0-9?$]*)*$');
-final _lowerCaseUnderScore = new RegExp(r'^([a-z]+([_]?[a-z0-9]+)*)+$');
+final _lowerCaseUnderScore = RegExp(r'^([a-z]+([_]?[a-z0-9]+)*)+$');
final _lowerCaseUnderScoreWithDots =
- new RegExp(r'^[a-z][_a-z0-9]*(\.[a-z][_a-z0-9]*)*$');
+ RegExp(r'^[a-z][_a-z0-9]*(\.[a-z][_a-z0-9]*)*$');
-final _pubspec = new RegExp(r'^[_]?pubspec\.yaml$');
+final _pubspec = RegExp(r'^[_]?pubspec\.yaml$');
-final _underscores = new RegExp(r'^[_]+$');
+final _underscores = RegExp(r'^[_]+$');
/// Create a library name prefix based on [libraryPath], [projectRoot] and
/// current [packageName].
@@ -97,25 +96,24 @@
featureSet = featureSet ?? FeatureSet.fromEnableFlags([]);
void spelunk() {
- var contents = new File(path).readAsStringSync();
+ var contents = File(path).readAsStringSync();
- var errorListener = new _ErrorListener();
+ var errorListener = _ErrorListener();
- var reader = new CharSequenceReader(contents);
- var stringSource = new StringSource(contents, path);
- var scanner = new Scanner(stringSource, reader, errorListener)
+ var reader = CharSequenceReader(contents);
+ var stringSource = StringSource(contents, path);
+ var scanner = Scanner(stringSource, reader, errorListener)
..configureFeatures(featureSet);
var startToken = scanner.tokenize();
errorListener.throwIfErrors();
- var parser =
- new Parser(stringSource, errorListener, featureSet: featureSet);
+ var parser = Parser(stringSource, errorListener, featureSet: featureSet);
var node = parser.parseCompilationUnit(startToken);
errorListener.throwIfErrors();
- var visitor = new _SourceVisitor(sink);
+ var visitor = _SourceVisitor(sink);
node.accept(visitor);
}
}
@@ -130,7 +128,7 @@
void throwIfErrors() {
if (errors.isNotEmpty) {
- throw new Exception(errors);
+ throw Exception(errors);
}
}
}
diff --git a/pkg/analyzer/lib/src/manifest/manifest_validator.dart b/pkg/analyzer/lib/src/manifest/manifest_validator.dart
index a79c84e..b91a4cf 100644
--- a/pkg/analyzer/lib/src/manifest/manifest_validator.dart
+++ b/pkg/analyzer/lib/src/manifest/manifest_validator.dart
@@ -28,8 +28,8 @@
* Validate the [contents] of the Android Manifest file.
*/
List<AnalysisError> validate(String contents, bool checkManifest) {
- RecordingErrorListener recorder = new RecordingErrorListener();
- ErrorReporter reporter = new ErrorReporter(recorder, source);
+ RecordingErrorListener recorder = RecordingErrorListener();
+ ErrorReporter reporter = ErrorReporter(recorder, source);
if (checkManifest) {
var document =
diff --git a/pkg/analyzer/lib/src/pubspec/pubspec_validator.dart b/pkg/analyzer/lib/src/pubspec/pubspec_validator.dart
index b835a7a..77c1905 100644
--- a/pkg/analyzer/lib/src/pubspec/pubspec_validator.dart
+++ b/pkg/analyzer/lib/src/pubspec/pubspec_validator.dart
@@ -59,8 +59,8 @@
* Validate the given [contents].
*/
List<AnalysisError> validate(Map<dynamic, YamlNode> contents) {
- RecordingErrorListener recorder = new RecordingErrorListener();
- ErrorReporter reporter = new ErrorReporter(recorder, source);
+ RecordingErrorListener recorder = RecordingErrorListener();
+ ErrorReporter reporter = ErrorReporter(recorder, source);
_validateDependencies(reporter, contents);
_validateFlutter(reporter, contents);
diff --git a/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart b/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart
index 0e3461b..c9d0ec0 100644
--- a/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart
+++ b/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart
@@ -92,7 +92,7 @@
const PubspecWarningCode(
'UNNECESSARY_DEV_DEPENDENCY',
"The dev dependency on {0} is unnecessary because there is also a "
- "normal dependency on that package.",
+ "normal dependency on that package.",
correction: "Try removing the dev dependency.");
/**
diff --git a/pkg/analyzer/lib/src/services/available_declarations.dart b/pkg/analyzer/lib/src/services/available_declarations.dart
index f1a916a..48ed6da 100644
--- a/pkg/analyzer/lib/src/services/available_declarations.dart
+++ b/pkg/analyzer/lib/src/services/available_declarations.dart
@@ -141,7 +141,7 @@
/// The combined information about all of the dartdoc directives in this
/// context.
- final DartdocDirectiveInfo _dartdocDirectiveInfo = new DartdocDirectiveInfo();
+ final DartdocDirectiveInfo _dartdocDirectiveInfo = DartdocDirectiveInfo();
/// Map of path prefixes to lists of paths of files from dependencies
/// (both libraries and parts, we don't know at the time when we fill this
@@ -606,7 +606,7 @@
}
if (file.exportedDeclarations == null) {
- new _LibraryWalker().walkLibrary(file);
+ _LibraryWalker().walkLibrary(file);
assert(file.exportedDeclarations != null);
}
@@ -654,7 +654,7 @@
/// Compute exported declarations for the given [libraries].
void _computeExportedDeclarations(Set<_File> libraries) {
- var walker = new _LibraryWalker();
+ var walker = _LibraryWalker();
for (var library in libraries) {
if (library.isLibrary && library.exportedDeclarations == null) {
walker.walkLibrary(library);
@@ -1645,7 +1645,7 @@
}
void _extractDartdocInfoFromUnit(CompilationUnit unit) {
- DartdocDirectiveInfo info = new DartdocDirectiveInfo();
+ DartdocDirectiveInfo info = DartdocDirectiveInfo();
for (Directive directive in unit.directives) {
Comment comment = directive.documentationComment;
if (comment != null) {
@@ -1860,13 +1860,13 @@
var errorListener = AnalysisErrorListener.NULL_LISTENER;
var source = StringSource(content, '');
- var reader = new CharSequenceReader(content);
- var scanner = new Scanner(null, reader, errorListener)
+ var reader = CharSequenceReader(content);
+ var scanner = Scanner(null, reader, errorListener)
..configureFeatures(featureSet);
var token = scanner.tokenize();
- var parser = new Parser(source, errorListener,
- featureSet: featureSet, useFasta: true);
+ var parser =
+ Parser(source, errorListener, featureSet: featureSet, useFasta: true);
var unit = parser.parseCompilationUnit(token);
unit.lineInfo = LineInfo(scanner.lineStarts);
@@ -1963,7 +1963,7 @@
}
_LibraryNode getNode(_File file) {
- return nodesOfFiles.putIfAbsent(file, () => new _LibraryNode(this, file));
+ return nodesOfFiles.putIfAbsent(file, () => _LibraryNode(this, file));
}
void walkLibrary(_File file) {
diff --git a/pkg/analyzer/lib/src/services/lint.dart b/pkg/analyzer/lib/src/services/lint.dart
index 2548085..c6342a4 100644
--- a/pkg/analyzer/lib/src/services/lint.dart
+++ b/pkg/analyzer/lib/src/services/lint.dart
@@ -10,7 +10,7 @@
import 'package:analyzer/src/generated/engine.dart';
/// Shared lint registry.
-LintRegistry lintRegistry = new LintRegistry();
+LintRegistry lintRegistry = LintRegistry();
/// Current linter version.
String linterVersion;
@@ -23,7 +23,7 @@
/// Associate these [lints] with the given [context].
void setLints(AnalysisContext context, List<Linter> lints) {
AnalysisOptionsImpl options =
- new AnalysisOptionsImpl.from(context.analysisOptions);
+ AnalysisOptionsImpl.from(context.analysisOptions);
options.lintRules = lints;
context.analysisOptions = options;
}
@@ -51,10 +51,10 @@
/// Manages lint timing.
class LintRegistry {
/// Dictionary mapping lints (by name) to timers.
- final Map<String, Stopwatch> timers = new HashMap<String, Stopwatch>();
+ final Map<String, Stopwatch> timers = HashMap<String, Stopwatch>();
/// Get a timer associated with the given lint rule (or create one if none
/// exists).
Stopwatch getTimer(Linter linter) =>
- timers.putIfAbsent(linter.name, () => new Stopwatch());
+ timers.putIfAbsent(linter.name, () => Stopwatch());
}
diff --git a/pkg/analyzer/lib/src/source/custom_resolver.dart b/pkg/analyzer/lib/src/source/custom_resolver.dart
index 0ce922e..c16ba84 100644
--- a/pkg/analyzer/lib/src/source/custom_resolver.dart
+++ b/pkg/analyzer/lib/src/source/custom_resolver.dart
@@ -18,7 +18,7 @@
if (mapping == null) {
return null;
}
- Uri fileUri = new Uri.file(mapping);
+ Uri fileUri = Uri.file(mapping);
if (!fileUri.isAbsolute) {
return null;
}
diff --git a/pkg/analyzer/lib/src/source/package_map_resolver.dart b/pkg/analyzer/lib/src/source/package_map_resolver.dart
index 7d9fbf5..a9f1f88 100644
--- a/pkg/analyzer/lib/src/source/package_map_resolver.dart
+++ b/pkg/analyzer/lib/src/source/package_map_resolver.dart
@@ -41,7 +41,7 @@
asserts.notNull(packageMap);
packageMap.forEach((name, folders) {
if (folders.length != 1) {
- throw new ArgumentError(
+ throw ArgumentError(
'Exactly one folder must be specified for a package.'
'Found $name = $folders');
}
diff --git a/pkg/analyzer/lib/src/source/path_filter.dart b/pkg/analyzer/lib/src/source/path_filter.dart
index 57aa87e..31b798d 100644
--- a/pkg/analyzer/lib/src/source/path_filter.dart
+++ b/pkg/analyzer/lib/src/source/path_filter.dart
@@ -15,7 +15,7 @@
final String root;
/// List of ignore patterns that paths are tested against.
- final List<Glob> _ignorePatterns = new List<Glob>();
+ final List<Glob> _ignorePatterns = List<Glob>();
/// Construct a new path filter rooted at [root] with [ignorePatterns].
/// If [pathContext] is not specified, then the system path context is used.
@@ -37,14 +37,14 @@
_ignorePatterns.clear();
if (ignorePatterns != null) {
for (var ignorePattern in ignorePatterns) {
- _ignorePatterns.add(new Glob(pathContext.separator, ignorePattern));
+ _ignorePatterns.add(Glob(pathContext.separator, ignorePattern));
}
}
}
@override
String toString() {
- StringBuffer sb = new StringBuffer();
+ StringBuffer sb = StringBuffer();
for (Glob pattern in _ignorePatterns) {
sb.write('$pattern ');
}
diff --git a/pkg/analyzer/lib/src/source/sdk_ext.dart b/pkg/analyzer/lib/src/source/sdk_ext.dart
index 32a1e5b..2ec8f35 100644
--- a/pkg/analyzer/lib/src/source/sdk_ext.dart
+++ b/pkg/analyzer/lib/src/source/sdk_ext.dart
@@ -51,8 +51,7 @@
* Return a table mapping the names of extensions to the paths where those
* extensions can be found.
*/
- Map<String, String> get urlMappings =>
- new Map<String, String>.from(_urlMappings);
+ Map<String, String> get urlMappings => Map<String, String>.from(_urlMappings);
/// Return the path mapping for [libName] or null if there is none.
String operator [](String libName) => _urlMappings[libName];
@@ -74,7 +73,7 @@
return null;
}
// This mapping points to the main entry file of the sdk extension.
- Uri libraryEntry = new Uri.file(mapping);
+ Uri libraryEntry = Uri.file(mapping);
if (!libraryEntry.isAbsolute) {
// We expect an absolute path.
return null;
@@ -189,17 +188,17 @@
/// Resolve an import of an sdk extension.
Source _resolveEntry(Uri libraryEntry, Uri importUri) {
// Library entry.
- JavaFile javaFile = new JavaFile.fromUri(libraryEntry);
- return new FileBasedSource(javaFile, importUri);
+ JavaFile javaFile = JavaFile.fromUri(libraryEntry);
+ return FileBasedSource(javaFile, importUri);
}
/// Resolve a 'part' statement inside an sdk extension.
Source _resolvePart(Uri libraryEntry, String partPath, Uri importUri) {
// Library part.
var directory = pathos.dirname(libraryEntry.path);
- var partUri = new Uri.file(pathos.join(directory, partPath));
+ var partUri = Uri.file(pathos.join(directory, partPath));
assert(partUri.isAbsolute);
- JavaFile javaFile = new JavaFile.fromUri(partUri);
- return new FileBasedSource(javaFile, importUri);
+ JavaFile javaFile = JavaFile.fromUri(partUri);
+ return FileBasedSource(javaFile, importUri);
}
}
diff --git a/pkg/analyzer/lib/src/source/source_resource.dart b/pkg/analyzer/lib/src/source/source_resource.dart
index b722c9c..9616197 100644
--- a/pkg/analyzer/lib/src/source/source_resource.dart
+++ b/pkg/analyzer/lib/src/source/source_resource.dart
@@ -31,7 +31,7 @@
* The URI and filepath are joined into a pair by separating them with an '@'
* character.
*/
- static final Map<String, int> _idTable = new HashMap<String, int>();
+ static final Map<String, int> _idTable = HashMap<String, int>();
/**
* The URI from which this source was originally derived.
@@ -88,7 +88,7 @@
* See [contents].
*/
TimestampedData<String> get contentsFromFile {
- return new TimestampedData<String>(
+ return TimestampedData<String>(
modificationStamp, fileReadMode(file.readAsStringSync()));
}
diff --git a/pkg/analyzer/lib/src/string_source.dart b/pkg/analyzer/lib/src/string_source.dart
index 7663db4..811b493 100644
--- a/pkg/analyzer/lib/src/string_source.dart
+++ b/pkg/analyzer/lib/src/string_source.dart
@@ -25,12 +25,12 @@
StringSource(this._contents, String fullName, {Uri uri})
: this.fullName = fullName,
- uri = uri ?? (fullName == null ? null : new Uri.file(fullName)),
- modificationStamp = new DateTime.now().millisecondsSinceEpoch;
+ uri = uri ?? (fullName == null ? null : Uri.file(fullName)),
+ modificationStamp = DateTime.now().millisecondsSinceEpoch;
@override
TimestampedData<String> get contents =>
- new TimestampedData(modificationStamp, _contents);
+ TimestampedData(modificationStamp, _contents);
@override
String get encoding => uri.toString();
diff --git a/pkg/analyzer/lib/src/summary/api_signature.dart b/pkg/analyzer/lib/src/summary/api_signature.dart
index c86d8b8..1342dac 100644
--- a/pkg/analyzer/lib/src/summary/api_signature.dart
+++ b/pkg/analyzer/lib/src/summary/api_signature.dart
@@ -34,7 +34,7 @@
/**
* Data accumulated so far.
*/
- ByteData _data = new ByteData(4096);
+ ByteData _data = ByteData(4096);
/**
* Offset into [_data] where the next byte should be written.
@@ -117,14 +117,14 @@
* has been collected.
*/
List<int> getBytes_forDebug() {
- return new Uint8List.view(_data.buffer, 0, _offset).toList();
+ return Uint8List.view(_data.buffer, 0, _offset).toList();
}
/**
* Return the bytes of the MD5 hash of the data collected so far.
*/
List<int> toByteList() {
- return md5.convert(new Uint8List.view(_data.buffer, 0, _offset)).bytes;
+ return md5.convert(Uint8List.view(_data.buffer, 0, _offset)).bytes;
}
/**
@@ -142,9 +142,9 @@
int oldLength = _data.lengthInBytes;
if (_offset + spaceNeeded > oldLength) {
int newLength = 2 * (_offset + spaceNeeded);
- ByteData newData = new ByteData(newLength);
- new Uint8List.view(newData.buffer)
- .setRange(0, oldLength, new Uint8List.view(_data.buffer));
+ ByteData newData = ByteData(newLength);
+ Uint8List.view(newData.buffer)
+ .setRange(0, oldLength, Uint8List.view(_data.buffer));
_data = newData;
}
}
diff --git a/pkg/analyzer/lib/src/summary/flat_buffers.dart b/pkg/analyzer/lib/src/summary/flat_buffers.dart
index 96d0719..76320d3 100644
--- a/pkg/analyzer/lib/src/summary/flat_buffers.dart
+++ b/pkg/analyzer/lib/src/summary/flat_buffers.dart
@@ -20,7 +20,7 @@
@override
List<bool> read(BufferContext bc, int offset) =>
- new _FbBoolList(bc, bc.derefObject(offset));
+ _FbBoolList(bc, bc.derefObject(offset));
}
/**
@@ -44,8 +44,8 @@
factory BufferContext.fromBytes(List<int> byteList) {
Uint8List uint8List = _asUint8List(byteList);
- ByteData buf = new ByteData.view(uint8List.buffer, uint8List.offsetInBytes);
- return new BufferContext._(buf);
+ ByteData buf = ByteData.view(uint8List.buffer, uint8List.offsetInBytes);
+ return BufferContext._(buf);
}
BufferContext._(this._buffer);
@@ -77,7 +77,7 @@
if (byteList is Uint8List) {
return byteList;
} else {
- return new Uint8List.fromList(byteList);
+ return Uint8List.fromList(byteList);
}
}
}
@@ -132,7 +132,7 @@
*/
Map<String, Offset<String>> _strings = <String, Offset<String>>{};
- Builder({this.initialSize: 1024}) {
+ Builder({this.initialSize = 1024}) {
reset();
}
@@ -237,7 +237,7 @@
*/
Offset endTable() {
if (_currentVTable == null) {
- throw new StateError('Start a table before ending it.');
+ throw StateError('Start a table before ending it.');
}
// Prepare for writing the VTable.
_prepare(4, 1);
@@ -270,7 +270,7 @@
_setInt32AtTail(_buf, tableTail, vTableTail - tableTail);
// Done with this table.
_currentVTable = null;
- return new Offset(tableTail);
+ return Offset(tableTail);
}
/**
@@ -305,7 +305,7 @@
* This is a low-level method, it should not be invoked by clients.
*/
void lowReset() {
- _buf = new ByteData(initialSize);
+ _buf = ByteData(initialSize);
_maxAlign = 1;
_tail = 0;
}
@@ -330,7 +330,7 @@
* Reset the builder and make it ready for filling a new buffer.
*/
void reset() {
- _buf = new ByteData(initialSize);
+ _buf = ByteData(initialSize);
_maxAlign = 1;
_tail = 0;
_currentVTable = null;
@@ -341,9 +341,9 @@
*/
void startTable() {
if (_currentVTable != null) {
- throw new StateError('Inline tables are not supported.');
+ throw StateError('Inline tables are not supported.');
}
- _currentVTable = new _VTable(_reusedFieldTails, _reusedFieldOffsets);
+ _currentVTable = _VTable(_reusedFieldTails, _reusedFieldOffsets);
_currentTableEndTail = _tail;
}
@@ -353,7 +353,7 @@
Offset writeList(List<Offset> values) {
_ensureNoVTable();
_prepare(4, 1 + values.length);
- Offset result = new Offset(_tail);
+ Offset result = Offset(_tail);
int tail = _tail;
_setUint32AtTail(_buf, tail, values.length);
tail -= 4;
@@ -372,7 +372,7 @@
int padding = (-bitLength) % 8;
int byteLength = (bitLength + padding) ~/ 8;
// Prepare the backing Uint8List.
- Uint8List bytes = new Uint8List(byteLength + 1);
+ Uint8List bytes = Uint8List(byteLength + 1);
// Record every bit.
int byteIndex = 0;
int byte = 0;
@@ -402,7 +402,7 @@
Offset writeListFloat64(List<double> values) {
_ensureNoVTable();
_prepare(8, 1 + values.length);
- Offset result = new Offset(_tail);
+ Offset result = Offset(_tail);
int tail = _tail;
_setUint32AtTail(_buf, tail, values.length);
tail -= 8;
@@ -419,7 +419,7 @@
Offset writeListInt32(List<int> values) {
_ensureNoVTable();
_prepare(4, 1 + values.length);
- Offset result = new Offset(_tail);
+ Offset result = Offset(_tail);
int tail = _tail;
_setUint32AtTail(_buf, tail, values.length);
tail -= 4;
@@ -436,7 +436,7 @@
Offset writeListUint32(List<int> values) {
_ensureNoVTable();
_prepare(4, 1 + values.length);
- Offset result = new Offset(_tail);
+ Offset result = Offset(_tail);
int tail = _tail;
_setUint32AtTail(_buf, tail, values.length);
tail -= 4;
@@ -453,7 +453,7 @@
Offset writeListUint8(List<int> values) {
_ensureNoVTable();
_prepare(4, 1, additionalBytes: values.length);
- Offset result = new Offset(_tail);
+ Offset result = Offset(_tail);
int tail = _tail;
_setUint32AtTail(_buf, tail, values.length);
tail -= 4;
@@ -476,7 +476,7 @@
List<int> bytes = utf8.encode(value);
int length = bytes.length;
_prepare(4, 1, additionalBytes: length);
- Offset<String> result = new Offset(_tail);
+ Offset<String> result = Offset(_tail);
_setUint32AtTail(_buf, _tail, length);
int offset = _buf.lengthInBytes - _tail + 4;
for (int i = 0; i < length; i++) {
@@ -493,7 +493,7 @@
*/
void _ensureCurrentVTable() {
if (_currentVTable == null) {
- throw new StateError('Start a table before adding values.');
+ throw StateError('Start a table before adding values.');
}
}
@@ -502,7 +502,7 @@
*/
void _ensureNoVTable() {
if (_currentVTable != null) {
- throw new StateError(
+ throw StateError(
'Cannot write a non-scalar value while writing a table.');
}
}
@@ -512,7 +512,7 @@
* Additionally allocate the specified [additionalBytes]. Update the current
* tail pointer to point at the allocated space.
*/
- void _prepare(int size, int count, {int additionalBytes: 0}) {
+ void _prepare(int size, int count, {int additionalBytes = 0}) {
// Update the alignment.
if (_maxAlign < size) {
_maxAlign = size;
@@ -529,7 +529,7 @@
int deltaCapacity = desiredNewCapacity - oldCapacity;
deltaCapacity += (-deltaCapacity) % _maxAlign;
int newCapacity = oldCapacity + deltaCapacity;
- ByteData newBuf = new ByteData(newCapacity);
+ ByteData newBuf = ByteData(newCapacity);
newBuf.buffer
.asUint8List()
.setAll(deltaCapacity, _buf.buffer.asUint8List());
@@ -577,7 +577,7 @@
@override
List<double> read(BufferContext bc, int offset) =>
- new _FbFloat64List(bc, bc.derefObject(offset));
+ _FbFloat64List(bc, bc.derefObject(offset));
}
/**
@@ -634,7 +634,7 @@
@override
List<E> read(BufferContext bc, int offset) =>
- new _FbGenericList<E>(_elementReader, bc, bc.derefObject(offset));
+ _FbGenericList<E>(_elementReader, bc, bc.derefObject(offset));
}
/**
@@ -696,7 +696,7 @@
int length = bc._getUint32(strOffset);
Uint8List bytes = bc._asUint8LIst(strOffset + 4, length);
if (_isLatin(bytes)) {
- return new String.fromCharCodes(bytes);
+ return String.fromCharCodes(bytes);
}
return utf8.decode(bytes);
}
@@ -746,7 +746,7 @@
@override
List<int> read(BufferContext bc, int offset) =>
- new _FbUint32List(bc, bc.derefObject(offset));
+ _FbUint32List(bc, bc.derefObject(offset));
}
/**
@@ -775,7 +775,7 @@
@override
List<int> read(BufferContext bc, int offset) =>
- new _FbUint8List(bc, bc.derefObject(offset));
+ _FbUint8List(bc, bc.derefObject(offset));
}
/**
@@ -811,8 +811,7 @@
}
@override
- void set length(int i) =>
- throw new StateError('Attempt to modify immutable list');
+ set length(int i) => throw StateError('Attempt to modify immutable list');
@override
bool operator [](int i) {
@@ -823,7 +822,7 @@
@override
void operator []=(int i, bool e) =>
- throw new StateError('Attempt to modify immutable list');
+ throw StateError('Attempt to modify immutable list');
int _getByte(int index) => bc._getUint8(offset + 4 + index);
}
@@ -853,7 +852,7 @@
@override
E operator [](int i) {
- _items ??= new List<E>(length);
+ _items ??= List<E>(length);
E item = _items[i];
if (item == null) {
item = elementReader.read(bc, offset + 4 + elementReader.size * i);
@@ -880,12 +879,11 @@
}
@override
- void set length(int i) =>
- throw new StateError('Attempt to modify immutable list');
+ set length(int i) => throw StateError('Attempt to modify immutable list');
@override
void operator []=(int i, E e) =>
- throw new StateError('Attempt to modify immutable list');
+ throw StateError('Attempt to modify immutable list');
}
/**
diff --git a/pkg/analyzer/lib/src/summary/format.dart b/pkg/analyzer/lib/src/summary/format.dart
index 77fd089..7375134 100644
--- a/pkg/analyzer/lib/src/summary/format.dart
+++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -244,7 +244,7 @@
}
List<int> toBuffer() {
- fb.Builder fbBuilder = new fb.Builder();
+ fb.Builder fbBuilder = fb.Builder();
return fbBuilder.finish(finish(fbBuilder), "ADEC");
}
@@ -285,7 +285,7 @@
idl.AnalysisDriverExceptionContext readAnalysisDriverExceptionContext(
List<int> buffer) {
- fb.BufferContext rootRef = new fb.BufferContext.fromBytes(buffer);
+ fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
return const _AnalysisDriverExceptionContextReader().read(rootRef, 0);
}
@@ -296,7 +296,7 @@
@override
_AnalysisDriverExceptionContextImpl createObject(
fb.BufferContext bc, int offset) =>
- new _AnalysisDriverExceptionContextImpl(bc, offset);
+ _AnalysisDriverExceptionContextImpl(bc, offset);
}
class _AnalysisDriverExceptionContextImpl extends Object
@@ -345,11 +345,18 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (exception != '') _result["exception"] = exception;
- if (files.isNotEmpty)
+ if (exception != '') {
+ _result["exception"] = exception;
+ }
+ if (files.isNotEmpty) {
_result["files"] = files.map((_value) => _value.toJson()).toList();
- if (path != '') _result["path"] = path;
- if (stackTrace != '') _result["stackTrace"] = stackTrace;
+ }
+ if (path != '') {
+ _result["path"] = path;
+ }
+ if (stackTrace != '') {
+ _result["stackTrace"] = stackTrace;
+ }
return _result;
}
@@ -427,7 +434,7 @@
@override
_AnalysisDriverExceptionFileImpl createObject(
fb.BufferContext bc, int offset) =>
- new _AnalysisDriverExceptionFileImpl(bc, offset);
+ _AnalysisDriverExceptionFileImpl(bc, offset);
}
class _AnalysisDriverExceptionFileImpl extends Object
@@ -459,8 +466,12 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (content != '') _result["content"] = content;
- if (path != '') _result["path"] = path;
+ if (content != '') {
+ _result["content"] = content;
+ }
+ if (path != '') {
+ _result["path"] = path;
+ }
return _result;
}
@@ -524,7 +535,7 @@
}
List<int> toBuffer() {
- fb.Builder fbBuilder = new fb.Builder();
+ fb.Builder fbBuilder = fb.Builder();
return fbBuilder.finish(finish(fbBuilder), "ADRU");
}
@@ -551,7 +562,7 @@
idl.AnalysisDriverResolvedUnit readAnalysisDriverResolvedUnit(
List<int> buffer) {
- fb.BufferContext rootRef = new fb.BufferContext.fromBytes(buffer);
+ fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
return const _AnalysisDriverResolvedUnitReader().read(rootRef, 0);
}
@@ -562,7 +573,7 @@
@override
_AnalysisDriverResolvedUnitImpl createObject(
fb.BufferContext bc, int offset) =>
- new _AnalysisDriverResolvedUnitImpl(bc, offset);
+ _AnalysisDriverResolvedUnitImpl(bc, offset);
}
class _AnalysisDriverResolvedUnitImpl extends Object
@@ -597,9 +608,12 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (errors.isNotEmpty)
+ if (errors.isNotEmpty) {
_result["errors"] = errors.map((_value) => _value.toJson()).toList();
- if (index != null) _result["index"] = index.toJson();
+ }
+ if (index != null) {
+ _result["index"] = index.toJson();
+ }
return _result;
}
@@ -682,7 +696,7 @@
@override
_AnalysisDriverSubtypeImpl createObject(fb.BufferContext bc, int offset) =>
- new _AnalysisDriverSubtypeImpl(bc, offset);
+ _AnalysisDriverSubtypeImpl(bc, offset);
}
class _AnalysisDriverSubtypeImpl extends Object
@@ -715,8 +729,12 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (members.isNotEmpty) _result["members"] = members;
- if (name != 0) _result["name"] = name;
+ if (members.isNotEmpty) {
+ _result["members"] = members;
+ }
+ if (name != 0) {
+ _result["name"] = name;
+ }
return _result;
}
@@ -874,7 +892,7 @@
@override
_AnalysisDriverUnitErrorImpl createObject(fb.BufferContext bc, int offset) =>
- new _AnalysisDriverUnitErrorImpl(bc, offset);
+ _AnalysisDriverUnitErrorImpl(bc, offset);
}
class _AnalysisDriverUnitErrorImpl extends Object
@@ -936,14 +954,25 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (contextMessages.isNotEmpty)
+ if (contextMessages.isNotEmpty) {
_result["contextMessages"] =
contextMessages.map((_value) => _value.toJson()).toList();
- if (correction != '') _result["correction"] = correction;
- if (length != 0) _result["length"] = length;
- if (message != '') _result["message"] = message;
- if (offset != 0) _result["offset"] = offset;
- if (uniqueName != '') _result["uniqueName"] = uniqueName;
+ }
+ if (correction != '') {
+ _result["correction"] = correction;
+ }
+ if (length != 0) {
+ _result["length"] = length;
+ }
+ if (message != '') {
+ _result["message"] = message;
+ }
+ if (offset != 0) {
+ _result["offset"] = offset;
+ }
+ if (uniqueName != '') {
+ _result["uniqueName"] = uniqueName;
+ }
return _result;
}
@@ -1402,7 +1431,7 @@
}
List<int> toBuffer() {
- fb.Builder fbBuilder = new fb.Builder();
+ fb.Builder fbBuilder = fb.Builder();
return fbBuilder.finish(finish(fbBuilder), "ADUI");
}
@@ -1566,7 +1595,7 @@
}
idl.AnalysisDriverUnitIndex readAnalysisDriverUnitIndex(List<int> buffer) {
- fb.BufferContext rootRef = new fb.BufferContext.fromBytes(buffer);
+ fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
return const _AnalysisDriverUnitIndexReader().read(rootRef, 0);
}
@@ -1576,7 +1605,7 @@
@override
_AnalysisDriverUnitIndexImpl createObject(fb.BufferContext bc, int offset) =>
- new _AnalysisDriverUnitIndexImpl(bc, offset);
+ _AnalysisDriverUnitIndexImpl(bc, offset);
}
class _AnalysisDriverUnitIndexImpl extends Object
@@ -1757,45 +1786,72 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (elementKinds.isNotEmpty)
+ if (elementKinds.isNotEmpty) {
_result["elementKinds"] = elementKinds
.map((_value) => _value.toString().split('.')[1])
.toList();
- if (elementNameClassMemberIds.isNotEmpty)
+ }
+ if (elementNameClassMemberIds.isNotEmpty) {
_result["elementNameClassMemberIds"] = elementNameClassMemberIds;
- if (elementNameParameterIds.isNotEmpty)
+ }
+ if (elementNameParameterIds.isNotEmpty) {
_result["elementNameParameterIds"] = elementNameParameterIds;
- if (elementNameUnitMemberIds.isNotEmpty)
+ }
+ if (elementNameUnitMemberIds.isNotEmpty) {
_result["elementNameUnitMemberIds"] = elementNameUnitMemberIds;
- if (elementUnits.isNotEmpty) _result["elementUnits"] = elementUnits;
- if (nullStringId != 0) _result["nullStringId"] = nullStringId;
- if (strings.isNotEmpty) _result["strings"] = strings;
- if (subtypes.isNotEmpty)
+ }
+ if (elementUnits.isNotEmpty) {
+ _result["elementUnits"] = elementUnits;
+ }
+ if (nullStringId != 0) {
+ _result["nullStringId"] = nullStringId;
+ }
+ if (strings.isNotEmpty) {
+ _result["strings"] = strings;
+ }
+ if (subtypes.isNotEmpty) {
_result["subtypes"] = subtypes.map((_value) => _value.toJson()).toList();
- if (supertypes.isNotEmpty) _result["supertypes"] = supertypes;
- if (unitLibraryUris.isNotEmpty)
+ }
+ if (supertypes.isNotEmpty) {
+ _result["supertypes"] = supertypes;
+ }
+ if (unitLibraryUris.isNotEmpty) {
_result["unitLibraryUris"] = unitLibraryUris;
- if (unitUnitUris.isNotEmpty) _result["unitUnitUris"] = unitUnitUris;
- if (usedElementIsQualifiedFlags.isNotEmpty)
+ }
+ if (unitUnitUris.isNotEmpty) {
+ _result["unitUnitUris"] = unitUnitUris;
+ }
+ if (usedElementIsQualifiedFlags.isNotEmpty) {
_result["usedElementIsQualifiedFlags"] = usedElementIsQualifiedFlags;
- if (usedElementKinds.isNotEmpty)
+ }
+ if (usedElementKinds.isNotEmpty) {
_result["usedElementKinds"] = usedElementKinds
.map((_value) => _value.toString().split('.')[1])
.toList();
- if (usedElementLengths.isNotEmpty)
+ }
+ if (usedElementLengths.isNotEmpty) {
_result["usedElementLengths"] = usedElementLengths;
- if (usedElementOffsets.isNotEmpty)
+ }
+ if (usedElementOffsets.isNotEmpty) {
_result["usedElementOffsets"] = usedElementOffsets;
- if (usedElements.isNotEmpty) _result["usedElements"] = usedElements;
- if (usedNameIsQualifiedFlags.isNotEmpty)
+ }
+ if (usedElements.isNotEmpty) {
+ _result["usedElements"] = usedElements;
+ }
+ if (usedNameIsQualifiedFlags.isNotEmpty) {
_result["usedNameIsQualifiedFlags"] = usedNameIsQualifiedFlags;
- if (usedNameKinds.isNotEmpty)
+ }
+ if (usedNameKinds.isNotEmpty) {
_result["usedNameKinds"] = usedNameKinds
.map((_value) => _value.toString().split('.')[1])
.toList();
- if (usedNameOffsets.isNotEmpty)
+ }
+ if (usedNameOffsets.isNotEmpty) {
_result["usedNameOffsets"] = usedNameOffsets;
- if (usedNames.isNotEmpty) _result["usedNames"] = usedNames;
+ }
+ if (usedNames.isNotEmpty) {
+ _result["usedNames"] = usedNames;
+ }
return _result;
}
@@ -1934,7 +1990,7 @@
}
List<int> toBuffer() {
- fb.Builder fbBuilder = new fb.Builder();
+ fb.Builder fbBuilder = fb.Builder();
return fbBuilder.finish(finish(fbBuilder), "ADUU");
}
@@ -1988,7 +2044,7 @@
idl.AnalysisDriverUnlinkedUnit readAnalysisDriverUnlinkedUnit(
List<int> buffer) {
- fb.BufferContext rootRef = new fb.BufferContext.fromBytes(buffer);
+ fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
return const _AnalysisDriverUnlinkedUnitReader().read(rootRef, 0);
}
@@ -1999,7 +2055,7 @@
@override
_AnalysisDriverUnlinkedUnitImpl createObject(
fb.BufferContext bc, int offset) =>
- new _AnalysisDriverUnlinkedUnitImpl(bc, offset);
+ _AnalysisDriverUnlinkedUnitImpl(bc, offset);
}
class _AnalysisDriverUnlinkedUnitImpl extends Object
@@ -2058,14 +2114,21 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (definedClassMemberNames.isNotEmpty)
+ if (definedClassMemberNames.isNotEmpty) {
_result["definedClassMemberNames"] = definedClassMemberNames;
- if (definedTopLevelNames.isNotEmpty)
+ }
+ if (definedTopLevelNames.isNotEmpty) {
_result["definedTopLevelNames"] = definedTopLevelNames;
- if (referencedNames.isNotEmpty)
+ }
+ if (referencedNames.isNotEmpty) {
_result["referencedNames"] = referencedNames;
- if (subtypedNames.isNotEmpty) _result["subtypedNames"] = subtypedNames;
- if (unit2 != null) _result["unit2"] = unit2.toJson();
+ }
+ if (subtypedNames.isNotEmpty) {
+ _result["subtypedNames"] = subtypedNames;
+ }
+ if (unit2 != null) {
+ _result["unit2"] = unit2.toJson();
+ }
return _result;
}
@@ -2553,7 +2616,7 @@
@override
_AvailableDeclarationImpl createObject(fb.BufferContext bc, int offset) =>
- new _AvailableDeclarationImpl(bc, offset);
+ _AvailableDeclarationImpl(bc, offset);
}
class _AvailableDeclarationImpl extends Object
@@ -2752,37 +2815,78 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (children.isNotEmpty)
+ if (children.isNotEmpty) {
_result["children"] = children.map((_value) => _value.toJson()).toList();
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (defaultArgumentListString != '')
+ }
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (defaultArgumentListString != '') {
_result["defaultArgumentListString"] = defaultArgumentListString;
- if (defaultArgumentListTextRanges.isNotEmpty)
+ }
+ if (defaultArgumentListTextRanges.isNotEmpty) {
_result["defaultArgumentListTextRanges"] = defaultArgumentListTextRanges;
- if (docComplete != '') _result["docComplete"] = docComplete;
- if (docSummary != '') _result["docSummary"] = docSummary;
- if (fieldMask != 0) _result["fieldMask"] = fieldMask;
- if (isAbstract != false) _result["isAbstract"] = isAbstract;
- if (isConst != false) _result["isConst"] = isConst;
- if (isDeprecated != false) _result["isDeprecated"] = isDeprecated;
- if (isFinal != false) _result["isFinal"] = isFinal;
- if (kind != idl.AvailableDeclarationKind.CLASS)
+ }
+ if (docComplete != '') {
+ _result["docComplete"] = docComplete;
+ }
+ if (docSummary != '') {
+ _result["docSummary"] = docSummary;
+ }
+ if (fieldMask != 0) {
+ _result["fieldMask"] = fieldMask;
+ }
+ if (isAbstract != false) {
+ _result["isAbstract"] = isAbstract;
+ }
+ if (isConst != false) {
+ _result["isConst"] = isConst;
+ }
+ if (isDeprecated != false) {
+ _result["isDeprecated"] = isDeprecated;
+ }
+ if (isFinal != false) {
+ _result["isFinal"] = isFinal;
+ }
+ if (kind != idl.AvailableDeclarationKind.CLASS) {
_result["kind"] = kind.toString().split('.')[1];
- if (locationOffset != 0) _result["locationOffset"] = locationOffset;
- if (locationStartColumn != 0)
+ }
+ if (locationOffset != 0) {
+ _result["locationOffset"] = locationOffset;
+ }
+ if (locationStartColumn != 0) {
_result["locationStartColumn"] = locationStartColumn;
- if (locationStartLine != 0)
+ }
+ if (locationStartLine != 0) {
_result["locationStartLine"] = locationStartLine;
- if (name != '') _result["name"] = name;
- if (parameterNames.isNotEmpty) _result["parameterNames"] = parameterNames;
- if (parameters != '') _result["parameters"] = parameters;
- if (parameterTypes.isNotEmpty) _result["parameterTypes"] = parameterTypes;
- if (relevanceTags.isNotEmpty) _result["relevanceTags"] = relevanceTags;
- if (requiredParameterCount != 0)
+ }
+ if (name != '') {
+ _result["name"] = name;
+ }
+ if (parameterNames.isNotEmpty) {
+ _result["parameterNames"] = parameterNames;
+ }
+ if (parameters != '') {
+ _result["parameters"] = parameters;
+ }
+ if (parameterTypes.isNotEmpty) {
+ _result["parameterTypes"] = parameterTypes;
+ }
+ if (relevanceTags.isNotEmpty) {
+ _result["relevanceTags"] = relevanceTags;
+ }
+ if (requiredParameterCount != 0) {
_result["requiredParameterCount"] = requiredParameterCount;
- if (returnType != '') _result["returnType"] = returnType;
- if (typeParameters != '') _result["typeParameters"] = typeParameters;
+ }
+ if (returnType != '') {
+ _result["returnType"] = returnType;
+ }
+ if (typeParameters != '') {
+ _result["typeParameters"] = typeParameters;
+ }
return _result;
}
@@ -2945,7 +3049,7 @@
}
List<int> toBuffer() {
- fb.Builder fbBuilder = new fb.Builder();
+ fb.Builder fbBuilder = fb.Builder();
return fbBuilder.finish(finish(fbBuilder), "UICF");
}
@@ -3000,7 +3104,7 @@
}
idl.AvailableFile readAvailableFile(List<int> buffer) {
- fb.BufferContext rootRef = new fb.BufferContext.fromBytes(buffer);
+ fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
return const _AvailableFileReader().read(rootRef, 0);
}
@@ -3009,7 +3113,7 @@
@override
_AvailableFileImpl createObject(fb.BufferContext bc, int offset) =>
- new _AvailableFileImpl(bc, offset);
+ _AvailableFileImpl(bc, offset);
}
class _AvailableFileImpl extends Object
@@ -3083,18 +3187,28 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (declarations.isNotEmpty)
+ if (declarations.isNotEmpty) {
_result["declarations"] =
declarations.map((_value) => _value.toJson()).toList();
- if (directiveInfo != null)
+ }
+ if (directiveInfo != null) {
_result["directiveInfo"] = directiveInfo.toJson();
- if (exports.isNotEmpty)
+ }
+ if (exports.isNotEmpty) {
_result["exports"] = exports.map((_value) => _value.toJson()).toList();
- if (isLibrary != false) _result["isLibrary"] = isLibrary;
- if (isLibraryDeprecated != false)
+ }
+ if (isLibrary != false) {
+ _result["isLibrary"] = isLibrary;
+ }
+ if (isLibraryDeprecated != false) {
_result["isLibraryDeprecated"] = isLibraryDeprecated;
- if (lineStarts.isNotEmpty) _result["lineStarts"] = lineStarts;
- if (parts.isNotEmpty) _result["parts"] = parts;
+ }
+ if (lineStarts.isNotEmpty) {
+ _result["lineStarts"] = lineStarts;
+ }
+ if (parts.isNotEmpty) {
+ _result["parts"] = parts;
+ }
return _result;
}
@@ -3186,7 +3300,7 @@
@override
_AvailableFileExportImpl createObject(fb.BufferContext bc, int offset) =>
- new _AvailableFileExportImpl(bc, offset);
+ _AvailableFileExportImpl(bc, offset);
}
class _AvailableFileExportImpl extends Object
@@ -3220,10 +3334,13 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (combinators.isNotEmpty)
+ if (combinators.isNotEmpty) {
_result["combinators"] =
combinators.map((_value) => _value.toJson()).toList();
- if (uri != '') _result["uri"] = uri;
+ }
+ if (uri != '') {
+ _result["uri"] = uri;
+ }
return _result;
}
@@ -3315,7 +3432,7 @@
@override
_AvailableFileExportCombinatorImpl createObject(
fb.BufferContext bc, int offset) =>
- new _AvailableFileExportCombinatorImpl(bc, offset);
+ _AvailableFileExportCombinatorImpl(bc, offset);
}
class _AvailableFileExportCombinatorImpl extends Object
@@ -3349,8 +3466,12 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (hides.isNotEmpty) _result["hides"] = hides;
- if (shows.isNotEmpty) _result["shows"] = shows;
+ if (hides.isNotEmpty) {
+ _result["hides"] = hides;
+ }
+ if (shows.isNotEmpty) {
+ _result["shows"] = shows;
+ }
return _result;
}
@@ -3456,7 +3577,7 @@
@override
_DiagnosticMessageImpl createObject(fb.BufferContext bc, int offset) =>
- new _DiagnosticMessageImpl(bc, offset);
+ _DiagnosticMessageImpl(bc, offset);
}
class _DiagnosticMessageImpl extends Object
@@ -3501,10 +3622,18 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (filePath != '') _result["filePath"] = filePath;
- if (length != 0) _result["length"] = length;
- if (message != '') _result["message"] = message;
- if (offset != 0) _result["offset"] = offset;
+ if (filePath != '') {
+ _result["filePath"] = filePath;
+ }
+ if (length != 0) {
+ _result["length"] = length;
+ }
+ if (message != '') {
+ _result["message"] = message;
+ }
+ if (offset != 0) {
+ _result["offset"] = offset;
+ }
return _result;
}
@@ -3597,7 +3726,7 @@
@override
_DirectiveInfoImpl createObject(fb.BufferContext bc, int offset) =>
- new _DirectiveInfoImpl(bc, offset);
+ _DirectiveInfoImpl(bc, offset);
}
class _DirectiveInfoImpl extends Object
@@ -3630,8 +3759,12 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (templateNames.isNotEmpty) _result["templateNames"] = templateNames;
- if (templateValues.isNotEmpty) _result["templateValues"] = templateValues;
+ if (templateNames.isNotEmpty) {
+ _result["templateNames"] = templateNames;
+ }
+ if (templateValues.isNotEmpty) {
+ _result["templateValues"] = templateValues;
+ }
return _result;
}
@@ -10167,7 +10300,7 @@
@override
_LinkedNodeImpl createObject(fb.BufferContext bc, int offset) =>
- new _LinkedNodeImpl(bc, offset);
+ _LinkedNodeImpl(bc, offset);
}
class _LinkedNodeImpl extends Object
@@ -12425,1201 +12558,1613 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (flags != 0) _result["flags"] = flags;
- if (kind != idl.LinkedNodeKind.adjacentStrings)
+ if (flags != 0) {
+ _result["flags"] = flags;
+ }
+ if (kind != idl.LinkedNodeKind.adjacentStrings) {
_result["kind"] = kind.toString().split('.')[1];
- if (name != '') _result["name"] = name;
+ }
+ if (name != '') {
+ _result["name"] = name;
+ }
if (kind == idl.LinkedNodeKind.adjacentStrings) {
- if (adjacentStrings_strings.isNotEmpty)
+ if (adjacentStrings_strings.isNotEmpty) {
_result["adjacentStrings_strings"] =
adjacentStrings_strings.map((_value) => _value.toJson()).toList();
+ }
}
if (kind == idl.LinkedNodeKind.annotation) {
- if (annotation_arguments != null)
+ if (annotation_arguments != null) {
_result["annotation_arguments"] = annotation_arguments.toJson();
- if (annotation_constructorName != null)
+ }
+ if (annotation_constructorName != null) {
_result["annotation_constructorName"] =
annotation_constructorName.toJson();
- if (annotation_element != 0)
+ }
+ if (annotation_element != 0) {
_result["annotation_element"] = annotation_element;
- if (annotation_name != null)
+ }
+ if (annotation_name != null) {
_result["annotation_name"] = annotation_name.toJson();
- if (annotation_substitution != null)
+ }
+ if (annotation_substitution != null) {
_result["annotation_substitution"] = annotation_substitution.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.argumentList) {
- if (argumentList_arguments.isNotEmpty)
+ if (argumentList_arguments.isNotEmpty) {
_result["argumentList_arguments"] =
argumentList_arguments.map((_value) => _value.toJson()).toList();
+ }
}
if (kind == idl.LinkedNodeKind.asExpression) {
- if (asExpression_expression != null)
+ if (asExpression_expression != null) {
_result["asExpression_expression"] = asExpression_expression.toJson();
- if (asExpression_type != null)
+ }
+ if (asExpression_type != null) {
_result["asExpression_type"] = asExpression_type.toJson();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.assertInitializer) {
- if (assertInitializer_condition != null)
+ if (assertInitializer_condition != null) {
_result["assertInitializer_condition"] =
assertInitializer_condition.toJson();
- if (assertInitializer_message != null)
+ }
+ if (assertInitializer_message != null) {
_result["assertInitializer_message"] =
assertInitializer_message.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.assertStatement) {
- if (assertStatement_condition != null)
+ if (assertStatement_condition != null) {
_result["assertStatement_condition"] =
assertStatement_condition.toJson();
- if (assertStatement_message != null)
+ }
+ if (assertStatement_message != null) {
_result["assertStatement_message"] = assertStatement_message.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.assignmentExpression) {
- if (assignmentExpression_leftHandSide != null)
+ if (assignmentExpression_leftHandSide != null) {
_result["assignmentExpression_leftHandSide"] =
assignmentExpression_leftHandSide.toJson();
- if (assignmentExpression_rightHandSide != null)
+ }
+ if (assignmentExpression_rightHandSide != null) {
_result["assignmentExpression_rightHandSide"] =
assignmentExpression_rightHandSide.toJson();
- if (assignmentExpression_substitution != null)
+ }
+ if (assignmentExpression_substitution != null) {
_result["assignmentExpression_substitution"] =
assignmentExpression_substitution.toJson();
- if (assignmentExpression_element != 0)
+ }
+ if (assignmentExpression_element != 0) {
_result["assignmentExpression_element"] = assignmentExpression_element;
- if (assignmentExpression_operator != idl.UnlinkedTokenType.NOTHING)
+ }
+ if (assignmentExpression_operator != idl.UnlinkedTokenType.NOTHING) {
_result["assignmentExpression_operator"] =
assignmentExpression_operator.toString().split('.')[1];
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.awaitExpression) {
- if (awaitExpression_expression != null)
+ if (awaitExpression_expression != null) {
_result["awaitExpression_expression"] =
awaitExpression_expression.toJson();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.binaryExpression) {
- if (binaryExpression_invokeType != null)
+ if (binaryExpression_invokeType != null) {
_result["binaryExpression_invokeType"] =
binaryExpression_invokeType.toJson();
- if (binaryExpression_leftOperand != null)
+ }
+ if (binaryExpression_leftOperand != null) {
_result["binaryExpression_leftOperand"] =
binaryExpression_leftOperand.toJson();
- if (binaryExpression_rightOperand != null)
+ }
+ if (binaryExpression_rightOperand != null) {
_result["binaryExpression_rightOperand"] =
binaryExpression_rightOperand.toJson();
- if (binaryExpression_substitution != null)
+ }
+ if (binaryExpression_substitution != null) {
_result["binaryExpression_substitution"] =
binaryExpression_substitution.toJson();
- if (binaryExpression_element != 0)
+ }
+ if (binaryExpression_element != 0) {
_result["binaryExpression_element"] = binaryExpression_element;
- if (binaryExpression_operator != idl.UnlinkedTokenType.NOTHING)
+ }
+ if (binaryExpression_operator != idl.UnlinkedTokenType.NOTHING) {
_result["binaryExpression_operator"] =
binaryExpression_operator.toString().split('.')[1];
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.block) {
- if (block_statements.isNotEmpty)
+ if (block_statements.isNotEmpty) {
_result["block_statements"] =
block_statements.map((_value) => _value.toJson()).toList();
+ }
}
if (kind == idl.LinkedNodeKind.blockFunctionBody) {
- if (blockFunctionBody_block != null)
+ if (blockFunctionBody_block != null) {
_result["blockFunctionBody_block"] = blockFunctionBody_block.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.booleanLiteral) {
- if (booleanLiteral_value != false)
+ if (booleanLiteral_value != false) {
_result["booleanLiteral_value"] = booleanLiteral_value;
+ }
}
if (kind == idl.LinkedNodeKind.breakStatement) {
- if (breakStatement_label != null)
+ if (breakStatement_label != null) {
_result["breakStatement_label"] = breakStatement_label.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.cascadeExpression) {
- if (cascadeExpression_sections.isNotEmpty)
+ if (cascadeExpression_sections.isNotEmpty) {
_result["cascadeExpression_sections"] = cascadeExpression_sections
.map((_value) => _value.toJson())
.toList();
- if (cascadeExpression_target != null)
+ }
+ if (cascadeExpression_target != null) {
_result["cascadeExpression_target"] = cascadeExpression_target.toJson();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.catchClause) {
- if (catchClause_body != null)
+ if (catchClause_body != null) {
_result["catchClause_body"] = catchClause_body.toJson();
- if (catchClause_exceptionParameter != null)
+ }
+ if (catchClause_exceptionParameter != null) {
_result["catchClause_exceptionParameter"] =
catchClause_exceptionParameter.toJson();
- if (catchClause_exceptionType != null)
+ }
+ if (catchClause_exceptionType != null) {
_result["catchClause_exceptionType"] =
catchClause_exceptionType.toJson();
- if (catchClause_stackTraceParameter != null)
+ }
+ if (catchClause_stackTraceParameter != null) {
_result["catchClause_stackTraceParameter"] =
catchClause_stackTraceParameter.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.classDeclaration) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (classDeclaration_extendsClause != null)
+ }
+ if (classDeclaration_extendsClause != null) {
_result["classDeclaration_extendsClause"] =
classDeclaration_extendsClause.toJson();
- if (classDeclaration_withClause != null)
+ }
+ if (classDeclaration_withClause != null) {
_result["classDeclaration_withClause"] =
classDeclaration_withClause.toJson();
- if (classDeclaration_nativeClause != null)
+ }
+ if (classDeclaration_nativeClause != null) {
_result["classDeclaration_nativeClause"] =
classDeclaration_nativeClause.toJson();
- if (classDeclaration_isDartObject != false)
+ }
+ if (classDeclaration_isDartObject != false) {
_result["classDeclaration_isDartObject"] =
classDeclaration_isDartObject;
- if (classOrMixinDeclaration_implementsClause != null)
+ }
+ if (classOrMixinDeclaration_implementsClause != null) {
_result["classOrMixinDeclaration_implementsClause"] =
classOrMixinDeclaration_implementsClause.toJson();
- if (classOrMixinDeclaration_members.isNotEmpty)
+ }
+ if (classOrMixinDeclaration_members.isNotEmpty) {
_result["classOrMixinDeclaration_members"] =
classOrMixinDeclaration_members
.map((_value) => _value.toJson())
.toList();
- if (classOrMixinDeclaration_typeParameters != null)
+ }
+ if (classOrMixinDeclaration_typeParameters != null) {
_result["classOrMixinDeclaration_typeParameters"] =
classOrMixinDeclaration_typeParameters.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (simplyBoundable_isSimplyBounded != false)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (simplyBoundable_isSimplyBounded != false) {
_result["simplyBoundable_isSimplyBounded"] =
simplyBoundable_isSimplyBounded;
- if (unused11 != null) _result["unused11"] = unused11.toJson();
+ }
+ if (unused11 != null) {
+ _result["unused11"] = unused11.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.classTypeAlias) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (classTypeAlias_typeParameters != null)
+ }
+ if (classTypeAlias_typeParameters != null) {
_result["classTypeAlias_typeParameters"] =
classTypeAlias_typeParameters.toJson();
- if (classTypeAlias_superclass != null)
+ }
+ if (classTypeAlias_superclass != null) {
_result["classTypeAlias_superclass"] =
classTypeAlias_superclass.toJson();
- if (classTypeAlias_withClause != null)
+ }
+ if (classTypeAlias_withClause != null) {
_result["classTypeAlias_withClause"] =
classTypeAlias_withClause.toJson();
- if (classTypeAlias_implementsClause != null)
+ }
+ if (classTypeAlias_implementsClause != null) {
_result["classTypeAlias_implementsClause"] =
classTypeAlias_implementsClause.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (simplyBoundable_isSimplyBounded != false)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (simplyBoundable_isSimplyBounded != false) {
_result["simplyBoundable_isSimplyBounded"] =
simplyBoundable_isSimplyBounded;
+ }
}
if (kind == idl.LinkedNodeKind.comment) {
- if (comment_references.isNotEmpty)
+ if (comment_references.isNotEmpty) {
_result["comment_references"] =
comment_references.map((_value) => _value.toJson()).toList();
- if (comment_tokens.isNotEmpty) _result["comment_tokens"] = comment_tokens;
- if (comment_type != idl.LinkedNodeCommentType.block)
+ }
+ if (comment_tokens.isNotEmpty) {
+ _result["comment_tokens"] = comment_tokens;
+ }
+ if (comment_type != idl.LinkedNodeCommentType.block) {
_result["comment_type"] = comment_type.toString().split('.')[1];
+ }
}
if (kind == idl.LinkedNodeKind.commentReference) {
- if (commentReference_identifier != null)
+ if (commentReference_identifier != null) {
_result["commentReference_identifier"] =
commentReference_identifier.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.compilationUnit) {
- if (compilationUnit_declarations.isNotEmpty)
+ if (compilationUnit_declarations.isNotEmpty) {
_result["compilationUnit_declarations"] = compilationUnit_declarations
.map((_value) => _value.toJson())
.toList();
- if (compilationUnit_scriptTag != null)
+ }
+ if (compilationUnit_scriptTag != null) {
_result["compilationUnit_scriptTag"] =
compilationUnit_scriptTag.toJson();
- if (compilationUnit_directives.isNotEmpty)
+ }
+ if (compilationUnit_directives.isNotEmpty) {
_result["compilationUnit_directives"] = compilationUnit_directives
.map((_value) => _value.toJson())
.toList();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.conditionalExpression) {
- if (conditionalExpression_condition != null)
+ if (conditionalExpression_condition != null) {
_result["conditionalExpression_condition"] =
conditionalExpression_condition.toJson();
- if (conditionalExpression_elseExpression != null)
+ }
+ if (conditionalExpression_elseExpression != null) {
_result["conditionalExpression_elseExpression"] =
conditionalExpression_elseExpression.toJson();
- if (conditionalExpression_thenExpression != null)
+ }
+ if (conditionalExpression_thenExpression != null) {
_result["conditionalExpression_thenExpression"] =
conditionalExpression_thenExpression.toJson();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.configuration) {
- if (configuration_name != null)
+ if (configuration_name != null) {
_result["configuration_name"] = configuration_name.toJson();
- if (configuration_value != null)
+ }
+ if (configuration_value != null) {
_result["configuration_value"] = configuration_value.toJson();
- if (configuration_uri != null)
+ }
+ if (configuration_uri != null) {
_result["configuration_uri"] = configuration_uri.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.constructorDeclaration) {
- if (constructorDeclaration_initializers.isNotEmpty)
+ if (constructorDeclaration_initializers.isNotEmpty) {
_result["constructorDeclaration_initializers"] =
constructorDeclaration_initializers
.map((_value) => _value.toJson())
.toList();
- if (annotatedNode_metadata.isNotEmpty)
+ }
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (constructorDeclaration_body != null)
+ }
+ if (constructorDeclaration_body != null) {
_result["constructorDeclaration_body"] =
constructorDeclaration_body.toJson();
- if (constructorDeclaration_parameters != null)
+ }
+ if (constructorDeclaration_parameters != null) {
_result["constructorDeclaration_parameters"] =
constructorDeclaration_parameters.toJson();
- if (constructorDeclaration_redirectedConstructor != null)
+ }
+ if (constructorDeclaration_redirectedConstructor != null) {
_result["constructorDeclaration_redirectedConstructor"] =
constructorDeclaration_redirectedConstructor.toJson();
- if (constructorDeclaration_returnType != null)
+ }
+ if (constructorDeclaration_returnType != null) {
_result["constructorDeclaration_returnType"] =
constructorDeclaration_returnType.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.constructorFieldInitializer) {
- if (constructorFieldInitializer_expression != null)
+ if (constructorFieldInitializer_expression != null) {
_result["constructorFieldInitializer_expression"] =
constructorFieldInitializer_expression.toJson();
- if (constructorFieldInitializer_fieldName != null)
+ }
+ if (constructorFieldInitializer_fieldName != null) {
_result["constructorFieldInitializer_fieldName"] =
constructorFieldInitializer_fieldName.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.constructorName) {
- if (constructorName_name != null)
+ if (constructorName_name != null) {
_result["constructorName_name"] = constructorName_name.toJson();
- if (constructorName_type != null)
+ }
+ if (constructorName_type != null) {
_result["constructorName_type"] = constructorName_type.toJson();
- if (constructorName_substitution != null)
+ }
+ if (constructorName_substitution != null) {
_result["constructorName_substitution"] =
constructorName_substitution.toJson();
- if (constructorName_element != 0)
+ }
+ if (constructorName_element != 0) {
_result["constructorName_element"] = constructorName_element;
+ }
}
if (kind == idl.LinkedNodeKind.continueStatement) {
- if (continueStatement_label != null)
+ if (continueStatement_label != null) {
_result["continueStatement_label"] = continueStatement_label.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.declaredIdentifier) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (declaredIdentifier_identifier != null)
+ }
+ if (declaredIdentifier_identifier != null) {
_result["declaredIdentifier_identifier"] =
declaredIdentifier_identifier.toJson();
- if (declaredIdentifier_type != null)
+ }
+ if (declaredIdentifier_type != null) {
_result["declaredIdentifier_type"] = declaredIdentifier_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.defaultFormalParameter) {
- if (defaultFormalParameter_defaultValue != null)
+ if (defaultFormalParameter_defaultValue != null) {
_result["defaultFormalParameter_defaultValue"] =
defaultFormalParameter_defaultValue.toJson();
- if (defaultFormalParameter_parameter != null)
+ }
+ if (defaultFormalParameter_parameter != null) {
_result["defaultFormalParameter_parameter"] =
defaultFormalParameter_parameter.toJson();
+ }
if (defaultFormalParameter_kind !=
- idl.LinkedNodeFormalParameterKind.requiredPositional)
+ idl.LinkedNodeFormalParameterKind.requiredPositional) {
_result["defaultFormalParameter_kind"] =
defaultFormalParameter_kind.toString().split('.')[1];
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.doStatement) {
- if (doStatement_body != null)
+ if (doStatement_body != null) {
_result["doStatement_body"] = doStatement_body.toJson();
- if (doStatement_condition != null)
+ }
+ if (doStatement_condition != null) {
_result["doStatement_condition"] = doStatement_condition.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.dottedName) {
- if (dottedName_components.isNotEmpty)
+ if (dottedName_components.isNotEmpty) {
_result["dottedName_components"] =
dottedName_components.map((_value) => _value.toJson()).toList();
+ }
}
if (kind == idl.LinkedNodeKind.doubleLiteral) {
- if (doubleLiteral_value != 0.0)
+ if (doubleLiteral_value != 0.0) {
_result["doubleLiteral_value"] = doubleLiteral_value.isFinite
? doubleLiteral_value
: doubleLiteral_value.toString();
+ }
}
if (kind == idl.LinkedNodeKind.emptyFunctionBody) {
- if (emptyFunctionBody_fake != 0)
+ if (emptyFunctionBody_fake != 0) {
_result["emptyFunctionBody_fake"] = emptyFunctionBody_fake;
+ }
}
if (kind == idl.LinkedNodeKind.emptyStatement) {
- if (emptyStatement_fake != 0)
+ if (emptyStatement_fake != 0) {
_result["emptyStatement_fake"] = emptyStatement_fake;
+ }
}
if (kind == idl.LinkedNodeKind.enumConstantDeclaration) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.enumDeclaration) {
- if (enumDeclaration_constants.isNotEmpty)
+ if (enumDeclaration_constants.isNotEmpty) {
_result["enumDeclaration_constants"] =
enumDeclaration_constants.map((_value) => _value.toJson()).toList();
- if (annotatedNode_metadata.isNotEmpty)
+ }
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.exportDirective) {
- if (namespaceDirective_combinators.isNotEmpty)
+ if (namespaceDirective_combinators.isNotEmpty) {
_result["namespaceDirective_combinators"] =
namespaceDirective_combinators
.map((_value) => _value.toJson())
.toList();
- if (annotatedNode_metadata.isNotEmpty)
+ }
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (namespaceDirective_configurations.isNotEmpty)
+ }
+ if (namespaceDirective_configurations.isNotEmpty) {
_result["namespaceDirective_configurations"] =
namespaceDirective_configurations
.map((_value) => _value.toJson())
.toList();
- if (namespaceDirective_selectedUri != '')
+ }
+ if (namespaceDirective_selectedUri != '') {
_result["namespaceDirective_selectedUri"] =
namespaceDirective_selectedUri;
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (uriBasedDirective_uri != null)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (uriBasedDirective_uri != null) {
_result["uriBasedDirective_uri"] = uriBasedDirective_uri.toJson();
- if (uriBasedDirective_uriContent != '')
+ }
+ if (uriBasedDirective_uriContent != '') {
_result["uriBasedDirective_uriContent"] = uriBasedDirective_uriContent;
- if (uriBasedDirective_uriElement != 0)
+ }
+ if (uriBasedDirective_uriElement != 0) {
_result["uriBasedDirective_uriElement"] = uriBasedDirective_uriElement;
+ }
}
if (kind == idl.LinkedNodeKind.expressionFunctionBody) {
- if (expressionFunctionBody_expression != null)
+ if (expressionFunctionBody_expression != null) {
_result["expressionFunctionBody_expression"] =
expressionFunctionBody_expression.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.expressionStatement) {
- if (expressionStatement_expression != null)
+ if (expressionStatement_expression != null) {
_result["expressionStatement_expression"] =
expressionStatement_expression.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.extendsClause) {
- if (extendsClause_superclass != null)
+ if (extendsClause_superclass != null) {
_result["extendsClause_superclass"] = extendsClause_superclass.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.extensionDeclaration) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (extensionDeclaration_typeParameters != null)
+ }
+ if (extensionDeclaration_typeParameters != null) {
_result["extensionDeclaration_typeParameters"] =
extensionDeclaration_typeParameters.toJson();
- if (extensionDeclaration_extendedType != null)
+ }
+ if (extensionDeclaration_extendedType != null) {
_result["extensionDeclaration_extendedType"] =
extensionDeclaration_extendedType.toJson();
- if (extensionDeclaration_members.isNotEmpty)
+ }
+ if (extensionDeclaration_members.isNotEmpty) {
_result["extensionDeclaration_members"] = extensionDeclaration_members
.map((_value) => _value.toJson())
.toList();
- if (extensionDeclaration_refName != '')
+ }
+ if (extensionDeclaration_refName != '') {
_result["extensionDeclaration_refName"] = extensionDeclaration_refName;
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.extensionOverride) {
- if (extensionOverride_extendedType != null)
+ if (extensionOverride_extendedType != null) {
_result["extensionOverride_extendedType"] =
extensionOverride_extendedType.toJson();
- if (extensionOverride_arguments.isNotEmpty)
+ }
+ if (extensionOverride_arguments.isNotEmpty) {
_result["extensionOverride_arguments"] = extensionOverride_arguments
.map((_value) => _value.toJson())
.toList();
- if (extensionOverride_extensionName != null)
+ }
+ if (extensionOverride_extensionName != null) {
_result["extensionOverride_extensionName"] =
extensionOverride_extensionName.toJson();
- if (extensionOverride_typeArguments != null)
+ }
+ if (extensionOverride_typeArguments != null) {
_result["extensionOverride_typeArguments"] =
extensionOverride_typeArguments.toJson();
- if (extensionOverride_typeArgumentTypes.isNotEmpty)
+ }
+ if (extensionOverride_typeArgumentTypes.isNotEmpty) {
_result["extensionOverride_typeArgumentTypes"] =
extensionOverride_typeArgumentTypes
.map((_value) => _value.toJson())
.toList();
+ }
}
if (kind == idl.LinkedNodeKind.fieldDeclaration) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (fieldDeclaration_fields != null)
+ }
+ if (fieldDeclaration_fields != null) {
_result["fieldDeclaration_fields"] = fieldDeclaration_fields.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.fieldFormalParameter) {
- if (actualType != null) _result["actualType"] = actualType.toJson();
- if (normalFormalParameter_metadata.isNotEmpty)
+ if (actualType != null) {
+ _result["actualType"] = actualType.toJson();
+ }
+ if (normalFormalParameter_metadata.isNotEmpty) {
_result["normalFormalParameter_metadata"] =
normalFormalParameter_metadata
.map((_value) => _value.toJson())
.toList();
- if (fieldFormalParameter_type != null)
+ }
+ if (fieldFormalParameter_type != null) {
_result["fieldFormalParameter_type"] =
fieldFormalParameter_type.toJson();
- if (fieldFormalParameter_typeParameters != null)
+ }
+ if (fieldFormalParameter_typeParameters != null) {
_result["fieldFormalParameter_typeParameters"] =
fieldFormalParameter_typeParameters.toJson();
- if (fieldFormalParameter_formalParameters != null)
+ }
+ if (fieldFormalParameter_formalParameters != null) {
_result["fieldFormalParameter_formalParameters"] =
fieldFormalParameter_formalParameters.toJson();
- if (inheritsCovariant != false)
+ }
+ if (inheritsCovariant != false) {
_result["inheritsCovariant"] = inheritsCovariant;
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.forEachPartsWithDeclaration) {
- if (forEachParts_iterable != null)
+ if (forEachParts_iterable != null) {
_result["forEachParts_iterable"] = forEachParts_iterable.toJson();
- if (forEachPartsWithDeclaration_loopVariable != null)
+ }
+ if (forEachPartsWithDeclaration_loopVariable != null) {
_result["forEachPartsWithDeclaration_loopVariable"] =
forEachPartsWithDeclaration_loopVariable.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.forEachPartsWithIdentifier) {
- if (forEachParts_iterable != null)
+ if (forEachParts_iterable != null) {
_result["forEachParts_iterable"] = forEachParts_iterable.toJson();
- if (forEachPartsWithIdentifier_identifier != null)
+ }
+ if (forEachPartsWithIdentifier_identifier != null) {
_result["forEachPartsWithIdentifier_identifier"] =
forEachPartsWithIdentifier_identifier.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.forElement) {
- if (forMixin_forLoopParts != null)
+ if (forMixin_forLoopParts != null) {
_result["forMixin_forLoopParts"] = forMixin_forLoopParts.toJson();
- if (forElement_body != null)
+ }
+ if (forElement_body != null) {
_result["forElement_body"] = forElement_body.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.forPartsWithDeclarations) {
- if (forParts_condition != null)
+ if (forParts_condition != null) {
_result["forParts_condition"] = forParts_condition.toJson();
- if (forPartsWithDeclarations_variables != null)
+ }
+ if (forPartsWithDeclarations_variables != null) {
_result["forPartsWithDeclarations_variables"] =
forPartsWithDeclarations_variables.toJson();
- if (forParts_updaters.isNotEmpty)
+ }
+ if (forParts_updaters.isNotEmpty) {
_result["forParts_updaters"] =
forParts_updaters.map((_value) => _value.toJson()).toList();
+ }
}
if (kind == idl.LinkedNodeKind.forPartsWithExpression) {
- if (forParts_condition != null)
+ if (forParts_condition != null) {
_result["forParts_condition"] = forParts_condition.toJson();
- if (forPartsWithExpression_initialization != null)
+ }
+ if (forPartsWithExpression_initialization != null) {
_result["forPartsWithExpression_initialization"] =
forPartsWithExpression_initialization.toJson();
- if (forParts_updaters.isNotEmpty)
+ }
+ if (forParts_updaters.isNotEmpty) {
_result["forParts_updaters"] =
forParts_updaters.map((_value) => _value.toJson()).toList();
+ }
}
if (kind == idl.LinkedNodeKind.forStatement) {
- if (forMixin_forLoopParts != null)
+ if (forMixin_forLoopParts != null) {
_result["forMixin_forLoopParts"] = forMixin_forLoopParts.toJson();
- if (forStatement_body != null)
+ }
+ if (forStatement_body != null) {
_result["forStatement_body"] = forStatement_body.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.formalParameterList) {
- if (formalParameterList_parameters.isNotEmpty)
+ if (formalParameterList_parameters.isNotEmpty) {
_result["formalParameterList_parameters"] =
formalParameterList_parameters
.map((_value) => _value.toJson())
.toList();
+ }
}
if (kind == idl.LinkedNodeKind.functionDeclaration) {
- if (actualReturnType != null)
+ if (actualReturnType != null) {
_result["actualReturnType"] = actualReturnType.toJson();
- if (annotatedNode_metadata.isNotEmpty)
+ }
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (functionDeclaration_functionExpression != null)
+ }
+ if (functionDeclaration_functionExpression != null) {
_result["functionDeclaration_functionExpression"] =
functionDeclaration_functionExpression.toJson();
- if (functionDeclaration_returnType != null)
+ }
+ if (functionDeclaration_returnType != null) {
_result["functionDeclaration_returnType"] =
functionDeclaration_returnType.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.functionDeclarationStatement) {
- if (functionDeclarationStatement_functionDeclaration != null)
+ if (functionDeclarationStatement_functionDeclaration != null) {
_result["functionDeclarationStatement_functionDeclaration"] =
functionDeclarationStatement_functionDeclaration.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.functionExpression) {
- if (actualReturnType != null)
+ if (actualReturnType != null) {
_result["actualReturnType"] = actualReturnType.toJson();
- if (functionExpression_body != null)
+ }
+ if (functionExpression_body != null) {
_result["functionExpression_body"] = functionExpression_body.toJson();
- if (functionExpression_formalParameters != null)
+ }
+ if (functionExpression_formalParameters != null) {
_result["functionExpression_formalParameters"] =
functionExpression_formalParameters.toJson();
- if (functionExpression_typeParameters != null)
+ }
+ if (functionExpression_typeParameters != null) {
_result["functionExpression_typeParameters"] =
functionExpression_typeParameters.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.functionExpressionInvocation) {
- if (invocationExpression_invokeType != null)
+ if (invocationExpression_invokeType != null) {
_result["invocationExpression_invokeType"] =
invocationExpression_invokeType.toJson();
- if (functionExpressionInvocation_function != null)
+ }
+ if (functionExpressionInvocation_function != null) {
_result["functionExpressionInvocation_function"] =
functionExpressionInvocation_function.toJson();
- if (invocationExpression_typeArguments != null)
+ }
+ if (invocationExpression_typeArguments != null) {
_result["invocationExpression_typeArguments"] =
invocationExpression_typeArguments.toJson();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
- if (invocationExpression_arguments != null)
+ }
+ if (invocationExpression_arguments != null) {
_result["invocationExpression_arguments"] =
invocationExpression_arguments.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.functionTypeAlias) {
- if (actualReturnType != null)
+ if (actualReturnType != null) {
_result["actualReturnType"] = actualReturnType.toJson();
- if (annotatedNode_metadata.isNotEmpty)
+ }
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (functionTypeAlias_formalParameters != null)
+ }
+ if (functionTypeAlias_formalParameters != null) {
_result["functionTypeAlias_formalParameters"] =
functionTypeAlias_formalParameters.toJson();
- if (functionTypeAlias_returnType != null)
+ }
+ if (functionTypeAlias_returnType != null) {
_result["functionTypeAlias_returnType"] =
functionTypeAlias_returnType.toJson();
- if (functionTypeAlias_typeParameters != null)
+ }
+ if (functionTypeAlias_typeParameters != null) {
_result["functionTypeAlias_typeParameters"] =
functionTypeAlias_typeParameters.toJson();
- if (typeAlias_hasSelfReference != false)
+ }
+ if (typeAlias_hasSelfReference != false) {
_result["typeAlias_hasSelfReference"] = typeAlias_hasSelfReference;
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (simplyBoundable_isSimplyBounded != false)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (simplyBoundable_isSimplyBounded != false) {
_result["simplyBoundable_isSimplyBounded"] =
simplyBoundable_isSimplyBounded;
+ }
}
if (kind == idl.LinkedNodeKind.functionTypedFormalParameter) {
- if (actualType != null) _result["actualType"] = actualType.toJson();
- if (normalFormalParameter_metadata.isNotEmpty)
+ if (actualType != null) {
+ _result["actualType"] = actualType.toJson();
+ }
+ if (normalFormalParameter_metadata.isNotEmpty) {
_result["normalFormalParameter_metadata"] =
normalFormalParameter_metadata
.map((_value) => _value.toJson())
.toList();
- if (functionTypedFormalParameter_formalParameters != null)
+ }
+ if (functionTypedFormalParameter_formalParameters != null) {
_result["functionTypedFormalParameter_formalParameters"] =
functionTypedFormalParameter_formalParameters.toJson();
- if (functionTypedFormalParameter_returnType != null)
+ }
+ if (functionTypedFormalParameter_returnType != null) {
_result["functionTypedFormalParameter_returnType"] =
functionTypedFormalParameter_returnType.toJson();
- if (functionTypedFormalParameter_typeParameters != null)
+ }
+ if (functionTypedFormalParameter_typeParameters != null) {
_result["functionTypedFormalParameter_typeParameters"] =
functionTypedFormalParameter_typeParameters.toJson();
- if (inheritsCovariant != false)
+ }
+ if (inheritsCovariant != false) {
_result["inheritsCovariant"] = inheritsCovariant;
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.genericFunctionType) {
- if (actualReturnType != null)
+ if (actualReturnType != null) {
_result["actualReturnType"] = actualReturnType.toJson();
- if (genericFunctionType_typeParameters != null)
+ }
+ if (genericFunctionType_typeParameters != null) {
_result["genericFunctionType_typeParameters"] =
genericFunctionType_typeParameters.toJson();
- if (genericFunctionType_returnType != null)
+ }
+ if (genericFunctionType_returnType != null) {
_result["genericFunctionType_returnType"] =
genericFunctionType_returnType.toJson();
- if (genericFunctionType_id != 0)
+ }
+ if (genericFunctionType_id != 0) {
_result["genericFunctionType_id"] = genericFunctionType_id;
- if (genericFunctionType_formalParameters != null)
+ }
+ if (genericFunctionType_formalParameters != null) {
_result["genericFunctionType_formalParameters"] =
genericFunctionType_formalParameters.toJson();
- if (genericFunctionType_type != null)
+ }
+ if (genericFunctionType_type != null) {
_result["genericFunctionType_type"] = genericFunctionType_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.genericTypeAlias) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (genericTypeAlias_typeParameters != null)
+ }
+ if (genericTypeAlias_typeParameters != null) {
_result["genericTypeAlias_typeParameters"] =
genericTypeAlias_typeParameters.toJson();
- if (genericTypeAlias_functionType != null)
+ }
+ if (genericTypeAlias_functionType != null) {
_result["genericTypeAlias_functionType"] =
genericTypeAlias_functionType.toJson();
- if (typeAlias_hasSelfReference != false)
+ }
+ if (typeAlias_hasSelfReference != false) {
_result["typeAlias_hasSelfReference"] = typeAlias_hasSelfReference;
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (simplyBoundable_isSimplyBounded != false)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (simplyBoundable_isSimplyBounded != false) {
_result["simplyBoundable_isSimplyBounded"] =
simplyBoundable_isSimplyBounded;
+ }
}
if (kind == idl.LinkedNodeKind.hideCombinator) {
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (names.isNotEmpty) _result["names"] = names;
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (names.isNotEmpty) {
+ _result["names"] = names;
+ }
}
if (kind == idl.LinkedNodeKind.ifElement) {
- if (ifMixin_condition != null)
+ if (ifMixin_condition != null) {
_result["ifMixin_condition"] = ifMixin_condition.toJson();
- if (ifElement_thenElement != null)
+ }
+ if (ifElement_thenElement != null) {
_result["ifElement_thenElement"] = ifElement_thenElement.toJson();
- if (ifElement_elseElement != null)
+ }
+ if (ifElement_elseElement != null) {
_result["ifElement_elseElement"] = ifElement_elseElement.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.ifStatement) {
- if (ifMixin_condition != null)
+ if (ifMixin_condition != null) {
_result["ifMixin_condition"] = ifMixin_condition.toJson();
- if (ifStatement_elseStatement != null)
+ }
+ if (ifStatement_elseStatement != null) {
_result["ifStatement_elseStatement"] =
ifStatement_elseStatement.toJson();
- if (ifStatement_thenStatement != null)
+ }
+ if (ifStatement_thenStatement != null) {
_result["ifStatement_thenStatement"] =
ifStatement_thenStatement.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.implementsClause) {
- if (implementsClause_interfaces.isNotEmpty)
+ if (implementsClause_interfaces.isNotEmpty) {
_result["implementsClause_interfaces"] = implementsClause_interfaces
.map((_value) => _value.toJson())
.toList();
+ }
}
if (kind == idl.LinkedNodeKind.importDirective) {
- if (namespaceDirective_combinators.isNotEmpty)
+ if (namespaceDirective_combinators.isNotEmpty) {
_result["namespaceDirective_combinators"] =
namespaceDirective_combinators
.map((_value) => _value.toJson())
.toList();
- if (annotatedNode_metadata.isNotEmpty)
+ }
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (namespaceDirective_configurations.isNotEmpty)
+ }
+ if (namespaceDirective_configurations.isNotEmpty) {
_result["namespaceDirective_configurations"] =
namespaceDirective_configurations
.map((_value) => _value.toJson())
.toList();
- if (namespaceDirective_selectedUri != '')
+ }
+ if (namespaceDirective_selectedUri != '') {
_result["namespaceDirective_selectedUri"] =
namespaceDirective_selectedUri;
- if (importDirective_prefix != '')
+ }
+ if (importDirective_prefix != '') {
_result["importDirective_prefix"] = importDirective_prefix;
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (uriBasedDirective_uri != null)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (uriBasedDirective_uri != null) {
_result["uriBasedDirective_uri"] = uriBasedDirective_uri.toJson();
- if (uriBasedDirective_uriContent != '')
+ }
+ if (uriBasedDirective_uriContent != '') {
_result["uriBasedDirective_uriContent"] = uriBasedDirective_uriContent;
- if (uriBasedDirective_uriElement != 0)
+ }
+ if (uriBasedDirective_uriElement != 0) {
_result["uriBasedDirective_uriElement"] = uriBasedDirective_uriElement;
+ }
}
if (kind == idl.LinkedNodeKind.indexExpression) {
- if (indexExpression_index != null)
+ if (indexExpression_index != null) {
_result["indexExpression_index"] = indexExpression_index.toJson();
- if (indexExpression_target != null)
+ }
+ if (indexExpression_target != null) {
_result["indexExpression_target"] = indexExpression_target.toJson();
- if (indexExpression_substitution != null)
+ }
+ if (indexExpression_substitution != null) {
_result["indexExpression_substitution"] =
indexExpression_substitution.toJson();
- if (indexExpression_element != 0)
+ }
+ if (indexExpression_element != 0) {
_result["indexExpression_element"] = indexExpression_element;
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.instanceCreationExpression) {
- if (instanceCreationExpression_arguments.isNotEmpty)
+ if (instanceCreationExpression_arguments.isNotEmpty) {
_result["instanceCreationExpression_arguments"] =
instanceCreationExpression_arguments
.map((_value) => _value.toJson())
.toList();
- if (instanceCreationExpression_constructorName != null)
+ }
+ if (instanceCreationExpression_constructorName != null) {
_result["instanceCreationExpression_constructorName"] =
instanceCreationExpression_constructorName.toJson();
- if (instanceCreationExpression_typeArguments != null)
+ }
+ if (instanceCreationExpression_typeArguments != null) {
_result["instanceCreationExpression_typeArguments"] =
instanceCreationExpression_typeArguments.toJson();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.integerLiteral) {
- if (expression_type != null)
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
- if (integerLiteral_value != 0)
+ }
+ if (integerLiteral_value != 0) {
_result["integerLiteral_value"] = integerLiteral_value;
+ }
}
if (kind == idl.LinkedNodeKind.interpolationExpression) {
- if (interpolationExpression_expression != null)
+ if (interpolationExpression_expression != null) {
_result["interpolationExpression_expression"] =
interpolationExpression_expression.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.interpolationString) {
- if (interpolationString_value != '')
+ if (interpolationString_value != '') {
_result["interpolationString_value"] = interpolationString_value;
+ }
}
if (kind == idl.LinkedNodeKind.isExpression) {
- if (isExpression_expression != null)
+ if (isExpression_expression != null) {
_result["isExpression_expression"] = isExpression_expression.toJson();
- if (isExpression_type != null)
+ }
+ if (isExpression_type != null) {
_result["isExpression_type"] = isExpression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.label) {
- if (label_label != null) _result["label_label"] = label_label.toJson();
+ if (label_label != null) {
+ _result["label_label"] = label_label.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.labeledStatement) {
- if (labeledStatement_labels.isNotEmpty)
+ if (labeledStatement_labels.isNotEmpty) {
_result["labeledStatement_labels"] =
labeledStatement_labels.map((_value) => _value.toJson()).toList();
- if (labeledStatement_statement != null)
+ }
+ if (labeledStatement_statement != null) {
_result["labeledStatement_statement"] =
labeledStatement_statement.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.libraryDirective) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (libraryDirective_name != null)
+ }
+ if (libraryDirective_name != null) {
_result["libraryDirective_name"] = libraryDirective_name.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.libraryIdentifier) {
- if (libraryIdentifier_components.isNotEmpty)
+ if (libraryIdentifier_components.isNotEmpty) {
_result["libraryIdentifier_components"] = libraryIdentifier_components
.map((_value) => _value.toJson())
.toList();
+ }
}
if (kind == idl.LinkedNodeKind.listLiteral) {
- if (typedLiteral_typeArguments.isNotEmpty)
+ if (typedLiteral_typeArguments.isNotEmpty) {
_result["typedLiteral_typeArguments"] = typedLiteral_typeArguments
.map((_value) => _value.toJson())
.toList();
- if (listLiteral_elements.isNotEmpty)
+ }
+ if (listLiteral_elements.isNotEmpty) {
_result["listLiteral_elements"] =
listLiteral_elements.map((_value) => _value.toJson()).toList();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.mapLiteralEntry) {
- if (mapLiteralEntry_key != null)
+ if (mapLiteralEntry_key != null) {
_result["mapLiteralEntry_key"] = mapLiteralEntry_key.toJson();
- if (mapLiteralEntry_value != null)
+ }
+ if (mapLiteralEntry_value != null) {
_result["mapLiteralEntry_value"] = mapLiteralEntry_value.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.methodDeclaration) {
- if (actualReturnType != null)
+ if (actualReturnType != null) {
_result["actualReturnType"] = actualReturnType.toJson();
- if (annotatedNode_metadata.isNotEmpty)
+ }
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (methodDeclaration_body != null)
+ }
+ if (methodDeclaration_body != null) {
_result["methodDeclaration_body"] = methodDeclaration_body.toJson();
- if (methodDeclaration_formalParameters != null)
+ }
+ if (methodDeclaration_formalParameters != null) {
_result["methodDeclaration_formalParameters"] =
methodDeclaration_formalParameters.toJson();
- if (methodDeclaration_returnType != null)
+ }
+ if (methodDeclaration_returnType != null) {
_result["methodDeclaration_returnType"] =
methodDeclaration_returnType.toJson();
- if (methodDeclaration_typeParameters != null)
+ }
+ if (methodDeclaration_typeParameters != null) {
_result["methodDeclaration_typeParameters"] =
methodDeclaration_typeParameters.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
if (methodDeclaration_hasOperatorEqualWithParameterTypeFromObject !=
- false)
+ false) {
_result["methodDeclaration_hasOperatorEqualWithParameterTypeFromObject"] =
methodDeclaration_hasOperatorEqualWithParameterTypeFromObject;
+ }
}
if (kind == idl.LinkedNodeKind.methodInvocation) {
- if (invocationExpression_invokeType != null)
+ if (invocationExpression_invokeType != null) {
_result["invocationExpression_invokeType"] =
invocationExpression_invokeType.toJson();
- if (methodInvocation_methodName != null)
+ }
+ if (methodInvocation_methodName != null) {
_result["methodInvocation_methodName"] =
methodInvocation_methodName.toJson();
- if (methodInvocation_target != null)
+ }
+ if (methodInvocation_target != null) {
_result["methodInvocation_target"] = methodInvocation_target.toJson();
- if (invocationExpression_typeArguments != null)
+ }
+ if (invocationExpression_typeArguments != null) {
_result["invocationExpression_typeArguments"] =
invocationExpression_typeArguments.toJson();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
- if (invocationExpression_arguments != null)
+ }
+ if (invocationExpression_arguments != null) {
_result["invocationExpression_arguments"] =
invocationExpression_arguments.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.mixinDeclaration) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (mixinDeclaration_onClause != null)
+ }
+ if (mixinDeclaration_onClause != null) {
_result["mixinDeclaration_onClause"] =
mixinDeclaration_onClause.toJson();
- if (classOrMixinDeclaration_implementsClause != null)
+ }
+ if (classOrMixinDeclaration_implementsClause != null) {
_result["classOrMixinDeclaration_implementsClause"] =
classOrMixinDeclaration_implementsClause.toJson();
- if (classOrMixinDeclaration_members.isNotEmpty)
+ }
+ if (classOrMixinDeclaration_members.isNotEmpty) {
_result["classOrMixinDeclaration_members"] =
classOrMixinDeclaration_members
.map((_value) => _value.toJson())
.toList();
- if (classOrMixinDeclaration_typeParameters != null)
+ }
+ if (classOrMixinDeclaration_typeParameters != null) {
_result["classOrMixinDeclaration_typeParameters"] =
classOrMixinDeclaration_typeParameters.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (simplyBoundable_isSimplyBounded != false)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (simplyBoundable_isSimplyBounded != false) {
_result["simplyBoundable_isSimplyBounded"] =
simplyBoundable_isSimplyBounded;
- if (mixinDeclaration_superInvokedNames.isNotEmpty)
+ }
+ if (mixinDeclaration_superInvokedNames.isNotEmpty) {
_result["mixinDeclaration_superInvokedNames"] =
mixinDeclaration_superInvokedNames;
+ }
}
if (kind == idl.LinkedNodeKind.namedExpression) {
- if (namedExpression_expression != null)
+ if (namedExpression_expression != null) {
_result["namedExpression_expression"] =
namedExpression_expression.toJson();
- if (namedExpression_name != null)
+ }
+ if (namedExpression_name != null) {
_result["namedExpression_name"] = namedExpression_name.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.nativeClause) {
- if (nativeClause_name != null)
+ if (nativeClause_name != null) {
_result["nativeClause_name"] = nativeClause_name.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.nativeFunctionBody) {
- if (nativeFunctionBody_stringLiteral != null)
+ if (nativeFunctionBody_stringLiteral != null) {
_result["nativeFunctionBody_stringLiteral"] =
nativeFunctionBody_stringLiteral.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.nullLiteral) {
- if (nullLiteral_fake != 0) _result["nullLiteral_fake"] = nullLiteral_fake;
- if (expression_type != null)
+ if (nullLiteral_fake != 0) {
+ _result["nullLiteral_fake"] = nullLiteral_fake;
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.onClause) {
- if (onClause_superclassConstraints.isNotEmpty)
+ if (onClause_superclassConstraints.isNotEmpty) {
_result["onClause_superclassConstraints"] =
onClause_superclassConstraints
.map((_value) => _value.toJson())
.toList();
+ }
}
if (kind == idl.LinkedNodeKind.parenthesizedExpression) {
- if (parenthesizedExpression_expression != null)
+ if (parenthesizedExpression_expression != null) {
_result["parenthesizedExpression_expression"] =
parenthesizedExpression_expression.toJson();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.partDirective) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (uriBasedDirective_uri != null)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (uriBasedDirective_uri != null) {
_result["uriBasedDirective_uri"] = uriBasedDirective_uri.toJson();
- if (uriBasedDirective_uriContent != '')
+ }
+ if (uriBasedDirective_uriContent != '') {
_result["uriBasedDirective_uriContent"] = uriBasedDirective_uriContent;
- if (uriBasedDirective_uriElement != 0)
+ }
+ if (uriBasedDirective_uriElement != 0) {
_result["uriBasedDirective_uriElement"] = uriBasedDirective_uriElement;
+ }
}
if (kind == idl.LinkedNodeKind.partOfDirective) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (partOfDirective_libraryName != null)
+ }
+ if (partOfDirective_libraryName != null) {
_result["partOfDirective_libraryName"] =
partOfDirective_libraryName.toJson();
- if (partOfDirective_uri != null)
+ }
+ if (partOfDirective_uri != null) {
_result["partOfDirective_uri"] = partOfDirective_uri.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.postfixExpression) {
- if (postfixExpression_operand != null)
+ if (postfixExpression_operand != null) {
_result["postfixExpression_operand"] =
postfixExpression_operand.toJson();
- if (postfixExpression_substitution != null)
+ }
+ if (postfixExpression_substitution != null) {
_result["postfixExpression_substitution"] =
postfixExpression_substitution.toJson();
- if (postfixExpression_element != 0)
+ }
+ if (postfixExpression_element != 0) {
_result["postfixExpression_element"] = postfixExpression_element;
- if (postfixExpression_operator != idl.UnlinkedTokenType.NOTHING)
+ }
+ if (postfixExpression_operator != idl.UnlinkedTokenType.NOTHING) {
_result["postfixExpression_operator"] =
postfixExpression_operator.toString().split('.')[1];
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.prefixExpression) {
- if (prefixExpression_operand != null)
+ if (prefixExpression_operand != null) {
_result["prefixExpression_operand"] = prefixExpression_operand.toJson();
- if (prefixExpression_substitution != null)
+ }
+ if (prefixExpression_substitution != null) {
_result["prefixExpression_substitution"] =
prefixExpression_substitution.toJson();
- if (prefixExpression_element != 0)
+ }
+ if (prefixExpression_element != 0) {
_result["prefixExpression_element"] = prefixExpression_element;
- if (prefixExpression_operator != idl.UnlinkedTokenType.NOTHING)
+ }
+ if (prefixExpression_operator != idl.UnlinkedTokenType.NOTHING) {
_result["prefixExpression_operator"] =
prefixExpression_operator.toString().split('.')[1];
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.prefixedIdentifier) {
- if (prefixedIdentifier_identifier != null)
+ if (prefixedIdentifier_identifier != null) {
_result["prefixedIdentifier_identifier"] =
prefixedIdentifier_identifier.toJson();
- if (prefixedIdentifier_prefix != null)
+ }
+ if (prefixedIdentifier_prefix != null) {
_result["prefixedIdentifier_prefix"] =
prefixedIdentifier_prefix.toJson();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.propertyAccess) {
- if (propertyAccess_propertyName != null)
+ if (propertyAccess_propertyName != null) {
_result["propertyAccess_propertyName"] =
propertyAccess_propertyName.toJson();
- if (propertyAccess_target != null)
+ }
+ if (propertyAccess_target != null) {
_result["propertyAccess_target"] = propertyAccess_target.toJson();
- if (propertyAccess_operator != idl.UnlinkedTokenType.NOTHING)
+ }
+ if (propertyAccess_operator != idl.UnlinkedTokenType.NOTHING) {
_result["propertyAccess_operator"] =
propertyAccess_operator.toString().split('.')[1];
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.redirectingConstructorInvocation) {
- if (redirectingConstructorInvocation_arguments != null)
+ if (redirectingConstructorInvocation_arguments != null) {
_result["redirectingConstructorInvocation_arguments"] =
redirectingConstructorInvocation_arguments.toJson();
- if (redirectingConstructorInvocation_constructorName != null)
+ }
+ if (redirectingConstructorInvocation_constructorName != null) {
_result["redirectingConstructorInvocation_constructorName"] =
redirectingConstructorInvocation_constructorName.toJson();
- if (redirectingConstructorInvocation_substitution != null)
+ }
+ if (redirectingConstructorInvocation_substitution != null) {
_result["redirectingConstructorInvocation_substitution"] =
redirectingConstructorInvocation_substitution.toJson();
- if (redirectingConstructorInvocation_element != 0)
+ }
+ if (redirectingConstructorInvocation_element != 0) {
_result["redirectingConstructorInvocation_element"] =
redirectingConstructorInvocation_element;
+ }
}
if (kind == idl.LinkedNodeKind.rethrowExpression) {
- if (expression_type != null)
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.returnStatement) {
- if (returnStatement_expression != null)
+ if (returnStatement_expression != null) {
_result["returnStatement_expression"] =
returnStatement_expression.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.setOrMapLiteral) {
- if (typedLiteral_typeArguments.isNotEmpty)
+ if (typedLiteral_typeArguments.isNotEmpty) {
_result["typedLiteral_typeArguments"] = typedLiteral_typeArguments
.map((_value) => _value.toJson())
.toList();
- if (setOrMapLiteral_elements.isNotEmpty)
+ }
+ if (setOrMapLiteral_elements.isNotEmpty) {
_result["setOrMapLiteral_elements"] =
setOrMapLiteral_elements.map((_value) => _value.toJson()).toList();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.showCombinator) {
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (names.isNotEmpty) _result["names"] = names;
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (names.isNotEmpty) {
+ _result["names"] = names;
+ }
}
if (kind == idl.LinkedNodeKind.simpleFormalParameter) {
- if (actualType != null) _result["actualType"] = actualType.toJson();
- if (normalFormalParameter_metadata.isNotEmpty)
+ if (actualType != null) {
+ _result["actualType"] = actualType.toJson();
+ }
+ if (normalFormalParameter_metadata.isNotEmpty) {
_result["normalFormalParameter_metadata"] =
normalFormalParameter_metadata
.map((_value) => _value.toJson())
.toList();
- if (simpleFormalParameter_type != null)
+ }
+ if (simpleFormalParameter_type != null) {
_result["simpleFormalParameter_type"] =
simpleFormalParameter_type.toJson();
- if (inheritsCovariant != false)
+ }
+ if (inheritsCovariant != false) {
_result["inheritsCovariant"] = inheritsCovariant;
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (topLevelTypeInferenceError != null)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (topLevelTypeInferenceError != null) {
_result["topLevelTypeInferenceError"] =
topLevelTypeInferenceError.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.simpleIdentifier) {
- if (simpleIdentifier_substitution != null)
+ if (simpleIdentifier_substitution != null) {
_result["simpleIdentifier_substitution"] =
simpleIdentifier_substitution.toJson();
- if (simpleIdentifier_element != 0)
+ }
+ if (simpleIdentifier_element != 0) {
_result["simpleIdentifier_element"] = simpleIdentifier_element;
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.simpleStringLiteral) {
- if (simpleStringLiteral_value != '')
+ if (simpleStringLiteral_value != '') {
_result["simpleStringLiteral_value"] = simpleStringLiteral_value;
+ }
}
if (kind == idl.LinkedNodeKind.spreadElement) {
- if (spreadElement_expression != null)
+ if (spreadElement_expression != null) {
_result["spreadElement_expression"] = spreadElement_expression.toJson();
- if (spreadElement_spreadOperator != idl.UnlinkedTokenType.NOTHING)
+ }
+ if (spreadElement_spreadOperator != idl.UnlinkedTokenType.NOTHING) {
_result["spreadElement_spreadOperator"] =
spreadElement_spreadOperator.toString().split('.')[1];
+ }
}
if (kind == idl.LinkedNodeKind.stringInterpolation) {
- if (stringInterpolation_elements.isNotEmpty)
+ if (stringInterpolation_elements.isNotEmpty) {
_result["stringInterpolation_elements"] = stringInterpolation_elements
.map((_value) => _value.toJson())
.toList();
+ }
}
if (kind == idl.LinkedNodeKind.superConstructorInvocation) {
- if (superConstructorInvocation_arguments != null)
+ if (superConstructorInvocation_arguments != null) {
_result["superConstructorInvocation_arguments"] =
superConstructorInvocation_arguments.toJson();
- if (superConstructorInvocation_constructorName != null)
+ }
+ if (superConstructorInvocation_constructorName != null) {
_result["superConstructorInvocation_constructorName"] =
superConstructorInvocation_constructorName.toJson();
- if (superConstructorInvocation_substitution != null)
+ }
+ if (superConstructorInvocation_substitution != null) {
_result["superConstructorInvocation_substitution"] =
superConstructorInvocation_substitution.toJson();
- if (superConstructorInvocation_element != 0)
+ }
+ if (superConstructorInvocation_element != 0) {
_result["superConstructorInvocation_element"] =
superConstructorInvocation_element;
+ }
}
if (kind == idl.LinkedNodeKind.superExpression) {
- if (expression_type != null)
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.switchCase) {
- if (switchMember_statements.isNotEmpty)
+ if (switchMember_statements.isNotEmpty) {
_result["switchMember_statements"] =
switchMember_statements.map((_value) => _value.toJson()).toList();
- if (switchCase_expression != null)
+ }
+ if (switchCase_expression != null) {
_result["switchCase_expression"] = switchCase_expression.toJson();
- if (switchMember_labels.isNotEmpty)
+ }
+ if (switchMember_labels.isNotEmpty) {
_result["switchMember_labels"] =
switchMember_labels.map((_value) => _value.toJson()).toList();
+ }
}
if (kind == idl.LinkedNodeKind.switchDefault) {
- if (switchMember_statements.isNotEmpty)
+ if (switchMember_statements.isNotEmpty) {
_result["switchMember_statements"] =
switchMember_statements.map((_value) => _value.toJson()).toList();
- if (switchMember_labels.isNotEmpty)
+ }
+ if (switchMember_labels.isNotEmpty) {
_result["switchMember_labels"] =
switchMember_labels.map((_value) => _value.toJson()).toList();
+ }
}
if (kind == idl.LinkedNodeKind.switchStatement) {
- if (switchStatement_members.isNotEmpty)
+ if (switchStatement_members.isNotEmpty) {
_result["switchStatement_members"] =
switchStatement_members.map((_value) => _value.toJson()).toList();
- if (switchStatement_expression != null)
+ }
+ if (switchStatement_expression != null) {
_result["switchStatement_expression"] =
switchStatement_expression.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.symbolLiteral) {
- if (expression_type != null)
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
- if (names.isNotEmpty) _result["names"] = names;
+ }
+ if (names.isNotEmpty) {
+ _result["names"] = names;
+ }
}
if (kind == idl.LinkedNodeKind.thisExpression) {
- if (expression_type != null)
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.throwExpression) {
- if (throwExpression_expression != null)
+ if (throwExpression_expression != null) {
_result["throwExpression_expression"] =
throwExpression_expression.toJson();
- if (expression_type != null)
+ }
+ if (expression_type != null) {
_result["expression_type"] = expression_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.topLevelVariableDeclaration) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (topLevelVariableDeclaration_variableList != null)
+ }
+ if (topLevelVariableDeclaration_variableList != null) {
_result["topLevelVariableDeclaration_variableList"] =
topLevelVariableDeclaration_variableList.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.tryStatement) {
- if (tryStatement_catchClauses.isNotEmpty)
+ if (tryStatement_catchClauses.isNotEmpty) {
_result["tryStatement_catchClauses"] =
tryStatement_catchClauses.map((_value) => _value.toJson()).toList();
- if (tryStatement_body != null)
+ }
+ if (tryStatement_body != null) {
_result["tryStatement_body"] = tryStatement_body.toJson();
- if (tryStatement_finallyBlock != null)
+ }
+ if (tryStatement_finallyBlock != null) {
_result["tryStatement_finallyBlock"] =
tryStatement_finallyBlock.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.typeArgumentList) {
- if (typeArgumentList_arguments.isNotEmpty)
+ if (typeArgumentList_arguments.isNotEmpty) {
_result["typeArgumentList_arguments"] = typeArgumentList_arguments
.map((_value) => _value.toJson())
.toList();
+ }
}
if (kind == idl.LinkedNodeKind.typeName) {
- if (typeName_typeArguments.isNotEmpty)
+ if (typeName_typeArguments.isNotEmpty) {
_result["typeName_typeArguments"] =
typeName_typeArguments.map((_value) => _value.toJson()).toList();
- if (typeName_name != null)
+ }
+ if (typeName_name != null) {
_result["typeName_name"] = typeName_name.toJson();
- if (typeName_type != null)
+ }
+ if (typeName_type != null) {
_result["typeName_type"] = typeName_type.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.typeParameter) {
- if (annotatedNode_metadata.isNotEmpty)
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (typeParameter_bound != null)
+ }
+ if (typeParameter_bound != null) {
_result["typeParameter_bound"] = typeParameter_bound.toJson();
- if (typeParameter_variance != idl.UnlinkedTokenType.NOTHING)
+ }
+ if (typeParameter_variance != idl.UnlinkedTokenType.NOTHING) {
_result["typeParameter_variance"] =
typeParameter_variance.toString().split('.')[1];
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (typeParameter_defaultType != null)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (typeParameter_defaultType != null) {
_result["typeParameter_defaultType"] =
typeParameter_defaultType.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.typeParameterList) {
- if (typeParameterList_typeParameters.isNotEmpty)
+ if (typeParameterList_typeParameters.isNotEmpty) {
_result["typeParameterList_typeParameters"] =
typeParameterList_typeParameters
.map((_value) => _value.toJson())
.toList();
+ }
}
if (kind == idl.LinkedNodeKind.variableDeclaration) {
- if (actualType != null) _result["actualType"] = actualType.toJson();
- if (annotatedNode_metadata.isNotEmpty)
+ if (actualType != null) {
+ _result["actualType"] = actualType.toJson();
+ }
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (variableDeclaration_initializer != null)
+ }
+ if (variableDeclaration_initializer != null) {
_result["variableDeclaration_initializer"] =
variableDeclaration_initializer.toJson();
- if (inheritsCovariant != false)
+ }
+ if (inheritsCovariant != false) {
_result["inheritsCovariant"] = inheritsCovariant;
- if (informativeId != 0) _result["informativeId"] = informativeId;
- if (topLevelTypeInferenceError != null)
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
+ if (topLevelTypeInferenceError != null) {
_result["topLevelTypeInferenceError"] =
topLevelTypeInferenceError.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.variableDeclarationList) {
- if (variableDeclarationList_variables.isNotEmpty)
+ if (variableDeclarationList_variables.isNotEmpty) {
_result["variableDeclarationList_variables"] =
variableDeclarationList_variables
.map((_value) => _value.toJson())
.toList();
- if (annotatedNode_metadata.isNotEmpty)
+ }
+ if (annotatedNode_metadata.isNotEmpty) {
_result["annotatedNode_metadata"] =
annotatedNode_metadata.map((_value) => _value.toJson()).toList();
- if (variableDeclarationList_type != null)
+ }
+ if (variableDeclarationList_type != null) {
_result["variableDeclarationList_type"] =
variableDeclarationList_type.toJson();
- if (informativeId != 0) _result["informativeId"] = informativeId;
+ }
+ if (informativeId != 0) {
+ _result["informativeId"] = informativeId;
+ }
}
if (kind == idl.LinkedNodeKind.variableDeclarationStatement) {
- if (variableDeclarationStatement_variables != null)
+ if (variableDeclarationStatement_variables != null) {
_result["variableDeclarationStatement_variables"] =
variableDeclarationStatement_variables.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.whileStatement) {
- if (whileStatement_body != null)
+ if (whileStatement_body != null) {
_result["whileStatement_body"] = whileStatement_body.toJson();
- if (whileStatement_condition != null)
+ }
+ if (whileStatement_condition != null) {
_result["whileStatement_condition"] = whileStatement_condition.toJson();
+ }
}
if (kind == idl.LinkedNodeKind.withClause) {
- if (withClause_mixinTypes.isNotEmpty)
+ if (withClause_mixinTypes.isNotEmpty) {
_result["withClause_mixinTypes"] =
withClause_mixinTypes.map((_value) => _value.toJson()).toList();
+ }
}
if (kind == idl.LinkedNodeKind.yieldStatement) {
- if (yieldStatement_expression != null)
+ if (yieldStatement_expression != null) {
_result["yieldStatement_expression"] =
yieldStatement_expression.toJson();
+ }
}
return _result;
}
@@ -14940,7 +15485,7 @@
}
List<int> toBuffer() {
- fb.Builder fbBuilder = new fb.Builder();
+ fb.Builder fbBuilder = fb.Builder();
return fbBuilder.finish(finish(fbBuilder), "LNBn");
}
@@ -14966,7 +15511,7 @@
}
idl.LinkedNodeBundle readLinkedNodeBundle(List<int> buffer) {
- fb.BufferContext rootRef = new fb.BufferContext.fromBytes(buffer);
+ fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
return const _LinkedNodeBundleReader().read(rootRef, 0);
}
@@ -14975,7 +15520,7 @@
@override
_LinkedNodeBundleImpl createObject(fb.BufferContext bc, int offset) =>
- new _LinkedNodeBundleImpl(bc, offset);
+ _LinkedNodeBundleImpl(bc, offset);
}
class _LinkedNodeBundleImpl extends Object
@@ -15009,10 +15554,13 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (libraries.isNotEmpty)
+ if (libraries.isNotEmpty) {
_result["libraries"] =
libraries.map((_value) => _value.toJson()).toList();
- if (references != null) _result["references"] = references.toJson();
+ }
+ if (references != null) {
+ _result["references"] = references.toJson();
+ }
return _result;
}
@@ -15170,7 +15718,7 @@
@override
_LinkedNodeLibraryImpl createObject(fb.BufferContext bc, int offset) =>
- new _LinkedNodeLibraryImpl(bc, offset);
+ _LinkedNodeLibraryImpl(bc, offset);
}
class _LinkedNodeLibraryImpl extends Object
@@ -15232,13 +15780,24 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (exports.isNotEmpty) _result["exports"] = exports;
- if (name != '') _result["name"] = name;
- if (nameLength != 0) _result["nameLength"] = nameLength;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (units.isNotEmpty)
+ if (exports.isNotEmpty) {
+ _result["exports"] = exports;
+ }
+ if (name != '') {
+ _result["name"] = name;
+ }
+ if (nameLength != 0) {
+ _result["nameLength"] = nameLength;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (units.isNotEmpty) {
_result["units"] = units.map((_value) => _value.toJson()).toList();
- if (uriStr != '') _result["uriStr"] = uriStr;
+ }
+ if (uriStr != '') {
+ _result["uriStr"] = uriStr;
+ }
return _result;
}
@@ -15331,7 +15890,7 @@
@override
_LinkedNodeReferencesImpl createObject(fb.BufferContext bc, int offset) =>
- new _LinkedNodeReferencesImpl(bc, offset);
+ _LinkedNodeReferencesImpl(bc, offset);
}
class _LinkedNodeReferencesImpl extends Object
@@ -15364,8 +15923,12 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (name.isNotEmpty) _result["name"] = name;
- if (parent.isNotEmpty) _result["parent"] = parent;
+ if (name.isNotEmpty) {
+ _result["name"] = name;
+ }
+ if (parent.isNotEmpty) {
+ _result["parent"] = parent;
+ }
return _result;
}
@@ -15634,7 +16197,7 @@
@override
_LinkedNodeTypeImpl createObject(fb.BufferContext bc, int offset) =>
- new _LinkedNodeTypeImpl(bc, offset);
+ _LinkedNodeTypeImpl(bc, offset);
}
class _LinkedNodeTypeImpl extends Object
@@ -15746,30 +16309,44 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (functionFormalParameters.isNotEmpty)
+ if (functionFormalParameters.isNotEmpty) {
_result["functionFormalParameters"] =
functionFormalParameters.map((_value) => _value.toJson()).toList();
- if (functionReturnType != null)
+ }
+ if (functionReturnType != null) {
_result["functionReturnType"] = functionReturnType.toJson();
- if (functionTypedef != 0) _result["functionTypedef"] = functionTypedef;
- if (functionTypedefTypeArguments.isNotEmpty)
+ }
+ if (functionTypedef != 0) {
+ _result["functionTypedef"] = functionTypedef;
+ }
+ if (functionTypedefTypeArguments.isNotEmpty) {
_result["functionTypedefTypeArguments"] = functionTypedefTypeArguments
.map((_value) => _value.toJson())
.toList();
- if (functionTypeParameters.isNotEmpty)
+ }
+ if (functionTypeParameters.isNotEmpty) {
_result["functionTypeParameters"] =
functionTypeParameters.map((_value) => _value.toJson()).toList();
- if (interfaceClass != 0) _result["interfaceClass"] = interfaceClass;
- if (interfaceTypeArguments.isNotEmpty)
+ }
+ if (interfaceClass != 0) {
+ _result["interfaceClass"] = interfaceClass;
+ }
+ if (interfaceTypeArguments.isNotEmpty) {
_result["interfaceTypeArguments"] =
interfaceTypeArguments.map((_value) => _value.toJson()).toList();
- if (kind != idl.LinkedNodeTypeKind.bottom)
+ }
+ if (kind != idl.LinkedNodeTypeKind.bottom) {
_result["kind"] = kind.toString().split('.')[1];
- if (nullabilitySuffix != idl.EntityRefNullabilitySuffix.starOrIrrelevant)
+ }
+ if (nullabilitySuffix != idl.EntityRefNullabilitySuffix.starOrIrrelevant) {
_result["nullabilitySuffix"] = nullabilitySuffix.toString().split('.')[1];
- if (typeParameterElement != 0)
+ }
+ if (typeParameterElement != 0) {
_result["typeParameterElement"] = typeParameterElement;
- if (typeParameterId != 0) _result["typeParameterId"] = typeParameterId;
+ }
+ if (typeParameterId != 0) {
+ _result["typeParameterId"] = typeParameterId;
+ }
return _result;
}
@@ -15873,7 +16450,7 @@
@override
_LinkedNodeTypeFormalParameterImpl createObject(
fb.BufferContext bc, int offset) =>
- new _LinkedNodeTypeFormalParameterImpl(bc, offset);
+ _LinkedNodeTypeFormalParameterImpl(bc, offset);
}
class _LinkedNodeTypeFormalParameterImpl extends Object
@@ -15913,10 +16490,15 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (kind != idl.LinkedNodeFormalParameterKind.requiredPositional)
+ if (kind != idl.LinkedNodeFormalParameterKind.requiredPositional) {
_result["kind"] = kind.toString().split('.')[1];
- if (name != '') _result["name"] = name;
- if (type != null) _result["type"] = type.toJson();
+ }
+ if (name != '') {
+ _result["name"] = name;
+ }
+ if (type != null) {
+ _result["type"] = type.toJson();
+ }
return _result;
}
@@ -16011,7 +16593,7 @@
@override
_LinkedNodeTypeSubstitutionImpl createObject(
fb.BufferContext bc, int offset) =>
- new _LinkedNodeTypeSubstitutionImpl(bc, offset);
+ _LinkedNodeTypeSubstitutionImpl(bc, offset);
}
class _LinkedNodeTypeSubstitutionImpl extends Object
@@ -16046,10 +16628,13 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (typeArguments.isNotEmpty)
+ if (typeArguments.isNotEmpty) {
_result["typeArguments"] =
typeArguments.map((_value) => _value.toJson()).toList();
- if (typeParameters.isNotEmpty) _result["typeParameters"] = typeParameters;
+ }
+ if (typeParameters.isNotEmpty) {
+ _result["typeParameters"] = typeParameters;
+ }
return _result;
}
@@ -16126,7 +16711,7 @@
@override
_LinkedNodeTypeTypeParameterImpl createObject(
fb.BufferContext bc, int offset) =>
- new _LinkedNodeTypeTypeParameterImpl(bc, offset);
+ _LinkedNodeTypeTypeParameterImpl(bc, offset);
}
class _LinkedNodeTypeTypeParameterImpl extends Object
@@ -16158,8 +16743,12 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (bound != null) _result["bound"] = bound.toJson();
- if (name != '') _result["name"] = name;
+ if (bound != null) {
+ _result["bound"] = bound.toJson();
+ }
+ if (name != '') {
+ _result["name"] = name;
+ }
return _result;
}
@@ -16285,7 +16874,7 @@
@override
_LinkedNodeUnitImpl createObject(fb.BufferContext bc, int offset) =>
- new _LinkedNodeUnitImpl(bc, offset);
+ _LinkedNodeUnitImpl(bc, offset);
}
class _LinkedNodeUnitImpl extends Object
@@ -16337,11 +16926,21 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (isNNBD != false) _result["isNNBD"] = isNNBD;
- if (isSynthetic != false) _result["isSynthetic"] = isSynthetic;
- if (node != null) _result["node"] = node.toJson();
- if (partUriStr != '') _result["partUriStr"] = partUriStr;
- if (uriStr != '') _result["uriStr"] = uriStr;
+ if (isNNBD != false) {
+ _result["isNNBD"] = isNNBD;
+ }
+ if (isSynthetic != false) {
+ _result["isSynthetic"] = isSynthetic;
+ }
+ if (node != null) {
+ _result["node"] = node.toJson();
+ }
+ if (partUriStr != '') {
+ _result["partUriStr"] = partUriStr;
+ }
+ if (uriStr != '') {
+ _result["uriStr"] = uriStr;
+ }
return _result;
}
@@ -16385,7 +16984,7 @@
}
List<int> toBuffer() {
- fb.Builder fbBuilder = new fb.Builder();
+ fb.Builder fbBuilder = fb.Builder();
return fbBuilder.finish(finish(fbBuilder), "PBdl");
}
@@ -16403,7 +17002,7 @@
}
idl.PackageBundle readPackageBundle(List<int> buffer) {
- fb.BufferContext rootRef = new fb.BufferContext.fromBytes(buffer);
+ fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
return const _PackageBundleReader().read(rootRef, 0);
}
@@ -16412,7 +17011,7 @@
@override
_PackageBundleImpl createObject(fb.BufferContext bc, int offset) =>
- new _PackageBundleImpl(bc, offset);
+ _PackageBundleImpl(bc, offset);
}
class _PackageBundleImpl extends Object
@@ -16437,7 +17036,9 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (bundle2 != null) _result["bundle2"] = bundle2.toJson();
+ if (bundle2 != null) {
+ _result["bundle2"] = bundle2.toJson();
+ }
return _result;
}
@@ -16534,7 +17135,7 @@
@override
_TopLevelInferenceErrorImpl createObject(fb.BufferContext bc, int offset) =>
- new _TopLevelInferenceErrorImpl(bc, offset);
+ _TopLevelInferenceErrorImpl(bc, offset);
}
class _TopLevelInferenceErrorImpl extends Object
@@ -16575,10 +17176,15 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (arguments.isNotEmpty) _result["arguments"] = arguments;
- if (kind != idl.TopLevelInferenceErrorKind.assignment)
+ if (arguments.isNotEmpty) {
+ _result["arguments"] = arguments;
+ }
+ if (kind != idl.TopLevelInferenceErrorKind.assignment) {
_result["kind"] = kind.toString().split('.')[1];
- if (slot != 0) _result["slot"] = slot;
+ }
+ if (slot != 0) {
+ _result["slot"] = slot;
+ }
return _result;
}
@@ -17471,7 +18077,7 @@
@override
_UnlinkedInformativeDataImpl createObject(fb.BufferContext bc, int offset) =>
- new _UnlinkedInformativeDataImpl(bc, offset);
+ _UnlinkedInformativeDataImpl(bc, offset);
}
class _UnlinkedInformativeDataImpl extends Object
@@ -17662,170 +18268,305 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (kind != idl.LinkedNodeKind.adjacentStrings)
+ if (kind != idl.LinkedNodeKind.adjacentStrings) {
_result["kind"] = kind.toString().split('.')[1];
+ }
if (kind == idl.LinkedNodeKind.classDeclaration) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.classTypeAlias) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.compilationUnit) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (compilationUnit_lineStarts.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (compilationUnit_lineStarts.isNotEmpty) {
_result["compilationUnit_lineStarts"] = compilationUnit_lineStarts;
+ }
}
if (kind == idl.LinkedNodeKind.constructorDeclaration) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (constructorDeclaration_periodOffset != 0)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (constructorDeclaration_periodOffset != 0) {
_result["constructorDeclaration_periodOffset"] =
constructorDeclaration_periodOffset;
- if (constructorDeclaration_returnTypeOffset != 0)
+ }
+ if (constructorDeclaration_returnTypeOffset != 0) {
_result["constructorDeclaration_returnTypeOffset"] =
constructorDeclaration_returnTypeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.defaultFormalParameter) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (defaultFormalParameter_defaultValueCode != '')
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (defaultFormalParameter_defaultValueCode != '') {
_result["defaultFormalParameter_defaultValueCode"] =
defaultFormalParameter_defaultValueCode;
+ }
}
if (kind == idl.LinkedNodeKind.enumConstantDeclaration) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.enumDeclaration) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.exportDirective) {
- if (directiveKeywordOffset != 0)
+ if (directiveKeywordOffset != 0) {
_result["directiveKeywordOffset"] = directiveKeywordOffset;
+ }
}
if (kind == idl.LinkedNodeKind.extensionDeclaration) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.fieldDeclaration) {
- if (documentationComment_tokens.isNotEmpty)
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.fieldFormalParameter) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
}
if (kind == idl.LinkedNodeKind.functionDeclaration) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.functionTypeAlias) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.functionTypedFormalParameter) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
}
if (kind == idl.LinkedNodeKind.genericTypeAlias) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.hideCombinator) {
- if (combinatorEnd != 0) _result["combinatorEnd"] = combinatorEnd;
- if (combinatorKeywordOffset != 0)
+ if (combinatorEnd != 0) {
+ _result["combinatorEnd"] = combinatorEnd;
+ }
+ if (combinatorKeywordOffset != 0) {
_result["combinatorKeywordOffset"] = combinatorKeywordOffset;
+ }
}
if (kind == idl.LinkedNodeKind.importDirective) {
- if (importDirective_prefixOffset != 0)
+ if (importDirective_prefixOffset != 0) {
_result["importDirective_prefixOffset"] = importDirective_prefixOffset;
- if (directiveKeywordOffset != 0)
+ }
+ if (directiveKeywordOffset != 0) {
_result["directiveKeywordOffset"] = directiveKeywordOffset;
+ }
}
if (kind == idl.LinkedNodeKind.libraryDirective) {
- if (directiveKeywordOffset != 0)
+ if (directiveKeywordOffset != 0) {
_result["directiveKeywordOffset"] = directiveKeywordOffset;
- if (documentationComment_tokens.isNotEmpty)
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.methodDeclaration) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.mixinDeclaration) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
- if (documentationComment_tokens.isNotEmpty)
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.partDirective) {
- if (directiveKeywordOffset != 0)
+ if (directiveKeywordOffset != 0) {
_result["directiveKeywordOffset"] = directiveKeywordOffset;
+ }
}
if (kind == idl.LinkedNodeKind.partOfDirective) {
- if (directiveKeywordOffset != 0)
+ if (directiveKeywordOffset != 0) {
_result["directiveKeywordOffset"] = directiveKeywordOffset;
+ }
}
if (kind == idl.LinkedNodeKind.showCombinator) {
- if (combinatorEnd != 0) _result["combinatorEnd"] = combinatorEnd;
- if (combinatorKeywordOffset != 0)
+ if (combinatorEnd != 0) {
+ _result["combinatorEnd"] = combinatorEnd;
+ }
+ if (combinatorKeywordOffset != 0) {
_result["combinatorKeywordOffset"] = combinatorKeywordOffset;
+ }
}
if (kind == idl.LinkedNodeKind.simpleFormalParameter) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
}
if (kind == idl.LinkedNodeKind.topLevelVariableDeclaration) {
- if (documentationComment_tokens.isNotEmpty)
+ if (documentationComment_tokens.isNotEmpty) {
_result["documentationComment_tokens"] = documentationComment_tokens;
+ }
}
if (kind == idl.LinkedNodeKind.typeParameter) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
}
if (kind == idl.LinkedNodeKind.variableDeclaration) {
- if (codeLength != 0) _result["codeLength"] = codeLength;
- if (codeOffset != 0) _result["codeOffset"] = codeOffset;
- if (nameOffset != 0) _result["nameOffset"] = nameOffset;
+ if (codeLength != 0) {
+ _result["codeLength"] = codeLength;
+ }
+ if (codeOffset != 0) {
+ _result["codeOffset"] = codeOffset;
+ }
+ if (nameOffset != 0) {
+ _result["nameOffset"] = nameOffset;
+ }
}
return _result;
}
@@ -18057,14 +18798,291 @@
String toString() => convert.json.encode(toJson());
}
+class UnlinkedNamespaceDirectiveBuilder extends Object
+ with _UnlinkedNamespaceDirectiveMixin
+ implements idl.UnlinkedNamespaceDirective {
+ List<UnlinkedNamespaceDirectiveConfigurationBuilder> _configurations;
+ String _uri;
+
+ @override
+ List<UnlinkedNamespaceDirectiveConfigurationBuilder> get configurations =>
+ _configurations ??= <UnlinkedNamespaceDirectiveConfigurationBuilder>[];
+
+ /// The configurations that control which library will actually be used.
+ set configurations(
+ List<UnlinkedNamespaceDirectiveConfigurationBuilder> value) {
+ this._configurations = value;
+ }
+
+ @override
+ String get uri => _uri ??= '';
+
+ /// The URI referenced by this directive, nad used by default when none
+ /// of the [configurations] matches.
+ set uri(String value) {
+ this._uri = value;
+ }
+
+ UnlinkedNamespaceDirectiveBuilder(
+ {List<UnlinkedNamespaceDirectiveConfigurationBuilder> configurations,
+ String uri})
+ : _configurations = configurations,
+ _uri = uri;
+
+ /// Flush [informative] data recursively.
+ void flushInformative() {
+ _configurations?.forEach((b) => b.flushInformative());
+ }
+
+ /// Accumulate non-[informative] data into [signature].
+ void collectApiSignature(api_sig.ApiSignature signature) {
+ if (this._configurations == null) {
+ signature.addInt(0);
+ } else {
+ signature.addInt(this._configurations.length);
+ for (var x in this._configurations) {
+ x?.collectApiSignature(signature);
+ }
+ }
+ signature.addString(this._uri ?? '');
+ }
+
+ fb.Offset finish(fb.Builder fbBuilder) {
+ fb.Offset offset_configurations;
+ fb.Offset offset_uri;
+ if (!(_configurations == null || _configurations.isEmpty)) {
+ offset_configurations = fbBuilder
+ .writeList(_configurations.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (_uri != null) {
+ offset_uri = fbBuilder.writeString(_uri);
+ }
+ fbBuilder.startTable();
+ if (offset_configurations != null) {
+ fbBuilder.addOffset(0, offset_configurations);
+ }
+ if (offset_uri != null) {
+ fbBuilder.addOffset(1, offset_uri);
+ }
+ return fbBuilder.endTable();
+ }
+}
+
+class _UnlinkedNamespaceDirectiveReader
+ extends fb.TableReader<_UnlinkedNamespaceDirectiveImpl> {
+ const _UnlinkedNamespaceDirectiveReader();
+
+ @override
+ _UnlinkedNamespaceDirectiveImpl createObject(
+ fb.BufferContext bc, int offset) =>
+ _UnlinkedNamespaceDirectiveImpl(bc, offset);
+}
+
+class _UnlinkedNamespaceDirectiveImpl extends Object
+ with _UnlinkedNamespaceDirectiveMixin
+ implements idl.UnlinkedNamespaceDirective {
+ final fb.BufferContext _bc;
+ final int _bcOffset;
+
+ _UnlinkedNamespaceDirectiveImpl(this._bc, this._bcOffset);
+
+ List<idl.UnlinkedNamespaceDirectiveConfiguration> _configurations;
+ String _uri;
+
+ @override
+ List<idl.UnlinkedNamespaceDirectiveConfiguration> get configurations {
+ _configurations ??=
+ const fb.ListReader<idl.UnlinkedNamespaceDirectiveConfiguration>(
+ const _UnlinkedNamespaceDirectiveConfigurationReader())
+ .vTableGet(_bc, _bcOffset, 0,
+ const <idl.UnlinkedNamespaceDirectiveConfiguration>[]);
+ return _configurations;
+ }
+
+ @override
+ String get uri {
+ _uri ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 1, '');
+ return _uri;
+ }
+}
+
+abstract class _UnlinkedNamespaceDirectiveMixin
+ implements idl.UnlinkedNamespaceDirective {
+ @override
+ Map<String, Object> toJson() {
+ Map<String, Object> _result = <String, Object>{};
+ if (configurations.isNotEmpty) {
+ _result["configurations"] =
+ configurations.map((_value) => _value.toJson()).toList();
+ }
+ if (uri != '') {
+ _result["uri"] = uri;
+ }
+ return _result;
+ }
+
+ @override
+ Map<String, Object> toMap() => {
+ "configurations": configurations,
+ "uri": uri,
+ };
+
+ @override
+ String toString() => convert.json.encode(toJson());
+}
+
+class UnlinkedNamespaceDirectiveConfigurationBuilder extends Object
+ with _UnlinkedNamespaceDirectiveConfigurationMixin
+ implements idl.UnlinkedNamespaceDirectiveConfiguration {
+ String _name;
+ String _uri;
+ String _value;
+
+ @override
+ String get name => _name ??= '';
+
+ /// The name of the declared variable used in the condition.
+ set name(String value) {
+ this._name = value;
+ }
+
+ @override
+ String get uri => _uri ??= '';
+
+ /// The URI to be used if the condition is true.
+ set uri(String value) {
+ this._uri = value;
+ }
+
+ @override
+ String get value => _value ??= '';
+
+ /// The value to which the value of the declared variable will be compared,
+ /// or the empty string if the condition does not include an equality test.
+ set value(String value) {
+ this._value = value;
+ }
+
+ UnlinkedNamespaceDirectiveConfigurationBuilder(
+ {String name, String uri, String value})
+ : _name = name,
+ _uri = uri,
+ _value = value;
+
+ /// Flush [informative] data recursively.
+ void flushInformative() {}
+
+ /// Accumulate non-[informative] data into [signature].
+ void collectApiSignature(api_sig.ApiSignature signature) {
+ signature.addString(this._name ?? '');
+ signature.addString(this._value ?? '');
+ signature.addString(this._uri ?? '');
+ }
+
+ fb.Offset finish(fb.Builder fbBuilder) {
+ fb.Offset offset_name;
+ fb.Offset offset_uri;
+ fb.Offset offset_value;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ if (_uri != null) {
+ offset_uri = fbBuilder.writeString(_uri);
+ }
+ if (_value != null) {
+ offset_value = fbBuilder.writeString(_value);
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (offset_uri != null) {
+ fbBuilder.addOffset(2, offset_uri);
+ }
+ if (offset_value != null) {
+ fbBuilder.addOffset(1, offset_value);
+ }
+ return fbBuilder.endTable();
+ }
+}
+
+class _UnlinkedNamespaceDirectiveConfigurationReader
+ extends fb.TableReader<_UnlinkedNamespaceDirectiveConfigurationImpl> {
+ const _UnlinkedNamespaceDirectiveConfigurationReader();
+
+ @override
+ _UnlinkedNamespaceDirectiveConfigurationImpl createObject(
+ fb.BufferContext bc, int offset) =>
+ _UnlinkedNamespaceDirectiveConfigurationImpl(bc, offset);
+}
+
+class _UnlinkedNamespaceDirectiveConfigurationImpl extends Object
+ with _UnlinkedNamespaceDirectiveConfigurationMixin
+ implements idl.UnlinkedNamespaceDirectiveConfiguration {
+ final fb.BufferContext _bc;
+ final int _bcOffset;
+
+ _UnlinkedNamespaceDirectiveConfigurationImpl(this._bc, this._bcOffset);
+
+ String _name;
+ String _uri;
+ String _value;
+
+ @override
+ String get name {
+ _name ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 0, '');
+ return _name;
+ }
+
+ @override
+ String get uri {
+ _uri ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 2, '');
+ return _uri;
+ }
+
+ @override
+ String get value {
+ _value ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 1, '');
+ return _value;
+ }
+}
+
+abstract class _UnlinkedNamespaceDirectiveConfigurationMixin
+ implements idl.UnlinkedNamespaceDirectiveConfiguration {
+ @override
+ Map<String, Object> toJson() {
+ Map<String, Object> _result = <String, Object>{};
+ if (name != '') {
+ _result["name"] = name;
+ }
+ if (uri != '') {
+ _result["uri"] = uri;
+ }
+ if (value != '') {
+ _result["value"] = value;
+ }
+ return _result;
+ }
+
+ @override
+ Map<String, Object> toMap() => {
+ "name": name,
+ "uri": uri,
+ "value": value,
+ };
+
+ @override
+ String toString() => convert.json.encode(toJson());
+}
+
class UnlinkedUnit2Builder extends Object
with _UnlinkedUnit2Mixin
implements idl.UnlinkedUnit2 {
List<int> _apiSignature;
- List<String> _exports;
+ List<UnlinkedNamespaceDirectiveBuilder> _exports;
bool _hasLibraryDirective;
bool _hasPartOfDirective;
- List<String> _imports;
+ List<UnlinkedNamespaceDirectiveBuilder> _imports;
List<UnlinkedInformativeDataBuilder> _informativeData;
List<int> _lineStarts;
List<String> _parts;
@@ -18080,10 +19098,11 @@
}
@override
- List<String> get exports => _exports ??= <String>[];
+ List<UnlinkedNamespaceDirectiveBuilder> get exports =>
+ _exports ??= <UnlinkedNamespaceDirectiveBuilder>[];
/// URIs of `export` directives.
- set exports(List<String> value) {
+ set exports(List<UnlinkedNamespaceDirectiveBuilder> value) {
this._exports = value;
}
@@ -18104,10 +19123,11 @@
}
@override
- List<String> get imports => _imports ??= <String>[];
+ List<UnlinkedNamespaceDirectiveBuilder> get imports =>
+ _imports ??= <UnlinkedNamespaceDirectiveBuilder>[];
/// URIs of `import` directives.
- set imports(List<String> value) {
+ set imports(List<UnlinkedNamespaceDirectiveBuilder> value) {
this._imports = value;
}
@@ -18138,10 +19158,10 @@
UnlinkedUnit2Builder(
{List<int> apiSignature,
- List<String> exports,
+ List<UnlinkedNamespaceDirectiveBuilder> exports,
bool hasLibraryDirective,
bool hasPartOfDirective,
- List<String> imports,
+ List<UnlinkedNamespaceDirectiveBuilder> imports,
List<UnlinkedInformativeDataBuilder> informativeData,
List<int> lineStarts,
List<String> parts})
@@ -18156,6 +19176,8 @@
/// Flush [informative] data recursively.
void flushInformative() {
+ _exports?.forEach((b) => b.flushInformative());
+ _imports?.forEach((b) => b.flushInformative());
_informativeData?.forEach((b) => b.flushInformative());
_lineStarts = null;
}
@@ -18175,7 +19197,7 @@
} else {
signature.addInt(this._exports.length);
for (var x in this._exports) {
- signature.addString(x);
+ x?.collectApiSignature(signature);
}
}
if (this._imports == null) {
@@ -18183,7 +19205,7 @@
} else {
signature.addInt(this._imports.length);
for (var x in this._imports) {
- signature.addString(x);
+ x?.collectApiSignature(signature);
}
}
signature.addBool(this._hasPartOfDirective == true);
@@ -18207,7 +19229,7 @@
}
List<int> toBuffer() {
- fb.Builder fbBuilder = new fb.Builder();
+ fb.Builder fbBuilder = fb.Builder();
return fbBuilder.finish(finish(fbBuilder), "UUN2");
}
@@ -18223,11 +19245,11 @@
}
if (!(_exports == null || _exports.isEmpty)) {
offset_exports = fbBuilder
- .writeList(_exports.map((b) => fbBuilder.writeString(b)).toList());
+ .writeList(_exports.map((b) => b.finish(fbBuilder)).toList());
}
if (!(_imports == null || _imports.isEmpty)) {
offset_imports = fbBuilder
- .writeList(_imports.map((b) => fbBuilder.writeString(b)).toList());
+ .writeList(_imports.map((b) => b.finish(fbBuilder)).toList());
}
if (!(_informativeData == null || _informativeData.isEmpty)) {
offset_informativeData = fbBuilder
@@ -18270,7 +19292,7 @@
}
idl.UnlinkedUnit2 readUnlinkedUnit2(List<int> buffer) {
- fb.BufferContext rootRef = new fb.BufferContext.fromBytes(buffer);
+ fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer);
return const _UnlinkedUnit2Reader().read(rootRef, 0);
}
@@ -18279,7 +19301,7 @@
@override
_UnlinkedUnit2Impl createObject(fb.BufferContext bc, int offset) =>
- new _UnlinkedUnit2Impl(bc, offset);
+ _UnlinkedUnit2Impl(bc, offset);
}
class _UnlinkedUnit2Impl extends Object
@@ -18291,10 +19313,10 @@
_UnlinkedUnit2Impl(this._bc, this._bcOffset);
List<int> _apiSignature;
- List<String> _exports;
+ List<idl.UnlinkedNamespaceDirective> _exports;
bool _hasLibraryDirective;
bool _hasPartOfDirective;
- List<String> _imports;
+ List<idl.UnlinkedNamespaceDirective> _imports;
List<idl.UnlinkedInformativeData> _informativeData;
List<int> _lineStarts;
List<String> _parts;
@@ -18307,9 +19329,10 @@
}
@override
- List<String> get exports {
- _exports ??= const fb.ListReader<String>(const fb.StringReader())
- .vTableGet(_bc, _bcOffset, 1, const <String>[]);
+ List<idl.UnlinkedNamespaceDirective> get exports {
+ _exports ??= const fb.ListReader<idl.UnlinkedNamespaceDirective>(
+ const _UnlinkedNamespaceDirectiveReader())
+ .vTableGet(_bc, _bcOffset, 1, const <idl.UnlinkedNamespaceDirective>[]);
return _exports;
}
@@ -18328,9 +19351,10 @@
}
@override
- List<String> get imports {
- _imports ??= const fb.ListReader<String>(const fb.StringReader())
- .vTableGet(_bc, _bcOffset, 2, const <String>[]);
+ List<idl.UnlinkedNamespaceDirective> get imports {
+ _imports ??= const fb.ListReader<idl.UnlinkedNamespaceDirective>(
+ const _UnlinkedNamespaceDirectiveReader())
+ .vTableGet(_bc, _bcOffset, 2, const <idl.UnlinkedNamespaceDirective>[]);
return _imports;
}
@@ -18361,18 +19385,31 @@
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (apiSignature.isNotEmpty) _result["apiSignature"] = apiSignature;
- if (exports.isNotEmpty) _result["exports"] = exports;
- if (hasLibraryDirective != false)
+ if (apiSignature.isNotEmpty) {
+ _result["apiSignature"] = apiSignature;
+ }
+ if (exports.isNotEmpty) {
+ _result["exports"] = exports.map((_value) => _value.toJson()).toList();
+ }
+ if (hasLibraryDirective != false) {
_result["hasLibraryDirective"] = hasLibraryDirective;
- if (hasPartOfDirective != false)
+ }
+ if (hasPartOfDirective != false) {
_result["hasPartOfDirective"] = hasPartOfDirective;
- if (imports.isNotEmpty) _result["imports"] = imports;
- if (informativeData.isNotEmpty)
+ }
+ if (imports.isNotEmpty) {
+ _result["imports"] = imports.map((_value) => _value.toJson()).toList();
+ }
+ if (informativeData.isNotEmpty) {
_result["informativeData"] =
informativeData.map((_value) => _value.toJson()).toList();
- if (lineStarts.isNotEmpty) _result["lineStarts"] = lineStarts;
- if (parts.isNotEmpty) _result["parts"] = parts;
+ }
+ if (lineStarts.isNotEmpty) {
+ _result["lineStarts"] = lineStarts;
+ }
+ if (parts.isNotEmpty) {
+ _result["parts"] = parts;
+ }
return _result;
}
diff --git a/pkg/analyzer/lib/src/summary/format.fbs b/pkg/analyzer/lib/src/summary/format.fbs
index be47572..d97c226 100644
--- a/pkg/analyzer/lib/src/summary/format.fbs
+++ b/pkg/analyzer/lib/src/summary/format.fbs
@@ -1263,6 +1263,29 @@
kind:LinkedNodeKind (id: 0);
}
+/// Unlinked summary information about a namespace directive.
+table UnlinkedNamespaceDirective {
+ /// The configurations that control which library will actually be used.
+ configurations:[UnlinkedNamespaceDirectiveConfiguration] (id: 0);
+
+ /// The URI referenced by this directive, nad used by default when none
+ /// of the [configurations] matches.
+ uri:string (id: 1);
+}
+
+/// Unlinked summary information about a namespace directive configuration.
+table UnlinkedNamespaceDirectiveConfiguration {
+ /// The name of the declared variable used in the condition.
+ name:string (id: 0);
+
+ /// The URI to be used if the condition is true.
+ uri:string (id: 2);
+
+ /// The value to which the value of the declared variable will be compared,
+ /// or the empty string if the condition does not include an equality test.
+ value:string (id: 1);
+}
+
/// Unlinked summary information about a compilation unit.
table UnlinkedUnit2 {
/// The MD5 hash signature of the API portion of this unit. It depends on all
@@ -1270,7 +1293,7 @@
apiSignature:[uint] (id: 0);
/// URIs of `export` directives.
- exports:[string] (id: 1);
+ exports:[UnlinkedNamespaceDirective] (id: 1);
/// Is `true` if the unit contains a `library` directive.
hasLibraryDirective:bool (id: 6);
@@ -1279,7 +1302,7 @@
hasPartOfDirective:bool (id: 3);
/// URIs of `import` directives.
- imports:[string] (id: 2);
+ imports:[UnlinkedNamespaceDirective] (id: 2);
informativeData:[UnlinkedInformativeData] (id: 7);
diff --git a/pkg/analyzer/lib/src/summary/idl.dart b/pkg/analyzer/lib/src/summary/idl.dart
index a7259a1..0a36c52 100644
--- a/pkg/analyzer/lib/src/summary/idl.dart
+++ b/pkg/analyzer/lib/src/summary/idl.dart
@@ -2,6 +2,43 @@
// 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.
+/// This file is an "idl" style description of the summary format. It
+/// contains abstract classes which declare the interface for reading data from
+/// summaries. It is parsed and transformed into code that implements the
+/// summary format.
+///
+/// The code generation process introduces the following semantics:
+/// - Getters of type List never return null, and have a default value of the
+/// empty list.
+/// - Getters of type int return unsigned 32-bit integers, never null, and have
+/// a default value of zero.
+/// - Getters of type String never return null, and have a default value of ''.
+/// - Getters of type bool never return null, and have a default value of false.
+/// - Getters of type double never return null, and have a default value of
+/// `0.0`.
+/// - Getters whose type is an enum never return null, and have a default value
+/// of the first value declared in the enum.
+///
+/// Terminology used in this document:
+/// - "Unlinked" refers to information that can be determined from reading a
+/// single .dart file in isolation.
+/// - "Prelinked" refers to information that can be determined from the defining
+/// compilation unit of a library, plus direct imports, plus the transitive
+/// closure of exports reachable from those libraries, plus all part files
+/// constituting those libraries.
+/// - "Linked" refers to all other information; in theory, this information may
+/// depend on all files in the transitive import/export closure. However, in
+/// practice we expect that the number of additional dependencies will usually
+/// be small, since the additional dependencies only need to be consulted for
+/// type propagation, type inference, and constant evaluation, which typically
+/// have short dependency chains.
+///
+/// Since we expect "linked" and "prelinked" dependencies to be similar, we only
+/// rarely distinguish between them; most information is that is not "unlinked"
+/// is typically considered "linked" for simplicity.
+///
+/// Except as otherwise noted, synthetic elements are not stored in the summary;
+/// they are re-synthesized at the time the summary is read.
import 'base.dart' as base;
import 'base.dart' show Id, TopLevel, Variant, VariantId;
import 'format.dart' as generated;
@@ -1947,6 +1984,35 @@
int get nameOffset;
}
+/// Unlinked summary information about a namespace directive.
+abstract class UnlinkedNamespaceDirective extends base.SummaryClass {
+ /// The configurations that control which library will actually be used.
+ @Id(0)
+ List<UnlinkedNamespaceDirectiveConfiguration> get configurations;
+
+ /// The URI referenced by this directive, nad used by default when none
+ /// of the [configurations] matches.
+ @Id(1)
+ String get uri;
+}
+
+/// Unlinked summary information about a namespace directive configuration.
+abstract class UnlinkedNamespaceDirectiveConfiguration
+ extends base.SummaryClass {
+ /// The name of the declared variable used in the condition.
+ @Id(0)
+ String get name;
+
+ /// The URI to be used if the condition is true.
+ @Id(2)
+ String get uri;
+
+ /// The value to which the value of the declared variable will be compared,
+ /// or the empty string if the condition does not include an equality test.
+ @Id(1)
+ String get value;
+}
+
/// Enum of token types, corresponding to AST token types.
enum UnlinkedTokenType {
NOTHING,
@@ -2107,7 +2173,7 @@
/// URIs of `export` directives.
@Id(1)
- List<String> get exports;
+ List<UnlinkedNamespaceDirective> get exports;
/// Is `true` if the unit contains a `library` directive.
@Id(6)
@@ -2119,7 +2185,7 @@
/// URIs of `import` directives.
@Id(2)
- List<String> get imports;
+ List<UnlinkedNamespaceDirective> get imports;
@Id(7)
List<UnlinkedInformativeData> get informativeData;
diff --git a/pkg/analyzer/lib/src/summary/name_filter.dart b/pkg/analyzer/lib/src/summary/name_filter.dart
index 2d98dcf0..23b2c23 100644
--- a/pkg/analyzer/lib/src/summary/name_filter.dart
+++ b/pkg/analyzer/lib/src/summary/name_filter.dart
@@ -12,8 +12,7 @@
/**
* A [NameFilter] representing no filtering at all (i.e. no combinators).
*/
- static final NameFilter identity =
- new NameFilter._(hiddenNames: new Set<String>());
+ static final NameFilter identity = NameFilter._(hiddenNames: Set<String>());
/**
* If this [NameFilter] accepts a finite number of names and hides all
@@ -40,12 +39,11 @@
*/
factory NameFilter.forNamespaceCombinator(NamespaceCombinator combinator) {
if (combinator is ShowElementCombinator) {
- return new NameFilter._(shownNames: combinator.shownNames.toSet());
+ return NameFilter._(shownNames: combinator.shownNames.toSet());
} else if (combinator is HideElementCombinator) {
- return new NameFilter._(hiddenNames: combinator.hiddenNames.toSet());
+ return NameFilter._(hiddenNames: combinator.hiddenNames.toSet());
} else {
- throw new StateError(
- 'Unexpected combinator type ${combinator.runtimeType}');
+ throw StateError('Unexpected combinator type ${combinator.runtimeType}');
}
}
@@ -57,7 +55,7 @@
List<NamespaceCombinator> combinators) {
NameFilter result = identity;
for (NamespaceCombinator combinator in combinators) {
- result = result.merge(new NameFilter.forNamespaceCombinator(combinator));
+ result = result.merge(NameFilter.forNamespaceCombinator(combinator));
}
return result;
}
@@ -86,19 +84,18 @@
NameFilter merge(NameFilter other) {
if (shownNames != null) {
if (other.shownNames != null) {
- return new NameFilter._(
+ return NameFilter._(
shownNames: shownNames.intersection(other.shownNames));
} else {
- return new NameFilter._(
+ return NameFilter._(
shownNames: shownNames.difference(other.hiddenNames));
}
} else {
if (other.shownNames != null) {
- return new NameFilter._(
+ return NameFilter._(
shownNames: other.shownNames.difference(hiddenNames));
} else {
- return new NameFilter._(
- hiddenNames: hiddenNames.union(other.hiddenNames));
+ return NameFilter._(hiddenNames: hiddenNames.union(other.hiddenNames));
}
}
}
diff --git a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
index bab03db..fce9d75 100644
--- a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
@@ -75,7 +75,7 @@
InSummarySource(Uri uri, this.summaryPath) : super(uri);
@override
- TimestampedData<String> get contents => new TimestampedData<String>(0, '');
+ TimestampedData<String> get contents => TimestampedData<String>(0, '');
@override
int get modificationStamp => 0;
@@ -106,7 +106,7 @@
String uriString = uri.toString();
String summaryPath = _dataStore.uriToSummaryPath[uriString];
if (summaryPath != null) {
- return new InSummarySource(actualUri, summaryPath);
+ return InSummarySource(actualUri, summaryPath);
}
return null;
}
@@ -190,10 +190,10 @@
var file = resourceProvider.getFile(path);
buffer = file.readAsBytesSync();
} else {
- io.File file = new io.File(path);
+ io.File file = io.File(path);
buffer = file.readAsBytesSync();
}
- PackageBundle bundle = new PackageBundle.fromBuffer(buffer);
+ PackageBundle bundle = PackageBundle.fromBuffer(buffer);
addBundle(path, bundle);
}
}
diff --git a/pkg/analyzer/lib/src/summary/summarize_elements.dart b/pkg/analyzer/lib/src/summary/summarize_elements.dart
index 1228ab8..20b0456 100644
--- a/pkg/analyzer/lib/src/summary/summarize_elements.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart
@@ -15,7 +15,7 @@
* Assemble a new [PackageBundleBuilder] using the gathered information.
*/
PackageBundleBuilder assemble() {
- return new PackageBundleBuilder(bundle2: _bundle2);
+ return PackageBundleBuilder(bundle2: _bundle2);
}
void setBundle2(LinkedNodeBundleBuilder bundle2) {
diff --git a/pkg/analyzer/lib/src/summary/summary_file_builder.dart b/pkg/analyzer/lib/src/summary/summary_file_builder.dart
index ed90c40..c70efd9 100644
--- a/pkg/analyzer/lib/src/summary/summary_file_builder.dart
+++ b/pkg/analyzer/lib/src/summary/summary_file_builder.dart
@@ -39,10 +39,10 @@
// Prepare SDK.
//
ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE;
- FolderBasedDartSdk sdk = new FolderBasedDartSdk(
+ FolderBasedDartSdk sdk = FolderBasedDartSdk(
resourceProvider, resourceProvider.getFolder(sdkPath));
sdk.useSummary = false;
- sdk.analysisOptions = new AnalysisOptionsImpl();
+ sdk.analysisOptions = AnalysisOptionsImpl();
//
// Prepare 'dart:' URIs to serialize.
@@ -51,28 +51,28 @@
sdk.sdkLibraries.map((SdkLibrary library) => library.shortName).toSet();
uriSet.add('dart:html_common/html_common_dart2js.dart');
- Set<Source> librarySources = new HashSet<Source>();
+ Set<Source> librarySources = HashSet<Source>();
for (String uri in uriSet) {
librarySources.add(sdk.mapDartUri(uri));
}
- return new SummaryBuilder(librarySources, sdk.context);
+ return SummaryBuilder(librarySources, sdk.context);
}
/**
* Build the linked bundle and return its bytes.
*/
- List<int> build() => new _Builder(context, librarySources).build();
+ List<int> build() => _Builder(context, librarySources).build();
}
class _Builder {
final AnalysisContext context;
final Iterable<Source> librarySources;
- final Set<String> libraryUris = new Set<String>();
+ final Set<String> libraryUris = Set<String>();
final List<summary2.LinkInputLibrary> inputLibraries = [];
- final PackageBundleAssembler bundleAssembler = new PackageBundleAssembler();
+ final PackageBundleAssembler bundleAssembler = PackageBundleAssembler();
_Builder(this.context, this.librarySources);
@@ -130,14 +130,14 @@
CompilationUnit _parse(Source source) {
AnalysisErrorListener errorListener = AnalysisErrorListener.NULL_LISTENER;
String code = source.contents.data;
- CharSequenceReader reader = new CharSequenceReader(code);
+ CharSequenceReader reader = CharSequenceReader(code);
// TODO(paulberry): figure out the appropriate featureSet to use here
var featureSet = FeatureSet.fromEnableFlags([]);
- Scanner scanner = new Scanner(source, reader, errorListener)
+ Scanner scanner = Scanner(source, reader, errorListener)
..configureFeatures(featureSet);
Token token = scanner.tokenize();
- LineInfo lineInfo = new LineInfo(scanner.lineStarts);
- Parser parser = new Parser(source, errorListener,
+ LineInfo lineInfo = LineInfo(scanner.lineStarts);
+ Parser parser = Parser(source, errorListener,
featureSet: featureSet,
useFasta: context.analysisOptions.useFastaParser);
parser.enableOptionalNewAndConst = true;
diff --git a/pkg/analyzer/lib/src/summary/summary_sdk.dart b/pkg/analyzer/lib/src/summary/summary_sdk.dart
index f5be007..47ccc26 100644
--- a/pkg/analyzer/lib/src/summary/summary_sdk.dart
+++ b/pkg/analyzer/lib/src/summary/summary_sdk.dart
@@ -26,20 +26,20 @@
/**
* The [AnalysisContext] which is used for all of the sources in this sdk.
*/
- InternalAnalysisContext _analysisContext;
+ SdkAnalysisContext _analysisContext;
SummaryBasedDartSdk(String summaryPath, bool _, {this.resourceProvider}) {
- _dataStore = new SummaryDataStore(<String>[summaryPath],
+ _dataStore = SummaryDataStore(<String>[summaryPath],
resourceProvider: resourceProvider);
- _uriResolver = new InSummaryUriResolver(resourceProvider, _dataStore);
+ _uriResolver = InSummaryUriResolver(resourceProvider, _dataStore);
_bundle = _dataStore.bundles.single;
}
SummaryBasedDartSdk.fromBundle(bool _, PackageBundle bundle,
{this.resourceProvider}) {
- _dataStore = new SummaryDataStore([], resourceProvider: resourceProvider);
+ _dataStore = SummaryDataStore([], resourceProvider: resourceProvider);
_dataStore.addBundle('dart_sdk.sum', bundle);
- _uriResolver = new InSummaryUriResolver(resourceProvider, _dataStore);
+ _uriResolver = InSummaryUriResolver(resourceProvider, _dataStore);
_bundle = bundle;
}
@@ -57,26 +57,26 @@
null,
resourceProvider,
);
- _analysisContext = new SdkAnalysisContext(analysisOptions, factory);
+ _analysisContext = SdkAnalysisContext(analysisOptions, factory);
}
return _analysisContext;
}
@override
List<SdkLibrary> get sdkLibraries {
- throw new UnimplementedError();
+ throw UnimplementedError();
}
@override
String get sdkVersion {
- throw new UnimplementedError();
+ throw UnimplementedError();
}
bool get strongMode => true;
@override
List<String> get uris {
- throw new UnimplementedError();
+ throw UnimplementedError();
}
@override
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_flags.dart b/pkg/analyzer/lib/src/summary2/ast_binary_flags.dart
index b866a53..ba41968 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_flags.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_flags.dart
@@ -225,43 +225,43 @@
);
static int encode({
- bool hasAwait: false,
- bool hasEqual: false,
- bool hasInitializer: false,
- bool hasName: false,
- bool hasNot: false,
- bool hasPeriod: false,
- bool hasPeriod2: false,
- bool hasQuestion: false,
- bool hasSeparatorColon: false,
- bool hasSeparatorEquals: false,
- bool hasThis: false,
- bool hasTypeArguments: false,
- bool isAbstract: false,
- bool isAsync: false,
- bool isConst: false,
- bool isCovariant: false,
- bool isDeclaration: false,
- bool isDeferred: false,
- bool isDelimiterCurly: false,
- bool isDelimiterSquare: false,
- bool isExternal: false,
- bool isFactory: false,
- bool isFinal: false,
- bool isGenerator: false,
- bool isGet: false,
- bool isLate: false,
- bool isMap: false,
- bool isNative: false,
- bool isNew: false,
- bool isOperator: false,
- bool isRequired: false,
- bool isSet: false,
- bool isStar: false,
- bool isStatic: false,
- bool isStringInterpolationIdentifier: false,
- bool isSync: false,
- bool isVar: false,
+ bool hasAwait = false,
+ bool hasEqual = false,
+ bool hasInitializer = false,
+ bool hasName = false,
+ bool hasNot = false,
+ bool hasPeriod = false,
+ bool hasPeriod2 = false,
+ bool hasQuestion = false,
+ bool hasSeparatorColon = false,
+ bool hasSeparatorEquals = false,
+ bool hasThis = false,
+ bool hasTypeArguments = false,
+ bool isAbstract = false,
+ bool isAsync = false,
+ bool isConst = false,
+ bool isCovariant = false,
+ bool isDeclaration = false,
+ bool isDeferred = false,
+ bool isDelimiterCurly = false,
+ bool isDelimiterSquare = false,
+ bool isExternal = false,
+ bool isFactory = false,
+ bool isFinal = false,
+ bool isGenerator = false,
+ bool isGet = false,
+ bool isLate = false,
+ bool isMap = false,
+ bool isNative = false,
+ bool isNew = false,
+ bool isOperator = false,
+ bool isRequired = false,
+ bool isSet = false,
+ bool isStar = false,
+ bool isStatic = false,
+ bool isStringInterpolationIdentifier = false,
+ bool isSync = false,
+ bool isVar = false,
}) {
var result = 0;
if (hasAwait) {
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
index 9774971..bad8134 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
@@ -1455,9 +1455,13 @@
}
StringInterpolation _read_stringInterpolation(LinkedNode data) {
- return astFactory.stringInterpolation(
+ var node = astFactory.stringInterpolation(
_readNodeList(data.stringInterpolation_elements),
- )..staticType = _stringType;
+ );
+ if (!_isReadingDirective) {
+ node.staticType = _stringType;
+ }
+ return node;
}
SuperConstructorInvocation _read_superConstructorInvocation(LinkedNode data) {
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
index 37aa5f7..3b165e8 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
@@ -1624,7 +1624,7 @@
}
void _storeTypedLiteral(LinkedNodeBuilder builder, TypedLiteral node,
- {bool isMap: false, bool isSet: false}) {
+ {bool isMap = false, bool isSet = false}) {
_storeExpression(builder, node);
builder
..flags = AstBinaryFlags.encode(
@@ -1712,7 +1712,7 @@
} else if (node.isOptionalNamed) {
return LinkedNodeFormalParameterKind.optionalNamed;
} else {
- throw new StateError('Unknown kind of parameter');
+ throw StateError('Unknown kind of parameter');
}
}
}
diff --git a/pkg/analyzer/lib/src/summary2/ast_resolver.dart b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
index 54a07fc..4faefc9 100644
--- a/pkg/analyzer/lib/src/summary2/ast_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
@@ -48,20 +48,20 @@
);
node = getNode();
- var variableResolverVisitor = new VariableResolverVisitor(
+ var variableResolverVisitor = VariableResolverVisitor(
_unitElement.library,
_unitElement.source,
- _linker.typeProvider,
+ _unitElement.library.typeProvider,
errorListener,
nameScope: _nameScope,
);
node.accept(variableResolverVisitor);
- var resolverVisitor = new ResolverVisitor(
+ var resolverVisitor = ResolverVisitor(
_linker.inheritance,
_unitElement.library,
_unitElement.source,
- _linker.typeProvider,
+ _unitElement.library.typeProvider,
errorListener,
featureSet: featureSet,
nameScope: _nameScope,
diff --git a/pkg/analyzer/lib/src/summary2/default_types_builder.dart b/pkg/analyzer/lib/src/summary2/default_types_builder.dart
index 888b899..f3cbbfa 100644
--- a/pkg/analyzer/lib/src/summary2/default_types_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/default_types_builder.dart
@@ -8,7 +8,6 @@
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/dart/element/type_algebra.dart';
-import 'package:analyzer/src/generated/type_system.dart';
import 'package:analyzer/src/summary2/function_type_builder.dart';
import 'package:analyzer/src/summary2/lazy_ast.dart';
import 'package:analyzer/src/summary2/named_type_builder.dart';
@@ -16,27 +15,28 @@
import 'package:kernel/util/graph.dart' show Graph, computeStrongComponents;
class DefaultTypesBuilder {
- final TypeSystemImpl typeSystem;
-
- DefaultTypesBuilder(this.typeSystem);
-
void build(List<AstNode> nodes) {
for (var node in nodes) {
if (node is ClassDeclaration) {
- _breakRawTypeCycles(node.declaredElement, node.typeParameters);
- _computeBounds(node.typeParameters);
+ var element = node.declaredElement;
+ _breakRawTypeCycles(element, node.typeParameters);
+ _computeBounds(element, node.typeParameters);
} else if (node is ClassTypeAlias) {
- _breakRawTypeCycles(node.declaredElement, node.typeParameters);
- _computeBounds(node.typeParameters);
+ var element = node.declaredElement;
+ _breakRawTypeCycles(element, node.typeParameters);
+ _computeBounds(element, node.typeParameters);
} else if (node is FunctionTypeAlias) {
- _breakRawTypeCycles(node.declaredElement, node.typeParameters);
- _computeBounds(node.typeParameters);
+ var element = node.declaredElement;
+ _breakRawTypeCycles(element, node.typeParameters);
+ _computeBounds(element, node.typeParameters);
} else if (node is GenericTypeAlias) {
- _breakRawTypeCycles(node.declaredElement, node.typeParameters);
- _computeBounds(node.typeParameters);
+ var element = node.declaredElement;
+ _breakRawTypeCycles(element, node.typeParameters);
+ _computeBounds(element, node.typeParameters);
} else if (node is MixinDeclaration) {
- _breakRawTypeCycles(node.declaredElement, node.typeParameters);
- _computeBounds(node.typeParameters);
+ var element = node.declaredElement;
+ _breakRawTypeCycles(element, node.typeParameters);
+ _computeBounds(element, node.typeParameters);
}
}
for (var node in nodes) {
@@ -101,11 +101,15 @@
/// Compute bounds to be provided as type arguments in place of missing type
/// arguments on raw types with the given type parameters.
- void _computeBounds(TypeParameterList parameterList) {
+ void _computeBounds(
+ Element declarationElement,
+ TypeParameterList parameterList,
+ ) {
if (parameterList == null) return;
- var dynamicType = typeSystem.typeProvider.dynamicType;
- var nullType = typeSystem.typeProvider.nullType;
+ var typeProvider = declarationElement.library.typeProvider;
+ var dynamicType = typeProvider.dynamicType;
+ var nullType = typeProvider.nullType;
var nodes = parameterList.typeParameters;
var length = nodes.length;
diff --git a/pkg/analyzer/lib/src/summary2/default_value_resolver.dart b/pkg/analyzer/lib/src/summary2/default_value_resolver.dart
index 680b212..887bbf7 100644
--- a/pkg/analyzer/lib/src/summary2/default_value_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/default_value_resolver.dart
@@ -100,7 +100,7 @@
var node = _defaultParameter(parameter);
if (node == null) return;
- var contextType = TypeVariableEliminator(_linker.typeProvider)
+ var contextType = TypeVariableEliminator(_libraryElement.typeProvider)
.substituteType(parameter.type);
_astResolver ??= AstResolver(_linker, _unitElement, _scope);
diff --git a/pkg/analyzer/lib/src/summary2/link.dart b/pkg/analyzer/lib/src/summary2/link.dart
index 7ad79b3..93cf8e1 100644
--- a/pkg/analyzer/lib/src/summary2/link.dart
+++ b/pkg/analyzer/lib/src/summary2/link.dart
@@ -5,12 +5,10 @@
import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart' show CompilationUnit;
+import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
import 'package:analyzer/src/generated/constant.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/generated/type_system.dart';
import 'package:analyzer/src/summary/format.dart';
import 'package:analyzer/src/summary2/ast_binary_writer.dart';
import 'package:analyzer/src/summary2/library_builder.dart';
@@ -58,7 +56,7 @@
);
}
- InternalAnalysisContext get analysisContext {
+ AnalysisContextImpl get analysisContext {
return elementFactory.analysisContext;
}
@@ -68,10 +66,6 @@
Reference get rootReference => elementFactory.rootReference;
- TypeProvider get typeProvider => analysisContext.typeProvider;
-
- TypeSystemImpl get typeSystem => analysisContext.typeSystem;
-
void link(List<LinkInputLibrary> inputLibraries) {
for (var inputLibrary in inputLibraries) {
LibraryBuilder.build(this, inputLibrary);
@@ -97,7 +91,6 @@
_createTypeSystem();
_resolveTypes();
TypeAliasSelfReferenceFinder().perform(this);
- _createLoadLibraryFunctions();
_performTopLevelInference();
_resolveConstructors();
_resolveConstantInitializers();
@@ -121,8 +114,8 @@
library.buildInitialExportScope();
}
- var exporters = new Set<LibraryBuilder>();
- var exportees = new Set<LibraryBuilder>();
+ var exporters = Set<LibraryBuilder>();
+ var exportees = Set<LibraryBuilder>();
for (var library in builders.values) {
library.addExporters();
@@ -137,7 +130,7 @@
}
}
- var both = new Set<LibraryBuilder>();
+ var both = Set<LibraryBuilder>();
for (var exported in exportees) {
if (exporters.contains(exported)) {
both.add(exported);
@@ -197,18 +190,7 @@
);
}
- void _createLoadLibraryFunctions() {
- for (var library in builders.values) {
- library.element.createLoadLibraryFunction(typeProvider);
- }
- }
-
void _createTypeSystem() {
- if (typeProvider != null) {
- inheritance = InheritanceManager3();
- return;
- }
-
var coreLib = elementFactory.libraryOfUri('dart:core');
var asyncLib = elementFactory.libraryOfUri('dart:async');
elementFactory.createTypeProviders(coreLib, asyncLib);
@@ -248,7 +230,7 @@
library.resolveTypes(nodesToBuildType);
}
computeSimplyBounded(bundleContext, builders.values);
- TypesBuilder(typeSystem).build(nodesToBuildType);
+ TypesBuilder().build(nodesToBuildType);
}
void _resolveUriDirectives() {
diff --git a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
index c07abb7..d7d48ed 100644
--- a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
@@ -66,6 +66,10 @@
LibraryElementImpl dartCore,
LibraryElementImpl dartAsync,
) {
+ if (analysisContext.typeProviderNonNullableByDefault != null) {
+ return;
+ }
+
analysisContext.setTypeProviders(
legacy: TypeProviderImpl(
coreLibrary: dartCore,
@@ -87,9 +91,6 @@
_setLibraryTypeSystem(libraryElement);
}
}
-
- dartCore.createLoadLibraryFunction(dartCore.typeProvider);
- dartAsync.createLoadLibraryFunction(dartAsync.typeProvider);
}
Element elementOfReference(Reference reference) {
@@ -165,7 +166,7 @@
// During linking we create libraries when typeProvider is not ready.
// And if we link dart:core and dart:async, we cannot create it.
// We will set typeProvider later, during [createTypeProviders].
- if (analysisContext.typeProviderLegacy == null) {
+ if (analysisContext.typeProviderNonNullableByDefault == null) {
return;
}
@@ -176,6 +177,8 @@
libraryElement.typeSystem = isNonNullable
? analysisContext.typeSystemNonNullableByDefault
: analysisContext.typeSystemLegacy;
+
+ libraryElement.createLoadLibraryFunction();
}
}
@@ -377,11 +380,6 @@
libraryElement.parts = units.skip(1).toList();
reference.element = libraryElement;
- var typeProvider = elementFactory.analysisContext.typeProvider;
- if (typeProvider != null) {
- libraryElement.createLoadLibraryFunction(typeProvider);
- }
-
return libraryElement;
}
diff --git a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
index 890ad24f..a2d3a1d 100644
--- a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
@@ -84,8 +84,11 @@
return _unit.featureSet.isEnabled(Feature.non_nullable);
}
- TypeProvider get typeProvider =>
- bundleContext.elementFactory.analysisContext.typeProvider;
+ TypeProvider get typeProvider {
+ var libraryReference = libraryContext.reference;
+ var libraryElement = libraryReference.element as LibraryElementImpl;
+ return libraryElement.typeProvider;
+ }
CompilationUnit get unit => _unit;
diff --git a/pkg/analyzer/lib/src/summary2/reference.dart b/pkg/analyzer/lib/src/summary2/reference.dart
index 781644d..193f2a7 100644
--- a/pkg/analyzer/lib/src/summary2/reference.dart
+++ b/pkg/analyzer/lib/src/summary2/reference.dart
@@ -77,7 +77,7 @@
/// Return the child with the given name, create if does not exist yet.
Reference getChild(String name) {
var map = _children ??= <String, Reference>{};
- return map[name] ??= new Reference._(this, name);
+ return map[name] ??= Reference._(this, name);
}
/// If the reference has element, and it is for the [node], return `true`.
diff --git a/pkg/analyzer/lib/src/summary2/reference_resolver.dart b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
index 169a9f4..23ffa03 100644
--- a/pkg/analyzer/lib/src/summary2/reference_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
@@ -71,14 +71,14 @@
node.name.staticElement = element;
_createTypeParameterElements(node.typeParameters);
- scope = new TypeParameterScope(scope, element);
+ scope = TypeParameterScope(scope, element);
node.typeParameters?.accept(this);
node.extendsClause?.accept(this);
node.implementsClause?.accept(this);
node.withClause?.accept(this);
- scope = new ClassScope(scope, element);
+ scope = ClassScope(scope, element);
LinkingNodeContext(node, scope);
_hasConstConstructor = false;
@@ -107,8 +107,8 @@
ClassElementImpl element = reference.element;
node.name.staticElement = element;
_createTypeParameterElements(node.typeParameters);
- scope = new TypeParameterScope(scope, element);
- scope = new ClassScope(scope, element);
+ scope = TypeParameterScope(scope, element);
+ scope = ClassScope(scope, element);
LinkingNodeContext(node, scope);
node.typeParameters?.accept(this);
@@ -185,12 +185,12 @@
node.name?.staticElement = element;
_createTypeParameterElements(node.typeParameters);
- scope = new TypeParameterScope(scope, element);
+ scope = TypeParameterScope(scope, element);
node.typeParameters?.accept(this);
node.extendedType.accept(this);
- scope = new ExtensionScope(scope, element);
+ scope = ExtensionScope(scope, element);
LinkingNodeContext(node, scope);
node.members.accept(this);
@@ -228,7 +228,7 @@
node.identifier.staticElement = element;
_createTypeParameterElements(node.typeParameters);
- scope = new EnclosedScope(scope);
+ scope = EnclosedScope(scope);
for (var typeParameter in element.typeParameters) {
scope.define(typeParameter);
}
@@ -266,7 +266,7 @@
ExecutableElementImpl element = reference.element;
node.name.staticElement = element;
_createTypeParameterElements(node.functionExpression.typeParameters);
- scope = new FunctionScope(scope, element);
+ scope = FunctionScope(scope, element);
LinkingNodeContext(node, scope);
node.returnType?.accept(this);
@@ -326,7 +326,7 @@
node.identifier.staticElement = element;
_createTypeParameterElements(node.typeParameters);
- scope = new EnclosedScope(scope);
+ scope = EnclosedScope(scope);
for (var typeParameter in element.typeParameters) {
scope.define(typeParameter);
}
@@ -422,7 +422,7 @@
);
node.name.staticElement = element;
_createTypeParameterElements(node.typeParameters);
- scope = new FunctionScope(scope, element);
+ scope = FunctionScope(scope, element);
LinkingNodeContext(node, scope);
node.returnType?.accept(this);
@@ -446,13 +446,13 @@
node.name.staticElement = element;
_createTypeParameterElements(node.typeParameters);
- scope = new TypeParameterScope(scope, element);
+ scope = TypeParameterScope(scope, element);
node.typeParameters?.accept(this);
node.onClause?.accept(this);
node.implementsClause?.accept(this);
- scope = new ClassScope(scope, element);
+ scope = ClassScope(scope, element);
LinkingNodeContext(node, scope);
node.members.accept(this);
diff --git a/pkg/analyzer/lib/src/summary2/top_level_inference.dart b/pkg/analyzer/lib/src/summary2/top_level_inference.dart
index 4abdf96..fa1f177 100644
--- a/pkg/analyzer/lib/src/summary2/top_level_inference.dart
+++ b/pkg/analyzer/lib/src/summary2/top_level_inference.dart
@@ -118,10 +118,7 @@
}
void _performOverrideInference() {
- var inferrer = new InstanceMemberInferrer(
- linker.typeProvider,
- linker.inheritance,
- );
+ var inferrer = InstanceMemberInferrer(linker.inheritance);
for (var builder in linker.builders.values) {
for (var unit in builder.element.units) {
inferrer.inferCompilationUnit(unit);
diff --git a/pkg/analyzer/lib/src/summary2/types_builder.dart b/pkg/analyzer/lib/src/summary2/types_builder.dart
index 54ec8cf..c986e94 100644
--- a/pkg/analyzer/lib/src/summary2/types_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/types_builder.dart
@@ -28,23 +28,19 @@
}
class TypesBuilder {
- final TypeSystemImpl typeSystem;
-
- TypesBuilder(this.typeSystem);
-
DynamicTypeImpl get _dynamicType => DynamicTypeImpl.instance;
VoidTypeImpl get _voidType => VoidTypeImpl.instance;
/// Build types for all type annotations, and set types for declarations.
void build(NodesToBuildType nodes) {
- DefaultTypesBuilder(typeSystem).build(nodes.declarations);
+ DefaultTypesBuilder().build(nodes.declarations);
for (var builder in nodes.typeBuilders) {
builder.build();
}
- _MixinsInference(typeSystem).perform(nodes.declarations);
+ _MixinsInference().perform(nodes.declarations);
for (var declaration in nodes.declarations) {
_declaration(declaration);
@@ -201,6 +197,7 @@
/// Performs mixins inference in a [ClassDeclaration].
class _MixinInference {
+ final ClassElementImpl element;
final TypeSystemImpl typeSystem;
final FeatureSet featureSet;
final InterfaceType classType;
@@ -208,7 +205,9 @@
List<InterfaceType> mixinTypes = [];
List<InterfaceType> supertypesForMixinInference;
- _MixinInference(this.typeSystem, this.featureSet, this.classType);
+ _MixinInference(this.element, this.featureSet)
+ : typeSystem = element.library.typeSystem,
+ classType = element.thisType;
NullabilitySuffix get _noneOrStarSuffix {
return _nonNullableEnabled
@@ -341,10 +340,6 @@
/// Performs mixin inference for all declarations.
class _MixinsInference {
- final TypeSystemImpl typeSystem;
-
- _MixinsInference(this.typeSystem);
-
void perform(List<AstNode> declarations) {
for (var node in declarations) {
if (node is ClassDeclaration || node is ClassTypeAlias) {
@@ -379,8 +374,7 @@
element.linkedMixinInferenceCallback = _callbackWhenLoop;
try {
var featureSet = _unitFeatureSet(element);
- _MixinInference(typeSystem, featureSet, element.thisType)
- .perform(withClause);
+ _MixinInference(element, featureSet).perform(withClause);
} finally {
element.linkedMixinInferenceCallback = null;
}
diff --git a/pkg/analyzer/lib/src/task/options.dart b/pkg/analyzer/lib/src/task/options.dart
index ee07eec..6062315 100644
--- a/pkg/analyzer/lib/src/task/options.dart
+++ b/pkg/analyzer/lib/src/task/options.dart
@@ -23,7 +23,7 @@
import 'package:source_span/source_span.dart';
import 'package:yaml/yaml.dart';
-final _OptionsProcessor _processor = new _OptionsProcessor();
+final _OptionsProcessor _processor = _OptionsProcessor();
List<AnalysisError> analyzeAnalysisOptions(
Source source, String content, SourceFactory sourceFactory) {
@@ -31,12 +31,12 @@
Source initialSource = source;
SourceSpan initialIncludeSpan;
AnalysisOptionsProvider optionsProvider =
- new AnalysisOptionsProvider(sourceFactory);
+ AnalysisOptionsProvider(sourceFactory);
// Validate the specified options and any included option files
void validate(Source source, YamlMap options) {
List<AnalysisError> validationErrors =
- new OptionsFileValidator(source).validate(options);
+ OptionsFileValidator(source).validate(options);
if (initialIncludeSpan != null && validationErrors.isNotEmpty) {
for (AnalysisError error in validationErrors) {
var args = [
@@ -45,7 +45,7 @@
(error.offset + error.length - 1).toString(),
error.message,
];
- errors.add(new AnalysisError(
+ errors.add(AnalysisError(
initialSource,
initialIncludeSpan.start.column + 1,
initialIncludeSpan.length,
@@ -65,7 +65,7 @@
String includeUri = span.text;
Source includedSource = sourceFactory.resolveUri(source, includeUri);
if (includedSource == null || !includedSource.exists()) {
- errors.add(new AnalysisError(
+ errors.add(AnalysisError(
initialSource,
initialIncludeSpan.start.column + 1,
initialIncludeSpan.length,
@@ -86,7 +86,7 @@
];
// Report errors for included option files
// on the include directive located in the initial options file.
- errors.add(new AnalysisError(
+ errors.add(AnalysisError(
initialSource,
initialIncludeSpan.start.column + 1,
initialIncludeSpan.length,
@@ -100,7 +100,7 @@
validate(source, options);
} on OptionsFormatException catch (e) {
SourceSpan span = e.span;
- errors.add(new AnalysisError(source, span.start.column + 1, span.length,
+ errors.add(AnalysisError(source, span.start.column + 1, span.length,
AnalysisOptionsErrorCode.PARSE_ERROR, [e.message]));
}
return errors;
@@ -141,8 +141,7 @@
static const List<String> ignoreSynonyms = const ['ignore', 'false'];
/// Valid error `severity`s.
- static final List<String> severities =
- new List.unmodifiable(severityMap.keys);
+ static final List<String> severities = List.unmodifiable(severityMap.keys);
/// Ways to say `include`.
static const List<String> includeSynonyms = const ['include', 'true'];
@@ -184,12 +183,12 @@
class AnalyzerOptionsValidator extends CompositeValidator {
AnalyzerOptionsValidator()
: super([
- new TopLevelAnalyzerOptionsValidator(),
- new StrongModeOptionValueValidator(),
- new ErrorFilterOptionValidator(),
- new EnabledExperimentsValidator(),
- new LanguageOptionValidator(),
- new OptionalChecksValueValidator()
+ TopLevelAnalyzerOptionsValidator(),
+ StrongModeOptionValueValidator(),
+ ErrorFilterOptionValidator(),
+ EnabledExperimentsValidator(),
+ LanguageOptionValidator(),
+ OptionalChecksValueValidator()
]);
}
@@ -206,8 +205,8 @@
/// Validates `analyzer` language configuration options.
class EnabledExperimentsValidator extends OptionsValidator {
- ErrorBuilder builder = new ErrorBuilder(AnalyzerOptions.languageOptions);
- ErrorBuilder trueOrFalseBuilder = new TrueOrFalseValueErrorBuilder();
+ ErrorBuilder builder = ErrorBuilder(AnalyzerOptions.languageOptions);
+ ErrorBuilder trueOrFalseBuilder = TrueOrFalseValueErrorBuilder();
@override
void validate(ErrorReporter reporter, YamlMap options) {
@@ -286,7 +285,7 @@
class ErrorFilterOptionValidator extends OptionsValidator {
/// Legal values.
static final List<String> legalValues =
- new List.from(AnalyzerOptions.ignoreSynonyms)
+ List.from(AnalyzerOptions.ignoreSynonyms)
..addAll(AnalyzerOptions.includeSynonyms)
..addAll(AnalyzerOptions.severities);
@@ -300,7 +299,7 @@
/// Legal error code names.
static Set<String> get errorCodes {
if (_errorCodes == null) {
- _errorCodes = new HashSet<String>();
+ _errorCodes = HashSet<String>();
// Engine codes.
_errorCodes.addAll(errorCodeValues.map((ErrorCode code) => code.name));
}
@@ -312,7 +311,7 @@
Set<String> get lintCodes {
if (_lintCodes == null) {
- _lintCodes = new Set.from(
+ _lintCodes = Set.from(
Registry.ruleRegistry.rules.map((rule) => rule.name.toUpperCase()));
}
return _lintCodes;
@@ -357,8 +356,8 @@
/// Validates `analyzer` language configuration options.
class LanguageOptionValidator extends OptionsValidator {
- ErrorBuilder builder = new ErrorBuilder(AnalyzerOptions.languageOptions);
- ErrorBuilder trueOrFalseBuilder = new TrueOrFalseValueErrorBuilder();
+ ErrorBuilder builder = ErrorBuilder(AnalyzerOptions.languageOptions);
+ ErrorBuilder trueOrFalseBuilder = TrueOrFalseValueErrorBuilder();
@override
void validate(ErrorReporter reporter, YamlMap options) {
@@ -420,18 +419,18 @@
final Source source;
final List<OptionsValidator> _validators = [
- new AnalyzerOptionsValidator(),
- new LinterOptionsValidator(),
- new LinterRuleOptionsValidator()
+ AnalyzerOptionsValidator(),
+ LinterOptionsValidator(),
+ LinterRuleOptionsValidator()
];
OptionsFileValidator(this.source);
List<AnalysisError> validate(YamlMap options) {
- RecordingErrorListener recorder = new RecordingErrorListener();
- ErrorReporter reporter = new ErrorReporter(recorder, source);
+ RecordingErrorListener recorder = RecordingErrorListener();
+ ErrorReporter reporter = ErrorReporter(recorder, source);
if (AnalysisEngine.ANALYSIS_OPTIONS_FILE == source.shortName) {
- reporter.reportError(new AnalysisError(
+ reporter.reportError(AnalysisError(
source,
0, // offset
1, // length
@@ -445,8 +444,8 @@
/// Validates `analyzer` strong-mode value configuration options.
class StrongModeOptionValueValidator extends OptionsValidator {
- ErrorBuilder builder = new ErrorBuilder(AnalyzerOptions.strongModeOptions);
- ErrorBuilder trueOrFalseBuilder = new TrueOrFalseValueErrorBuilder();
+ ErrorBuilder builder = ErrorBuilder(AnalyzerOptions.strongModeOptions);
+ ErrorBuilder trueOrFalseBuilder = TrueOrFalseValueErrorBuilder();
@override
void validate(ErrorReporter reporter, YamlMap options) {
@@ -497,9 +496,8 @@
/// Validates `analyzer` optional-checks value configuration options.
class OptionalChecksValueValidator extends OptionsValidator {
- ErrorBuilder builder =
- new ErrorBuilder(AnalyzerOptions.optionalChecksOptions);
- ErrorBuilder trueOrFalseBuilder = new TrueOrFalseValueErrorBuilder();
+ ErrorBuilder builder = ErrorBuilder(AnalyzerOptions.optionalChecksOptions);
+ ErrorBuilder trueOrFalseBuilder = TrueOrFalseValueErrorBuilder();
@override
void validate(ErrorReporter reporter, YamlMap options) {
@@ -701,7 +699,7 @@
}
void _applyProcessors(AnalysisOptionsImpl options, YamlNode codes) {
- ErrorConfig config = new ErrorConfig(codes);
+ ErrorConfig config = ErrorConfig(codes);
options.errorProcessors = config.processors;
}
diff --git a/pkg/analyzer/lib/src/task/strong/checker.dart b/pkg/analyzer/lib/src/task/strong/checker.dart
index 4be1702..4340889 100644
--- a/pkg/analyzer/lib/src/task/strong/checker.dart
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart
@@ -36,7 +36,7 @@
/// gets the known static type of the expression.
DartType getExpressionType(
Expression expression, TypeSystemImpl typeSystem, TypeProvider typeProvider,
- {bool read: false}) {
+ {bool read = false}) {
DartType type;
if (read) {
type = getReadType(expression);
@@ -136,7 +136,7 @@
: typeProvider = typeProvider,
rules = rules,
reporter = reporter {
- _overrideChecker = new _OverrideChecker(this);
+ _overrideChecker = _OverrideChecker(this);
}
bool get failure => _failure;
@@ -347,7 +347,7 @@
void visitCompilationUnit(CompilationUnit node) {
_featureSet = node.featureSet;
_hasImplicitCasts = false;
- _covariantPrivateMembers = new HashSet();
+ _covariantPrivateMembers = HashSet();
node.visitChildren(this);
setHasImplicitCasts(node, _hasImplicitCasts);
setCovariantPrivateMembers(node, _covariantPrivateMembers);
@@ -744,7 +744,11 @@
var rhsType = _getExpressionType(expr.rightHandSide);
var lhsType = _getExpressionType(expr.leftHandSide);
var returnType = rules.refineBinaryExpressionType(
- lhsType, op, rhsType, functionType.returnType, _featureSet);
+ lhsType,
+ op,
+ rhsType,
+ functionType.returnType,
+ );
// Check the argument for an implicit cast.
_checkImplicitCast(expr.rightHandSide, paramTypes[0], from: rhsType);
@@ -825,10 +829,10 @@
/// [to] or is already a subtype of it, does nothing.
void _checkImplicitCast(Expression expr, DartType to,
{DartType from,
- bool opAssign: false,
- bool forSpread: false,
- bool forSpreadKey: false,
- bool forSpreadValue: false}) {
+ bool opAssign = false,
+ bool forSpread = false,
+ bool forSpreadKey = false,
+ bool forSpreadValue = false}) {
from ??= _getExpressionType(expr);
if (_needsImplicitCast(expr, to, from: from) == true) {
@@ -939,7 +943,7 @@
}
void _checkReturnOrYield(Expression expression, AstNode node,
- {bool yieldStar: false}) {
+ {bool yieldStar = false}) {
FunctionBody body = node.thisOrAncestorOfType<FunctionBody>();
var type = _getExpectedReturnType(body, yieldStar: yieldStar);
if (type == null) {
@@ -976,8 +980,12 @@
var functionType = element.type;
var rhsType = typeProvider.intType;
var lhsType = _getExpressionType(operand);
- var returnType = rules.refineBinaryExpressionType(lhsType,
- TokenType.PLUS, rhsType, functionType.returnType, _featureSet);
+ var returnType = rules.refineBinaryExpressionType(
+ lhsType,
+ TokenType.PLUS,
+ rhsType,
+ functionType.returnType,
+ );
// Skip the argument check - `int` cannot be downcast.
//
@@ -996,7 +1004,7 @@
/// Gets the expected return type of the given function [body], either from
/// a normal return/yield, or from a yield*.
- DartType _getExpectedReturnType(FunctionBody body, {bool yieldStar: false}) {
+ DartType _getExpectedReturnType(FunctionBody body, {bool yieldStar = false}) {
FunctionType functionType;
var parent = body.parent;
if (parent is Declaration) {
@@ -1093,10 +1101,10 @@
e is PropertyAccessorElement && e.variable is FieldElement);
void _markImplicitCast(Expression expr, DartType to,
- {bool opAssign: false,
- bool forSpread: false,
- bool forSpreadKey: false,
- bool forSpreadValue: false}) {
+ {bool opAssign = false,
+ bool forSpread = false,
+ bool forSpreadKey = false,
+ bool forSpreadValue = false}) {
if (opAssign) {
setImplicitOperationCast(expr, to);
} else if (forSpread) {
@@ -1135,7 +1143,7 @@
}
// Down cast or legal sideways cast, coercion needed.
- if (rules.isAssignableTo(from, to, featureSet: _featureSet)) {
+ if (rules.isAssignableTo(from, to)) {
return true;
}
@@ -1168,10 +1176,10 @@
/// the AST node.
void _recordImplicitCast(Expression expr, DartType to,
{DartType from,
- bool opAssign: false,
- forSpread: false,
- forSpreadKey: false,
- forSpreadValue: false}) {
+ bool opAssign = false,
+ forSpread = false,
+ forSpreadKey = false,
+ forSpreadValue = false}) {
// If this is an implicit tearoff, we need to mark the cast, but we don't
// want to warn if it's a legal subtype.
if (from is InterfaceType && rules.acceptsFunctionType(to)) {
@@ -1286,8 +1294,8 @@
// Compute the right severity taking the analysis options into account.
// We construct a dummy error to make the common case where we end up
// ignoring the strong mode message cheaper.
- var processor = ErrorProcessor.getProcessor(_options,
- new AnalysisError.forValues(null, -1, 0, errorCode, null, null));
+ var processor = ErrorProcessor.getProcessor(
+ _options, AnalysisError.forValues(null, -1, 0, errorCode, null, null));
var severity =
(processor != null) ? processor.severity : errorCode.errorSeverity;
@@ -1304,8 +1312,7 @@
: node.offset;
int length = node.end - begin;
var source = (node.root as CompilationUnit).declaredElement.source;
- var error =
- new AnalysisError(source, begin, length, errorCode, arguments);
+ var error = AnalysisError(source, begin, length, errorCode, arguments);
reporter.onError(error);
}
}
@@ -1349,7 +1356,7 @@
}
void _validateTopLevelInitializer(String name, Expression n) {
- n.accept(new _TopLevelInitializerValidator(this, name));
+ n.accept(_TopLevelInitializerValidator(this, name));
}
void _visitForEachParts(ForEachParts node, SimpleIdentifier loopVariable) {
@@ -1369,7 +1376,7 @@
} else if (parent is ForElement) {
awaitKeyword = parent.awaitKeyword;
} else {
- throw new StateError(
+ throw StateError(
'Unexpected parent of ForEachParts: ${parent.runtimeType}');
}
// Find the element type of the sequence.
@@ -1477,7 +1484,7 @@
var allCovariant = _findAllGenericInterfaces(element);
if (allCovariant.isEmpty) return;
- var seenConcreteMembers = new HashSet<String>();
+ var seenConcreteMembers = HashSet<String>();
var members = _getConcreteMembers(element.thisType, seenConcreteMembers);
// For members on this class, check them against all generic interfaces.
@@ -1653,7 +1660,7 @@
///
Set<Element> _findSuperclassCovariantChecks(ClassElement element,
Set<ClassElement> allCovariant, HashSet<String> seenConcreteMembers) {
- var visited = new HashSet<ClassElement>()..add(element);
+ var visited = HashSet<ClassElement>()..add(element);
var superChecks = _createCovariantCheckSet();
var existingChecks = _createCovariantCheckSet();
@@ -1688,7 +1695,7 @@
}
static Set<Element> _createCovariantCheckSet() {
- return new LinkedHashSet(
+ return LinkedHashSet(
equals: (a, b) => a.declaration == b.declaration,
hashCode: (e) => e.declaration.hashCode,
);
@@ -1791,7 +1798,7 @@
}
void validateIdentifierElement(AstNode n, Element e,
- {bool isMethodCall: false}) {
+ {bool isMethodCall = false}) {
if (e == null) {
return;
}
diff --git a/pkg/analyzer/lib/src/task/strong_mode.dart b/pkg/analyzer/lib/src/task/strong_mode.dart
index 63503b2..005e306 100644
--- a/pkg/analyzer/lib/src/task/strong_mode.dart
+++ b/pkg/analyzer/lib/src/task/strong_mode.dart
@@ -8,8 +8,8 @@
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
+import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/dart/element/type_algebra.dart';
-import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
import 'package:analyzer/src/summary/format.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary2/lazy_ast.dart';
@@ -19,9 +19,8 @@
* instance methods within a single compilation unit.
*/
class InstanceMemberInferrer {
- final TypeProvider typeProvider;
final InheritanceManager3 inheritance;
- final Set<ClassElement> elementsBeingInferred = new HashSet<ClassElement>();
+ final Set<ClassElement> elementsBeingInferred = HashSet<ClassElement>();
bool isNonNullableLibrary;
InterfaceType interfaceType;
@@ -29,7 +28,9 @@
/**
* Initialize a newly create inferrer.
*/
- InstanceMemberInferrer(this.typeProvider, this.inheritance);
+ InstanceMemberInferrer(this.inheritance);
+
+ DartType get _dynamicType => DynamicTypeImpl.instance;
/**
* Infer type information for all of the instance members in the given
@@ -66,14 +67,14 @@
var overriddenGetters = inheritance.getOverridden(
interfaceType,
- new Name(accessor.library.source.uri, name),
+ Name(accessor.library.source.uri, name),
);
List<ExecutableElement> overriddenSetters;
if (overriddenGetters == null || !accessor.variable.isFinal) {
overriddenSetters = inheritance.getOverridden(
interfaceType,
- new Name(accessor.library.source.uri, '$name='),
+ Name(accessor.library.source.uri, '$name='),
);
}
@@ -96,7 +97,7 @@
for (ExecutableElement overriddenElement in overriddenElements) {
var overriddenElementKind = overriddenElement.kind;
if (overriddenElement == null) {
- return new _FieldOverrideInferenceResult(false, null, true);
+ return _FieldOverrideInferenceResult(false, null, true);
}
DartType type;
@@ -109,17 +110,17 @@
isCovariant = isCovariant || parameter.isCovariant;
}
} else {
- return new _FieldOverrideInferenceResult(false, null, true);
+ return _FieldOverrideInferenceResult(false, null, true);
}
if (impliedType == null) {
impliedType = type;
} else if (type != impliedType) {
- return new _FieldOverrideInferenceResult(false, null, true);
+ return _FieldOverrideInferenceResult(false, null, true);
}
}
- return new _FieldOverrideInferenceResult(isCovariant, impliedType, false);
+ return _FieldOverrideInferenceResult(isCovariant, impliedType, false);
}
/**
@@ -139,7 +140,7 @@
for (int i = 0; i < length; i++) {
ParameterElement matchingParameter = _getCorrespondingParameter(
parameter, index, overriddenTypes[i].parameters);
- DartType type = matchingParameter?.type ?? typeProvider.dynamicType;
+ DartType type = matchingParameter?.type ?? _dynamicType;
if (parameterType == null) {
parameterType = type;
} else if (parameterType != type) {
@@ -151,10 +152,10 @@
),
);
}
- return typeProvider.dynamicType;
+ return _dynamicType;
}
}
- return parameterType ?? typeProvider.dynamicType;
+ return parameterType ?? _dynamicType;
}
/**
@@ -169,15 +170,15 @@
DartType returnType;
for (DartType type in overriddenReturnTypes) {
if (type == null) {
- type = typeProvider.dynamicType;
+ type = _dynamicType;
}
if (returnType == null) {
returnType = type;
} else if (returnType != type) {
- return typeProvider.dynamicType;
+ return _dynamicType;
}
}
- return returnType ?? typeProvider.dynamicType;
+ return returnType ?? _dynamicType;
}
/**
@@ -263,7 +264,7 @@
// inherit from any class in the cycle. We could potentially limit the
// algorithm to only not inferring types in the classes in the cycle,
// but it isn't clear that the results would be significantly better.
- throw new _CycleException();
+ throw _CycleException();
}
try {
//
@@ -336,7 +337,7 @@
List<ExecutableElement> overriddenElements = inheritance.getOverridden(
interfaceType,
- new Name(element.library.source.uri, element.name),
+ Name(element.library.source.uri, element.name),
);
if (overriddenElements == null ||
!_allSameElementKind(element, overriddenElements)) {
@@ -409,7 +410,7 @@
}
if (newType == null || newType.isBottom || newType.isDartCoreNull) {
- newType = typeProvider.dynamicType;
+ newType = _dynamicType;
}
field.type = newType;
@@ -490,7 +491,7 @@
// Reset the type.
if (!isNonNullableLibrary) {
- parameter.type = typeProvider.dynamicType;
+ parameter.type = _dynamicType;
}
element.isOperatorEqualWithParameterTypeFromObject = true;
}
diff --git a/pkg/analyzer/lib/src/test_utilities/find_element.dart b/pkg/analyzer/lib/src/test_utilities/find_element.dart
index d707a19eb..8ada776 100644
--- a/pkg/analyzer/lib/src/test_utilities/find_element.dart
+++ b/pkg/analyzer/lib/src/test_utilities/find_element.dart
@@ -74,7 +74,7 @@
FunctionElement localFunction(String name) {
FunctionElement result;
- unit.accept(new FunctionAstVisitor(
+ unit.accept(FunctionAstVisitor(
functionDeclarationStatement: (node) {
var element = node.functionDeclaration.declaredElement;
if (element is FunctionElement) {
@@ -104,7 +104,7 @@
}
}
- unit.accept(new FunctionAstVisitor(
+ unit.accept(FunctionAstVisitor(
declaredIdentifier: (node) {
updateResult(node.declaredElement);
},
diff --git a/pkg/analyzer/lib/src/test_utilities/find_node.dart b/pkg/analyzer/lib/src/test_utilities/find_node.dart
index b862a58..8d1ef8e 100644
--- a/pkg/analyzer/lib/src/test_utilities/find_node.dart
+++ b/pkg/analyzer/lib/src/test_utilities/find_node.dart
@@ -311,21 +311,21 @@
AstNode _node(String search, bool Function(AstNode) predicate) {
var index = content.indexOf(search);
if (content.contains(search, index + 1)) {
- throw new StateError('The pattern |$search| is not unique in:\n$content');
+ throw StateError('The pattern |$search| is not unique in:\n$content');
}
if (index < 0) {
- throw new StateError('The pattern |$search| is not found in:\n$content');
+ throw StateError('The pattern |$search| is not found in:\n$content');
}
- var node = new NodeLocator2(index).searchWithin(unit);
+ var node = NodeLocator2(index).searchWithin(unit);
if (node == null) {
- throw new StateError(
+ throw StateError(
'The pattern |$search| had no corresponding node in:\n$content');
}
var result = node.thisOrAncestorMatching(predicate);
if (result == null) {
- throw new StateError(
+ throw StateError(
'The node for |$search| had no matching ancestor in:\n$content');
}
return result;
diff --git a/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart b/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
index eb7bc31..7960e88 100644
--- a/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
+++ b/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
@@ -888,7 +888,7 @@
/// Optional [additionalLibraries] should have unique URIs, and paths in
/// their units are relative (will be put into `sdkRoot/lib`).
MockSdk({
- bool generateSummaryFiles: false,
+ bool generateSummaryFiles = false,
@required this.resourceProvider,
AnalysisOptionsImpl analysisOptions,
List<MockSdkLibrary> additionalLibraries = const [],
@@ -954,7 +954,7 @@
}
@override
- String get sdkVersion => throw new UnimplementedError();
+ String get sdkVersion => throw UnimplementedError();
@override
List<String> get uris =>
@@ -1006,7 +1006,7 @@
} else {
bytes = _computeLinkedBundleBytes();
}
- _bundle = new PackageBundle.fromBuffer(bytes);
+ _bundle = PackageBundle.fromBuffer(bytes);
}
return _bundle;
}
@@ -1026,7 +1026,7 @@
String path = uriMap[dartUri];
if (path != null) {
File file = resourceProvider.getResource(path);
- Uri uri = new Uri(scheme: 'dart', path: dartUri.substring(5));
+ Uri uri = Uri(scheme: 'dart', path: dartUri.substring(5));
return file.createSource(uri);
}
// If we reach here then we tried to use a dartUri that's not in the
@@ -1041,7 +1041,7 @@
List<Source> librarySources = sdkLibraries
.map((SdkLibrary library) => mapDartUri(library.shortName))
.toList();
- return new SummaryBuilder(librarySources, context).build();
+ return SummaryBuilder(librarySources, context).build();
}
}
@@ -1051,25 +1051,25 @@
MockSdkLibrary(this.units);
@override
- String get category => throw new UnimplementedError();
+ String get category => throw UnimplementedError();
@override
- bool get isDart2JsLibrary => throw new UnimplementedError();
+ bool get isDart2JsLibrary => throw UnimplementedError();
@override
- bool get isDocumented => throw new UnimplementedError();
+ bool get isDocumented => throw UnimplementedError();
@override
- bool get isImplementation => throw new UnimplementedError();
+ bool get isImplementation => throw UnimplementedError();
@override
bool get isInternal => shortName.startsWith('dart:_');
@override
- bool get isShared => throw new UnimplementedError();
+ bool get isShared => throw UnimplementedError();
@override
- bool get isVmLibrary => throw new UnimplementedError();
+ bool get isVmLibrary => throw UnimplementedError();
@override
String get path => units[0].path;
diff --git a/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart b/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
index e442dec..01f978f 100644
--- a/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
+++ b/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
@@ -822,7 +822,7 @@
nullabilitySuffix == NullabilitySuffix.none,
);
- var asyncUnit = new CompilationUnitElementImpl();
+ var asyncUnit = CompilationUnitElementImpl();
var asyncSource = analysisContext.sourceFactory.forUri('dart:async');
asyncUnit.librarySource = asyncUnit.source = asyncSource;
asyncLibrary.definingCompilationUnit = asyncUnit;
diff --git a/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart b/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart
index 6c0072b..97b1c50 100644
--- a/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart
+++ b/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart
@@ -12,7 +12,7 @@
* path and convert it as appropriate for the actual platform.
*/
mixin ResourceProviderMixin {
- MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
+ MemoryResourceProvider resourceProvider = MemoryResourceProvider();
String convertPath(String path) => resourceProvider.convertPath(path);
diff --git a/pkg/analyzer/lib/src/util/asserts.dart b/pkg/analyzer/lib/src/util/asserts.dart
index f297109..b5a2158 100644
--- a/pkg/analyzer/lib/src/util/asserts.dart
+++ b/pkg/analyzer/lib/src/util/asserts.dart
@@ -10,9 +10,9 @@
void notNull(Object value, [String description]) {
if (value == null) {
if (description == null) {
- throw new ArgumentError('Must not be null');
+ throw ArgumentError('Must not be null');
} else {
- throw new ArgumentError('Must not be null: $description');
+ throw ArgumentError('Must not be null: $description');
}
}
}
diff --git a/pkg/analyzer/lib/src/util/comment.dart b/pkg/analyzer/lib/src/util/comment.dart
index 8e61774..3188e04 100644
--- a/pkg/analyzer/lib/src/util/comment.dart
+++ b/pkg/analyzer/lib/src/util/comment.dart
@@ -28,7 +28,7 @@
rawText = rawText.trim();
// Remove leading '* ' and '/// '.
- var result = new StringBuffer();
+ var result = StringBuffer();
var lines = rawText.split('\n');
for (var line in lines) {
line = line.trim();
@@ -56,7 +56,7 @@
String getDartDocSummary(String completeText) {
if (completeText == null) return null;
- var result = new StringBuffer();
+ var result = StringBuffer();
var lines = completeText.split('\n');
for (var line in lines) {
if (result.isNotEmpty) {
diff --git a/pkg/analyzer/lib/src/util/glob.dart b/pkg/analyzer/lib/src/util/glob.dart
index 0283753..fa88a22 100644
--- a/pkg/analyzer/lib/src/util/glob.dart
+++ b/pkg/analyzer/lib/src/util/glob.dart
@@ -18,8 +18,7 @@
* The special characters are: \ ^ $ . | + [ ] ( ) { }
* as defined here: http://ecma-international.org/ecma-262/5.1/#sec-15.10
*/
- static final RegExp _specialChars =
- new RegExp(r'([\\\^\$\.\|\+\[\]\(\)\{\}])');
+ static final RegExp _specialChars = RegExp(r'([\\\^\$\.\|\+\[\]\(\)\{\}])');
/**
* The path separator used to separate components in file paths.
@@ -88,7 +87,7 @@
}
static RegExp _regexpFromGlobPattern(String pattern) {
- StringBuffer sb = new StringBuffer();
+ StringBuffer sb = StringBuffer();
sb.write('^');
List<String> chars = pattern.split('');
for (int i = 0; i < chars.length; i++) {
@@ -110,6 +109,6 @@
}
}
sb.write(r'$');
- return new RegExp(sb.toString(), caseSensitive: false);
+ return RegExp(sb.toString(), caseSensitive: false);
}
}
diff --git a/pkg/analyzer/lib/src/util/lru_map.dart b/pkg/analyzer/lib/src/util/lru_map.dart
index faa11fa..aed109c 100644
--- a/pkg/analyzer/lib/src/util/lru_map.dart
+++ b/pkg/analyzer/lib/src/util/lru_map.dart
@@ -16,7 +16,7 @@
* accessed (both get and put) recently is evicted.
*/
class LRUMap<K, V> {
- final LinkedHashMap<K, V> _map = new LinkedHashMap<K, V>();
+ final LinkedHashMap<K, V> _map = LinkedHashMap<K, V>();
final int _maxSize;
final EvictionHandler<K, V> _handler;
diff --git a/pkg/analyzer/lib/src/util/sdk.dart b/pkg/analyzer/lib/src/util/sdk.dart
index 36ed5fd..7f6bdea 100644
--- a/pkg/analyzer/lib/src/util/sdk.dart
+++ b/pkg/analyzer/lib/src/util/sdk.dart
@@ -12,7 +12,7 @@
// Try the given SDK path.
{
String location = path.join(sdkPath, 'lib', '_internal');
- if (new File(path.join(location, 'vm_platform_strong.dill')).existsSync()) {
+ if (File(path.join(location, 'vm_platform_strong.dill')).existsSync()) {
return location;
}
}
diff --git a/pkg/analyzer/lib/src/util/yaml.dart b/pkg/analyzer/lib/src/util/yaml.dart
index 4485072..47593b0b 100644
--- a/pkg/analyzer/lib/src/util/yaml.dart
+++ b/pkg/analyzer/lib/src/util/yaml.dart
@@ -71,13 +71,13 @@
YamlNode merge(YamlNode o1, YamlNode o2) {
// Handle promotion first.
YamlMap listToMap(YamlList list) {
- Map<YamlNode, YamlNode> map = new HashMap<YamlNode,
- YamlNode>(); // equals: _equals, hashCode: _hashCode
- ScalarEvent event = new ScalarEvent(null, 'true', ScalarStyle.PLAIN);
+ Map<YamlNode, YamlNode> map =
+ HashMap<YamlNode, YamlNode>(); // equals: _equals, hashCode: _hashCode
+ ScalarEvent event = ScalarEvent(null, 'true', ScalarStyle.PLAIN);
for (var element in list.nodes) {
- map[element] = new YamlScalar.internal(true, event);
+ map[element] = YamlScalar.internal(true, event);
}
- return new YamlMap.internal(map, null, CollectionStyle.BLOCK);
+ return YamlMap.internal(map, null, CollectionStyle.BLOCK);
}
if (isListOfString(o1) && isMapToBools(o2)) {
@@ -105,13 +105,13 @@
list.add(n2);
}
}
- return new YamlList.internal(list, null, CollectionStyle.BLOCK);
+ return YamlList.internal(list, null, CollectionStyle.BLOCK);
}
/// Merge maps (recursively).
YamlMap mergeMap(YamlMap m1, YamlMap m2) {
- Map<YamlNode, YamlNode> merged = new HashMap<YamlNode,
- YamlNode>(); // equals: _equals, hashCode: _hashCode
+ Map<YamlNode, YamlNode> merged =
+ HashMap<YamlNode, YamlNode>(); // equals: _equals, hashCode: _hashCode
m1.nodes.forEach((k, v) {
merged[k] = v;
});
@@ -120,7 +120,7 @@
.firstWhere((key) => key.value == k.value, orElse: () => k);
merged[mergedKey] = merge(merged[mergedKey], v);
});
- return new YamlMap.internal(merged, null, CollectionStyle.BLOCK);
+ return YamlMap.internal(merged, null, CollectionStyle.BLOCK);
}
static bool isListOfString(Object o) =>
diff --git a/pkg/analyzer/lib/src/workspace/basic.dart b/pkg/analyzer/lib/src/workspace/basic.dart
index 59ff9e1..c7c9999 100644
--- a/pkg/analyzer/lib/src/workspace/basic.dart
+++ b/pkg/analyzer/lib/src/workspace/basic.dart
@@ -30,7 +30,7 @@
WorkspacePackage findPackageFor(String filePath) {
final Folder folder = provider.getFolder(filePath);
if (provider.pathContext.isWithin(root, folder.path)) {
- _theOnlyPackage ??= new BasicWorkspacePackage(root, this);
+ _theOnlyPackage ??= BasicWorkspacePackage(root, this);
return _theOnlyPackage;
} else {
return null;
@@ -50,7 +50,7 @@
if (resource is File) {
path = resource.parent.path;
}
- return new BasicWorkspace._(provider, path, builder);
+ return BasicWorkspace._(provider, path, builder);
}
}
diff --git a/pkg/analyzer/lib/src/workspace/bazel.dart b/pkg/analyzer/lib/src/workspace/bazel.dart
index ea670ae..e620e31 100644
--- a/pkg/analyzer/lib/src/workspace/bazel.dart
+++ b/pkg/analyzer/lib/src/workspace/bazel.dart
@@ -51,7 +51,7 @@
/**
* The cache of absolute [Uri]s to [Source]s mappings.
*/
- final Map<Uri, Source> _sourceCache = new HashMap<Uri, Source>();
+ final Map<Uri, Source> _sourceCache = HashMap<Uri, Source>();
BazelPackageUriResolver(BazelWorkspace workspace)
: _workspace = workspace,
@@ -202,20 +202,20 @@
Map<String, List<Folder>> get packageMap => null;
@override
- UriResolver get packageUriResolver => new BazelPackageUriResolver(this);
+ UriResolver get packageUriResolver => BazelPackageUriResolver(this);
@override
SourceFactory createSourceFactory(DartSdk sdk, SummaryDataStore summaryData) {
List<UriResolver> resolvers = <UriResolver>[];
if (sdk != null) {
- resolvers.add(new DartUriResolver(sdk));
+ resolvers.add(DartUriResolver(sdk));
}
resolvers.add(packageUriResolver);
- resolvers.add(new BazelFileUriResolver(this));
+ resolvers.add(BazelFileUriResolver(this));
if (summaryData != null) {
resolvers.add(InSummaryUriResolver(provider, summaryData));
}
- return new SourceFactory(resolvers, null, provider);
+ return SourceFactory(resolvers, null, provider);
}
/**
@@ -365,7 +365,7 @@
String symlinkPrefix =
_findSymlinkPrefix(provider, root, binPaths: binPaths);
binPaths ??= [context.join(root, '$symlinkPrefix-bin')];
- return new BazelWorkspace._(provider, root, readonlyRoot, binPaths,
+ return BazelWorkspace._(provider, root, readonlyRoot, binPaths,
context.join(root, '$symlinkPrefix-genfiles'));
}
}
@@ -377,8 +377,8 @@
String symlinkPrefix =
_findSymlinkPrefix(provider, root, binPaths: binPaths);
binPaths ??= [context.join(root, '$symlinkPrefix-bin')];
- return new BazelWorkspace._(provider, root, null /* readonly */,
- binPaths, context.join(root, '$symlinkPrefix-genfiles'));
+ return BazelWorkspace._(provider, root, null /* readonly */, binPaths,
+ context.join(root, '$symlinkPrefix-genfiles'));
}
// Found the WORKSPACE file, must be a non-git workspace.
@@ -388,8 +388,8 @@
String symlinkPrefix =
_findSymlinkPrefix(provider, root, binPaths: binPaths);
binPaths ??= [context.join(root, '$symlinkPrefix-bin')];
- return new BazelWorkspace._(provider, root, null /* readonly */,
- binPaths, context.join(root, '$symlinkPrefix-genfiles'));
+ return BazelWorkspace._(provider, root, null /* readonly */, binPaths,
+ context.join(root, '$symlinkPrefix-genfiles'));
}
// Go up the folder.
diff --git a/pkg/analyzer/lib/src/workspace/gn.dart b/pkg/analyzer/lib/src/workspace/gn.dart
index 7244b90..2c22481 100644
--- a/pkg/analyzer/lib/src/workspace/gn.dart
+++ b/pkg/analyzer/lib/src/workspace/gn.dart
@@ -75,21 +75,21 @@
@override
UriResolver get packageUriResolver =>
- new PackageMapUriResolver(provider, packageMap);
+ PackageMapUriResolver(provider, packageMap);
@override
SourceFactory createSourceFactory(DartSdk sdk, SummaryDataStore summaryData) {
if (summaryData != null) {
- throw new UnsupportedError(
+ throw UnsupportedError(
'Summary files are not supported in a GN workspace.');
}
List<UriResolver> resolvers = <UriResolver>[];
if (sdk != null) {
- resolvers.add(new DartUriResolver(sdk));
+ resolvers.add(DartUriResolver(sdk));
}
resolvers.add(packageUriResolver);
- resolvers.add(new ResourceUriResolver(provider));
- return new SourceFactory(resolvers, packages, provider);
+ resolvers.add(ResourceUriResolver(provider));
+ return SourceFactory(resolvers, packages, provider);
}
/**
@@ -135,7 +135,7 @@
* Creates an alternate representation for available packages.
*/
Map<String, List<Folder>> _convertPackagesToMap(Packages packages) {
- Map<String, List<Folder>> folderMap = new HashMap<String, List<Folder>>();
+ Map<String, List<Folder>> folderMap = HashMap<String, List<Folder>>();
if (packages != null && packages != Packages.noPackages) {
var pathContext = provider.pathContext;
packages.asMap().forEach((String packageName, Uri uri) {
@@ -159,7 +159,7 @@
return mapOne;
});
_resolveSymbolicLinks(map);
- return new MapPackages(map);
+ return MapPackages(map);
}
/**
@@ -217,7 +217,7 @@
if (packagesFiles.isEmpty) {
return null;
}
- return new GnWorkspace._(provider, root, packagesFiles);
+ return GnWorkspace._(provider, root, packagesFiles);
}
// Go up a folder.
diff --git a/pkg/analyzer/lib/src/workspace/package_build.dart b/pkg/analyzer/lib/src/workspace/package_build.dart
index 4459dd5..1e28a2c 100644
--- a/pkg/analyzer/lib/src/workspace/package_build.dart
+++ b/pkg/analyzer/lib/src/workspace/package_build.dart
@@ -60,7 +60,7 @@
/**
* The cache of absolute [Uri]s to [Source]s mappings.
*/
- final Map<Uri, Source> _sourceCache = new HashMap<Uri, Source>();
+ final Map<Uri, Source> _sourceCache = HashMap<Uri, Source>();
PackageBuildPackageUriResolver(
PackageBuildWorkspace workspace, this._normalUriResolver)
@@ -208,8 +208,8 @@
}
@override
- UriResolver get packageUriResolver => new PackageBuildPackageUriResolver(
- this, new PackageMapUriResolver(provider, packageMap));
+ UriResolver get packageUriResolver => PackageBuildPackageUriResolver(
+ this, PackageMapUriResolver(provider, packageMap));
/**
* For some package file, which may or may not be a package source (it could
@@ -246,16 +246,16 @@
@override
SourceFactory createSourceFactory(DartSdk sdk, SummaryDataStore summaryData) {
if (summaryData != null) {
- throw new UnsupportedError(
+ throw UnsupportedError(
'Summary files are not supported in a package:build workspace.');
}
List<UriResolver> resolvers = <UriResolver>[];
if (sdk != null) {
- resolvers.add(new DartUriResolver(sdk));
+ resolvers.add(DartUriResolver(sdk));
}
resolvers.add(packageUriResolver);
- resolvers.add(new PackageBuildFileUriResolver(this));
- return new SourceFactory(resolvers, packages, provider);
+ resolvers.add(PackageBuildFileUriResolver(this));
+ return SourceFactory(resolvers, packages, provider);
}
/**
@@ -288,7 +288,7 @@
path.Context context = provider.pathContext;
final folder = provider.getFolder(context.dirname(filePath));
if (context.isWithin(root, folder.path)) {
- _theOnlyPackage ??= new PackageBuildWorkspacePackage(root, this);
+ _theOnlyPackage ??= PackageBuildWorkspacePackage(root, this);
return _theOnlyPackage;
} else {
return null;
@@ -320,7 +320,7 @@
if (dartToolBuildDir.exists && pubspec.exists) {
try {
final yaml = loadYaml(pubspec.readAsStringSync());
- return new PackageBuildWorkspace._(
+ return PackageBuildWorkspace._(
provider, folder.path, yaml['name'], builder);
} on Exception {}
}
diff --git a/pkg/analyzer/lib/src/workspace/pub.dart b/pkg/analyzer/lib/src/workspace/pub.dart
index 65347eb..2ccbfed 100644
--- a/pkg/analyzer/lib/src/workspace/pub.dart
+++ b/pkg/analyzer/lib/src/workspace/pub.dart
@@ -26,7 +26,7 @@
WorkspacePackage findPackageFor(String filePath) {
final Folder folder = provider.getFolder(filePath);
if (provider.pathContext.isWithin(root, folder.path)) {
- _theOnlyPackage ??= new PubWorkspacePackage(root, this);
+ _theOnlyPackage ??= PubWorkspacePackage(root, this);
return _theOnlyPackage;
} else {
return null;
@@ -50,7 +50,7 @@
if (folder.getChildAssumingFile(_pubspecName).exists) {
// Found the pubspec.yaml file; this is our root.
String root = folder.path;
- return new PubWorkspace._(provider, root, builder);
+ return PubWorkspace._(provider, root, builder);
}
// Go up a folder.
diff --git a/pkg/analyzer/lib/src/workspace/simple.dart b/pkg/analyzer/lib/src/workspace/simple.dart
index c2d0d8e..b86c842 100644
--- a/pkg/analyzer/lib/src/workspace/simple.dart
+++ b/pkg/analyzer/lib/src/workspace/simple.dart
@@ -44,20 +44,20 @@
@override
UriResolver get packageUriResolver =>
- new PackageMapUriResolver(provider, packageMap);
+ PackageMapUriResolver(provider, packageMap);
@override
SourceFactory createSourceFactory(DartSdk sdk, SummaryDataStore summaryData) {
if (summaryData != null) {
- throw new UnsupportedError(
+ throw UnsupportedError(
'Summary files are not supported in a Pub workspace.');
}
List<UriResolver> resolvers = <UriResolver>[];
if (sdk != null) {
- resolvers.add(new DartUriResolver(sdk));
+ resolvers.add(DartUriResolver(sdk));
}
resolvers.add(packageUriResolver);
- resolvers.add(new ResourceUriResolver(provider));
- return new SourceFactory(resolvers, packages, provider);
+ resolvers.add(ResourceUriResolver(provider));
+ return SourceFactory(resolvers, packages, provider);
}
}
diff --git a/pkg/analyzer/test/dart/analysis/declared_variables_test.dart b/pkg/analyzer/test/dart/analysis/declared_variables_test.dart
index 129250a..0bdd537 100644
--- a/pkg/analyzer/test/dart/analysis/declared_variables_test.dart
+++ b/pkg/analyzer/test/dart/analysis/declared_variables_test.dart
@@ -18,84 +18,84 @@
@reflectiveTest
class DeclaredVariablesTest {
void test_getBool_false() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String variableName = "var";
DeclaredVariables variables =
- new DeclaredVariables.fromMap({variableName: 'false'});
+ DeclaredVariables.fromMap({variableName: 'false'});
DartObject object = variables.getBool(typeProvider, variableName);
expect(object, isNotNull);
expect(object.toBoolValue(), false);
}
void test_getBool_invalid() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String variableName = "var";
DeclaredVariables variables =
- new DeclaredVariables.fromMap({variableName: 'not true'});
+ DeclaredVariables.fromMap({variableName: 'not true'});
_assertNullDartObject(
typeProvider, variables.getBool(typeProvider, variableName));
}
void test_getBool_true() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String variableName = "var";
DeclaredVariables variables =
- new DeclaredVariables.fromMap({variableName: 'true'});
+ DeclaredVariables.fromMap({variableName: 'true'});
DartObject object = variables.getBool(typeProvider, variableName);
expect(object, isNotNull);
expect(object.toBoolValue(), true);
}
void test_getBool_undefined() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String variableName = "var";
- DeclaredVariables variables = new DeclaredVariables();
+ DeclaredVariables variables = DeclaredVariables();
_assertUnknownDartObject(
typeProvider.boolType, variables.getBool(typeProvider, variableName));
}
void test_getInt_invalid() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String variableName = "var";
- DeclaredVariables variables = new DeclaredVariables.fromMap(
- {variableName: 'four score and seven years'});
+ DeclaredVariables variables =
+ DeclaredVariables.fromMap({variableName: 'four score and seven years'});
_assertNullDartObject(
typeProvider, variables.getInt(typeProvider, variableName));
}
void test_getInt_undefined() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String variableName = "var";
- DeclaredVariables variables = new DeclaredVariables();
+ DeclaredVariables variables = DeclaredVariables();
_assertUnknownDartObject(
typeProvider.intType, variables.getInt(typeProvider, variableName));
}
void test_getInt_valid() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String variableName = "var";
DeclaredVariables variables =
- new DeclaredVariables.fromMap({variableName: '23'});
+ DeclaredVariables.fromMap({variableName: '23'});
DartObject object = variables.getInt(typeProvider, variableName);
expect(object, isNotNull);
expect(object.toIntValue(), 23);
}
void test_getString_defined() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String variableName = "var";
String value = "value";
DeclaredVariables variables =
- new DeclaredVariables.fromMap({variableName: value});
+ DeclaredVariables.fromMap({variableName: value});
DartObject object = variables.getString(typeProvider, variableName);
expect(object, isNotNull);
expect(object.toStringValue(), value);
}
void test_getString_undefined() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String variableName = "var";
- DeclaredVariables variables = new DeclaredVariables();
+ DeclaredVariables variables = DeclaredVariables();
_assertUnknownDartObject(typeProvider.stringType,
variables.getString(typeProvider, variableName));
}
diff --git a/pkg/analyzer/test/dart/ast/ast_test.dart b/pkg/analyzer/test/dart/ast/ast_test.dart
index d764b46..0030eeb 100644
--- a/pkg/analyzer/test/dart/ast/ast_test.dart
+++ b/pkg/analyzer/test/dart/ast/ast_test.dart
@@ -41,8 +41,7 @@
@reflectiveTest
class ClassDeclarationTest extends ParserTestCase {
void test_getConstructor() {
- List<ConstructorInitializer> initializers =
- new List<ConstructorInitializer>();
+ List<ConstructorInitializer> initializers = List<ConstructorInitializer>();
ConstructorDeclaration defaultConstructor =
AstTestFactory.constructorDeclaration(
AstTestFactory.identifier3("Test"),
@@ -498,7 +497,7 @@
void test_addAll() {
AstNode parent = AstTestFactory.argumentList();
- List<AstNode> firstNodes = new List<AstNode>();
+ List<AstNode> firstNodes = List<AstNode>();
AstNode firstNode = AstTestFactory.booleanLiteral(true);
AstNode secondNode = AstTestFactory.booleanLiteral(false);
firstNodes.add(firstNode);
@@ -510,7 +509,7 @@
expect(list[1], same(secondNode));
expect(firstNode.parent, same(parent));
expect(secondNode.parent, same(parent));
- List<AstNode> secondNodes = new List<AstNode>();
+ List<AstNode> secondNodes = List<AstNode>();
AstNode thirdNode = AstTestFactory.booleanLiteral(true);
AstNode fourthNode = AstTestFactory.booleanLiteral(false);
secondNodes.add(thirdNode);
@@ -588,7 +587,7 @@
}
void test_indexOf() {
- List<AstNode> nodes = new List<AstNode>();
+ List<AstNode> nodes = List<AstNode>();
AstNode firstNode = AstTestFactory.booleanLiteral(true);
AstNode secondNode = AstTestFactory.booleanLiteral(false);
AstNode thirdNode = AstTestFactory.booleanLiteral(true);
@@ -608,7 +607,7 @@
}
void test_remove() {
- List<AstNode> nodes = new List<AstNode>();
+ List<AstNode> nodes = List<AstNode>();
AstNode firstNode = AstTestFactory.booleanLiteral(true);
AstNode secondNode = AstTestFactory.booleanLiteral(false);
AstNode thirdNode = AstTestFactory.booleanLiteral(true);
@@ -648,7 +647,7 @@
}
void test_set() {
- List<AstNode> nodes = new List<AstNode>();
+ List<AstNode> nodes = List<AstNode>();
AstNode firstNode = AstTestFactory.booleanLiteral(true);
AstNode secondNode = AstTestFactory.booleanLiteral(false);
AstNode thirdNode = AstTestFactory.booleanLiteral(true);
@@ -711,15 +710,14 @@
CompilationUnit get unit {
if (_unit == null) {
GatheringErrorListener listener =
- new GatheringErrorListener(checkRanges: true);
+ GatheringErrorListener(checkRanges: true);
var source =
- new StringSource(contents, 'PreviousTokenTest_findPrevious.dart');
- var scanner = new Scanner.fasta(source, listener)
+ StringSource(contents, 'PreviousTokenTest_findPrevious.dart');
+ var scanner = Scanner.fasta(source, listener)
..configureFeatures(featureSet);
Token tokens = scanner.tokenize();
- _unit =
- new Parser(source, listener, featureSet: featureSet, useFasta: true)
- .parseCompilationUnit(tokens);
+ _unit = Parser(source, listener, featureSet: featureSet, useFasta: true)
+ .parseCompilationUnit(tokens);
}
return _unit;
}
@@ -761,10 +759,9 @@
BlockFunctionBody body = method.body;
Statement statement = body.block.statements[0];
- GatheringErrorListener listener =
- new GatheringErrorListener(checkRanges: true);
- var source = new StringSource('missing', 'PreviousTokenTest_missing.dart');
- var scanner = new Scanner.fasta(source, listener)
+ GatheringErrorListener listener = GatheringErrorListener(checkRanges: true);
+ var source = StringSource('missing', 'PreviousTokenTest_missing.dart');
+ var scanner = Scanner.fasta(source, listener)
..configureFeatures(featureSet);
Token missing = scanner.tokenize();
@@ -1328,7 +1325,7 @@
// 'a${bb}ccc'
{
var ae = AstTestFactory.interpolationString("'a", "a");
- var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
+ var cToken = StringToken(TokenType.STRING, "ccc'", 10);
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 1);
@@ -1337,7 +1334,7 @@
// '''a${bb}ccc'''
{
var ae = AstTestFactory.interpolationString("'''a", "a");
- var cToken = new StringToken(TokenType.STRING, "ccc'''", 10);
+ var cToken = StringToken(TokenType.STRING, "ccc'''", 10);
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 3);
@@ -1346,7 +1343,7 @@
// """a${bb}ccc"""
{
var ae = AstTestFactory.interpolationString('"""a', "a");
- var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10);
+ var cToken = StringToken(TokenType.STRING, 'ccc"""', 10);
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 3);
@@ -1355,7 +1352,7 @@
// r'a${bb}ccc'
{
var ae = AstTestFactory.interpolationString("r'a", "a");
- var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
+ var cToken = StringToken(TokenType.STRING, "ccc'", 10);
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 2);
@@ -1364,7 +1361,7 @@
// r'''a${bb}ccc'''
{
var ae = AstTestFactory.interpolationString("r'''a", "a");
- var cToken = new StringToken(TokenType.STRING, "ccc'''", 10);
+ var cToken = StringToken(TokenType.STRING, "ccc'''", 10);
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 4);
@@ -1373,7 +1370,7 @@
// r"""a${bb}ccc"""
{
var ae = AstTestFactory.interpolationString('r"""a', "a");
- var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10);
+ var cToken = StringToken(TokenType.STRING, 'ccc"""', 10);
var cElement = astFactory.interpolationString(cToken, 'ccc');
StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
expect(node.contentsOffset, 4);
@@ -1459,7 +1456,7 @@
VariableDeclaration varDecl = AstTestFactory.variableDeclaration("a");
TopLevelVariableDeclaration decl =
AstTestFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]);
- Comment comment = astFactory.documentationComment(new List<Token>(0));
+ Comment comment = astFactory.documentationComment(List<Token>(0));
expect(varDecl.documentationComment, isNull);
decl.documentationComment = comment;
expect(varDecl.documentationComment, isNotNull);
@@ -1468,7 +1465,7 @@
void test_getDocumentationComment_onNode() {
VariableDeclaration decl = AstTestFactory.variableDeclaration("a");
- Comment comment = astFactory.documentationComment(new List<Token>(0));
+ Comment comment = astFactory.documentationComment(List<Token>(0));
decl.documentationComment = comment;
expect(decl.documentationComment, isNotNull);
}
diff --git a/pkg/analyzer/test/dart/ast/visitor_test.dart b/pkg/analyzer/test/dart/ast/visitor_test.dart
index 31b3c35a..250a644 100644
--- a/pkg/analyzer/test/dart/ast/visitor_test.dart
+++ b/pkg/analyzer/test/dart/ast/visitor_test.dart
@@ -39,9 +39,9 @@
}
}''';
CompilationUnit unit = parseCompilationUnit(source);
- List<AstNode> nodes = new List<AstNode>();
+ List<AstNode> nodes = List<AstNode>();
_BreadthFirstVisitorTestHelper visitor =
- new _BreadthFirstVisitorTestHelper(nodes);
+ _BreadthFirstVisitorTestHelper(nodes);
visitor.visitAllNodes(unit);
expect(nodes, hasLength(59));
expect(nodes[0], isCompilationUnit);
diff --git a/pkg/analyzer/test/embedder_tests.dart b/pkg/analyzer/test/embedder_tests.dart
index 71101ab..01ba2eb 100644
--- a/pkg/analyzer/test/embedder_tests.dart
+++ b/pkg/analyzer/test/embedder_tests.dart
@@ -18,9 +18,9 @@
ResourceProvider resourceProvider;
buildResourceProvider() {
- MemoryResourceProvider rawProvider = new MemoryResourceProvider();
- resourceProvider = new TestResourceProvider(rawProvider);
- pathTranslator = new TestPathTranslator(rawProvider)
+ MemoryResourceProvider rawProvider = MemoryResourceProvider();
+ resourceProvider = TestResourceProvider(rawProvider);
+ pathTranslator = TestPathTranslator(rawProvider)
..newFolder('/home/.pub-cache/empty')
..newFolder('/home/.pub-cache/fox/lib')
..newFile('/home/.pub-cache/fox/lib/_embedder.yaml', r'''
diff --git a/pkg/analyzer/test/error/error_test.dart b/pkg/analyzer/test/error/error_test.dart
index 3d0c973..d091b8e 100644
--- a/pkg/analyzer/test/error/error_test.dart
+++ b/pkg/analyzer/test/error/error_test.dart
@@ -73,7 +73,7 @@
List<String> pathComponents = _analyzerRootComponents.toList()
..addAll(relativeComponents);
String filePath = path.normalize(path.joinAll(pathComponents));
- return parseCompilationUnit(new File(filePath).readAsStringSync());
+ return parseCompilationUnit(File(filePath).readAsStringSync());
}
test_errorCodeValues() {
diff --git a/pkg/analyzer/test/file_system/file_system_test_support.dart b/pkg/analyzer/test/file_system/file_system_test_support.dart
index 25c0d4b..19ec201 100644
--- a/pkg/analyzer/test/file_system/file_system_test_support.dart
+++ b/pkg/analyzer/test/file_system/file_system_test_support.dart
@@ -9,9 +9,9 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-final isFile = new TypeMatcher<File>();
-final isFileSystemException = new TypeMatcher<FileSystemException>();
-final isFolder = new TypeMatcher<Folder>();
+final isFile = TypeMatcher<File>();
+final isFileSystemException = TypeMatcher<FileSystemException>();
+final isFolder = TypeMatcher<Folder>();
abstract class FileSystemTestSupport {
/// The content used for the file at the [defaultFilePath] if it is created
@@ -93,7 +93,7 @@
expect(source, isNotNull);
expect(source.fullName, defaultFilePath);
expect(source.uriKind, UriKind.FILE_URI);
- expect(source.uri, new Uri.file(defaultFilePath));
+ expect(source.uri, Uri.file(defaultFilePath));
expect(source.exists(), isTrue);
expect(source.contents.data, defaultFileContent);
}
@@ -292,7 +292,7 @@
test_toUri() {
File file = getFile(exists: true);
- expect(file.toUri(), new Uri.file(file.path));
+ expect(file.toUri(), Uri.file(file.path));
}
test_writeAsBytesSync_existing() {
@@ -614,7 +614,7 @@
test_toUri() {
Folder folder = getFolder(exists: true);
- expect(folder.toUri(), new Uri.directory(defaultFolderPath));
+ expect(folder.toUri(), Uri.directory(defaultFolderPath));
}
/**
diff --git a/pkg/analyzer/test/file_system/memory_file_system_test.dart b/pkg/analyzer/test/file_system/memory_file_system_test.dart
index 76ee1651..099e8b7 100644
--- a/pkg/analyzer/test/file_system/memory_file_system_test.dart
+++ b/pkg/analyzer/test/file_system/memory_file_system_test.dart
@@ -53,7 +53,7 @@
/// Create the resource provider to be used by the tests. Subclasses can
/// override this method to change the class of resource provider that is
/// used.
- MemoryResourceProvider createProvider() => new MemoryResourceProvider();
+ MemoryResourceProvider createProvider() => MemoryResourceProvider();
File getFile({@required bool exists, String content, String filePath}) {
if (filePath == null) {
@@ -89,7 +89,7 @@
@reflectiveTest
class FileSystemExceptionTest {
test_constructor() {
- var exception = new FileSystemException('/my/path', 'my message');
+ var exception = FileSystemException('/my/path', 'my message');
expect(exception.path, '/my/path');
expect(exception.message, 'my message');
expect(exception.toString(),
@@ -124,7 +124,7 @@
}
test_equals_false_notMemorySource() {
- expect(source == new Object(), isFalse);
+ expect(source == Object(), isFalse);
}
test_equals_true_sameFile() {
@@ -445,7 +445,7 @@
}
Future _delayed(computation()) {
- return new Future.delayed(Duration.zero, computation);
+ return Future.delayed(Duration.zero, computation);
}
_watchingFolder(String path, test(List<WatchEvent> changesReceived)) {
diff --git a/pkg/analyzer/test/file_system/overlay_file_system_test.dart b/pkg/analyzer/test/file_system/overlay_file_system_test.dart
index 5138f20..952f5f3 100644
--- a/pkg/analyzer/test/file_system/overlay_file_system_test.dart
+++ b/pkg/analyzer/test/file_system/overlay_file_system_test.dart
@@ -18,9 +18,9 @@
});
}
-final _isFile = new TypeMatcher<File>();
-final _isFileSystemException = new TypeMatcher<FileSystemException>();
-final _isFolder = new TypeMatcher<Folder>();
+final _isFile = TypeMatcher<File>();
+final _isFileSystemException = TypeMatcher<FileSystemException>();
+final _isFolder = TypeMatcher<Folder>();
@reflectiveTest
class FileTest extends OverlayTestSupport {
@@ -71,7 +71,7 @@
Source source = file.createSource();
expect(source, isNotNull);
expect(source.fullName, defaultFilePath);
- expect(source.uri, new Uri.file(defaultFilePath));
+ expect(source.uri, Uri.file(defaultFilePath));
}
test_delete_existing_withoutOverlay() {
@@ -348,7 +348,7 @@
test_toUri() {
File file = _file(exists: true);
- expect(file.toUri(), new Uri.file(file.path));
+ expect(file.toUri(), Uri.file(file.path));
}
test_writeAsBytesSync_withoutOverlay() {
@@ -469,7 +469,7 @@
test_delete_notExisting() {
Folder folder = _folder(exists: false);
expect(folder.exists, isFalse);
- expect(() => folder.delete(), throwsA(new TypeMatcher<ArgumentError>()));
+ expect(() => folder.delete(), throwsA(TypeMatcher<ArgumentError>()));
}
test_exists_false() {
@@ -618,7 +618,7 @@
test_toUri() {
Folder folder = _folder(exists: true);
- expect(folder.toUri(), new Uri.directory(folder.path));
+ expect(folder.toUri(), Uri.directory(folder.path));
}
void _resolveSymbolicLinksSync_noLinks(Folder folder) {
@@ -813,8 +813,8 @@
String defaultFilePath;
void setUp() {
- baseProvider = new MemoryResourceProvider();
- provider = new OverlayResourceProvider(baseProvider);
+ baseProvider = MemoryResourceProvider();
+ provider = OverlayResourceProvider(baseProvider);
defaultFolderPath = baseProvider.convertPath('/foo/bar');
defaultFilePath = baseProvider.convertPath('/foo/bar/test.dart');
diff --git a/pkg/analyzer/test/file_system/physical_file_system_test.dart b/pkg/analyzer/test/file_system/physical_file_system_test.dart
index 11e744e..ef01cca 100644
--- a/pkg/analyzer/test/file_system/physical_file_system_test.dart
+++ b/pkg/analyzer/test/file_system/physical_file_system_test.dart
@@ -13,7 +13,7 @@
import 'file_system_test_support.dart';
main() {
- if (!new bool.fromEnvironment('skipPhysicalResourceProviderTests')) {
+ if (!bool.fromEnvironment('skipPhysicalResourceProviderTests')) {
defineReflectiveSuite(() {
defineReflectiveTests(PhysicalFileTest);
defineReflectiveTests(PhysicalFolderTest);
@@ -51,8 +51,7 @@
/// Create the resource provider to be used by the tests. Subclasses can
/// override this method to change the class of resource provider that is
/// used.
- PhysicalResourceProvider createProvider() =>
- new PhysicalResourceProvider(null);
+ PhysicalResourceProvider createProvider() => PhysicalResourceProvider(null);
File getFile({@required bool exists, String content, String filePath}) {
File file = provider.getFile(filePath ?? defaultFilePath);
@@ -111,18 +110,18 @@
test_resolveSymbolicLinksSync_links_existing() {
String pathA = join(tempPath, defaultFileContent);
String pathB = join(pathA, 'b');
- new io.Directory(pathB).createSync(recursive: true);
+ io.Directory(pathB).createSync(recursive: true);
String filePath = join(pathB, 'test.txt');
- io.File testFile = new io.File(filePath);
+ io.File testFile = io.File(filePath);
testFile.writeAsStringSync('test');
String pathC = join(tempPath, 'c');
String pathD = join(pathC, 'd');
- new io.Link(pathD).createSync(pathA, recursive: true);
+ io.Link(pathD).createSync(pathA, recursive: true);
String pathE = join(tempPath, 'e');
String pathF = join(pathE, 'f');
- new io.Link(pathF).createSync(pathC, recursive: true);
+ io.Link(pathF).createSync(pathC, recursive: true);
String linkPath = join(tempPath, 'e', 'f', 'd', 'b', 'test.txt');
File file = provider.getFile(linkPath);
diff --git a/pkg/analyzer/test/file_system/physical_resource_provider_watch_test.dart b/pkg/analyzer/test/file_system/physical_resource_provider_watch_test.dart
index bac4ad2..16436c9 100644
--- a/pkg/analyzer/test/file_system/physical_resource_provider_watch_test.dart
+++ b/pkg/analyzer/test/file_system/physical_resource_provider_watch_test.dart
@@ -15,7 +15,7 @@
import 'physical_file_system_test.dart' show BaseTest;
main() {
- if (!new bool.fromEnvironment('skipPhysicalResourceProviderTests')) {
+ if (!bool.fromEnvironment('skipPhysicalResourceProviderTests')) {
defineReflectiveSuite(() {
defineReflectiveTests(PhysicalResourceProviderWatchTest);
});
@@ -26,7 +26,7 @@
class PhysicalResourceProviderWatchTest extends BaseTest {
test_watchFile_delete() {
var filePath = path.join(tempPath, 'foo');
- var file = new io.File(filePath);
+ var file = io.File(filePath);
file.writeAsStringSync('contents 1');
return _watchingFile(filePath, (changesReceived) {
expect(changesReceived, hasLength(0));
@@ -50,7 +50,7 @@
test_watchFile_modify() {
var filePath = path.join(tempPath, 'foo');
- var file = new io.File(filePath);
+ var file = io.File(filePath);
file.writeAsStringSync('contents 1');
return _watchingFile(filePath, (changesReceived) {
expect(changesReceived, hasLength(0));
@@ -67,7 +67,7 @@
return _watchingFolder(tempPath, (changesReceived) {
expect(changesReceived, hasLength(0));
var filePath = path.join(tempPath, 'foo');
- new io.File(filePath).writeAsStringSync('contents');
+ io.File(filePath).writeAsStringSync('contents');
return _delayed(() {
// There should be an "add" event indicating that the file was added.
// Depending on how long it took to write the contents, it may be
@@ -85,7 +85,7 @@
test_watchFolder_deleteFile() {
var filePath = path.join(tempPath, 'foo');
- var file = new io.File(filePath);
+ var file = io.File(filePath);
file.writeAsStringSync('contents 1');
return _watchingFolder(tempPath, (changesReceived) {
expect(changesReceived, hasLength(0));
@@ -100,7 +100,7 @@
test_watchFolder_modifyFile() {
var filePath = path.join(tempPath, 'foo');
- var file = new io.File(filePath);
+ var file = io.File(filePath);
file.writeAsStringSync('contents 1');
return _watchingFolder(tempPath, (changesReceived) {
expect(changesReceived, hasLength(0));
@@ -115,9 +115,9 @@
test_watchFolder_modifyFile_inSubDir() {
var fooPath = path.join(tempPath, 'foo');
- new io.Directory(fooPath).createSync();
+ io.Directory(fooPath).createSync();
var barPath = path.join(tempPath, 'bar');
- var file = new io.File(barPath);
+ var file = io.File(barPath);
file.writeAsStringSync('contents 1');
return _watchingFolder(tempPath, (changesReceived) {
expect(changesReceived, hasLength(0));
@@ -134,7 +134,7 @@
// Give the tests 1 second to detect the changes. While it may only
// take up to a few hundred ms, a whole second gives a good margin
// for when running tests.
- return new Future.delayed(new Duration(seconds: 1), computation);
+ return Future.delayed(Duration(seconds: 1), computation);
}
_watchingFile(String filePath, test(List<WatchEvent> changesReceived)) {
diff --git a/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart b/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart
index 27994af..7cab103 100644
--- a/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart
+++ b/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart
@@ -19,7 +19,7 @@
ResourceUriResolver resolver;
void setUp() {
- resolver = new ResourceUriResolver(resourceProvider);
+ resolver = ResourceUriResolver(resourceProvider);
newFile('/test.dart');
newFolder('/folder');
}
@@ -48,14 +48,14 @@
}
void test_resolveAbsolute_notFile_dartUri() {
- var uri = new Uri(scheme: 'dart', path: 'core');
+ var uri = Uri(scheme: 'dart', path: 'core');
Source source = resolver.resolveAbsolute(uri);
expect(source, isNull);
}
void test_resolveAbsolute_notFile_httpsUri() {
- var uri = new Uri(scheme: 'https', path: '127.0.0.1/test.dart');
+ var uri = Uri(scheme: 'https', path: '127.0.0.1/test.dart');
Source source = resolver.resolveAbsolute(uri);
expect(source, isNull);
@@ -68,8 +68,8 @@
expect(source, isNotNull);
expect(resolver.restoreAbsolute(source), uri);
expect(
- resolver.restoreAbsolute(
- new NonExistingSource(source.fullName, null, null)),
+ resolver
+ .restoreAbsolute(NonExistingSource(source.fullName, null, null)),
uri);
}
}
diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
index c7b52204..b2d7b4d 100644
--- a/pkg/analyzer/test/generated/all_the_rest_test.dart
+++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
@@ -34,8 +34,8 @@
@reflectiveTest
class ContentCacheTest {
test_setContents() async {
- Source source = new TestSource();
- ContentCache cache = new ContentCache();
+ Source source = TestSource();
+ ContentCache cache = ContentCache();
expect(cache.getContents(source), isNull);
expect(cache.getModificationStamp(source), isNull);
String contents = "library lib;";
@@ -54,11 +54,11 @@
@reflectiveTest
class CustomUriResolverTest {
void test_creation() {
- expect(new CustomUriResolver({}), isNotNull);
+ expect(CustomUriResolver({}), isNotNull);
}
void test_resolve_unknown_uri() {
- UriResolver resolver = new CustomUriResolver({
+ UriResolver resolver = CustomUriResolver({
'custom:library': '/path/to/library.dart',
});
Source result = resolver.resolveAbsolute(Uri.parse("custom:non_library"));
@@ -68,7 +68,7 @@
void test_resolve_uri() {
String filePath =
FileUtilities2.createFile("/path/to/library.dart").getAbsolutePath();
- UriResolver resolver = new CustomUriResolver({
+ UriResolver resolver = CustomUriResolver({
'custom:library': filePath,
});
Source result = resolver.resolveAbsolute(Uri.parse("custom:library"));
@@ -84,11 +84,11 @@
@override
setUp() {
super.setUp();
- resolver = new DartUriResolver(sdk);
+ resolver = DartUriResolver(sdk);
}
void test_creation() {
- expect(new DartUriResolver(sdk), isNotNull);
+ expect(DartUriResolver(sdk), isNotNull);
}
void test_isDartUri_null_scheme() {
@@ -119,14 +119,14 @@
}
void test_restoreAbsolute_library() {
- _SourceMock source = new _SourceMock();
+ _SourceMock source = _SourceMock();
source.uri = toUri('/sdk/lib/core/core.dart');
Uri dartUri = resolver.restoreAbsolute(source);
expect(dartUri.toString(), 'dart:core');
}
void test_restoreAbsolute_part() {
- _SourceMock source = new _SourceMock();
+ _SourceMock source = _SourceMock();
source.uri = toUri('/sdk/lib/core/int.dart');
Uri dartUri = resolver.restoreAbsolute(source);
expect(dartUri.toString(), 'dart:core/int.dart');
@@ -186,22 +186,22 @@
test_equals_false_differentFiles() async {
JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart");
JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart");
- FileBasedSource source1 = new FileBasedSource(file1);
- FileBasedSource source2 = new FileBasedSource(file2);
+ FileBasedSource source1 = FileBasedSource(file1);
+ FileBasedSource source2 = FileBasedSource(file2);
expect(source1 == source2, isFalse);
}
test_equals_false_null() async {
JavaFile file = FileUtilities2.createFile("/does/not/exist1.dart");
- FileBasedSource source1 = new FileBasedSource(file);
+ FileBasedSource source1 = FileBasedSource(file);
expect(source1 == null, isFalse);
}
test_equals_true() async {
JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart");
JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source1 = new FileBasedSource(file1);
- FileBasedSource source2 = new FileBasedSource(file2);
+ FileBasedSource source1 = FileBasedSource(file1);
+ FileBasedSource source2 = FileBasedSource(file2);
expect(source1 == source2, isTrue);
}
@@ -250,28 +250,28 @@
test_getFullName() async {
String fullPath = "/does/not/exist.dart";
JavaFile file = FileUtilities2.createFile(fullPath);
- FileBasedSource source = new FileBasedSource(file);
+ FileBasedSource source = FileBasedSource(file);
expect(source.fullName, file.getAbsolutePath());
}
test_getShortName() async {
JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source = new FileBasedSource(file);
+ FileBasedSource source = FileBasedSource(file);
expect(source.shortName, "exist.dart");
}
test_hashCode() async {
JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart");
JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source1 = new FileBasedSource(file1);
- FileBasedSource source2 = new FileBasedSource(file2);
+ FileBasedSource source1 = FileBasedSource(file1);
+ FileBasedSource source2 = FileBasedSource(file2);
expect(source2.hashCode, source1.hashCode);
}
test_isInSystemLibrary_contagious() async {
- DartSdk sdk = (new _SimpleDartSdkTest()..setUp()).sdk;
- UriResolver resolver = new DartUriResolver(sdk);
- SourceFactory factory = new SourceFactory([resolver]);
+ DartSdk sdk = (_SimpleDartSdkTest()..setUp()).sdk;
+ UriResolver resolver = DartUriResolver(sdk);
+ SourceFactory factory = SourceFactory([resolver]);
// resolve dart:core
Source result = resolver.resolveAbsolute(Uri.parse("dart:core"));
expect(result, isNotNull);
@@ -284,7 +284,7 @@
test_isInSystemLibrary_false() async {
JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source = new FileBasedSource(file);
+ FileBasedSource source = FileBasedSource(file);
expect(source, isNotNull);
expect(source.fullName, file.getAbsolutePath());
expect(source.isInSystemLibrary, isFalse);
@@ -292,7 +292,7 @@
test_issue14500() async {
// see https://code.google.com/p/dart/issues/detail?id=14500
- FileBasedSource source = new FileBasedSource(
+ FileBasedSource source = FileBasedSource(
FileUtilities2.createFile("/some/packages/foo:bar.dart"));
expect(source, isNotNull);
expect(source.exists(), isFalse);
@@ -306,7 +306,7 @@
return;
}
JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
- FileBasedSource source = new FileBasedSource(file);
+ FileBasedSource source = FileBasedSource(file);
expect(source, isNotNull);
Uri relative = resolveRelativeUri(source.uri, Uri.parse("lib.dart"));
expect(relative, isNotNull);
@@ -321,7 +321,7 @@
return;
}
JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
- FileBasedSource source = new FileBasedSource(file);
+ FileBasedSource source = FileBasedSource(file);
expect(source, isNotNull);
Uri relative = resolveRelativeUri(source.uri, Uri.parse("c/lib.dart"));
expect(relative, isNotNull);
@@ -335,7 +335,7 @@
return;
}
JavaFile file = FileUtilities2.createFile("/a/b/test.dart");
- FileBasedSource source = new FileBasedSource(file);
+ FileBasedSource source = FileBasedSource(file);
expect(source, isNotNull);
Uri relative = resolveRelativeUri(source.uri, Uri.parse("../c/lib.dart"));
expect(relative, isNotNull);
@@ -344,7 +344,7 @@
test_system() async {
JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source = new FileBasedSource(file, Uri.parse("dart:core"));
+ FileBasedSource source = FileBasedSource(file, Uri.parse("dart:core"));
expect(source, isNotNull);
expect(source.fullName, file.getAbsolutePath());
expect(source.isInSystemLibrary, isTrue);
@@ -441,7 +441,7 @@
''');
Folder sdkFolder = newFolder('/sdk');
- sdk = new FolderBasedDartSdk(resourceProvider, sdkFolder);
+ sdk = FolderBasedDartSdk(resourceProvider, sdkFolder);
}
}
@@ -451,6 +451,6 @@
@override
noSuchMethod(Invocation invocation) {
- throw new StateError('Unexpected invocation of ${invocation.memberName}');
+ throw StateError('Unexpected invocation of ${invocation.memberName}');
}
}
diff --git a/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart b/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart
index db57bbb..3912bc6 100644
--- a/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart
+++ b/pkg/analyzer/test/generated/checked_mode_compile_time_error_code_test.dart
@@ -479,7 +479,7 @@
const Object x = [1];
const List<String> y = x;
''', [
- error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 41, 1),
+ error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 45, 1),
]);
}
@@ -488,7 +488,7 @@
const Object x = {1: 1};
const Map<String, dynamic> y = x;
''', [
- error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 52, 1),
+ error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 56, 1),
]);
}
@@ -497,7 +497,7 @@
const Object x = {1: 1};
const Map<dynamic, String> y = x;
''', [
- error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 52, 1),
+ error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 56, 1),
]);
}
@@ -619,7 +619,7 @@
await assertErrorsInCode('''
const int x = 'foo';
''', [
- error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 10, 1),
+ error(CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 14, 5),
error(StaticTypeWarningCode.INVALID_ASSIGNMENT, 14, 5),
]);
}
diff --git a/pkg/analyzer/test/generated/compile_time_error_code.dart b/pkg/analyzer/test/generated/compile_time_error_code.dart
index 0f460595..08915b1 100644
--- a/pkg/analyzer/test/generated/compile_time_error_code.dart
+++ b/pkg/analyzer/test/generated/compile_time_error_code.dart
@@ -878,7 +878,7 @@
}
f() { return const T(0, 1, c: 2, d: 3); }
''', [
- error(CompileTimeErrorCode.CONST_WITH_NON_CONST, 46, 25),
+ error(CompileTimeErrorCode.CONST_WITH_NON_CONST, 46, 5),
]);
}
@@ -1497,7 +1497,7 @@
test_fromEnvironment_bool_badDefault_whenDefined() async {
// The type of the defaultValue needs to be correct even when the default
// value isn't used (because the variable is defined in the environment).
- driver.declaredVariables = new DeclaredVariables.fromMap({'x': 'true'});
+ driver.declaredVariables = DeclaredVariables.fromMap({'x': 'true'});
await assertErrorsInCode('''
var b = const bool.fromEnvironment('x', defaultValue: 1);
''', [
@@ -4575,7 +4575,7 @@
driver.removeFile(filePath);
await resolveTestFile();
- GatheringErrorListener errorListener = new GatheringErrorListener();
+ GatheringErrorListener errorListener = GatheringErrorListener();
errorListener.addAll(result.errors);
errorListener.assertErrors([
error(CompileTimeErrorCode.URI_DOES_NOT_EXIST, 7, 13),
@@ -4596,7 +4596,7 @@
// TODO(brianwilkerson) The error does not go away, possibly because the
// file is not being reanalyzed.
await resolveTestFile();
- GatheringErrorListener errorListener = new GatheringErrorListener();
+ GatheringErrorListener errorListener = GatheringErrorListener();
errorListener.addAll(result.errors);
errorListener.assertErrors([
error(HintCode.UNUSED_IMPORT, 0, 0),
diff --git a/pkg/analyzer/test/generated/constant_test.dart b/pkg/analyzer/test/generated/constant_test.dart
index c234d8a..0780d4c 100644
--- a/pkg/analyzer/test/generated/constant_test.dart
+++ b/pkg/analyzer/test/generated/constant_test.dart
@@ -481,7 +481,7 @@
}
Future<EvaluationResult> _getExpressionValue(String expressionCode,
- {String context: ''}) async {
+ {String context = ''}) async {
await resolveTestCode('''
var x = $expressionCode;
diff --git a/pkg/analyzer/test/generated/element_resolver_test.dart b/pkg/analyzer/test/generated/element_resolver_test.dart
index c28ee46..b727ffe 100644
--- a/pkg/analyzer/test/generated/element_resolver_test.dart
+++ b/pkg/analyzer/test/generated/element_resolver_test.dart
@@ -14,7 +14,6 @@
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/generated/element_resolver.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
@@ -374,7 +373,7 @@
}
void setUp() {
- _listener = new GatheringErrorListener();
+ _listener = GatheringErrorListener();
_createResolver();
}
@@ -496,8 +495,7 @@
// break loop;
// }
String label = "loop";
- LabelElementImpl labelElement =
- new LabelElementImpl(label, -1, false, false);
+ LabelElementImpl labelElement = LabelElementImpl(label, -1, false, false);
BreakStatement breakStatement = AstTestFactory.breakStatement2(label);
Expression condition = AstTestFactory.booleanLiteral(true);
WhileStatement whileStatement =
@@ -524,7 +522,7 @@
ElementFactory.setterElement(propName, false, _typeProvider.intType);
classA.accessors = <PropertyAccessorElement>[getter, setter];
// set name scope
- _visitor.nameScope = new EnclosedScope(null)
+ _visitor.nameScope = EnclosedScope(null)
..defineNameWithoutChecking('A', classA);
// prepare "A.p"
PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'p');
@@ -544,7 +542,7 @@
ElementFactory.methodElement("m", _typeProvider.intType);
classA.methods = <MethodElement>[method];
// set name scope
- _visitor.nameScope = new EnclosedScope(null)
+ _visitor.nameScope = EnclosedScope(null)
..defineNameWithoutChecking('A', classA);
// prepare "A.m"
PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'm');
@@ -564,7 +562,7 @@
ElementFactory.methodElement("==", _typeProvider.boolType);
classA.methods = <MethodElement>[method];
// set name scope
- _visitor.nameScope = new EnclosedScope(null)
+ _visitor.nameScope = EnclosedScope(null)
..defineNameWithoutChecking('A', classA);
// prepare "A.=="
PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', '==');
@@ -610,8 +608,7 @@
// continue loop;
// }
String label = "loop";
- LabelElementImpl labelElement =
- new LabelElementImpl(label, -1, false, false);
+ LabelElementImpl labelElement = LabelElementImpl(label, -1, false, false);
ContinueStatement continueStatement =
AstTestFactory.continueStatement(label);
Expression condition = AstTestFactory.booleanLiteral(true);
@@ -640,7 +637,7 @@
AstTestFactory.annotation(AstTestFactory.identifier3('a'));
annotationNode.element = ElementFactory.classElement2('A');
annotationNode.elementAnnotation =
- new ElementAnnotationImpl(compilationUnitElement);
+ ElementAnnotationImpl(compilationUnitElement);
enumNode.metadata.add(annotationNode);
enumNode.name.staticElement = enumElement;
List<ElementAnnotation> metadata = <ElementAnnotation>[
@@ -1119,24 +1116,24 @@
* Create and return the resolver used by the tests.
*/
void _createResolver() {
- AnalysisContext context = TestAnalysisContext();
- _typeProvider = context.typeProvider;
+ var context = TestAnalysisContext();
+ _typeProvider = context.typeProviderLegacy;
- Source source = new FileSource(getFile("/test.dart"));
- CompilationUnitElementImpl unit = new CompilationUnitElementImpl();
+ Source source = FileSource(getFile("/test.dart"));
+ CompilationUnitElementImpl unit = CompilationUnitElementImpl();
unit.librarySource = unit.source = source;
_definingLibrary =
ElementFactory.library(context, "test", isNonNullableByDefault: false);
_definingLibrary.definingCompilationUnit = unit;
- _definingLibrary.typeProvider = context.typeProvider;
- _definingLibrary.typeSystem = context.typeSystem;
- var inheritance = new InheritanceManager3();
+ _definingLibrary.typeProvider = context.typeProviderLegacy;
+ _definingLibrary.typeSystem = context.typeSystemLegacy;
+ var inheritance = InheritanceManager3();
- _visitor = new ResolverVisitor(
+ _visitor = ResolverVisitor(
inheritance, _definingLibrary, source, _typeProvider, _listener,
featureSet: FeatureSet.forTesting(),
- nameScope: new LibraryScope(_definingLibrary));
+ nameScope: LibraryScope(_definingLibrary));
_resolver = _visitor.elementResolver;
}
@@ -1200,8 +1197,8 @@
Scope outerScope = _visitor.nameScope;
try {
_visitor.enclosingClass = enclosingClass;
- EnclosedScope innerScope = new ClassScope(
- new TypeParameterScope(outerScope, enclosingClass), enclosingClass);
+ EnclosedScope innerScope = ClassScope(
+ TypeParameterScope(outerScope, enclosingClass), enclosingClass);
_visitor.nameScope = innerScope;
node.accept(_resolver);
} finally {
@@ -1237,7 +1234,7 @@
void _resolveNode(AstNode node, [List<Element> definedElements]) {
Scope outerScope = _visitor.nameScope;
try {
- EnclosedScope innerScope = new EnclosedScope(outerScope);
+ EnclosedScope innerScope = EnclosedScope(outerScope);
if (definedElements != null) {
for (Element element in definedElements) {
innerScope.define(element);
@@ -1266,7 +1263,7 @@
if (labelElement == null) {
innerScope = outerScope;
} else {
- innerScope = new LabelScope(
+ innerScope = LabelScope(
outerScope, labelElement.name, labelTarget, labelElement);
}
_visitor.labelScope = innerScope;
diff --git a/pkg/analyzer/test/generated/elements_types_mixin.dart b/pkg/analyzer/test/generated/elements_types_mixin.dart
index 08de4eb..85eeee8 100644
--- a/pkg/analyzer/test/generated/elements_types_mixin.dart
+++ b/pkg/analyzer/test/generated/elements_types_mixin.dart
@@ -69,17 +69,17 @@
NeverTypeImpl get neverStar => NeverTypeImpl.instanceLegacy;
- InterfaceType get nullNone {
+ InterfaceTypeImpl get nullNone {
var element = typeProvider.nullType.element;
return interfaceTypeNone(element);
}
- InterfaceType get nullQuestion {
+ InterfaceTypeImpl get nullQuestion {
var element = typeProvider.nullType.element;
return interfaceTypeQuestion(element);
}
- InterfaceType get nullStar {
+ InterfaceTypeImpl get nullStar {
var element = typeProvider.nullType.element;
return interfaceTypeStar(element);
}
@@ -131,7 +131,7 @@
TypeProvider get typeProvider;
- VoidType get voidNone => typeProvider.voidType;
+ VoidTypeImpl get voidNone => VoidTypeImpl.instance;
ClassElementImpl class_({
@required String name,
diff --git a/pkg/analyzer/test/generated/engine_test.dart b/pkg/analyzer/test/generated/engine_test.dart
index c183ac8..71a877f 100644
--- a/pkg/analyzer/test/generated/engine_test.dart
+++ b/pkg/analyzer/test/generated/engine_test.dart
@@ -16,8 +16,8 @@
class AnalysisOptionsImplTest {
test_resetToDefaults() {
// Note that this only tests options visible from the interface.
- AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
- AnalysisOptionsImpl modifiedOptions = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl defaultOptions = AnalysisOptionsImpl();
+ AnalysisOptionsImpl modifiedOptions = AnalysisOptionsImpl();
modifiedOptions.dart2jsHint = true;
modifiedOptions.disableCacheFlushing = true;
modifiedOptions.enabledPluginNames = ['somePackage'];
diff --git a/pkg/analyzer/test/generated/invalid_code_test.dart b/pkg/analyzer/test/generated/invalid_code_test.dart
index c3f499c..00b7b2b 100644
--- a/pkg/analyzer/test/generated/invalid_code_test.dart
+++ b/pkg/analyzer/test/generated/invalid_code_test.dart
@@ -282,7 +282,7 @@
class InvalidCodeWithExtensionMethodsTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_extensionOverrideInAnnotationContext() async {
diff --git a/pkg/analyzer/test/generated/java_io_test.dart b/pkg/analyzer/test/generated/java_io_test.dart
index 54a93ca..561b53a 100644
--- a/pkg/analyzer/test/generated/java_io_test.dart
+++ b/pkg/analyzer/test/generated/java_io_test.dart
@@ -16,7 +16,7 @@
expect(path.context.isAbsolute(absolutePath), isTrue,
reason: '"$absolutePath" is not absolute');
// test that toURI() returns an absolute URI
- Uri uri = new JavaFile(absolutePath).toURI();
+ Uri uri = JavaFile(absolutePath).toURI();
expect(uri.isAbsolute, isTrue);
expect(uri.scheme, 'file');
});
@@ -30,7 +30,7 @@
// it may be not on Windows, if "temp" is on other disk.
String relPath = path.context.relative(absolutePath);
// test that toURI() returns an absolute URI
- Uri uri = new JavaFile(relPath).toURI();
+ Uri uri = JavaFile(relPath).toURI();
expect(uri.isAbsolute, isTrue);
expect(uri.scheme, 'file');
});
diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart
index 729a4a0..0e2eb33 100644
--- a/pkg/analyzer/test/generated/non_error_resolver_test.dart
+++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart
@@ -26,7 +26,7 @@
class NonConstantValueInInitializer extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0',
additionalFeatures: [Feature.constant_update_2018]);
diff --git a/pkg/analyzer/test/generated/non_hint_code_test.dart b/pkg/analyzer/test/generated/non_hint_code_test.dart
index 75f8910..1beaa47 100644
--- a/pkg/analyzer/test/generated/non_hint_code_test.dart
+++ b/pkg/analyzer/test/generated/non_hint_code_test.dart
@@ -276,7 +276,7 @@
newFile(path, content: content);
result = await resolveFile(path);
- var errorListener = new GatheringErrorListener();
+ var errorListener = GatheringErrorListener();
errorListener.addAll(result.errors);
errorListener.assertErrors(expectedErrors);
}
diff --git a/pkg/analyzer/test/generated/parser_fasta_test.dart b/pkg/analyzer/test/generated/parser_fasta_test.dart
index 695844b..b76ad9c 100644
--- a/pkg/analyzer/test/generated/parser_fasta_test.dart
+++ b/pkg/analyzer/test/generated/parser_fasta_test.dart
@@ -1911,7 +1911,7 @@
@override
set enableUriInPartOf(bool value) {
if (value == false) {
- throw new UnimplementedError(
+ throw UnimplementedError(
'URIs in "part of" declarations cannot be disabled in Fasta.');
}
}
@@ -1958,15 +1958,14 @@
: ScannerConfiguration.classic,
includeComments: true);
_fastaTokens = result.tokens;
- _parserProxy = new ParserProxy(_fastaTokens, featureSet,
+ _parserProxy = ParserProxy(_fastaTokens, featureSet,
allowNativeClause: allowNativeClause,
expectedEndOffset: expectedEndOffset);
}
@override
ExpectedError expectedError(ErrorCode code, int offset, int length) =>
- new ExpectedError(
- _toFastaGeneratedAnalyzerErrorCode(code), offset, length);
+ ExpectedError(_toFastaGeneratedAnalyzerErrorCode(code), offset, length);
@override
void expectNotNullIfNoErrors(Object result) {
@@ -1992,7 +1991,7 @@
@override
Expression parseAssignableSelector(String code, bool optional,
- {bool allowConditional: true}) {
+ {bool allowConditional = true}) {
if (optional) {
if (code.isEmpty) {
return _parseExpression('foo');
@@ -2050,8 +2049,7 @@
{List<ErrorCode> codes,
List<ExpectedError> errors,
FeatureSet featureSet}) {
- GatheringErrorListener listener =
- new GatheringErrorListener(checkRanges: true);
+ GatheringErrorListener listener = GatheringErrorListener(checkRanges: true);
CompilationUnit unit =
parseCompilationUnit2(content, listener, featureSet: featureSet);
@@ -2072,7 +2070,7 @@
String content, GatheringErrorListener listener,
{FeatureSet featureSet}) {
featureSet ??= FeatureSet.forTesting();
- var source = new StringSource(content, 'parser_test_StringSource.dart');
+ var source = StringSource(content, 'parser_test_StringSource.dart');
// Adjust the feature set based on language version comment.
void languageVersionChanged(
@@ -2090,10 +2088,10 @@
_fastaTokens = result.tokens;
// Run parser
- ErrorReporter errorReporter = new ErrorReporter(listener, source);
- fasta.Parser parser = new fasta.Parser(null);
+ ErrorReporter errorReporter = ErrorReporter(listener, source);
+ fasta.Parser parser = fasta.Parser(null);
AstBuilder astBuilder =
- new AstBuilder(errorReporter, source.uri, true, featureSet);
+ AstBuilder(errorReporter, source.uri, true, featureSet);
parser.listener = astBuilder;
astBuilder.parser = parser;
astBuilder.allowNativeClause = allowNativeClause;
@@ -2173,7 +2171,7 @@
@override
FormalParameter parseFormalParameter(String code, ParameterKind kind,
- {List<ErrorCode> errorCodes: const <ErrorCode>[]}) {
+ {List<ErrorCode> errorCodes = const <ErrorCode>[]}) {
String parametersCode;
if (kind == ParameterKind.REQUIRED) {
parametersCode = '($code)';
@@ -2191,8 +2189,8 @@
@override
FormalParameterList parseFormalParameterList(String code,
- {bool inFunctionType: false,
- List<ErrorCode> errorCodes: const <ErrorCode>[],
+ {bool inFunctionType = false,
+ List<ErrorCode> errorCodes = const <ErrorCode>[],
List<ExpectedError> errors}) {
createParser(code);
FormalParameterList result =
@@ -2284,8 +2282,8 @@
@override
NormalFormalParameter parseNormalFormalParameter(String code,
- {bool inFunctionType: false,
- List<ErrorCode> errorCodes: const <ErrorCode>[]}) {
+ {bool inFunctionType = false,
+ List<ErrorCode> errorCodes = const <ErrorCode>[]}) {
FormalParameterList list = parseFormalParameterList('($code)',
inFunctionType: inFunctionType, errorCodes: errorCodes);
return list.parameters.single;
@@ -2390,8 +2388,9 @@
code == ParserErrorCode.FINAL_CLASS ||
code == ParserErrorCode.FINAL_ENUM ||
code == ParserErrorCode.FINAL_TYPEDEF ||
- code == ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION)
+ code == ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION) {
return ParserErrorCode.EXTRANEOUS_MODIFIER;
+ }
return code;
}
@@ -3242,11 +3241,11 @@
* Fasta token.
*/
factory ParserProxy(analyzer.Token firstToken, FeatureSet featureSet,
- {bool allowNativeClause: false, int expectedEndOffset}) {
- TestSource source = new TestSource();
- var errorListener = new GatheringErrorListener(checkRanges: true);
- var errorReporter = new ErrorReporter(errorListener, source);
- return new ParserProxy._(
+ {bool allowNativeClause = false, int expectedEndOffset}) {
+ TestSource source = TestSource();
+ var errorListener = GatheringErrorListener(checkRanges: true);
+ var errorReporter = ErrorReporter(errorListener, source);
+ return ParserProxy._(
firstToken, errorReporter, null, errorListener, featureSet,
allowNativeClause: allowNativeClause,
expectedEndOffset: expectedEndOffset);
@@ -3254,10 +3253,10 @@
ParserProxy._(analyzer.Token firstToken, ErrorReporter errorReporter,
Uri fileUri, this._errorListener, FeatureSet featureSet,
- {bool allowNativeClause: false, this.expectedEndOffset})
+ {bool allowNativeClause = false, this.expectedEndOffset})
: super(firstToken, errorReporter, fileUri, featureSet,
allowNativeClause: allowNativeClause) {
- _eventListener = new ForwardingTestListener(astBuilder);
+ _eventListener = ForwardingTestListener(astBuilder);
fastaParser.listener = _eventListener;
}
@@ -3328,7 +3327,7 @@
}
@override
- FormalParameterList parseFormalParameterList({bool inFunctionType: false}) {
+ FormalParameterList parseFormalParameterList({bool inFunctionType = false}) {
return _run('unspecified',
() => super.parseFormalParameterList(inFunctionType: inFunctionType));
}
@@ -4061,7 +4060,7 @@
ParserErrorCode.NATIVE_CLAUSE_SHOULD_BE_ANNOTATION,
]);
}
- expect(member, new TypeMatcher<ClassDeclaration>());
+ expect(member, TypeMatcher<ClassDeclaration>());
ClassDeclaration declaration = member;
expect(declaration.nativeClause, isNotNull);
expect(declaration.nativeClause.nativeKeyword, isNotNull);
diff --git a/pkg/analyzer/test/generated/parser_test.dart b/pkg/analyzer/test/generated/parser_test.dart
index 4d04bc4..c0a3c9a 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -56,19 +56,19 @@
abstract class AbstractParserTestCase implements ParserTestHelpers {
bool get allowNativeClause;
- void set allowNativeClause(bool value);
+ set allowNativeClause(bool value);
/**
* Set a flag indicating whether the parser should parse instance creation
* expressions that lack either the `new` or `const` keyword.
*/
- void set enableOptionalNewAndConst(bool value);
+ set enableOptionalNewAndConst(bool value);
/**
* Set a flag indicating whether the parser is to parse part-of directives
* that specify a URI rather than a library name.
*/
- void set enableUriInPartOf(bool value);
+ set enableUriInPartOf(bool value);
/**
* The error listener to which scanner and parser errors will be reported.
@@ -122,7 +122,7 @@
Expression parseAssignableExpression(String code, bool primaryAllowed);
Expression parseAssignableSelector(String code, bool optional,
- {bool allowConditional: true});
+ {bool allowConditional = true});
AwaitExpression parseAwaitExpression(String code);
@@ -170,11 +170,11 @@
Expression parseExpressionWithoutCascade(String code);
FormalParameter parseFormalParameter(String code, ParameterKind kind,
- {List<ErrorCode> errorCodes: const <ErrorCode>[]});
+ {List<ErrorCode> errorCodes = const <ErrorCode>[]});
FormalParameterList parseFormalParameterList(String code,
- {bool inFunctionType: false,
- List<ErrorCode> errorCodes: const <ErrorCode>[],
+ {bool inFunctionType = false,
+ List<ErrorCode> errorCodes = const <ErrorCode>[],
List<ExpectedError> errors});
/**
@@ -213,8 +213,8 @@
InstanceCreationExpression parseNewExpression(String code);
NormalFormalParameter parseNormalFormalParameter(String code,
- {bool inFunctionType: false,
- List<ErrorCode> errorCodes: const <ErrorCode>[]});
+ {bool inFunctionType = false,
+ List<ErrorCode> errorCodes = const <ErrorCode>[]});
Expression parsePostfixExpression(String code);
@@ -254,7 +254,7 @@
/**
* A list containing the errors found while traversing the AST structure.
*/
- List<String> _errors = new List<String>();
+ List<String> _errors = List<String>();
/**
* Assert that no errors were found while traversing any of the AST structures that have been
@@ -262,7 +262,7 @@
*/
void assertValid() {
if (_errors.isNotEmpty) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write("Invalid AST structure:");
for (String message in _errors) {
buffer.write("\r\n ");
@@ -2070,11 +2070,11 @@
parseStatement('x is String<S> ? (x + y) : z;');
ConditionalExpression expression = statement.expression;
Expression condition = expression.condition;
- expect(condition, new TypeMatcher<IsExpression>());
+ expect(condition, TypeMatcher<IsExpression>());
Expression thenExpression = expression.thenExpression;
- expect(thenExpression, new TypeMatcher<ParenthesizedExpression>());
+ expect(thenExpression, TypeMatcher<ParenthesizedExpression>());
Expression elseExpression = expression.elseExpression;
- expect(elseExpression, new TypeMatcher<SimpleIdentifier>());
+ expect(elseExpression, TypeMatcher<SimpleIdentifier>());
}
void test_conditionalExpression_precedence_nullableTypeWithTypeArg1GFT_is() {
@@ -2082,11 +2082,11 @@
parseStatement('x is String<S> Function() ? (x + y) : z;');
ConditionalExpression expression = statement.expression;
Expression condition = expression.condition;
- expect(condition, new TypeMatcher<IsExpression>());
+ expect(condition, TypeMatcher<IsExpression>());
Expression thenExpression = expression.thenExpression;
- expect(thenExpression, new TypeMatcher<ParenthesizedExpression>());
+ expect(thenExpression, TypeMatcher<ParenthesizedExpression>());
Expression elseExpression = expression.elseExpression;
- expect(elseExpression, new TypeMatcher<SimpleIdentifier>());
+ expect(elseExpression, TypeMatcher<SimpleIdentifier>());
}
void test_conditionalExpression_precedence_nullableTypeWithTypeArg2_is() {
@@ -2094,11 +2094,11 @@
parseStatement('x is String<S,T> ? (x + y) : z;');
ConditionalExpression expression = statement.expression;
Expression condition = expression.condition;
- expect(condition, new TypeMatcher<IsExpression>());
+ expect(condition, TypeMatcher<IsExpression>());
Expression thenExpression = expression.thenExpression;
- expect(thenExpression, new TypeMatcher<ParenthesizedExpression>());
+ expect(thenExpression, TypeMatcher<ParenthesizedExpression>());
Expression elseExpression = expression.elseExpression;
- expect(elseExpression, new TypeMatcher<SimpleIdentifier>());
+ expect(elseExpression, TypeMatcher<SimpleIdentifier>());
}
void test_conditionalExpression_precedence_prefixedNullableType_is() {
@@ -2106,39 +2106,39 @@
ConditionalExpression expression = statement.expression;
Expression condition = expression.condition;
- expect(condition, new TypeMatcher<IsExpression>());
+ expect(condition, TypeMatcher<IsExpression>());
Expression thenExpression = expression.thenExpression;
- expect(thenExpression, new TypeMatcher<ParenthesizedExpression>());
+ expect(thenExpression, TypeMatcher<ParenthesizedExpression>());
Expression elseExpression = expression.elseExpression;
- expect(elseExpression, new TypeMatcher<SimpleIdentifier>());
+ expect(elseExpression, TypeMatcher<SimpleIdentifier>());
}
void test_conditionalExpression_precedence_withAssignment() {
ExpressionStatement statement = parseStatement('b ? c = true : g();');
ConditionalExpression expression = statement.expression;
- expect(expression.condition, new TypeMatcher<SimpleIdentifier>());
- expect(expression.thenExpression, new TypeMatcher<AssignmentExpression>());
+ expect(expression.condition, TypeMatcher<SimpleIdentifier>());
+ expect(expression.thenExpression, TypeMatcher<AssignmentExpression>());
}
void test_conditionalExpression_precedence_withAssignment2() {
ExpressionStatement statement = parseStatement('b.x ? c = true : g();');
ConditionalExpression expression = statement.expression;
- expect(expression.condition, new TypeMatcher<PrefixedIdentifier>());
- expect(expression.thenExpression, new TypeMatcher<AssignmentExpression>());
+ expect(expression.condition, TypeMatcher<PrefixedIdentifier>());
+ expect(expression.thenExpression, TypeMatcher<AssignmentExpression>());
}
void test_conditionalExpression_prefixedValue() {
ExpressionStatement statement = parseStatement('a.b ? y : z;');
ConditionalExpression expression = statement.expression;
- expect(expression.condition, new TypeMatcher<PrefixedIdentifier>());
- expect(expression.thenExpression, new TypeMatcher<SimpleIdentifier>());
+ expect(expression.condition, TypeMatcher<PrefixedIdentifier>());
+ expect(expression.thenExpression, TypeMatcher<SimpleIdentifier>());
}
void test_conditionalExpression_prefixedValue2() {
ExpressionStatement statement = parseStatement('a.b ? x.y : z;');
ConditionalExpression expression = statement.expression;
- expect(expression.condition, new TypeMatcher<PrefixedIdentifier>());
- expect(expression.thenExpression, new TypeMatcher<PrefixedIdentifier>());
+ expect(expression.condition, TypeMatcher<PrefixedIdentifier>());
+ expect(expression.thenExpression, TypeMatcher<PrefixedIdentifier>());
}
void test_constructor_initializer_withParenthesizedExpression() {
@@ -9470,13 +9470,13 @@
* prepared to parse the tokens scanned from the given [content].
*/
void createParser(String content, {int expectedEndOffset}) {
- Source source = new TestSource();
- listener = new GatheringErrorListener();
+ Source source = TestSource();
+ listener = GatheringErrorListener();
ScannerResult result = scanString(content, includeComments: true);
listener.setLineInfo(source, result.lineStarts);
- parser = new Parser(source, listener, featureSet: FeatureSet.forTesting());
+ parser = Parser(source, listener, featureSet: FeatureSet.forTesting());
parser.allowNativeClause = allowNativeClause;
parser.parseFunctionBodies = parseFunctionBodies;
parser.enableOptionalNewAndConst = enableOptionalNewAndConst;
@@ -9485,7 +9485,7 @@
@override
ExpectedError expectedError(ErrorCode code, int offset, int length) =>
- new ExpectedError(code, offset, length);
+ ExpectedError(code, offset, length);
@override
void expectNotNullIfNoErrors(Object result) {
@@ -9508,7 +9508,7 @@
@override
Expression parseAssignableSelector(String code, bool optional,
- {bool allowConditional: true}) {
+ {bool allowConditional = true}) {
if (usingFastaParser) {
if (optional) {
if (code.isEmpty) {
@@ -9521,8 +9521,8 @@
}
return parser.parseExpression2();
} else {
- Expression prefix = astFactory
- .simpleIdentifier(new StringToken(TokenType.STRING, 'foo', 0));
+ Expression prefix =
+ astFactory.simpleIdentifier(StringToken(TokenType.STRING, 'foo', 0));
createParser(code);
return parser.parseAssignableSelector(prefix, optional,
allowConditional: allowConditional);
@@ -9598,14 +9598,14 @@
*/
CompilationUnit parseCompilationUnit(String content,
{List<ErrorCode> codes, List<ExpectedError> errors}) {
- Source source = new TestSource();
- GatheringErrorListener listener = new GatheringErrorListener();
+ Source source = TestSource();
+ GatheringErrorListener listener = GatheringErrorListener();
ScannerResult result = scanString(content, includeComments: true);
listener.setLineInfo(source, result.lineStarts);
Parser parser =
- new Parser(source, listener, featureSet: FeatureSet.forTesting());
+ Parser(source, listener, featureSet: FeatureSet.forTesting());
parser.enableOptionalNewAndConst = enableOptionalNewAndConst;
CompilationUnit unit = parser.parseCompilationUnit(result.tokens);
expect(unit, isNotNull);
@@ -9630,10 +9630,10 @@
ScannerResult result = scanString(content, includeComments: true);
Parser parser =
- new Parser(source, listener, featureSet: FeatureSet.forTesting());
+ Parser(source, listener, featureSet: FeatureSet.forTesting());
parser.enableOptionalNewAndConst = enableOptionalNewAndConst;
CompilationUnit unit = parser.parseCompilationUnit(result.tokens);
- unit.lineInfo = new LineInfo(result.lineStarts);
+ unit.lineInfo = LineInfo(result.lineStarts);
return unit;
}
@@ -9720,7 +9720,7 @@
@override
FormalParameter parseFormalParameter(String code, ParameterKind kind,
- {List<ErrorCode> errorCodes: const <ErrorCode>[]}) {
+ {List<ErrorCode> errorCodes = const <ErrorCode>[]}) {
if (usingFastaParser) {
String parametersCode;
if (kind == ParameterKind.REQUIRED) {
@@ -9745,8 +9745,8 @@
@override
FormalParameterList parseFormalParameterList(String code,
- {bool inFunctionType: false,
- List<ErrorCode> errorCodes: const <ErrorCode>[],
+ {bool inFunctionType = false,
+ List<ErrorCode> errorCodes = const <ErrorCode>[],
List<ExpectedError> errors}) {
createParser(code);
FormalParameterList list =
@@ -9890,8 +9890,8 @@
@override
NormalFormalParameter parseNormalFormalParameter(String code,
- {bool inFunctionType: false,
- List<ErrorCode> errorCodes: const <ErrorCode>[]}) {
+ {bool inFunctionType = false,
+ List<ErrorCode> errorCodes = const <ErrorCode>[]}) {
if (usingFastaParser) {
FormalParameterList list = parseFormalParameterList('($code)',
inFunctionType: inFunctionType, errorCodes: errorCodes);
@@ -9957,14 +9957,14 @@
* is `true`, then lazy assignment operators should be enabled.
*/
Statement parseStatement(String content, {int expectedEndOffset}) {
- Source source = new TestSource();
- listener = new GatheringErrorListener();
+ Source source = TestSource();
+ listener = GatheringErrorListener();
ScannerResult result = scanString(content, includeComments: true);
listener.setLineInfo(source, result.lineStarts);
Parser parser =
- new Parser(source, listener, featureSet: FeatureSet.forTesting());
+ Parser(source, listener, featureSet: FeatureSet.forTesting());
parser.enableOptionalNewAndConst = enableOptionalNewAndConst;
Statement statement = parser.parseStatement(result.tokens);
expect(statement, isNotNull);
@@ -9984,14 +9984,14 @@
*/
List<Statement> parseStatements(String content, int expectedCount,
[List<ErrorCode> errorCodes = const <ErrorCode>[]]) {
- Source source = new TestSource();
- GatheringErrorListener listener = new GatheringErrorListener();
+ Source source = TestSource();
+ GatheringErrorListener listener = GatheringErrorListener();
ScannerResult result = scanString(content);
listener.setLineInfo(source, result.lineStarts);
Parser parser =
- new Parser(source, listener, featureSet: FeatureSet.forTesting());
+ Parser(source, listener, featureSet: FeatureSet.forTesting());
parser.enableOptionalNewAndConst = enableOptionalNewAndConst;
List<Statement> statements = parser.parseStatements(result.tokens);
expect(statements, hasLength(expectedCount));
@@ -12387,7 +12387,7 @@
void test_Parser() {
expect(
- new Parser(NonExistingSource.unknown, null,
+ Parser(NonExistingSource.unknown, null,
featureSet: FeatureSet.forTesting()),
isNotNull);
}
@@ -13316,7 +13316,7 @@
}
void test_parseCommentReferences_multiLine() {
- DocumentationCommentToken token = new DocumentationCommentToken(
+ DocumentationCommentToken token = DocumentationCommentToken(
TokenType.MULTI_LINE_COMMENT, "/** xxx [a] yyy [bb] zzz */", 3);
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[token];
createParser('');
@@ -13345,7 +13345,7 @@
}
void test_parseCommentReferences_notClosed_noIdentifier() {
- DocumentationCommentToken docToken = new DocumentationCommentToken(
+ DocumentationCommentToken docToken = DocumentationCommentToken(
TokenType.MULTI_LINE_COMMENT, "/** [ some text", 5);
createParser('');
List<CommentReference> references =
@@ -13366,7 +13366,7 @@
}
void test_parseCommentReferences_notClosed_withIdentifier() {
- DocumentationCommentToken docToken = new DocumentationCommentToken(
+ DocumentationCommentToken docToken = DocumentationCommentToken(
TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text", 5);
createParser('');
List<CommentReference> references =
@@ -13389,10 +13389,9 @@
void test_parseCommentReferences_singleLine() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(
+ DocumentationCommentToken(
TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz", 3),
- new DocumentationCommentToken(
- TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28)
+ DocumentationCommentToken(TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28)
];
createParser('');
List<CommentReference> references = parser.parseCommentReferences(tokens);
@@ -13415,7 +13414,7 @@
void test_parseCommentReferences_skipCodeBlock_4spaces_block() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
+ DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
"/**\n * a[i]\n * non-code line\n */", 3)
];
createParser('');
@@ -13427,9 +13426,9 @@
void test_parseCommentReferences_skipCodeBlock_4spaces_lines() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(
+ DocumentationCommentToken(
TokenType.SINGLE_LINE_COMMENT, "/// Code block:", 0),
- new DocumentationCommentToken(
+ DocumentationCommentToken(
TokenType.SINGLE_LINE_COMMENT, "/// a[i] == b[i]", 0)
];
createParser('');
@@ -13441,7 +13440,7 @@
void test_parseCommentReferences_skipCodeBlock_bracketed() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(
+ DocumentationCommentToken(
TokenType.MULTI_LINE_COMMENT, "/** [:xxx [a] yyy:] [b] zzz */", 3)
];
createParser('');
@@ -13457,7 +13456,7 @@
void test_parseCommentReferences_skipCodeBlock_gitHub() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(
+ DocumentationCommentToken(
TokenType.MULTI_LINE_COMMENT, "/** `a[i]` and [b] */", 0)
];
createParser('');
@@ -13473,7 +13472,7 @@
void test_parseCommentReferences_skipCodeBlock_gitHub_multiLine() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(
+ DocumentationCommentToken(
TokenType.MULTI_LINE_COMMENT,
r'''
/**
@@ -13503,8 +13502,8 @@
''';
List<DocumentationCommentToken> tokens = commentText
.split('\n')
- .map((line) => new DocumentationCommentToken(
- TokenType.SINGLE_LINE_COMMENT, line, 0))
+ .map((line) =>
+ DocumentationCommentToken(TokenType.SINGLE_LINE_COMMENT, line, 0))
.toList();
createParser('');
List<CommentReference> references = parser.parseCommentReferences(tokens);
@@ -13515,7 +13514,7 @@
void test_parseCommentReferences_skipCodeBlock_gitHub_notTerminated() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(
+ DocumentationCommentToken(
TokenType.MULTI_LINE_COMMENT, "/** `a[i] and [b] */", 0)
];
createParser('');
@@ -13527,7 +13526,7 @@
void test_parseCommentReferences_skipCodeBlock_spaces() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
+ DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
"/**\n * a[i]\n * xxx [i] zzz\n */", 3)
];
createParser('');
@@ -13543,7 +13542,7 @@
void test_parseCommentReferences_skipLink_direct_multiLine() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(
+ DocumentationCommentToken(
TokenType.MULTI_LINE_COMMENT,
'''
/**
@@ -13566,7 +13565,7 @@
void test_parseCommentReferences_skipLink_direct_singleLine() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
+ DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
"/** [a](http://www.google.com) [b] zzz */", 3)
];
createParser('');
@@ -13582,7 +13581,7 @@
void test_parseCommentReferences_skipLink_reference_multiLine() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(
+ DocumentationCommentToken(
TokenType.MULTI_LINE_COMMENT,
'''
/**
@@ -13605,7 +13604,7 @@
void test_parseCommentReferences_skipLink_reference_singleLine() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(
+ DocumentationCommentToken(
TokenType.MULTI_LINE_COMMENT, "/** [a][c] [b] zzz */", 3)
];
createParser('');
@@ -13621,7 +13620,7 @@
void test_parseCommentReferences_skipLinkDefinition() {
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
- new DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
+ DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
"/** [a]: http://www.google.com (Google) [b] zzz */", 3)
];
createParser('');
@@ -15945,7 +15944,7 @@
expect(statement.semicolon, isNotNull);
}
- Statement _parseAsyncStatement(String code, {bool isGenerator: false}) {
+ Statement _parseAsyncStatement(String code, {bool isGenerator = false}) {
var star = isGenerator ? '*' : '';
var localFunction = parseStatement('wrapper() async$star { $code }')
as FunctionDeclarationStatement;
@@ -16874,7 +16873,7 @@
CompilationUnitMember member = parseFullCompilationUnitMember();
expect(member, isNotNull);
assertNoErrors();
- expect(member, new TypeMatcher<FunctionTypeAlias>());
+ expect(member, TypeMatcher<FunctionTypeAlias>());
FunctionTypeAlias typeAlias = member;
expect(typeAlias.name.name, "F");
expect(typeAlias.parameters.parameters, hasLength(0));
@@ -16970,7 +16969,7 @@
Directive directive = parseFullDirective();
expect(directive, isNotNull);
assertNoErrors();
- expect(directive, new TypeMatcher<ExportDirective>());
+ expect(directive, TypeMatcher<ExportDirective>());
ExportDirective exportDirective = directive;
expect(exportDirective.keyword, isNotNull);
expect(exportDirective.uri, isNotNull);
@@ -16989,7 +16988,7 @@
Directive directive = parseFullDirective();
expect(directive, isNotNull);
assertNoErrors();
- expect(directive, new TypeMatcher<ImportDirective>());
+ expect(directive, TypeMatcher<ImportDirective>());
ImportDirective importDirective = directive;
expect(importDirective.keyword, isNotNull);
expect(importDirective.uri, isNotNull);
@@ -17004,7 +17003,7 @@
Directive directive = parseFullDirective();
expect(directive, isNotNull);
assertNoErrors();
- expect(directive, new TypeMatcher<LibraryDirective>());
+ expect(directive, TypeMatcher<LibraryDirective>());
LibraryDirective libraryDirective = directive;
expect(libraryDirective.libraryKeyword, isNotNull);
expect(libraryDirective.name, isNotNull);
@@ -17040,7 +17039,7 @@
Directive directive = parseFullDirective();
expect(directive, isNotNull);
assertNoErrors();
- expect(directive, new TypeMatcher<LibraryDirective>());
+ expect(directive, TypeMatcher<LibraryDirective>());
LibraryDirective libraryDirective = directive;
expect(libraryDirective.libraryKeyword, isNotNull);
expect(libraryDirective.name, isNotNull);
@@ -17055,7 +17054,7 @@
Directive directive = unit.directives[0];
expect(directive, isNotNull);
assertNoErrors();
- expect(directive, new TypeMatcher<LibraryDirective>());
+ expect(directive, TypeMatcher<LibraryDirective>());
LibraryDirective libraryDirective = directive;
expect(libraryDirective.libraryKeyword, isNotNull);
expect(libraryDirective.name, isNotNull);
@@ -17075,7 +17074,7 @@
Directive directive = parseFullDirective();
expect(directive, isNotNull);
assertNoErrors();
- expect(directive, new TypeMatcher<PartDirective>());
+ expect(directive, TypeMatcher<PartDirective>());
PartDirective partDirective = directive;
expect(partDirective.partKeyword, isNotNull);
expect(partDirective.uri, isNotNull);
@@ -17123,7 +17122,7 @@
Directive directive = parseFullDirective();
expect(directive, isNotNull);
assertNoErrors();
- expect(directive, new TypeMatcher<PartOfDirective>());
+ expect(directive, TypeMatcher<PartOfDirective>());
PartOfDirective partOfDirective = directive;
expect(partOfDirective.partKeyword, isNotNull);
expect(partOfDirective.ofKeyword, isNotNull);
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index 7400a44..94af44b 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -38,8 +38,8 @@
@reflectiveTest
class EnclosedScopeTest extends DriverResolutionTest {
test_define_duplicate() async {
- Scope rootScope = new _RootScope();
- EnclosedScope scope = new EnclosedScope(rootScope);
+ Scope rootScope = _RootScope();
+ EnclosedScope scope = EnclosedScope(rootScope);
SimpleIdentifier identifier = AstTestFactory.identifier3('v');
VariableElement element1 = ElementFactory.localVariableElement(identifier);
VariableElement element2 = ElementFactory.localVariableElement(identifier);
@@ -131,22 +131,22 @@
@reflectiveTest
class LibraryImportScopeTest extends ResolverTestCase {
void test_creation_empty() {
- new LibraryImportScope(createDefaultTestLibrary());
+ LibraryImportScope(createDefaultTestLibrary());
}
void test_creation_nonEmpty() {
AnalysisContext context = TestAnalysisContext();
String importedTypeName = "A";
- ClassElement importedType = new ClassElementImpl(importedTypeName, -1);
+ ClassElement importedType = ClassElementImpl(importedTypeName, -1);
LibraryElement importedLibrary = createTestLibrary(context, "imported");
(importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
.types = <ClassElement>[importedType];
LibraryElementImpl definingLibrary =
createTestLibrary(context, "importing");
- ImportElementImpl importElement = new ImportElementImpl(0);
+ ImportElementImpl importElement = ImportElementImpl(0);
importElement.importedLibrary = importedLibrary;
definingLibrary.imports = <ImportElement>[importElement];
- Scope scope = new LibraryImportScope(definingLibrary);
+ Scope scope = LibraryImportScope(definingLibrary);
expect(
scope.lookup(
AstTestFactory.identifier3(importedTypeName), definingLibrary),
@@ -204,7 +204,7 @@
prefixedImport,
nonPrefixedImport
];
- Scope scope = new LibraryImportScope(importingLibrary);
+ Scope scope = LibraryImportScope(importingLibrary);
Element prefixedElement = scope.lookup(
AstTestFactory.identifier5(prefixName, typeName), importingLibrary);
expect(prefixedElement, same(prefixedType));
@@ -217,22 +217,22 @@
@reflectiveTest
class LibraryScopeTest extends ResolverTestCase {
void test_creation_empty() {
- new LibraryScope(createDefaultTestLibrary());
+ LibraryScope(createDefaultTestLibrary());
}
void test_creation_nonEmpty() {
AnalysisContext context = TestAnalysisContext();
String importedTypeName = "A";
- ClassElement importedType = new ClassElementImpl(importedTypeName, -1);
+ ClassElement importedType = ClassElementImpl(importedTypeName, -1);
LibraryElement importedLibrary = createTestLibrary(context, "imported");
(importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)
.types = <ClassElement>[importedType];
LibraryElementImpl definingLibrary =
createTestLibrary(context, "importing");
- ImportElementImpl importElement = new ImportElementImpl(0);
+ ImportElementImpl importElement = ImportElementImpl(0);
importElement.importedLibrary = importedLibrary;
definingLibrary.imports = <ImportElement>[importElement];
- Scope scope = new LibraryScope(definingLibrary);
+ Scope scope = LibraryScope(definingLibrary);
expect(
scope.lookup(
AstTestFactory.identifier3(importedTypeName), definingLibrary),
@@ -248,7 +248,7 @@
compilationUnit.extensions = <ExtensionElement>[extension];
String libraryName = 'lib';
- LibraryElementImpl library = new LibraryElementImpl(
+ LibraryElementImpl library = LibraryElementImpl(
null, null, libraryName, 0, libraryName.length, false);
library.definingCompilationUnit = compilationUnit;
@@ -413,24 +413,24 @@
class PrefixedNamespaceTest extends DriverResolutionTest {
void test_lookup_missing() {
ClassElement element = ElementFactory.classElement2('A');
- PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element]));
+ PrefixedNamespace namespace = PrefixedNamespace('p', _toMap([element]));
expect(namespace.get('p.B'), isNull);
}
void test_lookup_missing_matchesPrefix() {
ClassElement element = ElementFactory.classElement2('A');
- PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element]));
+ PrefixedNamespace namespace = PrefixedNamespace('p', _toMap([element]));
expect(namespace.get('p'), isNull);
}
void test_lookup_valid() {
ClassElement element = ElementFactory.classElement2('A');
- PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element]));
+ PrefixedNamespace namespace = PrefixedNamespace('p', _toMap([element]));
expect(namespace.get('p.A'), same(element));
}
Map<String, Element> _toMap(List<Element> elements) {
- Map<String, Element> map = new HashMap<String, Element>();
+ Map<String, Element> map = HashMap<String, Element>();
for (Element element in elements) {
map[element.name] = element;
}
@@ -441,7 +441,7 @@
@reflectiveTest
class ScopeTest extends DriverResolutionTest {
void test_define_duplicate() {
- Scope scope = new _RootScope();
+ Scope scope = _RootScope();
SimpleIdentifier identifier = AstTestFactory.identifier3('v');
VariableElement element1 = ElementFactory.localVariableElement(identifier);
VariableElement element2 = ElementFactory.localVariableElement(identifier);
@@ -467,12 +467,12 @@
/**
* A list containing all of the AST Expression nodes that were not resolved.
*/
- List<Expression> _unresolvedExpressions = new List<Expression>();
+ List<Expression> _unresolvedExpressions = List<Expression>();
/**
* The TypeAnnotation nodes that were not resolved.
*/
- List<TypeAnnotation> _unresolvedTypes = new List<TypeAnnotation>();
+ List<TypeAnnotation> _unresolvedTypes = List<TypeAnnotation>();
/**
* Counter for the number of Expression nodes visited that are resolved.
@@ -489,7 +489,7 @@
*/
void assertResolved() {
if (_unresolvedExpressions.isNotEmpty || _unresolvedTypes.isNotEmpty) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
int unresolvedTypeCount = _unresolvedTypes.length;
if (unresolvedTypeCount > 0) {
buffer.write("Failed to resolve ");
diff --git a/pkg/analyzer/test/generated/resolver_test_case.dart b/pkg/analyzer/test/generated/resolver_test_case.dart
index d3b2718..d7b0ab5 100644
--- a/pkg/analyzer/test/generated/resolver_test_case.dart
+++ b/pkg/analyzer/test/generated/resolver_test_case.dart
@@ -51,13 +51,13 @@
/**
* A list containing all of the AST nodes that were not resolved.
*/
- List<AstNode> _unresolvedNodes = new List<AstNode>();
+ List<AstNode> _unresolvedNodes = List<AstNode>();
/**
* A list containing all of the AST nodes that were resolved to an element of
* the wrong type.
*/
- List<AstNode> _wrongTypedNodes = new List<AstNode>();
+ List<AstNode> _wrongTypedNodes = List<AstNode>();
/**
* Initialize a newly created verifier to verify that all of the identifiers
@@ -73,7 +73,7 @@
*/
void assertResolved() {
if (_unresolvedNodes.isNotEmpty || _wrongTypedNodes.isNotEmpty) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
if (_unresolvedNodes.isNotEmpty) {
buffer.write("Failed to resolve ");
buffer.write(_unresolvedNodes.length);
@@ -322,8 +322,8 @@
final Map<Source, TestAnalysisResult> analysisResults = {};
- StringBuffer _logBuffer = new StringBuffer();
- FileContentOverlay fileContentOverlay = new FileContentOverlay();
+ StringBuffer _logBuffer = StringBuffer();
+ FileContentOverlay fileContentOverlay = FileContentOverlay();
AnalysisDriver driver;
AnalysisOptions get analysisOptions => driver?.analysisOptions;
@@ -331,7 +331,7 @@
/**
* The default [AnalysisOptions] that should be used by [reset].
*/
- AnalysisOptions get defaultAnalysisOptions => new AnalysisOptionsImpl();
+ AnalysisOptions get defaultAnalysisOptions => AnalysisOptionsImpl();
/**
* Return the list of experiments that are to be enabled for tests in this
@@ -348,8 +348,7 @@
if (analysisResults.isEmpty) {
fail('typeProvider called before computing an analysis result.');
}
- return analysisResults
- .values.first.unit.declaredElement.context.typeProvider;
+ return analysisResults.values.first.typeProvider;
}
/**
@@ -394,7 +393,7 @@
TestAnalysisResult result = analysisResults[source];
expect(result, isNotNull);
- GatheringErrorListener errorListener = new GatheringErrorListener();
+ GatheringErrorListener errorListener = GatheringErrorListener();
for (AnalysisError error in result.errors) {
expect(error.source, source);
ErrorCode errorCode = error.errorCode;
@@ -421,7 +420,7 @@
*/
// TODO(rnystrom): Use this in more tests that have the same structure.
Future<void> assertErrorsInCode(String code, List<ErrorCode> errors,
- {bool verify: true, String sourceName: _defaultSourceName}) async {
+ {bool verify = true, String sourceName = _defaultSourceName}) async {
Source source = addNamedSource(sourceName, code);
await computeAnalysisResult(source);
assertErrors(source, errors);
@@ -467,8 +466,7 @@
Future<TestAnalysisResult> computeAnalysisResult(Source source) async {
TestAnalysisResult analysisResult;
ResolvedUnitResult result = await driver.getResult(source.fullName);
- analysisResult = new TestAnalysisResult(
- source, result.unit, result.errors, result.typeSystem);
+ analysisResult = TestAnalysisResult(source, result.unit, result.errors);
analysisResults[source] = analysisResult;
return analysisResult;
}
@@ -514,25 +512,24 @@
sourcedCompilationUnits = const <CompilationUnitElement>[];
} else {
int count = typeNames.length;
- sourcedCompilationUnits = new List<CompilationUnitElement>(count);
+ sourcedCompilationUnits = List<CompilationUnitElement>(count);
for (int i = 0; i < count; i++) {
String typeName = typeNames[i];
- ClassElementImpl type = new ClassElementImpl(typeName, -1);
+ ClassElementImpl type = ClassElementImpl(typeName, -1);
String fileName = "$typeName.dart";
CompilationUnitElementImpl compilationUnit =
- new CompilationUnitElementImpl();
+ CompilationUnitElementImpl();
compilationUnit.source = createNamedSource(fileName);
compilationUnit.librarySource = definingCompilationUnitSource;
compilationUnit.types = <ClassElement>[type];
sourcedCompilationUnits[i] = compilationUnit;
}
}
- CompilationUnitElementImpl compilationUnit =
- new CompilationUnitElementImpl();
+ CompilationUnitElementImpl compilationUnit = CompilationUnitElementImpl();
compilationUnit.librarySource =
compilationUnit.source = definingCompilationUnitSource;
var featureSet = context.analysisOptions.contextFeatures;
- LibraryElementImpl library = new LibraryElementImpl(
+ LibraryElementImpl library = LibraryElementImpl(
context,
driver?.currentSession,
libraryName,
@@ -583,14 +580,14 @@
if (experiments != null) {
(options as AnalysisOptionsImpl).enabledExperiments = experiments;
}
- DartSdk sdk = new MockSdk(
+ DartSdk sdk = MockSdk(
resourceProvider: resourceProvider,
analysisOptions: options,
);
List<UriResolver> resolvers = <UriResolver>[
- new DartUriResolver(sdk),
- new ResourceUriResolver(resourceProvider)
+ DartUriResolver(sdk),
+ ResourceUriResolver(resourceProvider)
];
if (packages != null) {
var packageMap = <String, List<Folder>>{};
@@ -600,21 +597,14 @@
File file = newFile('/packages/$name/$name.dart', content: content);
packageMap[name] = <Folder>[file.parent];
});
- resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap));
+ resolvers.add(PackageMapUriResolver(resourceProvider, packageMap));
}
- SourceFactory sourceFactory = new SourceFactory(resolvers);
+ SourceFactory sourceFactory = SourceFactory(resolvers);
- PerformanceLog log = new PerformanceLog(_logBuffer);
- AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log);
- driver = new AnalysisDriver(
- scheduler,
- log,
- resourceProvider,
- new MemoryByteStore(),
- fileContentOverlay,
- null,
- sourceFactory,
- options);
+ PerformanceLog log = PerformanceLog(_logBuffer);
+ AnalysisDriverScheduler scheduler = AnalysisDriverScheduler(log);
+ driver = AnalysisDriver(scheduler, log, resourceProvider, MemoryByteStore(),
+ fileContentOverlay, null, sourceFactory, options);
scheduler.start();
}
@@ -645,7 +635,7 @@
List<ErrorCode> codesWithoutExperimental,
List<ErrorCode> codesWithExperimental) async {
// Setup analysis context as non-experimental
- AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl options = AnalysisOptionsImpl();
// options.enableDeferredLoading = false;
resetWith(options: options);
// Analysis and assertions
@@ -683,7 +673,7 @@
* the given [sources] have been resolved.
*/
void verify(List<Source> sources) {
- ResolutionVerifier verifier = new ResolutionVerifier();
+ ResolutionVerifier verifier = ResolutionVerifier();
for (Source source in sources) {
TestAnalysisResult result = analysisResults[source];
expect(result, isNotNull);
@@ -717,10 +707,10 @@
* output.
*/
FunctionTypeImpl expectFunctionType(String name, String type,
- {String elementTypeParams: '[]',
- String typeParams: '[]',
- String typeArgs: '[]',
- String typeFormals: '[]',
+ {String elementTypeParams = '[]',
+ String typeParams = '[]',
+ String typeArgs = '[]',
+ String typeFormals = '[]',
String identifierType}) {
identifierType ??= type;
@@ -814,7 +804,12 @@
final Source source;
final CompilationUnit unit;
final List<AnalysisError> errors;
- final TypeSystemImpl typeSystem;
- TestAnalysisResult(this.source, this.unit, this.errors, this.typeSystem);
+ TestAnalysisResult(this.source, this.unit, this.errors);
+
+ LibraryElement get libraryElement => unit.declaredElement.library;
+
+ TypeProvider get typeProvider => libraryElement.typeProvider;
+
+ TypeSystem get typeSystem => libraryElement.typeSystem;
}
diff --git a/pkg/analyzer/test/generated/scanner_test.dart b/pkg/analyzer/test/generated/scanner_test.dart
index 1a32f9c..bec2ac5 100644
--- a/pkg/analyzer/test/generated/scanner_test.dart
+++ b/pkg/analyzer/test/generated/scanner_test.dart
@@ -23,8 +23,8 @@
class CharacterRangeReaderTest {
void test_advance() {
- CharSequenceReader baseReader = new CharSequenceReader("xyzzy");
- CharacterRangeReader reader = new CharacterRangeReader(baseReader, 1, 4);
+ CharSequenceReader baseReader = CharSequenceReader("xyzzy");
+ CharacterRangeReader reader = CharacterRangeReader(baseReader, 1, 4);
expect(reader.advance(), 0x79);
expect(reader.advance(), 0x80);
expect(reader.advance(), 0x80);
@@ -33,14 +33,14 @@
}
void test_creation() {
- CharSequenceReader baseReader = new CharSequenceReader("xyzzy");
- CharacterRangeReader reader = new CharacterRangeReader(baseReader, 1, 4);
+ CharSequenceReader baseReader = CharSequenceReader("xyzzy");
+ CharacterRangeReader reader = CharacterRangeReader(baseReader, 1, 4);
expect(reader, isNotNull);
}
void test_getOffset() {
- CharSequenceReader baseReader = new CharSequenceReader("xyzzy");
- CharacterRangeReader reader = new CharacterRangeReader(baseReader, 1, 2);
+ CharSequenceReader baseReader = CharSequenceReader("xyzzy");
+ CharacterRangeReader reader = CharacterRangeReader(baseReader, 1, 2);
expect(reader.offset, 1);
reader.advance();
expect(reader.offset, 2);
@@ -49,16 +49,16 @@
}
void test_getString() {
- CharSequenceReader baseReader = new CharSequenceReader("__xyzzy__");
- CharacterRangeReader reader = new CharacterRangeReader(baseReader, 2, 7);
+ CharSequenceReader baseReader = CharSequenceReader("__xyzzy__");
+ CharacterRangeReader reader = CharacterRangeReader(baseReader, 2, 7);
reader.offset = 5;
expect(reader.getString(3, 0), "yzz");
expect(reader.getString(4, 1), "zzy");
}
void test_peek() {
- CharSequenceReader baseReader = new CharSequenceReader("xyzzy");
- CharacterRangeReader reader = new CharacterRangeReader(baseReader, 1, 3);
+ CharSequenceReader baseReader = CharSequenceReader("xyzzy");
+ CharacterRangeReader reader = CharacterRangeReader(baseReader, 1, 3);
expect(reader.peek(), 0x79);
expect(reader.peek(), 0x79);
reader.advance();
@@ -70,8 +70,8 @@
}
void test_setOffset() {
- CharSequenceReader baseReader = new CharSequenceReader("xyzzy");
- CharacterRangeReader reader = new CharacterRangeReader(baseReader, 1, 4);
+ CharSequenceReader baseReader = CharSequenceReader("xyzzy");
+ CharacterRangeReader reader = CharacterRangeReader(baseReader, 1, 4);
reader.offset = 2;
expect(reader.offset, 2);
}
@@ -84,27 +84,27 @@
void test_lineInfo_multilineComment() {
String source = "/*\r\n *\r\n */";
_assertLineInfo(source, [
- new ScannerTest_ExpectedLocation(0, 1, 1),
- new ScannerTest_ExpectedLocation(5, 2, 2),
- new ScannerTest_ExpectedLocation(source.length - 1, 3, 3)
+ ScannerTest_ExpectedLocation(0, 1, 1),
+ ScannerTest_ExpectedLocation(5, 2, 2),
+ ScannerTest_ExpectedLocation(source.length - 1, 3, 3)
]);
}
void test_lineInfo_multilineString() {
String source = "'''a\r\nbc\r\nd'''";
_assertLineInfo(source, [
- new ScannerTest_ExpectedLocation(0, 1, 1),
- new ScannerTest_ExpectedLocation(7, 2, 2),
- new ScannerTest_ExpectedLocation(source.length - 1, 3, 4)
+ ScannerTest_ExpectedLocation(0, 1, 1),
+ ScannerTest_ExpectedLocation(7, 2, 2),
+ ScannerTest_ExpectedLocation(source.length - 1, 3, 4)
]);
}
void test_lineInfo_multilineString_raw() {
String source = "var a = r'''\nblah\n''';\n\nfoo";
_assertLineInfo(source, [
- new ScannerTest_ExpectedLocation(0, 1, 1),
- new ScannerTest_ExpectedLocation(14, 2, 2),
- new ScannerTest_ExpectedLocation(source.length - 2, 5, 2)
+ ScannerTest_ExpectedLocation(0, 1, 1),
+ ScannerTest_ExpectedLocation(14, 2, 2),
+ ScannerTest_ExpectedLocation(source.length - 2, 5, 2)
]);
}
@@ -112,26 +112,25 @@
String source =
"class Test {\r\n String s = '...';\r\n int get x => s.MISSING_GETTER;\r\n}";
_assertLineInfo(source, [
- new ScannerTest_ExpectedLocation(0, 1, 1),
- new ScannerTest_ExpectedLocation(source.indexOf("MISSING_GETTER"), 3, 20),
- new ScannerTest_ExpectedLocation(source.length - 1, 4, 1)
+ ScannerTest_ExpectedLocation(0, 1, 1),
+ ScannerTest_ExpectedLocation(source.indexOf("MISSING_GETTER"), 3, 20),
+ ScannerTest_ExpectedLocation(source.length - 1, 4, 1)
]);
}
void test_lineInfo_slashN() {
String source = "class Test {\n}";
_assertLineInfo(source, [
- new ScannerTest_ExpectedLocation(0, 1, 1),
- new ScannerTest_ExpectedLocation(source.indexOf("}"), 2, 1)
+ ScannerTest_ExpectedLocation(0, 1, 1),
+ ScannerTest_ExpectedLocation(source.indexOf("}"), 2, 1)
]);
}
void test_linestarts() {
String source = "var\r\ni\n=\n1;\n";
- GatheringErrorListener listener = new GatheringErrorListener();
- Scanner scanner =
- new Scanner(null, new CharSequenceReader(source), listener)
- ..configureFeatures(featureSet);
+ GatheringErrorListener listener = GatheringErrorListener();
+ Scanner scanner = Scanner(null, CharSequenceReader(source), listener)
+ ..configureFeatures(featureSet);
var token = scanner.tokenize();
expect(token.lexeme, 'var');
var lineStarts = scanner.lineStarts;
@@ -143,10 +142,9 @@
// to the correct analyzer error code.
// See https://github.com/dart-lang/sdk/issues/30320
String source = '<!-- @Component(';
- GatheringErrorListener listener = new GatheringErrorListener();
- Scanner scanner =
- new Scanner(null, new CharSequenceReader(source), listener)
- ..configureFeatures(featureSet);
+ GatheringErrorListener listener = GatheringErrorListener();
+ Scanner scanner = Scanner(null, CharSequenceReader(source), listener)
+ ..configureFeatures(featureSet);
Token token = scanner.tokenize(reportScannerErrors: false);
expect(token, TypeMatcher<UnmatchedToken>());
token = token.next;
@@ -157,10 +155,10 @@
void _assertLineInfo(
String source, List<ScannerTest_ExpectedLocation> expectedLocations) {
- GatheringErrorListener listener = new GatheringErrorListener();
+ GatheringErrorListener listener = GatheringErrorListener();
_scanWithListener(source, listener);
listener.assertNoErrors();
- LineInfo info = listener.getLineInfo(new TestSource());
+ LineInfo info = listener.getLineInfo(TestSource());
expect(info, isNotNull);
int count = expectedLocations.length;
for (int i = 0; i < count; i++) {
@@ -177,11 +175,10 @@
String source,
GatheringErrorListener listener,
) {
- Scanner scanner =
- new Scanner(null, new CharSequenceReader(source), listener)
- ..configureFeatures(featureSet);
+ Scanner scanner = Scanner(null, CharSequenceReader(source), listener)
+ ..configureFeatures(featureSet);
Token result = scanner.tokenize();
- listener.setLineInfo(new TestSource(), scanner.lineStarts);
+ listener.setLineInfo(TestSource(), scanner.lineStarts);
return result;
}
}
@@ -211,7 +208,7 @@
* correct.
*/
void validate(Token token) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
_validateStream(buffer, token);
if (buffer.length > 0) {
fail(buffer.toString());
diff --git a/pkg/analyzer/test/generated/sdk_test.dart b/pkg/analyzer/test/generated/sdk_test.dart
index e62602f..30cbb54 100644
--- a/pkg/analyzer/test/generated/sdk_test.dart
+++ b/pkg/analyzer/test/generated/sdk_test.dart
@@ -19,25 +19,25 @@
@reflectiveTest
class DartSdkManagerTest with ResourceProviderMixin {
void test_anySdk() {
- DartSdkManager manager = new DartSdkManager('/a/b/c', false);
+ DartSdkManager manager = DartSdkManager('/a/b/c', false);
expect(manager.anySdk, isNull);
- AnalysisOptions options = new AnalysisOptionsImpl();
- SdkDescription description = new SdkDescription(<String>['/c/d'], options);
- DartSdk sdk = new MockSdk(resourceProvider: resourceProvider);
+ AnalysisOptions options = AnalysisOptionsImpl();
+ SdkDescription description = SdkDescription(<String>['/c/d'], options);
+ DartSdk sdk = MockSdk(resourceProvider: resourceProvider);
manager.getSdk(description, () => sdk);
expect(manager.anySdk, same(sdk));
}
void test_getSdk_differentDescriptors() {
- DartSdkManager manager = new DartSdkManager('/a/b/c', false);
- AnalysisOptions options = new AnalysisOptionsImpl();
- SdkDescription description1 = new SdkDescription(<String>['/c/d'], options);
- DartSdk sdk1 = new MockSdk(resourceProvider: resourceProvider);
+ DartSdkManager manager = DartSdkManager('/a/b/c', false);
+ AnalysisOptions options = AnalysisOptionsImpl();
+ SdkDescription description1 = SdkDescription(<String>['/c/d'], options);
+ DartSdk sdk1 = MockSdk(resourceProvider: resourceProvider);
DartSdk result1 = manager.getSdk(description1, () => sdk1);
expect(result1, same(sdk1));
- SdkDescription description2 = new SdkDescription(<String>['/e/f'], options);
- DartSdk sdk2 = new MockSdk(resourceProvider: resourceProvider);
+ SdkDescription description2 = SdkDescription(<String>['/e/f'], options);
+ DartSdk sdk2 = MockSdk(resourceProvider: resourceProvider);
DartSdk result2 = manager.getSdk(description2, () => sdk2);
expect(result2, same(sdk2));
@@ -46,10 +46,10 @@
}
void test_getSdk_sameDescriptor() {
- DartSdkManager manager = new DartSdkManager('/a/b/c', false);
- AnalysisOptions options = new AnalysisOptionsImpl();
- SdkDescription description = new SdkDescription(<String>['/c/d'], options);
- DartSdk sdk = new MockSdk(resourceProvider: resourceProvider);
+ DartSdkManager manager = DartSdkManager('/a/b/c', false);
+ AnalysisOptions options = AnalysisOptionsImpl();
+ SdkDescription description = SdkDescription(<String>['/c/d'], options);
+ DartSdk sdk = MockSdk(resourceProvider: resourceProvider);
DartSdk result = manager.getSdk(description, () => sdk);
expect(result, same(sdk));
manager.getSdk(description, _failIfAbsent);
@@ -63,53 +63,53 @@
@reflectiveTest
class SdkDescriptionTest {
void test_equals_differentPaths_nested() {
- AnalysisOptions options = new AnalysisOptionsImpl();
- SdkDescription left = new SdkDescription(<String>['/a/b/c'], options);
- SdkDescription right = new SdkDescription(<String>['/a/b'], options);
+ AnalysisOptions options = AnalysisOptionsImpl();
+ SdkDescription left = SdkDescription(<String>['/a/b/c'], options);
+ SdkDescription right = SdkDescription(<String>['/a/b'], options);
expect(left == right, isFalse);
}
void test_equals_differentPaths_unrelated() {
- AnalysisOptions options = new AnalysisOptionsImpl();
- SdkDescription left = new SdkDescription(<String>['/a/b/c'], options);
- SdkDescription right = new SdkDescription(<String>['/d/e'], options);
+ AnalysisOptions options = AnalysisOptionsImpl();
+ SdkDescription left = SdkDescription(<String>['/a/b/c'], options);
+ SdkDescription right = SdkDescription(<String>['/d/e'], options);
expect(left == right, isFalse);
}
void test_equals_noPaths() {
- AnalysisOptions options = new AnalysisOptionsImpl();
- SdkDescription left = new SdkDescription(<String>[], options);
- SdkDescription right = new SdkDescription(<String>[], options);
+ AnalysisOptions options = AnalysisOptionsImpl();
+ SdkDescription left = SdkDescription(<String>[], options);
+ SdkDescription right = SdkDescription(<String>[], options);
expect(left == right, isTrue);
}
void test_equals_samePaths_differentOptions() {
String path = '/a/b/c';
- AnalysisOptionsImpl leftOptions = new AnalysisOptionsImpl()
+ AnalysisOptionsImpl leftOptions = AnalysisOptionsImpl()
..useFastaParser = false;
- AnalysisOptionsImpl rightOptions = new AnalysisOptionsImpl()
+ AnalysisOptionsImpl rightOptions = AnalysisOptionsImpl()
..useFastaParser = true;
- SdkDescription left = new SdkDescription(<String>[path], leftOptions);
- SdkDescription right = new SdkDescription(<String>[path], rightOptions);
+ SdkDescription left = SdkDescription(<String>[path], leftOptions);
+ SdkDescription right = SdkDescription(<String>[path], rightOptions);
expect(left == right, isFalse);
}
void test_equals_samePaths_sameOptions_multiple() {
String leftPath = '/a/b/c';
String rightPath = '/d/e';
- AnalysisOptions options = new AnalysisOptionsImpl();
+ AnalysisOptions options = AnalysisOptionsImpl();
SdkDescription left =
- new SdkDescription(<String>[leftPath, rightPath], options);
+ SdkDescription(<String>[leftPath, rightPath], options);
SdkDescription right =
- new SdkDescription(<String>[leftPath, rightPath], options);
+ SdkDescription(<String>[leftPath, rightPath], options);
expect(left == right, isTrue);
}
void test_equals_samePaths_sameOptions_single() {
String path = '/a/b/c';
- AnalysisOptions options = new AnalysisOptionsImpl();
- SdkDescription left = new SdkDescription(<String>[path], options);
- SdkDescription right = new SdkDescription(<String>[path], options);
+ AnalysisOptions options = AnalysisOptionsImpl();
+ SdkDescription left = SdkDescription(<String>[path], options);
+ SdkDescription right = SdkDescription(<String>[path], options);
expect(left == right, isTrue);
}
}
diff --git a/pkg/analyzer/test/generated/simple_resolver_test.dart b/pkg/analyzer/test/generated/simple_resolver_test.dart
index 501a1ef..f46a712 100644
--- a/pkg/analyzer/test/generated/simple_resolver_test.dart
+++ b/pkg/analyzer/test/generated/simple_resolver_test.dart
@@ -1293,7 +1293,7 @@
* Verify that all of the identifiers in the [result] have been resolved.
*/
void verifyTestResolved() {
- var verifier = new ResolutionVerifier();
+ var verifier = ResolutionVerifier();
result.unit.accept(verifier);
verifier.assertResolved();
}
diff --git a/pkg/analyzer/test/generated/source_factory_test.dart b/pkg/analyzer/test/generated/source_factory_test.dart
index 41aac7a..3dea86c 100644
--- a/pkg/analyzer/test/generated/source_factory_test.dart
+++ b/pkg/analyzer/test/generated/source_factory_test.dart
@@ -33,26 +33,26 @@
Source createSource({String path, String uri}) =>
//TODO(pquitslund): find some way to pass an actual URI into source creation
- new MemoryResourceProvider()
+ MemoryResourceProvider()
.getFile(path)
.createSource(uri != null ? Uri.parse(uri) : null);
void runPackageMapTests() {
- MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
- final Uri baseUri = new Uri.file('test/base');
+ MemoryResourceProvider resourceProvider = MemoryResourceProvider();
+ final Uri baseUri = Uri.file('test/base');
final List<UriResolver> testResolvers = [
- new ResourceUriResolver(resourceProvider)
+ ResourceUriResolver(resourceProvider)
];
Packages createPackageMap(Uri base, String configFileContents) {
List<int> bytes = utf8.encode(configFileContents);
Map<String, Uri> map = pkgfile.parse(bytes, base);
- return new MapPackages(map);
+ return MapPackages(map);
}
Map<String, List<Folder>> getPackageMap(String config) {
Packages packages = createPackageMap(baseUri, config);
- SourceFactory factory = new SourceFactory(testResolvers, packages);
+ SourceFactory factory = SourceFactory(testResolvers, packages);
return factory.packageMap;
}
@@ -66,11 +66,11 @@
if (customResolver != null) {
resolvers.add(customResolver);
}
- SourceFactory factory = new SourceFactory(resolvers, packages);
+ SourceFactory factory = SourceFactory(resolvers, packages);
expect(AnalysisEngine.instance.instrumentationService,
InstrumentationService.NULL_SERVICE);
- var instrumentor = new TestInstrumentor();
+ var instrumentor = TestInstrumentor();
AnalysisEngine.instance.instrumentationService = instrumentor;
try {
Source source = factory.resolveUri(containingSource, uri);
@@ -89,7 +89,7 @@
if (customResolver != null) {
resolvers.add(customResolver);
}
- SourceFactory factory = new SourceFactory(resolvers, packages);
+ SourceFactory factory = SourceFactory(resolvers, packages);
return factory.restoreUri(source);
}
@@ -120,7 +120,7 @@
expect(uri, isNull);
});
test('Non-package URI', () {
- var testResolver = new CustomUriResolver(uriPath: _p('/test.dart'));
+ var testResolver = CustomUriResolver(uriPath: _p('/test.dart'));
String uri = resolvePackageUri(config: '''
unittest:${_u('/home/somebody/.pub/cache/unittest-0.9.9/lib/')}
''', uri: 'custom:custom.dart', customResolver: testResolver);
@@ -137,7 +137,7 @@
expect(
() => resolvePackageUri(
config: 'foo:<:&%>', uri: 'package:foo/bar.dart'),
- throwsA(new TypeMatcher<FormatException>()));
+ throwsA(TypeMatcher<FormatException>()));
});
test('Valid URI that cannot be further resolved', () {
String uri = resolvePackageUri(
@@ -163,7 +163,7 @@
async:${_u('/home/somebody/.pub/cache/async-1.1.0/lib/')}
quiver:${_u('/home/somebody/.pub/cache/quiver-1.2.1/lib')}
''',
- source: new FileSource(resourceProvider.getFile(_p(
+ source: FileSource(resourceProvider.getFile(_p(
'/home/somebody/.pub/cache/unittest-0.9.9/lib/unittest.dart'))));
expect(uri, isNotNull);
expect(uri.toString(), equals('package:unittest/unittest.dart'));
@@ -205,7 +205,7 @@
@override
Source resolveAbsolute(Uri uri, [Uri actualUri]) {
- return new FileSource(
+ return FileSource(
resourceProvider.getFile(resourceProvider.pathContext.fromUri(uri)),
actualUri);
}
@@ -223,38 +223,38 @@
@reflectiveTest
class SourceFactoryTest with ResourceProviderMixin {
void test_creation() {
- expect(new SourceFactory([]), isNotNull);
+ expect(SourceFactory([]), isNotNull);
}
void test_resolveUri_absolute() {
- UriResolver_absolute resolver = new UriResolver_absolute();
- SourceFactory factory = new SourceFactory([resolver]);
+ UriResolver_absolute resolver = UriResolver_absolute();
+ SourceFactory factory = SourceFactory([resolver]);
factory.resolveUri(null, "dart:core");
expect(resolver.invoked, isTrue);
}
void test_resolveUri_nonAbsolute_absolute() {
SourceFactory factory =
- new SourceFactory([new AbsoluteUriResolver(resourceProvider)]);
+ SourceFactory([AbsoluteUriResolver(resourceProvider)]);
String sourcePath = convertPath('/does/not/exist.dart');
String targetRawPath = '/does/not/matter.dart';
String targetPath = convertPath(targetRawPath);
String targetUri = toUri(targetRawPath).toString();
- Source sourceSource = new FileSource(getFile(sourcePath));
+ Source sourceSource = FileSource(getFile(sourcePath));
Source result = factory.resolveUri(sourceSource, targetUri);
expect(result.fullName, targetPath);
}
void test_resolveUri_nonAbsolute_relative() {
SourceFactory factory =
- new SourceFactory([new AbsoluteUriResolver(resourceProvider)]);
- Source containingSource = new FileSource(getFile('/does/not/have.dart'));
+ SourceFactory([AbsoluteUriResolver(resourceProvider)]);
+ Source containingSource = FileSource(getFile('/does/not/have.dart'));
Source result = factory.resolveUri(containingSource, 'exist.dart');
expect(result.fullName, convertPath('/does/not/exist.dart'));
}
void test_resolveUri_nonAbsolute_relative_package() {
- MemoryResourceProvider provider = new MemoryResourceProvider();
+ MemoryResourceProvider provider = MemoryResourceProvider();
pathos.Context context = provider.pathContext;
String packagePath =
context.joinAll([context.separator, 'path', 'to', 'package']);
@@ -269,10 +269,10 @@
File firstFile = provider.newFile(firstPath, '');
provider.newFile(secondPath, '');
- PackageMapUriResolver resolver = new PackageMapUriResolver(provider, {
+ PackageMapUriResolver resolver = PackageMapUriResolver(provider, {
'package': [libFolder]
});
- SourceFactory factory = new SourceFactory([resolver]);
+ SourceFactory factory = SourceFactory([resolver]);
Source librarySource =
firstFile.createSource(Uri.parse('package:package/dir/first.dart'));
@@ -285,11 +285,11 @@
void test_restoreUri() {
File file1 = getFile("/some/file1.dart");
File file2 = getFile("/some/file2.dart");
- Source source1 = new FileSource(file1);
- Source source2 = new FileSource(file2);
+ Source source1 = FileSource(file1);
+ Source source2 = FileSource(file2);
Uri expected1 = Uri.parse("file:///my_file.dart");
SourceFactory factory =
- new SourceFactory([new UriResolver_restoreUri(source1, expected1)]);
+ SourceFactory([UriResolver_restoreUri(source1, expected1)]);
expect(factory.restoreUri(source1), same(expected1));
expect(factory.restoreUri(source2), same(null));
}
@@ -332,7 +332,7 @@
@override
Source resolveAbsolute(Uri uri, [Uri actualUri]) {
if (uri.toString() == encoding) {
- return new TestSource();
+ return TestSource();
}
return null;
}
diff --git a/pkg/analyzer/test/generated/static_type_analyzer_test.dart b/pkg/analyzer/test/generated/static_type_analyzer_test.dart
index 2c4562d..f8419b8 100644
--- a/pkg/analyzer/test/generated/static_type_analyzer_test.dart
+++ b/pkg/analyzer/test/generated/static_type_analyzer_test.dart
@@ -106,7 +106,7 @@
}
""");
// "foo" should be resolved to the "Foo" type
- expectIdentifierType("foo();", new TypeMatcher<FunctionType>());
+ expectIdentifierType("foo();", TypeMatcher<FunctionType>());
}
test_MethodInvocation_nameType_parameter_FunctionTypeAlias() async {
@@ -117,7 +117,7 @@
}
""");
// "foo" should be resolved to the "Foo" type
- expectIdentifierType("foo();", new TypeMatcher<FunctionType>());
+ expectIdentifierType("foo();", TypeMatcher<FunctionType>());
}
test_MethodInvocation_nameType_parameter_propagatedType() async {
@@ -206,6 +206,11 @@
ResolverVisitor _visitor;
/**
+ * The library containing the code being resolved.
+ */
+ LibraryElementImpl _definingLibrary;
+
+ /**
* The analyzer being used to analyze the test cases.
*/
StaticTypeAnalyzer _analyzer;
@@ -215,12 +220,12 @@
*/
TypeProvider _typeProvider;
- TypeProvider get typeProvider => _typeProvider;
+ TypeProvider get typeProvider => _definingLibrary.typeProvider;
/**
* The type system used to analyze the test cases.
*/
- TypeSystemImpl get _typeSystem => _visitor.typeSystem;
+ TypeSystemImpl get _typeSystem => _definingLibrary.typeSystem;
void fail_visitFunctionExpressionInvocation() {
_fail("Not yet tested");
@@ -238,7 +243,7 @@
}
void setUp() {
- _listener = new GatheringErrorListener();
+ _listener = GatheringErrorListener();
_analyzer = _createAnalyzer();
}
@@ -687,7 +692,7 @@
_analyze5(p1);
_analyze5(p2);
DartType resultType = _analyze(node);
- Map<String, DartType> expectedNamedTypes = new HashMap<String, DartType>();
+ Map<String, DartType> expectedNamedTypes = HashMap<String, DartType>();
expectedNamedTypes["p1"] = dynamicType;
expectedNamedTypes["p2"] = dynamicType;
_assertFunctionType(
@@ -706,7 +711,7 @@
AstTestFactory.expressionFunctionBody(_resolvedInteger(0)));
_analyze5(p);
DartType resultType = _analyze(node);
- Map<String, DartType> expectedNamedTypes = new HashMap<String, DartType>();
+ Map<String, DartType> expectedNamedTypes = HashMap<String, DartType>();
expectedNamedTypes["p"] = dynamicType;
_assertFunctionType(
dynamicType, null, null, expectedNamedTypes, resultType);
@@ -759,7 +764,7 @@
AstTestFactory.blockFunctionBody2());
_analyze5(p2);
DartType resultType = _analyze(node);
- Map<String, DartType> expectedNamedTypes = new HashMap<String, DartType>();
+ Map<String, DartType> expectedNamedTypes = HashMap<String, DartType>();
expectedNamedTypes["p2"] = dynamicType;
_assertFunctionType(dynamicType, <DartType>[dynamicType], null,
expectedNamedTypes, resultType);
@@ -779,7 +784,7 @@
AstTestFactory.expressionFunctionBody(_resolvedInteger(0)));
_analyze5(p2);
DartType resultType = _analyze(node);
- Map<String, DartType> expectedNamedTypes = new HashMap<String, DartType>();
+ Map<String, DartType> expectedNamedTypes = HashMap<String, DartType>();
expectedNamedTypes["p2"] = dynamicType;
_assertFunctionType(dynamicType, <DartType>[dynamicType], null,
expectedNamedTypes, resultType);
@@ -1314,20 +1319,25 @@
*/
StaticTypeAnalyzer _createAnalyzer() {
var context = TestAnalysisContext();
- var inheritance = new InheritanceManager3();
- Source source = new FileSource(getFile("/lib.dart"));
+ var inheritance = InheritanceManager3();
+ Source source = FileSource(getFile("/lib.dart"));
CompilationUnitElementImpl definingCompilationUnit =
- new CompilationUnitElementImpl();
+ CompilationUnitElementImpl();
definingCompilationUnit.librarySource =
definingCompilationUnit.source = source;
var featureSet = FeatureSet.forTesting();
- LibraryElementImpl definingLibrary = new LibraryElementImpl(
+
+ _definingLibrary = LibraryElementImpl(
context, null, null, -1, 0, featureSet.isEnabled(Feature.non_nullable));
- definingLibrary.definingCompilationUnit = definingCompilationUnit;
- _typeProvider = context.typeProvider;
- _visitor = new ResolverVisitor(
- inheritance, definingLibrary, source, _typeProvider, _listener,
- featureSet: featureSet, nameScope: new LibraryScope(definingLibrary));
+ _definingLibrary.definingCompilationUnit = definingCompilationUnit;
+
+ _definingLibrary.typeProvider = context.typeProviderLegacy;
+ _definingLibrary.typeSystem = context.typeSystemLegacy;
+ _typeProvider = context.typeProviderLegacy;
+
+ _visitor = ResolverVisitor(
+ inheritance, _definingLibrary, source, _typeProvider, _listener,
+ featureSet: featureSet, nameScope: LibraryScope(_definingLibrary));
return _visitor.typeAnalyzer;
}
@@ -1367,11 +1377,11 @@
*/
FunctionExpression _resolvedFunctionExpression(
FormalParameterList parameters, FunctionBody body) {
- List<ParameterElement> parameterElements = new List<ParameterElement>();
+ List<ParameterElement> parameterElements = List<ParameterElement>();
for (FormalParameter parameter in parameters.parameters) {
var nameNode = parameter.identifier;
ParameterElementImpl element =
- new ParameterElementImpl(nameNode.name, nameNode.offset);
+ ParameterElementImpl(nameNode.name, nameNode.offset);
// ignore: deprecated_member_use_from_same_package
element.parameterKind = parameter.kind;
element.type = _typeProvider.dynamicType;
@@ -1380,7 +1390,7 @@
}
FunctionExpression node =
AstTestFactory.functionExpression2(parameters, body);
- FunctionElementImpl element = new FunctionElementImpl('', -1);
+ FunctionElementImpl element = FunctionElementImpl('', -1);
element.parameters = parameterElements;
(node as FunctionExpressionImpl).declaredElement = element;
return node;
@@ -1437,7 +1447,7 @@
SimpleIdentifier identifier = parameter.identifier;
Element element = identifier.staticElement;
if (element is! ParameterElement) {
- element = new ParameterElementImpl(identifier.name, identifier.offset);
+ element = ParameterElementImpl(identifier.name, identifier.offset);
identifier.staticElement = element;
}
(element as ParameterElementImpl).type = type;
diff --git a/pkg/analyzer/test/generated/strong_mode_test.dart b/pkg/analyzer/test/generated/strong_mode_test.dart
index 1aa5efc..59480d6 100644
--- a/pkg/analyzer/test/generated/strong_mode_test.dart
+++ b/pkg/analyzer/test/generated/strong_mode_test.dart
@@ -1139,7 +1139,7 @@
Future<TestAnalysisResult> computeAnalysisResult(Source source) async {
TestAnalysisResult result = await super.computeAnalysisResult(source);
if (_assertions == null) {
- _assertions = new TypeAssertions(typeProvider);
+ _assertions = TypeAssertions(typeProvider);
_isType = _assertions.isType;
_hasElement = _assertions.hasElement;
_isInstantiationOf = _assertions.isInstantiationOf;
@@ -1167,7 +1167,7 @@
@override
void setUp() {
super.setUp();
- AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl options = AnalysisOptionsImpl();
resetWith(options: options);
}
@@ -2487,7 +2487,9 @@
_isInstantiationOf(_hasElement(elementA))([_isInt])(init.staticType);
}
- for (var i = 0; i < 5; i++) check(i);
+ for (var i = 0; i < 5; i++) {
+ check(i);
+ }
}
test_inferConstructor_unknownTypeLowerBound() async {
@@ -3895,9 +3897,9 @@
@reflectiveTest
class StrongModeLocalInferenceTest_NNBD extends ResolverTestCase {
@override
- AnalysisOptions get analysisOptions => new AnalysisOptionsImpl()
+ AnalysisOptions get analysisOptions => AnalysisOptionsImpl()
..contextFeatures =
- new FeatureSet.forTesting(additionalFeatures: [Feature.non_nullable]);
+ FeatureSet.forTesting(additionalFeatures: [Feature.non_nullable]);
@override
void setUp() {
diff --git a/pkg/analyzer/test/generated/test_analysis_context.dart b/pkg/analyzer/test/generated/test_analysis_context.dart
index e42b7ee..ed62032 100644
--- a/pkg/analyzer/test/generated/test_analysis_context.dart
+++ b/pkg/analyzer/test/generated/test_analysis_context.dart
@@ -15,9 +15,13 @@
@override
final SourceFactory sourceFactory = _MockSourceFactory();
- AnalysisOptions _analysisOptions;
- TypeProviderImpl _typeProvider;
- TypeSystemImpl _typeSystem;
+ AnalysisOptionsImpl _analysisOptions;
+
+ TypeProvider _typeProviderLegacy;
+ TypeProvider _typeProviderNonNullableByDefault;
+
+ TypeSystemImpl _typeSystemLegacy;
+ TypeSystemImpl _typeSystemNonNullableByDefault;
TestAnalysisContext({FeatureSet featureSet}) {
_analysisOptions = AnalysisOptionsImpl()
@@ -30,21 +34,30 @@
: NullabilitySuffix.star,
);
- _typeProvider = TypeProviderImpl(
+ _typeProviderLegacy = TypeProviderImpl(
coreLibrary: sdkElements.coreLibrary,
asyncLibrary: sdkElements.asyncLibrary,
isNonNullableByDefault: false,
);
- if (_analysisOptions.contextFeatures.isEnabled(Feature.non_nullable)) {
- _typeProvider = _typeProvider.asNonNullableByDefault;
- }
+ _typeProviderNonNullableByDefault = TypeProviderImpl(
+ coreLibrary: sdkElements.coreLibrary,
+ asyncLibrary: sdkElements.asyncLibrary,
+ isNonNullableByDefault: true,
+ );
- _typeSystem = TypeSystemImpl(
- implicitCasts: true,
+ _typeSystemLegacy = TypeSystemImpl(
+ implicitCasts: _analysisOptions.implicitCasts,
isNonNullableByDefault: false,
- strictInference: false,
- typeProvider: typeProvider,
+ strictInference: _analysisOptions.strictInference,
+ typeProvider: _typeProviderLegacy,
+ );
+
+ _typeSystemNonNullableByDefault = TypeSystemImpl(
+ implicitCasts: _analysisOptions.implicitCasts,
+ isNonNullableByDefault: true,
+ strictInference: _analysisOptions.strictInference,
+ typeProvider: _typeProviderNonNullableByDefault,
);
_setLibraryTypeSystem(sdkElements.coreLibrary);
@@ -54,17 +67,35 @@
@override
AnalysisOptions get analysisOptions => _analysisOptions;
+ @Deprecated('Use LibraryElement.typeProvider')
@override
- TypeProvider get typeProvider => _typeProvider;
+ TypeProvider get typeProvider => typeProviderLegacy;
+ TypeProvider get typeProviderLegacy {
+ return _typeProviderLegacy;
+ }
+
+ TypeProvider get typeProviderNonNullableByDefault {
+ return _typeProviderNonNullableByDefault;
+ }
+
+ @Deprecated('Use LibraryElement.typeSystem')
@override
- TypeSystemImpl get typeSystem => _typeSystem;
+ TypeSystemImpl get typeSystem => typeSystemLegacy;
+
+ TypeSystemImpl get typeSystemLegacy {
+ return _typeSystemLegacy;
+ }
+
+ TypeSystemImpl get typeSystemNonNullableByDefault {
+ return _typeSystemNonNullableByDefault;
+ }
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
void _setLibraryTypeSystem(LibraryElementImpl libraryElement) {
- libraryElement.typeProvider = _typeProvider;
- libraryElement.typeSystem = _typeSystem;
+ libraryElement.typeProvider = _typeProviderLegacy;
+ libraryElement.typeSystem = _typeSystemLegacy;
}
}
diff --git a/pkg/analyzer/test/generated/test_support.dart b/pkg/analyzer/test/generated/test_support.dart
index b2c9106..f4e1622 100644
--- a/pkg/analyzer/test/generated/test_support.dart
+++ b/pkg/analyzer/test/generated/test_support.dart
@@ -147,7 +147,7 @@
//
// Write the results.
//
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
if (unmatchedExpected.isNotEmpty) {
buffer.writeln('Expected but did not find:');
for (ExpectedError expected in unmatchedExpected) {
@@ -215,7 +215,7 @@
/// codes. The order in which the errors were gathered is ignored.
void assertErrorsWithCodes(
[List<ErrorCode> expectedErrorCodes = const <ErrorCode>[]]) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
//
// Compute the expected number of each type of error.
//
@@ -352,7 +352,7 @@
/// Set the line information associated with the given [source] to the given
/// list of [lineStarts].
void setLineInfo(Source source, List<int> lineStarts) {
- _lineInfoMap[source] = new LineInfo(lineStarts);
+ _lineInfoMap[source] = LineInfo(lineStarts);
}
}
@@ -397,9 +397,9 @@
readCount++;
if (generateExceptionOnRead) {
String msg = "I/O Exception while getting the contents of " + _name;
- throw new Exception(msg);
+ throw Exception(msg);
}
- return new TimestampedData<String>(0, _contents);
+ return TimestampedData<String>(0, _contents);
}
String get encoding => _name;
@@ -422,10 +422,10 @@
return _name;
}
- Uri get uri => new Uri.file(_name);
+ Uri get uri => Uri.file(_name);
UriKind get uriKind {
- throw new UnsupportedError('uriKind');
+ throw UnsupportedError('uriKind');
}
bool operator ==(Object other) {
@@ -438,12 +438,12 @@
bool exists() => exists2;
Source resolve(String uri) {
- throw new UnsupportedError('resolve');
+ throw UnsupportedError('resolve');
}
void setContents(String value) {
generateExceptionOnRead = false;
- _modificationStamp = new DateTime.now().millisecondsSinceEpoch;
+ _modificationStamp = DateTime.now().millisecondsSinceEpoch;
_contents = value;
}
diff --git a/pkg/analyzer/test/generated/type_system_test.dart b/pkg/analyzer/test/generated/type_system_test.dart
index 5bc1e83..365c8f9 100644
--- a/pkg/analyzer/test/generated/type_system_test.dart
+++ b/pkg/analyzer/test/generated/type_system_test.dart
@@ -41,56 +41,21 @@
}
abstract class AbstractTypeSystemTest with ElementsTypesMixin {
+ @override
TypeProvider typeProvider;
+
TypeSystemImpl typeSystem;
- InterfaceType get doubleType => typeProvider.doubleType;
-
- InterfaceType get intType => typeProvider.intType;
-
- DartType get nullType => typeProvider.nullType;
-
- InterfaceType get numType => typeProvider.numType;
-
- InterfaceType get objectType => typeProvider.objectType;
-
- InterfaceType get stringType => typeProvider.stringType;
-
FeatureSet get testFeatureSet {
return FeatureSet.forTesting();
}
- DartType get voidType => VoidTypeImpl.instance;
-
- DartType futureOrType(DartType T) {
- var futureOrElement = typeProvider.futureOrElement;
- return interfaceTypeStar(futureOrElement, typeArguments: [T]);
- }
-
- DartType futureType(DartType T) {
- var futureElement = typeProvider.futureElement;
- return interfaceTypeStar(futureElement, typeArguments: [T]);
- }
-
- DartType iterableType(DartType T) {
- var iterableElement = typeProvider.iterableElement;
- return interfaceTypeStar(iterableElement, typeArguments: [T]);
- }
-
- DartType listType(DartType T) {
- var listElement = typeProvider.listElement;
- return interfaceTypeStar(listElement, typeArguments: [T]);
- }
-
void setUp() {
var analysisContext = TestAnalysisContext(
featureSet: testFeatureSet,
);
- typeProvider = analysisContext.typeProvider;
- typeSystem = analysisContext.typeSystem;
-
- typeProvider = typeProvider;
- typeSystem = typeSystem;
+ typeProvider = analysisContext.typeProviderLegacy;
+ typeSystem = analysisContext.typeSystemLegacy;
}
String _typeString(TypeImpl type) {
@@ -104,11 +69,11 @@
var A = class_(name: 'A');
List<DartType> interassignable = <DartType>[
dynamicType,
- objectType,
- intType,
- doubleType,
- numType,
- stringType,
+ objectStar,
+ intStar,
+ doubleStar,
+ numStar,
+ stringStar,
interfaceTypeStar(A),
neverStar,
];
@@ -120,8 +85,8 @@
var B = class_(
name: 'B',
methods: [
- method('call', objectType, parameters: [
- requiredParameter(name: '_', type: intType),
+ method('call', objectStar, parameters: [
+ requiredParameter(name: '_', type: intStar),
]),
],
);
@@ -130,9 +95,9 @@
interfaceTypeStar(B),
functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: objectType,
+ returnType: objectStar,
),
);
}
@@ -158,18 +123,18 @@
var A = class_(name: 'A');
List<DartType> interassignable = <DartType>[
dynamicType,
- objectType,
- doubleType,
- numType,
+ objectStar,
+ doubleStar,
+ numStar,
neverStar,
];
List<DartType> unrelated = <DartType>[
- intType,
- stringType,
+ intStar,
+ stringStar,
interfaceTypeStar(A),
];
- _checkGroups(doubleType,
+ _checkGroups(doubleStar,
interassignable: interassignable, unrelated: unrelated);
}
@@ -177,11 +142,11 @@
var A = class_(name: 'A');
List<DartType> interassignable = <DartType>[
dynamicType,
- objectType,
- intType,
- doubleType,
- numType,
- stringType,
+ objectStar,
+ intStar,
+ doubleStar,
+ numStar,
+ stringStar,
interfaceTypeStar(A),
neverStar,
];
@@ -208,8 +173,8 @@
var top = interfaceTypeStar(L, typeArguments: [dynamicType]);
var left = interfaceTypeStar(M, typeArguments: [dynamicType]);
- var right = interfaceTypeStar(L, typeArguments: [intType]);
- var bottom = interfaceTypeStar(M, typeArguments: [intType]);
+ var right = interfaceTypeStar(L, typeArguments: [intStar]);
+ var bottom = interfaceTypeStar(M, typeArguments: [intStar]);
_checkCrossLattice(top, left, right, bottom);
}
@@ -218,83 +183,83 @@
var A = class_(name: 'A');
List<DartType> interassignable = <DartType>[
dynamicType,
- objectType,
- intType,
- numType,
+ objectStar,
+ intStar,
+ numStar,
neverStar,
];
List<DartType> unrelated = <DartType>[
- doubleType,
- stringType,
+ doubleStar,
+ stringStar,
interfaceTypeStar(A),
];
- _checkGroups(intType,
+ _checkGroups(intStar,
interassignable: interassignable, unrelated: unrelated);
}
void test_isAssignableTo_named_optional() {
var r = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: intType,
+ returnType: intStar,
);
var o = functionTypeStar(
parameters: [
- positionalParameter(type: intType),
+ positionalParameter(type: intStar),
],
- returnType: intType,
+ returnType: intStar,
);
var n = functionTypeStar(
parameters: [
- namedParameter(name: 'x', type: intType),
+ namedParameter(name: 'x', type: intStar),
],
- returnType: intType,
+ returnType: intStar,
);
var rr = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar),
],
- returnType: intType,
+ returnType: intStar,
);
var ro = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- positionalParameter(type: intType),
+ requiredParameter(type: intStar),
+ positionalParameter(type: intStar),
],
- returnType: intType,
+ returnType: intStar,
);
var rn = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- namedParameter(name: 'x', type: intType),
+ requiredParameter(type: intStar),
+ namedParameter(name: 'x', type: intStar),
],
- returnType: intType,
+ returnType: intStar,
);
var oo = functionTypeStar(
parameters: [
- positionalParameter(type: intType),
- positionalParameter(type: intType),
+ positionalParameter(type: intStar),
+ positionalParameter(type: intStar),
],
- returnType: intType,
+ returnType: intStar,
);
var nn = functionTypeStar(
parameters: [
- namedParameter(name: 'x', type: intType),
- namedParameter(name: 'y', type: intType),
+ namedParameter(name: 'x', type: intStar),
+ namedParameter(name: 'y', type: intStar),
],
- returnType: intType,
+ returnType: intStar,
);
var nnn = functionTypeStar(
parameters: [
- namedParameter(name: 'x', type: intType),
- namedParameter(name: 'y', type: intType),
- namedParameter(name: 'z', type: intType),
+ namedParameter(name: 'x', type: intStar),
+ namedParameter(name: 'y', type: intStar),
+ namedParameter(name: 'z', type: intStar),
],
- returnType: intType,
+ returnType: intStar,
);
_checkGroups(r,
@@ -319,48 +284,48 @@
var A = class_(name: 'A');
List<DartType> interassignable = <DartType>[
dynamicType,
- objectType,
- numType,
- intType,
- doubleType,
+ objectStar,
+ numStar,
+ intStar,
+ doubleStar,
neverStar,
];
List<DartType> unrelated = <DartType>[
- stringType,
+ stringStar,
interfaceTypeStar(A),
];
- _checkGroups(numType,
+ _checkGroups(numStar,
interassignable: interassignable, unrelated: unrelated);
}
void test_isAssignableTo_simple_function() {
var top = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: objectType,
+ returnType: objectStar,
);
var left = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: intType,
+ returnType: intStar,
);
var right = functionTypeStar(
parameters: [
- requiredParameter(type: objectType),
+ requiredParameter(type: objectStar),
],
- returnType: objectType,
+ returnType: objectStar,
);
var bottom = functionTypeStar(
parameters: [
- requiredParameter(type: objectType),
+ requiredParameter(type: objectStar),
],
- returnType: intType,
+ returnType: intStar,
);
_checkCrossLattice(top, left, right, bottom);
@@ -369,16 +334,16 @@
void test_isAssignableTo_void_functions() {
var top = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var bottom = functionTypeStar(
parameters: [
- requiredParameter(type: objectType),
+ requiredParameter(type: objectStar),
],
- returnType: intType,
+ returnType: intStar,
);
_checkEquivalent(bottom, top);
@@ -501,9 +466,9 @@
_checkOrdinarySubtypeMatch(
functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: stringType,
+ returnType: stringStar,
),
typeProvider.functionType,
[T],
@@ -517,13 +482,13 @@
parameters: [
requiredParameter(type: T),
],
- returnType: intType,
+ returnType: intStar,
),
functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
+ requiredParameter(type: stringStar),
],
- returnType: intType,
+ returnType: intStar,
),
[T],
['String <: T'],
@@ -535,15 +500,15 @@
_checkIsSubtypeMatchOf(
functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
returnType: T,
),
functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: stringType,
+ returnType: stringStar,
),
[T],
['T <: String'],
@@ -553,7 +518,7 @@
void test_futureOr_futureOr() {
_checkIsSubtypeMatchOf(
- futureOrType(T), futureOrType(stringType), [T], ['T <: String'],
+ futureOrStar(T), futureOrStar(stringStar), [T], ['T <: String'],
covariant: true);
}
@@ -561,7 +526,7 @@
// FutureOr<List<T>> <: List<String> can't be satisfied because
// Future<List<T>> <: List<String> can't be satisfied
_checkIsNotSubtypeMatchOf(
- futureOrType(listType(T)), listType(stringType), [T],
+ futureOrStar(listStar(T)), listStar(stringStar), [T],
covariant: true);
}
@@ -569,7 +534,7 @@
// FutureOr<List<T>> <: Future<List<String>> can't be satisfied because
// List<T> <: Future<List<String>> can't be satisfied
_checkIsNotSubtypeMatchOf(
- futureOrType(listType(T)), futureType(listType(stringType)), [T],
+ futureOrStar(listStar(T)), futureStar(listStar(stringStar)), [T],
covariant: true);
}
@@ -577,29 +542,29 @@
// FutureOr<T> <: Future<T> can be satisfied by T=Null. At this point in
// the type inference algorithm all we figure out is that T must be a
// subtype of both String and Future<String>.
- _checkIsSubtypeMatchOf(futureOrType(T), futureType(stringType), [T],
+ _checkIsSubtypeMatchOf(futureOrStar(T), futureStar(stringStar), [T],
['T <: String', 'T <: Future<String>'],
covariant: true);
}
void test_lhs_null() {
// Null <: T is trivially satisfied by the constraint Null <: T.
- _checkIsSubtypeMatchOf(nullType, T, [T], ['Null <: T'], covariant: false);
+ _checkIsSubtypeMatchOf(nullStar, T, [T], ['Null <: T'], covariant: false);
// For any other type X, Null <: X is satisfied without the need for any
// constraints.
- _checkOrdinarySubtypeMatch(nullType, listType(T), [T], covariant: false);
- _checkOrdinarySubtypeMatch(nullType, stringType, [T], covariant: false);
- _checkOrdinarySubtypeMatch(nullType, voidType, [T], covariant: false);
- _checkOrdinarySubtypeMatch(nullType, dynamicType, [T], covariant: false);
- _checkOrdinarySubtypeMatch(nullType, objectType, [T], covariant: false);
- _checkOrdinarySubtypeMatch(nullType, nullType, [T], covariant: false);
+ _checkOrdinarySubtypeMatch(nullStar, listStar(T), [T], covariant: false);
+ _checkOrdinarySubtypeMatch(nullStar, stringStar, [T], covariant: false);
+ _checkOrdinarySubtypeMatch(nullStar, voidNone, [T], covariant: false);
+ _checkOrdinarySubtypeMatch(nullStar, dynamicType, [T], covariant: false);
+ _checkOrdinarySubtypeMatch(nullStar, objectStar, [T], covariant: false);
+ _checkOrdinarySubtypeMatch(nullStar, nullStar, [T], covariant: false);
_checkOrdinarySubtypeMatch(
- nullType,
+ nullStar,
functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: stringType,
+ returnType: stringStar,
),
[T],
covariant: false,
@@ -617,7 +582,7 @@
// In other words, List<S> <: List<T> is satisfied provided that
// S <: T.
var S = typeParameterTypeStar(typeParameter('S'));
- _checkIsSubtypeMatchOf(listType(S), listType(T), [T], ['S <: T'],
+ _checkIsSubtypeMatchOf(listStar(S), listStar(T), [T], ['S <: T'],
covariant: false);
}
@@ -631,23 +596,23 @@
// bound(S) <: List<T>.
var S = typeParameterTypeStar(typeParameter(
'S',
- bound: listType(stringType),
+ bound: listStar(stringStar),
));
- _checkIsSubtypeMatchOf(S, listType(T), [T], ['String <: T'],
+ _checkIsSubtypeMatchOf(S, listStar(T), [T], ['String <: T'],
covariant: false);
}
void test_param_on_lhs_covariant() {
// When doing a covariant match, the type parameters we're trying to find
// types for are on the left hand side.
- _checkIsSubtypeMatchOf(T, stringType, [T], ['T <: String'],
+ _checkIsSubtypeMatchOf(T, stringStar, [T], ['T <: String'],
covariant: true);
}
void test_param_on_rhs_contravariant() {
// When doing a contravariant match, the type parameters we're trying to
// find types for are on the right hand side.
- _checkIsSubtypeMatchOf(stringType, T, [T], ['String <: T'],
+ _checkIsSubtypeMatchOf(stringStar, T, [T], ['String <: T'],
covariant: false);
}
@@ -675,17 +640,17 @@
// In other words, no match can be found for List<T> <: S because regardless
// of T, we can't guarantee that List<T> <: S for all S.
var S = typeParameterTypeStar(typeParameter('S'));
- _checkIsNotSubtypeMatchOf(listType(T), S, [T], covariant: true);
+ _checkIsNotSubtypeMatchOf(listStar(T), S, [T], covariant: true);
}
void test_related_interface_types_failure() {
- _checkIsNotSubtypeMatchOf(iterableType(T), listType(stringType), [T],
+ _checkIsNotSubtypeMatchOf(iterableStar(T), listStar(stringStar), [T],
covariant: true);
}
void test_related_interface_types_success() {
_checkIsSubtypeMatchOf(
- listType(T), iterableType(stringType), [T], ['T <: String'],
+ listStar(T), iterableStar(stringStar), [T], ['T <: String'],
covariant: true);
}
@@ -695,18 +660,18 @@
covariant: true);
// For any other type X, X <: dynamic is satisfied without the need for any
// constraints.
- _checkOrdinarySubtypeMatch(listType(T), dynamicType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(stringType, dynamicType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(voidType, dynamicType, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(listStar(T), dynamicType, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(stringStar, dynamicType, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(voidNone, dynamicType, [T], covariant: true);
_checkOrdinarySubtypeMatch(dynamicType, dynamicType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(objectType, dynamicType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(nullType, dynamicType, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(objectStar, dynamicType, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(nullStar, dynamicType, [T], covariant: true);
_checkOrdinarySubtypeMatch(
functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: stringType,
+ returnType: stringStar,
),
dynamicType,
[T],
@@ -716,24 +681,24 @@
void test_rhs_object() {
// T <: Object is trivially satisfied by the constraint T <: Object.
- _checkIsSubtypeMatchOf(T, objectType, [T], ['T <: Object'],
+ _checkIsSubtypeMatchOf(T, objectStar, [T], ['T <: Object'],
covariant: true);
// For any other type X, X <: Object is satisfied without the need for any
// constraints.
- _checkOrdinarySubtypeMatch(listType(T), objectType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(stringType, objectType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(voidType, objectType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(dynamicType, objectType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(objectType, objectType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(nullType, objectType, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(listStar(T), objectStar, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(stringStar, objectStar, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(voidNone, objectStar, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(dynamicType, objectStar, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(objectStar, objectStar, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(nullStar, objectStar, [T], covariant: true);
_checkOrdinarySubtypeMatch(
functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: stringType,
+ returnType: stringStar,
),
- objectType,
+ objectStar,
[T],
covariant: true,
);
@@ -741,23 +706,23 @@
void test_rhs_void() {
// T <: void is trivially satisfied by the constraint T <: void.
- _checkIsSubtypeMatchOf(T, voidType, [T], ['T <: void'], covariant: true);
+ _checkIsSubtypeMatchOf(T, voidNone, [T], ['T <: void'], covariant: true);
// For any other type X, X <: void is satisfied without the need for any
// constraints.
- _checkOrdinarySubtypeMatch(listType(T), voidType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(stringType, voidType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(voidType, voidType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(dynamicType, voidType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(objectType, voidType, [T], covariant: true);
- _checkOrdinarySubtypeMatch(nullType, voidType, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(listStar(T), voidNone, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(stringStar, voidNone, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(voidNone, voidNone, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(dynamicType, voidNone, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(objectStar, voidNone, [T], covariant: true);
+ _checkOrdinarySubtypeMatch(nullStar, voidNone, [T], covariant: true);
_checkOrdinarySubtypeMatch(
functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: stringType,
+ returnType: stringStar,
),
- voidType,
+ voidNone,
[T],
covariant: true,
);
@@ -765,7 +730,7 @@
void test_same_interface_types() {
_checkIsSubtypeMatchOf(
- listType(T), listType(stringType), [T], ['T <: String'],
+ listStar(T), listStar(stringStar), [T], ['T <: String'],
covariant: true);
}
@@ -778,7 +743,7 @@
// A<num>
// A<T>
var aNum = interfaceType(A,
- typeArguments: [numType], nullabilitySuffix: NullabilitySuffix.none);
+ typeArguments: [numStar], nullabilitySuffix: NullabilitySuffix.none);
var aT = interfaceType(A,
typeArguments: [tType], nullabilitySuffix: NullabilitySuffix.none);
@@ -794,7 +759,7 @@
// A<num>
// A<T>
var aNum = interfaceType(A,
- typeArguments: [numType], nullabilitySuffix: NullabilitySuffix.none);
+ typeArguments: [numStar], nullabilitySuffix: NullabilitySuffix.none);
var aT = interfaceType(A,
typeArguments: [tType], nullabilitySuffix: NullabilitySuffix.none);
@@ -811,7 +776,7 @@
// A<num>
// A<T>
var aNum = interfaceType(A,
- typeArguments: [numType], nullabilitySuffix: NullabilitySuffix.none);
+ typeArguments: [numStar], nullabilitySuffix: NullabilitySuffix.none);
var aT = interfaceType(A,
typeArguments: [tType], nullabilitySuffix: NullabilitySuffix.none);
@@ -823,7 +788,7 @@
void test_x_futureOr_fail_both_branches() {
// List<T> <: FutureOr<String> can't be satisfied because neither
// List<T> <: Future<String> nor List<T> <: int can be satisfied
- _checkIsNotSubtypeMatchOf(listType(T), futureOrType(stringType), [T],
+ _checkIsNotSubtypeMatchOf(listStar(T), futureOrStar(stringStar), [T],
covariant: true);
}
@@ -835,7 +800,7 @@
// constraint Future<String> <: T. We keep the constraint based on trying
// to match Future<String> <: Future<T>, so String <: T.
_checkIsSubtypeMatchOf(
- futureType(stringType), futureOrType(T), [T], ['String <: T'],
+ futureStar(stringStar), futureOrStar(T), [T], ['String <: T'],
covariant: false);
}
@@ -846,7 +811,7 @@
// T <: Object, whereas trying to match Future<T> <: Object generates no
// constraints, so we keep the constraint T <: Object.
_checkIsSubtypeMatchOf(
- futureType(T), futureOrType(objectType), [T], ['T <: Object'],
+ futureStar(T), futureOrStar(objectStar), [T], ['T <: Object'],
covariant: true);
}
@@ -856,7 +821,7 @@
// Trying to match Null <: FutureOr<T> generates no constraints, whereas
// trying to match Null <: T generates the constraint Null <: T,
// so we keep the constraint Null <: T.
- _checkIsSubtypeMatchOf(nullType, futureOrType(T), [T], ['Null <: T'],
+ _checkIsSubtypeMatchOf(nullStar, futureOrStar(T), [T], ['Null <: T'],
covariant: false);
}
@@ -865,7 +830,7 @@
// Future<String> <: Future<Object> and Future<String> <: Object.
// No constraints are recorded.
_checkIsSubtypeMatchOf(
- futureType(stringType), futureOrType(objectType), [T], [],
+ futureStar(stringStar), futureOrStar(objectStar), [T], [],
covariant: true);
}
@@ -873,7 +838,7 @@
// Future<T> <: FutureOr<String> can be satisfied because
// Future<T> <: Future<String> can be satisfied
_checkIsSubtypeMatchOf(
- futureType(T), futureOrType(stringType), [T], ['T <: String'],
+ futureStar(T), futureOrStar(stringStar), [T], ['T <: String'],
covariant: true);
}
@@ -881,14 +846,14 @@
// List<T> <: FutureOr<List<String>> can be satisfied because
// List<T> <: List<String> can be satisfied
_checkIsSubtypeMatchOf(
- listType(T), futureOrType(listType(stringType)), [T], ['T <: String'],
+ listStar(T), futureOrStar(listStar(stringStar)), [T], ['T <: String'],
covariant: true);
}
void _checkIsNotSubtypeMatchOf(
DartType t1, DartType t2, Iterable<TypeParameterType> typeFormals,
{bool covariant}) {
- var inferrer = new GenericInferrer(
+ var inferrer = GenericInferrer(
typeProvider, typeSystem, typeFormals.map((t) => t.element));
var success =
inferrer.tryMatchSubtypeOf(t1, t2, null, covariant: covariant);
@@ -904,7 +869,7 @@
Iterable<TypeParameterType> typeFormals,
Iterable<String> expectedConstraints,
{bool covariant}) {
- var inferrer = new GenericInferrer(
+ var inferrer = GenericInferrer(
typeProvider, typeSystem, typeFormals.map((t) => t.element));
var success =
inferrer.tryMatchSubtypeOf(t1, t2, null, covariant: covariant);
@@ -936,7 +901,7 @@
// <TFrom, TTo extends Iterable<TFrom>>(TFrom) -> TTo
var tFrom = typeParameter('TFrom');
var tTo =
- typeParameter('TTo', bound: iterableType(typeParameterTypeStar(tFrom)));
+ typeParameter('TTo', bound: iterableStar(typeParameterTypeStar(tFrom)));
var cast = functionTypeStar(
typeFormals: [tFrom, tTo],
parameters: [
@@ -946,15 +911,15 @@
],
returnType: typeParameterTypeStar(tTo),
);
- expect(
- _inferCall(cast, [stringType]), [stringType, iterableType(stringType)]);
+ expect(_inferCall(cast, [stringStar]),
+ [stringStar, (iterableStar(stringStar))]);
}
void test_boundedByOuterClass() {
// Regression test for https://github.com/dart-lang/sdk/issues/25740.
// class A {}
- var A = class_(name: 'A', superType: objectType);
+ var A = class_(name: 'A', superType: objectStar);
var typeA = interfaceTypeStar(A);
// class B extends A {}
@@ -965,7 +930,7 @@
var CT = typeParameter('T', bound: typeA);
var C = class_(
name: 'C',
- superType: objectType,
+ superType: objectStar,
typeParameters: [CT],
);
// S m<S extends T>(S);
@@ -985,7 +950,7 @@
// }
// C<Object> cOfObject;
- var cOfObject = interfaceTypeStar(C, typeArguments: [objectType]);
+ var cOfObject = interfaceTypeStar(C, typeArguments: [objectStar]);
// C<A> cOfA;
var cOfA = interfaceTypeStar(C, typeArguments: [typeA]);
// C<B> cOfB;
@@ -1006,7 +971,7 @@
// Regression test for https://github.com/dart-lang/sdk/issues/25740.
// class A {}
- var A = class_(name: 'A', superType: objectType);
+ var A = class_(name: 'A', superType: objectStar);
var typeA = interfaceTypeStar(A);
// class B extends A {}
@@ -1017,11 +982,11 @@
var CT = typeParameter('T', bound: typeA);
var C = class_(
name: 'C',
- superType: objectType,
+ superType: objectStar,
typeParameters: [CT],
);
// S m<S extends Iterable<T>>(S);
- var iterableOfT = iterableType(typeParameterTypeStar(CT));
+ var iterableOfT = iterableStar(typeParameterTypeStar(CT));
var S = typeParameter('S', bound: iterableOfT);
var m = method(
'm',
@@ -1038,13 +1003,13 @@
// }
// C<Object> cOfObject;
- var cOfObject = interfaceTypeStar(C, typeArguments: [objectType]);
+ var cOfObject = interfaceTypeStar(C, typeArguments: [objectStar]);
// C<A> cOfA;
var cOfA = interfaceTypeStar(C, typeArguments: [typeA]);
// C<B> cOfB;
var cOfB = interfaceTypeStar(C, typeArguments: [typeB]);
// List<B> b;
- var listOfB = listType(typeB);
+ var listOfB = listStar(typeB);
// cOfB.m(b); // infer <B>
expect(_inferCall2(cOfB.getMethod('m').type, [listOfB]).toString(),
'List<B> Function(List<B>)');
@@ -1061,7 +1026,7 @@
var T = typeParameter('T');
var A = class_(
name: 'Cloneable',
- superType: objectType,
+ superType: objectStar,
typeParameters: [T],
);
T.bound = interfaceTypeStar(
@@ -1092,8 +1057,8 @@
// Something invalid...
expect(
- _inferCall(clone, [stringType, numType], expectError: true),
- [objectType],
+ _inferCall(clone, [stringStar, numStar], expectError: true),
+ [objectStar],
);
}
@@ -1110,7 +1075,7 @@
],
returnType: typeParameterTypeStar(tTo),
);
- expect(_inferCall(cast, [intType]), [intType, dynamicType]);
+ expect(_inferCall(cast, [intStar]), [intStar, dynamicType]);
}
void test_genericCastFunctionWithUpperBound() {
@@ -1129,7 +1094,51 @@
],
returnType: typeParameterTypeStar(tTo),
);
- expect(_inferCall(cast, [intType]), [intType, intType]);
+ expect(_inferCall(cast, [intStar]), [intStar, intStar]);
+ }
+
+ void test_parameter_contravariantUseUpperBound() {
+ // <T>(T x, void Function(T) y) -> T
+ // Generates constraints int <: T <: num.
+ // Since T is contravariant, choose num.
+ var T = typeParameter('T', variance: Variance.contravariant);
+ var tFunction = functionTypeStar(
+ parameters: [requiredParameter(type: typeParameterTypeStar(T))],
+ returnType: voidNone);
+ var numFunction = functionTypeStar(
+ parameters: [requiredParameter(type: numStar)], returnType: voidNone);
+ var function = functionTypeStar(
+ typeFormals: [T],
+ parameters: [
+ requiredParameter(type: typeParameterTypeStar(T)),
+ requiredParameter(type: tFunction)
+ ],
+ returnType: typeParameterTypeStar(T),
+ );
+
+ expect(_inferCall(function, [intStar, numFunction]), [numStar]);
+ }
+
+ void test_parameter_covariantUseLowerBound() {
+ // <T>(T x, void Function(T) y) -> T
+ // Generates constraints int <: T <: num.
+ // Since T is covariant, choose int.
+ var T = typeParameter('T', variance: Variance.covariant);
+ var tFunction = functionTypeStar(
+ parameters: [requiredParameter(type: typeParameterTypeStar(T))],
+ returnType: voidNone);
+ var numFunction = functionTypeStar(
+ parameters: [requiredParameter(type: numStar)], returnType: voidNone);
+ var function = functionTypeStar(
+ typeFormals: [T],
+ parameters: [
+ requiredParameter(type: typeParameterTypeStar(T)),
+ requiredParameter(type: tFunction)
+ ],
+ returnType: typeParameterTypeStar(T),
+ );
+
+ expect(_inferCall(function, [intStar, numFunction]), [intStar]);
}
void test_parametersToFunctionParam() {
@@ -1155,12 +1164,12 @@
_inferCall(cast, [
functionTypeStar(
parameters: [
- requiredParameter(type: numType),
+ requiredParameter(type: numStar),
],
returnType: dynamicType,
)
]),
- [numType],
+ [numStar],
);
}
@@ -1175,12 +1184,12 @@
],
returnType: typeParameterTypeStar(T),
);
- expect(_inferCall(cast, [intType, doubleType]), [numType]);
+ expect(_inferCall(cast, [intStar, doubleStar]), [numStar]);
}
void test_parameterTypeUsesUpperBound() {
// <T extends num>(T) -> dynamic
- var T = typeParameter('T', bound: numType);
+ var T = typeParameter('T', bound: numStar);
var f = functionTypeStar(
typeFormals: [T],
parameters: [
@@ -1188,51 +1197,7 @@
],
returnType: dynamicType,
);
- expect(_inferCall(f, [intType]), [intType]);
- }
-
- void test_parameter_contravariantUseUpperBound() {
- // <T>(T x, void Function(T) y) -> T
- // Generates constraints int <: T <: num.
- // Since T is contravariant, choose num.
- var T = typeParameter('T', variance: Variance.contravariant);
- var tFunction = functionTypeStar(
- parameters: [requiredParameter(type: typeParameterTypeStar(T))],
- returnType: voidType);
- var numFunction = functionTypeStar(
- parameters: [requiredParameter(type: numType)], returnType: voidType);
- var function = functionTypeStar(
- typeFormals: [T],
- parameters: [
- requiredParameter(type: typeParameterTypeStar(T)),
- requiredParameter(type: tFunction)
- ],
- returnType: typeParameterTypeStar(T),
- );
-
- expect(_inferCall(function, [intType, numFunction]), [numType]);
- }
-
- void test_parameter_covariantUseLowerBound() {
- // <T>(T x, void Function(T) y) -> T
- // Generates constraints int <: T <: num.
- // Since T is covariant, choose int.
- var T = typeParameter('T', variance: Variance.covariant);
- var tFunction = functionTypeStar(
- parameters: [requiredParameter(type: typeParameterTypeStar(T))],
- returnType: voidType);
- var numFunction = functionTypeStar(
- parameters: [requiredParameter(type: numType)], returnType: voidType);
- var function = functionTypeStar(
- typeFormals: [T],
- parameters: [
- requiredParameter(type: typeParameterTypeStar(T)),
- requiredParameter(type: tFunction)
- ],
- returnType: typeParameterTypeStar(T),
- );
-
- expect(_inferCall(function, [intType, numFunction]), [intType]);
+ expect(_inferCall(f, [intStar]), [intStar]);
}
void test_returnFunctionWithGenericParameter() {
@@ -1254,19 +1219,19 @@
parameters: [
requiredParameter(type: typeParameterTypeStar(T)),
],
- returnType: voidType,
+ returnType: voidNone,
),
);
expect(
_inferCall(f, [
functionTypeStar(
parameters: [
- requiredParameter(type: numType),
+ requiredParameter(type: numStar),
],
- returnType: intType,
+ returnType: intStar,
),
]),
- [intType],
+ [intStar],
);
}
@@ -1289,7 +1254,7 @@
parameters: [
requiredParameter(type: typeParameterTypeStar(T)),
],
- returnType: nullType,
+ returnType: nullStar,
),
);
expect(
@@ -1298,12 +1263,12 @@
[],
returnType: functionTypeStar(
parameters: [
- requiredParameter(type: numType),
+ requiredParameter(type: numStar),
],
- returnType: intType,
+ returnType: intStar,
),
),
- [numType],
+ [numStar],
);
}
@@ -1333,12 +1298,12 @@
_inferCall(f, [
functionTypeStar(
parameters: [
- requiredParameter(type: numType),
+ requiredParameter(type: numStar),
],
- returnType: intType,
+ returnType: intStar,
)
]),
- [intType],
+ [intStar],
);
}
@@ -1365,12 +1330,12 @@
_inferCall(f, [
functionTypeStar(
parameters: [
- requiredParameter(type: numType),
+ requiredParameter(type: numStar),
],
- returnType: intType,
+ returnType: intStar,
)
]),
- [intType],
+ [intStar],
);
}
@@ -1381,27 +1346,27 @@
typeFormals: [T],
returnType: typeParameterTypeStar(T),
);
- expect(_inferCall(f, [], returnType: stringType), [stringType]);
+ expect(_inferCall(f, [], returnType: stringStar), [stringStar]);
}
void test_returnTypeWithBoundFromContext() {
// <T extends num>() -> T
- var T = typeParameter('T', bound: numType);
+ var T = typeParameter('T', bound: numStar);
var f = functionTypeStar(
typeFormals: [T],
returnType: typeParameterTypeStar(T),
);
- expect(_inferCall(f, [], returnType: doubleType), [doubleType]);
+ expect(_inferCall(f, [], returnType: doubleStar), [doubleStar]);
}
void test_returnTypeWithBoundFromInvalidContext() {
// <T extends num>() -> T
- var T = typeParameter('T', bound: numType);
+ var T = typeParameter('T', bound: numStar);
var f = functionTypeStar(
typeFormals: [T],
returnType: typeParameterTypeStar(T),
);
- expect(_inferCall(f, [], returnType: stringType), [nullType]);
+ expect(_inferCall(f, [], returnType: stringStar), [nullStar]);
}
void test_unifyParametersToFunctionParam() {
@@ -1437,18 +1402,18 @@
_inferCall(cast, [
functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
returnType: dynamicType,
),
functionTypeStar(
parameters: [
- requiredParameter(type: doubleType),
+ requiredParameter(type: doubleStar),
],
returnType: dynamicType,
)
]),
- [nullType],
+ [nullStar],
);
}
@@ -1464,22 +1429,20 @@
void test_unusedReturnTypeWithUpperBound() {
// <T extends num>() -> T
- var T = typeParameter('T', bound: numType);
+ var T = typeParameter('T', bound: numStar);
var f = functionTypeStar(
typeFormals: [T],
returnType: typeParameterTypeStar(T),
);
- expect(_inferCall(f, []), [numType]);
+ expect(_inferCall(f, []), [numStar]);
}
List<DartType> _inferCall(FunctionTypeImpl ft, List<DartType> arguments,
- {DartType returnType, bool expectError: false}) {
- var listener = new RecordingErrorListener();
+ {DartType returnType, bool expectError = false}) {
+ var listener = RecordingErrorListener();
- var reporter = new ErrorReporter(
- listener,
- new NonExistingSource(
- '/test.dart', toUri('/test.dart'), UriKind.FILE_URI));
+ var reporter = ErrorReporter(listener,
+ NonExistingSource('/test.dart', toUri('/test.dart'), UriKind.FILE_URI));
var typeArguments = typeSystem.inferGenericFunctionOrType(
typeParameters: ft.typeFormals,
@@ -1488,7 +1451,7 @@
argumentTypes: arguments,
contextReturnType: returnType,
errorReporter: reporter,
- errorNode: astFactory.nullLiteral(new KeywordToken(Keyword.NULL, 0)),
+ errorNode: astFactory.nullLiteral(KeywordToken(Keyword.NULL, 0)),
isNonNullableByDefault: false,
);
@@ -1503,7 +1466,7 @@
}
FunctionType _inferCall2(FunctionTypeImpl ft, List<DartType> arguments,
- {DartType returnType, bool expectError: false}) {
+ {DartType returnType, bool expectError = false}) {
var typeArguments = _inferCall(
ft,
arguments,
@@ -1518,7 +1481,7 @@
class GreatestLowerBoundTest extends BoundTestBase {
void test_bottom_function() {
_checkGreatestLowerBound(
- neverStar, functionTypeStar(returnType: voidType), neverStar);
+ neverStar, functionTypeStar(returnType: voidNone), neverStar);
}
void test_bottom_interface() {
@@ -1533,18 +1496,18 @@
void test_bounds_of_top_types_complete() {
// Test every combination of a subset of Tops programatically.
- var futureOrDynamicType = futureOrType(dynamicType);
- var futureOrObjectType = futureOrType(objectType);
- var futureOrVoidType = futureOrType(voidType);
- final futureOrFutureOrDynamicType = futureOrType(futureOrDynamicType);
- final futureOrFutureOrObjectType = futureOrType(futureOrObjectType);
- final futureOrFutureOrVoidType = futureOrType(futureOrVoidType);
+ var futureOrDynamicType = futureOrStar(dynamicType);
+ var futureOrObjectType = futureOrStar(objectStar);
+ var futureOrVoidType = futureOrStar(voidNone);
+ final futureOrFutureOrDynamicType = futureOrStar(futureOrDynamicType);
+ final futureOrFutureOrObjectType = futureOrStar(futureOrObjectType);
+ final futureOrFutureOrVoidType = futureOrStar(futureOrVoidType);
var orderedTops = [
// Lower index, so lower Top
- voidType,
+ voidNone,
dynamicType,
- objectType,
+ objectStar,
futureOrVoidType,
futureOrDynamicType,
futureOrObjectType,
@@ -1575,16 +1538,16 @@
}
void test_bounds_of_top_types_sanity() {
- var futureOrDynamicType = futureOrType(dynamicType);
- final futureOrFutureOrDynamicType = futureOrType(futureOrDynamicType);
+ var futureOrDynamicType = futureOrStar(dynamicType);
+ final futureOrFutureOrDynamicType = futureOrStar(futureOrDynamicType);
// Sanity check specific cases of top for GLB/LUB.
- _checkLeastUpperBound(objectType, dynamicType, dynamicType);
- _checkGreatestLowerBound(objectType, dynamicType, objectType);
- _checkLeastUpperBound(objectType, voidType, voidType);
+ _checkLeastUpperBound(objectStar, dynamicType, dynamicType);
+ _checkGreatestLowerBound(objectStar, dynamicType, objectStar);
+ _checkLeastUpperBound(objectStar, voidNone, voidNone);
_checkLeastUpperBound(futureOrDynamicType, dynamicType, dynamicType);
_checkGreatestLowerBound(
- futureOrDynamicType, objectType, futureOrDynamicType);
+ futureOrDynamicType, objectStar, futureOrDynamicType);
_checkGreatestLowerBound(futureOrDynamicType, futureOrFutureOrDynamicType,
futureOrFutureOrDynamicType);
}
@@ -1624,8 +1587,8 @@
void test_dynamic_function() {
_checkGreatestLowerBound(
dynamicType,
- functionTypeStar(returnType: voidType),
- functionTypeStar(returnType: voidType));
+ functionTypeStar(returnType: voidNone),
+ functionTypeStar(returnType: voidNone));
}
void test_dynamic_interface() {
@@ -1642,31 +1605,31 @@
void test_dynamic_void() {
// Note: _checkGreatestLowerBound tests `GLB(x, y)` as well as `GLB(y, x)`
- _checkGreatestLowerBound(dynamicType, voidType, dynamicType);
+ _checkGreatestLowerBound(dynamicType, voidNone, dynamicType);
}
void test_functionsDifferentNamedTakeUnion() {
var type1 = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: intType),
- namedParameter(name: 'b', type: intType),
+ namedParameter(name: 'a', type: intStar),
+ namedParameter(name: 'b', type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- namedParameter(name: 'b', type: doubleType),
- namedParameter(name: 'c', type: stringType),
+ namedParameter(name: 'b', type: doubleStar),
+ namedParameter(name: 'c', type: stringStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: intType),
- namedParameter(name: 'b', type: numType),
- namedParameter(name: 'c', type: stringType),
+ namedParameter(name: 'a', type: intStar),
+ namedParameter(name: 'b', type: numStar),
+ namedParameter(name: 'c', type: stringStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkGreatestLowerBound(type1, type2, expected);
}
@@ -1674,25 +1637,25 @@
void test_functionsDifferentOptionalArityTakeMax() {
var type1 = functionTypeStar(
parameters: [
- positionalParameter(type: intType),
+ positionalParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- positionalParameter(type: doubleType),
- positionalParameter(type: stringType),
- positionalParameter(type: objectType),
+ positionalParameter(type: doubleStar),
+ positionalParameter(type: stringStar),
+ positionalParameter(type: objectStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
- positionalParameter(type: numType),
- positionalParameter(type: stringType),
- positionalParameter(type: objectType),
+ positionalParameter(type: numStar),
+ positionalParameter(type: stringStar),
+ positionalParameter(type: objectStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkGreatestLowerBound(type1, type2, expected);
}
@@ -1700,25 +1663,25 @@
void test_functionsDifferentRequiredArityBecomeOptional() {
var type1 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- requiredParameter(type: intType),
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- positionalParameter(type: intType),
- positionalParameter(type: intType),
+ requiredParameter(type: intStar),
+ positionalParameter(type: intStar),
+ positionalParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkGreatestLowerBound(type1, type2, expected);
}
@@ -1728,32 +1691,32 @@
parameters: [
requiredParameter(type: dynamicType),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
requiredParameter(type: dynamicType),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkGreatestLowerBound(type1, type2, expected);
}
void test_functionsGlbReturnType() {
var type1 = functionTypeStar(
- returnType: intType,
+ returnType: intStar,
);
var type2 = functionTypeStar(
- returnType: numType,
+ returnType: numStar,
);
var expected = functionTypeStar(
- returnType: intType,
+ returnType: intStar,
);
_checkGreatestLowerBound(type1, type2, expected);
}
@@ -1761,24 +1724,24 @@
void test_functionsLubNamedParams() {
var type1 = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: stringType),
- namedParameter(name: 'b', type: intType),
+ namedParameter(name: 'a', type: stringStar),
+ namedParameter(name: 'b', type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: intType),
- namedParameter(name: 'b', type: numType),
+ namedParameter(name: 'a', type: intStar),
+ namedParameter(name: 'b', type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: objectType),
- namedParameter(name: 'b', type: numType),
+ namedParameter(name: 'a', type: objectStar),
+ namedParameter(name: 'b', type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkGreatestLowerBound(type1, type2, expected);
}
@@ -1786,24 +1749,24 @@
void test_functionsLubPositionalParams() {
var type1 = functionTypeStar(
parameters: [
- positionalParameter(type: stringType),
- positionalParameter(type: intType),
+ positionalParameter(type: stringStar),
+ positionalParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- positionalParameter(type: intType),
- positionalParameter(type: numType),
+ positionalParameter(type: intStar),
+ positionalParameter(type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
- positionalParameter(type: objectType),
- positionalParameter(type: numType),
+ positionalParameter(type: objectStar),
+ positionalParameter(type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkGreatestLowerBound(type1, type2, expected);
}
@@ -1811,27 +1774,27 @@
void test_functionsLubRequiredParams() {
var type1 = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: intType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- requiredParameter(type: doubleType),
- requiredParameter(type: numType),
+ requiredParameter(type: intStar),
+ requiredParameter(type: doubleStar),
+ requiredParameter(type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
- requiredParameter(type: objectType),
- requiredParameter(type: numType),
- requiredParameter(type: numType),
+ requiredParameter(type: objectStar),
+ requiredParameter(type: numStar),
+ requiredParameter(type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkGreatestLowerBound(type1, type2, expected);
}
@@ -1839,31 +1802,31 @@
void test_functionsMixedOptionalAndRequiredBecomeOptional() {
var type1 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- requiredParameter(type: intType),
- positionalParameter(type: intType),
- positionalParameter(type: intType),
- positionalParameter(type: intType),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar),
+ positionalParameter(type: intStar),
+ positionalParameter(type: intStar),
+ positionalParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- positionalParameter(type: intType),
- positionalParameter(type: intType),
+ requiredParameter(type: intStar),
+ positionalParameter(type: intStar),
+ positionalParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- positionalParameter(type: intType),
- positionalParameter(type: intType),
- positionalParameter(type: intType),
- positionalParameter(type: intType),
+ requiredParameter(type: intStar),
+ positionalParameter(type: intStar),
+ positionalParameter(type: intStar),
+ positionalParameter(type: intStar),
+ positionalParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkGreatestLowerBound(type1, type2, expected);
}
@@ -1873,16 +1836,16 @@
// so if we would have synthethized that, pick bottom instead.
var type1 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- namedParameter(name: 'a', type: intType),
+ requiredParameter(type: intStar),
+ namedParameter(name: 'a', type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: intType),
+ namedParameter(name: 'a', type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkGreatestLowerBound(type1, type2, neverStar);
}
@@ -1890,32 +1853,32 @@
void test_functionsSameType_withNamed() {
var type1 = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- namedParameter(name: 'n', type: numType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ namedParameter(name: 'n', type: numStar),
],
- returnType: intType,
+ returnType: intStar,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- namedParameter(name: 'n', type: numType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ namedParameter(name: 'n', type: numStar),
],
- returnType: intType,
+ returnType: intStar,
);
var expected = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- namedParameter(name: 'n', type: numType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ namedParameter(name: 'n', type: numStar),
],
- returnType: intType,
+ returnType: intStar,
);
_checkGreatestLowerBound(type1, type2, expected);
@@ -1924,32 +1887,32 @@
void test_functionsSameType_withOptional() {
var type1 = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- positionalParameter(type: doubleType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ positionalParameter(type: doubleStar),
],
- returnType: intType,
+ returnType: intStar,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- positionalParameter(type: doubleType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ positionalParameter(type: doubleStar),
],
- returnType: intType,
+ returnType: intStar,
);
var expected = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- positionalParameter(type: doubleType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ positionalParameter(type: doubleStar),
],
- returnType: intType,
+ returnType: intStar,
);
_checkGreatestLowerBound(type1, type2, expected);
@@ -1960,7 +1923,7 @@
var typeA = interfaceTypeStar(A);
_checkGreatestLowerBound(
typeA,
- functionTypeStar(returnType: voidType),
+ functionTypeStar(returnType: voidNone),
neverStar,
);
}
@@ -1997,11 +1960,11 @@
List<DartType> types = [
dynamicType,
- voidType,
+ voidNone,
neverStar,
typeParameterTypeStar(T),
interfaceTypeStar(A),
- functionTypeStar(returnType: voidType),
+ functionTypeStar(returnType: voidNone),
];
for (DartType type in types) {
@@ -2013,7 +1976,7 @@
var T = typeParameter('T');
_checkGreatestLowerBound(
typeParameterTypeStar(T),
- functionTypeStar(returnType: voidType),
+ functionTypeStar(returnType: voidNone),
neverStar,
);
}
@@ -2045,15 +2008,15 @@
void test_typeParameters_different() {
// GLB(List<int>, List<double>) = ⊥
- var listOfIntType = listType(intType);
- var listOfDoubleType = listType(doubleType);
+ var listOfIntType = listStar(intStar);
+ var listOfDoubleType = listStar(doubleStar);
// TODO(rnystrom): Can we do something better here?
_checkGreatestLowerBound(listOfIntType, listOfDoubleType, neverStar);
}
void test_typeParameters_same() {
// GLB(List<int>, List<int>) = List<int>
- var listOfIntType = listType(intType);
+ var listOfIntType = listStar(intStar);
_checkGreatestLowerBound(listOfIntType, listOfIntType, listOfIntType);
}
@@ -2072,13 +2035,13 @@
var T = typeParameter('T');
List<DartType> types = [
neverStar,
- functionTypeStar(returnType: voidType),
+ functionTypeStar(returnType: voidNone),
interfaceTypeStar(A),
typeParameterTypeStar(T),
];
for (DartType type in types) {
_checkGreatestLowerBound(
- functionTypeStar(returnType: voidType),
+ functionTypeStar(returnType: voidNone),
functionTypeStar(returnType: type),
functionTypeStar(returnType: type),
);
@@ -2091,18 +2054,18 @@
void test_differentRequiredArity() {
var type1 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- requiredParameter(type: intType),
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkLeastUpperBound(type1, type2, typeProvider.functionType);
}
@@ -2112,19 +2075,19 @@
parameters: [
requiredParameter(type: dynamicType),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkLeastUpperBound(type1, type2, expected);
}
@@ -2132,24 +2095,24 @@
void test_glbNamedParams() {
var type1 = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: stringType),
- namedParameter(name: 'b', type: intType),
+ namedParameter(name: 'a', type: stringStar),
+ namedParameter(name: 'b', type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: intType),
- namedParameter(name: 'b', type: numType),
+ namedParameter(name: 'a', type: intStar),
+ namedParameter(name: 'b', type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
namedParameter(name: 'a', type: neverStar),
- namedParameter(name: 'b', type: intType),
+ namedParameter(name: 'b', type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkLeastUpperBound(type1, type2, expected);
}
@@ -2157,24 +2120,24 @@
void test_glbPositionalParams() {
var type1 = functionTypeStar(
parameters: [
- positionalParameter(type: stringType),
- positionalParameter(type: intType),
+ positionalParameter(type: stringStar),
+ positionalParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- positionalParameter(type: intType),
- positionalParameter(type: numType),
+ positionalParameter(type: intStar),
+ positionalParameter(type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
positionalParameter(type: neverStar),
- positionalParameter(type: intType),
+ positionalParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkLeastUpperBound(type1, type2, expected);
}
@@ -2182,27 +2145,27 @@
void test_glbRequiredParams() {
var type1 = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: intType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- requiredParameter(type: doubleType),
- requiredParameter(type: numType),
+ requiredParameter(type: intStar),
+ requiredParameter(type: doubleStar),
+ requiredParameter(type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
requiredParameter(type: neverStar),
requiredParameter(type: neverStar),
- requiredParameter(type: intType),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkLeastUpperBound(type1, type2, expected);
}
@@ -2210,23 +2173,23 @@
void test_ignoreExtraNamedParams() {
var type1 = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: intType),
- namedParameter(name: 'b', type: intType),
+ namedParameter(name: 'a', type: intStar),
+ namedParameter(name: 'b', type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: intType),
- namedParameter(name: 'c', type: intType),
+ namedParameter(name: 'a', type: intStar),
+ namedParameter(name: 'c', type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
- namedParameter(name: 'a', type: intType),
+ namedParameter(name: 'a', type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkLeastUpperBound(type1, type2, expected);
}
@@ -2234,63 +2197,63 @@
void test_ignoreExtraPositionalParams() {
var type1 = functionTypeStar(
parameters: [
- positionalParameter(type: intType),
- positionalParameter(type: intType),
- positionalParameter(type: stringType),
+ positionalParameter(type: intStar),
+ positionalParameter(type: intStar),
+ positionalParameter(type: stringStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
- positionalParameter(type: intType),
+ positionalParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
- positionalParameter(type: intType),
+ positionalParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkLeastUpperBound(type1, type2, expected);
}
void test_lubReturnType() {
- var type1 = functionTypeStar(returnType: intType);
- var type2 = functionTypeStar(returnType: doubleType);
- var expected = functionTypeStar(returnType: numType);
+ var type1 = functionTypeStar(returnType: intStar);
+ var type2 = functionTypeStar(returnType: doubleStar);
+ var expected = functionTypeStar(returnType: numStar);
_checkLeastUpperBound(type1, type2, expected);
}
void test_sameType_withNamed() {
var type1 = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- namedParameter(name: 'n', type: numType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ namedParameter(name: 'n', type: numStar),
],
- returnType: intType,
+ returnType: intStar,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- namedParameter(name: 'n', type: numType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ namedParameter(name: 'n', type: numStar),
],
- returnType: intType,
+ returnType: intStar,
);
var expected = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- namedParameter(name: 'n', type: numType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ namedParameter(name: 'n', type: numStar),
],
- returnType: intType,
+ returnType: intStar,
);
_checkLeastUpperBound(type1, type2, expected);
@@ -2299,45 +2262,45 @@
void test_sameType_withOptional() {
var type1 = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- positionalParameter(type: doubleType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ positionalParameter(type: doubleStar),
],
- returnType: intType,
+ returnType: intStar,
);
var type2 = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- positionalParameter(type: doubleType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ positionalParameter(type: doubleStar),
],
- returnType: intType,
+ returnType: intStar,
);
var expected = functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: numType),
- positionalParameter(type: doubleType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: numStar),
+ positionalParameter(type: doubleStar),
],
- returnType: intType,
+ returnType: intStar,
);
_checkLeastUpperBound(type1, type2, expected);
}
void test_typeFormals_differentBounds() {
- var T1 = typeParameter('T1', bound: intType);
+ var T1 = typeParameter('T1', bound: intStar);
var type1 = functionTypeStar(
typeFormals: [T1],
returnType: typeParameterTypeStar(T1),
);
- var T2 = typeParameter('T2', bound: doubleType);
+ var T2 = typeParameter('T2', bound: doubleStar);
var type2 = functionTypeStar(
typeFormals: [T2],
returnType: typeParameterTypeStar(T2),
@@ -2347,31 +2310,31 @@
}
void test_typeFormals_differentNumber() {
- var T1 = typeParameter('T1', bound: numType);
+ var T1 = typeParameter('T1', bound: numStar);
var type1 = functionTypeStar(
typeFormals: [T1],
returnType: typeParameterTypeStar(T1),
);
- var type2 = functionTypeStar(returnType: intType);
+ var type2 = functionTypeStar(returnType: intStar);
_checkLeastUpperBound(type1, type2, typeProvider.functionType);
}
void test_typeFormals_sameBounds() {
- var T1 = typeParameter('T1', bound: numType);
+ var T1 = typeParameter('T1', bound: numStar);
var type1 = functionTypeStar(
typeFormals: [T1],
returnType: typeParameterTypeStar(T1),
);
- var T2 = typeParameter('T2', bound: numType);
+ var T2 = typeParameter('T2', bound: numStar);
var type2 = functionTypeStar(
typeFormals: [T2],
returnType: typeParameterTypeStar(T2),
);
- var TE = typeParameter('T', bound: numType);
+ var TE = typeParameter('T', bound: numStar);
var expected = functionTypeStar(
typeFormals: [TE],
returnType: typeParameterTypeStar(TE),
@@ -2383,20 +2346,17 @@
@reflectiveTest
class LeastUpperBoundTest extends BoundTestBase {
- @FailingTest(reason: 'With new rules UP(Never*, T)=T?')
void test_bottom_function() {
- _checkLeastUpperBound(neverStar, functionTypeStar(returnType: voidType),
- functionTypeStar(returnType: voidType));
+ _checkLeastUpperBound(neverStar, functionTypeStar(returnType: voidNone),
+ functionTypeStar(returnType: voidNone));
}
- @FailingTest(reason: 'With new rules UP(Never*, T)=T?')
void test_bottom_interface() {
var A = class_(name: 'A');
var typeA = interfaceTypeStar(A);
_checkLeastUpperBound(neverStar, typeA, typeA);
}
- @FailingTest(reason: 'With new rules UP(Never*, T)=T?')
void test_bottom_typeParam() {
var T = typeParameter('T');
var typeT = typeParameterTypeStar(T);
@@ -2504,7 +2464,7 @@
void test_dynamic_function() {
_checkLeastUpperBound(
- dynamicType, functionTypeStar(returnType: voidType), dynamicType);
+ dynamicType, functionTypeStar(returnType: voidNone), dynamicType);
}
void test_dynamic_interface() {
@@ -2519,13 +2479,13 @@
void test_dynamic_void() {
// Note: _checkLeastUpperBound tests `LUB(x, y)` as well as `LUB(y, x)`
- _checkLeastUpperBound(dynamicType, voidType, voidType);
+ _checkLeastUpperBound(dynamicType, voidNone, voidNone);
}
void test_interface_function() {
var A = class_(name: 'A');
_checkLeastUpperBound(interfaceTypeStar(A),
- functionTypeStar(returnType: voidType), objectType);
+ functionTypeStar(returnType: voidNone), objectStar);
}
void test_interface_sameElement_nullability() {
@@ -2581,7 +2541,7 @@
_checkLeastUpperBound(
interfaceTypeStar(classA),
interfaceTypeStar(mixinM),
- objectType,
+ objectStar,
);
}
@@ -2642,45 +2602,45 @@
requiredParameter(
type: functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: intType),
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar),
],
- returnType: voidType,
+ returnType: voidNone,
),
),
],
- returnType: voidType,
+ returnType: voidNone,
);
var type2 = functionTypeStar(
parameters: [
requiredParameter(
type: functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- requiredParameter(type: doubleType),
- requiredParameter(type: numType),
+ requiredParameter(type: intStar),
+ requiredParameter(type: doubleStar),
+ requiredParameter(type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
),
),
],
- returnType: voidType,
+ returnType: voidNone,
);
var expected = functionTypeStar(
parameters: [
requiredParameter(
type: functionTypeStar(
parameters: [
- requiredParameter(type: objectType),
- requiredParameter(type: numType),
- requiredParameter(type: numType),
+ requiredParameter(type: objectStar),
+ requiredParameter(type: numStar),
+ requiredParameter(type: numStar),
],
- returnType: voidType,
+ returnType: voidNone,
),
),
],
- returnType: voidType,
+ returnType: voidNone,
);
_checkLeastUpperBound(type1, type2, expected);
}
@@ -2694,19 +2654,19 @@
requiredParameter(
type: functionTypeStar(
parameters: [
- requiredParameter(type: stringType),
- requiredParameter(type: intType),
- requiredParameter(type: intType)
+ requiredParameter(type: stringStar),
+ requiredParameter(type: intStar),
+ requiredParameter(type: intStar)
],
- returnType: voidType,
+ returnType: voidNone,
),
),
],
- returnType: voidType,
+ returnType: voidNone,
),
),
],
- returnType: voidType,
+ returnType: voidNone,
);
expect(
type1.toString(withNullability: true),
@@ -2721,19 +2681,19 @@
requiredParameter(
type: functionTypeStar(
parameters: [
- requiredParameter(type: intType),
- requiredParameter(type: doubleType),
- requiredParameter(type: numType)
+ requiredParameter(type: intStar),
+ requiredParameter(type: doubleStar),
+ requiredParameter(type: numStar)
],
- returnType: voidType,
+ returnType: voidNone,
),
),
],
- returnType: voidType,
+ returnType: voidNone,
),
),
],
- returnType: voidType,
+ returnType: voidNone,
);
expect(
type2.toString(withNullability: true),
@@ -2749,17 +2709,17 @@
parameters: [
requiredParameter(type: neverStar),
requiredParameter(type: neverStar),
- requiredParameter(type: intType)
+ requiredParameter(type: intStar)
],
- returnType: voidType,
+ returnType: voidNone,
),
),
],
- returnType: voidType,
+ returnType: voidNone,
),
),
],
- returnType: voidType,
+ returnType: voidNone,
);
expect(
expected.toString(withNullability: true),
@@ -2789,11 +2749,11 @@
List<DartType> types = [
dynamicType,
- voidType,
+ voidNone,
neverStar,
typeParameterTypeStar(T),
interfaceTypeStar(A),
- functionTypeStar(returnType: voidType)
+ functionTypeStar(returnType: voidNone)
];
for (DartType type in types) {
@@ -3034,7 +2994,7 @@
}
void test_twoComparables() {
- _checkLeastUpperBound(stringType, numType, objectType);
+ _checkLeastUpperBound(stringStar, numStar, objectStar);
}
void test_typeParam_boundedByParam() {
@@ -3051,7 +3011,7 @@
var A = class_(name: 'A', superType: typeProvider.functionType);
var T = typeParameter('T', bound: interfaceTypeStar(A));
_checkLeastUpperBound(typeParameterTypeStar(T),
- functionTypeStar(returnType: voidType), objectType);
+ functionTypeStar(returnType: voidNone), objectStar);
}
void test_typeParam_fBounded() {
@@ -3069,7 +3029,7 @@
_checkLeastUpperBound(
typeS,
typeParameterTypeStar(U),
- interfaceTypeStar(A, typeArguments: [objectType]),
+ interfaceTypeStar(A, typeArguments: [objectStar]),
);
}
@@ -3077,7 +3037,7 @@
var T = typeParameter('T', bound: typeProvider.functionType);
_checkLeastUpperBound(
typeParameterTypeStar(T),
- functionTypeStar(returnType: voidType),
+ functionTypeStar(returnType: voidNone),
typeProvider.functionType,
);
}
@@ -3086,8 +3046,8 @@
var T = typeParameter('T');
_checkLeastUpperBound(
typeParameterTypeStar(T),
- functionTypeStar(returnType: voidType),
- objectType,
+ functionTypeStar(returnType: voidNone),
+ objectStar,
);
}
@@ -3113,7 +3073,7 @@
_checkLeastUpperBound(
typeParameterTypeStar(T),
interfaceTypeStar(A),
- objectType,
+ objectStar,
);
}
@@ -3124,8 +3084,8 @@
// A<num>
// A<int>
- var aNum = interfaceTypeStar(A, typeArguments: [numType]);
- var aInt = interfaceTypeStar(A, typeArguments: [intType]);
+ var aNum = interfaceTypeStar(A, typeArguments: [numStar]);
+ var aInt = interfaceTypeStar(A, typeArguments: [intStar]);
_checkLeastUpperBound(aInt, aNum, aInt);
}
@@ -3136,7 +3096,7 @@
var A = class_(name: 'A', typeParameters: [T]);
// A<num>
- var aNum = interfaceTypeStar(A, typeArguments: [numType]);
+ var aNum = interfaceTypeStar(A, typeArguments: [numStar]);
_checkLeastUpperBound(aNum, aNum, aNum);
}
@@ -3148,8 +3108,8 @@
// A<num>
// A<int>
- var aNum = interfaceTypeStar(A, typeArguments: [numType]);
- var aInt = interfaceTypeStar(A, typeArguments: [intType]);
+ var aNum = interfaceTypeStar(A, typeArguments: [numStar]);
+ var aInt = interfaceTypeStar(A, typeArguments: [intStar]);
_checkLeastUpperBound(aInt, aNum, aNum);
}
@@ -3160,7 +3120,7 @@
var A = class_(name: 'A', typeParameters: [T]);
// A<num>
- var aNum = interfaceTypeStar(A, typeArguments: [numType]);
+ var aNum = interfaceTypeStar(A, typeArguments: [numStar]);
_checkLeastUpperBound(aNum, aNum, aNum);
}
@@ -3169,9 +3129,9 @@
void test_typeParameters_different() {
// class List<int>
// class List<double>
- var listOfIntType = listType(intType);
- var listOfDoubleType = listType(doubleType);
- var listOfNum = listType(numType);
+ var listOfIntType = listStar(intStar);
+ var listOfDoubleType = listStar(doubleStar);
+ var listOfNum = listStar(numStar);
_checkLeastUpperBound(listOfIntType, listOfDoubleType, listOfNum);
}
@@ -3182,10 +3142,10 @@
// A<num>
// A<int>
- var aNum = interfaceTypeStar(A, typeArguments: [numType]);
- var aInt = interfaceTypeStar(A, typeArguments: [intType]);
+ var aNum = interfaceTypeStar(A, typeArguments: [numStar]);
+ var aInt = interfaceTypeStar(A, typeArguments: [intStar]);
- _checkLeastUpperBound(aNum, aInt, objectType);
+ _checkLeastUpperBound(aNum, aInt, objectStar);
}
void test_typeParameters_invariant_same() {
@@ -3194,7 +3154,7 @@
var A = class_(name: 'A', typeParameters: [T]);
// A<num>
- var aNum = interfaceTypeStar(A, typeArguments: [numType]);
+ var aNum = interfaceTypeStar(A, typeArguments: [numStar]);
_checkLeastUpperBound(aNum, aNum, aNum);
}
@@ -3209,13 +3169,13 @@
// Multi<num, num, num>
// Multi<int, num, int>
var multiNumNumNum =
- interfaceTypeStar(Multi, typeArguments: [numType, numType, numType]);
+ interfaceTypeStar(Multi, typeArguments: [numStar, numStar, numStar]);
var multiIntNumInt =
- interfaceTypeStar(Multi, typeArguments: [intType, numType, intType]);
+ interfaceTypeStar(Multi, typeArguments: [intStar, numStar, intStar]);
// We expect Multi<num, num, int>
var multiNumNumInt =
- interfaceTypeStar(Multi, typeArguments: [numType, numType, intType]);
+ interfaceTypeStar(Multi, typeArguments: [numStar, numStar, intStar]);
_checkLeastUpperBound(multiNumNumNum, multiIntNumInt, multiNumNumInt);
}
@@ -3230,11 +3190,11 @@
// Multi<num, String, num>
// Multi<int, num, int>
var multiNumStringNum =
- interfaceTypeStar(Multi, typeArguments: [numType, stringType, numType]);
+ interfaceTypeStar(Multi, typeArguments: [numStar, stringStar, numStar]);
var multiIntNumInt =
- interfaceTypeStar(Multi, typeArguments: [intType, numType, intType]);
+ interfaceTypeStar(Multi, typeArguments: [intStar, numStar, intStar]);
- _checkLeastUpperBound(multiNumStringNum, multiIntNumInt, objectType);
+ _checkLeastUpperBound(multiNumStringNum, multiIntNumInt, objectStar);
}
void test_typeParameters_multi_objectType() {
@@ -3247,13 +3207,13 @@
// Multi<String, num, num>
// Multi<int, num, int>
var multiStringNumNum =
- interfaceTypeStar(Multi, typeArguments: [stringType, numType, numType]);
+ interfaceTypeStar(Multi, typeArguments: [stringStar, numStar, numStar]);
var multiIntNumInt =
- interfaceTypeStar(Multi, typeArguments: [intType, numType, intType]);
+ interfaceTypeStar(Multi, typeArguments: [intStar, numStar, intStar]);
// We expect Multi<Object, num, int>
var multiObjectNumInt =
- interfaceTypeStar(Multi, typeArguments: [objectType, numType, intType]);
+ interfaceTypeStar(Multi, typeArguments: [objectStar, numStar, intStar]);
_checkLeastUpperBound(multiStringNumNum, multiIntNumInt, multiObjectNumInt);
}
@@ -3261,7 +3221,7 @@
void test_typeParameters_same() {
// List<int>
// List<int>
- var listOfIntType = listType(intType);
+ var listOfIntType = listStar(intStar);
_checkLeastUpperBound(listOfIntType, listOfIntType, listOfIntType);
}
@@ -3270,10 +3230,10 @@
void test_typeParametersAndClass_different() {
// class List<int>
// class Iterable<double>
- var listOfIntType = listType(intType);
- var iterableOfDoubleType = iterableType(doubleType);
+ var listOfIntType = listStar(intStar);
+ var iterableOfDoubleType = iterableStar(doubleStar);
// TODO(leafp): this should be iterableOfNumType
- _checkLeastUpperBound(listOfIntType, iterableOfDoubleType, objectType);
+ _checkLeastUpperBound(listOfIntType, iterableOfDoubleType, objectStar);
}
void test_void() {
@@ -3281,15 +3241,15 @@
var A = class_(name: 'A');
List<DartType> types = [
neverStar,
- functionTypeStar(returnType: voidType),
+ functionTypeStar(returnType: voidNone),
interfaceTypeStar(A),
typeParameterTypeStar(T),
];
for (DartType type in types) {
_checkLeastUpperBound(
- functionTypeStar(returnType: voidType),
+ functionTypeStar(returnType: voidNone),
functionTypeStar(returnType: type),
- functionTypeStar(returnType: voidType),
+ functionTypeStar(returnType: voidNone),
);
}
}
@@ -3320,19 +3280,19 @@
FunctionTypeImpl get nothingToVoidFunctionTypeNone {
return functionTypeNone(
- returnType: voidType,
+ returnType: voidNone,
);
}
FunctionTypeImpl get nothingToVoidFunctionTypeQuestion {
return functionTypeQuestion(
- returnType: voidType,
+ returnType: voidNone,
);
}
FunctionTypeImpl get nothingToVoidFunctionTypeStar {
return functionTypeStar(
- returnType: voidType,
+ returnType: voidNone,
);
}
@@ -3537,7 +3497,7 @@
}
test_isNonNullable_null() {
- expect(typeSystem.isNonNullable(nullType), false);
+ expect(typeSystem.isNonNullable(nullStar), false);
}
test_isNonNullable_typeParameter_noneBound_none() {
@@ -3586,7 +3546,7 @@
}
test_isNonNullable_void() {
- expect(typeSystem.isNonNullable(voidType), false);
+ expect(typeSystem.isNonNullable(voidNone), false);
}
test_isNullable_dynamic() {
@@ -3719,7 +3679,7 @@
}
test_isNullable_null() {
- expect(typeSystem.isNullable(nullType), true);
+ expect(typeSystem.isNullable(nullStar), true);
}
test_isNullable_typeParameter_noneBound_none() {
@@ -3768,7 +3728,7 @@
}
test_isNullable_void() {
- expect(typeSystem.isNullable(voidType), true);
+ expect(typeSystem.isNullable(voidNone), true);
}
test_isPotentiallyNonNullable_dynamic() {
@@ -3811,7 +3771,7 @@
}
test_isPotentiallyNonNullable_null() {
- expect(typeSystem.isPotentiallyNonNullable(nullType), false);
+ expect(typeSystem.isPotentiallyNonNullable(nullStar), false);
}
test_isPotentiallyNonNullable_question() {
@@ -3823,7 +3783,7 @@
}
test_isPotentiallyNonNullable_void() {
- expect(typeSystem.isPotentiallyNonNullable(voidType), false);
+ expect(typeSystem.isPotentiallyNonNullable(voidNone), false);
}
test_isPotentiallyNullable_dynamic() {
@@ -3866,7 +3826,7 @@
}
test_isPotentiallyNullable_null() {
- expect(typeSystem.isPotentiallyNullable(nullType), true);
+ expect(typeSystem.isPotentiallyNullable(nullStar), true);
}
test_isPotentiallyNullable_question() {
@@ -3878,7 +3838,7 @@
}
test_isPotentiallyNullable_void() {
- expect(typeSystem.isPotentiallyNullable(voidType), true);
+ expect(typeSystem.isPotentiallyNullable(voidNone), true);
}
test_promoteToNonNull_dynamic() {
@@ -3950,7 +3910,7 @@
}
test_promoteToNonNull_null() {
- expect(typeSystem.promoteToNonNull(nullType), neverNone);
+ expect(typeSystem.promoteToNonNull(nullStar), neverNone);
}
test_promoteToNonNull_typeParameter_noneBound_none() {
@@ -4026,8 +3986,8 @@
test_promoteToNonNull_void() {
expect(
- typeSystem.promoteToNonNull(voidType),
- voidType,
+ typeSystem.promoteToNonNull(voidNone),
+ voidNone,
);
}
diff --git a/pkg/analyzer/test/generated/utilities_test.dart b/pkg/analyzer/test/generated/utilities_test.dart
index eb0cec2..d1df912 100644
--- a/pkg/analyzer/test/generated/utilities_test.dart
+++ b/pkg/analyzer/test/generated/utilities_test.dart
@@ -1127,16 +1127,16 @@
*/
void _assertClone(AstNode node) {
{
- AstNode clone = node.accept(new AstCloner());
- AstCloneComparator comparator = new AstCloneComparator(false);
+ AstNode clone = node.accept(AstCloner());
+ AstCloneComparator comparator = AstCloneComparator(false);
if (!comparator.isEqualNodes(node, clone)) {
fail("Failed to clone ${node.runtimeType.toString()}");
}
_assertEqualTokens(clone, node);
}
{
- AstNode clone = node.accept(new AstCloner(true));
- AstCloneComparator comparator = new AstCloneComparator(true);
+ AstNode clone = node.accept(AstCloner(true));
+ AstCloneComparator comparator = AstCloneComparator(true);
if (!comparator.isEqualNodes(node, clone)) {
fail("Failed to clone ${node.runtimeType.toString()}");
}
@@ -1178,14 +1178,14 @@
}
CompilationUnit _parseUnit(String code) {
- GatheringErrorListener listener = new GatheringErrorListener();
- CharSequenceReader reader = new CharSequenceReader(code);
+ GatheringErrorListener listener = GatheringErrorListener();
+ CharSequenceReader reader = CharSequenceReader(code);
var featureSet = FeatureSet.forTesting(sdkVersion: '2.2.2');
- Scanner scanner = new Scanner(null, reader, listener)
+ Scanner scanner = Scanner(null, reader, listener)
..configureFeatures(featureSet);
Token token = scanner.tokenize();
Parser parser =
- new Parser(NonExistingSource.unknown, listener, featureSet: featureSet);
+ Parser(NonExistingSource.unknown, listener, featureSet: featureSet);
CompilationUnit unit = parser.parseCompilationUnit(token);
expect(unit, isNotNull);
listener.assertNoErrors();
@@ -1237,7 +1237,7 @@
}
// next tokens
if (original is CommentToken) {
- expect(clone, new TypeMatcher<CommentToken>());
+ expect(clone, TypeMatcher<CommentToken>());
skipOriginalComment = original;
skipCloneComment = clone;
original = (original as CommentToken).parent;
@@ -1333,9 +1333,9 @@
@reflectiveTest
class ExceptionHandlingDelegatingAstVisitorTest {
void test_handlerIsCalled() {
- AstVisitor exceptionThrowingVisitor = new _ExceptionThrowingVisitor();
+ AstVisitor exceptionThrowingVisitor = _ExceptionThrowingVisitor();
bool handlerInvoked = false;
- AstVisitor visitor = new ExceptionHandlingDelegatingAstVisitor(
+ AstVisitor visitor = ExceptionHandlingDelegatingAstVisitor(
[exceptionThrowingVisitor], (AstNode node, AstVisitor visitor,
dynamic exception, StackTrace stackTrace) {
handlerInvoked = true;
@@ -2275,51 +2275,51 @@
@reflectiveTest
class LineInfoTest {
void test_creation() {
- expect(new LineInfo(<int>[0]), isNotNull);
+ expect(LineInfo(<int>[0]), isNotNull);
}
void test_creation_empty() {
expect(() {
- new LineInfo(<int>[]);
+ LineInfo(<int>[]);
}, throwsArgumentError);
}
void test_creation_null() {
expect(() {
- new LineInfo(null);
+ LineInfo(null);
}, throwsArgumentError);
}
void test_getLocation_firstLine() {
- LineInfo info = new LineInfo(<int>[0, 12, 34]);
+ LineInfo info = LineInfo(<int>[0, 12, 34]);
CharacterLocation location = info.getLocation(4);
expect(location.lineNumber, 1);
expect(location.columnNumber, 5);
}
void test_getLocation_lastLine() {
- LineInfo info = new LineInfo(<int>[0, 12, 34]);
+ LineInfo info = LineInfo(<int>[0, 12, 34]);
CharacterLocation location = info.getLocation(36);
expect(location.lineNumber, 3);
expect(location.columnNumber, 3);
}
void test_getLocation_middleLine() {
- LineInfo info = new LineInfo(<int>[0, 12, 34]);
+ LineInfo info = LineInfo(<int>[0, 12, 34]);
CharacterLocation location = info.getLocation(12);
expect(location.lineNumber, 2);
expect(location.columnNumber, 1);
}
void test_getOffsetOfLine() {
- LineInfo info = new LineInfo(<int>[0, 12, 34]);
+ LineInfo info = LineInfo(<int>[0, 12, 34]);
expect(0, info.getOffsetOfLine(0));
expect(12, info.getOffsetOfLine(1));
expect(34, info.getOffsetOfLine(2));
}
void test_getOffsetOfLineAfter() {
- LineInfo info = new LineInfo(<int>[0, 12, 34]);
+ LineInfo info = LineInfo(<int>[0, 12, 34]);
expect(info.getOffsetOfLineAfter(0), 12);
expect(info.getOffsetOfLineAfter(11), 12);
@@ -2611,10 +2611,8 @@
void test_adjacentStrings() {
AdjacentStrings node = AstTestFactory.adjacentStrings(
[AstTestFactory.string2("a"), AstTestFactory.string2("b")]);
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_adjacentStrings_2(0));
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_adjacentStrings(1));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_adjacentStrings_2(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_adjacentStrings(1));
}
void test_annotation() {
@@ -2622,15 +2620,15 @@
AstTestFactory.identifier3("C"),
AstTestFactory.identifier3("c"),
AstTestFactory.argumentList([AstTestFactory.integer(0)]));
- _assertReplace(node, new Getter_NodeReplacerTest_test_annotation());
- _assertReplace(node, new Getter_NodeReplacerTest_test_annotation_3());
- _assertReplace(node, new Getter_NodeReplacerTest_test_annotation_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_annotation());
+ _assertReplace(node, Getter_NodeReplacerTest_test_annotation_3());
+ _assertReplace(node, Getter_NodeReplacerTest_test_annotation_2());
}
void test_argumentList() {
ArgumentList node =
AstTestFactory.argumentList([AstTestFactory.integer(0)]);
- _assertReplace(node, new ListGetter_NodeReplacerTest_test_argumentList(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_argumentList(0));
}
void test_asExpression() {
@@ -2638,15 +2636,15 @@
AstTestFactory.integer(0),
AstTestFactory.typeName3(
AstTestFactory.identifier3("a"), [AstTestFactory.typeName4("C")]));
- _assertReplace(node, new Getter_NodeReplacerTest_test_asExpression_2());
- _assertReplace(node, new Getter_NodeReplacerTest_test_asExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_asExpression_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_asExpression());
}
void test_assertStatement() {
AssertStatement node = AstTestFactory.assertStatement(
AstTestFactory.booleanLiteral(true), AstTestFactory.string2('foo'));
- _assertReplace(node, new Getter_NodeReplacerTest_test_assertStatement());
- _assertReplace(node, new Getter_NodeReplacerTest_test_assertStatement_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_assertStatement());
+ _assertReplace(node, Getter_NodeReplacerTest_test_assertStatement_2());
}
void test_assignmentExpression() {
@@ -2654,15 +2652,13 @@
AstTestFactory.identifier3("l"),
TokenType.EQ,
AstTestFactory.identifier3("r"));
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_assignmentExpression_2());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_assignmentExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_assignmentExpression_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_assignmentExpression());
}
void test_awaitExpression() {
var node = AstTestFactory.awaitExpression(AstTestFactory.identifier3("A"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_awaitExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_awaitExpression());
}
void test_binaryExpression() {
@@ -2670,33 +2666,32 @@
AstTestFactory.identifier3("l"),
TokenType.PLUS,
AstTestFactory.identifier3("r"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_binaryExpression());
- _assertReplace(node, new Getter_NodeReplacerTest_test_binaryExpression_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_binaryExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_binaryExpression_2());
}
void test_block() {
Block node = AstTestFactory.block([AstTestFactory.emptyStatement()]);
- _assertReplace(node, new ListGetter_NodeReplacerTest_test_block(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_block(0));
}
void test_blockFunctionBody() {
BlockFunctionBody node =
AstTestFactory.blockFunctionBody(AstTestFactory.block());
- _assertReplace(node, new Getter_NodeReplacerTest_test_blockFunctionBody());
+ _assertReplace(node, Getter_NodeReplacerTest_test_blockFunctionBody());
}
void test_breakStatement() {
BreakStatement node = AstTestFactory.breakStatement2("l");
- _assertReplace(node, new Getter_NodeReplacerTest_test_breakStatement());
+ _assertReplace(node, Getter_NodeReplacerTest_test_breakStatement());
}
void test_cascadeExpression() {
CascadeExpression node = AstTestFactory.cascadeExpression(
AstTestFactory.integer(0),
[AstTestFactory.propertyAccess(null, AstTestFactory.identifier3("b"))]);
- _assertReplace(node, new Getter_NodeReplacerTest_test_cascadeExpression());
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_cascadeExpression(0));
+ _assertReplace(node, Getter_NodeReplacerTest_test_cascadeExpression());
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_cascadeExpression(0));
}
void test_catchClause() {
@@ -2705,9 +2700,9 @@
"e",
"s",
[AstTestFactory.emptyStatement()]);
- _assertReplace(node, new Getter_NodeReplacerTest_test_catchClause_3());
- _assertReplace(node, new Getter_NodeReplacerTest_test_catchClause_2());
- _assertReplace(node, new Getter_NodeReplacerTest_test_catchClause());
+ _assertReplace(node, Getter_NodeReplacerTest_test_catchClause_3());
+ _assertReplace(node, Getter_NodeReplacerTest_test_catchClause_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_catchClause());
}
void test_classDeclaration() {
@@ -2725,14 +2720,13 @@
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
node.nativeClause = AstTestFactory.nativeClause("");
- _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_6());
- _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_5());
- _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_4());
- _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_2());
- _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration());
- _assertReplace(node, new Getter_NodeReplacerTest_test_classDeclaration_3());
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_classDeclaration(0));
+ _assertReplace(node, Getter_NodeReplacerTest_test_classDeclaration_6());
+ _assertReplace(node, Getter_NodeReplacerTest_test_classDeclaration_5());
+ _assertReplace(node, Getter_NodeReplacerTest_test_classDeclaration_4());
+ _assertReplace(node, Getter_NodeReplacerTest_test_classDeclaration_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_classDeclaration());
+ _assertReplace(node, Getter_NodeReplacerTest_test_classDeclaration_3());
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_classDeclaration(0));
_testAnnotatedNode(node);
}
@@ -2747,11 +2741,11 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(node, new Getter_NodeReplacerTest_test_classTypeAlias_4());
- _assertReplace(node, new Getter_NodeReplacerTest_test_classTypeAlias_5());
- _assertReplace(node, new Getter_NodeReplacerTest_test_classTypeAlias());
- _assertReplace(node, new Getter_NodeReplacerTest_test_classTypeAlias_3());
- _assertReplace(node, new Getter_NodeReplacerTest_test_classTypeAlias_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_classTypeAlias_4());
+ _assertReplace(node, Getter_NodeReplacerTest_test_classTypeAlias_5());
+ _assertReplace(node, Getter_NodeReplacerTest_test_classTypeAlias());
+ _assertReplace(node, Getter_NodeReplacerTest_test_classTypeAlias_3());
+ _assertReplace(node, Getter_NodeReplacerTest_test_classTypeAlias_2());
_testAnnotatedNode(node);
}
@@ -2759,13 +2753,13 @@
Comment node = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.references.add(
astFactory.commentReference(null, AstTestFactory.identifier3("x")));
- _assertReplace(node, new ListGetter_NodeReplacerTest_test_comment(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_comment(0));
}
void test_commentReference() {
CommentReference node =
astFactory.commentReference(null, AstTestFactory.identifier3("x"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_commentReference());
+ _assertReplace(node, Getter_NodeReplacerTest_test_commentReference());
}
void test_compilationUnit() {
@@ -2775,11 +2769,9 @@
AstTestFactory.topLevelVariableDeclaration2(
null, [AstTestFactory.variableDeclaration("X")])
]);
- _assertReplace(node, new Getter_NodeReplacerTest_test_compilationUnit());
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_compilationUnit(0));
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_compilationUnit_2(0));
+ _assertReplace(node, Getter_NodeReplacerTest_test_compilationUnit());
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_compilationUnit(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_compilationUnit_2(0));
}
void test_conditionalExpression() {
@@ -2788,11 +2780,10 @@
AstTestFactory.integer(0),
AstTestFactory.integer(1));
_assertReplace(
- node, new Getter_NodeReplacerTest_test_conditionalExpression_3());
+ node, Getter_NodeReplacerTest_test_conditionalExpression_3());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_conditionalExpression_2());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_conditionalExpression());
+ node, Getter_NodeReplacerTest_test_conditionalExpression_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_conditionalExpression());
}
void test_constructorDeclaration() {
@@ -2813,17 +2804,16 @@
node.redirectedConstructor =
AstTestFactory.constructorName(AstTestFactory.typeName4("B"), "a");
_assertReplace(
- node, new Getter_NodeReplacerTest_test_constructorDeclaration_3());
+ node, Getter_NodeReplacerTest_test_constructorDeclaration_3());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_constructorDeclaration_2());
+ node, Getter_NodeReplacerTest_test_constructorDeclaration_2());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_constructorDeclaration_4());
+ node, Getter_NodeReplacerTest_test_constructorDeclaration_4());
+ _assertReplace(node, Getter_NodeReplacerTest_test_constructorDeclaration());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_constructorDeclaration());
+ node, Getter_NodeReplacerTest_test_constructorDeclaration_5());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_constructorDeclaration_5());
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_constructorDeclaration(0));
+ node, ListGetter_NodeReplacerTest_test_constructorDeclaration(0));
_testAnnotatedNode(node);
}
@@ -2832,21 +2822,21 @@
AstTestFactory.constructorFieldInitializer(
false, "f", AstTestFactory.integer(0));
_assertReplace(
- node, new Getter_NodeReplacerTest_test_constructorFieldInitializer());
+ node, Getter_NodeReplacerTest_test_constructorFieldInitializer());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_constructorFieldInitializer_2());
+ node, Getter_NodeReplacerTest_test_constructorFieldInitializer_2());
}
void test_constructorName() {
ConstructorName node =
AstTestFactory.constructorName(AstTestFactory.typeName4("C"), "n");
- _assertReplace(node, new Getter_NodeReplacerTest_test_constructorName());
- _assertReplace(node, new Getter_NodeReplacerTest_test_constructorName_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_constructorName());
+ _assertReplace(node, Getter_NodeReplacerTest_test_constructorName_2());
}
void test_continueStatement() {
ContinueStatement node = AstTestFactory.continueStatement("l");
- _assertReplace(node, new Getter_NodeReplacerTest_test_continueStatement());
+ _assertReplace(node, Getter_NodeReplacerTest_test_continueStatement());
}
void test_declaredIdentifier() {
@@ -2855,26 +2845,24 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(node, new Getter_NodeReplacerTest_test_declaredIdentifier());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_declaredIdentifier_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_declaredIdentifier());
+ _assertReplace(node, Getter_NodeReplacerTest_test_declaredIdentifier_2());
_testAnnotatedNode(node);
}
void test_defaultFormalParameter() {
DefaultFormalParameter node = AstTestFactory.positionalFormalParameter(
AstTestFactory.simpleFormalParameter3("p"), AstTestFactory.integer(0));
+ _assertReplace(node, Getter_NodeReplacerTest_test_defaultFormalParameter());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_defaultFormalParameter());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_defaultFormalParameter_2());
+ node, Getter_NodeReplacerTest_test_defaultFormalParameter_2());
}
void test_doStatement() {
DoStatement node = AstTestFactory.doStatement(
AstTestFactory.block(), AstTestFactory.booleanLiteral(true));
- _assertReplace(node, new Getter_NodeReplacerTest_test_doStatement_2());
- _assertReplace(node, new Getter_NodeReplacerTest_test_doStatement());
+ _assertReplace(node, Getter_NodeReplacerTest_test_doStatement_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_doStatement());
}
void test_enumConstantDeclaration() {
@@ -2883,7 +2871,7 @@
[AstTestFactory.annotation(AstTestFactory.identifier3("a"))],
AstTestFactory.identifier3("C"));
_assertReplace(
- node, new Getter_NodeReplacerTest_test_enumConstantDeclaration());
+ node, Getter_NodeReplacerTest_test_enumConstantDeclaration());
_testAnnotatedNode(node);
}
@@ -2892,7 +2880,7 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(node, new Getter_NodeReplacerTest_test_enumDeclaration());
+ _assertReplace(node, Getter_NodeReplacerTest_test_enumDeclaration());
_testAnnotatedNode(node);
}
@@ -2909,21 +2897,19 @@
void test_expressionFunctionBody() {
ExpressionFunctionBody node =
AstTestFactory.expressionFunctionBody(AstTestFactory.integer(0));
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_expressionFunctionBody());
+ _assertReplace(node, Getter_NodeReplacerTest_test_expressionFunctionBody());
}
void test_expressionStatement() {
ExpressionStatement node =
AstTestFactory.expressionStatement(AstTestFactory.integer(0));
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_expressionStatement());
+ _assertReplace(node, Getter_NodeReplacerTest_test_expressionStatement());
}
void test_extendsClause() {
ExtendsClause node =
AstTestFactory.extendsClause(AstTestFactory.typeName4("S"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_extendsClause());
+ _assertReplace(node, Getter_NodeReplacerTest_test_extendsClause());
}
void test_fieldDeclaration() {
@@ -2935,7 +2921,7 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(node, new Getter_NodeReplacerTest_test_fieldDeclaration());
+ _assertReplace(node, Getter_NodeReplacerTest_test_fieldDeclaration());
_testAnnotatedNode(node);
}
@@ -2949,10 +2935,8 @@
node.metadata = [
AstTestFactory.annotation(AstTestFactory.identifier3("a"))
];
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_fieldFormalParameter_2());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_fieldFormalParameter());
+ _assertReplace(node, Getter_NodeReplacerTest_test_fieldFormalParameter_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_fieldFormalParameter());
_testNormalFormalParameter(node);
}
@@ -2961,12 +2945,12 @@
AstTestFactory.forEachPartsWithIdentifier(
AstTestFactory.identifier3("i"), AstTestFactory.identifier3("l")),
AstTestFactory.block());
- _assertReplace(node,
- new Getter_NodeReplacerTest_test_forEachStatement_withIdentifier_2());
- _assertReplace(node,
- new Getter_NodeReplacerTest_test_forEachStatement_withIdentifier_3());
- _assertReplace(node,
- new Getter_NodeReplacerTest_test_forEachStatement_withIdentifier());
+ _assertReplace(
+ node, Getter_NodeReplacerTest_test_forEachStatement_withIdentifier_2());
+ _assertReplace(
+ node, Getter_NodeReplacerTest_test_forEachStatement_withIdentifier_3());
+ _assertReplace(
+ node, Getter_NodeReplacerTest_test_forEachStatement_withIdentifier());
}
void test_forEachStatement_withLoopVariable() {
@@ -2976,18 +2960,18 @@
AstTestFactory.identifier3("l")),
AstTestFactory.block());
_assertReplace(node,
- new Getter_NodeReplacerTest_test_forEachStatement_withLoopVariable_2());
+ Getter_NodeReplacerTest_test_forEachStatement_withLoopVariable_2());
+ _assertReplace(
+ node, Getter_NodeReplacerTest_test_forEachStatement_withLoopVariable());
_assertReplace(node,
- new Getter_NodeReplacerTest_test_forEachStatement_withLoopVariable());
- _assertReplace(node,
- new Getter_NodeReplacerTest_test_forEachStatement_withLoopVariable_3());
+ Getter_NodeReplacerTest_test_forEachStatement_withLoopVariable_3());
}
void test_formalParameterList() {
FormalParameterList node = AstTestFactory.formalParameterList(
[AstTestFactory.simpleFormalParameter3("p")]);
_assertReplace(
- node, new ListGetter_NodeReplacerTest_test_formalParameterList(0));
+ node, ListGetter_NodeReplacerTest_test_formalParameterList(0));
}
void test_forStatement_withInitialization() {
@@ -2995,16 +2979,14 @@
AstTestFactory.forPartsWithExpression(AstTestFactory.identifier3("a"),
AstTestFactory.booleanLiteral(true), [AstTestFactory.integer(0)]),
AstTestFactory.block());
- _assertReplace(node,
- new Getter_NodeReplacerTest_test_forStatement_withInitialization_3());
- _assertReplace(node,
- new Getter_NodeReplacerTest_test_forStatement_withInitialization_2());
- _assertReplace(node,
- new Getter_NodeReplacerTest_test_forStatement_withInitialization());
_assertReplace(
- node,
- new ListGetter_NodeReplacerTest_test_forStatement_withInitialization(
- 0));
+ node, Getter_NodeReplacerTest_test_forStatement_withInitialization_3());
+ _assertReplace(
+ node, Getter_NodeReplacerTest_test_forStatement_withInitialization_2());
+ _assertReplace(
+ node, Getter_NodeReplacerTest_test_forStatement_withInitialization());
+ _assertReplace(node,
+ ListGetter_NodeReplacerTest_test_forStatement_withInitialization(0));
}
void test_forStatement_withVariables() {
@@ -3016,13 +2998,13 @@
[AstTestFactory.integer(0)]),
AstTestFactory.block());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_forStatement_withVariables_2());
+ node, Getter_NodeReplacerTest_test_forStatement_withVariables_2());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_forStatement_withVariables_3());
+ node, Getter_NodeReplacerTest_test_forStatement_withVariables_3());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_forStatement_withVariables());
- _assertReplace(node,
- new ListGetter_NodeReplacerTest_test_forStatement_withVariables(0));
+ node, Getter_NodeReplacerTest_test_forStatement_withVariables());
+ _assertReplace(
+ node, ListGetter_NodeReplacerTest_test_forStatement_withVariables(0));
}
void test_functionDeclaration() {
@@ -3035,12 +3017,9 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_functionDeclaration());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_functionDeclaration_3());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_functionDeclaration_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_functionDeclaration());
+ _assertReplace(node, Getter_NodeReplacerTest_test_functionDeclaration_3());
+ _assertReplace(node, Getter_NodeReplacerTest_test_functionDeclaration_2());
_testAnnotatedNode(node);
}
@@ -3054,16 +3033,15 @@
AstTestFactory.formalParameterList(),
AstTestFactory.blockFunctionBody(AstTestFactory.block())));
_assertReplace(
- node, new Getter_NodeReplacerTest_test_functionDeclarationStatement());
+ node, Getter_NodeReplacerTest_test_functionDeclarationStatement());
}
void test_functionExpression() {
FunctionExpression node = AstTestFactory.functionExpression2(
AstTestFactory.formalParameterList(),
AstTestFactory.blockFunctionBody(AstTestFactory.block()));
- _assertReplace(node, new Getter_NodeReplacerTest_test_functionExpression());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_functionExpression_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_functionExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_functionExpression_2());
}
void test_functionExpressionInvocation() {
@@ -3071,9 +3049,9 @@
AstTestFactory.functionExpressionInvocation(
AstTestFactory.identifier3("f"), [AstTestFactory.integer(0)]);
_assertReplace(
- node, new Getter_NodeReplacerTest_test_functionExpressionInvocation());
- _assertReplace(node,
- new Getter_NodeReplacerTest_test_functionExpressionInvocation_2());
+ node, Getter_NodeReplacerTest_test_functionExpressionInvocation());
+ _assertReplace(
+ node, Getter_NodeReplacerTest_test_functionExpressionInvocation_2());
}
void test_functionTypeAlias() {
@@ -3085,13 +3063,10 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_functionTypeAlias_3());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_functionTypeAlias_4());
- _assertReplace(node, new Getter_NodeReplacerTest_test_functionTypeAlias());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_functionTypeAlias_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_functionTypeAlias_3());
+ _assertReplace(node, Getter_NodeReplacerTest_test_functionTypeAlias_4());
+ _assertReplace(node, Getter_NodeReplacerTest_test_functionTypeAlias());
+ _assertReplace(node, Getter_NodeReplacerTest_test_functionTypeAlias_2());
_testAnnotatedNode(node);
}
@@ -3106,16 +3081,15 @@
AstTestFactory.annotation(AstTestFactory.identifier3("a"))
];
_assertReplace(
- node, new Getter_NodeReplacerTest_test_functionTypedFormalParameter());
- _assertReplace(node,
- new Getter_NodeReplacerTest_test_functionTypedFormalParameter_2());
+ node, Getter_NodeReplacerTest_test_functionTypedFormalParameter());
+ _assertReplace(
+ node, Getter_NodeReplacerTest_test_functionTypedFormalParameter_2());
_testNormalFormalParameter(node);
}
void test_hideCombinator() {
HideCombinator node = AstTestFactory.hideCombinator2(["A", "B"]);
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_hideCombinator(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_hideCombinator(0));
}
void test_ifStatement() {
@@ -3123,16 +3097,15 @@
AstTestFactory.booleanLiteral(true),
AstTestFactory.block(),
AstTestFactory.block());
- _assertReplace(node, new Getter_NodeReplacerTest_test_ifStatement());
- _assertReplace(node, new Getter_NodeReplacerTest_test_ifStatement_3());
- _assertReplace(node, new Getter_NodeReplacerTest_test_ifStatement_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_ifStatement());
+ _assertReplace(node, Getter_NodeReplacerTest_test_ifStatement_3());
+ _assertReplace(node, Getter_NodeReplacerTest_test_ifStatement_2());
}
void test_implementsClause() {
ImplementsClause node = AstTestFactory.implementsClause(
[AstTestFactory.typeName4("I"), AstTestFactory.typeName4("J")]);
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_implementsClause(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_implementsClause(0));
}
void test_importDirective() {
@@ -3143,15 +3116,15 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(node, new Getter_NodeReplacerTest_test_importDirective());
+ _assertReplace(node, Getter_NodeReplacerTest_test_importDirective());
_testNamespaceDirective(node);
}
void test_indexExpression() {
IndexExpression node = AstTestFactory.indexExpression(
AstTestFactory.identifier3("a"), AstTestFactory.identifier3("i"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_indexExpression());
- _assertReplace(node, new Getter_NodeReplacerTest_test_indexExpression_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_indexExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_indexExpression_2());
}
void test_instanceCreationExpression() {
@@ -3159,35 +3132,34 @@
AstTestFactory.instanceCreationExpression3(null,
AstTestFactory.typeName4("C"), "c", [AstTestFactory.integer(2)]);
_assertReplace(
- node, new Getter_NodeReplacerTest_test_instanceCreationExpression_2());
+ node, Getter_NodeReplacerTest_test_instanceCreationExpression_2());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_instanceCreationExpression());
+ node, Getter_NodeReplacerTest_test_instanceCreationExpression());
}
void test_interpolationExpression() {
InterpolationExpression node = AstTestFactory.interpolationExpression2("x");
_assertReplace(
- node, new Getter_NodeReplacerTest_test_interpolationExpression());
+ node, Getter_NodeReplacerTest_test_interpolationExpression());
}
void test_isExpression() {
IsExpression node = AstTestFactory.isExpression(
AstTestFactory.identifier3("v"), false, AstTestFactory.typeName4("T"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_isExpression());
- _assertReplace(node, new Getter_NodeReplacerTest_test_isExpression_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_isExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_isExpression_2());
}
void test_label() {
Label node = AstTestFactory.label2("l");
- _assertReplace(node, new Getter_NodeReplacerTest_test_label());
+ _assertReplace(node, Getter_NodeReplacerTest_test_label());
}
void test_labeledStatement() {
LabeledStatement node = AstTestFactory.labeledStatement(
[AstTestFactory.label2("l")], AstTestFactory.block());
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_labeledStatement(0));
- _assertReplace(node, new Getter_NodeReplacerTest_test_labeledStatement());
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_labeledStatement(0));
+ _assertReplace(node, Getter_NodeReplacerTest_test_labeledStatement());
}
void test_libraryDirective() {
@@ -3195,14 +3167,13 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(node, new Getter_NodeReplacerTest_test_libraryDirective());
+ _assertReplace(node, Getter_NodeReplacerTest_test_libraryDirective());
_testAnnotatedNode(node);
}
void test_libraryIdentifier() {
LibraryIdentifier node = AstTestFactory.libraryIdentifier2(["lib"]);
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_libraryIdentifier(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_libraryIdentifier(0));
}
void test_listLiteral() {
@@ -3210,7 +3181,7 @@
null,
AstTestFactory.typeArgumentList([AstTestFactory.typeName4("E")]),
[AstTestFactory.identifier3("e")]);
- _assertReplace(node, new ListGetter_NodeReplacerTest_test_listLiteral(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_listLiteral(0));
_testTypedLiteral(node);
}
@@ -3219,15 +3190,15 @@
null,
AstTestFactory.typeArgumentList([AstTestFactory.typeName4("E")]),
[AstTestFactory.mapLiteralEntry("k", AstTestFactory.identifier3("v"))]);
- _assertReplace(node, new ListGetter_NodeReplacerTest_test_mapLiteral(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_mapLiteral(0));
_testTypedLiteral(node);
}
void test_mapLiteralEntry() {
MapLiteralEntry node =
AstTestFactory.mapLiteralEntry("k", AstTestFactory.identifier3("v"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_mapLiteralEntry_2());
- _assertReplace(node, new Getter_NodeReplacerTest_test_mapLiteralEntry());
+ _assertReplace(node, Getter_NodeReplacerTest_test_mapLiteralEntry_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_mapLiteralEntry());
}
void test_methodDeclaration() {
@@ -3242,46 +3213,43 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(node, new Getter_NodeReplacerTest_test_methodDeclaration());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_methodDeclaration_3());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_methodDeclaration_4());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_methodDeclaration_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_methodDeclaration());
+ _assertReplace(node, Getter_NodeReplacerTest_test_methodDeclaration_3());
+ _assertReplace(node, Getter_NodeReplacerTest_test_methodDeclaration_4());
+ _assertReplace(node, Getter_NodeReplacerTest_test_methodDeclaration_2());
_testAnnotatedNode(node);
}
void test_methodInvocation() {
MethodInvocation node = AstTestFactory.methodInvocation(
AstTestFactory.identifier3("t"), "m", [AstTestFactory.integer(0)]);
- _assertReplace(node, new Getter_NodeReplacerTest_test_methodInvocation_2());
- _assertReplace(node, new Getter_NodeReplacerTest_test_methodInvocation_3());
- _assertReplace(node, new Getter_NodeReplacerTest_test_methodInvocation());
+ _assertReplace(node, Getter_NodeReplacerTest_test_methodInvocation_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_methodInvocation_3());
+ _assertReplace(node, Getter_NodeReplacerTest_test_methodInvocation());
}
void test_namedExpression() {
NamedExpression node =
AstTestFactory.namedExpression2("l", AstTestFactory.identifier3("v"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_namedExpression());
- _assertReplace(node, new Getter_NodeReplacerTest_test_namedExpression_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_namedExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_namedExpression_2());
}
void test_nativeClause() {
NativeClause node = AstTestFactory.nativeClause("");
- _assertReplace(node, new Getter_NodeReplacerTest_test_nativeClause());
+ _assertReplace(node, Getter_NodeReplacerTest_test_nativeClause());
}
void test_nativeFunctionBody() {
NativeFunctionBody node = AstTestFactory.nativeFunctionBody("m");
- _assertReplace(node, new Getter_NodeReplacerTest_test_nativeFunctionBody());
+ _assertReplace(node, Getter_NodeReplacerTest_test_nativeFunctionBody());
}
void test_parenthesizedExpression() {
ParenthesizedExpression node =
AstTestFactory.parenthesizedExpression(AstTestFactory.integer(0));
_assertReplace(
- node, new Getter_NodeReplacerTest_test_parenthesizedExpression());
+ node, Getter_NodeReplacerTest_test_parenthesizedExpression());
}
void test_partDirective() {
@@ -3298,56 +3266,54 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(node, new Getter_NodeReplacerTest_test_partOfDirective());
+ _assertReplace(node, Getter_NodeReplacerTest_test_partOfDirective());
_testAnnotatedNode(node);
}
void test_postfixExpression() {
PostfixExpression node = AstTestFactory.postfixExpression(
AstTestFactory.identifier3("x"), TokenType.MINUS_MINUS);
- _assertReplace(node, new Getter_NodeReplacerTest_test_postfixExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_postfixExpression());
}
void test_prefixedIdentifier() {
PrefixedIdentifier node = AstTestFactory.identifier5("a", "b");
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_prefixedIdentifier_2());
- _assertReplace(node, new Getter_NodeReplacerTest_test_prefixedIdentifier());
+ _assertReplace(node, Getter_NodeReplacerTest_test_prefixedIdentifier_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_prefixedIdentifier());
}
void test_prefixExpression() {
PrefixExpression node = AstTestFactory.prefixExpression(
TokenType.PLUS_PLUS, AstTestFactory.identifier3("y"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_prefixExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_prefixExpression());
}
void test_propertyAccess() {
PropertyAccess node =
AstTestFactory.propertyAccess2(AstTestFactory.identifier3("x"), "y");
- _assertReplace(node, new Getter_NodeReplacerTest_test_propertyAccess());
- _assertReplace(node, new Getter_NodeReplacerTest_test_propertyAccess_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_propertyAccess());
+ _assertReplace(node, Getter_NodeReplacerTest_test_propertyAccess_2());
}
void test_redirectingConstructorInvocation() {
RedirectingConstructorInvocation node =
AstTestFactory.redirectingConstructorInvocation2(
"c", [AstTestFactory.integer(0)]);
+ _assertReplace(
+ node, Getter_NodeReplacerTest_test_redirectingConstructorInvocation());
_assertReplace(node,
- new Getter_NodeReplacerTest_test_redirectingConstructorInvocation());
- _assertReplace(node,
- new Getter_NodeReplacerTest_test_redirectingConstructorInvocation_2());
+ Getter_NodeReplacerTest_test_redirectingConstructorInvocation_2());
}
void test_returnStatement() {
ReturnStatement node =
AstTestFactory.returnStatement2(AstTestFactory.integer(0));
- _assertReplace(node, new Getter_NodeReplacerTest_test_returnStatement());
+ _assertReplace(node, Getter_NodeReplacerTest_test_returnStatement());
}
void test_showCombinator() {
ShowCombinator node = AstTestFactory.showCombinator2(["X", "Y"]);
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_showCombinator(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_showCombinator(0));
}
void test_simpleFormalParameter() {
@@ -3357,8 +3323,7 @@
node.metadata = [
AstTestFactory.annotation(AstTestFactory.identifier3("a"))
];
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_simpleFormalParameter());
+ _assertReplace(node, Getter_NodeReplacerTest_test_simpleFormalParameter());
_testNormalFormalParameter(node);
}
@@ -3366,7 +3331,7 @@
StringInterpolation node =
AstTestFactory.string([AstTestFactory.interpolationExpression2("a")]);
_assertReplace(
- node, new ListGetter_NodeReplacerTest_test_stringInterpolation(0));
+ node, ListGetter_NodeReplacerTest_test_stringInterpolation(0));
}
void test_superConstructorInvocation() {
@@ -3374,15 +3339,15 @@
AstTestFactory.superConstructorInvocation2(
"s", [AstTestFactory.integer(1)]);
_assertReplace(
- node, new Getter_NodeReplacerTest_test_superConstructorInvocation());
+ node, Getter_NodeReplacerTest_test_superConstructorInvocation());
_assertReplace(
- node, new Getter_NodeReplacerTest_test_superConstructorInvocation_2());
+ node, Getter_NodeReplacerTest_test_superConstructorInvocation_2());
}
void test_switchCase() {
SwitchCase node = AstTestFactory.switchCase2([AstTestFactory.label2("l")],
AstTestFactory.integer(0), [AstTestFactory.block()]);
- _assertReplace(node, new Getter_NodeReplacerTest_test_switchCase());
+ _assertReplace(node, Getter_NodeReplacerTest_test_switchCase());
_testSwitchMember(node);
}
@@ -3400,15 +3365,14 @@
AstTestFactory.switchDefault(
[AstTestFactory.label2("l")], [AstTestFactory.block()])
]);
- _assertReplace(node, new Getter_NodeReplacerTest_test_switchStatement());
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_switchStatement(0));
+ _assertReplace(node, Getter_NodeReplacerTest_test_switchStatement());
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_switchStatement(0));
}
void test_throwExpression() {
ThrowExpression node =
AstTestFactory.throwExpression2(AstTestFactory.identifier3("e"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_throwExpression());
+ _assertReplace(node, Getter_NodeReplacerTest_test_throwExpression());
}
void test_topLevelVariableDeclaration() {
@@ -3421,7 +3385,7 @@
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(
- node, new Getter_NodeReplacerTest_test_topLevelVariableDeclaration());
+ node, Getter_NodeReplacerTest_test_topLevelVariableDeclaration());
_testAnnotatedNode(node);
}
@@ -3432,36 +3396,34 @@
AstTestFactory.catchClause("e", [AstTestFactory.block()])
],
AstTestFactory.block());
- _assertReplace(node, new Getter_NodeReplacerTest_test_tryStatement_2());
- _assertReplace(node, new Getter_NodeReplacerTest_test_tryStatement());
- _assertReplace(node, new ListGetter_NodeReplacerTest_test_tryStatement(0));
+ _assertReplace(node, Getter_NodeReplacerTest_test_tryStatement_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_tryStatement());
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_tryStatement(0));
}
void test_typeArgumentList() {
TypeArgumentList node =
AstTestFactory.typeArgumentList([AstTestFactory.typeName4("A")]);
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_typeArgumentList(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_typeArgumentList(0));
}
void test_typeName() {
TypeName node = AstTestFactory.typeName4(
"T", [AstTestFactory.typeName4("E"), AstTestFactory.typeName4("F")]);
- _assertReplace(node, new Getter_NodeReplacerTest_test_typeName_2());
- _assertReplace(node, new Getter_NodeReplacerTest_test_typeName());
+ _assertReplace(node, Getter_NodeReplacerTest_test_typeName_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_typeName());
}
void test_typeParameter() {
TypeParameter node =
AstTestFactory.typeParameter2("E", AstTestFactory.typeName4("B"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_typeParameter_2());
- _assertReplace(node, new Getter_NodeReplacerTest_test_typeParameter());
+ _assertReplace(node, Getter_NodeReplacerTest_test_typeParameter_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_typeParameter());
}
void test_typeParameterList() {
TypeParameterList node = AstTestFactory.typeParameterList(["A", "B"]);
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_test_typeParameterList(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_typeParameterList(0));
}
void test_variableDeclaration() {
@@ -3470,10 +3432,8 @@
node.documentationComment = astFactory.endOfLineComment(EMPTY_TOKEN_LIST);
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_variableDeclaration());
- _assertReplace(
- node, new Getter_NodeReplacerTest_test_variableDeclaration_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_variableDeclaration());
+ _assertReplace(node, Getter_NodeReplacerTest_test_variableDeclaration_2());
_testAnnotatedNode(node);
}
@@ -3486,9 +3446,9 @@
node.metadata
.add(AstTestFactory.annotation(AstTestFactory.identifier3("a")));
_assertReplace(
- node, new Getter_NodeReplacerTest_test_variableDeclarationList());
+ node, Getter_NodeReplacerTest_test_variableDeclarationList());
_assertReplace(
- node, new ListGetter_NodeReplacerTest_test_variableDeclarationList(0));
+ node, ListGetter_NodeReplacerTest_test_variableDeclarationList(0));
_testAnnotatedNode(node);
}
@@ -3499,31 +3459,31 @@
AstTestFactory.typeName4("T"),
[AstTestFactory.variableDeclaration("a")]);
_assertReplace(
- node, new Getter_NodeReplacerTest_test_variableDeclarationStatement());
+ node, Getter_NodeReplacerTest_test_variableDeclarationStatement());
}
void test_whileStatement() {
WhileStatement node = AstTestFactory.whileStatement(
AstTestFactory.booleanLiteral(true), AstTestFactory.block());
- _assertReplace(node, new Getter_NodeReplacerTest_test_whileStatement());
- _assertReplace(node, new Getter_NodeReplacerTest_test_whileStatement_2());
+ _assertReplace(node, Getter_NodeReplacerTest_test_whileStatement());
+ _assertReplace(node, Getter_NodeReplacerTest_test_whileStatement_2());
}
void test_withClause() {
WithClause node =
AstTestFactory.withClause([AstTestFactory.typeName4("M")]);
- _assertReplace(node, new ListGetter_NodeReplacerTest_test_withClause(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_test_withClause(0));
}
void test_yieldStatement() {
var node = AstTestFactory.yieldStatement(AstTestFactory.identifier3("A"));
- _assertReplace(node, new Getter_NodeReplacerTest_test_yieldStatement());
+ _assertReplace(node, Getter_NodeReplacerTest_test_yieldStatement());
}
void _assertReplace(AstNode parent, NodeReplacerTest_Getter getter) {
AstNode child = getter.get(parent);
if (child != null) {
- AstNode clone = child.accept(new AstCloner());
+ AstNode clone = child.accept(AstCloner());
NodeReplacer.replace(child, clone);
expect(getter.get(parent), clone);
expect(clone.parent, child.parent);
@@ -3531,36 +3491,33 @@
}
void _testAnnotatedNode(AnnotatedNode node) {
- _assertReplace(node, new Getter_NodeReplacerTest_testAnnotatedNode());
- _assertReplace(node, new ListGetter_NodeReplacerTest_testAnnotatedNode(0));
+ _assertReplace(node, Getter_NodeReplacerTest_testAnnotatedNode());
+ _assertReplace(node, ListGetter_NodeReplacerTest_testAnnotatedNode(0));
}
void _testNamespaceDirective(NamespaceDirective node) {
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_testNamespaceDirective(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_testNamespaceDirective(0));
_testUriBasedDirective(node);
}
void _testNormalFormalParameter(NormalFormalParameter node) {
+ _assertReplace(node, Getter_NodeReplacerTest_testNormalFormalParameter_2());
+ _assertReplace(node, Getter_NodeReplacerTest_testNormalFormalParameter());
_assertReplace(
- node, new Getter_NodeReplacerTest_testNormalFormalParameter_2());
- _assertReplace(
- node, new Getter_NodeReplacerTest_testNormalFormalParameter());
- _assertReplace(
- node, new ListGetter_NodeReplacerTest_testNormalFormalParameter(0));
+ node, ListGetter_NodeReplacerTest_testNormalFormalParameter(0));
}
void _testSwitchMember(SwitchMember node) {
- _assertReplace(node, new ListGetter_NodeReplacerTest_testSwitchMember(0));
- _assertReplace(node, new ListGetter_NodeReplacerTest_testSwitchMember_2(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_testSwitchMember(0));
+ _assertReplace(node, ListGetter_NodeReplacerTest_testSwitchMember_2(0));
}
void _testTypedLiteral(TypedLiteral node) {
- _assertReplace(node, new Getter_NodeReplacerTest_testTypedLiteral());
+ _assertReplace(node, Getter_NodeReplacerTest_testTypedLiteral());
}
void _testUriBasedDirective(UriBasedDirective node) {
- _assertReplace(node, new Getter_NodeReplacerTest_testUriBasedDirective());
+ _assertReplace(node, Getter_NodeReplacerTest_testUriBasedDirective());
_testAnnotatedNode(node);
}
}
@@ -3590,7 +3547,7 @@
@reflectiveTest
class SourceRangeTest {
void test_access() {
- SourceRange r = new SourceRange(10, 1);
+ SourceRange r = SourceRange(10, 1);
expect(r.offset, 10);
expect(r.length, 1);
expect(r.end, 10 + 1);
@@ -3599,7 +3556,7 @@
}
void test_contains() {
- SourceRange r = new SourceRange(5, 10);
+ SourceRange r = SourceRange(5, 10);
expect(r.contains(5), isTrue);
expect(r.contains(10), isTrue);
expect(r.contains(14), isTrue);
@@ -3608,7 +3565,7 @@
}
void test_containsExclusive() {
- SourceRange r = new SourceRange(5, 10);
+ SourceRange r = SourceRange(5, 10);
expect(r.containsExclusive(5), isFalse);
expect(r.containsExclusive(10), isTrue);
expect(r.containsExclusive(14), isTrue);
@@ -3617,119 +3574,119 @@
}
void test_coveredBy() {
- SourceRange r = new SourceRange(5, 10);
+ SourceRange r = SourceRange(5, 10);
// ends before
- expect(r.coveredBy(new SourceRange(20, 10)), isFalse);
+ expect(r.coveredBy(SourceRange(20, 10)), isFalse);
// starts after
- expect(r.coveredBy(new SourceRange(0, 3)), isFalse);
+ expect(r.coveredBy(SourceRange(0, 3)), isFalse);
// only intersects
- expect(r.coveredBy(new SourceRange(0, 10)), isFalse);
- expect(r.coveredBy(new SourceRange(10, 10)), isFalse);
+ expect(r.coveredBy(SourceRange(0, 10)), isFalse);
+ expect(r.coveredBy(SourceRange(10, 10)), isFalse);
// covered
- expect(r.coveredBy(new SourceRange(0, 20)), isTrue);
- expect(r.coveredBy(new SourceRange(5, 10)), isTrue);
+ expect(r.coveredBy(SourceRange(0, 20)), isTrue);
+ expect(r.coveredBy(SourceRange(5, 10)), isTrue);
}
void test_covers() {
- SourceRange r = new SourceRange(5, 10);
+ SourceRange r = SourceRange(5, 10);
// ends before
- expect(r.covers(new SourceRange(0, 3)), isFalse);
+ expect(r.covers(SourceRange(0, 3)), isFalse);
// starts after
- expect(r.covers(new SourceRange(20, 3)), isFalse);
+ expect(r.covers(SourceRange(20, 3)), isFalse);
// only intersects
- expect(r.covers(new SourceRange(0, 10)), isFalse);
- expect(r.covers(new SourceRange(10, 10)), isFalse);
+ expect(r.covers(SourceRange(0, 10)), isFalse);
+ expect(r.covers(SourceRange(10, 10)), isFalse);
// covers
- expect(r.covers(new SourceRange(5, 10)), isTrue);
- expect(r.covers(new SourceRange(6, 9)), isTrue);
- expect(r.covers(new SourceRange(6, 8)), isTrue);
+ expect(r.covers(SourceRange(5, 10)), isTrue);
+ expect(r.covers(SourceRange(6, 9)), isTrue);
+ expect(r.covers(SourceRange(6, 8)), isTrue);
}
void test_endsIn() {
- SourceRange r = new SourceRange(5, 10);
+ SourceRange r = SourceRange(5, 10);
// ends before
- expect(r.endsIn(new SourceRange(20, 10)), isFalse);
+ expect(r.endsIn(SourceRange(20, 10)), isFalse);
// starts after
- expect(r.endsIn(new SourceRange(0, 3)), isFalse);
+ expect(r.endsIn(SourceRange(0, 3)), isFalse);
// ends
- expect(r.endsIn(new SourceRange(10, 20)), isTrue);
- expect(r.endsIn(new SourceRange(0, 20)), isTrue);
+ expect(r.endsIn(SourceRange(10, 20)), isTrue);
+ expect(r.endsIn(SourceRange(0, 20)), isTrue);
}
void test_equals() {
- SourceRange r = new SourceRange(10, 1);
+ SourceRange r = SourceRange(10, 1);
expect(r == null, isFalse);
// ignore: unrelated_type_equality_checks
expect(r == this, isFalse);
- expect(r == new SourceRange(20, 2), isFalse);
- expect(r == new SourceRange(10, 1), isTrue);
+ expect(r == SourceRange(20, 2), isFalse);
+ expect(r == SourceRange(10, 1), isTrue);
expect(r == r, isTrue);
}
void test_getExpanded() {
- SourceRange r = new SourceRange(5, 3);
+ SourceRange r = SourceRange(5, 3);
expect(r.getExpanded(0), r);
- expect(r.getExpanded(2), new SourceRange(3, 7));
- expect(r.getExpanded(-1), new SourceRange(6, 1));
+ expect(r.getExpanded(2), SourceRange(3, 7));
+ expect(r.getExpanded(-1), SourceRange(6, 1));
}
void test_getMoveEnd() {
- SourceRange r = new SourceRange(5, 3);
+ SourceRange r = SourceRange(5, 3);
expect(r.getMoveEnd(0), r);
- expect(r.getMoveEnd(3), new SourceRange(5, 6));
- expect(r.getMoveEnd(-1), new SourceRange(5, 2));
+ expect(r.getMoveEnd(3), SourceRange(5, 6));
+ expect(r.getMoveEnd(-1), SourceRange(5, 2));
}
void test_getTranslated() {
- SourceRange r = new SourceRange(5, 3);
+ SourceRange r = SourceRange(5, 3);
expect(r.getTranslated(0), r);
- expect(r.getTranslated(2), new SourceRange(7, 3));
- expect(r.getTranslated(-1), new SourceRange(4, 3));
+ expect(r.getTranslated(2), SourceRange(7, 3));
+ expect(r.getTranslated(-1), SourceRange(4, 3));
}
void test_getUnion() {
- expect(new SourceRange(10, 10).getUnion(new SourceRange(15, 10)),
- new SourceRange(10, 15));
- expect(new SourceRange(15, 10).getUnion(new SourceRange(10, 10)),
- new SourceRange(10, 15));
+ expect(
+ SourceRange(10, 10).getUnion(SourceRange(15, 10)), SourceRange(10, 15));
+ expect(
+ SourceRange(15, 10).getUnion(SourceRange(10, 10)), SourceRange(10, 15));
// "other" is covered/covers
- expect(new SourceRange(10, 10).getUnion(new SourceRange(15, 2)),
- new SourceRange(10, 10));
- expect(new SourceRange(15, 2).getUnion(new SourceRange(10, 10)),
- new SourceRange(10, 10));
+ expect(
+ SourceRange(10, 10).getUnion(SourceRange(15, 2)), SourceRange(10, 10));
+ expect(
+ SourceRange(15, 2).getUnion(SourceRange(10, 10)), SourceRange(10, 10));
}
void test_intersects() {
- SourceRange r = new SourceRange(5, 3);
+ SourceRange r = SourceRange(5, 3);
// null
expect(r.intersects(null), isFalse);
// ends before
- expect(r.intersects(new SourceRange(0, 5)), isFalse);
+ expect(r.intersects(SourceRange(0, 5)), isFalse);
// begins after
- expect(r.intersects(new SourceRange(8, 5)), isFalse);
+ expect(r.intersects(SourceRange(8, 5)), isFalse);
// begins on same offset
- expect(r.intersects(new SourceRange(5, 1)), isTrue);
+ expect(r.intersects(SourceRange(5, 1)), isTrue);
// begins inside, ends inside
- expect(r.intersects(new SourceRange(6, 1)), isTrue);
+ expect(r.intersects(SourceRange(6, 1)), isTrue);
// begins inside, ends after
- expect(r.intersects(new SourceRange(6, 10)), isTrue);
+ expect(r.intersects(SourceRange(6, 10)), isTrue);
// begins before, ends after
- expect(r.intersects(new SourceRange(0, 10)), isTrue);
+ expect(r.intersects(SourceRange(0, 10)), isTrue);
}
void test_startsIn() {
- SourceRange r = new SourceRange(5, 10);
+ SourceRange r = SourceRange(5, 10);
// ends before
- expect(r.startsIn(new SourceRange(20, 10)), isFalse);
+ expect(r.startsIn(SourceRange(20, 10)), isFalse);
// starts after
- expect(r.startsIn(new SourceRange(0, 3)), isFalse);
+ expect(r.startsIn(SourceRange(0, 3)), isFalse);
// starts
- expect(r.startsIn(new SourceRange(5, 1)), isTrue);
- expect(r.startsIn(new SourceRange(0, 20)), isTrue);
+ expect(r.startsIn(SourceRange(5, 1)), isTrue);
+ expect(r.startsIn(SourceRange(0, 20)), isTrue);
}
void test_toString() {
- SourceRange r = new SourceRange(10, 1);
+ SourceRange r = SourceRange(10, 1);
expect(r.toString(), "[offset=10, length=1]");
}
}
@@ -3848,7 +3805,7 @@
void test_printListOfQuotedNames_empty() {
expect(() {
- StringUtilities.printListOfQuotedNames(new List<String>(0));
+ StringUtilities.printListOfQuotedNames(List<String>(0));
}, throwsArgumentError);
}
@@ -3994,6 +3951,6 @@
class _ExceptionThrowingVisitor extends SimpleAstVisitor {
visitNullLiteral(NullLiteral node) {
- throw new ArgumentError('');
+ throw ArgumentError('');
}
}
diff --git a/pkg/analyzer/test/id_tests/assigned_variables_test.dart b/pkg/analyzer/test/id_tests/assigned_variables_test.dart
index 31fb94e..9a7d09e 100644
--- a/pkg/analyzer/test/id_tests/assigned_variables_test.dart
+++ b/pkg/analyzer/test/id_tests/assigned_variables_test.dart
@@ -16,7 +16,7 @@
import '../util/id_testing_helper.dart';
main(List<String> args) async {
- Directory dataDir = new Directory.fromUri(Platform.script.resolve(
+ Directory dataDir = Directory.fromUri(Platform.script.resolve(
'../../../_fe_analyzer_shared/test/flow_analysis/assigned_variables/'
'data'));
await runTests(dataDir,
diff --git a/pkg/analyzer/test/id_tests/constant_test.dart b/pkg/analyzer/test/id_tests/constant_test.dart
index 0b01e0a..1b43b72 100644
--- a/pkg/analyzer/test/id_tests/constant_test.dart
+++ b/pkg/analyzer/test/id_tests/constant_test.dart
@@ -16,7 +16,7 @@
import '../util/id_testing_helper.dart';
main(List<String> args) async {
- Directory dataDir = new Directory.fromUri(Platform.script
+ Directory dataDir = Directory.fromUri(Platform.script
.resolve('../../../_fe_analyzer_shared/test/constants/data'));
await runTests(dataDir,
args: args,
diff --git a/pkg/analyzer/test/id_tests/definite_assignment_test.dart b/pkg/analyzer/test/id_tests/definite_assignment_test.dart
index cb5e417..bf8dc84 100644
--- a/pkg/analyzer/test/id_tests/definite_assignment_test.dart
+++ b/pkg/analyzer/test/id_tests/definite_assignment_test.dart
@@ -15,7 +15,7 @@
import '../util/id_testing_helper.dart';
main(List<String> args) async {
- Directory dataDir = new Directory.fromUri(Platform.script.resolve(
+ Directory dataDir = Directory.fromUri(Platform.script.resolve(
'../../../_fe_analyzer_shared/test/flow_analysis/definite_assignment/'
'data'));
await runTests(dataDir,
diff --git a/pkg/analyzer/test/id_tests/nullability_test.dart b/pkg/analyzer/test/id_tests/nullability_test.dart
index cba7b8c..ef902bb 100644
--- a/pkg/analyzer/test/id_tests/nullability_test.dart
+++ b/pkg/analyzer/test/id_tests/nullability_test.dart
@@ -19,7 +19,7 @@
import '../util/id_testing_helper.dart';
main(List<String> args) async {
- Directory dataDir = new Directory.fromUri(Platform.script.resolve(
+ Directory dataDir = Directory.fromUri(Platform.script.resolve(
'../../../_fe_analyzer_shared/test/flow_analysis/nullability/data'));
await runTests(dataDir,
args: args,
@@ -56,7 +56,7 @@
void computeUnitData(TestingData testingData, CompilationUnit unit,
Map<Id, ActualData<String>> actualMap) {
_NullabilityDataExtractor(unit.declaredElement.source.uri, actualMap,
- unit.declaredElement.context.typeSystem)
+ unit.declaredElement.library.typeSystem)
.run(unit);
}
}
diff --git a/pkg/analyzer/test/id_tests/reachability_test.dart b/pkg/analyzer/test/id_tests/reachability_test.dart
index 6c8463c..d5a4bb5 100644
--- a/pkg/analyzer/test/id_tests/reachability_test.dart
+++ b/pkg/analyzer/test/id_tests/reachability_test.dart
@@ -16,7 +16,7 @@
import '../util/id_testing_helper.dart';
main(List<String> args) async {
- Directory dataDir = new Directory.fromUri(Platform.script.resolve(
+ Directory dataDir = Directory.fromUri(Platform.script.resolve(
'../../../_fe_analyzer_shared/test/flow_analysis/reachability/data'));
await runTests(dataDir,
args: args,
diff --git a/pkg/analyzer/test/id_tests/type_promotion_test.dart b/pkg/analyzer/test/id_tests/type_promotion_test.dart
index e6ab989..65be590 100644
--- a/pkg/analyzer/test/id_tests/type_promotion_test.dart
+++ b/pkg/analyzer/test/id_tests/type_promotion_test.dart
@@ -17,7 +17,7 @@
import '../util/id_testing_helper.dart';
main(List<String> args) async {
- Directory dataDir = new Directory.fromUri(Platform.script
+ Directory dataDir = Directory.fromUri(Platform.script
.resolve('../../../_fe_analyzer_shared/test/flow_analysis/type_promotion/'
'data'));
await runTests(dataDir,
diff --git a/pkg/analyzer/test/instrumentation/instrumentation_test.dart b/pkg/analyzer/test/instrumentation/instrumentation_test.dart
index dd56b5e..452702d 100644
--- a/pkg/analyzer/test/instrumentation/instrumentation_test.dart
+++ b/pkg/analyzer/test/instrumentation/instrumentation_test.dart
@@ -22,30 +22,30 @@
}
void test_logError_withColon() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
service.logError('Error:message');
assertNormal(logger, InstrumentationLogAdapter.TAG_ERROR, 'Error::message');
}
void test_logError_withLeadingColon() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
service.logError(':a:bb');
assertNormal(logger, InstrumentationLogAdapter.TAG_ERROR, '::a::bb');
}
void test_logError_withoutColon() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
String message = 'Error message';
service.logError(message);
assertNormal(logger, InstrumentationLogAdapter.TAG_ERROR, message);
}
void test_logException_noTrace() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
String message = 'exceptionMessage';
service.logException(message);
assertNormal(
@@ -53,31 +53,31 @@
}
void test_logLogEntry() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
String level = 'level';
- DateTime time = new DateTime(2001);
+ DateTime time = DateTime(2001);
String message = 'message';
String exception = 'exception';
String stackTraceText = 'stackTrace';
- StackTrace stackTrace = new StackTrace.fromString(stackTraceText);
+ StackTrace stackTrace = StackTrace.fromString(stackTraceText);
service.logLogEntry(level, time, message, exception, stackTrace);
assertNormal(logger, InstrumentationLogAdapter.TAG_LOG_ENTRY,
'$level:${time.millisecondsSinceEpoch}:$message:$exception:$stackTraceText');
}
void test_logNotification() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
String message = 'notificationText';
service.logNotification(message);
assertNormal(logger, InstrumentationLogAdapter.TAG_NOTIFICATION, message);
}
void test_logPluginError() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
- PluginData plugin = new PluginData('path', 'name', 'version');
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
+ PluginData plugin = PluginData('path', 'name', 'version');
String code = 'code';
String message = 'exceptionMessage';
String stackTraceText = 'stackTrace';
@@ -87,9 +87,9 @@
}
void test_logPluginException_noTrace() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
- PluginData plugin = new PluginData('path', 'name', 'version');
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
+ PluginData plugin = PluginData('path', 'name', 'version');
String message = 'exceptionMessage';
service.logPluginException(plugin, message, null);
assertNormal(logger, InstrumentationLogAdapter.TAG_PLUGIN_EXCEPTION,
@@ -97,20 +97,20 @@
}
void test_logPluginException_withTrace() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
- PluginData plugin = new PluginData('path', 'name', 'version');
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
+ PluginData plugin = PluginData('path', 'name', 'version');
String message = 'exceptionMessage';
String stackTraceText = 'stackTrace';
- StackTrace stackTrace = new StackTrace.fromString(stackTraceText);
+ StackTrace stackTrace = StackTrace.fromString(stackTraceText);
service.logPluginException(plugin, message, stackTrace);
assertNormal(logger, InstrumentationLogAdapter.TAG_PLUGIN_EXCEPTION,
'$message:$stackTraceText:path:name:version');
}
void test_logPluginNotification() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
String notification = 'notification';
service.logPluginNotification('path', notification);
assertNormal(logger, InstrumentationLogAdapter.TAG_PLUGIN_NOTIFICATION,
@@ -118,8 +118,8 @@
}
void test_logPluginRequest() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
String request = 'request';
service.logPluginRequest('path', request);
assertNormal(logger, InstrumentationLogAdapter.TAG_PLUGIN_REQUEST,
@@ -127,8 +127,8 @@
}
void test_logPluginResponse() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
String response = 'response';
service.logPluginResponse('path', response);
assertNormal(logger, InstrumentationLogAdapter.TAG_PLUGIN_RESPONSE,
@@ -136,9 +136,9 @@
}
void test_logPluginTimeout() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
- PluginData plugin = new PluginData('path', 'name', 'version');
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
+ PluginData plugin = PluginData('path', 'name', 'version');
String request = 'request';
service.logPluginTimeout(plugin, request);
assertNormal(logger, InstrumentationLogAdapter.TAG_PLUGIN_TIMEOUT,
@@ -146,24 +146,24 @@
}
void test_logRequest() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
String message = 'requestText';
service.logRequest(message);
assertNormal(logger, InstrumentationLogAdapter.TAG_REQUEST, message);
}
void test_logResponse() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
String message = 'responseText';
service.logResponse(message);
assertNormal(logger, InstrumentationLogAdapter.TAG_RESPONSE, message);
}
void test_logVersion() {
- TestInstrumentationLogger logger = new TestInstrumentationLogger();
- InstrumentationService service = new InstrumentationLogAdapter(logger);
+ TestInstrumentationLogger logger = TestInstrumentationLogger();
+ InstrumentationService service = InstrumentationLogAdapter(logger);
service.logVersion('myUuid', 'someClientId', 'someClientVersion',
'aServerVersion', 'anSdkVersion');
expect(
@@ -175,12 +175,12 @@
@reflectiveTest
class MulticastInstrumentationServerTest {
- TestInstrumentationLogger loggerA = new TestInstrumentationLogger();
- TestInstrumentationLogger loggerB = new TestInstrumentationLogger();
+ TestInstrumentationLogger loggerA = TestInstrumentationLogger();
+ TestInstrumentationLogger loggerB = TestInstrumentationLogger();
MulticastInstrumentationService logger;
void setUp() {
- logger = new MulticastInstrumentationService([
+ logger = MulticastInstrumentationService([
InstrumentationLogAdapter(loggerA),
InstrumentationLogAdapter(loggerB)
]);
@@ -201,7 +201,7 @@
}
class TestInstrumentationLogger implements InstrumentationLogger {
- StringBuffer logged = new StringBuffer();
+ StringBuffer logged = StringBuffer();
@override
void log(String message) {
diff --git a/pkg/analyzer/test/source/analysis_options_provider_test.dart b/pkg/analyzer/test/source/analysis_options_provider_test.dart
index 33e23e4..f2981c1 100644
--- a/pkg/analyzer/test/source/analysis_options_provider_test.dart
+++ b/pkg/analyzer/test/source/analysis_options_provider_test.dart
@@ -25,7 +25,7 @@
});
group('AnalysisOptionsProvider', () {
void expectMergesTo(String defaults, String overrides, String expected) {
- var optionsProvider = new AnalysisOptionsProvider();
+ var optionsProvider = AnalysisOptionsProvider();
var defaultOptions = optionsProvider.getOptionsFromString(defaults);
var overrideOptions = optionsProvider.getOptionsFromString(overrides);
var merged = optionsProvider.merge(defaultOptions, overrideOptions);
@@ -80,9 +80,9 @@
strong-mode: true
''';
- var optionsProvider = new AnalysisOptionsProvider();
+ var optionsProvider = AnalysisOptionsProvider();
expect(() => optionsProvider.getOptionsFromString(src),
- throwsA(new TypeMatcher<OptionsFormatException>()));
+ throwsA(TypeMatcher<OptionsFormatException>()));
});
test('test_bad_yaml (2)', () {
@@ -91,7 +91,7 @@
strong-mode:true # missing space (sdk/issues/24885)
''';
- var optionsProvider = new AnalysisOptionsProvider();
+ var optionsProvider = AnalysisOptionsProvider();
// Should not throw an exception.
var options = optionsProvider.getOptionsFromString(src);
// Should return a non-null options list.
@@ -119,11 +119,11 @@
String get optionsFileName;
void setUp() {
- var rawProvider = new MemoryResourceProvider();
- resourceProvider = new TestResourceProvider(rawProvider);
- pathTranslator = new TestPathTranslator(rawProvider);
- provider = new AnalysisOptionsProvider(new SourceFactory([
- new ResourceUriResolver(rawProvider),
+ var rawProvider = MemoryResourceProvider();
+ resourceProvider = TestResourceProvider(rawProvider);
+ pathTranslator = TestPathTranslator(rawProvider);
+ provider = AnalysisOptionsProvider(SourceFactory([
+ ResourceUriResolver(rawProvider),
]));
}
@@ -241,7 +241,7 @@
}
}
- YamlMap _getOptions(String posixPath, {bool crawlUp: false}) {
+ YamlMap _getOptions(String posixPath, {bool crawlUp = false}) {
Resource resource = pathTranslator.getResource(posixPath);
return provider.getOptions(resource, crawlUp: crawlUp);
}
diff --git a/pkg/analyzer/test/source/embedder_test.dart b/pkg/analyzer/test/source/embedder_test.dart
index ad2cd7b..bf44c30 100644
--- a/pkg/analyzer/test/source/embedder_test.dart
+++ b/pkg/analyzer/test/source/embedder_test.dart
@@ -28,11 +28,11 @@
@reflectiveTest
class DartUriResolverTest extends EmbedderRelatedTest {
void test_embedderYaml() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(locator.embedderYamls);
- DartUriResolver resolver = new DartUriResolver(sdk);
+ EmbedderSdk sdk = EmbedderSdk(locator.embedderYamls);
+ DartUriResolver resolver = DartUriResolver(sdk);
void expectResolved(dartUri, posixPath) {
Source source = resolver.resolveAbsolute(Uri.parse(dartUri));
@@ -52,19 +52,19 @@
@reflectiveTest
class EmbedderSdkTest extends EmbedderRelatedTest {
void test_creation() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(locator.embedderYamls);
+ EmbedderSdk sdk = EmbedderSdk(locator.embedderYamls);
expect(sdk.urlMappings, hasLength(5));
}
void test_fromFileUri() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(locator.embedderYamls);
+ EmbedderSdk sdk = EmbedderSdk(locator.embedderYamls);
expectSource(String posixPath, String dartUri) {
Uri uri = Uri.parse(posixToOSFileUri(posixPath));
@@ -80,10 +80,10 @@
}
void test_getSdkLibrary() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(locator.embedderYamls);
+ EmbedderSdk sdk = EmbedderSdk(locator.embedderYamls);
SdkLibrary lib = sdk.getSdkLibrary('dart:fox');
expect(lib, isNotNull);
@@ -92,10 +92,10 @@
}
void test_mapDartUri() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(locator.embedderYamls);
+ EmbedderSdk sdk = EmbedderSdk(locator.embedderYamls);
void expectSource(String dartUri, String posixPath) {
Source source = sdk.mapDartUri(dartUri);
@@ -114,10 +114,10 @@
@reflectiveTest
class EmbedderUriResolverTest extends EmbedderRelatedTest {
void test_embedderYaml() {
- var locator = new EmbedderYamlLocator({
+ var locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- var resolver = new EmbedderUriResolver(locator.embedderYamls);
+ var resolver = EmbedderUriResolver(locator.embedderYamls);
expectResolved(dartUri, posixPath) {
Source source = resolver.resolveAbsolute(Uri.parse(dartUri));
@@ -136,15 +136,15 @@
}
void test_nullEmbedderYamls() {
- var resolver = new EmbedderUriResolver(null);
+ var resolver = EmbedderUriResolver(null);
expect(resolver, hasLength(0));
}
void test_restoreAbsolute() {
- var locator = new EmbedderYamlLocator({
+ var locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- var resolver = new EmbedderUriResolver(locator.embedderYamls);
+ var resolver = EmbedderUriResolver(locator.embedderYamls);
expectRestore(String dartUri, [String expected]) {
var parsedUri = Uri.parse(dartUri);
diff --git a/pkg/analyzer/test/source/error_processor_test.dart b/pkg/analyzer/test/source/error_processor_test.dart
index ec49f93..e9f2284 100644
--- a/pkg/analyzer/test/source/error_processor_test.dart
+++ b/pkg/analyzer/test/source/error_processor_test.dart
@@ -18,34 +18,34 @@
import '../src/util/yaml_test.dart';
main() {
- AnalysisError invalid_assignment = new AnalysisError(
- new TestSource(), 0, 1, StaticTypeWarningCode.INVALID_ASSIGNMENT, [
+ AnalysisError invalid_assignment = AnalysisError(
+ TestSource(), 0, 1, StaticTypeWarningCode.INVALID_ASSIGNMENT, [
['x'],
['y']
]);
AnalysisError missing_return =
- new AnalysisError(new TestSource(), 0, 1, HintCode.MISSING_RETURN, [
+ AnalysisError(TestSource(), 0, 1, HintCode.MISSING_RETURN, [
['x']
]);
- AnalysisError unused_local_variable = new AnalysisError(
- new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [
+ AnalysisError unused_local_variable =
+ AnalysisError(TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [
['x']
]);
- AnalysisError use_of_void_result = new AnalysisError(
- new TestSource(), 0, 1, StaticWarningCode.USE_OF_VOID_RESULT, [
+ AnalysisError use_of_void_result =
+ AnalysisError(TestSource(), 0, 1, StaticWarningCode.USE_OF_VOID_RESULT, [
['x']
]);
// We in-line a lint code here in order to avoid adding a dependency on the
// linter package.
- AnalysisError annotate_overrides = new AnalysisError(
- new TestSource(), 0, 1, new LintCode('annotate_overrides', ''));
+ AnalysisError annotate_overrides =
+ AnalysisError(TestSource(), 0, 1, LintCode('annotate_overrides', ''));
setUp(() {
- context = new TestContext();
+ context = TestContext();
});
group('ErrorProcessor', () {
@@ -86,7 +86,7 @@
test('yaml map', () {
var options = optionsProvider.getOptionsFromString(config);
var errorConfig =
- new ErrorConfig((options['analyzer'] as YamlMap)['errors']);
+ ErrorConfig((options['analyzer'] as YamlMap)['errors']);
expect(errorConfig.processors, hasLength(2));
// ignore
@@ -112,7 +112,7 @@
'missing_return': 'false',
'unused_local_variable': 'error'
});
- var errorConfig = new ErrorConfig(options);
+ var errorConfig = ErrorConfig(options);
expect(errorConfig.processors, hasLength(2));
// ignore
@@ -136,8 +136,7 @@
test('configure lints', () {
var options = optionsProvider.getOptionsFromString(
'analyzer:\n errors:\n annotate_overrides: warning\n');
- var errorConfig =
- new ErrorConfig((options['analyzer'] as YamlMap)['errors']);
+ var errorConfig = ErrorConfig((options['analyzer'] as YamlMap)['errors']);
expect(errorConfig.processors, hasLength(1));
ErrorProcessor processor = errorConfig.processors.first;
@@ -149,7 +148,7 @@
TestContext context;
-AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider();
+AnalysisOptionsProvider optionsProvider = AnalysisOptionsProvider();
ErrorProcessor processor;
void configureOptions(String options) {
diff --git a/pkg/analyzer/test/source/package_map_resolver_test.dart b/pkg/analyzer/test/source/package_map_resolver_test.dart
index 498e8f7..88350c2 100644
--- a/pkg/analyzer/test/source/package_map_resolver_test.dart
+++ b/pkg/analyzer/test/source/package_map_resolver_test.dart
@@ -20,7 +20,7 @@
class _PackageMapUriResolverTest {
static const Map<String, List<Folder>> EMPTY_MAP =
const <String, List<Folder>>{};
- MemoryResourceProvider provider = new MemoryResourceProvider();
+ MemoryResourceProvider provider = MemoryResourceProvider();
void test_isPackageUri() {
Uri uri = Uri.parse('package:test/test.dart');
@@ -42,13 +42,13 @@
void test_new_null_packageMap() {
expect(() {
- new PackageMapUriResolver(provider, null);
+ PackageMapUriResolver(provider, null);
}, throwsArgumentError);
}
void test_new_null_resourceProvider() {
expect(() {
- new PackageMapUriResolver(null, <String, List<Folder>>{});
+ PackageMapUriResolver(null, <String, List<Folder>>{});
}, throwsArgumentError);
}
@@ -56,14 +56,14 @@
var a = provider.newFile(provider.convertPath('/aaa/a.dart'), '');
var b = provider.newFile(provider.convertPath('/bbb/b.dart'), '');
expect(() {
- new PackageMapUriResolver(provider, <String, List<Folder>>{
+ PackageMapUriResolver(provider, <String, List<Folder>>{
'pkg': <Folder>[a.parent, b.parent]
});
}, throwsArgumentError);
}
void test_resolve_nonPackage() {
- UriResolver resolver = new PackageMapUriResolver(provider, EMPTY_MAP);
+ UriResolver resolver = PackageMapUriResolver(provider, EMPTY_MAP);
Uri uri = Uri.parse('dart:core');
Source result = resolver.resolveAbsolute(uri);
expect(result, isNull);
@@ -75,7 +75,7 @@
provider.newFile(pkgFileA, 'library lib_a;');
provider.newFile(pkgFileB, 'library lib_b;');
PackageMapUriResolver resolver =
- new PackageMapUriResolver(provider, <String, List<Folder>>{
+ PackageMapUriResolver(provider, <String, List<Folder>>{
'pkgA': <Folder>[provider.getResource(provider.convertPath('/pkgA/lib'))],
'pkgB': <Folder>[provider.getResource(provider.convertPath('/pkgB/lib'))]
});
@@ -98,28 +98,28 @@
}
void test_resolve_package_invalid_leadingSlash() {
- UriResolver resolver = new PackageMapUriResolver(provider, EMPTY_MAP);
+ UriResolver resolver = PackageMapUriResolver(provider, EMPTY_MAP);
Uri uri = Uri.parse('package:/foo');
Source result = resolver.resolveAbsolute(uri);
expect(result, isNull);
}
void test_resolve_package_invalid_noSlash() {
- UriResolver resolver = new PackageMapUriResolver(provider, EMPTY_MAP);
+ UriResolver resolver = PackageMapUriResolver(provider, EMPTY_MAP);
Uri uri = Uri.parse('package:foo');
Source result = resolver.resolveAbsolute(uri);
expect(result, isNull);
}
void test_resolve_package_invalid_onlySlash() {
- UriResolver resolver = new PackageMapUriResolver(provider, EMPTY_MAP);
+ UriResolver resolver = PackageMapUriResolver(provider, EMPTY_MAP);
Uri uri = Uri.parse('package:/');
Source result = resolver.resolveAbsolute(uri);
expect(result, isNull);
}
void test_resolve_package_notInMap() {
- UriResolver resolver = new PackageMapUriResolver(provider, EMPTY_MAP);
+ UriResolver resolver = PackageMapUriResolver(provider, EMPTY_MAP);
Uri uri = Uri.parse('package:analyzer/analyzer.dart');
Source result = resolver.resolveAbsolute(uri);
expect(result, isNull);
@@ -131,7 +131,7 @@
provider.newFile(pkgFileA, 'library lib_a;');
provider.newFile(pkgFileB, 'library lib_b;');
PackageMapUriResolver resolver =
- new PackageMapUriResolver(provider, <String, List<Folder>>{
+ PackageMapUriResolver(provider, <String, List<Folder>>{
'pkgA': <Folder>[provider.getResource(provider.convertPath('/pkgA/lib'))],
'pkgB': <Folder>[provider.getResource(provider.convertPath('/pkgB/lib'))]
});
@@ -157,6 +157,6 @@
}
Source _createFileSource(String path) {
- return new NonExistingSource(path, toUri(path), UriKind.FILE_URI);
+ return NonExistingSource(path, toUri(path), UriKind.FILE_URI);
}
}
diff --git a/pkg/analyzer/test/source/path_filter_test.dart b/pkg/analyzer/test/source/path_filter_test.dart
index 279deb4..5a115f6 100644
--- a/pkg/analyzer/test/source/path_filter_test.dart
+++ b/pkg/analyzer/test/source/path_filter_test.dart
@@ -12,37 +12,37 @@
setUp(() {});
tearDown(() {});
test('test_ignoreEverything', () {
- var filter = new PathFilter(root('/'), ['*'], context);
+ var filter = PathFilter(root('/'), ['*'], context);
expect(filter.ignored('a'), isTrue);
});
test('test_ignoreFile', () {
- var filter = new PathFilter(root('/'), ['apple'], context);
+ var filter = PathFilter(root('/'), ['apple'], context);
expect(filter.ignored('apple'), isTrue);
expect(filter.ignored('banana'), isFalse);
});
test('test_ignoreMultipleFiles', () {
- var filter = new PathFilter(root('/'), ['apple', 'banana'], context);
+ var filter = PathFilter(root('/'), ['apple', 'banana'], context);
expect(filter.ignored('apple'), isTrue);
expect(filter.ignored('banana'), isTrue);
});
test('test_ignoreSubDir', () {
- var filter = new PathFilter(root('/'), ['apple/*'], context);
+ var filter = PathFilter(root('/'), ['apple/*'], context);
expect(filter.ignored('apple/banana'), isTrue);
expect(filter.ignored('apple/banana/cantaloupe'), isFalse);
});
test('test_ignoreTree', () {
- var filter = new PathFilter(root('/'), ['apple/**'], context);
+ var filter = PathFilter(root('/'), ['apple/**'], context);
expect(filter.ignored('apple/banana'), isTrue);
expect(filter.ignored('apple/banana/cantaloupe'), isTrue);
});
test('test_ignoreSdkExt', () {
- var filter = new PathFilter(root('/'), ['sdk_ext/**'], context);
+ var filter = PathFilter(root('/'), ['sdk_ext/**'], context);
expect(filter.ignored('sdk_ext/entry.dart'), isTrue);
expect(filter.ignored('sdk_ext/lib/src/part.dart'), isTrue);
});
test('test_outsideRoot', () {
var filter =
- new PathFilter(root('/workspace/dart/sdk'), ['sdk_ext/**'], context);
+ PathFilter(root('/workspace/dart/sdk'), ['sdk_ext/**'], context);
expect(filter.ignored('/'), isTrue);
expect(filter.ignored('/workspace'), isTrue);
expect(filter.ignored('/workspace/dart'), isTrue);
@@ -51,7 +51,7 @@
});
test('test_relativePaths', () {
var filter =
- new PathFilter(root('/workspace/dart/sdk'), ['sdk_ext/**'], context);
+ PathFilter(root('/workspace/dart/sdk'), ['sdk_ext/**'], context);
expect(filter.ignored('../apple'), isTrue);
expect(filter.ignored('../sdk/main.dart'), isFalse);
expect(filter.ignored('../sdk/sdk_ext/entry.dart'), isTrue);
diff --git a/pkg/analyzer/test/source/sdk_ext_test.dart b/pkg/analyzer/test/source/sdk_ext_test.dart
index 0172bc6..289602a 100644
--- a/pkg/analyzer/test/source/sdk_ext_test.dart
+++ b/pkg/analyzer/test/source/sdk_ext_test.dart
@@ -36,25 +36,25 @@
}
test_create_badJSON() {
- var resolver = new SdkExtUriResolver(null);
+ var resolver = SdkExtUriResolver(null);
resolver.addSdkExt(r'''{{{,{{}}},}}''', null);
expect(resolver.length, 0);
}
test_create_noSdkExtPackageMap() {
- var resolver = new SdkExtUriResolver({
+ var resolver = SdkExtUriResolver({
'fox': <Folder>[getFolder('/empty')]
});
expect(resolver.length, 0);
}
test_create_nullPackageMap() {
- var resolver = new SdkExtUriResolver(null);
+ var resolver = SdkExtUriResolver(null);
expect(resolver.length, 0);
}
test_create_sdkExtPackageMap() {
- var resolver = new SdkExtUriResolver({
+ var resolver = SdkExtUriResolver({
'fox': <Folder>[newFolder('/tmp')]
});
// We have four mappings.
@@ -67,7 +67,7 @@
}
test_restoreAbsolute() {
- var resolver = new SdkExtUriResolver({
+ var resolver = SdkExtUriResolver({
'fox': <Folder>[newFolder('/tmp')]
});
var source = resolver.resolveAbsolute(Uri.parse('dart:fox'));
diff --git a/pkg/analyzer/test/src/command_line/arguments_test.dart b/pkg/analyzer/test/src/command_line/arguments_test.dart
index d9e2e10..9e2a63c 100644
--- a/pkg/analyzer/test/src/command_line/arguments_test.dart
+++ b/pkg/analyzer/test/src/command_line/arguments_test.dart
@@ -25,7 +25,7 @@
String defaultAnalysisOptionsFilePath = 'b';
String defaultPackageFilePath = 'c';
String defaultPackagesDirectoryPath = 'd';
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = [
'--dart-sdk-summary=$dartSdkSummaryPath',
@@ -57,7 +57,7 @@
}
void test_createContextBuilderOptions_none() {
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = [];
ArgResults result = parse(resourceProvider, parser, args);
@@ -76,7 +76,7 @@
}
void test_createDartSdkManager_noPath_noSummaries() {
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = [];
ArgResults result = parse(resourceProvider, parser, args);
@@ -89,7 +89,7 @@
}
void test_createDartSdkManager_noPath_summaries() {
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = [];
ArgResults result = parse(resourceProvider, parser, args);
@@ -103,7 +103,7 @@
}
void test_createDartSdkManager_path_noSummaries() {
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = ['--dart-sdk=x'];
ArgResults result = parse(resourceProvider, parser, args);
@@ -115,7 +115,7 @@
}
void test_createDartSdkManager_path_summaries() {
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = ['--dart-sdk=y'];
ArgResults result = parse(resourceProvider, parser, args);
@@ -127,7 +127,7 @@
}
void test_defineAnalysisArguments() {
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
expect(parser.options, hasLength(12));
}
@@ -149,7 +149,7 @@
void test_filterUnknownArguments() {
List<String> args = ['--a', '--b', '--c=0', '--d=1', '-e=2', '-f', 'bar'];
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
parser.addFlag('a');
parser.addOption('c');
parser.addOption('ee', abbr: 'e');
@@ -159,7 +159,7 @@
}
void test_implicitCast() {
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = [
'--implicit-casts',
@@ -173,7 +173,7 @@
}
void test_noImplicitCast() {
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
defineAnalysisArguments(parser);
List<String> args = [
'--no-implicit-casts',
@@ -187,7 +187,7 @@
}
void test_parse_noReplacement_noIgnored() {
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
parser.addFlag('xx');
parser.addOption('yy');
List<String> args = ['--xx', '--yy=abc', 'foo', 'bar'];
diff --git a/pkg/analyzer/test/src/context/builder_test.dart b/pkg/analyzer/test/src/context/builder_test.dart
index fccee0d..9ea669f 100644
--- a/pkg/analyzer/test/src/context/builder_test.dart
+++ b/pkg/analyzer/test/src/context/builder_test.dart
@@ -54,7 +54,7 @@
/**
* The options passed to the context builder.
*/
- ContextBuilderOptions builderOptions = new ContextBuilderOptions();
+ ContextBuilderOptions builderOptions = ContextBuilderOptions();
/**
* The context builder to be used in the test.
@@ -73,7 +73,7 @@
_MockLintRule _mockPublicMemberApiDocs;
Uri convertedDirectoryUri(String directoryPath) {
- return new Uri.directory(convertPath(directoryPath),
+ return Uri.directory(convertPath(directoryPath),
windows: resourceProvider.pathContext.style == path.windows.style);
}
@@ -87,16 +87,16 @@
"core": const LibraryInfo("core/core.dart"),
};
''');
- sdkManager = new DartSdkManager(defaultSdkPath, false);
- builder = new ContextBuilder(resourceProvider, sdkManager, contentCache,
+ sdkManager = DartSdkManager(defaultSdkPath, false);
+ builder = ContextBuilder(resourceProvider, sdkManager, contentCache,
options: builderOptions);
}
void setUp() {
- new MockSdk(resourceProvider: resourceProvider);
- sdkManager = new DartSdkManager(convertPath('/sdk'), false);
- contentCache = new ContentCache();
- builder = new ContextBuilder(
+ MockSdk(resourceProvider: resourceProvider);
+ sdkManager = DartSdkManager(convertPath('/sdk'), false);
+ contentCache = ContentCache();
+ builder = ContextBuilder(
resourceProvider,
sdkManager,
contentCache,
@@ -111,13 +111,13 @@
void test_cmdline_lint_defined() {
_defineMockLintRules();
- ArgParser argParser = new ArgParser();
+ ArgParser argParser = ArgParser();
defineAnalysisArguments(argParser);
ArgResults argResults = argParser.parse(['--$lintsFlag']);
- var builder = new ContextBuilder(resourceProvider, sdkManager, contentCache,
+ var builder = ContextBuilder(resourceProvider, sdkManager, contentCache,
options: createContextBuilderOptions(argResults));
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
expected.lint = true;
expected.lintRules = <LintRule>[
Registry.ruleRegistry['mock_lint_rule'],
@@ -136,13 +136,13 @@
}
void test_cmdline_lint_off() {
- ArgParser argParser = new ArgParser();
+ ArgParser argParser = ArgParser();
defineAnalysisArguments(argParser);
ArgResults argResults = argParser.parse(['--no-$lintsFlag']);
- var builder = new ContextBuilder(resourceProvider, sdkManager, contentCache,
+ var builder = ContextBuilder(resourceProvider, sdkManager, contentCache,
options: createContextBuilderOptions(argResults));
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
expected.lint = false;
expected.lintRules = <LintRule>[
Registry.ruleRegistry['mock_lint_rule'],
@@ -161,13 +161,13 @@
}
void test_cmdline_lint_unspecified_1() {
- ArgParser argParser = new ArgParser();
+ ArgParser argParser = ArgParser();
defineAnalysisArguments(argParser);
ArgResults argResults = argParser.parse([]);
- var builder = new ContextBuilder(resourceProvider, sdkManager, contentCache,
+ var builder = ContextBuilder(resourceProvider, sdkManager, contentCache,
options: createContextBuilderOptions(argResults));
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
expected.lint = true;
expected.lintRules = <LintRule>[
Registry.ruleRegistry['mock_lint_rule'],
@@ -186,13 +186,13 @@
}
void test_cmdline_lint_unspecified_2() {
- ArgParser argParser = new ArgParser();
+ ArgParser argParser = ArgParser();
defineAnalysisArguments(argParser);
ArgResults argResults = argParser.parse([]);
- var builder = new ContextBuilder(resourceProvider, sdkManager, contentCache,
+ var builder = ContextBuilder(resourceProvider, sdkManager, contentCache,
options: createContextBuilderOptions(argResults));
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
expected.lint = false;
expected.lintRules = <LintRule>[];
@@ -246,7 +246,7 @@
String barPath = convertPath('/pkg/bar');
Uri barUri = resourceProvider.pathContext.toUri(barPath);
- MapPackages packages = new MapPackages({fooName: fooUri, barName: barUri});
+ MapPackages packages = MapPackages({fooName: fooUri, barName: barUri});
Map<String, List<Folder>> result = builder.convertPackagesToMap(packages);
expect(result, isNotNull);
expect(result, hasLength(2));
@@ -259,7 +259,7 @@
void test_createDefaultOptions_default() {
// Invert a subset of the options to ensure that the default options are
// being returned.
- AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl defaultOptions = AnalysisOptionsImpl();
defaultOptions.dart2jsHint = !defaultOptions.dart2jsHint;
defaultOptions.enableLazyAssignmentOperators =
!defaultOptions.enableLazyAssignmentOperators;
@@ -270,7 +270,7 @@
void test_createDefaultOptions_noDefault() {
AnalysisOptions options = builder.createDefaultOptions();
- _expectEqualOptions(options, new AnalysisOptionsImpl());
+ _expectEqualOptions(options, AnalysisOptionsImpl());
}
void test_createPackageMap_fromPackageDirectory_explicit() {
@@ -399,7 +399,7 @@
newFolder('/workspace/bazel-genfiles');
newFolder(projectPath);
- AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl options = AnalysisOptionsImpl();
SourceFactoryImpl factory =
builder.createSourceFactory(projectPath, options);
expect(factory.resolvers,
@@ -416,7 +416,7 @@
newFolder(projectPath);
newFile(join(projectPath, '.packages'));
- AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl options = AnalysisOptionsImpl();
SourceFactoryImpl factory =
builder.createSourceFactory(projectPath, options);
expect(factory.resolvers,
@@ -450,7 +450,7 @@
newFile(extensionPath, content: '''{
"dart:foo": "${_relativeUri(fooPath, from: packageB)}"
}''');
- AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl options = AnalysisOptionsImpl();
SourceFactory factory = builder.createSourceFactory(projectPath, options);
@@ -487,7 +487,7 @@
"dart:async": ${_relativeUri(asyncPath, from: packageA)}
"dart:core": ${_relativeUri(corePath, from: packageA)}
''');
- AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl options = AnalysisOptionsImpl();
SourceFactory factory = builder.createSourceFactory(projectPath, options);
@@ -517,7 +517,7 @@
a:${resourceProvider.pathContext.toUri(packageA)}
b:${resourceProvider.pathContext.toUri(packageB)}
''');
- AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl options = AnalysisOptionsImpl();
SourceFactory factory = builder.createSourceFactory(projectPath, options);
@@ -618,12 +618,12 @@
}
void test_findSdk_noPackageMap() {
- DartSdk sdk = builder.findSdk(null, new AnalysisOptionsImpl());
+ DartSdk sdk = builder.findSdk(null, AnalysisOptionsImpl());
expect(sdk, isNotNull);
}
void test_findSdk_noPackageMap_html_strong() {
- DartSdk sdk = builder.findSdk(null, new AnalysisOptionsImpl());
+ DartSdk sdk = builder.findSdk(null, AnalysisOptionsImpl());
expect(sdk, isNotNull);
Source htmlSource = sdk.mapDartUri('dart:html');
expect(htmlSource.fullName,
@@ -633,9 +633,9 @@
void test_getAnalysisOptions_default_bazel() {
_defineMockLintRules();
- AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl defaultOptions = AnalysisOptionsImpl();
builderOptions.defaultOptions = defaultOptions;
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
expected.lint = true;
expected.lintRules = <Linter>[_mockLintRule];
newFile('/root/WORKSPACE');
@@ -656,9 +656,9 @@
void test_getAnalysisOptions_default_flutter() {
_defineMockLintRules();
- AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl defaultOptions = AnalysisOptionsImpl();
builderOptions.defaultOptions = defaultOptions;
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
expected.lint = true;
expected.lintRules = <Linter>[_mockLintRule];
String packagesFilePath = convertPath('/some/directory/path/.packages');
@@ -674,10 +674,10 @@
}
void test_getAnalysisOptions_default_noOverrides() {
- AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl defaultOptions = AnalysisOptionsImpl();
defaultOptions.enableLazyAssignmentOperators = true;
builderOptions.defaultOptions = defaultOptions;
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
expected.enableLazyAssignmentOperators = true;
String path = convertPath('/some/directory/path');
String filePath = join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
@@ -692,10 +692,10 @@
}
void test_getAnalysisOptions_default_overrides() {
- AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl defaultOptions = AnalysisOptionsImpl();
defaultOptions.implicitDynamic = true;
builderOptions.defaultOptions = defaultOptions;
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
expected.implicitDynamic = false;
String path = convertPath('/some/directory/path');
String filePath = join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
@@ -716,22 +716,22 @@
newFile('/workspace/out/debug/gen/dart.sources/foo_pkg',
content: _p('/workspace/foo_pkg/lib'));
newFolder(projectPath);
- ArgParser argParser = new ArgParser();
+ ArgParser argParser = ArgParser();
defineAnalysisArguments(argParser);
ArgResults argResults = argParser.parse([]);
builderOptions = createContextBuilderOptions(argResults);
- builder = new ContextBuilder(resourceProvider, sdkManager, contentCache,
+ builder = ContextBuilder(resourceProvider, sdkManager, contentCache,
options: builderOptions);
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
AnalysisOptions options = builder.getAnalysisOptions(projectPath);
_expectEqualOptions(options, expected);
}
void test_getAnalysisOptions_includes() {
_defineMockLintRules();
- AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl defaultOptions = AnalysisOptionsImpl();
builderOptions.defaultOptions = defaultOptions;
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
expected.lint = true;
expected.lintRules = <Linter>[
_mockLintRule,
@@ -784,11 +784,11 @@
''');
AnalysisOptions options = builder.getAnalysisOptions(path);
- _expectEqualOptions(options, new AnalysisOptionsImpl());
+ _expectEqualOptions(options, AnalysisOptionsImpl());
}
void test_getAnalysisOptions_noDefault_overrides() {
- AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl expected = AnalysisOptionsImpl();
expected.implicitDynamic = false;
String path = convertPath('/some/directory/path');
String filePath = join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
@@ -812,7 +812,7 @@
''');
ContextRoot root =
- new ContextRoot(path, [], pathContext: resourceProvider.pathContext);
+ ContextRoot(path, [], pathContext: resourceProvider.pathContext);
builder.getAnalysisOptions(path, contextRoot: root);
expect(root.optionsFilePath, equals(filePath));
}
@@ -889,13 +889,13 @@
}
_defineMockLintRules() {
- _mockLintRule = new _MockLintRule('mock_lint_rule');
+ _mockLintRule = _MockLintRule('mock_lint_rule');
Registry.ruleRegistry.register(_mockLintRule);
- _mockLintRule2 = new _MockLintRule('mock_lint_rule2');
+ _mockLintRule2 = _MockLintRule('mock_lint_rule2');
Registry.ruleRegistry.register(_mockLintRule2);
- _mockLintRule3 = new _MockLintRule('mock_lint_rule3');
+ _mockLintRule3 = _MockLintRule('mock_lint_rule3');
Registry.ruleRegistry.register(_mockLintRule3);
- _mockPublicMemberApiDocs = new _MockLintRule('public_member_api_docs');
+ _mockPublicMemberApiDocs = _MockLintRule('public_member_api_docs');
Registry.ruleRegistry.register(_mockPublicMemberApiDocs);
}
@@ -937,20 +937,20 @@
@reflectiveTest
class EmbedderYamlLocatorTest extends EmbedderRelatedTest {
void test_empty() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(emptyPath)]
});
expect(locator.embedderYamls, hasLength(0));
}
void test_invalid() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator(null);
+ EmbedderYamlLocator locator = EmbedderYamlLocator(null);
locator.addEmbedderYaml(null, r'''{{{,{{}}},}}''');
expect(locator.embedderYamls, hasLength(0));
}
void test_valid() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
expect(locator.embedderYamls, hasLength(1));
diff --git a/pkg/analyzer/test/src/context/source_test.dart b/pkg/analyzer/test/src/context/source_test.dart
index 5bc3108..9d7527e 100644
--- a/pkg/analyzer/test/src/context/source_test.dart
+++ b/pkg/analyzer/test/src/context/source_test.dart
@@ -22,9 +22,9 @@
String libPath = convertPath('/pkgs/somepkg/lib');
Uri libUri = getFolder(libPath).toUri();
Map<String, Uri> packageUriMap = <String, Uri>{'foo': libUri};
- SourceFactoryImpl sourceFactory = new SourceFactoryImpl(
- <UriResolver>[new ResourceUriResolver(resourceProvider)],
- new _MockPackages(packageUriMap),
+ SourceFactoryImpl sourceFactory = SourceFactoryImpl(
+ <UriResolver>[ResourceUriResolver(resourceProvider)],
+ _MockPackages(packageUriMap),
);
Source libSource = newFile('/pkgs/somepkg/lib').createSource();
Uri uri = sourceFactory.restoreUri(libSource);
diff --git a/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart b/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart
index b2870e7..02eadbe 100644
--- a/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart
@@ -18,7 +18,7 @@
@reflectiveTest
class AnalysisContextCollectionTest with ResourceProviderMixin {
void setUp() {
- new MockSdk(resourceProvider: resourceProvider);
+ MockSdk(resourceProvider: resourceProvider);
}
test_contextFor_noContext() {
@@ -47,14 +47,14 @@
test_new_includedPaths_notAbsolute() {
expect(
- () => new AnalysisContextCollectionImpl(includedPaths: ['root']),
+ () => AnalysisContextCollectionImpl(includedPaths: ['root']),
throwsArgumentError,
);
}
test_new_includedPaths_notNormalized() {
expect(
- () => new AnalysisContextCollectionImpl(
+ () => AnalysisContextCollectionImpl(
includedPaths: [convertPath('/root/lib/../lib')]),
throwsArgumentError,
);
@@ -93,7 +93,7 @@
test_new_sdkPath_notAbsolute() {
expect(
- () => new AnalysisContextCollectionImpl(
+ () => AnalysisContextCollectionImpl(
includedPaths: ['/root'], sdkPath: 'sdk'),
throwsArgumentError,
);
@@ -101,7 +101,7 @@
test_new_sdkPath_notNormalized() {
expect(
- () => new AnalysisContextCollectionImpl(
+ () => AnalysisContextCollectionImpl(
includedPaths: [convertPath('/root')], sdkPath: '/home/sdk/../sdk'),
throwsArgumentError,
);
@@ -109,7 +109,7 @@
AnalysisContextCollectionImpl _newCollection(
{@required List<String> includedPaths}) {
- return new AnalysisContextCollectionImpl(
+ return AnalysisContextCollectionImpl(
resourceProvider: resourceProvider,
includedPaths: includedPaths,
sdkPath: convertPath(sdkRoot),
diff --git a/pkg/analyzer/test/src/dart/analysis/base.dart b/pkg/analyzer/test/src/dart/analysis/base.dart
index 29aeeb5..7119c7e 100644
--- a/pkg/analyzer/test/src/dart/analysis/base.dart
+++ b/pkg/analyzer/test/src/dart/analysis/base.dart
@@ -27,7 +27,7 @@
*/
Element findChildElement(Element root, String name, [ElementKind kind]) {
Element result;
- root.accept(new _ElementVisitorFunctionWrapper((Element element) {
+ root.accept(_ElementVisitorFunctionWrapper((Element element) {
if (element.name != name) {
return;
}
@@ -48,14 +48,14 @@
class BaseAnalysisDriverTest with ResourceProviderMixin {
DartSdk sdk;
- final ByteStore byteStore = new MemoryByteStore();
- final FileContentOverlay contentOverlay = new FileContentOverlay();
+ final ByteStore byteStore = MemoryByteStore();
+ final FileContentOverlay contentOverlay = FileContentOverlay();
- final StringBuffer logBuffer = new StringBuffer();
+ final StringBuffer logBuffer = StringBuffer();
PerformanceLog logger;
final _GeneratedUriResolverMock generatedUriResolver =
- new _GeneratedUriResolverMock();
+ _GeneratedUriResolverMock();
AnalysisDriverScheduler scheduler;
AnalysisDriver driver;
final List<AnalysisStatus> allStatuses = <AnalysisStatus>[];
@@ -70,7 +70,7 @@
bool get disableChangesAndCacheAllResults => false;
- void addTestFile(String content, {bool priority: false}) {
+ void addTestFile(String content, {bool priority = false}) {
testCode = content;
newFile(testFile, content: content);
driver.addFile(testFile);
@@ -87,18 +87,18 @@
'aaa': [getFolder('/aaa/lib')],
'bbb': [getFolder('/bbb/lib')],
};
- return new AnalysisDriver(
+ return AnalysisDriver(
scheduler,
logger,
resourceProvider,
byteStore,
contentOverlay,
null,
- new SourceFactory([
- new DartUriResolver(sdk),
+ SourceFactory([
+ DartUriResolver(sdk),
generatedUriResolver,
- new PackageMapUriResolver(resourceProvider, packageMap),
- new ResourceUriResolver(resourceProvider)
+ PackageMapUriResolver(resourceProvider, packageMap),
+ ResourceUriResolver(resourceProvider)
], null, resourceProvider),
createAnalysisOptions(),
disableChangesAndCacheAllResults: disableChangesAndCacheAllResults,
@@ -106,7 +106,7 @@
externalSummaries: externalSummaries);
}
- AnalysisOptionsImpl createAnalysisOptions() => new AnalysisOptionsImpl()
+ AnalysisOptionsImpl createAnalysisOptions() => AnalysisOptionsImpl()
..useFastaParser = analyzer.Parser.useFasta
..enabledExperiments = enabledExperiments;
@@ -140,11 +140,11 @@
}
void setUp() {
- sdk = new MockSdk(resourceProvider: resourceProvider);
+ sdk = MockSdk(resourceProvider: resourceProvider);
testProject = convertPath('/test/lib');
testFile = convertPath('/test/lib/test.dart');
- logger = new PerformanceLog(logBuffer);
- scheduler = new AnalysisDriverScheduler(logger);
+ logger = PerformanceLog(logBuffer);
+ scheduler = AnalysisDriverScheduler(logger);
driver = createAnalysisDriver();
scheduler.start();
scheduler.status.listen(allStatuses.add);
@@ -179,7 +179,7 @@
@override
noSuchMethod(Invocation invocation) {
- throw new StateError('Unexpected invocation of ${invocation.memberName}');
+ throw StateError('Unexpected invocation of ${invocation.memberName}');
}
@override
diff --git a/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart b/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart
index 1a2be58..38435ac 100644
--- a/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart
@@ -14,14 +14,14 @@
}
List<int> _b(int length) {
- return new List<int>(length);
+ return List<int>(length);
}
@reflectiveTest
class MemoryCachingByteStoreTest {
test_get_notFound_evict() {
- var store = new NullByteStore();
- var cachingStore = new MemoryCachingByteStore(store, 100);
+ var store = NullByteStore();
+ var cachingStore = MemoryCachingByteStore(store, 100);
// Request '1'. Nothing found.
cachingStore.get('1');
@@ -33,9 +33,9 @@
}
test_get_notFound_retry() {
- var mockStore = new NullByteStore();
- var baseStore = new MemoryCachingByteStore(mockStore, 1000);
- var cachingStore = new MemoryCachingByteStore(baseStore, 100);
+ var mockStore = NullByteStore();
+ var baseStore = MemoryCachingByteStore(mockStore, 1000);
+ var cachingStore = MemoryCachingByteStore(baseStore, 100);
// Request '1'. Nothing found.
expect(cachingStore.get('1'), isNull);
@@ -49,8 +49,8 @@
}
test_get_put_evict() {
- var store = new NullByteStore();
- var cachingStore = new MemoryCachingByteStore(store, 100);
+ var store = NullByteStore();
+ var cachingStore = MemoryCachingByteStore(store, 100);
// Keys: [1, 2].
cachingStore.put('1', _b(40));
@@ -69,8 +69,8 @@
}
test_put_evict_first() {
- var store = new NullByteStore();
- var cachingStore = new MemoryCachingByteStore(store, 100);
+ var store = NullByteStore();
+ var cachingStore = MemoryCachingByteStore(store, 100);
// 40 + 50 < 100
cachingStore.put('1', _b(40));
@@ -87,8 +87,8 @@
}
test_put_evict_firstAndSecond() {
- var store = new NullByteStore();
- var cachingStore = new MemoryCachingByteStore(store, 100);
+ var store = NullByteStore();
+ var cachingStore = MemoryCachingByteStore(store, 100);
// 10 + 80 < 100
cachingStore.put('1', _b(10));
@@ -108,7 +108,7 @@
@reflectiveTest
class NullByteStoreTest {
test_get() {
- var store = new NullByteStore();
+ var store = NullByteStore();
expect(store.get('1'), isNull);
diff --git a/pkg/analyzer/test/src/dart/analysis/cache_test.dart b/pkg/analyzer/test/src/dart/analysis/cache_test.dart
index 60524d6..67ec341 100644
--- a/pkg/analyzer/test/src/dart/analysis/cache_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/cache_test.dart
@@ -13,7 +13,7 @@
}
List<int> _b(int length) {
- return new List<int>(length);
+ return List<int>(length);
}
@reflectiveTest
@@ -95,7 +95,7 @@
}
Cache<String, List<int>> _newBytesCache(int maxSizeBytes) =>
- new Cache<String, List<int>>(maxSizeBytes, (bytes) => bytes.length);
+ Cache<String, List<int>>(maxSizeBytes, (bytes) => bytes.length);
static List<int> _noBytes() => null;
}
diff --git a/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart b/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart
index c98351b..a937fd6 100644
--- a/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart
@@ -38,13 +38,13 @@
void setUp() {
newFile(io.Platform.resolvedExecutable); // create folders
var folder = newFolder('/home/test');
- contextBuilder = new ContextBuilderImpl(resourceProvider: resourceProvider);
- contextRoot = new ContextRootImpl(resourceProvider, folder);
+ contextBuilder = ContextBuilderImpl(resourceProvider: resourceProvider);
+ contextRoot = ContextRootImpl(resourceProvider, folder);
}
test_createContext_declaredVariables() {
DeclaredVariables declaredVariables =
- new DeclaredVariables.fromMap({'foo': 'true'});
+ DeclaredVariables.fromMap({'foo': 'true'});
DriverBasedAnalysisContext context = contextBuilder.createContext(
contextRoot: contextRoot, declaredVariables: declaredVariables);
expect(context.analysisOptions, isNotNull);
@@ -54,8 +54,8 @@
test_createContext_declaredVariables_sdkPath() {
DeclaredVariables declaredVariables =
- new DeclaredVariables.fromMap({'bar': 'true'});
- MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
+ DeclaredVariables.fromMap({'bar': 'true'});
+ MockSdk sdk = MockSdk(resourceProvider: resourceProvider);
DriverBasedAnalysisContext context = contextBuilder.createContext(
contextRoot: contextRoot,
declaredVariables: declaredVariables,
@@ -75,7 +75,7 @@
}
test_createContext_sdkPath() {
- MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
+ MockSdk sdk = MockSdk(resourceProvider: resourceProvider);
DriverBasedAnalysisContext context = contextBuilder.createContext(
contextRoot: contextRoot,
sdkPath: resourceProvider.convertPath(sdkRoot));
diff --git a/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart b/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart
index 300320e..1d80cb1 100644
--- a/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart
@@ -25,7 +25,7 @@
return root;
}
}
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write('Could not find "');
buffer.write(rootFolder.path);
buffer.write('" in');
@@ -38,7 +38,7 @@
}
void setUp() {
- contextLocator = new ContextLocatorImpl(resourceProvider: resourceProvider);
+ contextLocator = ContextLocatorImpl(resourceProvider: resourceProvider);
}
void test_locateRoots_multiple_dirAndNestedDir() {
@@ -135,7 +135,7 @@
return root;
}
}
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write('Could not find "');
buffer.write(includedPath);
buffer.write('" in');
diff --git a/pkg/analyzer/test/src/dart/analysis/context_root_test.dart b/pkg/analyzer/test/src/dart/analysis/context_root_test.dart
index 3e8299f..ce510fe 100644
--- a/pkg/analyzer/test/src/dart/analysis/context_root_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/context_root_test.dart
@@ -23,7 +23,7 @@
void setUp() {
rootPath = convertPath('/test/root');
rootFolder = newFolder(rootPath);
- contextRoot = new ContextRootImpl(resourceProvider, rootFolder);
+ contextRoot = ContextRootImpl(resourceProvider, rootFolder);
contextRoot.included.add(rootFolder);
}
@@ -84,7 +84,7 @@
String bPath = convertPath('/test/root/lib/b.dart');
File aFile = getFile(aPath);
- contextRoot = new ContextRootImpl(resourceProvider, rootFolder);
+ contextRoot = ContextRootImpl(resourceProvider, rootFolder);
contextRoot.included.add(aFile);
expect(contextRoot.isAnalyzed(aPath), isTrue);
diff --git a/pkg/analyzer/test/src/dart/analysis/dependency/reference_collector_test.dart b/pkg/analyzer/test/src/dart/analysis/dependency/reference_collector_test.dart
index ff7cce5..a2538a4 100644
--- a/pkg/analyzer/test/src/dart/analysis/dependency/reference_collector_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/dependency/reference_collector_test.dart
@@ -2252,10 +2252,10 @@
void _assertApi(Library library, String name, NodeKind kind,
{String memberOf,
String typeParameterOf,
- List<String> unprefixed: const [],
- Map<String, List<String>> prefixed: const {},
- List<String> superPrefixed: const [],
- List<_ExpectedClassMember> expectedMembers: const []}) {
+ List<String> unprefixed = const [],
+ Map<String, List<String>> prefixed = const {},
+ List<String> superPrefixed = const [],
+ List<_ExpectedClassMember> expectedMembers = const []}) {
var node = getNode(
library,
name: name,
@@ -2273,10 +2273,10 @@
}
void _assertDependencies(Dependencies dependencies,
- {List<String> unprefixed: const [],
- Map<String, List<String>> prefixed: const {},
- List<String> superPrefixed: const [],
- List<_ExpectedClassMember> expectedMembers: const []}) {
+ {List<String> unprefixed = const [],
+ Map<String, List<String>> prefixed = const {},
+ List<String> superPrefixed = const [],
+ List<_ExpectedClassMember> expectedMembers = const []}) {
expect(dependencies.unprefixedReferencedNames, unprefixed);
expect(dependencies.importPrefixes, prefixed.keys);
expect(dependencies.importPrefixedReferencedNames, prefixed.values);
@@ -2301,10 +2301,10 @@
void _assertImpl(Library library, String name, NodeKind kind,
{String memberOf,
String typeParameterOf,
- List<String> unprefixed: const [],
- Map<String, List<String>> prefixed: const {},
- List<String> superPrefixed: const [],
- List<_ExpectedClassMember> expectedMembers: const []}) {
+ List<String> unprefixed = const [],
+ Map<String, List<String>> prefixed = const {},
+ List<String> superPrefixed = const [],
+ List<_ExpectedClassMember> expectedMembers = const []}) {
var node = getNode(
library,
name: name,
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
index 573749d..9de6672 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
@@ -33,11 +33,11 @@
});
}
-final isDynamicType = new TypeMatcher<DynamicTypeImpl>();
+final isDynamicType = TypeMatcher<DynamicTypeImpl>();
-final isNeverType = new TypeMatcher<NeverTypeImpl>();
+final isNeverType = TypeMatcher<NeverTypeImpl>();
-final isVoidType = new TypeMatcher<VoidTypeImpl>();
+final isVoidType = TypeMatcher<VoidTypeImpl>();
/**
* Integration tests for resolution.
@@ -73,8 +73,7 @@
ClassElement get stringElement => typeProvider.stringType.element;
- TypeProvider get typeProvider =>
- result.unit.declaredElement.context.typeProvider;
+ TypeProvider get typeProvider => result.typeProvider;
void assertDeclaredVariableType(SimpleIdentifier node, String expected) {
VariableElement element = node.staticElement;
@@ -251,8 +250,8 @@
Future resolveTestFile() async {
result = await driver.getResult(testFile);
- findNode = new FindNode(result.content, result.unit);
- findElement = new FindElement(result.unit);
+ findNode = FindNode(result.content, result.unit);
+ findElement = FindElement(result.unit);
}
test_adjacentStrings() async {
@@ -569,7 +568,6 @@
''');
await resolveTestFile();
CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
ImportElement aImport = unit.declaredElement.library.imports[0];
PrefixElement aPrefix = aImport.prefix;
@@ -725,7 +723,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
CompilationUnitElement unitElement = unit.declaredElement;
- var typeProvider = unitElement.context.typeProvider;
ClassElement aClass = unitElement.getType('A');
var aGetter = aClass.getField('a').getter;
@@ -939,8 +936,6 @@
addTestFile(content);
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> mainStatements = _getMainStatements(result);
@@ -966,8 +961,6 @@
addTestFile(content);
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> mainStatements = _getMainStatements(result);
@@ -1016,8 +1009,6 @@
addTestFile(content);
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> statements = _getMainStatements(result);
ExpressionStatement statement = statements[0];
@@ -2165,9 +2156,7 @@
addTestFile(content);
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
InterfaceType intType = typeProvider.intType;
InterfaceType listIntType = typeProvider.listType2(intType);
@@ -2365,7 +2354,6 @@
''');
await resolveTestFile();
CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
ImportElement aImport = unit.declaredElement.library.imports[0];
LibraryElement aLibrary = aImport.importedLibrary;
@@ -2483,7 +2471,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
CompilationUnitElement unitElement = unit.declaredElement;
- var typeProvider = unitElement.context.typeProvider;
ClassElement cElement = unitElement.getType('C');
ConstructorElement defaultConstructor = cElement.constructors[0];
@@ -4947,7 +4934,6 @@
''');
await resolveTestFile();
CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
ClassDeclaration cDeclaration = unit.declarations[0];
@@ -4985,8 +4971,6 @@
}
''');
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> statements = _getMainStatements(result);
@@ -5021,7 +5005,6 @@
''');
await resolveTestFile();
CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> statements = _getMainStatements(result);
@@ -5054,8 +5037,6 @@
}
''');
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> statements = _getMainStatements(result);
@@ -5086,8 +5067,6 @@
}
''');
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> statements = _getMainStatements(result);
@@ -6163,8 +6142,6 @@
addTestFile(content);
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> mainStatements = _getMainStatements(result);
@@ -6202,7 +6179,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
ClassDeclaration cClassDeclaration = unit.declarations[1];
ClassElement cClassElement = cClassDeclaration.declaredElement;
@@ -6388,7 +6364,6 @@
var unitElement = result.unit.declaredElement;
ImportElement myImport = unitElement.library.imports[0];
PrefixElement myPrefix = myImport.prefix;
- var typeProvider = unitElement.context.typeProvider;
var myLibrary = myImport.importedLibrary;
var myUnit = myLibrary.definingCompilationUnit;
@@ -6465,8 +6440,6 @@
addTestFile(content);
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> mainStatements = _getMainStatements(result);
@@ -6514,8 +6487,6 @@
addTestFile(content);
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> mainStatements = _getMainStatements(result);
@@ -6554,7 +6525,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
ClassDeclaration cClassDeclaration = unit.declarations[1];
ClassElement cClassElement = cClassDeclaration.declaredElement;
@@ -6608,7 +6578,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
ClassDeclaration cClassDeclaration = unit.declarations[1];
ClassElement cClassElement = cClassDeclaration.declaredElement;
@@ -6643,7 +6612,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
ClassDeclaration cClassDeclaration = unit.declarations[1];
ClassElement cClassElement = cClassDeclaration.declaredElement;
@@ -7466,7 +7434,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
CompilationUnitElement unitElement = unit.declaredElement;
- var typeProvider = unitElement.context.typeProvider;
ClassDeclaration cNode = unit.declarations[0];
ClassElement cElement = cNode.declaredElement;
@@ -7513,8 +7480,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
- CompilationUnitElement unitElement = unit.declaredElement;
- var typeProvider = unitElement.context.typeProvider;
ClassDeclaration cNode = unit.declarations[0];
ClassElement cElement = cNode.declaredElement;
@@ -7560,7 +7525,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
CompilationUnitElement unitElement = unit.declaredElement;
- var typeProvider = unitElement.context.typeProvider;
{
TopLevelVariableDeclaration aDeclaration = unit.declarations[0];
@@ -7603,7 +7567,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
CompilationUnitElement unitElement = unit.declaredElement;
- var typeProvider = unitElement.context.typeProvider;
TopLevelVariableDeclaration variableDeclaration = unit.declarations[0];
expect(variableDeclaration.variables.type, isNull);
@@ -7718,7 +7681,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
CompilationUnitElement unitElement = unit.declaredElement;
- var typeProvider = unitElement.context.typeProvider;
FunctionTypeAlias alias = unit.declarations[0];
FunctionTypeAliasElement aliasElement = alias.declaredElement;
@@ -7752,7 +7714,6 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
CompilationUnitElement unitElement = unit.declaredElement;
- var typeProvider = unitElement.context.typeProvider;
ClassDeclaration aNode = unit.declarations[0];
ClassElement aElement = aNode.declaredElement;
@@ -7827,8 +7788,6 @@
}
''');
await resolveTestFile();
- CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
List<Statement> statements = _getMainStatements(result);
@@ -8038,7 +7997,6 @@
''');
await resolveTestFile();
CompilationUnit unit = result.unit;
- var typeProvider = unit.declaredElement.context.typeProvider;
FunctionTypeAlias fNode = unit.declarations[1];
FunctionTypeAliasElement fElement = fNode.declaredElement;
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 5a6a3f1..c5e43b1 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -46,21 +46,21 @@
* any code to run, as long as it's not waiting on some external event.
*/
Future pumpEventQueue([int times = 5000]) {
- if (times == 0) return new Future.value();
+ if (times == 0) return Future.value();
// We use a delayed future to allow microtask events to finish. The
// Future.value or Future() constructors use scheduleMicrotask themselves and
// would therefore not wait for microtask callbacks that are scheduled after
// invoking this method.
- return new Future.delayed(Duration.zero, () => pumpEventQueue(times - 1));
+ return Future.delayed(Duration.zero, () => pumpEventQueue(times - 1));
}
@reflectiveTest
class AnalysisDriverSchedulerTest with ResourceProviderMixin {
DartSdk sdk;
- final ByteStore byteStore = new MemoryByteStore();
- final FileContentOverlay contentOverlay = new FileContentOverlay();
+ final ByteStore byteStore = MemoryByteStore();
+ final FileContentOverlay contentOverlay = FileContentOverlay();
- final StringBuffer logBuffer = new StringBuffer();
+ final StringBuffer logBuffer = StringBuffer();
PerformanceLog logger;
AnalysisDriverScheduler scheduler;
@@ -68,27 +68,27 @@
List<ResolvedUnitResult> allResults = [];
AnalysisDriver newDriver() {
- sdk = new MockSdk(resourceProvider: resourceProvider);
- AnalysisDriver driver = new AnalysisDriver(
+ sdk = MockSdk(resourceProvider: resourceProvider);
+ AnalysisDriver driver = AnalysisDriver(
scheduler,
logger,
resourceProvider,
byteStore,
contentOverlay,
null,
- new SourceFactory([
- new DartUriResolver(sdk),
- new ResourceUriResolver(resourceProvider)
- ], null, resourceProvider),
- new AnalysisOptionsImpl());
+ SourceFactory(
+ [DartUriResolver(sdk), ResourceUriResolver(resourceProvider)],
+ null,
+ resourceProvider),
+ AnalysisOptionsImpl());
driver.results.forEach(allResults.add);
return driver;
}
void setUp() {
- sdk = new MockSdk(resourceProvider: resourceProvider);
- logger = new PerformanceLog(logBuffer);
- scheduler = new AnalysisDriverScheduler(logger);
+ sdk = MockSdk(resourceProvider: resourceProvider);
+ logger = PerformanceLog(logBuffer);
+ scheduler = AnalysisDriverScheduler(logger);
scheduler.start();
}
@@ -287,7 +287,7 @@
driver2.addFile(b);
driver2.addFile(c);
- Monitor idleStatusMonitor = new Monitor();
+ Monitor idleStatusMonitor = Monitor();
List<AnalysisStatus> allStatuses = [];
// awaiting times out.
// ignore: unawaited_futures
@@ -318,7 +318,7 @@
driver1.addFile(a);
driver2.addFile(b);
- Monitor idleStatusMonitor = new Monitor();
+ Monitor idleStatusMonitor = Monitor();
List<AnalysisStatus> allStatuses = [];
// awaiting times out.
// ignore: unawaited_futures
@@ -1106,7 +1106,7 @@
bbb() {}
''');
- Source generatedSource = new _SourceMock(generatedPath, uri);
+ Source generatedSource = _SourceMock(generatedPath, uri);
generatedUriResolver.resolveAbsoluteFunction =
(uri, actualUri) => generatedSource;
@@ -3021,7 +3021,7 @@
await scheduler.waitForIdle();
if (allExceptions.isNotEmpty) {
- var buffer = new StringBuffer();
+ var buffer = StringBuffer();
for (var exception in allExceptions) {
buffer.writeln('Path: ${exception.path}');
buffer.writeln('Exception: ${exception.exception}');
@@ -3222,6 +3222,6 @@
@override
noSuchMethod(Invocation invocation) {
- throw new StateError('Unexpected invocation of ${invocation.memberName}');
+ throw StateError('Unexpected invocation of ${invocation.memberName}');
}
}
diff --git a/pkg/analyzer/test/src/dart/analysis/file_byte_store_test.dart b/pkg/analyzer/test/src/dart/analysis/file_byte_store_test.dart
index 120aab9..af1072d 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_byte_store_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_byte_store_test.dart
@@ -14,7 +14,7 @@
@reflectiveTest
class FileByteStoreValidatorTest {
- final validator = new FileByteStoreValidator();
+ final validator = FileByteStoreValidator();
test_get_bad_notEnoughBytes() {
List<int> bytes = <int>[1, 2, 3];
diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
index c0c347e..a4195b1 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
@@ -5,6 +5,7 @@
import 'dart:convert';
import 'dart:typed_data';
+import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/byte_store.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart';
@@ -32,31 +33,31 @@
class FileSystemStateTest with ResourceProviderMixin {
MockSdk sdk;
- final ByteStore byteStore = new MemoryByteStore();
- final FileContentOverlay contentOverlay = new FileContentOverlay();
+ final ByteStore byteStore = MemoryByteStore();
+ final FileContentOverlay contentOverlay = FileContentOverlay();
- final StringBuffer logBuffer = new StringBuffer();
+ final StringBuffer logBuffer = StringBuffer();
final _GeneratedUriResolverMock generatedUriResolver =
- new _GeneratedUriResolverMock();
+ _GeneratedUriResolverMock();
SourceFactory sourceFactory;
PerformanceLog logger;
FileSystemState fileSystemState;
void setUp() {
- logger = new PerformanceLog(logBuffer);
- sdk = new MockSdk(resourceProvider: resourceProvider);
- sourceFactory = new SourceFactory([
- new DartUriResolver(sdk),
+ logger = PerformanceLog(logBuffer);
+ sdk = MockSdk(resourceProvider: resourceProvider);
+ sourceFactory = SourceFactory([
+ DartUriResolver(sdk),
generatedUriResolver,
- new PackageMapUriResolver(resourceProvider, <String, List<Folder>>{
+ PackageMapUriResolver(resourceProvider, <String, List<Folder>>{
'aaa': [getFolder('/aaa/lib')],
'bbb': [getFolder('/bbb/lib')],
}),
- new ResourceUriResolver(resourceProvider)
+ ResourceUriResolver(resourceProvider)
], null, resourceProvider);
- AnalysisOptions analysisOptions = new AnalysisOptionsImpl();
- fileSystemState = new FileSystemState(
+ AnalysisOptions analysisOptions = AnalysisOptionsImpl();
+ fileSystemState = FileSystemState(
logger,
byteStore,
contentOverlay,
@@ -64,8 +65,9 @@
'contextName',
sourceFactory,
analysisOptions,
- new Uint32List(0),
- new Uint32List(0));
+ DeclaredVariables(),
+ Uint32List(0),
+ Uint32List(0));
}
test_definedClassMemberNames() {
@@ -391,7 +393,7 @@
String templatePath = convertPath('/aaa/lib/foo.dart');
String generatedPath = convertPath('/generated/aaa/lib/foo.dart');
- Source generatedSource = new _SourceMock(generatedPath, uri);
+ Source generatedSource = _SourceMock(generatedPath, uri);
generatedUriResolver.resolveAbsoluteFunction =
(uri, actualUri) => generatedSource;
@@ -671,7 +673,7 @@
@override
noSuchMethod(Invocation invocation) {
- throw new StateError('Unexpected invocation of ${invocation.memberName}');
+ throw StateError('Unexpected invocation of ${invocation.memberName}');
}
@override
@@ -702,6 +704,6 @@
@override
noSuchMethod(Invocation invocation) {
- throw new StateError('Unexpected invocation of ${invocation.memberName}');
+ throw StateError('Unexpected invocation of ${invocation.memberName}');
}
}
diff --git a/pkg/analyzer/test/src/dart/analysis/fletcher16_test.dart b/pkg/analyzer/test/src/dart/analysis/fletcher16_test.dart
index fb801e5..091d70e 100644
--- a/pkg/analyzer/test/src/dart/analysis/fletcher16_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/fletcher16_test.dart
@@ -27,7 +27,7 @@
}
test_long() {
- List<int> data = new List.generate(6000, (i) => i);
+ List<int> data = List.generate(6000, (i) => i);
expect(fletcher16(data), 0x0178);
}
}
diff --git a/pkg/analyzer/test/src/dart/analysis/index_test.dart b/pkg/analyzer/test/src/dart/analysis/index_test.dart
index d7b788f..25f93cf 100644
--- a/pkg/analyzer/test/src/dart/analysis/index_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/index_test.dart
@@ -51,18 +51,18 @@
_ElementIndexAssert assertThat(Element element) {
List<_Relation> relations = _getElementRelations(element);
- return new _ElementIndexAssert(this, element, relations);
+ return _ElementIndexAssert(this, element, relations);
}
_NameIndexAssert assertThatName(String name) {
- return new _NameIndexAssert(this, name);
+ return _NameIndexAssert(this, name);
}
Element findElement(String name, [ElementKind kind]) {
return findChildElement(testUnitElement, name, kind);
}
- CompilationUnitElement importedUnit({int index: 0}) {
+ CompilationUnitElement importedUnit({int index = 0}) {
List<ImportElement> imports = testLibraryElement.imports;
return imports[index].importedLibrary.definingCompilationUnit;
}
@@ -1274,12 +1274,12 @@
if (length == null) {
length = getLeadingIdentifierLength(search);
}
- return new ExpectedLocation(testUnitElement, offset, length, isQualified);
+ return ExpectedLocation(testUnitElement, offset, length, isQualified);
}
void _failWithIndexDump(String msg) {
String packageIndexJsonString =
- new JsonEncoder.withIndent(' ').convert(index.toJson());
+ JsonEncoder.withIndent(' ').convert(index.toJson());
fail('$msg in\n' + packageIndexJsonString);
}
@@ -1289,7 +1289,7 @@
int _findElementId(Element element) {
int unitId = _getUnitId(element);
// Prepare the element that was put into the index.
- IndexElementInfo info = new IndexElementInfo(element);
+ IndexElementInfo info = IndexElementInfo(element);
element = info.element;
// Prepare element's name components.
int unitMemberId = index.nullStringId;
@@ -1335,7 +1335,7 @@
List<_Relation> relations = <_Relation>[];
for (int i = 0; i < index.usedElementOffsets.length; i++) {
if (index.usedElements[i] == elementId) {
- relations.add(new _Relation(
+ relations.add(_Relation(
index.usedElementKinds[i],
index.usedElementOffsets[i],
index.usedElementLengths[i],
@@ -1383,7 +1383,7 @@
AnalysisDriverUnitIndexBuilder indexBuilder = indexUnit(testUnit);
List<int> indexBytes = indexBuilder.toBuffer();
- index = new AnalysisDriverUnitIndex.fromBuffer(indexBytes);
+ index = AnalysisDriverUnitIndex.fromBuffer(indexBytes);
}
}
@@ -1391,7 +1391,7 @@
class IndexWithExtensionMethodsTest extends IndexTest {
@override
AnalysisOptionsImpl createAnalysisOptions() => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_isInvokedBy_MethodElement_ofExtension_instance() async {
diff --git a/pkg/analyzer/test/src/dart/analysis/mutex_test.dart b/pkg/analyzer/test/src/dart/analysis/mutex_test.dart
index a70119a..565168f 100644
--- a/pkg/analyzer/test/src/dart/analysis/mutex_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/mutex_test.dart
@@ -18,18 +18,18 @@
class MutexTest {
test_acquire() async {
var values = <int>[];
- var mutex = new Mutex();
+ var mutex = Mutex();
await Future.wait([
- new Future(() async {
+ Future(() async {
await mutex.acquire();
try {
- await new Future.delayed(new Duration(milliseconds: 10));
+ await Future.delayed(Duration(milliseconds: 10));
values.add(1);
} finally {
mutex.release();
}
}),
- new Future(() async {
+ Future(() async {
await mutex.acquire();
try {
values.add(2);
@@ -46,15 +46,15 @@
test_guard() async {
var values = <int>[];
- var mutex = new Mutex();
+ var mutex = Mutex();
await Future.wait([
- new Future(() async {
+ Future(() async {
await mutex.guard(() async {
- await new Future.delayed(new Duration(milliseconds: 10));
+ await Future.delayed(Duration(milliseconds: 10));
values.add(1);
});
}),
- new Future(() async {
+ Future(() async {
await mutex.guard(() async {
values.add(2);
});
@@ -67,14 +67,14 @@
}
test_release_noLock() {
- var mutex = new Mutex();
+ var mutex = Mutex();
expect(() {
mutex.release();
}, throwsStateError);
}
test_release_noLock_alreadyReleased() async {
- var mutex = new Mutex();
+ var mutex = Mutex();
await mutex.acquire();
mutex.release();
expect(() {
diff --git a/pkg/analyzer/test/src/dart/analysis/results_test.dart b/pkg/analyzer/test/src/dart/analysis/results_test.dart
index 9d9c4ed..6fdd90d 100644
--- a/pkg/analyzer/test/src/dart/analysis/results_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/results_test.dart
@@ -26,7 +26,7 @@
mixin ExtensionMethodsMixin implements GetElementDeclarationMixin {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_extension() async {
diff --git a/pkg/analyzer/test/src/dart/analysis/search_test.dart b/pkg/analyzer/test/src/dart/analysis/search_test.dart
index c6a0a66..9307097 100644
--- a/pkg/analyzer/test/src/dart/analysis/search_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/search_test.dart
@@ -35,7 +35,7 @@
final bool isQualified;
ExpectedResult(this.enclosingElement, this.kind, this.offset, this.length,
- {this.isResolved: true, this.isQualified: false});
+ {this.isResolved = true, this.isQualified = false});
bool operator ==(Object result) {
return result is SearchResult &&
@@ -49,7 +49,7 @@
@override
String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write("ExpectedResult(kind=");
buffer.write(kind);
buffer.write(", enclosingElement=");
@@ -350,7 +350,7 @@
CompilationUnit otherUnit = (await driver.getResult(other)).unit;
Element main = otherUnit.declaredElement.functions[0];
var expected = [
- new ExpectedResult(main, SearchResultKind.REFERENCE,
+ ExpectedResult(main, SearchResultKind.REFERENCE,
otherCode.indexOf('(); // in other'), 0,
isResolved: true, isQualified: true)
];
@@ -653,9 +653,9 @@
CompilationUnitElement unitElementA = element.parts[0];
CompilationUnitElement unitElementB = element.parts[1];
var expected = [
- new ExpectedResult(unitElementA, SearchResultKind.REFERENCE,
+ ExpectedResult(unitElementA, SearchResultKind.REFERENCE,
codeA.indexOf('lib; // A'), 'lib'.length),
- new ExpectedResult(unitElementB, SearchResultKind.REFERENCE,
+ ExpectedResult(unitElementB, SearchResultKind.REFERENCE,
codeB.indexOf('lib; // B'), 'lib'.length),
];
await _verifyReferences(element, expected);
@@ -679,9 +679,9 @@
CompilationUnitElement unitElementA = element.parts[0];
CompilationUnitElement unitElementB = element.parts[1];
var expected = [
- new ExpectedResult(unitElementA, SearchResultKind.REFERENCE,
+ ExpectedResult(unitElementA, SearchResultKind.REFERENCE,
codeA.indexOf('lib; // A'), 'lib'.length),
- new ExpectedResult(unitElementB, SearchResultKind.REFERENCE,
+ ExpectedResult(unitElementB, SearchResultKind.REFERENCE,
codeB.indexOf('lib; // B'), 'lib'.length),
];
await _verifyReferences(element, expected);
@@ -965,7 +965,7 @@
var expected = [
_expectId(main, SearchResultKind.REFERENCE, 'ppp.Future'),
_expectId(main, SearchResultKind.REFERENCE, 'ppp.Stream'),
- new ExpectedResult(c, SearchResultKind.REFERENCE,
+ ExpectedResult(c, SearchResultKind.REFERENCE,
partCode.indexOf('ppp.Future c'), 'ppp'.length)
];
await _verifyReferences(element, expected);
@@ -995,7 +995,7 @@
var expected = [
_expectId(main, SearchResultKind.REFERENCE, 'ppp.Future'),
_expectId(main, SearchResultKind.REFERENCE, 'ppp.Stream'),
- new ExpectedResult(c, SearchResultKind.REFERENCE,
+ ExpectedResult(c, SearchResultKind.REFERENCE,
partCode.indexOf('ppp.Future c'), 'ppp'.length)
];
await _verifyReferences(element, expected);
@@ -1029,9 +1029,9 @@
Element v2 = testLibraryElement.parts[1].topLevelVariables[0];
var expected = [
_expectId(v, SearchResultKind.REFERENCE, '_C v;', length: 2),
- new ExpectedResult(
+ ExpectedResult(
v1, SearchResultKind.REFERENCE, code1.indexOf('_C v1;'), 2),
- new ExpectedResult(
+ ExpectedResult(
v2, SearchResultKind.REFERENCE, code2.indexOf('_C v2;'), 2),
];
await _verifyReferences(element, expected);
@@ -1073,11 +1073,10 @@
Element v1 = testLibraryElement.parts[0].topLevelVariables[0];
Element v2 = testLibraryElement.parts[1].topLevelVariables[0];
var expected = [
- new ExpectedResult(
- v, SearchResultKind.REFERENCE, code.indexOf('_C v;'), 2),
- new ExpectedResult(
+ ExpectedResult(v, SearchResultKind.REFERENCE, code.indexOf('_C v;'), 2),
+ ExpectedResult(
v1, SearchResultKind.REFERENCE, code1.indexOf('_C v1;'), 2),
- new ExpectedResult(
+ ExpectedResult(
v2, SearchResultKind.REFERENCE, code2.indexOf('_C v2;'), 2),
];
await _verifyReferences(element, expected);
@@ -1107,11 +1106,11 @@
Element v1 = testLibraryElement.parts[0].topLevelVariables[0];
Element v2 = testLibraryElement.parts[1].topLevelVariables[0];
var expected = [
- new ExpectedResult(
+ ExpectedResult(
v, SearchResultKind.REFERENCE, testCode.indexOf('_C v;'), 2),
- new ExpectedResult(
+ ExpectedResult(
v1, SearchResultKind.REFERENCE, code1.indexOf('_C v1;'), 2),
- new ExpectedResult(
+ ExpectedResult(
v2, SearchResultKind.REFERENCE, code2.indexOf('_C v2;'), 2),
];
await _verifyReferences(element, expected);
@@ -1427,10 +1426,10 @@
LibraryElement coreLib = await driver.getLibraryByUri('dart:core');
ClassElement listElement = coreLib.getType('List');
- var searchedFiles = new SearchedFiles();
+ var searchedFiles = SearchedFiles();
var results = await driver.search.subTypes(listElement, searchedFiles);
- void assertHasResult(String path, String name, {bool not: false}) {
+ void assertHasResult(String path, String name, {bool not = false}) {
var matcher = contains(predicate((SearchResult r) {
var element = r.enclosingElement;
return element.name == name && element.source.fullName == path;
@@ -1550,19 +1549,19 @@
Element d = _findElement('D');
Element e = _findElement('e');
Element f = _findElement('f');
- RegExp regExp = new RegExp(r'^[ABCDef]$');
+ RegExp regExp = RegExp(r'^[ABCDef]$');
expect(await driver.search.topLevelElements(regExp),
unorderedEquals([a, b, c, d, e, f]));
}
ExpectedResult _expectId(
Element enclosingElement, SearchResultKind kind, String search,
- {int length, bool isResolved: true, bool isQualified: false}) {
+ {int length, bool isResolved = true, bool isQualified = false}) {
int offset = findOffset(search);
if (length == null) {
length = getLeadingIdentifierLength(search);
}
- return new ExpectedResult(enclosingElement, kind, offset, length,
+ return ExpectedResult(enclosingElement, kind, offset, length,
isResolved: isResolved, isQualified: isQualified);
}
@@ -1571,7 +1570,7 @@
*/
ExpectedResult _expectIdQ(
Element element, SearchResultKind kind, String search,
- {int length, bool isResolved: true}) {
+ {int length, bool isResolved = true}) {
return _expectId(element, kind, search, isQualified: true, length: length);
}
@@ -1601,11 +1600,11 @@
Element _findElementAtString(String search) {
int offset = findOffset(search);
- AstNode node = new NodeLocator(offset).searchWithin(testUnit);
+ AstNode node = NodeLocator(offset).searchWithin(testUnit);
return ElementLocator.locate(node);
}
- Future<void> _resolveTestUnit(String code, {bool addToDriver: true}) async {
+ Future<void> _resolveTestUnit(String code, {bool addToDriver = true}) async {
if (addToDriver) {
addTestFile(code);
} else {
@@ -1622,7 +1621,7 @@
Future<void> _verifyNameReferences(
String name, List<ExpectedResult> expectedMatches) async {
- var searchedFiles = new SearchedFiles();
+ var searchedFiles = SearchedFiles();
List<SearchResult> results =
await driver.search.unresolvedMemberReferences(name, searchedFiles);
_assertResults(results, expectedMatches);
@@ -1631,7 +1630,7 @@
Future _verifyReferences(
Element element, List<ExpectedResult> expectedMatches) async {
- var searchedFiles = new SearchedFiles();
+ var searchedFiles = SearchedFiles();
var results = await driver.search.references(element, searchedFiles);
_assertResults(results, expectedMatches);
expect(results, hasLength(expectedMatches.length));
@@ -1647,7 +1646,7 @@
class SearchWithExtensionMethodsTest extends SearchTest {
@override
AnalysisOptionsImpl createAnalysisOptions() => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_searchReferences_ExtensionElement() async {
diff --git a/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart b/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart
index 2a39d97..1a390a1 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart
@@ -23,7 +23,7 @@
@override
void setUp() {
super.setUp();
- helper = new AnalysisSessionHelper(driver.currentSession);
+ helper = AnalysisSessionHelper(driver.currentSession);
}
test_getClass_defined() async {
diff --git a/pkg/analyzer/test/src/dart/analysis/session_test.dart b/pkg/analyzer/test/src/dart/analysis/session_test.dart
index 055a4c0..839533e 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_test.dart
@@ -120,11 +120,12 @@
test_getParsedLibrary_getElementDeclaration_notThisLibrary() async {
newFile(testPath, content: '');
- var parsedLibrary = await session.getParsedLibrary(testPath);
-
- var typeProvider = await session.typeProvider;
+ var resolvedUnit = await session.getResolvedUnit(testPath);
+ var typeProvider = resolvedUnit.typeProvider;
var intClass = typeProvider.intType.element;
+ var parsedLibrary = await session.getParsedLibrary(testPath);
+
expect(() {
parsedLibrary.getElementDeclaration(intClass);
}, throwsArgumentError);
@@ -493,11 +494,13 @@
expect(session.resourceProvider, resourceProvider);
}
+ @deprecated
test_typeProvider() async {
var typeProvider = await session.typeProvider;
expect(typeProvider.intType.element.name, 'int');
}
+ @deprecated
test_typeSystem() async {
var typeSystem = await session.typeSystem;
var typeProvider = typeSystem.typeProvider;
diff --git a/pkg/analyzer/test/src/dart/analysis/uri_converter_test.dart b/pkg/analyzer/test/src/dart/analysis/uri_converter_test.dart
index c7e291e..67da0ca 100644
--- a/pkg/analyzer/test/src/dart/analysis/uri_converter_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/uri_converter_test.dart
@@ -27,24 +27,24 @@
Folder barFolder = newFolder('/packages/bar/lib');
Folder fooFolder = newFolder('/packages/foo/lib');
- SourceFactory sourceFactory = new SourceFactory([
- new DartUriResolver(new MockSdk(resourceProvider: resourceProvider)),
- new PackageMapUriResolver(resourceProvider, {
+ SourceFactory sourceFactory = SourceFactory([
+ DartUriResolver(MockSdk(resourceProvider: resourceProvider)),
+ PackageMapUriResolver(resourceProvider, {
'foo': [fooFolder],
'bar': [barFolder],
}),
- new ResourceUriResolver(resourceProvider),
+ ResourceUriResolver(resourceProvider),
], null, resourceProvider);
- ContextRoot contextRoot = new ContextRoot(barFolder.path, [],
+ ContextRoot contextRoot = ContextRoot(barFolder.path, [],
pathContext: resourceProvider.pathContext);
- MockAnalysisDriver driver = new MockAnalysisDriver();
+ MockAnalysisDriver driver = MockAnalysisDriver();
driver.resourceProvider = resourceProvider;
driver.sourceFactory = sourceFactory;
driver.contextRoot = contextRoot;
- uriConverter = new DriverBasedUriConverter(driver);
+ uriConverter = DriverBasedUriConverter(driver);
}
test_pathToUri_dart() {
diff --git a/pkg/analyzer/test/src/dart/ast/ast_test.dart b/pkg/analyzer/test/src/dart/ast/ast_test.dart
index 7c10555..79c11db 100644
--- a/pkg/analyzer/test/src/dart/ast/ast_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/ast_test.dart
@@ -28,9 +28,9 @@
void assertInContext(String snippet, bool isInContext) {
int index = testSource.indexOf(snippet);
expect(index >= 0, isTrue);
- NodeLocator visitor = new NodeLocator(index);
+ NodeLocator visitor = NodeLocator(index);
AstNodeImpl node = visitor.searchWithin(testUnit);
- expect(node, new TypeMatcher<ExpressionImpl>());
+ expect(node, TypeMatcher<ExpressionImpl>());
expect((node as ExpressionImpl).inConstantContext,
isInContext ? isTrue : isFalse);
}
@@ -472,7 +472,7 @@
void assertIsConst(String snippet, bool expectedResult) {
int index = testSource.indexOf(snippet);
expect(index >= 0, isTrue);
- NodeLocator visitor = new NodeLocator(index);
+ NodeLocator visitor = NodeLocator(index);
AstNodeImpl node = visitor.searchWithin(testUnit);
node = node.thisOrAncestorOfType<InstanceCreationExpressionImpl>();
expect(node, isNotNull);
diff --git a/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart b/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
index 791e065..39c1c33 100644
--- a/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
@@ -2839,8 +2839,8 @@
* visiting the given [node].
*/
void _assertSource(String expectedSource, AstNode node) {
- StringBuffer buffer = new StringBuffer();
- node.accept(new ToSourceVisitor(buffer));
+ StringBuffer buffer = StringBuffer();
+ node.accept(ToSourceVisitor(buffer));
expect(buffer.toString(), expectedSource);
}
}
diff --git a/pkg/analyzer/test/src/dart/ast/utilities_test.dart b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
index 8f414bc..1510706 100644
--- a/pkg/analyzer/test/src/dart/ast/utilities_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
@@ -40,17 +40,17 @@
VariableDeclarationList variableList = declaration.variables;
Identifier typeName = (variableList.type as TypeName).name;
SimpleIdentifier varName = variableList.variables[0].name;
- expect(new NodeLocator2(0).searchWithin(unit), same(unit));
- expect(new NodeLocator2(1).searchWithin(unit), same(typeName));
- expect(new NodeLocator2(2).searchWithin(unit), same(typeName));
- expect(new NodeLocator2(3).searchWithin(unit), same(typeName));
- expect(new NodeLocator2(4).searchWithin(unit), same(variableList));
- expect(new NodeLocator2(5).searchWithin(unit), same(varName));
- expect(new NodeLocator2(6).searchWithin(unit), same(varName));
- expect(new NodeLocator2(7).searchWithin(unit), same(declaration));
- expect(new NodeLocator2(8).searchWithin(unit), same(unit));
- expect(new NodeLocator2(9).searchWithin(unit), isNull);
- expect(new NodeLocator2(100).searchWithin(unit), isNull);
+ expect(NodeLocator2(0).searchWithin(unit), same(unit));
+ expect(NodeLocator2(1).searchWithin(unit), same(typeName));
+ expect(NodeLocator2(2).searchWithin(unit), same(typeName));
+ expect(NodeLocator2(3).searchWithin(unit), same(typeName));
+ expect(NodeLocator2(4).searchWithin(unit), same(variableList));
+ expect(NodeLocator2(5).searchWithin(unit), same(varName));
+ expect(NodeLocator2(6).searchWithin(unit), same(varName));
+ expect(NodeLocator2(7).searchWithin(unit), same(declaration));
+ expect(NodeLocator2(8).searchWithin(unit), same(unit));
+ expect(NodeLocator2(9).searchWithin(unit), isNull);
+ expect(NodeLocator2(100).searchWithin(unit), isNull);
}
void test_startEndOffset() {
@@ -61,16 +61,16 @@
VariableDeclarationList variableList = declaration.variables;
Identifier typeName = (variableList.type as TypeName).name;
SimpleIdentifier varName = variableList.variables[0].name;
- expect(new NodeLocator2(-1, 2).searchWithin(unit), isNull);
- expect(new NodeLocator2(0, 2).searchWithin(unit), same(unit));
- expect(new NodeLocator2(1, 2).searchWithin(unit), same(typeName));
- expect(new NodeLocator2(1, 3).searchWithin(unit), same(typeName));
- expect(new NodeLocator2(1, 4).searchWithin(unit), same(variableList));
- expect(new NodeLocator2(5, 6).searchWithin(unit), same(varName));
- expect(new NodeLocator2(5, 7).searchWithin(unit), same(declaration));
- expect(new NodeLocator2(5, 8).searchWithin(unit), same(unit));
- expect(new NodeLocator2(5, 100).searchWithin(unit), isNull);
- expect(new NodeLocator2(100, 200).searchWithin(unit), isNull);
+ expect(NodeLocator2(-1, 2).searchWithin(unit), isNull);
+ expect(NodeLocator2(0, 2).searchWithin(unit), same(unit));
+ expect(NodeLocator2(1, 2).searchWithin(unit), same(typeName));
+ expect(NodeLocator2(1, 3).searchWithin(unit), same(typeName));
+ expect(NodeLocator2(1, 4).searchWithin(unit), same(variableList));
+ expect(NodeLocator2(5, 6).searchWithin(unit), same(varName));
+ expect(NodeLocator2(5, 7).searchWithin(unit), same(declaration));
+ expect(NodeLocator2(5, 8).searchWithin(unit), same(unit));
+ expect(NodeLocator2(5, 100).searchWithin(unit), isNull);
+ expect(NodeLocator2(100, 200).searchWithin(unit), isNull);
}
}
@@ -83,7 +83,7 @@
}
void test_searchWithin_null() {
- NodeLocator locator = new NodeLocator(0, 0);
+ NodeLocator locator = NodeLocator(0, 0);
expect(locator.searchWithin(null), isNull);
}
@@ -97,7 +97,7 @@
CompilationUnit unit = parseCompilationUnit(r'''
class A {}
class B {}''');
- NodeLocator locator = new NodeLocator(1024, 1024);
+ NodeLocator locator = NodeLocator(1024, 1024);
AstNode node = locator.searchWithin(unit.declarations[0]);
expect(node, isNull);
}
@@ -106,7 +106,7 @@
CompilationUnit unit = parseCompilationUnit(r'''
class A {}
class B {}''');
- NodeLocator locator = new NodeLocator(0, 0);
+ NodeLocator locator = NodeLocator(0, 0);
AstNode node = locator.searchWithin(unit.declarations[1]);
expect(node, isNull);
}
@@ -116,7 +116,7 @@
int start,
int end,
) {
- NodeLocator locator = new NodeLocator(start, end);
+ NodeLocator locator = NodeLocator(start, end);
AstNode node = locator.searchWithin(unit);
expect(node, isNotNull);
expect(locator.foundNode, same(node));
@@ -227,7 +227,7 @@
void test_visitCompilationUnit() {
CompilationUnit fromNode = AstTestFactory.compilationUnit();
- CompilationUnitElement element = new CompilationUnitElementImpl();
+ CompilationUnitElement element = CompilationUnitElementImpl();
fromNode.element = element;
CompilationUnit toNode = AstTestFactory.compilationUnit();
ResolutionCopier.copyResolutionData(fromNode, toNode);
@@ -292,7 +292,7 @@
void test_visitExportDirective() {
ExportDirective fromNode = AstTestFactory.exportDirective2("dart:uri");
- ExportElement element = new ExportElementImpl(-1);
+ ExportElement element = ExportElementImpl(-1);
fromNode.element = element;
ExportDirective toNode = AstTestFactory.exportDirective2("dart:uri");
ResolutionCopier.copyResolutionData(fromNode, toNode);
@@ -488,7 +488,7 @@
void test_visitImportDirective() {
ImportDirective fromNode =
AstTestFactory.importDirective3("dart:uri", null);
- ImportElement element = new ImportElementImpl(0);
+ ImportElement element = ImportElementImpl(0);
fromNode.element = element;
ImportDirective toNode = AstTestFactory.importDirective3("dart:uri", null);
ResolutionCopier.copyResolutionData(fromNode, toNode);
@@ -500,7 +500,7 @@
AstTestFactory.identifier3("a"), AstTestFactory.integer(0));
MethodElement staticElement = ElementFactory.methodElement(
"m", interfaceTypeStar(ElementFactory.classElement2('C')));
- AuxiliaryElements auxiliaryElements = new AuxiliaryElements(staticElement);
+ AuxiliaryElements auxiliaryElements = AuxiliaryElements(staticElement);
fromNode.auxiliaryElements = auxiliaryElements;
fromNode.staticElement = staticElement;
DartType staticType = interfaceTypeStar(ElementFactory.classElement2('C'));
@@ -638,8 +638,7 @@
void test_visitPartDirective() {
PartDirective fromNode = AstTestFactory.partDirective2("part.dart");
- LibraryElement element =
- new LibraryElementImpl(null, null, 'lib', -1, 0, true);
+ LibraryElement element = LibraryElementImpl(null, null, 'lib', -1, 0, true);
fromNode.element = element;
PartDirective toNode = AstTestFactory.partDirective2("part.dart");
ResolutionCopier.copyResolutionData(fromNode, toNode);
@@ -649,8 +648,7 @@
void test_visitPartOfDirective() {
PartOfDirective fromNode = AstTestFactory.partOfDirective(
AstTestFactory.libraryIdentifier2(["lib"]));
- LibraryElement element =
- new LibraryElementImpl(null, null, 'lib', -1, 0, true);
+ LibraryElement element = LibraryElementImpl(null, null, 'lib', -1, 0, true);
fromNode.element = element;
PartOfDirective toNode = AstTestFactory.partOfDirective(
AstTestFactory.libraryIdentifier2(["lib"]));
@@ -780,7 +778,7 @@
SimpleIdentifier fromNode = AstTestFactory.identifier3("x");
MethodElement staticElement = ElementFactory.methodElement(
"m", interfaceTypeStar(ElementFactory.classElement2('C')));
- AuxiliaryElements auxiliaryElements = new AuxiliaryElements(staticElement);
+ AuxiliaryElements auxiliaryElements = AuxiliaryElements(staticElement);
fromNode.auxiliaryElements = auxiliaryElements;
fromNode.staticElement = staticElement;
DartType staticType = interfaceTypeStar(ElementFactory.classElement2('C'));
diff --git a/pkg/analyzer/test/src/dart/constant/evaluation_test.dart b/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
index 47b7e88..1e2aa11f 100644
--- a/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
+++ b/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
@@ -205,7 +205,7 @@
ConstantVisitor(
ConstantEvaluationEngine(
typeProvider,
- new DeclaredVariables(),
+ DeclaredVariables(),
experimentStatus: options.experimentStatus,
typeSystem: this.result.typeSystem,
),
diff --git a/pkg/analyzer/test/src/dart/constant/utilities_test.dart b/pkg/analyzer/test/src/dart/constant/utilities_test.dart
index c374591..b0c972a 100644
--- a/pkg/analyzer/test/src/dart/constant/utilities_test.dart
+++ b/pkg/analyzer/test/src/dart/constant/utilities_test.dart
@@ -36,8 +36,8 @@
Source _source;
void setUp() {
- _typeProvider = new TestTypeProvider();
- _source = new TestSource();
+ _typeProvider = TestTypeProvider();
+ _source = TestSource();
}
/**
@@ -50,7 +50,7 @@
ElementFactory.library(null, 'L').definingCompilationUnit =
compilationUnitElement;
ElementAnnotationImpl elementAnnotation =
- new ElementAnnotationImpl(compilationUnitElement);
+ ElementAnnotationImpl(compilationUnitElement);
_node = elementAnnotation.annotationAst =
AstTestFactory.annotation(AstTestFactory.identifier3('x'))
..elementAnnotation = elementAnnotation;
@@ -76,7 +76,7 @@
ElementFactory.library(null, 'L').definingCompilationUnit =
compilationUnitElement;
ElementAnnotationImpl elementAnnotation =
- new ElementAnnotationImpl(compilationUnitElement);
+ ElementAnnotationImpl(compilationUnitElement);
_node = elementAnnotation.annotationAst = AstTestFactory.annotation2(
AstTestFactory.identifier3('A'), null, AstTestFactory.argumentList())
..elementAnnotation = elementAnnotation;
@@ -167,18 +167,18 @@
}
List<Annotation> _findAnnotations() {
- Set<Annotation> annotations = new Set<Annotation>();
+ Set<Annotation> annotations = Set<Annotation>();
for (ConstantEvaluationTarget target in _findConstants()) {
if (target is ElementAnnotationImpl) {
expect(target.source, same(_source));
annotations.add(target.annotationAst);
}
}
- return new List<Annotation>.from(annotations);
+ return List<Annotation>.from(annotations);
}
List<ConstantEvaluationTarget> _findConstants() {
- ConstantFinder finder = new ConstantFinder();
+ ConstantFinder finder = ConstantFinder();
_node.accept(finder);
List<ConstantEvaluationTarget> constants = finder.constantsToCompute;
expect(constants, isNotNull);
@@ -206,9 +206,9 @@
VariableDeclaration _setupFieldDeclaration(
String className, String fieldName, Keyword keyword,
- {bool isInitialized: true,
- bool isStatic: false,
- bool hasConstConstructor: false}) {
+ {bool isInitialized = true,
+ bool isStatic = false,
+ bool hasConstConstructor = false}) {
VariableDeclaration variableDeclaration = isInitialized
? AstTestFactory.variableDeclaration2(
fieldName, AstTestFactory.integer(0))
@@ -252,7 +252,7 @@
VariableElement _setupVariableDeclaration(
String name, bool isConst, bool isInitialized,
- {isFinal: false}) {
+ {isFinal = false}) {
VariableDeclaration variableDeclaration = isInitialized
? AstTestFactory.variableDeclaration2(name, AstTestFactory.integer(0))
: AstTestFactory.variableDeclaration(name);
@@ -304,13 +304,12 @@
SuperConstructorInvocation _makeTailSuperConstructorInvocation(
String name, bool isConst) {
- List<ConstructorInitializer> initializers =
- new List<ConstructorInitializer>();
+ List<ConstructorInitializer> initializers = List<ConstructorInitializer>();
ConstructorDeclaration constructorDeclaration =
AstTestFactory.constructorDeclaration(AstTestFactory.identifier3(name),
null, AstTestFactory.formalParameterList(), initializers);
if (isConst) {
- constructorDeclaration.constKeyword = new KeywordToken(Keyword.CONST, 0);
+ constructorDeclaration.constKeyword = KeywordToken(Keyword.CONST, 0);
}
ClassElementImpl classElement = ElementFactory.classElement2(name);
SuperConstructorInvocation superConstructorInvocation =
@@ -337,7 +336,7 @@
}
void _visitNode(AstNode node) {
- var referenceFinder = new ReferenceFinder((dependency) {
+ var referenceFinder = ReferenceFinder((dependency) {
_dependencies.add(dependency);
});
node.accept(referenceFinder);
diff --git a/pkg/analyzer/test/src/dart/constant/value_test.dart b/pkg/analyzer/test/src/dart/constant/value_test.dart
index d26101c..594770b 100644
--- a/pkg/analyzer/test/src/dart/constant/value_test.dart
+++ b/pkg/analyzer/test/src/dart/constant/value_test.dart
@@ -18,11 +18,11 @@
const int LONG_MAX_VALUE = 0x7fffffffffffffff;
final Matcher throwsEvaluationException =
- throwsA(new TypeMatcher<EvaluationException>());
+ throwsA(TypeMatcher<EvaluationException>());
@reflectiveTest
class DartObjectImplTest {
- TypeProvider _typeProvider = new TestTypeProvider();
+ TypeProvider _typeProvider = TestTypeProvider();
void test_add_knownDouble_knownDouble() {
_assertAdd(_doubleValue(3.0), _doubleValue(1.0), _doubleValue(2.0));
@@ -1360,11 +1360,8 @@
}
void test_shiftLeft_knownInt_tooLarge() {
- _assertShiftLeft(
- _intValue(null),
- _intValue(6),
- new DartObjectImpl(
- _typeProvider.intType, new IntState(LONG_MAX_VALUE)));
+ _assertShiftLeft(_intValue(null), _intValue(6),
+ DartObjectImpl(_typeProvider.intType, IntState(LONG_MAX_VALUE)));
}
void test_shiftLeft_knownInt_unknownInt() {
@@ -1396,11 +1393,8 @@
}
void test_shiftRight_knownInt_tooLarge() {
- _assertShiftRight(
- _intValue(null),
- _intValue(48),
- new DartObjectImpl(
- _typeProvider.intType, new IntState(LONG_MAX_VALUE)));
+ _assertShiftRight(_intValue(null), _intValue(48),
+ DartObjectImpl(_typeProvider.intType, IntState(LONG_MAX_VALUE)));
}
void test_shiftRight_knownInt_unknownInt() {
@@ -1942,31 +1936,29 @@
DartObjectImpl _boolValue(bool value) {
if (value == null) {
- return new DartObjectImpl(
- _typeProvider.boolType, BoolState.UNKNOWN_VALUE);
+ return DartObjectImpl(_typeProvider.boolType, BoolState.UNKNOWN_VALUE);
} else if (identical(value, false)) {
- return new DartObjectImpl(_typeProvider.boolType, BoolState.FALSE_STATE);
+ return DartObjectImpl(_typeProvider.boolType, BoolState.FALSE_STATE);
} else if (identical(value, true)) {
- return new DartObjectImpl(_typeProvider.boolType, BoolState.TRUE_STATE);
+ return DartObjectImpl(_typeProvider.boolType, BoolState.TRUE_STATE);
}
fail("Invalid boolean value used in test");
}
DartObjectImpl _doubleValue(double value) {
if (value == null) {
- return new DartObjectImpl(
+ return DartObjectImpl(
_typeProvider.doubleType, DoubleState.UNKNOWN_VALUE);
} else {
- return new DartObjectImpl(
- _typeProvider.doubleType, new DoubleState(value));
+ return DartObjectImpl(_typeProvider.doubleType, DoubleState(value));
}
}
DartObjectImpl _intValue(int value) {
if (value == null) {
- return new DartObjectImpl(_typeProvider.intType, IntState.UNKNOWN_VALUE);
+ return DartObjectImpl(_typeProvider.intType, IntState.UNKNOWN_VALUE);
} else {
- return new DartObjectImpl(_typeProvider.intType, new IntState(value));
+ return DartObjectImpl(_typeProvider.intType, IntState(value));
}
}
@@ -1983,7 +1975,7 @@
DartObjectImpl _mapValue(DartType keyType, DartType valueType,
List<DartObjectImpl> keyElementPairs) {
Map<DartObjectImpl, DartObjectImpl> map =
- new Map<DartObjectImpl, DartObjectImpl>();
+ Map<DartObjectImpl, DartObjectImpl>();
int count = keyElementPairs.length;
for (int i = 0; i < count;) {
map[keyElementPairs[i++]] = keyElementPairs[i++];
@@ -1995,7 +1987,7 @@
}
DartObjectImpl _nullValue() {
- return new DartObjectImpl(_typeProvider.nullType, NullState.NULL_STATE);
+ return DartObjectImpl(_typeProvider.nullType, NullState.NULL_STATE);
}
DartObjectImpl _setValue(DartType type, Set<DartObjectImpl> elements) {
@@ -2004,15 +1996,14 @@
DartObjectImpl _stringValue(String value) {
if (value == null) {
- return new DartObjectImpl(
+ return DartObjectImpl(
_typeProvider.stringType, StringState.UNKNOWN_VALUE);
} else {
- return new DartObjectImpl(
- _typeProvider.stringType, new StringState(value));
+ return DartObjectImpl(_typeProvider.stringType, StringState(value));
}
}
DartObjectImpl _symbolValue(String value) {
- return new DartObjectImpl(_typeProvider.symbolType, new SymbolState(value));
+ return DartObjectImpl(_typeProvider.symbolType, SymbolState(value));
}
}
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index 49b073d..578bb23 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -38,14 +38,14 @@
}
class AbstractTypeTest with ElementsTypesMixin {
- AnalysisContext _analysisContext;
+ TestAnalysisContext _analysisContext;
TypeProvider _typeProvider;
TypeProvider get typeProvider => _typeProvider;
void setUp() {
_analysisContext = TestAnalysisContext();
- _typeProvider = _analysisContext.typeProvider;
+ _typeProvider = _analysisContext.typeProviderLegacy;
}
}
@@ -62,7 +62,7 @@
InterfaceType typeC = interfaceTypeStar(elementC);
elementC.interfaces = <InterfaceType>[typeB];
List<InterfaceType> supers = elementC.allSupertypes;
- List<InterfaceType> types = new List<InterfaceType>();
+ List<InterfaceType> types = List<InterfaceType>();
types.addAll(supers);
expect(types.contains(typeA), isTrue);
expect(types.contains(typeB), isTrue);
@@ -81,7 +81,7 @@
InterfaceType typeC = interfaceTypeStar(classC);
classC.mixins = <InterfaceType>[typeB];
List<InterfaceType> supers = classC.allSupertypes;
- List<InterfaceType> types = new List<InterfaceType>();
+ List<InterfaceType> types = List<InterfaceType>();
types.addAll(supers);
expect(types.contains(typeA), isTrue);
expect(types.contains(typeB), isTrue);
@@ -226,7 +226,7 @@
String firstConst = "A";
String secondConst = "B";
EnumElementImpl enumE = ElementFactory.enumElement(
- new TestTypeProvider(), "E", [firstConst, secondConst]);
+ TestTypeProvider(), "E", [firstConst, secondConst]);
// E is an enum
expect(enumE.isEnum, true);
@@ -867,7 +867,7 @@
@reflectiveTest
class CompilationUnitElementImplTest {
void test_getEnum_declared() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
CompilationUnitElementImpl unit =
ElementFactory.compilationUnit("/lib.dart");
String enumName = "E";
@@ -878,7 +878,7 @@
}
void test_getEnum_undeclared() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
CompilationUnitElementImpl unit =
ElementFactory.compilationUnit("/lib.dart");
String enumName = "E";
@@ -1048,7 +1048,7 @@
class ElementLocationImplTest {
void test_create_encoding() {
String encoding = "a;b;c";
- ElementLocationImpl location = new ElementLocationImpl.con2(encoding);
+ ElementLocationImpl location = ElementLocationImpl.con2(encoding);
expect(location.encoding, encoding);
}
@@ -1057,38 +1057,38 @@
*/
void test_create_encoding_emptyLast() {
String encoding = "a;b;c;";
- ElementLocationImpl location = new ElementLocationImpl.con2(encoding);
+ ElementLocationImpl location = ElementLocationImpl.con2(encoding);
expect(location.encoding, encoding);
}
void test_equals_equal() {
String encoding = "a;b;c";
- ElementLocationImpl first = new ElementLocationImpl.con2(encoding);
- ElementLocationImpl second = new ElementLocationImpl.con2(encoding);
+ ElementLocationImpl first = ElementLocationImpl.con2(encoding);
+ ElementLocationImpl second = ElementLocationImpl.con2(encoding);
expect(first == second, isTrue);
}
void test_equals_notEqual_differentLengths() {
- ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c");
- ElementLocationImpl second = new ElementLocationImpl.con2("a;b;c;d");
+ ElementLocationImpl first = ElementLocationImpl.con2("a;b;c");
+ ElementLocationImpl second = ElementLocationImpl.con2("a;b;c;d");
expect(first == second, isFalse);
}
void test_equals_notEqual_notLocation() {
- ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c");
+ ElementLocationImpl first = ElementLocationImpl.con2("a;b;c");
// ignore: unrelated_type_equality_checks
expect(first == "a;b;d", isFalse);
}
void test_equals_notEqual_sameLengths() {
- ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c");
- ElementLocationImpl second = new ElementLocationImpl.con2("a;b;d");
+ ElementLocationImpl first = ElementLocationImpl.con2("a;b;c");
+ ElementLocationImpl second = ElementLocationImpl.con2("a;b;d");
expect(first == second, isFalse);
}
void test_getComponents() {
String encoding = "a;b;c";
- ElementLocationImpl location = new ElementLocationImpl.con2(encoding);
+ ElementLocationImpl location = ElementLocationImpl.con2(encoding);
List<String> components = location.components;
expect(components, hasLength(3));
expect(components[0], "a");
@@ -1098,14 +1098,14 @@
void test_getEncoding() {
String encoding = "a;b;c;;d";
- ElementLocationImpl location = new ElementLocationImpl.con2(encoding);
+ ElementLocationImpl location = ElementLocationImpl.con2(encoding);
expect(location.encoding, encoding);
}
void test_hashCode_equal() {
String encoding = "a;b;c";
- ElementLocationImpl first = new ElementLocationImpl.con2(encoding);
- ElementLocationImpl second = new ElementLocationImpl.con2(encoding);
+ ElementLocationImpl first = ElementLocationImpl.con2(encoding);
+ ElementLocationImpl second = ElementLocationImpl.con2(encoding);
expect(first.hashCode == second.hashCode, isTrue);
}
}
@@ -1141,12 +1141,12 @@
// computation to terminate.
expect(
functionTypeAliasType(s) == functionTypeAliasType(u),
- new TypeMatcher<bool>(),
+ TypeMatcher<bool>(),
);
}
void test_getNamedParameterTypes_namedParameters() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
FunctionElement element = ElementFactory.functionElementWithParameters(
'f', VoidTypeImpl.instance, [
ElementFactory.requiredParameter2('a', typeProvider.intType),
@@ -1162,7 +1162,7 @@
}
void test_getNamedParameterTypes_noNamedParameters() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
FunctionElement element = ElementFactory.functionElementWithParameters(
'f', VoidTypeImpl.instance, [
ElementFactory.requiredParameter2('a', typeProvider.intType),
@@ -1181,7 +1181,7 @@
}
void test_getNormalParameterTypes_noNormalParameters() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
FunctionElement element = ElementFactory.functionElementWithParameters(
'f', VoidTypeImpl.instance, [
ElementFactory.positionalParameter2('c', typeProvider.stringType),
@@ -1199,7 +1199,7 @@
}
void test_getNormalParameterTypes_normalParameters() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
FunctionElement element = ElementFactory.functionElementWithParameters(
'f', VoidTypeImpl.instance, [
ElementFactory.requiredParameter2('a', typeProvider.intType),
@@ -1214,7 +1214,7 @@
}
void test_getOptionalParameterTypes_noOptionalParameters() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
FunctionElement element = ElementFactory.functionElementWithParameters(
'f', VoidTypeImpl.instance, [
ElementFactory.requiredParameter2('a', typeProvider.intType),
@@ -1234,7 +1234,7 @@
}
void test_getOptionalParameterTypes_optionalParameters() {
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
FunctionElement element = ElementFactory.functionElementWithParameters(
'f', VoidTypeImpl.instance, [
ElementFactory.requiredParameter2('a', typeProvider.intType),
@@ -1262,7 +1262,7 @@
ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]);
TypeParameterType parameterType =
typeParameterType(definingClass.typeParameters[0]);
- MethodElementImpl functionElement = new MethodElementImpl('m', -1);
+ MethodElementImpl functionElement = MethodElementImpl('m', -1);
String namedParameterName = "c";
functionElement.parameters = <ParameterElement>[
ElementFactory.requiredParameter2("a", parameterType),
@@ -1273,7 +1273,7 @@
definingClass.methods = <MethodElement>[functionElement];
FunctionTypeImpl functionType = functionElement.type;
InterfaceTypeImpl argumentType =
- new InterfaceTypeImpl(new ClassElementImpl('D', -1));
+ InterfaceTypeImpl(ClassElementImpl('D', -1));
FunctionType result = functionType
.substitute2(<DartType>[argumentType], <DartType>[parameterType]);
expect(result.returnType, argumentType);
@@ -1290,14 +1290,12 @@
@deprecated
void test_substitute2_notEqual() {
- DartType returnType = new InterfaceTypeImpl(new ClassElementImpl('R', -1));
- DartType normalParameterType =
- new InterfaceTypeImpl(new ClassElementImpl('A', -1));
+ DartType returnType = InterfaceTypeImpl(ClassElementImpl('R', -1));
+ DartType normalParameterType = InterfaceTypeImpl(ClassElementImpl('A', -1));
DartType optionalParameterType =
- new InterfaceTypeImpl(new ClassElementImpl('B', -1));
- DartType namedParameterType =
- new InterfaceTypeImpl(new ClassElementImpl('C', -1));
- FunctionElementImpl functionElement = new FunctionElementImpl('f', -1);
+ InterfaceTypeImpl(ClassElementImpl('B', -1));
+ DartType namedParameterType = InterfaceTypeImpl(ClassElementImpl('C', -1));
+ FunctionElementImpl functionElement = FunctionElementImpl('f', -1);
String namedParameterName = "c";
functionElement.parameters = <ParameterElement>[
ElementFactory.requiredParameter2("a", normalParameterType),
@@ -1307,9 +1305,9 @@
functionElement.returnType = returnType;
FunctionTypeImpl functionType = functionElement.type;
InterfaceTypeImpl argumentType =
- new InterfaceTypeImpl(new ClassElementImpl('D', -1));
+ InterfaceTypeImpl(ClassElementImpl('D', -1));
TypeParameterTypeImpl parameterType =
- new TypeParameterTypeImpl(new TypeParameterElementImpl('E', -1));
+ TypeParameterTypeImpl(TypeParameterElementImpl('E', -1));
FunctionType result = functionType
.substitute2(<DartType>[argumentType], <DartType>[parameterType]);
expect(result.returnType, returnType);
@@ -1411,7 +1409,7 @@
}
void test_creation() {
- expect(new InterfaceTypeImpl(class_(name: 'A')), isNotNull);
+ expect(InterfaceTypeImpl(class_(name: 'A')), isNotNull);
}
void test_getAccessors() {
@@ -1421,13 +1419,13 @@
PropertyAccessorElement getterH =
ElementFactory.getterElement("h", false, null);
typeElement.accessors = <PropertyAccessorElement>[getterG, getterH];
- InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement);
+ InterfaceTypeImpl type = InterfaceTypeImpl(typeElement);
expect(type.accessors.length, 2);
}
void test_getAccessors_empty() {
ClassElementImpl typeElement = class_(name: 'A');
- InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement);
+ InterfaceTypeImpl type = InterfaceTypeImpl(typeElement);
expect(type.accessors.length, 0);
}
@@ -1441,20 +1439,20 @@
constructorOne,
constructorTwo
];
- InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement);
+ InterfaceTypeImpl type = InterfaceTypeImpl(typeElement);
expect(type.constructors, hasLength(2));
}
void test_getConstructors_empty() {
ClassElementImpl typeElement = class_(name: 'A');
typeElement.constructors = const <ConstructorElement>[];
- InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement);
+ InterfaceTypeImpl type = InterfaceTypeImpl(typeElement);
expect(type.constructors, isEmpty);
}
void test_getElement() {
ClassElementImpl typeElement = class_(name: 'A');
- InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement);
+ InterfaceTypeImpl type = InterfaceTypeImpl(typeElement);
expect(type.element, typeElement);
}
@@ -1586,7 +1584,7 @@
//
InterfaceType typeI = interfaceTypeStar(class_(name: 'I'));
InterfaceTypeImpl typeAI =
- new InterfaceTypeImpl.explicit(classA, <DartType>[typeI]);
+ InterfaceTypeImpl.explicit(classA, <DartType>[typeI]);
MethodElement method = typeAI.getMethod(methodName);
expect(method, isNotNull);
FunctionType methodType = method.type;
@@ -1608,8 +1606,7 @@
// A<I>
//
InterfaceType typeI = interfaceTypeStar(class_(name: 'I'));
- InterfaceTypeImpl typeAI =
- new InterfaceTypeImpl.explicit(A, <DartType>[typeI]);
+ InterfaceTypeImpl typeAI = InterfaceTypeImpl.explicit(A, <DartType>[typeI]);
MethodElement method = typeAI.getMethod(methodName);
expect(method, isNotNull);
FunctionType methodType = method.type;
@@ -1634,13 +1631,13 @@
MethodElementImpl methodOne = ElementFactory.methodElement("one", null);
MethodElementImpl methodTwo = ElementFactory.methodElement("two", null);
typeElement.methods = <MethodElement>[methodOne, methodTwo];
- InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement);
+ InterfaceTypeImpl type = InterfaceTypeImpl(typeElement);
expect(type.methods.length, 2);
}
void test_getMethods_empty() {
ClassElementImpl typeElement = class_(name: 'A');
- InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement);
+ InterfaceTypeImpl type = InterfaceTypeImpl(typeElement);
expect(type.methods.length, 0);
}
@@ -1686,8 +1683,7 @@
// B<I>
//
InterfaceType typeI = interfaceTypeStar(class_(name: 'I'));
- InterfaceTypeImpl typeBI =
- new InterfaceTypeImpl.explicit(B, <DartType>[typeI]);
+ InterfaceTypeImpl typeBI = InterfaceTypeImpl.explicit(B, <DartType>[typeI]);
List<InterfaceType> interfaces = typeBI.mixins;
expect(interfaces, hasLength(1));
InterfaceType result = interfaces[0];
@@ -1723,8 +1719,7 @@
// A<I>
//
InterfaceType typeI = interfaceTypeStar(class_(name: 'I'));
- InterfaceTypeImpl typeAI =
- new InterfaceTypeImpl.explicit(A, <DartType>[typeI]);
+ InterfaceTypeImpl typeAI = InterfaceTypeImpl.explicit(A, <DartType>[typeI]);
PropertyAccessorElement setter = typeAI.getSetter(setterName);
expect(setter, isNotNull);
FunctionType setterType = setter.type;
@@ -1776,7 +1771,7 @@
//
InterfaceType typeI = interfaceTypeStar(class_(name: 'I'));
InterfaceTypeImpl typeBI =
- new InterfaceTypeImpl.explicit(classB, <DartType>[typeI]);
+ InterfaceTypeImpl.explicit(classB, <DartType>[typeI]);
InterfaceType superclass = typeBI.superclass;
expect(superclass.element, same(A));
expect(superclass.typeArguments[0], same(typeI));
@@ -1837,7 +1832,7 @@
// class M2 { get g {} }
// class C extends B with M1, M2 {}
//
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String getterName = 'g';
var classB = class_(name: 'B');
ClassElementImpl classM1 = ElementFactory.classElement2('M1');
@@ -1986,8 +1981,7 @@
// B<I>
//
InterfaceType typeI = interfaceTypeStar(class_(name: 'I'));
- InterfaceTypeImpl typeBI =
- new InterfaceTypeImpl.explicit(B, <DartType>[typeI]);
+ InterfaceTypeImpl typeBI = InterfaceTypeImpl.explicit(B, <DartType>[typeI]);
MethodElement method = typeBI.lookUpMethod(methodName, library);
expect(method, isNotNull);
FunctionType methodType = method.type;
@@ -2070,7 +2064,7 @@
// class M2 { set s() {} }
// class C extends B with M1, M2 {}
//
- TestTypeProvider typeProvider = new TestTypeProvider();
+ TestTypeProvider typeProvider = TestTypeProvider();
String setterName = 's';
var classB = class_(name: 'B');
ClassElementImpl classM1 = ElementFactory.classElement2('M1');
@@ -2136,7 +2130,7 @@
void test_substitute_exception() {
try {
var classA = class_(name: 'A');
- InterfaceTypeImpl type = new InterfaceTypeImpl(classA);
+ InterfaceTypeImpl type = InterfaceTypeImpl(classA);
InterfaceType argumentType = interfaceTypeStar(class_(name: 'B'));
type.substitute2(<DartType>[argumentType], <DartType>[]);
fail(
@@ -2152,14 +2146,13 @@
// implementation.
var classA = class_(name: 'A');
TypeParameterElementImpl parameterElement =
- new TypeParameterElementImpl('E', -1);
- TypeParameterTypeImpl parameter =
- new TypeParameterTypeImpl(parameterElement);
+ TypeParameterElementImpl('E', -1);
+ TypeParameterTypeImpl parameter = TypeParameterTypeImpl(parameterElement);
InterfaceTypeImpl type =
- new InterfaceTypeImpl.explicit(classA, <DartType>[parameter]);
+ InterfaceTypeImpl.explicit(classA, <DartType>[parameter]);
InterfaceType argumentType = interfaceTypeStar(class_(name: 'B'));
TypeParameterTypeImpl parameterType =
- new TypeParameterTypeImpl(new TypeParameterElementImpl('F', -1));
+ TypeParameterTypeImpl(TypeParameterElementImpl('F', -1));
InterfaceType result =
type.substitute2(<DartType>[argumentType], <DartType>[parameterType]);
expect(result.element, classA);
@@ -2177,8 +2170,8 @@
LibraryElementImpl library2 = ElementFactory.library(context, "l2");
LibraryElementImpl library3 = ElementFactory.library(context, "l3");
LibraryElementImpl library4 = ElementFactory.library(context, "l4");
- PrefixElement prefixA = new PrefixElementImpl('a', -1);
- PrefixElement prefixB = new PrefixElementImpl('b', -1);
+ PrefixElement prefixA = PrefixElementImpl('a', -1);
+ PrefixElement prefixB = PrefixElementImpl('b', -1);
List<ImportElementImpl> imports = [
ElementFactory.importFor(library2, null),
ElementFactory.importFor(library2, prefixB),
@@ -2196,8 +2189,8 @@
void test_getPrefixes() {
AnalysisContext context = TestAnalysisContext();
LibraryElementImpl library = ElementFactory.library(context, "l1");
- PrefixElement prefixA = new PrefixElementImpl('a', -1);
- PrefixElement prefixB = new PrefixElementImpl('b', -1);
+ PrefixElement prefixA = PrefixElementImpl('a', -1);
+ PrefixElement prefixB = PrefixElementImpl('b', -1);
List<ImportElementImpl> imports = [
ElementFactory.importFor(ElementFactory.library(context, "l2"), null),
ElementFactory.importFor(ElementFactory.library(context, "l3"), null),
@@ -2232,7 +2225,7 @@
void test_setImports() {
AnalysisContext context = TestAnalysisContext();
LibraryElementImpl library =
- new LibraryElementImpl(context, null, 'l1', -1, 0, true);
+ LibraryElementImpl(context, null, 'l1', -1, 0, true);
List<ImportElementImpl> expectedImports = [
ElementFactory.importFor(ElementFactory.library(context, "l2"), null),
ElementFactory.importFor(ElementFactory.library(context, "l3"), null)
@@ -2273,49 +2266,48 @@
@reflectiveTest
class TypeParameterTypeImplTest extends AbstractTypeTest {
void test_creation() {
- expect(new TypeParameterTypeImpl(new TypeParameterElementImpl('E', -1)),
- isNotNull);
+ expect(TypeParameterTypeImpl(TypeParameterElementImpl('E', -1)), isNotNull);
}
void test_getElement() {
- TypeParameterElementImpl element = new TypeParameterElementImpl('E', -1);
- TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
+ TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
+ TypeParameterTypeImpl type = TypeParameterTypeImpl(element);
expect(type.element, element);
}
void test_resolveToBound_bound() {
ClassElementImpl classS = class_(name: 'A');
- TypeParameterElementImpl element = new TypeParameterElementImpl('E', -1);
+ TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
element.bound = interfaceTypeStar(classS);
- TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
+ TypeParameterTypeImpl type = TypeParameterTypeImpl(element);
expect(type.resolveToBound(null), interfaceTypeStar(classS));
}
void test_resolveToBound_bound_nullableInner() {
ClassElementImpl classS = class_(name: 'A');
- TypeParameterElementImpl element = new TypeParameterElementImpl('E', -1);
+ TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
element.bound = (interfaceTypeStar(classS) as TypeImpl)
.withNullability(NullabilitySuffix.question);
- TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
+ TypeParameterTypeImpl type = TypeParameterTypeImpl(element);
expect(type.resolveToBound(null), same(element.bound));
}
void test_resolveToBound_bound_nullableInnerOuter() {
ClassElementImpl classS = class_(name: 'A');
- TypeParameterElementImpl element = new TypeParameterElementImpl('E', -1);
+ TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
element.bound = (interfaceTypeStar(classS) as TypeImpl)
.withNullability(NullabilitySuffix.question);
- TypeParameterTypeImpl type = new TypeParameterTypeImpl(element)
+ TypeParameterTypeImpl type = TypeParameterTypeImpl(element)
.withNullability(NullabilitySuffix.question);
expect(type.resolveToBound(null), same(element.bound));
}
void test_resolveToBound_bound_nullableInnerStarOuter() {
ClassElementImpl classS = class_(name: 'A');
- TypeParameterElementImpl element = new TypeParameterElementImpl('E', -1);
+ TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
element.bound = (interfaceTypeStar(classS) as TypeImpl)
.withNullability(NullabilitySuffix.star);
- TypeParameterTypeImpl type = new TypeParameterTypeImpl(element)
+ TypeParameterTypeImpl type = TypeParameterTypeImpl(element)
.withNullability(NullabilitySuffix.question);
expect(
type.resolveToBound(null),
@@ -2325,9 +2317,9 @@
void test_resolveToBound_bound_nullableOuter() {
ClassElementImpl classS = class_(name: 'A');
- TypeParameterElementImpl element = new TypeParameterElementImpl('E', -1);
+ TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
element.bound = interfaceTypeStar(classS);
- TypeParameterTypeImpl type = new TypeParameterTypeImpl(element)
+ TypeParameterTypeImpl type = TypeParameterTypeImpl(element)
.withNullability(NullabilitySuffix.question);
expect(
type.resolveToBound(null),
@@ -2337,29 +2329,29 @@
void test_resolveToBound_bound_starInner() {
ClassElementImpl classS = class_(name: 'A');
- TypeParameterElementImpl element = new TypeParameterElementImpl('E', -1);
+ TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
element.bound = (interfaceTypeStar(classS) as TypeImpl)
.withNullability(NullabilitySuffix.star);
- TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
+ TypeParameterTypeImpl type = TypeParameterTypeImpl(element);
expect(type.resolveToBound(null), same(element.bound));
}
void test_resolveToBound_bound_starInnerNullableOuter() {
ClassElementImpl classS = class_(name: 'A');
- TypeParameterElementImpl element = new TypeParameterElementImpl('E', -1);
+ TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
element.bound = (interfaceTypeStar(classS) as TypeImpl)
.withNullability(NullabilitySuffix.question);
- TypeParameterTypeImpl type = new TypeParameterTypeImpl(element)
- .withNullability(NullabilitySuffix.star);
+ TypeParameterTypeImpl type =
+ TypeParameterTypeImpl(element).withNullability(NullabilitySuffix.star);
expect(type.resolveToBound(null), same(element.bound));
}
void test_resolveToBound_bound_starOuter() {
ClassElementImpl classS = class_(name: 'A');
- TypeParameterElementImpl element = new TypeParameterElementImpl('E', -1);
+ TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
element.bound = interfaceTypeStar(classS);
- TypeParameterTypeImpl type = new TypeParameterTypeImpl(element)
- .withNullability(NullabilitySuffix.star);
+ TypeParameterTypeImpl type =
+ TypeParameterTypeImpl(element).withNullability(NullabilitySuffix.star);
expect(
type.resolveToBound(null),
(interfaceTypeStar(classS) as TypeImpl)
@@ -2368,18 +2360,18 @@
void test_resolveToBound_nestedBound() {
ClassElementImpl classS = class_(name: 'A');
- TypeParameterElementImpl elementE = new TypeParameterElementImpl('E', -1);
+ TypeParameterElementImpl elementE = TypeParameterElementImpl('E', -1);
elementE.bound = interfaceTypeStar(classS);
- TypeParameterTypeImpl typeE = new TypeParameterTypeImpl(elementE);
- TypeParameterElementImpl elementF = new TypeParameterElementImpl('F', -1);
+ TypeParameterTypeImpl typeE = TypeParameterTypeImpl(elementE);
+ TypeParameterElementImpl elementF = TypeParameterElementImpl('F', -1);
elementF.bound = typeE;
- TypeParameterTypeImpl typeF = new TypeParameterTypeImpl(elementE);
+ TypeParameterTypeImpl typeF = TypeParameterTypeImpl(elementE);
expect(typeF.resolveToBound(null), interfaceTypeStar(classS));
}
void test_resolveToBound_unbound() {
TypeParameterTypeImpl type =
- new TypeParameterTypeImpl(new TypeParameterElementImpl('E', -1));
+ TypeParameterTypeImpl(TypeParameterElementImpl('E', -1));
// Returns whatever type is passed to resolveToBound().
expect(type.resolveToBound(VoidTypeImpl.instance),
same(VoidTypeImpl.instance));
@@ -2387,11 +2379,10 @@
@deprecated
void test_substitute_equal() {
- TypeParameterElementImpl element = new TypeParameterElementImpl('E', -1);
- TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
- InterfaceTypeImpl argument =
- new InterfaceTypeImpl(new ClassElementImpl('A', -1));
- TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element);
+ TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
+ TypeParameterTypeImpl type = TypeParameterTypeImpl(element);
+ InterfaceTypeImpl argument = InterfaceTypeImpl(ClassElementImpl('A', -1));
+ TypeParameterTypeImpl parameter = TypeParameterTypeImpl(element);
expect(type.substitute2(<DartType>[argument], <DartType>[parameter]),
same(argument));
}
@@ -2399,11 +2390,10 @@
@deprecated
void test_substitute_notEqual() {
TypeParameterTypeImpl type =
- new TypeParameterTypeImpl(new TypeParameterElementImpl('E', -1));
- InterfaceTypeImpl argument =
- new InterfaceTypeImpl(new ClassElementImpl('A', -1));
+ TypeParameterTypeImpl(TypeParameterElementImpl('E', -1));
+ InterfaceTypeImpl argument = InterfaceTypeImpl(ClassElementImpl('A', -1));
TypeParameterTypeImpl parameter =
- new TypeParameterTypeImpl(new TypeParameterElementImpl('F', -1));
+ TypeParameterTypeImpl(TypeParameterElementImpl('F', -1));
expect(type.substitute2(<DartType>[argument], <DartType>[parameter]),
same(type));
}
diff --git a/pkg/analyzer/test/src/dart/element/function_type_test.dart b/pkg/analyzer/test/src/dart/element/function_type_test.dart
index bee0bbf..9fd56ae 100644
--- a/pkg/analyzer/test/src/dart/element/function_type_test.dart
+++ b/pkg/analyzer/test/src/dart/element/function_type_test.dart
@@ -38,18 +38,18 @@
void basicChecks(FunctionType f,
{element,
- displayName: 'dynamic Function()',
+ displayName = 'dynamic Function()',
returnType,
- namedParameterTypes: isEmpty,
- normalParameterNames: isEmpty,
- normalParameterTypes: isEmpty,
- optionalParameterNames: isEmpty,
- optionalParameterTypes: isEmpty,
- parameters: isEmpty,
- typeFormals: isEmpty,
- typeArguments: isEmpty,
- typeParameters: isEmpty,
- name: isNull}) {
+ namedParameterTypes = isEmpty,
+ normalParameterNames = isEmpty,
+ normalParameterTypes = isEmpty,
+ optionalParameterNames = isEmpty,
+ optionalParameterTypes = isEmpty,
+ parameters = isEmpty,
+ typeFormals = isEmpty,
+ typeArguments = isEmpty,
+ typeParameters = isEmpty,
+ name = isNull}) {
// DartType properties
expect(f.displayName, displayName, reason: 'displayName');
expect(f.element, element, reason: 'element');
@@ -74,10 +74,10 @@
GenericTypeAliasElementImpl genericTypeAliasElement(
String name, {
- List<ParameterElement> parameters: const [],
+ List<ParameterElement> parameters = const [],
DartType returnType,
- List<TypeParameterElement> typeParameters: const [],
- List<TypeParameterElement> innerTypeParameters: const [],
+ List<TypeParameterElement> typeParameters = const [],
+ List<TypeParameterElement> innerTypeParameters = const [],
}) {
var aliasElement = GenericTypeAliasElementImpl(name, 0);
aliasElement.typeParameters = typeParameters;
@@ -285,7 +285,7 @@
}
test_synthetic() {
- FunctionType f = new FunctionTypeImpl(
+ FunctionType f = FunctionTypeImpl(
typeFormals: const [],
parameters: const [],
returnType: dynamicType,
@@ -298,7 +298,7 @@
// T Function<T>(T x)
var t = typeParameter('T');
var x = requiredParameter(name: 'x', type: typeParameterType(t));
- FunctionType f = new FunctionTypeImpl(
+ FunctionType f = FunctionTypeImpl(
typeFormals: [t],
parameters: [x],
returnType: typeParameterType(t),
@@ -317,17 +317,17 @@
test_synthetic_instantiate_argument_length_mismatch() {
// dynamic Function<T>()
var t = typeParameter('T');
- FunctionType f = new FunctionTypeImpl(
+ FunctionType f = FunctionTypeImpl(
typeFormals: [t],
parameters: const [],
returnType: dynamicType,
nullabilitySuffix: NullabilitySuffix.star,
);
- expect(() => f.instantiate([]), throwsA(new TypeMatcher<ArgumentError>()));
+ expect(() => f.instantiate([]), throwsA(TypeMatcher<ArgumentError>()));
}
test_synthetic_instantiate_no_type_formals() {
- FunctionType f = new FunctionTypeImpl(
+ FunctionType f = FunctionTypeImpl(
typeFormals: const [],
parameters: const [],
returnType: dynamicType,
@@ -340,7 +340,7 @@
// T Function<T>(int x)
var t = typeParameter('T');
var x = requiredParameter(name: 'x', type: intType);
- FunctionType f = new FunctionTypeImpl(
+ FunctionType f = FunctionTypeImpl(
typeFormals: [t],
parameters: [x],
returnType: typeParameterType(t),
@@ -358,7 +358,7 @@
test_synthetic_namedParameter() {
var p = namedParameter(name: 'x', type: objectType);
- FunctionType f = new FunctionTypeImpl(
+ FunctionType f = FunctionTypeImpl(
typeFormals: const [],
parameters: [p],
returnType: dynamicType,
@@ -376,7 +376,7 @@
test_synthetic_normalParameter() {
var p = requiredParameter(name: 'x', type: objectType);
- FunctionType f = new FunctionTypeImpl(
+ FunctionType f = FunctionTypeImpl(
typeFormals: const [],
parameters: [p],
returnType: dynamicType,
@@ -395,7 +395,7 @@
test_synthetic_optionalParameter() {
var p = positionalParameter(name: 'x', type: objectType);
- FunctionType f = new FunctionTypeImpl(
+ FunctionType f = FunctionTypeImpl(
typeFormals: const [],
parameters: [p],
returnType: dynamicType,
@@ -413,7 +413,7 @@
}
test_synthetic_returnType() {
- FunctionType f = new FunctionTypeImpl(
+ FunctionType f = FunctionTypeImpl(
typeFormals: const [],
parameters: const [],
returnType: objectType,
@@ -432,7 +432,7 @@
var u = typeParameter('U', bound: typeParameterType(t));
var x = requiredParameter(name: 'x', type: typeParameterType(t));
var y = requiredParameter(name: 'y', type: typeParameterType(u));
- FunctionType f = new FunctionTypeImpl.synthetic(
+ FunctionType f = FunctionTypeImpl.synthetic(
mapOf(typeParameterType(t), typeParameterType(u)), [u], [x, y],
nullabilitySuffix: NullabilitySuffix.star);
FunctionType substituted =
@@ -455,10 +455,10 @@
test_synthetic_substitute_argument_length_mismatch() {
// dynamic Function()
var t = typeParameter('T');
- FunctionType f = new FunctionTypeImpl.synthetic(dynamicType, [], [],
+ FunctionType f = FunctionTypeImpl.synthetic(dynamicType, [], [],
nullabilitySuffix: NullabilitySuffix.star);
expect(() => f.substitute2([], [typeParameterType(t)]),
- throwsA(new TypeMatcher<ArgumentError>()));
+ throwsA(TypeMatcher<ArgumentError>()));
}
@deprecated
@@ -467,7 +467,7 @@
var t = typeParameter('T');
var u = typeParameter('U');
var x = requiredParameter(name: 'x', type: typeParameterType(u));
- FunctionType f = new FunctionTypeImpl.synthetic(dynamicType, [u], [x],
+ FunctionType f = FunctionTypeImpl.synthetic(dynamicType, [u], [x],
nullabilitySuffix: NullabilitySuffix.star);
FunctionType substituted =
f.substitute2([objectType], [typeParameterType(t)]);
@@ -476,7 +476,7 @@
test_synthetic_typeFormals() {
var t = typeParameter('T');
- FunctionType f = new FunctionTypeImpl(
+ FunctionType f = FunctionTypeImpl(
typeFormals: [t],
parameters: const [],
returnType: typeParameterType(t),
@@ -515,16 +515,16 @@
final Element enclosingElement;
MockFunctionTypedElement(
- {this.parameters: const [],
+ {this.parameters = const [],
DartType returnType,
- this.typeParameters: const [],
- this.enclosingElement: const MockCompilationUnitElement()})
+ this.typeParameters = const [],
+ this.enclosingElement = const MockCompilationUnitElement()})
: returnType = returnType ?? dynamicType;
MockFunctionTypedElement.withNullReturn(
- {this.parameters: const [],
- this.typeParameters: const [],
- this.enclosingElement: const MockCompilationUnitElement()})
+ {this.parameters = const [],
+ this.typeParameters = const [],
+ this.enclosingElement = const MockCompilationUnitElement()})
: returnType = null;
noSuchMethod(Invocation invocation) {
diff --git a/pkg/analyzer/test/src/dart/element/inheritance_manager3_test.dart b/pkg/analyzer/test/src/dart/element/inheritance_manager3_test.dart
index aa2e228..ac32620 100644
--- a/pkg/analyzer/test/src/dart/element/inheritance_manager3_test.dart
+++ b/pkg/analyzer/test/src/dart/element/inheritance_manager3_test.dart
@@ -1114,7 +1114,7 @@
@override
Future<void> resolveTestFile() async {
await super.resolveTestFile();
- manager = new InheritanceManager3();
+ manager = InheritanceManager3();
}
void _assertExecutable(ExecutableElement element, String expected) {
@@ -1140,7 +1140,7 @@
var member = manager.getInherited(
interfaceType,
- new Name(null, name),
+ Name(null, name),
);
_assertExecutable(member, expected);
@@ -1157,7 +1157,7 @@
var memberType = manager.getMember(
interfaceType,
- new Name(null, name),
+ Name(null, name),
concrete: concrete,
forSuper: forSuper,
);
diff --git a/pkg/analyzer/test/src/dart/element/nullability_eliminator_test.dart b/pkg/analyzer/test/src/dart/element/nullability_eliminator_test.dart
index 15b1c8c..2d2c7f5 100644
--- a/pkg/analyzer/test/src/dart/element/nullability_eliminator_test.dart
+++ b/pkg/analyzer/test/src/dart/element/nullability_eliminator_test.dart
@@ -31,7 +31,7 @@
additionalFeatures: [Feature.non_nullable],
),
);
- typeProvider = analysisContext.typeProvider;
+ typeProvider = analysisContext.typeProviderNonNullableByDefault;
}
test_dynamicType() {
diff --git a/pkg/analyzer/test/src/dart/element/subtype_test.dart b/pkg/analyzer/test/src/dart/element/subtype_test.dart
index d3999f4..c79b887 100644
--- a/pkg/analyzer/test/src/dart/element/subtype_test.dart
+++ b/pkg/analyzer/test/src/dart/element/subtype_test.dart
@@ -2138,7 +2138,7 @@
);
}
- test_functionType_requiredNamedParameter() {
+ test_functionType_requiredNamedParameter_01() {
var F0 = functionTypeNone(
returnType: voidNone,
parameters: [
@@ -2168,6 +2168,40 @@
);
}
+ test_functionType_requiredNamedParameter_02() {
+ isNotSubtype(
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ ),
+ strT0: 'void Function({required a: int})',
+ strT1: 'void Function()',
+ );
+
+ isNotSubtype(
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'a', type: intNone),
+ namedParameter(name: 'b', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedParameter(name: 'b', type: intNone),
+ ],
+ ),
+ strT0: 'void Function({required a: int, b: int})',
+ strT1: 'void Function({b: int})',
+ );
+ }
+
test_futureOr_01() {
isSubtype(
intStar,
@@ -6091,8 +6125,8 @@
var analysisContext = TestAnalysisContext(
featureSet: testFeatureSet,
);
- typeProvider = analysisContext.typeProvider;
- typeSystem = analysisContext.typeSystem;
+ typeProvider = analysisContext.typeProviderNonNullableByDefault;
+ typeSystem = analysisContext.typeSystemNonNullableByDefault;
}
}
diff --git a/pkg/analyzer/test/src/dart/element/test_all.dart b/pkg/analyzer/test/src/dart/element/test_all.dart
index 1527bf0..0bfa569 100644
--- a/pkg/analyzer/test/src/dart/element/test_all.dart
+++ b/pkg/analyzer/test/src/dart/element/test_all.dart
@@ -12,7 +12,7 @@
import 'subtype_test.dart' as subtype;
import 'type_algebra_test.dart' as type_algebra;
import 'type_parameter_element_test.dart' as type_parameter_element;
-import 'upper_bound_test.dart' as upper_bound;
+import 'upper_lower_bound_test.dart' as upper_bound;
/// Utility for manually running all tests.
main() {
diff --git a/pkg/analyzer/test/src/dart/element/type_parameter_element_test.dart b/pkg/analyzer/test/src/dart/element/type_parameter_element_test.dart
index 707e370..e80e2de 100644
--- a/pkg/analyzer/test/src/dart/element/type_parameter_element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/type_parameter_element_test.dart
@@ -67,6 +67,35 @@
expect(_equal(M, T), isTrue);
}
+ test_equal_memberMember2_differentBase() {
+ var T1 = typeParameter('T');
+ var T2 = typeParameter('T');
+
+ var M1 = TypeParameterMember(T1, null, typeProvider.numType);
+ var M2 = TypeParameterMember(T2, null, typeProvider.numType);
+
+ expect(M1 == M2, isFalse);
+ }
+
+ test_equal_memberMember2_sameBase_differentBounds() {
+ var T = typeParameter('T');
+
+ var M1 = TypeParameterMember(T, null, typeProvider.intType);
+ var M2 = TypeParameterMember(T, null, typeProvider.doubleType);
+
+ expect(M1 == M2, isTrue);
+ }
+
+ test_equal_memberMember2_sameBase_equalBounds() {
+ var T = typeParameter('T');
+
+ var M1 = TypeParameterMember(T, null, typeProvider.numType);
+ var M2 = TypeParameterMember(T, null, typeProvider.numType);
+
+ expect(M1 == M2, isTrue);
+ expect(M2 == M1, isTrue);
+ }
+
test_equal_memberMember_differentBase() {
var T1 = typeParameter('T1');
var T2 = typeParameter('T2');
diff --git a/pkg/analyzer/test/src/dart/element/upper_bound_test.dart b/pkg/analyzer/test/src/dart/element/upper_bound_test.dart
deleted file mode 100644
index 9a7c535..0000000
--- a/pkg/analyzer/test/src/dart/element/upper_bound_test.dart
+++ /dev/null
@@ -1,1366 +0,0 @@
-// Copyright (c) 2019, 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.
-
-import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/dart/element/nullability_suffix.dart';
-import 'package:analyzer/dart/element/type.dart';
-import 'package:analyzer/src/dart/element/member.dart';
-import 'package:analyzer/src/dart/element/type.dart';
-import 'package:analyzer/src/dart/element/type_visitor.dart';
-import 'package:analyzer/src/generated/resolver.dart';
-import 'package:test/test.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../../../generated/elements_types_mixin.dart';
-import '../../../generated/test_analysis_context.dart';
-
-main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(BoundsHelperPredicatesTest);
- defineReflectiveTests(UpperBoundTest);
- });
-}
-
-@reflectiveTest
-class BoundsHelperPredicatesTest extends _SubtypingTestBase {
- static final Map<String, StackTrace> _isMoreBottomChecked = {};
- static final Map<String, StackTrace> _isMoreTopChecked = {};
-
- @override
- FeatureSet get testFeatureSet {
- return FeatureSet.forTesting(
- additionalFeatures: [Feature.non_nullable],
- );
- }
-
- void isBottom(DartType type) {
- expect(typeSystem.isBottom(type), isTrue, reason: _typeString(type));
- }
-
- void isMoreBottom(DartType T, DartType S) {
- _assertIsBottomOrNull(T);
- _assertIsBottomOrNull(S);
-
- var str = _typeString(T) + ' vs ' + _typeString(S);
- _checkUniqueTypeStr(_isMoreBottomChecked, str);
-
- expect(typeSystem.isMoreBottom(T, S), isTrue, reason: str);
- }
-
- void isMoreTop(DartType T, DartType S) {
- _assertIsTopOrObject(T);
- _assertIsTopOrObject(S);
-
- var str = _typeString(T) + ' vs ' + _typeString(S);
- _checkUniqueTypeStr(_isMoreTopChecked, str);
-
- expect(typeSystem.isMoreTop(T, S), isTrue, reason: str);
- }
-
- void isNotBottom(DartType type) {
- expect(typeSystem.isBottom(type), isFalse, reason: _typeString(type));
- }
-
- void isNotMoreBottom(DartType T, DartType S) {
- _assertIsBottomOrNull(T);
- _assertIsBottomOrNull(S);
-
- var str = _typeString(T) + ' vs ' + _typeString(S);
- _checkUniqueTypeStr(_isMoreBottomChecked, str);
-
- expect(typeSystem.isMoreBottom(T, S), isFalse, reason: str);
- }
-
- void isNotMoreTop(DartType T, DartType S) {
- _assertIsTopOrObject(T);
- _assertIsTopOrObject(S);
-
- var str = _typeString(T) + ' vs ' + _typeString(S);
- _checkUniqueTypeStr(_isMoreTopChecked, str);
-
- expect(typeSystem.isMoreTop(T, S), isFalse, reason: str);
- }
-
- void isNotNull(DartType type) {
- expect(typeSystem.isNull(type), isFalse, reason: _typeString(type));
- }
-
- void isNotObject(DartType type) {
- expect(typeSystem.isObject(type), isFalse, reason: _typeString(type));
- }
-
- void isNotTop(DartType type) {
- expect(typeSystem.isTop(type), isFalse, reason: _typeString(type));
- }
-
- void isNull(DartType type) {
- expect(typeSystem.isNull(type), isTrue, reason: _typeString(type));
- }
-
- void isObject(DartType type) {
- expect(typeSystem.isObject(type), isTrue, reason: _typeString(type));
- }
-
- void isTop(DartType type) {
- expect(typeSystem.isTop(type), isTrue, reason: _typeString(type));
- }
-
- test_isBottom() {
- TypeParameterElement T;
- TypeParameterMember T2;
-
- // BOTTOM(Never) is true
- isBottom(neverNone);
- isNotBottom(neverQuestion);
- isNotBottom(neverStar);
-
- // BOTTOM(X&T) is true iff BOTTOM(T)
- T = typeParameter('T', bound: objectQuestion);
-
- T2 = promoteTypeParameter(T, neverNone);
- isBottom(typeParameterTypeNone(T2));
- isBottom(typeParameterTypeQuestion(T2));
- isBottom(typeParameterTypeStar(T2));
-
- T2 = promoteTypeParameter(T, neverQuestion);
- isNotBottom(typeParameterTypeNone(T2));
- isNotBottom(typeParameterTypeQuestion(T2));
- isNotBottom(typeParameterTypeStar(T2));
-
- // BOTTOM(X extends T) is true iff BOTTOM(T)
- T = typeParameter('T', bound: neverNone);
- isBottom(typeParameterTypeNone(T));
- isBottom(typeParameterTypeQuestion(T));
- isBottom(typeParameterTypeStar(T));
-
- T = typeParameter('T', bound: neverQuestion);
- isNotBottom(typeParameterTypeNone(T));
- isNotBottom(typeParameterTypeQuestion(T));
- isNotBottom(typeParameterTypeStar(T));
-
- // BOTTOM(T) is false otherwise
- isNotBottom(dynamicNone);
- isNotBottom(voidNone);
-
- isNotBottom(objectNone);
- isNotBottom(objectQuestion);
- isNotBottom(objectStar);
-
- isNotBottom(intNone);
- isNotBottom(intQuestion);
- isNotBottom(intStar);
-
- T = typeParameter('T', bound: numNone);
- isNotBottom(typeParameterTypeNone(T));
- isNotBottom(typeParameterTypeQuestion(T));
- isNotBottom(typeParameterTypeStar(T));
-
- T = typeParameter('T', bound: numStar);
- isNotBottom(typeParameterTypeNone(T));
- isNotBottom(typeParameterTypeQuestion(T));
- isNotBottom(typeParameterTypeStar(T));
-
- T2 = promoteTypeParameter(typeParameter('T'), intNone);
- isNotBottom(typeParameterTypeNone(T2));
- isNotBottom(typeParameterTypeQuestion(T2));
- isNotBottom(typeParameterTypeStar(T2));
- }
-
- test_isMoreBottom() {
- // MOREBOTTOM(Never, T) = true
- isMoreBottom(neverNone, neverNone);
- isMoreBottom(neverNone, neverQuestion);
- isMoreBottom(neverNone, neverStar);
-
- isMoreBottom(neverNone, nullNone);
- isMoreBottom(neverNone, nullQuestion);
- isMoreBottom(neverNone, nullStar);
-
- // MOREBOTTOM(T, Never) = false
- isNotMoreBottom(neverQuestion, neverNone);
- isNotMoreBottom(neverStar, neverNone);
-
- isNotMoreBottom(nullNone, neverNone);
- isNotMoreBottom(nullQuestion, neverNone);
- isNotMoreBottom(nullStar, neverNone);
-
- // MOREBOTTOM(Null, T) = true
- isMoreBottom(nullNone, neverQuestion);
- isMoreBottom(nullNone, neverStar);
-
- isMoreBottom(nullNone, nullNone);
- isMoreBottom(nullNone, nullQuestion);
- isMoreBottom(nullNone, nullStar);
-
- // MOREBOTTOM(T, Null) = false
- isNotMoreBottom(neverQuestion, nullNone);
- isNotMoreBottom(neverStar, nullNone);
-
- isNotMoreBottom(nullQuestion, nullNone);
- isNotMoreBottom(nullStar, nullNone);
-
- // MOREBOTTOM(T?, S?) = MOREBOTTOM(T, S)
- isMoreBottom(neverQuestion, nullQuestion);
- isNotMoreBottom(nullQuestion, neverQuestion);
-
- // MOREBOTTOM(T, S?) = true
- isMoreBottom(neverStar, nullQuestion);
- isMoreBottom(nullStar, neverQuestion);
-
- // MOREBOTTOM(T?, S) = false
- isNotMoreBottom(neverQuestion, nullStar);
- isNotMoreBottom(nullQuestion, neverStar);
-
- // MOREBOTTOM(T*, S*) = MOREBOTTOM(T, S)
- isMoreBottom(neverStar, nullStar);
- isNotMoreBottom(nullStar, neverStar);
-
- // MOREBOTTOM(T, S*) = true
- isMoreBottom(
- typeParameterTypeNone(
- typeParameter('S', bound: neverNone),
- ),
- nullStar,
- );
-
- // MOREBOTTOM(T*, S) = false
- isNotMoreBottom(
- nullStar,
- typeParameterTypeNone(
- typeParameter('S', bound: neverNone),
- ),
- );
-
- // MOREBOTTOM(X&T, Y&S) = MOREBOTTOM(T, S)
- isMoreBottom(
- typeParameterTypeNone(
- promoteTypeParameter(
- typeParameter('T', bound: objectQuestion),
- neverNone,
- ),
- ),
- typeParameterTypeQuestion(
- promoteTypeParameter(
- typeParameter('S', bound: objectQuestion),
- neverNone,
- ),
- ),
- );
-
- // MOREBOTTOM(X&T, S) = true
- isMoreBottom(
- typeParameterTypeNone(
- promoteTypeParameter(
- typeParameter('T', bound: objectQuestion),
- neverNone,
- ),
- ),
- typeParameterTypeNone(
- typeParameter('S', bound: neverNone),
- ),
- );
-
- // MOREBOTTOM(T, X&S) = false
- isNotMoreBottom(
- typeParameterTypeNone(
- typeParameter('T', bound: neverNone),
- ),
- typeParameterTypeNone(
- promoteTypeParameter(
- typeParameter('S', bound: objectQuestion),
- neverNone,
- ),
- ),
- );
-
- // MOREBOTTOM(X extends T, Y extends S) = MOREBOTTOM(T, S)
- isMoreBottom(
- typeParameterTypeNone(
- typeParameter('T', bound: neverNone),
- ),
- typeParameterTypeQuestion(
- typeParameter('S', bound: neverNone),
- ),
- );
- }
-
- test_isMoreTop() {
- // MORETOP(void, T) = true
- isMoreTop(voidNone, voidNone);
- isMoreTop(voidNone, dynamicNone);
- isMoreTop(voidNone, objectNone);
- isMoreTop(voidNone, objectQuestion);
- isMoreTop(voidNone, objectStar);
- isMoreTop(voidNone, futureOrNone(objectNone));
- isMoreTop(voidNone, futureOrNone(objectQuestion));
- isMoreTop(voidNone, futureOrNone(objectStar));
-
- // MORETOP(T, void) = false
- isNotMoreTop(dynamicNone, voidNone);
- isNotMoreTop(objectNone, voidNone);
- isNotMoreTop(objectQuestion, voidNone);
- isNotMoreTop(objectStar, voidNone);
- isNotMoreTop(futureOrNone(objectNone), voidNone);
- isNotMoreTop(futureOrNone(objectQuestion), voidNone);
- isNotMoreTop(futureOrNone(objectStar), voidNone);
-
- // MORETOP(dynamic, T) = true
- isMoreTop(dynamicNone, dynamicNone);
- isMoreTop(dynamicNone, objectNone);
- isMoreTop(dynamicNone, objectQuestion);
- isMoreTop(dynamicNone, objectStar);
- isMoreTop(dynamicNone, futureOrNone(objectNone));
- isMoreTop(dynamicNone, futureOrNone(objectQuestion));
- isMoreTop(dynamicNone, futureOrNone(objectStar));
-
- // MORETOP(T, dynamic) = false
- isNotMoreTop(objectNone, dynamicNone);
- isNotMoreTop(objectQuestion, dynamicNone);
- isNotMoreTop(objectStar, dynamicNone);
- isNotMoreTop(futureOrNone(objectNone), dynamicNone);
- isNotMoreTop(futureOrNone(objectQuestion), dynamicNone);
- isNotMoreTop(futureOrNone(objectStar), dynamicNone);
-
- // MORETOP(Object, T) = true
- isMoreTop(objectNone, objectNone);
- isMoreTop(objectNone, objectQuestion);
- isMoreTop(objectNone, objectStar);
- isMoreTop(objectNone, futureOrNone(objectNone));
- isMoreTop(objectNone, futureOrQuestion(objectNone));
- isMoreTop(objectNone, futureOrStar(objectNone));
-
- // MORETOP(T, Object) = false
- isNotMoreTop(objectQuestion, objectNone);
- isNotMoreTop(objectStar, objectNone);
- isNotMoreTop(futureOrNone(objectNone), objectNone);
- isNotMoreTop(futureOrQuestion(objectNone), objectNone);
- isNotMoreTop(futureOrStar(objectNone), objectNone);
-
- // MORETOP(T*, S*) = MORETOP(T, S)
- isMoreTop(objectStar, objectStar);
- isMoreTop(objectStar, futureOrStar(objectNone));
- isMoreTop(objectStar, futureOrStar(objectQuestion));
- isMoreTop(objectStar, futureOrStar(objectStar));
- isMoreTop(futureOrStar(objectNone), futureOrStar(objectNone));
-
- // MORETOP(T, S*) = true
- isMoreTop(futureOrNone(objectNone), futureOrStar(voidNone));
- isMoreTop(futureOrNone(objectNone), futureOrStar(dynamicNone));
- isMoreTop(futureOrNone(objectNone), futureOrStar(objectNone));
- isMoreTop(futureOrQuestion(objectNone), futureOrStar(voidNone));
- isMoreTop(futureOrQuestion(objectNone), futureOrStar(dynamicNone));
- isMoreTop(futureOrQuestion(objectNone), futureOrStar(objectNone));
-
- // MORETOP(T*, S) = false
- isNotMoreTop(futureOrStar(voidNone), futureOrNone(objectNone));
- isNotMoreTop(futureOrStar(dynamicNone), futureOrNone(objectNone));
- isNotMoreTop(futureOrStar(objectNone), futureOrNone(objectNone));
- isNotMoreTop(futureOrStar(voidNone), futureOrQuestion(objectNone));
- isNotMoreTop(futureOrStar(dynamicNone), futureOrQuestion(objectNone));
- isNotMoreTop(futureOrStar(objectNone), futureOrQuestion(objectNone));
-
- // MORETOP(T?, S?) = MORETOP(T, S)
- isMoreTop(objectQuestion, objectQuestion);
- isMoreTop(futureOrQuestion(voidNone), futureOrQuestion(voidNone));
- isMoreTop(futureOrQuestion(voidNone), futureOrQuestion(dynamicNone));
- isMoreTop(futureOrQuestion(voidNone), futureOrQuestion(objectNone));
-
- // MORETOP(T, S?) = true
- isMoreTop(futureOrNone(objectNone), futureOrQuestion(voidNone));
- isMoreTop(futureOrNone(objectNone), futureOrQuestion(dynamicNone));
- isMoreTop(futureOrNone(objectNone), futureOrQuestion(objectNone));
-
- // MORETOP(T?, S) = false
- isNotMoreTop(futureOrQuestion(voidNone), futureOrNone(objectNone));
- isNotMoreTop(futureOrQuestion(dynamicNone), futureOrNone(objectNone));
- isNotMoreTop(futureOrQuestion(objectNone), futureOrNone(objectNone));
-
- // MORETOP(FutureOr<T>, FutureOr<S>) = MORETOP(T, S)
- isMoreTop(futureOrNone(voidNone), futureOrNone(voidNone));
- isMoreTop(futureOrNone(voidNone), futureOrNone(dynamicNone));
- isMoreTop(futureOrNone(voidNone), futureOrNone(objectNone));
- isNotMoreTop(futureOrNone(dynamicNone), futureOrNone(voidNone));
- isNotMoreTop(futureOrNone(objectNone), futureOrNone(voidNone));
- }
-
- test_isNull() {
- // NULL(Null) is true
- isNull(nullNone);
-
- // NULL(T?) is true iff NULL(T) or BOTTOM(T)
- isNull(nullQuestion);
- isNull(neverQuestion);
- isNull(
- typeParameterTypeQuestion(
- typeParameter('T', bound: neverNone),
- ),
- );
-
- // NULL(T*) is true iff NULL(T) or BOTTOM(T)
- isNull(nullStar);
- isNull(neverStar);
- isNull(
- typeParameterTypeStar(
- typeParameter('T', bound: neverNone),
- ),
- );
-
- // NULL(T) is false otherwise
- isNotNull(dynamicNone);
- isNotNull(voidNone);
-
- isNotNull(objectNone);
- isNotNull(objectQuestion);
- isNotNull(objectStar);
-
- isNotNull(intNone);
- isNotNull(intQuestion);
- isNotNull(intStar);
-
- isNotNull(futureOrNone(nullNone));
- isNotNull(futureOrNone(nullQuestion));
- isNotNull(futureOrNone(nullStar));
-
- isNotNull(futureOrQuestion(nullNone));
- isNotNull(futureOrQuestion(nullQuestion));
- isNotNull(futureOrQuestion(nullStar));
-
- isNotNull(futureOrStar(nullNone));
- isNotNull(futureOrStar(nullQuestion));
- isNotNull(futureOrStar(nullStar));
- }
-
- test_isObject() {
- // OBJECT(Object) is true
- isObject(objectNone);
- isNotObject(objectQuestion);
- isNotObject(objectStar);
-
- // OBJECT(FutureOr<T>) is OBJECT(T)
- isObject(futureOrNone(objectNone));
- isNotObject(futureOrNone(objectQuestion));
- isNotObject(futureOrNone(objectStar));
-
- isNotObject(futureOrQuestion(objectNone));
- isNotObject(futureOrQuestion(objectQuestion));
- isNotObject(futureOrQuestion(objectStar));
-
- isNotObject(futureOrStar(objectNone));
- isNotObject(futureOrStar(objectQuestion));
- isNotObject(futureOrStar(objectStar));
-
- // OBJECT(T) is false otherwise
- isNotObject(dynamicNone);
- isNotObject(voidNone);
- isNotObject(intNone);
- }
-
- test_isTop() {
- // TOP(T?) is true iff TOP(T) or OBJECT(T)
- isTop(objectQuestion);
- isTop(futureOrQuestion(dynamicNone));
- isTop(futureOrQuestion(voidNone));
-
- isTop(futureOrQuestion(objectNone));
- isTop(futureOrQuestion(objectQuestion));
- isTop(futureOrQuestion(objectStar));
-
- isNotTop(futureOrQuestion(intNone));
- isNotTop(futureOrQuestion(intQuestion));
- isNotTop(futureOrQuestion(intStar));
-
- // TOP(T*) is true iff TOP(T) or OBJECT(T)
- isTop(objectStar);
- isTop(futureOrStar(dynamicNone));
- isTop(futureOrStar(voidNone));
-
- isTop(futureOrStar(objectNone));
- isTop(futureOrStar(objectQuestion));
- isTop(futureOrStar(objectStar));
-
- isNotTop(futureOrStar(intNone));
- isNotTop(futureOrStar(intQuestion));
- isNotTop(futureOrStar(intStar));
-
- // TOP(dynamic) is true
- isTop(dynamicNone);
-
- // TOP(void) is true
- isTop(voidNone);
-
- // TOP(FutureOr<T>) is TOP(T)
- isTop(futureOrNone(dynamicNone));
- isTop(futureOrNone(voidNone));
-
- isNotTop(futureOrNone(objectNone));
- isTop(futureOrNone(objectQuestion));
- isTop(futureOrNone(objectStar));
-
- // TOP(T) is false otherwise
- isNotTop(objectNone);
-
- isNotTop(intNone);
- isNotTop(intQuestion);
- isNotTop(intStar);
-
- isNotTop(neverNone);
- isNotTop(neverQuestion);
- isNotTop(neverStar);
- }
-
- /// [TypeSystemImpl.isMoreBottom] can be used only for `BOTTOM` or `NULL`
- /// types. No need to check other types.
- void _assertIsBottomOrNull(DartType type) {
- expect(typeSystem.isBottom(type) || typeSystem.isNull(type), isTrue,
- reason: _typeString(type));
- }
-
- /// [TypeSystemImpl.isMoreTop] can be used only for `TOP` or `OBJECT`
- /// types. No need to check other types.
- void _assertIsTopOrObject(DartType type) {
- expect(typeSystem.isTop(type) || typeSystem.isObject(type), isTrue,
- reason: _typeString(type));
- }
-
- void _checkUniqueTypeStr(Map<String, StackTrace> map, String str) {
- var previousStack = map[str];
- if (previousStack != null) {
- fail('Not unique: $str\n$previousStack');
- } else {
- map[str] = StackTrace.current;
- }
- }
-
- String _typeParametersStr(TypeImpl type) {
- var typeStr = '';
-
- var typeParameterCollector = _TypeParameterCollector();
- DartTypeVisitor.visit(type, typeParameterCollector);
- for (var typeParameter in typeParameterCollector.typeParameters) {
- if (typeParameter is TypeParameterMember) {
- var base = typeParameter.declaration;
- var baseBound = base.bound as TypeImpl;
- if (baseBound != null) {
- var baseBoundStr = baseBound.toString(withNullability: true);
- typeStr += ', ${typeParameter.name} extends ' + baseBoundStr;
- }
-
- var bound = typeParameter.bound as TypeImpl;
- var boundStr = bound.toString(withNullability: true);
- typeStr += ', ${typeParameter.name} & ' + boundStr;
- } else {
- var bound = typeParameter.bound as TypeImpl;
- if (bound != null) {
- var boundStr = bound.toString(withNullability: true);
- typeStr += ', ${typeParameter.name} extends ' + boundStr;
- }
- }
- }
- return typeStr;
- }
-}
-
-@reflectiveTest
-class UpperBoundTest extends _SubtypingTestBase {
- test_bottom_any() {
- void check(DartType T1, DartType T2) {
- expect(typeSystem.isBottom(T1), isTrue, reason: _typeString(T1));
- expect(typeSystem.isBottom(T2), isFalse, reason: _typeString(T2));
- _checkLeastUpperBound(T1, T2, T2);
- }
-
- check(neverNone, objectNone);
- check(neverNone, objectStar);
- check(neverNone, objectQuestion);
-
- check(neverNone, intNone);
- check(neverNone, intQuestion);
- check(neverNone, intStar);
-
- check(neverNone, listNone(intNone));
- check(neverNone, listQuestion(intNone));
- check(neverNone, listStar(intNone));
-
- check(neverNone, futureOrNone(intNone));
- check(neverNone, futureOrQuestion(intNone));
- check(neverNone, futureOrStar(intNone));
-
- {
- var T = typeParameterTypeNone(
- typeParameter('T', bound: neverNone),
- );
- check(T, intNone);
- check(T, intQuestion);
- check(T, intStar);
- }
-
- {
- var T = typeParameterTypeNone(
- promoteTypeParameter(
- typeParameter('T', bound: objectQuestion),
- neverNone,
- ),
- );
- check(T, intNone);
- check(T, intQuestion);
- check(T, intStar);
- }
- }
-
- test_bottom_bottom() {
- void check(DartType T1, DartType T2) {
- expect(typeSystem.isBottom(T1), isTrue, reason: _typeString(T1));
- expect(typeSystem.isBottom(T2), isTrue, reason: _typeString(T2));
- _checkLeastUpperBound(T1, T2, T2);
- }
-
- check(
- neverNone,
- typeParameterTypeNone(
- typeParameter('T', bound: neverNone),
- ),
- );
-
- check(
- neverNone,
- typeParameterTypeNone(
- promoteTypeParameter(
- typeParameter('T', bound: objectQuestion),
- neverNone,
- ),
- ),
- );
- }
-
- test_functionType2_parameters_named() {
- FunctionType build(Map<String, DartType> namedTypes) {
- return functionTypeNone(
- returnType: voidNone,
- parameters: namedTypes.entries.map((entry) {
- return namedParameter(name: entry.key, type: entry.value);
- }).toList(),
- );
- }
-
- void check(Map<String, DartType> T1_named, Map<String, DartType> T2_named,
- Map<String, DartType> expected_named) {
- var T1 = build(T1_named);
- var T2 = build(T2_named);
- var expected = build(expected_named);
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check({'a': intNone}, {}, {});
- check({'a': intNone}, {'b': intNone}, {});
-
- check({'a': intNone}, {'a': intNone}, {'a': intNone});
- check({'a': intNone}, {'a': intQuestion}, {'a': intNone});
-
- check({'a': intNone, 'b': doubleNone}, {'a': intNone}, {'a': intNone});
- }
-
- test_functionType2_parameters_optionalPositional() {
- FunctionType build(List<DartType> positionalTypes) {
- return functionTypeNone(
- returnType: voidNone,
- parameters: positionalTypes.map((type) {
- return positionalParameter(type: type);
- }).toList(),
- );
- }
-
- void check(List<DartType> T1_positional, List<DartType> T2_positional,
- DartType expected) {
- var T1 = build(T1_positional);
- var T2 = build(T2_positional);
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check([intNone], [], build([]));
- check([intNone, doubleNone], [intNone], build([intNone]));
-
- check([intNone], [intNone], build([intNone]));
- check([intNone], [intQuestion], build([intNone]));
-
- // TODO(scheglov) Uncomment when DOWN is NNBD based.
-// check([intNone], [intStar], build([intNone]));
-// check([intNone], [doubleNone], build([neverNone]));
-
- check([intNone], [numNone], build([intNone]));
-
- check(
- [doubleNone, numNone],
- [numNone, intNone],
- build([doubleNone, intNone]),
- );
- }
-
- test_functionType2_parameters_required() {
- FunctionType build(List<DartType> requiredTypes) {
- return functionTypeNone(
- returnType: voidNone,
- parameters: requiredTypes.map((type) {
- return requiredParameter(type: type);
- }).toList(),
- );
- }
-
- void check(List<DartType> T1_required, List<DartType> T2_required,
- DartType expected) {
- var T1 = build(T1_required);
- var T2 = build(T2_required);
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check([intNone], [], functionNone);
-
- check([intNone], [intNone], build([intNone]));
- check([intNone], [intQuestion], build([intNone]));
-
- // TODO(scheglov) Uncomment when DOWN is NNBD based.
-// check([intNone], [intStar], build([intNone]));
-// check([intNone], [doubleNone], build([neverNone]));
-
- check([intNone], [numNone], build([intNone]));
-
- check(
- [doubleNone, numNone],
- [numNone, intNone],
- build([doubleNone, intNone]),
- );
- }
-
- test_functionType2_returnType() {
- void check(DartType T1_ret, DartType T2_ret, DartType expected_ret) {
- _checkLeastUpperBound(
- functionTypeNone(returnType: T1_ret),
- functionTypeNone(returnType: T2_ret),
- functionTypeNone(returnType: expected_ret),
- );
- }
-
- check(intNone, intNone, intNone);
- check(intNone, intQuestion, intQuestion);
- check(intNone, intStar, intStar);
-
- check(intNone, numNone, numNone);
- check(intQuestion, numNone, numQuestion);
- check(intStar, numNone, numStar);
-
- check(intNone, dynamicNone, dynamicNone);
- check(intNone, neverNone, intNone);
- }
-
- test_functionType2_typeParameters() {
- void check(FunctionType T1, FunctionType T2, DartType expected) {
- _assertNullabilityNone(T1);
- _assertNullabilityNone(T2);
-
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check(
- functionTypeNone(
- returnType: voidNone,
- typeFormals: [
- typeParameter('T'),
- ],
- ),
- functionTypeNone(returnType: voidNone),
- functionNone,
- );
-
- check(
- functionTypeNone(
- returnType: voidNone,
- typeFormals: [
- typeParameter('T', bound: intNone),
- ],
- ),
- functionTypeNone(
- returnType: voidNone,
- typeFormals: [
- typeParameter('T', bound: numNone),
- ],
- ),
- functionNone,
- );
-
- {
- var T = typeParameter('T', bound: numNone);
- var U = typeParameter('U', bound: numNone);
- var R = typeParameter('R', bound: numNone);
- check(
- functionTypeNone(
- returnType: typeParameterTypeNone(T),
- typeFormals: [T],
- ),
- functionTypeNone(
- returnType: typeParameterTypeNone(U),
- typeFormals: [U],
- ),
- functionTypeNone(
- returnType: typeParameterTypeNone(R),
- typeFormals: [R],
- ),
- );
- }
- }
-
- test_functionType_interfaceType() {
- void check(FunctionType T1, InterfaceType T2, InterfaceType expected) {
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check(
- functionTypeNone(returnType: voidNone),
- intNone,
- objectNone,
- );
- }
-
- test_functionType_interfaceType_Function() {
- void check(FunctionType T1, InterfaceType T2, InterfaceType expected) {
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- void checkNone(FunctionType T1) {
- _assertNullabilityNone(T1);
- check(T1, functionNone, functionNone);
- }
-
- checkNone(functionTypeNone(returnType: voidNone));
-
- checkNone(
- functionTypeNone(
- returnType: intNone,
- parameters: [
- requiredParameter(type: numQuestion),
- ],
- ),
- );
-
- check(
- functionTypeQuestion(returnType: voidNone),
- functionNone,
- functionQuestion,
- );
- }
-
- test_identical() {
- void check(DartType type) {
- _checkLeastUpperBound(type, type, type);
- }
-
- check(intNone);
- check(intQuestion);
- check(intStar);
- check(listNone(intNone));
- }
-
- test_none_question() {
- void check(DartType T1, DartType T2, DartType expected) {
- _assertNullabilityNone(T1);
- _assertNullabilityQuestion(T2);
-
- _assertNotSpecial(T1);
- _assertNotSpecial(T2);
-
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check(doubleNone, intQuestion, numQuestion);
- check(numNone, doubleQuestion, numQuestion);
- check(numNone, intQuestion, numQuestion);
- }
-
- test_none_star() {
- void check(DartType T1, DartType T2, DartType expected) {
- _assertNullabilityNone(T1);
- _assertNullabilityStar(T2);
-
- _assertNotSpecial(T1);
- _assertNotSpecial(T2);
-
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check(doubleNone, intStar, numStar);
- check(numNone, doubleStar, numStar);
- check(numNone, intStar, numStar);
- }
-
- test_null_any() {
- void check(DartType T1, DartType T2, DartType expected) {
- var T1_str = _typeString(T1);
- var T2_str = _typeString(T2);
-
- expect(typeSystem.isNull(T1), isTrue, reason: 'isNull: $T1_str');
- expect(typeSystem.isNull(T2), isFalse, reason: 'isNull: $T2_str');
-
- expect(typeSystem.isTop(T1), isFalse, reason: 'isTop: $T1_str');
- expect(typeSystem.isTop(T2), isFalse, reason: 'isTop: $T2_str');
-
- expect(typeSystem.isBottom(T1), isFalse, reason: 'isBottom: $T1_str');
- expect(typeSystem.isBottom(T2), isFalse, reason: 'isBottom: $T2_str');
-
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check(nullNone, objectNone, objectQuestion);
-
- check(nullNone, intNone, intQuestion);
- check(nullNone, intQuestion, intQuestion);
- check(nullNone, intStar, intQuestion);
-
- check(nullQuestion, intNone, intQuestion);
- check(nullQuestion, intQuestion, intQuestion);
- check(nullQuestion, intStar, intQuestion);
-
- check(nullStar, intNone, intQuestion);
- check(nullStar, intQuestion, intQuestion);
- check(nullStar, intStar, intQuestion);
-
- check(nullNone, listNone(intNone), listQuestion(intNone));
- check(nullNone, listQuestion(intNone), listQuestion(intNone));
- check(nullNone, listStar(intNone), listQuestion(intNone));
-
- check(nullNone, futureOrNone(intNone), futureOrQuestion(intNone));
- check(nullNone, futureOrQuestion(intNone), futureOrQuestion(intNone));
- check(nullNone, futureOrStar(intNone), futureOrQuestion(intNone));
-
- check(nullNone, futureOrNone(intQuestion), futureOrNone(intQuestion));
- check(nullNone, futureOrStar(intQuestion), futureOrStar(intQuestion));
-
- check(
- nullNone,
- functionTypeNone(returnType: intNone),
- functionTypeQuestion(returnType: intNone),
- );
- }
-
- test_null_null() {
- void check(DartType T1, DartType T2) {
- var T1_str = _typeString(T1);
- var T2_str = _typeString(T2);
-
- expect(typeSystem.isNull(T1), isTrue, reason: 'isNull: $T1_str');
- expect(typeSystem.isNull(T2), isTrue, reason: 'isNull: $T2_str');
-
- expect(typeSystem.isBottom(T1), isFalse, reason: 'isBottom: $T1_str');
- expect(typeSystem.isBottom(T2), isFalse, reason: 'isBottom: $T2_str');
-
- _checkLeastUpperBound(T1, T2, T2);
- }
-
- check(nullNone, nullQuestion);
- check(nullNone, nullStar);
- }
-
- test_object_any() {
- void check(DartType T1, DartType T2, DartType expected) {
- var T1_str = _typeString(T1);
- var T2_str = _typeString(T2);
-
- expect(typeSystem.isObject(T1), isTrue, reason: 'isObject: $T1_str');
- expect(typeSystem.isObject(T2), isFalse, reason: 'isObject: $T2_str');
-
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check(objectNone, intNone, objectNone);
- check(objectNone, intQuestion, objectQuestion);
- check(objectNone, intStar, objectNone);
-
- check(objectNone, futureOrNone(intQuestion), objectQuestion);
-
- check(futureOrNone(objectNone), intNone, futureOrNone(objectNone));
- check(futureOrNone(objectNone), intQuestion, futureOrQuestion(objectNone));
- check(futureOrNone(objectNone), intStar, futureOrNone(objectNone));
- }
-
- test_object_object() {
- void check(DartType T1, DartType T2) {
- var T1_str = _typeString(T1);
- var T2_str = _typeString(T2);
-
- expect(typeSystem.isObject(T1), isTrue, reason: 'isObject: $T1_str');
- expect(typeSystem.isObject(T2), isTrue, reason: 'isObject: $T2_str');
-
- _checkLeastUpperBound(T1, T2, T2);
- }
-
- check(futureOrNone(objectNone), objectNone);
-
- check(
- futureOrNone(
- futureOrNone(objectNone),
- ),
- futureOrNone(objectNone),
- );
- }
-
- test_question_question() {
- void check(DartType T1, DartType T2, DartType expected) {
- _assertNullabilityQuestion(T1);
- _assertNullabilityQuestion(T2);
-
- _assertNotSpecial(T1);
- _assertNotSpecial(T2);
-
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check(doubleQuestion, intQuestion, numQuestion);
- check(numQuestion, doubleQuestion, numQuestion);
- check(numQuestion, intQuestion, numQuestion);
- }
-
- test_question_star() {
- void check(DartType T1, DartType T2, DartType expected) {
- _assertNullabilityQuestion(T1);
- _assertNullabilityStar(T2);
-
- _assertNotSpecial(T1);
- _assertNotSpecial(T2);
-
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check(doubleQuestion, intStar, numQuestion);
- check(numQuestion, doubleStar, numQuestion);
- check(numQuestion, intStar, numQuestion);
- }
-
- test_star_star() {
- void check(DartType T1, DartType T2, DartType expected) {
- _assertNullabilityStar(T1);
- _assertNullabilityStar(T2);
-
- _assertNotSpecial(T1);
- _assertNotSpecial(T2);
-
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- check(doubleStar, intStar, numStar);
- check(numStar, doubleStar, numStar);
- check(numStar, intStar, numStar);
- }
-
- test_top_any() {
- void check(DartType T1, DartType T2) {
- expect(typeSystem.isTop(T1), isTrue, reason: _typeString(T1));
- expect(typeSystem.isTop(T2), isFalse, reason: _typeString(T2));
- _checkLeastUpperBound(T1, T2, T1);
- }
-
- check(voidNone, objectNone);
- check(voidNone, intNone);
- check(voidNone, intQuestion);
- check(voidNone, intStar);
- check(voidNone, listNone(intNone));
- check(voidNone, futureOrNone(intNone));
-
- check(dynamicNone, objectNone);
- check(dynamicNone, intNone);
- check(dynamicNone, intQuestion);
- check(dynamicNone, intStar);
- check(dynamicNone, listNone(intNone));
- check(dynamicNone, futureOrNone(intNone));
-
- check(objectQuestion, objectNone);
- check(objectQuestion, intNone);
- check(objectQuestion, intQuestion);
- check(objectQuestion, intStar);
- check(objectQuestion, listNone(intNone));
- check(objectQuestion, futureOrNone(intNone));
-
- check(objectStar, objectNone);
- check(objectStar, intNone);
- check(objectStar, intQuestion);
- check(objectStar, intStar);
- check(objectStar, listNone(intNone));
- check(objectStar, futureOrNone(intNone));
-
- check(futureOrNone(voidNone), intNone);
- check(futureOrQuestion(voidNone), intNone);
- check(futureOrStar(voidNone), intNone);
- }
-
- test_top_top() {
- void check(DartType T1, DartType T2) {
- expect(typeSystem.isTop(T1), isTrue, reason: _typeString(T1));
- expect(typeSystem.isTop(T2), isTrue, reason: _typeString(T2));
- _checkLeastUpperBound(T1, T2, T1);
- }
-
- check(voidNone, dynamicNone);
- check(voidNone, objectStar);
- check(voidNone, objectQuestion);
- check(voidNone, futureOrNone(voidNone));
- check(voidNone, futureOrNone(dynamicNone));
- check(voidNone, futureOrNone(objectQuestion));
- check(voidNone, futureOrNone(objectStar));
-
- check(dynamicNone, objectStar);
- check(dynamicNone, objectQuestion);
- check(dynamicNone, futureOrNone(voidNone));
- check(dynamicNone, futureOrNone(dynamicNone));
- check(dynamicNone, futureOrNone(objectQuestion));
- check(dynamicNone, futureOrNone(objectStar));
- check(
- dynamicNone,
- futureOrStar(objectStar),
- );
-
- check(objectQuestion, futureOrQuestion(voidNone));
- check(objectQuestion, futureOrQuestion(dynamicNone));
- check(objectQuestion, futureOrQuestion(objectNone));
- check(objectQuestion, futureOrQuestion(objectQuestion));
- check(objectQuestion, futureOrQuestion(objectStar));
-
- check(objectQuestion, futureOrStar(voidNone));
- check(objectQuestion, futureOrStar(dynamicNone));
- check(objectQuestion, futureOrStar(objectNone));
- check(objectQuestion, futureOrStar(objectQuestion));
- check(objectQuestion, futureOrStar(objectStar));
-
- check(objectStar, futureOrStar(voidNone));
- check(objectStar, futureOrStar(dynamicNone));
- check(objectStar, futureOrStar(objectNone));
- check(objectStar, futureOrStar(objectQuestion));
- check(objectStar, futureOrStar(objectStar));
-
- check(futureOrNone(voidNone), objectQuestion);
- check(futureOrNone(dynamicNone), objectQuestion);
- check(futureOrNone(objectQuestion), objectQuestion);
- check(futureOrNone(objectStar), objectQuestion);
-
- check(futureOrNone(voidNone), futureOrNone(dynamicNone));
- check(futureOrNone(voidNone), futureOrNone(objectQuestion));
- check(futureOrNone(voidNone), futureOrNone(objectStar));
- check(futureOrNone(dynamicNone), futureOrNone(objectQuestion));
- check(futureOrNone(dynamicNone), futureOrNone(objectStar));
- }
-
- test_typeParameter_bound() {
- void check(TypeParameterType T1, DartType T2, DartType expected) {
- _assertNullabilityNone(T1);
- _assertNullabilityNone(T2);
-
- _assertNotSpecial(T1);
- _assertNotSpecial(T2);
-
- _checkLeastUpperBound(T1, T2, expected);
- }
-
- {
- var T = typeParameter('T', bound: intNone);
- check(typeParameterTypeNone(T), numNone, numNone);
- }
-
- {
- var T = typeParameter('T', bound: intNone);
- var U = typeParameter('U', bound: numNone);
- check(typeParameterTypeNone(T), typeParameterTypeNone(U), numNone);
- }
-
- {
- var T = typeParameter('T', bound: intNone);
- var U = typeParameter('U', bound: numQuestion);
- check(typeParameterTypeNone(T), typeParameterTypeNone(U), numQuestion);
- }
-
- {
- var T = typeParameter('T', bound: intQuestion);
- var U = typeParameter('U', bound: numNone);
- check(typeParameterTypeNone(T), typeParameterTypeNone(U), numQuestion);
- }
-
- {
- var T = typeParameter('T', bound: numNone);
- var T_none = typeParameterTypeNone(T);
- var U = typeParameter('U', bound: T_none);
- check(T_none, typeParameterTypeNone(U), T_none);
- }
- }
-
- void _assertNotBottom(DartType type) {
- if (typeSystem.isBottom(type)) {
- fail('isBottom must be false: ' + _typeString(type));
- }
- }
-
- void _assertNotNull(DartType type) {
- if (typeSystem.isNull(type)) {
- fail('isNull must be false: ' + _typeString(type));
- }
- }
-
- void _assertNotObject(DartType type) {
- if (typeSystem.isObject(type)) {
- fail('isObject must be false: ' + _typeString(type));
- }
- }
-
- void _assertNotSpecial(DartType type) {
- _assertNotBottom(type);
- _assertNotNull(type);
- _assertNotObject(type);
- _assertNotTop(type);
- }
-
- void _assertNotTop(DartType type) {
- if (typeSystem.isTop(type)) {
- fail('isTop must be false: ' + _typeString(type));
- }
- }
-
- void _assertNullability(DartType type, NullabilitySuffix expected) {
- if ((type as TypeImpl).nullabilitySuffix != expected) {
- fail('Expected $expected in ' + _typeString(type));
- }
- }
-
- void _assertNullabilityNone(DartType type) {
- _assertNullability(type, NullabilitySuffix.none);
- }
-
- void _assertNullabilityQuestion(DartType type) {
- _assertNullability(type, NullabilitySuffix.question);
- }
-
- void _assertNullabilityStar(DartType type) {
- _assertNullability(type, NullabilitySuffix.star);
- }
-
- void _checkLeastUpperBound(DartType T1, DartType T2, DartType expected) {
- var expectedStr = _typeString(expected);
-
- var result = typeSystem.getLeastUpperBound(T1, T2);
- var resultStr = _typeString(result);
- expect(result, expected, reason: '''
-expected: $expectedStr
-actual: $resultStr
-''');
-
- // Check that the result is an upper bound.
- expect(typeSystem.isSubtypeOf(T1, result), true);
- expect(typeSystem.isSubtypeOf(T2, result), true);
-
- // Check for symmetry.
- result = typeSystem.getLeastUpperBound(T2, T1);
- resultStr = _typeString(result);
- expect(result, expected, reason: '''
-expected: $expectedStr
-actual: $resultStr
-''');
- }
-}
-
-@reflectiveTest
-class _SubtypingTestBase with ElementsTypesMixin {
- TypeProvider typeProvider;
-
- TypeSystemImpl typeSystem;
-
- FeatureSet get testFeatureSet {
- return FeatureSet.forTesting();
- }
-
- void setUp() {
- var analysisContext = TestAnalysisContext(
- featureSet: testFeatureSet,
- );
- typeProvider = analysisContext.typeProvider;
- typeSystem = analysisContext.typeSystem;
- }
-
- String _typeParametersStr(TypeImpl type) {
- var typeStr = '';
-
- var typeParameterCollector = _TypeParameterCollector();
- DartTypeVisitor.visit(type, typeParameterCollector);
- for (var typeParameter in typeParameterCollector.typeParameters) {
- if (typeParameter is TypeParameterMember) {
- var base = typeParameter.declaration;
- var baseBound = base.bound as TypeImpl;
- if (baseBound != null) {
- var baseBoundStr = baseBound.toString(withNullability: true);
- typeStr += ', ${typeParameter.name} extends ' + baseBoundStr;
- }
-
- var bound = typeParameter.bound as TypeImpl;
- var boundStr = bound.toString(withNullability: true);
- typeStr += ', ${typeParameter.name} & ' + boundStr;
- } else {
- var bound = typeParameter.bound as TypeImpl;
- if (bound != null) {
- var boundStr = bound.toString(withNullability: true);
- typeStr += ', ${typeParameter.name} extends ' + boundStr;
- }
- }
- }
- return typeStr;
- }
-
- String _typeString(TypeImpl type) {
- if (type == null) return null;
- return type.toString(withNullability: true) + _typeParametersStr(type);
- }
-}
-
-class _TypeParameterCollector extends DartTypeVisitor<void> {
- final Set<TypeParameterElement> typeParameters = Set();
-
- /// We don't need to print bounds for these type parameters, because
- /// they are already included into the function type itself, and cannot
- /// be promoted.
- final Set<TypeParameterElement> functionTypeParameters = Set();
-
- @override
- void defaultDartType(DartType type) {
- throw UnimplementedError('(${type.runtimeType}) $type');
- }
-
- @override
- void visitDynamicType(DynamicTypeImpl type) {}
-
- @override
- void visitFunctionType(FunctionType type) {
- functionTypeParameters.addAll(type.typeFormals);
- for (var typeParameter in type.typeFormals) {
- var bound = typeParameter.bound;
- if (bound != null) {
- DartTypeVisitor.visit(bound, this);
- }
- }
- for (var parameter in type.parameters) {
- DartTypeVisitor.visit(parameter.type, this);
- }
- DartTypeVisitor.visit(type.returnType, this);
- }
-
- @override
- void visitInterfaceType(InterfaceType type) {
- for (var typeArgument in type.typeArguments) {
- DartTypeVisitor.visit(typeArgument, this);
- }
- }
-
- @override
- void visitNeverType(NeverTypeImpl type) {}
-
- @override
- void visitTypeParameterType(TypeParameterType type) {
- if (!functionTypeParameters.contains(type.element)) {
- typeParameters.add(type.element);
- }
- }
-
- @override
- void visitVoidType(VoidType type) {}
-}
diff --git a/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart b/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart
new file mode 100644
index 0000000..17766f8
--- /dev/null
+++ b/pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart
@@ -0,0 +1,2227 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/dart/element/nullability_suffix.dart';
+import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer/src/dart/element/member.dart';
+import 'package:analyzer/src/dart/element/type.dart';
+import 'package:analyzer/src/dart/element/type_visitor.dart';
+import 'package:analyzer/src/generated/resolver.dart';
+import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../../../generated/elements_types_mixin.dart';
+import '../../../generated/test_analysis_context.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(BoundsHelperPredicatesTest);
+ defineReflectiveTests(LowerBoundTest);
+ defineReflectiveTests(UpperBoundTest);
+ });
+}
+
+@reflectiveTest
+class BoundsHelperPredicatesTest extends _BoundsTestBase {
+ static final Map<String, StackTrace> _isMoreBottomChecked = {};
+ static final Map<String, StackTrace> _isMoreTopChecked = {};
+
+ @override
+ FeatureSet get testFeatureSet {
+ return FeatureSet.forTesting(
+ additionalFeatures: [Feature.non_nullable],
+ );
+ }
+
+ void isBottom(DartType type) {
+ expect(typeSystem.isBottom(type), isTrue, reason: _typeString(type));
+ }
+
+ void isMoreBottom(DartType T, DartType S) {
+ _assertIsBottomOrNull(T);
+ _assertIsBottomOrNull(S);
+
+ var str = _typeString(T) + ' vs ' + _typeString(S);
+ _checkUniqueTypeStr(_isMoreBottomChecked, str);
+
+ expect(typeSystem.isMoreBottom(T, S), isTrue, reason: str);
+ }
+
+ void isMoreTop(DartType T, DartType S) {
+ _assertIsTopOrObject(T);
+ _assertIsTopOrObject(S);
+
+ var str = _typeString(T) + ' vs ' + _typeString(S);
+ _checkUniqueTypeStr(_isMoreTopChecked, str);
+
+ expect(typeSystem.isMoreTop(T, S), isTrue, reason: str);
+ }
+
+ void isNotBottom(DartType type) {
+ expect(typeSystem.isBottom(type), isFalse, reason: _typeString(type));
+ }
+
+ void isNotMoreBottom(DartType T, DartType S) {
+ _assertIsBottomOrNull(T);
+ _assertIsBottomOrNull(S);
+
+ var str = _typeString(T) + ' vs ' + _typeString(S);
+ _checkUniqueTypeStr(_isMoreBottomChecked, str);
+
+ expect(typeSystem.isMoreBottom(T, S), isFalse, reason: str);
+ }
+
+ void isNotMoreTop(DartType T, DartType S) {
+ _assertIsTopOrObject(T);
+ _assertIsTopOrObject(S);
+
+ var str = _typeString(T) + ' vs ' + _typeString(S);
+ _checkUniqueTypeStr(_isMoreTopChecked, str);
+
+ expect(typeSystem.isMoreTop(T, S), isFalse, reason: str);
+ }
+
+ void isNotNull(DartType type) {
+ expect(typeSystem.isNull(type), isFalse, reason: _typeString(type));
+ }
+
+ void isNotObject(DartType type) {
+ expect(typeSystem.isObject(type), isFalse, reason: _typeString(type));
+ }
+
+ void isNotTop(DartType type) {
+ expect(typeSystem.isTop(type), isFalse, reason: _typeString(type));
+ }
+
+ void isNull(DartType type) {
+ expect(typeSystem.isNull(type), isTrue, reason: _typeString(type));
+ }
+
+ void isObject(DartType type) {
+ expect(typeSystem.isObject(type), isTrue, reason: _typeString(type));
+ }
+
+ void isTop(DartType type) {
+ expect(typeSystem.isTop(type), isTrue, reason: _typeString(type));
+ }
+
+ test_isBottom() {
+ TypeParameterElement T;
+ TypeParameterMember T2;
+
+ // BOTTOM(Never) is true
+ isBottom(neverNone);
+ isNotBottom(neverQuestion);
+ isNotBottom(neverStar);
+
+ // BOTTOM(X&T) is true iff BOTTOM(T)
+ T = typeParameter('T', bound: objectQuestion);
+
+ T2 = promoteTypeParameter(T, neverNone);
+ isBottom(typeParameterTypeNone(T2));
+ isBottom(typeParameterTypeQuestion(T2));
+ isBottom(typeParameterTypeStar(T2));
+
+ T2 = promoteTypeParameter(T, neverQuestion);
+ isNotBottom(typeParameterTypeNone(T2));
+ isNotBottom(typeParameterTypeQuestion(T2));
+ isNotBottom(typeParameterTypeStar(T2));
+
+ // BOTTOM(X extends T) is true iff BOTTOM(T)
+ T = typeParameter('T', bound: neverNone);
+ isBottom(typeParameterTypeNone(T));
+ isBottom(typeParameterTypeQuestion(T));
+ isBottom(typeParameterTypeStar(T));
+
+ T = typeParameter('T', bound: neverQuestion);
+ isNotBottom(typeParameterTypeNone(T));
+ isNotBottom(typeParameterTypeQuestion(T));
+ isNotBottom(typeParameterTypeStar(T));
+
+ // BOTTOM(T) is false otherwise
+ isNotBottom(dynamicNone);
+ isNotBottom(voidNone);
+
+ isNotBottom(objectNone);
+ isNotBottom(objectQuestion);
+ isNotBottom(objectStar);
+
+ isNotBottom(intNone);
+ isNotBottom(intQuestion);
+ isNotBottom(intStar);
+
+ T = typeParameter('T', bound: numNone);
+ isNotBottom(typeParameterTypeNone(T));
+ isNotBottom(typeParameterTypeQuestion(T));
+ isNotBottom(typeParameterTypeStar(T));
+
+ T = typeParameter('T', bound: numStar);
+ isNotBottom(typeParameterTypeNone(T));
+ isNotBottom(typeParameterTypeQuestion(T));
+ isNotBottom(typeParameterTypeStar(T));
+
+ T2 = promoteTypeParameter(typeParameter('T'), intNone);
+ isNotBottom(typeParameterTypeNone(T2));
+ isNotBottom(typeParameterTypeQuestion(T2));
+ isNotBottom(typeParameterTypeStar(T2));
+ }
+
+ test_isMoreBottom() {
+ // MOREBOTTOM(Never, T) = true
+ isMoreBottom(neverNone, neverNone);
+ isMoreBottom(neverNone, neverQuestion);
+ isMoreBottom(neverNone, neverStar);
+
+ isMoreBottom(neverNone, nullNone);
+ isMoreBottom(neverNone, nullQuestion);
+ isMoreBottom(neverNone, nullStar);
+
+ // MOREBOTTOM(T, Never) = false
+ isNotMoreBottom(neverQuestion, neverNone);
+ isNotMoreBottom(neverStar, neverNone);
+
+ isNotMoreBottom(nullNone, neverNone);
+ isNotMoreBottom(nullQuestion, neverNone);
+ isNotMoreBottom(nullStar, neverNone);
+
+ // MOREBOTTOM(Null, T) = true
+ isMoreBottom(nullNone, neverQuestion);
+ isMoreBottom(nullNone, neverStar);
+
+ isMoreBottom(nullNone, nullNone);
+ isMoreBottom(nullNone, nullQuestion);
+ isMoreBottom(nullNone, nullStar);
+
+ // MOREBOTTOM(T, Null) = false
+ isNotMoreBottom(neverQuestion, nullNone);
+ isNotMoreBottom(neverStar, nullNone);
+
+ isNotMoreBottom(nullQuestion, nullNone);
+ isNotMoreBottom(nullStar, nullNone);
+
+ // MOREBOTTOM(T?, S?) = MOREBOTTOM(T, S)
+ isMoreBottom(neverQuestion, nullQuestion);
+ isNotMoreBottom(nullQuestion, neverQuestion);
+
+ // MOREBOTTOM(T, S?) = true
+ isMoreBottom(neverStar, nullQuestion);
+ isMoreBottom(nullStar, neverQuestion);
+
+ // MOREBOTTOM(T?, S) = false
+ isNotMoreBottom(neverQuestion, nullStar);
+ isNotMoreBottom(nullQuestion, neverStar);
+
+ // MOREBOTTOM(T*, S*) = MOREBOTTOM(T, S)
+ isMoreBottom(neverStar, nullStar);
+ isNotMoreBottom(nullStar, neverStar);
+
+ // MOREBOTTOM(T, S*) = true
+ isMoreBottom(
+ typeParameterTypeNone(
+ typeParameter('S', bound: neverNone),
+ ),
+ nullStar,
+ );
+
+ // MOREBOTTOM(T*, S) = false
+ isNotMoreBottom(
+ nullStar,
+ typeParameterTypeNone(
+ typeParameter('S', bound: neverNone),
+ ),
+ );
+
+ // MOREBOTTOM(X&T, Y&S) = MOREBOTTOM(T, S)
+ isMoreBottom(
+ typeParameterTypeNone(
+ promoteTypeParameter(
+ typeParameter('T', bound: objectQuestion),
+ neverNone,
+ ),
+ ),
+ typeParameterTypeQuestion(
+ promoteTypeParameter(
+ typeParameter('S', bound: objectQuestion),
+ neverNone,
+ ),
+ ),
+ );
+
+ // MOREBOTTOM(X&T, S) = true
+ isMoreBottom(
+ typeParameterTypeNone(
+ promoteTypeParameter(
+ typeParameter('T', bound: objectQuestion),
+ neverNone,
+ ),
+ ),
+ typeParameterTypeNone(
+ typeParameter('S', bound: neverNone),
+ ),
+ );
+
+ // MOREBOTTOM(T, X&S) = false
+ isNotMoreBottom(
+ typeParameterTypeNone(
+ typeParameter('T', bound: neverNone),
+ ),
+ typeParameterTypeNone(
+ promoteTypeParameter(
+ typeParameter('S', bound: objectQuestion),
+ neverNone,
+ ),
+ ),
+ );
+
+ // MOREBOTTOM(X extends T, Y extends S) = MOREBOTTOM(T, S)
+ isMoreBottom(
+ typeParameterTypeNone(
+ typeParameter('T', bound: neverNone),
+ ),
+ typeParameterTypeQuestion(
+ typeParameter('S', bound: neverNone),
+ ),
+ );
+ }
+
+ test_isMoreTop() {
+ // MORETOP(void, T) = true
+ isMoreTop(voidNone, voidNone);
+ isMoreTop(voidNone, dynamicNone);
+ isMoreTop(voidNone, objectNone);
+ isMoreTop(voidNone, objectQuestion);
+ isMoreTop(voidNone, objectStar);
+ isMoreTop(voidNone, futureOrNone(objectNone));
+ isMoreTop(voidNone, futureOrNone(objectQuestion));
+ isMoreTop(voidNone, futureOrNone(objectStar));
+
+ // MORETOP(T, void) = false
+ isNotMoreTop(dynamicNone, voidNone);
+ isNotMoreTop(objectNone, voidNone);
+ isNotMoreTop(objectQuestion, voidNone);
+ isNotMoreTop(objectStar, voidNone);
+ isNotMoreTop(futureOrNone(objectNone), voidNone);
+ isNotMoreTop(futureOrNone(objectQuestion), voidNone);
+ isNotMoreTop(futureOrNone(objectStar), voidNone);
+
+ // MORETOP(dynamic, T) = true
+ isMoreTop(dynamicNone, dynamicNone);
+ isMoreTop(dynamicNone, objectNone);
+ isMoreTop(dynamicNone, objectQuestion);
+ isMoreTop(dynamicNone, objectStar);
+ isMoreTop(dynamicNone, futureOrNone(objectNone));
+ isMoreTop(dynamicNone, futureOrNone(objectQuestion));
+ isMoreTop(dynamicNone, futureOrNone(objectStar));
+
+ // MORETOP(T, dynamic) = false
+ isNotMoreTop(objectNone, dynamicNone);
+ isNotMoreTop(objectQuestion, dynamicNone);
+ isNotMoreTop(objectStar, dynamicNone);
+ isNotMoreTop(futureOrNone(objectNone), dynamicNone);
+ isNotMoreTop(futureOrNone(objectQuestion), dynamicNone);
+ isNotMoreTop(futureOrNone(objectStar), dynamicNone);
+
+ // MORETOP(Object, T) = true
+ isMoreTop(objectNone, objectNone);
+ isMoreTop(objectNone, objectQuestion);
+ isMoreTop(objectNone, objectStar);
+ isMoreTop(objectNone, futureOrNone(objectNone));
+ isMoreTop(objectNone, futureOrQuestion(objectNone));
+ isMoreTop(objectNone, futureOrStar(objectNone));
+
+ // MORETOP(T, Object) = false
+ isNotMoreTop(objectQuestion, objectNone);
+ isNotMoreTop(objectStar, objectNone);
+ isNotMoreTop(futureOrNone(objectNone), objectNone);
+ isNotMoreTop(futureOrQuestion(objectNone), objectNone);
+ isNotMoreTop(futureOrStar(objectNone), objectNone);
+
+ // MORETOP(T*, S*) = MORETOP(T, S)
+ isMoreTop(objectStar, objectStar);
+ isMoreTop(objectStar, futureOrStar(objectNone));
+ isMoreTop(objectStar, futureOrStar(objectQuestion));
+ isMoreTop(objectStar, futureOrStar(objectStar));
+ isMoreTop(futureOrStar(objectNone), futureOrStar(objectNone));
+
+ // MORETOP(T, S*) = true
+ isMoreTop(futureOrNone(objectNone), futureOrStar(voidNone));
+ isMoreTop(futureOrNone(objectNone), futureOrStar(dynamicNone));
+ isMoreTop(futureOrNone(objectNone), futureOrStar(objectNone));
+ isMoreTop(futureOrQuestion(objectNone), futureOrStar(voidNone));
+ isMoreTop(futureOrQuestion(objectNone), futureOrStar(dynamicNone));
+ isMoreTop(futureOrQuestion(objectNone), futureOrStar(objectNone));
+
+ // MORETOP(T*, S) = false
+ isNotMoreTop(futureOrStar(voidNone), futureOrNone(objectNone));
+ isNotMoreTop(futureOrStar(dynamicNone), futureOrNone(objectNone));
+ isNotMoreTop(futureOrStar(objectNone), futureOrNone(objectNone));
+ isNotMoreTop(futureOrStar(voidNone), futureOrQuestion(objectNone));
+ isNotMoreTop(futureOrStar(dynamicNone), futureOrQuestion(objectNone));
+ isNotMoreTop(futureOrStar(objectNone), futureOrQuestion(objectNone));
+
+ // MORETOP(T?, S?) = MORETOP(T, S)
+ isMoreTop(objectQuestion, objectQuestion);
+ isMoreTop(futureOrQuestion(voidNone), futureOrQuestion(voidNone));
+ isMoreTop(futureOrQuestion(voidNone), futureOrQuestion(dynamicNone));
+ isMoreTop(futureOrQuestion(voidNone), futureOrQuestion(objectNone));
+
+ // MORETOP(T, S?) = true
+ isMoreTop(futureOrNone(objectNone), futureOrQuestion(voidNone));
+ isMoreTop(futureOrNone(objectNone), futureOrQuestion(dynamicNone));
+ isMoreTop(futureOrNone(objectNone), futureOrQuestion(objectNone));
+
+ // MORETOP(T?, S) = false
+ isNotMoreTop(futureOrQuestion(voidNone), futureOrNone(objectNone));
+ isNotMoreTop(futureOrQuestion(dynamicNone), futureOrNone(objectNone));
+ isNotMoreTop(futureOrQuestion(objectNone), futureOrNone(objectNone));
+
+ // MORETOP(FutureOr<T>, FutureOr<S>) = MORETOP(T, S)
+ isMoreTop(futureOrNone(voidNone), futureOrNone(voidNone));
+ isMoreTop(futureOrNone(voidNone), futureOrNone(dynamicNone));
+ isMoreTop(futureOrNone(voidNone), futureOrNone(objectNone));
+ isNotMoreTop(futureOrNone(dynamicNone), futureOrNone(voidNone));
+ isNotMoreTop(futureOrNone(objectNone), futureOrNone(voidNone));
+ }
+
+ test_isNull() {
+ // NULL(Null) is true
+ isNull(nullNone);
+
+ // NULL(T?) is true iff NULL(T) or BOTTOM(T)
+ isNull(nullQuestion);
+ isNull(neverQuestion);
+ isNull(
+ typeParameterTypeQuestion(
+ typeParameter('T', bound: neverNone),
+ ),
+ );
+
+ // NULL(T*) is true iff NULL(T) or BOTTOM(T)
+ isNull(nullStar);
+ isNull(neverStar);
+ isNull(
+ typeParameterTypeStar(
+ typeParameter('T', bound: neverNone),
+ ),
+ );
+
+ // NULL(T) is false otherwise
+ isNotNull(dynamicNone);
+ isNotNull(voidNone);
+
+ isNotNull(objectNone);
+ isNotNull(objectQuestion);
+ isNotNull(objectStar);
+
+ isNotNull(intNone);
+ isNotNull(intQuestion);
+ isNotNull(intStar);
+
+ isNotNull(futureOrNone(nullNone));
+ isNotNull(futureOrNone(nullQuestion));
+ isNotNull(futureOrNone(nullStar));
+
+ isNotNull(futureOrQuestion(nullNone));
+ isNotNull(futureOrQuestion(nullQuestion));
+ isNotNull(futureOrQuestion(nullStar));
+
+ isNotNull(futureOrStar(nullNone));
+ isNotNull(futureOrStar(nullQuestion));
+ isNotNull(futureOrStar(nullStar));
+ }
+
+ test_isObject() {
+ // OBJECT(Object) is true
+ isObject(objectNone);
+ isNotObject(objectQuestion);
+ isNotObject(objectStar);
+
+ // OBJECT(FutureOr<T>) is OBJECT(T)
+ isObject(futureOrNone(objectNone));
+ isNotObject(futureOrNone(objectQuestion));
+ isNotObject(futureOrNone(objectStar));
+
+ isNotObject(futureOrQuestion(objectNone));
+ isNotObject(futureOrQuestion(objectQuestion));
+ isNotObject(futureOrQuestion(objectStar));
+
+ isNotObject(futureOrStar(objectNone));
+ isNotObject(futureOrStar(objectQuestion));
+ isNotObject(futureOrStar(objectStar));
+
+ // OBJECT(T) is false otherwise
+ isNotObject(dynamicNone);
+ isNotObject(voidNone);
+ isNotObject(intNone);
+ }
+
+ test_isTop() {
+ // TOP(T?) is true iff TOP(T) or OBJECT(T)
+ isTop(objectQuestion);
+ isTop(futureOrQuestion(dynamicNone));
+ isTop(futureOrQuestion(voidNone));
+
+ isTop(futureOrQuestion(objectNone));
+ isTop(futureOrQuestion(objectQuestion));
+ isTop(futureOrQuestion(objectStar));
+
+ isNotTop(futureOrQuestion(intNone));
+ isNotTop(futureOrQuestion(intQuestion));
+ isNotTop(futureOrQuestion(intStar));
+
+ // TOP(T*) is true iff TOP(T) or OBJECT(T)
+ isTop(objectStar);
+ isTop(futureOrStar(dynamicNone));
+ isTop(futureOrStar(voidNone));
+
+ isTop(futureOrStar(objectNone));
+ isTop(futureOrStar(objectQuestion));
+ isTop(futureOrStar(objectStar));
+
+ isNotTop(futureOrStar(intNone));
+ isNotTop(futureOrStar(intQuestion));
+ isNotTop(futureOrStar(intStar));
+
+ // TOP(dynamic) is true
+ isTop(dynamicNone);
+
+ // TOP(void) is true
+ isTop(voidNone);
+
+ // TOP(FutureOr<T>) is TOP(T)
+ isTop(futureOrNone(dynamicNone));
+ isTop(futureOrNone(voidNone));
+
+ isNotTop(futureOrNone(objectNone));
+ isTop(futureOrNone(objectQuestion));
+ isTop(futureOrNone(objectStar));
+
+ // TOP(T) is false otherwise
+ isNotTop(objectNone);
+
+ isNotTop(intNone);
+ isNotTop(intQuestion);
+ isNotTop(intStar);
+
+ isNotTop(neverNone);
+ isNotTop(neverQuestion);
+ isNotTop(neverStar);
+ }
+
+ /// [TypeSystemImpl.isMoreBottom] can be used only for `BOTTOM` or `NULL`
+ /// types. No need to check other types.
+ void _assertIsBottomOrNull(DartType type) {
+ expect(typeSystem.isBottom(type) || typeSystem.isNull(type), isTrue,
+ reason: _typeString(type));
+ }
+
+ /// [TypeSystemImpl.isMoreTop] can be used only for `TOP` or `OBJECT`
+ /// types. No need to check other types.
+ void _assertIsTopOrObject(DartType type) {
+ expect(typeSystem.isTop(type) || typeSystem.isObject(type), isTrue,
+ reason: _typeString(type));
+ }
+
+ void _checkUniqueTypeStr(Map<String, StackTrace> map, String str) {
+ var previousStack = map[str];
+ if (previousStack != null) {
+ fail('Not unique: $str\n$previousStack');
+ } else {
+ map[str] = StackTrace.current;
+ }
+ }
+}
+
+@reflectiveTest
+class LowerBoundTest extends _BoundsTestBase {
+ test_bottom_any() {
+ void check(DartType T1, DartType T2) {
+ expect(typeSystem.isBottom(T1), isTrue, reason: _typeString(T1));
+ expect(typeSystem.isBottom(T2), isFalse, reason: _typeString(T2));
+ _checkGreatestLowerBound(T1, T2, T1);
+ }
+
+ check(neverNone, objectNone);
+ check(neverNone, objectStar);
+ check(neverNone, objectQuestion);
+
+ check(neverNone, intNone);
+ check(neverNone, intQuestion);
+ check(neverNone, intStar);
+
+ check(neverNone, listNone(intNone));
+ check(neverNone, listQuestion(intNone));
+ check(neverNone, listStar(intNone));
+
+ check(neverNone, futureOrNone(intNone));
+ check(neverNone, futureOrQuestion(intNone));
+ check(neverNone, futureOrStar(intNone));
+
+ {
+ var T = typeParameterTypeNone(
+ typeParameter('T', bound: neverNone),
+ );
+ check(T, intNone);
+ check(T, intQuestion);
+ check(T, intStar);
+ }
+
+ {
+ var T = typeParameterTypeNone(
+ promoteTypeParameter(
+ typeParameter('T', bound: objectQuestion),
+ neverNone,
+ ),
+ );
+ check(T, intNone);
+ check(T, intQuestion);
+ check(T, intStar);
+ }
+ }
+
+ test_bottom_bottom() {
+ void check(DartType T1, DartType T2) {
+ expect(typeSystem.isBottom(T1), isTrue, reason: _typeString(T1));
+ expect(typeSystem.isBottom(T2), isTrue, reason: _typeString(T2));
+ _checkGreatestLowerBound(T1, T2, T1);
+ }
+
+ check(
+ neverNone,
+ typeParameterTypeNone(
+ typeParameter('T', bound: neverNone),
+ ),
+ );
+
+ check(
+ neverNone,
+ typeParameterTypeNone(
+ promoteTypeParameter(
+ typeParameter('T', bound: objectQuestion),
+ neverNone,
+ ),
+ ),
+ );
+ }
+
+ test_functionType2_parameters_conflicts() {
+ _checkGreatestLowerBound(
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ requiredParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedParameter(name: 'a', type: intNone),
+ ],
+ ),
+ neverNone,
+ );
+
+ _checkGreatestLowerBound(
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ positionalParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedParameter(name: 'a', type: intNone),
+ ],
+ ),
+ neverNone,
+ );
+ }
+
+ test_functionType2_parameters_named() {
+ FunctionType build(
+ List<DartType> requiredTypes,
+ Map<String, DartType> namedMap,
+ Map<String, DartType> namedRequiredMap,
+ ) {
+ var parameters = <ParameterElement>[];
+
+ for (var requiredType in requiredTypes) {
+ parameters.add(
+ requiredParameter(type: requiredType),
+ );
+ }
+
+ for (var entry in namedMap.entries) {
+ parameters.add(
+ namedParameter(name: entry.key, type: entry.value),
+ );
+ }
+
+ for (var entry in namedRequiredMap.entries) {
+ parameters.add(
+ namedRequiredParameter(name: entry.key, type: entry.value),
+ );
+ }
+
+ return functionTypeNone(
+ returnType: voidNone,
+ parameters: parameters,
+ );
+ }
+
+ void check(FunctionType T1, FunctionType T2, DartType expected) {
+ _checkGreatestLowerBound(T1, T2, expected);
+ }
+
+ check(
+ build([], {}, {}),
+ build([], {}, {}),
+ build([], {}, {}),
+ );
+
+ {
+ check(
+ build([], {'a': intNone}, {}),
+ build([], {'a': intNone}, {}),
+ build([], {'a': intNone}, {}),
+ );
+
+ check(
+ build([], {'a': intNone}, {}),
+ build([], {}, {'a': intNone}),
+ build([], {'a': intNone}, {}),
+ );
+
+ check(
+ build([], {}, {'a': intNone}),
+ build([], {}, {'a': intNone}),
+ build([], {}, {'a': intNone}),
+ );
+ }
+
+ {
+ check(
+ build([], {'a': intNone, 'b': intNone}, {}),
+ build([], {'a': intNone, 'c': intNone}, {}),
+ build([], {'a': intNone, 'b': intNone, 'c': intNone}, {}),
+ );
+
+ check(
+ build([], {'a': intNone}, {'b': intNone}),
+ build([], {'a': intNone}, {'c': intNone}),
+ build([], {'a': intNone, 'b': intNone, 'c': intNone}, {}),
+ );
+ }
+
+ {
+ check(
+ build([], {'a': intNone}, {}),
+ build([], {'a': numNone}, {}),
+ build([], {'a': numNone}, {}),
+ );
+
+ check(
+ build([], {'a': intNone}, {}),
+ build([], {'a': doubleNone}, {}),
+ build([], {'a': numNone}, {}),
+ );
+
+ check(
+ build([], {'a': intNone}, {}),
+ build([], {'a': doubleQuestion}, {}),
+ build([], {'a': numQuestion}, {}),
+ );
+
+ check(
+ build([], {'a': intNone}, {}),
+ build([], {'a': doubleStar}, {}),
+ build([], {'a': numStar}, {}),
+ );
+ }
+ }
+
+ test_functionType2_parameters_positional() {
+ FunctionType build(
+ List<DartType> requiredTypes,
+ List<DartType> positionalTypes,
+ ) {
+ var parameters = <ParameterElement>[];
+
+ for (var requiredType in requiredTypes) {
+ parameters.add(
+ requiredParameter(type: requiredType),
+ );
+ }
+
+ for (var positionalType in positionalTypes) {
+ parameters.add(
+ positionalParameter(type: positionalType),
+ );
+ }
+
+ return functionTypeNone(
+ returnType: voidNone,
+ parameters: parameters,
+ );
+ }
+
+ void check(FunctionType T1, FunctionType T2, DartType expected) {
+ _checkGreatestLowerBound(T1, T2, expected);
+ }
+
+ check(
+ build([], []),
+ build([], []),
+ build([], []),
+ );
+
+ check(
+ build([intNone], []),
+ build([intNone], []),
+ build([intNone], []),
+ );
+
+ check(
+ build([intNone], []),
+ build([numNone], []),
+ build([numNone], []),
+ );
+
+ check(
+ build([intNone], []),
+ build([doubleNone], []),
+ build([numNone], []),
+ );
+
+ check(
+ build([intNone], []),
+ build([doubleQuestion], []),
+ build([numQuestion], []),
+ );
+
+ check(
+ build([intNone], []),
+ build([doubleStar], []),
+ build([numStar], []),
+ );
+
+ {
+ check(
+ build([intNone], []),
+ build([], [intNone]),
+ build([], [intNone]),
+ );
+
+ check(
+ build([intNone], []),
+ build([], []),
+ build([], [intNone]),
+ );
+
+ check(
+ build([], [intNone]),
+ build([], [intNone]),
+ build([], [intNone]),
+ );
+
+ check(
+ build([], [intNone]),
+ build([], []),
+ build([], [intNone]),
+ );
+ }
+ }
+
+ test_functionType2_returnType() {
+ void check(DartType T1_ret, DartType T2_ret, DartType expected_ret) {
+ _checkGreatestLowerBound(
+ functionTypeNone(returnType: T1_ret),
+ functionTypeNone(returnType: T2_ret),
+ functionTypeNone(returnType: expected_ret),
+ );
+ }
+
+ check(intNone, intNone, intNone);
+ check(intNone, numNone, intNone);
+
+ check(intNone, voidNone, intNone);
+ check(intNone, neverNone, neverNone);
+ }
+
+ test_functionType2_typeParameters() {
+ void check(FunctionType T1, FunctionType T2, DartType expected) {
+ _assertNullabilityNone(T1);
+ _assertNullabilityNone(T2);
+
+ _checkGreatestLowerBound(T1, T2, expected, checkSubtype: false);
+ }
+
+ check(
+ functionTypeNone(
+ returnType: voidNone,
+ typeFormals: [
+ typeParameter('T'),
+ ],
+ ),
+ functionTypeNone(returnType: voidNone),
+ neverNone,
+ );
+
+ check(
+ functionTypeNone(
+ returnType: voidNone,
+ typeFormals: [
+ typeParameter('T', bound: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ typeFormals: [
+ typeParameter('T', bound: numNone),
+ ],
+ ),
+ neverNone,
+ );
+
+ {
+ var T = typeParameter('T', bound: numNone);
+ var U = typeParameter('U', bound: numNone);
+ var R = typeParameter('R', bound: numNone);
+ check(
+ functionTypeNone(
+ returnType: typeParameterTypeNone(T),
+ typeFormals: [T],
+ ),
+ functionTypeNone(
+ returnType: typeParameterTypeNone(U),
+ typeFormals: [U],
+ ),
+ functionTypeNone(
+ returnType: typeParameterTypeNone(R),
+ typeFormals: [R],
+ ),
+ );
+ }
+ }
+
+ test_functionType_interfaceType() {
+ void check(FunctionType T1, InterfaceType T2, DartType expected) {
+ _checkGreatestLowerBound(T1, T2, expected);
+ }
+
+ check(
+ functionTypeNone(returnType: voidNone),
+ intNone,
+ neverNone,
+ );
+ }
+
+ test_functionType_interfaceType_Function() {
+ void check(FunctionType T1) {
+ _assertNullabilityNone(T1);
+ _checkGreatestLowerBound(T1, functionNone, T1);
+ }
+
+ check(functionTypeNone(returnType: voidNone));
+
+ check(
+ functionTypeNone(
+ returnType: intNone,
+ parameters: [
+ requiredParameter(type: numQuestion),
+ ],
+ ),
+ );
+ }
+
+ test_identical() {
+ void check(DartType type) {
+ _checkGreatestLowerBound(type, type, type);
+ }
+
+ check(intNone);
+ check(intQuestion);
+ check(intStar);
+ check(listNone(intNone));
+ }
+
+ test_interfaceType2() {
+ void check(InterfaceType T1, InterfaceType T2, DartType expected) {
+ _assertNullabilityNone(T1);
+ _assertNullabilityNone(T2);
+
+ _checkGreatestLowerBound(T1, T2, expected);
+ }
+
+ check(numNone, intNone, intNone);
+ check(doubleNone, intNone, neverNone);
+ }
+
+ test_none_question() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ _assertNullabilityNone(T1);
+ _assertNullabilityQuestion(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkGreatestLowerBound(T1, T2, expected);
+ }
+
+ check(intNone, intQuestion, intNone);
+
+ check(numNone, intQuestion, intNone);
+ check(intNone, numQuestion, intNone);
+
+ check(doubleNone, intQuestion, neverNone);
+ check(intNone, doubleQuestion, neverNone);
+ }
+
+ test_none_star() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ _assertNullabilityNone(T1);
+ _assertNullabilityStar(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkGreatestLowerBound(T1, T2, expected);
+ }
+
+ check(intNone, intStar, intNone);
+
+ check(numNone, intStar, intNone);
+ check(intNone, numStar, intNone);
+
+ check(doubleNone, intStar, neverNone);
+ check(intNone, doubleStar, neverNone);
+ }
+
+ test_null_any() {
+ void check(DartType T2, DartType expected) {
+ var T2_str = _typeString(T2);
+
+ expect(typeSystem.isNull(T2), isFalse, reason: 'isNull: $T2_str');
+ expect(typeSystem.isTop(T2), isFalse, reason: 'isTop: $T2_str');
+ expect(typeSystem.isBottom(T2), isFalse, reason: 'isBottom: $T2_str');
+
+ _checkGreatestLowerBound(nullNone, T2, expected);
+ }
+
+ void checkNull(DartType T2) {
+ check(T2, nullNone);
+ }
+
+ void checkNever(DartType T2) {
+ check(T2, neverNone);
+ }
+
+ checkNull(futureOrNone(nullNone));
+ checkNull(futureOrNone(nullQuestion));
+ checkNull(futureOrNone(nullStar));
+
+ checkNull(futureOrQuestion(nullNone));
+ checkNull(futureOrQuestion(nullQuestion));
+ checkNull(futureOrQuestion(nullStar));
+
+ checkNull(futureOrStar(nullNone));
+ checkNull(futureOrStar(nullQuestion));
+ checkNull(futureOrStar(nullStar));
+
+ checkNever(objectNone);
+
+ checkNever(intNone);
+ checkNull(intQuestion);
+ checkNull(intStar);
+
+ checkNever(listNone(intNone));
+ checkNull(listQuestion(intNone));
+ checkNull(listStar(intNone));
+
+ checkNever(listNone(intQuestion));
+ checkNull(listQuestion(intQuestion));
+ checkNull(listStar(intQuestion));
+ }
+
+ test_null_null() {
+ void check(DartType T1, DartType T2) {
+ var T1_str = _typeString(T1);
+ var T2_str = _typeString(T2);
+
+ expect(typeSystem.isNull(T1), isTrue, reason: 'isNull: $T1_str');
+ expect(typeSystem.isNull(T2), isTrue, reason: 'isNull: $T2_str');
+
+ expect(typeSystem.isBottom(T1), isFalse, reason: 'isBottom: $T1_str');
+ expect(typeSystem.isBottom(T2), isFalse, reason: 'isBottom: $T2_str');
+
+ _checkGreatestLowerBound(T1, T2, T1);
+ }
+
+ check(nullNone, nullQuestion);
+ check(nullNone, nullStar);
+ }
+
+ test_object_any() {
+ void check(DartType T2, DartType expected) {
+ var T2_str = _typeString(T2);
+ expect(typeSystem.isObject(T2), isFalse, reason: 'isObject: $T2_str');
+
+ _checkGreatestLowerBound(objectNone, T2, expected);
+ }
+
+ void checkNever(DartType T2) {
+ check(T2, neverNone);
+ }
+
+ check(intNone, intNone);
+ check(intQuestion, intNone);
+ check(intStar, intStar);
+
+ check(futureOrNone(intNone), futureOrNone(intNone));
+ check(futureOrQuestion(intNone), futureOrNone(intNone));
+ check(futureOrNone(intNone), futureOrNone(intNone));
+
+ checkNever(futureOrNone(intQuestion));
+ checkNever(futureOrQuestion(intQuestion));
+ checkNever(futureOrNone(intQuestion));
+
+ {
+ var T = typeParameter('T', bound: objectNone);
+ check(typeParameterTypeNone(T), typeParameterTypeNone(T));
+ check(typeParameterTypeQuestion(T), typeParameterTypeNone(T));
+ check(typeParameterTypeStar(T), typeParameterTypeStar(T));
+ }
+
+ {
+ var T = typeParameter('T', bound: objectQuestion);
+ var T2 = promoteTypeParameter(T, objectNone);
+ check(typeParameterTypeNone(T), typeParameterTypeNone(T2));
+ check(typeParameterTypeQuestion(T), typeParameterTypeNone(T2));
+ check(typeParameterTypeStar(T), typeParameterTypeNone(T2));
+ }
+
+ {
+ var T = typeParameter('T', bound: futureOrNone(objectQuestion));
+ checkNever(typeParameterTypeNone(T));
+ checkNever(typeParameterTypeQuestion(T));
+ checkNever(typeParameterTypeStar(T));
+ }
+ }
+
+ test_object_object() {
+ void check(DartType T1, DartType T2) {
+ var T1_str = _typeString(T1);
+ var T2_str = _typeString(T2);
+
+ expect(typeSystem.isObject(T1), isTrue, reason: 'isObject: $T1_str');
+ expect(typeSystem.isObject(T2), isTrue, reason: 'isObject: $T2_str');
+
+ _checkGreatestLowerBound(T1, T2, T1);
+ }
+
+ check(futureOrNone(objectNone), objectNone);
+
+ check(
+ futureOrNone(
+ futureOrNone(objectNone),
+ ),
+ futureOrNone(objectNone),
+ );
+ }
+
+ test_question_question() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ _assertNullabilityQuestion(T1);
+ _assertNullabilityQuestion(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkGreatestLowerBound(T1, T2, expected);
+ }
+
+ check(intQuestion, intQuestion, intQuestion);
+
+ check(numQuestion, intQuestion, intQuestion);
+ check(intQuestion, numQuestion, intQuestion);
+
+ check(doubleQuestion, intQuestion, neverQuestion);
+ check(intQuestion, doubleQuestion, neverQuestion);
+ }
+
+ test_star_question() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ _assertNullabilityQuestion(T1);
+ _assertNullabilityStar(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkGreatestLowerBound(T1, T2, expected);
+ }
+
+ check(intQuestion, intStar, intStar);
+
+ check(numQuestion, intStar, intStar);
+ check(intQuestion, numStar, intStar);
+
+ check(doubleQuestion, intStar, neverStar);
+ check(intQuestion, doubleStar, neverStar);
+ }
+
+ test_star_star() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ _assertNullabilityStar(T1);
+ _assertNullabilityStar(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkGreatestLowerBound(T1, T2, expected);
+ }
+
+ check(intStar, numStar, intStar);
+ check(intStar, doubleStar, neverStar);
+ }
+
+ test_top_any() {
+ void check(DartType T1, DartType T2) {
+ expect(typeSystem.isTop(T1), isTrue, reason: _typeString(T1));
+ expect(typeSystem.isTop(T2), isFalse, reason: _typeString(T2));
+ _checkGreatestLowerBound(T1, T2, T2);
+ }
+
+ check(voidNone, objectNone);
+ check(voidNone, intNone);
+ check(voidNone, intQuestion);
+ check(voidNone, intStar);
+ check(voidNone, listNone(intNone));
+ check(voidNone, futureOrNone(intNone));
+
+ check(dynamicNone, objectNone);
+ check(dynamicNone, intNone);
+ check(dynamicNone, intQuestion);
+ check(dynamicNone, intStar);
+ check(dynamicNone, listNone(intNone));
+ check(dynamicNone, futureOrNone(intNone));
+
+ check(objectQuestion, objectNone);
+ check(objectQuestion, intNone);
+ check(objectQuestion, intQuestion);
+ check(objectQuestion, intStar);
+ check(objectQuestion, listNone(intNone));
+ check(objectQuestion, futureOrNone(intNone));
+
+ check(objectStar, objectNone);
+ check(objectStar, intNone);
+ check(objectStar, intQuestion);
+ check(objectStar, intStar);
+ check(objectStar, listNone(intNone));
+ check(objectStar, futureOrNone(intNone));
+
+ check(futureOrNone(voidNone), intNone);
+ check(futureOrQuestion(voidNone), intNone);
+ check(futureOrStar(voidNone), intNone);
+ }
+
+ test_top_top() {
+ void check(DartType T1, DartType T2) {
+ expect(typeSystem.isTop(T1), isTrue, reason: _typeString(T1));
+ expect(typeSystem.isTop(T2), isTrue, reason: _typeString(T2));
+ _checkGreatestLowerBound(T1, T2, T2);
+ }
+
+ check(voidNone, dynamicNone);
+ check(voidNone, objectStar);
+ check(voidNone, objectQuestion);
+ check(voidNone, futureOrNone(voidNone));
+ check(voidNone, futureOrNone(dynamicNone));
+ check(voidNone, futureOrNone(objectQuestion));
+ check(voidNone, futureOrNone(objectStar));
+
+ check(dynamicNone, objectStar);
+ check(dynamicNone, objectQuestion);
+ check(dynamicNone, futureOrNone(voidNone));
+ check(dynamicNone, futureOrNone(dynamicNone));
+ check(dynamicNone, futureOrNone(objectQuestion));
+ check(dynamicNone, futureOrNone(objectStar));
+ check(
+ dynamicNone,
+ futureOrStar(objectStar),
+ );
+
+ check(objectQuestion, futureOrQuestion(voidNone));
+ check(objectQuestion, futureOrQuestion(dynamicNone));
+ check(objectQuestion, futureOrQuestion(objectNone));
+ check(objectQuestion, futureOrQuestion(objectQuestion));
+ check(objectQuestion, futureOrQuestion(objectStar));
+
+ check(objectQuestion, futureOrStar(voidNone));
+ check(objectQuestion, futureOrStar(dynamicNone));
+ check(objectQuestion, futureOrStar(objectNone));
+ check(objectQuestion, futureOrStar(objectQuestion));
+ check(objectQuestion, futureOrStar(objectStar));
+
+ check(objectStar, futureOrStar(voidNone));
+ check(objectStar, futureOrStar(dynamicNone));
+ check(objectStar, futureOrStar(objectNone));
+ check(objectStar, futureOrStar(objectQuestion));
+ check(objectStar, futureOrStar(objectStar));
+
+ check(futureOrNone(voidNone), objectQuestion);
+ check(futureOrNone(dynamicNone), objectQuestion);
+ check(futureOrNone(objectQuestion), objectQuestion);
+ check(futureOrNone(objectStar), objectQuestion);
+
+ check(futureOrNone(voidNone), futureOrNone(dynamicNone));
+ check(futureOrNone(voidNone), futureOrNone(objectQuestion));
+ check(futureOrNone(voidNone), futureOrNone(objectStar));
+ check(futureOrNone(dynamicNone), futureOrNone(objectQuestion));
+ check(futureOrNone(dynamicNone), futureOrNone(objectStar));
+ }
+
+ void _checkGreatestLowerBound(DartType T1, DartType T2, DartType expected,
+ {bool checkSubtype = true}) {
+ var expectedStr = _typeString(expected);
+
+ var result = typeSystem.getGreatestLowerBound(T1, T2);
+ var resultStr = _typeString(result);
+ expect(result, expected, reason: '''
+expected: $expectedStr
+actual: $resultStr
+''');
+
+ // Check that the result is a lower bound.
+ if (checkSubtype) {
+ expect(typeSystem.isSubtypeOf(result, T1), true);
+ expect(typeSystem.isSubtypeOf(result, T2), true);
+ }
+
+ // Check for symmetry.
+ result = typeSystem.getGreatestLowerBound(T2, T1);
+ resultStr = _typeString(result);
+ expect(result, expected, reason: '''
+expected: $expectedStr
+actual: $resultStr
+''');
+ }
+}
+
+@reflectiveTest
+class UpperBoundTest extends _BoundsTestBase {
+ test_bottom_any() {
+ void check(DartType T1, DartType T2) {
+ expect(typeSystem.isBottom(T1), isTrue, reason: _typeString(T1));
+ expect(typeSystem.isBottom(T2), isFalse, reason: _typeString(T2));
+ _checkLeastUpperBound(T1, T2, T2);
+ }
+
+ check(neverNone, objectNone);
+ check(neverNone, objectStar);
+ check(neverNone, objectQuestion);
+
+ check(neverNone, intNone);
+ check(neverNone, intQuestion);
+ check(neverNone, intStar);
+
+ check(neverNone, listNone(intNone));
+ check(neverNone, listQuestion(intNone));
+ check(neverNone, listStar(intNone));
+
+ check(neverNone, futureOrNone(intNone));
+ check(neverNone, futureOrQuestion(intNone));
+ check(neverNone, futureOrStar(intNone));
+
+ {
+ var T = typeParameterTypeNone(
+ typeParameter('T', bound: neverNone),
+ );
+ check(T, intNone);
+ check(T, intQuestion);
+ check(T, intStar);
+ }
+
+ {
+ var T = typeParameterTypeNone(
+ promoteTypeParameter(
+ typeParameter('T', bound: objectQuestion),
+ neverNone,
+ ),
+ );
+ check(T, intNone);
+ check(T, intQuestion);
+ check(T, intStar);
+ }
+ }
+
+ test_bottom_bottom() {
+ void check(DartType T1, DartType T2) {
+ expect(typeSystem.isBottom(T1), isTrue, reason: _typeString(T1));
+ expect(typeSystem.isBottom(T2), isTrue, reason: _typeString(T2));
+ _checkLeastUpperBound(T1, T2, T2);
+ }
+
+ check(
+ neverNone,
+ typeParameterTypeNone(
+ typeParameter('T', bound: neverNone),
+ ),
+ );
+
+ check(
+ neverNone,
+ typeParameterTypeNone(
+ promoteTypeParameter(
+ typeParameter('T', bound: objectQuestion),
+ neverNone,
+ ),
+ ),
+ );
+ }
+
+ test_functionType2_parameters_optionalNamed() {
+ FunctionType build(Map<String, DartType> namedTypes) {
+ return functionTypeNone(
+ returnType: voidNone,
+ parameters: namedTypes.entries.map((entry) {
+ return namedParameter(name: entry.key, type: entry.value);
+ }).toList(),
+ );
+ }
+
+ void check(Map<String, DartType> T1_named, Map<String, DartType> T2_named,
+ Map<String, DartType> expected_named) {
+ var T1 = build(T1_named);
+ var T2 = build(T2_named);
+ var expected = build(expected_named);
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check({'a': intNone}, {}, {});
+ check({'a': intNone}, {'b': intNone}, {});
+
+ check({'a': intNone}, {'a': intNone}, {'a': intNone});
+ check({'a': intNone}, {'a': intQuestion}, {'a': intNone});
+
+ check({'a': intNone, 'b': doubleNone}, {'a': intNone}, {'a': intNone});
+ }
+
+ test_functionType2_parameters_optionalPositional() {
+ FunctionType build(List<DartType> positionalTypes) {
+ return functionTypeNone(
+ returnType: voidNone,
+ parameters: positionalTypes.map((type) {
+ return positionalParameter(type: type);
+ }).toList(),
+ );
+ }
+
+ void check(List<DartType> T1_positional, List<DartType> T2_positional,
+ DartType expected) {
+ var T1 = build(T1_positional);
+ var T2 = build(T2_positional);
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check([intNone], [], build([]));
+ check([intNone, doubleNone], [intNone], build([intNone]));
+
+ check([intNone], [intNone], build([intNone]));
+ check([intNone], [intQuestion], build([intNone]));
+
+ check([intNone], [intStar], build([intNone]));
+ check([intNone], [doubleNone], build([neverNone]));
+
+ check([intNone], [numNone], build([intNone]));
+
+ check(
+ [doubleNone, numNone],
+ [numNone, intNone],
+ build([doubleNone, intNone]),
+ );
+ }
+
+ test_functionType2_parameters_requiredNamed() {
+ _checkLeastUpperBound(
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ requiredParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionNone,
+ );
+
+ _checkLeastUpperBound(
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ positionalParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionNone,
+ );
+
+ _checkLeastUpperBound(
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedParameter(name: 'b', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionNone,
+ );
+
+ _checkLeastUpperBound(
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'a', type: intNone),
+ ],
+ ),
+ );
+
+ _checkLeastUpperBound(
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedParameter(name: 'a', type: intNone),
+ namedRequiredParameter(name: 'b', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'b', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'b', type: intNone),
+ ],
+ ),
+ );
+
+ _checkLeastUpperBound(
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'a', type: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'a', type: numNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ parameters: [
+ namedRequiredParameter(name: 'a', type: intNone),
+ ],
+ ),
+ );
+ }
+
+ test_functionType2_parameters_requiredPositional() {
+ FunctionType build(List<DartType> requiredTypes) {
+ return functionTypeNone(
+ returnType: voidNone,
+ parameters: requiredTypes.map((type) {
+ return requiredParameter(type: type);
+ }).toList(),
+ );
+ }
+
+ void check(List<DartType> T1_required, List<DartType> T2_required,
+ DartType expected) {
+ var T1 = build(T1_required);
+ var T2 = build(T2_required);
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check([intNone], [], functionNone);
+
+ check([intNone], [intNone], build([intNone]));
+ check([intNone], [intQuestion], build([intNone]));
+
+ check([intNone], [intStar], build([intNone]));
+ check([intNone], [doubleNone], build([neverNone]));
+
+ check([intNone], [numNone], build([intNone]));
+
+ check(
+ [doubleNone, numNone],
+ [numNone, intNone],
+ build([doubleNone, intNone]),
+ );
+ }
+
+ test_functionType2_returnType() {
+ void check(DartType T1_ret, DartType T2_ret, DartType expected_ret) {
+ _checkLeastUpperBound(
+ functionTypeNone(returnType: T1_ret),
+ functionTypeNone(returnType: T2_ret),
+ functionTypeNone(returnType: expected_ret),
+ );
+ }
+
+ check(intNone, intNone, intNone);
+ check(intNone, intQuestion, intQuestion);
+ check(intNone, intStar, intStar);
+
+ check(intNone, numNone, numNone);
+ check(intQuestion, numNone, numQuestion);
+ check(intStar, numNone, numStar);
+
+ check(intNone, dynamicNone, dynamicNone);
+ check(intNone, neverNone, intNone);
+ }
+
+ test_functionType2_typeParameters() {
+ void check(FunctionType T1, FunctionType T2, DartType expected) {
+ _assertNullabilityNone(T1);
+ _assertNullabilityNone(T2);
+
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check(
+ functionTypeNone(
+ returnType: voidNone,
+ typeFormals: [
+ typeParameter('T'),
+ ],
+ ),
+ functionTypeNone(returnType: voidNone),
+ functionNone,
+ );
+
+ check(
+ functionTypeNone(
+ returnType: voidNone,
+ typeFormals: [
+ typeParameter('T', bound: intNone),
+ ],
+ ),
+ functionTypeNone(
+ returnType: voidNone,
+ typeFormals: [
+ typeParameter('T', bound: numNone),
+ ],
+ ),
+ functionNone,
+ );
+
+ {
+ var T = typeParameter('T', bound: numNone);
+ var U = typeParameter('U', bound: numNone);
+ var R = typeParameter('R', bound: numNone);
+ check(
+ functionTypeNone(
+ returnType: typeParameterTypeNone(T),
+ typeFormals: [T],
+ ),
+ functionTypeNone(
+ returnType: typeParameterTypeNone(U),
+ typeFormals: [U],
+ ),
+ functionTypeNone(
+ returnType: typeParameterTypeNone(R),
+ typeFormals: [R],
+ ),
+ );
+ }
+ }
+
+ test_functionType_interfaceType() {
+ void check(FunctionType T1, InterfaceType T2, InterfaceType expected) {
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check(
+ functionTypeNone(returnType: voidNone),
+ intNone,
+ objectNone,
+ );
+ }
+
+ test_functionType_interfaceType_Function() {
+ void check(FunctionType T1, InterfaceType T2, InterfaceType expected) {
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ void checkNone(FunctionType T1) {
+ _assertNullabilityNone(T1);
+ check(T1, functionNone, functionNone);
+ }
+
+ checkNone(functionTypeNone(returnType: voidNone));
+
+ checkNone(
+ functionTypeNone(
+ returnType: intNone,
+ parameters: [
+ requiredParameter(type: numQuestion),
+ ],
+ ),
+ );
+
+ check(
+ functionTypeQuestion(returnType: voidNone),
+ functionNone,
+ functionQuestion,
+ );
+ }
+
+ test_identical() {
+ void check(DartType type) {
+ _checkLeastUpperBound(type, type, type);
+ }
+
+ check(intNone);
+ check(intQuestion);
+ check(intStar);
+ check(listNone(intNone));
+ }
+
+ test_none_question() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ _assertNullabilityNone(T1);
+ _assertNullabilityQuestion(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check(doubleNone, intQuestion, numQuestion);
+ check(numNone, doubleQuestion, numQuestion);
+ check(numNone, intQuestion, numQuestion);
+ }
+
+ test_none_star() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ _assertNullabilityNone(T1);
+ _assertNullabilityStar(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check(doubleNone, intStar, numStar);
+ check(numNone, doubleStar, numStar);
+ check(numNone, intStar, numStar);
+ }
+
+ test_null_any() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ var T1_str = _typeString(T1);
+ var T2_str = _typeString(T2);
+
+ expect(typeSystem.isNull(T1), isTrue, reason: 'isNull: $T1_str');
+ expect(typeSystem.isNull(T2), isFalse, reason: 'isNull: $T2_str');
+
+ expect(typeSystem.isTop(T1), isFalse, reason: 'isTop: $T1_str');
+ expect(typeSystem.isTop(T2), isFalse, reason: 'isTop: $T2_str');
+
+ expect(typeSystem.isBottom(T1), isFalse, reason: 'isBottom: $T1_str');
+ expect(typeSystem.isBottom(T2), isFalse, reason: 'isBottom: $T2_str');
+
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check(nullNone, objectNone, objectQuestion);
+
+ check(nullNone, intNone, intQuestion);
+ check(nullNone, intQuestion, intQuestion);
+ check(nullNone, intStar, intStar);
+
+ check(nullQuestion, intNone, intQuestion);
+ check(nullQuestion, intQuestion, intQuestion);
+ check(nullQuestion, intStar, intStar);
+
+ check(nullStar, intNone, intStar);
+ check(nullStar, intQuestion, intQuestion);
+ check(nullStar, intStar, intStar);
+
+ check(nullNone, listNone(intNone), listQuestion(intNone));
+ check(nullNone, listQuestion(intNone), listQuestion(intNone));
+ check(nullNone, listStar(intNone), listStar(intNone));
+
+ check(nullNone, futureOrNone(intNone), futureOrQuestion(intNone));
+ check(nullNone, futureOrQuestion(intNone), futureOrQuestion(intNone));
+ check(nullNone, futureOrStar(intNone), futureOrStar(intNone));
+
+ check(nullNone, futureOrNone(intQuestion), futureOrNone(intQuestion));
+ check(nullNone, futureOrStar(intQuestion), futureOrStar(intQuestion));
+
+ check(
+ nullNone,
+ functionTypeNone(returnType: intNone),
+ functionTypeQuestion(returnType: intNone),
+ );
+ }
+
+ test_null_null() {
+ void check(DartType T1, DartType T2) {
+ var T1_str = _typeString(T1);
+ var T2_str = _typeString(T2);
+
+ expect(typeSystem.isNull(T1), isTrue, reason: 'isNull: $T1_str');
+ expect(typeSystem.isNull(T2), isTrue, reason: 'isNull: $T2_str');
+
+ expect(typeSystem.isBottom(T1), isFalse, reason: 'isBottom: $T1_str');
+ expect(typeSystem.isBottom(T2), isFalse, reason: 'isBottom: $T2_str');
+
+ _checkLeastUpperBound(T1, T2, T2);
+ }
+
+ check(nullNone, nullQuestion);
+ check(nullNone, nullStar);
+ }
+
+ test_object_any() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ var T1_str = _typeString(T1);
+ var T2_str = _typeString(T2);
+
+ expect(typeSystem.isObject(T1), isTrue, reason: 'isObject: $T1_str');
+ expect(typeSystem.isObject(T2), isFalse, reason: 'isObject: $T2_str');
+
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check(objectNone, intNone, objectNone);
+ check(objectNone, intQuestion, objectQuestion);
+ check(objectNone, intStar, objectNone);
+
+ check(objectNone, futureOrNone(intQuestion), objectQuestion);
+
+ check(futureOrNone(objectNone), intNone, futureOrNone(objectNone));
+ check(futureOrNone(objectNone), intQuestion, futureOrQuestion(objectNone));
+ check(futureOrNone(objectNone), intStar, futureOrNone(objectNone));
+ }
+
+ test_object_object() {
+ void check(DartType T1, DartType T2) {
+ var T1_str = _typeString(T1);
+ var T2_str = _typeString(T2);
+
+ expect(typeSystem.isObject(T1), isTrue, reason: 'isObject: $T1_str');
+ expect(typeSystem.isObject(T2), isTrue, reason: 'isObject: $T2_str');
+
+ _checkLeastUpperBound(T1, T2, T2);
+ }
+
+ check(futureOrNone(objectNone), objectNone);
+
+ check(
+ futureOrNone(
+ futureOrNone(objectNone),
+ ),
+ futureOrNone(objectNone),
+ );
+ }
+
+ test_question_question() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ _assertNullabilityQuestion(T1);
+ _assertNullabilityQuestion(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check(doubleQuestion, intQuestion, numQuestion);
+ check(numQuestion, doubleQuestion, numQuestion);
+ check(numQuestion, intQuestion, numQuestion);
+ }
+
+ test_question_star() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ _assertNullabilityQuestion(T1);
+ _assertNullabilityStar(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check(doubleQuestion, intStar, numQuestion);
+ check(numQuestion, doubleStar, numQuestion);
+ check(numQuestion, intStar, numQuestion);
+ }
+
+ test_star_star() {
+ void check(DartType T1, DartType T2, DartType expected) {
+ _assertNullabilityStar(T1);
+ _assertNullabilityStar(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ check(doubleStar, intStar, numStar);
+ check(numStar, doubleStar, numStar);
+ check(numStar, intStar, numStar);
+ }
+
+ test_top_any() {
+ void check(DartType T1, DartType T2) {
+ expect(typeSystem.isTop(T1), isTrue, reason: _typeString(T1));
+ expect(typeSystem.isTop(T2), isFalse, reason: _typeString(T2));
+ _checkLeastUpperBound(T1, T2, T1);
+ }
+
+ check(voidNone, objectNone);
+ check(voidNone, intNone);
+ check(voidNone, intQuestion);
+ check(voidNone, intStar);
+ check(voidNone, listNone(intNone));
+ check(voidNone, futureOrNone(intNone));
+
+ check(dynamicNone, objectNone);
+ check(dynamicNone, intNone);
+ check(dynamicNone, intQuestion);
+ check(dynamicNone, intStar);
+ check(dynamicNone, listNone(intNone));
+ check(dynamicNone, futureOrNone(intNone));
+
+ check(objectQuestion, objectNone);
+ check(objectQuestion, intNone);
+ check(objectQuestion, intQuestion);
+ check(objectQuestion, intStar);
+ check(objectQuestion, listNone(intNone));
+ check(objectQuestion, futureOrNone(intNone));
+
+ check(objectStar, objectNone);
+ check(objectStar, intNone);
+ check(objectStar, intQuestion);
+ check(objectStar, intStar);
+ check(objectStar, listNone(intNone));
+ check(objectStar, futureOrNone(intNone));
+
+ check(futureOrNone(voidNone), intNone);
+ check(futureOrQuestion(voidNone), intNone);
+ check(futureOrStar(voidNone), intNone);
+ }
+
+ test_top_top() {
+ void check(DartType T1, DartType T2) {
+ expect(typeSystem.isTop(T1), isTrue, reason: _typeString(T1));
+ expect(typeSystem.isTop(T2), isTrue, reason: _typeString(T2));
+ _checkLeastUpperBound(T1, T2, T1);
+ }
+
+ check(voidNone, dynamicNone);
+ check(voidNone, objectStar);
+ check(voidNone, objectQuestion);
+ check(voidNone, futureOrNone(voidNone));
+ check(voidNone, futureOrNone(dynamicNone));
+ check(voidNone, futureOrNone(objectQuestion));
+ check(voidNone, futureOrNone(objectStar));
+
+ check(dynamicNone, objectStar);
+ check(dynamicNone, objectQuestion);
+ check(dynamicNone, futureOrNone(voidNone));
+ check(dynamicNone, futureOrNone(dynamicNone));
+ check(dynamicNone, futureOrNone(objectQuestion));
+ check(dynamicNone, futureOrNone(objectStar));
+ check(
+ dynamicNone,
+ futureOrStar(objectStar),
+ );
+
+ check(objectQuestion, futureOrQuestion(voidNone));
+ check(objectQuestion, futureOrQuestion(dynamicNone));
+ check(objectQuestion, futureOrQuestion(objectNone));
+ check(objectQuestion, futureOrQuestion(objectQuestion));
+ check(objectQuestion, futureOrQuestion(objectStar));
+
+ check(objectQuestion, futureOrStar(voidNone));
+ check(objectQuestion, futureOrStar(dynamicNone));
+ check(objectQuestion, futureOrStar(objectNone));
+ check(objectQuestion, futureOrStar(objectQuestion));
+ check(objectQuestion, futureOrStar(objectStar));
+
+ check(objectStar, futureOrStar(voidNone));
+ check(objectStar, futureOrStar(dynamicNone));
+ check(objectStar, futureOrStar(objectNone));
+ check(objectStar, futureOrStar(objectQuestion));
+ check(objectStar, futureOrStar(objectStar));
+
+ check(futureOrNone(voidNone), objectQuestion);
+ check(futureOrNone(dynamicNone), objectQuestion);
+ check(futureOrNone(objectQuestion), objectQuestion);
+ check(futureOrNone(objectStar), objectQuestion);
+
+ check(futureOrNone(voidNone), futureOrNone(dynamicNone));
+ check(futureOrNone(voidNone), futureOrNone(objectQuestion));
+ check(futureOrNone(voidNone), futureOrNone(objectStar));
+ check(futureOrNone(dynamicNone), futureOrNone(objectQuestion));
+ check(futureOrNone(dynamicNone), futureOrNone(objectStar));
+ }
+
+ test_typeParameter_bound() {
+ void check(TypeParameterType T1, DartType T2, DartType expected) {
+ _assertNullabilityNone(T1);
+ _assertNullabilityNone(T2);
+
+ _assertNotSpecial(T1);
+ _assertNotSpecial(T2);
+
+ _checkLeastUpperBound(T1, T2, expected);
+ }
+
+ {
+ var T = typeParameter('T', bound: intNone);
+ check(typeParameterTypeNone(T), numNone, numNone);
+ }
+
+ {
+ var T = typeParameter('T', bound: intNone);
+ var U = typeParameter('U', bound: numNone);
+ check(typeParameterTypeNone(T), typeParameterTypeNone(U), numNone);
+ }
+
+ {
+ var T = typeParameter('T', bound: intNone);
+ var U = typeParameter('U', bound: numQuestion);
+ check(typeParameterTypeNone(T), typeParameterTypeNone(U), numQuestion);
+ }
+
+ {
+ var T = typeParameter('T', bound: intQuestion);
+ var U = typeParameter('U', bound: numNone);
+ check(typeParameterTypeNone(T), typeParameterTypeNone(U), numQuestion);
+ }
+
+ {
+ var T = typeParameter('T', bound: numNone);
+ var T_none = typeParameterTypeNone(T);
+ var U = typeParameter('U', bound: T_none);
+ check(T_none, typeParameterTypeNone(U), T_none);
+ }
+ }
+
+ void _checkLeastUpperBound(DartType T1, DartType T2, DartType expected) {
+ var expectedStr = _typeString(expected);
+
+ var result = typeSystem.getLeastUpperBound(T1, T2);
+ var resultStr = _typeString(result);
+ expect(result, expected, reason: '''
+expected: $expectedStr
+actual: $resultStr
+''');
+
+ // Check that the result is an upper bound.
+ expect(typeSystem.isSubtypeOf(T1, result), true);
+ expect(typeSystem.isSubtypeOf(T2, result), true);
+
+ // Check for symmetry.
+ result = typeSystem.getLeastUpperBound(T2, T1);
+ resultStr = _typeString(result);
+ expect(result, expected, reason: '''
+expected: $expectedStr
+actual: $resultStr
+''');
+ }
+}
+
+@reflectiveTest
+class _BoundsTestBase with ElementsTypesMixin {
+ TypeProvider typeProvider;
+
+ TypeSystemImpl typeSystem;
+
+ FeatureSet get testFeatureSet {
+ return FeatureSet.forTesting();
+ }
+
+ void setUp() {
+ var analysisContext = TestAnalysisContext(
+ featureSet: testFeatureSet,
+ );
+ typeProvider = analysisContext.typeProviderNonNullableByDefault;
+ typeSystem = analysisContext.typeSystemNonNullableByDefault;
+ }
+
+ void _assertNotBottom(DartType type) {
+ if (typeSystem.isBottom(type)) {
+ fail('isBottom must be false: ' + _typeString(type));
+ }
+ }
+
+ void _assertNotNull(DartType type) {
+ if (typeSystem.isNull(type)) {
+ fail('isNull must be false: ' + _typeString(type));
+ }
+ }
+
+ void _assertNotObject(DartType type) {
+ if (typeSystem.isObject(type)) {
+ fail('isObject must be false: ' + _typeString(type));
+ }
+ }
+
+ void _assertNotSpecial(DartType type) {
+ _assertNotBottom(type);
+ _assertNotNull(type);
+ _assertNotObject(type);
+ _assertNotTop(type);
+ }
+
+ void _assertNotTop(DartType type) {
+ if (typeSystem.isTop(type)) {
+ fail('isTop must be false: ' + _typeString(type));
+ }
+ }
+
+ void _assertNullability(DartType type, NullabilitySuffix expected) {
+ if ((type as TypeImpl).nullabilitySuffix != expected) {
+ fail('Expected $expected in ' + _typeString(type));
+ }
+ }
+
+ void _assertNullabilityNone(DartType type) {
+ _assertNullability(type, NullabilitySuffix.none);
+ }
+
+ void _assertNullabilityQuestion(DartType type) {
+ _assertNullability(type, NullabilitySuffix.question);
+ }
+
+ void _assertNullabilityStar(DartType type) {
+ _assertNullability(type, NullabilitySuffix.star);
+ }
+
+ String _typeParametersStr(TypeImpl type) {
+ var typeStr = '';
+
+ var typeParameterCollector = _TypeParameterCollector();
+ DartTypeVisitor.visit(type, typeParameterCollector);
+ for (var typeParameter in typeParameterCollector.typeParameters) {
+ if (typeParameter is TypeParameterMember) {
+ var base = typeParameter.declaration;
+ var baseBound = base.bound as TypeImpl;
+ if (baseBound != null) {
+ var baseBoundStr = baseBound.toString(withNullability: true);
+ typeStr += ', ${typeParameter.name} extends ' + baseBoundStr;
+ }
+
+ var bound = typeParameter.bound as TypeImpl;
+ var boundStr = bound.toString(withNullability: true);
+ typeStr += ', ${typeParameter.name} & ' + boundStr;
+ } else {
+ var bound = typeParameter.bound as TypeImpl;
+ if (bound != null) {
+ var boundStr = bound.toString(withNullability: true);
+ typeStr += ', ${typeParameter.name} extends ' + boundStr;
+ }
+ }
+ }
+ return typeStr;
+ }
+
+ String _typeString(TypeImpl type) {
+ if (type == null) return null;
+ return type.toString(withNullability: true) + _typeParametersStr(type);
+ }
+}
+
+class _TypeParameterCollector extends DartTypeVisitor<void> {
+ final Set<TypeParameterElement> typeParameters = Set();
+
+ /// We don't need to print bounds for these type parameters, because
+ /// they are already included into the function type itself, and cannot
+ /// be promoted.
+ final Set<TypeParameterElement> functionTypeParameters = Set();
+
+ @override
+ void defaultDartType(DartType type) {
+ throw UnimplementedError('(${type.runtimeType}) $type');
+ }
+
+ @override
+ void visitDynamicType(DynamicTypeImpl type) {}
+
+ @override
+ void visitFunctionType(FunctionType type) {
+ functionTypeParameters.addAll(type.typeFormals);
+ for (var typeParameter in type.typeFormals) {
+ var bound = typeParameter.bound;
+ if (bound != null) {
+ DartTypeVisitor.visit(bound, this);
+ }
+ }
+ for (var parameter in type.parameters) {
+ DartTypeVisitor.visit(parameter.type, this);
+ }
+ DartTypeVisitor.visit(type.returnType, this);
+ }
+
+ @override
+ void visitInterfaceType(InterfaceType type) {
+ for (var typeArgument in type.typeArguments) {
+ DartTypeVisitor.visit(typeArgument, this);
+ }
+ }
+
+ @override
+ void visitNeverType(NeverTypeImpl type) {}
+
+ @override
+ void visitTypeParameterType(TypeParameterType type) {
+ if (!functionTypeParameters.contains(type.element)) {
+ typeParameters.add(type.element);
+ }
+ }
+
+ @override
+ void visitVoidType(VoidType type) {}
+}
diff --git a/pkg/analyzer/test/src/dart/resolution/driver_resolution.dart b/pkg/analyzer/test/src/dart/resolution/driver_resolution.dart
index 0a172b5..9e7d331 100644
--- a/pkg/analyzer/test/src/dart/resolution/driver_resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/driver_resolution.dart
@@ -21,9 +21,9 @@
/// [AnalysisDriver] based implementation of [ResolutionTest].
class DriverResolutionTest with ResourceProviderMixin, ResolutionTest {
- final ByteStore byteStore = new MemoryByteStore();
+ final ByteStore byteStore = MemoryByteStore();
- final StringBuffer logBuffer = new StringBuffer();
+ final StringBuffer logBuffer = StringBuffer();
PerformanceLog logger;
DartSdk sdk;
@@ -42,12 +42,12 @@
}
void setUp() {
- sdk = new MockSdk(
+ sdk = MockSdk(
resourceProvider: resourceProvider,
additionalLibraries: additionalMockSdkLibraries,
);
- logger = new PerformanceLog(logBuffer);
- scheduler = new AnalysisDriverScheduler(logger);
+ logger = PerformanceLog(logBuffer);
+ scheduler = AnalysisDriverScheduler(logger);
// TODO(brianwilkerson) Create an empty package map by default and only add
// packages in the tests that need them.
@@ -58,17 +58,17 @@
'meta': [getFolder('/.pub-cache/meta/lib')],
};
- driver = new AnalysisDriver(
+ driver = AnalysisDriver(
scheduler,
logger,
resourceProvider,
byteStore,
- new FileContentOverlay(),
+ FileContentOverlay(),
null,
- new SourceFactory([
- new DartUriResolver(sdk),
- new PackageMapUriResolver(resourceProvider, packageMap),
- new ResourceUriResolver(resourceProvider)
+ SourceFactory([
+ DartUriResolver(sdk),
+ PackageMapUriResolver(resourceProvider, packageMap),
+ ResourceUriResolver(resourceProvider)
], null, resourceProvider),
analysisOptions);
diff --git a/pkg/analyzer/test/src/dart/resolution/export_test.dart b/pkg/analyzer/test/src/dart/resolution/export_test.dart
index 5a4455a..8fcf08b 100644
--- a/pkg/analyzer/test/src/dart/resolution/export_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/export_test.dart
@@ -2,6 +2,7 @@
// 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.
+import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -15,6 +16,90 @@
@reflectiveTest
class ExportResolutionTest extends DriverResolutionTest {
+ test_configurations_default() async {
+ newFile('/test/lib/a.dart', content: 'class A {}');
+ newFile('/test/lib/a_html.dart', content: 'class A {}');
+ newFile('/test/lib/a_io.dart', content: 'class A {}');
+
+ _setDeclaredVariables({
+ 'dart.library.html': 'false',
+ 'dart.library.io': 'false',
+ });
+
+ await assertNoErrorsInCode(r'''
+export 'a.dart'
+ if (dart.library.html) 'a_html.dart'
+ if (dart.library.io) 'a_io.dart';
+''');
+
+ assertNamespaceDirectiveSelected(
+ findNode.export('a.dart'),
+ expectedRelativeUri: 'a.dart',
+ expectedUri: 'package:test/a.dart',
+ );
+
+ assertElementLibraryUri(
+ result.libraryElement.exportNamespace.get('A'),
+ 'package:test/a.dart',
+ );
+ }
+
+ test_configurations_first() async {
+ newFile('/test/lib/a.dart', content: 'class A {}');
+ newFile('/test/lib/a_html.dart', content: 'class A {}');
+ newFile('/test/lib/a_io.dart', content: 'class A {}');
+
+ _setDeclaredVariables({
+ 'dart.library.html': 'true',
+ 'dart.library.io': 'false',
+ });
+
+ await assertNoErrorsInCode(r'''
+export 'a.dart'
+ if (dart.library.html) 'a_html.dart'
+ if (dart.library.io) 'a_io.dart';
+''');
+
+ assertNamespaceDirectiveSelected(
+ findNode.export('a.dart'),
+ expectedRelativeUri: 'a_html.dart',
+ expectedUri: 'package:test/a_html.dart',
+ );
+
+ assertElementLibraryUri(
+ result.libraryElement.exportNamespace.get('A'),
+ 'package:test/a_html.dart',
+ );
+ }
+
+ test_configurations_second() async {
+ newFile('/test/lib/a.dart', content: 'class A {}');
+ newFile('/test/lib/a_html.dart', content: 'class A {}');
+ newFile('/test/lib/a_io.dart', content: 'class A {}');
+
+ _setDeclaredVariables({
+ 'dart.library.html': 'false',
+ 'dart.library.io': 'true',
+ });
+
+ await assertNoErrorsInCode(r'''
+export 'a.dart'
+ if (dart.library.html) 'a_html.dart'
+ if (dart.library.io) 'a_io.dart';
+''');
+
+ assertNamespaceDirectiveSelected(
+ findNode.export('a.dart'),
+ expectedRelativeUri: 'a_io.dart',
+ expectedUri: 'package:test/a_io.dart',
+ );
+
+ assertElementLibraryUri(
+ result.libraryElement.exportNamespace.get('A'),
+ 'package:test/a_io.dart',
+ );
+ }
+
/// Test that both getter and setter are in the export namespace.
test_namespace_getter_setter() async {
newFile('/test/lib/a.dart', content: r'''
@@ -28,4 +113,9 @@
expect(exportNamespace.get('f'), isNotNull);
expect(exportNamespace.get('f='), isNotNull);
}
+
+ void _setDeclaredVariables(Map<String, String> map) {
+ driver.declaredVariables = DeclaredVariables.fromMap(map);
+ driver.configure();
+ }
}
diff --git a/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart b/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
index a095591..ca3c60e 100644
--- a/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
@@ -26,7 +26,7 @@
abstract class BaseExtensionMethodsTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
}
@@ -318,7 +318,7 @@
class ExtensionMethodsDeclarationWithNnbdTest extends BaseExtensionMethodsTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.6.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart b/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart
index e9efa53..6ec9988 100644
--- a/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart
@@ -27,7 +27,7 @@
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
void findDeclarationAndOverride(
diff --git a/pkg/analyzer/test/src/dart/resolution/import_test.dart b/pkg/analyzer/test/src/dart/resolution/import_test.dart
new file mode 100644
index 0000000..78a4392
--- /dev/null
+++ b/pkg/analyzer/test/src/dart/resolution/import_test.dart
@@ -0,0 +1,106 @@
+// Copyright (c) 2018, 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.
+
+import 'package:analyzer/dart/analysis/declared_variables.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'driver_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(ImportDirectiveResolutionTest);
+ });
+}
+
+@reflectiveTest
+class ImportDirectiveResolutionTest extends DriverResolutionTest {
+ test_configurations_default() async {
+ newFile('/test/lib/a.dart', content: 'class A {}');
+ newFile('/test/lib/a_html.dart', content: 'class A {}');
+ newFile('/test/lib/a_io.dart', content: 'class A {}');
+
+ _setDeclaredVariables({
+ 'dart.library.html': 'false',
+ 'dart.library.io': 'false',
+ });
+
+ await assertNoErrorsInCode(r'''
+import 'a.dart'
+ if (dart.library.html) 'a_html.dart'
+ if (dart.library.io) 'a_io.dart';
+
+var a = A();
+''');
+
+ assertNamespaceDirectiveSelected(
+ findNode.import('a.dart'),
+ expectedRelativeUri: 'a.dart',
+ expectedUri: 'package:test/a.dart',
+ );
+
+ var a = findElement.topVar('a');
+ assertElementLibraryUri(a.type.element, 'package:test/a.dart');
+ }
+
+ test_configurations_first() async {
+ newFile('/test/lib/a.dart', content: 'class A {}');
+ newFile('/test/lib/a_html.dart', content: 'class A {}');
+ newFile('/test/lib/a_io.dart', content: 'class A {}');
+
+ _setDeclaredVariables({
+ 'dart.library.html': 'true',
+ 'dart.library.io': 'false',
+ });
+
+ await assertNoErrorsInCode(r'''
+import 'a.dart'
+ if (dart.library.html) 'a_html.dart'
+ if (dart.library.io) 'a_io.dart';
+
+var a = A();
+''');
+
+ assertNamespaceDirectiveSelected(
+ findNode.import('a.dart'),
+ expectedRelativeUri: 'a_html.dart',
+ expectedUri: 'package:test/a_html.dart',
+ );
+
+ var a = findElement.topVar('a');
+ assertElementLibraryUri(a.type.element, 'package:test/a_html.dart');
+ }
+
+ test_configurations_second() async {
+ newFile('/test/lib/a.dart', content: 'class A {}');
+ newFile('/test/lib/a_html.dart', content: 'class A {}');
+ newFile('/test/lib/a_io.dart', content: 'class A {}');
+
+ _setDeclaredVariables({
+ 'dart.library.html': 'false',
+ 'dart.library.io': 'true',
+ });
+
+ await assertNoErrorsInCode(r'''
+import 'a.dart'
+ if (dart.library.html) 'a_html.dart'
+ if (dart.library.io) 'a_io.dart';
+
+var a = A();
+''');
+
+ assertNamespaceDirectiveSelected(
+ findNode.import('a.dart'),
+ expectedRelativeUri: 'a_io.dart',
+ expectedUri: 'package:test/a_io.dart',
+ );
+
+ var a = findElement.topVar('a');
+ assertElementLibraryUri(a.type.element, 'package:test/a_io.dart');
+ }
+
+ void _setDeclaredVariables(Map<String, String> map) {
+ driver.declaredVariables = DeclaredVariables.fromMap(map);
+ driver.configure();
+ }
+}
diff --git a/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart b/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
index f521fdb..f86378b 100644
--- a/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
@@ -1775,8 +1775,8 @@
void _assertInvalidInvocation(String search, Element expectedElement,
{String expectedMethodNameType,
String expectedNameType,
- List<String> expectedTypeArguments: const <String>[],
- bool dynamicNameType: false}) {
+ List<String> expectedTypeArguments = const <String>[],
+ bool dynamicNameType = false}) {
var invocation = findNode.methodInvocation(search);
if (dynamicNameType) {
assertTypeDynamic(invocation.methodName);
@@ -1796,7 +1796,7 @@
void _assertUnresolvedMethodInvocation(
String search, {
- List<String> expectedTypeArguments: const <String>[],
+ List<String> expectedTypeArguments = const <String>[],
}) {
// TODO(scheglov) clean up
_assertInvalidInvocation(
diff --git a/pkg/analyzer/test/src/dart/resolution/namespace_test.dart b/pkg/analyzer/test/src/dart/resolution/namespace_test.dart
index f5b0bf7..2a0e9d0 100644
--- a/pkg/analyzer/test/src/dart/resolution/namespace_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/namespace_test.dart
@@ -33,6 +33,6 @@
class ImportResolutionWithNnbdTest extends ImportResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
}
diff --git a/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart b/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart
index 86ebbb9..cbb0ae4 100644
--- a/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart
@@ -517,6 +517,31 @@
'int? Function(bool, String, String?)?',
);
}
+
+ test_typedef_function_nullable_element() async {
+ await assertNoErrorsInCode('''
+typedef F<T> = int Function(T)?;
+
+main(F<int> a, F<double>? b) {}
+''');
+
+ assertType(findNode.typeName('F<int>'), 'int Function(int)?');
+ assertType(findNode.typeName('F<double>?'), 'int Function(double)?');
+ }
+
+ test_typedef_function_nullable_local() async {
+ await assertNoErrorsInCode('''
+typedef F<T> = int Function(T)?;
+
+main() {
+ F<int> a;
+ F<double>? b;
+}
+''');
+
+ assertType(findNode.typeName('F<int>'), 'int Function(int)?');
+ assertType(findNode.typeName('F<double>?'), 'int Function(double)?');
+ }
}
@reflectiveTest
diff --git a/pkg/analyzer/test/src/dart/resolution/resolution.dart b/pkg/analyzer/test/src/dart/resolution/resolution.dart
index 803474c..a7e9888 100644
--- a/pkg/analyzer/test/src/dart/resolution/resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/resolution.dart
@@ -19,15 +19,16 @@
import 'package:analyzer/src/test_utilities/find_element.dart';
import 'package:analyzer/src/test_utilities/find_node.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
+import 'package:meta/meta.dart';
import 'package:test/test.dart';
import '../../../generated/test_support.dart';
-final isDynamicType = new TypeMatcher<DynamicTypeImpl>();
+final isDynamicType = TypeMatcher<DynamicTypeImpl>();
-final isNeverType = new TypeMatcher<NeverTypeImpl>();
+final isNeverType = TypeMatcher<NeverTypeImpl>();
-final isVoidType = new TypeMatcher<VoidTypeImpl>();
+final isVoidType = TypeMatcher<VoidTypeImpl>();
/// Base for resolution tests.
mixin ResolutionTest implements ResourceProviderMixin {
@@ -59,8 +60,7 @@
InterfaceType get stringType => typeProvider.stringType;
- TypeProvider get typeProvider =>
- result.unit.declaredElement.context.typeProvider;
+ TypeProvider get typeProvider => result.typeProvider;
/// Whether `DartType.toString()` with nullability should be asked.
bool get typeToStringWithNullability => false;
@@ -120,6 +120,11 @@
expect(actual, same(expected));
}
+ void assertElementLibraryUri(Element element, String expected) {
+ var uri = element.library.source.uri;
+ expect('$uri', expected);
+ }
+
void assertElementName(Element element, String name,
{bool isSynthetic = false, int offset}) {
expect(element.name, name);
@@ -168,7 +173,26 @@
addTestFile(code);
await resolveTestFile();
- GatheringErrorListener errorListener = new GatheringErrorListener();
+ assertErrorsInResolvedUnit(result, expectedErrors);
+ }
+
+ Future<void> assertErrorsInFile(
+ String path,
+ String content,
+ List<ExpectedError> expectedErrors,
+ ) async {
+ path = convertPath(path);
+ newFile(path, content: content);
+
+ var result = await resolveFile(path);
+ assertErrorsInResolvedUnit(result, expectedErrors);
+ }
+
+ void assertErrorsInResolvedUnit(
+ ResolvedUnitResult result,
+ List<ExpectedError> expectedErrors,
+ ) {
+ GatheringErrorListener errorListener = GatheringErrorListener();
errorListener.addAll(result.errors);
errorListener.assertErrors(expectedErrors);
}
@@ -179,7 +203,7 @@
*/
void assertErrorsWithCodes(List<AnalysisError> errors,
[List<ErrorCode> expected = const <ErrorCode>[]]) {
- var errorListener = new GatheringErrorListener();
+ var errorListener = GatheringErrorListener();
for (AnalysisError error in result.errors) {
ErrorCode errorCode = error.errorCode;
if (!enableUnusedElement &&
@@ -226,7 +250,7 @@
void assertInstanceCreation(InstanceCreationExpression creation,
ClassElement expectedClassElement, String expectedType,
{String constructorName,
- bool expectedConstructorMember: false,
+ bool expectedConstructorMember = false,
Map<String, String> expectedSubstitution,
PrefixElement expectedPrefix}) {
String expectedClassName = expectedClassElement.name;
@@ -320,7 +344,7 @@
String expectedMethodNameType,
String expectedNameType,
String expectedType,
- List<String> expectedTypeArguments: const <String>[],
+ List<String> expectedTypeArguments = const <String>[],
}) {
MethodInvocationImpl invocationImpl = invocation;
@@ -356,6 +380,15 @@
assertTypeNull(ref);
}
+ void assertNamespaceDirectiveSelected(
+ NamespaceDirective directive, {
+ @required String expectedRelativeUri,
+ @required String expectedUri,
+ }) {
+ expect(directive.selectedUriContent, expectedRelativeUri);
+ expect('${directive.selectedSource.uri}', expectedUri);
+ }
+
Future<void> assertNoErrorsInCode(String code) async {
addTestFile(code);
await resolveTestFile();
@@ -534,8 +567,8 @@
Future<void> resolveTestFile() async {
var path = convertPath('/test/lib/test.dart');
result = await resolveFile(path);
- findNode = new FindNode(result.content, result.unit);
- findElement = new FindElement(result.unit);
+ findNode = FindNode(result.content, result.unit);
+ findElement = FindElement(result.unit);
}
/// Return a textual representation of the [type] that is appropriate for
diff --git a/pkg/analyzer/test/src/dart/resolution/test_all.dart b/pkg/analyzer/test/src/dart/resolution/test_all.dart
index fa9767e..484fae4 100644
--- a/pkg/analyzer/test/src/dart/resolution/test_all.dart
+++ b/pkg/analyzer/test/src/dart/resolution/test_all.dart
@@ -23,6 +23,7 @@
import 'generic_function_type_test.dart' as generic_function_type;
import 'generic_type_alias_test.dart' as generic_type_alias;
import 'import_prefix_test.dart' as import_prefix;
+import 'import_test.dart' as import_;
import 'index_expression_test.dart' as index_expression;
import 'instance_creation_test.dart' as instance_creation;
import 'instance_member_inference_class_test.dart'
@@ -60,6 +61,7 @@
function_type_alias.main();
generic_function_type.main();
generic_type_alias.main();
+ import_.main();
import_prefix.main();
index_expression.main();
instance_creation.main();
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/collection_elements_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/collection_elements_test.dart
index cb605a0..ada9374 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/collection_elements_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/collection_elements_test.dart
@@ -20,7 +20,7 @@
class ForElementWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
@@ -205,7 +205,7 @@
class IfElementWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
@@ -249,7 +249,7 @@
class SpreadElementWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/conditional_expression_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/conditional_expression_test.dart
index 2e27d71..6f28467 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/conditional_expression_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/conditional_expression_test.dart
@@ -32,7 +32,7 @@
class ConditionalExpressionWithNnbdTest extends ConditionalExpressionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/equality_expressions_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/equality_expressions_test.dart
index 9997f16..ddbebd7 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/equality_expressions_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/equality_expressions_test.dart
@@ -34,7 +34,7 @@
class EqualWithNnbdTest extends EqualTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
@@ -58,7 +58,7 @@
class NotEqualWithNnbdTest extends NotEqualTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/extension_methods_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/extension_methods_test.dart
index dfbb4ac..a9a3d0a 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/extension_methods_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/extension_methods_test.dart
@@ -19,7 +19,7 @@
class ExtensionMethodsTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_implicit_getter() async {
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/function_expression_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/function_expression_test.dart
index 0b63163..fdfc799 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/function_expression_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/function_expression_test.dart
@@ -17,7 +17,7 @@
@reflectiveTest
class FunctionExpressionTest extends DriverResolutionTest {
- test_returnType_notNullable() async {
+ test_returnType_blockBody_notNullable() async {
await resolveTestCode('''
var v = (bool b) {
if (b) return 0;
@@ -28,7 +28,7 @@
assertElementTypeString(element.returnType, 'num');
}
- test_returnType_null_hasReturn() async {
+ test_returnType_blockBody_null_hasReturn() async {
await resolveTestCode('''
var v = (bool b) {
if (b) return;
@@ -38,7 +38,7 @@
assertElementTypeString(element.returnType, 'Null');
}
- test_returnType_null_noReturn() async {
+ test_returnType_blockBody_null_noReturn() async {
await resolveTestCode('''
var v = () {};
''');
@@ -46,7 +46,7 @@
assertElementTypeString(element.returnType, 'Null');
}
- test_returnType_nullable() async {
+ test_returnType_blockBody_nullable() async {
await resolveTestCode('''
var v = (bool b) {
if (b) return 0;
@@ -59,13 +59,41 @@
assertElementTypeString(element.returnType, 'int');
}
}
+
+ test_returnType_expressionBody_Never() async {
+ await resolveTestCode('''
+var v = () => throw 42;
+''');
+ var element = findNode.functionExpression('() =>').declaredElement;
+ if (typeToStringWithNullability) {
+ assertElementTypeString(element.returnType, 'Never');
+ } else {
+ assertElementTypeString(element.returnType, 'Null');
+ }
+ }
+
+ test_returnType_expressionBody_notNullable() async {
+ await resolveTestCode('''
+var v = () => 42;
+''');
+ var element = findNode.functionExpression('() =>').declaredElement;
+ assertElementTypeString(element.returnType, 'int');
+ }
+
+ test_returnType_expressionBody_Null() async {
+ await resolveTestCode('''
+var v = () => null;
+''');
+ var element = findNode.functionExpression('() =>').declaredElement;
+ assertElementTypeString(element.returnType, 'Null');
+ }
}
@reflectiveTest
class FunctionExpressionWithNnbdTest extends FunctionExpressionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.6.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/list_literal_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/list_literal_test.dart
index d5ebe59..98e0bfbe 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/list_literal_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/list_literal_test.dart
@@ -291,7 +291,7 @@
class ListLiteralWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.6.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/logical_boolean_expressions_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/logical_boolean_expressions_test.dart
index 764822a..02eedf3 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/logical_boolean_expressions_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/logical_boolean_expressions_test.dart
@@ -34,7 +34,7 @@
class LogicalAndWithNnbdTest extends LogicalAndTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
@@ -72,7 +72,7 @@
class LogicalOrWithNnbdTest extends LogicalOrTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/prefix_expressions_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/prefix_expressions_test.dart
index 93067e4..4c52344 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/prefix_expressions_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/prefix_expressions_test.dart
@@ -32,7 +32,7 @@
class NotWithNnbdTest extends NotTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/statements_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/statements_test.dart
index 583b9fb..5848d62 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/statements_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/statements_test.dart
@@ -22,7 +22,7 @@
class AssertWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
@@ -43,7 +43,7 @@
class DoWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
@@ -64,7 +64,7 @@
class ForWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
@@ -128,7 +128,7 @@
class IfWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
@@ -149,7 +149,7 @@
class WhileWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/throw_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/throw_test.dart
index 8d00d68..d8a978c 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/throw_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/throw_test.dart
@@ -18,7 +18,7 @@
class ThrowWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/type_test_expressions_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/type_test_expressions_test.dart
index 641ffb6..f90d562 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/type_test_expressions_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/type_test_expressions_test.dart
@@ -34,7 +34,7 @@
class IsNotWithNnbdTest extends IsNotTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
@@ -58,7 +58,7 @@
class IsWithNnbdTest extends IsTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/dart/resolver/legacy_type_asserter_test.dart b/pkg/analyzer/test/src/dart/resolver/legacy_type_asserter_test.dart
index 1dfbedd..92e57f5 100644
--- a/pkg/analyzer/test/src/dart/resolver/legacy_type_asserter_test.dart
+++ b/pkg/analyzer/test/src/dart/resolver/legacy_type_asserter_test.dart
@@ -13,7 +13,7 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../resolution/driver_resolution.dart';
+import '../../../generated/test_analysis_context.dart';
main() {
defineReflectiveSuite(() {
@@ -21,14 +21,13 @@
});
}
-/// Tests for the [ExitDetector] that require that the control flow and spread
-/// experiments be enabled.
@reflectiveTest
-class LegacyTypeAsserterTest extends DriverResolutionTest {
+class LegacyTypeAsserterTest {
TypeProvider typeProvider;
- setUp() async {
- await super.setUp();
- typeProvider = await this.driver.currentSession.typeProvider;
+
+ void setUp() {
+ var analysisContext = TestAnalysisContext();
+ typeProvider = analysisContext.typeProviderLegacy;
}
test_nullableUnit_expressionStaticType_bottom() async {
diff --git a/pkg/analyzer/test/src/dart/sdk/patch_test.dart b/pkg/analyzer/test/src/dart/sdk/patch_test.dart
index 7c13bdf..0f7646d 100644
--- a/pkg/analyzer/test/src/dart/sdk/patch_test.dart
+++ b/pkg/analyzer/test/src/dart/sdk/patch_test.dart
@@ -27,8 +27,8 @@
Folder sdkFolder;
FolderBasedDartSdk sdk;
- SdkPatcher patcher = new SdkPatcher();
- RecordingErrorListener listener = new RecordingErrorListener();
+ SdkPatcher patcher = SdkPatcher();
+ RecordingErrorListener listener = RecordingErrorListener();
void setUp() {
sdkFolder = getFolder('/sdk');
@@ -629,7 +629,7 @@
ClassDeclaration cls = unit.declarations[0];
MethodDeclaration method = cls.members[0];
FormalParameter parameter = method.parameters.parameters[0];
- expect(parameter, new TypeMatcher<DefaultFormalParameter>());
+ expect(parameter, TypeMatcher<DefaultFormalParameter>());
}
test_class_method_patch_success_implicitReturnType() {
@@ -1055,8 +1055,8 @@
}
void _createSdk() {
- sdk = new FolderBasedDartSdk(resourceProvider, sdkFolder);
- sdk.analysisOptions = new AnalysisOptionsImpl();
+ sdk = FolderBasedDartSdk(resourceProvider, sdkFolder);
+ sdk.analysisOptions = AnalysisOptionsImpl();
}
CompilationUnit _doTopLevelPatching(String baseCode, String patchCode) {
diff --git a/pkg/analyzer/test/src/dart/sdk/sdk_test.dart b/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
index 43bfb89..ed50242 100644
--- a/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
+++ b/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
@@ -29,19 +29,19 @@
@reflectiveTest
class EmbedderSdkTest extends EmbedderRelatedTest {
void test_creation() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(resourceProvider, locator.embedderYamls);
+ EmbedderSdk sdk = EmbedderSdk(resourceProvider, locator.embedderYamls);
expect(sdk.urlMappings, hasLength(5));
}
void test_fromFileUri() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(resourceProvider, locator.embedderYamls);
+ EmbedderSdk sdk = EmbedderSdk(resourceProvider, locator.embedderYamls);
expectSource(String posixPath, String dartUri) {
Uri uri = Uri.parse(posixToOSFileUri(posixPath));
@@ -57,30 +57,30 @@
}
void test_getLinkedBundle_noBundle() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(resourceProvider, locator.embedderYamls);
+ EmbedderSdk sdk = EmbedderSdk(resourceProvider, locator.embedderYamls);
expect(sdk.getLinkedBundle(), isNull);
}
void test_getLinkedBundle_strong() {
- pathTranslator.newFileWithBytes('$foxPath/strong.sum',
- new PackageBundleAssembler().assemble().toBuffer());
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ pathTranslator.newFileWithBytes(
+ '$foxPath/strong.sum', PackageBundleAssembler().assemble().toBuffer());
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(resourceProvider, locator.embedderYamls);
- sdk.analysisOptions = new AnalysisOptionsImpl();
+ EmbedderSdk sdk = EmbedderSdk(resourceProvider, locator.embedderYamls);
+ sdk.analysisOptions = AnalysisOptionsImpl();
sdk.useSummary = true;
expect(sdk.getLinkedBundle(), isNotNull);
}
void test_getSdkLibrary() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(resourceProvider, locator.embedderYamls);
+ EmbedderSdk sdk = EmbedderSdk(resourceProvider, locator.embedderYamls);
SdkLibrary lib = sdk.getSdkLibrary('dart:fox');
expect(lib, isNotNull);
@@ -89,10 +89,10 @@
}
void test_mapDartUri() {
- EmbedderYamlLocator locator = new EmbedderYamlLocator({
+ EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
- EmbedderSdk sdk = new EmbedderSdk(resourceProvider, locator.embedderYamls);
+ EmbedderSdk sdk = EmbedderSdk(resourceProvider, locator.embedderYamls);
void expectSource(String dartUri, String posixPath) {
Source source = sdk.mapDartUri(dartUri);
@@ -125,17 +125,17 @@
FolderBasedDartSdk sdk = _createDartSdk();
sdk.context;
expect(() {
- sdk.analysisOptions = new AnalysisOptionsImpl();
+ sdk.analysisOptions = AnalysisOptionsImpl();
}, throwsStateError);
}
void test_analysisOptions_beforeContextCreation() {
FolderBasedDartSdk sdk = _createDartSdk();
- sdk.analysisOptions = new AnalysisOptionsImpl();
+ sdk.analysisOptions = AnalysisOptionsImpl();
sdk.context;
// cannot change "analysisOptions" in the context
expect(() {
- sdk.context.analysisOptions = new AnalysisOptionsImpl();
+ sdk.context.analysisOptions = AnalysisOptionsImpl();
}, throwsStateError);
}
@@ -270,11 +270,11 @@
_createFile(sdkDirectory, ['lib', 'html', 'dart2js', 'html_dart2js.dart']);
_createFile(
sdkDirectory, ['bin', (OSUtilities.isWindows() ? 'pub.bat' : 'pub')]);
- return new FolderBasedDartSdk(resourceProvider, sdkDirectory);
+ return FolderBasedDartSdk(resourceProvider, sdkDirectory);
}
void _createFile(Folder directory, List<String> segments,
- {String content: ''}) {
+ {String content = ''}) {
Folder parent = directory;
int last = segments.length - 1;
for (int i = 0; i < last; i++) {
@@ -328,19 +328,19 @@
}
test_create_noSdkExtPackageMap() {
- var resolver = new SdkExtensionFinder({
+ var resolver = SdkExtensionFinder({
'fox': <Folder>[getFolder('/empty')]
});
expect(resolver.urlMappings.length, equals(0));
}
test_create_nullPackageMap() {
- var resolver = new SdkExtensionFinder(null);
+ var resolver = SdkExtensionFinder(null);
expect(resolver.urlMappings.length, equals(0));
}
test_create_sdkExtPackageMap() {
- var resolver = new SdkExtensionFinder({
+ var resolver = SdkExtensionFinder({
'fox': <Folder>[getFolder('/tmp')]
});
// We have four mappings.
@@ -359,14 +359,14 @@
class SdkLibrariesReaderTest with ResourceProviderMixin {
void test_readFrom_empty() {
LibraryMap libraryMap =
- new SdkLibrariesReader().readFromFile(getFile("/libs.dart"), "");
+ SdkLibrariesReader().readFromFile(getFile("/libs.dart"), "");
expect(libraryMap, isNotNull);
expect(libraryMap.size(), 0);
}
void test_readFrom_normal() {
LibraryMap libraryMap =
- new SdkLibrariesReader().readFromFile(getFile("/libs.dart"), r'''
+ SdkLibrariesReader().readFromFile(getFile("/libs.dart"), r'''
final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
'first' : const LibraryInfo(
'first/first.dart',
diff --git a/pkg/analyzer/test/src/dartdoc/dartdoc_directive_info_test.dart b/pkg/analyzer/test/src/dartdoc/dartdoc_directive_info_test.dart
index 389fff5..a7f7a58 100644
--- a/pkg/analyzer/test/src/dartdoc/dartdoc_directive_info_test.dart
+++ b/pkg/analyzer/test/src/dartdoc/dartdoc_directive_info_test.dart
@@ -14,7 +14,7 @@
@reflectiveTest
class DartdocDirectiveInfoTest {
- DartdocDirectiveInfo info = new DartdocDirectiveInfo();
+ DartdocDirectiveInfo info = DartdocDirectiveInfo();
test_processDartdoc_macro_defined() {
info.extractTemplate('''
diff --git a/pkg/analyzer/test/src/diagnostics/ambiguous_export_test.dart b/pkg/analyzer/test/src/diagnostics/ambiguous_export_test.dart
index bf7926d..fefeb5e 100644
--- a/pkg/analyzer/test/src/diagnostics/ambiguous_export_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/ambiguous_export_test.dart
@@ -38,7 +38,7 @@
class AmbiguousExportWithExtensionMethodsTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_extensions_bothExported() async {
diff --git a/pkg/analyzer/test/src/diagnostics/ambiguous_extension_member_access_test.dart b/pkg/analyzer/test/src/diagnostics/ambiguous_extension_member_access_test.dart
index b71d2ab..dbc3e39 100644
--- a/pkg/analyzer/test/src/diagnostics/ambiguous_extension_member_access_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/ambiguous_extension_member_access_test.dart
@@ -19,7 +19,7 @@
class AmbiguousExtensionMemberAccessTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_call() async {
diff --git a/pkg/analyzer/test/src/diagnostics/ambiguous_import_test.dart b/pkg/analyzer/test/src/diagnostics/ambiguous_import_test.dart
index 1ddeae5..9a7fff4 100644
--- a/pkg/analyzer/test/src/diagnostics/ambiguous_import_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/ambiguous_import_test.dart
@@ -102,7 +102,7 @@
ResolvedUnitResult partResult =
await resolveFile(convertPath('/test/lib/part.dart'));
expect(libResult.errors, hasLength(0));
- new GatheringErrorListener()
+ GatheringErrorListener()
..addAll(partResult.errors)
..assertErrors([
error(StaticWarningCode.AMBIGUOUS_IMPORT, 29, 1),
diff --git a/pkg/analyzer/test/src/diagnostics/assignment_to_final_local_test.dart b/pkg/analyzer/test/src/diagnostics/assignment_to_final_local_test.dart
index 9b25380..0ba7329 100644
--- a/pkg/analyzer/test/src/diagnostics/assignment_to_final_local_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/assignment_to_final_local_test.dart
@@ -141,7 +141,7 @@
class AssignmentToFinalLocalWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_localVariable_late() async {
diff --git a/pkg/analyzer/test/src/diagnostics/assignment_to_final_no_setter_test.dart b/pkg/analyzer/test/src/diagnostics/assignment_to_final_no_setter_test.dart
index 20ed816..eca4cef 100644
--- a/pkg/analyzer/test/src/diagnostics/assignment_to_final_no_setter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/assignment_to_final_no_setter_test.dart
@@ -52,7 +52,7 @@
extends AssignmentToFinalNoSetterTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_instance_undefined_hasGetter() async {
diff --git a/pkg/analyzer/test/src/diagnostics/assignment_to_final_test.dart b/pkg/analyzer/test/src/diagnostics/assignment_to_final_test.dart
index cbe2f70..f1e2dfa 100644
--- a/pkg/analyzer/test/src/diagnostics/assignment_to_final_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/assignment_to_final_test.dart
@@ -49,7 +49,7 @@
class AssignmentToFinalWithNnbdTest extends AssignmentToFinalTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_field_late() async {
diff --git a/pkg/analyzer/test/src/diagnostics/assignment_to_method_test.dart b/pkg/analyzer/test/src/diagnostics/assignment_to_method_test.dart
index 912eefe..fce8b0a 100644
--- a/pkg/analyzer/test/src/diagnostics/assignment_to_method_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/assignment_to_method_test.dart
@@ -36,7 +36,7 @@
extends AssignmentToMethodTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_instance_extendedHasMethod_extensionHasSetter() async {
diff --git a/pkg/analyzer/test/src/diagnostics/await_in_late_local_variable_initializer_test.dart b/pkg/analyzer/test/src/diagnostics/await_in_late_local_variable_initializer_test.dart
new file mode 100644
index 0000000..0dd2f98
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/await_in_late_local_variable_initializer_test.dart
@@ -0,0 +1,90 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/src/error/codes.dart';
+import 'package:analyzer/src/generated/engine.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(AwaitInLateLocalVariableInitializerTest);
+ });
+}
+
+@reflectiveTest
+class AwaitInLateLocalVariableInitializerTest extends DriverResolutionTest {
+ static const _errorCode =
+ CompileTimeErrorCode.AWAIT_IN_LATE_LOCAL_VARIABLE_INITIALIZER;
+
+ @override
+ AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+ ..contextFeatures = FeatureSet.forTesting(
+ sdkVersion: '2.6.0', additionalFeatures: [Feature.non_nullable]);
+
+ test_closure_late_await() async {
+ await assertErrorsInCode('''
+main() {
+ var v = () async {
+ late v2 = await 42;
+ print(v2);
+ };
+ print(v);
+}
+''', [
+ error(_errorCode, 44, 5),
+ ]);
+ }
+
+ test_late_await() async {
+ await assertErrorsInCode('''
+main() async {
+ late v = await 42;
+ print(v);
+}
+''', [
+ error(_errorCode, 26, 5),
+ ]);
+ }
+
+ test_late_await_inClosure_blockBody() async {
+ await assertNoErrorsInCode('''
+main() async {
+ late v = () async {
+ await 42;
+ };
+ print(v);
+}
+''');
+ }
+
+ test_late_await_inClosure_expressionBody() async {
+ await assertNoErrorsInCode('''
+main() async {
+ late v = () async => await 42;
+ print(v);
+}
+''');
+ }
+
+ test_no_await() async {
+ await assertNoErrorsInCode('''
+main() async {
+ late v = 42;
+ print(v);
+}
+''');
+ }
+
+ test_not_late() async {
+ await assertNoErrorsInCode('''
+main() async {
+ var v = await 42;
+ print(v);
+}
+''');
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart b/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart
index b9a0264..8ce3236 100644
--- a/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart
@@ -83,7 +83,7 @@
extends ConflictingGenericInterfacesTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.6.0', additionalFeatures: [Feature.non_nullable]);
test_class_extends_implements_nullability() async {
diff --git a/pkg/analyzer/test/src/diagnostics/const_not_initialized_test.dart b/pkg/analyzer/test/src/diagnostics/const_not_initialized_test.dart
index eca8efc..0c15b2d 100644
--- a/pkg/analyzer/test/src/diagnostics/const_not_initialized_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_not_initialized_test.dart
@@ -24,7 +24,7 @@
class ConstNotInitializedWithExtensionMethodsTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_instance() async {
@@ -41,6 +41,6 @@
class ConstNotInitializedWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
}
diff --git a/pkg/analyzer/test/src/diagnostics/const_with_abstract_class_test.dart b/pkg/analyzer/test/src/diagnostics/const_with_abstract_class_test.dart
deleted file mode 100644
index 9248319..0000000
--- a/pkg/analyzer/test/src/diagnostics/const_with_abstract_class_test.dart
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2019, 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.
-
-import 'package:analyzer/src/dart/error/hint_codes.dart';
-import 'package:analyzer/src/error/codes.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../dart/resolution/driver_resolution.dart';
-
-main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConstWithAbstractClassTest);
- });
-}
-
-@reflectiveTest
-class ConstWithAbstractClassTest extends DriverResolutionTest {
- test_generic() async {
- await assertErrorsInCode('''
-abstract class A<E> {
- const A();
-}
-void f() {
- var a = const A<int>();
-}''', [
- error(HintCode.UNUSED_LOCAL_VARIABLE, 54, 1),
- error(StaticWarningCode.CONST_WITH_ABSTRACT_CLASS, 64, 6),
- ]);
-
- assertType(findNode.instanceCreation('const A<int>'), 'A<int>');
- }
-
- test_simple() async {
- await assertErrorsInCode('''
-abstract class A {
- const A();
-}
-void f() {
- A a = const A();
-}''', [
- error(HintCode.UNUSED_LOCAL_VARIABLE, 49, 1),
- error(StaticWarningCode.CONST_WITH_ABSTRACT_CLASS, 59, 1),
- ]);
- }
-}
diff --git a/pkg/analyzer/test/src/diagnostics/default_list_constructor_mismatch_test.dart b/pkg/analyzer/test/src/diagnostics/default_list_constructor_mismatch_test.dart
index 5e19d96..64b11f1 100644
--- a/pkg/analyzer/test/src/diagnostics/default_list_constructor_mismatch_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/default_list_constructor_mismatch_test.dart
@@ -19,7 +19,7 @@
class DefaultListConstructorMismatch extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_inferredType() async {
diff --git a/pkg/analyzer/test/src/diagnostics/default_value_on_required_parameter_test.dart b/pkg/analyzer/test/src/diagnostics/default_value_on_required_parameter_test.dart
index c8d20cd..8dc7e2f 100644
--- a/pkg/analyzer/test/src/diagnostics/default_value_on_required_parameter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/default_value_on_required_parameter_test.dart
@@ -19,7 +19,7 @@
class DefaultValueOnRequiredParameterTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_notRequired_default() async {
diff --git a/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart b/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
index 0c5caf1..cd3bfdb 100644
--- a/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
@@ -3,11 +3,10 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/source.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../generated/resolver_test_case.dart';
+import '../dart/resolution/driver_resolution.dart';
main() {
defineReflectiveSuite(() {
@@ -17,19 +16,20 @@
}
@reflectiveTest
-class DeprecatedMemberUseFromSamePackageTest extends ResolverTestCase {
+class DeprecatedMemberUseFromSamePackageTest extends DriverResolutionTest {
test_basicWorkspace() async {
- addNamedSource('/workspace/lib/deprecated_library.dart', r'''
+ newFile('/workspace/lib/deprecated_library.dart', content: r'''
@deprecated
library deprecated_library;
class A {}
''');
- await assertErrorsInCode(r'''
+ await assertErrorsInFile('/workspace/lib/test.dart', r'''
import 'deprecated_library.dart';
f(A a) {}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE],
- sourceName: '/workspace/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 0, 33),
+ ]);
}
test_bazelWorkspace() async {
@@ -37,17 +37,18 @@
newFile('/workspace/project/BUILD');
newFolder('/workspace/bazel-genfiles');
- addNamedSource('/workspace/project/lib/deprecated_library.dart', r'''
+ newFile('/workspace/project/lib/deprecated_library.dart', content: r'''
@deprecated
library deprecated_library;
class A {}
''');
- await assertErrorsInCode(r'''
+ await assertErrorsInFile('/workspace/project/lib/lib1.dart', r'''
import 'deprecated_library.dart';
f(A a) {}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE],
- sourceName: '/workspace/project/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 0, 33),
+ ]);
}
test_call() async {
@@ -60,7 +61,9 @@
a();
}
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 67, 3),
+ ]);
}
test_compoundAssignment() async {
@@ -73,18 +76,22 @@
A b;
a += b;
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 77, 6),
+ ]);
}
test_export() async {
- addNamedSource("/deprecated_library.dart", r'''
+ newFile("/test/lib/deprecated_library.dart", content: r'''
@deprecated
library deprecated_library;
class A {}
''');
await assertErrorsInCode('''
export 'deprecated_library.dart';
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 0, 33),
+ ]);
}
test_field() async {
@@ -96,7 +103,9 @@
f(A a) {
return a.x;
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 59, 1),
+ ]);
}
test_getter() async {
@@ -108,7 +117,9 @@
f(A a) {
return a.m;
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 60, 1),
+ ]);
}
test_gnWorkspace() async {
@@ -121,29 +132,33 @@
'FUCHSIA_BUILD_DIR=$buildDir\n');
newFile('/workspace/out/debug-x87_128/dartlang/gen/project/foo.packages');
- addNamedSource('/workspace/project/lib/deprecated_library.dart', r'''
+ newFile('/workspace/project/lib/deprecated_library.dart', content: r'''
@deprecated
library deprecated_library;
class A {}
''');
- await assertErrorsInCode(r'''
+ await assertErrorsInFile('/workspace/project/lib/lib1.dart', r'''
import 'deprecated_library.dart';
f(A a) {}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE],
- sourceName: '/workspace/project/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 0, 33),
+ ]);
}
test_import() async {
- addNamedSource("/deprecated_library.dart", r'''
+ newFile("/test/lib/deprecated_library.dart", content: r'''
@deprecated
library deprecated_library;
class A {}
''');
+
await assertErrorsInCode(r'''
import 'deprecated_library.dart';
f(A a) {}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 0, 33),
+ ]);
}
test_inDeprecatedClass() async {
@@ -262,7 +277,9 @@
f(A a) {
return a[1];
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 67, 4),
+ ]);
}
test_instanceCreation_defaultConstructor() async {
@@ -272,9 +289,11 @@
A(int i) {}
}
f() {
- A a = new A(1);
+ return new A(1);
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 55, 8),
+ ]);
}
test_instanceCreation_namedConstructor() async {
@@ -284,9 +303,11 @@
A.named(int i) {}
}
f() {
- A a = new A.named(1);
+ return new A.named(1);
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 61, 14),
+ ]);
}
test_methodInvocation_constant() async {
@@ -294,9 +315,13 @@
class A {
@deprecated
m() {}
- n() {m();}
+ n() {
+ m();
+ }
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 45, 1),
+ ]);
}
test_methodInvocation_constructor() async {
@@ -306,7 +331,10 @@
m() {}
n() {m();}
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE]);
+''', [
+ error(
+ HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE, 47, 1),
+ ]);
}
test_operator() async {
@@ -315,11 +343,12 @@
@deprecated
operator+(A a) {}
}
-f(A a) {
- A b;
+f(A a, A b) {
return a + b;
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 69, 5),
+ ]);
}
test_packageBuildWorkspace() async {
@@ -327,17 +356,18 @@
newFileWithBytes('/workspace/pubspec.yaml', 'name: project'.codeUnits);
newFileWithBytes('/workspace/.packages', 'project:lib/'.codeUnits);
- addNamedSource('/workspace/lib/deprecated_library.dart', r'''
+ newFile('/workspace/lib/deprecated_library.dart', content: r'''
@deprecated
library deprecated_library;
class A {}
''');
- await assertErrorsInCode(r'''
+ await assertErrorsInFile('/workspace/lib/lib1.dart', r'''
import 'deprecated_library.dart';
f(A a) {}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE],
- sourceName: '/workspace/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 0, 33),
+ ]);
}
test_parameter_named() async {
@@ -346,7 +376,9 @@
m({@deprecated int x}) {}
n() {m(x: 1);}
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 47, 1),
+ ]);
}
test_parameter_named_inDefiningFunction() async {
@@ -397,7 +429,9 @@
m([@deprecated int x]) {}
n() {m(1);}
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 47, 1),
+ ]);
}
test_setter() async {
@@ -409,7 +443,9 @@
f(A a) {
return a.s = 1;
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 60, 1),
+ ]);
}
test_superConstructor_defaultConstructor() async {
@@ -421,7 +457,9 @@
class B extends A {
B() : super() {}
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 63, 7),
+ ]);
}
test_superConstructor_namedConstructor() async {
@@ -433,22 +471,22 @@
class B extends A {
B() : super.named() {}
}
-''', [HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE]);
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE, 69, 13),
+ ]);
}
}
@reflectiveTest
-class DeprecatedMemberUseTest extends ResolverTestCase {
+class DeprecatedMemberUseTest extends DriverResolutionTest {
/// Write a pubspec file at [root], so that BestPracticesVerifier can see that
/// [root] is the root of a PubWorkspace, and a PubWorkspacePackage.
void newPubPackage(String root) {
newFile('$root/pubspec.yaml');
}
- void resetWithFooLibrary(String source) {
- super.resetWith(packages: [
- ['foo', source]
- ]);
+ void resetWithFooLibrary(String content) {
+ newFile('/aaa/lib/a.dart', content: content);
}
test_basicWorkspace() async {
@@ -459,11 +497,11 @@
''');
await assertErrorsInCode(r'''
-import 'package:foo/foo.dart';
+import 'package:aaa/a.dart';
f(A a) {}
-''', // This is a cross-package deprecated member usage.
- [HintCode.DEPRECATED_MEMBER_USE],
- sourceName: '/workspace/project/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE, 0, 28),
+ ]);
}
test_bazelWorkspace() async {
@@ -477,12 +515,12 @@
newFile('/workspace/project/BUILD');
newFolder('/workspace/bazel-genfiles');
- await assertErrorsInCode(r'''
-import 'package:foo/foo.dart';
+ await assertErrorsInFile('/workspace/project/lib/lib1.dart', r'''
+import 'package:aaa/a.dart';
f(A a) {}
-''', // This is a cross-package deprecated member usage.
- [HintCode.DEPRECATED_MEMBER_USE],
- sourceName: '/workspace/project/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE, 0, 28),
+ ]);
}
test_bazelWorkspace_sameWorkspace() async {
@@ -491,18 +529,18 @@
newFile('/workspace/project_b/BUILD');
newFolder('/workspace/bazel-genfiles');
- addNamedSource('/workspace/project_a/lib/deprecated_library.dart', r'''
+ newFile('/workspace/project_a/lib/deprecated_library.dart', content: r'''
@deprecated
library deprecated_library;
class A {}
''');
- await assertErrorsInCode(r'''
+ await assertErrorsInFile('/workspace/project_b/lib/lib1.dart', r'''
import '../../project_a/lib/deprecated_library.dart';
f(A a) {}
-''', // This is a same-workspace, cross-package deprecated member usage.
- [HintCode.DEPRECATED_MEMBER_USE],
- sourceName: '/workspace/project_b/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE, 0, 53),
+ ]);
}
test_export() async {
@@ -513,9 +551,11 @@
''');
newPubPackage('/pkg1');
- await assertErrorsInCode('''
-export 'package:foo/foo.dart';
-''', [HintCode.DEPRECATED_MEMBER_USE], sourceName: '/pkg1/lib/lib1.dart');
+ await assertErrorsInFile('/pkg1/lib/lib1.dart', '''
+export 'package:aaa/a.dart';
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE, 0, 28),
+ ]);
}
test_fieldGet_implicitGetter() async {
@@ -527,11 +567,12 @@
''');
newPubPackage('/pkg1');
- await assertErrorsInCode(r'''
-import 'package:foo/foo.dart';
-void main() { var b = A().bob; }
-''', [HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE],
- sourceName: '/pkg1/lib/lib1.dart');
+ await assertErrorsInFile('/pkg1/lib/lib1.dart', r'''
+import 'package:aaa/a.dart';
+void main() { A().bob; }
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE, 47, 3),
+ ]);
}
test_fieldSet_implicitSetter() async {
@@ -543,11 +584,12 @@
''');
newPubPackage('/pkg1');
- await assertErrorsInCode(r'''
-import 'package:foo/foo.dart';
+ await assertErrorsInFile('/pkg1/lib/lib1.dart', r'''
+import 'package:aaa/a.dart';
void main() { A().bob = false; }
-''', [HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE],
- sourceName: '/pkg1/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE, 47, 3),
+ ]);
}
test_gnWorkspace() async {
@@ -566,12 +608,12 @@
'BAR=bar\n');
newFile('/workspace/out/debug-x87_128/dartlang/gen/project/foo.packages');
- await assertErrorsInCode(r'''
-import 'package:foo/foo.dart';
+ await assertErrorsInFile('/workspace/project/lib/lib1.dart', r'''
+import 'package:aaa/a.dart';
f(A a) {}
-''', // This is a cross-package deprecated member usage.
- [HintCode.DEPRECATED_MEMBER_USE],
- sourceName: '/workspace/project/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE, 0, 28),
+ ]);
}
test_gnWorkspace_sameWorkspace() async {
@@ -586,18 +628,18 @@
'FUCHSIA_BUILD_DIR=$buildDir\n');
newFile('/workspace/out/debug-x87_128/dartlang/gen/project_a/foo.packages');
- addNamedSource('/workspace/project_a/lib/deprecated_library.dart', r'''
+ newFile('/workspace/project_a/lib/deprecated_library.dart', content: r'''
@deprecated
library deprecated_library;
class A {}
''');
- await assertErrorsInCode(r'''
+ await assertErrorsInFile('/workspace/project_b/lib/lib1.dart', r'''
import '../../project_a/lib/deprecated_library.dart';
f(A a) {}
-''', // This is a same-workspace, cross-package deprecated member usage.
- [HintCode.DEPRECATED_MEMBER_USE],
- sourceName: '/workspace/project_b/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE, 0, 53),
+ ]);
}
test_import() async {
@@ -607,16 +649,11 @@
class A {}
''');
- newPubPackage('/pkg1');
- Source source = addNamedSource('/pkg1/lib/lib1.dart', r'''
-import 'package:foo/foo.dart';
+ await resolveTestCode(r'''
+import 'package:aaa/a.dart';
f(A a) {}
''');
- await computeAnalysisResult(source);
- assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
- this.verify([source]);
- TestAnalysisResult result = analysisResults[source];
- expect(result.errors[0].message, contains('package:foo/foo.dart'));
+ expect(result.errors[0].message, contains('package:aaa/a.dart'));
}
test_methodInvocation_constant() async {
@@ -627,11 +664,12 @@
}
''');
- newPubPackage('/pkg1');
await assertErrorsInCode(r'''
-import 'package:foo/foo.dart';
+import 'package:aaa/a.dart';
void main() => A().m();
-''', [HintCode.DEPRECATED_MEMBER_USE], sourceName: '/pkg1/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE, 48, 1),
+ ]);
}
test_methodInvocation_constructor() async {
@@ -642,12 +680,12 @@
}
''');
- newPubPackage('/pkg1');
await assertErrorsInCode(r'''
-import 'package:foo/foo.dart';
+import 'package:aaa/a.dart';
void main() => A().m();
-''', [HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE],
- sourceName: '/pkg1/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE, 48, 1),
+ ]);
}
test_packageBuildWorkspace() async {
@@ -659,12 +697,13 @@
newFolder('/workspace/.dart_tool/build/generated/project/lib');
newFileWithBytes('/workspace/pubspec.yaml', 'name: project'.codeUnits);
- await assertErrorsInCode(r'''
-import 'package:foo/foo.dart';
+
+ await assertErrorsInFile('/workspace/package/lib/lib1.dart', r'''
+import 'package:aaa/a.dart';
f(A a) {}
-''', // This is a cross-package deprecated member usage.
- [HintCode.DEPRECATED_MEMBER_USE],
- sourceName: '/workspace/package/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE, 0, 28),
+ ]);
}
test_setterInvocation_constructor() async {
@@ -675,11 +714,11 @@
}
''');
- newPubPackage('/pkg1');
await assertErrorsInCode(r'''
-import 'package:foo/foo.dart';
+import 'package:aaa/a.dart';
void main() { A().bob = false; }
-''', [HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE],
- sourceName: '/pkg1/lib/lib1.dart');
+''', [
+ error(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE, 47, 3),
+ ]);
}
}
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
index 93e0972..67ba274 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
@@ -332,7 +332,7 @@
class DuplicateDefinitionExtensionTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_extendedType_instance() async {
diff --git a/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart b/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
index 1859d26..784bb3e 100644
--- a/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
@@ -23,7 +23,7 @@
class ExtendsNonClassWithNnbdTest extends ExtendsNonClassTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_Never() async {
diff --git a/pkg/analyzer/test/src/diagnostics/extension_as_expression_test.dart b/pkg/analyzer/test/src/diagnostics/extension_as_expression_test.dart
index cd9731d..68d825d 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_as_expression_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_as_expression_test.dart
@@ -19,7 +19,7 @@
class ExtensionAsExpressionTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_prefixedIdentifier() async {
diff --git a/pkg/analyzer/test/src/diagnostics/extension_conflicting_static_and_instance_test.dart b/pkg/analyzer/test/src/diagnostics/extension_conflicting_static_and_instance_test.dart
index 10df3869..8749ea7 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_conflicting_static_and_instance_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_conflicting_static_and_instance_test.dart
@@ -19,7 +19,7 @@
class ExtensionConflictingStaticAndInstanceTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
CompileTimeErrorCode get _errorCode =>
diff --git a/pkg/analyzer/test/src/diagnostics/extension_declares_abstract_method_test.dart b/pkg/analyzer/test/src/diagnostics/extension_declares_abstract_method_test.dart
index 55c639f..fd46bfb 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_declares_abstract_method_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_declares_abstract_method_test.dart
@@ -19,7 +19,7 @@
class ExtensionDeclaresAbstractMethodTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_getter() async {
diff --git a/pkg/analyzer/test/src/diagnostics/extension_declares_constructor_test.dart b/pkg/analyzer/test/src/diagnostics/extension_declares_constructor_test.dart
index 6334a96..179288d 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_declares_constructor_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_declares_constructor_test.dart
@@ -19,7 +19,7 @@
class ExtensionDeclaresConstructorTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_named() async {
diff --git a/pkg/analyzer/test/src/diagnostics/extension_declares_field_test.dart b/pkg/analyzer/test/src/diagnostics/extension_declares_field_test.dart
index 416293a..0a02d01 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_declares_field_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_declares_field_test.dart
@@ -19,7 +19,7 @@
class ExtensionDeclaresFieldTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_multiple() async {
diff --git a/pkg/analyzer/test/src/diagnostics/extension_declares_member_of_object_test.dart b/pkg/analyzer/test/src/diagnostics/extension_declares_member_of_object_test.dart
index 399b525..d4b339e 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_declares_member_of_object_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_declares_member_of_object_test.dart
@@ -19,7 +19,7 @@
class ExtensionDeclaresMemberOfObjectTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_instance_differentKind() async {
diff --git a/pkg/analyzer/test/src/diagnostics/extension_override_access_to_static_member_test.dart b/pkg/analyzer/test/src/diagnostics/extension_override_access_to_static_member_test.dart
index 4ec538c..dd93759 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_override_access_to_static_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_override_access_to_static_member_test.dart
@@ -19,7 +19,7 @@
class ExtensionOverrideAccessToStaticMemberTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_getter() async {
diff --git a/pkg/analyzer/test/src/diagnostics/extension_override_argument_not_assignable_test.dart b/pkg/analyzer/test/src/diagnostics/extension_override_argument_not_assignable_test.dart
index cb87bf4..6235401 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_override_argument_not_assignable_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_override_argument_not_assignable_test.dart
@@ -20,7 +20,7 @@
class ExtensionOverrideArgumentNotAssignableTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_subtype() async {
@@ -72,7 +72,7 @@
extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0',
additionalFeatures: [Feature.extension_methods, Feature.non_nullable]);
diff --git a/pkg/analyzer/test/src/diagnostics/extension_override_with_cascade_test.dart b/pkg/analyzer/test/src/diagnostics/extension_override_with_cascade_test.dart
index b8bcd87..5905ad9 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_override_with_cascade_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_override_with_cascade_test.dart
@@ -19,7 +19,7 @@
class ExtensionOverrideWithCascadeTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_getter() async {
diff --git a/pkg/analyzer/test/src/diagnostics/extension_override_without_access_test.dart b/pkg/analyzer/test/src/diagnostics/extension_override_without_access_test.dart
index c2723b8..05ab324 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_override_without_access_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_override_without_access_test.dart
@@ -19,7 +19,7 @@
class ExtensionOverrideWithoutAccessTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_binaryExpression() async {
diff --git a/pkg/analyzer/test/src/diagnostics/final_not_initialized_test.dart b/pkg/analyzer/test/src/diagnostics/final_not_initialized_test.dart
index 3c0937a..1a5d422 100644
--- a/pkg/analyzer/test/src/diagnostics/final_not_initialized_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/final_not_initialized_test.dart
@@ -61,7 +61,7 @@
class FinalNotInitializedWithExtensionMethodsTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_static() async {
@@ -78,7 +78,7 @@
class FinalNotInitializedWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_field_noConstructor_initializer() async {
diff --git a/pkg/analyzer/test/src/diagnostics/implements_non_class_test.dart b/pkg/analyzer/test/src/diagnostics/implements_non_class_test.dart
index 176830e..b960e59 100644
--- a/pkg/analyzer/test/src/diagnostics/implements_non_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/implements_non_class_test.dart
@@ -23,7 +23,7 @@
class ImplementsNonClassWithNnbdTest extends ImplementsNonClassTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_Never() async {
diff --git a/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_return_type_test.dart b/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_return_type_test.dart
index c04d1b0..fa016e6 100644
--- a/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_return_type_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_return_type_test.dart
@@ -21,7 +21,7 @@
extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods])
..strictInference = true;
diff --git a/pkg/analyzer/test/src/diagnostics/instance_access_to_static_member_test.dart b/pkg/analyzer/test/src/diagnostics/instance_access_to_static_member_test.dart
index cd3cb61..7eb09d81 100644
--- a/pkg/analyzer/test/src/diagnostics/instance_access_to_static_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/instance_access_to_static_member_test.dart
@@ -24,7 +24,7 @@
extends InstanceAccessToStaticMemberTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_getter() async {
diff --git a/pkg/analyzer/test/src/diagnostics/instantiate_abstract_class_test.dart b/pkg/analyzer/test/src/diagnostics/instantiate_abstract_class_test.dart
new file mode 100644
index 0000000..560995d
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/instantiate_abstract_class_test.dart
@@ -0,0 +1,93 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(InstantiateAbstractClassTest);
+ });
+}
+
+@reflectiveTest
+class InstantiateAbstractClassTest extends DriverResolutionTest {
+ test_const_generic() async {
+ await assertErrorsInCode('''
+abstract class A<E> {
+ const A();
+}
+void f() {
+ var a = const A<int>();
+}''', [
+ error(HintCode.UNUSED_LOCAL_VARIABLE, 54, 1),
+ error(StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS, 64, 6),
+ ]);
+
+ assertType(findNode.instanceCreation('const A<int>'), 'A<int>');
+ }
+
+ test_const_simple() async {
+ await assertErrorsInCode('''
+abstract class A {
+ const A();
+}
+void f() {
+ A a = const A();
+}''', [
+ error(HintCode.UNUSED_LOCAL_VARIABLE, 49, 1),
+ error(StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS, 59, 1),
+ ]);
+ }
+
+ test_new_generic() async {
+ await assertErrorsInCode('''
+abstract class A<E> {}
+void f() {
+ new A<int>();
+}
+''', [
+ error(StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS, 40, 6),
+ ]);
+
+ assertType(findNode.instanceCreation('new A<int>'), 'A<int>');
+ }
+
+ test_new_nonGeneric() async {
+ await assertErrorsInCode('''
+abstract class A {}
+void f() {
+ new A();
+}
+''', [
+ error(StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS, 37, 1),
+ ]);
+ }
+
+ test_noKeyword_generic() async {
+ await assertErrorsInCode('''
+abstract class A<E> {}
+void f() {
+ A<int>();
+}
+''', [
+ error(StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS, 36, 6),
+ ]);
+
+ assertType(findNode.instanceCreation('A<int>'), 'A<int>');
+ }
+
+ test_noKeyword_nonGeneric() async {
+ await assertErrorsInCode('''
+abstract class A {}
+void f() {
+ A();
+}
+''', [
+ error(StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS, 33, 1),
+ ]);
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_extension_argument_count_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_extension_argument_count_test.dart
index 7556e86..c98d1d0 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_extension_argument_count_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_extension_argument_count_test.dart
@@ -19,7 +19,7 @@
class InvalidExtensionArgumentCountTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_many() async {
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_language_override_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_language_override_test.dart
new file mode 100644
index 0000000..f7b74a5
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/invalid_language_override_test.dart
@@ -0,0 +1,245 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/src/dart/error/hint_codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(BadDartLanguageOverrideTest);
+ });
+}
+
+@reflectiveTest
+class BadDartLanguageOverrideTest extends DriverResolutionTest {
+ test_correct_withMultipleWhitespace() async {
+ await assertNoErrorsInCode(r'''
+// @dart = 2.0
+int i = 0;
+''');
+ }
+
+ test_correct_withoutWhitespace() async {
+ await assertNoErrorsInCode(r'''
+//@dart=2.0
+int i = 0;
+''');
+ }
+
+ test_correct_withWhitespace() async {
+ await assertNoErrorsInCode(r'''
+// @dart = 2.0
+int i = 0;
+''');
+ }
+
+ test_embeddedInBlockComment() async {
+ await assertNoErrorsInCode(r'''
+/**
+ * // @dart = 2.0
+ */
+int i = 0;
+''');
+ }
+
+ test_embeddedInBlockComment_noLeadingAsterisk() async {
+ await assertNoErrorsInCode(r'''
+/* Big comment.
+// @dart = 2.0
+ */
+int i = 0;
+''');
+ }
+
+ test_invalidOverrideFollowsValidOverride() async {
+ await assertNoErrorsInCode(r'''
+// @dart = 2.0
+// comment.
+// @dart >= 2.0
+int i = 0;
+''');
+ }
+
+ test_missingAtSign() async {
+ await assertErrorsInCode(r'''
+// dart = 2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN, 0, 13)]);
+ }
+
+ test_missingSeparator() async {
+ await assertErrorsInCode(r'''
+// @dart 2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS, 0, 12)]);
+ }
+
+ test_nonVersionOverride_atDart2js() async {
+ await assertNoErrorsInCode(r'''
+/// @dart2js.
+int i = 0;
+''');
+ }
+
+ test_nonVersionOverride_dart2js() async {
+ await assertNoErrorsInCode(r'''
+/// dart2js.
+int i = 0;
+''');
+ }
+
+ test_nonVersionOverride_empty() async {
+ await assertNoErrorsInCode(r'''
+///
+int i = 0;
+''');
+ }
+
+ test_nonVersionOverride_noNumbers() async {
+ await assertNoErrorsInCode(r'''
+// @dart
+int i = 0;
+''');
+ }
+
+ test_nonVersionOverride_noSeparatorOrNumber() async {
+ await assertNoErrorsInCode(r'''
+/// dart is great.
+int i = 0;
+''');
+ }
+
+ test_nonVersionOverride_onlyWhitespace() async {
+ await assertNoErrorsInCode(r'''
+///
+
+int i = 0;
+''');
+ }
+
+ test_nonVersionOverride_otherText() async {
+ await assertNoErrorsInCode(r'''
+// @dart is great
+int i = 0;
+''');
+ }
+
+ test_noWhitespace() async {
+ await assertNoErrorsInCode(r'''
+//@dart=2.0
+int i = 0;
+''');
+ }
+
+ test_separatorIsTooLong() async {
+ await assertErrorsInCode(r'''
+// @dart >= 2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS, 0, 15)]);
+ }
+
+ test_shebangLine() async {
+ await assertNoErrorsInCode(r'''
+#!/usr/bin/dart
+// @dart = 2.0
+int i = 0;
+''');
+ }
+
+ test_shebangLine_wrongCase() async {
+ await assertErrorsInCode(r'''
+#!/usr/bin/dart
+// @Dart = 2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE, 16, 14)]);
+ }
+
+ test_tooManySlashes() async {
+ await assertErrorsInCode(r'''
+/// @dart = 2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_TWO_SLASHES, 0, 15)]);
+ }
+
+ test_wrongAtSignPosition() async {
+ await assertErrorsInCode(r'''
+// dart @ 2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_AT_SIGN, 0, 13)]);
+ }
+
+ test_wrongCase_firstComment() async {
+ await assertErrorsInCode(r'''
+// @Dart = 2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE, 0, 14)]);
+ }
+
+ test_wrongCase_multilineComment() async {
+ await assertErrorsInCode(r'''
+// Copyright
+// @Dart = 2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE, 13, 14)]);
+ }
+
+ test_wrongCase_secondComment() async {
+ await assertErrorsInCode(r'''
+// Copyright
+
+// @Dart = 2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_LOWER_CASE, 14, 14)]);
+ }
+
+ test_wrongSeparator_noSpace() async {
+ await assertErrorsInCode(r'''
+// @dart:2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS, 0, 12)]);
+ }
+
+ test_wrongSeparator_withSpace() async {
+ await assertErrorsInCode(r'''
+// @dart : 2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_EQUALS, 0, 14)]);
+ }
+
+ test_wrongVersion_extraSpecificity() async {
+ await assertErrorsInCode(r'''
+// @dart = 2.0.0
+int i = 0;
+''', [
+ error(
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS, 0, 16)
+ ]);
+ }
+
+ test_wrongVersion_noMinorVersion() async {
+ await assertErrorsInCode(r'''
+// @dart = 2
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_NUMBER, 0, 12)]);
+ }
+
+ test_wrongVersion_prefixCharacter() async {
+ await assertErrorsInCode(r'''
+// @dart = v2.0
+int i = 0;
+''', [error(HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_PREFIX, 0, 15)]);
+ }
+
+ test_wrongVersion_tooManyDigits() async {
+ await assertErrorsInCode(r'''
+// @dart = 2.00
+int i = 0;
+''', [
+ error(
+ HintCode.INVALID_LANGUAGE_VERSION_OVERRIDE_TRAILING_CHARACTERS, 0, 15)
+ ]);
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_optional_parameter_type_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_optional_parameter_type_test.dart
index 51ad294..93b2d26 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_optional_parameter_type_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_optional_parameter_type_test.dart
@@ -11,18 +11,96 @@
main() {
defineReflectiveSuite(() {
- defineReflectiveTests(MissingDefaultValueForParameterTest);
+ defineReflectiveTests(InvalidOptionalParameterTypeTest);
});
}
@reflectiveTest
-class MissingDefaultValueForParameterTest extends DriverResolutionTest {
+class InvalidOptionalParameterTypeTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
- test_typeParameter_potentiallyNonNullable_named_optional_noDefault() async {
+ test_fieldFormalParameter_named_optional() async {
+ await assertErrorsInCode('''
+class A {
+ dynamic f;
+ A(void this.f({int a, int? b}));
+}
+''', [
+ error(CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE, 44, 1),
+ ]);
+ }
+
+ test_fieldFormalParameter_positional_optional() async {
+ await assertErrorsInCode('''
+class A {
+ dynamic f;
+ A(void this.f([int a, int? b]));
+}
+''', [
+ error(CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE, 44, 1),
+ ]);
+ }
+
+ test_functionTypeAlias_named_optional() async {
+ await assertErrorsInCode('''
+typedef void F({int a, int? b});
+''', [
+ error(CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE, 20, 1),
+ ]);
+ }
+
+ test_functionTypeAlias_positional_optional() async {
+ await assertErrorsInCode('''
+typedef void F([int a, int? b]);
+''', [
+ error(CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE, 20, 1),
+ ]);
+ }
+
+ test_functionTypedFormalParameter_named_optional() async {
+ await assertErrorsInCode('''
+void f(void p({int a, int? b})) {}
+''', [
+ error(CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE, 19, 1),
+ ]);
+ }
+
+ test_functionTypedFormalParameter_positional_optional() async {
+ await assertErrorsInCode('''
+void f(void p([int a, int? b])) {}
+''', [
+ error(CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE, 19, 1),
+ ]);
+ }
+
+ test_genericFunctionType_named_optional() async {
+ await assertErrorsInCode('''
+void f(void Function({int a, int? b}) p) {}
+''', [
+ error(CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE, 26, 1),
+ ]);
+ }
+
+ test_genericFunctionType_positional_optional() async {
+ await assertErrorsInCode('''
+void f(void Function([int a, int? b]) p) {}
+''', [
+ error(CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE, 26, 1),
+ ]);
+ }
+
+ test_genericFunctionType_positional_optional2() async {
+ await assertErrorsInCode('''
+void f(void Function([int, int?]) p) {}
+''', [
+ error(CompileTimeErrorCode.INVALID_OPTIONAL_PARAMETER_TYPE, 22, 3),
+ ]);
+ }
+
+ test_typeParameter_potentiallyNonNullable_named_optional() async {
await assertErrorsInCode('''
class A<T extends Object?> {
void f({T a}) {}
@@ -32,7 +110,7 @@
]);
}
- test_typeParameter_potentiallyNonNullable_positional_optional_noDefault() async {
+ test_typeParameter_potentiallyNonNullable_positional_optional() async {
await assertErrorsInCode('''
class A<T extends Object?> {
void f([T a]) {}
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_use_of_covariant_in_extension_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_use_of_covariant_in_extension_test.dart
index eef240a..48d6ac3 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_use_of_covariant_in_extension_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_use_of_covariant_in_extension_test.dart
@@ -19,7 +19,7 @@
class InvalidUseOfCovariantInExtensionTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_optional_named() async {
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_use_of_protected_member_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_use_of_protected_member_test.dart
index bd33642..373c11e 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_use_of_protected_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_use_of_protected_member_test.dart
@@ -440,7 +440,7 @@
extends InvalidUseOfProtectedMemberTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_extension_outsideClassAndFile() async {
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_template_member_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_template_member_test.dart
index 35f8b17..1a14f52 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_template_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_template_member_test.dart
@@ -261,7 +261,7 @@
extends InvalidUseOfVisibleForTemplateMemberTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_functionInExtension() async {
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_testing_member_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_testing_member_test.dart
index 97e5d82..07e7f4b 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_testing_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_testing_member_test.dart
@@ -22,7 +22,7 @@
with PackageMixin {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_unnamedConstructor() async {
@@ -298,7 +298,7 @@
extends InvalidUseOfVisibleForTestingMemberTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_functionInExtension() async {
diff --git a/pkg/analyzer/test/src/diagnostics/invocation_of_extension_without_call_test.dart b/pkg/analyzer/test/src/diagnostics/invocation_of_extension_without_call_test.dart
index 8708381..ec1bdbb 100644
--- a/pkg/analyzer/test/src/diagnostics/invocation_of_extension_without_call_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invocation_of_extension_without_call_test.dart
@@ -19,7 +19,7 @@
class InvocationOfExtensionWithoutCallTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_instance_differentKind() async {
diff --git a/pkg/analyzer/test/src/diagnostics/late_final_field_with_const_constructor_test.dart b/pkg/analyzer/test/src/diagnostics/late_final_field_with_const_constructor_test.dart
new file mode 100644
index 0000000..58d3572
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/late_final_field_with_const_constructor_test.dart
@@ -0,0 +1,79 @@
+// Copyright (c) 2019, 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.
+
+import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/src/error/codes.dart';
+import 'package:analyzer/src/generated/engine.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(LateFinalFieldWithConstConstructorTest);
+ });
+}
+
+@reflectiveTest
+class LateFinalFieldWithConstConstructorTest extends DriverResolutionTest {
+ static const _errorCode =
+ CompileTimeErrorCode.LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR;
+
+ @override
+ AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+ ..contextFeatures = FeatureSet.forTesting(
+ sdkVersion: '2.6.0', additionalFeatures: [Feature.non_nullable]);
+
+ test_class_hasConstConstructor_instance_hasInitializer() async {
+ await assertErrorsInCode('''
+class A {
+ late final f = 0;
+ const A();
+}
+''', [
+ error(_errorCode, 12, 4),
+ ]);
+ }
+
+ test_class_hasConstConstructor_instance_hasNotConst() async {
+ await assertErrorsInCode('''
+class A {
+ late final f = 0;
+ const A();
+ A.notConst();
+}
+''', [
+ error(_errorCode, 12, 4),
+ ]);
+ }
+
+ test_class_hasConstConstructor_instance_noInitializer() async {
+ await assertErrorsInCode('''
+class A {
+ late final f;
+ const A();
+}
+''', [
+ error(_errorCode, 12, 4),
+ ]);
+ }
+
+ test_class_hasConstConstructor_static_late_final() async {
+ await assertNoErrorsInCode('''
+class A {
+ static late final f = 0;
+ const A();
+}
+''');
+ }
+
+ test_class_noConstConstructor() async {
+ await assertNoErrorsInCode('''
+class A {
+ late final f = 0;
+ A();
+}
+''');
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/mismatched_getter_and_setter_types_test.dart b/pkg/analyzer/test/src/diagnostics/mismatched_getter_and_setter_types_test.dart
index d4c8ccd..56f83cc 100644
--- a/pkg/analyzer/test/src/diagnostics/mismatched_getter_and_setter_types_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mismatched_getter_and_setter_types_test.dart
@@ -34,7 +34,7 @@
extends MismatchedGetterAndSetterTypesTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_extensionMembers_instance() async {
@@ -65,7 +65,7 @@
extends MismatchedGetterAndSetterTypesTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_classMembers_instance() async {
diff --git a/pkg/analyzer/test/src/diagnostics/missing_default_value_for_parameter_test.dart b/pkg/analyzer/test/src/diagnostics/missing_default_value_for_parameter_test.dart
index 4574d92..caa5841 100644
--- a/pkg/analyzer/test/src/diagnostics/missing_default_value_for_parameter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/missing_default_value_for_parameter_test.dart
@@ -19,7 +19,7 @@
class MissingDefaultValueForParameterTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_class_nonNullable_named_optional_default() async {
@@ -108,27 +108,6 @@
''');
}
- test_fieldFormalParameter() async {
- await assertNoErrorsInCode('''
-class A {
- final log;
- A(void this.log({String s})) {}
-}
-''');
- }
-
- test_functionTypeAlias() async {
- await assertNoErrorsInCode('''
-typedef void log({String});
-''');
- }
-
- test_functionTypedParameter() async {
- await assertNoErrorsInCode('''
-void printToLog(void log({String})) {}
-''');
- }
-
test_futureOr_nonNullable_nonNullable_named_optional_default() async {
await assertNoErrorsInCode('''
import 'dart:async';
@@ -301,12 +280,6 @@
''');
}
- test_genericFunctionType() async {
- await assertNoErrorsInCode('''
-void Function({String s})? log;
-''');
- }
-
test_typeParameter_nullable_named_optional_default() async {
await assertNoErrorsInCode('''
class A<T extends Object?> {
diff --git a/pkg/analyzer/test/src/diagnostics/missing_required_param_test.dart b/pkg/analyzer/test/src/diagnostics/missing_required_param_test.dart
index d2bd02d..8672d46 100644
--- a/pkg/analyzer/test/src/diagnostics/missing_required_param_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/missing_required_param_test.dart
@@ -232,7 +232,7 @@
class MissingRequiredParamWithNnbdTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_constructor_argumentGiven() async {
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
index 6e5666d..7856157 100644
--- a/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
@@ -23,7 +23,7 @@
class MixinOfNonClassWithNnbdTest extends MixinOfNonClassTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_Never() async {
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_super_class_constraint_non_interface_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_super_class_constraint_non_interface_test.dart
index 07fbff3..cb304c57 100644
--- a/pkg/analyzer/test/src/diagnostics/mixin_super_class_constraint_non_interface_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mixin_super_class_constraint_non_interface_test.dart
@@ -24,7 +24,7 @@
extends MixinSuperClassConstraintNonInterfaceTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
test_Never() async {
diff --git a/pkg/analyzer/test/src/diagnostics/new_with_abstract_class_test.dart b/pkg/analyzer/test/src/diagnostics/new_with_abstract_class_test.dart
deleted file mode 100644
index 4350613..0000000
--- a/pkg/analyzer/test/src/diagnostics/new_with_abstract_class_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2019, 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.
-
-import 'package:analyzer/src/error/codes.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../dart/resolution/driver_resolution.dart';
-
-main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(NewWithAbstractClassTest);
- });
-}
-
-@reflectiveTest
-class NewWithAbstractClassTest extends DriverResolutionTest {
- test_generic() async {
- await assertErrorsInCode('''
-abstract class A<E> {}
-void f() {
- new A<int>();
-}
-''', [
- error(StaticWarningCode.NEW_WITH_ABSTRACT_CLASS, 40, 6),
- ]);
-
- assertType(findNode.instanceCreation('new A<int>'), 'A<int>');
- }
-
- test_nonGeneric() async {
- await assertErrorsInCode('''
-abstract class A {}
-void f() {
- new A();
-}
-''', [
- error(StaticWarningCode.NEW_WITH_ABSTRACT_CLASS, 37, 1),
- ]);
- }
-}
diff --git a/pkg/analyzer/test/src/diagnostics/non_null_opt_out_test.dart b/pkg/analyzer/test/src/diagnostics/non_null_opt_out_test.dart
index 546aea3..4030ba4 100644
--- a/pkg/analyzer/test/src/diagnostics/non_null_opt_out_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_null_opt_out_test.dart
@@ -25,7 +25,7 @@
class NonNullOptOutTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.6.0', additionalFeatures: [Feature.non_nullable]);
@override
diff --git a/pkg/analyzer/test/src/diagnostics/not_a_type_test.dart b/pkg/analyzer/test/src/diagnostics/not_a_type_test.dart
index d6af0b2..8f474bc 100644
--- a/pkg/analyzer/test/src/diagnostics/not_a_type_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/not_a_type_test.dart
@@ -34,7 +34,7 @@
class NotATypeWithExtensionMethodsTest extends NotATypeTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_extension() async {
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart
index e19ac7b..c9db85b 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart
@@ -19,7 +19,7 @@
class SdkVersionNeverTest extends SdkConstraintVerifierTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
@failingTest
diff --git a/pkg/analyzer/test/src/diagnostics/static_access_to_instance_member_test.dart b/pkg/analyzer/test/src/diagnostics/static_access_to_instance_member_test.dart
index f117889..616bd4e 100644
--- a/pkg/analyzer/test/src/diagnostics/static_access_to_instance_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/static_access_to_instance_member_test.dart
@@ -84,7 +84,7 @@
extends StaticAccessToInstanceMemberTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_getter() async {
diff --git a/pkg/analyzer/test/src/diagnostics/strict_raw_type_test.dart b/pkg/analyzer/test/src/diagnostics/strict_raw_type_test.dart
index 90f4c84..4ebefec 100644
--- a/pkg/analyzer/test/src/diagnostics/strict_raw_type_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/strict_raw_type_test.dart
@@ -22,7 +22,7 @@
with PackageMixin {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods])
..strictRawTypes = true;
diff --git a/pkg/analyzer/test/src/diagnostics/super_in_extension_test.dart b/pkg/analyzer/test/src/diagnostics/super_in_extension_test.dart
index 3b26ce9..50c932c 100644
--- a/pkg/analyzer/test/src/diagnostics/super_in_extension_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/super_in_extension_test.dart
@@ -19,7 +19,7 @@
class SuperInExtensionTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_binaryOperator_inMethod() async {
diff --git a/pkg/analyzer/test/src/diagnostics/test_all.dart b/pkg/analyzer/test/src/diagnostics/test_all.dart
index d7b3a4f..fda3c31 100644
--- a/pkg/analyzer/test/src/diagnostics/test_all.dart
+++ b/pkg/analyzer/test/src/diagnostics/test_all.dart
@@ -23,6 +23,8 @@
import 'assignment_to_type_test.dart' as assignment_to_type;
import 'async_keyword_used_as_identifier_test.dart'
as async_keyword_used_as_identifier;
+import 'await_in_late_local_variable_initializer_test.dart'
+ as await_in_late_local_variable_initializer;
import 'builtin_identifier_as_extension_name_test.dart'
as builtin_as_extension_name;
import 'can_be_null_after_null_aware_test.dart' as can_be_null_after_null_aware;
@@ -47,7 +49,6 @@
import 'const_spread_expected_list_or_set_test.dart'
as const_spread_expected_list_or_set;
import 'const_spread_expected_map_test.dart' as const_spread_expected_map;
-import 'const_with_abstract_class_test.dart' as const_with_abstract_class;
import 'dead_code_test.dart' as dead_code;
import 'default_list_constructor_mismatch_test.dart'
as default_list_constructor_mismatch;
@@ -129,6 +130,7 @@
as inference_failure_on_untyped_parameter;
import 'instance_access_to_static_member_test.dart'
as instance_access_to_static_member;
+import 'instantiate_abstract_class_test.dart' as instantiate_abstract_class;
import 'invalid_assignment_test.dart' as invalid_assignment;
import 'invalid_cast_new_expr_test.dart' as invalid_cast_new_expr;
import 'invalid_exception_value_test.dart' as invalid_exception_value;
@@ -138,6 +140,7 @@
import 'invalid_factory_method_impl_test.dart' as invalid_factory_method_impl;
import 'invalid_field_type_in_struct_test.dart' as invalid_field_type_in_struct;
import 'invalid_immutable_annotation_test.dart' as invalid_immutable_annotation;
+import 'invalid_language_override_test.dart' as invalid_language_override;
import 'invalid_literal_annotation_test.dart' as invalid_literal_annotation;
import 'invalid_non_virtual_annotation_test.dart'
as invalid_non_virtual_annotation;
@@ -175,6 +178,8 @@
import 'is_int_test.dart' as is_int;
import 'is_not_double_test.dart' as is_not_double;
import 'is_not_int_test.dart' as is_not_int;
+import 'late_final_field_with_const_constructor_test.dart'
+ as late_final_field_with_const_constructor;
import 'list_element_type_not_assignable_test.dart'
as list_element_type_not_assignable;
import 'map_entry_not_in_map_test.dart' as map_entry_not_in_map;
@@ -205,7 +210,6 @@
import 'must_be_a_subtype_test.dart' as must_be_a_subtype;
import 'must_be_immutable_test.dart' as must_be_immutable;
import 'must_call_super_test.dart' as must_call_super;
-import 'new_with_abstract_class_test.dart' as new_with_abstract_class;
import 'new_with_invalid_type_parameters_test.dart'
as new_with_invalid_type_parameters;
import 'new_with_non_type_test.dart' as new_with_non_type;
@@ -384,6 +388,7 @@
assignment_to_method.main();
assignment_to_type.main();
async_keyword_used_as_identifier.main();
+ await_in_late_local_variable_initializer.main();
builtin_as_extension_name.main();
can_be_null_after_null_aware.main();
case_block_not_terminated.main();
@@ -399,7 +404,6 @@
const_set_element_type_implements_equals.main();
const_spread_expected_list_or_set.main();
const_spread_expected_map.main();
- const_with_abstract_class.main();
dead_code.main();
default_list_constructor_mismatch.main();
default_value_on_required_paramter.main();
@@ -453,6 +457,7 @@
inference_failure_on_uninitialized_variable.main();
inference_failure_on_untyped_parameter.main();
instance_access_to_static_member.main();
+ instantiate_abstract_class.main();
invalid_assignment.main();
invalid_cast_new_expr.main();
invalid_exception_value.main();
@@ -461,6 +466,7 @@
invalid_factory_method_impl.main();
invalid_field_type_in_struct.main();
invalid_immutable_annotation.main();
+ invalid_language_override.main();
invalid_literal_annotation.main();
invalid_non_virtual_annotation.main();
invalid_optional_parameter_type.main();
@@ -485,6 +491,7 @@
is_int.main();
is_not_double.main();
is_not_int.main();
+ late_final_field_with_const_constructor.main();
list_element_type_not_assignable.main();
map_entry_not_in_map.main();
map_key_type_not_assignable.main();
@@ -507,7 +514,6 @@
must_be_a_subtype.main();
must_be_immutable.main();
must_call_super.main();
- new_with_abstract_class.main();
new_with_invalid_type_parameters.main();
new_with_non_type.main();
new_with_undefined_constructor.main();
diff --git a/pkg/analyzer/test/src/diagnostics/type_argument_not_matching_bounds_test.dart b/pkg/analyzer/test/src/diagnostics/type_argument_not_matching_bounds_test.dart
index e1c52d5..3d7be0e 100644
--- a/pkg/analyzer/test/src/diagnostics/type_argument_not_matching_bounds_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/type_argument_not_matching_bounds_test.dart
@@ -314,7 +314,7 @@
extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_extensionOverride_hasTypeArguments() async {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_extension_getter_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_extension_getter_test.dart
index 1eb33a7..22b8d9e 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_extension_getter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_extension_getter_test.dart
@@ -19,7 +19,7 @@
class UndefinedExtensionGetterTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_override_defined() async {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_extension_method_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_extension_method_test.dart
index 4ac7029..29eab14 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_extension_method_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_extension_method_test.dart
@@ -19,7 +19,7 @@
class UndefinedExtensionMethodTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_method_defined() async {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_extension_operator_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_extension_operator_test.dart
index b2c5f28..8d219b4 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_extension_operator_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_extension_operator_test.dart
@@ -19,7 +19,7 @@
class UndefinedExtensionMethodTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_binary_defined() async {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_extension_setter_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_extension_setter_test.dart
index a80bc83..7a2e805 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_extension_setter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_extension_setter_test.dart
@@ -19,7 +19,7 @@
class UndefinedExtensionSetterTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_override_defined() async {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_getter_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_getter_test.dart
index 92f90de..fb333fb 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_getter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_getter_test.dart
@@ -173,7 +173,7 @@
class UndefinedGetterWithExtensionMethodsTest extends UndefinedGetterTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_instance_extendedHasSetter_extensionHasGetter() async {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart
index 502c6a3..9c2ffa7 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart
@@ -155,6 +155,6 @@
class UndefinedIdentifierWithNnbdTest extends UndefinedIdentifierTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.6.0', additionalFeatures: [Feature.non_nullable]);
}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart
index e0ba03f..c55d8bf 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart
@@ -23,7 +23,7 @@
class UndefinedMethodWithExtensionMethodsTest extends UndefinedMethodTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_withExtension() async {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart
index 188e474..c07e0ed 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart
@@ -256,7 +256,7 @@
extends UndefinedOperatorTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_index_get_extendedHasNone_extensionHasGetter() async {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart
index f1d7322..5e80417 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart
@@ -66,7 +66,7 @@
class UndefinedSetterWithExtensionMethodsTest extends UndefinedGetterTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_withExtension() async {
diff --git a/pkg/analyzer/test/src/diagnostics/unqualified_reference_to_static_member_of_extended_type_test.dart b/pkg/analyzer/test/src/diagnostics/unqualified_reference_to_static_member_of_extended_type_test.dart
index d8cd1da..9045535 100644
--- a/pkg/analyzer/test/src/diagnostics/unqualified_reference_to_static_member_of_extended_type_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unqualified_reference_to_static_member_of_extended_type_test.dart
@@ -20,7 +20,7 @@
extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_getter() async {
diff --git a/pkg/analyzer/test/src/diagnostics/unused_field_test.dart b/pkg/analyzer/test/src/diagnostics/unused_field_test.dart
index 2bb674f..81b2c5c 100644
--- a/pkg/analyzer/test/src/diagnostics/unused_field_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unused_field_test.dart
@@ -30,6 +30,48 @@
''');
}
+ test_isUsed_extensionOnClass() async {
+ await assertNoErrorsInCode(r'''
+class Foo {}
+extension Bar on Foo {
+ int baz() => _baz;
+ static final _baz = 7;
+}
+''');
+ }
+
+ test_isUsed_extensionOnEnum() async {
+ await assertNoErrorsInCode(r'''
+enum Foo {a, b}
+extension Bar on Foo {
+ int baz() => _baz;
+ static final _baz = 1;
+}
+''');
+ }
+
+ test_isUsed_mixin() async {
+ await assertNoErrorsInCode(r'''
+mixin M {
+ int _f = 0;
+}
+class Bar with M {
+ int g() => _f;
+}
+''');
+ }
+
+ test_isUsed_mixinRestriction() async {
+ await assertNoErrorsInCode(r'''
+class Foo {
+ int _f = 0;
+}
+mixin M on Foo {
+ int g() => _f;
+}
+''');
+ }
+
test_isUsed_parameterized_subclass() async {
await assertNoErrorsInCode(r'''
class A<T extends num> {
@@ -144,6 +186,17 @@
]);
}
+ test_notUsed_extensionOnClass() async {
+ await assertErrorsInCode(r'''
+class Foo {}
+extension Bar on Foo {
+ static final _baz = 7;
+}
+''', [
+ error(HintCode.UNUSED_FIELD, 51, 4),
+ ]);
+ }
+
test_notUsed_fieldFormalParameter() async {
await assertErrorsInCode(r'''
class A {
@@ -155,6 +208,28 @@
]);
}
+ test_notUsed_mixin() async {
+ await assertErrorsInCode(r'''
+mixin M {
+ int _f = 0;
+}
+class Bar with M {}
+''', [
+ error(HintCode.UNUSED_FIELD, 16, 2),
+ ]);
+ }
+
+ test_notUsed_mixinRestriction() async {
+ await assertErrorsInCode(r'''
+class Foo {
+ int _f = 0;
+}
+mixin M on Foo {}
+''', [
+ error(HintCode.UNUSED_FIELD, 18, 2),
+ ]);
+ }
+
test_notUsed_noReference() async {
await assertErrorsInCode(r'''
class A {
diff --git a/pkg/analyzer/test/src/diagnostics/unused_import_test.dart b/pkg/analyzer/test/src/diagnostics/unused_import_test.dart
index 19a7be4..2704321 100644
--- a/pkg/analyzer/test/src/diagnostics/unused_import_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unused_import_test.dart
@@ -232,7 +232,7 @@
class UnusedImportWithExtensionMethodsTest extends UnusedImportTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_instance_call() async {
diff --git a/pkg/analyzer/test/src/diagnostics/unused_shown_name_test.dart b/pkg/analyzer/test/src/diagnostics/unused_shown_name_test.dart
index 804b8d8..831e22c 100644
--- a/pkg/analyzer/test/src/diagnostics/unused_shown_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unused_shown_name_test.dart
@@ -85,7 +85,7 @@
class UnusedShownNameWithExtensionMethodsTest extends UnusedShownNameTest {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_instance_method_unused() async {
diff --git a/pkg/analyzer/test/src/fasta/message_coverage_test.dart b/pkg/analyzer/test/src/fasta/message_coverage_test.dart
index 18a62fd..80f9b29 100644
--- a/pkg/analyzer/test/src/fasta/message_coverage_test.dart
+++ b/pkg/analyzer/test/src/fasta/message_coverage_test.dart
@@ -29,10 +29,10 @@
* file.
*/
Set<String> getGeneratedNames(String parserPath) {
- String content = new io.File(parserPath).readAsStringSync();
+ String content = io.File(parserPath).readAsStringSync();
CompilationUnit unit = parseCompilationUnit(content);
expect(unit, isNotNull);
- GeneratedCodesVisitor visitor = new GeneratedCodesVisitor();
+ GeneratedCodesVisitor visitor = GeneratedCodesVisitor();
unit.accept(visitor);
return visitor.generatedNames;
}
@@ -42,10 +42,10 @@
* keys defined in that file that define an 'analyzerCode'.
*/
List<String> getMappedCodes(String messagesPath) {
- String content = new io.File(messagesPath).readAsStringSync();
+ String content = io.File(messagesPath).readAsStringSync();
YamlDocument document = loadYamlDocument(content);
expect(document, isNotNull);
- Set<String> codes = new Set<String>();
+ Set<String> codes = Set<String>();
YamlNode contents = document.contents;
if (contents is YamlMap) {
for (String name in contents.keys) {
@@ -65,10 +65,10 @@
* codes defined in that file.
*/
List<String> getReferencedCodes(String messagesPath) {
- String content = new io.File(messagesPath).readAsStringSync();
+ String content = io.File(messagesPath).readAsStringSync();
YamlDocument document = loadYamlDocument(content);
expect(document, isNotNull);
- Set<String> codes = new Set<String>();
+ Set<String> codes = Set<String>();
YamlNode contents = document.contents;
if (contents is YamlMap) {
for (String name in contents.keys) {
@@ -89,7 +89,7 @@
* return a list of the analyzer codes that are translated by the builder.
*/
List<String> getTranslatedCodes(String astBuilderPath) {
- String content = new io.File(astBuilderPath).readAsStringSync();
+ String content = io.File(astBuilderPath).readAsStringSync();
CompilationUnit unit = parseCompilationUnit(content);
ClassDeclaration astBuilder = unit.declarations[0];
expect(astBuilder, isNotNull);
@@ -126,7 +126,7 @@
return;
}
List<String> sortedNames = generatedNames.toList()..sort();
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.writeln('Generated parser errors without analyzer codes:');
for (String name in sortedNames) {
buffer.write(' ');
@@ -152,7 +152,7 @@
untranslated.add(referencedCode);
}
}
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
if (untranslated.isNotEmpty) {
buffer
.writeln('Analyzer codes used in messages.yaml but not translated:');
@@ -199,7 +199,7 @@
/**
* The names of the message codes that are generated in the visited AST.
*/
- Set<String> generatedNames = new Set<String>();
+ Set<String> generatedNames = Set<String>();
@override
visitPrefixedIdentifier(PrefixedIdentifier node) {
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/annotation_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/annotation_test.dart
index 74d995d..08ad180 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/annotation_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/annotation_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new AnnotationTest().buildAll();
+ AnnotationTest().buildAll();
}
class AnnotationTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'annotation_topLevel',
[
- new TestDescriptor(
+ TestDescriptor(
'ampersand',
'@',
[
@@ -24,7 +24,7 @@
],
'@_s_',
expectedErrorsInValidCode: [ParserErrorCode.EXPECTED_EXECUTABLE]),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'@a(',
[
@@ -39,7 +39,7 @@
buildTests(
'annotation_topLevel',
[
- new TestDescriptor(
+ TestDescriptor(
'ampersand', '@', [ParserErrorCode.MISSING_IDENTIFIER], '@_s_',
failing: [
'typedef',
@@ -48,7 +48,7 @@
'mixin',
'setter'
]),
- new TestDescriptor(
+ TestDescriptor(
'leftParen', '@a(', [ScannerErrorCode.EXPECTED_TOKEN], '@a()',
allFailing: true),
],
@@ -59,7 +59,7 @@
buildTests(
'annotation_classMember',
[
- new TestDescriptor(
+ TestDescriptor(
'ampersand',
'@',
[
@@ -68,7 +68,7 @@
],
'@_s_',
expectedErrorsInValidCode: [ParserErrorCode.EXPECTED_CLASS_MEMBER]),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'@a(',
[
@@ -85,10 +85,10 @@
buildTests(
'annotation_classMember',
[
- new TestDescriptor(
+ TestDescriptor(
'ampersand', '@', [ParserErrorCode.MISSING_IDENTIFIER], '@_s_',
failing: ['methodNonVoid', 'getter', 'setter']),
- new TestDescriptor(
+ TestDescriptor(
'leftParen', '@a(', [ScannerErrorCode.EXPECTED_TOKEN], '@a()',
allFailing: true),
],
@@ -101,7 +101,7 @@
buildTests(
'annotation_local',
[
- new TestDescriptor(
+ TestDescriptor(
'ampersand',
'@',
[
@@ -114,7 +114,7 @@
ParserErrorCode.MISSING_IDENTIFIER,
ParserErrorCode.EXPECTED_TOKEN
]),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'@a(',
[
@@ -152,10 +152,10 @@
buildTests(
'annotation_local',
[
- new TestDescriptor(
+ TestDescriptor(
'ampersand', '@', [ParserErrorCode.MISSING_IDENTIFIER], '@_s_',
failing: ['localFunctionNonVoid']),
- new TestDescriptor(
+ TestDescriptor(
'leftParen', '@a(', [ParserErrorCode.MISSING_IDENTIFIER], '@a()',
allFailing: true),
],
@@ -167,7 +167,7 @@
buildTests(
'annotation_local',
[
- new TestDescriptor(
+ TestDescriptor(
'ampersand',
'@',
[
@@ -181,7 +181,7 @@
ParserErrorCode.EXPECTED_TOKEN
],
failing: ['labeled']),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'@a(',
[
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/assert_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/assert_statement_test.dart
index 511b2cc..77e0a6a 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/assert_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/assert_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new AssertStatementTest().buildAll();
+ AssertStatementTest().buildAll();
}
class AssertStatementTest extends PartialCodeTest {
@@ -17,12 +17,12 @@
buildTests(
'assert_statement',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'assert',
[ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN],
"assert (_s_);"),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'assert (',
[
@@ -39,28 +39,28 @@
'localFunctionVoid',
'return'
]),
- new TestDescriptor(
+ TestDescriptor(
'condition',
'assert (a',
[ParserErrorCode.EXPECTED_TOKEN, ScannerErrorCode.EXPECTED_TOKEN],
"assert (a);"),
- new TestDescriptor(
+ TestDescriptor(
'comma',
'assert (a,',
[ScannerErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN],
"assert (a,);",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'message',
'assert (a, b',
[ParserErrorCode.EXPECTED_TOKEN, ScannerErrorCode.EXPECTED_TOKEN],
"assert (a, b);"),
- new TestDescriptor(
+ TestDescriptor(
'trailingComma',
'assert (a, b,',
[ParserErrorCode.EXPECTED_TOKEN, ScannerErrorCode.EXPECTED_TOKEN],
"assert (a, b,);"),
- new TestDescriptor('rightParen', 'assert (a, b)',
+ TestDescriptor('rightParen', 'assert (a, b)',
[ParserErrorCode.EXPECTED_TOKEN], "assert (a, b);"),
],
PartialCodeTest.statementSuffixes,
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/break_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/break_statement_test.dart
index c84fd5d..e60c242 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/break_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/break_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new BreakStatementTest().buildAll();
+ BreakStatementTest().buildAll();
}
class BreakStatementTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'break_statement',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'break',
[
@@ -27,7 +27,7 @@
ParserErrorCode.BREAK_OUTSIDE_OF_LOOP
],
failing: ['labeled', 'localFunctionNonVoid']),
- new TestDescriptor(
+ TestDescriptor(
'label', 'break a', [ParserErrorCode.EXPECTED_TOKEN], "break a;"),
],
PartialCodeTest.statementSuffixes,
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/class_declaration_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/class_declaration_test.dart
index 934bad6..27774c8 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/class_declaration_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/class_declaration_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new ClassDeclarationTest().buildAll();
+ ClassDeclarationTest().buildAll();
}
class ClassDeclarationTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'class_declaration',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'class',
[
@@ -24,9 +24,9 @@
],
'class _s_ {}',
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor('named', 'class A',
+ TestDescriptor('named', 'class A',
[ParserErrorCode.MISSING_CLASS_BODY], 'class A {}'),
- new TestDescriptor(
+ TestDescriptor(
'extend',
'class A extend',
[
@@ -37,7 +37,7 @@
'class A extend _s_ {}',
expectedErrorsInValidCode: [ParserErrorCode.EXPECTED_INSTEAD],
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'extends',
'class A extends',
[
@@ -46,7 +46,7 @@
],
'class A extends _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'on',
'class A on',
[
@@ -57,20 +57,20 @@
'class A on _s_ {}',
expectedErrorsInValidCode: [ParserErrorCode.EXPECTED_INSTEAD],
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor('extendsBody', 'class A extends {}',
+ TestDescriptor('extendsBody', 'class A extends {}',
[ParserErrorCode.EXPECTED_TYPE_NAME], 'class A extends _s_ {}'),
- new TestDescriptor(
+ TestDescriptor(
'extendsWithNameBody',
'class A extends with B {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
'class A extends _s_ with B {}'),
- new TestDescriptor(
+ TestDescriptor(
'extendsImplementsNameBody',
'class A extends implements B {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
'class A extends _s_ implements B {}',
allFailing: true),
- new TestDescriptor(
+ TestDescriptor(
'extendsNameWith',
'class A extends B with',
[
@@ -79,12 +79,12 @@
],
'class A extends B with _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'extendsNameWithBody',
'class A extends B with {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
'class A extends B with _s_ {}'),
- new TestDescriptor(
+ TestDescriptor(
'extendsNameImplements',
'class A extends B implements',
[
@@ -93,12 +93,12 @@
],
'class A extends B implements _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'extendsNameImplementsBody',
'class A extends B implements {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
'class A extends B implements _s_ {}'),
- new TestDescriptor(
+ TestDescriptor(
'extendsNameWithNameImplements',
'class A extends B with C implements',
[
@@ -107,12 +107,12 @@
],
'class A extends B with C implements _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'extendsNameWithNameImplementsBody',
'class A extends B with C implements {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
'class A extends B with C implements _s_ {}'),
- new TestDescriptor(
+ TestDescriptor(
'implements',
'class A implements',
[
@@ -121,12 +121,12 @@
],
'class A implements _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'implementsBody',
'class A implements {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
'class A implements _s_ {}'),
- new TestDescriptor(
+ TestDescriptor(
'implementsNameComma',
'class A implements B,',
[
@@ -135,12 +135,12 @@
],
'class A implements B, _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'implementsNameCommaBody',
'class A implements B, {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
'class A implements B, _s_ {}'),
- new TestDescriptor(
+ TestDescriptor(
'equals',
'class A =',
[
@@ -150,13 +150,13 @@
],
'class A = _s_ with _s_;',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'equalsName',
'class A = B',
[ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN],
'class A = B with _s_;',
failing: ['functionVoid', 'functionNonVoid', 'getter']),
- new TestDescriptor(
+ TestDescriptor(
'equalsNameWith',
'class A = B with',
[
@@ -165,7 +165,7 @@
],
'class A = B with _s_;',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'equalsNameName',
'class A = B C',
[ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN],
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/constructor_declaration_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/constructor_declaration_test.dart
index 443f166..8d7499d 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/constructor_declaration_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/constructor_declaration_test.dart
@@ -9,7 +9,7 @@
import 'partial_code_support.dart';
main() {
- new ConstructorTest().buildAll();
+ ConstructorTest().buildAll();
}
class ConstructorTest extends PartialCodeTest {
@@ -17,7 +17,7 @@
buildTests(
'constructor',
[
- new TestDescriptor(
+ TestDescriptor(
'colon',
'C() :',
[
@@ -28,7 +28,7 @@
adjustValidUnitBeforeComparison: setSeparator,
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'colon_field',
'C() : f',
[
@@ -38,7 +38,7 @@
'C() : f = _s_ {}',
adjustValidUnitBeforeComparison: setSeparator,
),
- new TestDescriptor(
+ TestDescriptor(
'colon_field_increment',
'C() : f++',
[
@@ -48,7 +48,7 @@
'C() : _s_ = f++ {}',
adjustValidUnitBeforeComparison: setSeparator,
),
- new TestDescriptor(
+ TestDescriptor(
'colon_field_comma',
'C() : f = 0,',
[
@@ -59,21 +59,21 @@
adjustValidUnitBeforeComparison: setSeparator,
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'colon_block',
'C() : {}',
[ParserErrorCode.MISSING_INITIALIZER],
'C() : _s_ = _s_ {}',
adjustValidUnitBeforeComparison: setSeparator,
),
- new TestDescriptor(
+ TestDescriptor(
'colon_semicolon',
'C() : ;',
[ParserErrorCode.MISSING_INITIALIZER],
'C() : _s_ = _s_ ;',
adjustValidUnitBeforeComparison: setSeparator,
),
- new TestDescriptor(
+ TestDescriptor(
'super',
'C() : super',
[
@@ -82,7 +82,7 @@
],
'C() : super() {}',
),
- new TestDescriptor(
+ TestDescriptor(
'super_dot',
'C() : super.',
[
@@ -93,7 +93,7 @@
'C() : super._s_() {}',
failing: ['fieldConst', 'methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'super_qdot',
'C() : super?.',
[
@@ -117,7 +117,7 @@
ClassDeclaration declaration = unit.declarations[0];
ConstructorDeclaration member = declaration.members[0];
member.separator =
- new Token(TokenType.COLON, member.parameters.endToken.charOffset + 1);
+ Token(TokenType.COLON, member.parameters.endToken.charOffset + 1);
return unit;
}
}
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/continue_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/continue_statement_test.dart
index 1b49362..b19dd2b 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/continue_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/continue_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new ContinueStatementTest().buildAll();
+ ContinueStatementTest().buildAll();
}
class ContinueStatementTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'continue_statement',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'continue',
[
@@ -27,7 +27,7 @@
ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP
],
failing: ['labeled', 'localFunctionNonVoid']),
- new TestDescriptor(
+ TestDescriptor(
'label',
'continue a',
[
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/do_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/do_statement_test.dart
index 74b4feb..971e73e 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/do_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/do_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new DoStatementTest().buildAll();
+ DoStatementTest().buildAll();
}
class DoStatementTest extends PartialCodeTest {
@@ -17,7 +17,7 @@
buildTests(
'do_statement',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'do',
[
@@ -31,7 +31,7 @@
],
"do {} while (_s_);",
allFailing: true),
- new TestDescriptor(
+ TestDescriptor(
'leftBrace',
'do {',
[
@@ -43,7 +43,7 @@
],
"do {} while (_s_);",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'rightBrace',
'do {}',
[
@@ -54,7 +54,7 @@
],
"do {} while (_s_);",
failing: ['while']),
- new TestDescriptor(
+ TestDescriptor(
'while',
'do {} while',
[
@@ -63,7 +63,7 @@
ParserErrorCode.EXPECTED_TOKEN
],
"do {} while (_s_);"),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'do {} while (',
[
@@ -80,12 +80,12 @@
'localFunctionVoid',
'return'
]),
- new TestDescriptor(
+ TestDescriptor(
'condition',
'do {} while (a',
[ParserErrorCode.EXPECTED_TOKEN, ScannerErrorCode.EXPECTED_TOKEN],
"do {} while (a);"),
- new TestDescriptor('rightParen', 'do {} while (a)',
+ TestDescriptor('rightParen', 'do {} while (a)',
[ParserErrorCode.EXPECTED_TOKEN], "do {} while (a);"),
],
PartialCodeTest.statementSuffixes,
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/enum_declaration_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/enum_declaration_test.dart
index ad5f65e..392eb49 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/enum_declaration_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/enum_declaration_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new EnumDeclarationTest().buildAll();
+ EnumDeclarationTest().buildAll();
}
class EnumDeclarationTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'enum_declaration',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'enum',
[
@@ -25,10 +25,10 @@
'enum _s_ {}',
expectedErrorsInValidCode: [ParserErrorCode.EMPTY_ENUM_BODY],
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor('name', 'enum E',
- [ParserErrorCode.MISSING_ENUM_BODY], 'enum E {}',
+ TestDescriptor('name', 'enum E', [ParserErrorCode.MISSING_ENUM_BODY],
+ 'enum E {}',
expectedErrorsInValidCode: [ParserErrorCode.EMPTY_ENUM_BODY]),
- new TestDescriptor(
+ TestDescriptor(
'missingName',
'enum {}',
[
@@ -37,7 +37,7 @@
],
'enum _s_ {}',
expectedErrorsInValidCode: [ParserErrorCode.EMPTY_ENUM_BODY]),
- new TestDescriptor(
+ TestDescriptor(
'leftBrace',
'enum E {',
[
@@ -53,7 +53,7 @@
'mixin',
'setter'
]),
- new TestDescriptor(
+ TestDescriptor(
'comma',
'enum E {,',
[
@@ -70,9 +70,9 @@
'mixin',
'setter'
]),
- new TestDescriptor('value', 'enum E {a',
+ TestDescriptor('value', 'enum E {a',
[ScannerErrorCode.EXPECTED_TOKEN], 'enum E {a}'),
- new TestDescriptor(
+ TestDescriptor(
'commaValue',
'enum E {,a',
[
@@ -80,20 +80,20 @@
ScannerErrorCode.EXPECTED_TOKEN
],
'enum E {_s_, a}'),
- new TestDescriptor('commaRightBrace', 'enum E {,}',
+ TestDescriptor('commaRightBrace', 'enum E {,}',
[ParserErrorCode.MISSING_IDENTIFIER], 'enum E {_s_}'),
- new TestDescriptor('commaValueRightBrace', 'enum E {, a}',
+ TestDescriptor('commaValueRightBrace', 'enum E {, a}',
[ParserErrorCode.MISSING_IDENTIFIER], 'enum E {_s_, a}'),
],
PartialCodeTest.declarationSuffixes);
buildTests('enum_eof', [
- new TestDescriptor(
+ TestDescriptor(
'leftBrace',
'enum E {',
[ParserErrorCode.EMPTY_ENUM_BODY, ScannerErrorCode.EXPECTED_TOKEN],
'enum E {}',
expectedErrorsInValidCode: [ParserErrorCode.EMPTY_ENUM_BODY]),
- new TestDescriptor(
+ TestDescriptor(
'comma',
'enum E {,',
[ParserErrorCode.MISSING_IDENTIFIER, ScannerErrorCode.EXPECTED_TOKEN],
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/export_directive_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/export_directive_test.dart
index 4e3ccff..1adffb1 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/export_directive_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/export_directive_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new ExportDirectivesTest().buildAll();
+ ExportDirectivesTest().buildAll();
}
class ExportDirectivesTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'export_directive',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'export',
[
@@ -25,11 +25,11 @@
ParserErrorCode.EXPECTED_TOKEN
],
"export '';"),
- new TestDescriptor('emptyUri', "export ''",
+ TestDescriptor('emptyUri', "export ''",
[ParserErrorCode.EXPECTED_TOKEN], "export '';"),
- new TestDescriptor('uri', "export 'a.dart'",
+ TestDescriptor('uri', "export 'a.dart'",
[ParserErrorCode.EXPECTED_TOKEN], "export 'a.dart';"),
- new TestDescriptor(
+ TestDescriptor(
'hide',
"export 'a.dart' hide",
[
@@ -38,9 +38,9 @@
],
"export 'a.dart' hide _s_;",
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor('hideName', "export 'a.dart' hide A",
+ TestDescriptor('hideName', "export 'a.dart' hide A",
[ParserErrorCode.EXPECTED_TOKEN], "export 'a.dart' hide A;"),
- new TestDescriptor(
+ TestDescriptor(
'hideComma',
"export 'a.dart' hide A,",
[
@@ -49,9 +49,9 @@
],
"export 'a.dart' hide A, _s_;",
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor('hideCommaName', "export 'a.dart' hide A, B",
+ TestDescriptor('hideCommaName', "export 'a.dart' hide A, B",
[ParserErrorCode.EXPECTED_TOKEN], "export 'a.dart' hide A, B;"),
- new TestDescriptor(
+ TestDescriptor(
'hideShow',
"export 'a.dart' hide A show",
[
@@ -60,7 +60,7 @@
],
"export 'a.dart' hide A show _s_;",
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor(
+ TestDescriptor(
'show',
"export 'a.dart' show",
[
@@ -69,9 +69,9 @@
],
"export 'a.dart' show _s_;",
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor('showName', "export 'a.dart' show A",
+ TestDescriptor('showName', "export 'a.dart' show A",
[ParserErrorCode.EXPECTED_TOKEN], "export 'a.dart' show A;"),
- new TestDescriptor(
+ TestDescriptor(
'showComma',
"export 'a.dart' show A,",
[
@@ -80,9 +80,9 @@
],
"export 'a.dart' show A, _s_;",
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor('showCommaName', "export 'a.dart' show A, B",
+ TestDescriptor('showCommaName', "export 'a.dart' show A, B",
[ParserErrorCode.EXPECTED_TOKEN], "export 'a.dart' show A, B;"),
- new TestDescriptor(
+ TestDescriptor(
'showHide',
"export 'a.dart' show A hide",
[
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/extension_declaration_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/extension_declaration_test.dart
index ad7ff9a..528b76e 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/extension_declaration_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/extension_declaration_test.dart
@@ -8,7 +8,7 @@
import 'partial_code_support.dart';
main() {
- new ExtensionDeclarationTest().buildAll();
+ ExtensionDeclarationTest().buildAll();
}
class ExtensionDeclarationTest extends PartialCodeTest {
@@ -16,7 +16,7 @@
buildTests(
'extension_declaration',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'extension',
[
@@ -33,7 +33,7 @@
'setter',
'typedef'
]),
- new TestDescriptor(
+ TestDescriptor(
'named',
'extension E',
[
@@ -43,7 +43,7 @@
],
'extension E on _s_ {}',
failing: ['getter', 'functionNonVoid', 'functionVoid', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'on',
'extension E on',
[
@@ -52,7 +52,7 @@
],
'extension E on _s_ {}',
failing: ['getter', 'functionNonVoid', 'functionVoid', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'extendedType',
'extension E on String',
[
@@ -64,7 +64,7 @@
// the declaration that's expected to follow it.
//
// The notable exceptions are 'class', 'enum', 'mixin', and 'typedef'.
- new TestDescriptor(
+ TestDescriptor(
'partialBody',
'extension E on String {',
[
@@ -86,7 +86,7 @@
]),
],
PartialCodeTest.declarationSuffixes,
- featureSet: new FeatureSet.forTesting(
+ featureSet: FeatureSet.forTesting(
sdkVersion: '2.3.0',
additionalFeatures: [Feature.extension_methods]));
}
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/field_declaration_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/field_declaration_test.dart
index d7db9ab..496fcdc 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/field_declaration_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/field_declaration_test.dart
@@ -8,7 +8,7 @@
import 'partial_code_support.dart';
main() {
- new MethodTest().buildAll();
+ MethodTest().buildAll();
}
class MethodTest extends PartialCodeTest {
@@ -28,7 +28,7 @@
//
// Instance field, const.
//
- new TestDescriptor(
+ TestDescriptor(
'const_noName',
'const',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
@@ -38,7 +38,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'const_name',
'const f',
[
@@ -51,7 +51,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'const_equals',
'const f =',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
@@ -64,7 +64,7 @@
'setter'
],
),
- new TestDescriptor(
+ TestDescriptor(
'const_initializer',
'const f = 0',
[ParserErrorCode.EXPECTED_TOKEN],
@@ -73,21 +73,21 @@
//
// Instance field, final.
//
- new TestDescriptor(
+ TestDescriptor(
'final_noName',
'final',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
'final _s_;',
failing: allExceptAnnotationAndEof,
),
- new TestDescriptor(
+ TestDescriptor(
'final_name',
'final f',
[ParserErrorCode.EXPECTED_TOKEN],
'final f;',
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'final_equals',
'final f =',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
@@ -100,7 +100,7 @@
'setter'
],
),
- new TestDescriptor(
+ TestDescriptor(
'final_initializer',
'final f = 0',
[ParserErrorCode.EXPECTED_TOKEN],
@@ -109,28 +109,28 @@
//
// Instance field, var.
//
- new TestDescriptor(
+ TestDescriptor(
'var_noName',
'var',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
'var _s_;',
failing: allExceptAnnotationAndEof,
),
- new TestDescriptor(
+ TestDescriptor(
'var_name',
'var f',
[ParserErrorCode.EXPECTED_TOKEN],
'var f;',
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'var_name_comma',
'var f,',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
'var f, _s_;',
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'var_equals',
'var f =',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
@@ -143,7 +143,7 @@
'setter'
],
),
- new TestDescriptor(
+ TestDescriptor(
'var_initializer',
'var f = 0',
[ParserErrorCode.EXPECTED_TOKEN],
@@ -152,7 +152,7 @@
//
// Instance field, type.
//
- new TestDescriptor(
+ TestDescriptor(
'type_noName',
'A',
[
@@ -162,13 +162,13 @@
'A _s_;',
allFailing: true,
),
- new TestDescriptor(
+ TestDescriptor(
'type_name',
'A f',
[ParserErrorCode.EXPECTED_TOKEN],
'A f;',
),
- new TestDescriptor(
+ TestDescriptor(
'type_name_comma',
'A f,',
[
@@ -177,7 +177,7 @@
],
'A f, _s_;',
failing: ['methodNonVoid', 'getter', 'setter']),
- new TestDescriptor(
+ TestDescriptor(
'type_equals',
'A f =',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
@@ -190,7 +190,7 @@
'setter'
],
),
- new TestDescriptor(
+ TestDescriptor(
'type_initializer',
'A f = 0',
[ParserErrorCode.EXPECTED_TOKEN],
@@ -199,7 +199,7 @@
//
// Static field, const.
//
- new TestDescriptor(
+ TestDescriptor(
'static_const_noName',
'static const',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
@@ -209,7 +209,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'static_const_name',
'static const f',
[
@@ -222,7 +222,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'static_const_equals',
'static const f =',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
@@ -235,7 +235,7 @@
'setter'
],
),
- new TestDescriptor(
+ TestDescriptor(
'static_const_initializer',
'static const f = 0',
[ParserErrorCode.EXPECTED_TOKEN],
@@ -244,21 +244,21 @@
//
// Static field, final.
//
- new TestDescriptor(
+ TestDescriptor(
'static_final_noName',
'static final',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
'static final _s_;',
failing: allExceptAnnotationAndEof,
),
- new TestDescriptor(
+ TestDescriptor(
'static_final_name',
'static final f',
[ParserErrorCode.EXPECTED_TOKEN],
'static final f;',
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'static_final_equals',
'static final f =',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
@@ -271,7 +271,7 @@
'setter'
],
),
- new TestDescriptor(
+ TestDescriptor(
'static_final_initializer',
'static final f = 0',
[ParserErrorCode.EXPECTED_TOKEN],
@@ -280,21 +280,21 @@
//
// Static field, var.
//
- new TestDescriptor(
+ TestDescriptor(
'static_var_noName',
'static var',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
'static var _s_;',
failing: allExceptAnnotationAndEof,
),
- new TestDescriptor(
+ TestDescriptor(
'static_var_name',
'static var f',
[ParserErrorCode.EXPECTED_TOKEN],
'static var f;',
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'static_var_equals',
'static var f =',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
@@ -307,7 +307,7 @@
'setter'
],
),
- new TestDescriptor(
+ TestDescriptor(
'static_var_initializer',
'static var f = 0',
[ParserErrorCode.EXPECTED_TOKEN],
@@ -316,7 +316,7 @@
//
// Static field, type.
//
- new TestDescriptor(
+ TestDescriptor(
'static_type_noName',
'static A',
[
@@ -326,13 +326,13 @@
'static A _s_;',
allFailing: true,
),
- new TestDescriptor(
+ TestDescriptor(
'static_type_name',
'static A f',
[ParserErrorCode.EXPECTED_TOKEN],
'static A f;',
),
- new TestDescriptor(
+ TestDescriptor(
'static_type_equals',
'static A f =',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
@@ -345,7 +345,7 @@
'setter'
],
),
- new TestDescriptor(
+ TestDescriptor(
'static_type_initializer',
'static A f = 0',
[ParserErrorCode.EXPECTED_TOKEN],
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/for_each_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/for_each_statement_test.dart
index 2d7ef0f..a06c5c1 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/for_each_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/for_each_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new ForEachStatementTest().buildAll();
+ ForEachStatementTest().buildAll();
}
class ForEachStatementTest extends PartialCodeTest {
@@ -21,7 +21,7 @@
buildTests(
'forEach_statement',
[
- new TestDescriptor(
+ TestDescriptor(
'in',
'for (var a in',
[
@@ -32,7 +32,7 @@
],
'for (var a in _s_) _s_;',
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'iterator',
'for (var a in b',
[
@@ -53,9 +53,9 @@
buildTests(
'forEach_statement',
[
- new TestDescriptor('await_keyword', 'await for',
+ TestDescriptor('await_keyword', 'await for',
[ParserErrorCode.EXPECTED_TOKEN], 'await for (_s_ in _s_) _s_;'),
- new TestDescriptor(
+ TestDescriptor(
'await_leftParen',
'await for (',
[
@@ -70,7 +70,7 @@
],
"await for (_s_ in _s_) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'await_variableName',
'await for (a',
[
@@ -82,7 +82,7 @@
],
"await for (a in _s_) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'await_typeAndVariableName',
'await for (A a',
[
@@ -94,7 +94,7 @@
],
"await for (A a in _s_) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'await_in',
'await for (A a in',
[
@@ -105,7 +105,7 @@
],
"await for (A a in _s_) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'await_stream',
'await for (A a in b',
[
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/for_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/for_statement_test.dart
index 8d22fdf..7e22f1a 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/for_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/for_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new ForStatementTest().buildAll();
+ ForStatementTest().buildAll();
}
class ForStatementTest extends PartialCodeTest {
@@ -17,9 +17,9 @@
buildTests(
'for_statement',
[
- new TestDescriptor('keyword', 'for', [ParserErrorCode.EXPECTED_TOKEN],
+ TestDescriptor('keyword', 'for', [ParserErrorCode.EXPECTED_TOKEN],
'for (;;) _s_;'),
- new TestDescriptor(
+ TestDescriptor(
'emptyParen',
'for ()',
[
@@ -32,7 +32,7 @@
],
"for (_s_;_s_;) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'for (',
[
@@ -46,7 +46,7 @@
],
"for (_s_;_s_;) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'var',
'for (var',
[
@@ -58,7 +58,7 @@
],
"for (var _s_;;) _s_;",
allFailing: true),
- new TestDescriptor(
+ TestDescriptor(
'varAndIdentifier',
'for (var i',
[
@@ -71,7 +71,7 @@
],
"for (var i;_s_;) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'equals',
'for (var i =',
[
@@ -85,7 +85,7 @@
],
"for (var i = _s_;_s_;) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'initializer',
'for (var i = 0',
[
@@ -98,7 +98,7 @@
],
"for (var i = 0;_s_;) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'firstSemicolon',
'for (var i = 0;',
[
@@ -110,7 +110,7 @@
],
"for (var i = 0;_s_;) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'secondSemicolon',
'for (var i = 0;;',
[
@@ -120,7 +120,7 @@
],
"for (var i = 0;;) _s_;",
failing: allExceptEof),
- new TestDescriptor(
+ TestDescriptor(
'rightParen',
'for (var i = 0;;)',
[
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/if_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/if_statement_test.dart
index aa09fb2..23759c5 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/if_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/if_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new IfStatementTest().buildAll();
+ IfStatementTest().buildAll();
}
class IfStatementTest extends PartialCodeTest {
@@ -15,13 +15,13 @@
buildTests(
'if_statement',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'if',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
"if (_s_)",
),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'if (',
[ParserErrorCode.MISSING_IDENTIFIER, ScannerErrorCode.EXPECTED_TOKEN],
@@ -35,7 +35,7 @@
'return'
],
),
- new TestDescriptor(
+ TestDescriptor(
'condition',
'if (a',
[ScannerErrorCode.EXPECTED_TOKEN],
@@ -50,7 +50,7 @@
buildTests(
'if_statement',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'if',
[
@@ -61,14 +61,14 @@
"if (_s_);",
allFailing: true,
),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'if (',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
"if (_s_);",
allFailing: true,
),
- new TestDescriptor(
+ TestDescriptor(
'condition',
'if (a',
[ParserErrorCode.EXPECTED_TOKEN],
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/import_directive_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/import_directive_test.dart
index 5472bd1..35af3d0 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/import_directive_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/import_directive_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new ImportDirectivesTest().buildAll();
+ ImportDirectivesTest().buildAll();
}
class ImportDirectivesTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'import_directive',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'import',
[
@@ -25,11 +25,11 @@
ParserErrorCode.EXPECTED_TOKEN
],
"import '';"),
- new TestDescriptor('emptyUri', "import ''",
+ TestDescriptor('emptyUri', "import ''",
[ParserErrorCode.EXPECTED_TOKEN], "import '';"),
- new TestDescriptor('fullUri', "import 'a.dart'",
+ TestDescriptor('fullUri', "import 'a.dart'",
[ParserErrorCode.EXPECTED_TOKEN], "import 'a.dart';"),
- new TestDescriptor(
+ TestDescriptor(
'if',
"import 'a.dart' if",
[
@@ -38,7 +38,7 @@
ParserErrorCode.EXPECTED_STRING_LITERAL
],
"import 'a.dart' if (_s_) '';"),
- new TestDescriptor(
+ TestDescriptor(
'ifParen',
"import 'a.dart' if (",
[
@@ -49,7 +49,7 @@
],
"import 'a.dart' if (_s_) '';",
failing: ['functionNonVoid', 'getter', 'setter']),
- new TestDescriptor(
+ TestDescriptor(
'ifId',
"import 'a.dart' if (b",
[
@@ -58,7 +58,7 @@
ParserErrorCode.EXPECTED_STRING_LITERAL
],
"import 'a.dart' if (b) '';"),
- new TestDescriptor(
+ TestDescriptor(
'ifEquals',
"import 'a.dart' if (b ==",
[
@@ -68,7 +68,7 @@
ParserErrorCode.EXPECTED_STRING_LITERAL
],
"import 'a.dart' if (b == '') '';"),
- new TestDescriptor(
+ TestDescriptor(
'ifCondition',
"import 'a.dart' if (b)",
[
@@ -76,7 +76,7 @@
ParserErrorCode.EXPECTED_STRING_LITERAL
],
"import 'a.dart' if (b) '';"),
- new TestDescriptor(
+ TestDescriptor(
'as',
"import 'a.dart' as",
[
@@ -85,7 +85,7 @@
],
"import 'a.dart' as _s_;",
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor(
+ TestDescriptor(
'show',
"import 'a.dart' show",
[
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/index_expression_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/index_expression_test.dart
index a55d362..b81357b 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/index_expression_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/index_expression_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new IndexStatementTest().buildAll();
+ IndexStatementTest().buildAll();
}
class IndexStatementTest extends PartialCodeTest {
@@ -15,31 +15,31 @@
buildTests(
'index_assignment',
[
- new TestDescriptor(
+ TestDescriptor(
'missing_index_no_space',
'intList[] = 0;',
[ParserErrorCode.MISSING_IDENTIFIER],
'intList[_s_] = 0;',
),
- new TestDescriptor(
+ TestDescriptor(
'missing_index_with_space',
'intList[ ] = 0;',
[ParserErrorCode.MISSING_IDENTIFIER],
'intList[_s_] = 0;',
),
- new TestDescriptor(
+ TestDescriptor(
'trailing_comma',
'intList[x,] = 0;',
[ParserErrorCode.EXPECTED_TOKEN],
'intList[x] = 0;',
),
- new TestDescriptor(
+ TestDescriptor(
'trailing_comma_and_identifier',
'intList[x,y] = 0;',
[ParserErrorCode.EXPECTED_TOKEN],
'intList[x] = 0;',
),
- new TestDescriptor(
+ TestDescriptor(
'trailing_identifier_no_comma',
'intList[x y] = 0;',
[ParserErrorCode.EXPECTED_TOKEN],
@@ -53,7 +53,7 @@
buildTests(
'index_partial',
[
- new TestDescriptor(
+ TestDescriptor(
'open',
'intList[',
[
@@ -73,7 +73,7 @@
'return'
],
),
- new TestDescriptor(
+ TestDescriptor(
'identifier',
'intList[x',
[
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/instance_creation_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/instance_creation_test.dart
index e62cc14..d29313d 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/instance_creation_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/instance_creation_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new InstanceCreationTest().buildAll();
+ InstanceCreationTest().buildAll();
}
class InstanceCreationTest extends PartialCodeTest {
@@ -24,7 +24,7 @@
List<TestDescriptor> forKeyword(String keyword) {
return <TestDescriptor>[
- new TestDescriptor(
+ TestDescriptor(
'${keyword}_keyword',
'$keyword',
[
@@ -32,21 +32,21 @@
ParserErrorCode.EXPECTED_TOKEN,
],
"$keyword _s_()"),
- new TestDescriptor(
+ TestDescriptor(
'${keyword}_name_unnamed',
'$keyword A',
[
ParserErrorCode.EXPECTED_TOKEN,
],
"$keyword A()"),
- new TestDescriptor(
+ TestDescriptor(
'${keyword}_name_named',
'$keyword A.b',
[
ParserErrorCode.EXPECTED_TOKEN,
],
"$keyword A.b()"),
- new TestDescriptor(
+ TestDescriptor(
'${keyword}_name_dot',
'$keyword A.',
[
@@ -54,7 +54,7 @@
ParserErrorCode.EXPECTED_TOKEN,
],
"$keyword A._s_()"),
- new TestDescriptor(
+ TestDescriptor(
'${keyword}_leftParen_unnamed',
'$keyword A(',
[
@@ -62,7 +62,7 @@
],
"$keyword A()",
allFailing: true),
- new TestDescriptor(
+ TestDescriptor(
'${keyword}_leftParen_named',
'$keyword A.b(',
[
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/library_directive_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/library_directive_test.dart
index 256fbd3..6585bf0 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/library_directive_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/library_directive_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new LibraryDirectivesTest().buildAll();
+ LibraryDirectivesTest().buildAll();
}
class LibraryDirectivesTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'library_directive',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'library',
[
@@ -24,9 +24,9 @@
],
'library _s_;',
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor('name', 'library lib',
+ TestDescriptor('name', 'library lib',
[ParserErrorCode.EXPECTED_TOKEN], 'library lib;'),
- new TestDescriptor(
+ TestDescriptor(
'nameDot',
'library lib.',
[
@@ -35,7 +35,7 @@
],
'library lib._s_;',
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor('nameDotName', 'library lib.a',
+ TestDescriptor('nameDotName', 'library lib.a',
[ParserErrorCode.EXPECTED_TOKEN], 'library lib.a;'),
],
PartialCodeTest.prePartSuffixes);
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/local_variable_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/local_variable_test.dart
index 848d86d..e576bcd 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/local_variable_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/local_variable_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new LocalVariableTest().buildAll();
+ LocalVariableTest().buildAll();
}
class LocalVariableTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'local_variable',
[
- new TestDescriptor(
+ TestDescriptor(
'const',
'const',
[
@@ -24,16 +24,16 @@
],
"const _s_;",
allFailing: true),
- new TestDescriptor('constName', 'const a',
+ TestDescriptor('constName', 'const a',
[ParserErrorCode.EXPECTED_TOKEN], "const a;",
failing: <String>[
'eof',
'labeled',
'localFunctionNonVoid',
]),
- new TestDescriptor('constTypeName', 'const int a',
+ TestDescriptor('constTypeName', 'const int a',
[ParserErrorCode.EXPECTED_TOKEN], "const int a;"),
- new TestDescriptor(
+ TestDescriptor(
'constNameComma',
'const a,',
[
@@ -45,7 +45,7 @@
'labeled',
'localFunctionNonVoid',
]),
- new TestDescriptor(
+ TestDescriptor(
'constTypeNameComma',
'const int a,',
[
@@ -57,11 +57,11 @@
'labeled',
'localFunctionNonVoid',
]),
- new TestDescriptor('constNameCommaName', 'const a, b',
+ TestDescriptor('constNameCommaName', 'const a, b',
[ParserErrorCode.EXPECTED_TOKEN], "const a, b;"),
- new TestDescriptor('constTypeNameCommaName', 'const int a, b',
+ TestDescriptor('constTypeNameCommaName', 'const int a, b',
[ParserErrorCode.EXPECTED_TOKEN], "const int a, b;"),
- new TestDescriptor(
+ TestDescriptor(
'final',
'final',
[
@@ -75,15 +75,15 @@
'localFunctionVoid',
'localVariable',
]),
- new TestDescriptor('finalName', 'final a',
+ TestDescriptor('finalName', 'final a',
[ParserErrorCode.EXPECTED_TOKEN], "final a;",
failing: [
'labeled',
'localFunctionNonVoid',
]),
- new TestDescriptor('finalTypeName', 'final int a',
+ TestDescriptor('finalTypeName', 'final int a',
[ParserErrorCode.EXPECTED_TOKEN], "final int a;"),
- new TestDescriptor(
+ TestDescriptor(
'type',
'int',
[
@@ -92,9 +92,9 @@
],
"int _s_;",
allFailing: true),
- new TestDescriptor(
+ TestDescriptor(
'typeName', 'int a', [ParserErrorCode.EXPECTED_TOKEN], "int a;"),
- new TestDescriptor(
+ TestDescriptor(
'var',
'var',
[
@@ -108,13 +108,13 @@
'localFunctionVoid',
'localVariable',
]),
- new TestDescriptor(
+ TestDescriptor(
'varName', 'var a', [ParserErrorCode.EXPECTED_TOKEN], "var a;",
failing: [
'labeled',
'localFunctionNonVoid',
]),
- new TestDescriptor(
+ TestDescriptor(
'varNameEquals',
'var a =',
[
@@ -130,7 +130,7 @@
'localFunctionVoid',
'return'
]),
- new TestDescriptor('varNameEqualsExpression', 'var a = b',
+ TestDescriptor('varNameEqualsExpression', 'var a = b',
[ParserErrorCode.EXPECTED_TOKEN], "var a = b;"),
],
PartialCodeTest.statementSuffixes,
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/method_declaration_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/method_declaration_test.dart
index 080d5d4..af47fdf 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/method_declaration_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/method_declaration_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new MethodTest().buildAll();
+ MethodTest().buildAll();
}
class MethodTest extends PartialCodeTest {
@@ -28,7 +28,7 @@
//
// Instance method, no return type.
//
- new TestDescriptor(
+ TestDescriptor(
'noType_leftParen',
'm(',
[
@@ -38,7 +38,7 @@
'm() {}',
failing: allExceptEof,
),
- new TestDescriptor(
+ TestDescriptor(
'noType_paramName',
'm(B',
[
@@ -48,7 +48,7 @@
'm(B) {}',
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'noType_paramTypeAndName',
'm(B b',
[
@@ -56,7 +56,7 @@
ParserErrorCode.MISSING_FUNCTION_BODY
],
'm(B b) {}'),
- new TestDescriptor(
+ TestDescriptor(
'noType_paramAndComma',
'm(B b,',
[
@@ -66,19 +66,19 @@
'm(B b) {}',
failing: allExceptEof,
),
- new TestDescriptor(
+ TestDescriptor(
'noType_noParams',
'm()',
[ParserErrorCode.MISSING_FUNCTION_BODY],
'm() {}',
),
- new TestDescriptor(
+ TestDescriptor(
'noType_params',
'm(b, c)',
[ParserErrorCode.MISSING_FUNCTION_BODY],
'm(b, c) {}',
),
- new TestDescriptor(
+ TestDescriptor(
'noType_emptyOptional',
'm(B b, [])',
[
@@ -87,7 +87,7 @@
],
'm(B b, [_s_]){}',
),
- new TestDescriptor(
+ TestDescriptor(
'noType_emptyNamed',
'm(B b, {})',
[
@@ -99,7 +99,7 @@
//
// Instance method, with simple return type.
//
- new TestDescriptor(
+ TestDescriptor(
'type_leftParen',
'A m(',
[
@@ -109,7 +109,7 @@
'A m() {}',
failing: allExceptEof,
),
- new TestDescriptor(
+ TestDescriptor(
'type_paramName',
'A m(B',
[
@@ -119,7 +119,7 @@
'A m(B) {}',
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'type_paramTypeAndName',
'A m(B b',
[
@@ -128,7 +128,7 @@
],
'A m(B b) {}',
),
- new TestDescriptor(
+ TestDescriptor(
'type_paramAndComma',
'A m(B b,',
[
@@ -138,19 +138,19 @@
'A m(B b) {}',
failing: allExceptEof,
),
- new TestDescriptor(
+ TestDescriptor(
'type_noParams',
'A m()',
[ParserErrorCode.MISSING_FUNCTION_BODY],
'A m() {}',
),
- new TestDescriptor(
+ TestDescriptor(
'type_params',
'A m(b, c)',
[ParserErrorCode.MISSING_FUNCTION_BODY],
'A m(b, c) {}',
),
- new TestDescriptor(
+ TestDescriptor(
'type_emptyOptional',
'A m(B b, [])',
[
@@ -159,7 +159,7 @@
],
'A m(B b, [_s_]){}',
),
- new TestDescriptor(
+ TestDescriptor(
'type_emptyNamed',
'A m(B b, {})',
[
@@ -171,7 +171,7 @@
//
// Static method, no return type.
//
- new TestDescriptor(
+ TestDescriptor(
'static_noType_leftParen',
'static m(',
[
@@ -181,7 +181,7 @@
'static m() {}',
failing: allExceptEof,
),
- new TestDescriptor(
+ TestDescriptor(
'static_noType_paramName',
'static m(B',
[
@@ -191,7 +191,7 @@
'static m(B) {}',
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'static_noType_paramTypeAndName',
'static m(B b',
[
@@ -200,7 +200,7 @@
],
'static m(B b) {}',
),
- new TestDescriptor(
+ TestDescriptor(
'static_noType_paramAndComma',
'static m(B b,',
[
@@ -210,19 +210,19 @@
'static m(B b) {}',
failing: allExceptEof,
),
- new TestDescriptor(
+ TestDescriptor(
'static_noType_noParams',
'static m()',
[ParserErrorCode.MISSING_FUNCTION_BODY],
'static m() {}',
),
- new TestDescriptor(
+ TestDescriptor(
'static_noType_params',
'static m(b, c)',
[ParserErrorCode.MISSING_FUNCTION_BODY],
'static m(b, c) {}',
),
- new TestDescriptor(
+ TestDescriptor(
'static_noType_emptyOptional',
'static m(B b, [])',
[
@@ -231,7 +231,7 @@
],
'static m(B b, [_s_]){}',
),
- new TestDescriptor(
+ TestDescriptor(
'static_noType_emptyNamed',
'static m(B b, {})',
[
@@ -243,7 +243,7 @@
//
// Static method, with simple return type.
//
- new TestDescriptor(
+ TestDescriptor(
'static_type_leftParen',
'static A m(',
[
@@ -253,7 +253,7 @@
'static A m() {}',
failing: allExceptEof,
),
- new TestDescriptor(
+ TestDescriptor(
'static_type_paramName',
'static A m(B',
[
@@ -263,7 +263,7 @@
'static A m(B) {}',
failing: ['methodNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'static_type_paramTypeAndName',
'static A m(B b',
[
@@ -272,7 +272,7 @@
],
'static A m(B b) {}',
),
- new TestDescriptor(
+ TestDescriptor(
'static_type_paramAndComma',
'static A m(B b,',
[
@@ -282,19 +282,19 @@
'static A m(B b) {}',
failing: allExceptEof,
),
- new TestDescriptor(
+ TestDescriptor(
'static_type_noParams',
'static A m()',
[ParserErrorCode.MISSING_FUNCTION_BODY],
'static A m() {}',
),
- new TestDescriptor(
+ TestDescriptor(
'static_type_params',
'static A m(b, c)',
[ParserErrorCode.MISSING_FUNCTION_BODY],
'static A m(b, c) {}',
),
- new TestDescriptor(
+ TestDescriptor(
'static_type_emptyOptional',
'static A m(B b, [])',
[
@@ -303,7 +303,7 @@
],
'static A m(B b, [_s_]){}',
),
- new TestDescriptor(
+ TestDescriptor(
'static_type_emptyNamed',
'static A m(B b, {})',
[
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/mixin_declaration_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/mixin_declaration_test.dart
index 02a221b..9d39e82 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/mixin_declaration_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/mixin_declaration_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new MixinDeclarationTest().buildAll();
+ MixinDeclarationTest().buildAll();
}
class MixinDeclarationTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'mixin_declaration',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'mixin',
[
@@ -24,9 +24,9 @@
],
'mixin _s_ {}',
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor('named', 'mixin A',
+ TestDescriptor('named', 'mixin A',
[ParserErrorCode.MISSING_CLASS_BODY], 'mixin A {}'),
- new TestDescriptor(
+ TestDescriptor(
'on',
'mixin A on',
[
@@ -35,7 +35,7 @@
],
'mixin A on _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'extend',
'mixin A extend',
[
@@ -46,7 +46,7 @@
'mixin A extend _s_ {}',
expectedErrorsInValidCode: [ParserErrorCode.EXPECTED_INSTEAD],
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'extends',
'mixin A extends',
[
@@ -57,9 +57,9 @@
'mixin A extends _s_ {}',
expectedErrorsInValidCode: [ParserErrorCode.EXPECTED_INSTEAD],
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor('onBody', 'mixin A on {}',
+ TestDescriptor('onBody', 'mixin A on {}',
[ParserErrorCode.EXPECTED_TYPE_NAME], 'mixin A on _s_ {}'),
- new TestDescriptor(
+ TestDescriptor(
'onNameComma',
'mixin A on B,',
[
@@ -68,15 +68,15 @@
],
'mixin A on B, _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor('onNameCommaBody', 'mixin A on B, {}',
+ TestDescriptor('onNameCommaBody', 'mixin A on B, {}',
[ParserErrorCode.EXPECTED_TYPE_NAME], 'mixin A on B, _s_ {}'),
- new TestDescriptor(
+ TestDescriptor(
'onImplementsNameBody',
'mixin A on implements B {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
'mixin A on _s_ implements B {}',
allFailing: true),
- new TestDescriptor(
+ TestDescriptor(
'onNameImplements',
'mixin A on B implements',
[
@@ -85,12 +85,12 @@
],
'mixin A on B implements _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'onNameImplementsBody',
'mixin A on B implements {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
'mixin A on B implements _s_ {}'),
- new TestDescriptor(
+ TestDescriptor(
'implements',
'mixin A implements',
[
@@ -99,12 +99,12 @@
],
'mixin A implements _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'implementsBody',
'mixin A implements {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
'mixin A implements _s_ {}'),
- new TestDescriptor(
+ TestDescriptor(
'implementsNameComma',
'mixin A implements B,',
[
@@ -113,7 +113,7 @@
],
'mixin A implements B, _s_ {}',
failing: ['functionVoid', 'functionNonVoid', 'getter', 'mixin']),
- new TestDescriptor(
+ TestDescriptor(
'implementsNameCommaBody',
'mixin A implements B, {}',
[ParserErrorCode.EXPECTED_TYPE_NAME],
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/parameter_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/parameter_test.dart
index 7298a30..08379f9 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/parameter_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/parameter_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new ParameterTest().buildAll();
+ ParameterTest().buildAll();
}
class ParameterTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'required',
[
- new TestDescriptor(
+ TestDescriptor(
'functionType_noIdentifier',
'f(Function(void)) {}',
[
@@ -24,7 +24,7 @@
'f(Function(void) _s_) {}',
failing: ['eof'],
),
- new TestDescriptor(
+ TestDescriptor(
'typeArgument_noGt',
'''
class C<E> {}
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/part_directive_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/part_directive_test.dart
index 970336d..627383e 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/part_directive_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/part_directive_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new PartDirectivesTest().buildAll();
+ PartDirectivesTest().buildAll();
}
class PartDirectivesTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'part_directive',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'part',
[
@@ -25,9 +25,9 @@
ParserErrorCode.EXPECTED_TOKEN
],
"part '';"),
- new TestDescriptor('emptyUri', "part ''",
+ TestDescriptor('emptyUri', "part ''",
[ParserErrorCode.EXPECTED_TOKEN], "part '';"),
- new TestDescriptor('uri', "part 'a.dart'",
+ TestDescriptor('uri', "part 'a.dart'",
[ParserErrorCode.EXPECTED_TOKEN], "part 'a.dart';"),
],
PartialCodeTest.postPartSuffixes);
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/part_of_directive_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/part_of_directive_test.dart
index 246de37..8e5b8e4 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/part_of_directive_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/part_of_directive_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new PartOfDirectivesTest().buildAll();
+ PartOfDirectivesTest().buildAll();
}
class PartOfDirectivesTest extends PartialCodeTest {
@@ -27,7 +27,7 @@
buildTests(
'part_of_directive',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'part of',
[
@@ -41,7 +41,7 @@
buildTests(
'part_of_directive',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'part of',
[
@@ -56,10 +56,10 @@
buildTests(
'part_of_directive',
[
- new TestDescriptor('name', 'part of lib',
+ TestDescriptor('name', 'part of lib',
[ParserErrorCode.EXPECTED_TOKEN], 'library lib;',
allFailing: true),
- new TestDescriptor(
+ TestDescriptor(
'nameDot',
'part of lib.',
[
@@ -68,11 +68,11 @@
],
'part of lib._s_;',
failing: ['functionNonVoid', 'getter']),
- new TestDescriptor('nameDotName', 'part of lib.a',
+ TestDescriptor('nameDotName', 'part of lib.a',
[ParserErrorCode.EXPECTED_TOKEN], 'part of lib.a;'),
- new TestDescriptor('emptyUri', "part of ''",
+ TestDescriptor('emptyUri', "part of ''",
[ParserErrorCode.EXPECTED_TOKEN], "part of '';"),
- new TestDescriptor('uri', "part of 'a.dart'",
+ TestDescriptor('uri', "part of 'a.dart'",
[ParserErrorCode.EXPECTED_TOKEN], "part of 'a.dart';"),
],
PartialCodeTest.declarationSuffixes);
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/partial_code_support.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/partial_code_support.dart
index 45263e5..050ab72 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/partial_code_support.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/partial_code_support.dart
@@ -31,14 +31,14 @@
* A list of suffixes that can be used by tests of class members.
*/
static final List<TestSuffix> classMemberSuffixes = <TestSuffix>[
- new TestSuffix('annotation', '@annotation var f;'),
- new TestSuffix('field', 'var f;'),
- new TestSuffix('fieldConst', 'const f = 0;'),
- new TestSuffix('fieldFinal', 'final f = 0;'),
- new TestSuffix('methodNonVoid', 'int a(b) => 0;'),
- new TestSuffix('methodVoid', 'void a(b) {}'),
- new TestSuffix('getter', 'int get a => 0;'),
- new TestSuffix('setter', 'set a(b) {}')
+ TestSuffix('annotation', '@annotation var f;'),
+ TestSuffix('field', 'var f;'),
+ TestSuffix('fieldConst', 'const f = 0;'),
+ TestSuffix('fieldFinal', 'final f = 0;'),
+ TestSuffix('methodNonVoid', 'int a(b) => 0;'),
+ TestSuffix('methodVoid', 'void a(b) {}'),
+ TestSuffix('getter', 'int get a => 0;'),
+ TestSuffix('setter', 'set a(b) {}')
];
/**
@@ -46,18 +46,18 @@
* can validly be followed by any declaration.
*/
static final List<TestSuffix> declarationSuffixes = <TestSuffix>[
- new TestSuffix('class', 'class A {}'),
- new TestSuffix('enum', 'enum E { v }'),
+ TestSuffix('class', 'class A {}'),
+ TestSuffix('enum', 'enum E { v }'),
// new TestSuffix('extension', 'extension E on A {}'),
- new TestSuffix('mixin', 'mixin M {}'),
- new TestSuffix('typedef', 'typedef A = B Function(C, D);'),
- new TestSuffix('functionVoid', 'void f() {}'),
- new TestSuffix('functionNonVoid', 'int f() {}'),
- new TestSuffix('var', 'var a;'),
- new TestSuffix('const', 'const a = 0;'),
- new TestSuffix('final', 'final a = 0;'),
- new TestSuffix('getter', 'int get a => 0;'),
- new TestSuffix('setter', 'set a(b) {}')
+ TestSuffix('mixin', 'mixin M {}'),
+ TestSuffix('typedef', 'typedef A = B Function(C, D);'),
+ TestSuffix('functionVoid', 'void f() {}'),
+ TestSuffix('functionNonVoid', 'int f() {}'),
+ TestSuffix('var', 'var a;'),
+ TestSuffix('const', 'const a = 0;'),
+ TestSuffix('final', 'final a = 0;'),
+ TestSuffix('getter', 'int get a => 0;'),
+ TestSuffix('setter', 'set a(b) {}')
];
/**
@@ -65,7 +65,7 @@
* can validly be followed by anything that is valid after a part directive.
*/
static final List<TestSuffix> postPartSuffixes = <TestSuffix>[
- new TestSuffix('part', "part 'a.dart';")
+ TestSuffix('part', "part 'a.dart';")
]..addAll(declarationSuffixes);
/**
@@ -74,29 +74,29 @@
* library directive.
*/
static final List<TestSuffix> prePartSuffixes = <TestSuffix>[
- new TestSuffix('import', "import 'a.dart';"),
- new TestSuffix('export', "export 'a.dart';")
+ TestSuffix('import', "import 'a.dart';"),
+ TestSuffix('export', "export 'a.dart';")
]..addAll(postPartSuffixes);
/**
* A list of suffixes that can be used by tests of statements.
*/
static final List<TestSuffix> statementSuffixes = <TestSuffix>[
- new TestSuffix('assert', "assert (true);"),
- new TestSuffix('block', "{}"),
- new TestSuffix('break', "break;"),
- new TestSuffix('continue', "continue;"),
- new TestSuffix('do', "do {} while (true);"),
- new TestSuffix('if', "if (true) {}"),
- new TestSuffix('for', "for (var x in y) {}"),
- new TestSuffix('labeled', "l: {}"),
- new TestSuffix('localFunctionNonVoid', "int f() {}"),
- new TestSuffix('localFunctionVoid', "void f() {}"),
- new TestSuffix('localVariable', "var x;"),
- new TestSuffix('switch', "switch (x) {}"),
- new TestSuffix('try', "try {} finally {}"),
- new TestSuffix('return', "return;"),
- new TestSuffix('while', "while (true) {}"),
+ TestSuffix('assert', "assert (true);"),
+ TestSuffix('block', "{}"),
+ TestSuffix('break', "break;"),
+ TestSuffix('continue', "continue;"),
+ TestSuffix('do', "do {} while (true);"),
+ TestSuffix('if', "if (true) {}"),
+ TestSuffix('for', "for (var x in y) {}"),
+ TestSuffix('labeled', "l: {}"),
+ TestSuffix('localFunctionNonVoid', "int f() {}"),
+ TestSuffix('localFunctionVoid', "void f() {}"),
+ TestSuffix('localVariable', "var x;"),
+ TestSuffix('switch', "switch (x) {}"),
+ TestSuffix('try', "try {} finally {}"),
+ TestSuffix('return', "return;"),
+ TestSuffix('while', "while (true) {}"),
];
/**
@@ -111,7 +111,7 @@
List<TestSuffix> suffixes,
{FeatureSet featureSet,
String head,
- bool includeEof: true,
+ bool includeEof = true,
String tail}) {
group(groupName, () {
for (TestDescriptor descriptor in descriptors) {
@@ -127,7 +127,7 @@
}
if (descriptor.failing != null) {
test('${descriptor.name}_failingList', () {
- Set<String> failing = new Set.from(descriptor.failing);
+ Set<String> failing = Set.from(descriptor.failing);
if (includeEof) {
failing.remove('eof');
}
@@ -151,9 +151,9 @@
//
// Compose the invalid and valid pieces of code.
//
- StringBuffer invalid = new StringBuffer();
- StringBuffer valid = new StringBuffer();
- StringBuffer base = new StringBuffer();
+ StringBuffer invalid = StringBuffer();
+ StringBuffer valid = StringBuffer();
+ StringBuffer base = StringBuffer();
if (head != null) {
invalid.write(head);
valid.write(head);
@@ -179,7 +179,7 @@
// invalid code.
//
GatheringErrorListener listener =
- new GatheringErrorListener(checkRanges: true);
+ GatheringErrorListener(checkRanges: true);
parseCompilationUnit2(base.toString(), listener, featureSet: featureSet);
var baseErrorCodes = <ErrorCode>[];
listener.errors.forEach((AnalysisError error) {
@@ -284,7 +284,7 @@
* Initialize a newly created test descriptor.
*/
TestDescriptor(this.name, this.invalid, this.errorCodes, this.valid,
- {this.allFailing: false,
+ {this.allFailing = false,
this.failing,
this.expectedErrorsInValidCode,
this.adjustValidUnitBeforeComparison});
@@ -294,7 +294,7 @@
* A description of a set of suffixes that are to be used to construct tests.
*/
class TestSuffix {
- static final TestSuffix eof = new TestSuffix('eof', '');
+ static final TestSuffix eof = TestSuffix('eof', '');
/**
* The name of the suffix.
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/return_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/return_statement_test.dart
index a56d5b1..5f9837e 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/return_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/return_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new ReturnStatementTest().buildAll();
+ ReturnStatementTest().buildAll();
}
class ReturnStatementTest extends PartialCodeTest {
@@ -15,10 +15,10 @@
buildTests(
'return_statement',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword', 'return', [ParserErrorCode.EXPECTED_TOKEN], "return;",
allFailing: true),
- new TestDescriptor('expression', 'return a',
+ TestDescriptor('expression', 'return a',
[ParserErrorCode.EXPECTED_TOKEN], "return a;"),
],
PartialCodeTest.statementSuffixes,
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/switch_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/switch_statement_test.dart
index 914e1f6..db6a41f 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/switch_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/switch_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new SwitchStatementTest().buildAll();
+ SwitchStatementTest().buildAll();
}
class SwitchStatementTest extends PartialCodeTest {
@@ -17,7 +17,7 @@
buildTests(
'switch_statement',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'switch',
[
@@ -27,7 +27,7 @@
],
"switch (_s_) {}",
failing: ['block']),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'switch (',
[
@@ -44,16 +44,16 @@
'localFunctionVoid',
'return'
]),
- new TestDescriptor(
+ TestDescriptor(
'expression',
'switch (a',
[ParserErrorCode.EXPECTED_BODY, ScannerErrorCode.EXPECTED_TOKEN],
"switch (a) {}",
failing: ['block']),
- new TestDescriptor('rightParen', 'switch (a)',
+ TestDescriptor('rightParen', 'switch (a)',
[ParserErrorCode.EXPECTED_BODY], "switch (a) {}",
failing: ['block']),
- new TestDescriptor('leftBrace', 'switch (a) {',
+ TestDescriptor('leftBrace', 'switch (a) {',
[ScannerErrorCode.EXPECTED_TOKEN], "switch (a) {}",
failing: allExceptEof),
],
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/top_level_variable_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/top_level_variable_test.dart
index 06a3ef6..e57c5c8 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/top_level_variable_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/top_level_variable_test.dart
@@ -8,7 +8,7 @@
import 'partial_code_support.dart';
main() {
- new TopLevelVariableTest().buildAll();
+ TopLevelVariableTest().buildAll();
}
class TopLevelVariableTest extends PartialCodeTest {
@@ -16,7 +16,7 @@
buildTests(
'top_level_variable',
[
- new TestDescriptor(
+ TestDescriptor(
'const',
'const',
[
@@ -35,7 +35,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'constName',
'const a',
[
@@ -48,7 +48,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'constTypeName',
'const int a',
[
@@ -60,7 +60,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'constNameComma',
'const a,',
[
@@ -75,7 +75,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'constTypeNameComma',
'const int a,',
[
@@ -90,7 +90,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'constNameCommaName',
'const a, b',
[
@@ -104,7 +104,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'constTypeNameCommaName',
'const int a, b',
[
@@ -118,7 +118,7 @@
CompileTimeErrorCode.CONST_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'final',
'final',
[
@@ -137,7 +137,7 @@
StaticWarningCode.FINAL_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'finalName',
'final a',
[
@@ -150,7 +150,7 @@
StaticWarningCode.FINAL_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'finalTypeName',
'final int a',
[
@@ -162,7 +162,7 @@
StaticWarningCode.FINAL_NOT_INITIALIZED
],
),
- new TestDescriptor(
+ TestDescriptor(
'type',
'int',
[
@@ -172,13 +172,13 @@
"int _s_;",
allFailing: true,
),
- new TestDescriptor(
+ TestDescriptor(
'typeName',
'int a',
[ParserErrorCode.EXPECTED_TOKEN],
"int a;",
),
- new TestDescriptor(
+ TestDescriptor(
'var',
'var',
[
@@ -188,14 +188,14 @@
"var _s_;",
failing: ['functionVoid', 'functionNonVoid', 'getter', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'varName',
'var a',
[ParserErrorCode.EXPECTED_TOKEN],
"var a;",
failing: ['functionNonVoid', 'getter', 'mixin', 'setter'],
),
- new TestDescriptor(
+ TestDescriptor(
'varNameEquals',
'var a =',
[
@@ -215,7 +215,7 @@
'setter'
],
),
- new TestDescriptor(
+ TestDescriptor(
'varNameEqualsExpression',
'var a = b',
[ParserErrorCode.EXPECTED_TOKEN],
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/try_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/try_statement_test.dart
index 1e2f8a5..e00bf9f 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/try_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/try_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new TryStatementTest().buildAll();
+ TryStatementTest().buildAll();
}
class TryStatementTest extends PartialCodeTest {
@@ -18,7 +18,7 @@
//
// No clauses.
//
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'try',
[
@@ -27,13 +27,13 @@
],
"try {} finally {}",
allFailing: true),
- new TestDescriptor('noCatchOrFinally', 'try {}',
+ TestDescriptor('noCatchOrFinally', 'try {}',
[ParserErrorCode.MISSING_CATCH_OR_FINALLY], "try {} finally {}",
allFailing: true),
//
// Single on clause.
//
- new TestDescriptor(
+ TestDescriptor(
'on',
'try {} on',
[
@@ -47,19 +47,19 @@
'localFunctionNonVoid',
'localFunctionVoid'
]),
- new TestDescriptor('on_identifier', 'try {} on A',
+ TestDescriptor('on_identifier', 'try {} on A',
[ParserErrorCode.EXPECTED_BODY], "try {} on A {}",
failing: ['block']),
//
// Single catch clause.
//
- new TestDescriptor(
+ TestDescriptor(
'catch',
'try {} catch',
[ParserErrorCode.CATCH_SYNTAX, ParserErrorCode.EXPECTED_BODY],
"try {} catch (e) {}",
failing: ['block']),
- new TestDescriptor(
+ TestDescriptor(
'catch_leftParen',
'try {} catch (',
[
@@ -69,7 +69,7 @@
],
"try {} catch (e) {}",
failing: ['block', 'labeled', 'localFunctionNonVoid']),
- new TestDescriptor(
+ TestDescriptor(
'catch_identifier',
'try {} catch (e',
[
@@ -79,7 +79,7 @@
],
"try {} catch (e) {}",
failing: ['eof', 'block']),
- new TestDescriptor(
+ TestDescriptor(
'catch_identifierComma',
'try {} catch (e, ',
[
@@ -89,7 +89,7 @@
],
"try {} catch (e, _s_) {}",
failing: ['block', 'labeled', 'localFunctionNonVoid']),
- new TestDescriptor(
+ TestDescriptor(
'catch_identifierCommaIdentifier',
'try {} catch (e, s',
[
@@ -101,19 +101,19 @@
],
"try {} catch (e, s) {}",
failing: ['eof', 'block']),
- new TestDescriptor('catch_rightParen', 'try {} catch (e, s)',
+ TestDescriptor('catch_rightParen', 'try {} catch (e, s)',
[ParserErrorCode.EXPECTED_BODY], "try {} catch (e, s) {}",
failing: ['block']),
//
// Single catch clause after an on clause.
//
- new TestDescriptor(
+ TestDescriptor(
'on_catch',
'try {} on A catch',
[ParserErrorCode.CATCH_SYNTAX, ParserErrorCode.EXPECTED_BODY],
"try {} on A catch (e) {}",
failing: ['block']),
- new TestDescriptor(
+ TestDescriptor(
'on_catch_leftParen',
'try {} on A catch (',
[
@@ -123,7 +123,7 @@
],
"try {} on A catch (e) {}",
failing: ['block', 'labeled', 'localFunctionNonVoid']),
- new TestDescriptor(
+ TestDescriptor(
'on_catch_identifier',
'try {} on A catch (e',
[
@@ -133,7 +133,7 @@
],
"try {} on A catch (e) {}",
failing: ['eof', 'block']),
- new TestDescriptor(
+ TestDescriptor(
'on_catch_identifierComma',
'try {} on A catch (e, ',
[
@@ -143,7 +143,7 @@
],
"try {} on A catch (e, _s_) {}",
failing: ['block', 'labeled', 'localFunctionNonVoid']),
- new TestDescriptor(
+ TestDescriptor(
'on_catch_identifierCommaIdentifier',
'try {} on A catch (e, s',
[
@@ -155,23 +155,20 @@
],
"try {} on A catch (e, s) {}",
failing: ['eof', 'block']),
- new TestDescriptor('on_catch_rightParen', 'try {} on A catch (e, s)',
+ TestDescriptor('on_catch_rightParen', 'try {} on A catch (e, s)',
[ParserErrorCode.EXPECTED_BODY], "try {} on A catch (e, s) {}",
failing: ['block']),
//
// Only a finally clause.
//
- new TestDescriptor('finally_noCatch_noBlock', 'try {} finally',
+ TestDescriptor('finally_noCatch_noBlock', 'try {} finally',
[ParserErrorCode.EXPECTED_BODY], "try {} finally {}",
failing: ['block']),
//
// A catch and finally clause.
//
- new TestDescriptor(
- 'finally_catch_noBlock',
- 'try {} catch (e) {} finally',
- [ParserErrorCode.EXPECTED_BODY],
- "try {} catch (e) {} finally {}",
+ TestDescriptor('finally_catch_noBlock', 'try {} catch (e) {} finally',
+ [ParserErrorCode.EXPECTED_BODY], "try {} catch (e) {} finally {}",
failing: ['block']),
],
PartialCodeTest.statementSuffixes,
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/typedef_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/typedef_test.dart
index f961ba7..fc7f670 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/typedef_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/typedef_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new TypedefTest().buildAll();
+ TypedefTest().buildAll();
}
class TypedefTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'typedef',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'typedef',
[
@@ -25,7 +25,7 @@
],
"typedef _s_();",
failing: ['functionVoid', 'functionNonVoid', 'getter']),
- new TestDescriptor(
+ TestDescriptor(
'name',
'typedef T',
[
@@ -34,7 +34,7 @@
],
"typedef T();",
failing: ['functionNonVoid', 'getter', 'mixin', 'setter']),
- new TestDescriptor(
+ TestDescriptor(
'keywordEquals',
'typedef =',
[
@@ -44,7 +44,7 @@
],
"typedef _s_ = _s_;",
allFailing: true),
- new TestDescriptor(
+ TestDescriptor(
'equals',
'typedef T =',
[
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/while_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/while_statement_test.dart
index 7a01697..284b394 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/while_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/while_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new WhileStatementTest().buildAll();
+ WhileStatementTest().buildAll();
}
class WhileStatementTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'while_statement',
<TestDescriptor>[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'while',
[
@@ -30,7 +30,7 @@
ParserErrorCode.EXPECTED_TOKEN
],
),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'while (',
[
@@ -45,7 +45,7 @@
ParserErrorCode.EXPECTED_TOKEN
],
),
- new TestDescriptor(
+ TestDescriptor(
'condition',
'while (a',
[
@@ -67,14 +67,14 @@
buildTests(
'while_statement',
<TestDescriptor>[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'while',
[ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN],
"while (_s_)",
failing: ['break', 'continue'],
),
- new TestDescriptor(
+ TestDescriptor(
'leftParen',
'while (',
[ParserErrorCode.MISSING_IDENTIFIER, ScannerErrorCode.EXPECTED_TOKEN],
@@ -90,7 +90,7 @@
'return'
],
),
- new TestDescriptor(
+ TestDescriptor(
'condition',
'while (a',
[ScannerErrorCode.EXPECTED_TOKEN],
diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/yield_statement_test.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/yield_statement_test.dart
index f97da43..7c74a48 100644
--- a/pkg/analyzer/test/src/fasta/recovery/partial_code/yield_statement_test.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/yield_statement_test.dart
@@ -7,7 +7,7 @@
import 'partial_code_support.dart';
main() {
- new YieldStatementTest().buildAll();
+ YieldStatementTest().buildAll();
}
class YieldStatementTest extends PartialCodeTest {
@@ -15,7 +15,7 @@
buildTests(
'yield_statement',
[
- new TestDescriptor(
+ TestDescriptor(
'keyword',
'yield',
[
@@ -31,9 +31,9 @@
'localFunctionVoid',
'return',
]),
- new TestDescriptor('expression', 'yield a',
+ TestDescriptor('expression', 'yield a',
[ParserErrorCode.EXPECTED_TOKEN], "yield a;"),
- new TestDescriptor(
+ TestDescriptor(
'star',
'yield *',
[
@@ -49,7 +49,7 @@
'localFunctionVoid',
'return',
]),
- new TestDescriptor('star_expression', 'yield * a',
+ TestDescriptor('star_expression', 'yield * a',
[ParserErrorCode.EXPECTED_TOKEN], "yield * a;"),
],
PartialCodeTest.statementSuffixes,
diff --git a/pkg/analyzer/test/src/fasta/recovery/recovery_test_support.dart b/pkg/analyzer/test/src/fasta/recovery/recovery_test_support.dart
index 3f5de77..4504c95 100644
--- a/pkg/analyzer/test/src/fasta/recovery/recovery_test_support.dart
+++ b/pkg/analyzer/test/src/fasta/recovery/recovery_test_support.dart
@@ -39,8 +39,7 @@
}
// Compare the structures before asserting valid errors.
- GatheringErrorListener listener =
- new GatheringErrorListener(checkRanges: true);
+ GatheringErrorListener listener = GatheringErrorListener(checkRanges: true);
CompilationUnit invalidUnit =
parseCompilationUnit2(invalidCode, listener, featureSet: featureSet);
validateTokenStream(invalidUnit.beginToken);
@@ -77,7 +76,7 @@
*/
class ResultComparator extends AstComparator {
bool failDifferentLength(List first, List second) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.writeln('Expected a list of length ${second.length}');
buffer.writeln(' $second');
buffer.writeln('But found a list of length ${first.length}');
@@ -91,7 +90,7 @@
@override
bool failIfNotNull(Object first, Object second) {
if (second != null) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write('Expected null; found a ');
buffer.writeln(second.runtimeType);
if (second is AstNode) {
@@ -104,7 +103,7 @@
@override
bool failIsNull(Object first, Object second) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write('Expected a ');
buffer.write(first.runtimeType);
buffer.writeln('; found null');
@@ -116,7 +115,7 @@
@override
bool failRuntimeType(Object first, Object second) {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
buffer.write('Expected a ');
buffer.writeln(second.runtimeType);
buffer.write('; found ');
@@ -173,7 +172,7 @@
* different.
*/
static void compare(AstNode actual, AstNode expected) {
- ResultComparator comparator = new ResultComparator();
+ ResultComparator comparator = ResultComparator();
if (!comparator.isEqualNodes(actual, expected)) {
fail('Expected: $expected\n Found: $actual');
}
diff --git a/pkg/analyzer/test/src/hint/sdk_constraint_extractor_test.dart b/pkg/analyzer/test/src/hint/sdk_constraint_extractor_test.dart
index 76974b6..5d90e76 100644
--- a/pkg/analyzer/test/src/hint/sdk_constraint_extractor_test.dart
+++ b/pkg/analyzer/test/src/hint/sdk_constraint_extractor_test.dart
@@ -19,7 +19,7 @@
SdkConstraintExtractor extractorFor(String pubspecContent) {
String pubspecPath = '/pkg/test/pubspec.yaml';
File pubspecFile = newFile(pubspecPath, content: pubspecContent);
- return new SdkConstraintExtractor(pubspecFile);
+ return SdkConstraintExtractor(pubspecFile);
}
test_constraint_any() {
diff --git a/pkg/analyzer/test/src/lint/config_test.dart b/pkg/analyzer/test/src/lint/config_test.dart
index 082b835..cf75cf2 100644
--- a/pkg/analyzer/test/src/lint/config_test.dart
+++ b/pkg/analyzer/test/src/lint/config_test.dart
@@ -33,7 +33,7 @@
// - param1
// - param2
- var config = new LintConfig.parse(src);
+ var config = LintConfig.parse(src);
group('lint config', () {
group('file', () {
@@ -51,7 +51,7 @@
});
test('config', () {
- config = new LintConfig.parse('''
+ config = LintConfig.parse('''
rules:
style_guide:
unnecessary_getters: false''');
diff --git a/pkg/analyzer/test/src/lint/io_test.dart b/pkg/analyzer/test/src/lint/io_test.dart
index e92b940..631bacf 100644
--- a/pkg/analyzer/test/src/lint/io_test.dart
+++ b/pkg/analyzer/test/src/lint/io_test.dart
@@ -49,20 +49,20 @@
group('processing', () {
group('files', () {
test('dart', () {
- var file = new File('foo.dart');
+ var file = File('foo.dart');
expect(isLintable(file), isTrue);
});
test('pubspec', () {
- var file = new File('pubspec.yaml');
+ var file = File('pubspec.yaml');
expect(isLintable(file), isTrue);
});
test('_pubspec', () {
// Analyzable for testing purposes
- var file = new File('_pubspec.yaml');
+ var file = File('_pubspec.yaml');
expect(isLintable(file), isTrue);
});
test('text', () {
- var file = new File('foo.txt');
+ var file = File('foo.txt');
expect(isLintable(file), isFalse);
});
test('hidden dirs', () {
diff --git a/pkg/analyzer/test/src/lint/lint_rule_test.dart b/pkg/analyzer/test/src/lint/lint_rule_test.dart
index 55b1e3e5..be564a8 100644
--- a/pkg/analyzer/test/src/lint/lint_rule_test.dart
+++ b/pkg/analyzer/test/src/lint/lint_rule_test.dart
@@ -21,8 +21,8 @@
group('error code reporting', () {
test('reportLintForToken (custom)', () {
final rule = TestRule();
- final reporter = CollectingReporter(
- GatheringErrorListener(), new _MockSource('mock'));
+ final reporter =
+ CollectingReporter(GatheringErrorListener(), _MockSource('mock'));
rule.reporter = reporter;
rule.reportLintForToken(Token.eof(0),
@@ -31,8 +31,8 @@
});
test('reportLintForToken (default)', () {
final rule = TestRule();
- final reporter = CollectingReporter(
- GatheringErrorListener(), new _MockSource('mock'));
+ final reporter =
+ CollectingReporter(GatheringErrorListener(), _MockSource('mock'));
rule.reporter = reporter;
rule.reportLintForToken(Token.eof(0), ignoreSyntheticTokens: false);
@@ -40,23 +40,21 @@
});
test('reportLint (custom)', () {
final rule = TestRule();
- final reporter = CollectingReporter(
- GatheringErrorListener(), new _MockSource('mock'));
+ final reporter =
+ CollectingReporter(GatheringErrorListener(), _MockSource('mock'));
rule.reporter = reporter;
- final node =
- EmptyStatementImpl(new SimpleToken(TokenType.SEMICOLON, 0));
+ final node = EmptyStatementImpl(SimpleToken(TokenType.SEMICOLON, 0));
rule.reportLint(node, errorCode: customCode);
expect(reporter.code, customCode);
});
test('reportLint (default)', () {
final rule = TestRule();
- final reporter = CollectingReporter(
- GatheringErrorListener(), new _MockSource('mock'));
+ final reporter =
+ CollectingReporter(GatheringErrorListener(), _MockSource('mock'));
rule.reporter = reporter;
- final node =
- EmptyStatementImpl(new SimpleToken(TokenType.SEMICOLON, 0));
+ final node = EmptyStatementImpl(SimpleToken(TokenType.SEMICOLON, 0));
rule.reportLint(node);
expect(reporter.code, rule.lintCode);
});
@@ -108,6 +106,6 @@
@override
noSuchMethod(Invocation invocation) {
- throw new StateError('Unexpected invocation of ${invocation.memberName}');
+ throw StateError('Unexpected invocation of ${invocation.memberName}');
}
}
diff --git a/pkg/analyzer/test/src/lint/linter/linter_context_impl_test.dart b/pkg/analyzer/test/src/lint/linter/linter_context_impl_test.dart
index 754b7ad..935406a 100644
--- a/pkg/analyzer/test/src/lint/linter/linter_context_impl_test.dart
+++ b/pkg/analyzer/test/src/lint/linter/linter_context_impl_test.dart
@@ -29,14 +29,14 @@
var contextUnit = LinterContextUnit(result.content, result.unit);
final libraryPath = result.libraryElement.source.fullName;
- final builder = new ContextBuilder(
+ final builder = ContextBuilder(
resourceProvider, null /* sdkManager */, null /* contentCache */);
// todo (pq): get workspace from analysis context
final workspace =
ContextBuilder.createWorkspace(resourceProvider, libraryPath, builder);
final workspacePackage = workspace.findPackageFor(libraryPath);
- context = new LinterContextImpl(
+ context = LinterContextImpl(
[contextUnit],
contextUnit,
result.session.declaredVariables,
diff --git a/pkg/analyzer/test/src/lint/pub_test.dart b/pkg/analyzer/test/src/lint/pub_test.dart
index ea778f3..3224300 100644
--- a/pkg/analyzer/test/src/lint/pub_test.dart
+++ b/pkg/analyzer/test/src/lint/pub_test.dart
@@ -43,7 +43,7 @@
foo: 1.2.0
""";
- Pubspec ps = new Pubspec.parse(src);
+ Pubspec ps = Pubspec.parse(src);
group('pubspec', () {
group('basic', () {
diff --git a/pkg/analyzer/test/src/manifest/manifest_validator_test.dart b/pkg/analyzer/test/src/manifest/manifest_validator_test.dart
index 80f825a..a7d53c6 100644
--- a/pkg/analyzer/test/src/manifest/manifest_validator_test.dart
+++ b/pkg/analyzer/test/src/manifest/manifest_validator_test.dart
@@ -28,7 +28,7 @@
*/
void assertErrors(String content, List<ErrorCode> expectedErrorCodes) {
List<AnalysisError> errors = validator.validate(content, true);
- GatheringErrorListener listener = new GatheringErrorListener();
+ GatheringErrorListener listener = GatheringErrorListener();
listener.addAll(errors);
listener.assertErrorsWithCodes(expectedErrorCodes);
}
@@ -44,7 +44,7 @@
void setUp() {
File ManifestFile = getFile('/sample/Manifest.xml');
Source source = ManifestFile.createSource();
- validator = new ManifestValidator(source);
+ validator = ManifestValidator(source);
}
test_hardwareNotSupported_error() {
diff --git a/pkg/analyzer/test/src/options/options_rule_validator_test.dart b/pkg/analyzer/test/src/options/options_rule_validator_test.dart
index c4aa442..8d5514c 100644
--- a/pkg/analyzer/test/src/options/options_rule_validator_test.dart
+++ b/pkg/analyzer/test/src/options/options_rule_validator_test.dart
@@ -29,17 +29,17 @@
@reflectiveTest
class OptionsRuleValidatorTest extends Object with ResourceProviderMixin {
- LinterRuleOptionsValidator validator = new LinterRuleOptionsValidator(
- provider: () => [new DeprecatedLint(), new StableLint()]);
+ LinterRuleOptionsValidator validator = LinterRuleOptionsValidator(
+ provider: () => [DeprecatedLint(), StableLint()]);
/**
* Assert that when the validator is used on the given [content] the
* [expectedErrorCodes] are produced.
*/
void assertErrors(String content, List<ErrorCode> expectedErrorCodes) {
- GatheringErrorListener listener = new GatheringErrorListener();
- ErrorReporter reporter = new ErrorReporter(
- listener, new StringSource(content, 'analysis_options.yaml'));
+ GatheringErrorListener listener = GatheringErrorListener();
+ ErrorReporter reporter =
+ ErrorReporter(listener, StringSource(content, 'analysis_options.yaml'));
validator.validate(reporter, loadYamlNode(content));
listener.assertErrorsWithCodes(expectedErrorCodes);
}
diff --git a/pkg/analyzer/test/src/pubspec/pubspec_validator_test.dart b/pkg/analyzer/test/src/pubspec/pubspec_validator_test.dart
index ef1cc99..509b3b4 100644
--- a/pkg/analyzer/test/src/pubspec/pubspec_validator_test.dart
+++ b/pkg/analyzer/test/src/pubspec/pubspec_validator_test.dart
@@ -31,10 +31,10 @@
YamlNode node = loadYamlNode(content);
if (node is! YamlMap) {
// The file is empty.
- node = new YamlMap();
+ node = YamlMap();
}
List<AnalysisError> errors = validator.validate((node as YamlMap).nodes);
- GatheringErrorListener listener = new GatheringErrorListener();
+ GatheringErrorListener listener = GatheringErrorListener();
listener.addAll(errors);
listener.assertErrorsWithCodes(expectedErrorCodes);
}
@@ -50,7 +50,7 @@
void setUp() {
File pubspecFile = getFile('/sample/pubspec.yaml');
Source source = pubspecFile.createSource();
- validator = new PubspecValidator(resourceProvider, source);
+ validator = PubspecValidator(resourceProvider, source);
}
test_assetDirectoryDoesExists_noError() {
diff --git a/pkg/analyzer/test/src/services/available_declarations_test.dart b/pkg/analyzer/test/src/services/available_declarations_test.dart
index 0a3945b..a64dc09 100644
--- a/pkg/analyzer/test/src/services/available_declarations_test.dart
+++ b/pkg/analyzer/test/src/services/available_declarations_test.dart
@@ -103,7 +103,7 @@
}
setUp() {
- new MockSdk(resourceProvider: resourceProvider);
+ MockSdk(resourceProvider: resourceProvider);
newFolder('/home/test');
newFile('/home/test/.packages', content: '''
@@ -241,8 +241,8 @@
}
static Future pumpEventQueue([int times = 5000]) {
- if (times == 0) return new Future.value();
- return new Future.delayed(Duration.zero, () => pumpEventQueue(times - 1));
+ if (times == 0) return Future.value();
+ return Future.delayed(Duration.zero, () => pumpEventQueue(times - 1));
}
}
@@ -3168,7 +3168,7 @@
final String name;
final List<_ExpectedDeclaration> children;
- _ExpectedDeclaration(this.kind, this.name, {this.children: const []});
+ _ExpectedDeclaration(this.kind, this.name, {this.children = const []});
_ExpectedDeclaration.class_(String name, List<_ExpectedDeclaration> children)
: this(DeclarationKind.CLASS, name, children: children);
diff --git a/pkg/analyzer/test/src/source/source_resource_test.dart b/pkg/analyzer/test/src/source/source_resource_test.dart
index 81dbccc..29cbc93 100644
--- a/pkg/analyzer/test/src/source/source_resource_test.dart
+++ b/pkg/analyzer/test/src/source/source_resource_test.dart
@@ -25,22 +25,22 @@
void test_equals_false_differentFiles() {
File file1 = getFile("/does/not/exist1.dart");
File file2 = getFile("/does/not/exist2.dart");
- FileSource source1 = new FileSource(file1);
- FileSource source2 = new FileSource(file2);
+ FileSource source1 = FileSource(file1);
+ FileSource source2 = FileSource(file2);
expect(source1 == source2, isFalse);
}
void test_equals_false_null() {
File file = getFile("/does/not/exist1.dart");
- FileSource source1 = new FileSource(file);
+ FileSource source1 = FileSource(file);
expect(source1 == null, isFalse);
}
void test_equals_true() {
File file1 = getFile("/does/not/exist.dart");
File file2 = getFile("/does/not/exist.dart");
- FileSource source1 = new FileSource(file1);
- FileSource source2 = new FileSource(file2);
+ FileSource source1 = FileSource(file1);
+ FileSource source2 = FileSource(file2);
expect(source1 == source2, isTrue);
}
@@ -87,28 +87,28 @@
void test_getFullName() {
File file = getFile("/does/not/exist.dart");
- FileSource source = new FileSource(file);
+ FileSource source = FileSource(file);
expect(source.fullName, file.path);
}
void test_getShortName() {
File file = getFile("/does/not/exist.dart");
- FileSource source = new FileSource(file);
+ FileSource source = FileSource(file);
expect(source.shortName, "exist.dart");
}
void test_hashCode() {
File file1 = getFile("/does/not/exist.dart");
File file2 = getFile("/does/not/exist.dart");
- FileSource source1 = new FileSource(file1);
- FileSource source2 = new FileSource(file2);
+ FileSource source1 = FileSource(file1);
+ FileSource source2 = FileSource(file2);
expect(source2.hashCode, source1.hashCode);
}
void test_isInSystemLibrary_contagious() {
DartSdk sdk = _createSdk();
- UriResolver resolver = new DartUriResolver(sdk);
- SourceFactory factory = new SourceFactory([resolver]);
+ UriResolver resolver = DartUriResolver(sdk);
+ SourceFactory factory = SourceFactory([resolver]);
// resolve dart:core
Source result = resolver.resolveAbsolute(Uri.parse("dart:async"));
expect(result, isNotNull);
@@ -121,7 +121,7 @@
void test_isInSystemLibrary_false() {
File file = getFile("/does/not/exist.dart");
- FileSource source = new FileSource(file);
+ FileSource source = FileSource(file);
expect(source, isNotNull);
expect(source.fullName, file.path);
expect(source.isInSystemLibrary, isFalse);
@@ -129,7 +129,7 @@
void test_issue14500() {
// see https://code.google.com/p/dart/issues/detail?id=14500
- FileSource source = new FileSource(getFile("/some/packages/foo:bar.dart"));
+ FileSource source = FileSource(getFile("/some/packages/foo:bar.dart"));
expect(source, isNotNull);
expect(source.exists(), isFalse);
}
@@ -142,7 +142,7 @@
return;
}
File file = getFile("/a/b/test.dart");
- FileSource source = new FileSource(file);
+ FileSource source = FileSource(file);
expect(source, isNotNull);
Uri relative = resolveRelativeUri(source.uri, Uri.parse("lib.dart"));
expect(relative, isNotNull);
@@ -157,7 +157,7 @@
return;
}
File file = getFile("/a/b/test.dart");
- FileSource source = new FileSource(file);
+ FileSource source = FileSource(file);
expect(source, isNotNull);
Uri relative = resolveRelativeUri(source.uri, Uri.parse("c/lib.dart"));
expect(relative, isNotNull);
@@ -171,7 +171,7 @@
return;
}
File file = getFile("/a/b/test.dart");
- FileSource source = new FileSource(file);
+ FileSource source = FileSource(file);
expect(source, isNotNull);
Uri relative = resolveRelativeUri(source.uri, Uri.parse("../c/lib.dart"));
expect(relative, isNotNull);
@@ -180,13 +180,13 @@
void test_system() {
File file = getFile("/does/not/exist.dart");
- FileSource source = new FileSource(file, Uri.parse("dart:core"));
+ FileSource source = FileSource(file, Uri.parse("dart:core"));
expect(source, isNotNull);
expect(source.fullName, file.path);
expect(source.isInSystemLibrary, isTrue);
}
DartSdk _createSdk() {
- return new MockSdk(resourceProvider: resourceProvider);
+ return MockSdk(resourceProvider: resourceProvider);
}
}
diff --git a/pkg/analyzer/test/src/summary/api_signature_test.dart b/pkg/analyzer/test/src/summary/api_signature_test.dart
index 42c7caa..3d688bd 100644
--- a/pkg/analyzer/test/src/summary/api_signature_test.dart
+++ b/pkg/analyzer/test/src/summary/api_signature_test.dart
@@ -16,7 +16,7 @@
@reflectiveTest
class ApiSignatureTest {
- ApiSignature sig = new ApiSignature.unversioned();
+ ApiSignature sig = ApiSignature.unversioned();
void checkBytes(List<int> bytes) {
expect(sig.getBytes_forDebug(), bytes);
diff --git a/pkg/analyzer/test/src/summary/dependency_walker_test.dart b/pkg/analyzer/test/src/summary/dependency_walker_test.dart
index 1e4e9dc..716531bb 100644
--- a/pkg/analyzer/test/src/summary/dependency_walker_test.dart
+++ b/pkg/analyzer/test/src/summary/dependency_walker_test.dart
@@ -25,7 +25,7 @@
}
TestNode getNode(String name) =>
- nodes.putIfAbsent(name, () => new TestNode(name));
+ nodes.putIfAbsent(name, () => TestNode(name));
void makeGraph(Map<String, List<String>> graph) {
graph.forEach((name, deps) {
@@ -171,7 +171,7 @@
}
TestWalker walk(String startingNodeName) =>
- new TestWalker()..walk(getNode(startingNodeName));
+ TestWalker()..walk(getNode(startingNodeName));
}
class TestNode extends Node<TestNode> {
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 0555d63..bb6fdd6 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -7,7 +7,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart';
@@ -46,7 +45,7 @@
newCode =
newCode.substring(0, r.offset) + r.text + newCode.substring(r.end);
});
- new File(_testPath).writeAsStringSync(newCode);
+ File(_testPath).writeAsStringSync(newCode);
}
}
@@ -58,17 +57,17 @@
void checkElementText(
LibraryElement library,
String expected, {
- bool withCodeRanges: false,
- bool withConstElements: true,
- bool withExportScope: false,
- bool withFullyResolvedAst: false,
- bool withOffsets: false,
- bool withSyntheticAccessors: false,
- bool withSyntheticFields: false,
- bool withTypes: false,
- bool annotateNullability: false,
+ bool withCodeRanges = false,
+ bool withConstElements = true,
+ bool withExportScope = false,
+ bool withFullyResolvedAst = false,
+ bool withOffsets = false,
+ bool withSyntheticAccessors = false,
+ bool withSyntheticFields = false,
+ bool withTypes = false,
+ bool annotateNullability = false,
}) {
- var writer = new _ElementWriter(
+ var writer = _ElementWriter(
selfUriStr: '${library.source.uri}',
withCodeRanges: withCodeRanges,
withConstElements: withConstElements,
@@ -88,8 +87,8 @@
if (_testPath != null && actualText != expected) {
if (_testCode == null) {
- _testCode = new File(_testPath).readAsStringSync();
- _testCodeLines = new LineInfo.fromContent(_testCode);
+ _testCode = File(_testPath).readAsStringSync();
+ _testCodeLines = LineInfo.fromContent(_testCode);
}
try {
@@ -122,8 +121,8 @@
expectationOffset += rawStringPrefix.length;
int expectationEnd = _testCode.indexOf("'''", expectationOffset);
- _replacements.add(new _Replacement(
- expectationOffset, expectationEnd, '\n' + actualText));
+ _replacements.add(
+ _Replacement(expectationOffset, expectationEnd, '\n' + actualText));
}
}
@@ -150,21 +149,21 @@
final bool withSyntheticFields;
final bool withTypes;
final bool annotateNullability;
- final StringBuffer buffer = new StringBuffer();
+ final StringBuffer buffer = StringBuffer();
String indent = '';
_ElementWriter({
this.selfUriStr,
this.withCodeRanges,
- this.withConstElements: true,
- this.withExportScope: false,
- this.withFullyResolvedAst: false,
- this.withOffsets: false,
- this.withSyntheticAccessors: false,
- this.withSyntheticFields: false,
- this.withTypes: false,
- this.annotateNullability: false,
+ this.withConstElements = true,
+ this.withExportScope = false,
+ this.withFullyResolvedAst = false,
+ this.withOffsets = false,
+ this.withSyntheticAccessors = false,
+ this.withSyntheticFields = false,
+ this.withTypes = false,
+ this.annotateNullability = false,
});
bool isDynamicType(DartType type) => type is DynamicTypeImpl;
@@ -223,7 +222,7 @@
if (e.isMixin) {
if (e.superclassConstraints.isEmpty) {
- throw new StateError('At least Object is expected.');
+ throw StateError('At least Object is expected.');
}
writeList(' on ', '', e.superclassConstraints, ', ', writeType);
}
@@ -504,7 +503,7 @@
void writeList<T>(String open, String close, List<T> items, String separator,
writeItem(T item),
- {bool includeEmpty: false}) {
+ {bool includeEmpty = false}) {
if (!includeEmpty && items.isEmpty) {
return;
}
@@ -1030,45 +1029,11 @@
}
void writeType(DartType type) {
- if (type is InterfaceType) {
- buffer.write(type.element.name);
- if (type.element.typeParameters.isNotEmpty) {
- writeList('<', '>', type.typeArguments, ', ', writeType);
- }
- } else if (type is FunctionType) {
- writeType2(type.returnType);
- buffer.write('Function');
- writeTypeParameterElements(type.typeFormals);
- buffer.write('(');
- bool commaNeeded = false;
- commaNeeded = _writeParameters(
- type.parameters.where((p) => p.isRequiredPositional),
- commaNeeded,
- '',
- '');
- commaNeeded = _writeParameters(
- type.parameters.where((p) => p.isOptionalPositional),
- commaNeeded,
- '[',
- ']');
- commaNeeded = _writeParameters(
- type.parameters.where((p) => p.isNamed), commaNeeded, '{', '}');
- buffer.write(')');
- } else {
- buffer.write(type.displayName);
- }
- if (annotateNullability) {
- switch ((type as TypeImpl).nullabilitySuffix) {
- case NullabilitySuffix.none:
- break;
- case NullabilitySuffix.question:
- buffer.write('?');
- break;
- case NullabilitySuffix.star:
- buffer.write('*');
- break;
- }
- }
+ buffer.write(
+ type.getDisplayString(
+ withNullability: annotateNullability,
+ ),
+ );
}
void writeType2(DartType type) {
@@ -1200,32 +1165,6 @@
buffer.writeln(line);
}
- bool _writeParameters(Iterable<ParameterElement> parameters, bool commaNeeded,
- String prefix, String suffix) {
- if (parameters.isEmpty) return commaNeeded;
- if (commaNeeded) {
- buffer.write(', ');
- commaNeeded = false;
- }
- buffer.write(prefix);
- for (var parameter in parameters) {
- if (commaNeeded) {
- buffer.write(', ');
- }
- if (parameter.isRequiredNamed) {
- buffer.write('required ');
- }
- writeType(parameter.type);
- if (parameter.isNamed) {
- buffer.write(' ');
- buffer.write(parameter.name);
- }
- commaNeeded = true;
- }
- buffer.write(suffix);
- return commaNeeded;
- }
-
void _writeResolvedMetadata(List<ElementAnnotation> metadata) {
if (metadata.isNotEmpty) {
_writelnWithIndent('metadata');
diff --git a/pkg/analyzer/test/src/summary/flat_buffers_test.dart b/pkg/analyzer/test/src/summary/flat_buffers_test.dart
index 405b5ac..6d8e5e5 100644
--- a/pkg/analyzer/test/src/summary/flat_buffers_test.dart
+++ b/pkg/analyzer/test/src/summary/flat_buffers_test.dart
@@ -17,28 +17,28 @@
@reflectiveTest
class BuilderTest {
void test_error_addInt32_withoutStartTable() {
- Builder builder = new Builder();
+ Builder builder = Builder();
expect(() {
builder.addInt32(0, 0);
}, throwsStateError);
}
void test_error_addOffset_withoutStartTable() {
- Builder builder = new Builder();
+ Builder builder = Builder();
expect(() {
- builder.addOffset(0, new Offset(0));
+ builder.addOffset(0, Offset(0));
}, throwsStateError);
}
void test_error_endTable_withoutStartTable() {
- Builder builder = new Builder();
+ Builder builder = Builder();
expect(() {
builder.endTable();
}, throwsStateError);
}
void test_error_startTable_duringTable() {
- Builder builder = new Builder();
+ Builder builder = Builder();
builder.startTable();
expect(() {
builder.startTable();
@@ -46,7 +46,7 @@
}
void test_error_writeString_duringTable() {
- Builder builder = new Builder();
+ Builder builder = Builder();
builder.startTable();
expect(() {
builder.writeString('12345');
@@ -56,7 +56,7 @@
void test_file_identifier() {
Uint8List byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
builder.startTable();
Offset offset = builder.endTable();
byteList = builder.finish(offset, 'Az~ÿ');
@@ -82,7 +82,7 @@
}
void test_low() {
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
builder.lowReset();
expect((builder..lowWriteUint8(1)).lowFinish(), [1]);
expect((builder..lowWriteUint32(2)).lowFinish(), [2, 0, 0, 0, 0, 0, 0, 1]);
@@ -99,7 +99,7 @@
void test_table_default() {
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
builder.startTable();
builder.addInt32(0, 10, 10);
builder.addInt32(1, 20, 10);
@@ -107,7 +107,7 @@
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buffer = new BufferContext.fromBytes(byteList);
+ BufferContext buffer = BufferContext.fromBytes(byteList);
int objectOffset = buffer.derefObject(0);
// was not written, so uses the new default value
expect(const Int32Reader().vTableGet(buffer, objectOffset, 0, 15), 15);
@@ -118,7 +118,7 @@
void test_table_format() {
Uint8List byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
builder.startTable();
builder.addInt32(0, 10);
builder.addInt32(1, 20);
@@ -152,7 +152,7 @@
String unicodeString = 'Проба пера';
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
Offset<String> latinStringOffset = builder.writeString(latinString);
Offset<String> unicodeStringOffset = builder.writeString(unicodeString);
builder.startTable();
@@ -162,7 +162,7 @@
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
+ BufferContext buf = BufferContext.fromBytes(byteList);
int objectOffset = buf.derefObject(0);
expect(const StringReader().vTableGet(buf, objectOffset, 0), latinString);
expect(const StringReader().vTableGet(buf, objectOffset, 1), unicodeString);
@@ -171,7 +171,7 @@
void test_table_types() {
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
Offset<String> stringOffset = builder.writeString('12345');
builder.startTable();
builder.addBool(0, true);
@@ -186,7 +186,7 @@
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
+ BufferContext buf = BufferContext.fromBytes(byteList);
int objectOffset = buf.derefObject(0);
expect(const BoolReader().vTableGet(buf, objectOffset, 0), true);
expect(const Int8Reader().vTableGet(buf, objectOffset, 1), 10);
@@ -203,12 +203,12 @@
// write
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
Offset offset = builder.writeListUint32(values);
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
+ BufferContext buf = BufferContext.fromBytes(byteList);
List<int> items = const Uint32ListReader().read(buf, 0);
expect(items, hasLength(4));
expect(items, orderedEquals(values));
@@ -219,8 +219,8 @@
// write
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
- List<bool> values = new List<bool>.filled(len, false);
+ Builder builder = Builder(initialSize: 0);
+ List<bool> values = List<bool>.filled(len, false);
for (int bit in trueBits) {
values[bit] = true;
}
@@ -228,7 +228,7 @@
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
+ BufferContext buf = BufferContext.fromBytes(byteList);
List<bool> items = const BoolListReader().read(buf, 0);
expect(items, hasLength(len));
for (int i = 0; i < items.length; i++) {
@@ -247,12 +247,12 @@
verifyListBooleans(33, <int>[1, 2, 24, 25, 31, 32]);
verifyListBooleans(63, <int>[]);
verifyListBooleans(63, <int>[0, 1, 2, 61, 62]);
- verifyListBooleans(63, new List<int>.generate(63, (i) => i));
+ verifyListBooleans(63, List<int>.generate(63, (i) => i));
verifyListBooleans(64, <int>[]);
verifyListBooleans(64, <int>[0, 1, 2, 61, 62, 63]);
verifyListBooleans(64, <int>[1, 2, 62]);
verifyListBooleans(64, <int>[0, 1, 2, 63]);
- verifyListBooleans(64, new List<int>.generate(64, (i) => i));
+ verifyListBooleans(64, List<int>.generate(64, (i) => i));
verifyListBooleans(100, <int>[0, 3, 30, 60, 90, 99]);
}
@@ -261,12 +261,12 @@
// write
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
Offset offset = builder.writeListFloat64(values);
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
+ BufferContext buf = BufferContext.fromBytes(byteList);
List<double> items = const Float64ListReader().read(buf, 0);
expect(items, hasLength(5));
expect(items, orderedEquals(values));
@@ -275,12 +275,12 @@
void test_writeList_ofInt32() {
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
Offset offset = builder.writeListInt32(<int>[1, 2, 3, 4, 5]);
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
+ BufferContext buf = BufferContext.fromBytes(byteList);
List<int> items = const ListReader<int>(const Int32Reader()).read(buf, 0);
expect(items, hasLength(5));
expect(items, orderedEquals(<int>[1, 2, 3, 4, 5]));
@@ -289,7 +289,7 @@
void test_writeList_ofObjects() {
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
// write the object #1
Offset object1;
{
@@ -311,7 +311,7 @@
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
+ BufferContext buf = BufferContext.fromBytes(byteList);
List<TestPointImpl> items =
const ListReader<TestPointImpl>(const TestPointReader()).read(buf, 0);
expect(items, hasLength(2));
@@ -324,14 +324,14 @@
void test_writeList_ofStrings_asRoot() {
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
Offset<String> str1 = builder.writeString('12345');
Offset<String> str2 = builder.writeString('ABC');
Offset offset = builder.writeList([str1, str2]);
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
+ BufferContext buf = BufferContext.fromBytes(byteList);
List<String> items =
const ListReader<String>(const StringReader()).read(buf, 0);
expect(items, hasLength(2));
@@ -342,7 +342,7 @@
void test_writeList_ofStrings_inObject() {
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
Offset listOffset = builder.writeList(
[builder.writeString('12345'), builder.writeString('ABC')]);
builder.startTable();
@@ -351,8 +351,8 @@
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
- StringListWrapperImpl reader = new StringListWrapperReader().read(buf, 0);
+ BufferContext buf = BufferContext.fromBytes(byteList);
+ StringListWrapperImpl reader = StringListWrapperReader().read(buf, 0);
List<String> items = reader.items;
expect(items, hasLength(2));
expect(items, contains('12345'));
@@ -362,12 +362,12 @@
void test_writeList_ofUint32() {
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
Offset offset = builder.writeListUint32(<int>[1, 2, 0x9ABCDEF0]);
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
+ BufferContext buf = BufferContext.fromBytes(byteList);
List<int> items = const Uint32ListReader().read(buf, 0);
expect(items, hasLength(3));
expect(items, orderedEquals(<int>[1, 2, 0x9ABCDEF0]));
@@ -376,12 +376,12 @@
void test_writeList_ofUint8() {
List<int> byteList;
{
- Builder builder = new Builder(initialSize: 0);
+ Builder builder = Builder(initialSize: 0);
Offset offset = builder.writeListUint8(<int>[1, 2, 3, 4, 0x9A]);
byteList = builder.finish(offset);
}
// read and verify
- BufferContext buf = new BufferContext.fromBytes(byteList);
+ BufferContext buf = BufferContext.fromBytes(byteList);
List<int> items = const Uint8ListReader().read(buf, 0);
expect(items, hasLength(5));
expect(items, orderedEquals(<int>[1, 2, 3, 4, 0x9A]));
@@ -403,7 +403,7 @@
@override
StringListWrapperImpl createObject(BufferContext object, int offset) {
- return new StringListWrapperImpl(object, offset);
+ return StringListWrapperImpl(object, offset);
}
}
@@ -423,6 +423,6 @@
@override
TestPointImpl createObject(BufferContext object, int offset) {
- return new TestPointImpl(object, offset);
+ return TestPointImpl(object, offset);
}
}
diff --git a/pkg/analyzer/test/src/summary/in_summary_source_test.dart b/pkg/analyzer/test/src/summary/in_summary_source_test.dart
index 1ce0664..6e86476 100644
--- a/pkg/analyzer/test/src/summary/in_summary_source_test.dart
+++ b/pkg/analyzer/test/src/summary/in_summary_source_test.dart
@@ -17,10 +17,10 @@
@reflectiveTest
class InSummarySourceTest {
test_InSummarySource() {
- var sourceFactory = new SourceFactory([
- new InSummaryUriResolver(
+ var sourceFactory = SourceFactory([
+ InSummaryUriResolver(
PhysicalResourceProvider.INSTANCE,
- new MockSummaryDataStore.fake({
+ MockSummaryDataStore.fake({
'package:foo/foo.dart': 'foo.sum',
'package:foo/src/foo_impl.dart': 'foo.sum',
'package:bar/baz.dart': 'bar.sum',
@@ -47,7 +47,7 @@
MockSummaryDataStore(this.uriToSummaryPath);
factory MockSummaryDataStore.fake(Map<String, String> uriToSummary) {
- return new MockSummaryDataStore(uriToSummary);
+ return MockSummaryDataStore(uriToSummary);
}
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
diff --git a/pkg/analyzer/test/src/summary/name_filter_test.dart b/pkg/analyzer/test/src/summary/name_filter_test.dart
index 3d15cd6..4124b7e 100644
--- a/pkg/analyzer/test/src/summary/name_filter_test.dart
+++ b/pkg/analyzer/test/src/summary/name_filter_test.dart
@@ -15,7 +15,7 @@
@reflectiveTest
class NameFilterTest {
test_accepts_accessors_hide() {
- NameFilter filter = new NameFilter(hides: ['bar']);
+ NameFilter filter = NameFilter(hides: ['bar']);
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('foo='), isTrue);
expect(filter.accepts('bar'), isFalse);
@@ -23,7 +23,7 @@
}
test_accepts_accessors_show() {
- NameFilter filter = new NameFilter(shows: ['foo']);
+ NameFilter filter = NameFilter(shows: ['foo']);
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('foo='), isTrue);
expect(filter.accepts('bar'), isFalse);
@@ -39,7 +39,7 @@
test_merge_hides_hides() {
NameFilter filter =
- new NameFilter(hides: ['foo']).merge(new NameFilter(hides: ['bar']));
+ NameFilter(hides: ['foo']).merge(NameFilter(hides: ['bar']));
expect(filter.accepts('foo'), isFalse);
expect(filter.accepts('bar'), isFalse);
expect(filter.accepts('baz'), isTrue);
@@ -50,7 +50,7 @@
test_merge_hides_identity() {
NameFilter filter =
- new NameFilter(hides: ['foo', 'bar']).merge(NameFilter.identity);
+ NameFilter(hides: ['foo', 'bar']).merge(NameFilter.identity);
expect(filter.accepts('foo'), isFalse);
expect(filter.accepts('bar'), isFalse);
expect(filter.accepts('baz'), isTrue);
@@ -60,8 +60,8 @@
}
test_merge_hides_shows() {
- NameFilter filter = new NameFilter(hides: ['bar', 'baz'])
- .merge(new NameFilter(shows: ['foo', 'bar']));
+ NameFilter filter = NameFilter(hides: ['bar', 'baz'])
+ .merge(NameFilter(shows: ['foo', 'bar']));
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('bar'), isFalse);
expect(filter.accepts('baz'), isFalse);
@@ -72,7 +72,7 @@
test_merge_identity_hides() {
NameFilter filter =
- NameFilter.identity.merge(new NameFilter(hides: ['foo', 'bar']));
+ NameFilter.identity.merge(NameFilter(hides: ['foo', 'bar']));
expect(filter.accepts('foo'), isFalse);
expect(filter.accepts('bar'), isFalse);
expect(filter.accepts('baz'), isTrue);
@@ -91,7 +91,7 @@
test_merge_identity_shows() {
NameFilter filter =
- NameFilter.identity.merge(new NameFilter(shows: ['foo', 'bar']));
+ NameFilter.identity.merge(NameFilter(shows: ['foo', 'bar']));
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('bar'), isTrue);
expect(filter.accepts('baz'), isFalse);
@@ -101,8 +101,8 @@
}
test_merge_shows_hides() {
- NameFilter filter = new NameFilter(shows: ['foo', 'bar'])
- .merge(new NameFilter(hides: ['bar', 'baz']));
+ NameFilter filter = NameFilter(shows: ['foo', 'bar'])
+ .merge(NameFilter(hides: ['bar', 'baz']));
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('bar'), isFalse);
expect(filter.accepts('baz'), isFalse);
@@ -113,7 +113,7 @@
test_merge_shows_identity() {
NameFilter filter =
- new NameFilter(shows: ['foo', 'bar']).merge(NameFilter.identity);
+ NameFilter(shows: ['foo', 'bar']).merge(NameFilter.identity);
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('bar'), isTrue);
expect(filter.accepts('baz'), isFalse);
@@ -123,8 +123,8 @@
}
test_merge_shows_shows() {
- NameFilter filter = new NameFilter(shows: ['foo', 'bar'])
- .merge(new NameFilter(shows: ['bar', 'baz']));
+ NameFilter filter = NameFilter(shows: ['foo', 'bar'])
+ .merge(NameFilter(shows: ['bar', 'baz']));
expect(filter.accepts('foo'), isFalse);
expect(filter.accepts('bar'), isTrue);
expect(filter.accepts('baz'), isFalse);
@@ -135,7 +135,7 @@
test_merge_shows_shows_emptyResult() {
NameFilter filter =
- new NameFilter(shows: ['foo']).merge(new NameFilter(shows: ['bar']));
+ NameFilter(shows: ['foo']).merge(NameFilter(shows: ['bar']));
expect(filter.accepts('foo'), isFalse);
expect(filter.accepts('bar'), isFalse);
expect(filter.accepts('baz'), isFalse);
diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
index 28c0898..2e4006b 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
@@ -134,12 +134,6 @@
}
}
- if (analysisContext.typeProvider == null) {
- var dartCore = elementFactory.libraryOfUri('dart:core');
- var dartAsync = elementFactory.libraryOfUri('dart:async');
- elementFactory.createTypeProviders(dartCore, dartAsync);
- }
-
return elementFactory.libraryOfUri('${source.uri}');
}
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index d0f08cd..a20e3cc 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -27,13 +27,13 @@
* The return type separator: →
*/
abstract class AbstractResynthesizeTest with ResourceProviderMixin {
- DeclaredVariables declaredVariables = new DeclaredVariables();
+ DeclaredVariables declaredVariables = DeclaredVariables();
SourceFactory sourceFactory;
MockSdk sdk;
String testFile;
Source testSource;
- Set<Source> otherLibrarySources = new Set<Source>();
+ Set<Source> otherLibrarySources = Set<Source>();
/**
* Tests may set this to `true` to indicate that a missing file at the time of
@@ -42,7 +42,7 @@
bool allowMissingFiles = false;
AbstractResynthesizeTest() {
- sdk = new MockSdk(resourceProvider: resourceProvider);
+ sdk = MockSdk(resourceProvider: resourceProvider);
sourceFactory = SourceFactory(
[
@@ -5504,7 +5504,7 @@
}
test_export_configurations_useDefault() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'false',
});
addLibrarySource('/foo.dart', 'class A {}');
@@ -5529,7 +5529,7 @@
}
test_export_configurations_useFirst() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'true',
'dart.library.html': 'true',
});
@@ -5555,7 +5555,7 @@
}
test_export_configurations_useSecond() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'false',
'dart.library.html': 'true',
});
@@ -5762,7 +5762,7 @@
}
test_exportImport_configurations_useDefault() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'false',
});
addLibrarySource('/foo.dart', 'class A {}');
@@ -5787,7 +5787,7 @@
}
test_exportImport_configurations_useFirst() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'true',
'dart.library.html': 'false',
});
@@ -5813,7 +5813,7 @@
}
test_exportImport_configurations_useSecond() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'false',
'dart.library.html': 'true',
});
@@ -6634,7 +6634,7 @@
}
test_import_configurations_useDefault() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'false',
});
addLibrarySource('/foo.dart', 'class A {}');
@@ -6657,7 +6657,7 @@
}
test_import_configurations_useFirst() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'true',
'dart.library.html': 'true',
});
@@ -6681,7 +6681,7 @@
}
test_import_configurations_useFirst_eqTrue() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'true',
'dart.library.html': 'true',
});
@@ -6705,7 +6705,7 @@
}
test_import_configurations_useSecond() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'false',
'dart.library.html': 'true',
});
@@ -6729,7 +6729,7 @@
}
test_import_configurations_useSecond_eqTrue() async {
- declaredVariables = new DeclaredVariables.fromMap({
+ declaredVariables = DeclaredVariables.fromMap({
'dart.library.io': 'false',
'dart.library.html': 'true',
});
@@ -11428,7 +11428,7 @@
/// to be applied to a class implementing [ResynthesizeTestStrategy].
mixin ResynthesizeTestHelpers implements ResynthesizeTestStrategy {
Future<LibraryElementImpl> checkLibrary(String text,
- {bool allowErrors: false, bool dumpSummaries: false}) async {
+ {bool allowErrors = false, bool dumpSummaries = false}) async {
throw 42;
// Source source = addTestSource(text);
// SummaryResynthesizer resynthesizer = encodeLibrary(source);
diff --git a/pkg/analyzer/test/src/summary/test_strategies.dart b/pkg/analyzer/test/src/summary/test_strategies.dart
index 0d3d18e..6307779 100644
--- a/pkg/analyzer/test/src/summary/test_strategies.dart
+++ b/pkg/analyzer/test/src/summary/test_strategies.dart
@@ -21,19 +21,18 @@
FeatureSet featureSet,
) {
featureSet ??= FeatureSet.forTesting(sdkVersion: '2.3.0');
- CharSequenceReader reader = new CharSequenceReader(text);
- Scanner scanner =
- new Scanner(null, reader, AnalysisErrorListener.NULL_LISTENER)
- ..configureFeatures(featureSet);
+ CharSequenceReader reader = CharSequenceReader(text);
+ Scanner scanner = Scanner(null, reader, AnalysisErrorListener.NULL_LISTENER)
+ ..configureFeatures(featureSet);
Token token = scanner.tokenize();
// Pass the feature set from the scanner to the parser
// because the scanner may have detected a language version comment
// and downgraded the feature set it holds.
- Parser parser = new Parser(
+ Parser parser = Parser(
NonExistingSource.unknown, AnalysisErrorListener.NULL_LISTENER,
featureSet: scanner.featureSet);
CompilationUnit unit = parser.parseCompilationUnit(token);
- unit.lineInfo = new LineInfo(scanner.lineStarts);
+ unit.lineInfo = LineInfo(scanner.lineStarts);
return unit;
}
@@ -47,13 +46,13 @@
/// The set of features enabled in this test.
FeatureSet featureSet;
- void set allowMissingFiles(bool value);
+ set allowMissingFiles(bool value);
set declaredVariables(DeclaredVariables declaredVariables);
MemoryResourceProvider get resourceProvider;
- void set testFile(String value);
+ set testFile(String value);
Source get testSource;
@@ -73,7 +72,7 @@
@override
FeatureSet featureSet = FeatureSet.forTesting(sdkVersion: '2.2.2');
- final Set<Source> serializedSources = new Set<Source>();
+ final Set<Source> serializedSources = Set<Source>();
- PackageBundleAssembler bundleAssembler = new PackageBundleAssembler();
+ PackageBundleAssembler bundleAssembler = PackageBundleAssembler();
}
diff --git a/pkg/analyzer/test/src/summary2/ast_text_printer_test.dart b/pkg/analyzer/test/src/summary2/ast_text_printer_test.dart
index a20b7da..b81d0f0 100644
--- a/pkg/analyzer/test/src/summary2/ast_text_printer_test.dart
+++ b/pkg/analyzer/test/src/summary2/ast_text_printer_test.dart
@@ -22,7 +22,7 @@
///
/// Whitespaces and newlines are normalized and ignored.
void assertParseCodeAndPrintAst(ParseBase base, String code,
- {bool mightHasParseErrors: false}) {
+ {bool mightHasParseErrors = false}) {
code = code.trimRight();
code = code.replaceAll('\t', ' ');
code = code.replaceAll('\r\n', '\n');
@@ -117,7 +117,7 @@
class AstTextPrinterWithExtensionMethodsTest extends ParseBase {
@override
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
+ ..contextFeatures = FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
test_extensionOverride() async {
diff --git a/pkg/analyzer/test/src/task/options_test.dart b/pkg/analyzer/test/src/task/options_test.dart
index 653e1ee..926d7ad 100644
--- a/pkg/analyzer/test/src/task/options_test.dart
+++ b/pkg/analyzer/test/src/task/options_test.dart
@@ -77,12 +77,12 @@
List<ErrorProcessor> processors = analysisOptions.errorProcessors;
expect(processors, hasLength(2));
- var unused_local = new AnalysisError(
- new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [
+ var unused_local =
+ AnalysisError(TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [
['x']
]);
- var invalid_assignment = new AnalysisError(
- new TestSource(), 0, 1, StaticTypeWarningCode.INVALID_ASSIGNMENT, [
+ var invalid_assignment = AnalysisError(
+ TestSource(), 0, 1, StaticTypeWarningCode.INVALID_ASSIGNMENT, [
['x'],
['y']
]);
@@ -210,7 +210,7 @@
@reflectiveTest
class GenerateOldOptionsErrorsTaskTest with ResourceProviderMixin {
- final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider();
+ final AnalysisOptionsProvider optionsProvider = AnalysisOptionsProvider();
String get optionsFilePath => '/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}';
@@ -237,7 +237,7 @@
void validate(String content, List<ErrorCode> expected) {
final source = newFile(optionsFilePath, content: content).createSource();
var options = optionsProvider.getOptionsFromSource(source);
- final OptionsFileValidator validator = new OptionsFileValidator(source);
+ final OptionsFileValidator validator = OptionsFileValidator(source);
var errors = validator.validate(options);
expect(errors.map((AnalysisError e) => e.errorCode),
unorderedEquals(expected));
@@ -246,9 +246,8 @@
@reflectiveTest
class OptionsFileValidatorTest {
- final OptionsFileValidator validator =
- new OptionsFileValidator(new TestSource());
- final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider();
+ final OptionsFileValidator validator = OptionsFileValidator(TestSource());
+ final AnalysisOptionsProvider optionsProvider = AnalysisOptionsProvider();
test_analyzer_enableExperiment_badValue() {
validate('''
@@ -324,7 +323,7 @@
}
test_analyzer_lint_codes_recognized() {
- Registry.ruleRegistry.register(new TestRule());
+ Registry.ruleRegistry.register(TestRule());
validate('''
analyzer:
errors:
@@ -417,7 +416,7 @@
}
test_linter_supported_rules() {
- Registry.ruleRegistry.register(new TestRule());
+ Registry.ruleRegistry.register(TestRule());
validate('''
linter:
rules:
@@ -450,11 +449,11 @@
String get optionsFilePath => '/analysis_options.yaml';
void setUp() {
- var rawProvider = new MemoryResourceProvider();
- resourceProvider = new TestResourceProvider(rawProvider);
- pathTranslator = new TestPathTranslator(rawProvider);
- provider = new AnalysisOptionsProvider(new SourceFactory([
- new ResourceUriResolver(rawProvider),
+ var rawProvider = MemoryResourceProvider();
+ resourceProvider = TestResourceProvider(rawProvider);
+ pathTranslator = TestPathTranslator(rawProvider);
+ provider = AnalysisOptionsProvider(SourceFactory([
+ ResourceUriResolver(rawProvider),
]));
}
@@ -488,8 +487,8 @@
''';
pathTranslator.newFile(optionsFilePath, code);
- final lowlevellint = new TestRule.withName('lowlevellint');
- final toplevellint = new TestRule.withName('toplevellint');
+ final lowlevellint = TestRule.withName('lowlevellint');
+ final toplevellint = TestRule.withName('toplevellint');
Registry.ruleRegistry.register(lowlevellint);
Registry.ruleRegistry.register(toplevellint);
final options = _getOptionsObject('/');
@@ -502,21 +501,21 @@
expect(
options.errorProcessors,
unorderedMatches([
- new ErrorProcessorMatcher(
- new ErrorProcessor('toplevelerror', ErrorSeverity.WARNING)),
- new ErrorProcessorMatcher(
- new ErrorProcessor('lowlevelerror', ErrorSeverity.WARNING))
+ ErrorProcessorMatcher(
+ ErrorProcessor('toplevelerror', ErrorSeverity.WARNING)),
+ ErrorProcessorMatcher(
+ ErrorProcessor('lowlevelerror', ErrorSeverity.WARNING))
]));
}
- YamlMap _getOptions(String posixPath, {bool crawlUp: false}) {
+ YamlMap _getOptions(String posixPath, {bool crawlUp = false}) {
Resource resource = pathTranslator.getResource(posixPath);
return provider.getOptions(resource, crawlUp: crawlUp);
}
- AnalysisOptions _getOptionsObject(String posixPath, {bool crawlUp: false}) {
+ AnalysisOptions _getOptionsObject(String posixPath, {bool crawlUp = false}) {
final map = _getOptions(posixPath, crawlUp: crawlUp);
- final options = new AnalysisOptionsImpl();
+ final options = AnalysisOptionsImpl();
applyToAnalysisOptions(options, map);
return options;
}
diff --git a/pkg/analyzer/test/src/task/strong/checker_test.dart b/pkg/analyzer/test/src/task/strong/checker_test.dart
index d080c3b..fdf899c 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -146,7 +146,7 @@
static const num n = 3.0;
// The severe error is from constant evaluation where we know the
// concrete type.
- static const int /*error:VARIABLE_TYPE_MISMATCH*/i = /*info:ASSIGNMENT_CAST*/n;
+ static const int i = /*info:ASSIGNMENT_CAST, error:VARIABLE_TYPE_MISMATCH*/n;
final int fi;
const A(num a) : this.fi = /*info:DOWN_CAST_IMPLICIT*/a;
}
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index ce2d4c7..1a7aea7 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -32,14 +32,14 @@
/**
* Add a new file with the given [name] and [content].
*/
- void addFile(String content, {String name: '/main.dart'});
+ void addFile(String content, {String name = '/main.dart'});
/**
* Add the file, process it (resolve, validate, etc) and return the resolved
* unit.
*/
Future<CompilationUnit> checkFile(String content,
- {bool implicitCasts: true, bool implicitDynamic: true});
+ {bool implicitCasts = true, bool implicitDynamic = true});
/**
* Add the file, process it (resolve, validate, etc) and return the resolved
@@ -1701,7 +1701,7 @@
{String declared,
String downwards,
String upwards,
- String expectedInfo: ''}) =>
+ String expectedInfo = ''}) =>
'''
import 'dart:async';
class MyFuture<T> implements Future<T> {
@@ -1732,7 +1732,7 @@
{String declared,
String downwards,
String upwards,
- String expectedError: ''}) {
+ String expectedError = ''}) {
return '''
import 'dart:async';
class MyFuture<T> implements Future<T> {
diff --git a/pkg/analyzer/test/src/task/strong/strong_test_helper.dart b/pkg/analyzer/test/src/task/strong/strong_test_helper.dart
index 5068c51..91978a1 100644
--- a/pkg/analyzer/test/src/task/strong/strong_test_helper.dart
+++ b/pkg/analyzer/test/src/task/strong/strong_test_helper.dart
@@ -51,7 +51,7 @@
var text = content.substring(start, end);
var lineText = content.substring(lineStart, lineEnd);
- return new SourceSpanWithContext(startLoc, endLoc, text, lineText);
+ return SourceSpanWithContext(startLoc, endLoc, text, lineText);
}
ErrorSeverity _errorSeverity(
@@ -69,11 +69,11 @@
Iterable<AnalysisError> actualErrors) {
var expectedErrors = _findExpectedErrors(unit.beginToken);
- var actualMap = new SplayTreeMap<int, List<AnalysisError>>();
+ var actualMap = SplayTreeMap<int, List<AnalysisError>>();
for (var e in actualErrors) {
actualMap.putIfAbsent(e.offset, () => []).add(e);
}
- var expectedMap = new SplayTreeMap<int, List<_ErrorExpectation>>();
+ var expectedMap = SplayTreeMap<int, List<_ErrorExpectation>>();
for (var e in expectedErrors) {
expectedMap.putIfAbsent(e.offset, () => []).add(e);
}
@@ -144,13 +144,13 @@
SourceLocation _locationForOffset(LineInfo lineInfo, Uri uri, int offset) {
var loc = lineInfo.getLocation(offset);
- return new SourceLocation(offset,
+ return SourceLocation(offset,
sourceUrl: uri, line: loc.lineNumber - 1, column: loc.columnNumber - 1);
}
/// Returns all libraries transitively imported or exported from [start].
Set<LibraryElement> _reachableLibraries(LibraryElement start) {
- Set<LibraryElement> results = new Set<LibraryElement>();
+ Set<LibraryElement> results = Set<LibraryElement>();
void find(LibraryElement library) {
if (results.add(library)) {
@@ -184,7 +184,8 @@
span.message(error.message);
}
- String formatExpectedError(_ErrorExpectation error, {bool showSource: true}) {
+ String formatExpectedError(_ErrorExpectation error,
+ {bool showSource = true}) {
int offset = error.offset;
var severity = error.severity.displayName;
var result = '@$offset $severity:${error.typeName}';
@@ -194,7 +195,7 @@
return '$result\n${span.message('')}';
}
- var message = new StringBuffer();
+ var message = StringBuffer();
if (unreported.isNotEmpty) {
message.writeln('Expected errors that were not reported:');
unreported.map(formatExpectedError).forEach(message.writeln);
@@ -248,7 +249,7 @@
/// check();
///
/// For a single file, you may also use [checkFile].
- void addFile(String content, {String name: '/main.dart'}) {
+ void addFile(String content, {String name = '/main.dart'}) {
name = name.replaceFirst(RegExp('^package:'), '/packages/');
newFile(name, content: content);
_checkCalled = false;
@@ -262,16 +263,16 @@
///
/// Returns the main resolved library. This can be used for further checks.
Future<CompilationUnit> check(
- {bool implicitCasts: true,
- bool implicitDynamic: true,
- bool strictInference: false,
- bool strictRawTypes: false}) async {
+ {bool implicitCasts = true,
+ bool implicitDynamic = true,
+ bool strictInference = false,
+ bool strictRawTypes = false}) async {
_checkCalled = true;
File mainFile = getFile('/main.dart');
expect(mainFile.exists, true, reason: '`/main.dart` is missing');
- AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl();
+ AnalysisOptionsImpl analysisOptions = AnalysisOptionsImpl();
analysisOptions.strongModeHints = true;
analysisOptions.implicitCasts = implicitCasts;
analysisOptions.implicitDynamic = implicitDynamic;
@@ -279,27 +280,27 @@
analysisOptions.strictRawTypes = strictRawTypes;
analysisOptions.enabledExperiments = enabledExperiments;
- var mockSdk = new MockSdk(
+ var mockSdk = MockSdk(
resourceProvider: resourceProvider,
analysisOptions: analysisOptions,
);
- SourceFactory sourceFactory = new SourceFactory([
- new DartUriResolver(mockSdk),
- new PackageMapUriResolver(resourceProvider, packageMap),
- new ResourceUriResolver(resourceProvider),
+ SourceFactory sourceFactory = SourceFactory([
+ DartUriResolver(mockSdk),
+ PackageMapUriResolver(resourceProvider, packageMap),
+ ResourceUriResolver(resourceProvider),
]);
CompilationUnit mainUnit;
- StringBuffer logBuffer = new StringBuffer();
- FileContentOverlay fileContentOverlay = new FileContentOverlay();
- PerformanceLog log = new PerformanceLog(logBuffer);
- AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log);
- _driver = new AnalysisDriver(
+ StringBuffer logBuffer = StringBuffer();
+ FileContentOverlay fileContentOverlay = FileContentOverlay();
+ PerformanceLog log = PerformanceLog(logBuffer);
+ AnalysisDriverScheduler scheduler = AnalysisDriverScheduler(log);
+ _driver = AnalysisDriver(
scheduler,
log,
resourceProvider,
- new MemoryByteStore(),
+ MemoryByteStore(),
fileContentOverlay,
null,
sourceFactory,
@@ -356,7 +357,7 @@
///
/// Also returns the resolved compilation unit.
Future<CompilationUnit> checkFile(String content,
- {bool implicitCasts: true, bool implicitDynamic: true}) async {
+ {bool implicitCasts = true, bool implicitDynamic = true}) async {
addFile(content);
return await check(
implicitCasts: implicitCasts,
@@ -379,7 +380,7 @@
Future<_TestAnalysisResult> _resolve(Source source) async {
var result = await _driver.getResult(source.fullName);
- return new _TestAnalysisResult(source, result.unit, result.errors);
+ return _TestAnalysisResult(source, result.unit, result.errors);
}
}
@@ -423,7 +424,7 @@
reason: 'invalid severity in error descriptor: `${tokens[0]}`');
expect(typeName, isNotNull,
reason: 'invalid type in error descriptor: ${tokens[1]}');
- return new _ErrorExpectation(offset, level, typeName);
+ return _ErrorExpectation(offset, level, typeName);
}
}
diff --git a/pkg/analyzer/test/src/util/glob_test.dart b/pkg/analyzer/test/src/util/glob_test.dart
index 1bff610..30ba6c7 100644
--- a/pkg/analyzer/test/src/util/glob_test.dart
+++ b/pkg/analyzer/test/src/util/glob_test.dart
@@ -16,7 +16,7 @@
@reflectiveTest
class GlobPosixTest {
void test_case() {
- Glob glob = new Glob(r'\', r'**.DaRt');
+ Glob glob = Glob(r'\', r'**.DaRt');
expect(glob.matches(r'aaa.dart'), isTrue);
expect(glob.matches(r'bbb.DART'), isTrue);
expect(glob.matches(r'ccc.dArT'), isTrue);
@@ -24,14 +24,14 @@
}
void test_question() {
- Glob glob = new Glob(r'/', r'?.dart');
+ Glob glob = Glob(r'/', r'?.dart');
expect(glob.matches(r'a.dart'), isTrue);
expect(glob.matches(r'b.dart'), isTrue);
expect(glob.matches(r'cc.dart'), isFalse);
}
void test_specialChars() {
- Glob glob = new Glob(r'/', r'*.dart');
+ Glob glob = Glob(r'/', r'*.dart');
expect(glob.matches(r'a.dart'), isTrue);
expect(glob.matches('_-\a.dart'), isTrue);
expect(glob.matches(r'^$*?.dart'), isTrue);
@@ -40,13 +40,13 @@
}
void test_specialChars2() {
- Glob glob = new Glob(r'/', r'a[]b.dart');
+ Glob glob = Glob(r'/', r'a[]b.dart');
expect(glob.matches(r'a[]b.dart'), isTrue);
expect(glob.matches(r'aNb.dart'), isFalse);
}
void test_star() {
- Glob glob = new Glob(r'/', r'web/*.dart');
+ Glob glob = Glob(r'/', r'web/*.dart');
expect(glob.matches(r'web/foo.dart'), isTrue);
expect(glob.matches(r'web/barbaz.dart'), isTrue);
// does not end with 'dart'
@@ -59,7 +59,7 @@
}
void test_starStar() {
- Glob glob = new Glob(r'/', r'**.dart');
+ Glob glob = Glob(r'/', r'**.dart');
expect(glob.matches(r'foo/bar.dart'), isTrue);
expect(glob.matches(r'foo/bar/baz.dart'), isTrue);
expect(glob.matches(r'/foo/bar.dart'), isTrue);
@@ -69,7 +69,7 @@
}
void test_starStar_star() {
- Glob glob = new Glob(r'/', r'**/*.dart');
+ Glob glob = Glob(r'/', r'**/*.dart');
expect(glob.matches(r'foo/bar.dart'), isTrue);
expect(glob.matches(r'foo/bar/baz.dart'), isTrue);
expect(glob.matches(r'/foo/bar.dart'), isTrue);
@@ -82,7 +82,7 @@
@reflectiveTest
class GlobWindowsTest {
void test_case() {
- Glob glob = new Glob(r'\', r'**.dart');
+ Glob glob = Glob(r'\', r'**.dart');
expect(glob.matches(r'aaa.dart'), isTrue);
expect(glob.matches(r'bbb.DART'), isTrue);
expect(glob.matches(r'ccc.dArT'), isTrue);
@@ -90,14 +90,14 @@
}
void test_question() {
- Glob glob = new Glob(r'\', r'?.dart');
+ Glob glob = Glob(r'\', r'?.dart');
expect(glob.matches(r'a.dart'), isTrue);
expect(glob.matches(r'b.dart'), isTrue);
expect(glob.matches(r'cc.dart'), isFalse);
}
void test_specialChars() {
- Glob glob = new Glob(r'\', r'*.dart');
+ Glob glob = Glob(r'\', r'*.dart');
expect(glob.matches(r'a.dart'), isTrue);
expect(glob.matches('_-\a.dart'), isTrue);
expect(glob.matches(r'^$*?.dart'), isTrue);
@@ -106,7 +106,7 @@
}
void test_star() {
- Glob glob = new Glob(r'\', r'web/*.dart');
+ Glob glob = Glob(r'\', r'web/*.dart');
expect(glob.matches(r'web\foo.dart'), isTrue);
expect(glob.matches(r'web\barbaz.dart'), isTrue);
// does not end with 'dart'
@@ -119,7 +119,7 @@
}
void test_starStar() {
- Glob glob = new Glob(r'\', r'**.dart');
+ Glob glob = Glob(r'\', r'**.dart');
expect(glob.matches(r'foo\bar.dart'), isTrue);
expect(glob.matches(r'foo\bar\baz.dart'), isTrue);
expect(glob.matches(r'C:\foo\bar.dart'), isTrue);
diff --git a/pkg/analyzer/test/src/util/lru_map_test.dart b/pkg/analyzer/test/src/util/lru_map_test.dart
index 7be3e13..f7a5b36 100644
--- a/pkg/analyzer/test/src/util/lru_map_test.dart
+++ b/pkg/analyzer/test/src/util/lru_map_test.dart
@@ -14,12 +14,12 @@
@reflectiveTest
class _LRUCacheTest {
- LRUMap<int, String> cache = new LRUMap<int, String>(3);
+ LRUMap<int, String> cache = LRUMap<int, String>(3);
void test_evict_notGet() {
- List<int> evictedKeys = new List<int>();
- List<String> evictedValues = new List<String>();
- cache = new LRUMap<int, String>(3, (int key, String value) {
+ List<int> evictedKeys = List<int>();
+ List<String> evictedValues = List<String>();
+ cache = LRUMap<int, String>(3, (int key, String value) {
evictedKeys.add(key);
evictedValues.add(value);
});
@@ -42,9 +42,9 @@
}
void test_evict_notPut() {
- List<int> evictedKeys = new List<int>();
- List<String> evictedValues = new List<String>();
- cache = new LRUMap<int, String>(3, (int key, String value) {
+ List<int> evictedKeys = List<int>();
+ List<String> evictedValues = List<String>();
+ cache = LRUMap<int, String>(3, (int key, String value) {
evictedKeys.add(key);
evictedValues.add(value);
});
diff --git a/pkg/analyzer/test/src/util/yaml_test.dart b/pkg/analyzer/test/src/util/yaml_test.dart
index 683708e..fec42e0 100644
--- a/pkg/analyzer/test/src/util/yaml_test.dart
+++ b/pkg/analyzer/test/src/util/yaml_test.dart
@@ -97,14 +97,14 @@
});
}
-final Merger merger = new Merger();
+final Merger merger = Merger();
bool containsKey(Map<dynamic, YamlNode> map, dynamic key) =>
_getValue(map, key) != null;
void expectEquals(YamlNode actual, YamlNode expected) {
if (expected is YamlScalar) {
- expect(actual, new TypeMatcher<YamlScalar>());
+ expect(actual, TypeMatcher<YamlScalar>());
expect(expected.value, actual.value);
} else if (expected is YamlList) {
if (actual is YamlList) {
@@ -151,16 +151,15 @@
YamlNode wrap(Object value) {
if (value is List) {
List wrappedElements = value.map((e) => wrap(e)).toList();
- return new YamlList.internal(wrappedElements, null, CollectionStyle.BLOCK);
+ return YamlList.internal(wrappedElements, null, CollectionStyle.BLOCK);
} else if (value is Map) {
Map<dynamic, YamlNode> wrappedEntries = <dynamic, YamlNode>{};
value.forEach((k, v) {
wrappedEntries[wrap(k)] = wrap(v);
});
- return new YamlMap.internal(wrappedEntries, null, CollectionStyle.BLOCK);
+ return YamlMap.internal(wrappedEntries, null, CollectionStyle.BLOCK);
} else {
- return new YamlScalar.internal(
- value, new ScalarEvent(null, '', ScalarStyle.PLAIN));
+ return YamlScalar.internal(value, ScalarEvent(null, '', ScalarStyle.PLAIN));
}
}
diff --git a/pkg/analyzer/test/src/workspace/basic_test.dart b/pkg/analyzer/test/src/workspace/basic_test.dart
index 8fb66aa..81e5ea6 100644
--- a/pkg/analyzer/test/src/workspace/basic_test.dart
+++ b/pkg/analyzer/test/src/workspace/basic_test.dart
@@ -24,8 +24,8 @@
BasicWorkspace workspace;
setUp() {
- final contextBuilder = new MockContextBuilder();
- final packages = new MockPackages();
+ final contextBuilder = MockContextBuilder();
+ final packages = MockPackages();
final packageMap = <String, List<Folder>>{'project': []};
contextBuilder.packagesMapMap[convertPath('/workspace')] = packages;
contextBuilder.packagesToMapMap[packages] = packageMap;
@@ -93,7 +93,7 @@
void test_find_directory() {
BasicWorkspace workspace = BasicWorkspace.find(
- resourceProvider, convertPath('/workspace'), new MockContextBuilder());
+ resourceProvider, convertPath('/workspace'), MockContextBuilder());
expect(workspace.root, convertPath('/workspace'));
expect(workspace.isBazel, isFalse);
}
@@ -101,15 +101,13 @@
void test_find_fail_notAbsolute() {
expect(
() => BasicWorkspace.find(resourceProvider, convertPath('not_absolute'),
- new MockContextBuilder()),
+ MockContextBuilder()),
throwsA(TypeMatcher<ArgumentError>()));
}
void test_find_file() {
- BasicWorkspace workspace = BasicWorkspace.find(
- resourceProvider,
- convertPath('/workspace/project/lib/lib1.dart'),
- new MockContextBuilder());
+ BasicWorkspace workspace = BasicWorkspace.find(resourceProvider,
+ convertPath('/workspace/project/lib/lib1.dart'), MockContextBuilder());
expect(workspace.root, convertPath('/workspace/project/lib'));
expect(workspace.isBazel, isFalse);
}
diff --git a/pkg/analyzer/test/src/workspace/bazel_test.dart b/pkg/analyzer/test/src/workspace/bazel_test.dart
index 5a9a643..643033d 100644
--- a/pkg/analyzer/test/src/workspace/bazel_test.dart
+++ b/pkg/analyzer/test/src/workspace/bazel_test.dart
@@ -31,7 +31,7 @@
newFolder('/workspace/bazel-genfiles');
workspace =
BazelWorkspace.find(resourceProvider, convertPath('/workspace'));
- resolver = new BazelFileUriResolver(workspace);
+ resolver = BazelFileUriResolver(workspace);
newFile('/workspace/test.dart');
newFile('/workspace/bazel-bin/gen1.dart');
newFile('/workspace/bazel-genfiles/gen2.dart');
@@ -72,13 +72,13 @@
}
void test_resolveAbsolute_notFile_dartUri() {
- Uri uri = new Uri(scheme: 'dart', path: 'core');
+ Uri uri = Uri(scheme: 'dart', path: 'core');
Source source = resolver.resolveAbsolute(uri);
expect(source, isNull);
}
void test_resolveAbsolute_notFile_httpsUri() {
- Uri uri = new Uri(scheme: 'https', path: '127.0.0.1/test.dart');
+ Uri uri = Uri(scheme: 'https', path: '127.0.0.1/test.dart');
Source source = resolver.resolveAbsolute(uri);
expect(source, isNull);
}
@@ -90,8 +90,8 @@
expect(source, isNotNull);
expect(resolver.restoreAbsolute(source), uri);
expect(
- resolver.restoreAbsolute(
- new NonExistingSource(source.fullName, null, null)),
+ resolver
+ .restoreAbsolute(NonExistingSource(source.fullName, null, null)),
uri);
}
@@ -451,7 +451,8 @@
'package:third_party.something/foo.dart');
}
- void _addResources(List<String> paths, {String workspacePath: '/workspace'}) {
+ void _addResources(List<String> paths,
+ {String workspacePath = '/workspace'}) {
for (String path in paths) {
if (path.endsWith('/')) {
newFolder(path.substring(0, path.length - 1));
@@ -461,11 +462,11 @@
}
workspace =
BazelWorkspace.find(resourceProvider, convertPath(workspacePath));
- resolver = new BazelPackageUriResolver(workspace);
+ resolver = BazelPackageUriResolver(workspace);
}
void _assertResolve(String uriStr, String posixPath,
- {bool exists: true, bool restore: true}) {
+ {bool exists = true, bool restore = true}) {
Uri uri = Uri.parse(uriStr);
Source source = resolver.resolveAbsolute(uri);
expect(source, isNotNull);
@@ -481,7 +482,7 @@
void _assertRestore(String posixPath, String expectedUri) {
String path = convertPath(posixPath);
- _MockSource source = new _MockSource(path);
+ _MockSource source = _MockSource(path);
Uri uri = resolver.restoreAbsolute(source);
expect(uri?.toString(), expectedUri);
}
@@ -906,6 +907,6 @@
@override
noSuchMethod(Invocation invocation) {
- throw new StateError('Unexpected invocation of ${invocation.memberName}');
+ throw StateError('Unexpected invocation of ${invocation.memberName}');
}
}
diff --git a/pkg/analyzer/test/src/workspace/package_build_test.dart b/pkg/analyzer/test/src/workspace/package_build_test.dart
index 0a25d2c..1555cfe 100644
--- a/pkg/analyzer/test/src/workspace/package_build_test.dart
+++ b/pkg/analyzer/test/src/workspace/package_build_test.dart
@@ -57,13 +57,13 @@
void setUp() {
newFolder('/workspace/.dart_tool/build/generated/project/lib');
newFileWithBytes('/workspace/pubspec.yaml', 'name: project'.codeUnits);
- final MockContextBuilder contextBuilder = new MockContextBuilder();
- final Packages packages = new MockPackages();
+ final MockContextBuilder contextBuilder = MockContextBuilder();
+ final Packages packages = MockPackages();
contextBuilder.packagesMapMap[convertPath('/workspace')] = packages;
contextBuilder.packagesToMapMap[packages] = {'project': []};
workspace = PackageBuildWorkspace.find(
resourceProvider, convertPath('/workspace'), contextBuilder);
- resolver = new PackageBuildFileUriResolver(workspace);
+ resolver = PackageBuildFileUriResolver(workspace);
newFile('/workspace/test.dart');
newFile('/workspace/.dart_tool/build/generated/project/gen.dart');
expect(workspace.isBazel, isFalse);
@@ -97,13 +97,13 @@
}
void test_resolveAbsolute_notFile_dartUri() {
- Uri uri = new Uri(scheme: 'dart', path: 'core');
+ Uri uri = Uri(scheme: 'dart', path: 'core');
Source source = resolver.resolveAbsolute(uri);
expect(source, isNull);
}
void test_resolveAbsolute_notFile_httpsUri() {
- Uri uri = new Uri(scheme: 'https', path: '127.0.0.1/test.dart');
+ Uri uri = Uri(scheme: 'https', path: '127.0.0.1/test.dart');
Source source = resolver.resolveAbsolute(uri);
expect(source, isNull);
}
@@ -115,8 +115,8 @@
expect(source, isNotNull);
expect(resolver.restoreAbsolute(source), uri);
expect(
- resolver.restoreAbsolute(
- new NonExistingSource(source.fullName, null, null)),
+ resolver
+ .restoreAbsolute(NonExistingSource(source.fullName, null, null)),
uri);
}
@@ -132,7 +132,7 @@
PackageBuildPackageUriResolver resolver;
MockUriResolver packageUriResolver;
- Uri addPackageSource(String path, String uriStr, {bool create: true}) {
+ Uri addPackageSource(String path, String uriStr, {bool create = true}) {
Uri uri = Uri.parse(uriStr);
final File file = create
? newFile(path)
@@ -196,7 +196,8 @@
exists: false);
}
- void _addResources(List<String> paths, {String workspacePath: '/workspace'}) {
+ void _addResources(List<String> paths,
+ {String workspacePath = '/workspace'}) {
for (String path in paths) {
if (path.endsWith('/')) {
newFolder(path.substring(0, path.length - 1));
@@ -204,19 +205,18 @@
newFile(path);
}
}
- final contextBuilder = new MockContextBuilder();
- final packages = new MockPackages();
+ final contextBuilder = MockContextBuilder();
+ final packages = MockPackages();
contextBuilder.packagesMapMap[convertPath(workspacePath)] = packages;
contextBuilder.packagesToMapMap[packages] = {'project': []};
workspace = PackageBuildWorkspace.find(
resourceProvider, convertPath(workspacePath), contextBuilder);
- packageUriResolver = new MockUriResolver();
- resolver =
- new PackageBuildPackageUriResolver(workspace, packageUriResolver);
+ packageUriResolver = MockUriResolver();
+ resolver = PackageBuildPackageUriResolver(workspace, packageUriResolver);
}
Source _assertResolveUri(Uri uri, String posixPath,
- {bool exists: true, bool restore: true}) {
+ {bool exists = true, bool restore = true}) {
Source source = resolver.resolveAbsolute(uri);
expect(source, isNotNull);
expect(source.fullName, convertPath(posixPath));
@@ -313,15 +313,15 @@
}
PackageBuildWorkspace _createPackageBuildWorkspace() {
- final contextBuilder = new MockContextBuilder();
- final packagesForWorkspace = new MockPackages();
+ final contextBuilder = MockContextBuilder();
+ final packagesForWorkspace = MockPackages();
contextBuilder.packagesMapMap[convertPath('/workspace')] =
packagesForWorkspace;
contextBuilder.packagesToMapMap[packagesForWorkspace] = {
'project': <Folder>[getFolder('/workspace')]
};
- final packagesForWorkspace2 = new MockPackages();
+ final packagesForWorkspace2 = MockPackages();
contextBuilder.packagesMapMap[convertPath('/workspace2')] =
packagesForWorkspace2;
contextBuilder.packagesToMapMap[packagesForWorkspace2] = {
@@ -332,8 +332,8 @@
newFileWithBytes('/workspace/pubspec.yaml', 'name: project'.codeUnits);
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
resourceProvider, convertPath('/workspace'), contextBuilder);
- packageUriResolver = new MockUriResolver();
- new PackageBuildPackageUriResolver(workspace, packageUriResolver);
+ packageUriResolver = MockUriResolver();
+ PackageBuildPackageUriResolver(workspace, packageUriResolver);
return workspace;
}
}
@@ -381,7 +381,7 @@
void test_find_fail_notAbsolute() {
expect(
() => PackageBuildWorkspace.find(resourceProvider,
- convertPath('not_absolute'), new MockContextBuilder()),
+ convertPath('not_absolute'), MockContextBuilder()),
throwsA(const TypeMatcher<ArgumentError>()));
}
@@ -389,7 +389,7 @@
newFolder('/workspace/.dart_tool/build/generated/project/lib');
newFileWithBytes('/workspace/pubspec.yaml', 'name: project'.codeUnits);
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
- resourceProvider, convertPath('/workspace'), new MockContextBuilder());
+ resourceProvider, convertPath('/workspace'), MockContextBuilder());
expect(workspace.root, convertPath('/workspace'));
expect(workspace.projectPackageName, 'project');
}
@@ -403,7 +403,7 @@
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
resourceProvider,
convertPath('/workspace/opened/up/a/child/dir'),
- new MockContextBuilder());
+ MockContextBuilder());
expect(workspace.root, convertPath('/workspace/opened/up/a/child/dir'));
expect(workspace.projectPackageName, 'subproject');
}
@@ -418,7 +418,7 @@
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
resourceProvider,
convertPath('/workspace/opened/up/a/child/dir'),
- new MockContextBuilder());
+ MockContextBuilder());
expect(workspace.root, convertPath('/workspace'));
expect(workspace.projectPackageName, 'project');
}
@@ -431,7 +431,7 @@
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
resourceProvider,
convertPath('/workspace/opened/up/a/child/dir'),
- new MockContextBuilder());
+ MockContextBuilder());
expect(workspace.root, convertPath('/workspace'));
expect(workspace.projectPackageName, 'project');
}
@@ -445,7 +445,7 @@
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
resourceProvider,
convertPath('/workspace/opened/up/a/child/dir'),
- new MockContextBuilder());
+ MockContextBuilder());
expect(workspace.root, convertPath('/workspace'));
expect(workspace.projectPackageName, 'project');
}
@@ -455,14 +455,14 @@
newFolder('/workspace/.dart_tool');
newFileWithBytes('/workspace/pubspec.yaml', 'name: project'.codeUnits);
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
- resourceProvider, convertPath('/workspace'), new MockContextBuilder());
+ resourceProvider, convertPath('/workspace'), MockContextBuilder());
expect(workspace, isNull);
}
void test_find_hasDartToolNoPubspec() {
newFolder('/workspace/.dart_tool/build/generated/project/lib');
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
- resourceProvider, convertPath('/workspace'), new MockContextBuilder());
+ resourceProvider, convertPath('/workspace'), MockContextBuilder());
expect(workspace, isNull);
}
@@ -471,7 +471,7 @@
newFolder('/workspace/.dart_tool/pub');
newFileWithBytes('/workspace/pubspec.yaml', 'name: project'.codeUnits);
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
- resourceProvider, convertPath('/workspace'), new MockContextBuilder());
+ resourceProvider, convertPath('/workspace'), MockContextBuilder());
expect(workspace, isNull);
}
@@ -480,14 +480,14 @@
newFileWithBytes(
'/workspace/pubspec.yaml', 'not: yaml: here! 1111'.codeUnits);
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
- resourceProvider, convertPath('/workspace'), new MockContextBuilder());
+ resourceProvider, convertPath('/workspace'), MockContextBuilder());
expect(workspace, isNull);
}
void test_find_hasPubspecNoDartTool() {
newFileWithBytes('/workspace/pubspec.yaml', 'name: project'.codeUnits);
PackageBuildWorkspace workspace = PackageBuildWorkspace.find(
- resourceProvider, convertPath('/workspace'), new MockContextBuilder());
+ resourceProvider, convertPath('/workspace'), MockContextBuilder());
expect(workspace, isNull);
}
@@ -583,9 +583,9 @@
PackageBuildWorkspace _createWorkspace(
String root, List<String> packageNames) {
- final contextBuilder = new MockContextBuilder();
- final packages = new MockPackages();
- final packageMap = new Map<String, List<Folder>>.fromIterable(packageNames,
+ final contextBuilder = MockContextBuilder();
+ final packages = MockPackages();
+ final packageMap = Map<String, List<Folder>>.fromIterable(packageNames,
value: ((_) => []));
contextBuilder.packagesMapMap[convertPath(root)] = packages;
contextBuilder.packagesToMapMap[packages] = packageMap;
diff --git a/pkg/analyzer/test/src/workspace/pub_test.dart b/pkg/analyzer/test/src/workspace/pub_test.dart
index 5257ee9..e91cfe6 100644
--- a/pkg/analyzer/test/src/workspace/pub_test.dart
+++ b/pkg/analyzer/test/src/workspace/pub_test.dart
@@ -42,8 +42,8 @@
PubWorkspace workspace;
setUp() {
- final contextBuilder = new MockContextBuilder();
- final packages = new MockPackages();
+ final contextBuilder = MockContextBuilder();
+ final packages = MockPackages();
final packageMap = <String, List<Folder>>{'project': []};
contextBuilder.packagesMapMap[convertPath('/workspace')] = packages;
contextBuilder.packagesToMapMap[packages] = packageMap;
@@ -108,7 +108,7 @@
void test_find_directory() {
newFileWithBytes('/workspace/pubspec.yaml', 'name: project'.codeUnits);
PubWorkspace workspace = PubWorkspace.find(
- resourceProvider, convertPath('/workspace'), new MockContextBuilder());
+ resourceProvider, convertPath('/workspace'), MockContextBuilder());
expect(workspace.isBazel, isFalse);
expect(workspace.root, convertPath('/workspace'));
}
@@ -116,20 +116,20 @@
void test_find_fail_notAbsolute() {
expect(
() => PubWorkspace.find(resourceProvider, convertPath('not_absolute'),
- new MockContextBuilder()),
+ MockContextBuilder()),
throwsA(TypeMatcher<ArgumentError>()));
}
void test_find_file() {
newFileWithBytes('/workspace/pubspec.yaml', 'name: project'.codeUnits);
PubWorkspace workspace = PubWorkspace.find(resourceProvider,
- convertPath('/workspace/lib/lib1.dart'), new MockContextBuilder());
+ convertPath('/workspace/lib/lib1.dart'), MockContextBuilder());
expect(workspace.root, convertPath('/workspace'));
}
void test_find_missingPubspec() {
PubWorkspace workspace = PubWorkspace.find(resourceProvider,
- convertPath('/workspace/lib/lib1.dart'), new MockContextBuilder());
+ convertPath('/workspace/lib/lib1.dart'), MockContextBuilder());
expect(workspace, isNull);
}
}
diff --git a/pkg/analyzer/test/util/id_testing_helper.dart b/pkg/analyzer/test/util/id_testing_helper.dart
index 81f7eaa..b3a3385 100644
--- a/pkg/analyzer/test/util/id_testing_helper.dart
+++ b/pkg/analyzer/test/util/id_testing_helper.dart
@@ -46,13 +46,13 @@
Future<bool> checkTests<T>(
String rawCode, DataComputer<T> dataComputer, FeatureSet featureSet) async {
AnnotatedCode code =
- new AnnotatedCode.fromText(rawCode, commentStart, commentEnd);
+ AnnotatedCode.fromText(rawCode, commentStart, commentEnd);
String testFileName = 'test.dart';
var testFileUri = _toTestUri(testFileName);
var memorySourceFiles = {testFileName: code.sourceCode};
var marker = 'analyzer';
Map<String, MemberAnnotations<IdValue>> expectedMaps = {
- marker: new MemberAnnotations<IdValue>(),
+ marker: MemberAnnotations<IdValue>(),
};
computeExpectedMap(testFileUri, testFileName, code, expectedMaps,
onFailure: onFailure);
@@ -77,8 +77,8 @@
Future<bool> runTest<T>(TestData testData, DataComputer<T> dataComputer,
List<TestConfig> testedConfigs,
{bool testAfterFailures,
- bool forUserLibrariesOnly: true,
- Iterable<Id> globalIds: const <Id>[],
+ bool forUserLibrariesOnly = true,
+ Iterable<Id> globalIds = const <Id>[],
void onFailure(String message)}) async {
bool hasFailures = false;
for (TestConfig config in testedConfigs) {
@@ -108,31 +108,31 @@
{bool fatalErrors, void onFailure(String message)}) async {
MemberAnnotations<IdValue> memberAnnotations =
testData.expectedMaps[config.marker];
- var resourceProvider = new MemoryResourceProvider();
+ var resourceProvider = MemoryResourceProvider();
for (var entry in testData.memorySourceFiles.entries) {
resourceProvider.newFile(
resourceProvider.convertPath(_toTestUri(entry.key).path), entry.value);
}
- var sdk = new MockSdk(resourceProvider: resourceProvider);
- var logBuffer = new StringBuffer();
- var logger = new PerformanceLog(logBuffer);
- var scheduler = new AnalysisDriverScheduler(logger);
+ var sdk = MockSdk(resourceProvider: resourceProvider);
+ var logBuffer = StringBuffer();
+ var logger = PerformanceLog(logBuffer);
+ var scheduler = AnalysisDriverScheduler(logger);
// TODO(paulberry): Do we need a non-empty package map for any of these tests?
var packageMap = <String, List<Folder>>{};
- var byteStore = new MemoryByteStore();
+ var byteStore = MemoryByteStore();
var analysisOptions = AnalysisOptionsImpl()
..contextFeatures = config.featureSet;
- var driver = new AnalysisDriver(
+ var driver = AnalysisDriver(
scheduler,
logger,
resourceProvider,
byteStore,
- new FileContentOverlay(),
+ FileContentOverlay(),
null,
- new SourceFactory([
- new DartUriResolver(sdk),
- new PackageMapUriResolver(resourceProvider, packageMap),
- new ResourceUriResolver(resourceProvider)
+ SourceFactory([
+ DartUriResolver(sdk),
+ PackageMapUriResolver(resourceProvider, packageMap),
+ ResourceUriResolver(resourceProvider)
], null, resourceProvider),
analysisOptions,
retainDataForTesting: true);
@@ -238,7 +238,7 @@
@override
void reportError(Uri uri, int offset, String message,
- {bool succinct: false}) {
+ {bool succinct = false}) {
print('$offset: $message');
}
}
diff --git a/pkg/analyzer/test/utils/package_root.dart b/pkg/analyzer/test/utils/package_root.dart
index b586376..1957a61 100644
--- a/pkg/analyzer/test/utils/package_root.dart
+++ b/pkg/analyzer/test/utils/package_root.dart
@@ -24,5 +24,5 @@
if (pkgIndex != -1) {
return pathos.joinAll(parts.sublist(0, pkgIndex + 1)) + pathos.separator;
}
- throw new StateError('Unable to find sdk/pkg/ in $scriptPath');
+ throw StateError('Unable to find sdk/pkg/ in $scriptPath');
}
diff --git a/pkg/analyzer/test/verify_diagnostics_test.dart b/pkg/analyzer/test/verify_diagnostics_test.dart
index 280363c..6c51d54 100644
--- a/pkg/analyzer/test/verify_diagnostics_test.dart
+++ b/pkg/analyzer/test/verify_diagnostics_test.dart
@@ -73,7 +73,7 @@
/// Validate the documentation.
Future<void> validate() async {
- AnalysisContextCollection collection = new AnalysisContextCollection(
+ AnalysisContextCollection collection = AnalysisContextCollection(
includedPaths:
codePaths.map((codePath) => codePath.documentationPath).toList(),
resourceProvider: PhysicalResourceProvider.INSTANCE);
@@ -177,11 +177,11 @@
ParsedUnitResult _parse(AnalysisContextCollection collection, String path) {
AnalysisSession session = collection.contextFor(path).currentSession;
if (session == null) {
- throw new StateError('No session for "$path"');
+ throw StateError('No session for "$path"');
}
ParsedUnitResult result = session.getParsedUnit(path);
if (result.state != ResultState.VALID) {
- throw new StateError('Unable to parse "$path"');
+ throw StateError('Unable to parse "$path"');
}
return result;
}
diff --git a/pkg/analyzer/test/verify_docs_test.dart b/pkg/analyzer/test/verify_docs_test.dart
index 09c9b4f..6e5236c 100644
--- a/pkg/analyzer/test/verify_docs_test.dart
+++ b/pkg/analyzer/test/verify_docs_test.dart
@@ -109,7 +109,7 @@
''',
modificationStamp: 1);
try {
- AnalysisContextCollection collection = new AnalysisContextCollection(
+ AnalysisContextCollection collection = AnalysisContextCollection(
includedPaths: <String>[snippetDirPath], resourceProvider: provider);
List<AnalysisContext> contexts = collection.contexts;
if (contexts.length != 1) {
diff --git a/pkg/analyzer/test/verify_tests_test.dart b/pkg/analyzer/test/verify_tests_test.dart
index dc8285b..a25248d 100644
--- a/pkg/analyzer/test/verify_tests_test.dart
+++ b/pkg/analyzer/test/verify_tests_test.dart
@@ -20,7 +20,7 @@
String analyzerPath = provider.pathContext.join(packageRoot, 'analyzer');
String testDirPath = provider.pathContext.join(analyzerPath, 'test');
- AnalysisContextCollection collection = new AnalysisContextCollection(
+ AnalysisContextCollection collection = AnalysisContextCollection(
includedPaths: <String>[testDirPath], resourceProvider: provider);
List<AnalysisContext> contexts = collection.contexts;
if (contexts.length != 1) {
diff --git a/pkg/analyzer/tool/analysis_driver/inspect_exception.dart b/pkg/analyzer/tool/analysis_driver/inspect_exception.dart
index b15b904..2dc63cc 100644
--- a/pkg/analyzer/tool/analysis_driver/inspect_exception.dart
+++ b/pkg/analyzer/tool/analysis_driver/inspect_exception.dart
@@ -8,7 +8,7 @@
import 'package:args/args.dart';
main(List<String> args) {
- ArgParser argParser = new ArgParser()..addFlag('raw');
+ ArgParser argParser = ArgParser()..addFlag('raw');
ArgResults argResults = argParser.parse(args);
if (argResults.rest.length != 1) {
print(argParser.usage);
@@ -17,9 +17,9 @@
}
String path = argResults.rest[0];
- List<int> bytes = new File(path).readAsBytesSync();
+ List<int> bytes = File(path).readAsBytesSync();
AnalysisDriverExceptionContext context =
- new AnalysisDriverExceptionContext.fromBuffer(bytes);
+ AnalysisDriverExceptionContext.fromBuffer(bytes);
print(context.path);
print('');
diff --git a/pkg/analyzer/tool/diagnostics/diagnostics.md b/pkg/analyzer/tool/diagnostics/diagnostics.md
index 107a489..e5b81f3 100644
--- a/pkg/analyzer/tool/diagnostics/diagnostics.md
+++ b/pkg/analyzer/tool/diagnostics/diagnostics.md
@@ -1,10 +1,11 @@
---
-title: Diagnostics
+title: Diagnostic messages
description: Details for diagnostics produced by the Dart analyzer.
---
{%- comment %}
WARNING: Do NOT EDIT this file directly. It is autogenerated by the script in
`pkg/analyzer/tool/diagnostics/generate.dart` in the sdk repository.
+Update instructions: https://github.com/dart-lang/site-www/issues/1949
{% endcomment -%}
This page lists diagnostic messages produced by the Dart analyzer,
@@ -3077,10 +3078,10 @@
### return_of_invalid_type
-_A value of type '{0} can't be returned from function '{2}' because it has a
+_A value of type '{0}' can't be returned from function '{2}' because it has a
return type of '{1}'._
-_A value of type '{0} can't be returned from method '{2}' because it has a
+_A value of type '{0}' can't be returned from method '{2}' because it has a
return type of '{1}'._
#### Description
diff --git a/pkg/analyzer/tool/diagnostics/generate.dart b/pkg/analyzer/tool/diagnostics/generate.dart
index 17ffb98..ee6218d 100644
--- a/pkg/analyzer/tool/diagnostics/generate.dart
+++ b/pkg/analyzer/tool/diagnostics/generate.dart
@@ -173,7 +173,7 @@
includedPaths.add(codePath.declarationPath);
}
}
- AnalysisContextCollection collection = new AnalysisContextCollection(
+ AnalysisContextCollection collection = AnalysisContextCollection(
includedPaths: includedPaths,
resourceProvider: PhysicalResourceProvider.INSTANCE);
for (CodePath codePath in codePaths) {
@@ -341,11 +341,11 @@
ParsedUnitResult _parse(AnalysisContextCollection collection, String path) {
AnalysisSession session = collection.contextFor(path).currentSession;
if (session == null) {
- throw new StateError('No session for "$path"');
+ throw StateError('No session for "$path"');
}
ParsedUnitResult result = session.getParsedUnit(path);
if (result.state != ResultState.VALID) {
- throw new StateError('Unable to parse "$path"');
+ throw StateError('Unable to parse "$path"');
}
return result;
}
@@ -431,12 +431,13 @@
void _writeHeader(StringSink sink) {
sink.write('''
---
-title: Diagnostics
+title: Diagnostic messages
description: Details for diagnostics produced by the Dart analyzer.
---
{%- comment %}
WARNING: Do NOT EDIT this file directly. It is autogenerated by the script in
`pkg/analyzer/tool/diagnostics/generate.dart` in the sdk repository.
+Update instructions: https://github.com/dart-lang/site-www/issues/1949
{% endcomment -%}
This page lists diagnostic messages produced by the Dart analyzer,
diff --git a/pkg/analyzer/tool/experiments/generate.dart b/pkg/analyzer/tool/experiments/generate.dart
index 188115e..e89e24d 100644
--- a/pkg/analyzer/tool/experiments/generate.dart
+++ b/pkg/analyzer/tool/experiments/generate.dart
@@ -18,15 +18,15 @@
}
List<GeneratedContent> get allTargets {
- Map<dynamic, dynamic> experimentsYaml = loadYaml(new File(join(
+ Map<dynamic, dynamic> experimentsYaml = loadYaml(File(join(
normalize(join(pkg_root.packageRoot, '../tools')),
'experimental_features.yaml'))
.readAsStringSync());
return <GeneratedContent>[
- new GeneratedFile('lib/src/dart/analysis/experiments.g.dart',
+ GeneratedFile('lib/src/dart/analysis/experiments.g.dart',
(String pkgPath) async {
- var generator = new _ExperimentsGenerator(experimentsYaml);
+ var generator = _ExperimentsGenerator(experimentsYaml);
generator.generateFormatCode();
return generator.out.toString();
}),
@@ -50,7 +50,7 @@
List<String> keysSorted;
- final out = new StringBuffer('''
+ final out = StringBuffer('''
//
// THIS FILE IS GENERATED. DO NOT EDIT.
//
diff --git a/pkg/analyzer/tool/messages/generate.dart b/pkg/analyzer/tool/messages/generate.dart
index 0566bdf..020225e 100644
--- a/pkg/analyzer/tool/messages/generate.dart
+++ b/pkg/analyzer/tool/messages/generate.dart
@@ -29,23 +29,23 @@
String frontEndSharedPkgPath =
normalize(join(pkg_root.packageRoot, '_fe_analyzer_shared'));
- Map<dynamic, dynamic> messagesYaml = loadYaml(
- new File(join(frontEndPkgPath, 'messages.yaml')).readAsStringSync());
- String errorConverterSource = new File(join(analyzerPkgPath,
+ Map<dynamic, dynamic> messagesYaml =
+ loadYaml(File(join(frontEndPkgPath, 'messages.yaml')).readAsStringSync());
+ String errorConverterSource = File(join(analyzerPkgPath,
joinAll(posix.split('lib/src/fasta/error_converter.dart'))))
.readAsStringSync();
- String syntacticErrorsSource = new File(join(analyzerPkgPath,
+ String syntacticErrorsSource = File(join(analyzerPkgPath,
joinAll(posix.split('lib/src/dart/error/syntactic_errors.dart'))))
.readAsStringSync();
- String parserSource = new File(join(frontEndSharedPkgPath,
+ String parserSource = File(join(frontEndSharedPkgPath,
joinAll(posix.split('lib/src/parser/parser.dart'))))
.readAsStringSync();
- final codeGenerator = new _SyntacticErrorGenerator(
+ final codeGenerator = _SyntacticErrorGenerator(
messagesYaml, errorConverterSource, syntacticErrorsSource, parserSource);
await GeneratedContent.generateAll(analyzerPkgPath, <GeneratedContent>[
- new GeneratedFile('lib/src/dart/error/syntactic_errors.g.dart',
+ GeneratedFile('lib/src/dart/error/syntactic_errors.g.dart',
(String pkgPath) async {
codeGenerator.generateFormatCode();
return codeGenerator.out.toString();
@@ -93,8 +93,8 @@
final String syntacticErrorsSource;
final String parserSource;
final translatedEntries = <Map>[];
- final translatedFastaErrorCodes = new Set<String>();
- final out = new StringBuffer('''
+ final translatedFastaErrorCodes = Set<String>();
+ final out = StringBuffer('''
//
// THIS FILE IS GENERATED. DO NOT EDIT.
//
@@ -190,7 +190,7 @@
}
void generateFastaAnalyzerErrorCodeList() {
- final sorted = new List<Map>(translatedEntries.length);
+ final sorted = List<Map>(translatedEntries.length);
for (var entry in translatedEntries) {
var index = entry['index'];
if (index is int && index >= 1 && index <= sorted.length) {
@@ -227,15 +227,14 @@
final messageToName = <String, String>{};
for (ErrorCode errorCode in errorCodeValues) {
if (errorCode is ParserErrorCode) {
- String message =
- errorCode.message.replaceAll(new RegExp(r'\{\d+\}'), '');
+ String message = errorCode.message.replaceAll(RegExp(r'\{\d+\}'), '');
messageToName[message] = errorCode.name;
}
}
String messageFromEntryTemplate(Map entry) {
String template = entry['template'];
- String message = template.replaceAll(new RegExp(r'#\w+'), '');
+ String message = template.replaceAll(RegExp(r'#\w+'), '');
return message;
}
@@ -250,7 +249,7 @@
// List the ParserErrorCodes that could easily be auto generated
// but have not been already.
- final analyzerToFasta = new Map<String, List<String>>();
+ final analyzerToFasta = Map<String, List<String>>();
messagesYaml.forEach((fastaName, entry) {
if (entry is Map) {
final analyzerName = messageToName[messageFromEntryTemplate(entry)];
@@ -278,7 +277,7 @@
}
// List error codes in the parser that have not been translated.
- final untranslatedFastaErrorCodes = new Set<String>();
+ final untranslatedFastaErrorCodes = Set<String>();
Token token = scanString(parserSource).tokens;
while (!token.isEof) {
if (token.isIdentifier) {
diff --git a/pkg/analyzer/tool/summary/build_sdk_summaries.dart b/pkg/analyzer/tool/summary/build_sdk_summaries.dart
index aec1b06..8292a9f 100644
--- a/pkg/analyzer/tool/summary/build_sdk_summaries.dart
+++ b/pkg/analyzer/tool/summary/build_sdk_summaries.dart
@@ -51,9 +51,9 @@
void _buildSummary(String sdkPath, String outPath) {
print('Generating strong mode summary.');
- Stopwatch sw = new Stopwatch()..start();
- List<int> bytes = new SummaryBuilder.forSdk(sdkPath).build();
- new File(outPath).writeAsBytesSync(bytes, mode: FileMode.writeOnly);
+ Stopwatch sw = Stopwatch()..start();
+ List<int> bytes = SummaryBuilder.forSdk(sdkPath).build();
+ File(outPath).writeAsBytesSync(bytes, mode: FileMode.writeOnly);
print('\tDone in ${sw.elapsedMilliseconds} ms.');
}
diff --git a/pkg/analyzer/tool/summary/generate.dart b/pkg/analyzer/tool/summary/generate.dart
index 842e513..6c826e9 100644
--- a/pkg/analyzer/tool/summary/generate.dart
+++ b/pkg/analyzer/tool/summary/generate.dart
@@ -36,15 +36,14 @@
}
List<GeneratedContent> getAllTargets(String idlPath) {
- final GeneratedFile formatTarget =
- new GeneratedFile('format.dart', (_) async {
- _CodeGenerator codeGenerator = new _CodeGenerator(idlPath);
+ final GeneratedFile formatTarget = GeneratedFile('format.dart', (_) async {
+ _CodeGenerator codeGenerator = _CodeGenerator(idlPath);
codeGenerator.generateFormatCode();
return codeGenerator._outBuffer.toString();
});
- final GeneratedFile schemaTarget = new GeneratedFile('format.fbs', (_) async {
- _CodeGenerator codeGenerator = new _CodeGenerator(idlPath);
+ final GeneratedFile schemaTarget = GeneratedFile('format.fbs', (_) async {
+ _CodeGenerator codeGenerator = _CodeGenerator(idlPath);
codeGenerator.generateFlatBufferSchema();
return codeGenerator._outBuffer.toString();
});
@@ -78,7 +77,7 @@
if (type.isList) {
if (builder) {
idl_model.FieldType elementType =
- new idl_model.FieldType(type.typeName, false);
+ idl_model.FieldType(type.typeName, false);
return '<${encodedType(elementType)}>[]';
} else {
return 'const <${idlPrefix(type.typeName)}>[]';
@@ -434,7 +433,7 @@
writeCode = 'fbBuilder.addUint8($index, $valueName.index);';
}
if (writeCode == null) {
- throw new UnimplementedError('Writing type ${fieldType.typeName}');
+ throw UnimplementedError('Writing type ${fieldType.typeName}');
}
out('if ($condition) {');
indent(() {
@@ -637,20 +636,20 @@
class _CodeGenerator {
/// Buffer in which generated code is accumulated.
- final StringBuffer _outBuffer = new StringBuffer();
+ final StringBuffer _outBuffer = StringBuffer();
/// Semantic model of the "IDL" input file.
idl_model.Idl _idl;
_CodeGenerator(String idlPath) {
// Parse the input "IDL" file.
- File idlFile = new File(idlPath);
+ File idlFile = File(idlPath);
String idlText =
- idlFile.readAsStringSync().replaceAll(new RegExp('\r\n?'), '\n');
+ idlFile.readAsStringSync().replaceAll(RegExp('\r\n?'), '\n');
// Extract a description of the IDL and make sure it is valid.
var startingToken = scanString(idlText, includeComments: true).tokens;
- var listener = new MiniAstBuilder();
- var parser = new MiniAstParser(listener);
+ var listener = MiniAstBuilder();
+ var parser = MiniAstParser(listener);
parser.parseUnit(startingToken);
extractIdl(listener.compilationUnit);
checkIdl();
@@ -662,11 +661,11 @@
_idl.classes.forEach((String name, idl_model.ClassDeclaration cls) {
if (cls.fileIdentifier != null) {
if (cls.fileIdentifier.length != 4) {
- throw new Exception('$name: file identifier must be 4 characters');
+ throw Exception('$name: file identifier must be 4 characters');
}
for (int i = 0; i < cls.fileIdentifier.length; i++) {
if (cls.fileIdentifier.codeUnitAt(i) >= 256) {
- throw new Exception(
+ throw Exception(
'$name: file identifier must be encodable as Latin-1');
}
}
@@ -689,19 +688,19 @@
} else if (type.typeName == 'String') {
// List of strings is ok
} else {
- throw new Exception(
+ throw Exception(
'$name.$fieldName: illegal type (list of ${type.typeName})');
}
}
if (idsUsed.containsKey(field.id)) {
- throw new Exception('$name.$fieldName: id ${field.id} already used by'
+ throw Exception('$name.$fieldName: id ${field.id} already used by'
' ${idsUsed[field.id]}');
}
idsUsed[field.id] = fieldName;
}
for (int i = 0; i < idsUsed.length; i++) {
if (!idsUsed.containsKey(i)) {
- throw new Exception('$name: no field uses id $i');
+ throw Exception('$name: no field uses id $i');
}
}
});
@@ -710,7 +709,7 @@
/// Process the AST in [idlParsed] and store the resulting semantic model in
/// [_idl]. Also perform some error checking.
void extractIdl(CompilationUnit idlParsed) {
- _idl = new idl_model.Idl();
+ _idl = idl_model.Idl();
for (CompilationUnitMember decl in idlParsed.declarations) {
if (decl is ClassDeclaration) {
bool isTopLevel = false;
@@ -728,12 +727,12 @@
if (arg is StringLiteral) {
fileIdentifier = arg.stringValue;
} else {
- throw new Exception(
+ throw Exception(
'Class `$clsName`: TopLevel argument must be a string'
' literal');
}
} else if (annotation.arguments.isNotEmpty) {
- throw new Exception(
+ throw Exception(
'Class `$clsName`: TopLevel requires 0 or 1 arguments');
}
} else if (annotation.arguments == null &&
@@ -748,7 +747,7 @@
if (arg is StringLiteral) {
variantField = arg.stringValue;
} else {
- throw new Exception(
+ throw Exception(
'Class `$clsName`: @Variant argument must be a string literal',
);
}
@@ -759,7 +758,7 @@
}
}
}
- idl_model.ClassDeclaration cls = new idl_model.ClassDeclaration(
+ idl_model.ClassDeclaration cls = idl_model.ClassDeclaration(
documentation: _getNodeDoc(decl),
name: clsName,
isTopLevel: isTopLevel,
@@ -770,8 +769,7 @@
_idl.classes[clsName] = cls;
String expectedBase = 'base.SummaryClass';
if (decl.superclass == null || decl.superclass.name != expectedBase) {
- throw new Exception(
- 'Class `$clsName` needs to extend `$expectedBase`');
+ throw Exception('Class `$clsName` needs to extend `$expectedBase`');
}
for (ClassMember classMember in decl.members) {
if (classMember is MethodDeclaration && classMember.isGetter) {
@@ -781,21 +779,20 @@
// Ignore `fromBuffer` declarations; they simply forward to the
// read functions generated by [_generateReadFunction].
} else {
- throw new Exception('Unexpected class member `$classMember`');
+ throw Exception('Unexpected class member `$classMember`');
}
}
} else if (decl is EnumDeclaration) {
String doc = _getNodeDoc(decl);
idl_model.EnumDeclaration enm =
- new idl_model.EnumDeclaration(doc, decl.name);
+ idl_model.EnumDeclaration(doc, decl.name);
_idl.enums[enm.name] = enm;
for (EnumConstantDeclaration constDecl in decl.constants) {
String doc = _getNodeDoc(constDecl);
- enm.values
- .add(new idl_model.EnumValueDeclaration(doc, constDecl.name));
+ enm.values.add(idl_model.EnumValueDeclaration(doc, constDecl.name));
}
} else {
- throw new Exception('Unexpected declaration `$decl`');
+ throw Exception('Unexpected declaration `$decl`');
}
}
}
@@ -865,7 +862,7 @@
) {
var desc = '${cls.name}.${getter.name}';
if (getter.returnType == null) {
- throw new Exception('Getter needs a type: $desc');
+ throw Exception('Getter needs a type: $desc');
}
var type = getter.returnType;
@@ -878,7 +875,7 @@
type = type.typeArguments[0];
}
if (type.typeArguments != null) {
- throw new Exception('Cannot handle type arguments in `$type`');
+ throw Exception('Cannot handle type arguments in `$type`');
}
int id;
@@ -889,7 +886,7 @@
for (Annotation annotation in getter.metadata) {
if (annotation.name == 'Id') {
if (id != null) {
- throw new Exception('Duplicate @id annotation ($getter)');
+ throw Exception('Duplicate @id annotation ($getter)');
}
if (annotation.arguments == null) {
throw Exception('@Id must be passed an argument ($desc)');
@@ -902,13 +899,13 @@
if (idExpression is IntegerLiteral) {
id = idExpression.value;
} else {
- throw new Exception(
+ throw Exception(
'@Id argument must be an integer literal ($desc)',
);
}
} else if (annotation.name == 'deprecated') {
if (annotation.arguments != null) {
- throw new Exception('@deprecated does not take args ($desc)');
+ throw Exception('@deprecated does not take args ($desc)');
}
isDeprecated = true;
} else if (annotation.name == 'informative') {
@@ -961,10 +958,10 @@
}
}
if (id == null) {
- throw new Exception('Missing @id annotation ($desc)');
+ throw Exception('Missing @id annotation ($desc)');
}
- var fieldType = new idl_model.FieldType(type.name, isList);
+ var fieldType = idl_model.FieldType(type.name, isList);
String name = getter.name;
Map<String, idl_model.LogicalProperty> logicalProperties;
@@ -1333,6 +1330,12 @@
return '_result[${quoted(name)}] = $convertField';
}
+ void writeConditionalStatement(String condition, String statement) {
+ out('if ($condition) {');
+ out(' $statement;');
+ out('}');
+ }
+
// Write toJson().
out('@override');
out('Map<String, Object> toJson() {');
@@ -1345,7 +1348,7 @@
if (field.logicalProperties == null) {
var condition = jsonCondition(field.type, field.name);
var storeField = jsonStore(field.type, field.name);
- out('if ($condition) $storeField;');
+ writeConditionalStatement(condition, storeField);
}
}
for (var variant in _computeVariants(cls)) {
@@ -1359,7 +1362,7 @@
if (logicalProperty.variants.contains(variant)) {
var condition = jsonCondition(field.type, logicalName);
var storeField = jsonStore(field.type, logicalName);
- out('if ($condition) $storeField;');
+ writeConditionalStatement(condition, storeField);
}
}
}
@@ -1373,7 +1376,7 @@
for (idl_model.FieldDeclaration field in cls.fields) {
String condition = jsonCondition(field.type, field.name);
String storeField = jsonStore(field.type, field.name);
- out('if ($condition) $storeField;');
+ writeConditionalStatement(condition, storeField);
}
});
}
diff --git a/pkg/analyzer/tool/summary/mini_ast.dart b/pkg/analyzer/tool/summary/mini_ast.dart
index cdbb435..62c11ac 100644
--- a/pkg/analyzer/tool/summary/mini_ast.dart
+++ b/pkg/analyzer/tool/summary/mini_ast.dart
@@ -65,7 +65,7 @@
tokens.add(commentToken);
commentToken = commentToken.next;
}
- return new Comment._(isDocumentation, tokens);
+ return Comment._(isDocumentation, tokens);
}
Comment._(this.isDocumentation, this.tokens);
@@ -181,7 +181,7 @@
class MiniAstBuilder extends StackListener {
bool inMetadata = false;
- final compilationUnit = new CompilationUnit();
+ final compilationUnit = CompilationUnit();
@override
Uri get uri => null;
@@ -193,7 +193,7 @@
@override
void addProblem(Message message, int charOffset, int length,
- {bool wasHandled: false, List<LocatedMessage> context}) {
+ {bool wasHandled = false, List<LocatedMessage> context}) {
internalProblem(message, charOffset, uri);
}
@@ -206,7 +206,7 @@
void beginMetadataStar(Token token) {
debugEvent("beginMetadataStar");
if (token.precedingComments != null) {
- push(new Comment(token.precedingComments));
+ push(Comment(token.precedingComments));
} else {
push(NullValue.Comments);
}
@@ -215,7 +215,7 @@
@override
void endArguments(int count, Token beginToken, Token endToken) {
debugEvent("Arguments");
- push(popList(count, new List<dynamic>.filled(count, null, growable: true)));
+ push(popList(count, List<dynamic>.filled(count, null, growable: true)));
}
@override
@@ -223,7 +223,7 @@
DeclarationKind kind, int memberCount, Token beginToken, Token endToken) {
debugEvent("ClassOrMixinBody");
push(popList(memberCount,
- new List<ClassMember>.filled(memberCount, null, growable: true)));
+ List<ClassMember>.filled(memberCount, null, growable: true)));
}
@override
@@ -254,8 +254,8 @@
String name = pop();
List<Annotation> metadata = popTypedList();
Comment comment = pop();
- compilationUnit.declarations.add(
- new ClassDeclaration(comment, metadata, name, superclass, members));
+ compilationUnit.declarations
+ .add(ClassDeclaration(comment, metadata, name, superclass, members));
}
@override
@@ -277,13 +277,13 @@
void endEnum(Token enumKeyword, Token leftBrace, int count) {
debugEvent("Enum");
List<EnumConstantDeclaration> constants =
- new List.filled(count, null, growable: true);
+ List.filled(count, null, growable: true);
popList(count, constants);
String name = pop();
List<Annotation> metadata = popTypedList();
Comment comment = pop();
compilationUnit.declarations
- .add(new EnumDeclaration(comment, metadata, name, constants));
+ .add(EnumDeclaration(comment, metadata, name, constants));
}
@override
@@ -295,7 +295,7 @@
String name = pop();
List<Annotation> metadata = popTypedList();
Comment comment = pop();
- push(new ConstructorDeclaration(comment, metadata, name));
+ push(ConstructorDeclaration(comment, metadata, name));
}
@override
@@ -329,7 +329,7 @@
@override
void handleIdentifierList(int count) {
debugEvent("IdentifierList");
- push(popList(count, new List<dynamic>.filled(count, null, growable: true)));
+ push(popList(count, List<dynamic>.filled(count, null, growable: true)));
}
@override
@@ -365,7 +365,7 @@
void endLiteralString(int interpolationCount, Token endToken) {
super.endLiteralString(interpolationCount, endToken);
String value = pop();
- push(new StringLiteral(value));
+ push(StringLiteral(value));
}
@override
@@ -395,15 +395,14 @@
String constructorName = popIfNotNull(periodBeforeName);
pop(); // Type arguments
String name = pop();
- push(new Annotation(name, constructorName,
+ push(Annotation(name, constructorName,
arguments == null ? null : arguments.cast<Expression>()));
}
@override
void endMetadataStar(int count) {
debugEvent("MetadataStar");
- push(popList(
- count, new List<Annotation>.filled(count, null, growable: true)) ??
+ push(popList(count, List<Annotation>.filled(count, null, growable: true)) ??
NullValue.Metadata);
}
@@ -418,7 +417,7 @@
TypeName returnType = pop();
List<Annotation> metadata = popTypedList();
Comment comment = pop();
- push(new MethodDeclaration(
+ push(MethodDeclaration(
comment, metadata, getOrSet?.lexeme == 'get', name, returnType));
}
@@ -430,7 +429,7 @@
pop(); // Type arguments
if (arguments != null) {
pop(); // Receiver
- push(new UnknownExpression());
+ push(UnknownExpression());
} else {
// Property get.
}
@@ -479,8 +478,7 @@
// We ignore top level variable declarations; they are present just to make
// the IDL analyze without warnings.
debugEvent("TopLevelFields");
- popList(
- count, new List<dynamic>.filled(count, null, growable: true)); // Fields
+ popList(count, List<dynamic>.filled(count, null, growable: true)); // Fields
pop(); // Type
pop(); // Metadata
pop(); // Comment
@@ -489,8 +487,7 @@
@override
void endTypeArguments(int count, Token beginToken, Token endToken) {
debugEvent("TypeArguments");
- push(
- popList(count, new List<TypeName>.filled(count, null, growable: true)));
+ push(popList(count, List<TypeName>.filled(count, null, growable: true)));
}
@override
@@ -514,12 +511,12 @@
if (leftOperand is String && !leftOperand.contains('.')) {
push(PrefixedIdentifier(leftOperand, token, rightOperand));
} else {
- push(new UnknownExpression());
+ push(UnknownExpression());
}
} else {
pop(); // RHS
pop(); // LHS
- push(new UnknownExpression());
+ push(UnknownExpression());
}
}
@@ -549,7 +546,7 @@
if (context == IdentifierContext.enumValueDeclaration) {
List<Annotation> metadata = popTypedList();
Comment comment = pop();
- push(new EnumConstantDeclaration(comment, metadata, token.lexeme));
+ push(EnumConstantDeclaration(comment, metadata, token.lexeme));
} else {
push(token.lexeme);
}
@@ -563,12 +560,12 @@
void handleLiteralInt(Token token) {
debugEvent("LiteralInt");
- push(new IntegerLiteral(int.parse(token.lexeme)));
+ push(IntegerLiteral(int.parse(token.lexeme)));
}
void handleLiteralNull(Token token) {
debugEvent("LiteralNull");
- push(new UnknownExpression());
+ push(UnknownExpression());
}
@override
@@ -585,7 +582,7 @@
reportErrorIfNullableType(questionMark);
List<TypeName> typeArguments = popTypedList();
String name = pop();
- push(new TypeName(name, typeArguments));
+ push(TypeName(name, typeArguments));
}
@override
@@ -597,7 +594,7 @@
/// from the resulting `List<dynamic>`.
List<T> popTypedList<T>() {
List list = pop();
- return list != null ? new List<T>.from(list) : null;
+ return list != null ? List<T>.from(list) : null;
}
List popList(int n, List list) {
diff --git a/pkg/analyzer/tool/summary/stats.dart b/pkg/analyzer/tool/summary/stats.dart
index 018f9b1..456fe74 100644
--- a/pkg/analyzer/tool/summary/stats.dart
+++ b/pkg/analyzer/tool/summary/stats.dart
@@ -23,10 +23,10 @@
// Read the input.
PackageBundle bundle =
- new PackageBundle.fromBuffer(new File(inputFilePath).readAsBytesSync());
+ PackageBundle.fromBuffer(File(inputFilePath).readAsBytesSync());
// Compute and output stats.
- Stats stats = new Stats();
+ Stats stats = Stats();
stats.record(bundle);
stats.dump();
}
diff --git a/pkg/analyzer/tool/test_log_parser/test_log_parser.dart b/pkg/analyzer/tool/test_log_parser/test_log_parser.dart
index fc4c0d9..bebd6c5 100644
--- a/pkg/analyzer/tool/test_log_parser/test_log_parser.dart
+++ b/pkg/analyzer/tool/test_log_parser/test_log_parser.dart
@@ -13,7 +13,7 @@
}
String filePath = args[0];
- List<String> output = new File(filePath).readAsLinesSync();
+ List<String> output = File(filePath).readAsLinesSync();
int failureCount = 0;
int index = 0;
final int expectedPrefixLength = 'Expected: '.length;
@@ -31,7 +31,7 @@
String expected = output[index + 1].substring(expectedPrefixLength);
String actual = output[index + 2].substring(actualPrefixLength);
String key = '$expected-$actual';
- currentResult = new TestResult(testName, expected, actual);
+ currentResult = TestResult(testName, expected, actual);
testsByExpectedAndActual
.putIfAbsent(key, () => <TestResult>[])
.add(currentResult);
@@ -115,7 +115,7 @@
/// A representation of the result of a single test.
class TestResult {
- static final RegExp framePattern = new RegExp('#[0-9]+ ');
+ static final RegExp framePattern = RegExp('#[0-9]+ ');
String testName;
String expected;
diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
index d4a9061..086c426 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
@@ -482,7 +482,7 @@
} else {
write(' => ');
selectAll(() {
- write('null');
+ write('throw UnimplementedError()');
});
write(';');
}
@@ -555,7 +555,7 @@
});
} else {
selectAll(() {
- write('return null;');
+ write('throw UnimplementedError();');
});
}
writeln();
diff --git a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
index 2b22b737..98f6ec8 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
@@ -146,7 +146,7 @@
return optype;
}
- optype._typeSystem = target.unit?.declaredElement?.context?.typeSystem;
+ optype._typeSystem = target.unit?.declaredElement?.library?.typeSystem;
var targetNode = target.containingNode;
targetNode.accept(new _OpTypeAstVisitor(optype, target.entity, offset));
diff --git a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
index 37ce297..8726957 100644
--- a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
+++ b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
@@ -1223,7 +1223,7 @@
DartChangeBuilderImpl builder = newBuilder();
await builder.addFileEdit(path, (FileEditBuilder builder) {
builder.addInsertion(content.length - 1, (EditBuilder builder) {
- var typeProvider = unit.declaredElement.context.typeProvider;
+ var typeProvider = unit.declaredElement.library.typeProvider;
(builder as DartEditBuilder).writeType(typeProvider.dynamicType);
});
});
@@ -1439,7 +1439,7 @@
DartChangeBuilderImpl builder = newBuilder();
await builder.addFileEdit(path, (FileEditBuilder builder) {
builder.addInsertion(content.length - 1, (EditBuilder builder) {
- var typeProvider = unit.declaredElement.context.typeProvider;
+ var typeProvider = unit.declaredElement.library.typeProvider;
(builder as DartEditBuilder)
.writeType(typeProvider.dynamicType, required: true);
});
@@ -2286,10 +2286,10 @@
expected: '''
@override
// TODO: implement zero
- int get zero => null;
+ int get zero => throw UnimplementedError();
''',
displayText: 'zero => …',
- selection: new SourceRange(111, 4),
+ selection: new SourceRange(111, 26),
);
}
@@ -2328,11 +2328,11 @@
@override
A add(A a) {
// TODO: implement add
- return null;
+ throw UnimplementedError();
}
''',
displayText: 'add(A a) { … }',
- selection: new SourceRange(111, 12),
+ selection: new SourceRange(111, 27),
);
}
@@ -2418,11 +2418,11 @@
@override
forEach(int Function(double p1, String p2) f) {
// TODO: implement forEach
- return null;
+ throw UnimplementedError();
}
''',
displayText: 'forEach(int Function(double p1, String p2) f) { … }',
- selection: new SourceRange(176, 12),
+ selection: new SourceRange(176, 27),
);
}
@@ -2463,11 +2463,11 @@
@override
List<T> get<T>(T key) {
// TODO: implement get
- return null;
+ throw UnimplementedError();
}
''',
displayText: 'get<T>(T key) { … }',
- selection: new SourceRange(136, 12),
+ selection: new SourceRange(136, 27),
);
}
@@ -2508,11 +2508,11 @@
@override
List<T> get<T extends V2>(K2 key) {
// TODO: implement get
- return null;
+ throw UnimplementedError();
}
''',
displayText: 'get<T extends V2>(K2 key) { … }',
- selection: new SourceRange(184, 12),
+ selection: new SourceRange(184, 27),
);
}
@@ -2555,11 +2555,11 @@
@override
int foo(T Function<T>() fn) {
// TODO: implement foo
- return null;
+ throw UnimplementedError();
}
''',
displayText: 'foo(T Function<T>() fn) { … }',
- selection: new SourceRange(145, 12),
+ selection: new SourceRange(145, 27),
);
}
@@ -2600,11 +2600,11 @@
@override
List<Null> foo() {
// TODO: implement foo
- return null;
+ throw UnimplementedError();
}
''',
displayText: 'foo() { … }',
- selection: new SourceRange(123, 12),
+ selection: new SourceRange(123, 27),
);
}
@@ -2666,11 +2666,11 @@
@override
List<void> foo() {
// TODO: implement foo
- return null;
+ throw UnimplementedError();
}
''',
displayText: 'foo() { … }',
- selection: new SourceRange(123, 12),
+ selection: new SourceRange(123, 27),
);
}
diff --git a/pkg/compiler/lib/src/common_elements.dart b/pkg/compiler/lib/src/common_elements.dart
index 4f135b3..0fdf706 100644
--- a/pkg/compiler/lib/src/common_elements.dart
+++ b/pkg/compiler/lib/src/common_elements.dart
@@ -504,6 +504,7 @@
FunctionEntity get rtiBindMethod;
FunctionEntity get rtiAddRulesMethod;
FunctionEntity get rtiAddErasedTypesMethod;
+ FunctionEntity get rtiAddTypeParameterVariancesMethod;
FunctionEntity get generalIsTestImplementation;
FunctionEntity get generalAsCheckImplementation;
@@ -1943,6 +1944,12 @@
FunctionEntity get rtiAddErasedTypesMethod => _rtiAddErasedTypesMethod ??=
_findClassMember(_rtiUniverseClass, 'addErasedTypes');
+ FunctionEntity _rtiAddTypeParameterVariancesMethod;
+ @override
+ FunctionEntity get rtiAddTypeParameterVariancesMethod =>
+ _rtiAddTypeParameterVariancesMethod ??=
+ _findClassMember(_rtiUniverseClass, 'addTypeParameterVariances');
+
FunctionEntity _generalIsTestImplementation;
@override
FunctionEntity get generalIsTestImplementation =>
@@ -2305,6 +2312,9 @@
/// `Object`.
DartType getTypeVariableBound(TypeVariableEntity typeVariable);
+ /// Returns the variances for each type parameter in [cls].
+ List<Variance> getTypeVariableVariances(ClassEntity cls);
+
/// Returns the type of [function].
FunctionType getFunctionType(FunctionEntity function);
diff --git a/pkg/compiler/lib/src/elements/entities.dart b/pkg/compiler/lib/src/elements/entities.dart
index a621644..9ca42c6 100644
--- a/pkg/compiler/lib/src/elements/entities.dart
+++ b/pkg/compiler/lib/src/elements/entities.dart
@@ -218,6 +218,10 @@
int get index => values.indexOf(this);
}
+/// Values for variance annotations.
+/// This needs to be kept in sync with values of `Variance` in `dart:_rti`.
+enum Variance { legacyCovariant, covariant, contravariant, invariant }
+
/// Stripped down super interface for constructor like entities.
///
/// Currently only [ConstructorElement] but later also kernel based Dart
diff --git a/pkg/compiler/lib/src/elements/types.dart b/pkg/compiler/lib/src/elements/types.dart
index a5cee44..0996fbd 100644
--- a/pkg/compiler/lib/src/elements/types.dart
+++ b/pkg/compiler/lib/src/elements/types.dart
@@ -1501,6 +1501,9 @@
/// Returns the declared bound of [element].
DartType getTypeVariableBound(TypeVariableEntity element);
+ /// Returns the variances for each type parameter in [cls].
+ List<Variance> getTypeVariableVariances(ClassEntity cls);
+
@override
bool visitType(T t, T s) {
throw 'internal error: unknown type ${t}';
@@ -1529,10 +1532,25 @@
bool checkTypeArguments(InterfaceType instance, InterfaceType other) {
List<T> tTypeArgs = instance.typeArguments;
List<T> sTypeArgs = other.typeArguments;
+ List<Variance> tVariances = getTypeVariableVariances(instance.element);
assert(tTypeArgs.length == sTypeArgs.length);
+ assert(tTypeArgs.length == tVariances.length);
for (int i = 0; i < tTypeArgs.length; i++) {
- if (invalidTypeArguments(tTypeArgs[i], sTypeArgs[i])) {
- return false;
+ switch (tVariances[i]) {
+ case Variance.legacyCovariant:
+ case Variance.covariant:
+ if (invalidTypeArguments(tTypeArgs[i], sTypeArgs[i])) return false;
+ break;
+ case Variance.contravariant:
+ if (invalidTypeArguments(sTypeArgs[i], tTypeArgs[i])) return false;
+ break;
+ case Variance.invariant:
+ if (invalidTypeArguments(tTypeArgs[i], sTypeArgs[i]) ||
+ invalidTypeArguments(sTypeArgs[i], tTypeArgs[i])) return false;
+ break;
+ default:
+ throw StateError(
+ "Invalid variance ${tVariances[i]} used for subtype check.");
}
}
return true;
diff --git a/pkg/compiler/lib/src/inferrer/closure_tracer.dart b/pkg/compiler/lib/src/inferrer/closure_tracer.dart
index 3ee6a53..3dd6f3f 100644
--- a/pkg/compiler/lib/src/inferrer/closure_tracer.dart
+++ b/pkg/compiler/lib/src/inferrer/closure_tracer.dart
@@ -62,7 +62,7 @@
.signatureApplies(functionElement.parameterStructure)) {
return;
}
- inferrer.updateParameterAssignments(
+ inferrer.updateParameterInputs(
info, functionElement, info.arguments, selector, mask,
remove: false, addToQueue: false);
});
diff --git a/pkg/compiler/lib/src/inferrer/inferrer_engine.dart b/pkg/compiler/lib/src/inferrer/inferrer_engine.dart
index 98c43b2..729e9bc 100644
--- a/pkg/compiler/lib/src/inferrer/inferrer_engine.dart
+++ b/pkg/compiler/lib/src/inferrer/inferrer_engine.dart
@@ -43,7 +43,7 @@
/// An inferencing engine that computes a call graph of [TypeInformation] nodes
/// by visiting the AST of the application, and then does the inferencing on the
/// graph.
-abstract class InferrerEngine {
+class InferrerEngine {
/// A set of selector names that [List] implements, that we know return their
/// element type.
final Set<Selector> returnsListElementTypeSet =
@@ -58,11 +58,45 @@
new Selector.call(const PublicName('removeLast'), CallStructure.NO_ARGS)
]);
- CompilerOptions get options;
-
/// The [JClosedWorld] on which inference reasoning is based.
- JClosedWorld get closedWorld;
- DiagnosticReporter get reporter;
+ final JsClosedWorld closedWorld;
+
+ final TypeSystem types;
+ final Map<ir.TreeNode, TypeInformation> concreteTypes = {};
+ final InferredDataBuilder inferredDataBuilder;
+
+ final FunctionEntity mainElement;
+
+ final Map<Local, TypeInformation> _defaultTypeOfParameter =
+ new Map<Local, TypeInformation>();
+
+ final WorkQueue _workQueue = new WorkQueue();
+
+ final Set<MemberEntity> _analyzedElements = new Set<MemberEntity>();
+
+ /// The maximum number of times we allow a node in the graph to
+ /// change types. If a node reaches that limit, we give up
+ /// inferencing on it and give it the dynamic type.
+ final int _MAX_CHANGE_COUNT = 6;
+
+ int _overallRefineCount = 0;
+ int _addedInGraph = 0;
+
+ final CompilerOptions _options;
+ final Progress _progress;
+ final DiagnosticReporter _reporter;
+ final CompilerOutput _compilerOutput;
+
+ final Set<ConstructorEntity> _generativeConstructorsExposingThis =
+ new Set<ConstructorEntity>();
+
+ /// Data computed internally within elements, like the type-mask of a send a
+ /// list allocation, or a for-in loop.
+ final Map<MemberEntity, GlobalTypeInferenceElementData> _memberData =
+ new Map<MemberEntity, GlobalTypeInferenceElementData>();
+
+ ElementEnvironment get _elementEnvironment => closedWorld.elementEnvironment;
+
AbstractValueDomain get abstractValueDomain =>
closedWorld.abstractValueDomain;
CommonElements get commonElements => closedWorld.commonElements;
@@ -71,255 +105,19 @@
// [ClosureWorldRefiner].
NoSuchMethodData get noSuchMethodData => closedWorld.noSuchMethodData;
- TypeSystem get types;
- Map<ir.TreeNode, TypeInformation> get concreteTypes;
- InferredDataBuilder get inferredDataBuilder;
-
- FunctionEntity get mainElement;
-
- void runOverAllElements();
-
- void analyze(MemberEntity member);
- void analyzeListAndEnqueue(ListTypeInformation info);
- void analyzeSetAndEnqueue(SetTypeInformation info);
- void analyzeMapAndEnqueue(MapTypeInformation info);
-
- /// Notifies to the inferrer that [analyzedElement] can have return type
- /// [newType]. [currentType] is the type the inference has currently found.
- ///
- /// Returns the new type for [analyzedElement].
- TypeInformation addReturnTypeForMethod(
- FunctionEntity element, TypeInformation unused, TypeInformation newType);
-
- /// Applies [f] to all elements in the universe that match [selector] and
- /// [mask]. If [f] returns false, aborts the iteration.
- void forEachElementMatching(
- Selector selector, AbstractValue mask, bool f(MemberEntity element));
-
- /// Returns the [TypeInformation] node for the default value of a parameter.
- /// If this is queried before it is set by [setDefaultTypeOfParameter], a
- /// [PlaceholderTypeInformation] is returned, which will later be replaced
- /// by the actual node when [setDefaultTypeOfParameter] is called.
- ///
- /// Invariant: After graph construction, no [PlaceholderTypeInformation] nodes
- /// should be present and a default type for each parameter should exist.
- TypeInformation getDefaultTypeOfParameter(Local parameter);
-
- /// This helper breaks abstractions but is currently required to work around
- /// the wrong modeling of default values of optional parameters of
- /// synthetic constructors.
- ///
- /// TODO(johnniwinther): Remove once default values of synthetic parameters
- /// are fixed.
- bool hasAlreadyComputedTypeOfParameterDefault(Local parameter);
-
- /// Sets the type of a parameter's default value to [type]. If the global
- /// mapping in [defaultTypeOfParameter] already contains a type, it must be
- /// a [PlaceholderTypeInformation], which will be replaced. All its uses are
- /// updated.
- void setDefaultTypeOfParameter(Local parameter, TypeInformation type,
- {bool isInstanceMember});
-
- Iterable<MemberEntity> getCallersOfForTesting(MemberEntity element);
-
- // TODO(johnniwinther): Make this private again.
- GlobalTypeInferenceElementData dataOfMember(MemberEntity element);
-
- bool checkIfExposesThis(ConstructorEntity element);
-
- void recordExposesThis(ConstructorEntity element, bool exposesThis);
-
- /// Records that the return type [element] is of type [type].
- void recordReturnType(FunctionEntity element, TypeInformation type);
-
- /// Records that [element] is of type [type].
- void recordTypeOfField(FieldEntity element, TypeInformation type);
-
- /// Registers a call to await with an expression of type [argumentType] as
- /// argument.
- TypeInformation registerAwait(ir.Node node, TypeInformation argument);
-
- /// Registers a call to yield with an expression of type [argumentType] as
- /// argument.
- TypeInformation registerYield(ir.Node node, TypeInformation argument);
-
- /// Registers that [caller] calls [closure] with [arguments].
- ///
- /// [sideEffectsBuilder] will be updated to incorporate the potential callees'
- /// side effects.
- ///
- /// [inLoop] tells whether the call happens in a loop.
- TypeInformation registerCalledClosure(
- ir.Node node,
- Selector selector,
- AbstractValue mask,
- TypeInformation closure,
- MemberEntity caller,
- ArgumentsTypes arguments,
- SideEffectsBuilder sideEffectsBuilder,
- {bool inLoop});
-
- /// Registers that [caller] calls [callee] at location [node], with
- /// [selector], and [arguments]. Note that [selector] is null for forwarding
- /// constructors.
- ///
- /// [sideEffectsBuilder] will be updated to incorporate [callee]'s side
- /// effects.
- ///
- /// [inLoop] tells whether the call happens in a loop.
- TypeInformation registerCalledMember(
- Object node,
- Selector selector,
- AbstractValue mask,
- MemberEntity caller,
- MemberEntity callee,
- ArgumentsTypes arguments,
- SideEffectsBuilder sideEffectsBuilder,
- bool inLoop);
-
- /// Registers that [caller] calls [selector] with [receiverType] as receiver,
- /// and [arguments].
- ///
- /// [sideEffectsBuilder] will be updated to incorporate the potential callees'
- /// side effects.
- ///
- /// [inLoop] tells whether the call happens in a loop.
- TypeInformation registerCalledSelector(
- CallType callType,
- ir.Node node,
- Selector selector,
- AbstractValue mask,
- TypeInformation receiverType,
- MemberEntity caller,
- ArgumentsTypes arguments,
- SideEffectsBuilder sideEffectsBuilder,
- {bool inLoop,
- bool isConditional});
-
- /// Update the assignments to parameters in the graph. [remove] tells whether
- /// assignments must be added or removed. If [init] is false, parameters are
- /// added to the work queue.
- void updateParameterAssignments(TypeInformation caller, MemberEntity callee,
- ArgumentsTypes arguments, Selector selector, AbstractValue mask,
- {bool remove, bool addToQueue: true});
-
- void updateSelectorInMember(MemberEntity owner, CallType callType,
- ir.Node node, Selector selector, AbstractValue mask);
-
- /// Returns the return type of [element].
- TypeInformation returnTypeOfMember(MemberEntity element);
-
- /// Returns the type of [element] when being called with [selector].
- TypeInformation typeOfMemberWithSelector(
- MemberEntity element, Selector selector);
-
- /// Returns the type of [element].
- TypeInformation typeOfMember(MemberEntity element);
-
- /// Returns the type of [element].
- TypeInformation typeOfParameter(Local element);
-
- /// Returns the type for [nativeBehavior]. See documentation on
- /// [NativeBehavior].
- TypeInformation typeOfNativeBehavior(NativeBehavior nativeBehavior);
-
- /// For a given selector, return a shared dynamic call site that will be used
- /// to combine the results of multiple dynamic calls in the program via
- /// [IndirectDynamicCallSiteTypeInformation].
- ///
- /// This is used only for scalability reasons: if there are too many targets
- /// and call sites, we may have a quadratic number of edges in the graph, so
- /// we add a level of indirection to merge the information and keep the graph
- /// smaller.
- DynamicCallSiteTypeInformation typeOfSharedDynamicCall(
- Selector selector, CallStructure structure);
-
- bool returnsListElementType(Selector selector, AbstractValue mask);
-
- bool returnsMapValueType(Selector selector, AbstractValue mask);
-
- void close();
-
- void clear();
-
- /// Returns true if global optimizations such as type inferencing can apply to
- /// the field [element].
- ///
- /// One category of elements that do not apply is runtime helpers that the
- /// backend calls, but the optimizations don't see those calls.
- bool canFieldBeUsedForGlobalOptimizations(FieldEntity element);
-
- /// Returns true if global optimizations such as type inferencing can apply to
- /// the parameter [element].
- ///
- /// One category of elements that do not apply is runtime helpers that the
- /// backend calls, but the optimizations don't see those calls.
- bool canFunctionParametersBeUsedForGlobalOptimizations(
- FunctionEntity function);
-
- /// Returns `true` if inference of parameter types is disabled for [member].
- bool assumeDynamic(MemberEntity member);
-}
-
-class InferrerEngineImpl extends InferrerEngine {
- final Map<Local, TypeInformation> defaultTypeOfParameter =
- new Map<Local, TypeInformation>();
- final WorkQueue workQueue = new WorkQueue();
- @override
- final FunctionEntity mainElement;
- final Set<MemberEntity> analyzedElements = new Set<MemberEntity>();
-
- /// The maximum number of times we allow a node in the graph to
- /// change types. If a node reaches that limit, we give up
- /// inferencing on it and give it the dynamic type.
- final int MAX_CHANGE_COUNT = 6;
-
- int overallRefineCount = 0;
- int addedInGraph = 0;
-
- @override
- final CompilerOptions options;
- final Progress progress;
- @override
- final DiagnosticReporter reporter;
- final CompilerOutput _compilerOutput;
-
- @override
- final JsClosedWorld closedWorld;
- @override
- final InferredDataBuilder inferredDataBuilder;
-
- @override
- final TypeSystem types;
- @override
- final Map<ir.TreeNode, TypeInformation> concreteTypes =
- new Map<ir.TreeNode, TypeInformation>();
-
- final Set<ConstructorEntity> generativeConstructorsExposingThis =
- new Set<ConstructorEntity>();
-
- /// Data computed internally within elements, like the type-mask of a send a
- /// list allocation, or a for-in loop.
- final Map<MemberEntity, GlobalTypeInferenceElementData> _memberData =
- new Map<MemberEntity, GlobalTypeInferenceElementData>();
-
- final NoSuchMethodRegistry noSuchMethodRegistry;
-
- InferrerEngineImpl(
- this.options,
- this.progress,
- this.reporter,
+ InferrerEngine(
+ this._options,
+ this._progress,
+ this._reporter,
this._compilerOutput,
this.closedWorld,
- this.noSuchMethodRegistry,
this.mainElement,
this.inferredDataBuilder)
: this.types = new TypeSystem(
closedWorld, new KernelTypeSystemStrategy(closedWorld));
- ElementEnvironment get _elementEnvironment => closedWorld.elementEnvironment;
-
- @override
+ /// Applies [f] to all elements in the universe that match [selector] and
+ /// [mask]. If [f] returns false, aborts the iteration.
void forEachElementMatching(
Selector selector, AbstractValue mask, bool f(MemberEntity element)) {
Iterable<MemberEntity> elements = closedWorld.locateMembers(selector, mask);
@@ -329,13 +127,12 @@
}
// TODO(johnniwinther): Make this private again.
- @override
GlobalTypeInferenceElementData dataOfMember(MemberEntity element) =>
_memberData[element] ??= new KernelGlobalTypeInferenceElementData();
/// Update [sideEffects] with the side effects of [callee] being
/// called with [selector].
- void updateSideEffects(SideEffectsBuilder sideEffectsBuilder,
+ void _updateSideEffects(SideEffectsBuilder sideEffectsBuilder,
Selector selector, MemberEntity callee) {
if (callee.isField) {
if (callee.isInstanceMember) {
@@ -363,7 +160,8 @@
}
}
- @override
+ /// Returns the type for [nativeBehavior]. See documentation on
+ /// [NativeBehavior].
TypeInformation typeOfNativeBehavior(NativeBehavior nativeBehavior) {
if (nativeBehavior == null) return types.dynamicType;
List typesReturned = nativeBehavior.typesReturned;
@@ -404,7 +202,6 @@
return returnType;
}
- @override
void updateSelectorInMember(MemberEntity owner, CallType callType,
ir.Node node, Selector selector, AbstractValue mask) {
KernelGlobalTypeInferenceElementData data = dataOfMember(owner);
@@ -429,31 +226,26 @@
}
}
- @override
bool checkIfExposesThis(ConstructorEntity element) {
- return generativeConstructorsExposingThis.contains(element);
+ return _generativeConstructorsExposingThis.contains(element);
}
- @override
void recordExposesThis(ConstructorEntity element, bool exposesThis) {
if (exposesThis) {
- generativeConstructorsExposingThis.add(element);
+ _generativeConstructorsExposingThis.add(element);
}
}
- @override
bool returnsListElementType(Selector selector, AbstractValue mask) {
return mask != null &&
abstractValueDomain.isContainer(mask) &&
returnsListElementTypeSet.contains(selector);
}
- @override
bool returnsMapValueType(Selector selector, AbstractValue mask) {
return mask != null && abstractValueDomain.isMap(mask) && selector.isIndex;
}
- @override
void analyzeListAndEnqueue(ListTypeInformation info) {
if (info.analyzed) return;
info.analyzed = true;
@@ -468,13 +260,12 @@
info.originalType, abstractValueDomain.fixedListType)) {
info.checksGrowable = tracer.callsGrowableMethod;
}
- tracer.assignments.forEach(info.elementType.addAssignment);
+ tracer.inputs.forEach(info.elementType.addInput);
// Enqueue the list for later refinement
- workQueue.add(info);
- workQueue.add(info.elementType);
+ _workQueue.add(info);
+ _workQueue.add(info.elementType);
}
- @override
void analyzeSetAndEnqueue(SetTypeInformation info) {
if (info.analyzed) return;
info.analyzed = true;
@@ -486,13 +277,12 @@
info.bailedOut = false;
info.elementType.inferred = true;
- tracer.assignments.forEach(info.elementType.addAssignment);
+ tracer.inputs.forEach(info.elementType.addInput);
// Enqueue the set for later refinement.
- workQueue.add(info);
- workQueue.add(info.elementType);
+ _workQueue.add(info);
+ _workQueue.add(info.elementType);
}
- @override
void analyzeMapAndEnqueue(MapTypeInformation info) {
if (info.analyzed) return;
info.analyzed = true;
@@ -502,31 +292,30 @@
if (!succeeded) return;
info.bailedOut = false;
- for (int i = 0; i < tracer.keyAssignments.length; ++i) {
- TypeInformation newType = info.addEntryAssignment(abstractValueDomain,
- tracer.keyAssignments[i], tracer.valueAssignments[i]);
- if (newType != null) workQueue.add(newType);
+ for (int i = 0; i < tracer.keyInputs.length; ++i) {
+ TypeInformation newType = info.addEntryInput(
+ abstractValueDomain, tracer.keyInputs[i], tracer.valueInputs[i]);
+ if (newType != null) _workQueue.add(newType);
}
- for (TypeInformation map in tracer.mapAssignments) {
- workQueue.addAll(info.addMapAssignment(abstractValueDomain, map));
+ for (TypeInformation map in tracer.mapInputs) {
+ _workQueue.addAll(info.addMapInput(abstractValueDomain, map));
}
info.markAsInferred();
- workQueue.add(info.keyType);
- workQueue.add(info.valueType);
- workQueue.addAll(info.typeInfoMap.values);
- workQueue.add(info);
+ _workQueue.add(info.keyType);
+ _workQueue.add(info.valueType);
+ _workQueue.addAll(info.typeInfoMap.values);
+ _workQueue.add(info);
}
- @override
void runOverAllElements() {
- analyzeAllElements();
+ _analyzeAllElements();
TypeGraphDump dump =
debug.PRINT_GRAPH ? new TypeGraphDump(_compilerOutput, this) : null;
dump?.beforeAnalysis();
- buildWorkQueue();
- refine();
+ _buildWorkQueue();
+ _refine();
// Try to infer element types of lists and compute their escape information.
types.allocatedLists.values.forEach((TypeInformation info) {
@@ -560,7 +349,7 @@
types.strategy.forEachParameter(element, (Local parameter) {
types
.getInferredTypeOfParameter(parameter)
- .giveUp(this, clearAssignments: false);
+ .giveUp(this, clearInputs: false);
});
});
bailedOutOn.addAll(elements);
@@ -573,7 +362,7 @@
ParameterTypeInformation info =
types.getInferredTypeOfParameter(parameter);
info.maybeResume();
- workQueue.add(info);
+ _workQueue.add(info);
});
if (tracer.tracedType.mightBePassedToFunctionApply) {
inferredDataBuilder.registerMightBePassedToApply(element);
@@ -598,7 +387,7 @@
assert(calledElement is ConstructorEntity &&
calledElement.isGenerativeConstructor);
ClassEntity cls = calledElement.enclosingClass;
- FunctionEntity callMethod = lookupCallMethod(cls);
+ FunctionEntity callMethod = _lookupCallMethod(cls);
assert(callMethod != null, failedAt(cls));
Iterable<FunctionEntity> elements = [callMethod];
trace(elements, new ClosureTracerVisitor(elements, info, this));
@@ -625,17 +414,17 @@
// as nodes that use elements fetched from these lists/maps. The
// workset for a new run of the analysis will be these nodes.
Set<TypeInformation> seenTypes = new Set<TypeInformation>();
- while (!workQueue.isEmpty) {
- TypeInformation info = workQueue.remove();
+ while (!_workQueue.isEmpty) {
+ TypeInformation info = _workQueue.remove();
if (seenTypes.contains(info)) continue;
// If the node cannot be reset, we do not need to update its users either.
if (!info.reset(this)) continue;
seenTypes.add(info);
- workQueue.addAll(info.users);
+ _workQueue.addAll(info.users);
}
- workQueue.addAll(seenTypes);
- refine();
+ _workQueue.addAll(seenTypes);
+ _refine();
if (debug.PRINT_SUMMARY) {
types.allocatedLists.values.forEach((_info) {
@@ -681,42 +470,42 @@
}
} else if (info is StaticCallSiteTypeInformation) {
ClassEntity cls = info.calledElement.enclosingClass;
- FunctionEntity callMethod = lookupCallMethod(cls);
+ FunctionEntity callMethod = _lookupCallMethod(cls);
print('${types.getInferredSignatureOfMethod(callMethod)} for ${cls}');
} else {
print('${info.type} for some unknown kind of closure');
}
});
- analyzedElements.forEach((MemberEntity elem) {
+ _analyzedElements.forEach((MemberEntity elem) {
TypeInformation type = types.getInferredTypeOfMember(elem);
- print('${elem} :: ${type} from ${type.assignments} ');
+ print('${elem} :: ${type} from ${type.inputs} ');
});
}
dump?.afterAnalysis();
- reporter.log('Inferred $overallRefineCount types.');
+ _reporter.log('Inferred $_overallRefineCount types.');
- processLoopInformation();
+ _processLoopInformation();
}
/// Call [analyze] for all live members.
- void analyzeAllElements() {
+ void _analyzeAllElements() {
Iterable<MemberEntity> processedMembers = closedWorld.processedMembers
.where((MemberEntity member) => !member.isAbstract);
- progress.startPhase();
+ _progress.startPhase();
processedMembers.forEach((MemberEntity member) {
- progress.showProgress(
- 'Added ', addedInGraph, ' elements in inferencing graph.');
+ _progress.showProgress(
+ 'Added ', _addedInGraph, ' elements in inferencing graph.');
// This also forces the creation of the [ElementTypeInformation] to ensure
// it is in the graph.
types.withMember(member, () => analyze(member));
});
- reporter.log('Added $addedInGraph elements in inferencing graph.');
+ _reporter.log('Added $_addedInGraph elements in inferencing graph.');
}
/// Returns the body node for [member].
- ir.Node computeMemberBody(MemberEntity member) {
+ ir.Node _computeMemberBody(MemberEntity member) {
MemberDefinition definition =
closedWorld.elementMap.getMemberDefinition(member);
switch (definition.kind) {
@@ -752,7 +541,7 @@
/// Returns the `call` method on [cls] or the `noSuchMethod` if [cls] doesn't
/// implement `call`.
- FunctionEntity lookupCallMethod(ClassEntity cls) {
+ FunctionEntity _lookupCallMethod(ClassEntity cls) {
FunctionEntity function =
_elementEnvironment.lookupClassMember(cls, Identifiers.call);
if (function == null || function.isAbstract) {
@@ -762,18 +551,17 @@
return function;
}
- @override
void analyze(MemberEntity element) {
- if (analyzedElements.contains(element)) return;
- analyzedElements.add(element);
+ if (_analyzedElements.contains(element)) return;
+ _analyzedElements.add(element);
- ir.Node body = computeMemberBody(element);
+ ir.Node body = _computeMemberBody(element);
TypeInformation type;
- reporter.withCurrentElement(element, () {
- type = computeMemberTypeInformation(element, body);
+ _reporter.withCurrentElement(element, () {
+ type = _computeMemberTypeInformation(element, body);
});
- addedInGraph++;
+ _addedInGraph++;
if (element.isField) {
FieldEntity field = element;
@@ -784,7 +572,7 @@
if (type is! ListTypeInformation && type is! MapTypeInformation) {
// For non-container types, the constant handler does
// constant folding that could give more precise results.
- ConstantValue value = getFieldConstant(field);
+ ConstantValue value = _getFieldConstant(field);
if (value != null) {
if (value.isFunction) {
FunctionConstantValue functionConstant = value;
@@ -818,7 +606,7 @@
if ((element.isStatic || element.isTopLevel) &&
body != null &&
!element.isConst) {
- if (isFieldInitializerPotentiallyNull(element, body)) {
+ if (_isFieldInitializerPotentiallyNull(element, body)) {
recordTypeOfField(field, types.nullType);
}
}
@@ -829,10 +617,10 @@
}
/// Visits [body] to compute the [TypeInformation] node for [member].
- TypeInformation computeMemberTypeInformation(
+ TypeInformation _computeMemberTypeInformation(
MemberEntity member, ir.Node body) {
KernelTypeGraphBuilder visitor = new KernelTypeGraphBuilder(
- options,
+ _options,
closedWorld,
this,
member,
@@ -844,7 +632,7 @@
/// Returns `true` if the [initializer] of the non-const static or top-level
/// [field] is potentially `null`.
- bool isFieldInitializerPotentiallyNull(
+ bool _isFieldInitializerPotentiallyNull(
FieldEntity field, ir.Node initializer) {
// TODO(13429): We could do better here by using the
// constant handler to figure out if it's a lazy field or not.
@@ -866,18 +654,18 @@
/// Returns the [ConstantValue] for the initial value of [field], or
/// `null` if the initializer is not a constant value.
- ConstantValue getFieldConstant(FieldEntity field) {
+ ConstantValue _getFieldConstant(FieldEntity field) {
return closedWorld.fieldAnalysis.getFieldData(field).initialValue;
}
/// Returns `true` if [cls] has a 'call' method.
- bool hasCallType(ClassEntity cls) {
+ bool _hasCallType(ClassEntity cls) {
return closedWorld.elementMap.types
.getCallType(closedWorld.elementEnvironment.getThisType(cls)) !=
null;
}
- void processLoopInformation() {
+ void _processLoopInformation() {
types.allocatedCalls.forEach((CallSiteTypeInformation info) {
if (!info.inLoop) return;
// We can't compute the callees of closures, no new information to add.
@@ -900,20 +688,20 @@
});
}
- void refine() {
- progress.startPhase();
- while (!workQueue.isEmpty) {
- progress.showProgress('Inferred ', overallRefineCount, ' types.');
- TypeInformation info = workQueue.remove();
+ void _refine() {
+ _progress.startPhase();
+ while (!_workQueue.isEmpty) {
+ _progress.showProgress('Inferred ', _overallRefineCount, ' types.');
+ TypeInformation info = _workQueue.remove();
AbstractValue oldType = info.type;
AbstractValue newType = info.refine(this);
// Check that refinement has not accidentally changed the type.
assert(oldType == info.type);
if (info.abandonInferencing) info.doNotEnqueue = true;
if ((info.type = newType) != oldType) {
- overallRefineCount++;
+ _overallRefineCount++;
info.refineCount++;
- if (info.refineCount > MAX_CHANGE_COUNT) {
+ if (info.refineCount > _MAX_CHANGE_COUNT) {
if (debug.ANOMALY_WARN) {
print("ANOMALY WARNING: max refinement reached for $info");
}
@@ -921,7 +709,7 @@
info.type = info.refine(this);
info.doNotEnqueue = true;
}
- workQueue.addAll(info.users);
+ _workQueue.addAll(info.users);
if (info.hasStableType(this)) {
info.stabilize(this);
}
@@ -929,15 +717,17 @@
}
}
- void buildWorkQueue() {
- workQueue.addAll(types.orderedTypeInformations);
- workQueue.addAll(types.allocatedTypes);
- workQueue.addAll(types.allocatedClosures);
- workQueue.addAll(types.allocatedCalls);
+ void _buildWorkQueue() {
+ _workQueue.addAll(types.orderedTypeInformations);
+ _workQueue.addAll(types.allocatedTypes);
+ _workQueue.addAll(types.allocatedClosures);
+ _workQueue.addAll(types.allocatedCalls);
}
- @override
- void updateParameterAssignments(TypeInformation caller, MemberEntity callee,
+ /// Update the inputs to parameters in the graph. [remove] tells whether
+ /// inputs must be added or removed. If [init] is false, parameters are
+ /// added to the work queue.
+ void updateParameterInputs(TypeInformation caller, MemberEntity callee,
ArgumentsTypes arguments, Selector selector, AbstractValue mask,
{bool remove, bool addToQueue: true}) {
if (callee.name == Identifiers.noSuchMethod_) return;
@@ -945,11 +735,11 @@
if (selector.isSetter) {
ElementTypeInformation info = types.getInferredTypeOfMember(callee);
if (remove) {
- info.removeAssignment(arguments.positional[0]);
+ info.removeInput(arguments.positional[0]);
} else {
- info.addAssignment(arguments.positional[0]);
+ info.addInput(arguments.positional[0]);
}
- if (addToQueue) workQueue.add(info);
+ if (addToQueue) _workQueue.add(info);
}
} else if (callee.isGetter) {
return;
@@ -972,7 +762,7 @@
ParameterTypeInformation info =
types.getInferredTypeOfParameter(parameter);
info.tagAsTearOffClosureParameter(this);
- if (addToQueue) workQueue.add(info);
+ if (addToQueue) _workQueue.add(info);
});
}
} else {
@@ -991,34 +781,37 @@
if (type == null) type = getDefaultTypeOfParameter(parameter);
TypeInformation info = types.getInferredTypeOfParameter(parameter);
if (remove) {
- info.removeAssignment(type);
+ info.removeInput(type);
} else {
- info.addAssignment(type);
+ info.addInput(type);
}
parameterIndex++;
- if (addToQueue) workQueue.add(info);
+ if (addToQueue) _workQueue.add(info);
});
}
}
- @override
+ /// Sets the type of a parameter's default value to [type]. If the global
+ /// mapping in `_defaultTypeOfParameter` already contains a type, it must be
+ /// a [PlaceholderTypeInformation], which will be replaced. All its uses are
+ /// updated.
void setDefaultTypeOfParameter(Local parameter, TypeInformation type,
{bool isInstanceMember}) {
assert(
type != null, failedAt(parameter, "No default type for $parameter."));
- TypeInformation existing = defaultTypeOfParameter[parameter];
- defaultTypeOfParameter[parameter] = type;
+ TypeInformation existing = _defaultTypeOfParameter[parameter];
+ _defaultTypeOfParameter[parameter] = type;
TypeInformation info = types.getInferredTypeOfParameter(parameter);
if (existing != null && existing is PlaceholderTypeInformation) {
// Replace references to [existing] to use [type] instead.
if (isInstanceMember) {
- ParameterAssignments assignments = info.assignments;
- assignments.replace(existing, type);
+ ParameterInputs inputs = info.inputs;
+ inputs.replace(existing, type);
} else {
- List<TypeInformation> assignments = info.assignments;
- for (int i = 0; i < assignments.length; i++) {
- if (assignments[i] == existing) {
- assignments[i] = type;
+ List<TypeInformation> inputs = info.inputs;
+ for (int i = 0; i < inputs.length; i++) {
+ if (inputs[i] == existing) {
+ inputs[i] = type;
}
}
}
@@ -1029,56 +822,59 @@
}
}
- @override
+ /// Returns the [TypeInformation] node for the default value of a parameter.
+ /// If this is queried before it is set by [setDefaultTypeOfParameter], a
+ /// [PlaceholderTypeInformation] is returned, which will later be replaced
+ /// by the actual node when [setDefaultTypeOfParameter] is called.
+ ///
+ /// Invariant: After graph construction, no [PlaceholderTypeInformation] nodes
+ /// should be present and a default type for each parameter should exist.
TypeInformation getDefaultTypeOfParameter(Local parameter) {
- return defaultTypeOfParameter.putIfAbsent(parameter, () {
+ return _defaultTypeOfParameter.putIfAbsent(parameter, () {
return new PlaceholderTypeInformation(
abstractValueDomain, types.currentMember);
});
}
- @override
- bool hasAlreadyComputedTypeOfParameterDefault(Local parameter) {
- TypeInformation seen = defaultTypeOfParameter[parameter];
- return (seen != null && seen is! PlaceholderTypeInformation);
- }
-
- @override
+ /// Returns the type of [element].
TypeInformation typeOfParameter(Local element) {
return types.getInferredTypeOfParameter(element);
}
- @override
+ /// Returns the type of [element].
TypeInformation typeOfMember(MemberEntity element) {
if (element is FunctionEntity) return types.functionType;
return types.getInferredTypeOfMember(element);
}
- @override
+ /// Returns the return type of [element].
TypeInformation returnTypeOfMember(MemberEntity element) {
if (element is! FunctionEntity) return types.dynamicType;
return types.getInferredTypeOfMember(element);
}
- @override
+ /// Records that [element] is of type [type].
void recordTypeOfField(FieldEntity element, TypeInformation type) {
- types.getInferredTypeOfMember(element).addAssignment(type);
+ types.getInferredTypeOfMember(element).addInput(type);
}
- @override
+ /// Records that the return type [element] is of type [type].
void recordReturnType(FunctionEntity element, TypeInformation type) {
TypeInformation info = types.getInferredTypeOfMember(element);
if (element.name == '==') {
// Even if x.== doesn't return a bool, 'x == null' evaluates to 'false'.
- info.addAssignment(types.boolType);
+ info.addInput(types.boolType);
}
// TODO(ngeoffray): Clean up. We do these checks because
// [SimpleTypesInferrer] deals with two different inferrers.
if (type == null) return;
- if (info.assignments.isEmpty) info.addAssignment(type);
+ if (info.inputs.isEmpty) info.addInput(type);
}
- @override
+ /// Notifies to the inferrer that [analyzedElement] can have return type
+ /// [newType]. [currentType] is the type the inference has currently found.
+ ///
+ /// Returns the new type for [analyzedElement].
TypeInformation addReturnTypeForMethod(
FunctionEntity element, TypeInformation unused, TypeInformation newType) {
TypeInformation type = types.getInferredTypeOfMember(element);
@@ -1087,11 +883,18 @@
if (element is ConstructorEntity && element.isGenerativeConstructor) {
return type;
}
- type.addAssignment(newType);
+ type.addInput(newType);
return type;
}
- @override
+ /// Registers that [caller] calls [callee] at location [node], with
+ /// [selector], and [arguments]. Note that [selector] is null for forwarding
+ /// constructors.
+ ///
+ /// [sideEffectsBuilder] will be updated to incorporate [callee]'s side
+ /// effects.
+ ///
+ /// [inLoop] tells whether the call happens in a loop.
TypeInformation registerCalledMember(
Object node,
Selector selector,
@@ -1121,17 +924,23 @@
callee is ConstructorEntity &&
callee.isGenerativeConstructor) {
ClassEntity cls = callee.enclosingClass;
- if (hasCallType(cls)) {
+ if (_hasCallType(cls)) {
types.allocatedClosures.add(info);
}
}
info.addToGraph(this);
types.allocatedCalls.add(info);
- updateSideEffects(sideEffectsBuilder, selector, callee);
+ _updateSideEffects(sideEffectsBuilder, selector, callee);
return info;
}
- @override
+ /// Registers that [caller] calls [selector] with [receiverType] as receiver,
+ /// and [arguments].
+ ///
+ /// [sideEffectsBuilder] will be updated to incorporate the potential callees'
+ /// side effects.
+ ///
+ /// [inLoop] tells whether the call happens in a loop.
TypeInformation registerCalledSelector(
CallType callType,
ir.Node node,
@@ -1153,7 +962,7 @@
sideEffectsBuilder.setAllSideEffectsAndDependsOnSomething();
}
closedWorld.locateMembers(selector, mask).forEach((callee) {
- updateSideEffects(sideEffectsBuilder, selector, callee);
+ _updateSideEffects(sideEffectsBuilder, selector, callee);
});
CallSiteTypeInformation info;
@@ -1168,7 +977,7 @@
abstractValueDomain,
types.currentMember,
node,
- typeOfSharedDynamicCall(selector, CallStructure.ONE_ARG),
+ _typeOfSharedDynamicCall(selector, CallStructure.ONE_ARG),
caller,
selector,
mask,
@@ -1195,25 +1004,32 @@
return info;
}
- @override
+ /// Registers a call to await with an expression of type [argumentType] as
+ /// argument.
TypeInformation registerAwait(ir.Node node, TypeInformation argument) {
AwaitTypeInformation info = new AwaitTypeInformation(
abstractValueDomain, types.currentMember, node);
- info.addAssignment(argument);
+ info.addInput(argument);
types.allocatedTypes.add(info);
return info;
}
- @override
+ /// Registers a call to yield with an expression of type [argumentType] as
+ /// argument.
TypeInformation registerYield(ir.Node node, TypeInformation argument) {
YieldTypeInformation info = new YieldTypeInformation(
abstractValueDomain, types.currentMember, node);
- info.addAssignment(argument);
+ info.addInput(argument);
types.allocatedTypes.add(info);
return info;
}
- @override
+ /// Registers that [caller] calls [closure] with [arguments].
+ ///
+ /// [sideEffectsBuilder] will be updated to incorporate the potential callees'
+ /// side effects.
+ ///
+ /// [inLoop] tells whether the call happens in a loop.
TypeInformation registerCalledClosure(
ir.Node node,
Selector selector,
@@ -1239,7 +1055,6 @@
return info;
}
- @override
void close() {
for (MemberTypeInformation typeInformation
in types.memberTypeInformations.values) {
@@ -1247,7 +1062,6 @@
}
}
- @override
void clear() {
if (retainDataForTesting) return;
@@ -1258,7 +1072,7 @@
types.allocatedCalls.forEach(cleanup);
types.allocatedCalls.clear();
- defaultTypeOfParameter.clear();
+ _defaultTypeOfParameter.clear();
types.parameterTypeInformations.values.forEach(cleanup);
types.memberTypeInformations.values.forEach(cleanup);
@@ -1271,8 +1085,8 @@
types.allocatedClosures.forEach(cleanup);
types.allocatedClosures.clear();
- analyzedElements.clear();
- generativeConstructorsExposingThis.clear();
+ _analyzedElements.clear();
+ _generativeConstructorsExposingThis.clear();
types.allocatedMaps.values.forEach(cleanup);
types.allocatedSets.values.forEach(cleanup);
@@ -1281,13 +1095,12 @@
_memberData.clear();
}
- @override
Iterable<MemberEntity> getCallersOfForTesting(MemberEntity element) {
MemberTypeInformation info = types.getInferredTypeOfMember(element);
return info.callersForTesting;
}
- @override
+ /// Returns the type of [element] when being called with [selector].
TypeInformation typeOfMemberWithSelector(
MemberEntity element, Selector selector) {
if (element.name == Identifiers.noSuchMethod_ &&
@@ -1321,8 +1134,15 @@
/// cache holds that shared dynamic call node for a given selector.
Map<Selector, DynamicCallSiteTypeInformation> _sharedCalls = {};
- @override
- DynamicCallSiteTypeInformation typeOfSharedDynamicCall(
+ /// For a given selector, return a shared dynamic call site that will be used
+ /// to combine the results of multiple dynamic calls in the program via
+ /// [IndirectDynamicCallSiteTypeInformation].
+ ///
+ /// This is used only for scalability reasons: if there are too many targets
+ /// and call sites, we may have a quadratic number of edges in the graph, so
+ /// we add a level of indirection to merge the information and keep the graph
+ /// smaller.
+ DynamicCallSiteTypeInformation _typeOfSharedDynamicCall(
Selector selector, CallStructure structure) {
DynamicCallSiteTypeInformation info = _sharedCalls[selector];
if (info != null) return info;
@@ -1359,7 +1179,11 @@
return info;
}
- @override
+ /// Returns true if global optimizations such as type inferencing can apply to
+ /// the field [element].
+ ///
+ /// One category of elements that do not apply is runtime helpers that the
+ /// backend calls, but the optimizations don't see those calls.
bool canFieldBeUsedForGlobalOptimizations(FieldEntity element) {
if (closedWorld.backendUsage.isFieldUsedByBackend(element)) {
return false;
@@ -1370,13 +1194,17 @@
return true;
}
- @override
+ /// Returns true if global optimizations such as type inferencing can apply to
+ /// the parameter [element].
+ ///
+ /// One category of elements that do not apply is runtime helpers that the
+ /// backend calls, but the optimizations don't see those calls.
bool canFunctionParametersBeUsedForGlobalOptimizations(
FunctionEntity function) {
return !closedWorld.backendUsage.isFunctionUsedByBackend(function);
}
- @override
+ /// Returns `true` if inference of parameter types is disabled for [member].
bool assumeDynamic(MemberEntity member) {
return closedWorld.annotationsData.hasAssumeDynamic(member);
}
@@ -1451,7 +1279,7 @@
parameter,
type,
member,
- new ParameterAssignments());
+ new ParameterInputs());
} else {
return new ParameterTypeInformation.static(
abstractValueDomain, memberTypeInformation, parameter, type, member);
diff --git a/pkg/compiler/lib/src/inferrer/list_tracer.dart b/pkg/compiler/lib/src/inferrer/list_tracer.dart
index aaa69e4..db86752 100644
--- a/pkg/compiler/lib/src/inferrer/list_tracer.dart
+++ b/pkg/compiler/lib/src/inferrer/list_tracer.dart
@@ -130,13 +130,13 @@
class ListTracerVisitor extends TracerVisitor {
// The [Set] of found assignments to the list.
- Set<TypeInformation> assignments = new Setlet<TypeInformation>();
+ Set<TypeInformation> inputs = new Setlet<TypeInformation>();
bool callsGrowableMethod = false;
ListTracerVisitor(tracedType, inferrer) : super(tracedType, inferrer);
/// Returns [true] if the analysis completed successfully, [false] if it
- /// bailed out. In the former case, [assignments] holds a list of
+ /// bailed out. In the former case, [inputs] holds a list of
/// [TypeInformation] nodes that flow into the element type of this list.
bool run() {
analyze();
@@ -149,7 +149,7 @@
return true;
} else {
callsGrowableMethod = true;
- assignments = null;
+ inputs = null;
return false;
}
}
@@ -180,18 +180,18 @@
int positionalLength = info.arguments.positional.length;
if (selectorName == 'add') {
if (positionalLength == 1) {
- assignments.add(info.arguments.positional[0]);
+ inputs.add(info.arguments.positional[0]);
}
} else if (selectorName == 'insert') {
if (positionalLength == 2) {
- assignments.add(info.arguments.positional[1]);
+ inputs.add(info.arguments.positional[1]);
}
} else {
bailout('Used in a not-ok selector');
return;
}
} else if (selector.isIndexSet) {
- assignments.add(info.arguments.positional[1]);
+ inputs.add(info.arguments.positional[1]);
} else if (!selector.isIndex) {
bailout('Used in a not-ok selector');
return;
@@ -202,7 +202,7 @@
}
if (selectorName == 'length' && selector.isSetter) {
callsGrowableMethod = true;
- assignments.add(inferrer.types.nullType);
+ inputs.add(inferrer.types.nullType);
}
} else if (selector.isCall &&
(info.hasClosureCallTargets ||
diff --git a/pkg/compiler/lib/src/inferrer/map_tracer.dart b/pkg/compiler/lib/src/inferrer/map_tracer.dart
index f21fd15..3f29c0c 100644
--- a/pkg/compiler/lib/src/inferrer/map_tracer.dart
+++ b/pkg/compiler/lib/src/inferrer/map_tracer.dart
@@ -35,17 +35,17 @@
// These lists are used to keep track of newly discovered assignments to
// the map. Note that elements at corresponding indices are expected to
// belong to the same assignment operation.
- List<TypeInformation> keyAssignments = <TypeInformation>[];
- List<TypeInformation> valueAssignments = <TypeInformation>[];
+ List<TypeInformation> keyInputs = <TypeInformation>[];
+ List<TypeInformation> valueInputs = <TypeInformation>[];
// This list is used to keep track of assignments of entire maps to
// this map.
- List<MapTypeInformation> mapAssignments = <MapTypeInformation>[];
+ List<MapTypeInformation> mapInputs = <MapTypeInformation>[];
MapTracerVisitor(tracedType, inferrer) : super(tracedType, inferrer);
/// Returns [true] if the analysis completed successfully, [false]
- /// if it bailed out. In the former case, [keyAssignments] and
- /// [valueAssignments] hold a list of [TypeInformation] nodes that
+ /// if it bailed out. In the former case, [keyInputs] and
+ /// [valueInputs] hold a list of [TypeInformation] nodes that
/// flow into the key and value types of this map.
bool run() {
analyze();
@@ -54,7 +54,7 @@
map.addFlowsIntoTargets(flowsInto);
return true;
}
- keyAssignments = valueAssignments = mapAssignments = null;
+ keyInputs = valueInputs = mapInputs = null;
return false;
}
@@ -87,7 +87,7 @@
TypeInformation map = info.arguments.positional[0];
if (map is MapTypeInformation) {
inferrer.analyzeMapAndEnqueue(map);
- mapAssignments.add(map);
+ mapInputs.add(map);
} else {
// If we could select a component from a [TypeInformation],
// like the keytype or valuetype in this case, we could
@@ -103,8 +103,8 @@
// to go to dynamic.
// TODO(herhut,16507): Use return type of closure in
// Map.putIfAbsent.
- keyAssignments.add(info.arguments.positional[0]);
- valueAssignments.add(inferrer.types.dynamicType);
+ keyInputs.add(info.arguments.positional[0]);
+ valueInputs.add(inferrer.types.dynamicType);
} else {
// It would be nice to handle [Map.keys] and [Map.values], too.
// However, currently those calls do not trigger the creation
@@ -115,8 +115,8 @@
return;
}
} else if (selector.isIndexSet) {
- keyAssignments.add(info.arguments.positional[0]);
- valueAssignments.add(info.arguments.positional[1]);
+ keyInputs.add(info.arguments.positional[0]);
+ valueInputs.add(info.arguments.positional[1]);
} else if (!selector.isIndex) {
bailout('Map used in a not-ok selector [$selectorName]');
return;
diff --git a/pkg/compiler/lib/src/inferrer/set_tracer.dart b/pkg/compiler/lib/src/inferrer/set_tracer.dart
index 72cf043..8a98719 100644
--- a/pkg/compiler/lib/src/inferrer/set_tracer.dart
+++ b/pkg/compiler/lib/src/inferrer/set_tracer.dart
@@ -65,12 +65,12 @@
]);
class SetTracerVisitor extends TracerVisitor {
- List<TypeInformation> assignments = <TypeInformation>[];
+ List<TypeInformation> inputs = <TypeInformation>[];
SetTracerVisitor(tracedType, inferrer) : super(tracedType, inferrer);
/// Returns [true] if the analysis completed successfully, [false] if it
- /// bailed out. In the former case, [assignments] holds a list of
+ /// bailed out. In the former case, [inputs] holds a list of
/// [TypeInformation] nodes that flow into the element type of this set.
bool run() {
analyze();
@@ -79,7 +79,7 @@
set.addFlowsIntoTargets(flowsInto);
return true;
}
- assignments = null;
+ inputs = null;
return false;
}
@@ -108,7 +108,7 @@
if (selector.isCall) {
switch (selectorName) {
case 'add':
- assignments.add(info.arguments.positional[0]);
+ inputs.add(info.arguments.positional[0]);
break;
case 'addAll':
// TODO(fishythefish): Extract type argument from type
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_dump.dart b/pkg/compiler/lib/src/inferrer/type_graph_dump.dart
index a4ed3e3..c215ca1 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_dump.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_dump.dart
@@ -44,7 +44,7 @@
/// during the analysis.
void beforeAnalysis() {
for (TypeInformation node in inferrer.types.allTypes) {
- Set<TypeInformation> copy = node.assignments.toSet();
+ Set<TypeInformation> copy = node.inputs.toSet();
if (!copy.isEmpty) {
assignmentsBeforeAnalysis[node] = copy;
}
@@ -54,7 +54,7 @@
/// Like [beforeAnalysis], takes a copy of the assignment sets.
void beforeTracing() {
for (TypeInformation node in inferrer.types.allTypes) {
- Set<TypeInformation> copy = node.assignments.toSet();
+ Set<TypeInformation> copy = node.inputs.toSet();
if (!copy.isEmpty) {
assignmentsBeforeTracing[node] = copy;
}
@@ -266,7 +266,7 @@
/// Creates a node for [node] displaying the given [text] in its box.
///
/// [inputs] specify named inputs to the node. If omitted, edges will be
- /// based on [node.assignments].
+ /// based on [node.inputs].
void addNode(TypeInformation node, String text,
{String color: defaultNodeColor, Map<String, TypeInformation> inputs}) {
seen.add(node);
@@ -290,7 +290,7 @@
// added, removed, temporary, or unchanged.
dynamic originalSet = global.assignmentsBeforeAnalysis[node] ?? const [];
var tracerSet = global.assignmentsBeforeTracing[node] ?? const [];
- var currentSet = node.assignments.toSet();
+ var currentSet = node.inputs.toSet();
for (TypeInformation assignment in currentSet) {
String color =
originalSet.contains(assignment) ? unchangedEdge : addedEdge;
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
index a1e7c15..2de18dc 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
@@ -70,13 +70,12 @@
}
InferrerEngine createInferrerEngineFor(FunctionEntity main) {
- return new InferrerEngineImpl(
+ return InferrerEngine(
_compiler.options,
_compiler.progress,
_compiler.reporter,
_compiler.outputProvider,
closedWorld,
- _compiler.frontendStrategy.noSuchMethodRegistry,
main,
_inferredDataBuilder);
}
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
index af0410d..0f136c9 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
@@ -31,13 +31,13 @@
/// - Containers (for lists)
/// - Type of the element in a container
///
-/// A node has a set of assignments and users. Assignments are used to
+/// A node has a set of inputs and users. Inputs are used to
/// compute the type of the node ([TypeInformation.computeType]). Users are
/// added to the inferrer's work queue when the type of the node
/// changes.
abstract class TypeInformation {
Set<TypeInformation> users;
- var /* List|ParameterAssignments */ _assignments;
+ var /* List|ParameterInputs */ _inputs;
/// The type the inferrer has found for this [TypeInformation].
/// Initially empty.
@@ -49,15 +49,14 @@
/// The element this [TypeInformation] node belongs to.
MemberEntity get contextMember => context == null ? null : context.member;
- Iterable<TypeInformation> get assignments => _assignments;
+ Iterable<TypeInformation> get inputs => _inputs;
/// We abandon inference in certain cases (complex cyclic flow, native
/// behaviours, etc.). In some case, we might resume inference in the
- /// closure tracer, which is handled by checking whether [assignments] has
- /// been set to [STOP_TRACKING_ASSIGNMENTS_MARKER].
+ /// closure tracer, which is handled by checking whether [inputs] has
+ /// been set to [STOP_TRACKING_INPUTS_MARKER].
bool abandonInferencing = false;
- bool get mightResume =>
- !identical(assignments, STOP_TRACKING_ASSIGNMENTS_MARKER);
+ bool get mightResume => !identical(inputs, STOP_TRACKING_INPUTS_MARKER);
/// Number of times this [TypeInformation] has changed type.
int refineCount = 0;
@@ -85,19 +84,19 @@
bool get isConcrete => false;
TypeInformation(this.type, this.context)
- : _assignments = <TypeInformation>[],
+ : _inputs = <TypeInformation>[],
users = new Setlet<TypeInformation>();
- TypeInformation.noAssignments(this.type, this.context)
- : _assignments = const <TypeInformation>[],
+ TypeInformation.noInputs(this.type, this.context)
+ : _inputs = const <TypeInformation>[],
users = new Setlet<TypeInformation>();
TypeInformation.untracked(this.type)
- : _assignments = const <TypeInformation>[],
+ : _inputs = const <TypeInformation>[],
users = const ImmutableEmptySet(),
context = null;
- TypeInformation.withAssignments(this.type, this.context, this._assignments)
+ TypeInformation.withInputs(this.type, this.context, this._inputs)
: users = new Setlet<TypeInformation>();
void addUser(TypeInformation user) {
@@ -116,31 +115,31 @@
// The below is not a compile time constant to make it differentiable
// from other empty lists of [TypeInformation].
- static final STOP_TRACKING_ASSIGNMENTS_MARKER = new List<TypeInformation>(0);
+ static final STOP_TRACKING_INPUTS_MARKER = new List<TypeInformation>(0);
- bool areAssignmentsTracked() {
- return assignments != STOP_TRACKING_ASSIGNMENTS_MARKER;
+ bool areInputsTracked() {
+ return inputs != STOP_TRACKING_INPUTS_MARKER;
}
- void addAssignment(TypeInformation assignment) {
+ void addInput(TypeInformation input) {
// Cheap one-level cycle detection.
- if (assignment == this) return;
- if (areAssignmentsTracked()) {
- _assignments.add(assignment);
+ if (input == this) return;
+ if (areInputsTracked()) {
+ _inputs.add(input);
}
// Even if we abandon inferencing on this [TypeInformation] we
// need to collect the users, so that phases that track where
// elements flow in still work.
- assignment.addUser(this);
+ input.addUser(this);
}
- void removeAssignment(TypeInformation assignment) {
+ void removeInput(TypeInformation input) {
if (!abandonInferencing || mightResume) {
- _assignments.remove(assignment);
+ _inputs.remove(input);
}
- // We can have multiple assignments of the same [TypeInformation].
- if (!assignments.contains(assignment)) {
- assignment.removeUser(this);
+ // We can have multiple inputs of the same [TypeInformation].
+ if (!inputs.contains(input)) {
+ input.removeUser(this);
}
}
@@ -158,18 +157,18 @@
return inferrer.types.dynamicType.type;
}
- void giveUp(InferrerEngine inferrer, {bool clearAssignments: true}) {
+ void giveUp(InferrerEngine inferrer, {bool clearInputs: true}) {
abandonInferencing = true;
- // Do not remove [this] as a user of nodes in [assignments],
+ // Do not remove [this] as a user of nodes in [inputs],
// because our tracing analysis could be interested in tracing
// this node.
- if (clearAssignments) _assignments = STOP_TRACKING_ASSIGNMENTS_MARKER;
+ if (clearInputs) _inputs = STOP_TRACKING_INPUTS_MARKER;
// Do not remove users because our tracing analysis could be
// interested in tracing the users of this node.
}
void clear() {
- _assignments = STOP_TRACKING_ASSIGNMENTS_MARKER;
+ _inputs = STOP_TRACKING_INPUTS_MARKER;
users = const ImmutableEmptySet();
}
@@ -192,11 +191,11 @@
/// Returns whether the type cannot change after it has been
/// inferred.
bool hasStableType(InferrerEngine inferrer) {
- return !mightResume && assignments.every((e) => e.isStable);
+ return !mightResume && inputs.every((e) => e.isStable);
}
void removeAndClearReferences(InferrerEngine inferrer) {
- assignments.forEach((info) {
+ inputs.forEach((info) {
info.removeUser(this);
});
}
@@ -205,7 +204,7 @@
removeAndClearReferences(inferrer);
// Do not remove users because the tracing analysis could be interested
// in tracing the users of this node.
- _assignments = STOP_TRACKING_ASSIGNMENTS_MARKER;
+ _inputs = STOP_TRACKING_INPUTS_MARKER;
abandonInferencing = true;
isStable = true;
}
@@ -219,7 +218,7 @@
/// Destroys information not needed after type inference.
void cleanup() {
users = null;
- _assignments = null;
+ _inputs = null;
}
String toStructuredText(String indent) {
@@ -264,52 +263,52 @@
}
/// Parameters of instance functions behave differently than other
-/// elements because the inferrer may remove assignments. This happens
+/// elements because the inferrer may remove inputs. This happens
/// when the receiver of a dynamic call site can be refined
/// to a type where we know more about which instance method is being
/// called.
-class ParameterAssignments extends IterableBase<TypeInformation> {
- final Map<TypeInformation, int> assignments = new Map<TypeInformation, int>();
+class ParameterInputs extends IterableBase<TypeInformation> {
+ final Map<TypeInformation, int> _inputs = new Map<TypeInformation, int>();
void remove(TypeInformation info) {
- int existing = assignments[info];
+ int existing = _inputs[info];
if (existing == null) return;
if (existing == 1) {
- assignments.remove(info);
+ _inputs.remove(info);
} else {
- assignments[info] = existing - 1;
+ _inputs[info] = existing - 1;
}
}
void add(TypeInformation info) {
- int existing = assignments[info];
+ int existing = _inputs[info];
if (existing == null) {
- assignments[info] = 1;
+ _inputs[info] = 1;
} else {
- assignments[info] = existing + 1;
+ _inputs[info] = existing + 1;
}
}
void replace(TypeInformation old, TypeInformation replacement) {
- int existing = assignments[old];
+ int existing = _inputs[old];
if (existing != null) {
- int other = assignments[replacement];
+ int other = _inputs[replacement];
if (other != null) existing += other;
- assignments[replacement] = existing;
- assignments.remove(old);
+ _inputs[replacement] = existing;
+ _inputs.remove(old);
}
}
@override
- Iterator<TypeInformation> get iterator => assignments.keys.iterator;
+ Iterator<TypeInformation> get iterator => _inputs.keys.iterator;
@override
- Iterable<TypeInformation> where(Function f) => assignments.keys.where(f);
+ Iterable<TypeInformation> where(Function f) => _inputs.keys.where(f);
@override
- bool contains(Object info) => assignments.containsKey(info);
+ bool contains(Object info) => _inputs.containsKey(info);
@override
- String toString() => assignments.keys.toList().toString();
+ String toString() => _inputs.keys.toList().toString();
}
/// A node representing a resolved element of the component. The kind of
@@ -344,12 +343,9 @@
ElementTypeInformation._internal(
AbstractValueDomain abstractValueDomain, MemberTypeInformation context)
: super(abstractValueDomain.emptyType, context);
- ElementTypeInformation._withAssignments(
- AbstractValueDomain abstractValueDomain,
- MemberTypeInformation context,
- ParameterAssignments assignments)
- : super.withAssignments(
- abstractValueDomain.emptyType, context, assignments);
+ ElementTypeInformation._withInputs(AbstractValueDomain abstractValueDomain,
+ MemberTypeInformation context, ParameterInputs inputs)
+ : super.withInputs(abstractValueDomain.emptyType, context, inputs);
String getInferredSignature(TypeSystem types);
@@ -485,7 +481,7 @@
AbstractValue special = handleSpecialCases(inferrer);
if (special != null) return potentiallyNarrowType(special, inferrer);
return potentiallyNarrowType(
- inferrer.types.computeTypeMask(assignments), inferrer);
+ inferrer.types.computeTypeMask(inputs), inferrer);
}
@override
@@ -552,7 +548,7 @@
@override
bool hasStableType(InferrerEngine inferrer) {
- // The number of assignments of non-final fields is
+ // The number of inputs of non-final fields is
// not stable. Therefore such a field cannot be stable.
if (!_field.isAssignable) {
return false;
@@ -728,11 +724,11 @@
this._parameter,
this._type,
this._method,
- ParameterAssignments assignments)
+ ParameterInputs inputs)
: _isInstanceMemberParameter = true,
_isClosureParameter = false,
_isInitializingFormal = false,
- super._withAssignments(abstractValueDomain, context, assignments);
+ super._withInputs(abstractValueDomain, context, inputs);
FunctionEntity get method => _method;
@@ -770,9 +766,9 @@
if ((_isTearOffClosureParameter || _isClosureParameter) &&
disableInferenceForClosures) {
// Do not infer types for parameters of closures. We do not
- // clear the assignments in case the closure is successfully
+ // clear the inputs in case the closure is successfully
// traced.
- giveUp(inferrer, clearAssignments: false);
+ giveUp(inferrer, clearInputs: false);
return safeType(inferrer);
}
if (_isInstanceMemberParameter &&
@@ -845,7 +841,7 @@
AbstractValue special = handleSpecialCases(inferrer);
if (special != null) return special;
return potentiallyNarrowType(
- inferrer.types.computeTypeMask(assignments), inferrer);
+ inferrer.types.computeTypeMask(inputs), inferrer);
}
@override
@@ -855,7 +851,7 @@
@override
bool hasStableType(InferrerEngine inferrer) {
- // The number of assignments of parameters of instance methods is
+ // The number of inputs of parameters of instance methods is
// not stable. Therefore such a parameter cannot be stable.
if (_isInstanceMemberParameter) {
return false;
@@ -888,7 +884,7 @@
@override
AbstractValue computeType(InferrerEngine inferrer) =>
- inferrer.types.computeTypeMask(assignments);
+ inferrer.types.computeTypeMask(inputs);
@override
accept(TypeInformationVisitor visitor) {
@@ -943,7 +939,7 @@
this.mask,
this.arguments,
this.inLoop)
- : super.noAssignments(abstractValueDomain.emptyType, context) {
+ : super.noInputs(abstractValueDomain.emptyType, context) {
assert(_call is ir.Node || (_call == null && selector.name == '=='));
}
@@ -987,7 +983,7 @@
if (arguments != null) {
arguments.forEach((info) => info.addUser(this));
}
- inferrer.updateParameterAssignments(
+ inferrer.updateParameterInputs(
this, calledElement, arguments, selector, mask,
remove: false, addToQueue: false);
}
@@ -1075,14 +1071,14 @@
@override
void addToGraph(InferrerEngine inferrer) {
receiver.addUser(this);
- dynamicCall.receiver.addAssignment(receiver);
+ dynamicCall.receiver.addInput(receiver);
List<TypeInformation> positional = arguments.positional;
for (int i = 0; i < positional.length; i++) {
positional[i].addUser(this);
- dynamicCall.arguments.positional[i].addAssignment(positional[i]);
+ dynamicCall.arguments.positional[i].addInput(positional[i]);
}
arguments.named.forEach((name, namedInfo) {
- dynamicCall.arguments.named[name].addAssignment(namedInfo);
+ dynamicCall.arguments.named[name].addInput(namedInfo);
});
dynamicCall.addUser(this);
}
@@ -1113,12 +1109,12 @@
}
@override
- void giveUp(InferrerEngine inferrer, {bool clearAssignments: true}) {
+ void giveUp(InferrerEngine inferrer, {bool clearInputs: true}) {
if (!abandonInferencing) {
inferrer.updateSelectorInMember(
caller, CallType.access, _call, selector, mask);
}
- super.giveUp(inferrer, clearAssignments: clearAssignments);
+ super.giveUp(inferrer, clearInputs: clearInputs);
}
@override
@@ -1200,7 +1196,7 @@
inferrer.types.getInferredTypeOfMember(element);
_addCall(callee);
callee.addUser(this);
- inferrer.updateParameterAssignments(
+ inferrer.updateParameterInputs(
this, element, arguments, selector, typeMask,
remove: false, addToQueue: false);
}
@@ -1364,7 +1360,7 @@
inferrer.types.getInferredTypeOfMember(element);
_addCall(callee);
callee.addUser(this);
- inferrer.updateParameterAssignments(
+ inferrer.updateParameterInputs(
this, element, arguments, selector, typeMask,
remove: false, addToQueue: true);
});
@@ -1377,7 +1373,7 @@
inferrer.types.getInferredTypeOfMember(element);
_removeCall(callee);
callee.removeUser(this);
- inferrer.updateParameterAssignments(
+ inferrer.updateParameterInputs(
this, element, arguments, selector, typeMask,
remove: true, addToQueue: true);
});
@@ -1440,7 +1436,7 @@
}
@override
- void giveUp(InferrerEngine inferrer, {bool clearAssignments: true}) {
+ void giveUp(InferrerEngine inferrer, {bool clearInputs: true}) {
if (!abandonInferencing) {
inferrer.updateSelectorInMember(caller, _callType, _call, selector, mask);
Iterable<MemberEntity> oldTargets = _concreteTargets;
@@ -1452,13 +1448,13 @@
MemberTypeInformation callee =
inferrer.types.getInferredTypeOfMember(element);
callee.addCall(caller, _call);
- inferrer.updateParameterAssignments(
+ inferrer.updateParameterInputs(
this, element, arguments, selector, mask,
remove: false, addToQueue: true);
}
}
}
- super.giveUp(inferrer, clearAssignments: clearAssignments);
+ super.giveUp(inferrer, clearInputs: clearInputs);
}
@override
@@ -1574,12 +1570,12 @@
void removeUser(TypeInformation user) {}
@override
- void addAssignment(TypeInformation assignment) {
+ void addInput(TypeInformation assignment) {
throw "Not supported";
}
@override
- void removeAssignment(TypeInformation assignment) {
+ void removeInput(TypeInformation assignment) {
throw "Not supported";
}
@@ -1661,19 +1657,19 @@
NarrowTypeInformation(AbstractValueDomain abstractValueDomain,
TypeInformation narrowedType, this.typeAnnotation)
: super(abstractValueDomain.emptyType, narrowedType.context) {
- addAssignment(narrowedType);
+ addInput(narrowedType);
}
@override
- addAssignment(TypeInformation info) {
- super.addAssignment(info);
- assert(assignments.length == 1);
+ addInput(TypeInformation info) {
+ super.addInput(info);
+ assert(inputs.length == 1);
}
@override
AbstractValue computeType(InferrerEngine inferrer) {
AbstractValueDomain abstractValueDomain = inferrer.abstractValueDomain;
- AbstractValue input = assignments.first.type;
+ AbstractValue input = inputs.first.type;
AbstractValue intersection =
abstractValueDomain.intersection(input, typeAnnotation);
if (debug.ANOMALY_WARN) {
@@ -1702,7 +1698,7 @@
/// An [InferredTypeInformation] is a [TypeInformation] that
/// defaults to the dynamic type until it is marked as being
/// inferred, at which point it computes its type based on
-/// its assignments.
+/// its inputs.
abstract class InferredTypeInformation extends TypeInformation {
/// Whether the element type in that container has been inferred.
bool inferred = false;
@@ -1710,13 +1706,13 @@
InferredTypeInformation(AbstractValueDomain abstractValueDomain,
MemberTypeInformation context, TypeInformation parentType)
: super(abstractValueDomain.emptyType, context) {
- if (parentType != null) addAssignment(parentType);
+ if (parentType != null) addInput(parentType);
}
@override
AbstractValue computeType(InferrerEngine inferrer) {
if (!inferred) return safeType(inferrer);
- return inferrer.types.computeTypeMask(assignments);
+ return inferrer.types.computeTypeMask(inputs);
}
@override
@@ -1901,7 +1897,7 @@
valueType.addUser(this);
}
- TypeInformation addEntryAssignment(AbstractValueDomain abstractValueDomain,
+ TypeInformation addEntryInput(AbstractValueDomain abstractValueDomain,
TypeInformation key, TypeInformation value,
[bool nonNull = false]) {
TypeInformation newInfo = null;
@@ -1912,19 +1908,19 @@
abstractValueDomain, context, null, nonNull);
return newInfo;
});
- typeInfoMap[keyString].addAssignment(value);
+ typeInfoMap[keyString].addInput(value);
} else {
_allKeysAreStrings = false;
typeInfoMap.clear();
}
- keyType.addAssignment(key);
- valueType.addAssignment(value);
+ keyType.addInput(key);
+ valueType.addInput(value);
if (newInfo != null) newInfo.addUser(this);
return newInfo;
}
- List<TypeInformation> addMapAssignment(
+ List<TypeInformation> addMapInput(
AbstractValueDomain abstractValueDomain, MapTypeInformation other) {
List<TypeInformation> newInfos = <TypeInformation>[];
if (_allKeysAreStrings && other.inDictionaryMode) {
@@ -1935,14 +1931,14 @@
newInfos.add(newInfo);
return newInfo;
});
- typeInfoMap[keyString].addAssignment(value);
+ typeInfoMap[keyString].addInput(value);
});
} else {
_allKeysAreStrings = false;
typeInfoMap.clear();
}
- keyType.addAssignment(other.keyType);
- valueType.addAssignment(other.valueType);
+ keyType.addInput(other.keyType);
+ valueType.addInput(other.valueType);
return newInfos;
}
@@ -1953,7 +1949,7 @@
}
@override
- addAssignment(TypeInformation other) {
+ addInput(TypeInformation other) {
throw "not supported";
}
@@ -2103,7 +2099,7 @@
@override
AbstractValue computeType(InferrerEngine inferrer) {
- return inferrer.types.computeTypeMask(assignments);
+ return inferrer.types.computeTypeMask(inputs);
}
@override
@@ -2114,7 +2110,7 @@
StringBuffer sb, String indent, Set<TypeInformation> seen) {
if (seen.add(this)) {
sb.write('${toString()} [');
- for (TypeInformation assignment in assignments) {
+ for (TypeInformation assignment in inputs) {
sb.write('\n$indent ');
assignment._toStructuredText(sb, '$indent ', seen);
}
diff --git a/pkg/compiler/lib/src/inferrer/type_system.dart b/pkg/compiler/lib/src/inferrer/type_system.dart
index 2e05bac..6d5622e 100644
--- a/pkg/compiler/lib/src/inferrer/type_system.dart
+++ b/pkg/compiler/lib/src/inferrer/type_system.dart
@@ -536,7 +536,7 @@
new MapTypeInformation(currentMember, mask, keyTypeInfo, valueTypeInfo);
for (int i = 0; i < keyTypes.length; ++i) {
- TypeInformation newType = map.addEntryAssignment(
+ TypeInformation newType = map.addEntryInput(
_abstractValueDomain, keyTypes[i], valueTypes[i], true);
if (newType != null) allocatedTypes.add(newType);
}
@@ -562,8 +562,8 @@
PhiElementTypeInformation result = new PhiElementTypeInformation(
_abstractValueDomain, currentMember, null, null,
isTry: false);
- result.addAssignment(firstInput);
- result.addAssignment(secondInput);
+ result.addInput(firstInput);
+ result.addInput(secondInput);
allocatedTypes.add(result);
return result;
}
@@ -574,7 +574,7 @@
_abstractValueDomain, currentMember, node, variable,
isTry: isTry);
allocatedTypes.add(result);
- result.addAssignment(inputType);
+ result.addInput(inputType);
return result;
}
@@ -614,14 +614,14 @@
TypeInformation simplifyPhi(
ir.Node node, Local variable, PhiElementTypeInformation phiType) {
assert(phiType.branchNode == node);
- if (phiType.assignments.length == 1) return phiType.assignments.first;
+ if (phiType.inputs.length == 1) return phiType.inputs.first;
return phiType;
}
/// Adds [newType] as an input of [phiType].
PhiElementTypeInformation addPhiInput(Local variable,
PhiElementTypeInformation phiType, TypeInformation newType) {
- phiType.addAssignment(newType);
+ phiType.addInput(newType);
return phiType;
}
diff --git a/pkg/compiler/lib/src/ir/element_map.dart b/pkg/compiler/lib/src/ir/element_map.dart
index 09aecbe..f521fac 100644
--- a/pkg/compiler/lib/src/ir/element_map.dart
+++ b/pkg/compiler/lib/src/ir/element_map.dart
@@ -69,4 +69,5 @@
DartType getCallType(InterfaceType type);
int getHierarchyDepth(IndexedClass cls);
DartType getTypeVariableBound(IndexedTypeVariable typeVariable);
+ List<Variance> getTypeVariableVariances(IndexedClass cls);
}
diff --git a/pkg/compiler/lib/src/ir/static_type.dart b/pkg/compiler/lib/src/ir/static_type.dart
index 716567a..8e6bc4b 100644
--- a/pkg/compiler/lib/src/ir/static_type.dart
+++ b/pkg/compiler/lib/src/ir/static_type.dart
@@ -54,6 +54,7 @@
final ir.ClassHierarchy hierarchy;
ThisInterfaceType _thisType;
+ ir.Library _currentLibrary;
StaticTypeVisitor(ir.TypeEnvironment typeEnvironment, this.hierarchy)
: super(typeEnvironment);
@@ -83,6 +84,16 @@
_thisType = value;
}
+ ir.Library get currentLibrary {
+ assert(_currentLibrary != null);
+ return _currentLibrary;
+ }
+
+ void set currentLibrary(ir.Library value) {
+ assert(value == null || _currentLibrary == null);
+ _currentLibrary = value;
+ }
+
bool completes(ir.DartType type) => type != const DoesNotCompleteType();
Set<ir.VariableDeclaration> _currentVariables;
@@ -173,7 +184,8 @@
/// If this is not the case the raw type of [superclass] is returned.
///
/// This method is derived from `ir.Expression.getStaticTypeAsInstanceOf`.
- ir.InterfaceType getTypeAsInstanceOf(ir.DartType type, ir.Class superclass) {
+ ir.InterfaceType getTypeAsInstanceOf(
+ ir.DartType type, ir.Class superclass, ir.Library clientLibrary) {
// This method assumes the program is correctly typed, so if the superclass
// is not generic, we can just return its raw type without computing the
// type of this expression. It also ensures that all types are considered
@@ -186,14 +198,16 @@
type = (type as ir.TypeParameterType).parameter.bound;
}
if (type == typeEnvironment.nullType) {
- return superclass.bottomType;
+ return typeEnvironment.coreTypes
+ .bottomInterfaceType(superclass, ir.Nullability.legacy);
}
if (type is ir.InterfaceType) {
- ir.InterfaceType upcastType =
- typeEnvironment.getTypeAsInstanceOf(type, superclass);
+ ir.InterfaceType upcastType = typeEnvironment.getTypeAsInstanceOf(
+ type, superclass, clientLibrary, typeEnvironment.coreTypes);
if (upcastType != null) return upcastType;
} else if (type is ir.BottomType) {
- return superclass.bottomType;
+ return typeEnvironment.coreTypes
+ .bottomInterfaceType(superclass, ir.Nullability.legacy);
}
// TODO(johnniwinther): Should we assert that this doesn't happen?
return typeEnvironment.coreTypes.legacyRawType(superclass);
@@ -213,7 +227,8 @@
}
if (interfaceTarget != null) {
ir.Class superclass = interfaceTarget.enclosingClass;
- receiverType = getTypeAsInstanceOf(receiverType, superclass);
+ receiverType =
+ getTypeAsInstanceOf(receiverType, superclass, currentLibrary);
return ir.Substitution.fromInterfaceType(receiverType)
.substituteType(interfaceTarget.getterType);
}
@@ -283,7 +298,7 @@
ir.Class superclass = interfaceTarget.enclosingClass;
ir.Substitution receiverSubstitution =
ir.Substitution.fromInterfaceType(
- getTypeAsInstanceOf(receiverType, superclass));
+ getTypeAsInstanceOf(receiverType, superclass, currentLibrary));
ir.DartType setterType =
receiverSubstitution.substituteType(interfaceTarget.setterType);
if (!typeEnvironment.isSubtypeOf(
@@ -316,7 +331,8 @@
ir.DartType visitDirectPropertyGet(ir.DirectPropertyGet node) {
ir.DartType receiverType = visitNode(node.receiver);
ir.Class superclass = node.target.enclosingClass;
- receiverType = getTypeAsInstanceOf(receiverType, superclass);
+ receiverType =
+ getTypeAsInstanceOf(receiverType, superclass, currentLibrary);
ir.DartType resultType = ir.Substitution.fromInterfaceType(receiverType)
.substituteType(node.target.getterType);
_expressionTypeCache[node] = resultType;
@@ -341,7 +357,8 @@
receiverType, argumentType);
} else {
ir.Class superclass = node.target.enclosingClass;
- receiverType = getTypeAsInstanceOf(receiverType, superclass);
+ receiverType =
+ getTypeAsInstanceOf(receiverType, superclass, currentLibrary);
ir.DartType returnType = ir.Substitution.fromInterfaceType(receiverType)
.substituteType(node.target.function.returnType);
returnType = ir.Substitution.fromPairs(
@@ -597,7 +614,7 @@
if (interfaceTarget != null) {
ir.Class superclass = interfaceTarget.enclosingClass;
ir.Substitution receiverSubstitution = ir.Substitution.fromInterfaceType(
- getTypeAsInstanceOf(receiverType, superclass));
+ getTypeAsInstanceOf(receiverType, superclass, currentLibrary));
ir.DartType getterType =
receiverSubstitution.substituteType(interfaceTarget.getterType);
if (getterType is ir.FunctionType) {
@@ -810,8 +827,8 @@
if (declaringClass.typeParameters.isEmpty) {
resultType = node.interfaceTarget.getterType;
} else {
- ir.DartType receiver =
- typeEnvironment.getTypeAsInstanceOf(thisType, declaringClass);
+ ir.DartType receiver = typeEnvironment.getTypeAsInstanceOf(thisType,
+ declaringClass, currentLibrary, typeEnvironment.coreTypes);
resultType = ir.Substitution.fromInterfaceType(receiver)
.substituteType(node.interfaceTarget.getterType);
}
@@ -843,8 +860,8 @@
returnType = const ir.DynamicType();
} else {
ir.Class superclass = node.interfaceTarget.enclosingClass;
- ir.InterfaceType receiverType =
- typeEnvironment.getTypeAsInstanceOf(thisType, superclass);
+ ir.InterfaceType receiverType = typeEnvironment.getTypeAsInstanceOf(
+ thisType, superclass, currentLibrary, typeEnvironment.coreTypes);
returnType = ir.Substitution.fromInterfaceType(receiverType)
.substituteType(node.interfaceTarget.function.returnType);
returnType = ir.Substitution.fromPairs(
@@ -1216,7 +1233,10 @@
if (node.isAsync) {
ir.InterfaceType streamInterfaceType = getInterfaceTypeOf(iterableType);
ir.InterfaceType streamType = typeEnvironment.getTypeAsInstanceOf(
- streamInterfaceType, typeEnvironment.coreTypes.streamClass);
+ streamInterfaceType,
+ typeEnvironment.coreTypes.streamClass,
+ currentLibrary,
+ typeEnvironment.coreTypes);
if (streamType != null) {
iteratorType = new ir.InterfaceType(
typeEnvironment.coreTypes.streamIteratorClass,
@@ -1230,7 +1250,10 @@
if (member != null) {
iteratorType = ir.Substitution.fromInterfaceType(
typeEnvironment.getTypeAsInstanceOf(
- iterableInterfaceType, member.enclosingClass))
+ iterableInterfaceType,
+ member.enclosingClass,
+ currentLibrary,
+ typeEnvironment.coreTypes))
.substituteType(member.getterType);
}
}
@@ -1382,12 +1405,14 @@
thisType = new ThisInterfaceType.from(node.enclosingClass?.getThisType(
typeEnvironment.coreTypes, node.enclosingLibrary.nonNullable));
_currentVariables = {};
+ currentLibrary = node.enclosingLibrary;
visitSignature(node.function);
visitNode(node.function.body);
handleProcedure(node);
_invalidatedVariables.removeAll(_currentVariables);
_currentVariables = null;
thisType = null;
+ currentLibrary = null;
}
void handleConstructor(ir.Constructor node) {}
@@ -1397,6 +1422,7 @@
thisType = new ThisInterfaceType.from(node.enclosingClass.getThisType(
typeEnvironment.coreTypes, node.enclosingLibrary.nonNullable));
_currentVariables = {};
+ currentLibrary = node.enclosingLibrary;
visitSignature(node.function);
visitNodes(node.initializers);
visitNode(node.function.body);
@@ -1404,6 +1430,7 @@
_invalidatedVariables.removeAll(_currentVariables);
_currentVariables = null;
thisType = null;
+ currentLibrary = null;
}
void handleField(ir.Field node) {}
@@ -1413,11 +1440,13 @@
thisType = new ThisInterfaceType.from(node.enclosingClass?.getThisType(
typeEnvironment.coreTypes, node.enclosingLibrary.nonNullable));
_currentVariables = {};
+ currentLibrary = node.enclosingLibrary;
visitNode(node.initializer);
handleField(node);
_invalidatedVariables.removeAll(_currentVariables);
_currentVariables = null;
thisType = null;
+ currentLibrary = null;
}
void handleVariableDeclaration(ir.VariableDeclaration node) {}
diff --git a/pkg/compiler/lib/src/ir/types.dart b/pkg/compiler/lib/src/ir/types.dart
index ec95dff..6b13c4c 100644
--- a/pkg/compiler/lib/src/ir/types.dart
+++ b/pkg/compiler/lib/src/ir/types.dart
@@ -133,6 +133,11 @@
}
@override
+ List<Variance> getTypeVariableVariances(ClassEntity cls) {
+ return elementMap.getTypeVariableVariances(cls);
+ }
+
+ @override
FunctionType getCallType(InterfaceType type) {
return elementMap.getCallType(type);
}
diff --git a/pkg/compiler/lib/src/ir/util.dart b/pkg/compiler/lib/src/ir/util.dart
index 1f92dffc..40a8d77 100644
--- a/pkg/compiler/lib/src/ir/util.dart
+++ b/pkg/compiler/lib/src/ir/util.dart
@@ -68,6 +68,21 @@
}
}
+/// Returns the `Variance` corresponding to `node.variance`.
+Variance convertVariance(ir.TypeParameter node) {
+ if (node.isLegacyCovariant) return Variance.legacyCovariant;
+ switch (node.variance) {
+ case ir.Variance.covariant:
+ return Variance.covariant;
+ case ir.Variance.contravariant:
+ return Variance.contravariant;
+ case ir.Variance.invariant:
+ return Variance.invariant;
+ default:
+ throw new UnsupportedError("Variance ${node.variance} is not supported.");
+ }
+}
+
/// Kernel encodes a null-aware expression `a?.b` as
///
/// let final #1 = a in #1 == null ? null : #1.b
diff --git a/pkg/compiler/lib/src/js_backend/backend_impact.dart b/pkg/compiler/lib/src/js_backend/backend_impact.dart
index e4c6473..09a889e 100644
--- a/pkg/compiler/lib/src/js_backend/backend_impact.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_impact.dart
@@ -13,6 +13,7 @@
show WorldImpact, WorldImpactBuilder, WorldImpactBuilderImpl;
import '../universe/use.dart';
import '../util/enumset.dart';
+import '../options.dart';
/// Backend specific features required by a backend impact.
enum BackendFeature {
@@ -90,9 +91,9 @@
/// The JavaScript backend dependencies for various features.
class BackendImpacts {
final CommonElements _commonElements;
- final bool _newRti;
+ final CompilerOptions _options;
- BackendImpacts(this._commonElements, this._newRti);
+ BackendImpacts(this._commonElements, this._options);
BackendImpact _getRuntimeTypeArgument;
@@ -166,7 +167,7 @@
return _typeVariableBoundCheck ??= new BackendImpact(staticUses: [
_commonElements.throwTypeError,
_commonElements.assertIsSubtype,
- if (_newRti) _commonElements.checkTypeBound,
+ if (_options.experimentNewRti) _commonElements.checkTypeBound,
]);
}
@@ -428,7 +429,7 @@
_commonElements.typeLiteralClass
], staticUses: [
_commonElements.createRuntimeType,
- if (_newRti) _commonElements.typeLiteralMaker,
+ if (_options.experimentNewRti) _commonElements.typeLiteralMaker,
]);
}
@@ -770,7 +771,7 @@
_genericInstantiation[typeArgumentCount] ??=
new BackendImpact(staticUses: [
_commonElements.getInstantiateFunction(typeArgumentCount),
- ..._newRti
+ ..._options.experimentNewRti
? [
_commonElements.instantiatedGenericFunctionTypeNewRti,
_commonElements.closureFunctionType
@@ -785,7 +786,7 @@
/// Backend impact for --experiment-new-rti.
List<BackendImpact> newRtiImpacts(String what) {
- if (!_newRti) return [];
+ if (!_options.experimentNewRti) return [];
// TODO(sra): Split into refined impacts.
return [
BackendImpact(staticUses: [
@@ -825,9 +826,12 @@
BackendImpact _rtiAddRules;
+ // TODO(fishythefish): Split into refined impacts.
BackendImpact get rtiAddRules => _rtiAddRules ??= BackendImpact(globalUses: [
_commonElements.rtiAddRulesMethod,
- _commonElements.rtiAddErasedTypesMethod
+ _commonElements.rtiAddErasedTypesMethod,
+ if (_options.enableVariance)
+ _commonElements.rtiAddTypeParameterVariancesMethod,
], otherImpacts: [
_needsString('Needed to encode the new RTI ruleset.')
]);
diff --git a/pkg/compiler/lib/src/js_backend/codegen_listener.dart b/pkg/compiler/lib/src/js_backend/codegen_listener.dart
index f4ae36c..bc3ac78 100644
--- a/pkg/compiler/lib/src/js_backend/codegen_listener.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen_listener.dart
@@ -128,6 +128,11 @@
_commonElements.rtiAddRulesMethod, CallStructure.TWO_ARGS));
newRtiImpact.registerStaticUse(StaticUse.staticInvoke(
_commonElements.rtiAddErasedTypesMethod, CallStructure.TWO_ARGS));
+ if (_options.enableVariance) {
+ newRtiImpact.registerStaticUse(StaticUse.staticInvoke(
+ _commonElements.rtiAddTypeParameterVariancesMethod,
+ CallStructure.TWO_ARGS));
+ }
enqueuer.applyImpact(newRtiImpact);
_isNewRtiUsed = true;
}
diff --git a/pkg/compiler/lib/src/js_backend/runtime_types_new.dart b/pkg/compiler/lib/src/js_backend/runtime_types_new.dart
index 53f2004..3cf5f7b 100644
--- a/pkg/compiler/lib/src/js_backend/runtime_types_new.dart
+++ b/pkg/compiler/lib/src/js_backend/runtime_types_new.dart
@@ -634,4 +634,28 @@
_colon,
js.number(entry.value),
]);
+
+ jsAst.StringConcatenation encodeTypeParameterVariances(
+ Map<ClassEntity, List<Variance>> typeParameterVariances) =>
+ js.concatenateStrings([
+ _quote,
+ _leftBrace,
+ ...js.joinLiterals(
+ typeParameterVariances.entries
+ .map(_encodeTypeParameterVariancesForClass),
+ _comma),
+ _rightBrace,
+ _quote,
+ ]);
+
+ jsAst.StringConcatenation _encodeTypeParameterVariancesForClass(
+ MapEntry<ClassEntity, List<Variance>> classEntry) =>
+ js.concatenateStrings([
+ js.quoteName(_emitter.typeAccessNewRti(classEntry.key)),
+ _colon,
+ _leftBracket,
+ ...js.joinLiterals(
+ classEntry.value.map((v) => js.number(v.index)), _comma),
+ _rightBracket
+ ]);
}
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
index fbee515..19768cf 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
@@ -439,6 +439,9 @@
// Adds the subtype rules for the new RTI.
#typeRules;
+// Adds the variance table for the new RTI.
+#variances;
+
// Shared types need to be initialized before constants.
#sharedTypeRtis;
@@ -540,6 +543,9 @@
// Adds the subtype rules for the new RTI.
#typeRules;
+// Adds the variance table for the new RTI.
+#variances;
+
#sharedTypeRtis;
// Instantiates all constants of this deferred fragment.
// Note that the constant-holder has been updated earlier and storing the
@@ -702,6 +708,7 @@
'embeddedGlobalsPart2':
emitEmbeddedGlobalsPart2(program, deferredLoadingState),
'typeRules': emitTypeRules(fragment),
+ 'variances': emitVariances(fragment),
'sharedTypeRtis':
_options.experimentNewRti ? TypeReferenceResource() : [],
'nativeSupport': program.needsNativeSupport
@@ -786,6 +793,7 @@
var tearOffs = emitInstallTearOffs(fragment);
var constants = emitConstants(fragment);
var typeRules = emitTypeRules(fragment);
+ var variances = emitVariances(fragment);
var staticNonFinalFields = emitStaticNonFinalFields(fragment);
var lazyInitializers = emitLazilyInitializedStatics(fragment);
// TODO(floitsch): only call emitNativeSupport if we need native.
@@ -828,6 +836,7 @@
'aliases': methodAliases,
'tearOffs': tearOffs,
'typeRules': typeRules,
+ 'variances': variances,
'constants': constants,
'staticNonFinalFields': staticNonFinalFields,
'lazyStatics': lazyInitializers,
@@ -2041,6 +2050,41 @@
return js.Block(statements);
}
+ js.Statement emitVariances(Fragment fragment) {
+ if (!_options.enableVariance || !_options.experimentNewRti) {
+ return js.EmptyStatement();
+ }
+
+ Map<ClassEntity, List<Variance>> typeParameterVariances = {};
+ Iterable<Class> classes =
+ fragment.libraries.expand((Library library) => library.classes);
+ classes.forEach((Class cls) {
+ ClassEntity element = cls.element;
+ List<Variance> classVariances =
+ _elementEnvironment.getTypeVariableVariances(element);
+
+ // Emit variances for a class only if there is at least one explicit
+ // variance defined.
+ bool hasOnlyLegacyVariance = classVariances
+ .every((variance) => variance == Variance.legacyCovariant);
+ if (!hasOnlyLegacyVariance) {
+ typeParameterVariances[element] = classVariances;
+ }
+ });
+
+ if (typeParameterVariances.isNotEmpty) {
+ FunctionEntity addVariances =
+ _closedWorld.commonElements.rtiAddTypeParameterVariancesMethod;
+ return js.js.statement('#(init.#,JSON.parse(#));', [
+ _emitter.staticFunctionAccess(addVariances),
+ RTI_UNIVERSE,
+ _rulesetEncoder.encodeTypeParameterVariances(typeParameterVariances),
+ ]);
+ }
+
+ return js.EmptyStatement();
+ }
+
/// Returns an expression that creates the initial Rti Universe.
///
/// This needs to be kept in sync with `_Universe.create` in `dart:_rti`.
@@ -2053,6 +2097,7 @@
initField(RtiUniverseFieldNames.evalCache, 'new Map()');
initField(RtiUniverseFieldNames.typeRules, '{}');
initField(RtiUniverseFieldNames.erasedTypes, '{}');
+ initField(RtiUniverseFieldNames.typeParameterVariances, '{}');
initField(RtiUniverseFieldNames.sharedEmptyArray, '[]');
return js.ObjectInitializer(universeFields);
diff --git a/pkg/compiler/lib/src/js_model/closure.dart b/pkg/compiler/lib/src/js_model/closure.dart
index df0534f..c773393 100644
--- a/pkg/compiler/lib/src/js_model/closure.dart
+++ b/pkg/compiler/lib/src/js_model/closure.dart
@@ -895,6 +895,9 @@
@override
InterfaceType get instantiationToBounds => thisType;
+
+ @override
+ List<Variance> getVariances() => [];
}
/// A container for variables declared in a particular scope that are accessed
diff --git a/pkg/compiler/lib/src/js_model/element_map_impl.dart b/pkg/compiler/lib/src/js_model/element_map_impl.dart
index dad0b52..7d74506 100644
--- a/pkg/compiler/lib/src/js_model/element_map_impl.dart
+++ b/pkg/compiler/lib/src/js_model/element_map_impl.dart
@@ -1070,6 +1070,13 @@
return data.getBound(this);
}
+ @override
+ List<Variance> getTypeVariableVariances(IndexedClass cls) {
+ assert(checkFamily(cls));
+ JClassData data = classes.getData(cls);
+ return data.getVariances();
+ }
+
DartType _getTypeVariableDefaultType(IndexedTypeVariable typeVariable) {
assert(checkFamily(typeVariable));
JTypeVariableData data = typeVariables.getData(typeVariable);
@@ -2288,6 +2295,11 @@
}
@override
+ List<Variance> getTypeVariableVariances(ClassEntity cls) {
+ return elementMap.getTypeVariableVariances(cls);
+ }
+
+ @override
DartType getTypeVariableDefaultType(TypeVariableEntity typeVariable) {
return elementMap._getTypeVariableDefaultType(typeVariable);
}
diff --git a/pkg/compiler/lib/src/js_model/env.dart b/pkg/compiler/lib/src/js_model/env.dart
index 1b92036..030bf81 100644
--- a/pkg/compiler/lib/src/js_model/env.dart
+++ b/pkg/compiler/lib/src/js_model/env.dart
@@ -16,6 +16,7 @@
import '../ir/element_map.dart';
import '../ir/static_type_cache.dart';
import '../ir/visitors.dart';
+import '../ir/util.dart';
import '../js_model/element_map.dart';
import '../ordered_typeset.dart';
import '../serialization/serialization.dart';
@@ -451,6 +452,8 @@
bool get isEnumClass;
bool get isMixinApplication;
+
+ List<Variance> getVariances();
}
class JClassDataImpl implements JClassData {
@@ -482,6 +485,8 @@
@override
OrderedTypeSet orderedTypeSet;
+ List<Variance> _variances;
+
JClassDataImpl(this.cls, this.definition);
factory JClassDataImpl.readFromDataSource(DataSource source) {
@@ -506,6 +511,10 @@
@override
DartType get callType => null;
+
+ @override
+ List<Variance> getVariances() =>
+ _variances ??= cls.typeParameters.map(convertVariance).toList();
}
/// Enum used for identifying [JMemberData] subclasses in serialization.
diff --git a/pkg/compiler/lib/src/js_model/js_strategy.dart b/pkg/compiler/lib/src/js_model/js_strategy.dart
index 822be8c..166fae9 100644
--- a/pkg/compiler/lib/src/js_model/js_strategy.dart
+++ b/pkg/compiler/lib/src/js_model/js_strategy.dart
@@ -252,7 +252,7 @@
ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
CommonElements commonElements = closedWorld.commonElements;
BackendImpacts impacts =
- new BackendImpacts(commonElements, _compiler.options.experimentNewRti);
+ new BackendImpacts(commonElements, _compiler.options);
_customElementsCodegenAnalysis = new CustomElementsCodegenAnalysis(
commonElements, elementEnvironment, closedWorld.nativeData);
return new CodegenEnqueuer(
@@ -306,8 +306,8 @@
emitterTask.createEmitter(_namer, codegen, closedWorld);
// TODO(johnniwinther): Share the impact object created in
// createCodegenEnqueuer.
- BackendImpacts impacts = new BackendImpacts(
- closedWorld.commonElements, _compiler.options.experimentNewRti);
+ BackendImpacts impacts =
+ new BackendImpacts(closedWorld.commonElements, _compiler.options);
_codegenImpactTransformer = new CodegenImpactTransformer(
closedWorld,
diff --git a/pkg/compiler/lib/src/kernel/dart2js_target.dart b/pkg/compiler/lib/src/kernel/dart2js_target.dart
index 02c3047..19416dd 100644
--- a/pkg/compiler/lib/src/kernel/dart2js_target.dart
+++ b/pkg/compiler/lib/src/kernel/dart2js_target.dart
@@ -53,10 +53,8 @@
@override
bool get enableNoSuchMethodForwarders => true;
- // TODO(johnniwinther): Change this to `false` when late field lowering is
- // ready.
@override
- bool get supportsLateFields => true;
+ bool get supportsLateFields => false;
@override
List<String> get extraRequiredLibraries => _requiredLibraries[name];
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index c8e869a..b6979bc 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart
@@ -643,6 +643,13 @@
return data.getBound(this);
}
+ @override
+ List<Variance> getTypeVariableVariances(IndexedClass cls) {
+ assert(checkFamily(cls));
+ KClassData data = classes.getData(cls);
+ return data.getVariances();
+ }
+
ClassEntity getAppliedMixin(IndexedClass cls) {
assert(checkFamily(cls));
KClassData data = classes.getData(cls);
@@ -1743,6 +1750,11 @@
}
@override
+ List<Variance> getTypeVariableVariances(ClassEntity cls) {
+ return elementMap.getTypeVariableVariances(cls);
+ }
+
+ @override
InterfaceType createInterfaceType(
ClassEntity cls, List<DartType> typeArguments) {
return new InterfaceType(cls, typeArguments);
diff --git a/pkg/compiler/lib/src/kernel/env.dart b/pkg/compiler/lib/src/kernel/env.dart
index 6496281..2c593e2 100644
--- a/pkg/compiler/lib/src/kernel/env.dart
+++ b/pkg/compiler/lib/src/kernel/env.dart
@@ -629,6 +629,7 @@
bool get isMixinApplication;
Iterable<ConstantValue> getMetadata(IrToElementMap elementMap);
+ List<Variance> getVariances();
/// Convert this [KClassData] to the corresponding [JClassData].
JClassData convert();
@@ -659,6 +660,7 @@
OrderedTypeSet orderedTypeSet;
Iterable<ConstantValue> _metadata;
+ List<Variance> _variances;
KClassDataImpl(this.node);
@@ -678,6 +680,10 @@
}
@override
+ List<Variance> getVariances() =>
+ _variances ??= node.typeParameters.map(convertVariance).toList();
+
+ @override
JClassData convert() {
return new JClassDataImpl(node, new RegularClassDefinition(node));
}
diff --git a/pkg/compiler/lib/src/kernel/kernel_strategy.dart b/pkg/compiler/lib/src/kernel/kernel_strategy.dart
index 642120d..01b6a29 100644
--- a/pkg/compiler/lib/src/kernel/kernel_strategy.dart
+++ b/pkg/compiler/lib/src/kernel/kernel_strategy.dart
@@ -142,7 +142,7 @@
CompilerTask task, Compiler compiler) {
RuntimeTypesNeedBuilder rtiNeedBuilder = _createRuntimeTypesNeedBuilder();
BackendImpacts impacts =
- new BackendImpacts(commonElements, compiler.options.experimentNewRti);
+ new BackendImpacts(commonElements, compiler.options);
_nativeResolutionEnqueuer = new NativeResolutionEnqueuer(
compiler.options,
elementEnvironment,
diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart
index 40e7469..a305b6f 100644
--- a/pkg/compiler/lib/src/options.dart
+++ b/pkg/compiler/lib/src/options.dart
@@ -111,6 +111,9 @@
bool get useCFEConstants =>
languageExperiments[fe.ExperimentalFlag.constantUpdate2018];
+ /// `true` if variance is enabled.
+ bool get enableVariance => languageExperiments[fe.ExperimentalFlag.variance];
+
/// A possibly null state object for kernel compilation.
fe.InitializedCompilerState kernelInitializedCompilerState;
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index b696a67..8c3caff 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -381,6 +381,8 @@
return options.useContentSecurityPolicy;
case 'USE_NEW_RTI':
return options.experimentNewRti;
+ case 'VARIANCE':
+ return options.enableVariance;
default:
return null;
}
diff --git a/pkg/compiler/lib/src/ssa/variable_allocator.dart b/pkg/compiler/lib/src/ssa/variable_allocator.dart
index 33f1006..338204e 100644
--- a/pkg/compiler/lib/src/ssa/variable_allocator.dart
+++ b/pkg/compiler/lib/src/ssa/variable_allocator.dart
@@ -527,7 +527,7 @@
// instruction is used by a phi, try to use the name of the phi.
// Otherwise, just allocate a temporary name.
HPhi phi = firstPhiUserWithElement(instruction);
- if (phi != null) {
+ if (phi != null && phi.sourceElement.name != null) {
name = allocateWithHint(phi.sourceElement.name);
} else {
name = allocateTemporary();
diff --git a/pkg/dart_internal/pubspec.yaml b/pkg/dart_internal/pubspec.yaml
index a411212..26c9202 100644
--- a/pkg/dart_internal/pubspec.yaml
+++ b/pkg/dart_internal/pubspec.yaml
@@ -1,5 +1,5 @@
name: dart_internal
-version: 0.1.7
+version: 0.1.8
author: "Dart Team <misc@dartlang.org>"
homepage: http://www.dartlang.org
description: >
@@ -16,4 +16,4 @@
environment:
# Restrict the upper bound so that we can remove support for this in a later
# version of the SDK without it being a breaking change.
- sdk: ">=2.0.0-dev.12.0 <2.7.0"
+ sdk: ">=2.0.0-dev.12.0 <2.8.0"
diff --git a/pkg/dev_compiler/lib/src/analyzer/driver.dart b/pkg/dev_compiler/lib/src/analyzer/driver.dart
index 01bd34e..7a02ace 100644
--- a/pkg/dev_compiler/lib/src/analyzer/driver.dart
+++ b/pkg/dev_compiler/lib/src/analyzer/driver.dart
@@ -109,12 +109,12 @@
var sourceFactory = createSourceFactory(options,
sdkResolver: DartUriResolver(dartSdk), summaryData: summaryData);
- /// A fresh file system state for this list of [explicitSources].
- var fsState = _createFileSystemState(sourceFactory);
-
var declaredVariables = DeclaredVariables.fromMap(
Map.of(options.declaredVariables)..addAll(sdkLibraryVariables));
+ /// A fresh file system state for this list of [explicitSources].
+ var fsState = _createFileSystemState(declaredVariables, sourceFactory);
+
var resynthesizerBuilder = DevCompilerResynthesizerBuilder(
fsState: fsState,
analysisOptions: analysisOptions,
@@ -142,7 +142,8 @@
);
}
- FileSystemState _createFileSystemState(SourceFactory sourceFactory) {
+ FileSystemState _createFileSystemState(
+ DeclaredVariables declaredVariables, SourceFactory sourceFactory) {
var unlinkedSalt =
Uint32List(1 + AnalysisOptionsImpl.unlinkedSignatureLength);
unlinkedSalt[0] = AnalysisDriver.DATA_VERSION;
@@ -160,6 +161,7 @@
'contextName',
sourceFactory,
analysisOptions,
+ declaredVariables,
unlinkedSalt,
linkedSalt,
externalSummaries: summaryData);
diff --git a/pkg/dev_compiler/lib/src/analyzer/extension_types.dart b/pkg/dev_compiler/lib/src/analyzer/extension_types.dart
index 9f3399e..96d7d0b 100644
--- a/pkg/dev_compiler/lib/src/analyzer/extension_types.dart
+++ b/pkg/dev_compiler/lib/src/analyzer/extension_types.dart
@@ -60,7 +60,7 @@
// These are used natively by dart:html but also not annotated.
_addExtensionTypesForLibrary('dart:core', ['Comparable', 'Map']);
- _addExtensionTypesForLibrary('dart:collection', ['ListMixin']);
+ _addExtensionTypesForLibrary('dart:collection', ['ListMixin', 'MapMixin']);
_addExtensionTypesForLibrary('dart:math', ['Rectangle']);
// Second, html types - these are only searched if we use dart:html, etc.:
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index 478f3b3..4fcbd16 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -369,7 +369,7 @@
return CompilerResult(64);
}
StringBuffer sb = StringBuffer();
- kernel.Printer(sb, showExternal: false).writeComponentFile(component);
+ kernel.Printer(sb).writeComponentFile(component);
outFiles.add(File(outPaths.first + '.txt').writeAsString(sb.toString()));
}
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index 369ec38..0d1a0a7 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -814,7 +814,7 @@
for (var ctor in superclass.constructors) {
var savedUri = _currentUri;
_currentUri = ctor.enclosingClass.fileUri;
- var jsParams = _emitParameters(ctor.function);
+ var jsParams = _emitParameters(ctor.function, isForwarding: true);
_currentUri = savedUri;
var name = ctor.name.name;
var ctorBody = [
@@ -1015,18 +1015,16 @@
return #.is(o) || #.is(o);
}
''', [className, typeT, futureOfT]));
- // TODO(jmesserly): remove the fallback to `dart.as`. It's only for the
- // _ignoreTypeFailure logic.
body.add(js.statement('''
#.as = function as_FutureOr(o) {
if (o == null || #.is(o) || #.is(o)) return o;
- return #.as(o, this, false);
+ #.castError(o, this, false);
}
''', [className, typeT, futureOfT, runtimeModule]));
body.add(js.statement('''
#._check = function check_FutureOr(o) {
if (o == null || #.is(o) || #.is(o)) return o;
- return #.as(o, this, true);
+ #.castError(o, this, true);
}
''', [className, typeT, futureOfT, runtimeModule]));
return null;
@@ -1041,18 +1039,16 @@
return #.is(o) || #.is(o);
}
''', [className, typeT, futureOfT]));
- // TODO(jmesserly): remove the fallback to `dart.as`. It's only for the
- // _ignoreTypeFailure logic.
body.add(js.statement('''
#.as = function as_FutureOr(o) {
if (o == null || #.is(o) || #.is(o)) return o;
- return #.as(o, this, false);
+ #.castError(o, this, false);
}
''', [className, typeT, futureOfT, runtimeModule]));
body.add(js.statement('''
#._check = function check_FutureOr(o) {
if (o == null || #.is(o) || #.is(o)) return o;
- return #.as(o, this, true);
+ #.castError(o, this, true);
}
''', [className, typeT, futureOfT, runtimeModule]));
return null;
@@ -2821,9 +2817,28 @@
return js_ast.Fun(formals, block);
}
- List<js_ast.Parameter> _emitParameters(FunctionNode f) {
+ js_ast.Parameter _emitParameter(VariableDeclaration node,
+ {bool withoutInitializer = false}) {
+ var initializer = node.initializer;
+ var id = _emitVariableDef(node);
+ if (initializer == null || withoutInitializer) return id;
+ return js_ast.DestructuredVariable(
+ name: id, defaultValue: _visitExpression(initializer));
+ }
+
+ List<js_ast.Parameter> _emitParameters(FunctionNode f,
+ {bool isForwarding = false}) {
+ // Destructure optional positional parameters in place.
+ // Given:
+ // - (arg1, arg2, [opt1, opt2 = def2])
+ // Emit:
+ // - (arg1, arg2, opt1 = null, opt2 = def2)
+ // Note, if [isForwarding] is set, omit initializers as this actually a
+ // forwarded call not a parameter list. E.g., the second in:
+ // - foo(arg1, opt1 = def1) => super(arg1, opt1).
var positional = f.positionalParameters;
- var result = List<js_ast.Parameter>.of(positional.map(_emitVariableDef));
+ var result = List<js_ast.Parameter>.of(positional
+ .map((p) => _emitParameter(p, withoutInitializer: isForwarding)));
if (positional.isNotEmpty &&
f.requiredParameterCount == positional.length &&
positional.last.annotations.any(isJsRestAnnotation)) {
@@ -2914,7 +2929,7 @@
//
// In the future, we might be able to simplify this, see:
// https://github.com/dart-lang/sdk/issues/28320
- var jsParams = _emitParameters(function);
+ var jsParams = _emitParameters(function, isForwarding: true);
var mutatedParams = jsParams;
var gen = emitGeneratorFn((fnBody) {
var mutatedVars = js_ast.findMutatedVariables(fnBody);
@@ -2972,8 +2987,9 @@
DartType _expectedReturnType(FunctionNode f, Class expected) {
var type = f.thisFunctionType.returnType;
if (type is InterfaceType) {
- var match = _hierarchy.getTypeAsInstanceOf(type, expected);
- if (match != null) return match.typeArguments[0];
+ var matchArguments =
+ _hierarchy.getTypeArgumentsAsInstanceOf(type, expected);
+ if (matchArguments != null) return matchArguments[0];
}
return const DynamicType();
}
@@ -3055,19 +3071,10 @@
}
}
- for (var p in f.positionalParameters.take(f.requiredParameterCount)) {
+ for (var p in f.positionalParameters) {
var jsParam = _emitIdentifier(p.name);
initParameter(p, jsParam);
}
- for (var p in f.positionalParameters.skip(f.requiredParameterCount)) {
- var jsParam = _emitIdentifier(p.name);
- var defaultValue = _defaultParamValue(p);
- if (defaultValue != null) {
- body.add(js.statement(
- 'if (# === void 0) # = #;', [jsParam, jsParam, defaultValue]));
- }
- initParameter(p, jsParam);
- }
for (var p in f.namedParameters) {
// Parameters will be passed using their real names, not the (possibly
// renamed) local variable.
@@ -4050,8 +4057,6 @@
_emitStaticGet(node.target);
js_ast.Expression _emitStaticGet(Member target) {
- // TODO(vsm): Re-inline constants. See:
- // https://github.com/dart-lang/sdk/issues/36285
var result = _emitStaticTarget(target);
if (_reifyTearoff(target)) {
// TODO(jmesserly): we could tag static/top-level function types once
diff --git a/pkg/dev_compiler/lib/src/kernel/native_types.dart b/pkg/dev_compiler/lib/src/kernel/native_types.dart
index d5450f6..1a501ef 100644
--- a/pkg/dev_compiler/lib/src/kernel/native_types.dart
+++ b/pkg/dev_compiler/lib/src/kernel/native_types.dart
@@ -53,9 +53,13 @@
// These are used natively by dart:html but also not annotated.
_addExtensionTypesForLibrary('dart:core', ['Comparable', 'Map']);
- _addExtensionTypesForLibrary('dart:collection', ['ListMixin']);
+ _addExtensionTypesForLibrary('dart:collection', ['ListMixin', 'MapMixin']);
_addExtensionTypesForLibrary('dart:math', ['Rectangle']);
+ // TODO(39612) Validate that after this point no types from the SDK are
+ // added as native extensions (excluding types from dart:html and "friends"
+ // listed below).
+
// Second, html types - these are only searched if we use dart:html, etc.:
_addPendingExtensionTypes(sdk.getLibrary('dart:html'));
_addPendingExtensionTypes(sdk.getLibrary('dart:indexed_db'));
diff --git a/pkg/dev_compiler/lib/src/kernel/target.dart b/pkg/dev_compiler/lib/src/kernel/target.dart
index 7cd1fc0..ea51684 100644
--- a/pkg/dev_compiler/lib/src/kernel/target.dart
+++ b/pkg/dev_compiler/lib/src/kernel/target.dart
@@ -23,10 +23,8 @@
@override
bool get enableSuperMixins => true;
- // TODO(johnniwinther): Change this to `false` when late field lowering is
- // ready.
@override
- bool get supportsLateFields => true;
+ bool get supportsLateFields => false;
@override
String get name => 'dartdevc';
diff --git a/pkg/dev_compiler/test/modular_ddc_suite.dart b/pkg/dev_compiler/test/modular_ddc_suite.dart
index e525eb2..28a21bf 100644
--- a/pkg/dev_compiler/test/modular_ddc_suite.dart
+++ b/pkg/dev_compiler/test/modular_ddc_suite.dart
@@ -23,8 +23,8 @@
String _dartdevcScript;
String _buildSdkScript;
String _patchSdkScript;
-String _sdkDevRuntime;
-String _sdkDevRuntimeNnbd;
+String _librariesJson;
+String _librariesJsonNnbd;
main(List<String> args) async {
_options = Options.parse(args);
@@ -90,10 +90,13 @@
Platform.resolvedExecutable,
[
_patchSdkScript,
- sdkRoot.toFilePath(),
- if (nnbd) _sdkDevRuntimeNnbd else _sdkDevRuntime,
- 'patched_sdk',
- if (nnbd) 'sdk_nnbd'
+ '--target',
+ 'dartdevc',
+ '--libraries',
+ if (nnbd) _librariesJsonNnbd else _librariesJson,
+ '--out',
+ 'patched_sdk/',
+ if (nnbd) '--nnbd'
],
root.toFilePath());
_checkExitCode(result, this, module);
@@ -320,6 +323,6 @@
'pkg/dev_compiler/bin/dartdevc.dart', 'snapshots/dartdevc.dart.snapshot');
_buildSdkScript = await resolve('pkg/dev_compiler/tool/build_sdk.dart');
_patchSdkScript = await resolve('pkg/dev_compiler/tool/patch_sdk.dart');
- _sdkDevRuntime = await resolve('sdk/lib/_internal/js_dev_runtime');
- _sdkDevRuntimeNnbd = await resolve('sdk_nnbd/lib/_internal/js_dev_runtime');
+ _librariesJson = await resolve('sdk/lib/libraries.json');
+ _librariesJsonNnbd = await resolve('sdk_nnbd/lib/libraries.json');
}
diff --git a/pkg/dev_compiler/test/sourcemap/sourcemaps_ddk_suite.dart b/pkg/dev_compiler/test/sourcemap/sourcemaps_ddk_suite.dart
index 3246bd5..ebd27f8 100644
--- a/pkg/dev_compiler/test/sourcemap/sourcemaps_ddk_suite.dart
+++ b/pkg/dev_compiler/test/sourcemap/sourcemaps_ddk_suite.dart
@@ -53,7 +53,7 @@
Uri outDir = outputFile.resolve(".");
String outputFilename = outputFile.pathSegments.last;
- File sdkJsFile = findInOutDir("gen/utils/dartdevc/js/es6/dart_sdk.js");
+ File sdkJsFile = findInOutDir("gen/utils/dartdevc/kernel/es6/dart_sdk.js");
var jsSdkPath = sdkJsFile.uri;
File ddcSdkSummary = findInOutDir("ddc_sdk.dill");
diff --git a/pkg/dev_compiler/tool/check_nnbd_sdk.dart b/pkg/dev_compiler/tool/check_nnbd_sdk.dart
index 8d36bb9..743b2bd 100644
--- a/pkg/dev_compiler/tool/check_nnbd_sdk.dart
+++ b/pkg/dev_compiler/tool/check_nnbd_sdk.dart
@@ -15,6 +15,13 @@
void main(List<String> argv) {
var args = _parser.parse(argv);
+ if (args['help'] as bool || argv.isEmpty) {
+ print('Apply patch file to the SDK and report analysis errors from the '
+ 'resulting libraries.\n\n'
+ 'Usage: ${Platform.script.pathSegments.last} [options...]\n\n'
+ '${_parser.usage}');
+ return;
+ }
String baseDir = args['out'] as String;
if (baseDir == null) {
var tmp = Directory.systemTemp.createTempSync('check_sdk-');
@@ -53,6 +60,8 @@
'machine',
'--sdk-warnings',
'--no-hints',
+ '--enable-experiment',
+ 'non-nullable',
emptyProgramUri.toFilePath()
]);
@@ -74,4 +83,5 @@
'This name matches one of the possible targets in libraries.json '
'and it is used to pick which patch files will be applied.',
allowed: ['dartdevc', 'dart2js', 'dart2js_server', 'vm', 'flutter'],
- defaultsTo: 'dartdevc');
+ defaultsTo: 'dartdevc')
+ ..addFlag('help', abbr: 'h', help: 'Display this message.');
diff --git a/pkg/dev_compiler/tool/old_patch_sdk.dart b/pkg/dev_compiler/tool/old_patch_sdk.dart
new file mode 100755
index 0000000..1d1ab9b
--- /dev/null
+++ b/pkg/dev_compiler/tool/old_patch_sdk.dart
@@ -0,0 +1,510 @@
+#!/usr/bin/env dart
+// Copyright (c) 2015, 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.
+
+// TODO(sigmund): delete. This file is now replaced by `patch_sdk.dart`. We
+// are keeping this copy around because there is one remaining use of it in the
+// build system of our internal apps. That use is deprecated and will be
+// deleted, at that point this file will be deleted too.
+
+/// Command line tool to merge the SDK libraries and our patch files.
+/// This is currently designed as an offline tool, but we could automate it.
+
+import 'dart:io';
+import 'dart:math' as math;
+
+import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/dart/analysis/results.dart';
+import 'package:analyzer/dart/analysis/utilities.dart';
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/token.dart';
+import 'package:analyzer/dart/ast/visitor.dart';
+import 'package:analyzer/src/generated/sdk.dart';
+import 'package:path/path.dart' as p;
+
+void main(List<String> argv) {
+ var self = p.relative(p.fromUri(Platform.script));
+ if (argv.length < 3) {
+ var toolDir = p.relative(p.dirname(p.fromUri(Platform.script)));
+ var dartDir =
+ p.dirname(p.dirname(p.dirname(p.dirname(p.fromUri(Platform.script)))));
+
+ var repoExample = p.join(toolDir, '..', '..', '..');
+ var patchExample =
+ p.join(dartDir, 'sdk', 'lib', '_internal', 'js_dev_runtime');
+ var outExample = p.relative(p.normalize(p.join('gen', 'patched_sdk')));
+
+ print('Usage: $self DART_REPO_DIR PATCH_DIR OUTPUT_DIR');
+ print('For example:');
+ print('\$ $self $repoExample $patchExample $outExample');
+ exit(1);
+ }
+
+ var sdk = 'sdk';
+ var useNnbd = false;
+ if (argv.length > 3) {
+ sdk = argv[3];
+
+ // TODO(38701): While the core libraries have been forked for NNBD, use the
+ // SDK directory name to determine whether to enable the NNBD experiment
+ // when parsing the lib sources. Once the libraries have been unforked, we
+ // should unconditionally enable the experiment flag since then the
+ // canonical SDK libs will use NNBD syntax.
+ useNnbd = sdk.contains("nnbd");
+ }
+
+ var selfModifyTime = File(self).lastModifiedSync().millisecondsSinceEpoch;
+
+ var repoDir = argv[0];
+ var patchDir = argv[1];
+ var sdkLibIn = p.join(repoDir, sdk, 'lib');
+ var patchIn = p.join(patchDir, 'patch');
+ var privateIn = p.join(patchDir, 'private');
+ var sdkOut = p.join(argv[2], 'lib');
+
+ var INTERNAL_PATH = '_internal/js_runtime/lib/';
+
+ // Copy libraries.dart and version
+ var librariesDart = p.join(patchDir, 'libraries.dart');
+ var libContents = File(librariesDart).readAsStringSync();
+ // TODO(jmesserly): can we remove this?
+ _writeSync(p.join(sdkOut, '_internal', 'libraries.dart'), libContents);
+ _writeSync(
+ p.join(
+ sdkOut, '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart'),
+ libContents);
+ _writeSync(p.join(sdkOut, '..', 'version'),
+ File(p.join(repoDir, 'tools', 'VERSION')).readAsStringSync());
+
+ // Parse libraries.dart
+ var sdkLibraries = _getSdkLibraries(libContents, useNnbd: useNnbd);
+
+ // Enumerate core libraries and apply patches
+ for (SdkLibrary library in sdkLibraries) {
+ // TODO(jmesserly): analyzer does not handle the default case of
+ // "both platforms" correctly, and treats it as being supported on neither.
+ // So instead we skip explicitly marked as VM libs.
+ if (library.isVmLibrary) continue;
+
+ var libraryOut = p.join(sdkLibIn, library.path);
+ var libraryOverride = p.join(patchDir, 'lib', library.path);
+ String libraryIn;
+ if (library.path.contains(INTERNAL_PATH)) {
+ libraryIn = p.join(privateIn, library.path.replaceAll(INTERNAL_PATH, ''));
+ } else if (File(libraryOverride).existsSync()) {
+ libraryIn = libraryOverride;
+ } else {
+ libraryIn = libraryOut;
+ }
+
+ var libraryFile = File(libraryIn);
+ if (libraryFile.existsSync()) {
+ var outPaths = <String>[libraryOut];
+ var libraryContents = libraryFile.readAsStringSync();
+
+ int inputModifyTime = math.max(selfModifyTime,
+ libraryFile.lastModifiedSync().millisecondsSinceEpoch);
+ var partFiles = <File>[];
+ for (var part
+ in _parseString(libraryContents, useNnbd: useNnbd).unit.directives) {
+ if (part is PartDirective) {
+ var partPath = part.uri.stringValue;
+ outPaths.add(p.join(p.dirname(libraryOut), partPath));
+
+ var partFile = File(p.join(p.dirname(libraryIn), partPath));
+ partFiles.add(partFile);
+ inputModifyTime = math.max(inputModifyTime,
+ partFile.lastModifiedSync().millisecondsSinceEpoch);
+ }
+ }
+
+ // See if we can find a patch file.
+ var patchPath = p.join(
+ patchIn, p.basenameWithoutExtension(libraryIn) + '_patch.dart');
+
+ var patchFile = File(patchPath);
+ bool patchExists = patchFile.existsSync();
+ if (patchExists) {
+ inputModifyTime = math.max(inputModifyTime,
+ patchFile.lastModifiedSync().millisecondsSinceEpoch);
+ }
+
+ // Compute output paths
+ outPaths = outPaths
+ .map((path) => p.join(sdkOut, p.relative(path, from: sdkLibIn)))
+ .toList();
+
+ // Compare output modify time with input modify time.
+ bool needsUpdate = false;
+ for (var outPath in outPaths) {
+ var outFile = File(outPath);
+ if (!outFile.existsSync() ||
+ outFile.lastModifiedSync().millisecondsSinceEpoch <
+ inputModifyTime) {
+ needsUpdate = true;
+ break;
+ }
+ }
+
+ if (needsUpdate) {
+ var contents = <String>[libraryContents];
+ contents.addAll(partFiles.map((f) => f.readAsStringSync()));
+ if (patchExists) {
+ var patchContents = patchFile.readAsStringSync();
+ contents = _patchLibrary(contents, patchContents, useNnbd: useNnbd);
+ }
+
+ if (contents != null) {
+ for (var i = 0; i < outPaths.length; i++) {
+ _writeSync(outPaths[i], contents[i]);
+ }
+ } else {
+ exitCode = 2;
+ }
+ }
+ }
+ }
+}
+
+/// Writes a file, creating the directory if needed.
+void _writeSync(String filePath, String contents) {
+ var outDir = Directory(p.dirname(filePath));
+ if (!outDir.existsSync()) outDir.createSync(recursive: true);
+
+ File(filePath).writeAsStringSync(contents);
+}
+
+/// Merges dart:* library code with code from *_patch.dart file.
+///
+/// Takes a list of the library's parts contents, with the main library contents
+/// first in the list, and the contents of the patch file.
+///
+/// The result will have `@patch` implementations merged into the correct place
+/// (e.g. the class or top-level function declaration) and all other
+/// declarations introduced by the patch will be placed into the main library
+/// file.
+///
+/// This is purely a syntactic transformation. Unlike dart2js patch files, there
+/// is no semantic meaning given to the *_patch files, and they do not magically
+/// get their own library scope, etc.
+///
+/// Editorializing: the dart2js approach requires a Dart front end such as
+/// package:analyzer to semantically model a feature beyond what is specified
+/// in the Dart language. Since this feature is only for the convenience of
+/// writing the dart:* libraries, and not a tool given to Dart developers, it
+/// seems like a non-ideal situation. Instead we keep the preprocessing simple.
+List<String> _patchLibrary(List<String> partsContents, String patchContents,
+ {bool useNnbd = false}) {
+ var results = <StringEditBuffer>[];
+
+ // Parse the patch first. We'll need to extract bits of this as we go through
+ // the other files.
+ var patchFinder = PatchFinder.parseAndVisit(patchContents, useNnbd: useNnbd);
+
+ // Merge `external` declarations with the corresponding `@patch` code.
+ bool failed = false;
+ for (var partContent in partsContents) {
+ var partEdits = StringEditBuffer(partContent);
+ var partUnit = _parseString(partContent, useNnbd: useNnbd).unit;
+ var patcher = PatchApplier(partEdits, patchFinder);
+ partUnit.accept(patcher);
+ if (!failed) failed = patcher.patchWasMissing;
+ results.add(partEdits);
+ }
+ if (failed) return null;
+ return List<String>.from(results.map((e) => e.toString()));
+}
+
+/// Merge `@patch` declarations into `external` declarations.
+class PatchApplier extends GeneralizingAstVisitor {
+ final StringEditBuffer edits;
+ final PatchFinder patch;
+
+ bool _isLibrary = true; // until proven otherwise.
+ bool patchWasMissing = false;
+
+ PatchApplier(this.edits, this.patch);
+
+ @override
+ visitCompilationUnit(CompilationUnit node) {
+ super.visitCompilationUnit(node);
+ if (_isLibrary) _mergeUnpatched(node);
+ }
+
+ void _merge(AstNode node, int pos) {
+ var code = patch.contents.substring(node.offset, node.end);
+ edits.insert(pos, '\n' + code);
+ }
+
+ /// Merges directives and declarations that are not `@patch` into the library.
+ void _mergeUnpatched(CompilationUnit unit) {
+ // Merge imports from the patch
+ // TODO(jmesserly): remove duplicate imports
+
+ // To patch a library, we must have a library directive
+ var libDir = unit.directives.first as LibraryDirective;
+ int importPos = unit.directives
+ .lastWhere((d) => d is ImportDirective, orElse: () => libDir)
+ .end;
+ for (var d in patch.unit.directives.whereType<ImportDirective>()) {
+ _merge(d, importPos);
+ }
+
+ int partPos = unit.directives.last.end;
+ for (var d in patch.unit.directives.whereType<PartDirective>()) {
+ _merge(d, partPos);
+ }
+
+ // Merge declarations from the patch
+ int declPos = edits.original.length;
+ for (var d in patch.mergeDeclarations) {
+ _merge(d, declPos);
+ }
+ }
+
+ @override
+ visitPartOfDirective(PartOfDirective node) {
+ _isLibrary = false;
+ }
+
+ @override
+ visitFunctionDeclaration(FunctionDeclaration node) {
+ _maybePatch(node);
+ }
+
+ /// Merge patches and extensions into the class
+ @override
+ visitClassDeclaration(ClassDeclaration node) {
+ node.members.forEach(_maybePatch);
+
+ var mergeMembers = patch.mergeMembers[_qualifiedName(node)];
+ if (mergeMembers == null) return;
+
+ // Merge members from the patch
+ var pos = node.members.last.end;
+ for (var member in mergeMembers) {
+ var code = patch.contents.substring(member.offset, member.end);
+ edits.insert(pos, '\n\n ' + code);
+ }
+ }
+
+ void _maybePatch(Declaration node) {
+ if (node is FieldDeclaration) return;
+
+ var externalKeyword = (node as dynamic).externalKeyword as Token;
+ if (externalKeyword == null) return;
+
+ var name = _qualifiedName(node);
+ var patchNode = patch.patches[name];
+ if (patchNode == null) {
+ print('warning: patch not found for $name: $node');
+ patchWasMissing = true;
+ return;
+ }
+
+ Annotation patchMeta = patchNode.metadata.lastWhere(_isPatchAnnotation);
+ int start = patchMeta.endToken.next.offset;
+ var code = patch.contents.substring(start, patchNode.end);
+
+ // Const factory constructors can't be legally parsed from the patch file,
+ // so we need to omit the "const" there, but still preserve it.
+ if (node is ConstructorDeclaration &&
+ node.constKeyword != null &&
+ patchNode is ConstructorDeclaration &&
+ patchNode.constKeyword == null) {
+ code = 'const $code';
+ }
+
+ // For some node like static fields, the node's offset doesn't include
+ // the external keyword. Also starting from the keyword lets us preserve
+ // documentation comments.
+ edits.replace(externalKeyword.offset, node.end, code);
+ }
+}
+
+class PatchFinder extends GeneralizingAstVisitor {
+ final String contents;
+ final CompilationUnit unit;
+
+ final patches = <String, Declaration>{};
+ final mergeMembers = <String, List<ClassMember>>{};
+ final mergeDeclarations = <CompilationUnitMember>[];
+
+ PatchFinder.parseAndVisit(String contents, {bool useNnbd})
+ : contents = contents,
+ unit = _parseString(contents, useNnbd: useNnbd).unit {
+ visitCompilationUnit(unit);
+ }
+
+ @override
+ visitCompilationUnitMember(CompilationUnitMember node) {
+ mergeDeclarations.add(node);
+ }
+
+ @override
+ visitClassDeclaration(ClassDeclaration node) {
+ if (_isPatch(node)) {
+ var members = <ClassMember>[];
+ for (var member in node.members) {
+ if (_isPatch(member)) {
+ patches[_qualifiedName(member)] = member;
+ } else {
+ members.add(member);
+ }
+ }
+ if (members.isNotEmpty) {
+ mergeMembers[_qualifiedName(node)] = members;
+ }
+ } else {
+ mergeDeclarations.add(node);
+ }
+ }
+
+ @override
+ visitFunctionDeclaration(FunctionDeclaration node) {
+ if (_isPatch(node)) {
+ patches[_qualifiedName(node)] = node;
+ } else {
+ mergeDeclarations.add(node);
+ }
+ }
+
+ @override
+ visitFunctionBody(node) {} // skip method bodies
+}
+
+String _qualifiedName(Declaration node) {
+ var result = "";
+
+ var parent = node.parent;
+ if (parent is ClassDeclaration) {
+ result = "${parent.name.name}.";
+ }
+
+ var name = (node as dynamic).name as SimpleIdentifier;
+ if (name != null) result += name.name;
+
+ // Make sure setters and getters don't collide.
+ if (node is FunctionDeclaration && node.isSetter ||
+ node is MethodDeclaration && node.isSetter) {
+ result += "=";
+ }
+
+ return result;
+}
+
+bool _isPatch(AnnotatedNode node) => node.metadata.any(_isPatchAnnotation);
+
+bool _isPatchAnnotation(Annotation m) =>
+ m.name.name == 'patch' && m.constructorName == null && m.arguments == null;
+
+/// Editable string buffer.
+///
+/// Applies a series of edits (insertions, removals, replacements) using
+/// original location information, and composes them into the edited string.
+///
+/// For example, starting with a parsed AST with original source locations,
+/// this type allows edits to be made without regards to other edits.
+class StringEditBuffer {
+ final String original;
+ final _edits = <_StringEdit>[];
+
+ /// Creates a new transaction.
+ StringEditBuffer(this.original);
+
+ bool get hasEdits => _edits.isNotEmpty;
+
+ /// Edit the original text, replacing text on the range [begin] and
+ /// exclusive [end] with the [replacement] string.
+ void replace(int begin, int end, String replacement) {
+ _edits.add(_StringEdit(begin, end, replacement));
+ }
+
+ /// Insert [string] at [offset].
+ /// Equivalent to `replace(offset, offset, string)`.
+ void insert(int offset, String string) => replace(offset, offset, string);
+
+ /// Remove text from the range [begin] to exclusive [end].
+ /// Equivalent to `replace(begin, end, '')`.
+ void remove(int begin, int end) => replace(begin, end, '');
+
+ /// Applies all pending [edit]s and returns a new string.
+ ///
+ /// This method is non-destructive: it does not discard existing edits or
+ /// change the [original] string. Further edits can be added and this method
+ /// can be called again.
+ ///
+ /// Throws [UnsupportedError] if the edits were overlapping. If no edits were
+ /// made, the original string will be returned.
+ @override
+ String toString() {
+ var sb = StringBuffer();
+ if (_edits.isEmpty) return original;
+
+ // Sort edits by start location.
+ _edits.sort();
+
+ int consumed = 0;
+ for (var edit in _edits) {
+ if (consumed > edit.begin) {
+ sb = StringBuffer();
+ sb.write('overlapping edits. Insert at offset ');
+ sb.write(edit.begin);
+ sb.write(' but have consumed ');
+ sb.write(consumed);
+ sb.write(' input characters. List of edits:');
+ for (var e in _edits) {
+ sb.write('\n ');
+ sb.write(e);
+ }
+ throw UnsupportedError(sb.toString());
+ }
+
+ // Add characters from the original string between this edit and the last
+ // one, if any.
+ var betweenEdits = original.substring(consumed, edit.begin);
+ sb.write(betweenEdits);
+ sb.write(edit.replace);
+ consumed = edit.end;
+ }
+
+ // Add any text from the end of the original string that was not replaced.
+ sb.write(original.substring(consumed));
+ return sb.toString();
+ }
+}
+
+class _StringEdit implements Comparable<_StringEdit> {
+ final int begin;
+ final int end;
+ final String replace;
+
+ _StringEdit(this.begin, this.end, this.replace);
+
+ int get length => end - begin;
+
+ @override
+ String toString() => '(Edit @ $begin,$end: "$replace")';
+
+ @override
+ int compareTo(_StringEdit other) {
+ int diff = begin - other.begin;
+ if (diff != 0) return diff;
+ return end - other.end;
+ }
+}
+
+List<SdkLibrary> _getSdkLibraries(String contents, {bool useNnbd}) {
+ // TODO(jmesserly): fix SdkLibrariesReader_LibraryBuilder in Analyzer.
+ // It doesn't understand optional new/const in Dart 2. For now, we keep
+ // redundant `const` in tool/input_sdk/libraries.dart as a workaround.
+ var libraryBuilder = SdkLibrariesReader_LibraryBuilder();
+ _parseString(contents, useNnbd: useNnbd).unit.accept(libraryBuilder);
+ return libraryBuilder.librariesMap.sdkLibraries;
+}
+
+ParseStringResult _parseString(String source, {bool useNnbd}) {
+ var features = FeatureSet.fromEnableFlags([if (useNnbd) "non-nullable"]);
+ return parseString(content: source, featureSet: features);
+}
diff --git a/pkg/dev_compiler/tool/patch_sdk.dart b/pkg/dev_compiler/tool/patch_sdk.dart
index 493dc1b..8235b75 100755
--- a/pkg/dev_compiler/tool/patch_sdk.dart
+++ b/pkg/dev_compiler/tool/patch_sdk.dart
@@ -7,169 +7,137 @@
/// This is currently designed as an offline tool, but we could automate it.
import 'dart:io';
-import 'dart:math' as math;
+import 'package:_fe_analyzer_shared/src/util/relativize.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/utilities.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/src/generated/sdk.dart';
-import 'package:path/path.dart' as p;
+import 'package:args/args.dart';
+import 'package:front_end/src/base/libraries_specification.dart';
+import 'package:front_end/src/fasta/resolve_input_uri.dart';
void main(List<String> argv) {
- var self = p.relative(p.fromUri(Platform.script));
- if (argv.length < 3) {
- var toolDir = p.relative(p.dirname(p.fromUri(Platform.script)));
- var dartDir =
- p.dirname(p.dirname(p.dirname(p.dirname(p.fromUri(Platform.script)))));
-
- var repoExample = p.join(toolDir, '..', '..', '..');
- var patchExample =
- p.join(dartDir, 'sdk', 'lib', '_internal', 'js_dev_runtime');
- var outExample = p.relative(p.normalize(p.join('gen', 'patched_sdk')));
-
- print('Usage: $self DART_REPO_DIR PATCH_DIR OUTPUT_DIR');
+ var args = _parser.parse(argv);
+ if (args['libraries'] == null || args['out'] == null) {
+ var self = relativizeUri(Uri.base, Platform.script, isWindows);
+ var librariesJson = relativizeUri(Uri.base,
+ Platform.script.resolve('../../../sdk/lib/libraries.json'), isWindows);
+ print('Usage: $self [other options]'
+ ' --libraries <libraries.json> --out <output-dir>');
print('For example:');
- print('\$ $self $repoExample $patchExample $outExample');
+ print('\$ $self --nnbd --libraries $librariesJson --out patched-sdk-dir');
exit(1);
}
- var sdk = 'sdk';
- var useNnbd = false;
- if (argv.length > 3) {
- sdk = argv[3];
+ var useNnbd = args['nnbd'] as bool;
+ var target = args['target'] as String;
+ var jsonUri = resolveInputUri(args['libraries'] as String);
+ var libRoot = jsonUri.resolve('./');
+ var outPath = args['out'] as String;
+ var outDir = resolveInputUri(outPath.endsWith('/') ? outPath : '$outPath/');
+ var outLibRoot = outDir.resolve('lib/');
- // TODO(38701): While the core libraries have been forked for NNBD, use the
- // SDK directory name to determine whether to enable the NNBD experiment
- // when parsing the lib sources. Once the libraries have been unforked, we
- // should unconditionally enable the experiment flag since then the
- // canonical SDK libs will use NNBD syntax.
- useNnbd = sdk.contains("nnbd");
- }
+ var inputVersion = Platform.script.resolve('../../../tools/VERSION');
+ var outVersion = outDir.resolve('version');
- var selfModifyTime = File(self).lastModifiedSync().millisecondsSinceEpoch;
-
- var repoDir = argv[0];
- var patchDir = argv[1];
- var sdkLibIn = p.join(repoDir, sdk, 'lib');
- var patchIn = p.join(patchDir, 'patch');
- var privateIn = p.join(patchDir, 'private');
- var sdkOut = p.join(argv[2], 'lib');
-
- var INTERNAL_PATH = '_internal/js_runtime/lib/';
+ var specification = LibrariesSpecification.parse(
+ jsonUri, File.fromUri(jsonUri).readAsStringSync())
+ .specificationFor(target);
// Copy libraries.dart and version
- var librariesDart = p.join(patchDir, 'libraries.dart');
- var libContents = File(librariesDart).readAsStringSync();
- // TODO(jmesserly): can we remove this?
- _writeSync(p.join(sdkOut, '_internal', 'libraries.dart'), libContents);
- _writeSync(
- p.join(
- sdkOut, '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart'),
- libContents);
- _writeSync(p.join(sdkOut, '..', 'version'),
- File(p.join(repoDir, 'tools', 'VERSION')).readAsStringSync());
+ _writeSync(outVersion, File.fromUri(inputVersion).readAsStringSync());
- // Parse libraries.dart
- var sdkLibraries = _getSdkLibraries(libContents, useNnbd: useNnbd);
-
- // Enumerate core libraries and apply patches
- for (SdkLibrary library in sdkLibraries) {
- // TODO(jmesserly): analyzer does not handle the default case of
- // "both platforms" correctly, and treats it as being supported on neither.
- // So instead we skip explicitly marked as VM libs.
- if (library.isVmLibrary) continue;
-
- var libraryOut = p.join(sdkLibIn, library.path);
- var libraryOverride = p.join(patchDir, 'lib', library.path);
- String libraryIn;
- if (library.path.contains(INTERNAL_PATH)) {
- libraryIn = p.join(privateIn, library.path.replaceAll(INTERNAL_PATH, ''));
- } else if (File(libraryOverride).existsSync()) {
- libraryIn = libraryOverride;
- } else {
- libraryIn = libraryOut;
- }
-
- var libraryFile = File(libraryIn);
+ // Enumerate sdk libraries and apply patches
+ for (var library in specification.allLibraries) {
+ var libraryFile = File.fromUri(library.uri);
+ var libraryOut =
+ outLibRoot.resolve(relativizeLibraryUri(libRoot, library.uri, useNnbd));
if (libraryFile.existsSync()) {
- var outPaths = <String>[libraryOut];
+ var outUris = <Uri>[libraryOut];
var libraryContents = libraryFile.readAsStringSync();
+ var contents = <String>[libraryContents];
- int inputModifyTime = math.max(selfModifyTime,
- libraryFile.lastModifiedSync().millisecondsSinceEpoch);
- var partFiles = <File>[];
for (var part
in _parseString(libraryContents, useNnbd: useNnbd).unit.directives) {
if (part is PartDirective) {
var partPath = part.uri.stringValue;
- outPaths.add(p.join(p.dirname(libraryOut), partPath));
-
- var partFile = File(p.join(p.dirname(libraryIn), partPath));
- partFiles.add(partFile);
- inputModifyTime = math.max(inputModifyTime,
- partFile.lastModifiedSync().millisecondsSinceEpoch);
+ outUris.add(libraryOut.resolve(partPath));
+ contents.add(
+ File.fromUri(library.uri.resolve(partPath)).readAsStringSync());
}
}
- // See if we can find a patch file.
- var patchPath = p.join(
- patchIn, p.basenameWithoutExtension(libraryIn) + '_patch.dart');
-
- var patchFile = File(patchPath);
- bool patchExists = patchFile.existsSync();
- if (patchExists) {
- inputModifyTime = math.max(inputModifyTime,
- patchFile.lastModifiedSync().millisecondsSinceEpoch);
+ if (args['merge-parts'] as bool && outUris.length > 1) {
+ outUris.length = 1;
+ contents = [
+ contents
+ .join('\n')
+ .replaceAll(RegExp("^part [^\n]*\$", multiLine: true), "")
+ ];
}
- // Compute output paths
- outPaths = outPaths
- .map((path) => p.join(sdkOut, p.relative(path, from: sdkLibIn)))
- .toList();
+ var buffer = StringBuffer();
+ for (var patchUri in library.patches) {
+ // Note: VM targets enumerate more than one patch file, they are
+ // currently written so that the first file is a valid patch file and
+ // all other files can be appended at the end.
+ buffer.write(File.fromUri(patchUri).readAsStringSync());
+ }
+ var patchContents = '$buffer';
- // Compare output modify time with input modify time.
- bool needsUpdate = false;
- for (var outPath in outPaths) {
- var outFile = File(outPath);
- if (!outFile.existsSync() ||
- outFile.lastModifiedSync().millisecondsSinceEpoch <
- inputModifyTime) {
- needsUpdate = true;
- break;
- }
+ if (patchContents.isNotEmpty) {
+ contents = _patchLibrary(contents, patchContents, useNnbd: useNnbd);
}
- if (needsUpdate) {
- var contents = <String>[libraryContents];
- contents.addAll(partFiles.map((f) => f.readAsStringSync()));
- if (patchExists) {
- var patchContents = patchFile.readAsStringSync();
- contents = _patchLibrary(contents, patchContents, useNnbd: useNnbd);
+ if (contents != null) {
+ for (var i = 0; i < outUris.length; i++) {
+ _writeSync(outUris[i], contents[i]);
}
-
- if (contents != null) {
- for (var i = 0; i < outPaths.length; i++) {
- _writeSync(outPaths[i], contents[i]);
- }
- } else {
- exitCode = 2;
- }
+ } else {
+ exitCode = 2;
}
}
}
+
+ var outLibrariesDart =
+ outLibRoot.resolve('_internal/sdk_library_metadata/lib/libraries.dart');
+ _writeSync(outLibrariesDart,
+ _generateLibrariesDart(libRoot, specification, useNnbd));
}
/// Writes a file, creating the directory if needed.
-void _writeSync(String filePath, String contents) {
- var outDir = Directory(p.dirname(filePath));
+void _writeSync(Uri fileUri, String contents) {
+ var outDir = Directory.fromUri(fileUri.resolve('.'));
if (!outDir.existsSync()) outDir.createSync(recursive: true);
- File(filePath).writeAsStringSync(contents);
+ File.fromUri(fileUri).writeAsStringSync(contents);
}
+final _parser = ArgParser()
+ ..addFlag('nnbd',
+ help: 'Whether to enable the nnbd feature.', defaultsTo: false)
+ ..addFlag('merge-parts',
+ help: 'Whether to merge part files. '
+ 'Technically this is not necessary, but dartanalyzer '
+ 'produces less warnings when enabling this flag.',
+ defaultsTo: false)
+ ..addOption('libraries',
+ help: 'Path to a libraries.json specification file (required). '
+ 'All libary URIs within libraries.json are expected to be somewhere '
+ 'under the directory containing the libraries.json file. Reaching '
+ 'out above such directory is generally not supported. Today it is '
+ 'only allowed for the nnbd sdk to reuse libraries of the non-nnbd '
+ 'sdk, in which case the path starts with "../../sdk/lib/".')
+ ..addOption('out', help: 'Path to an output folder (required).')
+ ..addOption('target',
+ help: 'The target tool. '
+ 'This name matches one of the possible targets in libraries.json '
+ 'and it is used to pick which patch files will be applied.',
+ allowed: ['dartdevc', 'dart2js', 'dart2js_server', 'vm', 'flutter']);
+
/// Merges dart:* library code with code from *_patch.dart file.
///
/// Takes a list of the library's parts contents, with the main library contents
@@ -490,16 +458,142 @@
}
}
-List<SdkLibrary> _getSdkLibraries(String contents, {bool useNnbd}) {
- // TODO(jmesserly): fix SdkLibrariesReader_LibraryBuilder in Analyzer.
- // It doesn't understand optional new/const in Dart 2. For now, we keep
- // redundant `const` in tool/input_sdk/libraries.dart as a workaround.
- var libraryBuilder = SdkLibrariesReader_LibraryBuilder();
- _parseString(contents, useNnbd: useNnbd).unit.accept(libraryBuilder);
- return libraryBuilder.librariesMap.sdkLibraries;
-}
-
ParseStringResult _parseString(String source, {bool useNnbd}) {
var features = FeatureSet.fromEnableFlags([if (useNnbd) "non-nullable"]);
return parseString(content: source, featureSet: features);
}
+
+/// Use the data from a libraries.json specification to generate the contents
+/// of `sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart`, which is
+/// needed by dartdevc-legacy and dartanalyzer.
+String _generateLibrariesDart(
+ Uri libBaseUri, TargetLibrariesSpecification specification, bool usdNnbd) {
+ var contents = StringBuffer();
+ contents.write(_LIBRARIES_DART_PREFIX);
+ for (var library in specification.allLibraries) {
+ var path = relativizeLibraryUri(libBaseUri, library.uri, usdNnbd);
+ contents.write(' "${library.name}": \n'
+ ' const LibraryInfo("$path",\n'
+ ' categories: "Client,Server"),\n');
+ }
+ contents.write(_LIBRARIES_DART_SUFFIX);
+ return '$contents';
+}
+
+String relativizeLibraryUri(Uri libRoot, Uri uri, bool useNnbd) {
+ String relativePath = relativizeUri(libRoot, uri, isWindows);
+ // During the nnbd-migration we may have paths that reach out into the
+ // non-nnbd directory.
+ if (relativePath.startsWith("..")) {
+ if (!useNnbd || !relativePath.startsWith('../../sdk/lib/')) {
+ print("error: can't handle libraries that live out of the sdk folder"
+ ": $relativePath");
+ exit(1);
+ }
+ relativePath = relativePath.replaceFirst('../../sdk/lib/', '');
+ }
+ return relativePath;
+}
+
+final _LIBRARIES_DART_PREFIX = r'''
+library libraries;
+
+const int DART2JS_PLATFORM = 1;
+const int VM_PLATFORM = 2;
+
+enum Category { client, server, embedded }
+
+Category parseCategory(String name) {
+ switch (name) {
+ case "Client":
+ return Category.client;
+ case "Server":
+ return Category.server;
+ case "Embedded":
+ return Category.embedded;
+ }
+ return null;
+}
+
+const Map<String, LibraryInfo> libraries = const {
+''';
+
+final _LIBRARIES_DART_SUFFIX = r'''
+};
+
+class LibraryInfo {
+ final String path;
+ final String _categories;
+ final String dart2jsPath;
+ final String dart2jsPatchPath;
+ final bool documented;
+ final int platforms;
+ final bool implementation;
+ final Maturity maturity;
+
+ const LibraryInfo(this.path,
+ {String categories: "",
+ this.dart2jsPath,
+ this.dart2jsPatchPath,
+ this.implementation: false,
+ this.documented: true,
+ this.maturity: Maturity.UNSPECIFIED,
+ this.platforms: DART2JS_PLATFORM | VM_PLATFORM})
+ : _categories = categories;
+
+ bool get isDart2jsLibrary => (platforms & DART2JS_PLATFORM) != 0;
+ bool get isVmLibrary => (platforms & VM_PLATFORM) != 0;
+ List<Category> get categories {
+ // `"".split(,)` returns [""] not [], so we handle that case separately.
+ if (_categories == "") return const <Category>[];
+ return _categories.split(",").map(parseCategory).toList();
+ }
+
+ bool get isInternal => categories.isEmpty;
+ String get categoriesString => _categories;
+}
+
+class Maturity {
+ final int level;
+ final String name;
+ final String description;
+
+ const Maturity(this.level, this.name, this.description);
+
+ String toString() => "$name: $level\n$description\n";
+
+ static const Maturity DEPRECATED = const Maturity(0, "Deprecated",
+ "This library will be remove before next major release.");
+
+ static const Maturity EXPERIMENTAL = const Maturity(
+ 1,
+ "Experimental",
+ "This library is experimental and will likely change or be removed\n"
+ "in future versions.");
+
+ static const Maturity UNSTABLE = const Maturity(
+ 2,
+ "Unstable",
+ "This library is in still changing and have not yet endured\n"
+ "sufficient real-world testing.\n"
+ "Backwards-compatibility is NOT guaranteed.");
+
+ static const Maturity WEB_STABLE = const Maturity(
+ 3,
+ "Web Stable",
+ "This library is tracking the DOM evolution as defined by WC3.\n"
+ "Backwards-compatibility is NOT guaranteed.");
+
+ static const Maturity STABLE = const Maturity(
+ 4,
+ "Stable",
+ "The library is stable. API backwards-compatibility is guaranteed.\n"
+ "However implementation details might change.");
+
+ static const Maturity LOCKED = const Maturity(5, "Locked",
+ "This library will not change except when serious bugs are encountered.");
+
+ static const Maturity UNSPECIFIED = const Maturity(-1, "Unspecified",
+ "The maturity for this library has not been specified.");
+}
+''';
diff --git a/pkg/front_end/lib/src/api_unstable/ddc.dart b/pkg/front_end/lib/src/api_unstable/ddc.dart
index 1f39033..bd2044e 100644
--- a/pkg/front_end/lib/src/api_unstable/ddc.dart
+++ b/pkg/front_end/lib/src/api_unstable/ddc.dart
@@ -120,19 +120,6 @@
equalMaps(oldState.options.experimentalFlags, experiments) &&
equalMaps(oldState.options.environmentDefines, environmentDefines)) {
// Reuse old state.
-
- // These libraries are marked external when compiling. If not un-marking
- // them compilation will fail.
- // Remove once [kernel_generator_impl.dart] no longer marks the libraries
- // as external.
- (await oldState.processedOpts.loadSdkSummary(null))
- .libraries
- // ignore: DEPRECATED_MEMBER_USE
- .forEach((lib) => lib.isExternal = false);
- (await oldState.processedOpts.loadInputSummaries(null))
- // ignore: DEPRECATED_MEMBER_USE
- .forEach((p) => p.libraries.forEach((lib) => lib.isExternal = false));
-
return oldState;
}
diff --git a/pkg/front_end/lib/src/external_state_snapshot.dart b/pkg/front_end/lib/src/external_state_snapshot.dart
deleted file mode 100644
index c49ce26..0000000
--- a/pkg/front_end/lib/src/external_state_snapshot.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2017, 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.
-
-// TODO(ahe): Remove this file.
-
-import 'package:kernel/kernel.dart' show Library, Component;
-
-/// Helper class to work around modifications in [kernel_generator_impl.dart].
-class ExternalStateSnapshot {
- final List<ExternalState> snapshots;
-
- ExternalStateSnapshot(Component component)
- : snapshots = new List<ExternalState>.from(
- // ignore: DEPRECATED_MEMBER_USE
- component.libraries.map((l) => new ExternalState(l, l.isExternal)));
-
- void restore() {
- for (ExternalState state in snapshots) {
- state.restore();
- }
- }
-}
-
-class ExternalState {
- final Library library;
- final bool isExternal;
-
- ExternalState(this.library, this.isExternal);
-
- void restore() {
- // ignore: DEPRECATED_MEMBER_USE
- library.isExternal = isExternal;
- }
-}
diff --git a/pkg/front_end/lib/src/fasta/builder/class_builder.dart b/pkg/front_end/lib/src/fasta/builder/class_builder.dart
index 8c3c529..3bfa5c7 100644
--- a/pkg/front_end/lib/src/fasta/builder/class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/class_builder.dart
@@ -39,8 +39,6 @@
import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
-import 'package:kernel/clone.dart' show CloneWithoutBody;
-
import 'package:kernel/core_types.dart' show CoreTypes;
import 'package:kernel/src/bounds_checks.dart'
@@ -54,9 +52,6 @@
import 'package:kernel/type_algebra.dart' show Substitution, substitute;
-import 'package:kernel/type_algebra.dart' as type_algebra
- show getSubstitutionMap;
-
import 'package:kernel/type_environment.dart'
show SubtypeCheckMode, TypeEnvironment;
@@ -75,7 +70,6 @@
messagePatchDeclarationMismatch,
messagePatchDeclarationOrigin,
noLength,
- templateDuplicatedDeclarationUse,
templateGenericFunctionTypeInferredAsActualTypeArgument,
templateImplementsRepeated,
templateImplementsSuperClass,
@@ -100,11 +94,9 @@
templateOverrideTypeMismatchSetter,
templateOverrideTypeVariablesMismatch,
templateRedirectingFactoryIncompatibleTypeArgument,
- templateRedirectionTargetNotFound,
templateTypeArgumentMismatch;
-import '../kernel/redirecting_factory_body.dart'
- show getRedirectingFactoryBody, RedirectingFactoryBody;
+import '../kernel/redirecting_factory_body.dart' show getRedirectingFactoryBody;
import '../kernel/kernel_target.dart' show KernelTarget;
@@ -114,8 +106,7 @@
import '../names.dart' show noSuchMethodName;
-import '../problems.dart'
- show internalProblem, unexpected, unhandled, unimplemented;
+import '../problems.dart' show internalProblem, unhandled, unimplemented;
import '../scope.dart';
@@ -178,7 +169,7 @@
List<ConstructorReferenceBuilder> get constructorReferences;
- void buildOutlineExpressions(LibraryBuilder library);
+ void buildOutlineExpressions(LibraryBuilder library, CoreTypes coreTypes);
/// Registers a constructor redirection for this class and returns true if
/// this redirection gives rise to a cycle that has not been reported before.
@@ -264,19 +255,6 @@
void transformProcedureToNoSuchMethodForwarder(
Member noSuchMethodInterface, KernelTarget target, Procedure procedure);
- void addNoSuchMethodForwarderForProcedure(Member noSuchMethod,
- KernelTarget target, Procedure procedure, ClassHierarchy hierarchy);
-
- void addNoSuchMethodForwarderGetterForField(Member noSuchMethod,
- KernelTarget target, Field field, ClassHierarchy hierarchy);
-
- void addNoSuchMethodForwarderSetterForField(Member noSuchMethod,
- KernelTarget target, Field field, ClassHierarchy hierarchy);
-
- /// Adds noSuchMethod forwarding stubs to this class. Returns `true` if the
- /// class was modified.
- bool addNoSuchMethodForwarders(KernelTarget target, ClassHierarchy hierarchy);
-
/// Returns whether a covariant parameter was seen and more methods thus have
/// to be checked.
bool checkMethodOverride(Types types, Procedure declaredMember,
@@ -296,7 +274,7 @@
Message message, int fileOffset, int length,
{List<LocatedMessage> context});
- void checkMixinApplication(ClassHierarchy hierarchy);
+ void checkMixinApplication(ClassHierarchy hierarchy, CoreTypes coreTypes);
// Computes the function type of a given redirection target. Returns [null] if
// the type of the target could not be computed.
@@ -431,10 +409,10 @@
List<ConstructorReferenceBuilder> get constructorReferences => null;
@override
- void buildOutlineExpressions(LibraryBuilder library) {
+ void buildOutlineExpressions(LibraryBuilder library, CoreTypes coreTypes) {
void build(String ignore, Builder declaration) {
MemberBuilder member = declaration;
- member.buildOutlineExpressions(library);
+ member.buildOutlineExpressions(library, coreTypes);
}
MetadataBuilder.buildAnnotations(
@@ -461,93 +439,6 @@
}
@override
- int resolveConstructors(LibraryBuilder library) {
- if (constructorReferences == null) return 0;
- for (ConstructorReferenceBuilder ref in constructorReferences) {
- ref.resolveIn(scope, library);
- }
- int count = constructorReferences.length;
- if (count != 0) {
- Map<String, MemberBuilder> constructors = this.constructors.local;
- // Copy keys to avoid concurrent modification error.
- List<String> names = constructors.keys.toList();
- for (String name in names) {
- Builder declaration = constructors[name];
- do {
- if (declaration.parent != this) {
- unexpected("$fileUri", "${declaration.parent.fileUri}", charOffset,
- fileUri);
- }
- if (declaration is RedirectingFactoryBuilder) {
- // Compute the immediate redirection target, not the effective.
- ConstructorReferenceBuilder redirectionTarget =
- declaration.redirectionTarget;
- if (redirectionTarget != null) {
- Builder targetBuilder = redirectionTarget.target;
- if (declaration.next == null) {
- // Only the first one (that is, the last on in the linked list)
- // is actually in the kernel tree. This call creates a StaticGet
- // to [declaration.target] in a field `_redirecting#` which is
- // only legal to do to things in the kernel tree.
- addRedirectingConstructor(declaration, library);
- }
- if (targetBuilder is FunctionBuilder) {
- List<DartType> typeArguments = declaration.typeArguments;
- if (typeArguments == null) {
- // TODO(32049) If type arguments aren't specified, they should
- // be inferred. Currently, the inference is not performed.
- // The code below is a workaround.
- typeArguments = new List<DartType>.filled(
- targetBuilder.member.enclosingClass.typeParameters.length,
- const DynamicType(),
- growable: true);
- }
- declaration.setRedirectingFactoryBody(
- targetBuilder.member, typeArguments);
- } else if (targetBuilder is DillMemberBuilder) {
- List<DartType> typeArguments = declaration.typeArguments;
- if (typeArguments == null) {
- // TODO(32049) If type arguments aren't specified, they should
- // be inferred. Currently, the inference is not performed.
- // The code below is a workaround.
- typeArguments = new List<DartType>.filled(
- targetBuilder.member.enclosingClass.typeParameters.length,
- const DynamicType(),
- growable: true);
- }
- declaration.setRedirectingFactoryBody(
- targetBuilder.member, typeArguments);
- } else if (targetBuilder is AmbiguousBuilder) {
- addProblem(
- templateDuplicatedDeclarationUse
- .withArguments(redirectionTarget.fullNameForErrors),
- redirectionTarget.charOffset,
- noLength);
- // CoreTypes aren't computed yet, and this is the outline
- // phase. So we can't and shouldn't create a method body.
- declaration.body = new RedirectingFactoryBody.unresolved(
- redirectionTarget.fullNameForErrors);
- } else {
- addProblem(
- templateRedirectionTargetNotFound
- .withArguments(redirectionTarget.fullNameForErrors),
- redirectionTarget.charOffset,
- noLength);
- // CoreTypes aren't computed yet, and this is the outline
- // phase. So we can't and shouldn't create a method body.
- declaration.body = new RedirectingFactoryBody.unresolved(
- redirectionTarget.fullNameForErrors);
- }
- }
- }
- declaration = declaration.next;
- } while (declaration != null);
- }
- }
- return count;
- }
-
- @override
Builder findStaticBuilder(
String name, int charOffset, Uri fileUri, LibraryBuilder accessingLibrary,
{bool isSetter: false}) {
@@ -818,7 +709,7 @@
if (argument is FunctionType && argument.typeParameters.length > 0) {
if (inferred) {
message = templateGenericFunctionTypeInferredAsActualTypeArgument
- .withArguments(argument);
+ .withArguments(argument, library.isNonNullableByDefault);
} else {
message = messageGenericFunctionTypeUsedAsActualTypeArgument;
}
@@ -832,7 +723,8 @@
typeParameter.name,
getGenericTypeName(issue.enclosingType),
supertype.classNode.name,
- name);
+ name,
+ library.isNonNullableByDefault);
} else {
message = templateIncorrectTypeArgumentInSupertype.withArguments(
argument,
@@ -840,7 +732,8 @@
typeParameter.name,
getGenericTypeName(issue.enclosingType),
supertype.classNode.name,
- name);
+ name,
+ library.isNonNullableByDefault);
}
}
@@ -881,7 +774,8 @@
argument,
typeParameter.bound,
typeParameter.name,
- getGenericTypeName(issue.enclosingType));
+ getGenericTypeName(issue.enclosingType),
+ library.isNonNullableByDefault);
}
library.reportTypeArgumentIssue(
@@ -1183,189 +1077,6 @@
procedure.isForwardingSemiStub = false;
}
- @override
- void addNoSuchMethodForwarderForProcedure(Member noSuchMethod,
- KernelTarget target, Procedure procedure, ClassHierarchy hierarchy) {
- CloneWithoutBody cloner = new CloneWithoutBody(
- typeSubstitution: type_algebra.getSubstitutionMap(
- hierarchy.getClassAsInstanceOf(cls, procedure.enclosingClass)),
- cloneAnnotations: false);
- Procedure cloned = cloner.clone(procedure)..isExternal = false;
- transformProcedureToNoSuchMethodForwarder(noSuchMethod, target, cloned);
- cls.procedures.add(cloned);
- cloned.parent = cls;
-
- SourceLibraryBuilder library = this.library;
- library.forwardersOrigins.add(cloned);
- library.forwardersOrigins.add(procedure);
- }
-
- @override
- void addNoSuchMethodForwarderGetterForField(Member noSuchMethod,
- KernelTarget target, Field field, ClassHierarchy hierarchy) {
- Substitution substitution = Substitution.fromSupertype(
- hierarchy.getClassAsInstanceOf(cls, field.enclosingClass));
- Procedure getter = new Procedure(
- field.name,
- ProcedureKind.Getter,
- new FunctionNode(null,
- typeParameters: <TypeParameter>[],
- positionalParameters: <VariableDeclaration>[],
- namedParameters: <VariableDeclaration>[],
- requiredParameterCount: 0,
- returnType: substitution.substituteType(field.type)),
- fileUri: field.fileUri)
- ..fileOffset = field.fileOffset;
- transformProcedureToNoSuchMethodForwarder(noSuchMethod, target, getter);
- cls.procedures.add(getter);
- getter.parent = cls;
- }
-
- @override
- void addNoSuchMethodForwarderSetterForField(Member noSuchMethod,
- KernelTarget target, Field field, ClassHierarchy hierarchy) {
- Substitution substitution = Substitution.fromSupertype(
- hierarchy.getClassAsInstanceOf(cls, field.enclosingClass));
- Procedure setter = new Procedure(
- field.name,
- ProcedureKind.Setter,
- new FunctionNode(null,
- typeParameters: <TypeParameter>[],
- positionalParameters: <VariableDeclaration>[
- new VariableDeclaration("value",
- type: substitution.substituteType(field.type))
- ],
- namedParameters: <VariableDeclaration>[],
- requiredParameterCount: 1,
- returnType: const VoidType()),
- fileUri: field.fileUri)
- ..fileOffset = field.fileOffset;
- transformProcedureToNoSuchMethodForwarder(noSuchMethod, target, setter);
- cls.procedures.add(setter);
- setter.parent = cls;
- }
-
- @override
- bool addNoSuchMethodForwarders(
- KernelTarget target, ClassHierarchy hierarchy) {
- if (cls.isAbstract) return false;
-
- Set<Name> existingForwardersNames = new Set<Name>();
- Set<Name> existingSetterForwardersNames = new Set<Name>();
- Class leastConcreteSuperclass = cls.superclass;
- while (
- leastConcreteSuperclass != null && leastConcreteSuperclass.isAbstract) {
- leastConcreteSuperclass = leastConcreteSuperclass.superclass;
- }
- if (leastConcreteSuperclass != null) {
- bool superHasUserDefinedNoSuchMethod = hasUserDefinedNoSuchMethod(
- leastConcreteSuperclass, hierarchy, target.objectClass);
- List<Member> concrete =
- hierarchy.getDispatchTargets(leastConcreteSuperclass);
- for (Member member
- in hierarchy.getInterfaceMembers(leastConcreteSuperclass)) {
- if ((superHasUserDefinedNoSuchMethod ||
- leastConcreteSuperclass.enclosingLibrary.compareTo(
- member.enclosingClass.enclosingLibrary) !=
- 0 &&
- member.name.isPrivate) &&
- ClassHierarchy.findMemberByName(concrete, member.name) == null) {
- existingForwardersNames.add(member.name);
- }
- }
-
- List<Member> concreteSetters =
- hierarchy.getDispatchTargets(leastConcreteSuperclass, setters: true);
- for (Member member in hierarchy
- .getInterfaceMembers(leastConcreteSuperclass, setters: true)) {
- if (ClassHierarchy.findMemberByName(concreteSetters, member.name) ==
- null) {
- existingSetterForwardersNames.add(member.name);
- }
- }
- }
-
- Member noSuchMethod = ClassHierarchy.findMemberByName(
- hierarchy.getInterfaceMembers(cls), noSuchMethodName);
-
- List<Member> concrete = hierarchy.getDispatchTargets(cls);
- List<Member> declared = hierarchy.getDeclaredMembers(cls);
-
- bool clsHasUserDefinedNoSuchMethod =
- hasUserDefinedNoSuchMethod(cls, hierarchy, target.objectClass);
- bool changed = false;
- for (Member member in hierarchy.getInterfaceMembers(cls)) {
- // We generate a noSuchMethod forwarder for [member] in [cls] if the
- // following three conditions are satisfied simultaneously:
- // 1) There is a user-defined noSuchMethod in [cls] or [member] is private
- // and the enclosing library of [member] is different from that of
- // [cls].
- // 2) There is no implementation of [member] in [cls].
- // 3) The superclass of [cls] has no forwarder for [member].
- if (member is Procedure &&
- (clsHasUserDefinedNoSuchMethod ||
- cls.enclosingLibrary
- .compareTo(member.enclosingClass.enclosingLibrary) !=
- 0 &&
- member.name.isPrivate) &&
- ClassHierarchy.findMemberByName(concrete, member.name) == null &&
- !existingForwardersNames.contains(member.name)) {
- if (ClassHierarchy.findMemberByName(declared, member.name) != null) {
- transformProcedureToNoSuchMethodForwarder(
- noSuchMethod, target, member);
- } else {
- addNoSuchMethodForwarderForProcedure(
- noSuchMethod, target, member, hierarchy);
- }
- existingForwardersNames.add(member.name);
- changed = true;
- continue;
- }
-
- if (member is Field &&
- ClassHierarchy.findMemberByName(concrete, member.name) == null &&
- !existingForwardersNames.contains(member.name)) {
- addNoSuchMethodForwarderGetterForField(
- noSuchMethod, target, member, hierarchy);
- existingForwardersNames.add(member.name);
- changed = true;
- }
- }
-
- List<Member> concreteSetters =
- hierarchy.getDispatchTargets(cls, setters: true);
- List<Member> declaredSetters =
- hierarchy.getDeclaredMembers(cls, setters: true);
- for (Member member in hierarchy.getInterfaceMembers(cls, setters: true)) {
- if (member is Procedure &&
- ClassHierarchy.findMemberByName(concreteSetters, member.name) ==
- null &&
- !existingSetterForwardersNames.contains(member.name)) {
- if (ClassHierarchy.findMemberByName(declaredSetters, member.name) !=
- null) {
- transformProcedureToNoSuchMethodForwarder(
- noSuchMethod, target, member);
- } else {
- addNoSuchMethodForwarderForProcedure(
- noSuchMethod, target, member, hierarchy);
- }
- existingSetterForwardersNames.add(member.name);
- changed = true;
- }
- if (member is Field &&
- ClassHierarchy.findMemberByName(concreteSetters, member.name) ==
- null &&
- !existingSetterForwardersNames.contains(member.name)) {
- addNoSuchMethodForwarderSetterForField(
- noSuchMethod, target, member, hierarchy);
- existingSetterForwardersNames.add(member.name);
- changed = true;
- }
- }
-
- return changed;
- }
-
Uri _getMemberUri(Member member) {
if (member is Field) return member.fileUri;
if (member is Procedure) return member.fileUri;
@@ -1383,8 +1094,11 @@
bool isInterfaceCheck) {
Substitution interfaceSubstitution = Substitution.empty;
if (interfaceMember.enclosingClass.typeParameters.isNotEmpty) {
- interfaceSubstitution = Substitution.fromInterfaceType(types.hierarchy
- .getKernelTypeAsInstanceOf(thisType, interfaceMember.enclosingClass));
+ Class enclosingClass = interfaceMember.enclosingClass;
+ interfaceSubstitution = Substitution.fromPairs(
+ enclosingClass.typeParameters,
+ types.hierarchy
+ .getKernelTypeArgumentsAsInstanceOf(thisType, enclosingClass));
}
if (declaredFunction?.typeParameters?.length !=
interfaceFunction?.typeParameters?.length) {
@@ -1455,8 +1169,11 @@
Types types, Member declaredMember) {
Substitution declaredSubstitution = Substitution.empty;
if (declaredMember.enclosingClass.typeParameters.isNotEmpty) {
- declaredSubstitution = Substitution.fromInterfaceType(types.hierarchy
- .getKernelTypeAsInstanceOf(thisType, declaredMember.enclosingClass));
+ Class enclosingClass = declaredMember.enclosingClass;
+ declaredSubstitution = Substitution.fromPairs(
+ enclosingClass.typeParameters,
+ types.hierarchy
+ .getKernelTypeArgumentsAsInstanceOf(thisType, enclosingClass));
}
return declaredSubstitution;
}
@@ -1510,13 +1227,15 @@
declaredMemberName,
declaredType,
interfaceType,
- interfaceMemberName);
+ interfaceMemberName,
+ library.isNonNullableByDefault);
} else {
message = templateOverrideTypeMismatchReturnType.withArguments(
declaredMemberName,
declaredType,
interfaceType,
- interfaceMemberName);
+ interfaceMemberName,
+ library.isNonNullableByDefault);
}
fileOffset = declaredMember.fileOffset;
} else {
@@ -1525,7 +1244,8 @@
declaredMemberName,
declaredType,
interfaceType,
- interfaceMemberName);
+ interfaceMemberName,
+ library.isNonNullableByDefault);
fileOffset = declaredParameter.fileOffset;
}
reportInvalidOverride(
@@ -1820,7 +1540,7 @@
}
@override
- void checkMixinApplication(ClassHierarchy hierarchy) {
+ void checkMixinApplication(ClassHierarchy hierarchy, CoreTypes coreTypes) {
// A mixin declaration can only be applied to a class that implements all
// the declaration's superclass constraints.
InterfaceType supertype = cls.supertype.asInterfaceType;
@@ -1828,11 +1548,15 @@
for (Supertype constraint in cls.mixedInClass.superclassConstraints()) {
InterfaceType interface =
substitution.substituteSupertype(constraint).asInterfaceType;
- if (hierarchy.getTypeAsInstanceOf(supertype, interface.classNode) !=
+ if (hierarchy.getTypeAsInstanceOf(
+ supertype, interface.classNode, library.library, coreTypes) !=
interface) {
library.addProblem(
templateMixinApplicationIncompatibleSupertype.withArguments(
- supertype, interface, cls.mixedInType.asInterfaceType),
+ supertype,
+ interface,
+ cls.mixedInType.asInterfaceType,
+ library.isNonNullableByDefault),
cls.fileOffset,
noLength,
cls.fileUri);
@@ -1955,7 +1679,9 @@
SubtypeCheckMode.ignoringNullabilities)) {
addProblem(
templateRedirectingFactoryIncompatibleTypeArgument.withArguments(
- typeArgument, typeParameterBound),
+ typeArgument,
+ typeParameterBound,
+ library.isNonNullableByDefault),
redirectionTarget.charOffset,
noLength);
hasProblem = true;
@@ -2016,7 +1742,7 @@
redirecteeType, factoryType, SubtypeCheckMode.ignoringNullabilities)) {
addProblem(
templateIncompatibleRedirecteeFunctionType.withArguments(
- redirecteeType, factoryType),
+ redirecteeType, factoryType, library.isNonNullableByDefault),
factory.redirectionTarget.charOffset,
noLength);
}
diff --git a/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart b/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart
index dfb0012..2981094 100644
--- a/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart
@@ -7,6 +7,7 @@
import 'package:_fe_analyzer_shared/src/scanner/token.dart' show Token;
import 'package:kernel/ast.dart';
+import 'package:kernel/core_types.dart';
import '../constant_context.dart' show ConstantContext;
@@ -63,8 +64,6 @@
bool get isRedirectingGenerativeConstructor;
- bool get isEligibleForTopLevelInference;
-
/// The [Constructor] built by this builder.
Constructor get constructor;
@@ -75,6 +74,9 @@
Initializer initializer, ExpressionGeneratorHelper helper);
void prepareInitializers();
+
+ /// Infers the types of any untyped initializing formals.
+ void inferFormalTypes();
}
class ConstructorBuilderImpl extends FunctionBuilderImpl
@@ -158,16 +160,6 @@
}
@override
- bool get isEligibleForTopLevelInference {
- if (formals != null) {
- for (FormalParameterBuilder formal in formals) {
- if (formal.type == null && formal.isInitializingFormal) return true;
- }
- }
- return false;
- }
-
- @override
void buildMembers(
LibraryBuilder library, void Function(Member, BuiltMemberKind) f) {
Member member = build(library);
@@ -186,21 +178,40 @@
_constructor.isExternal = isExternal;
_constructor.name = new Name(name, libraryBuilder.library);
}
- if (isEligibleForTopLevelInference) {
+ if (formals != null) {
+ bool needsInference = false;
for (FormalParameterBuilder formal in formals) {
if (formal.type == null && formal.isInitializingFormal) {
formal.variable.type = null;
+ needsInference = true;
}
}
- libraryBuilder.loader.typeInferenceEngine.toBeInferred[_constructor] =
- libraryBuilder;
+ if (needsInference) {
+ assert(
+ library == libraryBuilder,
+ "Unexpected library builder ${libraryBuilder} for"
+ " constructor $this in ${library}.");
+ libraryBuilder.loader.typeInferenceEngine.toBeInferred[_constructor] =
+ this;
+ }
}
return _constructor;
}
@override
- void buildOutlineExpressions(LibraryBuilder library) {
- super.buildOutlineExpressions(library);
+ void inferFormalTypes() {
+ if (formals != null) {
+ for (FormalParameterBuilder formal in formals) {
+ if (formal.type == null && formal.isInitializingFormal) {
+ formal.finalizeInitializingFormal(classBuilder);
+ }
+ }
+ }
+ }
+
+ @override
+ void buildOutlineExpressions(LibraryBuilder library, CoreTypes coreTypes) {
+ super.buildOutlineExpressions(library, coreTypes);
// For modular compilation purposes we need to include initializers
// for const constructors into the outline.
diff --git a/pkg/front_end/lib/src/fasta/builder/enum_builder.dart b/pkg/front_end/lib/src/fasta/builder/enum_builder.dart
index 2d01cccc..ffaa510 100644
--- a/pkg/front_end/lib/src/fasta/builder/enum_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/enum_builder.dart
@@ -297,8 +297,11 @@
}
SourceFieldBuilder valuesBuilder = firstMemberNamed("values");
valuesBuilder.build(libraryBuilder);
- valuesBuilder.buildBody(new ListLiteral(values,
- typeArgument: rawType(library.nonNullable), isConst: true));
+ valuesBuilder.buildBody(
+ // TODO(johnniwinther): Create the bodies only when we have core types.
+ null,
+ new ListLiteral(values,
+ typeArgument: rawType(library.nonNullable), isConst: true));
ConstructorBuilderImpl constructorBuilder = constructorScopeBuilder[""];
Constructor constructor = constructorBuilder.build(libraryBuilder);
constructor.initializers.insert(
@@ -343,6 +346,9 @@
new StringLiteral("$name.$constant")
]);
field.buildBody(
+ // TODO(johnniwinther): Create the bodies only when we have core
+ // types.
+ null,
new ConstructorInvocation(constructor, arguments, isConst: true));
}
}
diff --git a/pkg/front_end/lib/src/fasta/builder/extension_builder.dart b/pkg/front_end/lib/src/fasta/builder/extension_builder.dart
index f1dfab0..d908710 100644
--- a/pkg/front_end/lib/src/fasta/builder/extension_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/extension_builder.dart
@@ -5,6 +5,7 @@
import 'dart:core' hide MapEntry;
import 'package:kernel/ast.dart';
+import 'package:kernel/core_types.dart';
import '../fasta_codes.dart' show templateInternalProblemNotFoundIn;
import '../scope.dart';
@@ -26,7 +27,7 @@
/// Return the [Extension] built by this builder.
Extension get extension;
- void buildOutlineExpressions(LibraryBuilder library);
+ void buildOutlineExpressions(LibraryBuilder library, CoreTypes coreTypes);
/// Looks up extension member by [name] taking privacy into account.
///
@@ -120,10 +121,10 @@
String get debugName => "ExtensionBuilder";
@override
- void buildOutlineExpressions(LibraryBuilder library) {
+ void buildOutlineExpressions(LibraryBuilder library, CoreTypes coreTypes) {
void build(String ignore, Builder declaration) {
MemberBuilder member = declaration;
- member.buildOutlineExpressions(library);
+ member.buildOutlineExpressions(library, coreTypes);
}
// TODO(johnniwinther): Handle annotations on the extension declaration.
diff --git a/pkg/front_end/lib/src/fasta/builder/field_builder.dart b/pkg/front_end/lib/src/fasta/builder/field_builder.dart
index 341fe25..ed82b58 100644
--- a/pkg/front_end/lib/src/fasta/builder/field_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/field_builder.dart
@@ -7,6 +7,7 @@
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart' show Token;
import 'package:kernel/ast.dart' hide MapEntry;
+import 'package:kernel/core_types.dart';
import '../constant_context.dart' show ConstantContext;
@@ -70,7 +71,7 @@
/// Builds the body of this field using [initializer] as the initializer
/// expression.
- void buildBody(Expression initializer);
+ void buildBody(CoreTypes coreTypes, Expression initializer);
/// Builds the field initializers for each field used to encode this field
/// using the [fileOffset] for the created nodes and [value] as the initial
@@ -154,7 +155,7 @@
bool get hasInitializer => (modifiers & hasInitializerMask) != 0;
@override
- void buildBody(Expression initializer) {
+ void buildBody(CoreTypes coreTypes, Expression initializer) {
assert(!hasBodyBeenBuilt);
hasBodyBeenBuilt = true;
if (!hasInitializer &&
@@ -165,7 +166,7 @@
internalProblem(
messageInternalProblemAlreadyInitialized, charOffset, fileUri);
}
- _fieldEncoding.createBodies(initializer);
+ _fieldEncoding.createBodies(coreTypes, initializer);
}
@override
@@ -220,7 +221,9 @@
}
@override
- void buildOutlineExpressions(LibraryBuilder library) {
+ void buildOutlineExpressions(LibraryBuilder library, CoreTypes coreTypes) {
+ _fieldEncoding.completeSignature(coreTypes);
+
ClassBuilder classBuilder = isClassMember ? parent : null;
MetadataBuilder.buildAnnotations(
_fieldEncoding.field, metadata, library, classBuilder, this);
@@ -255,7 +258,7 @@
bodyBuilder.transformCollections, library.library);
initializer = wrapper.operand;
}
- buildBody(initializer);
+ buildBody(coreTypes, initializer);
bodyBuilder.resolveRedirectingFactoryTargets();
}
constInitializerToken = null;
@@ -374,7 +377,7 @@
///
/// This method is not called for fields in outlines unless their are constant
/// or part of a const constructor.
- void createBodies(Expression initializer);
+ void createBodies(CoreTypes coreTypes, Expression initializer);
List<Initializer> createInitializer(int fileOffset, Expression value,
{bool isSynthetic});
@@ -406,9 +409,16 @@
SourceFieldBuilder fieldBuilder,
void Function(Member, BuiltMemberKind) f);
+ /// Returns a list of the field, getters and methods created by this field
+ /// encoding.
List<ClassMember> getLocalMembers(SourceFieldBuilder fieldBuilder);
+ /// Returns a list of the setters created by this field encoding.
List<ClassMember> getLocalSetters(SourceFieldBuilder fieldBuilder);
+
+ /// Ensures that the signatures all members created by this field encoding
+ /// are fully typed.
+ void completeSignature(CoreTypes coreTypes);
}
class RegularFieldEncoding implements FieldEncoding {
@@ -429,7 +439,10 @@
}
@override
- void createBodies(Expression initializer) {
+ void completeSignature(CoreTypes coreTypes) {}
+
+ @override
+ void createBodies(CoreTypes coreTypes, Expression initializer) {
if (initializer != null) {
_field.initializer = initializer..parent = _field;
}
@@ -538,18 +551,25 @@
}
@override
- void createBodies(Expression initializer) {
+ void completeSignature(CoreTypes coreTypes) {
+ if (_lateIsSetField != null) {
+ _lateIsSetField.type = coreTypes.boolRawType(Nullability.nonNullable);
+ }
+ }
+
+ @override
+ void createBodies(CoreTypes coreTypes, Expression initializer) {
assert(_type != null, "Type has not been computed for field $name.");
_field.initializer = new NullLiteral()..parent = _field;
if (_type.isPotentiallyNullable) {
_lateIsSetField.initializer = new BoolLiteral(false)
..parent = _lateIsSetField;
}
- _lateGetter.function.body = _createGetterBody(name, initializer)
+ _lateGetter.function.body = _createGetterBody(coreTypes, name, initializer)
..parent = _lateGetter.function;
if (_lateSetter != null) {
_lateSetter.function.body = _createSetterBody(
- name, _lateSetter.function.positionalParameters.first)
+ coreTypes, name, _lateSetter.function.positionalParameters.first)
..parent = _lateSetter.function;
}
}
@@ -590,7 +610,8 @@
}
}
- Statement _createGetterBody(String name, Expression initializer);
+ Statement _createGetterBody(
+ CoreTypes coreTypes, String name, Expression initializer);
Procedure _createSetter(String name, Uri fileUri, int charOffset) {
VariableDeclaration parameter = new VariableDeclaration(null);
@@ -603,7 +624,8 @@
..fileOffset = charOffset;
}
- Statement _createSetterBody(String name, VariableDeclaration parameter);
+ Statement _createSetterBody(
+ CoreTypes coreTypes, String name, VariableDeclaration parameter);
@override
DartType get type => _type;
@@ -674,9 +696,6 @@
..hasImplicitSetter = isInstanceMember
..isStatic = _field.isStatic
..isExtensionMember = isExtensionMember;
- // TODO(johnniwinther): Provide access to a `bool` type here.
- /*_lateIsSetField.type =
- libraryBuilder.loader.coreTypes.boolNonNullableRawType;*/
}
_lateGetter
..name = new Name(fieldName, libraryBuilder.library)
@@ -731,7 +750,8 @@
mixin NonFinalLate on AbstractLateFieldEncoding {
@override
- Statement _createSetterBody(String name, VariableDeclaration parameter) {
+ Statement _createSetterBody(
+ CoreTypes coreTypes, String name, VariableDeclaration parameter) {
assert(_type != null, "Type has not been computed for field $name.");
return late_lowering.createSetterBody(fileOffset, name, parameter, _type,
shouldReturnValue: false,
@@ -744,7 +764,8 @@
mixin LateWithInitializer on AbstractLateFieldEncoding {
@override
- Statement _createGetterBody(String name, Expression initializer) {
+ Statement _createGetterBody(
+ CoreTypes coreTypes, String name, Expression initializer) {
assert(_type != null, "Type has not been computed for field $name.");
return late_lowering.createGetterWithInitializer(
fileOffset, name, _type, initializer,
@@ -755,19 +776,15 @@
createIsSetWrite: (Expression value) =>
_createFieldSet(_lateIsSetField, value));
}
-
- @override
- void createBodies(Expression initializer) {
- super.createBodies(initializer);
- }
}
mixin LateWithoutInitializer on AbstractLateFieldEncoding {
@override
- Statement _createGetterBody(String name, Expression initializer) {
+ Statement _createGetterBody(
+ CoreTypes coreTypes, String name, Expression initializer) {
assert(_type != null, "Type has not been computed for field $name.");
return late_lowering.createGetterBodyWithoutInitializer(
- fileOffset, name, type, 'Field',
+ coreTypes, fileOffset, name, type, 'Field',
createVariableRead: () => _createFieldGet(_field),
createIsSetRead: () => _createFieldGet(_lateIsSetField));
}
@@ -794,10 +811,11 @@
: super(name, fileUri, charOffset, charEndOffset);
@override
- Statement _createSetterBody(String name, VariableDeclaration parameter) {
+ Statement _createSetterBody(
+ CoreTypes coreTypes, String name, VariableDeclaration parameter) {
assert(_type != null, "Type has not been computed for field $name.");
return late_lowering.createSetterBodyFinal(
- fileOffset, name, parameter, type, 'Field',
+ coreTypes, fileOffset, name, parameter, type, 'Field',
shouldReturnValue: false,
createVariableRead: () => _createFieldGet(_field),
createVariableWrite: (Expression value) =>
@@ -818,7 +836,8 @@
Procedure _createSetter(String name, Uri fileUri, int charOffset) => null;
@override
- Statement _createSetterBody(String name, VariableDeclaration parameter) =>
+ Statement _createSetterBody(
+ CoreTypes coreTypes, String name, VariableDeclaration parameter) =>
null;
}
diff --git a/pkg/front_end/lib/src/fasta/builder/formal_parameter_builder.dart b/pkg/front_end/lib/src/fasta/builder/formal_parameter_builder.dart
index 14cc3ac..4b2ba9b 100644
--- a/pkg/front_end/lib/src/fasta/builder/formal_parameter_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/formal_parameter_builder.dart
@@ -15,7 +15,8 @@
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart' show Token;
-import 'package:kernel/ast.dart' show Expression, VariableDeclaration;
+import 'package:kernel/ast.dart'
+ show DynamicType, Expression, VariableDeclaration;
import '../constant_context.dart' show ConstantContext;
@@ -145,13 +146,13 @@
..variable = variable);
}
- void finalizeInitializingFormal() {
- Object cls = parent.parent;
- if (cls is ClassBuilder) {
- Builder fieldBuilder = cls.scope.lookup(name, charOffset, fileUri);
- if (fieldBuilder is FieldBuilder) {
- variable.type = fieldBuilder.field.type;
- }
+ void finalizeInitializingFormal(ClassBuilder classBuilder) {
+ assert(variable.type == null);
+ Builder fieldBuilder = classBuilder.lookupLocalMember(name);
+ if (fieldBuilder is FieldBuilder) {
+ variable.type = fieldBuilder.inferType();
+ } else {
+ variable.type = const DynamicType();
}
}
diff --git a/pkg/front_end/lib/src/fasta/builder/function_builder.dart b/pkg/front_end/lib/src/fasta/builder/function_builder.dart
index 15d3f43..0630117 100644
--- a/pkg/front_end/lib/src/fasta/builder/function_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/function_builder.dart
@@ -483,7 +483,7 @@
}
@override
- void buildOutlineExpressions(LibraryBuilder library) {
+ void buildOutlineExpressions(LibraryBuilder library, CoreTypes coreTypes) {
MetadataBuilder.buildAnnotations(
member, metadata, library, isClassMember ? parent : null, this);
diff --git a/pkg/front_end/lib/src/fasta/builder/member_builder.dart b/pkg/front_end/lib/src/fasta/builder/member_builder.dart
index 5e5a6d0..5c024a7 100644
--- a/pkg/front_end/lib/src/fasta/builder/member_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/member_builder.dart
@@ -7,6 +7,7 @@
import 'dart:core' hide MapEntry;
import 'package:kernel/ast.dart';
+import 'package:kernel/core_types.dart';
import '../../base/common.dart';
@@ -53,7 +54,7 @@
// TODO(johnniwinther): Remove this and create a [ProcedureBuilder] interface.
ProcedureKind get kind;
- void buildOutlineExpressions(LibraryBuilder library);
+ void buildOutlineExpressions(LibraryBuilder library, CoreTypes coreTypes);
/// Returns the [ClassMember]s for the non-setter members created for this
/// member builder.
@@ -133,7 +134,7 @@
ProcedureKind get kind => unsupported("kind", charOffset, fileUri);
@override
- void buildOutlineExpressions(LibraryBuilder library) {}
+ void buildOutlineExpressions(LibraryBuilder library, CoreTypes coreTypes) {}
void buildMembers(
LibraryBuilder library, void Function(Member, BuiltMemberKind) f);
diff --git a/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart b/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart
index 2cd6217..bc96258 100644
--- a/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart
+++ b/pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart
@@ -12,26 +12,32 @@
part of fasta.codes;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<Message Function(String name, DartType _type, DartType _type2)>
- templateAmbiguousSupertypes = const Template<
- Message Function(String name, DartType _type, DartType _type2)>(
+const Template<
+ Message Function(String name, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)> templateAmbiguousSupertypes =
+ const Template<
+ Message Function(String name, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)>(
messageTemplate:
r"""'#name' can't implement both '#type' and '#type2'""",
withArguments: _withArgumentsAmbiguousSupertypes);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(String name, DartType _type, DartType _type2)>
- codeAmbiguousSupertypes =
- const Code<Message Function(String name, DartType _type, DartType _type2)>(
+const Code<
+ Message Function(String name, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)> codeAmbiguousSupertypes =
+ const Code<
+ Message Function(String name, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)>(
"AmbiguousSupertypes", templateAmbiguousSupertypes,
analyzerCodes: <String>["AMBIGUOUS_SUPERTYPES"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsAmbiguousSupertypes(
- String name, DartType _type, DartType _type2) {
+ String name, DartType _type, DartType _type2, bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -44,26 +50,29 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType
- _type2)> templateArgumentTypeNotAssignable = const Template<
- Message Function(DartType _type, DartType _type2)>(
- messageTemplate:
- r"""The argument type '#type' can't be assigned to the parameter type '#type2'.""",
- withArguments: _withArgumentsArgumentTypeNotAssignable);
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateArgumentTypeNotAssignable = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The argument type '#type' can't be assigned to the parameter type '#type2'.""",
+ withArguments: _withArgumentsArgumentTypeNotAssignable);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeArgumentTypeNotAssignable =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeArgumentTypeNotAssignable = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"ArgumentTypeNotAssignable", templateArgumentTypeNotAssignable,
analyzerCodes: <String>["ARGUMENT_TYPE_NOT_ASSIGNABLE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsArgumentTypeNotAssignable(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -77,23 +86,24 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- Constant
- _constant)> templateConstEvalDuplicateElement = const Template<
- Message Function(Constant _constant)>(
- messageTemplate:
- r"""The element '#constant' conflicts with another existing element in the set.""",
- withArguments: _withArgumentsConstEvalDuplicateElement);
+ Message Function(Constant _constant, bool isNonNullableByDefault)>
+ templateConstEvalDuplicateElement = const Template<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The element '#constant' conflicts with another existing element in the set.""",
+ withArguments: _withArgumentsConstEvalDuplicateElement);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(Constant _constant)> codeConstEvalDuplicateElement =
- const Code<Message Function(Constant _constant)>(
+const Code<Message Function(Constant _constant, bool isNonNullableByDefault)>
+ codeConstEvalDuplicateElement = const Code<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
"ConstEvalDuplicateElement", templateConstEvalDuplicateElement,
analyzerCodes: <String>["EQUAL_ELEMENTS_IN_CONST_SET"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsConstEvalDuplicateElement(Constant _constant) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsConstEvalDuplicateElement(
+ Constant _constant, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
String constant = constantParts.join();
return new Message(codeConstEvalDuplicateElement,
@@ -105,23 +115,24 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- Constant
- _constant)> templateConstEvalDuplicateKey = const Template<
- Message Function(Constant _constant)>(
- messageTemplate:
- r"""The key '#constant' conflicts with another existing key in the map.""",
- withArguments: _withArgumentsConstEvalDuplicateKey);
+ Message Function(Constant _constant, bool isNonNullableByDefault)>
+ templateConstEvalDuplicateKey = const Template<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The key '#constant' conflicts with another existing key in the map.""",
+ withArguments: _withArgumentsConstEvalDuplicateKey);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(Constant _constant)> codeConstEvalDuplicateKey =
- const Code<Message Function(Constant _constant)>(
+const Code<Message Function(Constant _constant, bool isNonNullableByDefault)>
+ codeConstEvalDuplicateKey = const Code<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
"ConstEvalDuplicateKey", templateConstEvalDuplicateKey,
analyzerCodes: <String>["EQUAL_KEYS_IN_CONST_MAP"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsConstEvalDuplicateKey(Constant _constant) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsConstEvalDuplicateKey(
+ Constant _constant, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
String constant = constantParts.join();
return new Message(codeConstEvalDuplicateKey,
@@ -133,25 +144,25 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- Constant
- _constant)> templateConstEvalElementImplementsEqual = const Template<
- Message Function(Constant _constant)>(
- messageTemplate:
- r"""The element '#constant' does not have a primitive operator '=='.""",
- withArguments: _withArgumentsConstEvalElementImplementsEqual);
+ Message Function(Constant _constant, bool isNonNullableByDefault)>
+ templateConstEvalElementImplementsEqual = const Template<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The element '#constant' does not have a primitive operator '=='.""",
+ withArguments: _withArgumentsConstEvalElementImplementsEqual);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(Constant _constant)>
- codeConstEvalElementImplementsEqual =
- const Code<Message Function(Constant _constant)>(
+const Code<Message Function(Constant _constant, bool isNonNullableByDefault)>
+ codeConstEvalElementImplementsEqual = const Code<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
"ConstEvalElementImplementsEqual",
templateConstEvalElementImplementsEqual,
analyzerCodes: <String>["CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsConstEvalElementImplementsEqual(Constant _constant) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsConstEvalElementImplementsEqual(
+ Constant _constant, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
String constant = constantParts.join();
return new Message(codeConstEvalElementImplementsEqual,
@@ -162,25 +173,25 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<
- Message Function(
- DartType
- _type)> templateConstEvalFreeTypeParameter = const Template<
- Message Function(DartType _type)>(
- messageTemplate:
- r"""The type '#type' is not a constant because it depends on a type parameter, only instantiated types are allowed.""",
- withArguments: _withArgumentsConstEvalFreeTypeParameter);
+const Template<Message Function(DartType _type, bool isNonNullableByDefault)>
+ templateConstEvalFreeTypeParameter = const Template<
+ Message Function(DartType _type, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The type '#type' is not a constant because it depends on a type parameter, only instantiated types are allowed.""",
+ withArguments: _withArgumentsConstEvalFreeTypeParameter);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type)> codeConstEvalFreeTypeParameter =
- const Code<Message Function(DartType _type)>(
+const Code<Message Function(DartType _type, bool isNonNullableByDefault)>
+ codeConstEvalFreeTypeParameter =
+ const Code<Message Function(DartType _type, bool isNonNullableByDefault)>(
"ConstEvalFreeTypeParameter",
templateConstEvalFreeTypeParameter,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsConstEvalFreeTypeParameter(DartType _type) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsConstEvalFreeTypeParameter(
+ DartType _type, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeConstEvalFreeTypeParameter,
@@ -192,33 +203,35 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- String string,
- Constant _constant,
- DartType _type,
- DartType
- _type2)> templateConstEvalInvalidBinaryOperandType = const Template<
Message Function(String string, Constant _constant, DartType _type,
- DartType _type2)>(
- messageTemplate:
- r"""Binary operator '#string' on '#constant' requires operand of type '#type', but was of type '#type2'.""",
- withArguments: _withArgumentsConstEvalInvalidBinaryOperandType);
+ DartType _type2, bool isNonNullableByDefault)>
+ templateConstEvalInvalidBinaryOperandType = const Template<
+ Message Function(String string, Constant _constant, DartType _type,
+ DartType _type2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Binary operator '#string' on '#constant' requires operand of type '#type', but was of type '#type2'.""",
+ withArguments: _withArgumentsConstEvalInvalidBinaryOperandType);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
- Message Function(String string, Constant _constant, DartType _type,
- DartType _type2)> codeConstEvalInvalidBinaryOperandType = const Code<
- Message Function(
- String string, Constant _constant, DartType _type, DartType _type2)>(
+ Message Function(String string, Constant _constant, DartType _type,
+ DartType _type2, bool isNonNullableByDefault)>
+ codeConstEvalInvalidBinaryOperandType = const Code<
+ Message Function(String string, Constant _constant, DartType _type,
+ DartType _type2, bool isNonNullableByDefault)>(
"ConstEvalInvalidBinaryOperandType",
templateConstEvalInvalidBinaryOperandType,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsConstEvalInvalidBinaryOperandType(
- String string, Constant _constant, DartType _type, DartType _type2) {
+ String string,
+ Constant _constant,
+ DartType _type,
+ DartType _type2,
+ bool isNonNullableByDefault) {
if (string.isEmpty) throw 'No string provided';
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
@@ -239,27 +252,30 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- Constant _constant,
- DartType
- _type)> templateConstEvalInvalidEqualsOperandType = const Template<
- Message Function(Constant _constant, DartType _type)>(
- messageTemplate:
- r"""Binary operator '==' requires receiver constant '#constant' of type 'Null', 'bool', 'int', 'double', or 'String', but was of type '#type'.""",
- withArguments: _withArgumentsConstEvalInvalidEqualsOperandType);
+ Message Function(
+ Constant _constant, DartType _type, bool isNonNullableByDefault)>
+ templateConstEvalInvalidEqualsOperandType = const Template<
+ Message Function(Constant _constant, DartType _type,
+ bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Binary operator '==' requires receiver constant '#constant' of type 'Null', 'bool', 'int', 'double', or 'String', but was of type '#type'.""",
+ withArguments: _withArgumentsConstEvalInvalidEqualsOperandType);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(Constant _constant, DartType _type)>
- codeConstEvalInvalidEqualsOperandType =
- const Code<Message Function(Constant _constant, DartType _type)>(
+const Code<
+ Message Function(
+ Constant _constant, DartType _type, bool isNonNullableByDefault)>
+ codeConstEvalInvalidEqualsOperandType = const Code<
+ Message Function(
+ Constant _constant, DartType _type, bool isNonNullableByDefault)>(
"ConstEvalInvalidEqualsOperandType",
templateConstEvalInvalidEqualsOperandType,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsConstEvalInvalidEqualsOperandType(
- Constant _constant, DartType _type) {
- TypeLabeler labeler = new TypeLabeler();
+ Constant _constant, DartType _type, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
List<Object> typeParts = labeler.labelType(_type);
String constant = constantParts.join();
@@ -273,28 +289,31 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- String string,
- Constant
- _constant)> templateConstEvalInvalidMethodInvocation = const Template<
- Message Function(String string, Constant _constant)>(
- messageTemplate:
- r"""The method '#string' can't be invoked on '#constant' in a constant expression.""",
- withArguments: _withArgumentsConstEvalInvalidMethodInvocation);
+ Message Function(
+ String string, Constant _constant, bool isNonNullableByDefault)>
+ templateConstEvalInvalidMethodInvocation = const Template<
+ Message Function(String string, Constant _constant,
+ bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The method '#string' can't be invoked on '#constant' in a constant expression.""",
+ withArguments: _withArgumentsConstEvalInvalidMethodInvocation);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(String string, Constant _constant)>
- codeConstEvalInvalidMethodInvocation =
- const Code<Message Function(String string, Constant _constant)>(
+const Code<
+ Message Function(
+ String string, Constant _constant, bool isNonNullableByDefault)>
+ codeConstEvalInvalidMethodInvocation = const Code<
+ Message Function(String string, Constant _constant,
+ bool isNonNullableByDefault)>(
"ConstEvalInvalidMethodInvocation",
templateConstEvalInvalidMethodInvocation,
analyzerCodes: <String>["UNDEFINED_OPERATOR"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsConstEvalInvalidMethodInvocation(
- String string, Constant _constant) {
+ String string, Constant _constant, bool isNonNullableByDefault) {
if (string.isEmpty) throw 'No string provided';
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
String constant = constantParts.join();
return new Message(codeConstEvalInvalidMethodInvocation,
@@ -306,27 +325,30 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- String string,
- Constant
- _constant)> templateConstEvalInvalidPropertyGet = const Template<
- Message Function(String string, Constant _constant)>(
- messageTemplate:
- r"""The property '#string' can't be accessed on '#constant' in a constant expression.""",
- withArguments: _withArgumentsConstEvalInvalidPropertyGet);
+ Message Function(
+ String string, Constant _constant, bool isNonNullableByDefault)>
+ templateConstEvalInvalidPropertyGet = const Template<
+ Message Function(String string, Constant _constant,
+ bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The property '#string' can't be accessed on '#constant' in a constant expression.""",
+ withArguments: _withArgumentsConstEvalInvalidPropertyGet);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(String string, Constant _constant)>
- codeConstEvalInvalidPropertyGet =
- const Code<Message Function(String string, Constant _constant)>(
+const Code<
+ Message Function(
+ String string, Constant _constant, bool isNonNullableByDefault)>
+ codeConstEvalInvalidPropertyGet = const Code<
+ Message Function(String string, Constant _constant,
+ bool isNonNullableByDefault)>(
"ConstEvalInvalidPropertyGet", templateConstEvalInvalidPropertyGet,
analyzerCodes: <String>["CONST_EVAL_THROWS_EXCEPTION"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsConstEvalInvalidPropertyGet(
- String string, Constant _constant) {
+ String string, Constant _constant, bool isNonNullableByDefault) {
if (string.isEmpty) throw 'No string provided';
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
String constant = constantParts.join();
return new Message(codeConstEvalInvalidPropertyGet,
@@ -337,9 +359,10 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<Message Function(Constant _constant)>
- templateConstEvalInvalidStringInterpolationOperand =
- const Template<Message Function(Constant _constant)>(
+const Template<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>
+ templateConstEvalInvalidStringInterpolationOperand = const Template<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
messageTemplate:
r"""The constant value '#constant' can't be used as part of a string interpolation in a constant expression.
Only values of type 'null', 'bool', 'int', 'double', or 'String' can be used.""",
@@ -347,17 +370,17 @@
_withArgumentsConstEvalInvalidStringInterpolationOperand);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(Constant _constant)>
- codeConstEvalInvalidStringInterpolationOperand =
- const Code<Message Function(Constant _constant)>(
+const Code<Message Function(Constant _constant, bool isNonNullableByDefault)>
+ codeConstEvalInvalidStringInterpolationOperand = const Code<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
"ConstEvalInvalidStringInterpolationOperand",
templateConstEvalInvalidStringInterpolationOperand,
analyzerCodes: <String>["CONST_EVAL_TYPE_BOOL_NUM_STRING"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsConstEvalInvalidStringInterpolationOperand(
- Constant _constant) {
- TypeLabeler labeler = new TypeLabeler();
+ Constant _constant, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
String constant = constantParts.join();
return new Message(codeConstEvalInvalidStringInterpolationOperand,
@@ -370,24 +393,24 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- Constant
- _constant)> templateConstEvalInvalidSymbolName = const Template<
- Message Function(Constant _constant)>(
- messageTemplate:
- r"""The symbol name must be a valid public Dart member name, public constructor name, or library name, optionally qualified, but was '#constant'.""",
- withArguments: _withArgumentsConstEvalInvalidSymbolName);
+ Message Function(Constant _constant, bool isNonNullableByDefault)>
+ templateConstEvalInvalidSymbolName = const Template<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The symbol name must be a valid public Dart member name, public constructor name, or library name, optionally qualified, but was '#constant'.""",
+ withArguments: _withArgumentsConstEvalInvalidSymbolName);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(Constant _constant)>
- codeConstEvalInvalidSymbolName =
- const Code<Message Function(Constant _constant)>(
+const Code<Message Function(Constant _constant, bool isNonNullableByDefault)>
+ codeConstEvalInvalidSymbolName = const Code<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
"ConstEvalInvalidSymbolName", templateConstEvalInvalidSymbolName,
analyzerCodes: <String>["CONST_EVAL_THROWS_EXCEPTION"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsConstEvalInvalidSymbolName(Constant _constant) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsConstEvalInvalidSymbolName(
+ Constant _constant, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
String constant = constantParts.join();
return new Message(codeConstEvalInvalidSymbolName,
@@ -402,26 +425,29 @@
Message Function(
Constant _constant,
DartType _type,
- DartType
- _type2)> templateConstEvalInvalidType = const Template<
- Message Function(Constant _constant, DartType _type, DartType _type2)>(
+ DartType _type2,
+ bool
+ isNonNullableByDefault)> templateConstEvalInvalidType = const Template<
+ Message Function(Constant _constant, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)>(
messageTemplate:
r"""Expected constant '#constant' to be of type '#type', but was of type '#type2'.""",
withArguments: _withArgumentsConstEvalInvalidType);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
- Message Function(Constant _constant, DartType _type, DartType _type2)>
- codeConstEvalInvalidType = const Code<
- Message Function(Constant _constant, DartType _type, DartType _type2)>(
+ Message Function(Constant _constant, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)> codeConstEvalInvalidType = const Code<
+ Message Function(Constant _constant, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)>(
"ConstEvalInvalidType",
templateConstEvalInvalidType,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsConstEvalInvalidType(
- Constant _constant, DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsConstEvalInvalidType(Constant _constant, DartType _type,
+ DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
@@ -436,25 +462,27 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<Message Function(Constant _constant)>
- templateConstEvalKeyImplementsEqual =
- const Template<Message Function(Constant _constant)>(
+const Template<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>
+ templateConstEvalKeyImplementsEqual = const Template<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
messageTemplate:
r"""The key '#constant' does not have a primitive operator '=='.""",
withArguments: _withArgumentsConstEvalKeyImplementsEqual);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(Constant _constant)>
- codeConstEvalKeyImplementsEqual =
- const Code<Message Function(Constant _constant)>(
+const Code<Message Function(Constant _constant, bool isNonNullableByDefault)>
+ codeConstEvalKeyImplementsEqual = const Code<
+ Message Function(Constant _constant, bool isNonNullableByDefault)>(
"ConstEvalKeyImplementsEqual", templateConstEvalKeyImplementsEqual,
analyzerCodes: <String>[
"CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS"
]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsConstEvalKeyImplementsEqual(Constant _constant) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsConstEvalKeyImplementsEqual(
+ Constant _constant, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> constantParts = labeler.labelConstant(_constant);
String constant = constantParts.join();
return new Message(codeConstEvalKeyImplementsEqual,
@@ -468,9 +496,11 @@
const Template<
Message Function(
DartType _type,
- String
- name)> templateDeferredTypeAnnotation = const Template<
- Message Function(DartType _type, String name)>(
+ String name,
+ bool
+ isNonNullableByDefault)> templateDeferredTypeAnnotation = const Template<
+ Message Function(
+ DartType _type, String name, bool isNonNullableByDefault)>(
messageTemplate:
r"""The type '#type' is deferred loaded via prefix '#name' and can't be used as a type annotation.""",
tipTemplate:
@@ -478,15 +508,19 @@
withArguments: _withArgumentsDeferredTypeAnnotation);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, String name)>
- codeDeferredTypeAnnotation =
- const Code<Message Function(DartType _type, String name)>(
+const Code<
+ Message Function(
+ DartType _type, String name, bool isNonNullableByDefault)>
+ codeDeferredTypeAnnotation = const Code<
+ Message Function(
+ DartType _type, String name, bool isNonNullableByDefault)>(
"DeferredTypeAnnotation", templateDeferredTypeAnnotation,
analyzerCodes: <String>["TYPE_ANNOTATION_DEFERRED_CLASS"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsDeferredTypeAnnotation(DartType _type, String name) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsDeferredTypeAnnotation(
+ DartType _type, String name, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
@@ -500,23 +534,30 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<Message Function(DartType _type, DartType _type2)>
- templateFfiDartTypeMismatch =
- const Template<Message Function(DartType _type, DartType _type2)>(
+const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateFfiDartTypeMismatch = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
messageTemplate: r"""Expected '#type' to be a subtype of '#type2'.""",
withArguments: _withArgumentsFfiDartTypeMismatch);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeFfiDartTypeMismatch =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeFfiDartTypeMismatch = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"FfiDartTypeMismatch",
templateFfiDartTypeMismatch,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsFfiDartTypeMismatch(DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsFfiDartTypeMismatch(
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -528,25 +569,25 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<
- Message Function(
- DartType
- _type)> templateFfiExpectedExceptionalReturn = const Template<
- Message Function(DartType _type)>(
- messageTemplate:
- r"""Expected an exceptional return value for a native callback returning '#type'.""",
- withArguments: _withArgumentsFfiExpectedExceptionalReturn);
+const Template<Message Function(DartType _type, bool isNonNullableByDefault)>
+ templateFfiExpectedExceptionalReturn = const Template<
+ Message Function(DartType _type, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Expected an exceptional return value for a native callback returning '#type'.""",
+ withArguments: _withArgumentsFfiExpectedExceptionalReturn);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type)> codeFfiExpectedExceptionalReturn =
- const Code<Message Function(DartType _type)>(
+const Code<Message Function(DartType _type, bool isNonNullableByDefault)>
+ codeFfiExpectedExceptionalReturn =
+ const Code<Message Function(DartType _type, bool isNonNullableByDefault)>(
"FfiExpectedExceptionalReturn",
templateFfiExpectedExceptionalReturn,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsFfiExpectedExceptionalReturn(DartType _type) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsFfiExpectedExceptionalReturn(
+ DartType _type, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeFfiExpectedExceptionalReturn,
@@ -557,26 +598,25 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<
- Message Function(
- DartType
- _type)> templateFfiExpectedNoExceptionalReturn = const Template<
- Message Function(DartType _type)>(
- messageTemplate:
- r"""Exceptional return value cannot be provided for a native callback returning '#type'.""",
- withArguments: _withArgumentsFfiExpectedNoExceptionalReturn);
+const Template<Message Function(DartType _type, bool isNonNullableByDefault)>
+ templateFfiExpectedNoExceptionalReturn = const Template<
+ Message Function(DartType _type, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Exceptional return value cannot be provided for a native callback returning '#type'.""",
+ withArguments: _withArgumentsFfiExpectedNoExceptionalReturn);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type)>
+const Code<Message Function(DartType _type, bool isNonNullableByDefault)>
codeFfiExpectedNoExceptionalReturn =
- const Code<Message Function(DartType _type)>(
+ const Code<Message Function(DartType _type, bool isNonNullableByDefault)>(
"FfiExpectedNoExceptionalReturn",
templateFfiExpectedNoExceptionalReturn,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsFfiExpectedNoExceptionalReturn(DartType _type) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsFfiExpectedNoExceptionalReturn(
+ DartType _type, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeFfiExpectedNoExceptionalReturn,
@@ -588,22 +628,27 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(DartType _type)> templateFfiTypeInvalid = const Template<
- Message Function(DartType _type)>(
+ Message Function(
+ DartType _type,
+ bool
+ isNonNullableByDefault)> templateFfiTypeInvalid = const Template<
+ Message Function(DartType _type, bool isNonNullableByDefault)>(
messageTemplate:
r"""Expected type '#type' to be a valid and instantiated subtype of 'NativeType'.""",
withArguments: _withArgumentsFfiTypeInvalid);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type)> codeFfiTypeInvalid =
- const Code<Message Function(DartType _type)>(
+const Code<Message Function(DartType _type, bool isNonNullableByDefault)>
+ codeFfiTypeInvalid =
+ const Code<Message Function(DartType _type, bool isNonNullableByDefault)>(
"FfiTypeInvalid",
templateFfiTypeInvalid,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsFfiTypeInvalid(DartType _type) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsFfiTypeInvalid(
+ DartType _type, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeFfiTypeInvalid,
@@ -618,25 +663,29 @@
Message Function(
DartType _type,
DartType _type2,
- DartType
- _type3)> templateFfiTypeMismatch = const Template<
- Message Function(DartType _type, DartType _type2, DartType _type3)>(
+ DartType _type3,
+ bool
+ isNonNullableByDefault)> templateFfiTypeMismatch = const Template<
+ Message Function(DartType _type, DartType _type2, DartType _type3,
+ bool isNonNullableByDefault)>(
messageTemplate:
r"""Expected type '#type' to be '#type2', which is the Dart type corresponding to '#type3'.""",
withArguments: _withArgumentsFfiTypeMismatch);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2, DartType _type3)>
- codeFfiTypeMismatch = const Code<
- Message Function(DartType _type, DartType _type2, DartType _type3)>(
+const Code<
+ Message Function(DartType _type, DartType _type2, DartType _type3,
+ bool isNonNullableByDefault)> codeFfiTypeMismatch = const Code<
+ Message Function(DartType _type, DartType _type2, DartType _type3,
+ bool isNonNullableByDefault)>(
"FfiTypeMismatch",
templateFfiTypeMismatch,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsFfiTypeMismatch(
- DartType _type, DartType _type2, DartType _type3) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsFfiTypeMismatch(DartType _type, DartType _type2,
+ DartType _type3, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
List<Object> type3Parts = labeler.labelType(_type3);
@@ -652,28 +701,31 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType
- _type2)> templateForInLoopElementTypeNotAssignable = const Template<
- Message Function(DartType _type, DartType _type2)>(
- messageTemplate:
- r"""A value of type '#type' can't be assigned to a variable of type '#type2'.""",
- tipTemplate: r"""Try changing the type of the variable.""",
- withArguments: _withArgumentsForInLoopElementTypeNotAssignable);
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateForInLoopElementTypeNotAssignable = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""A value of type '#type' can't be assigned to a variable of type '#type2'.""",
+ tipTemplate: r"""Try changing the type of the variable.""",
+ withArguments: _withArgumentsForInLoopElementTypeNotAssignable);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeForInLoopElementTypeNotAssignable =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeForInLoopElementTypeNotAssignable = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"ForInLoopElementTypeNotAssignable",
templateForInLoopElementTypeNotAssignable,
analyzerCodes: <String>["FOR_IN_OF_INVALID_ELEMENT_TYPE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsForInLoopElementTypeNotAssignable(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -688,26 +740,29 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType
- _type2)> templateForInLoopTypeNotIterable = const Template<
- Message Function(DartType _type, DartType _type2)>(
- messageTemplate:
- r"""The type '#type' used in the 'for' loop must implement '#type2'.""",
- withArguments: _withArgumentsForInLoopTypeNotIterable);
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateForInLoopTypeNotIterable = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The type '#type' used in the 'for' loop must implement '#type2'.""",
+ withArguments: _withArgumentsForInLoopTypeNotIterable);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeForInLoopTypeNotIterable =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeForInLoopTypeNotIterable = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"ForInLoopTypeNotIterable", templateForInLoopTypeNotIterable,
analyzerCodes: <String>["FOR_IN_OF_INVALID_TYPE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsForInLoopTypeNotIterable(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -720,9 +775,9 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<Message Function(DartType _type)>
- templateGenericFunctionTypeInferredAsActualTypeArgument =
- const Template<Message Function(DartType _type)>(
+const Template<Message Function(DartType _type, bool isNonNullableByDefault)>
+ templateGenericFunctionTypeInferredAsActualTypeArgument = const Template<
+ Message Function(DartType _type, bool isNonNullableByDefault)>(
messageTemplate:
r"""Generic function type '#type' inferred as a type argument.""",
tipTemplate:
@@ -731,17 +786,17 @@
_withArgumentsGenericFunctionTypeInferredAsActualTypeArgument);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type)>
+const Code<Message Function(DartType _type, bool isNonNullableByDefault)>
codeGenericFunctionTypeInferredAsActualTypeArgument =
- const Code<Message Function(DartType _type)>(
+ const Code<Message Function(DartType _type, bool isNonNullableByDefault)>(
"GenericFunctionTypeInferredAsActualTypeArgument",
templateGenericFunctionTypeInferredAsActualTypeArgument,
analyzerCodes: <String>["GENERIC_FUNCTION_CANNOT_BE_TYPE_ARGUMENT"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsGenericFunctionTypeInferredAsActualTypeArgument(
- DartType _type) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeGenericFunctionTypeInferredAsActualTypeArgument,
@@ -753,21 +808,24 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<Message Function(DartType _type)> templateIllegalRecursiveType =
- const Template<Message Function(DartType _type)>(
+const Template<Message Function(DartType _type, bool isNonNullableByDefault)>
+ templateIllegalRecursiveType = const Template<
+ Message Function(DartType _type, bool isNonNullableByDefault)>(
messageTemplate: r"""Illegal recursive type '#type'.""",
withArguments: _withArgumentsIllegalRecursiveType);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type)> codeIllegalRecursiveType =
- const Code<Message Function(DartType _type)>(
+const Code<Message Function(DartType _type, bool isNonNullableByDefault)>
+ codeIllegalRecursiveType =
+ const Code<Message Function(DartType _type, bool isNonNullableByDefault)>(
"IllegalRecursiveType",
templateIllegalRecursiveType,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsIllegalRecursiveType(DartType _type) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsIllegalRecursiveType(
+ DartType _type, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeIllegalRecursiveType,
@@ -776,26 +834,26 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<
- Message Function(
- DartType
- _type)> templateImplicitCallOfNonMethod = const Template<
- Message Function(DartType _type)>(
- messageTemplate:
- r"""Cannot invoke an instance of '#type' because it declares 'call' to be something other than a method.""",
- tipTemplate:
- r"""Try changing 'call' to a method or explicitly invoke 'call'.""",
- withArguments: _withArgumentsImplicitCallOfNonMethod);
+const Template<Message Function(DartType _type, bool isNonNullableByDefault)>
+ templateImplicitCallOfNonMethod = const Template<
+ Message Function(DartType _type, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Cannot invoke an instance of '#type' because it declares 'call' to be something other than a method.""",
+ tipTemplate:
+ r"""Try changing 'call' to a method or explicitly invoke 'call'.""",
+ withArguments: _withArgumentsImplicitCallOfNonMethod);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type)> codeImplicitCallOfNonMethod =
- const Code<Message Function(DartType _type)>(
+const Code<Message Function(DartType _type, bool isNonNullableByDefault)>
+ codeImplicitCallOfNonMethod =
+ const Code<Message Function(DartType _type, bool isNonNullableByDefault)>(
"ImplicitCallOfNonMethod", templateImplicitCallOfNonMethod,
analyzerCodes: <String>["IMPLICIT_CALL_OF_NON_METHOD"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsImplicitCallOfNonMethod(DartType _type) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsImplicitCallOfNonMethod(
+ DartType _type, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeImplicitCallOfNonMethod,
@@ -808,27 +866,30 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType
- _type2)> templateIncompatibleRedirecteeFunctionType = const Template<
- Message Function(DartType _type, DartType _type2)>(
- messageTemplate:
- r"""The constructor function type '#type' isn't a subtype of '#type2'.""",
- withArguments: _withArgumentsIncompatibleRedirecteeFunctionType);
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateIncompatibleRedirecteeFunctionType = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The constructor function type '#type' isn't a subtype of '#type2'.""",
+ withArguments: _withArgumentsIncompatibleRedirecteeFunctionType);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeIncompatibleRedirecteeFunctionType =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeIncompatibleRedirecteeFunctionType = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"IncompatibleRedirecteeFunctionType",
templateIncompatibleRedirecteeFunctionType,
analyzerCodes: <String>["REDIRECT_TO_INVALID_TYPE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsIncompatibleRedirecteeFunctionType(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -842,34 +903,31 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType _type2,
- String name,
- String
- name2)> templateIncorrectTypeArgument = const Template<
- Message Function(
- DartType _type, DartType _type2, String name, String name2)>(
- messageTemplate:
- r"""Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'.""",
- tipTemplate:
- r"""Try changing type arguments so that they conform to the bounds.""",
- withArguments: _withArgumentsIncorrectTypeArgument);
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>
+ templateIncorrectTypeArgument = const Template<
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'.""",
+ tipTemplate:
+ r"""Try changing type arguments so that they conform to the bounds.""",
+ withArguments: _withArgumentsIncorrectTypeArgument);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
- Message Function(
- DartType _type, DartType _type2, String name, String name2)>
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>
codeIncorrectTypeArgument = const Code<
- Message Function(
- DartType _type, DartType _type2, String name, String name2)>(
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>(
"IncorrectTypeArgument", templateIncorrectTypeArgument,
analyzerCodes: <String>["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsIncorrectTypeArgument(
- DartType _type, DartType _type2, String name, String name2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsIncorrectTypeArgument(DartType _type, DartType _type2,
+ String name, String name2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
if (name.isEmpty) throw 'No name provided';
@@ -893,35 +951,32 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType _type2,
- String name,
- String
- name2)> templateIncorrectTypeArgumentInReturnType = const Template<
- Message Function(
- DartType _type, DartType _type2, String name, String name2)>(
- messageTemplate:
- r"""Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the return type.""",
- tipTemplate:
- r"""Try changing type arguments so that they conform to the bounds.""",
- withArguments: _withArgumentsIncorrectTypeArgumentInReturnType);
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>
+ templateIncorrectTypeArgumentInReturnType = const Template<
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the return type.""",
+ tipTemplate:
+ r"""Try changing type arguments so that they conform to the bounds.""",
+ withArguments: _withArgumentsIncorrectTypeArgumentInReturnType);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
- Message Function(
- DartType _type, DartType _type2, String name, String name2)>
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>
codeIncorrectTypeArgumentInReturnType = const Code<
- Message Function(
- DartType _type, DartType _type2, String name, String name2)>(
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>(
"IncorrectTypeArgumentInReturnType",
templateIncorrectTypeArgumentInReturnType,
analyzerCodes: <String>["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsIncorrectTypeArgumentInReturnType(
- DartType _type, DartType _type2, String name, String name2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsIncorrectTypeArgumentInReturnType(DartType _type,
+ DartType _type2, String name, String name2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
if (name.isEmpty) throw 'No name provided';
@@ -945,37 +1000,61 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType _type2,
- String name,
- String name2,
- String name3,
- String
- name4)> templateIncorrectTypeArgumentInSupertype = const Template<
- Message Function(DartType _type, DartType _type2, String name,
- String name2, String name3, String name4)>(
- messageTemplate:
- r"""Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the supertype '#name3' of class '#name4'.""",
- tipTemplate:
- r"""Try changing type arguments so that they conform to the bounds.""",
- withArguments: _withArgumentsIncorrectTypeArgumentInSupertype);
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ String name,
+ String name2,
+ String name3,
+ String name4,
+ bool isNonNullableByDefault)>
+ templateIncorrectTypeArgumentInSupertype = const Template<
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ String name,
+ String name2,
+ String name3,
+ String name4,
+ bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the supertype '#name3' of class '#name4'.""",
+ tipTemplate:
+ r"""Try changing type arguments so that they conform to the bounds.""",
+ withArguments: _withArgumentsIncorrectTypeArgumentInSupertype);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
- Message Function(DartType _type, DartType _type2, String name,
- String name2, String name3, String name4)>
- codeIncorrectTypeArgumentInSupertype = const Code<
- Message Function(DartType _type, DartType _type2, String name,
- String name2, String name3, String name4)>(
- "IncorrectTypeArgumentInSupertype",
- templateIncorrectTypeArgumentInSupertype,
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ String name,
+ String name2,
+ String name3,
+ String name4,
+ bool isNonNullableByDefault)> codeIncorrectTypeArgumentInSupertype =
+ const Code<
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ String name,
+ String name2,
+ String name3,
+ String name4,
+ bool isNonNullableByDefault)>(
+ "IncorrectTypeArgumentInSupertype", templateIncorrectTypeArgumentInSupertype,
analyzerCodes: <String>["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsIncorrectTypeArgumentInSupertype(DartType _type,
- DartType _type2, String name, String name2, String name3, String name4) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsIncorrectTypeArgumentInSupertype(
+ DartType _type,
+ DartType _type2,
+ String name,
+ String name2,
+ String name3,
+ String name4,
+ bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
if (name.isEmpty) throw 'No name provided';
@@ -1006,43 +1085,61 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType _type2,
- String name,
- String name2,
- String name3,
- String
- name4)> templateIncorrectTypeArgumentInSupertypeInferred = const Template<
Message Function(
DartType _type,
DartType _type2,
String name,
String name2,
String name3,
- String
- name4)>(
- messageTemplate:
- r"""Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the supertype '#name3' of class '#name4'.""",
- tipTemplate:
- r"""Try specifying type arguments explicitly so that they conform to the bounds.""",
- withArguments: _withArgumentsIncorrectTypeArgumentInSupertypeInferred);
+ String name4,
+ bool isNonNullableByDefault)>
+ templateIncorrectTypeArgumentInSupertypeInferred = const Template<
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ String name,
+ String name2,
+ String name3,
+ String name4,
+ bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2' in the supertype '#name3' of class '#name4'.""",
+ tipTemplate:
+ r"""Try specifying type arguments explicitly so that they conform to the bounds.""",
+ withArguments: _withArgumentsIncorrectTypeArgumentInSupertypeInferred);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
- Message Function(DartType _type, DartType _type2, String name,
- String name2, String name3, String name4)>
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ String name,
+ String name2,
+ String name3,
+ String name4,
+ bool isNonNullableByDefault)>
codeIncorrectTypeArgumentInSupertypeInferred = const Code<
- Message Function(DartType _type, DartType _type2, String name,
- String name2, String name3, String name4)>(
- "IncorrectTypeArgumentInSupertypeInferred",
- templateIncorrectTypeArgumentInSupertypeInferred,
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ String name,
+ String name2,
+ String name3,
+ String name4,
+ bool isNonNullableByDefault)>(
+ "IncorrectTypeArgumentInSupertypeInferred", templateIncorrectTypeArgumentInSupertypeInferred,
analyzerCodes: <String>["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsIncorrectTypeArgumentInSupertypeInferred(DartType _type,
- DartType _type2, String name, String name2, String name3, String name4) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsIncorrectTypeArgumentInSupertypeInferred(
+ DartType _type,
+ DartType _type2,
+ String name,
+ String name2,
+ String name3,
+ String name4,
+ bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
if (name.isEmpty) throw 'No name provided';
@@ -1073,34 +1170,31 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType _type2,
- String name,
- String
- name2)> templateIncorrectTypeArgumentInferred = const Template<
- Message Function(
- DartType _type, DartType _type2, String name, String name2)>(
- messageTemplate:
- r"""Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'.""",
- tipTemplate:
- r"""Try specifying type arguments explicitly so that they conform to the bounds.""",
- withArguments: _withArgumentsIncorrectTypeArgumentInferred);
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>
+ templateIncorrectTypeArgumentInferred = const Template<
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#name2'.""",
+ tipTemplate:
+ r"""Try specifying type arguments explicitly so that they conform to the bounds.""",
+ withArguments: _withArgumentsIncorrectTypeArgumentInferred);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
- Message Function(
- DartType _type, DartType _type2, String name, String name2)>
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>
codeIncorrectTypeArgumentInferred = const Code<
- Message Function(
- DartType _type, DartType _type2, String name, String name2)>(
+ Message Function(DartType _type, DartType _type2, String name,
+ String name2, bool isNonNullableByDefault)>(
"IncorrectTypeArgumentInferred", templateIncorrectTypeArgumentInferred,
analyzerCodes: <String>["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsIncorrectTypeArgumentInferred(
- DartType _type, DartType _type2, String name, String name2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsIncorrectTypeArgumentInferred(DartType _type,
+ DartType _type2, String name, String name2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
if (name.isEmpty) throw 'No name provided';
@@ -1124,41 +1218,37 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType _type2,
- String name,
- DartType _type3,
- String
- name2)> templateIncorrectTypeArgumentQualified = const Template<
- Message Function(
- DartType _type,
- DartType _type2,
- String name,
- DartType _type3,
- String
- name2)>(
- messageTemplate:
- r"""Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3.#name2'.""",
- tipTemplate:
- r"""Try changing type arguments so that they conform to the bounds.""",
- withArguments: _withArgumentsIncorrectTypeArgumentQualified);
+ Message Function(DartType _type, DartType _type2, String name,
+ DartType _type3, String name2, bool isNonNullableByDefault)>
+ templateIncorrectTypeArgumentQualified = const Template<
+ Message Function(DartType _type, DartType _type2, String name,
+ DartType _type3, String name2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3.#name2'.""",
+ tipTemplate:
+ r"""Try changing type arguments so that they conform to the bounds.""",
+ withArguments: _withArgumentsIncorrectTypeArgumentQualified);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
Message Function(DartType _type, DartType _type2, String name,
- DartType _type3, String name2)> codeIncorrectTypeArgumentQualified =
- const Code<
+ DartType _type3, String name2, bool isNonNullableByDefault)>
+ codeIncorrectTypeArgumentQualified = const Code<
Message Function(DartType _type, DartType _type2, String name,
- DartType _type3, String name2)>(
+ DartType _type3, String name2, bool isNonNullableByDefault)>(
"IncorrectTypeArgumentQualified",
templateIncorrectTypeArgumentQualified,
analyzerCodes: <String>["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsIncorrectTypeArgumentQualified(DartType _type,
- DartType _type2, String name, DartType _type3, String name2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsIncorrectTypeArgumentQualified(
+ DartType _type,
+ DartType _type2,
+ String name,
+ DartType _type3,
+ String name2,
+ bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
if (name.isEmpty) throw 'No name provided';
@@ -1185,36 +1275,36 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType _type2,
- String name,
- DartType _type3,
- String
- name2)> templateIncorrectTypeArgumentQualifiedInferred = const Template<
Message Function(DartType _type, DartType _type2, String name,
- DartType _type3, String name2)>(
- messageTemplate:
- r"""Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3.#name2'.""",
- tipTemplate:
- r"""Try specifying type arguments explicitly so that they conform to the bounds.""",
- withArguments: _withArgumentsIncorrectTypeArgumentQualifiedInferred);
+ DartType _type3, String name2, bool isNonNullableByDefault)>
+ templateIncorrectTypeArgumentQualifiedInferred = const Template<
+ Message Function(DartType _type, DartType _type2, String name,
+ DartType _type3, String name2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Inferred type argument '#type' doesn't conform to the bound '#type2' of the type variable '#name' on '#type3.#name2'.""",
+ tipTemplate:
+ r"""Try specifying type arguments explicitly so that they conform to the bounds.""",
+ withArguments: _withArgumentsIncorrectTypeArgumentQualifiedInferred);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
Message Function(DartType _type, DartType _type2, String name,
- DartType _type3, String name2)>
+ DartType _type3, String name2, bool isNonNullableByDefault)>
codeIncorrectTypeArgumentQualifiedInferred = const Code<
Message Function(DartType _type, DartType _type2, String name,
- DartType _type3, String name2)>(
- "IncorrectTypeArgumentQualifiedInferred",
- templateIncorrectTypeArgumentQualifiedInferred,
+ DartType _type3, String name2, bool isNonNullableByDefault)>(
+ "IncorrectTypeArgumentQualifiedInferred", templateIncorrectTypeArgumentQualifiedInferred,
analyzerCodes: <String>["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsIncorrectTypeArgumentQualifiedInferred(DartType _type,
- DartType _type2, String name, DartType _type3, String name2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsIncorrectTypeArgumentQualifiedInferred(
+ DartType _type,
+ DartType _type2,
+ String name,
+ DartType _type3,
+ String name2,
+ bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
if (name.isEmpty) throw 'No name provided';
@@ -1241,32 +1331,33 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- String name,
- DartType _type,
- DartType
- _type2)> templateInitializingFormalTypeMismatch = const Template<
- Message Function(String name, DartType _type, DartType _type2)>(
- messageTemplate:
- r"""The type of parameter '#name', '#type' is not a subtype of the corresponding field's type, '#type2'.""",
- tipTemplate:
- r"""Try changing the type of parameter '#name' to a subtype of '#type2'.""",
- withArguments: _withArgumentsInitializingFormalTypeMismatch);
+ Message Function(String name, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)>
+ templateInitializingFormalTypeMismatch = const Template<
+ Message Function(String name, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The type of parameter '#name', '#type' is not a subtype of the corresponding field's type, '#type2'.""",
+ tipTemplate:
+ r"""Try changing the type of parameter '#name' to a subtype of '#type2'.""",
+ withArguments: _withArgumentsInitializingFormalTypeMismatch);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(String name, DartType _type, DartType _type2)>
- codeInitializingFormalTypeMismatch =
- const Code<Message Function(String name, DartType _type, DartType _type2)>(
- "InitializingFormalTypeMismatch",
+const Code<
+ Message Function(String name, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)> codeInitializingFormalTypeMismatch =
+ const Code<
+ Message Function(String name, DartType _type, DartType _type2,
+ bool isNonNullableByDefault)>("InitializingFormalTypeMismatch",
templateInitializingFormalTypeMismatch,
analyzerCodes: <String>["INVALID_PARAMETER_DECLARATION"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsInitializingFormalTypeMismatch(
- String name, DartType _type, DartType _type2) {
+ String name, DartType _type, DartType _type2, bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1283,23 +1374,29 @@
const Template<
Message Function(
DartType _type,
- DartType
- _type2)> templateInvalidAssignment = const Template<
- Message Function(DartType _type, DartType _type2)>(
+ DartType _type2,
+ bool
+ isNonNullableByDefault)> templateInvalidAssignment = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
messageTemplate:
r"""A value of type '#type' can't be assigned to a variable of type '#type2'.""",
withArguments: _withArgumentsInvalidAssignment);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeInvalidAssignment =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeInvalidAssignment = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"InvalidAssignment", templateInvalidAssignment,
analyzerCodes: <String>["INVALID_ASSIGNMENT"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsInvalidAssignment(DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsInvalidAssignment(
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1315,9 +1412,11 @@
const Template<
Message Function(
DartType _type,
- DartType
- _type2)> templateInvalidCastFunctionExpr = const Template<
- Message Function(DartType _type, DartType _type2)>(
+ DartType _type2,
+ bool
+ isNonNullableByDefault)> templateInvalidCastFunctionExpr = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
messageTemplate:
r"""The function expression type '#type' isn't of expected type '#type2'.""",
tipTemplate:
@@ -1325,15 +1424,19 @@
withArguments: _withArgumentsInvalidCastFunctionExpr);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeInvalidCastFunctionExpr =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeInvalidCastFunctionExpr = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"InvalidCastFunctionExpr", templateInvalidCastFunctionExpr,
analyzerCodes: <String>["INVALID_CAST_FUNCTION_EXPR"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsInvalidCastFunctionExpr(DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsInvalidCastFunctionExpr(
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1350,9 +1453,14 @@
const Template<
Message Function(
DartType _type,
- DartType
- _type2)> templateInvalidCastLiteralList = const Template<
- Message Function(DartType _type, DartType _type2)>(
+ DartType _type2,
+ bool
+ isNonNullableByDefault)> templateInvalidCastLiteralList = const Template<
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ bool
+ isNonNullableByDefault)>(
messageTemplate:
r"""The list literal type '#type' isn't of expected type '#type2'.""",
tipTemplate:
@@ -1360,15 +1468,19 @@
withArguments: _withArgumentsInvalidCastLiteralList);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeInvalidCastLiteralList =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeInvalidCastLiteralList = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"InvalidCastLiteralList", templateInvalidCastLiteralList,
analyzerCodes: <String>["INVALID_CAST_LITERAL_LIST"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsInvalidCastLiteralList(DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsInvalidCastLiteralList(
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1385,9 +1497,14 @@
const Template<
Message Function(
DartType _type,
- DartType
- _type2)> templateInvalidCastLiteralMap = const Template<
- Message Function(DartType _type, DartType _type2)>(
+ DartType _type2,
+ bool
+ isNonNullableByDefault)> templateInvalidCastLiteralMap = const Template<
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ bool
+ isNonNullableByDefault)>(
messageTemplate:
r"""The map literal type '#type' isn't of expected type '#type2'.""",
tipTemplate:
@@ -1395,15 +1512,19 @@
withArguments: _withArgumentsInvalidCastLiteralMap);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeInvalidCastLiteralMap =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeInvalidCastLiteralMap = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"InvalidCastLiteralMap", templateInvalidCastLiteralMap,
analyzerCodes: <String>["INVALID_CAST_LITERAL_MAP"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsInvalidCastLiteralMap(DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsInvalidCastLiteralMap(
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1420,9 +1541,14 @@
const Template<
Message Function(
DartType _type,
- DartType
- _type2)> templateInvalidCastLiteralSet = const Template<
- Message Function(DartType _type, DartType _type2)>(
+ DartType _type2,
+ bool
+ isNonNullableByDefault)> templateInvalidCastLiteralSet = const Template<
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ bool
+ isNonNullableByDefault)>(
messageTemplate:
r"""The set literal type '#type' isn't of expected type '#type2'.""",
tipTemplate:
@@ -1430,15 +1556,19 @@
withArguments: _withArgumentsInvalidCastLiteralSet);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeInvalidCastLiteralSet =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeInvalidCastLiteralSet = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"InvalidCastLiteralSet", templateInvalidCastLiteralSet,
analyzerCodes: <String>["INVALID_CAST_LITERAL_SET"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsInvalidCastLiteralSet(DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsInvalidCastLiteralSet(
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1455,9 +1585,14 @@
const Template<
Message Function(
DartType _type,
- DartType
- _type2)> templateInvalidCastLocalFunction = const Template<
- Message Function(DartType _type, DartType _type2)>(
+ DartType _type2,
+ bool
+ isNonNullableByDefault)> templateInvalidCastLocalFunction = const Template<
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ bool
+ isNonNullableByDefault)>(
messageTemplate:
r"""The local function has type '#type' that isn't of expected type '#type2'.""",
tipTemplate:
@@ -1465,16 +1600,19 @@
withArguments: _withArgumentsInvalidCastLocalFunction);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeInvalidCastLocalFunction =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeInvalidCastLocalFunction = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"InvalidCastLocalFunction", templateInvalidCastLocalFunction,
analyzerCodes: <String>["INVALID_CAST_FUNCTION"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsInvalidCastLocalFunction(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1491,9 +1629,14 @@
const Template<
Message Function(
DartType _type,
- DartType
- _type2)> templateInvalidCastNewExpr = const Template<
- Message Function(DartType _type, DartType _type2)>(
+ DartType _type2,
+ bool
+ isNonNullableByDefault)> templateInvalidCastNewExpr = const Template<
+ Message Function(
+ DartType _type,
+ DartType _type2,
+ bool
+ isNonNullableByDefault)>(
messageTemplate:
r"""The constructor returns type '#type' that isn't of expected type '#type2'.""",
tipTemplate:
@@ -1501,15 +1644,19 @@
withArguments: _withArgumentsInvalidCastNewExpr);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeInvalidCastNewExpr =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeInvalidCastNewExpr = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"InvalidCastNewExpr", templateInvalidCastNewExpr,
analyzerCodes: <String>["INVALID_CAST_NEW_EXPR"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsInvalidCastNewExpr(DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsInvalidCastNewExpr(
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1526,9 +1673,11 @@
const Template<
Message Function(
DartType _type,
- DartType
- _type2)> templateInvalidCastStaticMethod = const Template<
- Message Function(DartType _type, DartType _type2)>(
+ DartType _type2,
+ bool
+ isNonNullableByDefault)> templateInvalidCastStaticMethod = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
messageTemplate:
r"""The static method has type '#type' that isn't of expected type '#type2'.""",
tipTemplate:
@@ -1536,15 +1685,19 @@
withArguments: _withArgumentsInvalidCastStaticMethod);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeInvalidCastStaticMethod =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeInvalidCastStaticMethod = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"InvalidCastStaticMethod", templateInvalidCastStaticMethod,
analyzerCodes: <String>["INVALID_CAST_METHOD"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsInvalidCastStaticMethod(DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsInvalidCastStaticMethod(
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1559,28 +1712,31 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType
- _type2)> templateInvalidCastTopLevelFunction = const Template<
- Message Function(DartType _type, DartType _type2)>(
- messageTemplate:
- r"""The top level function has type '#type' that isn't of expected type '#type2'.""",
- tipTemplate:
- r"""Change the type of the function or the context in which it is used.""",
- withArguments: _withArgumentsInvalidCastTopLevelFunction);
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateInvalidCastTopLevelFunction = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The top level function has type '#type' that isn't of expected type '#type2'.""",
+ tipTemplate:
+ r"""Change the type of the function or the context in which it is used.""",
+ withArguments: _withArgumentsInvalidCastTopLevelFunction);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeInvalidCastTopLevelFunction =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeInvalidCastTopLevelFunction = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"InvalidCastTopLevelFunction", templateInvalidCastTopLevelFunction,
analyzerCodes: <String>["INVALID_CAST_FUNCTION"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsInvalidCastTopLevelFunction(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1595,25 +1751,30 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(DartType _type, DartType _type2, DartType _type3)>
+ Message Function(DartType _type, DartType _type2, DartType _type3,
+ bool isNonNullableByDefault)>
templateMixinApplicationIncompatibleSupertype = const Template<
- Message Function(DartType _type, DartType _type2, DartType _type3)>(
+ Message Function(DartType _type, DartType _type2, DartType _type3,
+ bool isNonNullableByDefault)>(
messageTemplate:
r"""'#type' doesn't implement '#type2' so it can't be used with '#type3'.""",
withArguments: _withArgumentsMixinApplicationIncompatibleSupertype);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2, DartType _type3)>
+const Code<
+ Message Function(DartType _type, DartType _type2, DartType _type3,
+ bool isNonNullableByDefault)>
codeMixinApplicationIncompatibleSupertype = const Code<
- Message Function(DartType _type, DartType _type2, DartType _type3)>(
+ Message Function(DartType _type, DartType _type2, DartType _type3,
+ bool isNonNullableByDefault)>(
"MixinApplicationIncompatibleSupertype",
templateMixinApplicationIncompatibleSupertype,
analyzerCodes: <String>["MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsMixinApplicationIncompatibleSupertype(
- DartType _type, DartType _type2, DartType _type3) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsMixinApplicationIncompatibleSupertype(DartType _type,
+ DartType _type2, DartType _type3, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
List<Object> type3Parts = labeler.labelType(_type3);
@@ -1629,31 +1790,34 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- String name,
- String name2,
- DartType
- _type)> templateMixinInferenceNoMatchingClass = const Template<
- Message Function(String name, String name2, DartType _type)>(
- messageTemplate:
- r"""Type parameters could not be inferred for the mixin '#name' because '#name2' does not implement the mixin's supertype constraint '#type'.""",
- withArguments: _withArgumentsMixinInferenceNoMatchingClass);
+ Message Function(String name, String name2, DartType _type,
+ bool isNonNullableByDefault)>
+ templateMixinInferenceNoMatchingClass =
+ const Template<
+ Message Function(String name, String name2, DartType _type,
+ bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Type parameters could not be inferred for the mixin '#name' because '#name2' does not implement the mixin's supertype constraint '#type'.""",
+ withArguments: _withArgumentsMixinInferenceNoMatchingClass);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(String name, String name2, DartType _type)>
- codeMixinInferenceNoMatchingClass =
- const Code<Message Function(String name, String name2, DartType _type)>(
+const Code<
+ Message Function(String name, String name2, DartType _type,
+ bool isNonNullableByDefault)> codeMixinInferenceNoMatchingClass =
+ const Code<
+ Message Function(String name, String name2, DartType _type,
+ bool isNonNullableByDefault)>(
"MixinInferenceNoMatchingClass", templateMixinInferenceNoMatchingClass,
analyzerCodes: <String>["MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsMixinInferenceNoMatchingClass(
- String name, String name2, DartType _type) {
+ String name, String name2, DartType _type, bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
if (name2.isEmpty) throw 'No name provided';
name2 = demangleMixinApplicationName(name2);
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeMixinInferenceNoMatchingClass,
@@ -1665,44 +1829,40 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- String name,
- String name2,
- DartType _type,
- DartType _type2,
- String
- name3)> templateOverrideTypeMismatchParameter = const Template<
- Message Function(
- String name,
- String name2,
- DartType _type,
- DartType _type2,
- String
- name3)>(
- messageTemplate:
- r"""The parameter '#name' of the method '#name2' has type '#type', which does not match the corresponding type, '#type2', in the overridden method, '#name3'.""",
- tipTemplate:
- r"""Change to a supertype of '#type2', or, for a covariant parameter, a subtype.""",
- withArguments: _withArgumentsOverrideTypeMismatchParameter);
+ Message Function(String name, String name2, DartType _type,
+ DartType _type2, String name3, bool isNonNullableByDefault)>
+ templateOverrideTypeMismatchParameter = const Template<
+ Message Function(String name, String name2, DartType _type,
+ DartType _type2, String name3, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The parameter '#name' of the method '#name2' has type '#type', which does not match the corresponding type, '#type2', in the overridden method, '#name3'.""",
+ tipTemplate:
+ r"""Change to a supertype of '#type2', or, for a covariant parameter, a subtype.""",
+ withArguments: _withArgumentsOverrideTypeMismatchParameter);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
Message Function(String name, String name2, DartType _type,
- DartType _type2, String name3)> codeOverrideTypeMismatchParameter =
- const Code<
+ DartType _type2, String name3, bool isNonNullableByDefault)>
+ codeOverrideTypeMismatchParameter = const Code<
Message Function(String name, String name2, DartType _type,
- DartType _type2, String name3)>(
+ DartType _type2, String name3, bool isNonNullableByDefault)>(
"OverrideTypeMismatchParameter", templateOverrideTypeMismatchParameter,
analyzerCodes: <String>["INVALID_METHOD_OVERRIDE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsOverrideTypeMismatchParameter(
- String name, String name2, DartType _type, DartType _type2, String name3) {
+ String name,
+ String name2,
+ DartType _type,
+ DartType _type2,
+ String name3,
+ bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
if (name2.isEmpty) throw 'No name provided';
name2 = demangleMixinApplicationName(name2);
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
if (name3.isEmpty) throw 'No name provided';
@@ -1725,36 +1885,37 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- String name,
- DartType _type,
- DartType _type2,
- String
- name2)> templateOverrideTypeMismatchReturnType = const Template<
- Message Function(
- String name, DartType _type, DartType _type2, String name2)>(
- messageTemplate:
- r"""The return type of the method '#name' is '#type', which does not match the return type, '#type2', of the overridden method, '#name2'.""",
- tipTemplate: r"""Change to a subtype of '#type2'.""",
- withArguments: _withArgumentsOverrideTypeMismatchReturnType);
+ Message Function(String name, DartType _type, DartType _type2,
+ String name2, bool isNonNullableByDefault)>
+ templateOverrideTypeMismatchReturnType = const Template<
+ Message Function(String name, DartType _type, DartType _type2,
+ String name2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The return type of the method '#name' is '#type', which does not match the return type, '#type2', of the overridden method, '#name2'.""",
+ tipTemplate: r"""Change to a subtype of '#type2'.""",
+ withArguments: _withArgumentsOverrideTypeMismatchReturnType);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
- Message Function(
- String name, DartType _type, DartType _type2, String name2)>
+ Message Function(String name, DartType _type, DartType _type2,
+ String name2, bool isNonNullableByDefault)>
codeOverrideTypeMismatchReturnType = const Code<
- Message Function(
- String name, DartType _type, DartType _type2, String name2)>(
+ Message Function(String name, DartType _type, DartType _type2,
+ String name2, bool isNonNullableByDefault)>(
"OverrideTypeMismatchReturnType",
templateOverrideTypeMismatchReturnType,
analyzerCodes: <String>["INVALID_METHOD_OVERRIDE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsOverrideTypeMismatchReturnType(
- String name, DartType _type, DartType _type2, String name2) {
+ String name,
+ DartType _type,
+ DartType _type2,
+ String name2,
+ bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
if (name2.isEmpty) throw 'No name provided';
@@ -1776,34 +1937,31 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- String name,
- DartType _type,
- DartType _type2,
- String
- name2)> templateOverrideTypeMismatchSetter = const Template<
- Message Function(
- String name, DartType _type, DartType _type2, String name2)>(
- messageTemplate:
- r"""The field '#name' has type '#type', which does not match the corresponding type, '#type2', in the overridden setter, '#name2'.""",
- withArguments: _withArgumentsOverrideTypeMismatchSetter);
+ Message Function(String name, DartType _type, DartType _type2,
+ String name2, bool isNonNullableByDefault)>
+ templateOverrideTypeMismatchSetter = const Template<
+ Message Function(String name, DartType _type, DartType _type2,
+ String name2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""The field '#name' has type '#type', which does not match the corresponding type, '#type2', in the overridden setter, '#name2'.""",
+ withArguments: _withArgumentsOverrideTypeMismatchSetter);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<
- Message Function(
- String name, DartType _type, DartType _type2, String name2)>
+ Message Function(String name, DartType _type, DartType _type2,
+ String name2, bool isNonNullableByDefault)>
codeOverrideTypeMismatchSetter = const Code<
- Message Function(
- String name, DartType _type, DartType _type2, String name2)>(
+ Message Function(String name, DartType _type, DartType _type2,
+ String name2, bool isNonNullableByDefault)>(
"OverrideTypeMismatchSetter", templateOverrideTypeMismatchSetter,
analyzerCodes: <String>["INVALID_METHOD_OVERRIDE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsOverrideTypeMismatchSetter(
- String name, DartType _type, DartType _type2, String name2) {
+Message _withArgumentsOverrideTypeMismatchSetter(String name, DartType _type,
+ DartType _type2, String name2, bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
if (name2.isEmpty) throw 'No name provided';
@@ -1823,26 +1981,32 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<Message Function(DartType _type, DartType _type2)>
- templateRedirectingFactoryIncompatibleTypeArgument =
- const Template<Message Function(DartType _type, DartType _type2)>(
+const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateRedirectingFactoryIncompatibleTypeArgument = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
messageTemplate: r"""The type '#type' doesn't extend '#type2'.""",
tipTemplate: r"""Try using a different type as argument.""",
withArguments:
_withArgumentsRedirectingFactoryIncompatibleTypeArgument);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeRedirectingFactoryIncompatibleTypeArgument =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeRedirectingFactoryIncompatibleTypeArgument = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"RedirectingFactoryIncompatibleTypeArgument",
templateRedirectingFactoryIncompatibleTypeArgument,
analyzerCodes: <String>["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsRedirectingFactoryIncompatibleTypeArgument(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1856,26 +2020,29 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType
- _type2)> templateSpreadElementTypeMismatch = const Template<
- Message Function(DartType _type, DartType _type2)>(
- messageTemplate:
- r"""Can't assign spread elements of type '#type' to collection elements of type '#type2'.""",
- withArguments: _withArgumentsSpreadElementTypeMismatch);
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateSpreadElementTypeMismatch = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Can't assign spread elements of type '#type' to collection elements of type '#type2'.""",
+ withArguments: _withArgumentsSpreadElementTypeMismatch);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeSpreadElementTypeMismatch =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeSpreadElementTypeMismatch = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"SpreadElementTypeMismatch", templateSpreadElementTypeMismatch,
analyzerCodes: <String>["LIST_ELEMENT_TYPE_NOT_ASSIGNABLE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsSpreadElementTypeMismatch(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1889,27 +2056,30 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType
- _type2)> templateSpreadMapEntryElementKeyTypeMismatch = const Template<
- Message Function(DartType _type, DartType _type2)>(
- messageTemplate:
- r"""Can't assign spread entry keys of type '#type' to map entry keys of type '#type2'.""",
- withArguments: _withArgumentsSpreadMapEntryElementKeyTypeMismatch);
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateSpreadMapEntryElementKeyTypeMismatch = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Can't assign spread entry keys of type '#type' to map entry keys of type '#type2'.""",
+ withArguments: _withArgumentsSpreadMapEntryElementKeyTypeMismatch);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeSpreadMapEntryElementKeyTypeMismatch =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeSpreadMapEntryElementKeyTypeMismatch = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"SpreadMapEntryElementKeyTypeMismatch",
templateSpreadMapEntryElementKeyTypeMismatch,
analyzerCodes: <String>["MAP_KEY_TYPE_NOT_ASSIGNABLE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsSpreadMapEntryElementKeyTypeMismatch(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1922,25 +2092,31 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<Message Function(DartType _type, DartType _type2)>
- templateSpreadMapEntryElementValueTypeMismatch =
- const Template<Message Function(DartType _type, DartType _type2)>(
+const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateSpreadMapEntryElementValueTypeMismatch = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
messageTemplate:
r"""Can't assign spread entry values of type '#type' to map entry values of type '#type2'.""",
withArguments: _withArgumentsSpreadMapEntryElementValueTypeMismatch);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeSpreadMapEntryElementValueTypeMismatch =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeSpreadMapEntryElementValueTypeMismatch = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"SpreadMapEntryElementValueTypeMismatch",
templateSpreadMapEntryElementValueTypeMismatch,
analyzerCodes: <String>["MAP_VALUE_TYPE_NOT_ASSIGNABLE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsSpreadMapEntryElementValueTypeMismatch(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -1953,25 +2129,25 @@
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<
- Message Function(
- DartType
- _type)> templateSpreadMapEntryTypeMismatch = const Template<
- Message Function(DartType _type)>(
- messageTemplate:
- r"""Unexpected type '#type' of a map spread entry. Expected 'dynamic' or a Map.""",
- withArguments: _withArgumentsSpreadMapEntryTypeMismatch);
+const Template<Message Function(DartType _type, bool isNonNullableByDefault)>
+ templateSpreadMapEntryTypeMismatch = const Template<
+ Message Function(DartType _type, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Unexpected type '#type' of a map spread entry. Expected 'dynamic' or a Map.""",
+ withArguments: _withArgumentsSpreadMapEntryTypeMismatch);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type)> codeSpreadMapEntryTypeMismatch =
- const Code<Message Function(DartType _type)>(
+const Code<Message Function(DartType _type, bool isNonNullableByDefault)>
+ codeSpreadMapEntryTypeMismatch =
+ const Code<Message Function(DartType _type, bool isNonNullableByDefault)>(
"SpreadMapEntryTypeMismatch",
templateSpreadMapEntryTypeMismatch,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsSpreadMapEntryTypeMismatch(DartType _type) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsSpreadMapEntryTypeMismatch(
+ DartType _type, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeSpreadMapEntryTypeMismatch,
@@ -1984,23 +2160,26 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
- DartType
- _type)> templateSpreadTypeMismatch = const Template<
- Message Function(DartType _type)>(
+ DartType _type,
+ bool
+ isNonNullableByDefault)> templateSpreadTypeMismatch = const Template<
+ Message Function(DartType _type, bool isNonNullableByDefault)>(
messageTemplate:
r"""Unexpected type '#type' of a spread. Expected 'dynamic' or an Iterable.""",
withArguments: _withArgumentsSpreadTypeMismatch);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type)> codeSpreadTypeMismatch =
- const Code<Message Function(DartType _type)>(
+const Code<Message Function(DartType _type, bool isNonNullableByDefault)>
+ codeSpreadTypeMismatch =
+ const Code<Message Function(DartType _type, bool isNonNullableByDefault)>(
"SpreadTypeMismatch",
templateSpreadTypeMismatch,
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsSpreadTypeMismatch(DartType _type) {
- TypeLabeler labeler = new TypeLabeler();
+Message _withArgumentsSpreadTypeMismatch(
+ DartType _type, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeSpreadTypeMismatch,
@@ -2012,26 +2191,29 @@
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
- Message Function(
- DartType _type,
- DartType
- _type2)> templateSwitchExpressionNotAssignable = const Template<
- Message Function(DartType _type, DartType _type2)>(
- messageTemplate:
- r"""Type '#type' of the switch expression isn't assignable to the type '#type2' of this case expression.""",
- withArguments: _withArgumentsSwitchExpressionNotAssignable);
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ templateSwitchExpressionNotAssignable = const Template<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
+ messageTemplate:
+ r"""Type '#type' of the switch expression isn't assignable to the type '#type2' of this case expression.""",
+ withArguments: _withArgumentsSwitchExpressionNotAssignable);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(DartType _type, DartType _type2)>
- codeSwitchExpressionNotAssignable =
- const Code<Message Function(DartType _type, DartType _type2)>(
+const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>
+ codeSwitchExpressionNotAssignable = const Code<
+ Message Function(
+ DartType _type, DartType _type2, bool isNonNullableByDefault)>(
"SwitchExpressionNotAssignable", templateSwitchExpressionNotAssignable,
analyzerCodes: <String>["SWITCH_EXPRESSION_NOT_ASSIGNABLE"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsSwitchExpressionNotAssignable(
- DartType _type, DartType _type2) {
- TypeLabeler labeler = new TypeLabeler();
+ DartType _type, DartType _type2, bool isNonNullableByDefault) {
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
List<Object> type2Parts = labeler.labelType(_type2);
String type = typeParts.join();
@@ -2047,9 +2229,11 @@
const Template<
Message Function(
String name,
- DartType
- _type)> templateUndefinedGetter = const Template<
- Message Function(String name, DartType _type)>(
+ DartType _type,
+ bool
+ isNonNullableByDefault)> templateUndefinedGetter = const Template<
+ Message Function(
+ String name, DartType _type, bool isNonNullableByDefault)>(
messageTemplate:
r"""The getter '#name' isn't defined for the class '#type'.""",
tipTemplate:
@@ -2057,16 +2241,21 @@
withArguments: _withArgumentsUndefinedGetter);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(String name, DartType _type)> codeUndefinedGetter =
- const Code<Message Function(String name, DartType _type)>(
+const Code<
+ Message Function(
+ String name, DartType _type, bool isNonNullableByDefault)>
+ codeUndefinedGetter = const Code<
+ Message Function(
+ String name, DartType _type, bool isNonNullableByDefault)>(
"UndefinedGetter", templateUndefinedGetter,
analyzerCodes: <String>["UNDEFINED_GETTER"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsUndefinedGetter(String name, DartType _type) {
+Message _withArgumentsUndefinedGetter(
+ String name, DartType _type, bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeUndefinedGetter,
@@ -2082,9 +2271,11 @@
const Template<
Message Function(
String name,
- DartType
- _type)> templateUndefinedMethod = const Template<
- Message Function(String name, DartType _type)>(
+ DartType _type,
+ bool
+ isNonNullableByDefault)> templateUndefinedMethod = const Template<
+ Message Function(
+ String name, DartType _type, bool isNonNullableByDefault)>(
messageTemplate:
r"""The method '#name' isn't defined for the class '#type'.""",
tipTemplate:
@@ -2092,16 +2283,21 @@
withArguments: _withArgumentsUndefinedMethod);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(String name, DartType _type)> codeUndefinedMethod =
- const Code<Message Function(String name, DartType _type)>(
+const Code<
+ Message Function(
+ String name, DartType _type, bool isNonNullableByDefault)>
+ codeUndefinedMethod = const Code<
+ Message Function(
+ String name, DartType _type, bool isNonNullableByDefault)>(
"UndefinedMethod", templateUndefinedMethod,
analyzerCodes: <String>["UNDEFINED_METHOD"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsUndefinedMethod(String name, DartType _type) {
+Message _withArgumentsUndefinedMethod(
+ String name, DartType _type, bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeUndefinedMethod,
@@ -2117,9 +2313,11 @@
const Template<
Message Function(
String name,
- DartType
- _type)> templateUndefinedSetter = const Template<
- Message Function(String name, DartType _type)>(
+ DartType _type,
+ bool
+ isNonNullableByDefault)> templateUndefinedSetter = const Template<
+ Message Function(
+ String name, DartType _type, bool isNonNullableByDefault)>(
messageTemplate:
r"""The setter '#name' isn't defined for the class '#type'.""",
tipTemplate:
@@ -2127,16 +2325,21 @@
withArguments: _withArgumentsUndefinedSetter);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Code<Message Function(String name, DartType _type)> codeUndefinedSetter =
- const Code<Message Function(String name, DartType _type)>(
+const Code<
+ Message Function(
+ String name, DartType _type, bool isNonNullableByDefault)>
+ codeUndefinedSetter = const Code<
+ Message Function(
+ String name, DartType _type, bool isNonNullableByDefault)>(
"UndefinedSetter", templateUndefinedSetter,
analyzerCodes: <String>["UNDEFINED_SETTER"]);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-Message _withArgumentsUndefinedSetter(String name, DartType _type) {
+Message _withArgumentsUndefinedSetter(
+ String name, DartType _type, bool isNonNullableByDefault) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);
List<Object> typeParts = labeler.labelType(_type);
String type = typeParts.join();
return new Message(codeUndefinedSetter,
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index fd64898..032583e 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -254,6 +254,8 @@
///
bool inLateFieldInitializer = false;
+ List<Initializer> _initializers;
+
bool inCatchClause = false;
bool inCatchBlock = false;
@@ -698,10 +700,10 @@
libraryBuilder.library);
initializer = wrapper.operand;
}
- fieldBuilder.buildBody(initializer);
+ fieldBuilder.buildBody(coreTypes, initializer);
}
} else if (!fieldBuilder.hasBodyBeenBuilt) {
- fieldBuilder.buildBody(null);
+ fieldBuilder.buildBody(coreTypes, null);
}
}
{
@@ -758,12 +760,11 @@
];
} else {
initializers = buildFieldInitializer(
- true,
formal.name,
formal.charOffset,
formal.charOffset,
new VariableGet(formal.variable),
- formalType: formal.variable.type);
+ formal: formal);
}
for (Initializer initializer in initializers) {
member.addInitializer(initializer, this);
@@ -811,7 +812,6 @@
debugEvent("endInitializer");
inFieldInitializer = false;
assert(!inInitializer);
- final ModifierBuilder member = this.member;
Object node = pop();
List<Initializer> initializers;
if (node is Initializer) {
@@ -833,14 +833,10 @@
buildInvalidInitializer(node, token.charOffset)
];
}
- for (Initializer initializer in initializers) {
- typeInferrer?.inferInitializer(this, initializer);
- }
- if (member is ConstructorBuilder && !member.isExternal) {
- for (Initializer initializer in initializers) {
- member.addInitializer(initializer, this);
- }
- } else {
+ _initializers ??= <Initializer>[];
+ _initializers.addAll(initializers);
+ final ModifierBuilder member = this.member;
+ if (!(member is ConstructorBuilder && !member.isExternal)) {
addProblem(
fasta.templateInitializerOutsideConstructor
.withArguments(member.name),
@@ -866,6 +862,14 @@
typeInferrer?.assignedVariables?.finish();
FunctionBuilder builder = member;
+ FunctionNode function = builder.member.function;
+ for (VariableDeclaration parameter in function.positionalParameters) {
+ typeInferrer?.flowAnalysis?.initialize(parameter);
+ }
+ for (VariableDeclaration parameter in function.namedParameters) {
+ typeInferrer?.flowAnalysis?.initialize(parameter);
+ }
+
if (formals?.parameters != null) {
for (int i = 0; i < formals.parameters.length; i++) {
FormalParameterBuilder parameter = formals.parameters[i];
@@ -906,13 +910,18 @@
}
}
}
+ if (builder is ConstructorBuilder) {
+ finishConstructor(builder, asyncModifier, body);
+ } else if (builder is ProcedureBuilder) {
+ builder.asyncModifier = asyncModifier;
+ } else {
+ unhandled("${builder.runtimeType}", "finishFunction", builder.charOffset,
+ builder.fileUri);
+ }
+
if (body != null) {
body = typeInferrer?.inferFunctionBody(
- this,
- _computeReturnTypeContext(member),
- asyncModifier,
- builder.member.function,
- body);
+ this, _computeReturnTypeContext(member), asyncModifier, body);
libraryBuilder.loader.transformPostInference(body, transformSetLiterals,
transformCollections, libraryBuilder.library);
}
@@ -957,10 +966,10 @@
// building, so we should skip them here.
bool isNoSuchMethodForwarder = (builder.function.parent is Procedure &&
(builder.function.parent as Procedure).isNoSuchMethodForwarder);
- if (!builder.isExternal && !isNoSuchMethodForwarder) {
- builder.body = body;
- } else {
- if (body != null) {
+ if (body != null) {
+ if (!builder.isExternal && !isNoSuchMethodForwarder) {
+ builder.body = body;
+ } else {
builder.body = new Block(<Statement>[
new ExpressionStatement(buildProblem(
fasta.messageExternalMethodWithBody, body.fileOffset, noLength))
@@ -970,15 +979,6 @@
..fileOffset = body.fileOffset;
}
}
- if (builder is ConstructorBuilder) {
- finishConstructor(builder, asyncModifier);
- } else if (builder is ProcedureBuilder) {
- builder.asyncModifier = asyncModifier;
- } else {
- unhandled("${builder.runtimeType}", "finishFunction", builder.charOffset,
- builder.fileUri);
- }
-
resolveRedirectingFactoryTargets();
finishVariableMetadata();
}
@@ -1293,7 +1293,7 @@
ReturnStatementImpl fakeReturn = new ReturnStatementImpl(true, expression);
typeInferrer?.inferFunctionBody(
- this, const DynamicType(), AsyncMarker.Sync, null, fakeReturn);
+ this, const DynamicType(), AsyncMarker.Sync, fakeReturn);
return fakeReturn.expression;
}
@@ -1308,7 +1308,7 @@
}
// We are passing [AsyncMarker.Sync] because the error will be reported
// already.
- finishConstructor(member, AsyncMarker.Sync);
+ finishConstructor(member, AsyncMarker.Sync, null);
}
Expression parseFieldInitializer(Token token) {
@@ -1328,17 +1328,25 @@
}
void finishConstructor(
- ConstructorBuilder builder, AsyncMarker asyncModifier) {
+ ConstructorBuilder builder, AsyncMarker asyncModifier, Statement body) {
/// Quotes below are from [Dart Programming Language Specification, 4th
/// Edition](
/// https://ecma-international.org/publications/files/ECMA-ST/ECMA-408.pdf).
assert(builder == member);
Constructor constructor = builder.actualConstructor;
+ if (_initializers != null) {
+ for (Initializer initializer in _initializers) {
+ typeInferrer?.inferInitializer(this, initializer);
+ }
+ if (!builder.isExternal) {
+ for (Initializer initializer in _initializers) {
+ builder.addInitializer(initializer, this);
+ }
+ }
+ }
if (asyncModifier != AsyncMarker.Sync) {
- // TODO(ahe): Change this to a null check.
- int offset = builder.body?.fileOffset ?? builder.charOffset;
- constructor.initializers.add(buildInvalidInitializer(
- buildProblem(fasta.messageConstructorNotSync, offset, noLength)));
+ constructor.initializers.add(buildInvalidInitializer(buildProblem(
+ fasta.messageConstructorNotSync, body.fileOffset, noLength)));
}
if (needsImplicitSuperInitializer) {
/// >If no superinitializer is provided, an implicit superinitializer
@@ -1372,7 +1380,7 @@
setParents(constructor.initializers, constructor);
libraryBuilder.loader.transformListPostInference(constructor.initializers,
transformSetLiterals, transformCollections, libraryBuilder.library);
- if (constructor.function.body == null) {
+ if (body == null) {
/// >If a generative constructor c is not a redirecting constructor
/// >and no body is provided, then c implicitly has an empty body {}.
/// We use an empty statement instead.
@@ -2403,8 +2411,7 @@
exitLocalScope();
push(block);
if (blockKind == BlockKind.tryStatement) {
- // This is matched by the calls to [deferNode] and [endNode] in
- // [endTryStatement].
+ // This is matched by the call to [beginNode] in [beginBlock].
typeInferrer?.assignedVariables?.endNode(block);
}
}
@@ -2625,9 +2632,10 @@
exitLocalScope();
JumpTarget continueTarget = exitContinueTarget();
JumpTarget breakTarget = exitBreakTarget();
+ List<BreakStatementImpl> continueStatements;
if (continueTarget.hasUsers) {
body = forest.createLabeledStatement(body);
- continueTarget.resolveContinues(forest, body);
+ continueStatements = continueTarget.resolveContinues(forest, body);
}
Expression condition;
if (conditionStatement is ExpressionStatement) {
@@ -2635,13 +2643,19 @@
} else {
assert(conditionStatement is EmptyStatement);
}
- Statement result = forest.createForStatement(
+ Statement forStatement = forest.createForStatement(
offsetForToken(forKeyword), variables, condition, updates, body);
typeInferrer?.assignedVariables
- ?.storeInfo(result, assignedVariablesNodeInfo);
+ ?.storeInfo(forStatement, assignedVariablesNodeInfo);
+ if (continueStatements != null) {
+ for (BreakStatementImpl continueStatement in continueStatements) {
+ continueStatement.targetStatement = forStatement;
+ }
+ }
+ Statement result = forStatement;
if (breakTarget.hasUsers) {
result = forest.createLabeledStatement(result);
- breakTarget.resolveBreaks(forest, result);
+ breakTarget.resolveBreaks(forest, result, forStatement);
}
if (variableOrExpression is ParserRecovery) {
problemInLoopOrSwitch ??= buildProblemStatement(
@@ -3042,6 +3056,15 @@
FormalParameters formals = pop();
UnresolvedType returnType = pop();
List<TypeVariableBuilder> typeVariables = pop();
+ if (typeVariables != null) {
+ for (TypeVariableBuilder builder in typeVariables) {
+ if (builder.parameter.annotations.isNotEmpty) {
+ addProblem(fasta.messageAnnotationOnFunctionTypeTypeVariable,
+ builder.charOffset, builder.name.length);
+ builder.parameter.annotations = const <Expression>[];
+ }
+ }
+ }
UnresolvedType type = formals.toFunctionType(
returnType,
libraryBuilder.nullableBuilderIfTrue(questionMark != null),
@@ -4389,17 +4412,24 @@
Statement body = popStatement();
JumpTarget continueTarget = exitContinueTarget();
JumpTarget breakTarget = exitBreakTarget();
+ List<BreakStatementImpl> continueStatements;
if (continueTarget.hasUsers) {
body = forest.createLabeledStatement(body);
- continueTarget.resolveContinues(forest, body);
+ continueStatements = continueTarget.resolveContinues(forest, body);
}
- Statement result =
+ Statement doStatement =
forest.createDoStatement(offsetForToken(doKeyword), body, condition);
// This is matched by the [beginNode] call in [beginDoWhileStatement].
- typeInferrer?.assignedVariables?.endNode(result);
+ typeInferrer?.assignedVariables?.endNode(doStatement);
+ if (continueStatements != null) {
+ for (BreakStatementImpl continueStatement in continueStatements) {
+ continueStatement.targetStatement = doStatement;
+ }
+ }
+ Statement result = doStatement;
if (breakTarget.hasUsers) {
result = forest.createLabeledStatement(result);
- breakTarget.resolveBreaks(forest, result);
+ breakTarget.resolveBreaks(forest, result, doStatement);
}
exitLoopOrSwitch(result);
}
@@ -4576,9 +4606,10 @@
exitLocalScope();
JumpTarget continueTarget = exitContinueTarget();
JumpTarget breakTarget = exitBreakTarget();
+ List<BreakStatementImpl> continueStatements;
if (continueTarget.hasUsers) {
body = forest.createLabeledStatement(body);
- continueTarget.resolveContinues(forest, body);
+ continueStatements = continueTarget.resolveContinues(forest, body);
}
VariableDeclaration variable = buildForInVariable(forToken, lvalue);
Expression problem = checkForInVariable(lvalue, variable, forToken);
@@ -4597,15 +4628,21 @@
body = combineStatements(prologue, body);
}
}
- Statement result = new ForInStatement(variable, expression, body,
+ Statement forInStatement = new ForInStatement(variable, expression, body,
isAsync: awaitToken != null)
..fileOffset = awaitToken?.charOffset ?? forToken.charOffset
..bodyOffset = body.fileOffset; // TODO(ahe): Isn't this redundant?
typeInferrer?.assignedVariables
- ?.storeInfo(result, assignedVariablesNodeInfo);
+ ?.storeInfo(forInStatement, assignedVariablesNodeInfo);
+ if (continueStatements != null) {
+ for (BreakStatementImpl continueStatement in continueStatements) {
+ continueStatement.targetStatement = forInStatement;
+ }
+ }
+ Statement result = forInStatement;
if (breakTarget.hasUsers) {
result = forest.createLabeledStatement(result);
- breakTarget.resolveBreaks(forest, result);
+ breakTarget.resolveBreaks(forest, result, forInStatement);
}
if (problem != null) {
result = combineStatements(
@@ -4653,8 +4690,14 @@
if (statement is! LabeledStatement) {
statement = forest.createLabeledStatement(statement);
}
- target.breakTarget.resolveBreaks(forest, statement);
- target.continueTarget.resolveContinues(forest, statement);
+ target.breakTarget.resolveBreaks(forest, statement, statement);
+ List<BreakStatementImpl> continueStatements =
+ target.continueTarget.resolveContinues(forest, statement);
+ if (continueStatements != null) {
+ for (BreakStatementImpl continueStatement in continueStatements) {
+ continueStatement.targetStatement = statement;
+ }
+ }
}
push(statement);
}
@@ -4692,16 +4735,22 @@
Expression condition = popForValue();
JumpTarget continueTarget = exitContinueTarget();
JumpTarget breakTarget = exitBreakTarget();
+ List<BreakStatementImpl> continueStatements;
if (continueTarget.hasUsers) {
body = forest.createLabeledStatement(body);
- continueTarget.resolveContinues(forest, body);
+ continueStatements = continueTarget.resolveContinues(forest, body);
}
Statement whileStatement = forest.createWhileStatement(
offsetForToken(whileKeyword), condition, body);
+ if (continueStatements != null) {
+ for (BreakStatementImpl continueStatement in continueStatements) {
+ continueStatement.targetStatement = whileStatement;
+ }
+ }
Statement result = whileStatement;
if (breakTarget.hasUsers) {
result = forest.createLabeledStatement(result);
- breakTarget.resolveBreaks(forest, result);
+ breakTarget.resolveBreaks(forest, result, whileStatement);
}
exitLoopOrSwitch(result);
// This is matched by the [beginNode] call in [beginWhileStatement].
@@ -4871,8 +4920,9 @@
for (Expression expression in expressions) {
expressionOffsets.add(expression.fileOffset);
}
- push(new SwitchCase(expressions, expressionOffsets, block,
- isDefault: defaultKeyword != null)
+ assert(labels == null || labels.isNotEmpty);
+ push(new SwitchCaseImpl(expressions, expressionOffsets, block,
+ isDefault: defaultKeyword != null, hasLabel: labels != null)
..fileOffset = firstToken.charOffset);
push(labels ?? NullValue.Labels);
}
@@ -4891,7 +4941,7 @@
Statement result = switchStatement;
if (target.hasUsers) {
result = forest.createLabeledStatement(result);
- target.resolveBreaks(forest, result);
+ target.resolveBreaks(forest, result, switchStatement);
}
exitLoopOrSwitch(result);
// This is matched by the [beginNode] call in [beginSwitchBlock].
@@ -5290,9 +5340,9 @@
/// immediately enclosing class. It is a static warning if the static type of
/// _id_ is not a subtype of _Tid_."
@override
- List<Initializer> buildFieldInitializer(bool isSynthetic, String name,
- int fieldNameOffset, int assignmentOffset, Expression expression,
- {DartType formalType}) {
+ List<Initializer> buildFieldInitializer(String name, int fieldNameOffset,
+ int assignmentOffset, Expression expression,
+ {FormalParameterBuilder formal}) {
Builder builder = declarationBuilder.lookupLocalMember(name);
if (builder?.next != null) {
// Duplicated name, already reported.
@@ -5341,22 +5391,27 @@
..fileOffset = assignmentOffset
];
} else {
- if (formalType != null &&
- !typeEnvironment.isSubtypeOf(formalType, builder.field.type,
- SubtypeCheckMode.ignoringNullabilities)) {
- libraryBuilder.addProblem(
- fasta.templateInitializingFormalTypeMismatch
- .withArguments(name, formalType, builder.field.type),
- assignmentOffset,
- noLength,
- uri,
- context: [
- fasta.messageInitializingFormalTypeMismatchField
- .withLocation(builder.fileUri, builder.charOffset, noLength)
- ]);
+ if (formal != null && formal.type != null) {
+ DartType formalType = formal.variable.type;
+ if (!typeEnvironment.isSubtypeOf(formalType, builder.fieldType,
+ SubtypeCheckMode.ignoringNullabilities)) {
+ libraryBuilder.addProblem(
+ fasta.templateInitializingFormalTypeMismatch.withArguments(
+ name,
+ formalType,
+ builder.fieldType,
+ libraryBuilder.isNonNullableByDefault),
+ assignmentOffset,
+ noLength,
+ uri,
+ context: [
+ fasta.messageInitializingFormalTypeMismatchField.withLocation(
+ builder.fileUri, builder.charOffset, noLength)
+ ]);
+ }
}
return builder.buildInitializer(assignmentOffset, expression,
- isSynthetic: isSynthetic);
+ isSynthetic: formal != null);
}
} else {
return <Initializer>[
@@ -5717,20 +5772,25 @@
users.add(statement);
}
- void resolveBreaks(Forest forest, Statement target) {
+ void resolveBreaks(
+ Forest forest, Statement target, Statement targetStatement) {
assert(isBreakTarget);
- for (BreakStatement user in users) {
+ for (BreakStatementImpl user in users) {
user.target = target;
+ user.targetStatement = targetStatement;
}
users.clear();
}
- void resolveContinues(Forest forest, Statement target) {
+ List<BreakStatementImpl> resolveContinues(Forest forest, Statement target) {
assert(isContinueTarget);
- for (BreakStatement user in users) {
+ List<BreakStatementImpl> statements = <BreakStatementImpl>[];
+ for (BreakStatementImpl user in users) {
user.target = target;
+ statements.add(user);
}
users.clear();
+ return statements;
}
void resolveGotos(Forest forest, SwitchCase target) {
@@ -5791,12 +5851,13 @@
unsupported("addGoto", charOffset, fileUri);
}
- void resolveBreaks(Forest forest, Statement target) {
- breakTarget.resolveBreaks(forest, target);
+ void resolveBreaks(
+ Forest forest, Statement target, Statement targetStatement) {
+ breakTarget.resolveBreaks(forest, target, targetStatement);
}
- void resolveContinues(Forest forest, Statement target) {
- continueTarget.resolveContinues(forest, target);
+ List<BreakStatementImpl> resolveContinues(Forest forest, Statement target) {
+ return continueTarget.resolveContinues(forest, target);
}
void resolveGotos(Forest forest, SwitchCase target) {
diff --git a/pkg/front_end/lib/src/fasta/kernel/class_hierarchy_builder.dart b/pkg/front_end/lib/src/fasta/kernel/class_hierarchy_builder.dart
index a1798c4..764c8ee 100644
--- a/pkg/front_end/lib/src/fasta/kernel/class_hierarchy_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/class_hierarchy_builder.dart
@@ -30,6 +30,8 @@
import 'package:kernel/type_algebra.dart' show Substitution;
import 'package:kernel/type_environment.dart';
+import 'package:kernel/src/future_or.dart';
+
import '../builder/builder.dart';
import '../builder/class_builder.dart';
import '../builder/field_builder.dart';
@@ -290,18 +292,18 @@
}
InterfaceType getKernelTypeAsInstanceOf(
- InterfaceType type, Class superclass) {
+ InterfaceType type, Class superclass, Library clientLibrary) {
Class kernelClass = type.classNode;
if (kernelClass == superclass) return type;
if (kernelClass == nullClass) {
if (superclass.typeParameters.isEmpty) {
- return coreTypes.legacyRawType(superclass);
+ return coreTypes.rawType(superclass, clientLibrary.nullable);
} else {
// This is a safe fall-back for dealing with `Null`. It will likely be
// faster to check for `Null` before calling this method.
return new InterfaceType(
superclass,
- Nullability.legacy,
+ clientLibrary.nullable,
new List<DartType>.filled(
superclass.typeParameters.length, coreTypes.nullType));
}
@@ -309,15 +311,49 @@
NamedTypeBuilder supertype = asSupertypeOf(kernelClass, superclass);
if (supertype == null) return null;
if (supertype.arguments == null && superclass.typeParameters.isEmpty) {
- return coreTypes.legacyRawType(superclass);
+ return coreTypes.rawType(superclass, type.nullability);
}
return Substitution.fromInterfaceType(type)
- .substituteType(supertype.build(null));
+ .substituteType(supertype.build(null))
+ .withNullability(type.nullability);
+ }
+
+ List<DartType> getKernelTypeArgumentsAsInstanceOf(
+ InterfaceType type, Class superclass) {
+ Class kernelClass = type.classNode;
+ if (kernelClass == superclass) return type.typeArguments;
+ if (kernelClass == nullClass) {
+ if (superclass.typeParameters.isEmpty) return const <DartType>[];
+ return new List<DartType>.filled(
+ superclass.typeParameters.length, coreTypes.nullType);
+ }
+ NamedTypeBuilder supertype = asSupertypeOf(kernelClass, superclass);
+ if (supertype == null) return null;
+ if (supertype.arguments == null && superclass.typeParameters.isEmpty) {
+ return const <DartType>[];
+ }
+ return (Substitution.fromInterfaceType(type)
+ .substituteType(supertype.build(null)) as InterfaceType)
+ .typeArguments;
}
InterfaceType getKernelLegacyLeastUpperBound(
- InterfaceType type1, InterfaceType type2) {
+ InterfaceType type1, InterfaceType type2, Library clientLibrary) {
if (type1 == type2) return type1;
+
+ // LLUB(Null, List<dynamic>*) works differently for opt-in and opt-out
+ // libraries. In opt-out libraries the legacy behavior is preserved, so
+ // LLUB(Null, List<dynamic>*) = List<dynamic>*. In opt-out libraries the
+ // rules imply that LLUB(Null, List<dynamic>*) = List<dynamic>?.
+ if (!clientLibrary.isNonNullableByDefault) {
+ if (type1 is InterfaceType && type1.classNode == nullClass) {
+ return type2;
+ }
+ if (type2 is InterfaceType && type2.classNode == nullClass) {
+ return type1;
+ }
+ }
+
ClassHierarchyNode node1 = getNodeFromKernelClass(type1.classNode);
ClassHierarchyNode node2 = getNodeFromKernelClass(type2.classNode);
Set<ClassHierarchyNode> nodes1 = node1.computeAllSuperNodes(this).toSet();
@@ -328,30 +364,37 @@
ClassHierarchyNode node = nodes2[i];
if (node == null) continue;
if (nodes1.contains(node)) {
- DartType candidate1 =
- getKernelTypeAsInstanceOf(type1, node.classBuilder.cls);
- DartType candidate2 =
- getKernelTypeAsInstanceOf(type2, node.classBuilder.cls);
+ DartType candidate1 = getKernelTypeAsInstanceOf(
+ type1, node.classBuilder.cls, clientLibrary);
+ DartType candidate2 = getKernelTypeAsInstanceOf(
+ type2, node.classBuilder.cls, clientLibrary);
if (candidate1 == candidate2) {
common.add(node);
}
}
}
- if (common.length == 1) return coreTypes.objectLegacyRawType;
+ if (common.length == 1) {
+ return coreTypes.objectRawType(
+ uniteNullabilities(type1.nullability, type2.nullability));
+ }
common.sort(ClassHierarchyNode.compareMaxInheritancePath);
for (int i = 0; i < common.length - 1; i++) {
ClassHierarchyNode node = common[i];
if (node.maxInheritancePath != common[i + 1].maxInheritancePath) {
- return getKernelTypeAsInstanceOf(type1, node.classBuilder.cls);
+ return getKernelTypeAsInstanceOf(
+ type1, node.classBuilder.cls, clientLibrary)
+ .withNullability(
+ uniteNullabilities(type1.nullability, type2.nullability));
} else {
do {
i++;
} while (node.maxInheritancePath == common[i + 1].maxInheritancePath);
}
}
- return coreTypes.objectLegacyRawType;
+ return coreTypes.objectRawType(
+ uniteNullabilities(type1.nullability, type2.nullability));
}
Member getInterfaceMemberKernel(Class cls, Name name, bool isSetter) {
@@ -1964,10 +2007,10 @@
: super(coreTypes, gatherer);
Supertype asInstantiationOf(Supertype type, Class superclass) {
- InterfaceType interfaceType =
- gatherer.getTypeAsInstanceOf(type.asInterfaceType, superclass);
- if (interfaceType == null) return null;
- return new Supertype(interfaceType.classNode, interfaceType.typeArguments);
+ List<DartType> arguments =
+ gatherer.getTypeArgumentsAsInstanceOf(type.asInterfaceType, superclass);
+ if (arguments == null) return null;
+ return new Supertype(superclass, arguments);
}
void reportProblem(Message message, Class kernelClass) {
@@ -2003,21 +2046,27 @@
InterfaceType get nullType => hierarchy.coreTypes.nullType;
@override
- InterfaceType get objectLegacyRawType =>
- hierarchy.coreTypes.objectLegacyRawType;
-
- @override
- InterfaceType get functionLegacyRawType =>
- hierarchy.coreTypes.functionLegacyRawType;
-
- @override
- void addLowerBound(TypeConstraint constraint, DartType lower) {
- constraint.lower = getStandardUpperBound(constraint.lower, lower);
+ InterfaceType get objectLegacyRawType {
+ return hierarchy.coreTypes.objectLegacyRawType;
}
@override
- void addUpperBound(TypeConstraint constraint, DartType upper) {
- constraint.upper = getStandardLowerBound(constraint.upper, upper);
+ InterfaceType get functionLegacyRawType {
+ return hierarchy.coreTypes.functionLegacyRawType;
+ }
+
+ @override
+ void addLowerBound(
+ TypeConstraint constraint, DartType lower, Library clientLibrary) {
+ constraint.lower =
+ getStandardUpperBound(constraint.lower, lower, clientLibrary);
+ }
+
+ @override
+ void addUpperBound(
+ TypeConstraint constraint, DartType upper, Library clientLibrary) {
+ constraint.upper =
+ getStandardLowerBound(constraint.upper, upper, clientLibrary);
}
@override
@@ -2026,8 +2075,15 @@
}
@override
- InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass) {
- return hierarchy.getKernelTypeAsInstanceOf(type, superclass);
+ InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass,
+ Library clientLibrary, CoreTypes coreTypes) {
+ return hierarchy.getKernelTypeAsInstanceOf(type, superclass, clientLibrary);
+ }
+
+ @override
+ List<DartType> getTypeArgumentsAsInstanceOf(
+ InterfaceType type, Class superclass) {
+ return hierarchy.getKernelTypeArgumentsAsInstanceOf(type, superclass);
}
@override
@@ -2044,8 +2100,9 @@
@override
InterfaceType getLegacyLeastUpperBound(
- InterfaceType type1, InterfaceType type2) {
- return hierarchy.getKernelLegacyLeastUpperBound(type1, type2);
+ InterfaceType type1, InterfaceType type2, Library clientLibrary) {
+ return hierarchy.getKernelLegacyLeastUpperBound(
+ type1, type2, clientLibrary);
}
}
@@ -2086,7 +2143,8 @@
hierarchy.getKernelTypeAsInstanceOf(
hierarchy.coreTypes.thisInterfaceType(
classBuilder.cls, classBuilder.library.nonNullable),
- b.member.enclosingClass))
+ b.member.enclosingClass,
+ classBuilder.library.library))
.substituteType(type);
if (!a.hadTypesInferred || !b.isSetter) {
inferReturnType(
@@ -2110,7 +2168,8 @@
hierarchy.getKernelTypeAsInstanceOf(
hierarchy.coreTypes.thisInterfaceType(
classBuilder.cls, classBuilder.library.nonNullable),
- b.member.enclosingClass))
+ b.member.enclosingClass,
+ classBuilder.library.library))
.substituteType(type);
if (!a.hadTypesInferred || !b.isGetter) {
inferParameterType(classBuilder, a, a.formals.single, type,
@@ -2136,7 +2195,8 @@
hierarchy.getKernelTypeAsInstanceOf(
hierarchy.coreTypes.thisInterfaceType(
classBuilder.cls, classBuilder.library.nonNullable),
- b.member.enclosingClass))
+ b.member.enclosingClass,
+ classBuilder.library.library))
.substituteType(type);
if (type != a.fieldType) {
if (a.hadTypesInferred) {
@@ -2317,7 +2377,7 @@
classBuilder.fileUri);
}
return Substitution.fromInterfaceType(hierarchy.getKernelTypeAsInstanceOf(
- thisType, member.enclosingClass))
+ thisType, member.enclosingClass, classBuilder.library.library))
.substituteType(type);
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/constant_collection_builders.dart b/pkg/front_end/lib/src/fasta/kernel/constant_collection_builders.dart
index b3b7d64..d948589 100644
--- a/pkg/front_end/lib/src/fasta/kernel/constant_collection_builders.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/constant_collection_builders.dart
@@ -116,12 +116,16 @@
@override
void addConstant(Constant constant, TreeNode context) {
if (!evaluator.hasPrimitiveEqual(constant)) {
- evaluator.report(context,
- templateConstEvalElementImplementsEqual.withArguments(constant));
+ evaluator.report(
+ context,
+ templateConstEvalElementImplementsEqual.withArguments(
+ constant, evaluator.isNonNullableByDefault));
}
if (!seen.add(constant)) {
evaluator.report(
- context, templateConstEvalDuplicateElement.withArguments(constant));
+ context,
+ templateConstEvalDuplicateElement.withArguments(
+ constant, evaluator.isNonNullableByDefault));
}
List<Constant> lastPart;
@@ -239,11 +243,15 @@
}
if (!evaluator.hasPrimitiveEqual(key)) {
evaluator.report(
- keyContext, templateConstEvalKeyImplementsEqual.withArguments(key));
+ keyContext,
+ templateConstEvalKeyImplementsEqual.withArguments(
+ key, evaluator.isNonNullableByDefault));
}
if (!seenKeys.add(key)) {
evaluator.report(
- keyContext, templateConstEvalDuplicateKey.withArguments(key));
+ keyContext,
+ templateConstEvalDuplicateKey.withArguments(
+ key, evaluator.isNonNullableByDefault));
}
lastPart.add(new ConstantMapEntry(
evaluator.ensureIsSubtype(key, keyType, keyContext),
diff --git a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
index 35868d9..ec1e42b 100644
--- a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
@@ -552,6 +552,9 @@
bool get targetingJavaScript => numberSemantics == NumberSemantics.js;
+ bool get isNonNullableByDefault =>
+ _staticTypeContext.nonNullable == Nullability.nonNullable;
+
ConstantEvaluator(this.backend, this.environmentDefines, this.typeEnvironment,
this.errorReporter,
{this.desugarSets = false,
@@ -957,8 +960,10 @@
if (nameValue is StringConstant && isValidSymbolName(nameValue.value)) {
return canonicalize(new SymbolConstant(nameValue.value, null));
}
- return report(node.arguments.positional.first,
- templateConstEvalInvalidSymbolName.withArguments(nameValue));
+ return report(
+ node.arguments.positional.first,
+ templateConstEvalInvalidSymbolName.withArguments(
+ nameValue, isNonNullableByDefault));
}
final List<DartType> typeArguments =
@@ -1269,7 +1274,8 @@
templateConstEvalInvalidType.withArguments(
message,
typeEnvironment.coreTypes.stringLegacyRawType,
- message.getType(_staticTypeContext)));
+ message.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
}
} else {
@@ -1278,7 +1284,8 @@
templateConstEvalInvalidType.withArguments(
condition,
typeEnvironment.coreTypes.boolLegacyRawType,
- condition.getType(_staticTypeContext)));
+ condition.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
}
@@ -1323,8 +1330,8 @@
} else {
return report(
node,
- templateConstEvalInvalidEqualsOperandType.withArguments(
- receiver, receiver.getType(_staticTypeContext)));
+ templateConstEvalInvalidEqualsOperandType.withArguments(receiver,
+ receiver.getType(_staticTypeContext), isNonNullableByDefault));
}
}
@@ -1344,7 +1351,8 @@
'+',
receiver,
typeEnvironment.coreTypes.stringLegacyRawType,
- other.getType(_staticTypeContext)));
+ other.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
}
} else if (intFolder.isInt(receiver)) {
@@ -1364,7 +1372,8 @@
op,
other,
typeEnvironment.coreTypes.intLegacyRawType,
- other.getType(_staticTypeContext)));
+ other.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
num receiverValue = (receiver as PrimitiveConstant<num>).value;
return canonicalize(evaluateBinaryNumericOperation(
@@ -1376,7 +1385,8 @@
op,
receiver,
typeEnvironment.coreTypes.numLegacyRawType,
- other.getType(_staticTypeContext)));
+ other.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
} else if (receiver is DoubleConstant) {
if ((op == '|' || op == '&' || op == '^') ||
@@ -1387,7 +1397,8 @@
op,
receiver,
typeEnvironment.coreTypes.intLegacyRawType,
- receiver.getType(_staticTypeContext)));
+ receiver.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
if (arguments.length == 0) {
switch (op) {
@@ -1408,7 +1419,8 @@
op,
receiver,
typeEnvironment.coreTypes.numLegacyRawType,
- other.getType(_staticTypeContext)));
+ other.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
} else if (receiver is BoolConstant) {
if (arguments.length == 1) {
@@ -1431,8 +1443,10 @@
return report(node, messageConstEvalNullValue);
}
- return report(node,
- templateConstEvalInvalidMethodInvocation.withArguments(op, receiver));
+ return report(
+ node,
+ templateConstEvalInvalidMethodInvocation.withArguments(
+ op, receiver, isNonNullableByDefault));
}
@override
@@ -1461,12 +1475,13 @@
node.operator,
left,
typeEnvironment.coreTypes.boolLegacyRawType,
- right.getType(_staticTypeContext)));
+ right.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
return report(
node,
templateConstEvalInvalidMethodInvocation.withArguments(
- node.operator, left));
+ node.operator, left, isNonNullableByDefault));
case '&&':
if (left is BoolConstant) {
if (!left.value) return falseConstant;
@@ -1482,12 +1497,13 @@
node.operator,
left,
typeEnvironment.coreTypes.boolLegacyRawType,
- right.getType(_staticTypeContext)));
+ right.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
return report(
node,
templateConstEvalInvalidMethodInvocation.withArguments(
- node.operator, left));
+ node.operator, left, isNonNullableByDefault));
case '??':
return (left is! NullConstant)
? left
@@ -1496,7 +1512,7 @@
return report(
node,
templateConstEvalInvalidMethodInvocation.withArguments(
- node.operator, left));
+ node.operator, left, isNonNullableByDefault));
}
}
@@ -1522,7 +1538,8 @@
templateConstEvalInvalidType.withArguments(
condition,
typeEnvironment.coreTypes.boolLegacyRawType,
- condition.getType(_staticTypeContext)));
+ condition.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
}
@@ -1554,7 +1571,7 @@
return report(
node,
templateConstEvalInvalidPropertyGet.withArguments(
- node.name.name, receiver));
+ node.name.name, receiver, isNonNullableByDefault));
}
@override
@@ -1642,8 +1659,8 @@
} else {
return report(
node,
- templateConstEvalInvalidStringInterpolationOperand
- .withArguments(constant));
+ templateConstEvalInvalidStringInterpolationOperand.withArguments(
+ constant, isNonNullableByDefault));
}
}
if (concatenated.length > 1) {
@@ -1806,7 +1823,8 @@
templateConstEvalInvalidType.withArguments(
constant,
typeEnvironment.coreTypes.boolLegacyRawType,
- constant.getType(_staticTypeContext)));
+ constant.getType(_staticTypeContext),
+ isNonNullableByDefault));
}
@override
@@ -1917,8 +1935,8 @@
if (!isSubtype(constant, type)) {
return report(
node,
- templateConstEvalInvalidType.withArguments(
- constant, type, constant.getType(_staticTypeContext)));
+ templateConstEvalInvalidType.withArguments(constant, type,
+ constant.getType(_staticTypeContext), isNonNullableByDefault));
}
return constant;
}
@@ -1943,7 +1961,9 @@
if (!isInstantiated(result)) {
return report(
- node, templateConstEvalFreeTypeParameter.withArguments(type));
+ node,
+ templateConstEvalFreeTypeParameter.withArguments(
+ type, isNonNullableByDefault));
}
return result;
diff --git a/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart b/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
index ac47c4d..6a2dc65 100644
--- a/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/expression_generator.dart
@@ -2790,7 +2790,8 @@
message = templateDeferredTypeAnnotation
.withArguments(
_helper.buildDartType(new UnresolvedType(type, charOffset, _uri)),
- prefixGenerator._plainNameForRead)
+ prefixGenerator._plainNameForRead,
+ _helper.libraryBuilder.isNonNullableByDefault)
.withLocation(
_uri, charOffset, lengthOfSpan(prefixGenerator.token, token));
}
@@ -3526,7 +3527,7 @@
generator is! ThisPropertyAccessGenerator) {
return generator.buildFieldInitializer(initializedFields);
}
- return _helper.buildFieldInitializer(false, generator._plainNameForRead,
+ return _helper.buildFieldInitializer(generator._plainNameForRead,
offsetForToken(generator.token), fileOffset, value);
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/expression_generator_helper.dart b/pkg/front_end/lib/src/fasta/kernel/expression_generator_helper.dart
index c83a89b..f92b281 100644
--- a/pkg/front_end/lib/src/fasta/kernel/expression_generator_helper.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/expression_generator_helper.dart
@@ -7,6 +7,7 @@
import 'package:_fe_analyzer_shared/src/scanner/token.dart' show Token;
import '../builder/builder.dart';
+import '../builder/formal_parameter_builder.dart';
import '../builder/library_builder.dart';
import '../builder/prefix_builder.dart';
import '../builder/type_declaration_builder.dart';
@@ -63,9 +64,9 @@
Initializer buildInvalidInitializer(Expression expression, [int offset]);
- List<Initializer> buildFieldInitializer(bool isSynthetic, String name,
- int fieldNameOffset, int assignmentOffset, Expression expression,
- {DartType formalType});
+ List<Initializer> buildFieldInitializer(String name, int fieldNameOffset,
+ int assignmentOffset, Expression expression,
+ {FormalParameterBuilder formal});
Initializer buildSuperInitializer(
bool isSynthetic, Constructor constructor, Arguments arguments,
diff --git a/pkg/front_end/lib/src/fasta/kernel/forest.dart b/pkg/front_end/lib/src/fasta/kernel/forest.dart
index 391ea59..a9c7d9d 100644
--- a/pkg/front_end/lib/src/fasta/kernel/forest.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/forest.dart
@@ -323,7 +323,7 @@
Statement createBreakStatement(int fileOffset, Object label) {
assert(fileOffset != null);
// TODO(johnniwinther): Use [label]?
- return new BreakStatement(null)..fileOffset = fileOffset;
+ return new BreakStatementImpl(isContinue: false)..fileOffset = fileOffset;
}
/// Return a representation of a catch clause.
@@ -355,7 +355,7 @@
Statement createContinueStatement(int fileOffset, Object label) {
assert(fileOffset != null);
// TODO(johnniwinther): Use [label]?
- return new BreakStatement(null)..fileOffset = fileOffset;
+ return new BreakStatementImpl(isContinue: true)..fileOffset = fileOffset;
}
/// Return a representation of a do statement.
diff --git a/pkg/front_end/lib/src/fasta/kernel/forwarding_node.dart b/pkg/front_end/lib/src/fasta/kernel/forwarding_node.dart
index 4e1e2a5..55ee9ab 100644
--- a/pkg/front_end/lib/src/fasta/kernel/forwarding_node.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/forwarding_node.dart
@@ -384,7 +384,8 @@
return Substitution.fromInterfaceType(hierarchy.getKernelTypeAsInstanceOf(
hierarchy.coreTypes
.thisInterfaceType(class_, class_.enclosingLibrary.nonNullable),
- candidate.enclosingClass));
+ candidate.enclosingClass,
+ class_.enclosingLibrary));
}
List<VariableDeclaration> getPositionalParameters(Member member) {
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 26597c3..9c6a0bb 100644
--- a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
@@ -4,6 +4,8 @@
import 'dart:core' hide MapEntry;
+import 'package:_fe_analyzer_shared/src/util/link.dart';
+
import 'package:kernel/ast.dart';
import 'package:kernel/type_algebra.dart' show Substitution;
@@ -16,8 +18,6 @@
InstrumentationValueForType,
InstrumentationValueForTypeArgs;
-import '../builder/library_builder.dart';
-
import '../fasta_codes.dart'
show
messageCantDisambiguateAmbiguousInformation,
@@ -25,7 +25,6 @@
messageNonNullAwareSpreadIsNull,
messageSwitchExpressionNotAssignableCause,
noLength,
- templateCantInferTypeDueToCircularity,
templateForInLoopElementTypeNotAssignable,
templateForInLoopTypeNotIterable,
templateIntegerLiteralIsOutOfRange,
@@ -340,9 +339,15 @@
}
@override
- StatementInferenceResult visitBreakStatement(BreakStatement node) {
+ StatementInferenceResult visitBreakStatement(
+ covariant BreakStatementImpl node) {
// TODO(johnniwinther): Refactor break/continue encoding.
- inferrer.flowAnalysis.handleBreak(node.target);
+ assert(node.targetStatement != null);
+ if (node.isContinue) {
+ inferrer.flowAnalysis.handleContinue(node.targetStatement);
+ } else {
+ inferrer.flowAnalysis.handleBreak(node.targetStatement);
+ }
return const StatementInferenceResult();
}
@@ -350,8 +355,14 @@
ExpressionInferenceResult result = inferrer.inferExpression(
node.variable.initializer, typeContext, true,
isVoidAllowed: false);
+
node.variable.initializer = result.expression..parent = node.variable;
node.variable.type = result.inferredType;
+ NullAwareGuard nullAwareGuard;
+ if (node.isNullAware) {
+ nullAwareGuard = inferrer.createNullAwareGuard(node.variable);
+ }
+
List<ExpressionInferenceResult> expressionResults =
<ExpressionInferenceResult>[];
for (Expression expression in node.expressions) {
@@ -367,11 +378,6 @@
}
if (node.isNullAware) {
- Member equalsMember = inferrer
- .findInterfaceMember(result.inferredType, equalsName, node.fileOffset)
- .member;
- NullAwareGuard nullAwareGuard = new NullAwareGuard(
- node.variable, node.variable.fileOffset, equalsMember);
replacement =
nullAwareGuard.createExpression(result.inferredType, replacement);
} else {
@@ -409,8 +415,8 @@
isReachable: isOtherwiseReachable);
inferrer.flowAnalysis.conditional_end(node.condition, node.otherwise);
DartType inferredType = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(
- thenResult.inferredType, otherwiseResult.inferredType);
+ .getStandardUpperBound(thenResult.inferredType,
+ otherwiseResult.inferredType, inferrer.library.library);
node.staticType = inferredType;
return new ExpressionInferenceResult(inferredType, node);
}
@@ -418,44 +424,7 @@
@override
ExpressionInferenceResult visitConstructorInvocation(
ConstructorInvocation node, DartType typeContext) {
- LibraryBuilder library = inferrer.engine.beingInferred[node.target];
- if (library != null) {
- // There is a cyclic dependency where inferring the types of the
- // initializing formals of a constructor required us to infer the
- // corresponding field type which required us to know the type of the
- // constructor.
- String name = node.target.enclosingClass.name;
- if (node.target.name.name.isNotEmpty) {
- // TODO(ahe): Use `inferrer.helper.constructorNameForDiagnostics`
- // instead. However, `inferrer.helper` may be null.
- name += ".${node.target.name.name}";
- }
- library.addProblem(
- templateCantInferTypeDueToCircularity.withArguments(name),
- node.target.fileOffset,
- name.length,
- node.target.fileUri);
- for (VariableDeclaration declaration
- in node.target.function.positionalParameters) {
- declaration.type ??= const InvalidType();
- }
- for (VariableDeclaration declaration
- in node.target.function.namedParameters) {
- declaration.type ??= const InvalidType();
- }
- } else if ((library = inferrer.engine.toBeInferred[node.target]) != null) {
- inferrer.engine.toBeInferred.remove(node.target);
- inferrer.engine.beingInferred[node.target] = library;
- for (VariableDeclaration declaration
- in node.target.function.positionalParameters) {
- inferrer.engine.inferInitializingFormal(declaration, node.target);
- }
- for (VariableDeclaration declaration
- in node.target.function.namedParameters) {
- inferrer.engine.inferInitializingFormal(declaration, node.target);
- }
- inferrer.engine.beingInferred.remove(node.target);
- }
+ inferrer.inferConstructorParameterTypes(node.target);
bool hasExplicitTypeArguments =
getExplicitTypeArguments(node.arguments) != null;
DartType inferredType = inferrer.inferInvocation(typeContext,
@@ -477,7 +446,7 @@
@override
StatementInferenceResult visitContinueSwitchStatement(
ContinueSwitchStatement node) {
- // No inference needs to be done.
+ inferrer.flowAnalysis.handleContinue(node.target.body);
return const StatementInferenceResult();
}
@@ -846,10 +815,13 @@
if (typeNeeded) {
inferredType = const DynamicType();
if (inferredExpressionType is InterfaceType) {
- InterfaceType supertype = inferrer.classHierarchy
- .getTypeAsInstanceOf(inferredExpressionType, iterableClass);
- if (supertype != null) {
- inferredType = supertype.typeArguments[0];
+ // TODO(johnniwinther): Should we use the type of
+ // `iterable.iterator.current` instead?
+ List<DartType> supertypeArguments = inferrer.classHierarchy
+ .getTypeArgumentsAsInstanceOf(
+ inferredExpressionType, iterableClass);
+ if (supertypeArguments != null) {
+ inferredType = supertypeArguments[0];
}
}
}
@@ -1084,7 +1056,7 @@
node.condition = condition..parent = node;
}
- inferrer.flowAnalysis.for_bodyBegin(node.body, node.condition);
+ inferrer.flowAnalysis.for_bodyBegin(node, node.condition);
StatementInferenceResult bodyResult = inferrer.inferStatement(node.body);
if (bodyResult.hasChanged) {
node.body = bodyResult.statement..parent = node;
@@ -1176,7 +1148,8 @@
// UP(t0, t1)
// - Then the inferred type is T.
DartType inferredType = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(lhsResult.inferredType, rhsResult.inferredType);
+ .getStandardUpperBound(lhsResult.inferredType, rhsResult.inferredType,
+ inferrer.library.library);
VariableDeclaration variable =
createVariable(lhsResult.expression, lhsResult.inferredType);
MethodInvocation equalsNull = createEqualsNull(
@@ -1308,9 +1281,10 @@
DartType getSpreadElementType(DartType spreadType, bool isNullAware) {
if (spreadType is InterfaceType) {
- InterfaceType supertype = inferrer.typeSchemaEnvironment
- .getTypeAsInstanceOf(spreadType, inferrer.coreTypes.iterableClass);
- if (supertype != null) return supertype.typeArguments[0];
+ List<DartType> supertypeArguments = inferrer.typeSchemaEnvironment
+ .getTypeArgumentsAsInstanceOf(
+ spreadType, inferrer.coreTypes.iterableClass);
+ if (supertypeArguments != null) return supertypeArguments[0];
if (spreadType.classNode == inferrer.coreTypes.nullClass && isNullAware) {
return spreadType;
}
@@ -1353,7 +1327,8 @@
1);
} else {
replacement = inferrer.helper.buildProblem(
- templateSpreadTypeMismatch.withArguments(spreadType),
+ templateSpreadTypeMismatch.withArguments(
+ spreadType, inferrer.isNonNullableByDefault),
element.expression.fileOffset,
1);
}
@@ -1361,7 +1336,9 @@
if (!inferrer.isAssignable(inferredTypeArgument, spreadElementType)) {
replacement = inferrer.helper.buildProblem(
templateSpreadElementTypeMismatch.withArguments(
- spreadElementType, inferredTypeArgument),
+ spreadElementType,
+ inferredTypeArgument,
+ inferrer.isNonNullableByDefault),
element.expression.fileOffset,
1);
}
@@ -1404,7 +1381,9 @@
otherwiseResult == null
? thenResult.inferredType
: inferrer.typeSchemaEnvironment.getStandardUpperBound(
- thenResult.inferredType, otherwiseResult.inferredType),
+ thenResult.inferredType,
+ otherwiseResult.inferredType,
+ inferrer.library.library),
element);
} else if (element is ForElement) {
// TODO(johnniwinther): Use _visitStatements instead.
@@ -1688,11 +1667,12 @@
void storeSpreadMapEntryElementTypes(DartType spreadMapEntryType,
bool isNullAware, List<DartType> output, int offset) {
if (spreadMapEntryType is InterfaceType) {
- InterfaceType supertype = inferrer.typeSchemaEnvironment
- .getTypeAsInstanceOf(spreadMapEntryType, inferrer.coreTypes.mapClass);
- if (supertype != null) {
- output[offset] = supertype.typeArguments[0];
- output[offset + 1] = supertype.typeArguments[1];
+ List<DartType> supertypeArguments = inferrer.typeSchemaEnvironment
+ .getTypeArgumentsAsInstanceOf(
+ spreadMapEntryType, inferrer.coreTypes.mapClass);
+ if (supertypeArguments != null) {
+ output[offset] = supertypeArguments[0];
+ output[offset + 1] = supertypeArguments[1];
} else if (spreadMapEntryType.classNode == inferrer.coreTypes.nullClass &&
isNullAware) {
output[offset] = output[offset + 1] = spreadMapEntryType;
@@ -1755,8 +1735,8 @@
} else {
replacement = new MapEntry(
inferrer.helper.buildProblem(
- templateSpreadMapEntryTypeMismatch
- .withArguments(spreadType),
+ templateSpreadMapEntryTypeMismatch.withArguments(
+ spreadType, inferrer.isNonNullableByDefault),
entry.expression.fileOffset,
1),
new NullLiteral())
@@ -1768,14 +1748,18 @@
if (!inferrer.isAssignable(inferredKeyType, actualKeyType)) {
keyError = inferrer.helper.buildProblem(
templateSpreadMapEntryElementKeyTypeMismatch.withArguments(
- actualKeyType, inferredKeyType),
+ actualKeyType,
+ inferredKeyType,
+ inferrer.isNonNullableByDefault),
entry.expression.fileOffset,
1);
}
if (!inferrer.isAssignable(inferredValueType, actualValueType)) {
valueError = inferrer.helper.buildProblem(
templateSpreadMapEntryElementValueTypeMismatch.withArguments(
- actualValueType, inferredValueType),
+ actualValueType,
+ inferredValueType,
+ inferrer.isNonNullableByDefault),
entry.expression.fileOffset,
1);
}
@@ -1867,13 +1851,15 @@
typeChecksNeeded);
int length = actualTypes.length;
actualTypes[length - 2] = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(actualKeyType, actualTypes[length - 2]);
+ .getStandardUpperBound(actualKeyType, actualTypes[length - 2],
+ inferrer.library.library);
actualTypes[length - 1] = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(actualValueType, actualTypes[length - 1]);
+ .getStandardUpperBound(actualValueType, actualTypes[length - 1],
+ inferrer.library.library);
int lengthForSet = actualTypesForSet.length;
actualTypesForSet[lengthForSet - 1] = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(
- actualTypeForSet, actualTypesForSet[lengthForSet - 1]);
+ .getStandardUpperBound(actualTypeForSet,
+ actualTypesForSet[lengthForSet - 1], inferrer.library.library);
entry.otherwise = otherwise..parent = entry;
}
return entry;
@@ -2031,8 +2017,8 @@
if (iterableSpreadOffset != null) {
replacement = new MapEntry(
inferrer.helper.buildProblem(
- templateSpreadMapEntryTypeMismatch
- .withArguments(iterableSpreadType),
+ templateSpreadMapEntryTypeMismatch.withArguments(
+ iterableSpreadType, inferrer.isNonNullableByDefault),
iterableSpreadOffset,
1),
new NullLiteral());
@@ -2154,8 +2140,11 @@
iterableSpreadType = null;
DartType spreadTypeContext = const UnknownType();
if (typeContextIsIterable && !typeContextIsMap) {
- spreadTypeContext = inferrer.typeSchemaEnvironment
- .getTypeAsInstanceOf(typeContext, inferrer.coreTypes.iterableClass);
+ spreadTypeContext = inferrer.typeSchemaEnvironment.getTypeAsInstanceOf(
+ typeContext,
+ inferrer.coreTypes.iterableClass,
+ inferrer.library.library,
+ inferrer.coreTypes);
} else if (!typeContextIsIterable && typeContextIsMap) {
spreadTypeContext = new InterfaceType(
inferrer.coreTypes.mapClass,
@@ -2301,71 +2290,7 @@
@override
ExpressionInferenceResult visitMethodInvocation(
covariant MethodInvocationImpl node, DartType typeContext) {
- if (node.name.name == 'unary-' &&
- node.arguments.types.isEmpty &&
- node.arguments.positional.isEmpty &&
- node.arguments.named.isEmpty) {
- // Replace integer literals in a double context with the corresponding
- // double literal if it's exact. For double literals, the negation is
- // folded away. In any non-double context, or if there is no exact
- // double value, then the corresponding integer literal is left. The
- // negation is not folded away so that platforms with web literals can
- // distinguish between (non-negated) 0x8000000000000000 represented as
- // integer literal -9223372036854775808 which should be a positive number,
- // and negated 9223372036854775808 represented as
- // -9223372036854775808.unary-() which should be a negative number.
- if (node.receiver is IntJudgment) {
- IntJudgment receiver = node.receiver;
- if (inferrer.isDoubleContext(typeContext)) {
- double doubleValue = receiver.asDouble(negated: true);
- if (doubleValue != null) {
- Expression replacement = new DoubleLiteral(doubleValue)
- ..fileOffset = node.fileOffset;
- DartType inferredType =
- inferrer.coreTypes.doubleRawType(inferrer.library.nonNullable);
- return new ExpressionInferenceResult(inferredType, replacement);
- }
- }
- Expression error = checkWebIntLiteralsErrorIfUnexact(
- inferrer, receiver.value, receiver.literal, receiver.fileOffset);
- if (error != null) {
- return new ExpressionInferenceResult(const DynamicType(), error);
- }
- } else if (node.receiver is ShadowLargeIntLiteral) {
- ShadowLargeIntLiteral receiver = node.receiver;
- if (!receiver.isParenthesized) {
- if (inferrer.isDoubleContext(typeContext)) {
- double doubleValue = receiver.asDouble(negated: true);
- if (doubleValue != null) {
- Expression replacement = new DoubleLiteral(doubleValue)
- ..fileOffset = node.fileOffset;
- DartType inferredType = inferrer.coreTypes
- .doubleRawType(inferrer.library.nonNullable);
- return new ExpressionInferenceResult(inferredType, replacement);
- }
- }
- int intValue = receiver.asInt64(negated: true);
- if (intValue == null) {
- Expression error = inferrer.helper.buildProblem(
- templateIntegerLiteralIsOutOfRange
- .withArguments(receiver.literal),
- receiver.fileOffset,
- receiver.literal.length);
- return new ExpressionInferenceResult(const DynamicType(), error);
- }
- if (intValue != null) {
- Expression error = checkWebIntLiteralsErrorIfUnexact(
- inferrer, intValue, receiver.literal, receiver.fileOffset);
- if (error != null) {
- return new ExpressionInferenceResult(const DynamicType(), error);
- }
- node.receiver = new IntLiteral(-intValue)
- ..fileOffset = node.receiver.fileOffset
- ..parent = node;
- }
- }
- }
- }
+ assert(node.name != unaryMinusName);
return inferrer.inferMethodInvocation(node, typeContext);
}
@@ -2410,59 +2335,54 @@
ExpressionInferenceResult visitNullAwareMethodInvocation(
NullAwareMethodInvocation node, DartType typeContext) {
- inferrer.inferSyntheticVariable(node.variable);
+ Link<NullAwareGuard> nullAwareGuards =
+ inferrer.inferSyntheticVariableNullAware(node.variable);
+ NullAwareGuard nullAwareGuard =
+ inferrer.createNullAwareGuard(node.variable);
ExpressionInferenceResult invocationResult = inferrer.inferExpression(
node.invocation, typeContext, true,
isVoidAllowed: true);
- Member equalsMember = inferrer
- .findInterfaceMember(node.variable.type, equalsName, node.fileOffset)
- .member;
return new ExpressionInferenceResult.nullAware(
invocationResult.inferredType,
invocationResult.expression,
- new NullAwareGuard(node.variable, node.fileOffset, equalsMember));
+ nullAwareGuards.prepend(nullAwareGuard));
}
ExpressionInferenceResult visitNullAwarePropertyGet(
NullAwarePropertyGet node, DartType typeContext) {
- inferrer.inferSyntheticVariable(node.variable);
+ Link<NullAwareGuard> nullAwareGuards =
+ inferrer.inferSyntheticVariableNullAware(node.variable);
+ NullAwareGuard nullAwareGuard =
+ inferrer.createNullAwareGuard(node.variable);
ExpressionInferenceResult readResult =
- inferrer.inferExpression(node.read, const UnknownType(), true);
- Member equalsMember = inferrer
- .findInterfaceMember(node.variable.type, equalsName, node.fileOffset)
- .member;
- return new ExpressionInferenceResult.nullAware(
- readResult.inferredType,
- readResult.expression,
- new NullAwareGuard(node.variable, node.fileOffset, equalsMember));
+ inferrer.inferExpression(node.read, typeContext, true);
+ return new ExpressionInferenceResult.nullAware(readResult.inferredType,
+ readResult.expression, nullAwareGuards.prepend(nullAwareGuard));
}
ExpressionInferenceResult visitNullAwarePropertySet(
NullAwarePropertySet node, DartType typeContext) {
- inferrer.inferSyntheticVariable(node.variable);
+ Link<NullAwareGuard> nullAwareGuards =
+ inferrer.inferSyntheticVariableNullAware(node.variable);
+ NullAwareGuard nullAwareGuard =
+ inferrer.createNullAwareGuard(node.variable);
ExpressionInferenceResult writeResult =
inferrer.inferExpression(node.write, typeContext, true);
- Member equalsMember = inferrer
- .findInterfaceMember(node.variable.type, equalsName, node.fileOffset)
- .member;
- return new ExpressionInferenceResult.nullAware(
- writeResult.inferredType,
- writeResult.expression,
- new NullAwareGuard(node.variable, node.fileOffset, equalsMember));
+ return new ExpressionInferenceResult.nullAware(writeResult.inferredType,
+ writeResult.expression, nullAwareGuards.prepend(nullAwareGuard));
}
ExpressionInferenceResult visitNullAwareExtension(
NullAwareExtension node, DartType typeContext) {
inferrer.inferSyntheticVariable(node.variable);
+ NullAwareGuard nullAwareGuard =
+ inferrer.createNullAwareGuard(node.variable);
ExpressionInferenceResult expressionResult =
inferrer.inferExpression(node.expression, const UnknownType(), true);
- Member equalsMember = inferrer
- .findInterfaceMember(node.variable.type, equalsName, node.fileOffset)
- .member;
return new ExpressionInferenceResult.nullAware(
expressionResult.inferredType,
expressionResult.expression,
- new NullAwareGuard(node.variable, node.fileOffset, equalsMember));
+ const Link<NullAwareGuard>().prepend(nullAwareGuard));
}
ExpressionInferenceResult visitStaticPostIncDec(
@@ -2530,10 +2450,10 @@
node.receiver, const UnknownType(), true,
isVoidAllowed: false);
- NullAwareGuard nullAwareGuard;
+ Link<NullAwareGuard> nullAwareGuards;
Expression receiver;
if (inferrer.isNonNullableByDefault) {
- nullAwareGuard = receiverResult.nullAwareGuard;
+ nullAwareGuards = receiverResult.nullAwareGuards;
receiver = receiverResult.nullAwareAction;
} else {
receiver = receiverResult.expression;
@@ -2585,25 +2505,31 @@
}
replacement.fileOffset = node.fileOffset;
return new ExpressionInferenceResult.nullAware(
- binaryType, replacement, nullAwareGuard);
+ binaryType, replacement, nullAwareGuards);
}
ExpressionInferenceResult visitIfNullPropertySet(
IfNullPropertySet node, DartType typeContext) {
- inferrer.inferSyntheticVariable(node.variable);
+ Link<NullAwareGuard> nullAwareGuards =
+ inferrer.inferSyntheticVariableNullAware(node.variable);
ExpressionInferenceResult readResult = inferrer.inferExpression(
node.read, const UnknownType(), true,
isVoidAllowed: true);
+ Expression read = readResult.expression;
+ DartType readType = readResult.inferredType;
+
+ inferrer.flowAnalysis.ifNullExpression_rightBegin(read);
ExpressionInferenceResult writeResult = inferrer
.inferExpression(node.write, typeContext, true, isVoidAllowed: true);
+ inferrer.flowAnalysis.ifNullExpression_end();
+
Member equalsMember = inferrer
- .findInterfaceMember(
- readResult.inferredType, equalsName, node.fileOffset)
+ .findInterfaceMember(readType, equalsName, node.fileOffset)
.member;
DartType inferredType = inferrer.typeSchemaEnvironment
.getStandardUpperBound(
- readResult.inferredType, writeResult.inferredType);
+ readType, writeResult.inferredType, inferrer.library.library);
Expression replacement;
if (node.forEffect) {
@@ -2611,8 +2537,8 @@
//
// let v1 = o in v1.a == null ? v1.a = b : null
//
- MethodInvocation equalsNull = createEqualsNull(
- node.fileOffset, readResult.expression, equalsMember);
+ MethodInvocation equalsNull =
+ createEqualsNull(node.fileOffset, read, equalsMember);
ConditionalExpression conditional = new ConditionalExpression(
equalsNull,
writeResult.expression,
@@ -2626,8 +2552,7 @@
//
// let v1 = o in let v2 = v1.a in v2 == null ? v1.a = b : v2
//
- VariableDeclaration readVariable =
- createVariable(readResult.expression, readResult.inferredType);
+ VariableDeclaration readVariable = createVariable(read, readType);
MethodInvocation equalsNull = createEqualsNull(
node.fileOffset, createVariableGet(readVariable), equalsMember);
ConditionalExpression conditional = new ConditionalExpression(equalsNull,
@@ -2637,23 +2562,35 @@
..fileOffset = node.fileOffset;
}
- return new ExpressionInferenceResult(inferredType, replacement);
+ return new ExpressionInferenceResult.nullAware(
+ inferredType, replacement, nullAwareGuards);
}
ExpressionInferenceResult visitIfNullSet(
IfNullSet node, DartType typeContext) {
ExpressionInferenceResult readResult =
inferrer.inferExpression(node.read, const UnknownType(), true);
+ Link<NullAwareGuard> nullAwareGuards;
+ Expression read;
+ if (inferrer.isNonNullableByDefault) {
+ nullAwareGuards = readResult.nullAwareGuards;
+ read = readResult.nullAwareAction;
+ } else {
+ read = readResult.expression;
+ }
+ inferrer.flowAnalysis.ifNullExpression_rightBegin(read);
ExpressionInferenceResult writeResult = inferrer
.inferExpression(node.write, typeContext, true, isVoidAllowed: true);
+ inferrer.flowAnalysis.ifNullExpression_end();
+
Member equalsMember = inferrer
.findInterfaceMember(
readResult.inferredType, equalsName, node.fileOffset)
.member;
DartType inferredType = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(
- readResult.inferredType, writeResult.inferredType);
+ .getStandardUpperBound(readResult.inferredType,
+ writeResult.inferredType, inferrer.library.library);
Expression replacement;
if (node.forEffect) {
@@ -2661,8 +2598,8 @@
//
// a == null ? a = b : null
//
- MethodInvocation equalsNull = createEqualsNull(
- node.fileOffset, readResult.expression, equalsMember);
+ MethodInvocation equalsNull =
+ createEqualsNull(node.fileOffset, read, equalsMember);
replacement = new ConditionalExpression(
equalsNull,
writeResult.expression,
@@ -2675,7 +2612,7 @@
// let v1 = a in v1 == null ? a = b : v1
//
VariableDeclaration readVariable =
- createVariable(readResult.expression, readResult.inferredType);
+ createVariable(read, readResult.inferredType);
MethodInvocation equalsNull = createEqualsNull(
node.fileOffset, createVariableGet(readVariable), equalsMember);
ConditionalExpression conditional = new ConditionalExpression(equalsNull,
@@ -2684,7 +2621,8 @@
replacement = new Let(readVariable, conditional)
..fileOffset = node.fileOffset;
}
- return new ExpressionInferenceResult(inferredType, replacement);
+ return new ExpressionInferenceResult.nullAware(
+ inferredType, replacement, nullAwareGuards);
}
ExpressionInferenceResult visitIndexGet(IndexGet node, DartType typeContext) {
@@ -2692,9 +2630,9 @@
node.receiver, const UnknownType(), true,
isVoidAllowed: true);
Expression receiver;
- NullAwareGuard nullAwareGuard;
+ Link<NullAwareGuard> nullAwareGuards;
if (inferrer.isNonNullableByDefault) {
- nullAwareGuard = receiverResult.nullAwareGuard;
+ nullAwareGuards = receiverResult.nullAwareGuards;
receiver = receiverResult.nullAwareAction;
} else {
receiver = receiverResult.expression;
@@ -2719,7 +2657,7 @@
ExpressionInferenceResult replacement = _computeIndexGet(node.fileOffset,
receiver, receiverType, indexGetTarget, index, readCheckKind);
return new ExpressionInferenceResult.nullAware(
- replacement.inferredType, replacement.expression, nullAwareGuard);
+ replacement.inferredType, replacement.expression, nullAwareGuards);
}
ExpressionInferenceResult visitIndexSet(IndexSet node, DartType typeContext) {
@@ -2727,9 +2665,9 @@
node.receiver, const UnknownType(), true,
isVoidAllowed: true);
Expression receiver;
- NullAwareGuard nullAwareGuard;
+ Link<NullAwareGuard> nullAwareGuards;
if (inferrer.isNonNullableByDefault) {
- nullAwareGuard = receiverResult.nullAwareGuard;
+ nullAwareGuards = receiverResult.nullAwareGuards;
receiver = receiverResult.nullAwareAction;
} else {
receiver = receiverResult.expression;
@@ -2795,7 +2733,7 @@
}
replacement.fileOffset = node.fileOffset;
return new ExpressionInferenceResult.nullAware(
- inferredType, replacement, nullAwareGuard);
+ inferredType, replacement, nullAwareGuards);
}
ExpressionInferenceResult visitSuperIndexSet(
@@ -2930,9 +2868,9 @@
isVoidAllowed: true);
Expression receiver;
- NullAwareGuard nullAwareGuard;
+ Link<NullAwareGuard> nullAwareGuards;
if (inferrer.isNonNullableByDefault) {
- nullAwareGuard = receiverResult.nullAwareGuard;
+ nullAwareGuards = receiverResult.nullAwareGuards;
receiver = receiverResult.nullAwareAction;
} else {
receiver = receiverResult.expression;
@@ -2981,6 +2919,7 @@
readReceiver, receiverType, readTarget, readIndex, checkKind);
Expression read = readResult.expression;
DartType readType = readResult.inferredType;
+ inferrer.flowAnalysis.ifNullExpression_rightBegin(read);
Member equalsMember = inferrer
.findInterfaceMember(readType, equalsName, node.testOffset)
@@ -2993,9 +2932,11 @@
ExpressionInferenceResult valueResult = inferrer
.inferExpression(node.value, valueType, true, isVoidAllowed: true);
Expression value = inferrer.ensureAssignableResult(valueType, valueResult);
+ inferrer.flowAnalysis.ifNullExpression_end();
DartType inferredType = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(readType, valueResult.inferredType);
+ .getStandardUpperBound(
+ readType, valueResult.inferredType, inferrer.library.library);
VariableDeclaration valueVariable;
if (node.forEffect) {
@@ -3079,7 +3020,7 @@
replacement = inner;
}
return new ExpressionInferenceResult.nullAware(
- inferredType, replacement, nullAwareGuard);
+ inferredType, replacement, nullAwareGuards);
}
ExpressionInferenceResult visitIfNullSuperIndexSet(
@@ -3118,13 +3059,6 @@
writeIndex = inferrer.ensureAssignable(
writeIndexType, indexResult.inferredType, writeIndex);
- ExpressionInferenceResult valueResult = inferrer
- .inferExpression(node.value, valueType, true, isVoidAllowed: true);
- Expression value = inferrer.ensureAssignableResult(valueType, valueResult);
-
- DartType inferredType = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(readType, valueResult.inferredType);
-
Expression read;
if (readTarget.isMissing) {
@@ -3146,6 +3080,16 @@
..fileOffset = node.readOffset;
}
+ inferrer.flowAnalysis.ifNullExpression_rightBegin(read);
+ ExpressionInferenceResult valueResult = inferrer
+ .inferExpression(node.value, valueType, true, isVoidAllowed: true);
+ Expression value = inferrer.ensureAssignableResult(valueType, valueResult);
+ inferrer.flowAnalysis.ifNullExpression_end();
+
+ DartType inferredType = inferrer.typeSchemaEnvironment
+ .getStandardUpperBound(
+ readType, valueResult.inferredType, inferrer.library.library);
+
VariableDeclaration valueVariable;
if (node.forEffect) {
// No need for a value variable.
@@ -3282,6 +3226,7 @@
MethodContravarianceCheckKind.none);
Expression read = readResult.expression;
DartType readType = readResult.inferredType;
+ inferrer.flowAnalysis.ifNullExpression_rightBegin(read);
Member equalsMember = inferrer
.findInterfaceMember(readType, equalsName, node.testOffset)
@@ -3294,9 +3239,11 @@
ExpressionInferenceResult valueResult = inferrer
.inferExpression(node.value, valueType, true, isVoidAllowed: true);
Expression value = inferrer.ensureAssignableResult(valueType, valueResult);
+ inferrer.flowAnalysis.ifNullExpression_end();
DartType inferredType = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(readType, valueResult.inferredType);
+ .getStandardUpperBound(
+ readType, valueResult.inferredType, inferrer.library.library);
VariableDeclaration valueVariable;
if (node.forEffect) {
@@ -3821,9 +3768,9 @@
node.receiver, const UnknownType(), true,
isVoidAllowed: true);
Expression receiver;
- NullAwareGuard nullAwareGuard;
+ Link<NullAwareGuard> nullAwareGuards;
if (inferrer.isNonNullableByDefault) {
- nullAwareGuard = receiverResult.nullAwareGuard;
+ nullAwareGuards = receiverResult.nullAwareGuards;
receiver = receiverResult.nullAwareAction;
} else {
receiver = receiverResult.expression;
@@ -3961,7 +3908,7 @@
return new ExpressionInferenceResult.nullAware(
node.forPostIncDec ? readType : binaryType,
replacement,
- nullAwareGuard);
+ nullAwareGuards);
}
ExpressionInferenceResult visitNullAwareCompoundSet(
@@ -3970,15 +3917,24 @@
node.receiver, const UnknownType(), true,
isVoidAllowed: true);
DartType receiverType = receiverResult.inferredType;
- VariableDeclaration receiverVariable =
- createVariableForResult(receiverResult);
+
+ Link<NullAwareGuard> nullAwareGuards;
+ VariableDeclaration receiverVariable;
+ if (inferrer.isNonNullableByDefault) {
+ receiverVariable =
+ createVariable(receiverResult.nullAwareAction, receiverType);
+ nullAwareGuards = receiverResult.nullAwareGuards;
+ } else {
+ receiverVariable =
+ createVariable(receiverResult.expression, receiverType);
+ nullAwareGuards = const Link<NullAwareGuard>();
+ }
+
+ NullAwareGuard nullAwareGuard =
+ inferrer.createNullAwareGuard(receiverVariable);
Expression readReceiver = createVariableGet(receiverVariable);
Expression writeReceiver = createVariableGet(receiverVariable);
- Member equalsMember = inferrer
- .findInterfaceMember(receiverType, equalsName, node.receiver.fileOffset)
- .member;
-
ExpressionInferenceResult readResult = _computePropertyGet(node.readOffset,
readReceiver, receiverType, node.propertyName, const UnknownType(),
isThisReceiver: node.receiver is ThisExpression);
@@ -4077,8 +4033,8 @@
createLet(writeVariable, createVariableGet(valueVariable)));
}
- return new ExpressionInferenceResult.nullAware(resultType, action,
- new NullAwareGuard(receiverVariable, node.fileOffset, equalsMember));
+ return new ExpressionInferenceResult.nullAware(
+ resultType, action, nullAwareGuards.prepend(nullAwareGuard));
}
ExpressionInferenceResult visitCompoundSuperIndexSet(
@@ -4417,9 +4373,9 @@
isVoidAllowed: false);
DartType receiverType = receiverResult.inferredType;
Expression receiver;
- NullAwareGuard nullAwareGuard;
+ Link<NullAwareGuard> nullAwareGuards;
if (inferrer.isNonNullableByDefault) {
- nullAwareGuard = receiverResult.nullAwareGuard;
+ nullAwareGuards = receiverResult.nullAwareGuards;
receiver = receiverResult.nullAwareAction;
} else {
receiver = receiverResult.expression;
@@ -4451,7 +4407,7 @@
valueType: rhsType, forEffect: node.forEffect);
return new ExpressionInferenceResult.nullAware(
- rhsType, replacement, nullAwareGuard);
+ rhsType, replacement, nullAwareGuards);
}
ExpressionInferenceResult visitNullAwareIfNullSet(
@@ -4459,21 +4415,29 @@
ExpressionInferenceResult receiverResult = inferrer.inferExpression(
node.receiver, const UnknownType(), true,
isVoidAllowed: false);
+ Link<NullAwareGuard> nullAwareGuards;
+ Expression receiver;
DartType receiverType = receiverResult.inferredType;
+ if (inferrer.isNonNullableByDefault) {
+ nullAwareGuards = receiverResult.nullAwareGuards;
+ receiver = receiverResult.nullAwareAction;
+ } else {
+ nullAwareGuards = const Link<NullAwareGuard>();
+ receiver = receiverResult.expression;
+ }
VariableDeclaration receiverVariable =
- createVariableForResult(receiverResult);
+ createVariable(receiver, receiverType);
+ NullAwareGuard nullAwareGuard =
+ inferrer.createNullAwareGuard(receiverVariable);
Expression readReceiver = createVariableGet(receiverVariable);
Expression writeReceiver = createVariableGet(receiverVariable);
- Member receiverEqualsMember = inferrer
- .findInterfaceMember(receiverType, equalsName, node.receiver.fileOffset)
- .member;
-
ExpressionInferenceResult readResult = _computePropertyGet(
node.readOffset, readReceiver, receiverType, node.name, typeContext,
isThisReceiver: node.receiver is ThisExpression);
Expression read = readResult.expression;
DartType readType = readResult.inferredType;
+ inferrer.flowAnalysis.ifNullExpression_rightBegin(read);
Member readEqualsMember = inferrer
.findInterfaceMember(readType, equalsName, node.testOffset)
@@ -4499,8 +4463,11 @@
receiverType, node.name, writeTarget, value,
valueType: valueResult.inferredType, forEffect: node.forEffect);
+ inferrer.flowAnalysis.ifNullExpression_end();
+
DartType inferredType = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(readType, valueResult.inferredType);
+ .getStandardUpperBound(
+ readType, valueResult.inferredType, inferrer.library.library);
Expression replacement;
if (node.forEffect) {
@@ -4513,23 +4480,10 @@
// receiverVariable.name = value : null)
//
- MethodInvocation receiverEqualsNull = createEqualsNull(
- receiverVariable.fileOffset,
- createVariableGet(receiverVariable),
- receiverEqualsMember);
MethodInvocation readEqualsNull =
createEqualsNull(node.readOffset, read, readEqualsMember);
- ConditionalExpression innerCondition = new ConditionalExpression(
- readEqualsNull,
- write,
- new NullLiteral()..fileOffset = node.writeOffset,
- inferredType);
- ConditionalExpression outerCondition = new ConditionalExpression(
- receiverEqualsNull,
- new NullLiteral()..fileOffset = node.readOffset,
- innerCondition,
- inferredType);
- replacement = createLet(receiverVariable, outerCondition);
+ replacement = new ConditionalExpression(readEqualsNull, write,
+ new NullLiteral()..fileOffset = node.writeOffset, inferredType);
} else {
// Encode `receiver?.name ??= value` as:
//
@@ -4541,23 +4495,15 @@
//
assert(readVariable != null);
- MethodInvocation receiverEqualsNull = createEqualsNull(
- receiverVariable.fileOffset,
- createVariableGet(receiverVariable),
- receiverEqualsMember);
MethodInvocation readEqualsNull =
createEqualsNull(receiverVariable.fileOffset, read, readEqualsMember);
- ConditionalExpression innerCondition = new ConditionalExpression(
+ ConditionalExpression condition = new ConditionalExpression(
readEqualsNull, write, createVariableGet(readVariable), inferredType);
- ConditionalExpression outerCondition = new ConditionalExpression(
- receiverEqualsNull,
- new NullLiteral()..fileOffset = node.readOffset,
- createLet(readVariable, innerCondition),
- inferredType);
- replacement = createLet(receiverVariable, outerCondition);
+ replacement = createLet(readVariable, condition);
}
- return new ExpressionInferenceResult(inferredType, replacement);
+ return new ExpressionInferenceResult.nullAware(
+ inferredType, replacement, nullAwareGuards.prepend(nullAwareGuard));
}
@override
@@ -4565,10 +4511,10 @@
PropertyGet node, DartType typeContext) {
ExpressionInferenceResult result =
inferrer.inferExpression(node.receiver, const UnknownType(), true);
- NullAwareGuard nullAwareGuard;
+ Link<NullAwareGuard> nullAwareGuards;
Expression receiver;
if (inferrer.isNonNullableByDefault) {
- nullAwareGuard = result.nullAwareGuard;
+ nullAwareGuards = result.nullAwareGuards;
receiver = result.nullAwareAction;
} else {
receiver = result.expression;
@@ -4579,11 +4525,12 @@
node.fileOffset, receiver, receiverType, node.name, typeContext,
isThisReceiver: node.receiver is ThisExpression);
return new ExpressionInferenceResult.nullAware(
- readResult.inferredType, readResult.expression, nullAwareGuard);
+ readResult.inferredType, readResult.expression, nullAwareGuards);
}
@override
void visitRedirectingInitializer(RedirectingInitializer node) {
+ inferrer.inferConstructorParameterTypes(node.target);
List<TypeParameter> classTypeParameters =
node.target.enclosingClass.typeParameters;
List<DartType> typeArguments =
@@ -4793,6 +4740,7 @@
@override
void visitSuperInitializer(SuperInitializer node) {
+ inferrer.inferConstructorParameterTypes(node.target);
Substitution substitution = Substitution.fromSupertype(
inferrer.classHierarchy.getClassAsInstanceOf(
inferrer.thisType.classNode, node.target.enclosingClass));
@@ -4846,7 +4794,10 @@
ExpressionInferenceResult visitSuperPropertySet(
SuperPropertySet node, DartType typeContext) {
DartType receiverType = inferrer.classHierarchy.getTypeAsInstanceOf(
- inferrer.thisType, inferrer.thisType.classNode.supertype.classNode);
+ inferrer.thisType,
+ inferrer.thisType.classNode.supertype.classNode,
+ inferrer.library.library,
+ inferrer.coreTypes);
ObjectAccessTarget writeTarget = inferrer.findInterfaceMember(
receiverType, node.name, node.fileOffset,
@@ -4874,10 +4825,10 @@
inferrer.flowAnalysis.switchStatement_expressionEnd(node);
bool hasDefault = false;
- for (SwitchCase switchCase in node.cases) {
+ for (SwitchCaseImpl switchCase in node.cases) {
hasDefault = hasDefault || switchCase.isDefault;
- // TODO(dmitryas): Pass in the actual value for the first parameter.
- inferrer.flowAnalysis.switchStatement_beginCase(false, node);
+ inferrer.flowAnalysis
+ .switchStatement_beginCase(switchCase.hasLabel, node);
for (int index = 0; index < switchCase.expressions.length; index++) {
ExpressionInferenceResult caseExpressionResult =
inferrer.inferExpression(
@@ -4892,7 +4843,9 @@
if (!inferrer.isAssignable(expressionType, caseExpressionType)) {
inferrer.helper.addProblem(
templateSwitchExpressionNotAssignable.withArguments(
- expressionType, caseExpressionType),
+ expressionType,
+ caseExpressionType,
+ inferrer.isNonNullableByDefault),
caseExpression.fileOffset,
noLength,
context: [
@@ -4976,7 +4929,10 @@
if (bodyResult.hasChanged) {
node.body = bodyResult.statement..parent = node;
}
- inferrer.flowAnalysis.tryFinallyStatement_finallyBegin(node.finalizer);
+ // TODO(johnniwinther): Use one internal statement for try-catch-finally.
+ TreeNode body = node.body;
+ inferrer.flowAnalysis
+ .tryFinallyStatement_finallyBegin(body is TryCatch ? body.body : body);
StatementInferenceResult finalizerResult =
inferrer.inferStatement(node.finalizer);
if (finalizerResult.hasChanged) {
@@ -5089,7 +5045,11 @@
new FunctionNode(
node.initializer == null
? late_lowering.createGetterBodyWithoutInitializer(
- fileOffset, node.name, node.type, 'Local',
+ inferrer.coreTypes,
+ fileOffset,
+ node.name,
+ node.type,
+ 'Local',
createVariableRead: createVariableRead,
createIsSetRead: createIsSetRead)
: late_lowering.createGetterWithInitializer(
@@ -5115,8 +5075,13 @@
setVariable,
new FunctionNode(
node.isFinal
- ? late_lowering.createSetterBodyFinal(fileOffset,
- node.name, setterParameter, node.type, 'Local',
+ ? late_lowering.createSetterBodyFinal(
+ inferrer.coreTypes,
+ fileOffset,
+ node.name,
+ setterParameter,
+ node.type,
+ 'Local',
shouldReturnValue: true,
createVariableRead: createVariableRead,
createVariableWrite: createVariableWrite,
@@ -5159,7 +5124,10 @@
DartType promotedType;
DartType declaredOrInferredType = variable.type;
if (inferrer.isNonNullableByDefault) {
- promotedType = inferrer.flowAnalysis.variableRead(node, variable);
+ if (!variable.isLocalFunction) {
+ // Don't promote local functions.
+ promotedType = inferrer.flowAnalysis.variableRead(node, variable);
+ }
} else {
bool mutatedInClosure = variable.mutatedInClosure;
promotedType = inferrer.typePromoter
@@ -5192,6 +5160,7 @@
@override
StatementInferenceResult visitWhileStatement(WhileStatement node) {
+ inferrer.flowAnalysis.whileStatement_conditionBegin(node);
InterfaceType expectedType =
inferrer.coreTypes.boolRawType(inferrer.library.nonNullable);
ExpressionInferenceResult conditionResult = inferrer.inferExpression(
@@ -5200,10 +5169,12 @@
Expression condition =
inferrer.ensureAssignableResult(expectedType, conditionResult);
node.condition = condition..parent = node;
+ inferrer.flowAnalysis.whileStatement_bodyBegin(node, node.condition);
StatementInferenceResult bodyResult = inferrer.inferStatement(node.body);
if (bodyResult.hasChanged) {
node.body = bodyResult.statement..parent = node;
}
+ inferrer.flowAnalysis.whileStatement_end();
return const StatementInferenceResult();
}
@@ -5287,7 +5258,7 @@
ExpressionInferenceResult visitUnary(
UnaryExpression node, DartType typeContext) {
ExpressionInferenceResult expressionResult;
- if (node.unaryName.name == 'unary-') {
+ if (node.unaryName == unaryMinusName) {
// Replace integer literals in a double context with the corresponding
// double literal if it's exact. For double literals, the negation is
// folded away. In any non-double context, or if there is no exact
diff --git a/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart b/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
index b97a372..bf4c254 100644
--- a/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
@@ -21,7 +21,7 @@
import 'dart:core' hide MapEntry;
import 'package:kernel/ast.dart';
-
+import 'package:kernel/text/ast_to_text.dart';
import 'package:kernel/core_types.dart';
import '../fasta_codes.dart'
@@ -195,6 +195,25 @@
ClassInferenceInfo(this.builder);
}
+class SwitchCaseImpl extends SwitchCase {
+ final bool hasLabel;
+
+ SwitchCaseImpl(
+ List<Expression> expressions, List<int> expressionOffsets, Statement body,
+ {bool isDefault: false, this.hasLabel})
+ : assert(hasLabel != null),
+ super(expressions, expressionOffsets, body, isDefault: isDefault);
+}
+
+class BreakStatementImpl extends BreakStatement {
+ Statement targetStatement;
+ final bool isContinue;
+
+ BreakStatementImpl({this.isContinue})
+ : assert(isContinue != null),
+ super(null);
+}
+
enum InternalExpressionKind {
Binary,
Cascade,
@@ -237,8 +256,13 @@
InternalExpressionKind get kind;
@override
- R accept<R>(ExpressionVisitor<R> visitor) =>
- unsupported("${runtimeType}.accept", -1, null);
+ R accept<R>(ExpressionVisitor<R> visitor) {
+ if (visitor is Printer || visitor is Precedence) {
+ // Allow visitors needed for toString.
+ return visitor.defaultExpression(this);
+ }
+ return unsupported("${runtimeType}.accept", -1, null);
+ }
@override
R accept1<R, A>(ExpressionVisitor1<R, A> visitor, A arg) =>
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index dbd9dfb..a5e8d91 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -25,7 +25,6 @@
Library,
Name,
NamedExpression,
- Nullability,
NullLiteral,
Procedure,
RedirectingInitializer,
@@ -284,7 +283,7 @@
loader.checkRedirectingFactories(myClasses);
loader.addNoSuchMethodForwarders(myClasses);
loader.checkMixins(myClasses);
- loader.buildOutlineExpressions();
+ loader.buildOutlineExpressions(loader.coreTypes);
installAllComponentProblems(loader.allComponentProblems);
loader.allComponentProblems.clear();
return component;
@@ -568,8 +567,8 @@
new TypeParameterType.withDefaultNullabilityForLibrary(
typeParameter, enclosingClass.enclosingLibrary));
}
- return new InterfaceType(
- enclosingClass, Nullability.legacy, typeParameterTypes);
+ return new InterfaceType(enclosingClass,
+ enclosingClass.enclosingLibrary.nonNullable, typeParameterTypes);
}
void setupTopAndBottomTypes() {
diff --git a/pkg/front_end/lib/src/fasta/kernel/late_lowering.dart b/pkg/front_end/lib/src/fasta/kernel/late_lowering.dart
index 02f87f8..3f0a3c4 100644
--- a/pkg/front_end/lib/src/fasta/kernel/late_lowering.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/late_lowering.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:kernel/ast.dart' hide MapEntry;
+import 'package:kernel/core_types.dart';
import '../names.dart';
@@ -68,12 +69,18 @@
}
}
-Statement createGetterBodyWithoutInitializer(
+Statement createGetterBodyWithoutInitializer(CoreTypes coreTypes,
int fileOffset, String name, DartType type, String variableKindName,
{Expression createVariableRead(), Expression createIsSetRead()}) {
- Expression exception = new Throw(
- new StringLiteral("$variableKindName '${name}' has not been initialized.")
+ Expression exception = new Throw(new ConstructorInvocation(
+ coreTypes.lateInitializationErrorConstructor,
+ new Arguments(<Expression>[
+ new StringLiteral(
+ "$variableKindName '${name}' has not been initialized.")
+ ..fileOffset = fileOffset
+ ])
..fileOffset = fileOffset)
+ ..fileOffset = fileOffset)
..fileOffset = fileOffset;
if (type.isPotentiallyNullable) {
// Generate:
@@ -153,17 +160,27 @@
}
}
-Statement createSetterBodyFinal(int fileOffset, String name,
- VariableDeclaration parameter, DartType type, String variableKindName,
+Statement createSetterBodyFinal(
+ CoreTypes coreTypes,
+ int fileOffset,
+ String name,
+ VariableDeclaration parameter,
+ DartType type,
+ String variableKindName,
{bool shouldReturnValue,
Expression createVariableRead(),
Expression createVariableWrite(Expression value),
Expression createIsSetRead(),
Expression createIsSetWrite(Expression value)}) {
- Expression exception = new Throw(
- new StringLiteral(
- "${variableKindName} '${name}' has already been initialized.")
+ Expression exception = new Throw(new ConstructorInvocation(
+ coreTypes.lateInitializationErrorConstructor,
+ new Arguments(<Expression>[
+ new StringLiteral(
+ "${variableKindName} '${name}' has already been initialized.")
+ ..fileOffset = fileOffset
+ ])
..fileOffset = fileOffset)
+ ..fileOffset = fileOffset)
..fileOffset = fileOffset;
Statement createReturn(Expression value) {
diff --git a/pkg/front_end/lib/src/fasta/kernel/load_library_builder.dart b/pkg/front_end/lib/src/fasta/kernel/load_library_builder.dart
index e209c0b..b5d38d7 100644
--- a/pkg/front_end/lib/src/fasta/kernel/load_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/load_library_builder.dart
@@ -13,7 +13,6 @@
LoadLibrary,
Member,
Name,
- Nullability,
Procedure,
ProcedureKind,
ReturnStatement;
@@ -55,7 +54,7 @@
ProcedureKind.Method,
new FunctionNode(new ReturnStatement(expression),
returnType: new InterfaceType(parent.loader.coreTypes.futureClass,
- Nullability.legacy, <DartType>[const DynamicType()])),
+ parent.nonNullable, <DartType>[const DynamicType()])),
fileUri: parent.library.fileUri,
isStatic: true)
..startFileOffset = charOffset
diff --git a/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart b/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart
index 91ab53c..69f2b57 100644
--- a/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart
@@ -54,11 +54,14 @@
/// distinguish different types with the same name. This is used in diagnostic
/// messages to indicate the origins of types occurring in the message.
class TypeLabeler implements DartTypeVisitor<void>, ConstantVisitor<void> {
- List<LabeledNode> names = <LabeledNode>[];
- Map<String, List<LabeledNode>> nameMap = <String, List<LabeledNode>>{};
+ final List<LabeledNode> names = <LabeledNode>[];
+ final Map<String, List<LabeledNode>> nameMap = <String, List<LabeledNode>>{};
+ final bool printNullability;
List<Object> result;
+ TypeLabeler(this.printNullability);
+
/// Pretty-print a type.
/// When all types and constants appearing in the same message have been
/// pretty-printed, the returned list can be converted to its string
@@ -128,6 +131,14 @@
}
}
+ void addNullability(Nullability nullability) {
+ if (printNullability) {
+ if (nullability == Nullability.nullable) {
+ result.add("?");
+ }
+ }
+ }
+
void defaultDartType(DartType type) {}
void visitTypedefType(TypedefType node) {}
@@ -169,6 +180,7 @@
node.parameter.name,
enclosingLibrary == null ? unknownUri : enclosingLibrary.importUri,
enclosingLibrary == null ? unknownUri : enclosingLibrary.fileUri));
+ addNullability(node.typeParameterTypeNullability);
}
void visitFunctionType(FunctionType node) {
@@ -223,6 +235,7 @@
result.add("}");
}
result.add(")");
+ addNullability(node.nullability);
}
void visitInterfaceType(InterfaceType node) {
@@ -242,6 +255,7 @@
}
result.add(">");
}
+ addNullability(node.nullability);
}
void defaultConstant(Constant node) {}
diff --git a/pkg/front_end/lib/src/fasta/kernel/types.dart b/pkg/front_end/lib/src/fasta/kernel/types.dart
index 5f75c6d..8f443ff 100644
--- a/pkg/front_end/lib/src/fasta/kernel/types.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/types.dart
@@ -13,6 +13,7 @@
FunctionType,
InterfaceType,
InvalidType,
+ Library,
NamedType,
NeverType,
Nullability,
@@ -22,6 +23,8 @@
Variance,
VoidType;
+import 'package:kernel/core_types.dart';
+
import 'package:kernel/type_algebra.dart'
show Substitution, combineNullabilitiesForSubstitution;
@@ -282,8 +285,15 @@
}
@override
- InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass) {
- return hierarchy.getKernelTypeAsInstanceOf(type, superclass);
+ InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass,
+ Library clientLibrary, CoreTypes coreTypes) {
+ return hierarchy.getKernelTypeAsInstanceOf(type, superclass, clientLibrary);
+ }
+
+ @override
+ List<DartType> getTypeArgumentsAsInstanceOf(
+ InterfaceType type, Class superclass) {
+ return hierarchy.getKernelTypeArgumentsAsInstanceOf(type, superclass);
}
@override
@@ -349,14 +359,14 @@
// arguments in getKernelTypeAsInstanceOf.
return new IsSubtypeOf.basedSolelyOnNullabilities(s, t);
}
- InterfaceType asSupertype =
- types.hierarchy.getKernelTypeAsInstanceOf(s, t.classNode);
- if (asSupertype == null) {
+ List<DartType> asSupertypeArguments =
+ types.hierarchy.getKernelTypeArgumentsAsInstanceOf(s, t.classNode);
+ if (asSupertypeArguments == null) {
return const IsSubtypeOf.never();
}
return types
- .areTypeArgumentsOfSubtypeKernel(asSupertype.typeArguments,
- t.typeArguments, t.classNode.typeParameters)
+ .areTypeArgumentsOfSubtypeKernel(
+ asSupertypeArguments, t.typeArguments, t.classNode.typeParameters)
.and(new IsSubtypeOf.basedSolelyOnNullabilities(s, t));
}
diff --git a/pkg/front_end/lib/src/fasta/scope.dart b/pkg/front_end/lib/src/fasta/scope.dart
index c564753..09d9258 100644
--- a/pkg/front_end/lib/src/fasta/scope.dart
+++ b/pkg/front_end/lib/src/fasta/scope.dart
@@ -5,6 +5,7 @@
library fasta.scope;
import 'package:kernel/ast.dart' hide MapEntry;
+import 'package:kernel/core_types.dart';
import 'builder/builder.dart';
import 'builder/class_builder.dart';
@@ -639,7 +640,7 @@
ProcedureKind get kind => null;
@override
- void buildOutlineExpressions(LibraryBuilder library) {
+ void buildOutlineExpressions(LibraryBuilder library, CoreTypes coreTypes) {
throw new UnsupportedError(
'AmbiguousMemberBuilder.buildOutlineExpressions');
}
diff --git a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
index 9198824..588f760 100644
--- a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
@@ -7,16 +7,58 @@
import 'package:kernel/ast.dart'
show Class, Constructor, Member, Supertype, TreeNode;
+import 'package:kernel/ast.dart'
+ show
+ Class,
+ Constructor,
+ DartType,
+ DynamicType,
+ Field,
+ FunctionNode,
+ Member,
+ Name,
+ Procedure,
+ ProcedureKind,
+ Supertype,
+ TreeNode,
+ TypeParameter,
+ VariableDeclaration,
+ Variance,
+ VoidType;
+
+import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
+
+import 'package:kernel/clone.dart' show CloneWithoutBody;
+
+import 'package:kernel/type_algebra.dart' show Substitution;
+
+import 'package:kernel/type_algebra.dart' as type_algebra
+ show getSubstitutionMap;
+
import '../builder/builder.dart';
+
import '../builder/class_builder.dart';
+
import '../builder/constructor_reference_builder.dart';
+
+import '../builder/function_builder.dart';
+
import '../builder/invalid_type_declaration_builder.dart';
+
import '../builder/library_builder.dart';
-import '../builder/metadata_builder.dart';
+
import '../builder/member_builder.dart';
+
+import '../builder/metadata_builder.dart';
+
import '../builder/named_type_builder.dart';
+
import '../builder/nullability_builder.dart';
+
+import '../builder/procedure_builder.dart';
+
import '../builder/type_builder.dart';
+
import '../builder/type_variable_builder.dart';
import '../dill/dill_member_builder.dart' show DillMemberBuilder;
@@ -25,22 +67,32 @@
show
Message,
noLength,
- templateInvalidTypeVariableInSupertype,
- templateInvalidTypeVariableInSupertypeWithVariance,
templateConflictsWithConstructor,
templateConflictsWithFactory,
templateConflictsWithMember,
templateConflictsWithSetter,
+ templateDuplicatedDeclarationUse,
+ templateInvalidTypeVariableInSupertype,
+ templateInvalidTypeVariableInSupertypeWithVariance,
+ templateRedirectionTargetNotFound,
templateSupertypeIsIllegal;
import '../kernel/kernel_builder.dart' show compareProcedures;
+import '../kernel/kernel_target.dart' show KernelTarget;
+
+import '../kernel/redirecting_factory_body.dart' show RedirectingFactoryBody;
+
import '../kernel/type_algorithms.dart' show Variance, computeVariance;
+import '../names.dart' show noSuchMethodName;
+
import '../problems.dart' show unexpected, unhandled;
import '../scope.dart';
+import '../source/source_library_builder.dart' show SourceLibraryBuilder;
+
import 'source_library_builder.dart' show SourceLibraryBuilder;
Class initializeClass(
@@ -316,4 +368,272 @@
if (result != 0) return result;
return charOffset.compareTo(other.charOffset);
}
+
+ void addNoSuchMethodForwarderForProcedure(Member noSuchMethod,
+ KernelTarget target, Procedure procedure, ClassHierarchy hierarchy) {
+ CloneWithoutBody cloner = new CloneWithoutBody(
+ typeSubstitution: type_algebra.getSubstitutionMap(
+ hierarchy.getClassAsInstanceOf(cls, procedure.enclosingClass)),
+ cloneAnnotations: false);
+ Procedure cloned = cloner.clone(procedure)..isExternal = false;
+ transformProcedureToNoSuchMethodForwarder(noSuchMethod, target, cloned);
+ cls.procedures.add(cloned);
+ cloned.parent = cls;
+
+ SourceLibraryBuilder library = this.library;
+ library.forwardersOrigins.add(cloned);
+ library.forwardersOrigins.add(procedure);
+ }
+
+ void addNoSuchMethodForwarderGetterForField(Member noSuchMethod,
+ KernelTarget target, Field field, ClassHierarchy hierarchy) {
+ Substitution substitution = Substitution.fromSupertype(
+ hierarchy.getClassAsInstanceOf(cls, field.enclosingClass));
+ Procedure getter = new Procedure(
+ field.name,
+ ProcedureKind.Getter,
+ new FunctionNode(null,
+ typeParameters: <TypeParameter>[],
+ positionalParameters: <VariableDeclaration>[],
+ namedParameters: <VariableDeclaration>[],
+ requiredParameterCount: 0,
+ returnType: substitution.substituteType(field.type)),
+ fileUri: field.fileUri)
+ ..fileOffset = field.fileOffset;
+ transformProcedureToNoSuchMethodForwarder(noSuchMethod, target, getter);
+ cls.procedures.add(getter);
+ getter.parent = cls;
+ }
+
+ void addNoSuchMethodForwarderSetterForField(Member noSuchMethod,
+ KernelTarget target, Field field, ClassHierarchy hierarchy) {
+ Substitution substitution = Substitution.fromSupertype(
+ hierarchy.getClassAsInstanceOf(cls, field.enclosingClass));
+ Procedure setter = new Procedure(
+ field.name,
+ ProcedureKind.Setter,
+ new FunctionNode(null,
+ typeParameters: <TypeParameter>[],
+ positionalParameters: <VariableDeclaration>[
+ new VariableDeclaration("value",
+ type: substitution.substituteType(field.type))
+ ],
+ namedParameters: <VariableDeclaration>[],
+ requiredParameterCount: 1,
+ returnType: const VoidType()),
+ fileUri: field.fileUri)
+ ..fileOffset = field.fileOffset;
+ transformProcedureToNoSuchMethodForwarder(noSuchMethod, target, setter);
+ cls.procedures.add(setter);
+ setter.parent = cls;
+ }
+
+ /// Adds noSuchMethod forwarding stubs to this class. Returns `true` if the
+ /// class was modified.
+ bool addNoSuchMethodForwarders(
+ KernelTarget target, ClassHierarchy hierarchy) {
+ if (cls.isAbstract) return false;
+
+ Set<Name> existingForwardersNames = new Set<Name>();
+ Set<Name> existingSetterForwardersNames = new Set<Name>();
+ Class leastConcreteSuperclass = cls.superclass;
+ while (
+ leastConcreteSuperclass != null && leastConcreteSuperclass.isAbstract) {
+ leastConcreteSuperclass = leastConcreteSuperclass.superclass;
+ }
+ if (leastConcreteSuperclass != null) {
+ bool superHasUserDefinedNoSuchMethod = hasUserDefinedNoSuchMethod(
+ leastConcreteSuperclass, hierarchy, target.objectClass);
+ List<Member> concrete =
+ hierarchy.getDispatchTargets(leastConcreteSuperclass);
+ for (Member member
+ in hierarchy.getInterfaceMembers(leastConcreteSuperclass)) {
+ if ((superHasUserDefinedNoSuchMethod ||
+ leastConcreteSuperclass.enclosingLibrary.compareTo(
+ member.enclosingClass.enclosingLibrary) !=
+ 0 &&
+ member.name.isPrivate) &&
+ ClassHierarchy.findMemberByName(concrete, member.name) == null) {
+ existingForwardersNames.add(member.name);
+ }
+ }
+
+ List<Member> concreteSetters =
+ hierarchy.getDispatchTargets(leastConcreteSuperclass, setters: true);
+ for (Member member in hierarchy
+ .getInterfaceMembers(leastConcreteSuperclass, setters: true)) {
+ if (ClassHierarchy.findMemberByName(concreteSetters, member.name) ==
+ null) {
+ existingSetterForwardersNames.add(member.name);
+ }
+ }
+ }
+
+ Member noSuchMethod = ClassHierarchy.findMemberByName(
+ hierarchy.getInterfaceMembers(cls), noSuchMethodName);
+
+ List<Member> concrete = hierarchy.getDispatchTargets(cls);
+ List<Member> declared = hierarchy.getDeclaredMembers(cls);
+
+ bool clsHasUserDefinedNoSuchMethod =
+ hasUserDefinedNoSuchMethod(cls, hierarchy, target.objectClass);
+ bool changed = false;
+ for (Member member in hierarchy.getInterfaceMembers(cls)) {
+ // We generate a noSuchMethod forwarder for [member] in [cls] if the
+ // following three conditions are satisfied simultaneously:
+ // 1) There is a user-defined noSuchMethod in [cls] or [member] is private
+ // and the enclosing library of [member] is different from that of
+ // [cls].
+ // 2) There is no implementation of [member] in [cls].
+ // 3) The superclass of [cls] has no forwarder for [member].
+ if (member is Procedure &&
+ (clsHasUserDefinedNoSuchMethod ||
+ cls.enclosingLibrary
+ .compareTo(member.enclosingClass.enclosingLibrary) !=
+ 0 &&
+ member.name.isPrivate) &&
+ ClassHierarchy.findMemberByName(concrete, member.name) == null &&
+ !existingForwardersNames.contains(member.name)) {
+ if (ClassHierarchy.findMemberByName(declared, member.name) != null) {
+ transformProcedureToNoSuchMethodForwarder(
+ noSuchMethod, target, member);
+ } else {
+ addNoSuchMethodForwarderForProcedure(
+ noSuchMethod, target, member, hierarchy);
+ }
+ existingForwardersNames.add(member.name);
+ changed = true;
+ continue;
+ }
+
+ if (member is Field &&
+ ClassHierarchy.findMemberByName(concrete, member.name) == null &&
+ !existingForwardersNames.contains(member.name)) {
+ addNoSuchMethodForwarderGetterForField(
+ noSuchMethod, target, member, hierarchy);
+ existingForwardersNames.add(member.name);
+ changed = true;
+ }
+ }
+
+ List<Member> concreteSetters =
+ hierarchy.getDispatchTargets(cls, setters: true);
+ List<Member> declaredSetters =
+ hierarchy.getDeclaredMembers(cls, setters: true);
+ for (Member member in hierarchy.getInterfaceMembers(cls, setters: true)) {
+ if (member is Procedure &&
+ ClassHierarchy.findMemberByName(concreteSetters, member.name) ==
+ null &&
+ !existingSetterForwardersNames.contains(member.name)) {
+ if (ClassHierarchy.findMemberByName(declaredSetters, member.name) !=
+ null) {
+ transformProcedureToNoSuchMethodForwarder(
+ noSuchMethod, target, member);
+ } else {
+ addNoSuchMethodForwarderForProcedure(
+ noSuchMethod, target, member, hierarchy);
+ }
+ existingSetterForwardersNames.add(member.name);
+ changed = true;
+ }
+ if (member is Field &&
+ ClassHierarchy.findMemberByName(concreteSetters, member.name) ==
+ null &&
+ !existingSetterForwardersNames.contains(member.name)) {
+ addNoSuchMethodForwarderSetterForField(
+ noSuchMethod, target, member, hierarchy);
+ existingSetterForwardersNames.add(member.name);
+ changed = true;
+ }
+ }
+
+ return changed;
+ }
+
+ @override
+ int resolveConstructors(LibraryBuilder library) {
+ if (constructorReferences == null) return 0;
+ for (ConstructorReferenceBuilder ref in constructorReferences) {
+ ref.resolveIn(scope, library);
+ }
+ int count = constructorReferences.length;
+ if (count != 0) {
+ Map<String, MemberBuilder> constructors = this.constructors.local;
+ // Copy keys to avoid concurrent modification error.
+ List<String> names = constructors.keys.toList();
+ for (String name in names) {
+ Builder declaration = constructors[name];
+ do {
+ if (declaration.parent != this) {
+ unexpected("$fileUri", "${declaration.parent.fileUri}", charOffset,
+ fileUri);
+ }
+ if (declaration is RedirectingFactoryBuilder) {
+ // Compute the immediate redirection target, not the effective.
+ ConstructorReferenceBuilder redirectionTarget =
+ declaration.redirectionTarget;
+ if (redirectionTarget != null) {
+ Builder targetBuilder = redirectionTarget.target;
+ if (declaration.next == null) {
+ // Only the first one (that is, the last on in the linked list)
+ // is actually in the kernel tree. This call creates a StaticGet
+ // to [declaration.target] in a field `_redirecting#` which is
+ // only legal to do to things in the kernel tree.
+ addRedirectingConstructor(declaration, library);
+ }
+ if (targetBuilder is FunctionBuilder) {
+ List<DartType> typeArguments = declaration.typeArguments;
+ if (typeArguments == null) {
+ // TODO(32049) If type arguments aren't specified, they should
+ // be inferred. Currently, the inference is not performed.
+ // The code below is a workaround.
+ typeArguments = new List<DartType>.filled(
+ targetBuilder.member.enclosingClass.typeParameters.length,
+ const DynamicType(),
+ growable: true);
+ }
+ declaration.setRedirectingFactoryBody(
+ targetBuilder.member, typeArguments);
+ } else if (targetBuilder is DillMemberBuilder) {
+ List<DartType> typeArguments = declaration.typeArguments;
+ if (typeArguments == null) {
+ // TODO(32049) If type arguments aren't specified, they should
+ // be inferred. Currently, the inference is not performed.
+ // The code below is a workaround.
+ typeArguments = new List<DartType>.filled(
+ targetBuilder.member.enclosingClass.typeParameters.length,
+ const DynamicType(),
+ growable: true);
+ }
+ declaration.setRedirectingFactoryBody(
+ targetBuilder.member, typeArguments);
+ } else if (targetBuilder is AmbiguousBuilder) {
+ addProblem(
+ templateDuplicatedDeclarationUse
+ .withArguments(redirectionTarget.fullNameForErrors),
+ redirectionTarget.charOffset,
+ noLength);
+ // CoreTypes aren't computed yet, and this is the outline
+ // phase. So we can't and shouldn't create a method body.
+ declaration.body = new RedirectingFactoryBody.unresolved(
+ redirectionTarget.fullNameForErrors);
+ } else {
+ addProblem(
+ templateRedirectionTargetNotFound
+ .withArguments(redirectionTarget.fullNameForErrors),
+ redirectionTarget.charOffset,
+ noLength);
+ // CoreTypes aren't computed yet, and this is the outline
+ // phase. So we can't and shouldn't create a method body.
+ declaration.body = new RedirectingFactoryBody.unresolved(
+ redirectionTarget.fullNameForErrors);
+ }
+ }
+ }
+ declaration = declaration.next;
+ } while (declaration != null);
+ }
+ }
+ return count;
+ }
}
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index 20b52a4..088d12a 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -598,6 +598,8 @@
Uri newFileUri;
resolvedUri = resolve(this.uri, uri, charOffset, isPart: true);
newFileUri = resolve(fileUri, uri, charOffset);
+ // TODO(johnniwinther): Add a LibraryPartBuilder instead of using
+ // [LibraryBuilder] to represent both libraries and parts.
parts.add(loader.read(resolvedUri, charOffset,
fileUri: newFileUri, accessor: this));
partOffsets.add(charOffset);
@@ -950,7 +952,6 @@
// parts, so that metadata annotations can be associated with it.
addProblem(
messageLanguageVersionMismatchInPart, partOffset, noLength, fileUri);
- return false;
}
part.validatePart(this, usedParts);
@@ -2616,7 +2617,7 @@
if (argument is FunctionType && argument.typeParameters.length > 0) {
if (issueInferred) {
message = templateGenericFunctionTypeInferredAsActualTypeArgument
- .withArguments(argument);
+ .withArguments(argument, isNonNullableByDefault);
} else {
message = messageGenericFunctionTypeUsedAsActualTypeArgument;
}
@@ -2630,14 +2631,16 @@
typeParameter.bound,
typeParameter.name,
targetReceiver,
- targetName);
+ targetName,
+ isNonNullableByDefault);
} else {
message = templateIncorrectTypeArgumentQualified.withArguments(
argument,
typeParameter.bound,
typeParameter.name,
targetReceiver,
- targetName);
+ targetName,
+ isNonNullableByDefault);
}
} else {
String enclosingName = issue.enclosingType == null
@@ -2649,10 +2652,15 @@
argument,
typeParameter.bound,
typeParameter.name,
- enclosingName);
+ enclosingName,
+ isNonNullableByDefault);
} else {
- message = templateIncorrectTypeArgument.withArguments(argument,
- typeParameter.bound, typeParameter.name, enclosingName);
+ message = templateIncorrectTypeArgument.withArguments(
+ argument,
+ typeParameter.bound,
+ typeParameter.name,
+ enclosingName,
+ isNonNullableByDefault);
}
}
}
@@ -2730,7 +2738,8 @@
argument,
typeParameter.bound,
typeParameter.name,
- getGenericTypeName(issue.enclosingType));
+ getGenericTypeName(issue.enclosingType),
+ isNonNullableByDefault);
}
reportTypeArgumentIssue(message, fileUri, offset, typeParameter);
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index 874292a..5ae2024 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -142,12 +142,23 @@
ClassHierarchyBuilder builderHierarchy;
- // Used when building directly to kernel.
+ /// Used when building directly to kernel.
ClassHierarchy hierarchy;
- CoreTypes coreTypes;
- // Used when checking whether a return type of an async function is valid.
+ CoreTypes _coreTypes;
+
+ /// Used when checking whether a return type of an async function is valid.
+ ///
+ /// The said return type is valid if it's a subtype of [futureOfBottom].
DartType futureOfBottom;
+
+ /// Used when checking whether a return type of a sync* function is valid.
+ ///
+ /// The said return type is valid if it's a subtype of [iterableOfBottom].
DartType iterableOfBottom;
+
+ /// Used when checking whether a return type of an async* function is valid.
+ ///
+ /// The said return type is valid if it's a subtype of [streamOfBottom].
DartType streamOfBottom;
TypeInferenceEngineImpl typeInferenceEngine;
@@ -165,6 +176,11 @@
retainDataForTesting ? new SourceLoaderDataForTesting() : null,
super(target);
+ CoreTypes get coreTypes {
+ assert(_coreTypes != null, "CoreTypes has not been computed.");
+ return _coreTypes;
+ }
+
Template<SummaryTemplate> get outlineSummaryTemplate =>
templateSourceOutlineSummary;
@@ -870,8 +886,8 @@
void handleAmbiguousSupertypes(Class cls, Supertype a, Supertype b) {
addProblem(
- templateAmbiguousSupertypes.withArguments(
- cls.name, a.asInterfaceType, b.asInterfaceType),
+ templateAmbiguousSupertypes.withArguments(cls.name, a.asInterfaceType,
+ b.asInterfaceType, cls.enclosingLibrary.isNonNullableByDefault),
cls.fileOffset,
noLength,
cls.fileUri);
@@ -880,14 +896,19 @@
void ignoreAmbiguousSupertypes(Class cls, Supertype a, Supertype b) {}
void computeCoreTypes(Component component) {
- coreTypes = new CoreTypes(component);
+ assert(_coreTypes == null, "CoreTypes has already been computed");
+ _coreTypes = new CoreTypes(component);
+ // These types are used on the left-hand side of the is-subtype-of relation
+ // to check if the return types of functions with async, sync*, and async*
+ // bodies are correct. It's valid to use the non-nullable types on the
+ // left-hand side in both opt-in and opt-out code.
futureOfBottom = new InterfaceType(coreTypes.futureClass,
- Nullability.legacy, <DartType>[const BottomType()]);
+ Nullability.nonNullable, <DartType>[const BottomType()]);
iterableOfBottom = new InterfaceType(coreTypes.iterableClass,
- Nullability.legacy, <DartType>[const BottomType()]);
+ Nullability.nonNullable, <DartType>[const BottomType()]);
streamOfBottom = new InterfaceType(coreTypes.streamClass,
- Nullability.legacy, <DartType>[const BottomType()]);
+ Nullability.nonNullable, <DartType>[const BottomType()]);
ticker.logMs("Computed core types");
}
@@ -975,14 +996,14 @@
if (builder.library.loader == this && !builder.isPatch) {
Class mixedInClass = builder.cls.mixedInClass;
if (mixedInClass != null && mixedInClass.isMixinDeclaration) {
- builder.checkMixinApplication(hierarchy);
+ builder.checkMixinApplication(hierarchy, coreTypes);
}
}
}
ticker.logMs("Checked mixin declaration applications");
}
- void buildOutlineExpressions() {
+ void buildOutlineExpressions(CoreTypes coreTypes) {
builders.forEach((Uri uri, LibraryBuilder library) {
if (library.loader == this) {
library.buildOutlineExpressions();
@@ -990,11 +1011,11 @@
while (iterator.moveNext()) {
Builder declaration = iterator.current;
if (declaration is ClassBuilder) {
- declaration.buildOutlineExpressions(library);
+ declaration.buildOutlineExpressions(library, coreTypes);
} else if (declaration is ExtensionBuilder) {
- declaration.buildOutlineExpressions(library);
+ declaration.buildOutlineExpressions(library, coreTypes);
} else if (declaration is MemberBuilder) {
- declaration.buildOutlineExpressions(library);
+ declaration.buildOutlineExpressions(library, coreTypes);
}
}
}
@@ -1128,7 +1149,7 @@
first = null;
sourceBytes?.clear();
target?.releaseAncillaryResources();
- coreTypes = null;
+ _coreTypes = null;
instrumentation = null;
collectionTransformer = null;
setLiteralTransformer = null;
diff --git a/pkg/front_end/lib/src/fasta/type_inference/standard_bounds.dart b/pkg/front_end/lib/src/fasta/type_inference/standard_bounds.dart
index 67147c8..7a4451f 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/standard_bounds.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/standard_bounds.dart
@@ -13,6 +13,7 @@
FunctionType,
InterfaceType,
InvalidType,
+ Library,
NamedType,
TypeParameter,
TypeParameterType,
@@ -38,14 +39,15 @@
bool isSubtypeOf(DartType subtype, DartType supertype, SubtypeCheckMode mode);
InterfaceType getLegacyLeastUpperBound(
- InterfaceType type1, InterfaceType type2);
+ InterfaceType type1, InterfaceType type2, Library clientLibrary);
/// Computes the standard lower bound of [type1] and [type2].
///
/// Standard lower bound is a lower bound function that imposes an
/// ordering on the top types `void`, `dynamic`, and `object`. This function
/// additionally handles the unknown type that appears during type inference.
- DartType getStandardLowerBound(DartType type1, DartType type2) {
+ DartType getStandardLowerBound(
+ DartType type1, DartType type2, Library clientLibrary) {
// For all types T, SLB(T,T) = T. Note that we don't test for equality
// because we don't want to make the algorithm quadratic. This is ok
// because the check is not needed for correctness; it's just a speed
@@ -94,7 +96,7 @@
// Function types have structural lower bounds.
if (type1 is FunctionType && type2 is FunctionType) {
- return _functionStandardLowerBound(type1, type2);
+ return _functionStandardLowerBound(type1, type2, clientLibrary);
}
// Otherwise, the lower bounds of two types is one of them it if it is a
@@ -113,7 +115,7 @@
if (type2.classNode == futureOrClass) {
// GLB(FutureOr<A>, FutureOr<B>) == FutureOr<GLB(A, B)>
DartType argument = getStandardLowerBound(
- type1.typeArguments[0], type2.typeArguments[0]);
+ type1.typeArguments[0], type2.typeArguments[0], clientLibrary);
return new InterfaceType(
futureOrClass, argument.nullability, <DartType>[argument]);
}
@@ -125,13 +127,14 @@
computeNullabilityOfFutureOr(type1, futureOrClass),
type2.nullability),
<DartType>[
- getStandardLowerBound(
- type1.typeArguments[0], type2.typeArguments[0])
+ getStandardLowerBound(type1.typeArguments[0],
+ type2.typeArguments[0], clientLibrary)
]);
}
}
// GLB(FutureOr<A>, B) == GLB(A, B)
- return getStandardLowerBound(type1.typeArguments[0], type2);
+ return getStandardLowerBound(
+ type1.typeArguments[0], type2, clientLibrary);
}
// The if-statement below handles the following rule:
// GLB(A, FutureOr<B>) == GLB(FutureOr<B>, A)
@@ -147,11 +150,12 @@
computeNullabilityOfFutureOr(type2, futureOrClass)),
<DartType>[
getStandardLowerBound(
- type2.typeArguments[0], type1.typeArguments[0])
+ type2.typeArguments[0], type1.typeArguments[0], clientLibrary)
]);
}
// GLB(A, FutureOr<B>) == GLB(B, A)
- return getStandardLowerBound(type2.typeArguments[0], type1);
+ return getStandardLowerBound(
+ type2.typeArguments[0], type1, clientLibrary);
}
// No subtype relation, so the lower bound is bottom.
@@ -163,7 +167,8 @@
/// Standard upper bound is an upper bound function that imposes an ordering
/// on the top types 'void', 'dynamic', and `object`. This function
/// additionally handles the unknown type that appears during type inference.
- DartType getStandardUpperBound(DartType type1, DartType type2) {
+ DartType getStandardUpperBound(
+ DartType type1, DartType type2, Library clientLibrary) {
// For all types T, SUB(T,T) = T. Note that we don't test for equality
// because we don't want to make the algorithm quadratic. This is ok
// because the check is not needed for correctness; it's just a speed
@@ -211,7 +216,7 @@
if (type2 == nullType) return type1;
if (type1 is TypeParameterType || type2 is TypeParameterType) {
- return _typeParameterStandardUpperBound(type1, type2);
+ return _typeParameterStandardUpperBound(type1, type2, clientLibrary);
}
// The standard upper bound of a function type and an interface type T is
@@ -226,11 +231,11 @@
// At this point type1 and type2 should both either be interface types or
// function types.
if (type1 is InterfaceType && type2 is InterfaceType) {
- return _interfaceStandardUpperBound(type1, type2);
+ return _interfaceStandardUpperBound(type1, type2, clientLibrary);
}
if (type1 is FunctionType && type2 is FunctionType) {
- return _functionStandardUpperBound(type1, type2);
+ return _functionStandardUpperBound(type1, type2, clientLibrary);
}
if (type1 is InvalidType || type2 is InvalidType) {
@@ -259,7 +264,8 @@
/// the resulting parameter type.
///
/// - Use the SLB of their return types.
- DartType _functionStandardLowerBound(FunctionType f, FunctionType g) {
+ DartType _functionStandardLowerBound(
+ FunctionType f, FunctionType g, Library clientLibrary) {
// TODO(rnystrom,paulberry): Right now, this assumes f and g do not have any
// type parameters. Revisit that in the presence of generic methods.
@@ -272,7 +278,8 @@
DartType fType = f.positionalParameters[i];
if (i < g.positionalParameters.length) {
DartType gType = g.positionalParameters[i];
- positionalParameters[i] = getStandardUpperBound(fType, gType);
+ positionalParameters[i] =
+ getStandardUpperBound(fType, gType, clientLibrary);
} else {
positionalParameters[i] = fType;
}
@@ -307,7 +314,7 @@
namedParameters.add(new NamedType(
fName,
getStandardUpperBound(f.namedParameters[i++].type,
- g.namedParameters[j++].type)));
+ g.namedParameters[j++].type, clientLibrary)));
}
} else {
namedParameters.addAll(f.namedParameters.skip(i));
@@ -326,7 +333,8 @@
if (hasPositional && hasNamed) return const BottomType();
// Calculate the SLB of the return type.
- DartType returnType = getStandardLowerBound(f.returnType, g.returnType);
+ DartType returnType =
+ getStandardLowerBound(f.returnType, g.returnType, clientLibrary);
return new FunctionType(positionalParameters, returnType,
intersectNullabilities(f.nullability, g.nullability),
namedParameters: namedParameters,
@@ -345,7 +353,8 @@
///
/// - Compute the SLB of each corresponding pair of parameter types, and the
/// SUB of the return types. Return a function type with those types.
- DartType _functionStandardUpperBound(FunctionType f, FunctionType g) {
+ DartType _functionStandardUpperBound(
+ FunctionType f, FunctionType g, Library clientLibrary) {
// TODO(rnystrom): Right now, this assumes f and g do not have any type
// parameters. Revisit that in the presence of generic methods.
@@ -369,7 +378,7 @@
List<DartType> positionalParameters = new List<DartType>(totalPositional);
for (int i = 0; i < totalPositional; i++) {
positionalParameters[i] = getStandardLowerBound(
- f.positionalParameters[i], g.positionalParameters[i]);
+ f.positionalParameters[i], g.positionalParameters[i], clientLibrary);
}
// Intersect the named parameters.
@@ -391,7 +400,7 @@
namedParameters.add(new NamedType(
fName,
getStandardLowerBound(f.namedParameters[i++].type,
- g.namedParameters[j++].type)));
+ g.namedParameters[j++].type, clientLibrary)));
}
} else {
break;
@@ -403,7 +412,8 @@
}
// Calculate the SUB of the return type.
- DartType returnType = getStandardUpperBound(f.returnType, g.returnType);
+ DartType returnType =
+ getStandardUpperBound(f.returnType, g.returnType, clientLibrary);
return new FunctionType(positionalParameters, returnType,
uniteNullabilities(f.nullability, g.nullability),
namedParameters: namedParameters,
@@ -411,7 +421,7 @@
}
DartType _interfaceStandardUpperBound(
- InterfaceType type1, InterfaceType type2) {
+ InterfaceType type1, InterfaceType type2, Library clientLibrary) {
// This currently does not implement a very complete standard upper bound
// algorithm, but handles a couple of the very common cases that are
// causing pain in real code. The current algorithm is:
@@ -449,29 +459,30 @@
List<DartType> tArgs = new List(tArgs1.length);
for (int i = 0; i < tArgs1.length; i++) {
if (tParams[i].variance == Variance.contravariant) {
- tArgs[i] = getStandardLowerBound(tArgs1[i], tArgs2[i]);
+ tArgs[i] = getStandardLowerBound(tArgs1[i], tArgs2[i], clientLibrary);
} else if (tParams[i].variance == Variance.invariant) {
if (!isSubtypeOf(tArgs1[i], tArgs2[i],
SubtypeCheckMode.ignoringNullabilities) ||
!isSubtypeOf(tArgs2[i], tArgs1[i],
SubtypeCheckMode.ignoringNullabilities)) {
// No bound will be valid, find bound at the interface level.
- return getLegacyLeastUpperBound(type1, type2);
+ return getLegacyLeastUpperBound(type1, type2, clientLibrary);
}
// TODO (kallentu) : Fix asymmetric bounds behavior for invariant type
// parameters.
tArgs[i] = tArgs1[i];
} else {
- tArgs[i] = getStandardUpperBound(tArgs1[i], tArgs2[i]);
+ tArgs[i] = getStandardUpperBound(tArgs1[i], tArgs2[i], clientLibrary);
}
}
return new InterfaceType(type1.classNode,
uniteNullabilities(type1.nullability, type2.nullability), tArgs);
}
- return getLegacyLeastUpperBound(type1, type2);
+ return getLegacyLeastUpperBound(type1, type2, clientLibrary);
}
- DartType _typeParameterStandardUpperBound(DartType type1, DartType type2) {
+ DartType _typeParameterStandardUpperBound(
+ DartType type1, DartType type2, Library clientLibrary) {
// This currently just implements a simple standard upper bound to
// handle some common cases. It also avoids some termination issues
// with the naive spec algorithm. The standard upper bound of two types
@@ -517,12 +528,14 @@
return getStandardUpperBound(
Substitution.fromMap({type1.parameter: objectLegacyRawType})
.substituteType(type1.parameter.bound),
- type2);
+ type2,
+ clientLibrary);
} else if (type2 is TypeParameterType) {
return getStandardUpperBound(
type1,
Substitution.fromMap({type2.parameter: objectLegacyRawType})
- .substituteType(type2.parameter.bound));
+ .substituteType(type2.parameter.bound),
+ clientLibrary);
} else {
// We should only be called when at least one of the types is a
// TypeParameterType
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
index c71249a..861ef34 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
@@ -20,6 +20,8 @@
Variance,
VoidType;
+import 'package:kernel/core_types.dart';
+
import 'package:kernel/type_algebra.dart' show substitute, Substitution;
import 'package:kernel/type_environment.dart';
@@ -63,18 +65,24 @@
Class get nullClass;
- void addUpperBound(TypeConstraint constraint, DartType upper);
+ void addUpperBound(
+ TypeConstraint constraint, DartType upper, Library clientLibrary);
- void addLowerBound(TypeConstraint constraint, DartType lower);
+ void addLowerBound(
+ TypeConstraint constraint, DartType lower, Library clientLibrary);
Member getInterfaceMember(Class class_, Name name, {bool setter: false});
- InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass);
+ InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass,
+ Library clientLibrary, CoreTypes coreTypes);
+
+ List<DartType> getTypeArgumentsAsInstanceOf(
+ InterfaceType type, Class superclass);
InterfaceType futureType(DartType type, Nullability nullability);
/// Returns the set of type constraints that was gathered.
- Map<TypeParameter, TypeConstraint> computeConstraints() {
+ Map<TypeParameter, TypeConstraint> computeConstraints(Library clientLibrary) {
Map<TypeParameter, TypeConstraint> result =
<TypeParameter, TypeConstraint>{};
for (TypeParameter parameter in _parametersToConstrain) {
@@ -82,9 +90,11 @@
}
for (_ProtoConstraint protoConstraint in _protoConstraints) {
if (protoConstraint.isUpper) {
- addUpperBound(result[protoConstraint.parameter], protoConstraint.bound);
+ addUpperBound(result[protoConstraint.parameter], protoConstraint.bound,
+ clientLibrary);
} else {
- addLowerBound(result[protoConstraint.parameter], protoConstraint.bound);
+ addLowerBound(result[protoConstraint.parameter], protoConstraint.bound,
+ clientLibrary);
}
}
return result;
@@ -212,26 +222,26 @@
// of supertypes of a given type more than once, the order of the checks
// above is irrelevant; we just need to find the matched superclass,
// substitute, and then iterate through type variables.
- InterfaceType matchingSupertypeOfSubtype =
- getTypeAsInstanceOf(subtype, supertype.classNode);
- if (matchingSupertypeOfSubtype == null) return false;
+ List<DartType> matchingSupertypeOfSubtypeArguments =
+ getTypeArgumentsAsInstanceOf(subtype, supertype.classNode);
+ if (matchingSupertypeOfSubtypeArguments == null) return false;
for (int i = 0; i < supertype.classNode.typeParameters.length; i++) {
// Generate constraints and subtype match with respect to variance.
int parameterVariance = supertype.classNode.typeParameters[i].variance;
if (parameterVariance == Variance.contravariant) {
if (!_isSubtypeMatch(supertype.typeArguments[i],
- matchingSupertypeOfSubtype.typeArguments[i])) {
+ matchingSupertypeOfSubtypeArguments[i])) {
return false;
}
} else if (parameterVariance == Variance.invariant) {
if (!_isSubtypeMatch(supertype.typeArguments[i],
- matchingSupertypeOfSubtype.typeArguments[i]) ||
- !_isSubtypeMatch(matchingSupertypeOfSubtype.typeArguments[i],
+ matchingSupertypeOfSubtypeArguments[i]) ||
+ !_isSubtypeMatch(matchingSupertypeOfSubtypeArguments[i],
supertype.typeArguments[i])) {
return false;
}
} else {
- if (!_isSubtypeMatch(matchingSupertypeOfSubtype.typeArguments[i],
+ if (!_isSubtypeMatch(matchingSupertypeOfSubtypeArguments[i],
supertype.typeArguments[i])) {
return false;
}
@@ -476,13 +486,15 @@
Class get nullClass => environment.coreTypes.nullClass;
@override
- void addUpperBound(TypeConstraint constraint, DartType upper) {
- environment.addUpperBound(constraint, upper);
+ void addUpperBound(
+ TypeConstraint constraint, DartType upper, Library clientLibrary) {
+ environment.addUpperBound(constraint, upper, clientLibrary);
}
@override
- void addLowerBound(TypeConstraint constraint, DartType lower) {
- environment.addLowerBound(constraint, lower);
+ void addLowerBound(
+ TypeConstraint constraint, DartType lower, Library clientLibrary) {
+ environment.addLowerBound(constraint, lower, clientLibrary);
}
@override
@@ -492,8 +504,16 @@
}
@override
- InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass) {
- return environment.getTypeAsInstanceOf(type, superclass);
+ InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass,
+ Library clientLibrary, CoreTypes coreTypes) {
+ return environment.getTypeAsInstanceOf(
+ type, superclass, clientLibrary, coreTypes);
+ }
+
+ @override
+ List<DartType> getTypeArgumentsAsInstanceOf(
+ InterfaceType type, Class superclass) {
+ return environment.getTypeArgumentsAsInstanceOf(type, superclass);
}
@override
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
index 609f21b..73af49e 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
@@ -9,12 +9,12 @@
Constructor,
DartType,
DartTypeVisitor,
- DynamicType,
Field,
FunctionType,
InterfaceType,
Member,
NamedType,
+ NeverType,
Nullability,
TreeNode,
TypeParameter,
@@ -31,7 +31,7 @@
import '../../base/instrumentation.dart' show Instrumentation;
-import '../builder/library_builder.dart';
+import '../builder/constructor_builder.dart';
import '../kernel/forest.dart';
@@ -128,14 +128,14 @@
/// This is represented as a map from a constructor to its library
/// builder because the builder is used to report errors due to cyclic
/// inference dependencies.
- final Map<Constructor, LibraryBuilder> toBeInferred = {};
+ final Map<Constructor, ConstructorBuilder> toBeInferred = {};
/// A map containing constructors in the process of being inferred.
///
/// This is used to detect cyclic inference dependencies. It is represented
/// as a map from a constructor to its library builder because the builder
/// is used to report errors.
- final Map<Constructor, LibraryBuilder> beingInferred = {};
+ final Map<Constructor, ConstructorBuilder> beingInferred = {};
final Instrumentation instrumentation;
@@ -155,37 +155,14 @@
/// constructors still needing inference and infer the types of their
/// initializing formals from the corresponding fields.
void finishTopLevelInitializingFormals() {
- // Field types have all been inferred so there cannot be a cyclic
- // dependency.
- for (Constructor constructor in toBeInferred.keys) {
- for (VariableDeclaration declaration
- in constructor.function.positionalParameters) {
- inferInitializingFormal(declaration, constructor);
- }
- for (VariableDeclaration declaration
- in constructor.function.namedParameters) {
- inferInitializingFormal(declaration, constructor);
- }
- }
+ // Field types have all been inferred so we don't need to guard against
+ // cyclic dependency.
+ toBeInferred.values.forEach((ConstructorBuilder builder) {
+ builder.inferFormalTypes();
+ });
toBeInferred.clear();
}
- void inferInitializingFormal(VariableDeclaration formal, Constructor parent) {
- if (formal.type == null) {
- for (Field field in parent.enclosingClass.fields) {
- if (field.name.name == formal.name) {
- TypeInferenceEngine.resolveInferenceNode(field);
- formal.type = field.type;
- return;
- }
- }
- // We did not find the corresponding field, so the program is erroneous.
- // The error should have been reported elsewhere and type inference
- // should continue by inferring dynamic.
- formal.type = const DynamicType();
- }
- }
-
/// Gets ready to do top level type inference for the component having the
/// given [hierarchy], using the given [coreTypes].
void prepareTopLevel(CoreTypes coreTypes, ClassHierarchy hierarchy) {
@@ -284,6 +261,16 @@
@override
DartType promoteToNonNull(DartType type) {
+ if (type is TypeParameterType) {
+ DartType bound = type.bound.withNullability(Nullability.nonNullable);
+ if (bound != type.bound) {
+ return new TypeParameterType(
+ type.parameter, type.typeParameterTypeNullability, bound);
+ }
+ return type;
+ } else if (type == typeEnvironment.nullType) {
+ return const NeverType(Nullability.nonNullable);
+ }
return type.withNullability(Nullability.nonNullable);
}
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index 8db173a..4633040 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -6,6 +6,8 @@
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
+import 'package:_fe_analyzer_shared/src/util/link.dart';
+
import 'package:front_end/src/fasta/kernel/internal_ast.dart';
import 'package:front_end/src/fasta/type_inference/type_demotion.dart';
@@ -28,6 +30,7 @@
InstrumentationValueForType,
InstrumentationValueForTypeArgs;
+import '../builder/constructor_builder.dart';
import '../builder/extension_builder.dart';
import '../builder/member_builder.dart';
@@ -278,8 +281,8 @@
_inferredUnwrappedReturnOrYieldType = unwrappedType;
} else {
_inferredUnwrappedReturnOrYieldType = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(
- _inferredUnwrappedReturnOrYieldType, unwrappedType);
+ .getStandardUpperBound(_inferredUnwrappedReturnOrYieldType,
+ unwrappedType, inferrer.library.library);
}
return;
}
@@ -329,8 +332,8 @@
_inferredUnwrappedReturnOrYieldType = unwrappedType;
} else {
_inferredUnwrappedReturnOrYieldType = inferrer.typeSchemaEnvironment
- .getStandardUpperBound(
- _inferredUnwrappedReturnOrYieldType, unwrappedType);
+ .getStandardUpperBound(_inferredUnwrappedReturnOrYieldType,
+ unwrappedType, inferrer.library.library);
}
}
}
@@ -403,6 +406,10 @@
/// Gets the [TypeSchemaEnvironment] being used for type inference.
TypeSchemaEnvironment get typeSchemaEnvironment;
+ /// Returns the [FlowAnalysis] used during inference.
+ FlowAnalysis<TreeNode, Statement, Expression, VariableDeclaration, DartType>
+ get flowAnalysis;
+
/// The URI of the code for which type inference is currently being
/// performed--this is used for testing.
Uri get uriForInstrumentation;
@@ -415,7 +422,7 @@
/// Performs type inference on the given function body.
Statement inferFunctionBody(InferenceHelper helper, DartType returnType,
- AsyncMarker asyncMarker, FunctionNode function, Statement body);
+ AsyncMarker asyncMarker, Statement body);
/// Performs type inference on the given constructor initializer.
void inferInitializer(InferenceHelper helper, Initializer initializer);
@@ -433,6 +440,11 @@
/// expression.
Expression inferParameterInitializer(
InferenceHelper helper, Expression initializer, DartType declaredType);
+
+ /// Ensures that all parameter types of [constructor] have been inferred.
+ // TODO(johnniwinther): We are still parameters on synthesized mixin
+ // application constructors.
+ void inferConstructorParameterTypes(Constructor constructor);
}
/// Concrete implementation of [TypeInferrer] specialized to work with kernel
@@ -440,8 +452,7 @@
class TypeInferrerImpl implements TypeInferrer {
/// Marker object to indicate that a function takes an unknown number
/// of arguments.
- static final FunctionType unknownFunction =
- new FunctionType(const [], const DynamicType(), Nullability.legacy);
+ final FunctionType unknownFunction;
final TypeInferenceEngine engine;
@@ -491,12 +502,13 @@
TypeInferrerImpl(this.engine, this.uriForInstrumentation, bool topLevel,
this.thisType, this.library, this.assignedVariables, this.dataForTesting)
: assert(library != null),
+ unknownFunction = new FunctionType(
+ const [], const DynamicType(), library.nonNullable),
classHierarchy = engine.classHierarchy,
instrumentation = topLevel ? null : engine.instrumentation,
typeSchemaEnvironment = engine.typeSchemaEnvironment,
isTopLevel = topLevel,
typePromoter = new TypePromoter(engine.typeSchemaEnvironment),
- // TODO(dmitryas): Pass in the actual assigned variables.
flowAnalysis = new FlowAnalysis(
new TypeOperationsCfe(engine.typeSchemaEnvironment),
assignedVariables);
@@ -514,6 +526,40 @@
}
@override
+ void inferConstructorParameterTypes(Constructor target) {
+ ConstructorBuilder constructor = engine.beingInferred[target];
+ if (constructor != null) {
+ // There is a cyclic dependency where inferring the types of the
+ // initializing formals of a constructor required us to infer the
+ // corresponding field type which required us to know the type of the
+ // constructor.
+ String name = target.enclosingClass.name;
+ if (target.name.name.isNotEmpty) {
+ // TODO(ahe): Use `inferrer.helper.constructorNameForDiagnostics`
+ // instead. However, `inferrer.helper` may be null.
+ name += ".${target.name.name}";
+ }
+ constructor.library.addProblem(
+ templateCantInferTypeDueToCircularity.withArguments(name),
+ target.fileOffset,
+ name.length,
+ target.fileUri);
+ for (VariableDeclaration declaration
+ in target.function.positionalParameters) {
+ declaration.type ??= const InvalidType();
+ }
+ for (VariableDeclaration declaration in target.function.namedParameters) {
+ declaration.type ??= const InvalidType();
+ }
+ } else if ((constructor = engine.toBeInferred[target]) != null) {
+ engine.toBeInferred.remove(target);
+ engine.beingInferred[target] = constructor;
+ constructor.inferFormalTypes();
+ engine.beingInferred.remove(target);
+ }
+ }
+
+ @override
void inferInitializer(InferenceHelper helper, Initializer initializer) {
this.helper = helper;
// Use polymorphic dispatch on [KernelInitializer] to perform whatever
@@ -572,7 +618,7 @@
{int fileOffset,
bool isReturnFromAsync: false,
bool isVoidAllowed: false,
- Template<Message Function(DartType, DartType)> template}) {
+ Template<Message Function(DartType, DartType, bool)> template}) {
assert(expectedType != null);
fileOffset ??= expression.fileOffset;
expectedType = greatestClosure(coreTypes, expectedType);
@@ -662,19 +708,22 @@
if (expectedType is! InvalidType && actualType is! InvalidType) {
errorNode = helper.wrapInProblem(
errorNode,
- (template ?? templateInvalidAssignment)
- .withArguments(actualType, expectedType),
+ (template ?? templateInvalidAssignment).withArguments(
+ actualType, expectedType, isNonNullableByDefault),
noLength);
}
return errorNode;
} else {
- Template<Message Function(DartType, DartType)> template =
+ Template<Message Function(DartType, DartType, bool)> template =
_getPreciseTypeErrorTemplate(expression);
if (template != null) {
// The type of the expression is known precisely, so an implicit
// downcast is guaranteed to fail. Insert a compile-time error.
- return helper.wrapInProblem(expression,
- template.withArguments(actualType, expectedType), noLength);
+ return helper.wrapInProblem(
+ expression,
+ template.withArguments(
+ actualType, expectedType, isNonNullableByDefault),
+ noLength);
} else {
// Insert an implicit downcast.
return new AsExpression(expression, initialExpectedType)
@@ -905,7 +954,7 @@
DartType receiverType,
Name name,
int fileOffset,
- Template<Message Function(String, DartType)> errorTemplate) {
+ Template<Message Function(String, DartType, bool)> errorTemplate) {
assert(receiverType != null && isKnown(receiverType));
if (!isTopLevel && target.isMissing && errorTemplate != null) {
int length = name.name.length;
@@ -914,8 +963,8 @@
length = 1;
}
return helper.buildProblem(
- errorTemplate.withArguments(
- name.name, resolveTypeParameter(receiverType)),
+ errorTemplate.withArguments(name.name,
+ resolveTypeParameter(receiverType), isNonNullableByDefault),
fileOffset,
length);
}
@@ -1007,9 +1056,10 @@
if (memberClass.typeParameters.isNotEmpty) {
receiverType = resolveTypeParameter(receiverType);
if (receiverType is InterfaceType) {
- InterfaceType castedType =
- classHierarchy.getTypeAsInstanceOf(receiverType, memberClass);
- calleeType = Substitution.fromInterfaceType(castedType)
+ List<DartType> castedTypeArguments = classHierarchy
+ .getTypeArgumentsAsInstanceOf(receiverType, memberClass);
+ calleeType = Substitution.fromPairs(
+ memberClass.typeParameters, castedTypeArguments)
.substituteType(calleeType);
}
}
@@ -1275,10 +1325,10 @@
DartType getDerivedTypeArgumentOf(DartType type, Class class_) {
if (type is InterfaceType) {
- InterfaceType typeAsInstanceOfClass =
- classHierarchy.getTypeAsInstanceOf(type, class_);
- if (typeAsInstanceOfClass != null) {
- return typeAsInstanceOfClass.typeArguments[0];
+ List<DartType> typeArgumentsAsInstanceOfClass =
+ classHierarchy.getTypeArgumentsAsInstanceOf(type, class_);
+ if (typeArgumentsAsInstanceOfClass != null) {
+ return typeArgumentsAsInstanceOfClass[0];
}
}
return null;
@@ -1320,9 +1370,10 @@
if (memberClass.typeParameters.isNotEmpty) {
receiverType = resolveTypeParameter(receiverType);
if (receiverType is InterfaceType) {
- InterfaceType castedType =
- classHierarchy.getTypeAsInstanceOf(receiverType, memberClass);
- setterType = Substitution.fromInterfaceType(castedType)
+ setterType = Substitution.fromPairs(
+ memberClass.typeParameters,
+ classHierarchy.getTypeArgumentsAsInstanceOf(
+ receiverType, memberClass))
.substituteType(setterType);
}
}
@@ -1439,6 +1490,36 @@
variable.type = inferredType;
}
+ Link<NullAwareGuard> inferSyntheticVariableNullAware(
+ VariableDeclarationImpl variable) {
+ assert(variable.isImplicitlyTyped);
+ assert(variable.initializer != null);
+ ExpressionInferenceResult result = inferExpression(
+ variable.initializer, const UnknownType(), true,
+ isVoidAllowed: true);
+ Link<NullAwareGuard> nullAwareGuards;
+ if (isNonNullableByDefault) {
+ variable.initializer = result.nullAwareAction..parent = variable;
+ nullAwareGuards = result.nullAwareGuards;
+ } else {
+ variable.initializer = result.expression..parent = variable;
+ nullAwareGuards = const Link<NullAwareGuard>();
+ }
+ DartType inferredType = inferDeclarationType(result.inferredType);
+ instrumentation?.record(uriForInstrumentation, variable.fileOffset, 'type',
+ new InstrumentationValueForType(inferredType));
+ variable.type = inferredType;
+ return nullAwareGuards;
+ }
+
+ NullAwareGuard createNullAwareGuard(VariableDeclaration variable) {
+ Member equalsMember =
+ findInterfaceMember(variable.type, equalsName, variable.fileOffset)
+ .member;
+ return new NullAwareGuard(
+ variable, variable.fileOffset, equalsMember, this);
+ }
+
/// Performs type inference on the given [expression].
///
/// [typeContext] is the expected type of the expression, based on surrounding
@@ -1509,19 +1590,11 @@
@override
Statement inferFunctionBody(InferenceHelper helper, DartType returnType,
- AsyncMarker asyncMarker, FunctionNode function, Statement body) {
+ AsyncMarker asyncMarker, Statement body) {
assert(body != null);
assert(closureContext == null);
this.helper = helper;
closureContext = new ClosureContext(this, asyncMarker, returnType, false);
- if (function != null) {
- for (VariableDeclaration parameter in function.positionalParameters) {
- flowAnalysis.initialize(parameter);
- }
- for (VariableDeclaration parameter in function.namedParameters) {
- flowAnalysis.initialize(parameter);
- }
- }
StatementInferenceResult result = inferStatement(body);
closureContext = null;
this.helper = null;
@@ -2068,7 +2141,7 @@
ExpressionInferenceResult _inferDynamicInvocation(
int fileOffset,
- NullAwareGuard nullAwareGuard,
+ Link<NullAwareGuard> nullAwareGuards,
Expression receiver,
Name name,
Arguments arguments,
@@ -2081,12 +2154,12 @@
inferredType,
new MethodInvocationImpl(receiver, name, arguments)
..fileOffset = fileOffset,
- nullAwareGuard);
+ nullAwareGuards);
}
ExpressionInferenceResult _inferMissingInvocation(
int fileOffset,
- NullAwareGuard nullAwareGuard,
+ Link<NullAwareGuard> nullAwareGuards,
Expression receiver,
DartType receiverType,
ObjectAccessTarget target,
@@ -2102,12 +2175,13 @@
receiverType: receiverType);
assert(name != equalsName);
// TODO(johnniwinther): Use InvalidType instead.
- return new ExpressionInferenceResult(const DynamicType(), error);
+ return new ExpressionInferenceResult.nullAware(
+ const DynamicType(), error, nullAwareGuards);
}
ExpressionInferenceResult _inferExtensionInvocation(
int fileOffset,
- NullAwareGuard nullAwareGuard,
+ Link<NullAwareGuard> nullAwareGuards,
Expression receiver,
DartType receiverType,
ObjectAccessTarget target,
@@ -2140,12 +2214,12 @@
typeSchemaEnvironment, helper.uri, getTypeArgumentsInfo(arguments));
}
return new ExpressionInferenceResult.nullAware(
- inferredType, staticInvocation, nullAwareGuard);
+ inferredType, staticInvocation, nullAwareGuards);
}
ExpressionInferenceResult _inferFunctionInvocation(
int fileOffset,
- NullAwareGuard nullAwareGuard,
+ Link<NullAwareGuard> nullAwareGuards,
Expression receiver,
DartType receiverType,
ObjectAccessTarget target,
@@ -2161,12 +2235,12 @@
inferredType,
new MethodInvocation(receiver, callName, arguments)
..fileOffset = fileOffset,
- nullAwareGuard);
+ nullAwareGuards);
}
ExpressionInferenceResult _inferInstanceMethodInvocation(
int fileOffset,
- NullAwareGuard nullAwareGuard,
+ Link<NullAwareGuard> nullAwareGuards,
Expression receiver,
DartType receiverType,
ObjectAccessTarget target,
@@ -2254,12 +2328,12 @@
..fileOffset = fileOffset;
return new ExpressionInferenceResult.nullAware(
- inferredType, replacement, nullAwareGuard);
+ inferredType, replacement, nullAwareGuards);
}
ExpressionInferenceResult _inferInstanceGetterInvocation(
int fileOffset,
- NullAwareGuard nullAwareGuard,
+ Link<NullAwareGuard> nullAwareGuards,
Expression receiver,
DartType receiverType,
ObjectAccessTarget target,
@@ -2320,7 +2394,8 @@
if (isImplicitCall) {
Expression error = helper.buildProblem(
- templateImplicitCallOfNonMethod.withArguments(receiverType),
+ templateImplicitCallOfNonMethod.withArguments(
+ receiverType, isNonNullableByDefault),
fileOffset,
noLength);
return new ExpressionInferenceResult(const DynamicType(), error);
@@ -2351,12 +2426,12 @@
..fileOffset = fileOffset;
return new ExpressionInferenceResult.nullAware(
- inferredType, replacement, nullAwareGuard);
+ inferredType, replacement, nullAwareGuards);
}
ExpressionInferenceResult _inferInstanceFieldInvocation(
int fileOffset,
- NullAwareGuard nullAwareGuard,
+ Link<NullAwareGuard> nullAwareGuards,
Expression receiver,
DartType receiverType,
ObjectAccessTarget target,
@@ -2395,7 +2470,8 @@
if (isImplicitCall) {
Expression error = helper.buildProblem(
- templateImplicitCallOfNonMethod.withArguments(receiverType),
+ templateImplicitCallOfNonMethod.withArguments(
+ receiverType, isNonNullableByDefault),
fileOffset,
noLength);
return new ExpressionInferenceResult(const DynamicType(), error);
@@ -2425,7 +2501,7 @@
..fileOffset = fileOffset;
return new ExpressionInferenceResult.nullAware(
- inferredType, replacement, nullAwareGuard);
+ inferredType, replacement, nullAwareGuards);
}
/// Performs the core type inference algorithm for method invocations (this
@@ -2436,9 +2512,9 @@
ExpressionInferenceResult result =
inferExpression(node.receiver, const UnknownType(), true);
Expression receiver;
- NullAwareGuard nullAwareGuard;
+ Link<NullAwareGuard> nullAwareGuards;
if (isNonNullableByDefault) {
- nullAwareGuard = result.nullAwareGuard;
+ nullAwareGuards = result.nullAwareGuards;
receiver = result.nullAwareAction;
} else {
receiver = result.expression;
@@ -2454,7 +2530,7 @@
if (member.kind == ProcedureKind.Getter) {
return _inferInstanceGetterInvocation(
node.fileOffset,
- nullAwareGuard,
+ nullAwareGuards,
receiver,
receiverType,
target,
@@ -2464,7 +2540,7 @@
} else {
return _inferInstanceMethodInvocation(
node.fileOffset,
- nullAwareGuard,
+ nullAwareGuards,
receiver,
receiverType,
target,
@@ -2473,18 +2549,18 @@
isImplicitCall: node.isImplicitCall);
}
} else {
- return _inferInstanceFieldInvocation(node.fileOffset, nullAwareGuard,
+ return _inferInstanceFieldInvocation(node.fileOffset, nullAwareGuards,
receiver, receiverType, target, node.arguments, typeContext,
isImplicitCall: node.isImplicitCall);
}
break;
case ObjectAccessTargetKind.callFunction:
- return _inferFunctionInvocation(node.fileOffset, nullAwareGuard,
+ return _inferFunctionInvocation(node.fileOffset, nullAwareGuards,
receiver, receiverType, target, node.arguments, typeContext);
case ObjectAccessTargetKind.extensionMember:
return _inferExtensionInvocation(
node.fileOffset,
- nullAwareGuard,
+ nullAwareGuards,
receiver,
receiverType,
target,
@@ -2494,7 +2570,7 @@
case ObjectAccessTargetKind.missing:
return _inferMissingInvocation(
node.fileOffset,
- nullAwareGuard,
+ nullAwareGuards,
receiver,
receiverType,
target,
@@ -2505,7 +2581,7 @@
case ObjectAccessTargetKind.dynamic:
case ObjectAccessTargetKind.invalid:
case ObjectAccessTargetKind.unresolved:
- return _inferDynamicInvocation(node.fileOffset, nullAwareGuard,
+ return _inferDynamicInvocation(node.fileOffset, nullAwareGuards,
receiver, node.name, node.arguments, typeContext);
}
return unhandled('$target', 'inferMethodInvocation', node.fileOffset,
@@ -2812,8 +2888,8 @@
///
/// If it is, an error message template is returned, which can be used by the
/// caller to report an invalid cast. Otherwise, `null` is returned.
- Template<Message Function(DartType, DartType)> _getPreciseTypeErrorTemplate(
- Expression expression) {
+ Template<Message Function(DartType, DartType, bool)>
+ _getPreciseTypeErrorTemplate(Expression expression) {
if (expression is ListLiteral) {
return templateInvalidCastLiteralList;
}
@@ -2902,8 +2978,8 @@
.createMethodInvocation(fileOffset, receiver, name, arguments);
} else {
return helper.buildProblem(
- templateUndefinedMethod.withArguments(
- name.name, resolveTypeParameter(receiverType)),
+ templateUndefinedMethod.withArguments(name.name,
+ resolveTypeParameter(receiverType), isNonNullableByDefault),
fileOffset,
isImplicitCall ? noLength : name.name.length);
}
@@ -2916,8 +2992,8 @@
.createPropertyGet(fileOffset, receiver, propertyName);
} else {
return helper.buildProblem(
- templateUndefinedGetter.withArguments(
- propertyName.name, resolveTypeParameter(receiverType)),
+ templateUndefinedGetter.withArguments(propertyName.name,
+ resolveTypeParameter(receiverType), isNonNullableByDefault),
fileOffset,
propertyName.name.length);
}
@@ -2933,8 +3009,8 @@
forEffect: forEffect);
} else {
return helper.buildProblem(
- templateUndefinedSetter.withArguments(
- propertyName.name, resolveTypeParameter(receiverType)),
+ templateUndefinedSetter.withArguments(propertyName.name,
+ resolveTypeParameter(receiverType), isNonNullableByDefault),
fileOffset,
propertyName.name.length);
}
@@ -2946,8 +3022,8 @@
return engine.forest.createIndexGet(fileOffset, receiver, index);
} else {
return helper.buildProblem(
- templateUndefinedMethod.withArguments(
- indexGetName.name, resolveTypeParameter(receiverType)),
+ templateUndefinedMethod.withArguments(indexGetName.name,
+ resolveTypeParameter(receiverType), isNonNullableByDefault),
fileOffset,
noLength);
}
@@ -2963,8 +3039,8 @@
forEffect: forEffect, readOnlyReceiver: readOnlyReceiver);
} else {
return helper.buildProblem(
- templateUndefinedMethod.withArguments(
- indexSetName.name, resolveTypeParameter(receiverType)),
+ templateUndefinedMethod.withArguments(indexSetName.name,
+ resolveTypeParameter(receiverType), isNonNullableByDefault),
fileOffset,
noLength);
}
@@ -2978,8 +3054,8 @@
engine.forest.createArguments(fileOffset, <Expression>[right]));
} else {
return helper.buildProblem(
- templateUndefinedMethod.withArguments(
- binaryName.name, resolveTypeParameter(leftType)),
+ templateUndefinedMethod.withArguments(binaryName.name,
+ resolveTypeParameter(leftType), isNonNullableByDefault),
fileOffset,
binaryName.name.length);
}
@@ -2992,8 +3068,8 @@
..fileOffset = fileOffset;
} else {
return helper.buildProblem(
- templateUndefinedMethod.withArguments(
- unaryName.name, resolveTypeParameter(expressionType)),
+ templateUndefinedMethod.withArguments(unaryName.name,
+ resolveTypeParameter(expressionType), isNonNullableByDefault),
fileOffset,
unaryName.name == unaryMinusName.name ? 1 : unaryName.name.length);
}
@@ -3078,8 +3154,11 @@
asInstantiationOf(baseType, mixinSupertype.classNode);
if (supertype == null) {
reportProblem(
- templateMixinInferenceNoMatchingClass.withArguments(mixinClass.name,
- baseType.classNode.name, mixinSupertype.asInterfaceType),
+ templateMixinInferenceNoMatchingClass.withArguments(
+ mixinClass.name,
+ baseType.classNode.name,
+ mixinSupertype.asInterfaceType,
+ mixinClass.enclosingLibrary.isNonNullableByDefault),
mixinClass);
return;
}
@@ -3108,7 +3187,8 @@
generateConstraints(mixinClass, baseType, mixinSupertype);
// Solve them to get a map from type parameters to upper and lower
// bounds.
- Map<TypeParameter, TypeConstraint> result = gatherer.computeConstraints();
+ Map<TypeParameter, TypeConstraint> result =
+ gatherer.computeConstraints(classNode.enclosingLibrary);
// Generate new type parameters with the solution as bounds.
List<TypeParameter> parameters = mixinClass.typeParameters.map((p) {
TypeConstraint constraint = result[p];
@@ -3116,8 +3196,11 @@
// either unconstrained or else with identical upper and lower bounds.
if (constraint != null && constraint.upper != constraint.lower) {
reportProblem(
- templateMixinInferenceNoMatchingClass.withArguments(mixinClass.name,
- baseType.classNode.name, mixinSupertype.asInterfaceType),
+ templateMixinInferenceNoMatchingClass.withArguments(
+ mixinClass.name,
+ baseType.classNode.name,
+ mixinSupertype.asInterfaceType,
+ mixinClass.enclosingLibrary.isNonNullableByDefault),
mixinClass);
return p;
}
@@ -3205,10 +3288,10 @@
factory ExpressionInferenceResult.nullAware(
DartType inferredType, Expression expression,
- [NullAwareGuard nullAwareGuard]) {
- if (nullAwareGuard != null) {
+ [Link<NullAwareGuard> nullAwareGuards = const Link<NullAwareGuard>()]) {
+ if (nullAwareGuards != null && nullAwareGuards.isNotEmpty) {
return new NullAwareExpressionInferenceResult(
- inferredType, nullAwareGuard, expression);
+ inferredType, nullAwareGuards, expression);
} else {
return new ExpressionInferenceResult(inferredType, expression);
}
@@ -3217,13 +3300,13 @@
ExpressionInferenceResult(this.inferredType, this.expression)
: assert(expression != null);
- /// The guard used for null-aware access if the expression is part of a
- /// null-shorting, and `null` otherwise.
- NullAwareGuard get nullAwareGuard => null;
+ /// The guards used for null-aware access if the expression is part of a
+ /// null-shorting.
+ Link<NullAwareGuard> get nullAwareGuards => const Link<NullAwareGuard>();
- /// If the expression is part of a null-shorting, the action performed on
- /// the variable in [nullAwareGuard]. Otherwise, this is the same as
- /// [expression].
+ /// If the expression is part of a null-shorting, this is the action performed
+ /// on the guarded variable, found as the first guard in [nullAwareGuards].
+ /// Otherwise, this is the same as [expression].
Expression get nullAwareAction => expression;
String toString() => 'ExpressionInferenceResult($inferredType,$expression)';
@@ -3240,11 +3323,25 @@
/// The [Member] used for the == call.
final Member _nullAwareEquals;
- NullAwareGuard(
- this._nullAwareVariable, this._nullAwareFileOffset, this._nullAwareEquals)
+ final TypeInferrerImpl _inferrer;
+
+ NullAwareGuard(this._nullAwareVariable, this._nullAwareFileOffset,
+ this._nullAwareEquals, this._inferrer)
: assert(_nullAwareVariable != null),
assert(_nullAwareFileOffset != null),
- assert(_nullAwareEquals != null);
+ assert(_nullAwareEquals != null),
+ assert(_inferrer != null) {
+ // Ensure the initializer of [_nullAwareVariable] is promoted to
+ // non-nullable.
+ _inferrer.flowAnalysis
+ .nullAwareAccess_rightBegin(_nullAwareVariable.initializer);
+ // Ensure [_nullAwareVariable] is promoted to non-nullable.
+ // TODO(johnniwinther): Avoid creating a [VariableGet] to promote the
+ // variable.
+ VariableGet read = new VariableGet(_nullAwareVariable);
+ _inferrer.flowAnalysis.variableRead(read, _nullAwareVariable);
+ _inferrer.flowAnalysis.nullAwareAccess_rightBegin(read);
+ }
/// Creates the null-guarded application of [nullAwareAction] with the
/// [inferredType].
@@ -3256,6 +3353,10 @@
///
Expression createExpression(
DartType inferredType, Expression nullAwareAction) {
+ // End non-nullable promotion of [_nullAwareVariable].
+ _inferrer.flowAnalysis.nullAwareAccess_end();
+ // End non-nullable promotion of the initializer of [_nullAwareVariable].
+ _inferrer.flowAnalysis.nullAwareAccess_end();
MethodInvocation equalsNull = createEqualsNull(_nullAwareFileOffset,
createVariableGet(_nullAwareVariable), _nullAwareEquals);
ConditionalExpression condition = new ConditionalExpression(
@@ -3279,7 +3380,7 @@
final DartType inferredType;
@override
- final NullAwareGuard nullAwareGuard;
+ final Link<NullAwareGuard> nullAwareGuards;
@override
final Expression nullAwareAction;
@@ -3287,20 +3388,25 @@
Expression _expression;
NullAwareExpressionInferenceResult(
- this.inferredType, this.nullAwareGuard, this.nullAwareAction)
- : assert(nullAwareGuard != null),
+ this.inferredType, this.nullAwareGuards, this.nullAwareAction)
+ : assert(nullAwareGuards.isNotEmpty),
assert(nullAwareAction != null);
Expression get expression {
if (_expression == null) {
- _expression ??=
- nullAwareGuard.createExpression(inferredType, nullAwareAction);
+ _expression = nullAwareAction;
+ Link<NullAwareGuard> nullAwareGuard = nullAwareGuards;
+ while (nullAwareGuard.isNotEmpty) {
+ _expression =
+ nullAwareGuard.head.createExpression(inferredType, _expression);
+ nullAwareGuard = nullAwareGuard.tail;
+ }
}
return _expression;
}
String toString() =>
- 'NullAwareExpressionInferenceResult($inferredType,$nullAwareGuard,'
+ 'NullAwareExpressionInferenceResult($inferredType,$nullAwareGuards,'
'$nullAwareAction)';
}
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_schema.dart b/pkg/front_end/lib/src/fasta/type_inference/type_schema.dart
index 3ded48c..1ab9afb 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_schema.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_schema.dart
@@ -34,13 +34,11 @@
class TypeSchemaPrinter extends Printer {
TypeSchemaPrinter(StringSink sink,
{NameSystem syntheticNames,
- bool showExternal,
bool showOffsets: false,
ImportTable importTable,
Annotator annotator})
: super(sink,
syntheticNames: syntheticNames,
- showExternal: showExternal,
showOffsets: showOffsets,
importTable: importTable,
annotator: annotator);
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart b/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
index 16f0ff7..6a42d91 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
@@ -110,18 +110,23 @@
Class get objectClass => coreTypes.objectClass;
InterfaceType getLegacyLeastUpperBound(
- InterfaceType type1, InterfaceType type2) {
- return hierarchy.getLegacyLeastUpperBound(type1, type2, this.coreTypes);
+ InterfaceType type1, InterfaceType type2, Library clientLibrary) {
+ return hierarchy.getLegacyLeastUpperBound(
+ type1, type2, clientLibrary, this.coreTypes);
}
/// Modify the given [constraint]'s lower bound to include [lower].
- void addLowerBound(TypeConstraint constraint, DartType lower) {
- constraint.lower = getStandardUpperBound(constraint.lower, lower);
+ void addLowerBound(
+ TypeConstraint constraint, DartType lower, Library clientLibrary) {
+ constraint.lower =
+ getStandardUpperBound(constraint.lower, lower, clientLibrary);
}
/// Modify the given [constraint]'s upper bound to include [upper].
- void addUpperBound(TypeConstraint constraint, DartType upper) {
- constraint.upper = getStandardLowerBound(constraint.upper, upper);
+ void addUpperBound(
+ TypeConstraint constraint, DartType upper, Library clientLibrary) {
+ constraint.upper =
+ getStandardLowerBound(constraint.upper, upper, clientLibrary);
}
@override
@@ -170,7 +175,7 @@
List<DartType> actualTypes,
DartType returnContextType,
List<DartType> inferredTypes,
- Library currentLibrary,
+ Library clientLibrary,
{bool isConst: false}) {
if (typeParametersToInfer.isEmpty) {
return;
@@ -181,7 +186,7 @@
// be subtypes (or supertypes) as necessary, and track the constraints that
// are implied by this.
TypeConstraintGatherer gatherer =
- new TypeConstraintGatherer(this, typeParametersToInfer, currentLibrary);
+ new TypeConstraintGatherer(this, typeParametersToInfer, clientLibrary);
if (!isEmptyContext(returnContextType)) {
if (isConst) {
@@ -199,8 +204,8 @@
}
}
- inferTypeFromConstraints(
- gatherer.computeConstraints(), typeParametersToInfer, inferredTypes,
+ inferTypeFromConstraints(gatherer.computeConstraints(clientLibrary),
+ typeParametersToInfer, inferredTypes, clientLibrary,
downwardsInferPhase: formalTypes == null);
for (int i = 0; i < inferredTypes.length; i++) {
@@ -238,8 +243,11 @@
/// inference, and must not conclude `?` for any type formal. In this pass,
/// [inferredTypes] should contain the values from the first pass. They will
/// be replaced with the final inferred types.
- void inferTypeFromConstraints(Map<TypeParameter, TypeConstraint> constraints,
- List<TypeParameter> typeParametersToInfer, List<DartType> inferredTypes,
+ void inferTypeFromConstraints(
+ Map<TypeParameter, TypeConstraint> constraints,
+ List<TypeParameter> typeParametersToInfer,
+ List<DartType> inferredTypes,
+ Library clientLibrary,
{bool downwardsInferPhase: false}) {
List<DartType> typesFromDownwardsInference =
downwardsInferPhase ? null : inferredTypes.toList(growable: false);
@@ -258,11 +266,14 @@
TypeConstraint constraint = constraints[typeParam];
if (downwardsInferPhase || !typeParam.isLegacyCovariant) {
inferredTypes[i] = _inferTypeParameterFromContext(
- constraint, extendsConstraint,
+ constraint, extendsConstraint, clientLibrary,
isContravariant: typeParam.variance == Variance.contravariant);
} else {
inferredTypes[i] = _inferTypeParameterFromAll(
- typesFromDownwardsInference[i], constraint, extendsConstraint);
+ typesFromDownwardsInference[i],
+ constraint,
+ extendsConstraint,
+ clientLibrary);
}
}
@@ -409,8 +420,11 @@
type, constraint.upper, SubtypeCheckMode.ignoringNullabilities);
}
- DartType _inferTypeParameterFromAll(DartType typeFromContextInference,
- TypeConstraint constraint, DartType extendsConstraint) {
+ DartType _inferTypeParameterFromAll(
+ DartType typeFromContextInference,
+ TypeConstraint constraint,
+ DartType extendsConstraint,
+ Library clientLibrary) {
// See if we already fixed this type from downwards inference.
// If so, then we aren't allowed to change it based on argument types.
if (isKnown(typeFromContextInference)) {
@@ -419,14 +433,14 @@
if (extendsConstraint != null) {
constraint = constraint.clone();
- addUpperBound(constraint, extendsConstraint);
+ addUpperBound(constraint, extendsConstraint, clientLibrary);
}
return solveTypeConstraint(constraint, grounded: true);
}
- DartType _inferTypeParameterFromContext(
- TypeConstraint constraint, DartType extendsConstraint,
+ DartType _inferTypeParameterFromContext(TypeConstraint constraint,
+ DartType extendsConstraint, Library clientLibrary,
{bool isContravariant: false}) {
DartType t =
solveTypeConstraint(constraint, isContravariant: isContravariant);
@@ -443,7 +457,7 @@
// If we consider the `T extends num` we conclude `<num>`, which works.
if (extendsConstraint != null) {
constraint = constraint.clone();
- addUpperBound(constraint, extendsConstraint);
+ addUpperBound(constraint, extendsConstraint, clientLibrary);
return solveTypeConstraint(constraint);
}
return t;
diff --git a/pkg/front_end/lib/src/kernel_generator_impl.dart b/pkg/front_end/lib/src/kernel_generator_impl.dart
index 4f0fbf1..a430146 100644
--- a/pkg/front_end/lib/src/kernel_generator_impl.dart
+++ b/pkg/front_end/lib/src/kernel_generator_impl.dart
@@ -73,14 +73,6 @@
DillTarget dillTarget =
new DillTarget(options.ticker, uriTranslator, options.target);
- Set<Uri> externalLibs(Component component) {
- return component.libraries
- // ignore: DEPRECATED_MEMBER_USE
- .where((lib) => lib.isExternal)
- .map((lib) => lib.importUri)
- .toSet();
- }
-
List<Component> loadedComponents = new List<Component>();
Component sdkSummary = await options.loadSdkSummary(null);
@@ -88,9 +80,7 @@
// sdkSummary between multiple invocations.
CanonicalName nameRoot = sdkSummary?.root ?? new CanonicalName.root();
if (sdkSummary != null) {
- Set<Uri> excluded = externalLibs(sdkSummary);
- dillTarget.loader.appendLibraries(sdkSummary,
- filter: (uri) => !excluded.contains(uri));
+ dillTarget.loader.appendLibraries(sdkSummary);
}
// TODO(sigmund): provide better error reporting if input summaries or
@@ -98,25 +88,14 @@
// sort them).
for (Component inputSummary in await options.loadInputSummaries(nameRoot)) {
loadedComponents.add(inputSummary);
- Set<Uri> excluded = externalLibs(inputSummary);
- dillTarget.loader.appendLibraries(inputSummary,
- filter: (uri) => !excluded.contains(uri));
+ dillTarget.loader.appendLibraries(inputSummary);
}
- // All summaries are considered external and shouldn't include source-info.
- dillTarget.loader.libraries.forEach((lib) {
- // TODO(ahe): Don't do this, and remove [external_state_snapshot.dart].
- // ignore: DEPRECATED_MEMBER_USE
- lib.isExternal = true;
- });
-
// Linked dependencies are meant to be part of the component so they are not
// marked external.
for (Component dependency in await options.loadLinkDependencies(nameRoot)) {
loadedComponents.add(dependency);
- Set<Uri> excluded = externalLibs(dependency);
- dillTarget.loader.appendLibraries(dependency,
- filter: (uri) => !excluded.contains(uri));
+ dillTarget.loader.appendLibraries(dependency);
}
await dillTarget.buildOutlines();
diff --git a/pkg/front_end/messages.status b/pkg/front_end/messages.status
index e420f29..17cf06b 100644
--- a/pkg/front_end/messages.status
+++ b/pkg/front_end/messages.status
@@ -13,6 +13,7 @@
AccessError/example: Fail
AmbiguousSupertypes/example: Fail
AnnotationOnEnumConstant/example: Fail
+AnnotationOnFunctionTypeTypeVariable/analyzerCode: Fail
AnonymousBreakTargetOutsideFunction/part_wrapped_statement: Fail
AnonymousBreakTargetOutsideFunction/statement: Fail # Duplicated error as parser also complains.
AnonymousContinueTargetOutsideFunction/part_wrapped_statement: Fail
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index e8794be..6c65925 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -780,6 +780,7 @@
template: "Can't have modifier '#lexeme' in an extension."
tip: "Try removing '#lexeme'."
analyzerCode: ParserErrorCode.INVALID_USE_OF_COVARIANT_IN_EXTENSION
+ hasPublishedDocs: true
script:
- "extension on String { foo(covariant String child) {} }"
@@ -2061,6 +2062,11 @@
template: "A type variable can't have the same name as its enclosing declaration."
analyzerCode: CONFLICTING_TYPE_VARIABLE_AND_CLASS
+AnnotationOnFunctionTypeTypeVariable:
+ template: "A type variable on a function type can't have annotations."
+ script:
+ - "main() { Function<@Object() T>() x; }"
+
ExpectedEnumBody:
template: "Expected a enum body, but got '#lexeme'."
tip: "An enum definition must have a body with at least one constant name."
diff --git a/pkg/front_end/test/fasta/expression_suite.dart b/pkg/front_end/test/fasta/expression_suite.dart
index 87a0834..43c3679 100644
--- a/pkg/front_end/test/fasta/expression_suite.dart
+++ b/pkg/front_end/test/fasta/expression_suite.dart
@@ -27,9 +27,6 @@
import 'package:front_end/src/compute_platform_binaries_location.dart'
show computePlatformBinariesLocation;
-import 'package:front_end/src/external_state_snapshot.dart'
- show ExternalStateSnapshot;
-
import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext;
import 'package:front_end/src/fasta/incremental_compiler.dart'
@@ -60,13 +57,11 @@
class Context extends ChainContext {
final CompilerContext compilerContext;
- final ExternalStateSnapshot snapshot;
final List<DiagnosticMessage> errors;
final List<Step> steps;
- Context(
- this.compilerContext, this.snapshot, this.errors, bool updateExpectations)
+ Context(this.compilerContext, this.errors, bool updateExpectations)
: steps = <Step>[
const ReadTest(),
const CompileExpression(),
@@ -84,7 +79,6 @@
void reset() {
errors.clear();
- snapshot.restore();
}
List<DiagnosticMessage> takeErrors() {
@@ -420,9 +414,6 @@
final ProcessedOptions options =
new ProcessedOptions(options: optionBuilder, inputs: [entryPoint]);
- final ExternalStateSnapshot snapshot =
- new ExternalStateSnapshot(await options.loadSdkSummary(null));
-
final bool updateExpectations = environment["updateExpectations"] == "true";
final CompilerContext compilerContext = new CompilerContext(options);
@@ -431,7 +422,7 @@
// platforms and independent of stdin/stderr.
colors.enableColors = false;
- return new Context(compilerContext, snapshot, errors, updateExpectations);
+ return new Context(compilerContext, errors, updateExpectations);
}
main([List<String> arguments = const []]) =>
diff --git a/pkg/front_end/test/fasta/incremental_suite.dart b/pkg/front_end/test/fasta/incremental_suite.dart
index a1403c3..e43a838 100644
--- a/pkg/front_end/test/fasta/incremental_suite.dart
+++ b/pkg/front_end/test/fasta/incremental_suite.dart
@@ -36,9 +36,6 @@
import 'package:front_end/src/compute_platform_binaries_location.dart'
show computePlatformBinariesLocation;
-import 'package:front_end/src/external_state_snapshot.dart'
- show ExternalStateSnapshot;
-
import 'package:front_end/src/base/processed_options.dart'
show ProcessedOptions;
@@ -60,7 +57,6 @@
class Context extends ChainContext {
final CompilerContext compilerContext;
- final ExternalStateSnapshot snapshot;
final List<DiagnosticMessage> errors;
final List<Step> steps = const <Step>[
@@ -70,7 +66,7 @@
final IncrementalKernelGenerator compiler;
- Context(this.compilerContext, this.snapshot, this.errors)
+ Context(this.compilerContext, this.errors)
: compiler = new IncrementalCompiler(compilerContext);
ProcessedOptions get options => compilerContext.options;
@@ -83,7 +79,6 @@
void reset() {
errors.clear();
- snapshot.restore();
}
List<DiagnosticMessage> takeErrors() {
@@ -238,10 +233,7 @@
final ProcessedOptions options =
new ProcessedOptions(options: optionBuilder, inputs: [entryPoint]);
- final ExternalStateSnapshot snapshot =
- new ExternalStateSnapshot(await options.loadSdkSummary(null));
-
- return new Context(new CompilerContext(options), snapshot, errors);
+ return new Context(new CompilerContext(options), errors);
}
main([List<String> arguments = const []]) =>
diff --git a/pkg/front_end/test/fasta/testing/suite.dart b/pkg/front_end/test/fasta/testing/suite.dart
index 2972102..263aefb 100644
--- a/pkg/front_end/test/fasta/testing/suite.dart
+++ b/pkg/front_end/test/fasta/testing/suite.dart
@@ -201,10 +201,12 @@
if (!ignoreExpectations) {
steps.add(new MatchExpectation(
fullCompile ? ".strong.expect" : ".outline.expect",
- serializeFirst: true));
- steps.add(new MatchExpectation(
- fullCompile ? ".strong.expect" : ".outline.expect",
serializeFirst: false));
+ if (!updateExpectations) {
+ steps.add(new MatchExpectation(
+ fullCompile ? ".strong.expect" : ".outline.expect",
+ serializeFirst: true));
+ }
}
steps.add(const TypeCheck());
steps.add(const EnsureNoErrors());
@@ -218,12 +220,14 @@
fullCompile
? ".strong.transformed.expect"
: ".outline.transformed.expect",
- serializeFirst: true));
- steps.add(new MatchExpectation(
- fullCompile
- ? ".strong.transformed.expect"
- : ".outline.transformed.expect",
serializeFirst: false));
+ if (!updateExpectations) {
+ steps.add(new MatchExpectation(
+ fullCompile
+ ? ".strong.transformed.expect"
+ : ".outline.transformed.expect",
+ serializeFirst: true));
+ }
}
steps.add(const EnsureNoErrors());
if (!skipVm) {
diff --git a/pkg/front_end/test/fasta/text_serialization1_suite.dart b/pkg/front_end/test/fasta/text_serialization1_suite.dart
new file mode 100644
index 0000000..1a9ba5e
--- /dev/null
+++ b/pkg/front_end/test/fasta/text_serialization1_suite.dart
@@ -0,0 +1,9 @@
+// Copyright (c) 2019, 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.md file.
+
+import 'text_serialization_tester.dart';
+
+main(List<String> arguments) {
+ internalMain(arguments: arguments, shards: shardCount, shard: 0);
+}
diff --git a/pkg/front_end/test/fasta/text_serialization2_suite.dart b/pkg/front_end/test/fasta/text_serialization2_suite.dart
new file mode 100644
index 0000000..b922a21
--- /dev/null
+++ b/pkg/front_end/test/fasta/text_serialization2_suite.dart
@@ -0,0 +1,9 @@
+// Copyright (c) 2019, 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.md file.
+
+import 'text_serialization_tester.dart';
+
+main(List<String> arguments) {
+ internalMain(arguments: arguments, shards: shardCount, shard: 1);
+}
diff --git a/pkg/front_end/test/fasta/text_serialization3_suite.dart b/pkg/front_end/test/fasta/text_serialization3_suite.dart
new file mode 100644
index 0000000..f14949c5
--- /dev/null
+++ b/pkg/front_end/test/fasta/text_serialization3_suite.dart
@@ -0,0 +1,9 @@
+// Copyright (c) 2019, 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.md file.
+
+import 'text_serialization_tester.dart';
+
+main(List<String> arguments) {
+ internalMain(arguments: arguments, shards: shardCount, shard: 2);
+}
diff --git a/pkg/front_end/test/fasta/text_serialization4_suite.dart b/pkg/front_end/test/fasta/text_serialization4_suite.dart
new file mode 100644
index 0000000..9807292
--- /dev/null
+++ b/pkg/front_end/test/fasta/text_serialization4_suite.dart
@@ -0,0 +1,9 @@
+// Copyright (c) 2019, 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.md file.
+
+import 'text_serialization_tester.dart';
+
+main(List<String> arguments) {
+ internalMain(arguments: arguments, shards: shardCount, shard: 3);
+}
diff --git a/pkg/front_end/test/fasta/text_serialization_suite.dart b/pkg/front_end/test/fasta/text_serialization_suite.dart
deleted file mode 100644
index fa51b54..0000000
--- a/pkg/front_end/test/fasta/text_serialization_suite.dart
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2019, 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.md file.
-
-library fasta.test.text_serialization_test;
-
-import 'dart:async' show Future;
-
-import 'testing/suite.dart';
-
-Future<FastaContext> createContext(
- Chain suite, Map<String, String> environment) {
- environment[ENABLE_FULL_COMPILE] = "";
- environment[KERNEL_TEXT_SERIALIZATION] = "";
- return FastaContext.create(suite, environment);
-}
-
-main([List<String> arguments = const []]) =>
- runMe(arguments, createContext, configurationPath: "../../testing.json");
diff --git a/pkg/front_end/test/fasta/text_serialization_tester.dart b/pkg/front_end/test/fasta/text_serialization_tester.dart
new file mode 100644
index 0000000..3a0deda
--- /dev/null
+++ b/pkg/front_end/test/fasta/text_serialization_tester.dart
@@ -0,0 +1,32 @@
+// Copyright (c) 2017, 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.md file.
+
+library fasta.test.text_serialization_test;
+
+import 'dart:async' show Future;
+import 'dart:io' show Platform;
+
+import 'testing/suite.dart';
+
+const int shardCount = 4;
+
+Future<FastaContext> createContext(
+ Chain suite, Map<String, String> environment) {
+ environment[ENABLE_FULL_COMPILE] = "";
+ environment[KERNEL_TEXT_SERIALIZATION] = "";
+ return FastaContext.create(suite, environment);
+}
+
+main(List<String> arguments) {
+ internalMain(arguments: arguments);
+}
+
+internalMain(
+ {List<String> arguments = const [], int shards = 1, int shard = 0}) {
+ runMe(arguments, createContext,
+ configurationPath: "../../testing.json",
+ me: Platform.script.resolve('text_serialization_tester.dart'),
+ shards: shards,
+ shard: shard);
+}
diff --git a/pkg/front_end/test/fasta/tool_test.dart b/pkg/front_end/test/fasta/tool_test.dart
index d94ba75..280549e 100644
--- a/pkg/front_end/test/fasta/tool_test.dart
+++ b/pkg/front_end/test/fasta/tool_test.dart
@@ -22,7 +22,6 @@
"outline",
"parser",
"scanner",
- "dump-partial",
"dump-ir",
"testing",
"generate-messages",
@@ -115,12 +114,6 @@
"exitCode": 0,
"stderr": "",
},
- "dump-partial": {
- "exitCode": 1,
- "stdout": "usage: pkg/front_end/tool/fasta dump_partial"
- " partial.dill [extra1.dill] ... [extraN.dill]\n",
- "stderr": "",
- },
"dump-ir": {
"exitCode": 2,
"stdout": "",
diff --git a/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart b/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart
index 4e948de..a661a3e 100644
--- a/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart
@@ -74,27 +74,27 @@
InterfaceType get Q => coreTypes.legacyRawType(classQ);
void test_any_subtype_parameter() {
- _checkConstraints(Q, T1, ['lib::Q* <: T1']);
+ _checkConstraints(Q, T1, testLib, ['lib::Q* <: T1']);
}
void test_any_subtype_top() {
- _checkConstraints(P, dynamicType, []);
- _checkConstraints(P, objectType, []);
- _checkConstraints(P, voidType, []);
+ _checkConstraints(P, dynamicType, testLib, []);
+ _checkConstraints(P, objectType, testLib, []);
+ _checkConstraints(P, voidType, testLib, []);
}
void test_any_subtype_unknown() {
- _checkConstraints(P, unknownType, []);
- _checkConstraints(T1, unknownType, []);
+ _checkConstraints(P, unknownType, testLib, []);
+ _checkConstraints(T1, unknownType, testLib, []);
}
void test_different_classes() {
- _checkConstraints(_list(T1), _iterable(Q), ['T1 <: lib::Q*']);
- _checkConstraints(_iterable(T1), _list(Q), null);
+ _checkConstraints(_list(T1), _iterable(Q), testLib, ['T1 <: lib::Q*']);
+ _checkConstraints(_iterable(T1), _list(Q), testLib, null);
}
void test_equal_types() {
- _checkConstraints(P, P, []);
+ _checkConstraints(P, P, testLib, []);
}
void test_function_generic() {
@@ -107,12 +107,14 @@
new FunctionType([], dynamicType, Nullability.legacy,
typeParameters: [T.parameter]),
new FunctionType([], dynamicType, Nullability.legacy),
+ testLib,
null);
// () -> dynamic <: <T>() -> dynamic, never
_checkConstraints(
new FunctionType([], dynamicType, Nullability.legacy),
new FunctionType([], dynamicType, Nullability.legacy,
typeParameters: [T.parameter]),
+ testLib,
null);
// <T>(T) -> T <: <U>(U) -> U, always
_checkConstraints(
@@ -120,39 +122,44 @@
typeParameters: [T.parameter]),
new FunctionType([U], U, Nullability.legacy,
typeParameters: [U.parameter]),
+ testLib,
[]);
}
void test_function_parameter_mismatch() {
// (P) -> dynamic <: () -> dynamic, never
_checkConstraints(new FunctionType([P], dynamicType, Nullability.legacy),
- new FunctionType([], dynamicType, Nullability.legacy), null);
+ new FunctionType([], dynamicType, Nullability.legacy), testLib, null);
// () -> dynamic <: (P) -> dynamic, never
_checkConstraints(new FunctionType([], dynamicType, Nullability.legacy),
- new FunctionType([P], dynamicType, Nullability.legacy), null);
+ new FunctionType([P], dynamicType, Nullability.legacy), testLib, null);
// ([P]) -> dynamic <: () -> dynamic, always
_checkConstraints(
new FunctionType([P], dynamicType, Nullability.legacy,
requiredParameterCount: 0),
new FunctionType([], dynamicType, Nullability.legacy),
+ testLib,
[]);
// () -> dynamic <: ([P]) -> dynamic, never
_checkConstraints(
new FunctionType([], dynamicType, Nullability.legacy),
new FunctionType([P], dynamicType, Nullability.legacy,
requiredParameterCount: 0),
+ testLib,
null);
// ({x: P}) -> dynamic <: () -> dynamic, always
_checkConstraints(
new FunctionType([], dynamicType, Nullability.legacy,
namedParameters: [new NamedType('x', P)]),
new FunctionType([], dynamicType, Nullability.legacy),
+ testLib,
[]);
// () -> dynamic !<: ({x: P}) -> dynamic, never
_checkConstraints(
new FunctionType([], dynamicType, Nullability.legacy),
new FunctionType([], dynamicType, Nullability.legacy,
namedParameters: [new NamedType('x', P)]),
+ testLib,
null);
}
@@ -161,6 +168,7 @@
_checkConstraints(
new FunctionType([T1], dynamicType, Nullability.legacy),
new FunctionType([Q], dynamicType, Nullability.legacy),
+ testLib,
['lib::Q* <: T1']);
// ({x: T1}) -> dynamic <: ({x: Q}) -> dynamic, under constraint Q <: T1
_checkConstraints(
@@ -168,58 +176,62 @@
namedParameters: [new NamedType('x', T1)]),
new FunctionType([], dynamicType, Nullability.legacy,
namedParameters: [new NamedType('x', Q)]),
+ testLib,
['lib::Q* <: T1']);
}
void test_function_return_type() {
// () -> T1 <: () -> Q, under constraint T1 <: Q
- _checkConstraints(new FunctionType([], T1, Nullability.legacy),
- new FunctionType([], Q, Nullability.legacy), ['T1 <: lib::Q*']);
+ _checkConstraints(
+ new FunctionType([], T1, Nullability.legacy),
+ new FunctionType([], Q, Nullability.legacy),
+ testLib,
+ ['T1 <: lib::Q*']);
// () -> P <: () -> void, always
_checkConstraints(new FunctionType([], P, Nullability.legacy),
- new FunctionType([], voidType, Nullability.legacy), []);
+ new FunctionType([], voidType, Nullability.legacy), testLib, []);
// () -> void <: () -> P, never
_checkConstraints(new FunctionType([], voidType, Nullability.legacy),
- new FunctionType([], P, Nullability.legacy), null);
+ new FunctionType([], P, Nullability.legacy), testLib, null);
}
void test_function_trivial_cases() {
var F = new FunctionType([], dynamicType, Nullability.legacy);
// () -> dynamic <: dynamic, always
- _checkConstraints(F, dynamicType, []);
+ _checkConstraints(F, dynamicType, testLib, []);
// () -> dynamic <: Function, always
- _checkConstraints(F, functionType, []);
+ _checkConstraints(F, functionType, testLib, []);
// () -> dynamic <: Object, always
- _checkConstraints(F, objectType, []);
+ _checkConstraints(F, objectType, testLib, []);
}
void test_nonInferredParameter_subtype_any() {
var U = new TypeParameterType(
new TypeParameter('U', _list(P)), Nullability.legacy);
- _checkConstraints(U, _list(T1), ['lib::P* <: T1']);
+ _checkConstraints(U, _list(T1), testLib, ['lib::P* <: T1']);
}
void test_null_subtype_any() {
- _checkConstraints(nullType, T1, ['dart.core::Null? <: T1']);
- _checkConstraints(nullType, Q, []);
+ _checkConstraints(nullType, T1, testLib, ['dart.core::Null? <: T1']);
+ _checkConstraints(nullType, Q, testLib, []);
}
void test_parameter_subtype_any() {
- _checkConstraints(T1, Q, ['T1 <: lib::Q*']);
+ _checkConstraints(T1, Q, testLib, ['T1 <: lib::Q*']);
}
void test_same_classes() {
- _checkConstraints(_list(T1), _list(Q), ['T1 <: lib::Q*']);
+ _checkConstraints(_list(T1), _list(Q), testLib, ['T1 <: lib::Q*']);
}
void test_typeParameters() {
_checkConstraints(
- _map(T1, T2), _map(P, Q), ['T1 <: lib::P*', 'T2 <: lib::Q*']);
+ _map(T1, T2), _map(P, Q), testLib, ['T1 <: lib::P*', 'T2 <: lib::Q*']);
}
void test_unknown_subtype_any() {
- _checkConstraints(unknownType, Q, []);
- _checkConstraints(unknownType, T1, []);
+ _checkConstraints(unknownType, Q, testLib, []);
+ _checkConstraints(unknownType, T1, testLib, []);
}
Class _addClass(Class c) {
@@ -227,14 +239,14 @@
return c;
}
- void _checkConstraints(
- DartType a, DartType b, List<String> expectedConstraints) {
+ void _checkConstraints(DartType a, DartType b, Library clientLibrary,
+ List<String> expectedConstraints) {
var typeSchemaEnvironment =
new TypeSchemaEnvironment(coreTypes, new ClassHierarchy(component));
var typeConstraintGatherer = new TypeConstraintGatherer(
typeSchemaEnvironment, [T1.parameter, T2.parameter], testLib);
var constraints = typeConstraintGatherer.trySubtypeMatch(a, b)
- ? typeConstraintGatherer.computeConstraints()
+ ? typeConstraintGatherer.computeConstraints(clientLibrary)
: null;
if (expectedConstraints == null) {
expect(constraints, isNull);
diff --git a/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart b/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart
index fb49702..22c5dc0 100644
--- a/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart
@@ -69,9 +69,9 @@
var env = _makeEnv();
var typeConstraint = new TypeConstraint();
expect(typeConstraint.lower, same(unknownType));
- env.addLowerBound(typeConstraint, B);
+ env.addLowerBound(typeConstraint, B, testLib);
expect(typeConstraint.lower, same(B));
- env.addLowerBound(typeConstraint, C);
+ env.addLowerBound(typeConstraint, C, testLib);
expect(typeConstraint.lower, same(A));
}
@@ -86,19 +86,19 @@
var env = _makeEnv();
var typeConstraint = new TypeConstraint();
expect(typeConstraint.upper, same(unknownType));
- env.addUpperBound(typeConstraint, A);
+ env.addUpperBound(typeConstraint, A, testLib);
expect(typeConstraint.upper, same(A));
- env.addUpperBound(typeConstraint, B);
+ env.addUpperBound(typeConstraint, B, testLib);
expect(typeConstraint.upper, same(B));
- env.addUpperBound(typeConstraint, C);
+ env.addUpperBound(typeConstraint, C, testLib);
expect(typeConstraint.upper, same(bottomType));
}
void test_glb_bottom() {
var A = coreTypes.rawType(_addClass(_class('A')), Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardLowerBound(bottomType, A), same(bottomType));
- expect(env.getStandardLowerBound(A, bottomType), same(bottomType));
+ expect(env.getStandardLowerBound(bottomType, A, testLib), same(bottomType));
+ expect(env.getStandardLowerBound(A, bottomType, testLib), same(bottomType));
}
void test_glb_function() {
@@ -110,31 +110,35 @@
// GLB(() -> A, () -> B) = () -> B
expect(
env.getStandardLowerBound(new FunctionType([], A, Nullability.legacy),
- new FunctionType([], B, Nullability.legacy)),
+ new FunctionType([], B, Nullability.legacy), testLib),
new FunctionType([], B, Nullability.legacy));
// GLB(() -> void, (A, B) -> void) = ([A, B]) -> void
expect(
env.getStandardLowerBound(
new FunctionType([], voidType, Nullability.legacy),
- new FunctionType([A, B], voidType, Nullability.legacy)),
+ new FunctionType([A, B], voidType, Nullability.legacy),
+ testLib),
new FunctionType([A, B], voidType, Nullability.legacy,
requiredParameterCount: 0));
expect(
env.getStandardLowerBound(
new FunctionType([A, B], voidType, Nullability.legacy),
- new FunctionType([], voidType, Nullability.legacy)),
+ new FunctionType([], voidType, Nullability.legacy),
+ testLib),
new FunctionType([A, B], voidType, Nullability.legacy,
requiredParameterCount: 0));
// GLB((A) -> void, (B) -> void) = (A) -> void
expect(
env.getStandardLowerBound(
new FunctionType([A], voidType, Nullability.legacy),
- new FunctionType([B], voidType, Nullability.legacy)),
+ new FunctionType([B], voidType, Nullability.legacy),
+ testLib),
new FunctionType([A], voidType, Nullability.legacy));
expect(
env.getStandardLowerBound(
new FunctionType([B], voidType, Nullability.legacy),
- new FunctionType([A], voidType, Nullability.legacy)),
+ new FunctionType([A], voidType, Nullability.legacy),
+ testLib),
new FunctionType([A], voidType, Nullability.legacy));
// GLB(({a: A}) -> void, ({b: B}) -> void) = ({a: A, b: B}) -> void
expect(
@@ -142,7 +146,8 @@
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A)]),
new FunctionType([], voidType, Nullability.legacy,
- namedParameters: [new NamedType('b', B)])),
+ namedParameters: [new NamedType('b', B)]),
+ testLib),
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A), new NamedType('b', B)]));
expect(
@@ -150,7 +155,8 @@
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('b', B)]),
new FunctionType([], voidType, Nullability.legacy,
- namedParameters: [new NamedType('a', A)])),
+ namedParameters: [new NamedType('a', A)]),
+ testLib),
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A), new NamedType('b', B)]));
// GLB(({a: A, c: A}) -> void, ({b: B, d: B}) -> void)
@@ -166,7 +172,8 @@
namedParameters: [
new NamedType('b', B),
new NamedType('d', B)
- ])),
+ ]),
+ testLib),
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [
new NamedType('a', A),
@@ -187,7 +194,8 @@
namedParameters: [
new NamedType('a', B),
new NamedType('b', A)
- ])),
+ ]),
+ testLib),
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A), new NamedType('b', A)]));
expect(
@@ -201,7 +209,8 @@
namedParameters: [
new NamedType('a', A),
new NamedType('b', B)
- ])),
+ ]),
+ testLib),
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A), new NamedType('b', A)]));
// GLB((B, {a: A}) -> void, (B) -> void) = (B, {a: A}) -> void
@@ -209,7 +218,8 @@
env.getStandardLowerBound(
new FunctionType([B], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A)]),
- new FunctionType([B], voidType, Nullability.legacy)),
+ new FunctionType([B], voidType, Nullability.legacy),
+ testLib),
new FunctionType([B], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A)]));
// GLB(({a: A}) -> void, (B) -> void) = bottom
@@ -217,7 +227,8 @@
env.getStandardLowerBound(
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A)]),
- new FunctionType([B], voidType, Nullability.legacy)),
+ new FunctionType([B], voidType, Nullability.legacy),
+ testLib),
same(bottomType));
// GLB(({a: A}) -> void, ([B]) -> void) = bottom
expect(
@@ -225,17 +236,18 @@
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A)]),
new FunctionType([B], voidType, Nullability.legacy,
- requiredParameterCount: 0)),
+ requiredParameterCount: 0),
+ testLib),
same(bottomType));
}
void test_glb_identical() {
var A = coreTypes.rawType(_addClass(_class('A')), Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardLowerBound(A, A), same(A));
+ expect(env.getStandardLowerBound(A, A, testLib), same(A));
expect(
env.getStandardLowerBound(
- new InterfaceType(A.classNode, Nullability.legacy), A),
+ new InterfaceType(A.classNode, Nullability.legacy), A, testLib),
A);
}
@@ -245,33 +257,33 @@
_addClass(_class('B', supertype: A.classNode.asThisSupertype)),
Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardLowerBound(A, B), same(B));
- expect(env.getStandardLowerBound(B, A), same(B));
+ expect(env.getStandardLowerBound(A, B, testLib), same(B));
+ expect(env.getStandardLowerBound(B, A, testLib), same(B));
}
void test_glb_top() {
var A = coreTypes.rawType(_addClass(_class('A')), Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardLowerBound(dynamicType, A), same(A));
- expect(env.getStandardLowerBound(A, dynamicType), same(A));
- expect(env.getStandardLowerBound(objectType, A), same(A));
- expect(env.getStandardLowerBound(A, objectType), same(A));
- expect(env.getStandardLowerBound(voidType, A), same(A));
- expect(env.getStandardLowerBound(A, voidType), same(A));
+ expect(env.getStandardLowerBound(dynamicType, A, testLib), same(A));
+ expect(env.getStandardLowerBound(A, dynamicType, testLib), same(A));
+ expect(env.getStandardLowerBound(objectType, A, testLib), same(A));
+ expect(env.getStandardLowerBound(A, objectType, testLib), same(A));
+ expect(env.getStandardLowerBound(voidType, A, testLib), same(A));
+ expect(env.getStandardLowerBound(A, voidType, testLib), same(A));
}
void test_glb_unknown() {
var A = coreTypes.rawType(_addClass(_class('A')), Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardLowerBound(A, unknownType), same(A));
- expect(env.getStandardLowerBound(unknownType, A), same(A));
+ expect(env.getStandardLowerBound(A, unknownType, testLib), same(A));
+ expect(env.getStandardLowerBound(unknownType, A, testLib), same(A));
}
void test_glb_unrelated() {
var A = coreTypes.rawType(_addClass(_class('A')), Nullability.legacy);
var B = coreTypes.rawType(_addClass(_class('B')), Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardLowerBound(A, B), same(bottomType));
+ expect(env.getStandardLowerBound(A, B, testLib), same(bottomType));
}
void test_inferGenericFunctionOrType() {
@@ -317,11 +329,11 @@
var constraints = {T: new TypeConstraint()};
// Downward inference should infer A<?>
var inferredTypes = <DartType>[unknownType];
- env.inferTypeFromConstraints(constraints, [T], inferredTypes,
+ env.inferTypeFromConstraints(constraints, [T], inferredTypes, testLib,
downwardsInferPhase: true);
expect(inferredTypes[0], unknownType);
// Upward inference should infer A<num>
- env.inferTypeFromConstraints(constraints, [T], inferredTypes);
+ env.inferTypeFromConstraints(constraints, [T], inferredTypes, testLib);
expect(inferredTypes[0], numType);
}
{
@@ -329,16 +341,16 @@
var constraints = {T: _makeConstraint(upper: objectType)};
// Downward inference should infer A<num>
var inferredTypes = <DartType>[unknownType];
- env.inferTypeFromConstraints(constraints, [T], inferredTypes,
+ env.inferTypeFromConstraints(constraints, [T], inferredTypes, testLib,
downwardsInferPhase: true);
expect(inferredTypes[0], numType);
// Upward inference should infer A<num>
- env.inferTypeFromConstraints(constraints, [T], inferredTypes);
+ env.inferTypeFromConstraints(constraints, [T], inferredTypes, testLib);
expect(inferredTypes[0], numType);
// Upward inference should still infer A<num> even if there are more
// constraints now, because num was finalized during downward inference.
constraints = {T: _makeConstraint(lower: intType, upper: intType)};
- env.inferTypeFromConstraints(constraints, [T], inferredTypes);
+ env.inferTypeFromConstraints(constraints, [T], inferredTypes, testLib);
expect(inferredTypes[0], numType);
}
}
@@ -350,11 +362,11 @@
var constraints = {T: _makeConstraint(upper: _list(unknownType))};
// Downwards inference should infer List<List<?>>
var inferredTypes = <DartType>[unknownType];
- env.inferTypeFromConstraints(constraints, [T], inferredTypes,
+ env.inferTypeFromConstraints(constraints, [T], inferredTypes, testLib,
downwardsInferPhase: true);
expect(inferredTypes[0], _list(unknownType));
// Upwards inference should refine that to List<List<dynamic>>
- env.inferTypeFromConstraints(constraints, [T], inferredTypes);
+ env.inferTypeFromConstraints(constraints, [T], inferredTypes, testLib);
expect(inferredTypes[0], _list(dynamicType));
}
@@ -388,12 +400,13 @@
])),
Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardUpperBound(D, E), A);
+ expect(env.getStandardUpperBound(D, E, testLib), A);
}
void test_lub_commonClass() {
var env = _makeEnv();
- expect(env.getStandardUpperBound(_list(intType), _list(doubleType)),
+ expect(
+ env.getStandardUpperBound(_list(intType), _list(doubleType), testLib),
_list(numType));
}
@@ -406,36 +419,41 @@
// LUB(() -> A, () -> B) = () -> A
expect(
env.getStandardUpperBound(new FunctionType([], A, Nullability.legacy),
- new FunctionType([], B, Nullability.legacy)),
+ new FunctionType([], B, Nullability.legacy), testLib),
new FunctionType([], A, Nullability.legacy));
// LUB(([A]) -> void, (A) -> void) = Function
expect(
env.getStandardUpperBound(
new FunctionType([A], voidType, Nullability.legacy,
requiredParameterCount: 0),
- new FunctionType([A], voidType, Nullability.legacy)),
+ new FunctionType([A], voidType, Nullability.legacy),
+ testLib),
functionType);
// LUB(() -> void, (A, B) -> void) = Function
expect(
env.getStandardUpperBound(
new FunctionType([], voidType, Nullability.legacy),
- new FunctionType([A, B], voidType, Nullability.legacy)),
+ new FunctionType([A, B], voidType, Nullability.legacy),
+ testLib),
functionType);
expect(
env.getStandardUpperBound(
new FunctionType([A, B], voidType, Nullability.legacy),
- new FunctionType([], voidType, Nullability.legacy)),
+ new FunctionType([], voidType, Nullability.legacy),
+ testLib),
functionType);
// LUB((A) -> void, (B) -> void) = (B) -> void
expect(
env.getStandardUpperBound(
new FunctionType([A], voidType, Nullability.legacy),
- new FunctionType([B], voidType, Nullability.legacy)),
+ new FunctionType([B], voidType, Nullability.legacy),
+ testLib),
new FunctionType([B], voidType, Nullability.legacy));
expect(
env.getStandardUpperBound(
new FunctionType([B], voidType, Nullability.legacy),
- new FunctionType([A], voidType, Nullability.legacy)),
+ new FunctionType([A], voidType, Nullability.legacy),
+ testLib),
new FunctionType([B], voidType, Nullability.legacy));
// LUB(({a: A}) -> void, ({b: B}) -> void) = () -> void
expect(
@@ -443,14 +461,16 @@
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A)]),
new FunctionType([], voidType, Nullability.legacy,
- namedParameters: [new NamedType('b', B)])),
+ namedParameters: [new NamedType('b', B)]),
+ testLib),
new FunctionType([], voidType, Nullability.legacy));
expect(
env.getStandardUpperBound(
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('b', B)]),
new FunctionType([], voidType, Nullability.legacy,
- namedParameters: [new NamedType('a', A)])),
+ namedParameters: [new NamedType('a', A)]),
+ testLib),
new FunctionType([], voidType, Nullability.legacy));
// LUB(({a: A, c: A}) -> void, ({b: B, d: B}) -> void) = () -> void
expect(
@@ -464,7 +484,8 @@
namedParameters: [
new NamedType('b', B),
new NamedType('d', B)
- ])),
+ ]),
+ testLib),
new FunctionType([], voidType, Nullability.legacy));
// LUB(({a: A, b: B}) -> void, ({a: B, b: A}) -> void)
// = ({a: B, b: B}) -> void
@@ -479,7 +500,8 @@
namedParameters: [
new NamedType('a', B),
new NamedType('b', A)
- ])),
+ ]),
+ testLib),
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', B), new NamedType('b', B)]));
expect(
@@ -493,7 +515,8 @@
namedParameters: [
new NamedType('a', A),
new NamedType('b', B)
- ])),
+ ]),
+ testLib),
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', B), new NamedType('b', B)]));
// LUB((B, {a: A}) -> void, (B) -> void) = (B) -> void
@@ -501,14 +524,16 @@
env.getStandardUpperBound(
new FunctionType([B], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A)]),
- new FunctionType([B], voidType, Nullability.legacy)),
+ new FunctionType([B], voidType, Nullability.legacy),
+ testLib),
new FunctionType([B], voidType, Nullability.legacy));
// LUB(({a: A}) -> void, (B) -> void) = Function
expect(
env.getStandardUpperBound(
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A)]),
- new FunctionType([B], voidType, Nullability.legacy)),
+ new FunctionType([B], voidType, Nullability.legacy),
+ testLib),
functionType);
// GLB(({a: A}) -> void, ([B]) -> void) = () -> void
expect(
@@ -516,17 +541,18 @@
new FunctionType([], voidType, Nullability.legacy,
namedParameters: [new NamedType('a', A)]),
new FunctionType([B], voidType, Nullability.legacy,
- requiredParameterCount: 0)),
+ requiredParameterCount: 0),
+ testLib),
new FunctionType([], voidType, Nullability.legacy));
}
void test_lub_identical() {
var A = coreTypes.rawType(_addClass(_class('A')), Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardUpperBound(A, A), same(A));
+ expect(env.getStandardUpperBound(A, A, testLib), same(A));
expect(
env.getStandardUpperBound(
- new InterfaceType(A.classNode, Nullability.legacy), A),
+ new InterfaceType(A.classNode, Nullability.legacy), A, testLib),
A);
}
@@ -536,34 +562,43 @@
_addClass(_class('B', supertype: A.classNode.asThisSupertype)),
Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardUpperBound(_map(A, B), _map(B, A)), _map(A, A));
+ expect(
+ env.getStandardUpperBound(_map(A, B), _map(B, A), testLib), _map(A, A));
}
void test_lub_subtype() {
var env = _makeEnv();
- expect(env.getStandardUpperBound(_list(intType), _iterable(numType)),
+ expect(
+ env.getStandardUpperBound(_list(intType), _iterable(numType), testLib),
_iterable(numType));
- expect(env.getStandardUpperBound(_iterable(numType), _list(intType)),
+ expect(
+ env.getStandardUpperBound(_iterable(numType), _list(intType), testLib),
_iterable(numType));
}
void test_lub_top() {
var A = coreTypes.rawType(_addClass(_class('A')), Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardUpperBound(dynamicType, A), same(dynamicType));
- expect(env.getStandardUpperBound(A, dynamicType), same(dynamicType));
- expect(env.getStandardUpperBound(objectType, A), same(objectType));
- expect(env.getStandardUpperBound(A, objectType), same(objectType));
- expect(env.getStandardUpperBound(voidType, A), same(voidType));
- expect(env.getStandardUpperBound(A, voidType), same(voidType));
expect(
- env.getStandardUpperBound(dynamicType, objectType), same(dynamicType));
+ env.getStandardUpperBound(dynamicType, A, testLib), same(dynamicType));
expect(
- env.getStandardUpperBound(objectType, dynamicType), same(dynamicType));
- expect(env.getStandardUpperBound(dynamicType, voidType), same(voidType));
- expect(env.getStandardUpperBound(voidType, dynamicType), same(voidType));
- expect(env.getStandardUpperBound(objectType, voidType), same(voidType));
- expect(env.getStandardUpperBound(voidType, objectType), same(voidType));
+ env.getStandardUpperBound(A, dynamicType, testLib), same(dynamicType));
+ expect(env.getStandardUpperBound(objectType, A, testLib), same(objectType));
+ expect(env.getStandardUpperBound(A, objectType, testLib), same(objectType));
+ expect(env.getStandardUpperBound(voidType, A, testLib), same(voidType));
+ expect(env.getStandardUpperBound(A, voidType, testLib), same(voidType));
+ expect(env.getStandardUpperBound(dynamicType, objectType, testLib),
+ same(dynamicType));
+ expect(env.getStandardUpperBound(objectType, dynamicType, testLib),
+ same(dynamicType));
+ expect(env.getStandardUpperBound(dynamicType, voidType, testLib),
+ same(voidType));
+ expect(env.getStandardUpperBound(voidType, dynamicType, testLib),
+ same(voidType));
+ expect(env.getStandardUpperBound(objectType, voidType, testLib),
+ same(voidType));
+ expect(env.getStandardUpperBound(voidType, objectType, testLib),
+ same(voidType));
}
void test_lub_typeParameter() {
@@ -573,21 +608,23 @@
U.parameter.bound = _list(bottomType);
var env = _makeEnv();
// LUB(T, T) = T
- expect(env.getStandardUpperBound(T, T), same(T));
+ expect(env.getStandardUpperBound(T, T, testLib), same(T));
// LUB(T, List<Bottom>) = LUB(List<Object>, List<Bottom>) = List<Object>
- expect(env.getStandardUpperBound(T, _list(bottomType)), _list(objectType));
- expect(env.getStandardUpperBound(_list(bottomType), T), _list(objectType));
+ expect(env.getStandardUpperBound(T, _list(bottomType), testLib),
+ _list(objectType));
+ expect(env.getStandardUpperBound(_list(bottomType), T, testLib),
+ _list(objectType));
// LUB(T, U) = LUB(List<Object>, U) = LUB(List<Object>, List<Bottom>)
// = List<Object>
- expect(env.getStandardUpperBound(T, U), _list(objectType));
- expect(env.getStandardUpperBound(U, T), _list(objectType));
+ expect(env.getStandardUpperBound(T, U, testLib), _list(objectType));
+ expect(env.getStandardUpperBound(U, T, testLib), _list(objectType));
}
void test_lub_unknown() {
var A = coreTypes.rawType(_addClass(_class('A')), Nullability.legacy);
var env = _makeEnv();
- expect(env.getStandardLowerBound(A, unknownType), same(A));
- expect(env.getStandardLowerBound(unknownType, A), same(A));
+ expect(env.getStandardLowerBound(A, unknownType, testLib), same(A));
+ expect(env.getStandardLowerBound(unknownType, A, testLib), same(A));
}
void test_solveTypeConstraint() {
diff --git a/pkg/front_end/test/fasta/types/fasta_legacy_upper_bound_test.dart b/pkg/front_end/test/fasta/types/fasta_legacy_upper_bound_test.dart
index 1a5e9af..ebfcd28 100644
--- a/pkg/front_end/test/fasta/types/fasta_legacy_upper_bound_test.dart
+++ b/pkg/front_end/test/fasta/types/fasta_legacy_upper_bound_test.dart
@@ -2,7 +2,7 @@
// 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.
-import "package:kernel/ast.dart" show DartType;
+import "package:kernel/ast.dart" show DartType, Library;
import "package:kernel/core_types.dart" show CoreTypes;
@@ -55,8 +55,8 @@
@override
DartType getLegacyLeastUpperBound(
- DartType a, DartType b, CoreTypes coreTypes) {
- return hierarchy.getKernelLegacyLeastUpperBound(a, b);
+ DartType a, DartType b, Library clientLibrary, CoreTypes coreTypes) {
+ return hierarchy.getKernelLegacyLeastUpperBound(a, b, clientLibrary);
}
}
diff --git a/pkg/front_end/test/fasta/types/kernel_legacy_upper_bound_test.dart b/pkg/front_end/test/fasta/types/kernel_legacy_upper_bound_test.dart
index da6a0ad..256e582 100644
--- a/pkg/front_end/test/fasta/types/kernel_legacy_upper_bound_test.dart
+++ b/pkg/front_end/test/fasta/types/kernel_legacy_upper_bound_test.dart
@@ -4,7 +4,7 @@
import "legacy_upper_bound_helper.dart" show LegacyUpperBoundTest;
-import "package:kernel/ast.dart" show DartType;
+import "package:kernel/ast.dart" show DartType, Library;
import "package:kernel/class_hierarchy.dart" show ClassHierarchy;
@@ -22,8 +22,8 @@
@override
DartType getLegacyLeastUpperBound(
- DartType a, DartType b, CoreTypes coreTypes) {
- return hierarchy.getLegacyLeastUpperBound(a, b, coreTypes);
+ DartType a, DartType b, Library clientLibrary, CoreTypes coreTypes) {
+ return hierarchy.getLegacyLeastUpperBound(a, b, clientLibrary, coreTypes);
}
}
diff --git a/pkg/front_end/test/fasta/types/legacy_upper_bound_helper.dart b/pkg/front_end/test/fasta/types/legacy_upper_bound_helper.dart
index d95d034..06847dc 100644
--- a/pkg/front_end/test/fasta/types/legacy_upper_bound_helper.dart
+++ b/pkg/front_end/test/fasta/types/legacy_upper_bound_helper.dart
@@ -7,7 +7,7 @@
import "package:expect/expect.dart" show Expect;
import "package:kernel/ast.dart"
- show Class, Component, DartType, InterfaceType, Nullability;
+ show Class, Component, DartType, InterfaceType, Library, Nullability;
import "package:kernel/core_types.dart";
@@ -49,11 +49,11 @@
}
DartType getLegacyLeastUpperBound(
- DartType a, DartType b, CoreTypes coreTypes);
+ DartType a, DartType b, Library clientLibrary, CoreTypes coreTypes);
void checkGetLegacyLeastUpperBound(
- DartType a, DartType b, DartType expected) {
- DartType actual = getLegacyLeastUpperBound(a, b, coreTypes);
+ DartType a, DartType b, Library clientLibrary, DartType expected) {
+ DartType actual = getLegacyLeastUpperBound(a, b, clientLibrary, coreTypes);
Expect.equals(expected, actual);
}
@@ -76,6 +76,7 @@
Class N = getClass("N");
Class C1 = getClass("C1");
Class C2 = getClass("C2");
+ Library testLib = N.enclosingLibrary;
// The least upper bound of C1<int> and N<C1<String>> is Object since the
// supertypes are
@@ -87,6 +88,7 @@
new InterfaceType(N, Nullability.legacy, [
new InterfaceType(C1, Nullability.legacy, [stringType])
]),
+ testLib,
objectType);
// The least upper bound of C2<int> and N<C2<String>> is Object since the
@@ -99,6 +101,7 @@
new InterfaceType(N, Nullability.legacy, [
new InterfaceType(C2, Nullability.legacy, [stringType])
]),
+ testLib,
objectType);
}
@@ -118,26 +121,32 @@
Class d = getClass("D");
Class e = getClass("E");
Class f = getClass("F");
+ Library testLib = a.enclosingLibrary;
checkGetLegacyLeastUpperBound(
new InterfaceType(d, Nullability.legacy, [intType, doubleType]),
new InterfaceType(d, Nullability.legacy, [intType, doubleType]),
+ testLib,
new InterfaceType(d, Nullability.legacy, [intType, doubleType]));
checkGetLegacyLeastUpperBound(
new InterfaceType(d, Nullability.legacy, [intType, doubleType]),
new InterfaceType(d, Nullability.legacy, [intType, boolType]),
+ testLib,
new InterfaceType(b, Nullability.legacy, [intType]));
checkGetLegacyLeastUpperBound(
new InterfaceType(d, Nullability.legacy, [intType, doubleType]),
new InterfaceType(d, Nullability.legacy, [boolType, doubleType]),
+ testLib,
new InterfaceType(c, Nullability.legacy, [doubleType]));
checkGetLegacyLeastUpperBound(
new InterfaceType(d, Nullability.legacy, [intType, doubleType]),
new InterfaceType(d, Nullability.legacy, [boolType, intType]),
+ testLib,
coreTypes.legacyRawType(a));
checkGetLegacyLeastUpperBound(
coreTypes.legacyRawType(e),
coreTypes.legacyRawType(f),
+ testLib,
new InterfaceType(b, Nullability.legacy, [intType]));
}
@@ -162,22 +171,23 @@
Class g = getClass("G");
Class h = getClass("H");
Class i = getClass("I");
+ Library testLib = a.enclosingLibrary;
- checkGetLegacyLeastUpperBound(
- coreTypes.legacyRawType(a), coreTypes.legacyRawType(b), objectType);
- checkGetLegacyLeastUpperBound(
- coreTypes.legacyRawType(a), objectType, objectType);
- checkGetLegacyLeastUpperBound(
- objectType, coreTypes.legacyRawType(b), objectType);
- checkGetLegacyLeastUpperBound(coreTypes.legacyRawType(c),
- coreTypes.legacyRawType(d), coreTypes.legacyRawType(a));
- checkGetLegacyLeastUpperBound(coreTypes.legacyRawType(c),
- coreTypes.legacyRawType(a), coreTypes.legacyRawType(a));
checkGetLegacyLeastUpperBound(coreTypes.legacyRawType(a),
- coreTypes.legacyRawType(d), coreTypes.legacyRawType(a));
+ coreTypes.legacyRawType(b), testLib, objectType);
+ checkGetLegacyLeastUpperBound(
+ coreTypes.legacyRawType(a), objectType, testLib, objectType);
+ checkGetLegacyLeastUpperBound(
+ objectType, coreTypes.legacyRawType(b), testLib, objectType);
+ checkGetLegacyLeastUpperBound(coreTypes.legacyRawType(c),
+ coreTypes.legacyRawType(d), testLib, coreTypes.legacyRawType(a));
+ checkGetLegacyLeastUpperBound(coreTypes.legacyRawType(c),
+ coreTypes.legacyRawType(a), testLib, coreTypes.legacyRawType(a));
+ checkGetLegacyLeastUpperBound(coreTypes.legacyRawType(a),
+ coreTypes.legacyRawType(d), testLib, coreTypes.legacyRawType(a));
checkGetLegacyLeastUpperBound(coreTypes.legacyRawType(f),
- coreTypes.legacyRawType(g), coreTypes.legacyRawType(a));
+ coreTypes.legacyRawType(g), testLib, coreTypes.legacyRawType(a));
checkGetLegacyLeastUpperBound(coreTypes.legacyRawType(h),
- coreTypes.legacyRawType(i), coreTypes.legacyRawType(a));
+ coreTypes.legacyRawType(i), testLib, coreTypes.legacyRawType(a));
}
}
diff --git a/pkg/front_end/test/fasta/types/shared_type_tests.dart b/pkg/front_end/test/fasta/types/shared_type_tests.dart
index 1217c30..20eb6a3 100644
--- a/pkg/front_end/test/fasta/types/shared_type_tests.dart
+++ b/pkg/front_end/test/fasta/types/shared_type_tests.dart
@@ -906,8 +906,10 @@
isObliviousSubtype('Id<T & String?>', 'T & String',
typeParameters: 'T extends Object?');
// TODO(dmitryas): Uncomment the following.
- //isObliviousSubtype('Id<T & String>?', 'T & String', typeParameters: 'T extends Object');
- //isObliviousSubtype('Id<T & String>?', 'T & String?', typeParameters: 'T extends Object');
+// isObliviousSubtype('Id<T & String>?', 'T & String',
+// typeParameters: 'T extends Object');
+// isObliviousSubtype('Id<T & String>?', 'T & String?',
+// typeParameters: 'T extends Object');
isSubtype('Id<T* & String*>*', 'T*', typeParameters: 'T extends Object*');
isSubtype('Id<T & String>', 'T', typeParameters: 'T extends Object');
diff --git a/pkg/front_end/test/id_tests/assigned_variables_test.dart b/pkg/front_end/test/id_tests/assigned_variables_test.dart
index 412b439..c121737 100644
--- a/pkg/front_end/test/id_tests/assigned_variables_test.dart
+++ b/pkg/front_end/test/id_tests/assigned_variables_test.dart
@@ -27,11 +27,7 @@
createUriForFileName: createUriForFileName,
onFailure: onFailure,
runTest: runTestFor(
- const AssignedVariablesDataComputer(), [cfeNonNullableOnlyConfig]),
- skipList: [
- 'for.dart',
- 'for_element.dart',
- ]);
+ const AssignedVariablesDataComputer(), [cfeNonNullableOnlyConfig]));
}
class AssignedVariablesDataComputer extends DataComputer<_Data> {
diff --git a/pkg/front_end/test/id_tests/definite_assignment_test.dart b/pkg/front_end/test/id_tests/definite_assignment_test.dart
index 69be70e..6d084f5 100644
--- a/pkg/front_end/test/id_tests/definite_assignment_test.dart
+++ b/pkg/front_end/test/id_tests/definite_assignment_test.dart
@@ -25,12 +25,8 @@
runTest: runTestFor(
const DefiniteAssignmentDataComputer(), [cfeNonNullableOnlyConfig]),
skipList: [
- // TODO(johnniwinther): Update break/continue handling to support these:
- 'do.dart',
- 'for.dart',
+ // TODO(johnniwinther): Change for loop encoding to support this:
'for_each.dart',
- 'switch.dart',
- 'while.dart',
]);
}
diff --git a/pkg/front_end/test/id_tests/nullability_test.dart b/pkg/front_end/test/id_tests/nullability_test.dart
index 2ff1bca..594d001 100644
--- a/pkg/front_end/test/id_tests/nullability_test.dart
+++ b/pkg/front_end/test/id_tests/nullability_test.dart
@@ -19,13 +19,7 @@
createUriForFileName: createUriForFileName,
onFailure: onFailure,
runTest: runTestFor(
- const NullabilityDataComputer(), [cfeNonNullableOnlyConfig]),
- skipList: [
- // TODO(johnniwinther): Run all nullability tests.
- 'null_aware_access.dart',
- 'try_finally.dart',
- 'while.dart',
- ]);
+ const NullabilityDataComputer(), [cfeNonNullableOnlyConfig]));
}
class NullabilityDataComputer extends DataComputer<String> {
diff --git a/pkg/front_end/test/id_tests/type_promotion_test.dart b/pkg/front_end/test/id_tests/type_promotion_test.dart
index 03f1e5b..c92b3f4 100644
--- a/pkg/front_end/test/id_tests/type_promotion_test.dart
+++ b/pkg/front_end/test/id_tests/type_promotion_test.dart
@@ -24,17 +24,8 @@
const TypePromotionDataComputer(), [cfeNonNullableOnlyConfig]),
skipList: [
// TODO(johnniwinther): Run all type promotion tests.
- 'assignment_promoted.dart',
'bug39178.dart',
- 'constructor_initializer.dart',
'for.dart',
- 'not_promoted.dart',
- 'null_aware_assignment.dart',
- 'switch.dart',
- 'try_finally.dart',
- 'type_parameter.dart',
- 'while.dart',
- 'write_capture.dart',
]);
}
diff --git a/pkg/front_end/test/kernel_generator_test.dart b/pkg/front_end/test/kernel_generator_test.dart
index 92c2b12..8103c8c 100644
--- a/pkg/front_end/test/kernel_generator_test.dart
+++ b/pkg/front_end/test/kernel_generator_test.dart
@@ -11,7 +11,6 @@
greaterThan,
group,
isEmpty,
- isFalse,
isNotEmpty,
isNotNull,
isTrue,
@@ -102,63 +101,6 @@
isNotNull);
});
- test('code from summary dependencies are marked external', () async {
- Component component = (await compileScript(
- 'a() => print("hi"); main() {}',
- fileName: 'a.dart'))
- ?.component;
- for (var lib in component.libraries) {
- if (lib.importUri.scheme == 'dart') {
- // ignore: DEPRECATED_MEMBER_USE
- expect(lib.isExternal, isTrue);
- }
- }
-
- // Pretend that the compiled code is a summary
- var bytes = serializeComponent(component);
- component = (await compileScript(
- {
- 'b.dart': 'import "a.dart" as m; b() => m.a(); main() {}',
- 'summary.dill': bytes
- },
- fileName: 'b.dart',
- inputSummaries: ['summary.dill']))
- ?.component;
-
- var aLib = component.libraries
- .firstWhere((lib) => lib.importUri.path == '/a/b/c/a.dart');
- // ignore: DEPRECATED_MEMBER_USE
- expect(aLib.isExternal, isTrue);
- });
-
- test('code from linked dependencies are not marked external', () async {
- Component component = (await compileScript(
- 'a() => print("hi"); main() {}',
- fileName: 'a.dart'))
- ?.component;
- for (var lib in component.libraries) {
- if (lib.importUri.scheme == 'dart') {
- // ignore: DEPRECATED_MEMBER_USE
- expect(lib.isExternal, isTrue);
- }
- }
-
- var bytes = serializeComponent(component);
- component = (await compileScript(
- {
- 'b.dart': 'import "a.dart" as m; b() => m.a(); main() {}',
- 'link.dill': bytes
- },
- fileName: 'b.dart',
- linkedDependencies: ['link.dill']))
- ?.component;
-
- var aLib = component.libraries
- .firstWhere((lib) => lib.importUri.path == '/a/b/c/a.dart');
- // ignore: DEPRECATED_MEMBER_USE
- expect(aLib.isExternal, isFalse);
- });
-
// TODO(sigmund): add tests discovering libraries.json
});
diff --git a/pkg/front_end/test/language_versioning/data/parts_disagreeing/main.dart b/pkg/front_end/test/language_versioning/data/parts_disagreeing/main.dart
index 391adb5..e2e4fc4 100644
--- a/pkg/front_end/test/language_versioning/data/parts_disagreeing/main.dart
+++ b/pkg/front_end/test/language_versioning/data/parts_disagreeing/main.dart
@@ -9,5 +9,5 @@
/*library: languageVersion=2.5*/
main() {
- /*error: MethodNotFound*/ foo();
+ foo();
}
diff --git a/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package/lib/foo.dart b/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package/lib/foo.dart
index 043246e..622a9e7 100644
--- a/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package/lib/foo.dart
+++ b/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package/lib/foo.dart
@@ -12,5 +12,5 @@
/*library: languageVersion=2.5*/
foo() {
- /*error: MethodNotFound*/ bar();
+ bar();
}
diff --git a/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package_2/lib/foo.dart b/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package_2/lib/foo.dart
index 10a3c24..7c0e67c 100644
--- a/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package_2/lib/foo.dart
+++ b/pkg/front_end/test/language_versioning/data/parts_disagreeing_has_package_2/lib/foo.dart
@@ -10,5 +10,5 @@
/*library: languageVersion=2.5*/
foo() {
- /*error: MethodNotFound*/ bar();
+ bar();
}
diff --git a/pkg/front_end/test/lint_test.status b/pkg/front_end/test/lint_test.status
index f4d0a40..c236ac1 100644
--- a/pkg/front_end/test/lint_test.status
+++ b/pkg/front_end/test/lint_test.status
@@ -3,7 +3,6 @@
# BSD-style license that can be found in the LICENSE.md file.
src/api_unstable/bazel_worker/ImportsTwice: Fail
-src/fasta/builder/class_builder/ImportsTwice: Fail
src/fasta/incremental_compiler/ImportsTwice: Fail
src/fasta/kernel/body_builder/ImportsTwice: Fail
src/fasta/kernel/expression_generator_helper/ImportsTwice: Fail
@@ -13,6 +12,7 @@
src/fasta/scanner/string_scanner/ImportsTwice: Fail
src/fasta/scanner/token/ImportsTwice: Fail
src/fasta/scanner/utf8_bytes_scanner/ImportsTwice: Fail
+src/fasta/source/source_class_builder/ImportsTwice: Fail
src/fasta/source/value_kinds/ImportsTwice: Fail
src/fasta/type_inference/type_constraint_gatherer/ImportsTwice: Fail
src/fasta/type_inference/type_inferrer/ImportsTwice: Fail
diff --git a/pkg/front_end/test/patching/data/initializing_formals/libraries.json b/pkg/front_end/test/patching/data/initializing_formals/libraries.json
new file mode 100644
index 0000000..a697508
--- /dev/null
+++ b/pkg/front_end/test/patching/data/initializing_formals/libraries.json
@@ -0,0 +1,12 @@
+{
+ "none": {
+ "libraries": {
+ "test": {
+ "patches": [
+ "patch.dart"
+ ],
+ "uri": "origin.dart"
+ }
+ }
+ }
+}
diff --git a/pkg/front_end/test/patching/data/initializing_formals/main.dart b/pkg/front_end/test/patching/data/initializing_formals/main.dart
new file mode 100644
index 0000000..de864d5
--- /dev/null
+++ b/pkg/front_end/test/patching/data/initializing_formals/main.dart
@@ -0,0 +1,10 @@
+// Copyright (c) 2019, 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.
+
+// ignore: uri_does_not_exist
+import 'dart:test';
+
+main() {
+ new PatchedClass(10, 20);
+}
diff --git a/pkg/front_end/test/patching/data/initializing_formals/origin.dart b/pkg/front_end/test/patching/data/initializing_formals/origin.dart
new file mode 100644
index 0000000..0376794
--- /dev/null
+++ b/pkg/front_end/test/patching/data/initializing_formals/origin.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2019, 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.
+
+/*class: PatchedClass:
+ kernel-members=[
+ PatchedClass.,
+ _privateField,
+ publicField],
+ scope=[publicField]
+*/
+class PatchedClass {
+ int publicField;
+
+ external PatchedClass(publicField, privateField);
+}
diff --git a/pkg/front_end/test/patching/data/initializing_formals/patch.dart b/pkg/front_end/test/patching/data/initializing_formals/patch.dart
new file mode 100644
index 0000000..5182eaf
--- /dev/null
+++ b/pkg/front_end/test/patching/data/initializing_formals/patch.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2019, 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.
+
+// ignore: import_internal_library
+import 'dart:_internal';
+
+@patch
+class PatchedClass {
+ final int _privateField;
+
+ /*member: PatchedClass.:initializers=[
+ FieldInitializer(_privateField),
+ FieldInitializer(publicField),SuperInitializer]
+ */
+ @patch
+ PatchedClass(this.publicField, this._privateField);
+}
diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt
index ac01f71..b596f15 100644
--- a/pkg/front_end/test/spell_checking_list_code.txt
+++ b/pkg/front_end/test/spell_checking_list_code.txt
@@ -157,6 +157,7 @@
completes
complicating
component's
+comprehensive
compressed
compression
concat
@@ -175,6 +176,8 @@
continuations
contra
convention
+coordinated
+coordinating
core
core's
corrected
@@ -193,6 +196,7 @@
d
d11e
dag
+dangerous
dangling
danrubel
daringfireball
@@ -349,6 +353,7 @@
frontends
fs
fsource
+fuller
function's
fuse
futured
@@ -458,7 +463,6 @@
juxtaposition
juxtapositions
k
-k’s
kallentu
kernel's
kernel2kernel
@@ -466,6 +470,7 @@
kmillikin
kustermann
kv
+k’s
l
lacks
lang
@@ -486,6 +491,7 @@
lifter
linearized
lives
+llub
lm
locationd
lots
@@ -643,13 +649,13 @@
quick
quoted
r
+r'$creation
r'\f
r'\r
r'\s
r'\t
r'\u
r'\v
-r'$creation
ra
radix
raises
@@ -695,6 +701,7 @@
relativize
relax
relaxes
+relink
remapped
remedy
removal
@@ -728,6 +735,7 @@
rs
runnable
s
+say
sb
scheglov
scoped
@@ -841,6 +849,7 @@
tagger
tags
taking
+talks
team
tear
tearing
@@ -857,6 +866,7 @@
tester
tex
th
+therein
thought
ti
tick
@@ -905,6 +915,7 @@
uint16
uint32
uint8
+ultimately
umbrella
un
unaffected
@@ -985,6 +996,7 @@
widgets
wiki
wikipedia
+wind
with1
worthwhile
writeln
diff --git a/pkg/front_end/test/spelling_test_base.dart b/pkg/front_end/test/spelling_test_base.dart
index 605bdeb..60c1471 100644
--- a/pkg/front_end/test/spelling_test_base.dart
+++ b/pkg/front_end/test/spelling_test_base.dart
@@ -43,6 +43,42 @@
List<spell.Dictionaries> get dictionaries;
bool get onlyBlacklisted;
+
+ Set<String> reportedWords = {};
+ Set<String> reportedWordsBlacklisted = {};
+
+ @override
+ Future<void> postRun() {
+ if (reportedWordsBlacklisted.isNotEmpty) {
+ print("\n\n\n");
+ print("================");
+ print("The following words was reported as used and blacklisted:");
+ print("----------------");
+ for (String s in reportedWordsBlacklisted) {
+ print("$s");
+ }
+ print("================");
+ }
+ if (reportedWords.isNotEmpty) {
+ print("\n\n\n");
+ print("================");
+ print("The following word(s) were reported as unknown:");
+ print("----------------");
+ for (String s in reportedWords) {
+ print("$s");
+ }
+ if (dictionaries.isNotEmpty) {
+ print("----------------");
+ print("If the word(s) are correctly spelled please add it to one of "
+ "these files:");
+ for (spell.Dictionaries dictionary in dictionaries) {
+ print(" - ${spell.dictionaryToUri(dictionary)}");
+ }
+ }
+ print("================");
+ }
+ return null;
+ }
}
class SpellTest extends Step<TestDescription, TestDescription, SpellContext> {
@@ -73,8 +109,10 @@
String message;
if (blacklisted) {
message = "Misspelled word: '$word' has explicitly been blacklisted.";
+ context.reportedWordsBlacklisted.add(word);
} else {
message = "The word '$word' is not in our dictionary.";
+ context.reportedWords.add(word);
}
if (alternatives != null && alternatives.isNotEmpty) {
message += "\n\nThe following word(s) was 'close' "
diff --git a/pkg/front_end/test/static_types/data/for_in.dart b/pkg/front_end/test/static_types/data/for_in.dart
new file mode 100644
index 0000000..c75d8a9
--- /dev/null
+++ b/pkg/front_end/test/static_types/data/for_in.dart
@@ -0,0 +1,181 @@
+// Copyright (c) 2019, 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.
+
+/*cfe|dart2js.library: nnbd=false*/
+/*cfe:nnbd.library: nnbd=true*/
+
+forInDynamicList(dynamic list) {
+ /*current: dynamic*/
+ for (var e in
+ /*cfe|dart2js.as: Iterable<dynamic>*/
+ /*cfe:nnbd.as: Iterable<dynamic>!*/
+ /*dynamic*/ list) {
+ /*dynamic*/ e;
+ }
+}
+
+forInDynamic(List<dynamic> list) {
+ /*current: dynamic*/
+ for (var e in
+ /*cfe|dart2js.List<dynamic>*/
+ /*cfe:nnbd.List<dynamic>!*/ list) {
+ /*dynamic*/ e;
+ }
+}
+
+forInInt(List<int> list) {
+ /*current: int*/
+ for (var e in
+ /*cfe|dart2js.List<int>*/
+ /*cfe:nnbd.List<int!>!*/ list) {
+ /*int*/
+ e;
+ }
+}
+
+forInIntToNum(List<int> list) {
+ /*current: int*/
+ for (num e in
+ /*cfe|dart2js.List<int>*/
+ /*cfe:nnbd.List<int!>!*/ list) {
+ /*cfe|dart2js.num*/
+ /*cfe:nnbd.num!*/
+ e;
+ }
+}
+
+asyncForInDynamicStream(dynamic stream) async {
+ /*current: dynamic*/
+ await for (var e in
+ /*cfe|dart2js.as: Stream<dynamic>*/
+ /*cfe:nnbd.as: Stream<dynamic>!*/
+ /*dynamic*/ stream) {
+ /*dynamic*/ e;
+ }
+}
+
+asyncForInDynamic(Stream<dynamic> stream) async {
+ /*current: dynamic*/
+ await for (var e in
+ /*cfe|dart2js.Stream<dynamic>*/
+ /*cfe:nnbd.Stream<dynamic>!*/
+ stream) {
+ /*dynamic*/ e;
+ }
+}
+
+asyncForInInt(Stream<int> stream) async {
+ /*current: int*/
+ await for (var e in
+ /*cfe|dart2js.Stream<int>*/
+ /*cfe:nnbd.Stream<int!>!*/
+ stream) {
+ /*int*/
+ e;
+ }
+}
+
+asyncForInIntToNum(Stream<int> stream) async {
+ /*current: int*/
+ await for (num e in
+ /*cfe|dart2js.Stream<int>*/
+ /*cfe:nnbd.Stream<int!>!*/
+ stream) {
+ /*cfe|dart2js.num*/
+ /*cfe:nnbd.num!*/
+ e;
+ }
+}
+
+abstract class CustomIterable implements Iterable<num> {
+ Iterator<int> get iterator;
+}
+
+customIterable(CustomIterable iterable) {
+ /*cfe|dart2js.current: num*/
+ /*cfe:nnbd.current: num!*/
+ for (var e in
+ /*cfe|dart2js.CustomIterable*/
+ /*cfe:nnbd.CustomIterable!*/
+ iterable) {
+ /*cfe|dart2js.num*/
+ /*cfe:nnbd.num!*/
+ e;
+ }
+}
+
+abstract class CustomStream implements Stream<num> {
+ Iterator<int> get iterator;
+}
+
+customStream(CustomStream stream) async {
+ /*cfe|dart2js.current: num*/
+ /*cfe:nnbd.current: num!*/
+ await for (var e in
+ /*cfe|dart2js.CustomStream*/
+ /*cfe:nnbd.CustomStream!*/
+ stream) {
+ /*cfe|dart2js.num*/
+ /*cfe:nnbd.num!*/
+ e;
+ }
+}
+
+abstract class IterableWithCustomIterator implements Iterable<num> {
+ CustomIterator get iterator;
+}
+
+abstract class CustomIterator implements Iterator<num> {
+ int get current;
+}
+
+customIterableIterator(IterableWithCustomIterator iterable) {
+ /*cfe|dart2js.current: num*/
+ /*cfe:nnbd.current: num!*/
+ for (var e in
+ /*cfe|dart2js.IterableWithCustomIterator*/
+ /*cfe:nnbd.IterableWithCustomIterator!*/
+ iterable) {
+ /*cfe|dart2js.num*/
+ /*cfe:nnbd.num!*/
+ e;
+ }
+}
+
+abstract class StreamWithCustomIterator implements Stream<num> {
+ CustomIterator get iterator;
+}
+
+customStreamIterator(StreamWithCustomIterator stream) async {
+ /*cfe|dart2js.current: num*/
+ /*cfe:nnbd.current: num!*/
+ await for (var e in
+ /*cfe|dart2js.StreamWithCustomIterator*/
+ /*cfe:nnbd.StreamWithCustomIterator!*/
+ stream) {
+ /*cfe|dart2js.num*/
+ /*cfe:nnbd.num!*/
+ e;
+ }
+}
+
+void genericIterable<T extends Iterable<T>>(T x) {
+ /*current: T*/
+ for (var y in
+ /*cfe|dart2js.T*/
+ /*cfe:nnbd.T!*/
+ x) {
+ /*T*/ y;
+ }
+}
+
+void genericStream<T extends Stream<T>>(T x) async {
+ /*current: T*/
+ await for (var y in
+ /*cfe|dart2js.T*/
+ /*cfe:nnbd.T!*/
+ x) {
+ /*T*/ y;
+ }
+}
diff --git a/pkg/front_end/test/static_types/data/list_literals.dart b/pkg/front_end/test/static_types/data/list_literals.dart
index 8cb149c..08a1667 100644
--- a/pkg/front_end/test/static_types/data/list_literals.dart
+++ b/pkg/front_end/test/static_types/data/list_literals.dart
@@ -15,14 +15,14 @@
[/*cfe|dart2js.int*/ /*cfe:nnbd.int!*/ 0];
/*cfe|dart2js.List<num>*/
- /*cfe:nnbd.List<num>!*/
+ /*cfe:nnbd.List<num!>!*/
[
/*cfe|dart2js.int*/ /*cfe:nnbd.int!*/ 0,
/*cfe|dart2js.double*/ /*cfe:nnbd.double!*/ 0.5
];
/*cfe|dart2js.List<Object>*/
- /*cfe:nnbd.List<Object>!*/
+ /*cfe:nnbd.List<Object!>!*/
[
/*cfe|dart2js.int*/ /*cfe:nnbd.int!*/ 0,
/*cfe|dart2js.String*/ /*cfe:nnbd.String!*/ ''
diff --git a/pkg/front_end/test/static_types/data/map_literals.dart b/pkg/front_end/test/static_types/data/map_literals.dart
index c83e20c..0bd1892 100644
--- a/pkg/front_end/test/static_types/data/map_literals.dart
+++ b/pkg/front_end/test/static_types/data/map_literals.dart
@@ -41,7 +41,7 @@
// ignore: unused_local_variable
var a3 =
/*cfe|dart2js.Map<int,num>*/
- /*cfe:nnbd.Map<int!,num>!*/
+ /*cfe:nnbd.Map<int!,num!>!*/
{
/*cfe|dart2js.int*/
/*cfe:nnbd.int!*/
@@ -60,7 +60,7 @@
// ignore: unused_local_variable
var a4 =
/*cfe|dart2js.Map<num,double>*/
- /*cfe:nnbd.Map<num,double!>!*/
+ /*cfe:nnbd.Map<num!,double!>!*/
{
/*cfe|dart2js.int*/
/*cfe:nnbd.int!*/
@@ -79,7 +79,7 @@
// ignore: unused_local_variable
var a5 =
/*cfe|dart2js.Map<num,num>*/
- /*cfe:nnbd.Map<num,num>!*/
+ /*cfe:nnbd.Map<num!,num!>!*/
{
/*cfe|dart2js.int*/
/*cfe:nnbd.int!*/
@@ -98,7 +98,7 @@
// ignore: unused_local_variable
var a6 =
/*cfe|dart2js.Map<int,Object>*/
- /*cfe:nnbd.Map<int!,Object>!*/
+ /*cfe:nnbd.Map<int!,Object!>!*/
{
/*cfe|dart2js.int*/
/*cfe:nnbd.int!*/
@@ -117,7 +117,7 @@
// ignore: unused_local_variable
var a7 =
/*cfe|dart2js.Map<Object,double>*/
- /*cfe:nnbd.Map<Object,double!>!*/
+ /*cfe:nnbd.Map<Object!,double!>!*/
{
/*cfe|dart2js.int*/
/*cfe:nnbd.int!*/
@@ -136,7 +136,7 @@
// ignore: unused_local_variable
var a8 =
/*cfe|dart2js.Map<Object,Object>*/
- /*cfe:nnbd.Map<Object,Object>!*/
+ /*cfe:nnbd.Map<Object!,Object!>!*/
{
/*cfe|dart2js.int*/
/*cfe:nnbd.int!*/
diff --git a/pkg/front_end/test/static_types/data/null_aware_for_in.dart b/pkg/front_end/test/static_types/data/null_aware_for_in.dart
index be939a7..1739c41 100644
--- a/pkg/front_end/test/static_types/data/null_aware_for_in.dart
+++ b/pkg/front_end/test/static_types/data/null_aware_for_in.dart
@@ -9,6 +9,7 @@
main() {
var o;
+ /*current: dynamic*/
/*cfe|dart2js.as: Class*/
/*cfe:nnbd.as: Class!*/
for (
diff --git a/pkg/front_end/test/static_types/data/set_literals.dart b/pkg/front_end/test/static_types/data/set_literals.dart
index 0a253e2..4cb2022 100644
--- a/pkg/front_end/test/static_types/data/set_literals.dart
+++ b/pkg/front_end/test/static_types/data/set_literals.dart
@@ -25,7 +25,7 @@
// ignore: unused_local_variable
var a2 =
/*cfe|dart2js.Set<num>*/
- /*cfe:nnbd.Set<num>!*/
+ /*cfe:nnbd.Set<num!>!*/
{
/*cfe|dart2js.int*/
/*cfe:nnbd.int!*/
@@ -38,7 +38,7 @@
// ignore: unused_local_variable
var a3 =
/*cfe|dart2js.Set<Object>*/
- /*cfe:nnbd.Set<Object>!*/
+ /*cfe:nnbd.Set<Object!>!*/
{
/*cfe|dart2js.int*/
/*cfe:nnbd.int!*/
diff --git a/pkg/front_end/test/static_types/static_type_test.dart b/pkg/front_end/test/static_types/static_type_test.dart
index 6ae12f2..9074b70 100644
--- a/pkg/front_end/test/static_types/static_type_test.dart
+++ b/pkg/front_end/test/static_types/static_type_test.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:io' show Directory, Platform;
-import 'package:_fe_analyzer_shared/src/testing/id.dart' show ActualData, Id;
+import 'package:_fe_analyzer_shared/src/testing/id.dart';
import 'package:_fe_analyzer_shared/src/testing/id_testing.dart'
show DataInterpreter, runTests;
import 'package:_fe_analyzer_shared/src/testing/id_testing.dart';
@@ -94,6 +94,13 @@
if (node.types.isNotEmpty) {
return '<${node.types.map(typeToText).join(',')}>';
}
+ } else if (node is ForInStatement) {
+ if (id.kind == IdKind.current) {
+ DartType type = _staticTypeContext.typeEnvironment
+ .forInElementType(
+ node, node.iterable.getStaticType(_staticTypeContext));
+ return typeToText(type);
+ }
}
return null;
}
diff --git a/pkg/front_end/test/summary_generator_test.dart b/pkg/front_end/test/summary_generator_test.dart
index bd63826..bd4775e 100644
--- a/pkg/front_end/test/summary_generator_test.dart
+++ b/pkg/front_end/test/summary_generator_test.dart
@@ -34,40 +34,6 @@
expect(fooMethod.function.body is EmptyStatement, isTrue);
});
- test('summarized libraries are not marked external', () async {
- var summary = await summarize(['a.dart'], allSources);
- var component = loadComponentFromBytes(summary);
- var aLib = findLibrary(component, 'a.dart');
- expect(aLib.importUri.path, '/a/b/c/a.dart');
- // ignore: DEPRECATED_MEMBER_USE
- expect(aLib.isExternal, isFalse);
- });
-
- test('sdk dependencies are marked external', () async {
- // Note: by default this test is loading the SDK from summaries.
- var summary = await summarize(['a.dart'], allSources);
- var component = loadComponentFromBytes(summary);
- var coreLib = findLibrary(component, 'core');
- // ignore: DEPRECATED_MEMBER_USE
- expect(coreLib.isExternal, isTrue);
- });
-
- test('non-sdk dependencies are marked external', () async {
- var summaryA = await summarize(['a.dart'], allSources);
- var sourcesWithA = new Map<String, dynamic>.from(allSources);
- sourcesWithA['a.dill'] = summaryA;
- var summaryB =
- await summarize(['b.dart'], sourcesWithA, inputSummaries: ['a.dill']);
-
- var component = loadComponentFromBytes(summaryB);
- var aLib = findLibrary(component, 'a.dart');
- var bLib = findLibrary(component, 'b.dart');
- // ignore: DEPRECATED_MEMBER_USE
- expect(aLib.isExternal, isTrue);
- // ignore: DEPRECATED_MEMBER_USE
- expect(bLib.isExternal, isFalse);
- });
-
test('dependencies can be combined without conflict', () async {
var summaryA = await summarize(['a.dart'], allSources);
var sourcesWithA = new Map<String, dynamic>.from(allSources);
@@ -151,19 +117,8 @@
var component = loadComponentFromBytes(summary);
var aLib = findLibrary(component, 'a.dart');
var bLib = findLibrary(component, 'b.dart');
- var cLib = findLibrary(component, 'c.dart');
var dLib = findLibrary(component, 'd.dart');
- // All libraries but `d.dart` are marked external.
- // ignore: DEPRECATED_MEMBER_USE
- expect(aLib.isExternal, isTrue);
- // ignore: DEPRECATED_MEMBER_USE
- expect(bLib.isExternal, isTrue);
- // ignore: DEPRECATED_MEMBER_USE
- expect(cLib.isExternal, isTrue);
- // ignore: DEPRECATED_MEMBER_USE
- expect(dLib.isExternal, isFalse);
-
// The type-hierarchy for A, B, D is visible and correct
var aClass = aLib.classes.firstWhere((c) => c.name == 'A');
var bClass = bLib.classes.firstWhere((c) => c.name == 'B');
diff --git a/pkg/front_end/test/type_labeler_test.dart b/pkg/front_end/test/type_labeler_test.dart
index 3adb0e8..bab4138 100644
--- a/pkg/front_end/test/type_labeler_test.dart
+++ b/pkg/front_end/test/type_labeler_test.dart
@@ -10,7 +10,7 @@
main() {
void check(Map<Node, String> expectations, int bulletCount) {
- TypeLabeler labeler = new TypeLabeler();
+ TypeLabeler labeler = new TypeLabeler(false);
Map<Node, List<Object>> conversions = {};
expectations.forEach((Node node, String expected) {
if (node is DartType) {
diff --git a/pkg/front_end/test/unit_test_suites.dart b/pkg/front_end/test/unit_test_suites.dart
index 29cdd86..8cf95ac 100644
--- a/pkg/front_end/test/unit_test_suites.dart
+++ b/pkg/front_end/test/unit_test_suites.dart
@@ -22,7 +22,7 @@
import 'fasta/incremental_suite.dart' as incremental show createContext;
import 'fasta/messages_suite.dart' as messages show createContext;
import 'fasta/strong_tester.dart' as strong show createContext;
-import 'fasta/text_serialization_suite.dart' as text_serialization
+import 'fasta/text_serialization_tester.dart' as text_serialization
show createContext;
import 'incremental_bulk_compiler_smoke_suite.dart' as incremental_bulk_compiler
show createContext;
@@ -214,8 +214,30 @@
const Suite(
"fasta/incremental", incremental.createContext, "../../testing.json"),
const Suite("fasta/messages", messages.createContext, "../../testing.json"),
- const Suite("fasta/text_serialization", text_serialization.createContext,
- "../../testing.json"),
+ const Suite("fasta/text_serialization1", text_serialization.createContext,
+ "../../testing.json",
+ path: "fasta/text_serialization_tester.dart",
+ shardCount: 4,
+ shard: 0,
+ prefix: "fasta/text_serialization"),
+ const Suite("fasta/text_serialization2", text_serialization.createContext,
+ "../../testing.json",
+ path: "fasta/text_serialization_tester.dart",
+ shardCount: 4,
+ shard: 1,
+ prefix: "fasta/text_serialization"),
+ const Suite("fasta/text_serialization3", text_serialization.createContext,
+ "../../testing.json",
+ path: "fasta/text_serialization_tester.dart",
+ shardCount: 4,
+ shard: 2,
+ prefix: "fasta/text_serialization"),
+ const Suite("fasta/text_serialization4", text_serialization.createContext,
+ "../../testing.json",
+ path: "fasta/text_serialization_tester.dart",
+ shardCount: 4,
+ shard: 3,
+ prefix: "fasta/text_serialization"),
const Suite("fasta/strong1", strong.createContext, "../../testing.json",
path: "fasta/strong_tester.dart",
shardCount: 4,
@@ -249,7 +271,7 @@
"spelling_test_src", spelling_src.createContext, "../testing.json"),
];
-const Duration timeoutDuration = Duration(minutes: 10);
+const Duration timeoutDuration = Duration(minutes: 15);
class SuiteConfiguration {
final String name;
@@ -345,8 +367,8 @@
await exitPort.first;
timer.cancel();
if (!timedOut) {
- print(
- "Suite $name finished (took ${stopwatch.elapsedMilliseconds}ms).");
+ int seconds = stopwatch.elapsedMilliseconds ~/ 1000;
+ print("Suite $name finished (took ${seconds} seconds)");
}
return timedOut;
});
diff --git a/pkg/front_end/testcases/general/await_complex.dart.strong.transformed.expect b/pkg/front_end/testcases/general/await_complex.dart.strong.transformed.expect
index afff0fe..b6697d5 100644
--- a/pkg/front_end/testcases/general/await_complex.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/await_complex.dart.strong.transformed.expect
@@ -343,44 +343,50 @@
try {
#L6:
{
- for (final core::Function* #t26 in <core::Function*>[#C1, #C2]) {
- final <T extends core::Object* = dynamic>(T*) →* asy::FutureOr<T*>* func = #t26 as{TypeError} <T extends core::Object* = dynamic>(T*) →* asy::FutureOr<T*>*;
- assert {
- [yield] let dynamic #t27 = asy::_awaitHelper(func.call<core::bool*>(true), :async_op_then, :async_op_error, :async_op) in null;
- assert(_in::unsafeCast<core::bool*>(:result));
- }
- assert {
- if(self::id<core::bool*>(true) as{TypeError} core::bool*)
- ;
- else {
- [yield] let dynamic #t28 = asy::_awaitHelper(func.call<core::String*>("message"), :async_op_then, :async_op_error, :async_op) in null;
- assert(false, _in::unsafeCast<core::String*>(:result));
- }
- }
- assert {
- [yield] let dynamic #t29 = asy::_awaitHelper(func.call<core::bool*>(true), :async_op_then, :async_op_error, :async_op) in null;
- if(_in::unsafeCast<core::bool*>(:result))
- ;
- else {
- [yield] let dynamic #t30 = asy::_awaitHelper(func.call<core::String*>("message"), :async_op_then, :async_op_error, :async_op) in null;
- assert(false, _in::unsafeCast<core::String*>(:result));
- }
- }
- try {
- assert {
- [yield] let dynamic #t31 = asy::_awaitHelper(func.call<core::bool*>(false), :async_op_then, :async_op_error, :async_op) in null;
- if(_in::unsafeCast<core::bool*>(:result))
- ;
- else {
- [yield] let dynamic #t32 = asy::_awaitHelper(func.call<core::String*>("message"), :async_op_then, :async_op_error, :async_op) in null;
- assert(false, _in::unsafeCast<core::String*>(:result));
+ {
+ core::Iterator<core::Function*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::Function*>*>(<core::Function*>[#C1, #C2]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::Function* #t26 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final <T extends core::Object* = dynamic>(T*) →* asy::FutureOr<T*>* func = #t26 as{TypeError} <T extends core::Object* = dynamic>(T*) →* asy::FutureOr<T*>*;
+ assert {
+ [yield] let dynamic #t27 = asy::_awaitHelper(func.call<core::bool*>(true), :async_op_then, :async_op_error, :async_op) in null;
+ assert(_in::unsafeCast<core::bool*>(:result));
+ }
+ assert {
+ if(self::id<core::bool*>(true) as{TypeError} core::bool*)
+ ;
+ else {
+ [yield] let dynamic #t28 = asy::_awaitHelper(func.call<core::String*>("message"), :async_op_then, :async_op_error, :async_op) in null;
+ assert(false, _in::unsafeCast<core::String*>(:result));
+ }
+ }
+ assert {
+ [yield] let dynamic #t29 = asy::_awaitHelper(func.call<core::bool*>(true), :async_op_then, :async_op_error, :async_op) in null;
+ if(_in::unsafeCast<core::bool*>(:result))
+ ;
+ else {
+ [yield] let dynamic #t30 = asy::_awaitHelper(func.call<core::String*>("message"), :async_op_then, :async_op_error, :async_op) in null;
+ assert(false, _in::unsafeCast<core::String*>(:result));
+ }
+ }
+ try {
+ assert {
+ [yield] let dynamic #t31 = asy::_awaitHelper(func.call<core::bool*>(false), :async_op_then, :async_op_error, :async_op) in null;
+ if(_in::unsafeCast<core::bool*>(:result))
+ ;
+ else {
+ [yield] let dynamic #t32 = asy::_awaitHelper(func.call<core::String*>("message"), :async_op_then, :async_op_error, :async_op) in null;
+ assert(false, _in::unsafeCast<core::String*>(:result));
+ }
+ }
+ if(self::assertStatementsEnabled)
+ throw "Didn't throw";
+ }
+ on core::AssertionError* catch(final core::AssertionError* e) {
+ self::expect("message", e.{core::AssertionError::message});
}
}
- if(self::assertStatementsEnabled)
- throw "Didn't throw";
- }
- on core::AssertionError* catch(final core::AssertionError* e) {
- self::expect("message", e.{core::AssertionError::message});
}
}
}
@@ -416,251 +422,257 @@
try {
#L7:
{
- for (final core::Function* #t33 in <core::Function*>[#C1, #C2]) {
- final <T extends core::Object* = dynamic>(T*) →* asy::FutureOr<T*>* func = #t33 as{TypeError} <T extends core::Object* = dynamic>(T*) →* asy::FutureOr<T*>*;
- core::int* c = 0;
- {
- dynamic #t34 = true;
- core::int* #t35;
- #L8:
- while (true) {
- core::int* i;
- if(#t34) {
- #t34 = false;
- [yield] let dynamic #t36 = asy::_awaitHelper(func.call<core::int*>(0), :async_op_then, :async_op_error, :async_op) in null;
- i = _in::unsafeCast<core::int*>(:result);
+ {
+ core::Iterator<core::Function*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::Function*>*>(<core::Function*>[#C1, #C2]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::Function* #t33 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final <T extends core::Object* = dynamic>(T*) →* asy::FutureOr<T*>* func = #t33 as{TypeError} <T extends core::Object* = dynamic>(T*) →* asy::FutureOr<T*>*;
+ core::int* c = 0;
+ {
+ dynamic #t34 = true;
+ core::int* #t35;
+ #L8:
+ while (true) {
+ core::int* i;
+ if(#t34) {
+ #t34 = false;
+ [yield] let dynamic #t36 = asy::_awaitHelper(func.call<core::int*>(0), :async_op_then, :async_op_error, :async_op) in null;
+ i = _in::unsafeCast<core::int*>(:result);
+ }
+ else {
+ i = #t35;
+ [yield] let dynamic #t37 = asy::_awaitHelper(func.call<core::int*>(let final core::int* #t38 = i in let final core::int* #t39 = i = #t38.{core::num::+}(1) in #t38), :async_op_then, :async_op_error, :async_op) in null;
+ _in::unsafeCast<core::int*>(:result);
+ }
+ [yield] let dynamic #t40 = asy::_awaitHelper(func.call<core::bool*>(i.{core::num::<}(5)), :async_op_then, :async_op_error, :async_op) in null;
+ if(_in::unsafeCast<core::bool*>(:result)) {
+ {
+ c = c.{core::num::+}(1);
+ }
+ #t35 = i;
+ }
+ else
+ break #L8;
+ }
+ }
+ self::expect(5, c);
+ c = 0;
+ #L9:
+ while (true) {
+ [yield] let dynamic #t41 = asy::_awaitHelper(func.call<core::bool*>(c.{core::num::<}(5)), :async_op_then, :async_op_error, :async_op) in null;
+ if(_in::unsafeCast<core::bool*>(:result))
+ c = c.{core::num::+}(1);
+ else
+ break #L9;
+ }
+ self::expect(5, c);
+ c = 0;
+ do {
+ c = c.{core::num::+}(1);
+ [yield] let dynamic #t42 = asy::_awaitHelper(func.call<core::bool*>(c.{core::num::<}(5)), :async_op_then, :async_op_error, :async_op) in null;
+ }
+ while (_in::unsafeCast<core::bool*>(:result))
+ self::expect(5, c);
+ [yield] let dynamic #t43 = asy::_awaitHelper(func.call<core::bool*>(c.{core::num::==}(5)), :async_op_then, :async_op_error, :async_op) in null;
+ if(_in::unsafeCast<core::bool*>(:result)) {
+ self::expect(5, c);
}
else {
- i = #t35;
- [yield] let dynamic #t37 = asy::_awaitHelper(func.call<core::int*>(let final core::int* #t38 = i in let final core::int* #t39 = i = #t38.{core::num::+}(1) in #t38), :async_op_then, :async_op_error, :async_op) in null;
- _in::unsafeCast<core::int*>(:result);
+ throw "unreachable";
}
- [yield] let dynamic #t40 = asy::_awaitHelper(func.call<core::bool*>(i.{core::num::<}(5)), :async_op_then, :async_op_error, :async_op) in null;
- if(_in::unsafeCast<core::bool*>(:result)) {
- {
- c = c.{core::num::+}(1);
- }
- #t35 = i;
+ try {
+ [yield] let dynamic #t44 = asy::_awaitHelper(func.call<core::String*>("string"), :async_op_then, :async_op_error, :async_op) in null;
+ throw _in::unsafeCast<core::String*>(:result);
}
- else
- break #L8;
- }
- }
- self::expect(5, c);
- c = 0;
- #L9:
- while (true) {
- [yield] let dynamic #t41 = asy::_awaitHelper(func.call<core::bool*>(c.{core::num::<}(5)), :async_op_then, :async_op_error, :async_op) in null;
- if(_in::unsafeCast<core::bool*>(:result))
- c = c.{core::num::+}(1);
- else
- break #L9;
- }
- self::expect(5, c);
- c = 0;
- do {
- c = c.{core::num::+}(1);
- [yield] let dynamic #t42 = asy::_awaitHelper(func.call<core::bool*>(c.{core::num::<}(5)), :async_op_then, :async_op_error, :async_op) in null;
- }
- while (_in::unsafeCast<core::bool*>(:result))
- self::expect(5, c);
- [yield] let dynamic #t43 = asy::_awaitHelper(func.call<core::bool*>(c.{core::num::==}(5)), :async_op_then, :async_op_error, :async_op) in null;
- if(_in::unsafeCast<core::bool*>(:result)) {
- self::expect(5, c);
- }
- else {
- throw "unreachable";
- }
- try {
- [yield] let dynamic #t44 = asy::_awaitHelper(func.call<core::String*>("string"), :async_op_then, :async_op_error, :async_op) in null;
- throw _in::unsafeCast<core::String*>(:result);
- }
- on core::String* catch(no-exception-var) {
- }
- try {
- [yield] let dynamic #t45 = asy::_awaitHelper(throw "string", :async_op_then, :async_op_error, :async_op) in null;
- _in::unsafeCast<<BottomType>>(:result);
- }
- on core::String* catch(no-exception-var) {
- }
- try
- try {
+ on core::String* catch(no-exception-var) {
+ }
+ try {
+ [yield] let dynamic #t45 = asy::_awaitHelper(throw "string", :async_op_then, :async_op_error, :async_op) in null;
+ _in::unsafeCast<<BottomType>>(:result);
+ }
+ on core::String* catch(no-exception-var) {
+ }
try
try {
- throw "string";
+ try
+ try {
+ throw "string";
+ }
+ on dynamic catch(final dynamic e) {
+ self::expect("string", e);
+ [yield] let dynamic #t46 = asy::_awaitHelper(func.call<core::int*>(0), :async_op_then, :async_op_error, :async_op) in null;
+ self::expect(0, _in::unsafeCast<core::int*>(:result));
+ rethrow;
+ }
+ finally {
+ [yield] let dynamic #t47 = asy::_awaitHelper(func.call<core::int*>(0), :async_op_then, :async_op_error, :async_op) in null;
+ self::expect(0, _in::unsafeCast<core::int*>(:result));
+ }
}
on dynamic catch(final dynamic e) {
- self::expect("string", e);
- [yield] let dynamic #t46 = asy::_awaitHelper(func.call<core::int*>(0), :async_op_then, :async_op_error, :async_op) in null;
+ [yield] let dynamic #t48 = asy::_awaitHelper(func.call<core::int*>(0), :async_op_then, :async_op_error, :async_op) in null;
self::expect(0, _in::unsafeCast<core::int*>(:result));
- rethrow;
+ self::expect("string", e);
}
finally {
- [yield] let dynamic #t47 = asy::_awaitHelper(func.call<core::int*>(0), :async_op_then, :async_op_error, :async_op) in null;
+ [yield] let dynamic #t49 = asy::_awaitHelper(func.call<core::int*>(0), :async_op_then, :async_op_error, :async_op) in null;
self::expect(0, _in::unsafeCast<core::int*>(:result));
}
- }
- on dynamic catch(final dynamic e) {
- [yield] let dynamic #t48 = asy::_awaitHelper(func.call<core::int*>(0), :async_op_then, :async_op_error, :async_op) in null;
- self::expect(0, _in::unsafeCast<core::int*>(:result));
- self::expect("string", e);
- }
- finally {
- [yield] let dynamic #t49 = asy::_awaitHelper(func.call<core::int*>(0), :async_op_then, :async_op_error, :async_op) in null;
- self::expect(0, _in::unsafeCast<core::int*>(:result));
- }
- #L10:
- {
- [yield] let dynamic #t50 = asy::_awaitHelper(func.call<core::int*>(2), :async_op_then, :async_op_error, :async_op) in null;
- switch(_in::unsafeCast<core::int*>(:result)) {
- #L11:
- case #C3:
- {
- break #L10;
+ #L10:
+ {
+ [yield] let dynamic #t50 = asy::_awaitHelper(func.call<core::int*>(2), :async_op_then, :async_op_error, :async_op) in null;
+ switch(_in::unsafeCast<core::int*>(:result)) {
+ #L11:
+ case #C3:
+ {
+ break #L10;
+ }
+ #L12:
+ default:
+ {
+ throw "unreachable";
+ }
}
- #L12:
- default:
- {
- throw "unreachable";
- }
- }
- }
- [yield] let dynamic #t51 = asy::_awaitHelper((() → asy::Future<dynamic>* /* originally async */ {
- final asy::_AsyncAwaitCompleter<dynamic>* :async_completer = new asy::_AsyncAwaitCompleter::•<dynamic>();
- asy::FutureOr<dynamic>* :return_value;
- dynamic :async_stack_trace;
- dynamic :async_op_then;
- dynamic :async_op_error;
- core::int* :await_jump_var = 0;
- dynamic :await_ctx_var;
- dynamic :saved_try_context_var0;
- function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
- try {
- #L13:
- {
- [yield] let dynamic #t52 = asy::_awaitHelper(func.call<dynamic>(42), :async_op_then, :async_op_error, :async_op) in null;
- :return_value = :result;
- break #L13;
- }
- asy::_completeOnAsyncReturn(:async_completer, :return_value);
- return;
}
- on dynamic catch(dynamic :exception, dynamic :stack_trace) {
- :async_completer.{asy::Completer::completeError}(:exception, :stack_trace);
- }
- :async_stack_trace = asy::_asyncStackTraceHelper(:async_op);
- :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
- :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
- :async_completer.start(:async_op);
- return :async_completer.{asy::Completer::future};
- }).call(), :async_op_then, :async_op_error, :async_op) in null;
- self::expect(42, :result);
- [yield] let dynamic #t53 = asy::_awaitHelper((() → asy::Future<dynamic>* /* originally async */ {
- final asy::_AsyncAwaitCompleter<dynamic>* :async_completer = new asy::_AsyncAwaitCompleter::•<dynamic>();
- asy::FutureOr<dynamic>* :return_value;
- dynamic :async_stack_trace;
- dynamic :async_op_then;
- dynamic :async_op_error;
- core::int* :await_jump_var = 0;
- dynamic :await_ctx_var;
- function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
- try {
- #L14:
- {
- :return_value = func.call<dynamic>(42);
- break #L14;
- }
- asy::_completeOnAsyncReturn(:async_completer, :return_value);
- return;
- }
- on dynamic catch(dynamic :exception, dynamic :stack_trace) {
- :async_completer.{asy::Completer::completeError}(:exception, :stack_trace);
- }
- :async_stack_trace = asy::_asyncStackTraceHelper(:async_op);
- :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
- :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
- :async_completer.start(:async_op);
- return :async_completer.{asy::Completer::future};
- }).call(), :async_op_then, :async_op_error, :async_op) in null;
- self::expect(42, :result);
- function testStream1() → asy::Stream<core::int*>* /* originally async* */ {
- asy::_AsyncStarStreamController<core::int*>* :controller;
- dynamic :controller_stream;
- dynamic :async_stack_trace;
- dynamic :async_op_then;
- dynamic :async_op_error;
- core::int* :await_jump_var = 0;
- dynamic :await_ctx_var;
- dynamic :saved_try_context_var0;
- dynamic :saved_try_context_var1;
- function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
- try
- try {
- #L15:
- {
- [yield] let dynamic #t54 = asy::_awaitHelper(func.call<core::int*>(42), :async_op_then, :async_op_error, :async_op) in null;
- if(:controller.{asy::_AsyncStarStreamController::add}(_in::unsafeCast<core::int*>(:result)))
- return null;
- else
- [yield] null;
+ [yield] let dynamic #t51 = asy::_awaitHelper((() → asy::Future<dynamic>* /* originally async */ {
+ final asy::_AsyncAwaitCompleter<dynamic>* :async_completer = new asy::_AsyncAwaitCompleter::•<dynamic>();
+ asy::FutureOr<dynamic>* :return_value;
+ dynamic :async_stack_trace;
+ dynamic :async_op_then;
+ dynamic :async_op_error;
+ core::int* :await_jump_var = 0;
+ dynamic :await_ctx_var;
+ dynamic :saved_try_context_var0;
+ function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
+ try {
+ #L13:
+ {
+ [yield] let dynamic #t52 = asy::_awaitHelper(func.call<dynamic>(42), :async_op_then, :async_op_error, :async_op) in null;
+ :return_value = :result;
+ break #L13;
+ }
+ asy::_completeOnAsyncReturn(:async_completer, :return_value);
+ return;
}
- return;
- }
- on dynamic catch(dynamic :exception, dynamic :stack_trace) {
- :controller.{asy::_AsyncStarStreamController::addError}(:exception, :stack_trace);
- }
- finally {
- :controller.{asy::_AsyncStarStreamController::close}();
- }
- :async_stack_trace = asy::_asyncStackTraceHelper(:async_op);
- :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
- :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
- :controller = new asy::_AsyncStarStreamController::•<core::int*>(:async_op);
- :controller_stream = :controller.{asy::_AsyncStarStreamController::stream};
- return :controller_stream;
- }
- :async_temporary_0 = <dynamic>[42];
- [yield] let dynamic #t55 = asy::_awaitHelper(testStream1.call().{asy::Stream::toList}(), :async_op_then, :async_op_error, :async_op) in null;
- self::expectList(:async_temporary_0, _in::unsafeCast<core::List<core::int*>*>(:result));
- function testStream2() → asy::Stream<core::int*>* /* originally async* */ {
- asy::_AsyncStarStreamController<core::int*>* :controller;
- dynamic :controller_stream;
- dynamic :async_stack_trace;
- dynamic :async_op_then;
- dynamic :async_op_error;
- core::int* :await_jump_var = 0;
- dynamic :await_ctx_var;
- dynamic :saved_try_context_var0;
- dynamic :saved_try_context_var1;
- function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
- try
- try {
- #L16:
- {
- [yield] let dynamic #t56 = asy::_awaitHelper(func.call<asy::Stream<core::int*>*>(self::intStream()), :async_op_then, :async_op_error, :async_op) in null;
- if(:controller.{asy::_AsyncStarStreamController::addStream}(_in::unsafeCast<asy::Stream<core::int*>*>(:result)))
- return null;
- else
- [yield] null;
+ on dynamic catch(dynamic :exception, dynamic :stack_trace) {
+ :async_completer.{asy::Completer::completeError}(:exception, :stack_trace);
}
- return;
- }
- on dynamic catch(dynamic :exception, dynamic :stack_trace) {
- :controller.{asy::_AsyncStarStreamController::addError}(:exception, :stack_trace);
- }
- finally {
- :controller.{asy::_AsyncStarStreamController::close}();
+ :async_stack_trace = asy::_asyncStackTraceHelper(:async_op);
+ :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+ :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+ :async_completer.start(:async_op);
+ return :async_completer.{asy::Completer::future};
+ }).call(), :async_op_then, :async_op_error, :async_op) in null;
+ self::expect(42, :result);
+ [yield] let dynamic #t53 = asy::_awaitHelper((() → asy::Future<dynamic>* /* originally async */ {
+ final asy::_AsyncAwaitCompleter<dynamic>* :async_completer = new asy::_AsyncAwaitCompleter::•<dynamic>();
+ asy::FutureOr<dynamic>* :return_value;
+ dynamic :async_stack_trace;
+ dynamic :async_op_then;
+ dynamic :async_op_error;
+ core::int* :await_jump_var = 0;
+ dynamic :await_ctx_var;
+ function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
+ try {
+ #L14:
+ {
+ :return_value = func.call<dynamic>(42);
+ break #L14;
+ }
+ asy::_completeOnAsyncReturn(:async_completer, :return_value);
+ return;
+ }
+ on dynamic catch(dynamic :exception, dynamic :stack_trace) {
+ :async_completer.{asy::Completer::completeError}(:exception, :stack_trace);
+ }
+ :async_stack_trace = asy::_asyncStackTraceHelper(:async_op);
+ :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+ :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+ :async_completer.start(:async_op);
+ return :async_completer.{asy::Completer::future};
+ }).call(), :async_op_then, :async_op_error, :async_op) in null;
+ self::expect(42, :result);
+ function testStream1() → asy::Stream<core::int*>* /* originally async* */ {
+ asy::_AsyncStarStreamController<core::int*>* :controller;
+ dynamic :controller_stream;
+ dynamic :async_stack_trace;
+ dynamic :async_op_then;
+ dynamic :async_op_error;
+ core::int* :await_jump_var = 0;
+ dynamic :await_ctx_var;
+ dynamic :saved_try_context_var0;
+ dynamic :saved_try_context_var1;
+ function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
+ try
+ try {
+ #L15:
+ {
+ [yield] let dynamic #t54 = asy::_awaitHelper(func.call<core::int*>(42), :async_op_then, :async_op_error, :async_op) in null;
+ if(:controller.{asy::_AsyncStarStreamController::add}(_in::unsafeCast<core::int*>(:result)))
+ return null;
+ else
+ [yield] null;
+ }
+ return;
+ }
+ on dynamic catch(dynamic :exception, dynamic :stack_trace) {
+ :controller.{asy::_AsyncStarStreamController::addError}(:exception, :stack_trace);
+ }
+ finally {
+ :controller.{asy::_AsyncStarStreamController::close}();
+ }
+ :async_stack_trace = asy::_asyncStackTraceHelper(:async_op);
+ :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+ :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+ :controller = new asy::_AsyncStarStreamController::•<core::int*>(:async_op);
+ :controller_stream = :controller.{asy::_AsyncStarStreamController::stream};
+ return :controller_stream;
}
- :async_stack_trace = asy::_asyncStackTraceHelper(:async_op);
- :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
- :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
- :controller = new asy::_AsyncStarStreamController::•<core::int*>(:async_op);
- :controller_stream = :controller.{asy::_AsyncStarStreamController::stream};
- return :controller_stream;
+ :async_temporary_0 = <dynamic>[42];
+ [yield] let dynamic #t55 = asy::_awaitHelper(testStream1.call().{asy::Stream::toList}(), :async_op_then, :async_op_error, :async_op) in null;
+ self::expectList(:async_temporary_0, _in::unsafeCast<core::List<core::int*>*>(:result));
+ function testStream2() → asy::Stream<core::int*>* /* originally async* */ {
+ asy::_AsyncStarStreamController<core::int*>* :controller;
+ dynamic :controller_stream;
+ dynamic :async_stack_trace;
+ dynamic :async_op_then;
+ dynamic :async_op_error;
+ core::int* :await_jump_var = 0;
+ dynamic :await_ctx_var;
+ dynamic :saved_try_context_var0;
+ dynamic :saved_try_context_var1;
+ function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
+ try
+ try {
+ #L16:
+ {
+ [yield] let dynamic #t56 = asy::_awaitHelper(func.call<asy::Stream<core::int*>*>(self::intStream()), :async_op_then, :async_op_error, :async_op) in null;
+ if(:controller.{asy::_AsyncStarStreamController::addStream}(_in::unsafeCast<asy::Stream<core::int*>*>(:result)))
+ return null;
+ else
+ [yield] null;
+ }
+ return;
+ }
+ on dynamic catch(dynamic :exception, dynamic :stack_trace) {
+ :controller.{asy::_AsyncStarStreamController::addError}(:exception, :stack_trace);
+ }
+ finally {
+ :controller.{asy::_AsyncStarStreamController::close}();
+ }
+ :async_stack_trace = asy::_asyncStackTraceHelper(:async_op);
+ :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+ :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+ :controller = new asy::_AsyncStarStreamController::•<core::int*>(:async_op);
+ :controller_stream = :controller.{asy::_AsyncStarStreamController::stream};
+ return :controller_stream;
+ }
+ :async_temporary_1 = <dynamic>[42];
+ [yield] let dynamic #t57 = asy::_awaitHelper(testStream2.call().{asy::Stream::toList}(), :async_op_then, :async_op_error, :async_op) in null;
+ self::expectList(:async_temporary_1, _in::unsafeCast<core::List<core::int*>*>(:result));
+ }
}
- :async_temporary_1 = <dynamic>[42];
- [yield] let dynamic #t57 = asy::_awaitHelper(testStream2.call().{asy::Stream::toList}(), :async_op_then, :async_op_error, :async_op) in null;
- self::expectList(:async_temporary_1, _in::unsafeCast<core::List<core::int*>*>(:result));
}
}
asy::_completeOnAsyncReturn(:async_completer, :return_value);
diff --git a/pkg/front_end/testcases/general/control_flow_collection.dart.strong.transformed.expect b/pkg/front_end/testcases/general/control_flow_collection.dart.strong.transformed.expect
index f133a9d..ac4ad8d 100644
--- a/pkg/front_end/testcases/general/control_flow_collection.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/control_flow_collection.dart.strong.transformed.expect
@@ -1,6 +1,7 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
import "dart:collection" as col;
static method main() → dynamic {
@@ -16,11 +17,21 @@
if(self::oracle() as{TypeError} core::bool*)
if(self::oracle() as{TypeError} core::bool*)
#t1.{core::List::add}(4);
- for (core::int* i in <core::int*>[5, 6, 7])
- #t1.{core::List::add}(i);
- for (core::int* i in <core::int*>[8, 9, 10])
- if(self::oracle() as{TypeError} core::bool*)
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[5, 6, 7]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
#t1.{core::List::add}(i);
+ }
+ }
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[8, 9, 10]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
+ if(self::oracle() as{TypeError} core::bool*)
+ #t1.{core::List::add}(i);
+ }
+ }
for (core::int* i = 11; i.{core::num::<=}(14); i = i.{core::num::+}(1))
#t1.{core::List::add}(i);
} =>#t1;
@@ -36,11 +47,21 @@
if(self::oracle() as{TypeError} core::bool*)
if(self::oracle() as{TypeError} core::bool*)
#t2.{core::Set::add}(4);
- for (core::int* i in <core::int*>[5, 6, 7])
- #t2.{core::Set::add}(i);
- for (core::int* i in <core::int*>[8, 9, 10])
- if(self::oracle() as{TypeError} core::bool*)
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[5, 6, 7]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
#t2.{core::Set::add}(i);
+ }
+ }
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[8, 9, 10]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
+ if(self::oracle() as{TypeError} core::bool*)
+ #t2.{core::Set::add}(i);
+ }
+ }
for (core::int* i = 11; i.{core::num::<=}(14); i = i.{core::num::+}(1))
#t2.{core::Set::add}(i);
} =>#t2;
@@ -56,11 +77,21 @@
if(self::oracle() as{TypeError} core::bool*)
if(self::oracle() as{TypeError} core::bool*)
#t3.{core::Map::[]=}(4, 4);
- for (core::int* i in <core::int*>[5, 6, 7])
- #t3.{core::Map::[]=}(i, i);
- for (core::int* i in <core::int*>[8, 9, 10])
- if(self::oracle() as{TypeError} core::bool*)
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[5, 6, 7]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
#t3.{core::Map::[]=}(i, i);
+ }
+ }
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[8, 9, 10]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
+ if(self::oracle() as{TypeError} core::bool*)
+ #t3.{core::Map::[]=}(i, i);
+ }
+ }
for (core::int* i = 11; i.{core::num::<=}(14); i = i.{core::num::+}(1))
#t3.{core::Map::[]=}(i, i);
} =>#t3;
diff --git a/pkg/front_end/testcases/general/control_flow_collection_inference.dart.strong.transformed.expect b/pkg/front_end/testcases/general/control_flow_collection_inference.dart.strong.transformed.expect
index afb21c7..82dc289 100644
--- a/pkg/front_end/testcases/general/control_flow_collection_inference.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/control_flow_collection_inference.dart.strong.transformed.expect
@@ -424,8 +424,8 @@
import self as self;
import "dart:core" as core;
import "dart:collection" as col;
-import "dart:async" as asy;
import "dart:_internal" as _in;
+import "dart:async" as asy;
class A extends core::Object {
synthetic constructor •() → self::A*
@@ -495,144 +495,224 @@
} =>#t9;
core::List<core::int*>* list20 = block {
final core::List<core::int*>* #t10 = <core::int*>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::int* #t11 in <core::int*>[42])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[42]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t11 = :sync-for-iterator.{core::Iterator::current};
#t10.{core::List::add}(#t11);
+ }
+ }
} =>#t10;
core::Set<core::int*>* set20 = block {
final core::Set<core::int*>* #t12 = col::LinkedHashSet::•<core::int*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::int* #t13 in <core::int*>[42])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[42]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t13 = :sync-for-iterator.{core::Iterator::current};
#t12.{core::Set::add}(#t13);
+ }
+ }
#t12.{core::Set::add}(null);
} =>#t12;
core::Map<core::String*, core::int*>* map20 = block {
final core::Map<core::String*, core::int*>* #t14 = <core::String*, core::int*>{};
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::int*>* #t15 in <core::String*, core::int*>{"bar": 42}.{core::Map::entries})
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(<core::String*, core::int*>{"bar": 42}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t15 = :sync-for-iterator.{core::Iterator::current};
#t14.{core::Map::[]=}(#t15.{core::MapEntry::key}, #t15.{core::MapEntry::value});
+ }
+ }
#t14.{core::Map::[]=}("baz", null);
} =>#t14;
core::List<dynamic>* list21 = block {
final core::List<dynamic>* #t16 = <dynamic>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final dynamic #t17 in <dynamic>[dynVar])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[dynVar]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t17 = :sync-for-iterator.{core::Iterator::current};
#t16.{core::List::add}(#t17);
+ }
+ }
} =>#t16;
core::Set<dynamic>* set21 = block {
final core::Set<dynamic>* #t18 = col::LinkedHashSet::•<dynamic>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final dynamic #t19 in <dynamic>[dynVar])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[dynVar]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t19 = :sync-for-iterator.{core::Iterator::current};
#t18.{core::Set::add}(#t19);
+ }
+ }
#t18.{core::Set::add}(null);
} =>#t18;
core::Map<core::String*, dynamic>* map21 = block {
final core::Map<core::String*, dynamic>* #t20 = <core::String*, dynamic>{};
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, dynamic>* #t21 in <core::String*, dynamic>{"bar": dynVar}.{core::Map::entries})
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, dynamic>*>*>(<core::String*, dynamic>{"bar": dynVar}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, dynamic>* #t21 = :sync-for-iterator.{core::Iterator::current};
#t20.{core::Map::[]=}(#t21.{core::MapEntry::key}, #t21.{core::MapEntry::value});
+ }
+ }
#t20.{core::Map::[]=}("baz", null);
} =>#t20;
core::List<core::List<core::int*>*>* list22 = block {
final core::List<core::List<core::int*>*>* #t22 = <core::List<core::int*>*>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t23 in <core::List<core::int*>*>[<core::int*>[42]])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[42]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t23 = :sync-for-iterator.{core::Iterator::current};
#t22.{core::List::add}(#t23);
+ }
+ }
} =>#t22;
core::Set<core::List<core::int*>*>* set22 = block {
final core::Set<core::List<core::int*>*>* #t24 = col::LinkedHashSet::•<core::List<core::int*>*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t25 in <core::List<core::int*>*>[<core::int*>[42]])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[42]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t25 = :sync-for-iterator.{core::Iterator::current};
#t24.{core::Set::add}(#t25);
+ }
+ }
#t24.{core::Set::add}(null);
} =>#t24;
core::Map<core::String*, core::List<core::int*>*>* map22 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t26 = <core::String*, core::List<core::int*>*>{};
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t27 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[42]}.{core::Map::entries})
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[42]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t27 = :sync-for-iterator.{core::Iterator::current};
#t26.{core::Map::[]=}(#t27.{core::MapEntry::key}, #t27.{core::MapEntry::value});
+ }
+ }
#t26.{core::Map::[]=}("baz", null);
} =>#t26;
core::List<core::int*>* list30 = block {
final core::List<core::int*>* #t28 = <core::int*>[];
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::int* #t29 in <core::int*>[42])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[42]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t29 = :sync-for-iterator.{core::Iterator::current};
#t28.{core::List::add}(#t29);
+ }
+ }
} =>#t28;
core::Set<core::int*>* set30 = block {
final core::Set<core::int*>* #t30 = col::LinkedHashSet::•<core::int*>();
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::int* #t31 in <core::int*>[42])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[42]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t31 = :sync-for-iterator.{core::Iterator::current};
#t30.{core::Set::add}(#t31);
+ }
+ }
#t30.{core::Set::add}(null);
} =>#t30;
core::Map<core::String*, core::int*>* map30 = block {
final core::Map<core::String*, core::int*>* #t32 = <core::String*, core::int*>{};
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::int*>* #t33 in <core::String*, core::int*>{"bar": 42}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(<core::String*, core::int*>{"bar": 42}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t33 = :sync-for-iterator.{core::Iterator::current};
#t32.{core::Map::[]=}(#t33.{core::MapEntry::key}, #t33.{core::MapEntry::value});
+ }
+ }
#t32.{core::Map::[]=}("baz", null);
} =>#t32;
core::List<dynamic>* list31 = block {
final core::List<dynamic>* #t34 = <dynamic>[];
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final dynamic #t35 in <dynamic>[dynVar])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[dynVar]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t35 = :sync-for-iterator.{core::Iterator::current};
#t34.{core::List::add}(#t35);
+ }
+ }
} =>#t34;
core::Set<dynamic>* set31 = block {
final core::Set<dynamic>* #t36 = col::LinkedHashSet::•<dynamic>();
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final dynamic #t37 in <dynamic>[dynVar])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[dynVar]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t37 = :sync-for-iterator.{core::Iterator::current};
#t36.{core::Set::add}(#t37);
+ }
+ }
#t36.{core::Set::add}(null);
} =>#t36;
core::Map<core::String*, dynamic>* map31 = block {
final core::Map<core::String*, dynamic>* #t38 = <core::String*, dynamic>{};
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, dynamic>* #t39 in <core::String*, dynamic>{"bar": dynVar}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, dynamic>*>*>(<core::String*, dynamic>{"bar": dynVar}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, dynamic>* #t39 = :sync-for-iterator.{core::Iterator::current};
#t38.{core::Map::[]=}(#t39.{core::MapEntry::key}, #t39.{core::MapEntry::value});
+ }
+ }
#t38.{core::Map::[]=}("baz", null);
} =>#t38;
core::List<core::List<core::int*>*>* list33 = block {
final core::List<core::List<core::int*>*>* #t40 = <core::List<core::int*>*>[];
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t41 in <core::List<core::int*>*>[<core::int*>[42]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[42]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t41 = :sync-for-iterator.{core::Iterator::current};
#t40.{core::List::add}(#t41);
+ }
+ }
} =>#t40;
core::Set<core::List<core::int*>*>* set33 = block {
final core::Set<core::List<core::int*>*>* #t42 = col::LinkedHashSet::•<core::List<core::int*>*>();
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t43 in <core::List<core::int*>*>[<core::int*>[42]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[42]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t43 = :sync-for-iterator.{core::Iterator::current};
#t42.{core::Set::add}(#t43);
+ }
+ }
#t42.{core::Set::add}(null);
} =>#t42;
core::Map<core::String*, core::List<core::int*>*>* map33 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t44 = <core::String*, core::List<core::int*>*>{};
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t45 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[42]}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[42]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t45 = :sync-for-iterator.{core::Iterator::current};
#t44.{core::Map::[]=}(#t45.{core::MapEntry::key}, #t45.{core::MapEntry::value});
+ }
+ }
#t44.{core::Map::[]=}("baz", null);
} =>#t44;
core::List<core::List<core::int*>*>* list40 = block {
final core::List<core::List<core::int*>*>* #t46 = <core::List<core::int*>*>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t47 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t47 = :sync-for-iterator.{core::Iterator::current};
#t46.{core::List::add}(#t47);
+ }
+ }
} =>#t46;
core::Set<core::List<core::int*>*>* set40 = block {
final core::Set<core::List<core::int*>*>* #t48 = col::LinkedHashSet::•<core::List<core::int*>*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t49 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t49 = :sync-for-iterator.{core::Iterator::current};
#t48.{core::Set::add}(#t49);
+ }
+ }
#t48.{core::Set::add}(null);
} =>#t48;
core::Map<core::String*, core::List<core::int*>*>* map40 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:39:34: Error: Both Iterable and Map spread elements encountered in ambiguous literal.
@@ -640,137 +720,213 @@
^";
core::List<core::List<core::int*>*>* list41 = block {
final core::List<core::List<core::int*>*>* #t50 = <core::List<core::int*>*>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t51 in let final core::Set<core::List<core::int*>*>* #t52 = col::LinkedHashSet::•<core::List<core::int*>*>() in let final core::bool* #t53 = #t52.{core::Set::add}(<core::int*>[]) in #t52)
- #t50.{core::List::add}(#t51);
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(let final core::Set<core::List<core::int*>*>* #t51 = col::LinkedHashSet::•<core::List<core::int*>*>() in let final core::bool* #t52 = #t51.{core::Set::add}(<core::int*>[]) in #t51).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t53 = :sync-for-iterator.{core::Iterator::current};
+ #t50.{core::List::add}(#t53);
+ }
+ }
} =>#t50;
core::Set<core::List<core::int*>*>* set41 = block {
final core::Set<core::List<core::int*>*>* #t54 = col::LinkedHashSet::•<core::List<core::int*>*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t55 in let final core::Set<core::List<core::int*>*>* #t56 = col::LinkedHashSet::•<core::List<core::int*>*>() in let final core::bool* #t57 = #t56.{core::Set::add}(<core::int*>[]) in #t56)
- #t54.{core::Set::add}(#t55);
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(let final core::Set<core::List<core::int*>*>* #t55 = col::LinkedHashSet::•<core::List<core::int*>*>() in let final core::bool* #t56 = #t55.{core::Set::add}(<core::int*>[]) in #t55).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t57 = :sync-for-iterator.{core::Iterator::current};
+ #t54.{core::Set::add}(#t57);
+ }
+ }
#t54.{core::Set::add}(null);
} =>#t54;
core::List<core::List<core::int*>*>* list42 = block {
final core::List<core::List<core::int*>*>* #t58 = <core::List<core::int*>*>[];
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t59 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t59 = :sync-for-iterator.{core::Iterator::current};
#t58.{core::List::add}(#t59);
+ }
+ }
} =>#t58;
core::Set<core::List<core::int*>*>* set42 = block {
final core::Set<core::List<core::int*>*>* #t60 = col::LinkedHashSet::•<core::List<core::int*>*>();
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t61 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t61 = :sync-for-iterator.{core::Iterator::current};
#t60.{core::Set::add}(#t61);
+ }
+ }
#t60.{core::Set::add}(null);
} =>#t60;
core::Map<core::String*, core::List<core::int*>*>* map42 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t62 = <core::String*, core::List<core::int*>*>{};
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t63 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t63 = :sync-for-iterator.{core::Iterator::current};
#t62.{core::Map::[]=}(#t63.{core::MapEntry::key}, #t63.{core::MapEntry::value});
+ }
+ }
#t62.{core::Map::[]=}("baz", null);
} =>#t62;
core::List<core::int*>* list50 = block {
final core::List<core::int*>* #t64 = <core::int*>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::int* #t65 in <core::int*>[])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t65 = :sync-for-iterator.{core::Iterator::current};
#t64.{core::List::add}(#t65);
+ }
+ }
} =>#t64;
core::Set<core::int*>* set50 = block {
final core::Set<core::int*>* #t66 = col::LinkedHashSet::•<core::int*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::int* #t67 in <core::int*>[])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t67 = :sync-for-iterator.{core::Iterator::current};
#t66.{core::Set::add}(#t67);
+ }
+ }
#t66.{core::Set::add}(null);
} =>#t66;
core::Map<core::String*, core::int*>* map50 = block {
final core::Map<core::String*, core::int*>* #t68 = <core::String*, core::int*>{};
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::int*>* #t69 in <core::String*, core::int*>{}.{core::Map::entries})
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(<core::String*, core::int*>{}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t69 = :sync-for-iterator.{core::Iterator::current};
#t68.{core::Map::[]=}(#t69.{core::MapEntry::key}, #t69.{core::MapEntry::value});
+ }
+ }
#t68.{core::Map::[]=}("baz", null);
} =>#t68;
core::List<core::int*>* list51 = block {
final core::List<core::int*>* #t70 = <core::int*>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::int* #t71 in let final core::Set<core::int*>* #t72 = col::LinkedHashSet::•<core::int*>() in #t72)
- #t70.{core::List::add}(#t71);
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(let final core::Set<core::int*>* #t71 = col::LinkedHashSet::•<core::int*>() in #t71).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t72 = :sync-for-iterator.{core::Iterator::current};
+ #t70.{core::List::add}(#t72);
+ }
+ }
} =>#t70;
core::Set<core::int*>* set51 = block {
final core::Set<core::int*>* #t73 = col::LinkedHashSet::•<core::int*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::int* #t74 in let final core::Set<core::int*>* #t75 = col::LinkedHashSet::•<core::int*>() in #t75)
- #t73.{core::Set::add}(#t74);
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(let final core::Set<core::int*>* #t74 = col::LinkedHashSet::•<core::int*>() in #t74).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t75 = :sync-for-iterator.{core::Iterator::current};
+ #t73.{core::Set::add}(#t75);
+ }
+ }
#t73.{core::Set::add}(null);
} =>#t73;
core::List<core::int*>* list52 = block {
final core::List<core::int*>* #t76 = <core::int*>[];
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::int* #t77 in <core::int*>[])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t77 = :sync-for-iterator.{core::Iterator::current};
#t76.{core::List::add}(#t77);
+ }
+ }
} =>#t76;
core::Set<core::int*>* set52 = block {
final core::Set<core::int*>* #t78 = col::LinkedHashSet::•<core::int*>();
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::int* #t79 in <core::int*>[])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t79 = :sync-for-iterator.{core::Iterator::current};
#t78.{core::Set::add}(#t79);
+ }
+ }
#t78.{core::Set::add}(null);
} =>#t78;
core::Map<core::String*, core::int*>* map52 = block {
final core::Map<core::String*, core::int*>* #t80 = <core::String*, core::int*>{};
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::int*>* #t81 in <core::String*, core::int*>{}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(<core::String*, core::int*>{}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t81 = :sync-for-iterator.{core::Iterator::current};
#t80.{core::Map::[]=}(#t81.{core::MapEntry::key}, #t81.{core::MapEntry::value});
+ }
+ }
#t80.{core::Map::[]=}("baz", null);
} =>#t80;
core::List<core::List<core::int*>*>* list60 = block {
final core::List<core::List<core::int*>*>* #t82 = <core::List<core::int*>*>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t83 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t83 = :sync-for-iterator.{core::Iterator::current};
#t82.{core::List::add}(#t83);
+ }
+ }
} =>#t82;
core::Set<core::List<core::int*>*>* set60 = block {
final core::Set<core::List<core::int*>*>* #t84 = col::LinkedHashSet::•<core::List<core::int*>*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t85 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t85 = :sync-for-iterator.{core::Iterator::current};
#t84.{core::Set::add}(#t85);
+ }
+ }
#t84.{core::Set::add}(null);
} =>#t84;
core::Map<core::String*, core::List<core::int*>*>* map60 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t86 = <core::String*, core::List<core::int*>*>{};
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t87 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries})
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t87 = :sync-for-iterator.{core::Iterator::current};
#t86.{core::Map::[]=}(#t87.{core::MapEntry::key}, #t87.{core::MapEntry::value});
+ }
+ }
#t86.{core::Map::[]=}("baz", null);
} =>#t86;
core::List<core::List<core::int*>*>* list61 = block {
final core::List<core::List<core::int*>*>* #t88 = <core::List<core::int*>*>[];
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t89 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t89 = :sync-for-iterator.{core::Iterator::current};
#t88.{core::List::add}(#t89);
+ }
+ }
} =>#t88;
core::Set<core::List<core::int*>*>* set61 = block {
final core::Set<core::List<core::int*>*>* #t90 = col::LinkedHashSet::•<core::List<core::int*>*>();
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t91 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t91 = :sync-for-iterator.{core::Iterator::current};
#t90.{core::Set::add}(#t91);
+ }
+ }
#t90.{core::Set::add}(null);
} =>#t90;
core::Map<core::String*, core::List<core::int*>*>* map61 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t92 = <core::String*, core::List<core::int*>*>{};
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t93 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t93 = :sync-for-iterator.{core::Iterator::current};
#t92.{core::Map::[]=}(#t93.{core::MapEntry::key}, #t93.{core::MapEntry::value});
+ }
+ }
#t92.{core::Map::[]=}("baz", null);
} =>#t92;
core::List<core::List<core::int*>*>* list70 = block {
@@ -822,50 +978,90 @@
} =>#t100;
core::List<core::num*>* list81 = block {
final core::List<core::num*>* #t101 = <core::num*>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::num* #t102 in listInt)
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(listInt).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t102 = :sync-for-iterator.{core::Iterator::current};
#t101.{core::List::add}(#t102);
- else
- for (final core::num* #t103 in listDouble)
+ }
+ }
+ else {
+ core::Iterator<core::double*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::double*>*>(listDouble).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t103 = :sync-for-iterator.{core::Iterator::current};
#t101.{core::List::add}(#t103);
+ }
+ }
} =>#t101;
core::Set<core::num*>* set81 = block {
final core::Set<core::num*>* #t104 = col::LinkedHashSet::•<core::num*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::num* #t105 in listInt)
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(listInt).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t105 = :sync-for-iterator.{core::Iterator::current};
#t104.{core::Set::add}(#t105);
- else
- for (final core::num* #t106 in listDouble)
+ }
+ }
+ else {
+ core::Iterator<core::double*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::double*>*>(listDouble).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t106 = :sync-for-iterator.{core::Iterator::current};
#t104.{core::Set::add}(#t106);
+ }
+ }
#t104.{core::Set::add}(null);
} =>#t104;
core::Map<core::String*, core::num*>* map81 = block {
final core::Map<core::String*, core::num*>* #t107 = <core::String*, core::num*>{};
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::num*>* #t108 in mapToInt.{core::Map::entries})
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(mapToInt.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::num*>* #t108 = :sync-for-iterator.{core::Iterator::current};
#t107.{core::Map::[]=}(#t108.{core::MapEntry::key}, #t108.{core::MapEntry::value});
- else
- for (final core::MapEntry<core::String*, core::num*>* #t109 in mapToDouble.{core::Map::entries})
+ }
+ }
+ else {
+ core::Iterator<core::MapEntry<core::String*, core::double*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::double*>*>*>(mapToDouble.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::num*>* #t109 = :sync-for-iterator.{core::Iterator::current};
#t107.{core::Map::[]=}(#t109.{core::MapEntry::key}, #t109.{core::MapEntry::value});
+ }
+ }
#t107.{core::Map::[]=}("baz", null);
} =>#t107;
core::List<dynamic>* list82 = block {
final core::List<dynamic>* #t110 = <dynamic>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final dynamic #t111 in listInt)
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(listInt).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t111 = :sync-for-iterator.{core::Iterator::current};
#t110.{core::List::add}(#t111);
- else
- for (final dynamic #t112 in dynVar as{TypeError} core::Iterable<dynamic>*)
+ }
+ }
+ else {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t112 = :sync-for-iterator.{core::Iterator::current};
#t110.{core::List::add}(#t112);
+ }
+ }
} =>#t110;
core::Set<dynamic>* set82 = block {
final core::Set<dynamic>* #t113 = col::LinkedHashSet::•<dynamic>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final dynamic #t114 in listInt)
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(listInt).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t114 = :sync-for-iterator.{core::Iterator::current};
#t113.{core::Set::add}(#t114);
- else
- for (final dynamic #t115 in dynVar as{TypeError} core::Iterable<dynamic>*)
+ }
+ }
+ else {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t115 = :sync-for-iterator.{core::Iterator::current};
#t113.{core::Set::add}(#t115);
+ }
+ }
#t113.{core::Set::add}(null);
} =>#t113;
core::Set<dynamic>* map82 = block {
@@ -875,33 +1071,49 @@
- 'Map' is from 'dart:core'.
var map82 = {if (oracle(\"foo\")) ...mapToInt else ...dynVar, null};
^");
- else
- for (final dynamic #t117 in dynVar as{TypeError} core::Iterable<dynamic>*)
+ else {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t117 = :sync-for-iterator.{core::Iterator::current};
#t116.{core::Set::add}(#t117);
+ }
+ }
#t116.{core::Set::add}(null);
} =>#t116;
core::List<core::num*>* list83 = block {
final core::List<core::num*>* #t118 = <core::num*>[];
if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
#t118.{core::List::add}(42);
- else
- for (final core::num* #t119 in listDouble)
+ else {
+ core::Iterator<core::double*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::double*>*>(listDouble).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t119 = :sync-for-iterator.{core::Iterator::current};
#t118.{core::List::add}(#t119);
+ }
+ }
} =>#t118;
core::Set<core::num*>* set83 = block {
final core::Set<core::num*>* #t120 = col::LinkedHashSet::•<core::num*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::num* #t121 in listInt)
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(listInt).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t121 = :sync-for-iterator.{core::Iterator::current};
#t120.{core::Set::add}(#t121);
+ }
+ }
else
#t120.{core::Set::add}(3.14);
#t120.{core::Set::add}(null);
} =>#t120;
core::Map<core::String*, core::num*>* map83 = block {
final core::Map<core::String*, core::num*>* #t122 = <core::String*, core::num*>{};
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::num*>* #t123 in mapToInt.{core::Map::entries})
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(mapToInt.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::num*>* #t123 = :sync-for-iterator.{core::Iterator::current};
#t122.{core::Map::[]=}(#t123.{core::MapEntry::key}, #t123.{core::MapEntry::value});
+ }
+ }
else
#t122.{core::Map::[]=}("bar", 3.14);
#t122.{core::Map::[]=}("baz", null);
@@ -925,29 +1137,44 @@
} =>#t126;
core::List<core::int*>* list91 = block {
final core::List<core::int*>* #t127 = <core::int*>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final dynamic #t128 in dynVar as{TypeError} core::Iterable<dynamic>*) {
- final core::int* #t129 = #t128 as{TypeError} core::int*;
- #t127.{core::List::add}(#t129);
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t128 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::int* #t129 = #t128 as{TypeError} core::int*;
+ #t127.{core::List::add}(#t129);
+ }
}
+ }
} =>#t127;
core::Set<core::int*>* set91 = block {
final core::Set<core::int*>* #t130 = col::LinkedHashSet::•<core::int*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final dynamic #t131 in dynVar as{TypeError} core::Iterable<dynamic>*) {
- final core::int* #t132 = #t131 as{TypeError} core::int*;
- #t130.{core::Set::add}(#t132);
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t131 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::int* #t132 = #t131 as{TypeError} core::int*;
+ #t130.{core::Set::add}(#t132);
+ }
}
+ }
#t130.{core::Set::add}(null);
} =>#t130;
core::Map<core::String*, core::int*>* map91 = block {
final core::Map<core::String*, core::int*>* #t133 = <core::String*, core::int*>{};
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::MapEntry<dynamic, dynamic>* #t134 in (dynVar as{TypeError} core::Map<dynamic, dynamic>*).{core::Map::entries}) {
- final core::String* #t135 = #t134.{core::MapEntry::key} as{TypeError} core::String*;
- final core::int* #t136 = #t134.{core::MapEntry::value} as{TypeError} core::int*;
- #t133.{core::Map::[]=}(#t135, #t136);
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>((dynVar as{TypeError} core::Map<dynamic, dynamic>*).{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t134 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::String* #t135 = #t134.{core::MapEntry::key} as{TypeError} core::String*;
+ final core::int* #t136 = #t134.{core::MapEntry::value} as{TypeError} core::int*;
+ #t133.{core::Map::[]=}(#t135, #t136);
+ }
}
+ }
#t133.{core::Map::[]=}("baz", null);
} =>#t133;
core::List<core::int*>* list100 = block {
@@ -992,28 +1219,40 @@
} =>#t144;
block {
final core::List<core::int*>* #t146 = <core::int*>[];
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::int* #t147 in <core::int*>[let final<BottomType> #t148 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:90:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[let final<BottomType> #t147 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:90:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
<int>[if (oracle(\"foo\")) ...[\"bar\"]];
- ^" in "bar" as{TypeError} core::int*])
- #t146.{core::List::add}(#t147);
+ ^" in "bar" as{TypeError} core::int*]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t148 = :sync-for-iterator.{core::Iterator::current};
+ #t146.{core::List::add}(#t148);
+ }
+ }
} =>#t146;
block {
final core::Set<core::int*>* #t149 = col::LinkedHashSet::•<core::int*>();
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::int* #t150 in <core::int*>[let final<BottomType> #t151 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:91:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[let final<BottomType> #t150 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:91:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
<int>{if (oracle(\"foo\")) ...[\"bar\"], null};
- ^" in "bar" as{TypeError} core::int*])
- #t149.{core::Set::add}(#t150);
+ ^" in "bar" as{TypeError} core::int*]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t151 = :sync-for-iterator.{core::Iterator::current};
+ #t149.{core::Set::add}(#t151);
+ }
+ }
#t149.{core::Set::add}(null);
} =>#t149;
block {
final core::Map<core::String*, core::int*>* #t152 = <core::String*, core::int*>{};
- if(self::oracle<core::String*>("foo") as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::int*>* #t153 in <core::String*, core::int*>{"bar": let final<BottomType> #t154 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:92:47: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ if(self::oracle<core::String*>("foo") as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(<core::String*, core::int*>{"bar": let final<BottomType> #t153 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:92:47: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
<String, int>{if (oracle(\"foo\")) ...{\"bar\": \"bar\"}, \"baz\": null};
- ^" in "bar" as{TypeError} core::int*}.{core::Map::entries})
- #t152.{core::Map::[]=}(#t153.{core::MapEntry::key}, #t153.{core::MapEntry::value});
+ ^" in "bar" as{TypeError} core::int*}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t154 = :sync-for-iterator.{core::Iterator::current};
+ #t152.{core::Map::[]=}(#t154.{core::MapEntry::key}, #t154.{core::MapEntry::value});
+ }
+ }
#t152.{core::Map::[]=}("baz", null);
} =>#t152;
block {
@@ -1269,278 +1508,434 @@
} =>#t196;
core::List<core::int*>* list20 = block {
final core::List<core::int*>* #t197 = <core::int*>[];
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::int* #t198 in <core::int*>[42])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[42]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t198 = :sync-for-iterator.{core::Iterator::current};
#t197.{core::List::add}(#t198);
+ }
+ }
} =>#t197;
core::Set<core::int*>* set20 = block {
final core::Set<core::int*>* #t199 = col::LinkedHashSet::•<core::int*>();
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::int* #t200 in <core::int*>[42])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[42]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t200 = :sync-for-iterator.{core::Iterator::current};
#t199.{core::Set::add}(#t200);
+ }
+ }
#t199.{core::Set::add}(null);
} =>#t199;
core::Map<core::String*, core::int*>* map20 = block {
final core::Map<core::String*, core::int*>* #t201 = <core::String*, core::int*>{};
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::MapEntry<core::String*, core::int*>* #t202 in <core::String*, core::int*>{"bar": 42}.{core::Map::entries})
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(<core::String*, core::int*>{"bar": 42}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t202 = :sync-for-iterator.{core::Iterator::current};
#t201.{core::Map::[]=}(#t202.{core::MapEntry::key}, #t202.{core::MapEntry::value});
+ }
+ }
#t201.{core::Map::[]=}("baz", null);
} =>#t201;
core::List<dynamic>* list21 = block {
final core::List<dynamic>* #t203 = <dynamic>[];
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final dynamic #t204 in <dynamic>[dynVar])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[dynVar]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t204 = :sync-for-iterator.{core::Iterator::current};
#t203.{core::List::add}(#t204);
+ }
+ }
} =>#t203;
core::Set<dynamic>* set21 = block {
final core::Set<dynamic>* #t205 = col::LinkedHashSet::•<dynamic>();
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final dynamic #t206 in <dynamic>[dynVar])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[dynVar]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t206 = :sync-for-iterator.{core::Iterator::current};
#t205.{core::Set::add}(#t206);
+ }
+ }
#t205.{core::Set::add}(null);
} =>#t205;
core::Map<core::String*, dynamic>* map21 = block {
final core::Map<core::String*, dynamic>* #t207 = <core::String*, dynamic>{};
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::MapEntry<core::String*, dynamic>* #t208 in <core::String*, dynamic>{"bar": dynVar}.{core::Map::entries})
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::MapEntry<core::String*, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, dynamic>*>*>(<core::String*, dynamic>{"bar": dynVar}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, dynamic>* #t208 = :sync-for-iterator.{core::Iterator::current};
#t207.{core::Map::[]=}(#t208.{core::MapEntry::key}, #t208.{core::MapEntry::value});
+ }
+ }
#t207.{core::Map::[]=}("baz", null);
} =>#t207;
core::List<core::List<core::int*>*>* list22 = block {
final core::List<core::List<core::int*>*>* #t209 = <core::List<core::int*>*>[];
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::List<core::int*>* #t210 in <core::List<core::int*>*>[<core::int*>[42]])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[42]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t210 = :sync-for-iterator.{core::Iterator::current};
#t209.{core::List::add}(#t210);
+ }
+ }
} =>#t209;
core::Set<core::List<core::int*>*>* set22 = block {
final core::Set<core::List<core::int*>*>* #t211 = col::LinkedHashSet::•<core::List<core::int*>*>();
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::List<core::int*>* #t212 in <core::List<core::int*>*>[<core::int*>[42]])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[42]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t212 = :sync-for-iterator.{core::Iterator::current};
#t211.{core::Set::add}(#t212);
+ }
+ }
#t211.{core::Set::add}(null);
} =>#t211;
core::Map<core::String*, core::List<core::int*>*>* map22 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t213 = <core::String*, core::List<core::int*>*>{};
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t214 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[42]}.{core::Map::entries})
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[42]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t214 = :sync-for-iterator.{core::Iterator::current};
#t213.{core::Map::[]=}(#t214.{core::MapEntry::key}, #t214.{core::MapEntry::value});
+ }
+ }
#t213.{core::Map::[]=}("baz", null);
} =>#t213;
core::List<core::int*>* list30 = block {
final core::List<core::int*>* #t215 = <core::int*>[];
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::int* #t216 in <core::int*>[42])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[42]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t216 = :sync-for-iterator.{core::Iterator::current};
#t215.{core::List::add}(#t216);
+ }
+ }
} =>#t215;
core::Set<core::int*>* set30 = block {
final core::Set<core::int*>* #t217 = col::LinkedHashSet::•<core::int*>();
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::int* #t218 in <core::int*>[42])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[42]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t218 = :sync-for-iterator.{core::Iterator::current};
#t217.{core::Set::add}(#t218);
+ }
+ }
#t217.{core::Set::add}(null);
} =>#t217;
core::Map<core::String*, core::int*>* map30 = block {
final core::Map<core::String*, core::int*>* #t219 = <core::String*, core::int*>{};
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::int*>* #t220 in <core::String*, core::int*>{"bar": 42}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(<core::String*, core::int*>{"bar": 42}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t220 = :sync-for-iterator.{core::Iterator::current};
#t219.{core::Map::[]=}(#t220.{core::MapEntry::key}, #t220.{core::MapEntry::value});
+ }
+ }
#t219.{core::Map::[]=}("baz", null);
} =>#t219;
core::List<dynamic>* list31 = block {
final core::List<dynamic>* #t221 = <dynamic>[];
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final dynamic #t222 in <dynamic>[dynVar])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[dynVar]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t222 = :sync-for-iterator.{core::Iterator::current};
#t221.{core::List::add}(#t222);
+ }
+ }
} =>#t221;
core::Set<dynamic>* set31 = block {
final core::Set<dynamic>* #t223 = col::LinkedHashSet::•<dynamic>();
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final dynamic #t224 in <dynamic>[dynVar])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[dynVar]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t224 = :sync-for-iterator.{core::Iterator::current};
#t223.{core::Set::add}(#t224);
+ }
+ }
#t223.{core::Set::add}(null);
} =>#t223;
core::Map<core::String*, dynamic>* map31 = block {
final core::Map<core::String*, dynamic>* #t225 = <core::String*, dynamic>{};
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, dynamic>* #t226 in <core::String*, dynamic>{"bar": dynVar}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, dynamic>*>*>(<core::String*, dynamic>{"bar": dynVar}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, dynamic>* #t226 = :sync-for-iterator.{core::Iterator::current};
#t225.{core::Map::[]=}(#t226.{core::MapEntry::key}, #t226.{core::MapEntry::value});
+ }
+ }
#t225.{core::Map::[]=}("baz", null);
} =>#t225;
core::List<core::List<core::int*>*>* list33 = block {
final core::List<core::List<core::int*>*>* #t227 = <core::List<core::int*>*>[];
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t228 in <core::List<core::int*>*>[<core::int*>[42]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[42]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t228 = :sync-for-iterator.{core::Iterator::current};
#t227.{core::List::add}(#t228);
+ }
+ }
} =>#t227;
core::Set<core::List<core::int*>*>* set33 = block {
final core::Set<core::List<core::int*>*>* #t229 = col::LinkedHashSet::•<core::List<core::int*>*>();
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t230 in <core::List<core::int*>*>[<core::int*>[42]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[42]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t230 = :sync-for-iterator.{core::Iterator::current};
#t229.{core::Set::add}(#t230);
+ }
+ }
#t229.{core::Set::add}(null);
} =>#t229;
core::Map<core::String*, core::List<core::int*>*>* map33 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t231 = <core::String*, core::List<core::int*>*>{};
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t232 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[42]}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[42]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t232 = :sync-for-iterator.{core::Iterator::current};
#t231.{core::Map::[]=}(#t232.{core::MapEntry::key}, #t232.{core::MapEntry::value});
+ }
+ }
#t231.{core::Map::[]=}("baz", null);
} =>#t231;
core::List<core::List<core::int*>*>* list40 = block {
final core::List<core::List<core::int*>*>* #t233 = <core::List<core::int*>*>[];
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::List<core::int*>* #t234 in <core::List<core::int*>*>[<core::int*>[]])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t234 = :sync-for-iterator.{core::Iterator::current};
#t233.{core::List::add}(#t234);
+ }
+ }
} =>#t233;
core::Set<core::List<core::int*>*>* set40 = block {
final core::Set<core::List<core::int*>*>* #t235 = col::LinkedHashSet::•<core::List<core::int*>*>();
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::List<core::int*>* #t236 in <core::List<core::int*>*>[<core::int*>[]])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t236 = :sync-for-iterator.{core::Iterator::current};
#t235.{core::Set::add}(#t236);
+ }
+ }
#t235.{core::Set::add}(null);
} =>#t235;
core::Map<core::String*, core::List<core::int*>*>* map40 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t237 = <core::String*, core::List<core::int*>*>{};
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t238 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries})
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t238 = :sync-for-iterator.{core::Iterator::current};
#t237.{core::Map::[]=}(#t238.{core::MapEntry::key}, #t238.{core::MapEntry::value});
+ }
+ }
#t237.{core::Map::[]=}("baz", null);
} =>#t237;
core::List<core::List<core::int*>*>* list41 = block {
final core::List<core::List<core::int*>*>* #t239 = <core::List<core::int*>*>[];
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::List<core::int*>* #t240 in let final core::Set<core::List<core::int*>*>* #t241 = col::LinkedHashSet::•<core::List<core::int*>*>() in let final core::bool* #t242 = #t241.{core::Set::add}(<core::int*>[]) in #t241)
- #t239.{core::List::add}(#t240);
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(let final core::Set<core::List<core::int*>*>* #t240 = col::LinkedHashSet::•<core::List<core::int*>*>() in let final core::bool* #t241 = #t240.{core::Set::add}(<core::int*>[]) in #t240).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t242 = :sync-for-iterator.{core::Iterator::current};
+ #t239.{core::List::add}(#t242);
+ }
+ }
} =>#t239;
core::Set<core::List<core::int*>*>* set41 = block {
final core::Set<core::List<core::int*>*>* #t243 = col::LinkedHashSet::•<core::List<core::int*>*>();
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::List<core::int*>* #t244 in let final core::Set<core::List<core::int*>*>* #t245 = col::LinkedHashSet::•<core::List<core::int*>*>() in let final core::bool* #t246 = #t245.{core::Set::add}(<core::int*>[]) in #t245)
- #t243.{core::Set::add}(#t244);
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(let final core::Set<core::List<core::int*>*>* #t244 = col::LinkedHashSet::•<core::List<core::int*>*>() in let final core::bool* #t245 = #t244.{core::Set::add}(<core::int*>[]) in #t244).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t246 = :sync-for-iterator.{core::Iterator::current};
+ #t243.{core::Set::add}(#t246);
+ }
+ }
#t243.{core::Set::add}(null);
} =>#t243;
core::List<core::List<core::int*>*>* list42 = block {
final core::List<core::List<core::int*>*>* #t247 = <core::List<core::int*>*>[];
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t248 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t248 = :sync-for-iterator.{core::Iterator::current};
#t247.{core::List::add}(#t248);
+ }
+ }
} =>#t247;
core::Set<core::List<core::int*>*>* set42 = block {
final core::Set<core::List<core::int*>*>* #t249 = col::LinkedHashSet::•<core::List<core::int*>*>();
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t250 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t250 = :sync-for-iterator.{core::Iterator::current};
#t249.{core::Set::add}(#t250);
+ }
+ }
#t249.{core::Set::add}(null);
} =>#t249;
core::Map<core::String*, core::List<core::int*>*>* map42 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t251 = <core::String*, core::List<core::int*>*>{};
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t252 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t252 = :sync-for-iterator.{core::Iterator::current};
#t251.{core::Map::[]=}(#t252.{core::MapEntry::key}, #t252.{core::MapEntry::value});
+ }
+ }
#t251.{core::Map::[]=}("baz", null);
} =>#t251;
core::List<core::int*>* list50 = block {
final core::List<core::int*>* #t253 = <core::int*>[];
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::int* #t254 in <core::int*>[])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t254 = :sync-for-iterator.{core::Iterator::current};
#t253.{core::List::add}(#t254);
+ }
+ }
} =>#t253;
core::Set<core::int*>* set50 = block {
final core::Set<core::int*>* #t255 = col::LinkedHashSet::•<core::int*>();
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::int* #t256 in <core::int*>[])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t256 = :sync-for-iterator.{core::Iterator::current};
#t255.{core::Set::add}(#t256);
+ }
+ }
#t255.{core::Set::add}(null);
} =>#t255;
core::Map<core::String*, core::int*>* map50 = block {
final core::Map<core::String*, core::int*>* #t257 = <core::String*, core::int*>{};
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::MapEntry<core::String*, core::int*>* #t258 in <core::String*, core::int*>{}.{core::Map::entries})
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(<core::String*, core::int*>{}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t258 = :sync-for-iterator.{core::Iterator::current};
#t257.{core::Map::[]=}(#t258.{core::MapEntry::key}, #t258.{core::MapEntry::value});
+ }
+ }
#t257.{core::Map::[]=}("baz", null);
} =>#t257;
core::List<core::int*>* list51 = block {
final core::List<core::int*>* #t259 = <core::int*>[];
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::int* #t260 in let final core::Set<core::int*>* #t261 = col::LinkedHashSet::•<core::int*>() in #t261)
- #t259.{core::List::add}(#t260);
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(let final core::Set<core::int*>* #t260 = col::LinkedHashSet::•<core::int*>() in #t260).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t261 = :sync-for-iterator.{core::Iterator::current};
+ #t259.{core::List::add}(#t261);
+ }
+ }
} =>#t259;
core::Set<core::int*>* set51 = block {
final core::Set<core::int*>* #t262 = col::LinkedHashSet::•<core::int*>();
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::int* #t263 in let final core::Set<core::int*>* #t264 = col::LinkedHashSet::•<core::int*>() in #t264)
- #t262.{core::Set::add}(#t263);
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(let final core::Set<core::int*>* #t263 = col::LinkedHashSet::•<core::int*>() in #t263).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t264 = :sync-for-iterator.{core::Iterator::current};
+ #t262.{core::Set::add}(#t264);
+ }
+ }
#t262.{core::Set::add}(null);
} =>#t262;
core::List<core::int*>* list52 = block {
final core::List<core::int*>* #t265 = <core::int*>[];
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::int* #t266 in <core::int*>[])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t266 = :sync-for-iterator.{core::Iterator::current};
#t265.{core::List::add}(#t266);
+ }
+ }
} =>#t265;
core::Set<core::int*>* set52 = block {
final core::Set<core::int*>* #t267 = col::LinkedHashSet::•<core::int*>();
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::int* #t268 in <core::int*>[])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t268 = :sync-for-iterator.{core::Iterator::current};
#t267.{core::Set::add}(#t268);
+ }
+ }
#t267.{core::Set::add}(null);
} =>#t267;
core::List<core::List<core::int*>*>* list60 = block {
final core::List<core::List<core::int*>*>* #t269 = <core::List<core::int*>*>[];
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::List<core::int*>* #t270 in <core::List<core::int*>*>[<core::int*>[]])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t270 = :sync-for-iterator.{core::Iterator::current};
#t269.{core::List::add}(#t270);
+ }
+ }
} =>#t269;
core::Set<core::List<core::int*>*>* set60 = block {
final core::Set<core::List<core::int*>*>* #t271 = col::LinkedHashSet::•<core::List<core::int*>*>();
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::List<core::int*>* #t272 in <core::List<core::int*>*>[<core::int*>[]])
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t272 = :sync-for-iterator.{core::Iterator::current};
#t271.{core::Set::add}(#t272);
+ }
+ }
#t271.{core::Set::add}(null);
} =>#t271;
core::Map<core::String*, core::List<core::int*>*>* map60 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t273 = <core::String*, core::List<core::int*>*>{};
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t274 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries})
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t274 = :sync-for-iterator.{core::Iterator::current};
#t273.{core::Map::[]=}(#t274.{core::MapEntry::key}, #t274.{core::MapEntry::value});
+ }
+ }
#t273.{core::Map::[]=}("baz", null);
} =>#t273;
core::List<core::List<core::int*>*>* list61 = block {
final core::List<core::List<core::int*>*>* #t275 = <core::List<core::int*>*>[];
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t276 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t276 = :sync-for-iterator.{core::Iterator::current};
#t275.{core::List::add}(#t276);
+ }
+ }
} =>#t275;
core::Set<core::List<core::int*>*>* set61 = block {
final core::Set<core::List<core::int*>*>* #t277 = col::LinkedHashSet::•<core::List<core::int*>*>();
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::List<core::int*>* #t278 in <core::List<core::int*>*>[<core::int*>[]])
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t278 = :sync-for-iterator.{core::Iterator::current};
#t277.{core::Set::add}(#t278);
+ }
+ }
#t277.{core::Set::add}(null);
} =>#t277;
core::Map<core::String*, core::List<core::int*>*>* map61 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t279 = <core::String*, core::List<core::int*>*>{};
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t280 in <core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"bar": <core::int*>[]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t280 = :sync-for-iterator.{core::Iterator::current};
#t279.{core::Map::[]=}(#t280.{core::MapEntry::key}, #t280.{core::MapEntry::value});
+ }
+ }
#t279.{core::Map::[]=}("baz", null);
} =>#t279;
core::List<core::List<core::int*>*>* list70 = block {
@@ -1609,65 +2004,113 @@
core::List<core::num*>* list81 = block {
final core::List<core::num*>* #t290 = <core::num*>[];
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::num* #t291 in listInt)
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(listInt).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t291 = :sync-for-iterator.{core::Iterator::current};
#t290.{core::List::add}(#t291);
- else
- for (final core::num* #t292 in listDouble)
+ }
+ }
+ else {
+ core::Iterator<core::double*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::double*>*>(listDouble).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t292 = :sync-for-iterator.{core::Iterator::current};
#t290.{core::List::add}(#t292);
+ }
+ }
} =>#t290;
core::Set<core::num*>* set81 = block {
final core::Set<core::num*>* #t293 = col::LinkedHashSet::•<core::num*>();
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::num* #t294 in listInt)
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(listInt).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t294 = :sync-for-iterator.{core::Iterator::current};
#t293.{core::Set::add}(#t294);
- else
- for (final core::num* #t295 in listDouble)
+ }
+ }
+ else {
+ core::Iterator<core::double*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::double*>*>(listDouble).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t295 = :sync-for-iterator.{core::Iterator::current};
#t293.{core::Set::add}(#t295);
+ }
+ }
#t293.{core::Set::add}(null);
} =>#t293;
core::Map<core::String*, core::num*>* map81 = block {
final core::Map<core::String*, core::num*>* #t296 = <core::String*, core::num*>{};
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::num*>* #t297 in mapStringInt.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(mapStringInt.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::num*>* #t297 = :sync-for-iterator.{core::Iterator::current};
#t296.{core::Map::[]=}(#t297.{core::MapEntry::key}, #t297.{core::MapEntry::value});
- else
- for (final core::MapEntry<core::String*, core::num*>* #t298 in mapStringDouble.{core::Map::entries})
+ }
+ }
+ else {
+ core::Iterator<core::MapEntry<core::String*, core::double*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::double*>*>*>(mapStringDouble.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::num*>* #t298 = :sync-for-iterator.{core::Iterator::current};
#t296.{core::Map::[]=}(#t298.{core::MapEntry::key}, #t298.{core::MapEntry::value});
+ }
+ }
#t296.{core::Map::[]=}("baz", null);
} =>#t296;
core::List<dynamic>* list82 = block {
final core::List<dynamic>* #t299 = <dynamic>[];
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final dynamic #t300 in listInt)
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(listInt).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t300 = :sync-for-iterator.{core::Iterator::current};
#t299.{core::List::add}(#t300);
- else
- for (final dynamic #t301 in dynVar as{TypeError} core::Iterable<dynamic>*)
+ }
+ }
+ else {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t301 = :sync-for-iterator.{core::Iterator::current};
#t299.{core::List::add}(#t301);
+ }
+ }
} =>#t299;
core::Set<dynamic>* set82 = block {
final core::Set<dynamic>* #t302 = col::LinkedHashSet::•<dynamic>();
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final dynamic #t303 in listInt)
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(listInt).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t303 = :sync-for-iterator.{core::Iterator::current};
#t302.{core::Set::add}(#t303);
- else
- for (final dynamic #t304 in dynVar as{TypeError} core::Iterable<dynamic>*)
+ }
+ }
+ else {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t304 = :sync-for-iterator.{core::Iterator::current};
#t302.{core::Set::add}(#t304);
+ }
+ }
#t302.{core::Set::add}(null);
} =>#t302;
core::Map<dynamic, dynamic>* map82 = block {
final core::Map<dynamic, dynamic>* #t305 = <dynamic, dynamic>{};
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<dynamic, dynamic>* #t306 in mapStringInt.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(mapStringInt.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t306 = :sync-for-iterator.{core::Iterator::current};
#t305.{core::Map::[]=}(#t306.{core::MapEntry::key}, #t306.{core::MapEntry::value});
- else
- for (final core::MapEntry<dynamic, dynamic>* #t307 in (dynVar as{TypeError} core::Map<dynamic, dynamic>*).{core::Map::entries})
+ }
+ }
+ else {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>((dynVar as{TypeError} core::Map<dynamic, dynamic>*).{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t307 = :sync-for-iterator.{core::Iterator::current};
#t305.{core::Map::[]=}(#t307.{core::MapEntry::key}, #t307.{core::MapEntry::value});
+ }
+ }
#t305.{core::Map::[]=}("baz", null);
} =>#t305;
core::List<core::num*>* list83 = block {
@@ -1675,16 +2118,24 @@
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
if(self::oracle<dynamic>() as{TypeError} core::bool*)
#t308.{core::List::add}(42);
- else
- for (final core::num* #t309 in listDouble)
+ else {
+ core::Iterator<core::double*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::double*>*>(listDouble).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t309 = :sync-for-iterator.{core::Iterator::current};
#t308.{core::List::add}(#t309);
+ }
+ }
} =>#t308;
core::Set<core::num*>* set83 = block {
final core::Set<core::num*>* #t310 = col::LinkedHashSet::•<core::num*>();
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::num* #t311 in listInt)
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(listInt).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::num* #t311 = :sync-for-iterator.{core::Iterator::current};
#t310.{core::Set::add}(#t311);
+ }
+ }
else
#t310.{core::Set::add}(3.14);
#t310.{core::Set::add}(null);
@@ -1692,9 +2143,13 @@
core::Map<core::String*, core::num*>* map83 = block {
final core::Map<core::String*, core::num*>* #t312 = <core::String*, core::num*>{};
for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- if(self::oracle<dynamic>() as{TypeError} core::bool*)
- for (final core::MapEntry<core::String*, core::num*>* #t313 in mapStringInt.{core::Map::entries})
+ if(self::oracle<dynamic>() as{TypeError} core::bool*) {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(mapStringInt.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::num*>* #t313 = :sync-for-iterator.{core::Iterator::current};
#t312.{core::Map::[]=}(#t313.{core::MapEntry::key}, #t313.{core::MapEntry::value});
+ }
+ }
else
#t312.{core::Map::[]=}("bar", 3.14);
#t312.{core::Map::[]=}("baz", null);
@@ -1718,29 +2173,44 @@
} =>#t316;
core::List<core::int*>* list91 = block {
final core::List<core::int*>* #t317 = <core::int*>[];
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final dynamic #t318 in dynVar as{TypeError} core::Iterable<dynamic>*) {
- final core::int* #t319 = #t318 as{TypeError} core::int*;
- #t317.{core::List::add}(#t319);
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t318 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::int* #t319 = #t318 as{TypeError} core::int*;
+ #t317.{core::List::add}(#t319);
+ }
}
+ }
} =>#t317;
core::Set<core::int*>* set91 = block {
final core::Set<core::int*>* #t320 = col::LinkedHashSet::•<core::int*>();
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final dynamic #t321 in dynVar as{TypeError} core::Iterable<dynamic>*) {
- final core::int* #t322 = #t321 as{TypeError} core::int*;
- #t320.{core::Set::add}(#t322);
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t321 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::int* #t322 = #t321 as{TypeError} core::int*;
+ #t320.{core::Set::add}(#t322);
+ }
}
+ }
#t320.{core::Set::add}(null);
} =>#t320;
core::Map<core::String*, core::int*>* map91 = block {
final core::Map<core::String*, core::int*>* #t323 = <core::String*, core::int*>{};
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::MapEntry<dynamic, dynamic>* #t324 in (dynVar as{TypeError} core::Map<dynamic, dynamic>*).{core::Map::entries}) {
- final core::String* #t325 = #t324.{core::MapEntry::key} as{TypeError} core::String*;
- final core::int* #t326 = #t324.{core::MapEntry::value} as{TypeError} core::int*;
- #t323.{core::Map::[]=}(#t325, #t326);
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>((dynVar as{TypeError} core::Map<dynamic, dynamic>*).{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t324 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::String* #t325 = #t324.{core::MapEntry::key} as{TypeError} core::String*;
+ final core::int* #t326 = #t324.{core::MapEntry::value} as{TypeError} core::int*;
+ #t323.{core::Map::[]=}(#t325, #t326);
+ }
}
+ }
#t323.{core::Map::[]=}("baz", null);
} =>#t323;
core::List<core::int*>* list100 = block {
@@ -1760,36 +2230,66 @@
} =>#t331;
core::List<core::int*>* list110 = block {
final core::List<core::int*>* #t333 = <core::int*>[];
- for (core::int* i in <core::int*>[1, 2, 3])
- #t333.{core::List::add}(i);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[1, 2, 3]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
+ #t333.{core::List::add}(i);
+ }
+ }
} =>#t333;
core::Set<core::int*>* set110 = block {
final core::Set<core::int*>* #t334 = col::LinkedHashSet::•<core::int*>();
- for (core::int* i in <core::int*>[1, 2, 3])
- #t334.{core::Set::add}(i);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[1, 2, 3]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
+ #t334.{core::Set::add}(i);
+ }
+ }
#t334.{core::Set::add}(null);
} =>#t334;
core::Map<core::String*, core::int*>* map110 = block {
final core::Map<core::String*, core::int*>* #t335 = <core::String*, core::int*>{};
- for (core::int* i in <core::int*>[1, 2, 3])
- #t335.{core::Map::[]=}("bar", i);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[1, 2, 3]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
+ #t335.{core::Map::[]=}("bar", i);
+ }
+ }
#t335.{core::Map::[]=}("baz", null);
} =>#t335;
core::List<core::int*>* list120 = block {
final core::List<core::int*>* #t336 = <core::int*>[];
- for (dynamic i in dynVar as{TypeError} core::Iterable<dynamic>*)
- #t336.{core::List::add}(i as{TypeError} core::int*);
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic i = :sync-for-iterator.{core::Iterator::current};
+ #t336.{core::List::add}(i as{TypeError} core::int*);
+ }
+ }
} =>#t336;
core::Set<core::int*>* set120 = block {
final core::Set<core::int*>* #t337 = col::LinkedHashSet::•<core::int*>();
- for (dynamic i in dynVar as{TypeError} core::Iterable<dynamic>*)
- #t337.{core::Set::add}(i as{TypeError} core::int*);
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic i = :sync-for-iterator.{core::Iterator::current};
+ #t337.{core::Set::add}(i as{TypeError} core::int*);
+ }
+ }
#t337.{core::Set::add}(null);
} =>#t337;
core::Map<core::String*, core::int*>* map120 = block {
final core::Map<core::String*, core::int*>* #t338 = <core::String*, core::int*>{};
- for (dynamic i in dynVar as{TypeError} core::Iterable<dynamic>*)
- #t338.{core::Map::[]=}("bar", i as{TypeError} core::int*);
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic i = :sync-for-iterator.{core::Iterator::current};
+ #t338.{core::Map::[]=}("bar", i as{TypeError} core::int*);
+ }
+ }
#t338.{core::Map::[]=}("baz", null);
} =>#t338;
core::List<core::int*>* list130 = block {
@@ -1853,30 +2353,42 @@
} =>#t346;
block {
final core::List<core::int*>* #t350 = <core::int*>[];
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::int* #t351 in <core::int*>[let final<BottomType> #t352 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:213:49: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[let final<BottomType> #t351 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:213:49: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
<int>[for (int i = 0; oracle(\"foo\"); i++) ...[\"bar\"]];
- ^" in "bar" as{TypeError} core::int*])
- #t350.{core::List::add}(#t351);
+ ^" in "bar" as{TypeError} core::int*]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t352 = :sync-for-iterator.{core::Iterator::current};
+ #t350.{core::List::add}(#t352);
+ }
+ }
} =>#t350;
block {
final core::Set<core::int*>* #t353 = col::LinkedHashSet::•<core::int*>();
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::int* #t354 in <core::int*>[let final<BottomType> #t355 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:214:49: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[let final<BottomType> #t354 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:214:49: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
<int>{for (int i = 0; oracle(\"foo\"); i++) ...[\"bar\"], null};
- ^" in "bar" as{TypeError} core::int*])
- #t353.{core::Set::add}(#t354);
+ ^" in "bar" as{TypeError} core::int*]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t355 = :sync-for-iterator.{core::Iterator::current};
+ #t353.{core::Set::add}(#t355);
+ }
+ }
#t353.{core::Set::add}(null);
} =>#t353;
block {
final core::Map<core::int*, core::int*>* #t356 = <core::int*, core::int*>{};
- for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1))
- for (final core::MapEntry<core::int*, core::int*>* #t357 in <core::int*, core::int*>{let final<BottomType> #t358 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:215:54: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ for (core::int* i = 0; self::oracle<core::String*>("foo") as{TypeError} core::bool*; i = i.{core::num::+}(1)) {
+ core::Iterator<core::MapEntry<core::int*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::int*, core::int*>*>*>(<core::int*, core::int*>{let final<BottomType> #t357 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:215:54: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
<int, int>{for (int i = 0; oracle(\"foo\"); i++) ...{\"bar\": \"bar\"}, \"baz\": null};
- ^" in "bar" as{TypeError} core::int*: let final<BottomType> #t359 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:215:61: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ ^" in "bar" as{TypeError} core::int*: let final<BottomType> #t358 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:215:61: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
<int, int>{for (int i = 0; oracle(\"foo\"); i++) ...{\"bar\": \"bar\"}, \"baz\": null};
- ^" in "bar" as{TypeError} core::int*}.{core::Map::entries})
- #t356.{core::Map::[]=}(#t357.{core::MapEntry::key}, #t357.{core::MapEntry::value});
+ ^" in "bar" as{TypeError} core::int*}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::int*, core::int*>* #t359 = :sync-for-iterator.{core::Iterator::current};
+ #t356.{core::Map::[]=}(#t359.{core::MapEntry::key}, #t359.{core::MapEntry::value});
+ }
+ }
#t356.{core::Map::[]=}(let final<BottomType> #t360 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:215:69: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
<int, int>{for (int i = 0; oracle(\"foo\"); i++) ...{\"bar\": \"bar\"}, \"baz\": null};
^" in "baz" as{TypeError} core::int*, null);
@@ -2006,86 +2518,134 @@
final core::int* i = 0;
block {
final core::List<core::int*>* #t376 = <core::int*>[];
- for (final core::int* #t377 in <core::int*>[1]) {
- invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:230:14: Error: Setter not found: 'i'.
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[1]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t377 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:230:14: Error: Setter not found: 'i'.
<int>[for (i in <int>[1]) i];
^";
- #t376.{core::List::add}(i);
+ #t376.{core::List::add}(i);
+ }
+ }
}
} =>#t376;
block {
final core::Set<core::int*>* #t378 = col::LinkedHashSet::•<core::int*>();
- for (final core::int* #t379 in <core::int*>[1]) {
- invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:231:14: Error: Setter not found: 'i'.
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[1]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t379 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:231:14: Error: Setter not found: 'i'.
<int>{for (i in <int>[1]) i, null};
^";
- #t378.{core::Set::add}(i);
+ #t378.{core::Set::add}(i);
+ }
+ }
}
#t378.{core::Set::add}(null);
} =>#t378;
block {
final core::Map<core::String*, core::int*>* #t380 = <core::String*, core::int*>{};
- for (final core::int* #t381 in <core::int*>[1]) {
- invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:232:21: Error: Setter not found: 'i'.
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[1]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t381 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:232:21: Error: Setter not found: 'i'.
\t<String, int>{for (i in <int>[1]) \"bar\": i, \"baz\": null};
\t ^";
- #t380.{core::Map::[]=}("bar", i);
+ #t380.{core::Map::[]=}("bar", i);
+ }
+ }
}
#t380.{core::Map::[]=}("baz", null);
} =>#t380;
core::List<dynamic>* list10 = block {
final core::List<dynamic>* #t382 = <dynamic>[];
- for (dynamic i in let final<BottomType> #t383 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:234:31: Error: The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(let final<BottomType> #t383 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:234:31: Error: The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
- 'Iterable' is from 'dart:core'.
var list10 = [for (var i in \"not iterable\") i];
- ^" in "not iterable" as{TypeError} core::Iterable<dynamic>*)
- #t382.{core::List::add}(i);
+ ^" in "not iterable" as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic i = :sync-for-iterator.{core::Iterator::current};
+ #t382.{core::List::add}(i);
+ }
+ }
} =>#t382;
core::Set<dynamic>* set10 = block {
final core::Set<dynamic>* #t384 = col::LinkedHashSet::•<dynamic>();
- for (dynamic i in let final<BottomType> #t385 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:235:30: Error: The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(let final<BottomType> #t385 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:235:30: Error: The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
- 'Iterable' is from 'dart:core'.
var set10 = {for (var i in \"not iterable\") i, null};
- ^" in "not iterable" as{TypeError} core::Iterable<dynamic>*)
- #t384.{core::Set::add}(i);
+ ^" in "not iterable" as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic i = :sync-for-iterator.{core::Iterator::current};
+ #t384.{core::Set::add}(i);
+ }
+ }
#t384.{core::Set::add}(null);
} =>#t384;
core::Map<core::String*, dynamic>* map10 = block {
final core::Map<core::String*, dynamic>* #t386 = <core::String*, dynamic>{};
- for (dynamic i in let final<BottomType> #t387 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:236:30: Error: The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(let final<BottomType> #t387 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:236:30: Error: The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
- 'Iterable' is from 'dart:core'.
var map10 = {for (var i in \"not iterable\") \"bar\": i, \"baz\": null};
- ^" in "not iterable" as{TypeError} core::Iterable<dynamic>*)
- #t386.{core::Map::[]=}("bar", i);
+ ^" in "not iterable" as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic i = :sync-for-iterator.{core::Iterator::current};
+ #t386.{core::Map::[]=}("bar", i);
+ }
+ }
#t386.{core::Map::[]=}("baz", null);
} =>#t386;
core::List<core::int*>* list20 = block {
final core::List<core::int*>* #t388 = <core::int*>[];
- for (core::int* i in <core::int*>[let final<BottomType> #t389 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:237:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[let final<BottomType> #t389 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:237:32: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
var list20 = [for (int i in [\"not\", \"int\"]) i];
^" in "not" as{TypeError} core::int*, let final<BottomType> #t390 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:237:39: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
var list20 = [for (int i in [\"not\", \"int\"]) i];
- ^" in "int" as{TypeError} core::int*])
- #t388.{core::List::add}(i);
+ ^" in "int" as{TypeError} core::int*]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
+ #t388.{core::List::add}(i);
+ }
+ }
} =>#t388;
core::Set<core::int*>* set20 = block {
final core::Set<core::int*>* #t391 = col::LinkedHashSet::•<core::int*>();
- for (core::int* i in <core::int*>[let final<BottomType> #t392 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:238:31: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[let final<BottomType> #t392 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:238:31: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
var set20 = {for (int i in [\"not\", \"int\"]) i, null};
^" in "not" as{TypeError} core::int*, let final<BottomType> #t393 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:238:38: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
var set20 = {for (int i in [\"not\", \"int\"]) i, null};
- ^" in "int" as{TypeError} core::int*])
- #t391.{core::Set::add}(i);
+ ^" in "int" as{TypeError} core::int*]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
+ #t391.{core::Set::add}(i);
+ }
+ }
#t391.{core::Set::add}(null);
} =>#t391;
core::Map<core::String*, core::int*>* map20 = block {
final core::Map<core::String*, core::int*>* #t394 = <core::String*, core::int*>{};
- for (core::int* i in <core::int*>[let final<BottomType> #t395 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:239:31: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[let final<BottomType> #t395 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:239:31: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
var map20 = {for (int i in [\"not\", \"int\"]) \"bar\": i, \"baz\": null};
^" in "not" as{TypeError} core::int*, let final<BottomType> #t396 = invalid-expression "pkg/front_end/testcases/general/control_flow_collection_inference.dart:239:38: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
var map20 = {for (int i in [\"not\", \"int\"]) \"bar\": i, \"baz\": null};
- ^" in "int" as{TypeError} core::int*])
- #t394.{core::Map::[]=}("bar", i);
+ ^" in "int" as{TypeError} core::int*]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
+ #t394.{core::Map::[]=}("bar", i);
+ }
+ }
#t394.{core::Map::[]=}("baz", null);
} =>#t394;
final core::List<dynamic>* #t397 = <dynamic>[];
diff --git a/pkg/front_end/testcases/general/for_in_scope.dart.strong.transformed.expect b/pkg/front_end/testcases/general/for_in_scope.dart.strong.transformed.expect
index 78f359e..cb9a540 100644
--- a/pkg/front_end/testcases/general/for_in_scope.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/for_in_scope.dart.strong.transformed.expect
@@ -1,9 +1,16 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method main(core::List<core::String*>* arguments) → dynamic {
- for (core::String* arguments in arguments) {
- core::print(arguments);
+ {
+ core::Iterator<core::String*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::String*>*>(arguments).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::String* arguments = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::print(arguments);
+ }
+ }
}
}
diff --git a/pkg/front_end/testcases/general/for_in_without_declaration.dart.strong.transformed.expect b/pkg/front_end/testcases/general/for_in_without_declaration.dart.strong.transformed.expect
index 6916586..0571257 100644
--- a/pkg/front_end/testcases/general/for_in_without_declaration.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/for_in_without_declaration.dart.strong.transformed.expect
@@ -66,6 +66,7 @@
//
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Super extends core::Object {
field core::int* superInstanceField = null;
@@ -85,93 +86,201 @@
method m() → dynamic {
core::String* local;
dynamic untypedLocal;
- for (final core::String* #t1 in <core::String*>[]) {
- local = #t1;
+ {
+ core::Iterator<core::String*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::String*>*>(<core::String*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::String* #t1 = :sync-for-iterator.{core::Iterator::current};
+ {
+ local = #t1;
+ }
+ }
}
- for (final dynamic #t2 in <dynamic>[]) {
- untypedLocal = #t2;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t2 = :sync-for-iterator.{core::Iterator::current};
+ {
+ untypedLocal = #t2;
+ }
+ }
}
- for (final core::int* #t3 in <core::int*>[]) {
- this.{self::C::instanceField} = #t3;
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t3 = :sync-for-iterator.{core::Iterator::current};
+ {
+ this.{self::C::instanceField} = #t3;
+ }
+ }
}
- for (final dynamic #t4 in <dynamic>[]) {
- this.{self::C::untypedInstanceField} = #t4;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t4 = :sync-for-iterator.{core::Iterator::current};
+ {
+ this.{self::C::untypedInstanceField} = #t4;
+ }
+ }
}
- for (final core::double* #t5 in <core::double*>[]) {
- self::C::staticField = #t5;
+ {
+ core::Iterator<core::double*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::double*>*>(<core::double*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::double* #t5 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::C::staticField = #t5;
+ }
+ }
}
- for (final dynamic #t6 in <dynamic>[]) {
- self::C::untypedStaticField = #t6;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t6 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::C::untypedStaticField = #t6;
+ }
+ }
}
- for (final core::bool* #t7 in <core::bool*>[]) {
- self::topLevelField = #t7;
+ {
+ core::Iterator<core::bool*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::bool*>*>(<core::bool*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::bool* #t7 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::topLevelField = #t7;
+ }
+ }
}
- for (final dynamic #t8 in <dynamic>[]) {
- self::untypedTopLevelField = #t8;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t8 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::untypedTopLevelField = #t8;
+ }
+ }
}
- for (final core::int* #t9 in <core::int*>[]) {
- super.{self::Super::superInstanceField} = #t9;
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t9 = :sync-for-iterator.{core::Iterator::current};
+ {
+ super.{self::Super::superInstanceField} = #t9;
+ }
+ }
}
- for (final dynamic #t10 in <dynamic>[]) {
- super.{self::Super::untypedSuperInstanceField} = #t10;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t10 = :sync-for-iterator.{core::Iterator::current};
+ {
+ super.{self::Super::untypedSuperInstanceField} = #t10;
+ }
+ }
}
self::C* c = new self::C::•();
- for (final core::int* #t11 in <core::int*>[]) {
- c.{self::C::instanceField} = #t11;
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t11 = :sync-for-iterator.{core::Iterator::current};
+ {
+ c.{self::C::instanceField} = #t11;
+ }
+ }
}
- for (final dynamic #t12 in <dynamic>[]) {
- c.{self::Super::untypedSuperInstanceField} = #t12;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t12 = :sync-for-iterator.{core::Iterator::current};
+ {
+ c.{self::Super::untypedSuperInstanceField} = #t12;
+ }
+ }
}
- for (final dynamic #t13 in <dynamic>[]) {
- invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:37:10: Error: The setter 'unresolved' isn't defined for the class 'C'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t13 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:37:10: Error: The setter 'unresolved' isn't defined for the class 'C'.
- 'C' is from 'pkg/front_end/testcases/general/for_in_without_declaration.dart'.
Try correcting the name to the name of an existing setter, or defining a setter or field named 'unresolved'.
for (unresolved in []) {}
^^^^^^^^^^";
+ }
+ }
}
- for (final dynamic #t14 in <dynamic>[]) {
- invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:38:10: Error: The getter 'unresolved' isn't defined for the class 'C'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t14 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:38:10: Error: The getter 'unresolved' isn't defined for the class 'C'.
- 'C' is from 'pkg/front_end/testcases/general/for_in_without_declaration.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'unresolved'.
for (unresolved.foo in []) {}
^^^^^^^^^^".foo = #t14;
+ }
+ }
}
- for (final dynamic #t15 in <dynamic>[]) {
- invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:39:12: Error: The setter 'unresolved' isn't defined for the class 'C'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t15 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:39:12: Error: The setter 'unresolved' isn't defined for the class 'C'.
- 'C' is from 'pkg/front_end/testcases/general/for_in_without_declaration.dart'.
Try correcting the name to the name of an existing setter, or defining a setter or field named 'unresolved'.
for (c.unresolved in []) {}
^^^^^^^^^^";
+ }
+ }
}
{
invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:40:10: Error: Can't assign to this, so it can't be used in a for-in loop.
for (main() in []) {}
^^^^";
- for (final dynamic #t16 in <dynamic>[]) {
- invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:40:10: Error: Can't assign to this, so it can't be used in a for-in loop.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t16 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:40:10: Error: Can't assign to this, so it can't be used in a for-in loop.
for (main() in []) {}
^^^^";
- self::main();
+ self::main();
+ }
+ }
}
}
{
invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:41:10: Error: A for-in loop can't have more than one loop variable.
for (var x, y in <int>[]) {
^^^";
- for (final core::int* #t17 in <core::int*>[]) {
- invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:41:10: Error: A for-in loop can't have more than one loop variable.
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t17 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:41:10: Error: A for-in loop can't have more than one loop variable.
for (var x, y in <int>[]) {
^^^";
- dynamic x;
- dynamic y;
- core::print(x);
- core::print(y);
+ dynamic x;
+ dynamic y;
+ core::print(x);
+ core::print(y);
+ }
+ }
}
}
- for (final dynamic #t18 in <dynamic>[]) {
- invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:46:10: Error: Setter not found: 'constant'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t18 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/general/for_in_without_declaration.dart:46:10: Error: Setter not found: 'constant'.
for (constant in []) {}
^^^^^^^^";
+ }
+ }
}
}
}
diff --git a/pkg/front_end/testcases/general/issue37027.dart.strong.transformed.expect b/pkg/front_end/testcases/general/issue37027.dart.strong.transformed.expect
index 4789444..606d3a0 100644
--- a/pkg/front_end/testcases/general/issue37027.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/issue37027.dart.strong.transformed.expect
@@ -2,15 +2,21 @@
import self as self;
import "dart:core" as core;
import "dart:collection" as col;
+import "dart:_internal" as _in;
class C extends core::Object {
final field core::Set<core::int*>* s;
constructor •(core::List<core::int*>* ell) → self::C*
: self::C::s = block {
final core::Set<core::int*>* #t1 = col::LinkedHashSet::•<core::int*>();
- for (core::int* e in ell)
- if(e.{core::int::isOdd})
- #t1.{core::Set::add}(2.{core::num::*}(e));
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(ell).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* e = :sync-for-iterator.{core::Iterator::current};
+ if(e.{core::int::isOdd})
+ #t1.{core::Set::add}(2.{core::num::*}(e));
+ }
+ }
} =>#t1, super core::Object::•()
;
}
diff --git a/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart b/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart
new file mode 100644
index 0000000..6ed8c68
--- /dev/null
+++ b/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart
@@ -0,0 +1,20 @@
+// Copyright (c) 2019, 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.
+
+class Mixin {}
+
+class Super {
+ var field = 42;
+
+ Super(this.field);
+}
+
+class Class = Super with Mixin;
+
+main() {
+ // TODO(johnniwinther): The parameter is created before the super constructor
+ // parameter type is inferred. Set up a way to propagate the inferred type
+ // to its use sites.
+ new Class('');
+}
diff --git a/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart.outline.expect b/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart.outline.expect
new file mode 100644
index 0000000..275d510
--- /dev/null
+++ b/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart.outline.expect
@@ -0,0 +1,20 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Mixin extends core::Object {
+ synthetic constructor •() → self::Mixin*
+ ;
+}
+class Super extends core::Object {
+ field core::int* field;
+ constructor •(core::int* field) → self::Super*
+ ;
+}
+class Class = self::Super with self::Mixin {
+ synthetic constructor •(dynamic field) → self::Class*
+ : super self::Super::•(field)
+ ;
+}
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart.strong.expect b/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart.strong.expect
new file mode 100644
index 0000000..db0dcf5
--- /dev/null
+++ b/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart.strong.expect
@@ -0,0 +1,23 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Mixin extends core::Object {
+ synthetic constructor •() → self::Mixin*
+ : super core::Object::•()
+ ;
+}
+class Super extends core::Object {
+ field core::int* field = 42;
+ constructor •(core::int* field) → self::Super*
+ : self::Super::field = field, super core::Object::•()
+ ;
+}
+class Class = self::Super with self::Mixin {
+ synthetic constructor •(dynamic field) → self::Class*
+ : super self::Super::•(field)
+ ;
+}
+static method main() → dynamic {
+ new self::Class::•("");
+}
diff --git a/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart.strong.transformed.expect b/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart.strong.transformed.expect
new file mode 100644
index 0000000..174f790
--- /dev/null
+++ b/pkg/front_end/testcases/general/mixin_application_inferred_parameter_type.dart.strong.transformed.expect
@@ -0,0 +1,23 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Mixin extends core::Object {
+ synthetic constructor •() → self::Mixin*
+ : super core::Object::•()
+ ;
+}
+class Super extends core::Object {
+ field core::int* field = 42;
+ constructor •(core::int* field) → self::Super*
+ : self::Super::field = field, super core::Object::•()
+ ;
+}
+class Class extends self::Super implements self::Mixin {
+ synthetic constructor •(dynamic field) → self::Class*
+ : super self::Super::•(field)
+ ;
+}
+static method main() → dynamic {
+ new self::Class::•("");
+}
diff --git a/pkg/front_end/testcases/general/null_aware_for_in.dart.strong.transformed.expect b/pkg/front_end/testcases/general/null_aware_for_in.dart.strong.transformed.expect
index 18203ab..f6157cd 100644
--- a/pkg/front_end/testcases/general/null_aware_for_in.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/null_aware_for_in.dart.strong.transformed.expect
@@ -1,6 +1,7 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
synthetic constructor •() → self::Class*
@@ -10,8 +11,14 @@
static method main() → dynamic {
dynamic o;
if(false) {
- for (final dynamic #t1 in (let final dynamic #t2 = o in #t2.{core::Object::==}(null) ?{dynamic} null : #t2.iterable) as{TypeError} core::Iterable<dynamic>*) {
- self::Class* c = #t1 as{TypeError} self::Class*;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>((let final dynamic #t1 = o in #t1.{core::Object::==}(null) ?{dynamic} null : #t1.iterable) as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t2 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::Class* c = #t2 as{TypeError} self::Class*;
+ }
+ }
}
}
}
diff --git a/pkg/front_end/testcases/general/spread_collection.dart.strong.transformed.expect b/pkg/front_end/testcases/general/spread_collection.dart.strong.transformed.expect
index eb0c3cc..4d80567b 100644
--- a/pkg/front_end/testcases/general/spread_collection.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/spread_collection.dart.strong.transformed.expect
@@ -9,38 +9,66 @@
//
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
import "dart:collection" as col;
static method main() → dynamic {
final core::List<core::int*>* aList = block {
final core::List<core::int*>* #t1 = <core::int*>[];
#t1.{core::List::add}(1);
- for (final core::int* #t2 in <core::int*>[2])
- #t1.{core::List::add}(#t2);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[2]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t2 = :sync-for-iterator.{core::Iterator::current};
+ #t1.{core::List::add}(#t2);
+ }
+ }
final dynamic #t3 = <core::int*>[3];
- if(!#t3.{core::Object::==}(null))
- for (final core::int* #t4 in #t3)
+ if(!#t3.{core::Object::==}(null)) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(#t3).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t4 = :sync-for-iterator.{core::Iterator::current};
#t1.{core::List::add}(#t4);
+ }
+ }
} =>#t1;
final core::Map<core::int*, core::int*>* aMap = block {
final core::Map<core::int*, core::int*>* #t5 = <core::int*, core::int*>{};
#t5.{core::Map::[]=}(1, 1);
- for (final core::MapEntry<core::int*, core::int*>* #t6 in <core::int*, core::int*>{2: 2}.{core::Map::entries})
- #t5.{core::Map::[]=}(#t6.{core::MapEntry::key}, #t6.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<core::int*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::int*, core::int*>*>*>(<core::int*, core::int*>{2: 2}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::int*, core::int*>* #t6 = :sync-for-iterator.{core::Iterator::current};
+ #t5.{core::Map::[]=}(#t6.{core::MapEntry::key}, #t6.{core::MapEntry::value});
+ }
+ }
final core::Map<dynamic, dynamic>* #t7 = <core::int*, core::int*>{3: 3};
- if(!#t7.{core::Object::==}(null))
- for (final core::MapEntry<core::int*, core::int*>* #t8 in #t7.{core::Map::entries})
+ if(!#t7.{core::Object::==}(null)) {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>(#t7.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::int*, core::int*>* #t8 = :sync-for-iterator.{core::Iterator::current};
#t5.{core::Map::[]=}(#t8.{core::MapEntry::key}, #t8.{core::MapEntry::value});
+ }
+ }
} =>#t5;
final core::Set<core::int*>* aSet = block {
final core::Set<core::int*>* #t9 = col::LinkedHashSet::•<core::int*>();
#t9.{core::Set::add}(1);
- for (final core::int* #t10 in <core::int*>[2])
- #t9.{core::Set::add}(#t10);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[2]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t10 = :sync-for-iterator.{core::Iterator::current};
+ #t9.{core::Set::add}(#t10);
+ }
+ }
final dynamic #t11 = <core::int*>[3];
- if(!#t11.{core::Object::==}(null))
- for (final core::int* #t12 in #t11)
+ if(!#t11.{core::Object::==}(null)) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(#t11).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t12 = :sync-for-iterator.{core::Iterator::current};
#t9.{core::Set::add}(#t12);
+ }
+ }
} =>#t9;
final dynamic aSetOrMap = invalid-expression "pkg/front_end/testcases/general/spread_collection.dart:21:21: Error: Not enough type information to disambiguate between literal set and literal map.
Try providing type arguments for the literal explicitly to disambiguate it.
diff --git a/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.transformed.expect b/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.transformed.expect
index 3a6b58b..24aaf98 100644
--- a/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/spread_collection_inference.dart.strong.transformed.expect
@@ -98,6 +98,7 @@
//
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
import "dart:collection" as col;
static method bar<K extends core::Object* = dynamic, V extends core::Object* = dynamic>() → core::Map<self::bar::K*, self::bar::V*>*
@@ -111,68 +112,129 @@
core::List<core::num*>* listNum = <core::num*>[42];
core::List<dynamic>* lhs10 = block {
final core::List<dynamic>* #t1 = <dynamic>[];
- for (final dynamic #t2 in <dynamic>[])
- #t1.{core::List::add}(#t2);
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t2 = :sync-for-iterator.{core::Iterator::current};
+ #t1.{core::List::add}(#t2);
+ }
+ }
} =>#t1;
core::Set<dynamic>* set10 = block {
final core::Set<dynamic>* #t3 = col::LinkedHashSet::•<dynamic>();
- for (final dynamic #t4 in <dynamic>[])
- #t3.{core::Set::add}(#t4);
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t4 = :sync-for-iterator.{core::Iterator::current};
+ #t3.{core::Set::add}(#t4);
+ }
+ }
} =>#t3;
core::Map<dynamic, dynamic>* map10 = block {
final core::Map<dynamic, dynamic>* #t5 = <dynamic, dynamic>{};
- for (final core::MapEntry<dynamic, dynamic>* #t6 in <dynamic, dynamic>{}.{core::Map::entries})
- #t5.{core::Map::[]=}(#t6.{core::MapEntry::key}, #t6.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>(<dynamic, dynamic>{}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t6 = :sync-for-iterator.{core::Iterator::current};
+ #t5.{core::Map::[]=}(#t6.{core::MapEntry::key}, #t6.{core::MapEntry::value});
+ }
+ }
} =>#t5;
core::Map<dynamic, dynamic>* map10ambiguous = block {
final core::Map<dynamic, dynamic>* #t7 = <dynamic, dynamic>{};
- for (final core::MapEntry<dynamic, dynamic>* #t8 in <dynamic, dynamic>{}.{core::Map::entries})
- #t7.{core::Map::[]=}(#t8.{core::MapEntry::key}, #t8.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>(<dynamic, dynamic>{}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t8 = :sync-for-iterator.{core::Iterator::current};
+ #t7.{core::Map::[]=}(#t8.{core::MapEntry::key}, #t8.{core::MapEntry::value});
+ }
+ }
} =>#t7;
core::List<core::int*>* lhs20 = block {
final core::List<core::int*>* #t9 = <core::int*>[];
- for (final core::int* #t10 in spread)
- #t9.{core::List::add}(#t10);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(spread).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t10 = :sync-for-iterator.{core::Iterator::current};
+ #t9.{core::List::add}(#t10);
+ }
+ }
} =>#t9;
core::Set<core::int*>* set20 = block {
final core::Set<core::int*>* #t11 = col::LinkedHashSet::•<core::int*>();
- for (final core::int* #t12 in spread)
- #t11.{core::Set::add}(#t12);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(spread).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t12 = :sync-for-iterator.{core::Iterator::current};
+ #t11.{core::Set::add}(#t12);
+ }
+ }
#t11.{core::Set::add}(42);
} =>#t11;
core::Set<core::int*>* set20ambiguous = block {
final core::Set<core::int*>* #t13 = col::LinkedHashSet::•<core::int*>();
- for (final dynamic #t14 in spread) {
- final core::int* #t15 = #t14 as{TypeError} core::int*;
- #t13.{core::Set::add}(#t15);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(spread).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t14 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::int* #t15 = #t14 as{TypeError} core::int*;
+ #t13.{core::Set::add}(#t15);
+ }
+ }
}
} =>#t13;
core::Map<core::String*, core::int*>* map20 = block {
final core::Map<core::String*, core::int*>* #t16 = <core::String*, core::int*>{};
- for (final core::MapEntry<core::String*, core::int*>* #t17 in mapSpread.{core::Map::entries})
- #t16.{core::Map::[]=}(#t17.{core::MapEntry::key}, #t17.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(mapSpread.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t17 = :sync-for-iterator.{core::Iterator::current};
+ #t16.{core::Map::[]=}(#t17.{core::MapEntry::key}, #t17.{core::MapEntry::value});
+ }
+ }
#t16.{core::Map::[]=}("baz", 42);
} =>#t16;
core::Map<core::String*, core::int*>* map20ambiguous = block {
final core::Map<core::String*, core::int*>* #t18 = <core::String*, core::int*>{};
- for (final core::MapEntry<core::String*, core::int*>* #t19 in mapSpread.{core::Map::entries})
- #t18.{core::Map::[]=}(#t19.{core::MapEntry::key}, #t19.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(mapSpread.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t19 = :sync-for-iterator.{core::Iterator::current};
+ #t18.{core::Map::[]=}(#t19.{core::MapEntry::key}, #t19.{core::MapEntry::value});
+ }
+ }
} =>#t18;
core::List<dynamic>* lhs21 = block {
final core::List<dynamic>* #t20 = <dynamic>[];
- for (final dynamic #t21 in (spread as dynamic) as{TypeError} core::Iterable<dynamic>*)
- #t20.{core::List::add}(#t21);
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>((spread as dynamic) as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t21 = :sync-for-iterator.{core::Iterator::current};
+ #t20.{core::List::add}(#t21);
+ }
+ }
} =>#t20;
core::Set<dynamic>* set21 = block {
final core::Set<dynamic>* #t22 = col::LinkedHashSet::•<dynamic>();
- for (final dynamic #t23 in (spread as dynamic) as{TypeError} core::Iterable<dynamic>*)
- #t22.{core::Set::add}(#t23);
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>((spread as dynamic) as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t23 = :sync-for-iterator.{core::Iterator::current};
+ #t22.{core::Set::add}(#t23);
+ }
+ }
#t22.{core::Set::add}(42);
} =>#t22;
core::Map<dynamic, dynamic>* map21 = block {
final core::Map<dynamic, dynamic>* #t24 = <dynamic, dynamic>{};
- for (final core::MapEntry<dynamic, dynamic>* #t25 in ((mapSpread as dynamic) as{TypeError} core::Map<dynamic, dynamic>*).{core::Map::entries})
- #t24.{core::Map::[]=}(#t25.{core::MapEntry::key}, #t25.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>(((mapSpread as dynamic) as{TypeError} core::Map<dynamic, dynamic>*).{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t25 = :sync-for-iterator.{core::Iterator::current};
+ #t24.{core::Map::[]=}(#t25.{core::MapEntry::key}, #t25.{core::MapEntry::value});
+ }
+ }
#t24.{core::Map::[]=}("baz", 42);
} =>#t24;
dynamic map21ambiguous = invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:64:28: Error: Not enough type information to disambiguate between literal set and literal map.
@@ -181,49 +243,91 @@
^";
core::List<core::int*>* lhs22 = block {
final core::List<core::int*>* #t26 = <core::int*>[];
- for (final core::int* #t27 in <core::int*>[])
- #t26.{core::List::add}(#t27);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t27 = :sync-for-iterator.{core::Iterator::current};
+ #t26.{core::List::add}(#t27);
+ }
+ }
} =>#t26;
core::Set<core::int*>* set22 = block {
final core::Set<core::int*>* #t28 = col::LinkedHashSet::•<core::int*>();
- for (final core::int* #t29 in <core::int*>[])
- #t28.{core::Set::add}(#t29);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t29 = :sync-for-iterator.{core::Iterator::current};
+ #t28.{core::Set::add}(#t29);
+ }
+ }
#t28.{core::Set::add}(42);
} =>#t28;
core::Set<core::int*>* set22ambiguous = block {
final core::Set<core::int*>* #t30 = col::LinkedHashSet::•<core::int*>();
- for (final dynamic #t31 in <core::int*>[]) {
- final core::int* #t32 = #t31 as{TypeError} core::int*;
- #t30.{core::Set::add}(#t32);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t31 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::int* #t32 = #t31 as{TypeError} core::int*;
+ #t30.{core::Set::add}(#t32);
+ }
+ }
}
} =>#t30;
core::Map<core::String*, core::int*>* map22 = block {
final core::Map<core::String*, core::int*>* #t33 = <core::String*, core::int*>{};
- for (final core::MapEntry<core::String*, core::int*>* #t34 in <core::String*, core::int*>{}.{core::Map::entries})
- #t33.{core::Map::[]=}(#t34.{core::MapEntry::key}, #t34.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(<core::String*, core::int*>{}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t34 = :sync-for-iterator.{core::Iterator::current};
+ #t33.{core::Map::[]=}(#t34.{core::MapEntry::key}, #t34.{core::MapEntry::value});
+ }
+ }
} =>#t33;
core::List<core::List<core::int*>*>* lhs23 = block {
final core::List<core::List<core::int*>*>* #t35 = <core::List<core::int*>*>[];
- for (final core::List<core::int*>* #t36 in <core::List<core::int*>*>[<core::int*>[]])
- #t35.{core::List::add}(#t36);
+ {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t36 = :sync-for-iterator.{core::Iterator::current};
+ #t35.{core::List::add}(#t36);
+ }
+ }
} =>#t35;
core::Set<core::List<core::int*>*>* set23 = block {
final core::Set<core::List<core::int*>*>* #t37 = col::LinkedHashSet::•<core::List<core::int*>*>();
- for (final core::List<core::int*>* #t38 in <core::List<core::int*>*>[<core::int*>[]])
- #t37.{core::Set::add}(#t38);
+ {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::List<core::int*>* #t38 = :sync-for-iterator.{core::Iterator::current};
+ #t37.{core::Set::add}(#t38);
+ }
+ }
#t37.{core::Set::add}(<core::int*>[42]);
} =>#t37;
core::Set<core::List<core::int*>*>* set23ambiguous = block {
final core::Set<core::List<core::int*>*>* #t39 = col::LinkedHashSet::•<core::List<core::int*>*>();
- for (final dynamic #t40 in <core::List<core::int*>*>[<core::int*>[]]) {
- final core::List<core::int*>* #t41 = #t40 as{TypeError} core::List<core::int*>*;
- #t39.{core::Set::add}(#t41);
+ {
+ core::Iterator<core::List<core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::List<core::int*>*>*>(<core::List<core::int*>*>[<core::int*>[]]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t40 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::List<core::int*>* #t41 = #t40 as{TypeError} core::List<core::int*>*;
+ #t39.{core::Set::add}(#t41);
+ }
+ }
}
} =>#t39;
core::Map<core::String*, core::List<core::int*>*>* map23 = block {
final core::Map<core::String*, core::List<core::int*>*>* #t42 = <core::String*, core::List<core::int*>*>{};
- for (final core::MapEntry<core::String*, core::List<core::int*>*>* #t43 in <core::String*, core::List<core::int*>*>{"baz": <core::int*>[]}.{core::Map::entries})
- #t42.{core::Map::[]=}(#t43.{core::MapEntry::key}, #t43.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<core::String*, core::List<core::int*>*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::List<core::int*>*>*>*>(<core::String*, core::List<core::int*>*>{"baz": <core::int*>[]}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::List<core::int*>*>* #t43 = :sync-for-iterator.{core::Iterator::current};
+ #t42.{core::Map::[]=}(#t43.{core::MapEntry::key}, #t43.{core::MapEntry::value});
+ }
+ }
} =>#t42;
dynamic map24ambiguous = invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:96:28: Error: Both Iterable and Map spread elements encountered in ambiguous literal.
dynamic map24ambiguous = {...spread, ...mapSpread};
@@ -233,16 +337,26 @@
int lhs30 = /*@ typeArgs=int* */ [...spread];
^" in ( block {
final core::List<core::int*>* #t45 = <core::int*>[];
- for (final core::int* #t46 in spread)
- #t45.{core::List::add}(#t46);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(spread).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t46 = :sync-for-iterator.{core::Iterator::current};
+ #t45.{core::List::add}(#t46);
+ }
+ }
} =>#t45) as{TypeError} core::int*;
core::int* set30 = let final<BottomType> #t47 = invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:100:36: Error: A value of type 'Set<int>' can't be assigned to a variable of type 'int'.
- 'Set' is from 'dart:core'.
int set30 = /*@ typeArgs=int* */ {...spread, 42};
^" in ( block {
final core::Set<core::int*>* #t48 = col::LinkedHashSet::•<core::int*>();
- for (final core::int* #t49 in spread)
- #t48.{core::Set::add}(#t49);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(spread).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t49 = :sync-for-iterator.{core::Iterator::current};
+ #t48.{core::Set::add}(#t49);
+ }
+ }
#t48.{core::Set::add}(42);
} =>#t48) as{TypeError} core::int*;
core::int* set30ambiguous = let final<BottomType> #t50 = invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:103:7: Error: A value of type 'Set<int>' can't be assigned to a variable of type 'int'.
@@ -250,9 +364,15 @@
{...spread};
^" in ( block {
final core::Set<core::int*>* #t51 = col::LinkedHashSet::•<core::int*>();
- for (final dynamic #t52 in spread) {
- final core::int* #t53 = #t52 as{TypeError} core::int*;
- #t51.{core::Set::add}(#t53);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(spread).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t52 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::int* #t53 = #t52 as{TypeError} core::int*;
+ #t51.{core::Set::add}(#t53);
+ }
+ }
}
} =>#t51) as{TypeError} core::int*;
core::int* map30 = let final<BottomType> #t54 = invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:106:7: Error: A value of type 'Map<String, int>' can't be assigned to a variable of type 'int'.
@@ -260,8 +380,13 @@
{...mapSpread, \"baz\": 42};
^" in ( block {
final core::Map<core::String*, core::int*>* #t55 = <core::String*, core::int*>{};
- for (final core::MapEntry<core::String*, core::int*>* #t56 in mapSpread.{core::Map::entries})
- #t55.{core::Map::[]=}(#t56.{core::MapEntry::key}, #t56.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(mapSpread.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t56 = :sync-for-iterator.{core::Iterator::current};
+ #t55.{core::Map::[]=}(#t56.{core::MapEntry::key}, #t56.{core::MapEntry::value});
+ }
+ }
#t55.{core::Map::[]=}("baz", 42);
} =>#t55) as{TypeError} core::int*;
core::int* map30ambiguous = let final<BottomType> #t57 = invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:109:7: Error: A value of type 'Map<String, int>' can't be assigned to a variable of type 'int'.
@@ -269,8 +394,13 @@
{...mapSpread};
^" in ( block {
final core::Map<core::String*, core::int*>* #t58 = <core::String*, core::int*>{};
- for (final core::MapEntry<core::String*, core::int*>* #t59 in mapSpread.{core::Map::entries})
- #t58.{core::Map::[]=}(#t59.{core::MapEntry::key}, #t59.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(mapSpread.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t59 = :sync-for-iterator.{core::Iterator::current};
+ #t58.{core::Map::[]=}(#t59.{core::MapEntry::key}, #t59.{core::MapEntry::value});
+ }
+ }
} =>#t58) as{TypeError} core::int*;
core::List<dynamic>* lhs40 = <dynamic>[invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:111:38: Error: Unexpected type 'int' of a spread. Expected 'dynamic' or an Iterable.
List<dynamic> lhs40 = <dynamic>[...notSpreadInt];
@@ -313,9 +443,15 @@
#t68.{core::Set::add}(invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:137:8: Error: Expected ',' before this.
...null,
^");
- for (final dynamic #t69 in <dynamic>[]) {
- final dynamic #t70 = #t69 as{TypeError} dynamic;
- #t68.{core::Set::add}(#t70);
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t69 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final dynamic #t70 = #t69 as{TypeError} dynamic;
+ #t68.{core::Set::add}(#t70);
+ }
+ }
}
} =>#t68;
core::Map<core::String*, core::int*>* map70 = <core::String*, core::int*>{invalid-expression "pkg/front_end/testcases/general/spread_collection_inference.dart:142:45: Error: Can't spread a value with static type Null.
@@ -324,70 +460,122 @@
core::List<core::int*>* lhs80 = block {
final core::List<core::int*>* #t71 = <core::int*>[];
final dynamic #t72 = null;
- if(!#t72.{core::Object::==}(null))
- for (final core::int* #t73 in #t72)
+ if(!#t72.{core::Object::==}(null)) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(#t72).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t73 = :sync-for-iterator.{core::Iterator::current};
#t71.{core::List::add}(#t73);
+ }
+ }
} =>#t71;
core::Set<core::int*>* set80 = block {
final core::Set<core::int*>* #t74 = col::LinkedHashSet::•<core::int*>();
final dynamic #t75 = null;
- if(!#t75.{core::Object::==}(null))
- for (final core::int* #t76 in #t75)
+ if(!#t75.{core::Object::==}(null)) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(#t75).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::int* #t76 = :sync-for-iterator.{core::Iterator::current};
#t74.{core::Set::add}(#t76);
+ }
+ }
} =>#t74;
core::Set<dynamic>* set81ambiguous = block {
final core::Set<dynamic>* #t77 = col::LinkedHashSet::•<dynamic>();
final dynamic #t78 = null;
- if(!#t78.{core::Object::==}(null))
- for (final dynamic #t79 in #t78) {
- final dynamic #t80 = #t79 as{TypeError} dynamic;
- #t77.{core::Set::add}(#t80);
+ if(!#t78.{core::Object::==}(null)) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(#t78).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t79 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final dynamic #t80 = #t79 as{TypeError} dynamic;
+ #t77.{core::Set::add}(#t80);
+ }
}
- for (final dynamic #t81 in <dynamic>[]) {
- final dynamic #t82 = #t81 as{TypeError} dynamic;
- #t77.{core::Set::add}(#t82);
+ }
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t81 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final dynamic #t82 = #t81 as{TypeError} dynamic;
+ #t77.{core::Set::add}(#t82);
+ }
+ }
}
} =>#t77;
core::Map<core::String*, core::int*>* map80 = block {
final core::Map<core::String*, core::int*>* #t83 = <core::String*, core::int*>{};
final core::Map<dynamic, dynamic>* #t84 = null;
- if(!#t84.{core::Object::==}(null))
- for (final core::MapEntry<core::String*, core::int*>* #t85 in #t84.{core::Map::entries})
+ if(!#t84.{core::Object::==}(null)) {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>(#t84.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t85 = :sync-for-iterator.{core::Iterator::current};
#t83.{core::Map::[]=}(#t85.{core::MapEntry::key}, #t85.{core::MapEntry::value});
+ }
+ }
} =>#t83;
core::Map<core::String*, core::int*>* map90 = block {
final core::Map<core::String*, core::int*>* #t86 = <core::String*, core::int*>{};
- for (final core::MapEntry<core::String*, core::int*>* #t87 in self::bar<core::String*, core::int*>().{core::Map::entries})
- #t86.{core::Map::[]=}(#t87.{core::MapEntry::key}, #t87.{core::MapEntry::value});
+ {
+ core::Iterator<core::MapEntry<core::String*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::String*, core::int*>*>*>(self::bar<core::String*, core::int*>().{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::String*, core::int*>* #t87 = :sync-for-iterator.{core::Iterator::current};
+ #t86.{core::Map::[]=}(#t87.{core::MapEntry::key}, #t87.{core::MapEntry::value});
+ }
+ }
} =>#t86;
core::List<core::int*>* list100 = block {
final core::List<core::int*>* #t88 = <core::int*>[];
- for (final dynamic #t89 in listNum) {
- final core::int* #t90 = #t89 as{TypeError} core::int*;
- #t88.{core::List::add}(#t90);
+ {
+ core::Iterator<core::num*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::num*>*>(listNum).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t89 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::int* #t90 = #t89 as{TypeError} core::int*;
+ #t88.{core::List::add}(#t90);
+ }
+ }
}
} =>#t88;
core::Map<core::num*, core::int*>* map100 = block {
final core::Map<core::num*, core::int*>* #t91 = <core::num*, core::int*>{};
- for (final core::MapEntry<dynamic, dynamic>* #t92 in mapIntNum.{core::Map::entries}) {
- final core::num* #t93 = #t92.{core::MapEntry::key} as{TypeError} core::num*;
- final core::int* #t94 = #t92.{core::MapEntry::value} as{TypeError} core::int*;
- #t91.{core::Map::[]=}(#t93, #t94);
+ {
+ core::Iterator<core::MapEntry<core::int*, core::num*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::int*, core::num*>*>*>(mapIntNum.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t92 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::num* #t93 = #t92.{core::MapEntry::key} as{TypeError} core::num*;
+ final core::int* #t94 = #t92.{core::MapEntry::value} as{TypeError} core::int*;
+ #t91.{core::Map::[]=}(#t93, #t94);
+ }
+ }
}
} =>#t91;
core::List<core::int*>* list110 = block {
final core::List<core::int*>* #t95 = <core::int*>[];
- for (final dynamic #t96 in dynVar as{TypeError} core::Iterable<dynamic>*) {
- final core::int* #t97 = #t96 as{TypeError} core::int*;
- #t95.{core::List::add}(#t97);
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(dynVar as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t96 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::int* #t97 = #t96 as{TypeError} core::int*;
+ #t95.{core::List::add}(#t97);
+ }
+ }
}
} =>#t95;
core::Map<core::num*, core::int*>* map110 = block {
final core::Map<core::num*, core::int*>* #t98 = <core::num*, core::int*>{};
- for (final core::MapEntry<dynamic, dynamic>* #t99 in (dynVar as{TypeError} core::Map<dynamic, dynamic>*).{core::Map::entries}) {
- final core::num* #t100 = #t99.{core::MapEntry::key} as{TypeError} core::num*;
- final core::int* #t101 = #t99.{core::MapEntry::value} as{TypeError} core::int*;
- #t98.{core::Map::[]=}(#t100, #t101);
+ {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>((dynVar as{TypeError} core::Map<dynamic, dynamic>*).{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t99 = :sync-for-iterator.{core::Iterator::current};
+ {
+ final core::num* #t100 = #t99.{core::MapEntry::key} as{TypeError} core::num*;
+ final core::int* #t101 = #t99.{core::MapEntry::value} as{TypeError} core::int*;
+ #t98.{core::Map::[]=}(#t100, #t101);
+ }
+ }
}
} =>#t98;
}
diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/experiments_enabled_1.yaml.world.1.expect b/pkg/front_end/testcases/incremental_initialize_from_dill/experiments_enabled_1.yaml.world.1.expect
index ce0d68a..26a90cf 100644
--- a/pkg/front_end/testcases/incremental_initialize_from_dill/experiments_enabled_1.yaml.world.1.expect
+++ b/pkg/front_end/testcases/incremental_initialize_from_dill/experiments_enabled_1.yaml.world.1.expect
@@ -2,7 +2,7 @@
library from "org-dartlang-test:///main.dart" as main {
class Class extends dart.core::Object {
- synthetic constructor •() → main::Class*
+ synthetic constructor •() → main::Class
: super dart.core::Object::•()
;
}
diff --git a/pkg/front_end/testcases/inference/downwards_inference_annotations_for_loop_variable.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/downwards_inference_annotations_for_loop_variable.dart.strong.transformed.expect
index 2a1ae24..7d1a7f3 100644
--- a/pkg/front_end/testcases/inference/downwards_inference_annotations_for_loop_variable.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference/downwards_inference_annotations_for_loop_variable.dart.strong.transformed.expect
@@ -1,6 +1,7 @@
library test;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Foo extends core::Object {
const constructor •(core::List<core::String*>* l) → self::Foo*
@@ -10,7 +11,12 @@
static method test() → void {
for (@#C1 core::int* i = 0; i.{core::num::<}(1); i = i.{core::num::+}(1)) {
}
- for (@#C1 core::int* i in <core::int*>[0]) {
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[0]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ @#C1 core::int* i = :sync-for-iterator.{core::Iterator::current};
+ {}
+ }
}
}
static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart b/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart
index 432c249..a81e330 100644
--- a/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart
+++ b/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart
@@ -11,7 +11,7 @@
void test() {
void f<@Foo(/*@ typeArgs=String* */ const []) T>() {}
- var /*@ type=<@Foo::•(const <String*>[]) T extends Object* = dynamic>() ->* Null? */ x =
+ var /*@ type=<T extends Object* = dynamic>() ->* Null? */ x =
<@Foo(/*@ typeArgs=String* */ const []) T> /*@ returnType=Null? */ () {};
}
diff --git a/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart.strong.expect b/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart.strong.expect
index a003f3b..c30db0b 100644
--- a/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart.strong.expect
+++ b/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart.strong.expect
@@ -9,7 +9,7 @@
}
static method test() → void {
function f<@#C1 T extends core::Object* = dynamic>() → void {}
- <@self::Foo::•(const <core::String*>[]) T extends core::Object* = dynamic>() →* core::Null? x = <@#C1 T extends core::Object* = dynamic>() → core::Null? {};
+ <T extends core::Object* = dynamic>() →* core::Null? x = <@#C1 T extends core::Object* = dynamic>() → core::Null? {};
}
static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart.strong.transformed.expect
index a003f3b..c30db0b 100644
--- a/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference/downwards_inference_annotations_type_variable_local.dart.strong.transformed.expect
@@ -9,7 +9,7 @@
}
static method test() → void {
function f<@#C1 T extends core::Object* = dynamic>() → void {}
- <@self::Foo::•(const <core::String*>[]) T extends core::Object* = dynamic>() →* core::Null? x = <@#C1 T extends core::Object* = dynamic>() → core::Null? {};
+ <T extends core::Object* = dynamic>() →* core::Null? x = <@#C1 T extends core::Object* = dynamic>() → core::Null? {};
}
static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference/downwards_inference_for_each.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/downwards_inference_for_each.dart.strong.transformed.expect
index 95bdb47..f95b190 100644
--- a/pkg/front_end/testcases/inference/downwards_inference_for_each.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference/downwards_inference_for_each.dart.strong.transformed.expect
@@ -30,17 +30,44 @@
{
dynamic d;
core::Object* o;
- for (dynamic x in self::F<core::Iterable<dynamic>*>()) {
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(self::F<core::Iterable<dynamic>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic x = :sync-for-iterator.{core::Iterator::current};
+ {}
+ }
}
- for (dynamic x in self::F<core::Iterable<dynamic>*>()) {
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(self::F<core::Iterable<dynamic>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic x = :sync-for-iterator.{core::Iterator::current};
+ {}
+ }
}
- for (core::Object* x in self::F<core::Iterable<core::Object*>*>()) {
+ {
+ core::Iterator<core::Object*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::Object*>*>(self::F<core::Iterable<core::Object*>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::Object* x = :sync-for-iterator.{core::Iterator::current};
+ {}
+ }
}
- for (final dynamic #t1 in self::F<core::Iterable<dynamic>*>()) {
- d = #t1;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(self::F<core::Iterable<dynamic>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t1 = :sync-for-iterator.{core::Iterator::current};
+ {
+ d = #t1;
+ }
+ }
}
- for (final core::Object* #t2 in self::F<core::Iterable<core::Object*>*>()) {
- o = #t2;
+ {
+ core::Iterator<core::Object*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::Object*>*>(self::F<core::Iterable<core::Object*>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::Object* #t2 = :sync-for-iterator.{core::Iterator::current};
+ {
+ o = #t2;
+ }
+ }
}
{
dynamic :stream = self::F<asy::Stream<dynamic>*>();
@@ -185,11 +212,26 @@
try {
#L7:
{
- for (core::int* x in <core::int*>[1, 2, 3]) {
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[1, 2, 3]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* x = :sync-for-iterator.{core::Iterator::current};
+ {}
+ }
}
- for (core::num* x in <core::num*>[1, 2, 3]) {
+ {
+ core::Iterator<core::num*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::num*>*>(<core::num*>[1, 2, 3]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::num* x = :sync-for-iterator.{core::Iterator::current};
+ {}
+ }
}
- for (core::int* x in <core::int*>[1, 2, 3]) {
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[1, 2, 3]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* x = :sync-for-iterator.{core::Iterator::current};
+ {}
+ }
}
{
dynamic :stream = self::MyStream::•<core::int*>();
diff --git a/pkg/front_end/testcases/inference/for_each_downcast_iterable.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/for_each_downcast_iterable.dart.strong.transformed.expect
index 1e3cd61..6d20b98 100644
--- a/pkg/front_end/testcases/inference/for_each_downcast_iterable.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference/for_each_downcast_iterable.dart.strong.transformed.expect
@@ -21,7 +21,12 @@
#L1:
{
core::Object* o;
- for (dynamic x in o as{TypeError} core::Iterable<dynamic>*) {
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(o as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic x = :sync-for-iterator.{core::Iterator::current};
+ {}
+ }
}
{
dynamic :stream = o as{TypeError} asy::Stream<dynamic>*;
@@ -46,8 +51,14 @@
}
}
core::int* y;
- for (final dynamic #t4 in o as{TypeError} core::Iterable<dynamic>*) {
- y = #t4 as{TypeError} core::int*;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(o as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t4 = :sync-for-iterator.{core::Iterator::current};
+ {
+ y = #t4 as{TypeError} core::int*;
+ }
+ }
}
{
dynamic :stream = o as{TypeError} asy::Stream<dynamic>*;
diff --git a/pkg/front_end/testcases/inference/for_in_loop_promotion.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/for_in_loop_promotion.dart.strong.transformed.expect
index f98e42e..a5c5985 100644
--- a/pkg/front_end/testcases/inference/for_in_loop_promotion.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference/for_in_loop_promotion.dart.strong.transformed.expect
@@ -1,11 +1,18 @@
library test;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method test(core::List<core::num*>* nums) → void {
- for (core::num* x in nums) {
- if(x is core::int*) {
- core::int* y = x{core::int*};
+ {
+ core::Iterator<core::num*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::num*>*>(nums).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::num* x = :sync-for-iterator.{core::Iterator::current};
+ {
+ if(x is core::int*) {
+ core::int* y = x{core::int*};
+ }
+ }
}
}
}
diff --git a/pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart.strong.transformed.expect
index 12a0f49..67247a8 100644
--- a/pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart.strong.transformed.expect
@@ -30,6 +30,7 @@
//
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Foo extends core::Object {
field core::int* bar = 42;
@@ -42,10 +43,16 @@
: super core::Object::•()
;
method foo(generic-covariant-impl self::Bar::T* t) → void {
- for (core::String* i in t) {
- core::int* x = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:15:44: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(t).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::String* i = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::int* x = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:15:44: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
int x = /*error:INVALID_ASSIGNMENT*/ i;
^" in i as{TypeError} core::int*;
+ }
+ }
}
}
}
@@ -54,59 +61,113 @@
: super core::Object::•()
;
method foo(generic-covariant-impl self::Baz::S* t) → void {
- for (self::Baz::T* i in t) {
- core::int* x = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:23:44: Error: A value of type 'T' can't be assigned to a variable of type 'int'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(t).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ self::Baz::T* i = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::int* x = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:23:44: Error: A value of type 'T' can't be assigned to a variable of type 'int'.
int x = /*error:INVALID_ASSIGNMENT*/ i;
^" in i as{TypeError} core::int*;
- self::Baz::T* y = i;
+ self::Baz::T* y = i;
+ }
+ }
}
}
}
static method test() → dynamic {
core::List<self::Foo*>* list = <self::Foo*>[];
- for (self::Foo* x in list) {
- core::String* y = let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:32:45: Error: A value of type 'Foo' can't be assigned to a variable of type 'String'.
+ {
+ core::Iterator<self::Foo*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::Foo*>*>(list).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ self::Foo* x = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::String* y = let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:32:45: Error: A value of type 'Foo' can't be assigned to a variable of type 'String'.
- 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart'.
String y = /*error:INVALID_ASSIGNMENT*/ x;
^" in x as{TypeError} core::String*;
+ }
+ }
}
- for (dynamic x in list) {
- core::String* y = x as{TypeError} core::String*;
+ {
+ core::Iterator<self::Foo*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::Foo*>*>(list).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic x = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::String* y = x as{TypeError} core::String*;
+ }
+ }
}
- for (final self::Foo* #t4 in list) {
- core::String* x = let final<BottomType> #t5 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:39:15: Error: A value of type 'Foo' can't be assigned to a variable of type 'String'.
+ {
+ core::Iterator<self::Foo*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::Foo*>*>(list).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::Foo* #t4 = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::String* x = let final<BottomType> #t5 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:39:15: Error: A value of type 'Foo' can't be assigned to a variable of type 'String'.
- 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart'.
Try changing the type of the variable.
for (String x in /*error:FOR_IN_OF_INVALID_ELEMENT_TYPE*/ list) {
^" in #t4 as{TypeError} core::String*;
- core::String* y = x;
+ core::String* y = x;
+ }
+ }
}
dynamic z;
- for (final self::Foo* #t6 in list) {
- z = #t6;
- core::String* y = z as{TypeError} core::String*;
+ {
+ core::Iterator<self::Foo*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::Foo*>*>(list).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::Foo* #t6 = :sync-for-iterator.{core::Iterator::current};
+ {
+ z = #t6;
+ core::String* y = z as{TypeError} core::String*;
+ }
+ }
}
core::Iterable<dynamic>* iter = list;
- for (final dynamic #t7 in iter) {
- self::Foo* x = #t7 as{TypeError} self::Foo*;
- self::Foo* y = x;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(iter).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t7 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::Foo* x = #t7 as{TypeError} self::Foo*;
+ self::Foo* y = x;
+ }
+ }
}
dynamic iter2 = list;
- for (final dynamic #t8 in iter2 as{TypeError} core::Iterable<dynamic>*) {
- self::Foo* x = #t8 as{TypeError} self::Foo*;
- self::Foo* y = x;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(iter2 as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t8 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::Foo* x = #t8 as{TypeError} self::Foo*;
+ self::Foo* y = x;
+ }
+ }
}
core::Map<core::String*, self::Foo*>* map = <core::String*, self::Foo*>{};
- for (dynamic x in let final<BottomType> #t9 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:60:70: Error: The type 'Map<String, Foo>' used in the 'for' loop must implement 'Iterable<dynamic>'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(let final<BottomType> #t9 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:60:70: Error: The type 'Map<String, Foo>' used in the 'for' loop must implement 'Iterable<dynamic>'.
- 'Map' is from 'dart:core'.
- 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart'.
- 'Iterable' is from 'dart:core'.
for (var /*@ type=dynamic */ x in /*error:FOR_IN_OF_INVALID_TYPE*/ map) {
- ^" in map as{TypeError} core::Iterable<dynamic>*) {
- core::String* y = x as{TypeError} core::String*;
+ ^" in map as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic x = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::String* y = x as{TypeError} core::String*;
+ }
+ }
}
- for (core::String* x in map.{core::Map::keys}) {
- core::String* y = x;
+ {
+ core::Iterator<core::String*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::String*>*>(map.{core::Map::keys}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::String* x = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::String* y = x;
+ }
+ }
}
}
static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference_new/for_each_identifier_downwards.dart.strong.transformed.expect b/pkg/front_end/testcases/inference_new/for_each_identifier_downwards.dart.strong.transformed.expect
index b48f3df..6bbfddf 100644
--- a/pkg/front_end/testcases/inference_new/for_each_identifier_downwards.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference_new/for_each_identifier_downwards.dart.strong.transformed.expect
@@ -1,6 +1,7 @@
library test;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class A extends core::Object {
synthetic constructor •() → self::A*
@@ -15,20 +16,50 @@
set aSetter(self::A* value) → void {}
method test() → void {
self::A* aLocal;
- for (final self::A* #t1 in self::f<core::Iterable<self::A*>*>()) {
- aLocal = #t1;
+ {
+ core::Iterator<self::A*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::A*>*>(self::f<core::Iterable<self::A*>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::A* #t1 = :sync-for-iterator.{core::Iterator::current};
+ {
+ aLocal = #t1;
+ }
+ }
}
- for (final self::A* #t2 in self::f<core::Iterable<self::A*>*>()) {
- this.{self::C::aField} = #t2;
+ {
+ core::Iterator<self::A*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::A*>*>(self::f<core::Iterable<self::A*>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::A* #t2 = :sync-for-iterator.{core::Iterator::current};
+ {
+ this.{self::C::aField} = #t2;
+ }
+ }
}
- for (final self::A* #t3 in self::f<core::Iterable<self::A*>*>()) {
- this.{self::C::aSetter} = #t3;
+ {
+ core::Iterator<self::A*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::A*>*>(self::f<core::Iterable<self::A*>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::A* #t3 = :sync-for-iterator.{core::Iterator::current};
+ {
+ this.{self::C::aSetter} = #t3;
+ }
+ }
}
- for (final self::A* #t4 in self::f<core::Iterable<self::A*>*>()) {
- self::aTopLevel = #t4;
+ {
+ core::Iterator<self::A*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::A*>*>(self::f<core::Iterable<self::A*>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::A* #t4 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::aTopLevel = #t4;
+ }
+ }
}
- for (final self::A* #t5 in self::f<core::Iterable<self::A*>*>()) {
- self::aTopLevelSetter = #t5;
+ {
+ core::Iterator<self::A*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::A*>*>(self::f<core::Iterable<self::A*>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::A* #t5 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::aTopLevelSetter = #t5;
+ }
+ }
}
}
}
diff --git a/pkg/front_end/testcases/inference_new/for_each_invalid_iterable.dart.strong.transformed.expect b/pkg/front_end/testcases/inference_new/for_each_invalid_iterable.dart.strong.transformed.expect
index ee4302e..367cb2e 100644
--- a/pkg/front_end/testcases/inference_new/for_each_invalid_iterable.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference_new/for_each_invalid_iterable.dart.strong.transformed.expect
@@ -44,11 +44,17 @@
#L1:
{
core::String* s;
- for (final dynamic #t1 in let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/inference_new/for_each_invalid_iterable.dart:10:17: Error: The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/inference_new/for_each_invalid_iterable.dart:10:17: Error: The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
- 'Iterable' is from 'dart:core'.
for (int x in s) {}
- ^" in s as{TypeError} core::Iterable<dynamic>*) {
- core::int* x = #t1 as{TypeError} core::int*;
+ ^" in s as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t2 = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::int* x = #t2 as{TypeError} core::int*;
+ }
+ }
}
{
dynamic :stream = let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/inference_new/for_each_invalid_iterable.dart:11:23: Error: The type 'String' used in the 'for' loop must implement 'Stream<dynamic>'.
@@ -78,11 +84,17 @@
}
}
core::int* y;
- for (final dynamic #t8 in let final<BottomType> #t9 = invalid-expression "pkg/front_end/testcases/inference_new/for_each_invalid_iterable.dart:13:13: Error: The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(let final<BottomType> #t8 = invalid-expression "pkg/front_end/testcases/inference_new/for_each_invalid_iterable.dart:13:13: Error: The type 'String' used in the 'for' loop must implement 'Iterable<dynamic>'.
- 'Iterable' is from 'dart:core'.
for (y in s) {}
- ^" in s as{TypeError} core::Iterable<dynamic>*) {
- y = #t8 as{TypeError} core::int*;
+ ^" in s as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t9 = :sync-for-iterator.{core::Iterator::current};
+ {
+ y = #t9 as{TypeError} core::int*;
+ }
+ }
}
{
dynamic :stream = let final<BottomType> #t10 = invalid-expression "pkg/front_end/testcases/inference_new/for_each_invalid_iterable.dart:14:19: Error: The type 'String' used in the 'for' loop must implement 'Stream<dynamic>'.
diff --git a/pkg/front_end/testcases/inference_new/for_each_outer_var_type.dart.strong.transformed.expect b/pkg/front_end/testcases/inference_new/for_each_outer_var_type.dart.strong.transformed.expect
index 649f649..480adea 100644
--- a/pkg/front_end/testcases/inference_new/for_each_outer_var_type.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inference_new/for_each_outer_var_type.dart.strong.transformed.expect
@@ -54,8 +54,14 @@
self::A* a;
self::B* b;
core::int* i;
- for (final self::A* #t1 in iterable) {
- a = #t1;
+ {
+ core::Iterator<self::A*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::A*>*>(iterable).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::A* #t1 = :sync-for-iterator.{core::Iterator::current};
+ {
+ a = #t1;
+ }
+ }
}
{
dynamic :stream = stream;
@@ -81,8 +87,14 @@
:result;
}
}
- for (final self::A* #t6 in iterable) {
- b = #t6 as{TypeError} self::B*;
+ {
+ core::Iterator<self::A*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::A*>*>(iterable).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::A* #t6 = :sync-for-iterator.{core::Iterator::current};
+ {
+ b = #t6 as{TypeError} self::B*;
+ }
+ }
}
{
dynamic :stream = stream;
@@ -108,12 +120,18 @@
:result;
}
}
- for (final self::A* #t11 in iterable) {
- i = let final<BottomType> #t12 = invalid-expression "pkg/front_end/testcases/inference_new/for_each_outer_var_type.dart:26:10: Error: A value of type 'A' can't be assigned to a variable of type 'int'.
+ {
+ core::Iterator<self::A*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::A*>*>(iterable).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::A* #t11 = :sync-for-iterator.{core::Iterator::current};
+ {
+ i = let final<BottomType> #t12 = invalid-expression "pkg/front_end/testcases/inference_new/for_each_outer_var_type.dart:26:10: Error: A value of type 'A' can't be assigned to a variable of type 'int'.
- 'A' is from 'pkg/front_end/testcases/inference_new/for_each_outer_var_type.dart'.
Try changing the type of the variable.
for (i in iterable) {}
^" in #t11 as{TypeError} core::int*;
+ }
+ }
}
{
dynamic :stream = stream;
@@ -143,8 +161,14 @@
:result;
}
}
- for (final self::A* #t18 in self::f<core::Iterable<self::A*>*>()) {
- a = #t18;
+ {
+ core::Iterator<self::A*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<self::A*>*>(self::f<core::Iterable<self::A*>*>()).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final self::A* #t18 = :sync-for-iterator.{core::Iterator::current};
+ {
+ a = #t18;
+ }
+ }
}
{
dynamic :stream = self::f<asy::Stream<self::A*>*>();
diff --git a/pkg/front_end/testcases/inference_new/null_aware_property_get.dart b/pkg/front_end/testcases/inference_new/null_aware_property_get.dart
new file mode 100644
index 0000000..dca1e29
--- /dev/null
+++ b/pkg/front_end/testcases/inference_new/null_aware_property_get.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2017, 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+class Class {
+ T method<T>() => null;
+}
+
+main() {
+ Class c;
+ num Function() f = /*@ target=Object::== */ /*@type=Class**/ c
+ ?. /*@ target=Class::method */ method;
+}
diff --git a/pkg/front_end/testcases/inference_new/null_aware_property_get.dart.outline.expect b/pkg/front_end/testcases/inference_new/null_aware_property_get.dart.outline.expect
new file mode 100644
index 0000000..63107b0
--- /dev/null
+++ b/pkg/front_end/testcases/inference_new/null_aware_property_get.dart.outline.expect
@@ -0,0 +1,12 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ synthetic constructor •() → self::Class*
+ ;
+ method method<T extends core::Object* = dynamic>() → self::Class::method::T*
+ ;
+}
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/inference_new/null_aware_property_get.dart.strong.expect b/pkg/front_end/testcases/inference_new/null_aware_property_get.dart.strong.expect
new file mode 100644
index 0000000..ff1741a
--- /dev/null
+++ b/pkg/front_end/testcases/inference_new/null_aware_property_get.dart.strong.expect
@@ -0,0 +1,15 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ synthetic constructor •() → self::Class*
+ : super core::Object::•()
+ ;
+ method method<T extends core::Object* = dynamic>() → self::Class::method::T*
+ return null;
+}
+static method main() → dynamic {
+ self::Class* c;
+ () →* core::num* f = let final self::Class* #t1 = c in #t1.{core::Object::==}(null) ?{() →* core::num*} null : #t1.{self::Class::method}<core::num*>;
+}
diff --git a/pkg/front_end/testcases/inference_new/null_aware_property_get.dart.strong.transformed.expect b/pkg/front_end/testcases/inference_new/null_aware_property_get.dart.strong.transformed.expect
new file mode 100644
index 0000000..ff1741a
--- /dev/null
+++ b/pkg/front_end/testcases/inference_new/null_aware_property_get.dart.strong.transformed.expect
@@ -0,0 +1,15 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ synthetic constructor •() → self::Class*
+ : super core::Object::•()
+ ;
+ method method<T extends core::Object* = dynamic>() → self::Class::method::T*
+ return null;
+}
+static method main() → dynamic {
+ self::Class* c;
+ () →* core::num* f = let final self::Class* #t1 = c in #t1.{core::Object::==}(null) ?{() →* core::num*} null : #t1.{self::Class::method}<core::num*>;
+}
diff --git a/pkg/front_end/testcases/late_lowering/instance_field_with_initializer.dart b/pkg/front_end/testcases/late_lowering/instance_field_with_initializer.dart
index 1ff72a5..7b17a44 100644
--- a/pkg/front_end/testcases/late_lowering/instance_field_with_initializer.dart
+++ b/pkg/front_end/testcases/late_lowering/instance_field_with_initializer.dart
@@ -6,9 +6,9 @@
late int field = 10;
Class.constructor1();
- Class.constructor2(int this.field);
+ Class.constructor2(this.field);
Class.constructor3(int value) : this.field = value + 1;
- Class.constructor4([int this.field = 42]);
+ Class.constructor4([this.field = 42]);
}
class Subclass extends Class {
diff --git a/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart b/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart
index b06db9d..601d77e 100644
--- a/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart
+++ b/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart
@@ -6,9 +6,9 @@
late int field;
Class.constructor1();
- Class.constructor2(int this.field);
+ Class.constructor2(this.field);
Class.constructor3(int value) : this.field = value + 1;
- Class.constructor4([int this.field = 42]);
+ Class.constructor4([this.field = 42]);
}
class Subclass extends Class {
diff --git a/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart.strong.expect
index 7e44af1..19bf6a7 100644
--- a/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart.strong.expect
@@ -1,6 +1,7 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
field core::int? _#field = null;
@@ -17,7 +18,7 @@
: self::Class::_#field = field, super core::Object::•()
;
get field() → core::int
- return let final core::int? #t1 = this.{self::Class::_#field} in #t1.==(null) ?{core::int} throw "Field 'field' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = this.{self::Class::_#field} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'field' has not been initialized.") : #t1{core::int};
set field(core::int #t2) → void
this.{self::Class::_#field} = #t2;
}
diff --git a/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart.strong.transformed.expect
index 7e44af1..19bf6a7 100644
--- a/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_field_without_initializer.dart.strong.transformed.expect
@@ -1,6 +1,7 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
field core::int? _#field = null;
@@ -17,7 +18,7 @@
: self::Class::_#field = field, super core::Object::•()
;
get field() → core::int
- return let final core::int? #t1 = this.{self::Class::_#field} in #t1.==(null) ?{core::int} throw "Field 'field' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = this.{self::Class::_#field} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'field' has not been initialized.") : #t1{core::int};
set field(core::int #t2) → void
this.{self::Class::_#field} = #t2;
}
diff --git a/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart b/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart
index e857d22..a219300 100644
--- a/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart
+++ b/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart
@@ -6,9 +6,9 @@
late final int field;
Class.constructor1();
- Class.constructor2(int this.field);
+ Class.constructor2(this.field);
Class.constructor3(int value) : this.field = value + 1;
- Class.constructor4([int this.field = 42]);
+ Class.constructor4([this.field = 42]);
}
class Subclass extends Class {
diff --git a/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart.strong.expect
index 8e4ad19..1e31185 100644
--- a/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart.strong.expect
@@ -1,6 +1,7 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
field core::int? _#field = null;
@@ -17,12 +18,12 @@
: self::Class::_#field = field, super core::Object::•()
;
get field() → core::int
- return let final core::int? #t1 = this.{self::Class::_#field} in #t1.==(null) ?{core::int} throw "Field 'field' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = this.{self::Class::_#field} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'field' has not been initialized.") : #t1{core::int};
set field(core::int #t2) → void
if(this.{self::Class::_#field}.==(null))
this.{self::Class::_#field} = #t2;
else
- throw "Field 'field' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'field' has already been initialized.");
}
class Subclass extends self::Class {
constructor constructor1() → self::Subclass
diff --git a/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart.strong.transformed.expect
index 8e4ad19..1e31185 100644
--- a/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_final_field_without_initializer.dart.strong.transformed.expect
@@ -1,6 +1,7 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
field core::int? _#field = null;
@@ -17,12 +18,12 @@
: self::Class::_#field = field, super core::Object::•()
;
get field() → core::int
- return let final core::int? #t1 = this.{self::Class::_#field} in #t1.==(null) ?{core::int} throw "Field 'field' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = this.{self::Class::_#field} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'field' has not been initialized.") : #t1{core::int};
set field(core::int #t2) → void
if(this.{self::Class::_#field}.==(null))
this.{self::Class::_#field} = #t2;
else
- throw "Field 'field' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'field' has already been initialized.");
}
class Subclass extends self::Class {
constructor constructor1() → self::Subclass
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart b/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart
index c7bf971..a7f362f 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart
@@ -8,9 +8,9 @@
late int? field = initField();
Class.constructor1();
- Class.constructor2(int this.field);
+ Class.constructor2(this.field);
Class.constructor3(int value) : this.field = value + 1;
- Class.constructor4([int this.field = 42]);
+ Class.constructor4([this.field = 42]);
}
class Subclass extends Class {
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.outline.expect
index 395faa3..208d20e 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.outline.expect
@@ -4,14 +4,14 @@
class Class extends core::Object {
field core::int? _#field;
- field dynamic _#field#isSet;
+ field core::bool _#field#isSet;
constructor constructor1() → self::Class
;
- constructor constructor2(core::int field) → self::Class
+ constructor constructor2(core::int? field) → self::Class
;
constructor constructor3(core::int value) → self::Class
;
- constructor constructor4([core::int field]) → self::Class
+ constructor constructor4([core::int? field]) → self::Class
;
get field() → core::int?;
set field(core::int? #t1) → void;
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.strong.expect
index b7e7998..ce5887c 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.strong.expect
@@ -4,17 +4,17 @@
class Class extends core::Object {
field core::int? _#field = null;
- field dynamic _#field#isSet = false;
+ field core::bool _#field#isSet = false;
constructor constructor1() → self::Class
: super core::Object::•()
;
- constructor constructor2(core::int field) → self::Class
+ constructor constructor2(core::int? field) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
constructor constructor3(core::int value) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = value.{core::num::+}(1), super core::Object::•()
;
- constructor constructor4([core::int field = #C1]) → self::Class
+ constructor constructor4([core::int? field = #C1]) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
get field() → core::int? {
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.strong.transformed.expect
index b7e7998..ce5887c 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_field_with_initializer.dart.strong.transformed.expect
@@ -4,17 +4,17 @@
class Class extends core::Object {
field core::int? _#field = null;
- field dynamic _#field#isSet = false;
+ field core::bool _#field#isSet = false;
constructor constructor1() → self::Class
: super core::Object::•()
;
- constructor constructor2(core::int field) → self::Class
+ constructor constructor2(core::int? field) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
constructor constructor3(core::int value) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = value.{core::num::+}(1), super core::Object::•()
;
- constructor constructor4([core::int field = #C1]) → self::Class
+ constructor constructor4([core::int? field = #C1]) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
get field() → core::int? {
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart b/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart
index f3497a1..130430a 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart
@@ -6,9 +6,9 @@
late int? field;
Class.constructor1();
- Class.constructor2(int this.field);
+ Class.constructor2(this.field);
Class.constructor3(int value) : this.field = value + 1;
- Class.constructor4([int this.field = 42]);
+ Class.constructor4([this.field = 42]);
}
class Subclass extends Class {
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.outline.expect
index 4a4e3d4..7e493d3 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.outline.expect
@@ -4,14 +4,14 @@
class Class extends core::Object {
field core::int? _#field;
- field dynamic _#field#isSet;
+ field core::bool _#field#isSet;
constructor constructor1() → self::Class
;
- constructor constructor2(core::int field) → self::Class
+ constructor constructor2(core::int? field) → self::Class
;
constructor constructor3(core::int value) → self::Class
;
- constructor constructor4([core::int field]) → self::Class
+ constructor constructor4([core::int? field]) → self::Class
;
get field() → core::int?;
set field(core::int? #t1) → void;
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.strong.expect
index 33b5099..e54098e 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.strong.expect
@@ -1,24 +1,25 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
field core::int? _#field = null;
- field dynamic _#field#isSet = false;
+ field core::bool _#field#isSet = false;
constructor constructor1() → self::Class
: super core::Object::•()
;
- constructor constructor2(core::int field) → self::Class
+ constructor constructor2(core::int? field) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
constructor constructor3(core::int value) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = value.{core::num::+}(1), super core::Object::•()
;
- constructor constructor4([core::int field = #C1]) → self::Class
+ constructor constructor4([core::int? field = #C1]) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
get field() → core::int?
- return this.{self::Class::_#field#isSet} ?{core::int?} this.{self::Class::_#field} : throw "Field 'field' has not been initialized.";
+ return this.{self::Class::_#field#isSet} ?{core::int?} this.{self::Class::_#field} : throw new _in::LateInitializationErrorImpl::•("Field 'field' has not been initialized.");
set field(core::int? #t1) → void {
this.{self::Class::_#field#isSet} = true;
this.{self::Class::_#field} = #t1;
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.strong.transformed.expect
index 33b5099..e54098e 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_field_without_initializer.dart.strong.transformed.expect
@@ -1,24 +1,25 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
field core::int? _#field = null;
- field dynamic _#field#isSet = false;
+ field core::bool _#field#isSet = false;
constructor constructor1() → self::Class
: super core::Object::•()
;
- constructor constructor2(core::int field) → self::Class
+ constructor constructor2(core::int? field) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
constructor constructor3(core::int value) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = value.{core::num::+}(1), super core::Object::•()
;
- constructor constructor4([core::int field = #C1]) → self::Class
+ constructor constructor4([core::int? field = #C1]) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
get field() → core::int?
- return this.{self::Class::_#field#isSet} ?{core::int?} this.{self::Class::_#field} : throw "Field 'field' has not been initialized.";
+ return this.{self::Class::_#field#isSet} ?{core::int?} this.{self::Class::_#field} : throw new _in::LateInitializationErrorImpl::•("Field 'field' has not been initialized.");
set field(core::int? #t1) → void {
this.{self::Class::_#field#isSet} = true;
this.{self::Class::_#field} = #t1;
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart b/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart
index 7a79d4a..4b3c993 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart
@@ -6,9 +6,9 @@
late final int? field;
Class.constructor1();
- Class.constructor2(int this.field);
+ Class.constructor2(this.field);
Class.constructor3(int value) : this.field = value + 1;
- Class.constructor4([int this.field = 42]);
+ Class.constructor4([this.field = 42]);
}
class Subclass extends Class {
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.outline.expect
index 4a4e3d4..7e493d3 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.outline.expect
@@ -4,14 +4,14 @@
class Class extends core::Object {
field core::int? _#field;
- field dynamic _#field#isSet;
+ field core::bool _#field#isSet;
constructor constructor1() → self::Class
;
- constructor constructor2(core::int field) → self::Class
+ constructor constructor2(core::int? field) → self::Class
;
constructor constructor3(core::int value) → self::Class
;
- constructor constructor4([core::int field]) → self::Class
+ constructor constructor4([core::int? field]) → self::Class
;
get field() → core::int?;
set field(core::int? #t1) → void;
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.strong.expect
index f4ff248..14a09f4 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.strong.expect
@@ -1,27 +1,28 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
field core::int? _#field = null;
- field dynamic _#field#isSet = false;
+ field core::bool _#field#isSet = false;
constructor constructor1() → self::Class
: super core::Object::•()
;
- constructor constructor2(core::int field) → self::Class
+ constructor constructor2(core::int? field) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
constructor constructor3(core::int value) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = value.{core::num::+}(1), super core::Object::•()
;
- constructor constructor4([core::int field = #C1]) → self::Class
+ constructor constructor4([core::int? field = #C1]) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
get field() → core::int?
- return this.{self::Class::_#field#isSet} ?{core::int?} this.{self::Class::_#field} : throw "Field 'field' has not been initialized.";
+ return this.{self::Class::_#field#isSet} ?{core::int?} this.{self::Class::_#field} : throw new _in::LateInitializationErrorImpl::•("Field 'field' has not been initialized.");
set field(core::int? #t1) → void
if(this.{self::Class::_#field#isSet})
- throw "Field 'field' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'field' has already been initialized.");
else {
this.{self::Class::_#field#isSet} = true;
this.{self::Class::_#field} = #t1;
diff --git a/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.strong.transformed.expect
index f4ff248..14a09f4 100644
--- a/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/instance_nullable_final_field_without_initializer.dart.strong.transformed.expect
@@ -1,27 +1,28 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
field core::int? _#field = null;
- field dynamic _#field#isSet = false;
+ field core::bool _#field#isSet = false;
constructor constructor1() → self::Class
: super core::Object::•()
;
- constructor constructor2(core::int field) → self::Class
+ constructor constructor2(core::int? field) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
constructor constructor3(core::int value) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = value.{core::num::+}(1), super core::Object::•()
;
- constructor constructor4([core::int field = #C1]) → self::Class
+ constructor constructor4([core::int? field = #C1]) → self::Class
: self::Class::_#field#isSet = true, self::Class::_#field = field, super core::Object::•()
;
get field() → core::int?
- return this.{self::Class::_#field#isSet} ?{core::int?} this.{self::Class::_#field} : throw "Field 'field' has not been initialized.";
+ return this.{self::Class::_#field#isSet} ?{core::int?} this.{self::Class::_#field} : throw new _in::LateInitializationErrorImpl::•("Field 'field' has not been initialized.");
set field(core::int? #t1) → void
if(this.{self::Class::_#field#isSet})
- throw "Field 'field' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'field' has already been initialized.");
else {
this.{self::Class::_#field#isSet} = true;
this.{self::Class::_#field} = #t1;
diff --git a/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.outline.expect
index dff7386..e28ea8c 100644
--- a/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.outline.expect
@@ -6,7 +6,7 @@
static field core::int? _#lateStaticField1;
static field core::int? _#lateStaticField2;
field core::int? _#lateInstanceField;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
static get lateStaticField1() → core::int;
static set lateStaticField1(core::int #t1) → void;
diff --git a/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.strong.expect
index f873e75..41775a2 100644
--- a/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.strong.expect
@@ -6,7 +6,7 @@
static field core::int? _#lateStaticField1 = null;
static field core::int? _#lateStaticField2 = null;
field core::int? _#lateInstanceField = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static get lateStaticField1() → core::int
diff --git a/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.strong.transformed.expect
index f873e75..41775a2 100644
--- a/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_field_with_initializer.dart.strong.transformed.expect
@@ -6,7 +6,7 @@
static field core::int? _#lateStaticField1 = null;
static field core::int? _#lateStaticField2 = null;
field core::int? _#lateInstanceField = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static get lateStaticField1() → core::int
diff --git a/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.outline.expect
index 553fa89..e7e3cc1 100644
--- a/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.outline.expect
@@ -6,7 +6,7 @@
static field core::int? _#lateStaticField1;
static field core::int? _#lateStaticField2;
field core::int? _#lateInstanceField;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
static get lateStaticField1() → core::int;
static set lateStaticField1(core::int #t1) → void;
diff --git a/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.strong.expect
index a61fbc2..299a721 100644
--- a/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.strong.expect
@@ -1,20 +1,21 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
static field core::int? _#lateStaticField1 = null;
static field core::int? _#lateStaticField2 = null;
field core::int? _#lateInstanceField = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static get lateStaticField1() → core::int
- return let final core::int? #t1 = self::Class::_#lateStaticField1 in #t1.==(null) ?{core::int} throw "Field 'lateStaticField1' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = self::Class::_#lateStaticField1 in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has not been initialized.") : #t1{core::int};
static set lateStaticField1(core::int #t2) → void
self::Class::_#lateStaticField1 = #t2;
static get lateStaticField2() → core::int
- return let final core::int? #t3 = self::Class::_#lateStaticField2 in #t3.==(null) ?{core::int} throw "Field 'lateStaticField2' has not been initialized." : #t3{core::int};
+ return let final core::int? #t3 = self::Class::_#lateStaticField2 in #t3.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has not been initialized.") : #t3{core::int};
static set lateStaticField2(core::int #t4) → void
self::Class::_#lateStaticField2 = #t4;
static method staticMethod() → dynamic {
@@ -23,7 +24,7 @@
self::expect(42, self::Class::lateStaticField2);
}
get lateInstanceField() → core::int
- return let final core::int? #t5 = this.{self::Class::_#lateInstanceField} in #t5.==(null) ?{core::int} throw "Field 'lateInstanceField' has not been initialized." : #t5{core::int};
+ return let final core::int? #t5 = this.{self::Class::_#lateInstanceField} in #t5.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has not been initialized.") : #t5{core::int};
set lateInstanceField(core::int #t6) → void
this.{self::Class::_#lateInstanceField} = #t6;
method instanceMethod() → dynamic {
@@ -34,7 +35,7 @@
}
static field core::int? _#lateTopLevelField = null;
static get lateTopLevelField() → core::int
- return let final core::int? #t7 = self::_#lateTopLevelField in #t7.==(null) ?{core::int} throw "Field 'lateTopLevelField' has not been initialized." : #t7{core::int};
+ return let final core::int? #t7 = self::_#lateTopLevelField in #t7.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has not been initialized.") : #t7{core::int};
static set lateTopLevelField(core::int #t8) → void
self::_#lateTopLevelField = #t8;
static method main() → dynamic {
diff --git a/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.strong.transformed.expect
index a61fbc2..299a721 100644
--- a/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_field_without_initializer.dart.strong.transformed.expect
@@ -1,20 +1,21 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
static field core::int? _#lateStaticField1 = null;
static field core::int? _#lateStaticField2 = null;
field core::int? _#lateInstanceField = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static get lateStaticField1() → core::int
- return let final core::int? #t1 = self::Class::_#lateStaticField1 in #t1.==(null) ?{core::int} throw "Field 'lateStaticField1' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = self::Class::_#lateStaticField1 in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has not been initialized.") : #t1{core::int};
static set lateStaticField1(core::int #t2) → void
self::Class::_#lateStaticField1 = #t2;
static get lateStaticField2() → core::int
- return let final core::int? #t3 = self::Class::_#lateStaticField2 in #t3.==(null) ?{core::int} throw "Field 'lateStaticField2' has not been initialized." : #t3{core::int};
+ return let final core::int? #t3 = self::Class::_#lateStaticField2 in #t3.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has not been initialized.") : #t3{core::int};
static set lateStaticField2(core::int #t4) → void
self::Class::_#lateStaticField2 = #t4;
static method staticMethod() → dynamic {
@@ -23,7 +24,7 @@
self::expect(42, self::Class::lateStaticField2);
}
get lateInstanceField() → core::int
- return let final core::int? #t5 = this.{self::Class::_#lateInstanceField} in #t5.==(null) ?{core::int} throw "Field 'lateInstanceField' has not been initialized." : #t5{core::int};
+ return let final core::int? #t5 = this.{self::Class::_#lateInstanceField} in #t5.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has not been initialized.") : #t5{core::int};
set lateInstanceField(core::int #t6) → void
this.{self::Class::_#lateInstanceField} = #t6;
method instanceMethod() → dynamic {
@@ -34,7 +35,7 @@
}
static field core::int? _#lateTopLevelField = null;
static get lateTopLevelField() → core::int
- return let final core::int? #t7 = self::_#lateTopLevelField in #t7.==(null) ?{core::int} throw "Field 'lateTopLevelField' has not been initialized." : #t7{core::int};
+ return let final core::int? #t7 = self::_#lateTopLevelField in #t7.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has not been initialized.") : #t7{core::int};
static set lateTopLevelField(core::int #t8) → void
self::_#lateTopLevelField = #t8;
static method main() → dynamic {
diff --git a/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.outline.expect
index 42bc15e..5b6009a 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.outline.expect
@@ -9,7 +9,7 @@
static field core::int? _#lateStaticField2;
field core::int? lateInstanceFieldInit;
field core::int? _#lateInstanceField;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
static method initLateStaticField1(core::int value) → core::int
;
diff --git a/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.strong.expect
index 69ddb3c..dcc2bf2 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.strong.expect
@@ -9,7 +9,7 @@
static field core::int? _#lateStaticField2 = null;
field core::int? lateInstanceFieldInit = null;
field core::int? _#lateInstanceField = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static method initLateStaticField1(core::int value) → core::int {
diff --git a/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.strong.transformed.expect
index 69ddb3c..dcc2bf2 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_field_with_initializer.dart.strong.transformed.expect
@@ -9,7 +9,7 @@
static field core::int? _#lateStaticField2 = null;
field core::int? lateInstanceFieldInit = null;
field core::int? _#lateInstanceField = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static method initLateStaticField1(core::int value) → core::int {
diff --git a/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.outline.expect
index 553fa89..e7e3cc1 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.outline.expect
@@ -6,7 +6,7 @@
static field core::int? _#lateStaticField1;
static field core::int? _#lateStaticField2;
field core::int? _#lateInstanceField;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
static get lateStaticField1() → core::int;
static set lateStaticField1(core::int #t1) → void;
diff --git a/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.strong.expect
index 0617737..9034ca3 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.strong.expect
@@ -1,28 +1,29 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
static field core::int? _#lateStaticField1 = null;
static field core::int? _#lateStaticField2 = null;
field core::int? _#lateInstanceField = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static get lateStaticField1() → core::int
- return let final core::int? #t1 = self::Class::_#lateStaticField1 in #t1.==(null) ?{core::int} throw "Field 'lateStaticField1' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = self::Class::_#lateStaticField1 in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has not been initialized.") : #t1{core::int};
static set lateStaticField1(core::int #t2) → void
if(self::Class::_#lateStaticField1.==(null))
self::Class::_#lateStaticField1 = #t2;
else
- throw "Field 'lateStaticField1' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has already been initialized.");
static get lateStaticField2() → core::int
- return let final core::int? #t3 = self::Class::_#lateStaticField2 in #t3.==(null) ?{core::int} throw "Field 'lateStaticField2' has not been initialized." : #t3{core::int};
+ return let final core::int? #t3 = self::Class::_#lateStaticField2 in #t3.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has not been initialized.") : #t3{core::int};
static set lateStaticField2(core::int #t4) → void
if(self::Class::_#lateStaticField2.==(null))
self::Class::_#lateStaticField2 = #t4;
else
- throw "Field 'lateStaticField2' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has already been initialized.");
static method staticMethod() → dynamic {
self::throws(() → core::int => self::Class::lateStaticField2, "Read value from uninitialized Class.lateStaticField2");
self::Class::lateStaticField2 = 42;
@@ -30,12 +31,12 @@
self::throws(() → core::int => self::Class::lateStaticField2 = 43, "Write value to initialized Class.lateStaticField2");
}
get lateInstanceField() → core::int
- return let final core::int? #t5 = this.{self::Class::_#lateInstanceField} in #t5.==(null) ?{core::int} throw "Field 'lateInstanceField' has not been initialized." : #t5{core::int};
+ return let final core::int? #t5 = this.{self::Class::_#lateInstanceField} in #t5.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has not been initialized.") : #t5{core::int};
set lateInstanceField(core::int #t6) → void
if(this.{self::Class::_#lateInstanceField}.==(null))
this.{self::Class::_#lateInstanceField} = #t6;
else
- throw "Field 'lateInstanceField' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has already been initialized.");
method instanceMethod() → dynamic {
self::throws(() → core::int => this.{self::Class::lateInstanceField}, "Read value from uninitialized Class.lateInstanceField");
this.{self::Class::lateInstanceField} = 16;
@@ -45,12 +46,12 @@
}
static field core::int? _#lateTopLevelField = null;
static get lateTopLevelField() → core::int
- return let final core::int? #t7 = self::_#lateTopLevelField in #t7.==(null) ?{core::int} throw "Field 'lateTopLevelField' has not been initialized." : #t7{core::int};
+ return let final core::int? #t7 = self::_#lateTopLevelField in #t7.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has not been initialized.") : #t7{core::int};
static set lateTopLevelField(core::int #t8) → void
if(self::_#lateTopLevelField.==(null))
self::_#lateTopLevelField = #t8;
else
- throw "Field 'lateTopLevelField' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has already been initialized.");
static method main() → dynamic {
self::throws(() → core::int => self::lateTopLevelField, "Read value from uninitialized lateTopLevelField");
self::lateTopLevelField = 123;
diff --git a/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.strong.transformed.expect
index 0617737..9034ca3 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_field_without_initializer.dart.strong.transformed.expect
@@ -1,28 +1,29 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
static field core::int? _#lateStaticField1 = null;
static field core::int? _#lateStaticField2 = null;
field core::int? _#lateInstanceField = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static get lateStaticField1() → core::int
- return let final core::int? #t1 = self::Class::_#lateStaticField1 in #t1.==(null) ?{core::int} throw "Field 'lateStaticField1' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = self::Class::_#lateStaticField1 in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has not been initialized.") : #t1{core::int};
static set lateStaticField1(core::int #t2) → void
if(self::Class::_#lateStaticField1.==(null))
self::Class::_#lateStaticField1 = #t2;
else
- throw "Field 'lateStaticField1' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has already been initialized.");
static get lateStaticField2() → core::int
- return let final core::int? #t3 = self::Class::_#lateStaticField2 in #t3.==(null) ?{core::int} throw "Field 'lateStaticField2' has not been initialized." : #t3{core::int};
+ return let final core::int? #t3 = self::Class::_#lateStaticField2 in #t3.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has not been initialized.") : #t3{core::int};
static set lateStaticField2(core::int #t4) → void
if(self::Class::_#lateStaticField2.==(null))
self::Class::_#lateStaticField2 = #t4;
else
- throw "Field 'lateStaticField2' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has already been initialized.");
static method staticMethod() → dynamic {
self::throws(() → core::int => self::Class::lateStaticField2, "Read value from uninitialized Class.lateStaticField2");
self::Class::lateStaticField2 = 42;
@@ -30,12 +31,12 @@
self::throws(() → core::int => self::Class::lateStaticField2 = 43, "Write value to initialized Class.lateStaticField2");
}
get lateInstanceField() → core::int
- return let final core::int? #t5 = this.{self::Class::_#lateInstanceField} in #t5.==(null) ?{core::int} throw "Field 'lateInstanceField' has not been initialized." : #t5{core::int};
+ return let final core::int? #t5 = this.{self::Class::_#lateInstanceField} in #t5.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has not been initialized.") : #t5{core::int};
set lateInstanceField(core::int #t6) → void
if(this.{self::Class::_#lateInstanceField}.==(null))
this.{self::Class::_#lateInstanceField} = #t6;
else
- throw "Field 'lateInstanceField' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has already been initialized.");
method instanceMethod() → dynamic {
self::throws(() → core::int => this.{self::Class::lateInstanceField}, "Read value from uninitialized Class.lateInstanceField");
this.{self::Class::lateInstanceField} = 16;
@@ -45,12 +46,12 @@
}
static field core::int? _#lateTopLevelField = null;
static get lateTopLevelField() → core::int
- return let final core::int? #t7 = self::_#lateTopLevelField in #t7.==(null) ?{core::int} throw "Field 'lateTopLevelField' has not been initialized." : #t7{core::int};
+ return let final core::int? #t7 = self::_#lateTopLevelField in #t7.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has not been initialized.") : #t7{core::int};
static set lateTopLevelField(core::int #t8) → void
if(self::_#lateTopLevelField.==(null))
self::_#lateTopLevelField = #t8;
else
- throw "Field 'lateTopLevelField' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has already been initialized.");
static method main() → dynamic {
self::throws(() → core::int => self::lateTopLevelField, "Read value from uninitialized lateTopLevelField");
self::lateTopLevelField = 123;
diff --git a/pkg/front_end/testcases/late_lowering/late_final_local_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_final_local_without_initializer.dart.strong.expect
index 904b411..e918f09 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_local_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_local_without_initializer.dart.strong.expect
@@ -1,16 +1,17 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method main() → dynamic {
final core::int? lateLocal;
function #lateLocal#get() → core::int
- return let final core::int? #t1 = lateLocal in #t1.==(null) ?{core::int} throw "Local 'lateLocal' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = lateLocal in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has not been initialized.") : #t1{core::int};
function #lateLocal#set(core::int #t2) → dynamic
if(lateLocal.==(null))
return lateLocal = #t2;
else
- throw "Local 'lateLocal' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has already been initialized.");
self::throws(() → core::int? => #lateLocal#get.call(), "Read value from uninitialized lateLocal");
self::expect(123, #lateLocal#set.call(123));
self::expect(123, #lateLocal#get.call());
diff --git a/pkg/front_end/testcases/late_lowering/late_final_local_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_final_local_without_initializer.dart.strong.transformed.expect
index 904b411..e918f09 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_local_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_local_without_initializer.dart.strong.transformed.expect
@@ -1,16 +1,17 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method main() → dynamic {
final core::int? lateLocal;
function #lateLocal#get() → core::int
- return let final core::int? #t1 = lateLocal in #t1.==(null) ?{core::int} throw "Local 'lateLocal' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = lateLocal in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has not been initialized.") : #t1{core::int};
function #lateLocal#set(core::int #t2) → dynamic
if(lateLocal.==(null))
return lateLocal = #t2;
else
- throw "Local 'lateLocal' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has already been initialized.");
self::throws(() → core::int? => #lateLocal#get.call(), "Read value from uninitialized lateLocal");
self::expect(123, #lateLocal#set.call(123));
self::expect(123, #lateLocal#get.call());
diff --git a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.outline.expect
index d9b8c23..64c696d 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.outline.expect
@@ -5,14 +5,14 @@
class Class extends core::Object {
static field core::int? lateStaticField1Init;
static field core::int? _#lateStaticField1;
- static field dynamic _#lateStaticField1#isSet;
+ static field core::bool _#lateStaticField1#isSet;
static field core::int? lateStaticField2Init;
static field core::int? _#lateStaticField2;
- static field dynamic _#lateStaticField2#isSet;
+ static field core::bool _#lateStaticField2#isSet;
field core::int? lateInstanceFieldInit;
field core::int? _#lateInstanceField;
- field dynamic _#lateInstanceField#isSet;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet;
+ synthetic constructor •() → self::Class
;
static method initLateStaticField1(core::int value) → core::int?
;
@@ -30,7 +30,7 @@
}
static field core::int? lateTopLevelField1Init;
static field core::int? _#lateTopLevelField1;
-static field dynamic _#lateTopLevelField1#isSet;
+static field core::bool _#lateTopLevelField1#isSet;
static method initLateTopLevelField1(core::int value) → core::int?
;
static get lateTopLevelField1() → core::int?;
diff --git a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.strong.expect
index d26702c..69fa89d 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.strong.expect
@@ -5,14 +5,14 @@
class Class extends core::Object {
static field core::int? lateStaticField1Init = null;
static field core::int? _#lateStaticField1 = null;
- static field dynamic _#lateStaticField1#isSet = false;
+ static field core::bool _#lateStaticField1#isSet = false;
static field core::int? lateStaticField2Init = null;
static field core::int? _#lateStaticField2 = null;
- static field dynamic _#lateStaticField2#isSet = false;
+ static field core::bool _#lateStaticField2#isSet = false;
field core::int? lateInstanceFieldInit = null;
field core::int? _#lateInstanceField = null;
- field dynamic _#lateInstanceField#isSet = false;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet = false;
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static method initLateStaticField1(core::int value) → core::int? {
@@ -58,7 +58,7 @@
}
static field core::int? lateTopLevelField1Init;
static field core::int? _#lateTopLevelField1 = null;
-static field dynamic _#lateTopLevelField1#isSet = false;
+static field core::bool _#lateTopLevelField1#isSet = false;
static method initLateTopLevelField1(core::int value) → core::int? {
return self::lateTopLevelField1Init = value;
}
diff --git a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.strong.transformed.expect
index d26702c..69fa89d 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_with_initializer.dart.strong.transformed.expect
@@ -5,14 +5,14 @@
class Class extends core::Object {
static field core::int? lateStaticField1Init = null;
static field core::int? _#lateStaticField1 = null;
- static field dynamic _#lateStaticField1#isSet = false;
+ static field core::bool _#lateStaticField1#isSet = false;
static field core::int? lateStaticField2Init = null;
static field core::int? _#lateStaticField2 = null;
- static field dynamic _#lateStaticField2#isSet = false;
+ static field core::bool _#lateStaticField2#isSet = false;
field core::int? lateInstanceFieldInit = null;
field core::int? _#lateInstanceField = null;
- field dynamic _#lateInstanceField#isSet = false;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet = false;
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static method initLateStaticField1(core::int value) → core::int? {
@@ -58,7 +58,7 @@
}
static field core::int? lateTopLevelField1Init;
static field core::int? _#lateTopLevelField1 = null;
-static field dynamic _#lateTopLevelField1#isSet = false;
+static field core::bool _#lateTopLevelField1#isSet = false;
static method initLateTopLevelField1(core::int value) → core::int? {
return self::lateTopLevelField1Init = value;
}
diff --git a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.outline.expect
index 9dc7c80..cb84a8b 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.outline.expect
@@ -4,12 +4,12 @@
class Class extends core::Object {
static field core::int? _#lateStaticField1;
- static field dynamic _#lateStaticField1#isSet;
+ static field core::bool _#lateStaticField1#isSet;
static field core::int? _#lateStaticField2;
- static field dynamic _#lateStaticField2#isSet;
+ static field core::bool _#lateStaticField2#isSet;
field core::int? _#lateInstanceField;
- field dynamic _#lateInstanceField#isSet;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet;
+ synthetic constructor •() → self::Class
;
static get lateStaticField1() → core::int?;
static set lateStaticField1(core::int? #t1) → void;
@@ -23,7 +23,7 @@
;
}
static field core::int? _#lateTopLevelField;
-static field dynamic _#lateTopLevelField#isSet;
+static field core::bool _#lateTopLevelField#isSet;
static get lateTopLevelField() → core::int?;
static set lateTopLevelField(core::int? #t4) → void;
static method main() → dynamic
diff --git a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.strong.expect
index fff7e44..7af514e 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.strong.expect
@@ -1,31 +1,32 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
static field core::int? _#lateStaticField1 = null;
- static field dynamic _#lateStaticField1#isSet = false;
+ static field core::bool _#lateStaticField1#isSet = false;
static field core::int? _#lateStaticField2 = null;
- static field dynamic _#lateStaticField2#isSet = false;
+ static field core::bool _#lateStaticField2#isSet = false;
field core::int? _#lateInstanceField = null;
- field dynamic _#lateInstanceField#isSet = false;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet = false;
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static get lateStaticField1() → core::int?
- return self::Class::_#lateStaticField1#isSet ?{core::int?} self::Class::_#lateStaticField1 : throw "Field 'lateStaticField1' has not been initialized.";
+ return self::Class::_#lateStaticField1#isSet ?{core::int?} self::Class::_#lateStaticField1 : throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has not been initialized.");
static set lateStaticField1(core::int? #t1) → void
if(self::Class::_#lateStaticField1#isSet)
- throw "Field 'lateStaticField1' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has already been initialized.");
else {
self::Class::_#lateStaticField1#isSet = true;
self::Class::_#lateStaticField1 = #t1;
}
static get lateStaticField2() → core::int?
- return self::Class::_#lateStaticField2#isSet ?{core::int?} self::Class::_#lateStaticField2 : throw "Field 'lateStaticField2' has not been initialized.";
+ return self::Class::_#lateStaticField2#isSet ?{core::int?} self::Class::_#lateStaticField2 : throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has not been initialized.");
static set lateStaticField2(core::int? #t2) → void
if(self::Class::_#lateStaticField2#isSet)
- throw "Field 'lateStaticField2' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has already been initialized.");
else {
self::Class::_#lateStaticField2#isSet = true;
self::Class::_#lateStaticField2 = #t2;
@@ -37,10 +38,10 @@
self::throws(() → core::int => self::Class::lateStaticField2 = 43, "Write value to initialized Class.lateStaticField2");
}
get lateInstanceField() → core::int?
- return this.{self::Class::_#lateInstanceField#isSet} ?{core::int?} this.{self::Class::_#lateInstanceField} : throw "Field 'lateInstanceField' has not been initialized.";
+ return this.{self::Class::_#lateInstanceField#isSet} ?{core::int?} this.{self::Class::_#lateInstanceField} : throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has not been initialized.");
set lateInstanceField(core::int? #t3) → void
if(this.{self::Class::_#lateInstanceField#isSet})
- throw "Field 'lateInstanceField' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has already been initialized.");
else {
this.{self::Class::_#lateInstanceField#isSet} = true;
this.{self::Class::_#lateInstanceField} = #t3;
@@ -53,12 +54,12 @@
}
}
static field core::int? _#lateTopLevelField = null;
-static field dynamic _#lateTopLevelField#isSet = false;
+static field core::bool _#lateTopLevelField#isSet = false;
static get lateTopLevelField() → core::int?
- return self::_#lateTopLevelField#isSet ?{core::int?} self::_#lateTopLevelField : throw "Field 'lateTopLevelField' has not been initialized.";
+ return self::_#lateTopLevelField#isSet ?{core::int?} self::_#lateTopLevelField : throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has not been initialized.");
static set lateTopLevelField(core::int? #t4) → void
if(self::_#lateTopLevelField#isSet)
- throw "Field 'lateTopLevelField' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has already been initialized.");
else {
self::_#lateTopLevelField#isSet = true;
self::_#lateTopLevelField = #t4;
diff --git a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.strong.transformed.expect
index fff7e44..7af514e 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_nullable_field_without_initializer.dart.strong.transformed.expect
@@ -1,31 +1,32 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
static field core::int? _#lateStaticField1 = null;
- static field dynamic _#lateStaticField1#isSet = false;
+ static field core::bool _#lateStaticField1#isSet = false;
static field core::int? _#lateStaticField2 = null;
- static field dynamic _#lateStaticField2#isSet = false;
+ static field core::bool _#lateStaticField2#isSet = false;
field core::int? _#lateInstanceField = null;
- field dynamic _#lateInstanceField#isSet = false;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet = false;
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static get lateStaticField1() → core::int?
- return self::Class::_#lateStaticField1#isSet ?{core::int?} self::Class::_#lateStaticField1 : throw "Field 'lateStaticField1' has not been initialized.";
+ return self::Class::_#lateStaticField1#isSet ?{core::int?} self::Class::_#lateStaticField1 : throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has not been initialized.");
static set lateStaticField1(core::int? #t1) → void
if(self::Class::_#lateStaticField1#isSet)
- throw "Field 'lateStaticField1' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has already been initialized.");
else {
self::Class::_#lateStaticField1#isSet = true;
self::Class::_#lateStaticField1 = #t1;
}
static get lateStaticField2() → core::int?
- return self::Class::_#lateStaticField2#isSet ?{core::int?} self::Class::_#lateStaticField2 : throw "Field 'lateStaticField2' has not been initialized.";
+ return self::Class::_#lateStaticField2#isSet ?{core::int?} self::Class::_#lateStaticField2 : throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has not been initialized.");
static set lateStaticField2(core::int? #t2) → void
if(self::Class::_#lateStaticField2#isSet)
- throw "Field 'lateStaticField2' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has already been initialized.");
else {
self::Class::_#lateStaticField2#isSet = true;
self::Class::_#lateStaticField2 = #t2;
@@ -37,10 +38,10 @@
self::throws(() → core::int => self::Class::lateStaticField2 = 43, "Write value to initialized Class.lateStaticField2");
}
get lateInstanceField() → core::int?
- return this.{self::Class::_#lateInstanceField#isSet} ?{core::int?} this.{self::Class::_#lateInstanceField} : throw "Field 'lateInstanceField' has not been initialized.";
+ return this.{self::Class::_#lateInstanceField#isSet} ?{core::int?} this.{self::Class::_#lateInstanceField} : throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has not been initialized.");
set lateInstanceField(core::int? #t3) → void
if(this.{self::Class::_#lateInstanceField#isSet})
- throw "Field 'lateInstanceField' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has already been initialized.");
else {
this.{self::Class::_#lateInstanceField#isSet} = true;
this.{self::Class::_#lateInstanceField} = #t3;
@@ -53,12 +54,12 @@
}
}
static field core::int? _#lateTopLevelField = null;
-static field dynamic _#lateTopLevelField#isSet = false;
+static field core::bool _#lateTopLevelField#isSet = false;
static get lateTopLevelField() → core::int?
- return self::_#lateTopLevelField#isSet ?{core::int?} self::_#lateTopLevelField : throw "Field 'lateTopLevelField' has not been initialized.";
+ return self::_#lateTopLevelField#isSet ?{core::int?} self::_#lateTopLevelField : throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has not been initialized.");
static set lateTopLevelField(core::int? #t4) → void
if(self::_#lateTopLevelField#isSet)
- throw "Field 'lateTopLevelField' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has already been initialized.");
else {
self::_#lateTopLevelField#isSet = true;
self::_#lateTopLevelField = #t4;
diff --git a/pkg/front_end/testcases/late_lowering/late_final_nullable_local_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_final_nullable_local_without_initializer.dart.strong.expect
index 97cbe14..268b399 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_nullable_local_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_nullable_local_without_initializer.dart.strong.expect
@@ -1,15 +1,16 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method main() → dynamic {
final core::int? lateLocal;
core::bool #lateLocal#isSet = false;
function #lateLocal#get() → core::int?
- return #lateLocal#isSet ?{core::int?} lateLocal : throw "Local 'lateLocal' has not been initialized.";
+ return #lateLocal#isSet ?{core::int?} lateLocal : throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has not been initialized.");
function #lateLocal#set(core::int? #t1) → dynamic
if(#lateLocal#isSet)
- throw "Local 'lateLocal' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has already been initialized.");
else {
#lateLocal#isSet = true;
return lateLocal = #t1;
diff --git a/pkg/front_end/testcases/late_lowering/late_final_nullable_local_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_final_nullable_local_without_initializer.dart.strong.transformed.expect
index 97cbe14..268b399 100644
--- a/pkg/front_end/testcases/late_lowering/late_final_nullable_local_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_final_nullable_local_without_initializer.dart.strong.transformed.expect
@@ -1,15 +1,16 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method main() → dynamic {
final core::int? lateLocal;
core::bool #lateLocal#isSet = false;
function #lateLocal#get() → core::int?
- return #lateLocal#isSet ?{core::int?} lateLocal : throw "Local 'lateLocal' has not been initialized.";
+ return #lateLocal#isSet ?{core::int?} lateLocal : throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has not been initialized.");
function #lateLocal#set(core::int? #t1) → dynamic
if(#lateLocal#isSet)
- throw "Local 'lateLocal' has already been initialized.";
+ throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has already been initialized.");
else {
#lateLocal#isSet = true;
return lateLocal = #t1;
diff --git a/pkg/front_end/testcases/late_lowering/late_local_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_local_without_initializer.dart.strong.expect
index 7f10865..26d533b 100644
--- a/pkg/front_end/testcases/late_lowering/late_local_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_local_without_initializer.dart.strong.expect
@@ -1,11 +1,12 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method main() → dynamic {
core::int? lateLocal;
function #lateLocal#get() → core::int
- return let final core::int? #t1 = lateLocal in #t1.==(null) ?{core::int} throw "Local 'lateLocal' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = lateLocal in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has not been initialized.") : #t1{core::int};
function #lateLocal#set(core::int #t2) → dynamic
return lateLocal = #t2;
self::throws(() → core::int? => #lateLocal#get.call(), "Read value from uninitialized lateLocal");
diff --git a/pkg/front_end/testcases/late_lowering/late_local_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_local_without_initializer.dart.strong.transformed.expect
index 7f10865..26d533b 100644
--- a/pkg/front_end/testcases/late_lowering/late_local_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_local_without_initializer.dart.strong.transformed.expect
@@ -1,11 +1,12 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method main() → dynamic {
core::int? lateLocal;
function #lateLocal#get() → core::int
- return let final core::int? #t1 = lateLocal in #t1.==(null) ?{core::int} throw "Local 'lateLocal' has not been initialized." : #t1{core::int};
+ return let final core::int? #t1 = lateLocal in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has not been initialized.") : #t1{core::int};
function #lateLocal#set(core::int #t2) → dynamic
return lateLocal = #t2;
self::throws(() → core::int? => #lateLocal#get.call(), "Read value from uninitialized lateLocal");
diff --git a/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.outline.expect
index bc10a9a..b98c8ed 100644
--- a/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.outline.expect
@@ -4,12 +4,12 @@
class Class extends core::Object {
static field core::int? _#lateStaticField1;
- static field dynamic _#lateStaticField1#isSet;
+ static field core::bool _#lateStaticField1#isSet;
static field core::int? _#lateStaticField2;
- static field dynamic _#lateStaticField2#isSet;
+ static field core::bool _#lateStaticField2#isSet;
field core::int? _#lateInstanceField;
- field dynamic _#lateInstanceField#isSet;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet;
+ synthetic constructor •() → self::Class
;
static method lateStaticField1Init() → core::int?
;
@@ -29,7 +29,7 @@
;
}
static field core::int? _#lateTopLevelField1;
-static field dynamic _#lateTopLevelField1#isSet;
+static field core::bool _#lateTopLevelField1#isSet;
static method lateTopLevelField1Init() → core::int?
;
static get lateTopLevelField1() → core::int?;
diff --git a/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.strong.expect
index f0f3d5a..8ae398a 100644
--- a/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.strong.expect
@@ -4,12 +4,12 @@
class Class extends core::Object {
static field core::int? _#lateStaticField1 = null;
- static field dynamic _#lateStaticField1#isSet = false;
+ static field core::bool _#lateStaticField1#isSet = false;
static field core::int? _#lateStaticField2 = null;
- static field dynamic _#lateStaticField2#isSet = false;
+ static field core::bool _#lateStaticField2#isSet = false;
field core::int? _#lateInstanceField = null;
- field dynamic _#lateInstanceField#isSet = false;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet = false;
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static method lateStaticField1Init() → core::int?
@@ -63,7 +63,7 @@
}
}
static field core::int? _#lateTopLevelField1 = null;
-static field dynamic _#lateTopLevelField1#isSet = false;
+static field core::bool _#lateTopLevelField1#isSet = false;
static method lateTopLevelField1Init() → core::int?
return 123;
static get lateTopLevelField1() → core::int? {
diff --git a/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.strong.transformed.expect
index f0f3d5a..8ae398a 100644
--- a/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_nullable_field_with_initializer.dart.strong.transformed.expect
@@ -4,12 +4,12 @@
class Class extends core::Object {
static field core::int? _#lateStaticField1 = null;
- static field dynamic _#lateStaticField1#isSet = false;
+ static field core::bool _#lateStaticField1#isSet = false;
static field core::int? _#lateStaticField2 = null;
- static field dynamic _#lateStaticField2#isSet = false;
+ static field core::bool _#lateStaticField2#isSet = false;
field core::int? _#lateInstanceField = null;
- field dynamic _#lateInstanceField#isSet = false;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet = false;
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static method lateStaticField1Init() → core::int?
@@ -63,7 +63,7 @@
}
}
static field core::int? _#lateTopLevelField1 = null;
-static field dynamic _#lateTopLevelField1#isSet = false;
+static field core::bool _#lateTopLevelField1#isSet = false;
static method lateTopLevelField1Init() → core::int?
return 123;
static get lateTopLevelField1() → core::int? {
diff --git a/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.outline.expect b/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.outline.expect
index 9dc7c80..cb84a8b 100644
--- a/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.outline.expect
+++ b/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.outline.expect
@@ -4,12 +4,12 @@
class Class extends core::Object {
static field core::int? _#lateStaticField1;
- static field dynamic _#lateStaticField1#isSet;
+ static field core::bool _#lateStaticField1#isSet;
static field core::int? _#lateStaticField2;
- static field dynamic _#lateStaticField2#isSet;
+ static field core::bool _#lateStaticField2#isSet;
field core::int? _#lateInstanceField;
- field dynamic _#lateInstanceField#isSet;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet;
+ synthetic constructor •() → self::Class
;
static get lateStaticField1() → core::int?;
static set lateStaticField1(core::int? #t1) → void;
@@ -23,7 +23,7 @@
;
}
static field core::int? _#lateTopLevelField;
-static field dynamic _#lateTopLevelField#isSet;
+static field core::bool _#lateTopLevelField#isSet;
static get lateTopLevelField() → core::int?;
static set lateTopLevelField(core::int? #t4) → void;
static method main() → dynamic
diff --git a/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.strong.expect
index 68e4f55..d5c374c 100644
--- a/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.strong.expect
@@ -1,25 +1,26 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
static field core::int? _#lateStaticField1 = null;
- static field dynamic _#lateStaticField1#isSet = false;
+ static field core::bool _#lateStaticField1#isSet = false;
static field core::int? _#lateStaticField2 = null;
- static field dynamic _#lateStaticField2#isSet = false;
+ static field core::bool _#lateStaticField2#isSet = false;
field core::int? _#lateInstanceField = null;
- field dynamic _#lateInstanceField#isSet = false;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet = false;
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static get lateStaticField1() → core::int?
- return self::Class::_#lateStaticField1#isSet ?{core::int?} self::Class::_#lateStaticField1 : throw "Field 'lateStaticField1' has not been initialized.";
+ return self::Class::_#lateStaticField1#isSet ?{core::int?} self::Class::_#lateStaticField1 : throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has not been initialized.");
static set lateStaticField1(core::int? #t1) → void {
self::Class::_#lateStaticField1#isSet = true;
self::Class::_#lateStaticField1 = #t1;
}
static get lateStaticField2() → core::int?
- return self::Class::_#lateStaticField2#isSet ?{core::int?} self::Class::_#lateStaticField2 : throw "Field 'lateStaticField2' has not been initialized.";
+ return self::Class::_#lateStaticField2#isSet ?{core::int?} self::Class::_#lateStaticField2 : throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has not been initialized.");
static set lateStaticField2(core::int? #t2) → void {
self::Class::_#lateStaticField2#isSet = true;
self::Class::_#lateStaticField2 = #t2;
@@ -30,7 +31,7 @@
self::expect(42, self::Class::lateStaticField2);
}
get lateInstanceField() → core::int?
- return this.{self::Class::_#lateInstanceField#isSet} ?{core::int?} this.{self::Class::_#lateInstanceField} : throw "Field 'lateInstanceField' has not been initialized.";
+ return this.{self::Class::_#lateInstanceField#isSet} ?{core::int?} this.{self::Class::_#lateInstanceField} : throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has not been initialized.");
set lateInstanceField(core::int? #t3) → void {
this.{self::Class::_#lateInstanceField#isSet} = true;
this.{self::Class::_#lateInstanceField} = #t3;
@@ -42,9 +43,9 @@
}
}
static field core::int? _#lateTopLevelField = null;
-static field dynamic _#lateTopLevelField#isSet = false;
+static field core::bool _#lateTopLevelField#isSet = false;
static get lateTopLevelField() → core::int?
- return self::_#lateTopLevelField#isSet ?{core::int?} self::_#lateTopLevelField : throw "Field 'lateTopLevelField' has not been initialized.";
+ return self::_#lateTopLevelField#isSet ?{core::int?} self::_#lateTopLevelField : throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has not been initialized.");
static set lateTopLevelField(core::int? #t4) → void {
self::_#lateTopLevelField#isSet = true;
self::_#lateTopLevelField = #t4;
diff --git a/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.strong.transformed.expect
index 68e4f55..d5c374c 100644
--- a/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_nullable_field_without_initializer.dart.strong.transformed.expect
@@ -1,25 +1,26 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class Class extends core::Object {
static field core::int? _#lateStaticField1 = null;
- static field dynamic _#lateStaticField1#isSet = false;
+ static field core::bool _#lateStaticField1#isSet = false;
static field core::int? _#lateStaticField2 = null;
- static field dynamic _#lateStaticField2#isSet = false;
+ static field core::bool _#lateStaticField2#isSet = false;
field core::int? _#lateInstanceField = null;
- field dynamic _#lateInstanceField#isSet = false;
- synthetic constructor •() → self::Class*
+ field core::bool _#lateInstanceField#isSet = false;
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
static get lateStaticField1() → core::int?
- return self::Class::_#lateStaticField1#isSet ?{core::int?} self::Class::_#lateStaticField1 : throw "Field 'lateStaticField1' has not been initialized.";
+ return self::Class::_#lateStaticField1#isSet ?{core::int?} self::Class::_#lateStaticField1 : throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField1' has not been initialized.");
static set lateStaticField1(core::int? #t1) → void {
self::Class::_#lateStaticField1#isSet = true;
self::Class::_#lateStaticField1 = #t1;
}
static get lateStaticField2() → core::int?
- return self::Class::_#lateStaticField2#isSet ?{core::int?} self::Class::_#lateStaticField2 : throw "Field 'lateStaticField2' has not been initialized.";
+ return self::Class::_#lateStaticField2#isSet ?{core::int?} self::Class::_#lateStaticField2 : throw new _in::LateInitializationErrorImpl::•("Field 'lateStaticField2' has not been initialized.");
static set lateStaticField2(core::int? #t2) → void {
self::Class::_#lateStaticField2#isSet = true;
self::Class::_#lateStaticField2 = #t2;
@@ -30,7 +31,7 @@
self::expect(42, self::Class::lateStaticField2);
}
get lateInstanceField() → core::int?
- return this.{self::Class::_#lateInstanceField#isSet} ?{core::int?} this.{self::Class::_#lateInstanceField} : throw "Field 'lateInstanceField' has not been initialized.";
+ return this.{self::Class::_#lateInstanceField#isSet} ?{core::int?} this.{self::Class::_#lateInstanceField} : throw new _in::LateInitializationErrorImpl::•("Field 'lateInstanceField' has not been initialized.");
set lateInstanceField(core::int? #t3) → void {
this.{self::Class::_#lateInstanceField#isSet} = true;
this.{self::Class::_#lateInstanceField} = #t3;
@@ -42,9 +43,9 @@
}
}
static field core::int? _#lateTopLevelField = null;
-static field dynamic _#lateTopLevelField#isSet = false;
+static field core::bool _#lateTopLevelField#isSet = false;
static get lateTopLevelField() → core::int?
- return self::_#lateTopLevelField#isSet ?{core::int?} self::_#lateTopLevelField : throw "Field 'lateTopLevelField' has not been initialized.";
+ return self::_#lateTopLevelField#isSet ?{core::int?} self::_#lateTopLevelField : throw new _in::LateInitializationErrorImpl::•("Field 'lateTopLevelField' has not been initialized.");
static set lateTopLevelField(core::int? #t4) → void {
self::_#lateTopLevelField#isSet = true;
self::_#lateTopLevelField = #t4;
diff --git a/pkg/front_end/testcases/late_lowering/late_nullable_local_without_initializer.dart.strong.expect b/pkg/front_end/testcases/late_lowering/late_nullable_local_without_initializer.dart.strong.expect
index 7a9b940..1ce4c50 100644
--- a/pkg/front_end/testcases/late_lowering/late_nullable_local_without_initializer.dart.strong.expect
+++ b/pkg/front_end/testcases/late_lowering/late_nullable_local_without_initializer.dart.strong.expect
@@ -1,12 +1,13 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method main() → dynamic {
core::int? lateLocal;
core::bool #lateLocal#isSet = false;
function #lateLocal#get() → core::int?
- return #lateLocal#isSet ?{core::int?} lateLocal : throw "Local 'lateLocal' has not been initialized.";
+ return #lateLocal#isSet ?{core::int?} lateLocal : throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has not been initialized.");
function #lateLocal#set(core::int? #t1) → dynamic {
#lateLocal#isSet = true;
return lateLocal = #t1;
diff --git a/pkg/front_end/testcases/late_lowering/late_nullable_local_without_initializer.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/late_nullable_local_without_initializer.dart.strong.transformed.expect
index 7a9b940..1ce4c50 100644
--- a/pkg/front_end/testcases/late_lowering/late_nullable_local_without_initializer.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/late_lowering/late_nullable_local_without_initializer.dart.strong.transformed.expect
@@ -1,12 +1,13 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method main() → dynamic {
core::int? lateLocal;
core::bool #lateLocal#isSet = false;
function #lateLocal#get() → core::int?
- return #lateLocal#isSet ?{core::int?} lateLocal : throw "Local 'lateLocal' has not been initialized.";
+ return #lateLocal#isSet ?{core::int?} lateLocal : throw new _in::LateInitializationErrorImpl::•("Local 'lateLocal' has not been initialized.");
function #lateLocal#set(core::int? #t1) → dynamic {
#lateLocal#isSet = true;
return lateLocal = #t1;
diff --git a/pkg/front_end/testcases/nnbd/function_types.dart.outline.expect b/pkg/front_end/testcases/nnbd/function_types.dart.outline.expect
index 9ebda38..56f5079 100644
--- a/pkg/front_end/testcases/nnbd/function_types.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/function_types.dart.outline.expect
@@ -4,11 +4,11 @@
typedef F = () → void;
class A<T extends core::Object? = dynamic> extends core::Object {
- synthetic constructor •() → self::A<self::A::T%>*
+ synthetic constructor •() → self::A<self::A::T%>
;
}
class B extends self::A<() →? dynamic> {
- synthetic constructor •() → self::B*
+ synthetic constructor •() → self::B
;
method method(() →? dynamic x) → () →? dynamic
;
diff --git a/pkg/front_end/testcases/nnbd/function_types.dart.strong.expect b/pkg/front_end/testcases/nnbd/function_types.dart.strong.expect
index 8aab301..7531780 100644
--- a/pkg/front_end/testcases/nnbd/function_types.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/function_types.dart.strong.expect
@@ -4,12 +4,12 @@
typedef F = () → void;
class A<T extends core::Object? = dynamic> extends core::Object {
- synthetic constructor •() → self::A<self::A::T%>*
+ synthetic constructor •() → self::A<self::A::T%>
: super core::Object::•()
;
}
class B extends self::A<() →? dynamic> {
- synthetic constructor •() → self::B*
+ synthetic constructor •() → self::B
: super self::A::•()
;
method method(() →? dynamic x) → () →? dynamic
diff --git a/pkg/front_end/testcases/nnbd/function_types.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/function_types.dart.strong.transformed.expect
index 8aab301..7531780 100644
--- a/pkg/front_end/testcases/nnbd/function_types.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/function_types.dart.strong.transformed.expect
@@ -4,12 +4,12 @@
typedef F = () → void;
class A<T extends core::Object? = dynamic> extends core::Object {
- synthetic constructor •() → self::A<self::A::T%>*
+ synthetic constructor •() → self::A<self::A::T%>
: super core::Object::•()
;
}
class B extends self::A<() →? dynamic> {
- synthetic constructor •() → self::B*
+ synthetic constructor •() → self::B
: super self::A::•()
;
method method(() →? dynamic x) → () →? dynamic
diff --git a/pkg/front_end/testcases/nnbd/inheritance_from_opt_out.dart.outline.expect b/pkg/front_end/testcases/nnbd/inheritance_from_opt_out.dart.outline.expect
index 8d72534..0fd5843 100644
--- a/pkg/front_end/testcases/nnbd/inheritance_from_opt_out.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/inheritance_from_opt_out.dart.outline.expect
@@ -19,35 +19,35 @@
import "org-dartlang-testcase:///inheritance_from_opt_out_lib.dart";
class Class1 extends inh::LegacyClass1 {
- synthetic constructor •() → self::Class1*
+ synthetic constructor •() → self::Class1
;
}
class Class2<T extends core::Object? = dynamic> extends inh::LegacyClass2<self::Class2::T%> {
- synthetic constructor •() → self::Class2<self::Class2::T%>*
+ synthetic constructor •() → self::Class2<self::Class2::T%>
;
}
class Class3a<T extends core::Object? = dynamic> extends inh::LegacyClass3<self::Class3a::T%> {
- synthetic constructor •() → self::Class3a<self::Class3a::T%>*
+ synthetic constructor •() → self::Class3a<self::Class3a::T%>
;
}
class Class3b<T extends core::Object? = dynamic> extends inh::LegacyClass3<self::Class3b::T%> implements inh::GenericInterface<self::Class3b::T%> {
- synthetic constructor •() → self::Class3b<self::Class3b::T%>*
+ synthetic constructor •() → self::Class3b<self::Class3b::T%>
;
}
class Class4a extends inh::LegacyClass4 {
- synthetic constructor •() → self::Class4a*
+ synthetic constructor •() → self::Class4a
;
}
class Class4b extends core::Object implements inh::GenericInterface<core::num> {
- synthetic constructor •() → self::Class4b*
+ synthetic constructor •() → self::Class4b
;
}
class Class4c extends core::Object implements inh::GenericInterface<core::num?> {
- synthetic constructor •() → self::Class4c*
+ synthetic constructor •() → self::Class4c
;
}
class Class4d extends inh::LegacyClass4 implements inh::GenericInterface<core::num> {
- synthetic constructor •() → self::Class4d*
+ synthetic constructor •() → self::Class4d
;
}
static method main() → dynamic
diff --git a/pkg/front_end/testcases/nnbd/inheritance_from_opt_out.dart.strong.expect b/pkg/front_end/testcases/nnbd/inheritance_from_opt_out.dart.strong.expect
index 3b75a32..5c9ceb3 100644
--- a/pkg/front_end/testcases/nnbd/inheritance_from_opt_out.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/inheritance_from_opt_out.dart.strong.expect
@@ -19,42 +19,42 @@
import "org-dartlang-testcase:///inheritance_from_opt_out_lib.dart";
class Class1 extends inh::LegacyClass1 {
- synthetic constructor •() → self::Class1*
+ synthetic constructor •() → self::Class1
: super inh::LegacyClass1::•()
;
}
class Class2<T extends core::Object? = dynamic> extends inh::LegacyClass2<self::Class2::T%> {
- synthetic constructor •() → self::Class2<self::Class2::T%>*
+ synthetic constructor •() → self::Class2<self::Class2::T%>
: super inh::LegacyClass2::•()
;
}
class Class3a<T extends core::Object? = dynamic> extends inh::LegacyClass3<self::Class3a::T%> {
- synthetic constructor •() → self::Class3a<self::Class3a::T%>*
+ synthetic constructor •() → self::Class3a<self::Class3a::T%>
: super inh::LegacyClass3::•()
;
}
class Class3b<T extends core::Object? = dynamic> extends inh::LegacyClass3<self::Class3b::T%> implements inh::GenericInterface<self::Class3b::T%> {
- synthetic constructor •() → self::Class3b<self::Class3b::T%>*
+ synthetic constructor •() → self::Class3b<self::Class3b::T%>
: super inh::LegacyClass3::•()
;
}
class Class4a extends inh::LegacyClass4 {
- synthetic constructor •() → self::Class4a*
+ synthetic constructor •() → self::Class4a
: super inh::LegacyClass4::•()
;
}
class Class4b extends core::Object implements inh::GenericInterface<core::num> {
- synthetic constructor •() → self::Class4b*
+ synthetic constructor •() → self::Class4b
: super core::Object::•()
;
}
class Class4c extends core::Object implements inh::GenericInterface<core::num?> {
- synthetic constructor •() → self::Class4c*
+ synthetic constructor •() → self::Class4c
: super core::Object::•()
;
}
class Class4d extends inh::LegacyClass4 implements inh::GenericInterface<core::num> {
- synthetic constructor •() → self::Class4d*
+ synthetic constructor •() → self::Class4d
: super inh::LegacyClass4::•()
;
}
diff --git a/pkg/front_end/testcases/nnbd/intersection_types.dart.outline.expect b/pkg/front_end/testcases/nnbd/intersection_types.dart.outline.expect
index a1b7bfb..d27719d 100644
--- a/pkg/front_end/testcases/nnbd/intersection_types.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/intersection_types.dart.outline.expect
@@ -3,19 +3,19 @@
import "dart:core" as core;
class A extends core::Object {
- synthetic constructor •() → self::A*
+ synthetic constructor •() → self::A
;
}
class B extends self::A {
- synthetic constructor •() → self::B*
+ synthetic constructor •() → self::B
;
}
class C extends self::B {
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
;
}
class Foo<T extends self::A? = self::A?> extends core::Object {
- synthetic constructor •() → self::Foo<self::Foo::T%>*
+ synthetic constructor •() → self::Foo<self::Foo::T%>
;
method doPromotionsToNullable(generic-covariant-impl self::Foo::T% t) → dynamic
;
diff --git a/pkg/front_end/testcases/nnbd/intersection_types.dart.strong.expect b/pkg/front_end/testcases/nnbd/intersection_types.dart.strong.expect
index 4f137d3..7facb01 100644
--- a/pkg/front_end/testcases/nnbd/intersection_types.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/intersection_types.dart.strong.expect
@@ -3,22 +3,22 @@
import "dart:core" as core;
class A extends core::Object {
- synthetic constructor •() → self::A*
+ synthetic constructor •() → self::A
: super core::Object::•()
;
}
class B extends self::A {
- synthetic constructor •() → self::B*
+ synthetic constructor •() → self::B
: super self::A::•()
;
}
class C extends self::B {
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
: super self::B::•()
;
}
class Foo<T extends self::A? = self::A?> extends core::Object {
- synthetic constructor •() → self::Foo<self::Foo::T%>*
+ synthetic constructor •() → self::Foo<self::Foo::T%>
: super core::Object::•()
;
method doPromotionsToNullable(generic-covariant-impl self::Foo::T% t) → dynamic {
diff --git a/pkg/front_end/testcases/nnbd/intersection_types.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/intersection_types.dart.strong.transformed.expect
index 4f137d3..7facb01 100644
--- a/pkg/front_end/testcases/nnbd/intersection_types.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/intersection_types.dart.strong.transformed.expect
@@ -3,22 +3,22 @@
import "dart:core" as core;
class A extends core::Object {
- synthetic constructor •() → self::A*
+ synthetic constructor •() → self::A
: super core::Object::•()
;
}
class B extends self::A {
- synthetic constructor •() → self::B*
+ synthetic constructor •() → self::B
: super self::A::•()
;
}
class C extends self::B {
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
: super self::B::•()
;
}
class Foo<T extends self::A? = self::A?> extends core::Object {
- synthetic constructor •() → self::Foo<self::Foo::T%>*
+ synthetic constructor •() → self::Foo<self::Foo::T%>
: super core::Object::•()
;
method doPromotionsToNullable(generic-covariant-impl self::Foo::T% t) → dynamic {
diff --git a/pkg/front_end/testcases/nnbd/issue_39286.dart.outline.expect b/pkg/front_end/testcases/nnbd/issue_39286.dart.outline.expect
index acfeb30..2874413 100644
--- a/pkg/front_end/testcases/nnbd/issue_39286.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/issue_39286.dart.outline.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class C extends core::Object {
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
;
method f() → self::D?
;
@@ -11,7 +11,7 @@
;
}
class D extends core::Object {
- synthetic constructor •() → self::D*
+ synthetic constructor •() → self::D
;
method g() → void
;
diff --git a/pkg/front_end/testcases/nnbd/issue_39286.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue_39286.dart.strong.expect
index 108244e..ae125e8 100644
--- a/pkg/front_end/testcases/nnbd/issue_39286.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/issue_39286.dart.strong.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class C extends core::Object {
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
: super core::Object::•()
;
method f() → self::D?
@@ -11,7 +11,7 @@
method h() → void {}
}
class D extends core::Object {
- synthetic constructor •() → self::D*
+ synthetic constructor •() → self::D
: super core::Object::•()
;
method g() → void {}
diff --git a/pkg/front_end/testcases/nnbd/issue_39286.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/issue_39286.dart.strong.transformed.expect
index 108244e..ae125e8 100644
--- a/pkg/front_end/testcases/nnbd/issue_39286.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/issue_39286.dart.strong.transformed.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class C extends core::Object {
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
: super core::Object::•()
;
method f() → self::D?
@@ -11,7 +11,7 @@
method h() → void {}
}
class D extends core::Object {
- synthetic constructor •() → self::D*
+ synthetic constructor •() → self::D
: super core::Object::•()
;
method g() → void {}
diff --git a/pkg/front_end/testcases/nnbd/issue_39286_2.dart.outline.expect b/pkg/front_end/testcases/nnbd/issue_39286_2.dart.outline.expect
index f2c2b39..8872e99 100644
--- a/pkg/front_end/testcases/nnbd/issue_39286_2.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/issue_39286_2.dart.outline.expect
@@ -4,7 +4,7 @@
class C extends core::Object {
field core::int y;
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
;
method f() → self::D?
;
@@ -12,7 +12,7 @@
;
}
class D extends core::Object {
- synthetic constructor •() → self::D*
+ synthetic constructor •() → self::D
;
method g() → self::D
;
diff --git a/pkg/front_end/testcases/nnbd/issue_39286_2.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue_39286_2.dart.strong.expect
index 37e9149..32274dd 100644
--- a/pkg/front_end/testcases/nnbd/issue_39286_2.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/issue_39286_2.dart.strong.expect
@@ -4,7 +4,7 @@
class C extends core::Object {
field core::int y = null;
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
: super core::Object::•()
;
method f() → self::D?
@@ -13,7 +13,7 @@
return this;
}
class D extends core::Object {
- synthetic constructor •() → self::D*
+ synthetic constructor •() → self::D
: super core::Object::•()
;
method g() → self::D
diff --git a/pkg/front_end/testcases/nnbd/issue_39286_2.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/issue_39286_2.dart.strong.transformed.expect
index 37e9149..32274dd 100644
--- a/pkg/front_end/testcases/nnbd/issue_39286_2.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/issue_39286_2.dart.strong.transformed.expect
@@ -4,7 +4,7 @@
class C extends core::Object {
field core::int y = null;
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
: super core::Object::•()
;
method f() → self::D?
@@ -13,7 +13,7 @@
return this;
}
class D extends core::Object {
- synthetic constructor •() → self::D*
+ synthetic constructor •() → self::D
: super core::Object::•()
;
method g() → self::D
diff --git a/pkg/front_end/testcases/nnbd/late.dart.outline.expect b/pkg/front_end/testcases/nnbd/late.dart.outline.expect
index ab02fd7..88ea1d5 100644
--- a/pkg/front_end/testcases/nnbd/late.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/late.dart.outline.expect
@@ -13,7 +13,7 @@
late static final field core::int lateFinalStaticField1;
late static final field core::int lateFinalStaticField2;
late static final field core::int lateFinalStaticFieldWithInit;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
method method() → dynamic
;
diff --git a/pkg/front_end/testcases/nnbd/late.dart.strong.expect b/pkg/front_end/testcases/nnbd/late.dart.strong.expect
index f22251a..854f872 100644
--- a/pkg/front_end/testcases/nnbd/late.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/late.dart.strong.expect
@@ -44,7 +44,7 @@
late static final field core::int lateFinalStaticField1;
late static final field core::int lateFinalStaticField2;
late static final field core::int lateFinalStaticFieldWithInit = 0;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
method method() → dynamic {
diff --git a/pkg/front_end/testcases/nnbd/late.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/late.dart.strong.transformed.expect
index f22251a..854f872 100644
--- a/pkg/front_end/testcases/nnbd/late.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/late.dart.strong.transformed.expect
@@ -44,7 +44,7 @@
late static final field core::int lateFinalStaticField1;
late static final field core::int lateFinalStaticField2;
late static final field core::int lateFinalStaticFieldWithInit = 0;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
method method() → dynamic {
diff --git a/pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart b/pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart
new file mode 100644
index 0000000..a34cf670
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2019, 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.
+
+import 'messages_with_types_opt_out.dart';
+
+class SuperIn {
+ String? nullableSame() => "foo";
+ String nonNullableSame() => "bar";
+ int? nullableBad<T>(T t) => 1;
+ int nonNullableBad<T>(T t) => 2;
+}
+
+class SubInIn extends SuperIn {
+ String? nullableSame() => "foo";
+ String nonNullableSame() => "bar";
+ T? nullableBad<T>(T t) => null;
+ T nonNullableBad<T>(T t) => t;
+}
+
+class SubOutIn extends SuperOut {
+ String? nullableSame() => "foo";
+ String nonNullableSame() => "bar";
+ T? nullableBad<T>(T t) => null;
+ T nonNullableBad<T>(T t) => t;
+}
+
+int Function()? nullableVar = () => 3;
+double nonNullableVar = 4.0;
+
+testOptIn() {
+ nullableVar = nonNullableVar;
+ nonNullableVar = nullableVar;
+ legacyVar = nullableVar;
+ nullableVar = legacyVar;
+ nonNullableVar = legacyVar;
+ legacyVar = nonNullableVar;
+}
diff --git a/pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart.outline.expect b/pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart.outline.expect
new file mode 100644
index 0000000..83a9a17
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart.outline.expect
@@ -0,0 +1,192 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:17:6: Error: The return type of the method 'SubInIn.nullableBad' is 'T?', which does not match the return type, 'int?', of the overridden method, 'SuperIn.nullableBad'.
+// Change to a subtype of 'int?'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:18:5: Error: The return type of the method 'SubInIn.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:24:6: Error: Declared type variables of 'SubOutIn.nullableBad' doesn't match those on overridden method 'SuperOut.nullableBad'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:24:6: Error: The return type of the method 'SubOutIn.nullableBad' is 'T?', which does not match the return type, 'int', of the overridden method, 'SuperOut.nullableBad'.
+// Change to a subtype of 'int'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:25:5: Error: Declared type variables of 'SubOutIn.nonNullableBad' doesn't match those on overridden method 'SuperOut.nonNullableBad'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:25:5: Error: The return type of the method 'SubOutIn.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+import self as self;
+import "dart:core" as core;
+import "messages_with_types_opt_out.dart" as mes;
+
+import "org-dartlang-testcase:///messages_with_types_opt_out.dart";
+
+class SuperIn extends core::Object {
+ synthetic constructor •() → self::SuperIn
+ ;
+ method nullableSame() → core::String?
+ ;
+ method nonNullableSame() → core::String
+ ;
+ method nullableBad<T extends core::Object? = dynamic>(self::SuperIn::nullableBad::T% t) → core::int?
+ ;
+ method nonNullableBad<T extends core::Object? = dynamic>(self::SuperIn::nonNullableBad::T% t) → core::int
+ ;
+}
+class SubInIn extends self::SuperIn {
+ synthetic constructor •() → self::SubInIn
+ ;
+ method nullableSame() → core::String?
+ ;
+ method nonNullableSame() → core::String
+ ;
+ method nullableBad<T extends core::Object? = dynamic>(self::SubInIn::nullableBad::T% t) → self::SubInIn::nullableBad::T?
+ ;
+ method nonNullableBad<T extends core::Object? = dynamic>(self::SubInIn::nonNullableBad::T% t) → self::SubInIn::nonNullableBad::T%
+ ;
+}
+class SubOutIn extends mes::SuperOut {
+ synthetic constructor •() → self::SubOutIn
+ ;
+ method nullableSame() → core::String?
+ ;
+ method nonNullableSame() → core::String
+ ;
+ method nullableBad<T extends core::Object? = dynamic>(self::SubOutIn::nullableBad::T% t) → self::SubOutIn::nullableBad::T?
+ ;
+ method nonNullableBad<T extends core::Object? = dynamic>(self::SubOutIn::nonNullableBad::T% t) → self::SubOutIn::nonNullableBad::T%
+ ;
+}
+static field () →? core::int nullableVar;
+static field core::double nonNullableVar;
+static method testOptIn() → dynamic
+ ;
+
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:19:5: Error: The return type of the method 'SubOutOut.nullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nullableBad'.
+// Change to a subtype of 'int'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:20:5: Error: The return type of the method 'SubOutOut.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:26:5: Error: Declared type variables of 'SubInOut.nullableBad' doesn't match those on overridden method 'SuperIn.nullableBad'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:26:5: Error: The return type of the method 'SubInOut.nullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nullableBad'.
+// Change to a subtype of 'int'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:27:5: Error: Declared type variables of 'SubInOut.nonNullableBad' doesn't match those on overridden method 'SuperIn.nonNullableBad'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:27:5: Error: The return type of the method 'SubInOut.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+import self as mes;
+import "dart:core" as core;
+import "messages_with_types_opt_in.dart" as self;
+
+import "org-dartlang-testcase:///messages_with_types_opt_in.dart";
+
+class SuperOut extends core::Object {
+ synthetic constructor •() → mes::SuperOut*
+ ;
+ method nullableSame() → core::String*
+ ;
+ method nonNullableSame() → core::String*
+ ;
+ method nullableBad<T extends core::Object* = dynamic>(mes::SuperOut::nullableBad::T* t) → core::int*
+ ;
+ method nonNullableBad<T extends core::Object* = dynamic>(mes::SuperOut::nonNullableBad::T* t) → core::int*
+ ;
+}
+class SubOutOut extends mes::SuperOut {
+ synthetic constructor •() → mes::SubOutOut*
+ ;
+ method nullableSame() → core::String*
+ ;
+ method nonNullableSame() → core::String*
+ ;
+ method nullableBad<T extends core::Object* = dynamic>(mes::SubOutOut::nullableBad::T* t) → mes::SubOutOut::nullableBad::T*
+ ;
+ method nonNullableBad<T extends core::Object* = dynamic>(mes::SubOutOut::nonNullableBad::T* t) → mes::SubOutOut::nonNullableBad::T*
+ ;
+}
+class SubInOut extends self::SuperIn {
+ synthetic constructor •() → mes::SubInOut*
+ ;
+ method nullableSame() → core::String*
+ ;
+ method nonNullableSame() → core::String*
+ ;
+ method nullableBad<T extends core::Object* = dynamic>(mes::SubInOut::nullableBad::T* t) → mes::SubInOut::nullableBad::T*
+ ;
+ method nonNullableBad<T extends core::Object* = dynamic>(mes::SubInOut::nonNullableBad::T* t) → mes::SubInOut::nonNullableBad::T*
+ ;
+}
+static field core::String* legacyVar;
+static method testOptOut() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart.strong.expect b/pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart.strong.expect
new file mode 100644
index 0000000..050c5f8
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart.strong.expect
@@ -0,0 +1,282 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:17:6: Error: The return type of the method 'SubInIn.nullableBad' is 'T?', which does not match the return type, 'int?', of the overridden method, 'SuperIn.nullableBad'.
+// Change to a subtype of 'int?'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:18:5: Error: The return type of the method 'SubInIn.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:24:6: Error: Declared type variables of 'SubOutIn.nullableBad' doesn't match those on overridden method 'SuperOut.nullableBad'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:24:6: Error: The return type of the method 'SubOutIn.nullableBad' is 'T?', which does not match the return type, 'int', of the overridden method, 'SuperOut.nullableBad'.
+// Change to a subtype of 'int'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:25:5: Error: Declared type variables of 'SubOutIn.nonNullableBad' doesn't match those on overridden method 'SuperOut.nonNullableBad'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:25:5: Error: The return type of the method 'SubOutIn.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:32:17: Error: A value of type 'double' can't be assigned to a variable of type 'int Function()?'.
+// nullableVar = nonNullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:33:20: Error: A value of type 'int Function()?' can't be assigned to a variable of type 'double'.
+// nonNullableVar = nullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:34:15: Error: A value of type 'int Function()?' can't be assigned to a variable of type 'String'.
+// legacyVar = nullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:35:17: Error: A value of type 'String' can't be assigned to a variable of type 'int Function()?'.
+// nullableVar = legacyVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:36:20: Error: A value of type 'String' can't be assigned to a variable of type 'double'.
+// nonNullableVar = legacyVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:37:15: Error: A value of type 'double' can't be assigned to a variable of type 'String'.
+// legacyVar = nonNullableVar;
+// ^
+//
+import self as self;
+import "dart:core" as core;
+import "messages_with_types_opt_out.dart" as mes;
+
+import "org-dartlang-testcase:///messages_with_types_opt_out.dart";
+
+class SuperIn extends core::Object {
+ synthetic constructor •() → self::SuperIn
+ : super core::Object::•()
+ ;
+ method nullableSame() → core::String?
+ return "foo";
+ method nonNullableSame() → core::String
+ return "bar";
+ method nullableBad<T extends core::Object? = dynamic>(self::SuperIn::nullableBad::T% t) → core::int?
+ return 1;
+ method nonNullableBad<T extends core::Object? = dynamic>(self::SuperIn::nonNullableBad::T% t) → core::int
+ return 2;
+}
+class SubInIn extends self::SuperIn {
+ synthetic constructor •() → self::SubInIn
+ : super self::SuperIn::•()
+ ;
+ method nullableSame() → core::String?
+ return "foo";
+ method nonNullableSame() → core::String
+ return "bar";
+ method nullableBad<T extends core::Object? = dynamic>(self::SubInIn::nullableBad::T% t) → self::SubInIn::nullableBad::T?
+ return null;
+ method nonNullableBad<T extends core::Object? = dynamic>(self::SubInIn::nonNullableBad::T% t) → self::SubInIn::nonNullableBad::T%
+ return t;
+}
+class SubOutIn extends mes::SuperOut {
+ synthetic constructor •() → self::SubOutIn
+ : super mes::SuperOut::•()
+ ;
+ method nullableSame() → core::String?
+ return "foo";
+ method nonNullableSame() → core::String
+ return "bar";
+ method nullableBad<T extends core::Object? = dynamic>(self::SubOutIn::nullableBad::T% t) → self::SubOutIn::nullableBad::T?
+ return null;
+ method nonNullableBad<T extends core::Object? = dynamic>(self::SubOutIn::nonNullableBad::T% t) → self::SubOutIn::nonNullableBad::T%
+ return t;
+}
+static field () →? core::int nullableVar = () → core::int => 3;
+static field core::double nonNullableVar = 4.0;
+static method testOptIn() → dynamic {
+ self::nullableVar = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:32:17: Error: A value of type 'double' can't be assigned to a variable of type 'int Function()?'.
+ nullableVar = nonNullableVar;
+ ^" in self::nonNullableVar as{TypeError} () →? core::int;
+ self::nonNullableVar = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:33:20: Error: A value of type 'int Function()?' can't be assigned to a variable of type 'double'.
+ nonNullableVar = nullableVar;
+ ^" in self::nullableVar as{TypeError} core::double;
+ mes::legacyVar = let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:34:15: Error: A value of type 'int Function()?' can't be assigned to a variable of type 'String'.
+ legacyVar = nullableVar;
+ ^" in self::nullableVar as{TypeError} core::String*;
+ self::nullableVar = let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:35:17: Error: A value of type 'String' can't be assigned to a variable of type 'int Function()?'.
+ nullableVar = legacyVar;
+ ^" in mes::legacyVar as{TypeError} () →? core::int;
+ self::nonNullableVar = let final<BottomType> #t5 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:36:20: Error: A value of type 'String' can't be assigned to a variable of type 'double'.
+ nonNullableVar = legacyVar;
+ ^" in mes::legacyVar as{TypeError} core::double;
+ mes::legacyVar = let final<BottomType> #t6 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:37:15: Error: A value of type 'double' can't be assigned to a variable of type 'String'.
+ legacyVar = nonNullableVar;
+ ^" in self::nonNullableVar as{TypeError} core::String*;
+}
+
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:19:5: Error: The return type of the method 'SubOutOut.nullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nullableBad'.
+// Change to a subtype of 'int'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:20:5: Error: The return type of the method 'SubOutOut.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:26:5: Error: Declared type variables of 'SubInOut.nullableBad' doesn't match those on overridden method 'SuperIn.nullableBad'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:26:5: Error: The return type of the method 'SubInOut.nullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nullableBad'.
+// Change to a subtype of 'int'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:27:5: Error: Declared type variables of 'SubInOut.nonNullableBad' doesn't match those on overridden method 'SuperIn.nonNullableBad'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:27:5: Error: The return type of the method 'SubInOut.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:33:17: Error: A value of type 'double' can't be assigned to a variable of type 'int Function()'.
+// nullableVar = nonNullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:34:20: Error: A value of type 'int Function()' can't be assigned to a variable of type 'double'.
+// nonNullableVar = nullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:35:15: Error: A value of type 'int Function()' can't be assigned to a variable of type 'String'.
+// legacyVar = nullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:36:17: Error: A value of type 'String' can't be assigned to a variable of type 'int Function()'.
+// nullableVar = legacyVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:37:20: Error: A value of type 'String' can't be assigned to a variable of type 'double'.
+// nonNullableVar = legacyVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:38:15: Error: A value of type 'double' can't be assigned to a variable of type 'String'.
+// legacyVar = nonNullableVar;
+// ^
+//
+import self as mes;
+import "dart:core" as core;
+import "messages_with_types_opt_in.dart" as self;
+
+import "org-dartlang-testcase:///messages_with_types_opt_in.dart";
+
+class SuperOut extends core::Object {
+ synthetic constructor •() → mes::SuperOut*
+ : super core::Object::•()
+ ;
+ method nullableSame() → core::String*
+ return "foo";
+ method nonNullableSame() → core::String*
+ return "bar";
+ method nullableBad<T extends core::Object* = dynamic>(mes::SuperOut::nullableBad::T* t) → core::int*
+ return 1;
+ method nonNullableBad<T extends core::Object* = dynamic>(mes::SuperOut::nonNullableBad::T* t) → core::int*
+ return 2;
+}
+class SubOutOut extends mes::SuperOut {
+ synthetic constructor •() → mes::SubOutOut*
+ : super mes::SuperOut::•()
+ ;
+ method nullableSame() → core::String*
+ return "foo";
+ method nonNullableSame() → core::String*
+ return "bar";
+ method nullableBad<T extends core::Object* = dynamic>(mes::SubOutOut::nullableBad::T* t) → mes::SubOutOut::nullableBad::T*
+ return null;
+ method nonNullableBad<T extends core::Object* = dynamic>(mes::SubOutOut::nonNullableBad::T* t) → mes::SubOutOut::nonNullableBad::T*
+ return t;
+}
+class SubInOut extends self::SuperIn {
+ synthetic constructor •() → mes::SubInOut*
+ : super self::SuperIn::•()
+ ;
+ method nullableSame() → core::String*
+ return "foo";
+ method nonNullableSame() → core::String*
+ return "bar";
+ method nullableBad<T extends core::Object* = dynamic>(mes::SubInOut::nullableBad::T* t) → mes::SubInOut::nullableBad::T*
+ return null;
+ method nonNullableBad<T extends core::Object* = dynamic>(mes::SubInOut::nonNullableBad::T* t) → mes::SubInOut::nonNullableBad::T*
+ return t;
+}
+static field core::String* legacyVar = "legacy";
+static method testOptOut() → dynamic {
+ self::nullableVar = let final<BottomType> #t7 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:33:17: Error: A value of type 'double' can't be assigned to a variable of type 'int Function()'.
+ nullableVar = nonNullableVar;
+ ^" in self::nonNullableVar as{TypeError} () →? core::int;
+ self::nonNullableVar = let final<BottomType> #t8 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:34:20: Error: A value of type 'int Function()' can't be assigned to a variable of type 'double'.
+ nonNullableVar = nullableVar;
+ ^" in self::nullableVar as{TypeError} core::double;
+ mes::legacyVar = let final<BottomType> #t9 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:35:15: Error: A value of type 'int Function()' can't be assigned to a variable of type 'String'.
+ legacyVar = nullableVar;
+ ^" in self::nullableVar as{TypeError} core::String*;
+ self::nullableVar = let final<BottomType> #t10 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:36:17: Error: A value of type 'String' can't be assigned to a variable of type 'int Function()'.
+ nullableVar = legacyVar;
+ ^" in mes::legacyVar as{TypeError} () →? core::int;
+ self::nonNullableVar = let final<BottomType> #t11 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:37:20: Error: A value of type 'String' can't be assigned to a variable of type 'double'.
+ nonNullableVar = legacyVar;
+ ^" in mes::legacyVar as{TypeError} core::double;
+ mes::legacyVar = let final<BottomType> #t12 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:38:15: Error: A value of type 'double' can't be assigned to a variable of type 'String'.
+ legacyVar = nonNullableVar;
+ ^" in self::nonNullableVar as{TypeError} core::String*;
+}
diff --git a/pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart b/pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart
new file mode 100644
index 0000000..7e040ef
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2019, 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.
+
+// @dart=2.5
+
+import 'messages_with_types_opt_in.dart';
+
+class SuperOut {
+ String nullableSame() => "foo";
+ String nonNullableSame() => "bar";
+ int nullableBad<T>(T t) => 1;
+ int nonNullableBad<T>(T t) => 2;
+}
+
+class SubOutOut extends SuperOut {
+ String nullableSame() => "foo";
+ String nonNullableSame() => "bar";
+ T nullableBad<T>(T t) => null;
+ T nonNullableBad<T>(T t) => t;
+}
+
+class SubInOut extends SuperIn {
+ String nullableSame() => "foo";
+ String nonNullableSame() => "bar";
+ T nullableBad<T>(T t) => null;
+ T nonNullableBad<T>(T t) => t;
+}
+
+String legacyVar = "legacy";
+
+testOptOut() {
+ nullableVar = nonNullableVar;
+ nonNullableVar = nullableVar;
+ legacyVar = nullableVar;
+ nullableVar = legacyVar;
+ nonNullableVar = legacyVar;
+ legacyVar = nonNullableVar;
+}
diff --git a/pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart.outline.expect b/pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart.outline.expect
new file mode 100644
index 0000000..51f5591
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart.outline.expect
@@ -0,0 +1,192 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:19:5: Error: The return type of the method 'SubOutOut.nullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nullableBad'.
+// Change to a subtype of 'int'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:20:5: Error: The return type of the method 'SubOutOut.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:26:5: Error: Declared type variables of 'SubInOut.nullableBad' doesn't match those on overridden method 'SuperIn.nullableBad'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:26:5: Error: The return type of the method 'SubInOut.nullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nullableBad'.
+// Change to a subtype of 'int'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:27:5: Error: Declared type variables of 'SubInOut.nonNullableBad' doesn't match those on overridden method 'SuperIn.nonNullableBad'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:27:5: Error: The return type of the method 'SubInOut.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+import self as self;
+import "dart:core" as core;
+import "messages_with_types_opt_in.dart" as mes;
+
+import "org-dartlang-testcase:///messages_with_types_opt_in.dart";
+
+class SuperOut extends core::Object {
+ synthetic constructor •() → self::SuperOut*
+ ;
+ method nullableSame() → core::String*
+ ;
+ method nonNullableSame() → core::String*
+ ;
+ method nullableBad<T extends core::Object* = dynamic>(self::SuperOut::nullableBad::T* t) → core::int*
+ ;
+ method nonNullableBad<T extends core::Object* = dynamic>(self::SuperOut::nonNullableBad::T* t) → core::int*
+ ;
+}
+class SubOutOut extends self::SuperOut {
+ synthetic constructor •() → self::SubOutOut*
+ ;
+ method nullableSame() → core::String*
+ ;
+ method nonNullableSame() → core::String*
+ ;
+ method nullableBad<T extends core::Object* = dynamic>(self::SubOutOut::nullableBad::T* t) → self::SubOutOut::nullableBad::T*
+ ;
+ method nonNullableBad<T extends core::Object* = dynamic>(self::SubOutOut::nonNullableBad::T* t) → self::SubOutOut::nonNullableBad::T*
+ ;
+}
+class SubInOut extends mes::SuperIn {
+ synthetic constructor •() → self::SubInOut*
+ ;
+ method nullableSame() → core::String*
+ ;
+ method nonNullableSame() → core::String*
+ ;
+ method nullableBad<T extends core::Object* = dynamic>(self::SubInOut::nullableBad::T* t) → self::SubInOut::nullableBad::T*
+ ;
+ method nonNullableBad<T extends core::Object* = dynamic>(self::SubInOut::nonNullableBad::T* t) → self::SubInOut::nonNullableBad::T*
+ ;
+}
+static field core::String* legacyVar;
+static method testOptOut() → dynamic
+ ;
+
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:17:6: Error: The return type of the method 'SubInIn.nullableBad' is 'T?', which does not match the return type, 'int?', of the overridden method, 'SuperIn.nullableBad'.
+// Change to a subtype of 'int?'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:18:5: Error: The return type of the method 'SubInIn.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:24:6: Error: Declared type variables of 'SubOutIn.nullableBad' doesn't match those on overridden method 'SuperOut.nullableBad'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:24:6: Error: The return type of the method 'SubOutIn.nullableBad' is 'T?', which does not match the return type, 'int', of the overridden method, 'SuperOut.nullableBad'.
+// Change to a subtype of 'int'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:25:5: Error: Declared type variables of 'SubOutIn.nonNullableBad' doesn't match those on overridden method 'SuperOut.nonNullableBad'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:25:5: Error: The return type of the method 'SubOutIn.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+import self as mes;
+import "dart:core" as core;
+import "messages_with_types_opt_out.dart" as self;
+
+import "org-dartlang-testcase:///messages_with_types_opt_out.dart";
+
+class SuperIn extends core::Object {
+ synthetic constructor •() → mes::SuperIn
+ ;
+ method nullableSame() → core::String?
+ ;
+ method nonNullableSame() → core::String
+ ;
+ method nullableBad<T extends core::Object? = dynamic>(mes::SuperIn::nullableBad::T% t) → core::int?
+ ;
+ method nonNullableBad<T extends core::Object? = dynamic>(mes::SuperIn::nonNullableBad::T% t) → core::int
+ ;
+}
+class SubInIn extends mes::SuperIn {
+ synthetic constructor •() → mes::SubInIn
+ ;
+ method nullableSame() → core::String?
+ ;
+ method nonNullableSame() → core::String
+ ;
+ method nullableBad<T extends core::Object? = dynamic>(mes::SubInIn::nullableBad::T% t) → mes::SubInIn::nullableBad::T?
+ ;
+ method nonNullableBad<T extends core::Object? = dynamic>(mes::SubInIn::nonNullableBad::T% t) → mes::SubInIn::nonNullableBad::T%
+ ;
+}
+class SubOutIn extends self::SuperOut {
+ synthetic constructor •() → mes::SubOutIn
+ ;
+ method nullableSame() → core::String?
+ ;
+ method nonNullableSame() → core::String
+ ;
+ method nullableBad<T extends core::Object? = dynamic>(mes::SubOutIn::nullableBad::T% t) → mes::SubOutIn::nullableBad::T?
+ ;
+ method nonNullableBad<T extends core::Object? = dynamic>(mes::SubOutIn::nonNullableBad::T% t) → mes::SubOutIn::nonNullableBad::T%
+ ;
+}
+static field () →? core::int nullableVar;
+static field core::double nonNullableVar;
+static method testOptIn() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart.strong.expect b/pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart.strong.expect
new file mode 100644
index 0000000..fe57a7b
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart.strong.expect
@@ -0,0 +1,282 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:19:5: Error: The return type of the method 'SubOutOut.nullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nullableBad'.
+// Change to a subtype of 'int'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:20:5: Error: The return type of the method 'SubOutOut.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:26:5: Error: Declared type variables of 'SubInOut.nullableBad' doesn't match those on overridden method 'SuperIn.nullableBad'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:26:5: Error: The return type of the method 'SubInOut.nullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nullableBad'.
+// Change to a subtype of 'int'.
+// T nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:27:5: Error: Declared type variables of 'SubInOut.nonNullableBad' doesn't match those on overridden method 'SuperIn.nonNullableBad'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:27:5: Error: The return type of the method 'SubInOut.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:33:17: Error: A value of type 'double' can't be assigned to a variable of type 'int Function()'.
+// nullableVar = nonNullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:34:20: Error: A value of type 'int Function()' can't be assigned to a variable of type 'double'.
+// nonNullableVar = nullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:35:15: Error: A value of type 'int Function()' can't be assigned to a variable of type 'String'.
+// legacyVar = nullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:36:17: Error: A value of type 'String' can't be assigned to a variable of type 'int Function()'.
+// nullableVar = legacyVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:37:20: Error: A value of type 'String' can't be assigned to a variable of type 'double'.
+// nonNullableVar = legacyVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:38:15: Error: A value of type 'double' can't be assigned to a variable of type 'String'.
+// legacyVar = nonNullableVar;
+// ^
+//
+import self as self;
+import "dart:core" as core;
+import "messages_with_types_opt_in.dart" as mes;
+
+import "org-dartlang-testcase:///messages_with_types_opt_in.dart";
+
+class SuperOut extends core::Object {
+ synthetic constructor •() → self::SuperOut*
+ : super core::Object::•()
+ ;
+ method nullableSame() → core::String*
+ return "foo";
+ method nonNullableSame() → core::String*
+ return "bar";
+ method nullableBad<T extends core::Object* = dynamic>(self::SuperOut::nullableBad::T* t) → core::int*
+ return 1;
+ method nonNullableBad<T extends core::Object* = dynamic>(self::SuperOut::nonNullableBad::T* t) → core::int*
+ return 2;
+}
+class SubOutOut extends self::SuperOut {
+ synthetic constructor •() → self::SubOutOut*
+ : super self::SuperOut::•()
+ ;
+ method nullableSame() → core::String*
+ return "foo";
+ method nonNullableSame() → core::String*
+ return "bar";
+ method nullableBad<T extends core::Object* = dynamic>(self::SubOutOut::nullableBad::T* t) → self::SubOutOut::nullableBad::T*
+ return null;
+ method nonNullableBad<T extends core::Object* = dynamic>(self::SubOutOut::nonNullableBad::T* t) → self::SubOutOut::nonNullableBad::T*
+ return t;
+}
+class SubInOut extends mes::SuperIn {
+ synthetic constructor •() → self::SubInOut*
+ : super mes::SuperIn::•()
+ ;
+ method nullableSame() → core::String*
+ return "foo";
+ method nonNullableSame() → core::String*
+ return "bar";
+ method nullableBad<T extends core::Object* = dynamic>(self::SubInOut::nullableBad::T* t) → self::SubInOut::nullableBad::T*
+ return null;
+ method nonNullableBad<T extends core::Object* = dynamic>(self::SubInOut::nonNullableBad::T* t) → self::SubInOut::nonNullableBad::T*
+ return t;
+}
+static field core::String* legacyVar = "legacy";
+static method testOptOut() → dynamic {
+ mes::nullableVar = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:33:17: Error: A value of type 'double' can't be assigned to a variable of type 'int Function()'.
+ nullableVar = nonNullableVar;
+ ^" in mes::nonNullableVar as{TypeError} () →? core::int;
+ mes::nonNullableVar = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:34:20: Error: A value of type 'int Function()' can't be assigned to a variable of type 'double'.
+ nonNullableVar = nullableVar;
+ ^" in mes::nullableVar as{TypeError} core::double;
+ self::legacyVar = let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:35:15: Error: A value of type 'int Function()' can't be assigned to a variable of type 'String'.
+ legacyVar = nullableVar;
+ ^" in mes::nullableVar as{TypeError} core::String*;
+ mes::nullableVar = let final<BottomType> #t4 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:36:17: Error: A value of type 'String' can't be assigned to a variable of type 'int Function()'.
+ nullableVar = legacyVar;
+ ^" in self::legacyVar as{TypeError} () →? core::int;
+ mes::nonNullableVar = let final<BottomType> #t5 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:37:20: Error: A value of type 'String' can't be assigned to a variable of type 'double'.
+ nonNullableVar = legacyVar;
+ ^" in self::legacyVar as{TypeError} core::double;
+ self::legacyVar = let final<BottomType> #t6 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:38:15: Error: A value of type 'double' can't be assigned to a variable of type 'String'.
+ legacyVar = nonNullableVar;
+ ^" in mes::nonNullableVar as{TypeError} core::String*;
+}
+
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:17:6: Error: The return type of the method 'SubInIn.nullableBad' is 'T?', which does not match the return type, 'int?', of the overridden method, 'SuperIn.nullableBad'.
+// Change to a subtype of 'int?'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:10:8: Context: This is the overridden method ('nullableBad').
+// int? nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:18:5: Error: The return type of the method 'SubInIn.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperIn.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:11:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:24:6: Error: Declared type variables of 'SubOutIn.nullableBad' doesn't match those on overridden method 'SuperOut.nullableBad'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:24:6: Error: The return type of the method 'SubOutIn.nullableBad' is 'T?', which does not match the return type, 'int', of the overridden method, 'SuperOut.nullableBad'.
+// Change to a subtype of 'int'.
+// T? nullableBad<T>(T t) => null;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:12:7: Context: This is the overridden method ('nullableBad').
+// int nullableBad<T>(T t) => 1;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:25:5: Error: Declared type variables of 'SubOutIn.nonNullableBad' doesn't match those on overridden method 'SuperOut.nonNullableBad'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:25:5: Error: The return type of the method 'SubOutIn.nonNullableBad' is 'T', which does not match the return type, 'int', of the overridden method, 'SuperOut.nonNullableBad'.
+// Change to a subtype of 'int'.
+// T nonNullableBad<T>(T t) => t;
+// ^
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_out.dart:13:7: Context: This is the overridden method ('nonNullableBad').
+// int nonNullableBad<T>(T t) => 2;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:32:17: Error: A value of type 'double' can't be assigned to a variable of type 'int Function()?'.
+// nullableVar = nonNullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:33:20: Error: A value of type 'int Function()?' can't be assigned to a variable of type 'double'.
+// nonNullableVar = nullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:34:15: Error: A value of type 'int Function()?' can't be assigned to a variable of type 'String'.
+// legacyVar = nullableVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:35:17: Error: A value of type 'String' can't be assigned to a variable of type 'int Function()?'.
+// nullableVar = legacyVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:36:20: Error: A value of type 'String' can't be assigned to a variable of type 'double'.
+// nonNullableVar = legacyVar;
+// ^
+//
+// pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:37:15: Error: A value of type 'double' can't be assigned to a variable of type 'String'.
+// legacyVar = nonNullableVar;
+// ^
+//
+import self as mes;
+import "dart:core" as core;
+import "messages_with_types_opt_out.dart" as self;
+
+import "org-dartlang-testcase:///messages_with_types_opt_out.dart";
+
+class SuperIn extends core::Object {
+ synthetic constructor •() → mes::SuperIn
+ : super core::Object::•()
+ ;
+ method nullableSame() → core::String?
+ return "foo";
+ method nonNullableSame() → core::String
+ return "bar";
+ method nullableBad<T extends core::Object? = dynamic>(mes::SuperIn::nullableBad::T% t) → core::int?
+ return 1;
+ method nonNullableBad<T extends core::Object? = dynamic>(mes::SuperIn::nonNullableBad::T% t) → core::int
+ return 2;
+}
+class SubInIn extends mes::SuperIn {
+ synthetic constructor •() → mes::SubInIn
+ : super mes::SuperIn::•()
+ ;
+ method nullableSame() → core::String?
+ return "foo";
+ method nonNullableSame() → core::String
+ return "bar";
+ method nullableBad<T extends core::Object? = dynamic>(mes::SubInIn::nullableBad::T% t) → mes::SubInIn::nullableBad::T?
+ return null;
+ method nonNullableBad<T extends core::Object? = dynamic>(mes::SubInIn::nonNullableBad::T% t) → mes::SubInIn::nonNullableBad::T%
+ return t;
+}
+class SubOutIn extends self::SuperOut {
+ synthetic constructor •() → mes::SubOutIn
+ : super self::SuperOut::•()
+ ;
+ method nullableSame() → core::String?
+ return "foo";
+ method nonNullableSame() → core::String
+ return "bar";
+ method nullableBad<T extends core::Object? = dynamic>(mes::SubOutIn::nullableBad::T% t) → mes::SubOutIn::nullableBad::T?
+ return null;
+ method nonNullableBad<T extends core::Object? = dynamic>(mes::SubOutIn::nonNullableBad::T% t) → mes::SubOutIn::nonNullableBad::T%
+ return t;
+}
+static field () →? core::int nullableVar = () → core::int => 3;
+static field core::double nonNullableVar = 4.0;
+static method testOptIn() → dynamic {
+ mes::nullableVar = let final<BottomType> #t7 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:32:17: Error: A value of type 'double' can't be assigned to a variable of type 'int Function()?'.
+ nullableVar = nonNullableVar;
+ ^" in mes::nonNullableVar as{TypeError} () →? core::int;
+ mes::nonNullableVar = let final<BottomType> #t8 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:33:20: Error: A value of type 'int Function()?' can't be assigned to a variable of type 'double'.
+ nonNullableVar = nullableVar;
+ ^" in mes::nullableVar as{TypeError} core::double;
+ self::legacyVar = let final<BottomType> #t9 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:34:15: Error: A value of type 'int Function()?' can't be assigned to a variable of type 'String'.
+ legacyVar = nullableVar;
+ ^" in mes::nullableVar as{TypeError} core::String*;
+ mes::nullableVar = let final<BottomType> #t10 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:35:17: Error: A value of type 'String' can't be assigned to a variable of type 'int Function()?'.
+ nullableVar = legacyVar;
+ ^" in self::legacyVar as{TypeError} () →? core::int;
+ mes::nonNullableVar = let final<BottomType> #t11 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:36:20: Error: A value of type 'String' can't be assigned to a variable of type 'double'.
+ nonNullableVar = legacyVar;
+ ^" in self::legacyVar as{TypeError} core::double;
+ self::legacyVar = let final<BottomType> #t12 = invalid-expression "pkg/front_end/testcases/nnbd/messages_with_types_opt_in.dart:37:15: Error: A value of type 'double' can't be assigned to a variable of type 'String'.
+ legacyVar = nonNullableVar;
+ ^" in mes::nonNullableVar as{TypeError} core::String*;
+}
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting.dart b/pkg/front_end/testcases/nnbd/no_null_shorting.dart
new file mode 100644
index 0000000..9cce447
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting.dart
@@ -0,0 +1,160 @@
+// Copyright (c) 2019, 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.
+
+// @dart=2.6
+
+class Class {
+ Class field;
+ Class method() => field;
+
+ Class operator [](Class key) => field;
+ void operator []=(Class key, Class value) {
+ field = value;
+ }
+
+ Class operator +(int value) => field;
+
+ Class operator -() => field;
+}
+
+main() {
+ propertyAccess(null);
+ indexAccess(null);
+ operatorAccess(null);
+ ifNull(null);
+}
+
+void propertyAccess(Class c) {
+ c?.field;
+ c?.field = new Class();
+ c = c?.field = new Class();
+ c?.method();
+
+ throws(() => c?.field.field);
+ c?.field?.field;
+ throws(() => c?.field.field?.field);
+ throws(() => c?.field.field = new Class());
+ c?.field?.field = new Class();
+ throws(() => c?.field.field?.field = new Class());
+ throws(() => (c?.field).field);
+ throws(() => (c?.field = new Class()).field);
+ throws(() => (c?.method()).field);
+ throws(() => c = c?.field.field = new Class());
+ c = c?.field?.field = new Class();
+ throws(() => c = c?.field.field?.field = new Class());
+ throws(() => c?.field.method());
+ c?.field = new Class().field;
+ c = c?.field = new Class().field;
+ c?.field = new Class().field = new Class();
+ c = c?.field = new Class().field = new Class();
+ c?.field = new Class().method();
+ c = c?.field = new Class().method();
+ throws(() => c?.method().field);
+ throws(() => c?.method().field = new Class());
+ throws(() => c?.method().method());
+
+ throws(() => c?.field.field.field);
+ throws(() => c?.field.field.field = new Class());
+ throws(() => c = c?.field.field.field = new Class());
+ throws(() => c?.field.field.method());
+ c?.field = new Class().field.field;
+ c = c?.field = new Class().field.field;
+ c?.field = new Class().field.field = new Class();
+ c = c?.field = new Class().field.field = new Class();
+ c?.field = new Class().field.method();
+ c = c?.field = new Class().field.method();
+ throws(() => c?.method().field.field);
+ throws(() => c?.method().field.field = new Class());
+ throws(() => c?.method().field.method());
+
+ throws(() => c?.field.field = new Class().field);
+ throws(() => c = c?.field.field = new Class().field);
+ throws(() => c?.field.field = new Class().field = new Class());
+ throws(() => c = c?.field.field = new Class().field = new Class());
+ throws(() => c?.field.field = new Class().method());
+ throws(() => c = c?.field.field = new Class().method());
+ c?.field = new Class().field = new Class().field;
+ c = c?.field = new Class().field = new Class().field;
+ c?.field = new Class().field = new Class().field = new Class();
+ c = c?.field = new Class().field = new Class().field = new Class();
+ c?.field = new Class().field = new Class().method();
+ c = c?.field = new Class().field = new Class().method();
+ throws(() => c?.method().field = new Class().field);
+ throws(() => c = c?.method().field = new Class().field);
+ throws(() => c?.method().field = new Class().field = new Class());
+ throws(() => c = c?.method().field = new Class().field = new Class());
+ throws(() => c?.method().field = new Class().method());
+ throws(() => c = c?.method().field = new Class().method());
+
+ throws(() => c?.field.method().field);
+ throws(() => c?.field.method().field = new Class());
+ throws(() => c = c?.field.method().field = new Class());
+ throws(() => c?.field.method().method());
+ c?.field = new Class().method().field;
+ c = c?.field = new Class().method().field;
+ c?.field = new Class().method().field = new Class();
+ c = c?.field = new Class().method().field = new Class();
+ c?.field = new Class().method().method();
+ c = c?.field = new Class().method().method();
+ throws(() => c?.method().method().field);
+ throws(() => c?.method().method().field = new Class());
+ throws(() => c?.method().method().method());
+
+ c?.method()?.method();
+}
+
+void indexAccess(Class c) {
+ throws(() => c?.field[c]);
+ throws(() => c?.field[c] = new Class());
+ throws(() => c = c?.field[c] = new Class());
+ throws(() => c?.field[c].method());
+ throws(() => c?.field[c] += 0);
+ throws(() => c = c?.field[c] += 0);
+ throws(() => c?.field[c]++);
+ throws(() => c = c?.field[c]++);
+ throws(() => ++c?.field[c]);
+ throws(() => c = ++c?.field[c]);
+
+ throws(() => c?.field[c][c]);
+ throws(() => c?.field[c][c] = new Class());
+ throws(() => c = c?.field[c][c] = new Class());
+ throws(() => c?.field[c][c].method());
+ throws(() => c?.field[c][c] += 0);
+ throws(() => c = c?.field[c][c] += 0);
+ throws(() => c?.field[c][c]++);
+ throws(() => c = c?.field[c][c]++);
+ throws(() => ++c?.field[c][c]);
+ throws(() => c = ++c?.field[c][c]);
+}
+
+void operatorAccess(Class c) {
+ throws(() => c?.field + 0);
+ throws(() => -c?.field);
+ c?.field += 0;
+ c = c?.field += 0;
+ throws(() => c?.field.field += 0);
+ throws(() => c = c?.field.field += 0);
+ c?.field++;
+ c = c?.field++;
+ ++c?.field;
+ c = ++c?.field;
+}
+
+void ifNull(Class c) {
+ c?.field ??= c;
+ c = c?.field ??= c;
+ throws(() => c?.field.field ??= c);
+ throws(() => c = c?.field.field ??= c);
+ throws(() => c?.field[c] ??= c);
+ throws(() => c = c?.field[c] ??= c);
+}
+
+void throws(void Function() f) {
+ try {
+ f();
+ } catch (_) {
+ return;
+ }
+ throw 'Expected exception.';
+}
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting.dart.outline.expect b/pkg/front_end/testcases/nnbd/no_null_shorting.dart.outline.expect
new file mode 100644
index 0000000..7ed6f00
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting.dart.outline.expect
@@ -0,0 +1,31 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class* field;
+ synthetic constructor •() → self::Class*
+ ;
+ method method() → self::Class*
+ ;
+ operator [](self::Class* key) → self::Class*
+ ;
+ operator []=(self::Class* key, self::Class* value) → void
+ ;
+ operator +(core::int* value) → self::Class*
+ ;
+ operator unary-() → self::Class*
+ ;
+}
+static method main() → dynamic
+ ;
+static method propertyAccess(self::Class* c) → void
+ ;
+static method indexAccess(self::Class* c) → void
+ ;
+static method operatorAccess(self::Class* c) → void
+ ;
+static method ifNull(self::Class* c) → void
+ ;
+static method throws(() →* void f) → void
+ ;
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting.dart.strong.expect b/pkg/front_end/testcases/nnbd/no_null_shorting.dart.strong.expect
new file mode 100644
index 0000000..b0d09f9
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting.dart.strong.expect
@@ -0,0 +1,151 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class* field = null;
+ synthetic constructor •() → self::Class*
+ : super core::Object::•()
+ ;
+ method method() → self::Class*
+ return this.{self::Class::field};
+ operator [](self::Class* key) → self::Class*
+ return this.{self::Class::field};
+ operator []=(self::Class* key, self::Class* value) → void {
+ this.{self::Class::field} = value;
+ }
+ operator +(core::int* value) → self::Class*
+ return this.{self::Class::field};
+ operator unary-() → self::Class*
+ return this.{self::Class::field};
+}
+static method main() → dynamic {
+ self::propertyAccess(null);
+ self::indexAccess(null);
+ self::operatorAccess(null);
+ self::ifNull(null);
+}
+static method propertyAccess(self::Class* c) → void {
+ let final self::Class* #t1 = c in #t1.{core::Object::==}(null) ?{self::Class*} null : #t1.{self::Class::field};
+ let final self::Class* #t2 = c in #t2.{core::Object::==}(null) ?{self::Class*} null : #t2.{self::Class::field} = new self::Class::•();
+ c = let final self::Class* #t3 = c in #t3.{core::Object::==}(null) ?{self::Class*} null : #t3.{self::Class::field} = new self::Class::•();
+ let final self::Class* #t4 = c in #t4.{core::Object::==}(null) ?{self::Class*} null : #t4.{self::Class::method}();
+ self::throws(() → self::Class* => (let final self::Class* #t5 = c in #t5.{core::Object::==}(null) ?{self::Class*} null : #t5.{self::Class::field}).{self::Class::field});
+ let final self::Class* #t6 = let final self::Class* #t7 = c in #t7.{core::Object::==}(null) ?{self::Class*} null : #t7.{self::Class::field} in #t6.{core::Object::==}(null) ?{self::Class*} null : #t6.{self::Class::field};
+ self::throws(() → self::Class* => let final self::Class* #t8 = (let final self::Class* #t9 = c in #t9.{core::Object::==}(null) ?{self::Class*} null : #t9.{self::Class::field}).{self::Class::field} in #t8.{core::Object::==}(null) ?{self::Class*} null : #t8.{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t10 = c in #t10.{core::Object::==}(null) ?{self::Class*} null : #t10.{self::Class::field}).{self::Class::field} = new self::Class::•());
+ let final self::Class* #t11 = let final self::Class* #t12 = c in #t12.{core::Object::==}(null) ?{self::Class*} null : #t12.{self::Class::field} in #t11.{core::Object::==}(null) ?{self::Class*} null : #t11.{self::Class::field} = new self::Class::•();
+ self::throws(() → self::Class* => let final self::Class* #t13 = (let final self::Class* #t14 = c in #t14.{core::Object::==}(null) ?{self::Class*} null : #t14.{self::Class::field}).{self::Class::field} in #t13.{core::Object::==}(null) ?{self::Class*} null : #t13.{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t15 = c in #t15.{core::Object::==}(null) ?{self::Class*} null : #t15.{self::Class::field}).{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t16 = c in #t16.{core::Object::==}(null) ?{self::Class*} null : #t16.{self::Class::field} = new self::Class::•()).{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t17 = c in #t17.{core::Object::==}(null) ?{self::Class*} null : #t17.{self::Class::method}()).{self::Class::field});
+ self::throws(() → self::Class* => c = (let final self::Class* #t18 = c in #t18.{core::Object::==}(null) ?{self::Class*} null : #t18.{self::Class::field}).{self::Class::field} = new self::Class::•());
+ c = let final self::Class* #t19 = let final self::Class* #t20 = c in #t20.{core::Object::==}(null) ?{self::Class*} null : #t20.{self::Class::field} in #t19.{core::Object::==}(null) ?{self::Class*} null : #t19.{self::Class::field} = new self::Class::•();
+ self::throws(() → self::Class* => c = let final self::Class* #t21 = (let final self::Class* #t22 = c in #t22.{core::Object::==}(null) ?{self::Class*} null : #t22.{self::Class::field}).{self::Class::field} in #t21.{core::Object::==}(null) ?{self::Class*} null : #t21.{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t23 = c in #t23.{core::Object::==}(null) ?{self::Class*} null : #t23.{self::Class::field}).{self::Class::method}());
+ let final self::Class* #t24 = c in #t24.{core::Object::==}(null) ?{self::Class*} null : #t24.{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class* #t25 = c in #t25.{core::Object::==}(null) ?{self::Class*} null : #t25.{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class* #t26 = c in #t26.{core::Object::==}(null) ?{self::Class*} null : #t26.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class* #t27 = c in #t27.{core::Object::==}(null) ?{self::Class*} null : #t27.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class* #t28 = c in #t28.{core::Object::==}(null) ?{self::Class*} null : #t28.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class* #t29 = c in #t29.{core::Object::==}(null) ?{self::Class*} null : #t29.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ self::throws(() → self::Class* => (let final self::Class* #t30 = c in #t30.{core::Object::==}(null) ?{self::Class*} null : #t30.{self::Class::method}()).{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t31 = c in #t31.{core::Object::==}(null) ?{self::Class*} null : #t31.{self::Class::method}()).{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t32 = c in #t32.{core::Object::==}(null) ?{self::Class*} null : #t32.{self::Class::method}()).{self::Class::method}());
+ self::throws(() → self::Class* => (let final self::Class* #t33 = c in #t33.{core::Object::==}(null) ?{self::Class*} null : #t33.{self::Class::field}).{self::Class::field}.{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t34 = c in #t34.{core::Object::==}(null) ?{self::Class*} null : #t34.{self::Class::field}).{self::Class::field}.{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => c = (let final self::Class* #t35 = c in #t35.{core::Object::==}(null) ?{self::Class*} null : #t35.{self::Class::field}).{self::Class::field}.{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t36 = c in #t36.{core::Object::==}(null) ?{self::Class*} null : #t36.{self::Class::field}).{self::Class::field}.{self::Class::method}());
+ let final self::Class* #t37 = c in #t37.{core::Object::==}(null) ?{self::Class*} null : #t37.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
+ c = let final self::Class* #t38 = c in #t38.{core::Object::==}(null) ?{self::Class*} null : #t38.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
+ let final self::Class* #t39 = c in #t39.{core::Object::==}(null) ?{self::Class*} null : #t39.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class* #t40 = c in #t40.{core::Object::==}(null) ?{self::Class*} null : #t40.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
+ let final self::Class* #t41 = c in #t41.{core::Object::==}(null) ?{self::Class*} null : #t41.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
+ c = let final self::Class* #t42 = c in #t42.{core::Object::==}(null) ?{self::Class*} null : #t42.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
+ self::throws(() → self::Class* => (let final self::Class* #t43 = c in #t43.{core::Object::==}(null) ?{self::Class*} null : #t43.{self::Class::method}()).{self::Class::field}.{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t44 = c in #t44.{core::Object::==}(null) ?{self::Class*} null : #t44.{self::Class::method}()).{self::Class::field}.{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t45 = c in #t45.{core::Object::==}(null) ?{self::Class*} null : #t45.{self::Class::method}()).{self::Class::field}.{self::Class::method}());
+ self::throws(() → self::Class* => (let final self::Class* #t46 = c in #t46.{core::Object::==}(null) ?{self::Class*} null : #t46.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::field});
+ self::throws(() → self::Class* => c = (let final self::Class* #t47 = c in #t47.{core::Object::==}(null) ?{self::Class*} null : #t47.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t48 = c in #t48.{core::Object::==}(null) ?{self::Class*} null : #t48.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => c = (let final self::Class* #t49 = c in #t49.{core::Object::==}(null) ?{self::Class*} null : #t49.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t50 = c in #t50.{core::Object::==}(null) ?{self::Class*} null : #t50.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::method}());
+ self::throws(() → self::Class* => c = (let final self::Class* #t51 = c in #t51.{core::Object::==}(null) ?{self::Class*} null : #t51.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::method}());
+ let final self::Class* #t52 = c in #t52.{core::Object::==}(null) ?{self::Class*} null : #t52.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class* #t53 = c in #t53.{core::Object::==}(null) ?{self::Class*} null : #t53.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class* #t54 = c in #t54.{core::Object::==}(null) ?{self::Class*} null : #t54.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class* #t55 = c in #t55.{core::Object::==}(null) ?{self::Class*} null : #t55.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class* #t56 = c in #t56.{core::Object::==}(null) ?{self::Class*} null : #t56.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class* #t57 = c in #t57.{core::Object::==}(null) ?{self::Class*} null : #t57.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ self::throws(() → self::Class* => (let final self::Class* #t58 = c in #t58.{core::Object::==}(null) ?{self::Class*} null : #t58.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::field});
+ self::throws(() → self::Class* => c = (let final self::Class* #t59 = c in #t59.{core::Object::==}(null) ?{self::Class*} null : #t59.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t60 = c in #t60.{core::Object::==}(null) ?{self::Class*} null : #t60.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => c = (let final self::Class* #t61 = c in #t61.{core::Object::==}(null) ?{self::Class*} null : #t61.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t62 = c in #t62.{core::Object::==}(null) ?{self::Class*} null : #t62.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::method}());
+ self::throws(() → self::Class* => c = (let final self::Class* #t63 = c in #t63.{core::Object::==}(null) ?{self::Class*} null : #t63.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::method}());
+ self::throws(() → self::Class* => (let final self::Class* #t64 = c in #t64.{core::Object::==}(null) ?{self::Class*} null : #t64.{self::Class::field}).{self::Class::method}().{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t65 = c in #t65.{core::Object::==}(null) ?{self::Class*} null : #t65.{self::Class::field}).{self::Class::method}().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => c = (let final self::Class* #t66 = c in #t66.{core::Object::==}(null) ?{self::Class*} null : #t66.{self::Class::field}).{self::Class::method}().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t67 = c in #t67.{core::Object::==}(null) ?{self::Class*} null : #t67.{self::Class::field}).{self::Class::method}().{self::Class::method}());
+ let final self::Class* #t68 = c in #t68.{core::Object::==}(null) ?{self::Class*} null : #t68.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
+ c = let final self::Class* #t69 = c in #t69.{core::Object::==}(null) ?{self::Class*} null : #t69.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
+ let final self::Class* #t70 = c in #t70.{core::Object::==}(null) ?{self::Class*} null : #t70.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
+ c = let final self::Class* #t71 = c in #t71.{core::Object::==}(null) ?{self::Class*} null : #t71.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
+ let final self::Class* #t72 = c in #t72.{core::Object::==}(null) ?{self::Class*} null : #t72.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
+ c = let final self::Class* #t73 = c in #t73.{core::Object::==}(null) ?{self::Class*} null : #t73.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
+ self::throws(() → self::Class* => (let final self::Class* #t74 = c in #t74.{core::Object::==}(null) ?{self::Class*} null : #t74.{self::Class::method}()).{self::Class::method}().{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t75 = c in #t75.{core::Object::==}(null) ?{self::Class*} null : #t75.{self::Class::method}()).{self::Class::method}().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t76 = c in #t76.{core::Object::==}(null) ?{self::Class*} null : #t76.{self::Class::method}()).{self::Class::method}().{self::Class::method}());
+ let final self::Class* #t77 = let final self::Class* #t78 = c in #t78.{core::Object::==}(null) ?{self::Class*} null : #t78.{self::Class::method}() in #t77.{core::Object::==}(null) ?{self::Class*} null : #t77.{self::Class::method}();
+}
+static method indexAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => (let final self::Class* #t79 = c in #t79.{core::Object::==}(null) ?{self::Class*} null : #t79.{self::Class::field}).{self::Class::[]}(c));
+ self::throws(() → self::Class* => let final self::Class* #t80 = let final self::Class* #t81 = c in #t81.{core::Object::==}(null) ?{self::Class*} null : #t81.{self::Class::field} in let final self::Class* #t82 = c in let final self::Class* #t83 = new self::Class::•() in let final void #t84 = #t80.{self::Class::[]=}(#t82, #t83) in #t83);
+ self::throws(() → self::Class* => c = let final self::Class* #t85 = let final self::Class* #t86 = c in #t86.{core::Object::==}(null) ?{self::Class*} null : #t86.{self::Class::field} in let final self::Class* #t87 = c in let final self::Class* #t88 = new self::Class::•() in let final void #t89 = #t85.{self::Class::[]=}(#t87, #t88) in #t88);
+ self::throws(() → self::Class* => (let final self::Class* #t90 = c in #t90.{core::Object::==}(null) ?{self::Class*} null : #t90.{self::Class::field}).{self::Class::[]}(c).{self::Class::method}());
+ self::throws(() → self::Class* => let final self::Class* #t91 = let final self::Class* #t92 = c in #t92.{core::Object::==}(null) ?{self::Class*} null : #t92.{self::Class::field} in let final self::Class* #t93 = c in let final self::Class* #t94 = #t91.{self::Class::[]}(#t93).{self::Class::+}(0) in let final void #t95 = #t91.{self::Class::[]=}(#t93, #t94) in #t94);
+ self::throws(() → self::Class* => c = let final self::Class* #t96 = let final self::Class* #t97 = c in #t97.{core::Object::==}(null) ?{self::Class*} null : #t97.{self::Class::field} in let final self::Class* #t98 = c in let final self::Class* #t99 = #t96.{self::Class::[]}(#t98).{self::Class::+}(0) in let final void #t100 = #t96.{self::Class::[]=}(#t98, #t99) in #t99);
+ self::throws(() → self::Class* => let final self::Class* #t101 = let final self::Class* #t102 = c in #t102.{core::Object::==}(null) ?{self::Class*} null : #t102.{self::Class::field} in let final self::Class* #t103 = c in let final self::Class* #t104 = #t101.{self::Class::[]}(#t103) in let final void #t105 = #t101.{self::Class::[]=}(#t103, #t104.{self::Class::+}(1)) in #t104);
+ self::throws(() → self::Class* => c = let final self::Class* #t106 = let final self::Class* #t107 = c in #t107.{core::Object::==}(null) ?{self::Class*} null : #t107.{self::Class::field} in let final self::Class* #t108 = c in let final self::Class* #t109 = #t106.{self::Class::[]}(#t108) in let final void #t110 = #t106.{self::Class::[]=}(#t108, #t109.{self::Class::+}(1)) in #t109);
+ self::throws(() → self::Class* => let final self::Class* #t111 = let final self::Class* #t112 = c in #t112.{core::Object::==}(null) ?{self::Class*} null : #t112.{self::Class::field} in let final self::Class* #t113 = c in let final self::Class* #t114 = #t111.{self::Class::[]}(#t113).{self::Class::+}(1) in let final void #t115 = #t111.{self::Class::[]=}(#t113, #t114) in #t114);
+ self::throws(() → self::Class* => c = let final self::Class* #t116 = let final self::Class* #t117 = c in #t117.{core::Object::==}(null) ?{self::Class*} null : #t117.{self::Class::field} in let final self::Class* #t118 = c in let final self::Class* #t119 = #t116.{self::Class::[]}(#t118).{self::Class::+}(1) in let final void #t120 = #t116.{self::Class::[]=}(#t118, #t119) in #t119);
+ self::throws(() → self::Class* => (let final self::Class* #t121 = c in #t121.{core::Object::==}(null) ?{self::Class*} null : #t121.{self::Class::field}).{self::Class::[]}(c).{self::Class::[]}(c));
+ self::throws(() → self::Class* => let final self::Class* #t122 = (let final self::Class* #t123 = c in #t123.{core::Object::==}(null) ?{self::Class*} null : #t123.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t124 = c in let final self::Class* #t125 = new self::Class::•() in let final void #t126 = #t122.{self::Class::[]=}(#t124, #t125) in #t125);
+ self::throws(() → self::Class* => c = let final self::Class* #t127 = (let final self::Class* #t128 = c in #t128.{core::Object::==}(null) ?{self::Class*} null : #t128.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t129 = c in let final self::Class* #t130 = new self::Class::•() in let final void #t131 = #t127.{self::Class::[]=}(#t129, #t130) in #t130);
+ self::throws(() → self::Class* => (let final self::Class* #t132 = c in #t132.{core::Object::==}(null) ?{self::Class*} null : #t132.{self::Class::field}).{self::Class::[]}(c).{self::Class::[]}(c).{self::Class::method}());
+ self::throws(() → self::Class* => let final self::Class* #t133 = (let final self::Class* #t134 = c in #t134.{core::Object::==}(null) ?{self::Class*} null : #t134.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t135 = c in let final self::Class* #t136 = #t133.{self::Class::[]}(#t135).{self::Class::+}(0) in let final void #t137 = #t133.{self::Class::[]=}(#t135, #t136) in #t136);
+ self::throws(() → self::Class* => c = let final self::Class* #t138 = (let final self::Class* #t139 = c in #t139.{core::Object::==}(null) ?{self::Class*} null : #t139.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t140 = c in let final self::Class* #t141 = #t138.{self::Class::[]}(#t140).{self::Class::+}(0) in let final void #t142 = #t138.{self::Class::[]=}(#t140, #t141) in #t141);
+ self::throws(() → self::Class* => let final self::Class* #t143 = (let final self::Class* #t144 = c in #t144.{core::Object::==}(null) ?{self::Class*} null : #t144.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t145 = c in let final self::Class* #t146 = #t143.{self::Class::[]}(#t145) in let final void #t147 = #t143.{self::Class::[]=}(#t145, #t146.{self::Class::+}(1)) in #t146);
+ self::throws(() → self::Class* => c = let final self::Class* #t148 = (let final self::Class* #t149 = c in #t149.{core::Object::==}(null) ?{self::Class*} null : #t149.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t150 = c in let final self::Class* #t151 = #t148.{self::Class::[]}(#t150) in let final void #t152 = #t148.{self::Class::[]=}(#t150, #t151.{self::Class::+}(1)) in #t151);
+ self::throws(() → self::Class* => let final self::Class* #t153 = (let final self::Class* #t154 = c in #t154.{core::Object::==}(null) ?{self::Class*} null : #t154.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t155 = c in let final self::Class* #t156 = #t153.{self::Class::[]}(#t155).{self::Class::+}(1) in let final void #t157 = #t153.{self::Class::[]=}(#t155, #t156) in #t156);
+ self::throws(() → self::Class* => c = let final self::Class* #t158 = (let final self::Class* #t159 = c in #t159.{core::Object::==}(null) ?{self::Class*} null : #t159.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t160 = c in let final self::Class* #t161 = #t158.{self::Class::[]}(#t160).{self::Class::+}(1) in let final void #t162 = #t158.{self::Class::[]=}(#t160, #t161) in #t161);
+}
+static method operatorAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => (let final self::Class* #t163 = c in #t163.{core::Object::==}(null) ?{self::Class*} null : #t163.{self::Class::field}).{self::Class::+}(0));
+ self::throws(() → self::Class* => (let final self::Class* #t164 = c in #t164.{core::Object::==}(null) ?{self::Class*} null : #t164.{self::Class::field}).{self::Class::unary-}());
+ let final self::Class* #t165 = c in #t165.{core::Object::==}(null) ?{self::Class*} null : #t165.{self::Class::field} = #t165.{self::Class::field}.{self::Class::+}(0);
+ c = let final self::Class* #t166 = c in #t166.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t167 = #t166.{self::Class::field}.{self::Class::+}(0) in let final void #t168 = #t166.{self::Class::field} = #t167 in #t167;
+ self::throws(() → self::Class* => let final self::Class* #t169 = let final self::Class* #t170 = c in #t170.{core::Object::==}(null) ?{self::Class*} null : #t170.{self::Class::field} in #t169.{self::Class::field} = #t169.{self::Class::field}.{self::Class::+}(0));
+ self::throws(() → self::Class* => c = let final self::Class* #t171 = let final self::Class* #t172 = c in #t172.{core::Object::==}(null) ?{self::Class*} null : #t172.{self::Class::field} in #t171.{self::Class::field} = #t171.{self::Class::field}.{self::Class::+}(0));
+ let final self::Class* #t173 = c in #t173.{core::Object::==}(null) ?{self::Class*} null : #t173.{self::Class::field} = #t173.{self::Class::field}.{self::Class::+}(1);
+ c = let final self::Class* #t174 = c in #t174.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t175 = #t174.{self::Class::field} in let final void #t176 = #t174.{self::Class::field} = #t175.{self::Class::+}(1) in #t175;
+ let final self::Class* #t177 = c in #t177.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t178 = #t177.{self::Class::field}.{self::Class::+}(1) in let final void #t179 = #t177.{self::Class::field} = #t178 in #t178;
+ c = let final self::Class* #t180 = c in #t180.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t181 = #t180.{self::Class::field}.{self::Class::+}(1) in let final void #t182 = #t180.{self::Class::field} = #t181 in #t181;
+}
+static method ifNull(self::Class* c) → void {
+ let final self::Class* #t183 = c in #t183.{core::Object::==}(null) ?{self::Class*} null : #t183.{self::Class::field}.{core::Object::==}(null) ?{self::Class*} #t183.{self::Class::field} = c : null;
+ c = let final self::Class* #t184 = c in #t184.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t185 = #t184.{self::Class::field} in #t185.{core::Object::==}(null) ?{self::Class*} #t184.{self::Class::field} = c : #t185;
+ self::throws(() → self::Class* => let final self::Class* #t186 = let final self::Class* #t187 = c in #t187.{core::Object::==}(null) ?{self::Class*} null : #t187.{self::Class::field} in let final self::Class* #t188 = #t186.{self::Class::field} in #t188.{core::Object::==}(null) ?{self::Class*} #t186.{self::Class::field} = c : #t188);
+ self::throws(() → self::Class* => c = let final self::Class* #t189 = let final self::Class* #t190 = c in #t190.{core::Object::==}(null) ?{self::Class*} null : #t190.{self::Class::field} in let final self::Class* #t191 = #t189.{self::Class::field} in #t191.{core::Object::==}(null) ?{self::Class*} #t189.{self::Class::field} = c : #t191);
+ self::throws(() → self::Class* => let final self::Class* #t192 = let final self::Class* #t193 = c in #t193.{core::Object::==}(null) ?{self::Class*} null : #t193.{self::Class::field} in let final self::Class* #t194 = c in let final self::Class* #t195 = #t192.{self::Class::[]}(#t194) in #t195.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t196 = c in let final void #t197 = #t192.{self::Class::[]=}(#t194, #t196) in #t196 : #t195);
+ self::throws(() → self::Class* => c = let final self::Class* #t198 = let final self::Class* #t199 = c in #t199.{core::Object::==}(null) ?{self::Class*} null : #t199.{self::Class::field} in let final self::Class* #t200 = c in let final self::Class* #t201 = #t198.{self::Class::[]}(#t200) in #t201.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t202 = c in let final void #t203 = #t198.{self::Class::[]=}(#t200, #t202) in #t202 : #t201);
+}
+static method throws(() →* void f) → void {
+ try {
+ f.call();
+ }
+ on dynamic catch(final dynamic _) {
+ return;
+ }
+ throw "Expected exception.";
+}
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/no_null_shorting.dart.strong.transformed.expect
new file mode 100644
index 0000000..b0d09f9
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting.dart.strong.transformed.expect
@@ -0,0 +1,151 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class* field = null;
+ synthetic constructor •() → self::Class*
+ : super core::Object::•()
+ ;
+ method method() → self::Class*
+ return this.{self::Class::field};
+ operator [](self::Class* key) → self::Class*
+ return this.{self::Class::field};
+ operator []=(self::Class* key, self::Class* value) → void {
+ this.{self::Class::field} = value;
+ }
+ operator +(core::int* value) → self::Class*
+ return this.{self::Class::field};
+ operator unary-() → self::Class*
+ return this.{self::Class::field};
+}
+static method main() → dynamic {
+ self::propertyAccess(null);
+ self::indexAccess(null);
+ self::operatorAccess(null);
+ self::ifNull(null);
+}
+static method propertyAccess(self::Class* c) → void {
+ let final self::Class* #t1 = c in #t1.{core::Object::==}(null) ?{self::Class*} null : #t1.{self::Class::field};
+ let final self::Class* #t2 = c in #t2.{core::Object::==}(null) ?{self::Class*} null : #t2.{self::Class::field} = new self::Class::•();
+ c = let final self::Class* #t3 = c in #t3.{core::Object::==}(null) ?{self::Class*} null : #t3.{self::Class::field} = new self::Class::•();
+ let final self::Class* #t4 = c in #t4.{core::Object::==}(null) ?{self::Class*} null : #t4.{self::Class::method}();
+ self::throws(() → self::Class* => (let final self::Class* #t5 = c in #t5.{core::Object::==}(null) ?{self::Class*} null : #t5.{self::Class::field}).{self::Class::field});
+ let final self::Class* #t6 = let final self::Class* #t7 = c in #t7.{core::Object::==}(null) ?{self::Class*} null : #t7.{self::Class::field} in #t6.{core::Object::==}(null) ?{self::Class*} null : #t6.{self::Class::field};
+ self::throws(() → self::Class* => let final self::Class* #t8 = (let final self::Class* #t9 = c in #t9.{core::Object::==}(null) ?{self::Class*} null : #t9.{self::Class::field}).{self::Class::field} in #t8.{core::Object::==}(null) ?{self::Class*} null : #t8.{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t10 = c in #t10.{core::Object::==}(null) ?{self::Class*} null : #t10.{self::Class::field}).{self::Class::field} = new self::Class::•());
+ let final self::Class* #t11 = let final self::Class* #t12 = c in #t12.{core::Object::==}(null) ?{self::Class*} null : #t12.{self::Class::field} in #t11.{core::Object::==}(null) ?{self::Class*} null : #t11.{self::Class::field} = new self::Class::•();
+ self::throws(() → self::Class* => let final self::Class* #t13 = (let final self::Class* #t14 = c in #t14.{core::Object::==}(null) ?{self::Class*} null : #t14.{self::Class::field}).{self::Class::field} in #t13.{core::Object::==}(null) ?{self::Class*} null : #t13.{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t15 = c in #t15.{core::Object::==}(null) ?{self::Class*} null : #t15.{self::Class::field}).{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t16 = c in #t16.{core::Object::==}(null) ?{self::Class*} null : #t16.{self::Class::field} = new self::Class::•()).{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t17 = c in #t17.{core::Object::==}(null) ?{self::Class*} null : #t17.{self::Class::method}()).{self::Class::field});
+ self::throws(() → self::Class* => c = (let final self::Class* #t18 = c in #t18.{core::Object::==}(null) ?{self::Class*} null : #t18.{self::Class::field}).{self::Class::field} = new self::Class::•());
+ c = let final self::Class* #t19 = let final self::Class* #t20 = c in #t20.{core::Object::==}(null) ?{self::Class*} null : #t20.{self::Class::field} in #t19.{core::Object::==}(null) ?{self::Class*} null : #t19.{self::Class::field} = new self::Class::•();
+ self::throws(() → self::Class* => c = let final self::Class* #t21 = (let final self::Class* #t22 = c in #t22.{core::Object::==}(null) ?{self::Class*} null : #t22.{self::Class::field}).{self::Class::field} in #t21.{core::Object::==}(null) ?{self::Class*} null : #t21.{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t23 = c in #t23.{core::Object::==}(null) ?{self::Class*} null : #t23.{self::Class::field}).{self::Class::method}());
+ let final self::Class* #t24 = c in #t24.{core::Object::==}(null) ?{self::Class*} null : #t24.{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class* #t25 = c in #t25.{core::Object::==}(null) ?{self::Class*} null : #t25.{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class* #t26 = c in #t26.{core::Object::==}(null) ?{self::Class*} null : #t26.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class* #t27 = c in #t27.{core::Object::==}(null) ?{self::Class*} null : #t27.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class* #t28 = c in #t28.{core::Object::==}(null) ?{self::Class*} null : #t28.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class* #t29 = c in #t29.{core::Object::==}(null) ?{self::Class*} null : #t29.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ self::throws(() → self::Class* => (let final self::Class* #t30 = c in #t30.{core::Object::==}(null) ?{self::Class*} null : #t30.{self::Class::method}()).{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t31 = c in #t31.{core::Object::==}(null) ?{self::Class*} null : #t31.{self::Class::method}()).{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t32 = c in #t32.{core::Object::==}(null) ?{self::Class*} null : #t32.{self::Class::method}()).{self::Class::method}());
+ self::throws(() → self::Class* => (let final self::Class* #t33 = c in #t33.{core::Object::==}(null) ?{self::Class*} null : #t33.{self::Class::field}).{self::Class::field}.{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t34 = c in #t34.{core::Object::==}(null) ?{self::Class*} null : #t34.{self::Class::field}).{self::Class::field}.{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => c = (let final self::Class* #t35 = c in #t35.{core::Object::==}(null) ?{self::Class*} null : #t35.{self::Class::field}).{self::Class::field}.{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t36 = c in #t36.{core::Object::==}(null) ?{self::Class*} null : #t36.{self::Class::field}).{self::Class::field}.{self::Class::method}());
+ let final self::Class* #t37 = c in #t37.{core::Object::==}(null) ?{self::Class*} null : #t37.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
+ c = let final self::Class* #t38 = c in #t38.{core::Object::==}(null) ?{self::Class*} null : #t38.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
+ let final self::Class* #t39 = c in #t39.{core::Object::==}(null) ?{self::Class*} null : #t39.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class* #t40 = c in #t40.{core::Object::==}(null) ?{self::Class*} null : #t40.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
+ let final self::Class* #t41 = c in #t41.{core::Object::==}(null) ?{self::Class*} null : #t41.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
+ c = let final self::Class* #t42 = c in #t42.{core::Object::==}(null) ?{self::Class*} null : #t42.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
+ self::throws(() → self::Class* => (let final self::Class* #t43 = c in #t43.{core::Object::==}(null) ?{self::Class*} null : #t43.{self::Class::method}()).{self::Class::field}.{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t44 = c in #t44.{core::Object::==}(null) ?{self::Class*} null : #t44.{self::Class::method}()).{self::Class::field}.{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t45 = c in #t45.{core::Object::==}(null) ?{self::Class*} null : #t45.{self::Class::method}()).{self::Class::field}.{self::Class::method}());
+ self::throws(() → self::Class* => (let final self::Class* #t46 = c in #t46.{core::Object::==}(null) ?{self::Class*} null : #t46.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::field});
+ self::throws(() → self::Class* => c = (let final self::Class* #t47 = c in #t47.{core::Object::==}(null) ?{self::Class*} null : #t47.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t48 = c in #t48.{core::Object::==}(null) ?{self::Class*} null : #t48.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => c = (let final self::Class* #t49 = c in #t49.{core::Object::==}(null) ?{self::Class*} null : #t49.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t50 = c in #t50.{core::Object::==}(null) ?{self::Class*} null : #t50.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::method}());
+ self::throws(() → self::Class* => c = (let final self::Class* #t51 = c in #t51.{core::Object::==}(null) ?{self::Class*} null : #t51.{self::Class::field}).{self::Class::field} = new self::Class::•().{self::Class::method}());
+ let final self::Class* #t52 = c in #t52.{core::Object::==}(null) ?{self::Class*} null : #t52.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class* #t53 = c in #t53.{core::Object::==}(null) ?{self::Class*} null : #t53.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class* #t54 = c in #t54.{core::Object::==}(null) ?{self::Class*} null : #t54.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class* #t55 = c in #t55.{core::Object::==}(null) ?{self::Class*} null : #t55.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class* #t56 = c in #t56.{core::Object::==}(null) ?{self::Class*} null : #t56.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class* #t57 = c in #t57.{core::Object::==}(null) ?{self::Class*} null : #t57.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ self::throws(() → self::Class* => (let final self::Class* #t58 = c in #t58.{core::Object::==}(null) ?{self::Class*} null : #t58.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::field});
+ self::throws(() → self::Class* => c = (let final self::Class* #t59 = c in #t59.{core::Object::==}(null) ?{self::Class*} null : #t59.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t60 = c in #t60.{core::Object::==}(null) ?{self::Class*} null : #t60.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => c = (let final self::Class* #t61 = c in #t61.{core::Object::==}(null) ?{self::Class*} null : #t61.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t62 = c in #t62.{core::Object::==}(null) ?{self::Class*} null : #t62.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::method}());
+ self::throws(() → self::Class* => c = (let final self::Class* #t63 = c in #t63.{core::Object::==}(null) ?{self::Class*} null : #t63.{self::Class::method}()).{self::Class::field} = new self::Class::•().{self::Class::method}());
+ self::throws(() → self::Class* => (let final self::Class* #t64 = c in #t64.{core::Object::==}(null) ?{self::Class*} null : #t64.{self::Class::field}).{self::Class::method}().{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t65 = c in #t65.{core::Object::==}(null) ?{self::Class*} null : #t65.{self::Class::field}).{self::Class::method}().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => c = (let final self::Class* #t66 = c in #t66.{core::Object::==}(null) ?{self::Class*} null : #t66.{self::Class::field}).{self::Class::method}().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t67 = c in #t67.{core::Object::==}(null) ?{self::Class*} null : #t67.{self::Class::field}).{self::Class::method}().{self::Class::method}());
+ let final self::Class* #t68 = c in #t68.{core::Object::==}(null) ?{self::Class*} null : #t68.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
+ c = let final self::Class* #t69 = c in #t69.{core::Object::==}(null) ?{self::Class*} null : #t69.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
+ let final self::Class* #t70 = c in #t70.{core::Object::==}(null) ?{self::Class*} null : #t70.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
+ c = let final self::Class* #t71 = c in #t71.{core::Object::==}(null) ?{self::Class*} null : #t71.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
+ let final self::Class* #t72 = c in #t72.{core::Object::==}(null) ?{self::Class*} null : #t72.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
+ c = let final self::Class* #t73 = c in #t73.{core::Object::==}(null) ?{self::Class*} null : #t73.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
+ self::throws(() → self::Class* => (let final self::Class* #t74 = c in #t74.{core::Object::==}(null) ?{self::Class*} null : #t74.{self::Class::method}()).{self::Class::method}().{self::Class::field});
+ self::throws(() → self::Class* => (let final self::Class* #t75 = c in #t75.{core::Object::==}(null) ?{self::Class*} null : #t75.{self::Class::method}()).{self::Class::method}().{self::Class::field} = new self::Class::•());
+ self::throws(() → self::Class* => (let final self::Class* #t76 = c in #t76.{core::Object::==}(null) ?{self::Class*} null : #t76.{self::Class::method}()).{self::Class::method}().{self::Class::method}());
+ let final self::Class* #t77 = let final self::Class* #t78 = c in #t78.{core::Object::==}(null) ?{self::Class*} null : #t78.{self::Class::method}() in #t77.{core::Object::==}(null) ?{self::Class*} null : #t77.{self::Class::method}();
+}
+static method indexAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => (let final self::Class* #t79 = c in #t79.{core::Object::==}(null) ?{self::Class*} null : #t79.{self::Class::field}).{self::Class::[]}(c));
+ self::throws(() → self::Class* => let final self::Class* #t80 = let final self::Class* #t81 = c in #t81.{core::Object::==}(null) ?{self::Class*} null : #t81.{self::Class::field} in let final self::Class* #t82 = c in let final self::Class* #t83 = new self::Class::•() in let final void #t84 = #t80.{self::Class::[]=}(#t82, #t83) in #t83);
+ self::throws(() → self::Class* => c = let final self::Class* #t85 = let final self::Class* #t86 = c in #t86.{core::Object::==}(null) ?{self::Class*} null : #t86.{self::Class::field} in let final self::Class* #t87 = c in let final self::Class* #t88 = new self::Class::•() in let final void #t89 = #t85.{self::Class::[]=}(#t87, #t88) in #t88);
+ self::throws(() → self::Class* => (let final self::Class* #t90 = c in #t90.{core::Object::==}(null) ?{self::Class*} null : #t90.{self::Class::field}).{self::Class::[]}(c).{self::Class::method}());
+ self::throws(() → self::Class* => let final self::Class* #t91 = let final self::Class* #t92 = c in #t92.{core::Object::==}(null) ?{self::Class*} null : #t92.{self::Class::field} in let final self::Class* #t93 = c in let final self::Class* #t94 = #t91.{self::Class::[]}(#t93).{self::Class::+}(0) in let final void #t95 = #t91.{self::Class::[]=}(#t93, #t94) in #t94);
+ self::throws(() → self::Class* => c = let final self::Class* #t96 = let final self::Class* #t97 = c in #t97.{core::Object::==}(null) ?{self::Class*} null : #t97.{self::Class::field} in let final self::Class* #t98 = c in let final self::Class* #t99 = #t96.{self::Class::[]}(#t98).{self::Class::+}(0) in let final void #t100 = #t96.{self::Class::[]=}(#t98, #t99) in #t99);
+ self::throws(() → self::Class* => let final self::Class* #t101 = let final self::Class* #t102 = c in #t102.{core::Object::==}(null) ?{self::Class*} null : #t102.{self::Class::field} in let final self::Class* #t103 = c in let final self::Class* #t104 = #t101.{self::Class::[]}(#t103) in let final void #t105 = #t101.{self::Class::[]=}(#t103, #t104.{self::Class::+}(1)) in #t104);
+ self::throws(() → self::Class* => c = let final self::Class* #t106 = let final self::Class* #t107 = c in #t107.{core::Object::==}(null) ?{self::Class*} null : #t107.{self::Class::field} in let final self::Class* #t108 = c in let final self::Class* #t109 = #t106.{self::Class::[]}(#t108) in let final void #t110 = #t106.{self::Class::[]=}(#t108, #t109.{self::Class::+}(1)) in #t109);
+ self::throws(() → self::Class* => let final self::Class* #t111 = let final self::Class* #t112 = c in #t112.{core::Object::==}(null) ?{self::Class*} null : #t112.{self::Class::field} in let final self::Class* #t113 = c in let final self::Class* #t114 = #t111.{self::Class::[]}(#t113).{self::Class::+}(1) in let final void #t115 = #t111.{self::Class::[]=}(#t113, #t114) in #t114);
+ self::throws(() → self::Class* => c = let final self::Class* #t116 = let final self::Class* #t117 = c in #t117.{core::Object::==}(null) ?{self::Class*} null : #t117.{self::Class::field} in let final self::Class* #t118 = c in let final self::Class* #t119 = #t116.{self::Class::[]}(#t118).{self::Class::+}(1) in let final void #t120 = #t116.{self::Class::[]=}(#t118, #t119) in #t119);
+ self::throws(() → self::Class* => (let final self::Class* #t121 = c in #t121.{core::Object::==}(null) ?{self::Class*} null : #t121.{self::Class::field}).{self::Class::[]}(c).{self::Class::[]}(c));
+ self::throws(() → self::Class* => let final self::Class* #t122 = (let final self::Class* #t123 = c in #t123.{core::Object::==}(null) ?{self::Class*} null : #t123.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t124 = c in let final self::Class* #t125 = new self::Class::•() in let final void #t126 = #t122.{self::Class::[]=}(#t124, #t125) in #t125);
+ self::throws(() → self::Class* => c = let final self::Class* #t127 = (let final self::Class* #t128 = c in #t128.{core::Object::==}(null) ?{self::Class*} null : #t128.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t129 = c in let final self::Class* #t130 = new self::Class::•() in let final void #t131 = #t127.{self::Class::[]=}(#t129, #t130) in #t130);
+ self::throws(() → self::Class* => (let final self::Class* #t132 = c in #t132.{core::Object::==}(null) ?{self::Class*} null : #t132.{self::Class::field}).{self::Class::[]}(c).{self::Class::[]}(c).{self::Class::method}());
+ self::throws(() → self::Class* => let final self::Class* #t133 = (let final self::Class* #t134 = c in #t134.{core::Object::==}(null) ?{self::Class*} null : #t134.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t135 = c in let final self::Class* #t136 = #t133.{self::Class::[]}(#t135).{self::Class::+}(0) in let final void #t137 = #t133.{self::Class::[]=}(#t135, #t136) in #t136);
+ self::throws(() → self::Class* => c = let final self::Class* #t138 = (let final self::Class* #t139 = c in #t139.{core::Object::==}(null) ?{self::Class*} null : #t139.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t140 = c in let final self::Class* #t141 = #t138.{self::Class::[]}(#t140).{self::Class::+}(0) in let final void #t142 = #t138.{self::Class::[]=}(#t140, #t141) in #t141);
+ self::throws(() → self::Class* => let final self::Class* #t143 = (let final self::Class* #t144 = c in #t144.{core::Object::==}(null) ?{self::Class*} null : #t144.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t145 = c in let final self::Class* #t146 = #t143.{self::Class::[]}(#t145) in let final void #t147 = #t143.{self::Class::[]=}(#t145, #t146.{self::Class::+}(1)) in #t146);
+ self::throws(() → self::Class* => c = let final self::Class* #t148 = (let final self::Class* #t149 = c in #t149.{core::Object::==}(null) ?{self::Class*} null : #t149.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t150 = c in let final self::Class* #t151 = #t148.{self::Class::[]}(#t150) in let final void #t152 = #t148.{self::Class::[]=}(#t150, #t151.{self::Class::+}(1)) in #t151);
+ self::throws(() → self::Class* => let final self::Class* #t153 = (let final self::Class* #t154 = c in #t154.{core::Object::==}(null) ?{self::Class*} null : #t154.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t155 = c in let final self::Class* #t156 = #t153.{self::Class::[]}(#t155).{self::Class::+}(1) in let final void #t157 = #t153.{self::Class::[]=}(#t155, #t156) in #t156);
+ self::throws(() → self::Class* => c = let final self::Class* #t158 = (let final self::Class* #t159 = c in #t159.{core::Object::==}(null) ?{self::Class*} null : #t159.{self::Class::field}).{self::Class::[]}(c) in let final self::Class* #t160 = c in let final self::Class* #t161 = #t158.{self::Class::[]}(#t160).{self::Class::+}(1) in let final void #t162 = #t158.{self::Class::[]=}(#t160, #t161) in #t161);
+}
+static method operatorAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => (let final self::Class* #t163 = c in #t163.{core::Object::==}(null) ?{self::Class*} null : #t163.{self::Class::field}).{self::Class::+}(0));
+ self::throws(() → self::Class* => (let final self::Class* #t164 = c in #t164.{core::Object::==}(null) ?{self::Class*} null : #t164.{self::Class::field}).{self::Class::unary-}());
+ let final self::Class* #t165 = c in #t165.{core::Object::==}(null) ?{self::Class*} null : #t165.{self::Class::field} = #t165.{self::Class::field}.{self::Class::+}(0);
+ c = let final self::Class* #t166 = c in #t166.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t167 = #t166.{self::Class::field}.{self::Class::+}(0) in let final void #t168 = #t166.{self::Class::field} = #t167 in #t167;
+ self::throws(() → self::Class* => let final self::Class* #t169 = let final self::Class* #t170 = c in #t170.{core::Object::==}(null) ?{self::Class*} null : #t170.{self::Class::field} in #t169.{self::Class::field} = #t169.{self::Class::field}.{self::Class::+}(0));
+ self::throws(() → self::Class* => c = let final self::Class* #t171 = let final self::Class* #t172 = c in #t172.{core::Object::==}(null) ?{self::Class*} null : #t172.{self::Class::field} in #t171.{self::Class::field} = #t171.{self::Class::field}.{self::Class::+}(0));
+ let final self::Class* #t173 = c in #t173.{core::Object::==}(null) ?{self::Class*} null : #t173.{self::Class::field} = #t173.{self::Class::field}.{self::Class::+}(1);
+ c = let final self::Class* #t174 = c in #t174.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t175 = #t174.{self::Class::field} in let final void #t176 = #t174.{self::Class::field} = #t175.{self::Class::+}(1) in #t175;
+ let final self::Class* #t177 = c in #t177.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t178 = #t177.{self::Class::field}.{self::Class::+}(1) in let final void #t179 = #t177.{self::Class::field} = #t178 in #t178;
+ c = let final self::Class* #t180 = c in #t180.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t181 = #t180.{self::Class::field}.{self::Class::+}(1) in let final void #t182 = #t180.{self::Class::field} = #t181 in #t181;
+}
+static method ifNull(self::Class* c) → void {
+ let final self::Class* #t183 = c in #t183.{core::Object::==}(null) ?{self::Class*} null : #t183.{self::Class::field}.{core::Object::==}(null) ?{self::Class*} #t183.{self::Class::field} = c : null;
+ c = let final self::Class* #t184 = c in #t184.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t185 = #t184.{self::Class::field} in #t185.{core::Object::==}(null) ?{self::Class*} #t184.{self::Class::field} = c : #t185;
+ self::throws(() → self::Class* => let final self::Class* #t186 = let final self::Class* #t187 = c in #t187.{core::Object::==}(null) ?{self::Class*} null : #t187.{self::Class::field} in let final self::Class* #t188 = #t186.{self::Class::field} in #t188.{core::Object::==}(null) ?{self::Class*} #t186.{self::Class::field} = c : #t188);
+ self::throws(() → self::Class* => c = let final self::Class* #t189 = let final self::Class* #t190 = c in #t190.{core::Object::==}(null) ?{self::Class*} null : #t190.{self::Class::field} in let final self::Class* #t191 = #t189.{self::Class::field} in #t191.{core::Object::==}(null) ?{self::Class*} #t189.{self::Class::field} = c : #t191);
+ self::throws(() → self::Class* => let final self::Class* #t192 = let final self::Class* #t193 = c in #t193.{core::Object::==}(null) ?{self::Class*} null : #t193.{self::Class::field} in let final self::Class* #t194 = c in let final self::Class* #t195 = #t192.{self::Class::[]}(#t194) in #t195.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t196 = c in let final void #t197 = #t192.{self::Class::[]=}(#t194, #t196) in #t196 : #t195);
+ self::throws(() → self::Class* => c = let final self::Class* #t198 = let final self::Class* #t199 = c in #t199.{core::Object::==}(null) ?{self::Class*} null : #t199.{self::Class::field} in let final self::Class* #t200 = c in let final self::Class* #t201 = #t198.{self::Class::[]}(#t200) in #t201.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t202 = c in let final void #t203 = #t198.{self::Class::[]=}(#t200, #t202) in #t202 : #t201);
+}
+static method throws(() →* void f) → void {
+ try {
+ f.call();
+ }
+ on dynamic catch(final dynamic _) {
+ return;
+ }
+ throw "Expected exception.";
+}
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart b/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart
new file mode 100644
index 0000000..8d1ca35
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart
@@ -0,0 +1,172 @@
+// Copyright (c) 2019, 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.
+
+// @dart=2.6
+
+class Class {
+ Class _field;
+}
+
+extension Extension on Class {
+ Class get field => _field;
+ void set field(Class value) {
+ _field = value;
+ }
+
+ Class method() => field;
+
+ Class operator [](Class key) => field;
+ void operator []=(Class key, Class value) {
+ field = value;
+ }
+
+ Class operator +(int value) => field;
+
+ Class operator -() => field;
+}
+
+main() {
+ propertyAccess(null);
+ indexAccess(null);
+ operatorAccess(null);
+ ifNull(null);
+}
+
+void propertyAccess(Class c) {
+ Extension(c)?.field;
+ Extension(c)?.field = new Class();
+ c = Extension(c)?.field = new Class();
+ Extension(c)?.method();
+
+ throws(() => Extension(c)?.field.field);
+ Extension(c)?.field?.field;
+ throws(() => Extension(c)?.field.field?.field);
+ throws(() => Extension(c)?.field.field = new Class());
+ Extension(c)?.field?.field = new Class();
+ throws(() => Extension(c)?.field.field?.field = new Class());
+ throws(() => (Extension(c)?.field).field);
+ throws(() => (Extension(c)?.field = new Class()).field);
+ throws(() => (Extension(c)?.method()).field);
+ throws(() => c = Extension(c)?.field.field = new Class());
+ c = Extension(c)?.field?.field = new Class();
+ throws(() => c = Extension(c)?.field.field?.field = new Class());
+ throws(() => Extension(c)?.field.method());
+ Extension(c)?.field = new Class().field;
+ c = Extension(c)?.field = new Class().field;
+ Extension(c)?.field = new Class().field = new Class();
+ c = Extension(c)?.field = new Class().field = new Class();
+ Extension(c)?.field = new Class().method();
+ c = Extension(c)?.field = new Class().method();
+ throws(() => Extension(c)?.method().field);
+ throws(() => Extension(c)?.method().field = new Class());
+ throws(() => Extension(c)?.method().method());
+
+ throws(() => Extension(c)?.field.field.field);
+ throws(() => Extension(c)?.field.field.field = new Class());
+ throws(() => c = Extension(c)?.field.field.field = new Class());
+ throws(() => Extension(c)?.field.field.method());
+ Extension(c)?.field = new Class().field.field;
+ c = Extension(c)?.field = new Class().field.field;
+ Extension(c)?.field = new Class().field.field = new Class();
+ c = Extension(c)?.field = new Class().field.field = new Class();
+ Extension(c)?.field = new Class().field.method();
+ c = Extension(c)?.field = new Class().field.method();
+ throws(() => Extension(c)?.method().field.field);
+ throws(() => Extension(c)?.method().field.field = new Class());
+ throws(() => Extension(c)?.method().field.method());
+
+ throws(() => Extension(c)?.field.field = new Class().field);
+ throws(() => c = Extension(c)?.field.field = new Class().field);
+ throws(() => Extension(c)?.field.field = new Class().field = new Class());
+ throws(() => c = Extension(c)?.field.field = new Class().field = new Class());
+ throws(() => Extension(c)?.field.field = new Class().method());
+ throws(() => c = Extension(c)?.field.field = new Class().method());
+ Extension(c)?.field = new Class().field = new Class().field;
+ c = Extension(c)?.field = new Class().field = new Class().field;
+ Extension(c)?.field = new Class().field = new Class().field = new Class();
+ c = Extension(c)?.field = new Class().field = new Class().field = new Class();
+ Extension(c)?.field = new Class().field = new Class().method();
+ c = Extension(c)?.field = new Class().field = new Class().method();
+ throws(() => Extension(c)?.method().field = new Class().field);
+ throws(() => c = Extension(c)?.method().field = new Class().field);
+ throws(() => Extension(c)?.method().field = new Class().field = new Class());
+ throws(
+ () => c = Extension(c)?.method().field = new Class().field = new Class());
+ throws(() => Extension(c)?.method().field = new Class().method());
+ throws(() => c = Extension(c)?.method().field = new Class().method());
+
+ throws(() => Extension(c)?.field.method().field);
+ throws(() => Extension(c)?.field.method().field = new Class());
+ throws(() => c = Extension(c)?.field.method().field = new Class());
+ throws(() => Extension(c)?.field.method().method());
+ Extension(c)?.field = new Class().method().field;
+ c = Extension(c)?.field = new Class().method().field;
+ Extension(c)?.field = new Class().method().field = new Class();
+ c = Extension(c)?.field = new Class().method().field = new Class();
+ Extension(c)?.field = new Class().method().method();
+ c = Extension(c)?.field = new Class().method().method();
+ throws(() => Extension(c)?.method().method().field);
+ throws(() => Extension(c)?.method().method().field = new Class());
+ throws(() => Extension(c)?.method().method().method());
+
+ Extension(c)?.method()?.method();
+
+ throws(() => Extension(c?.field).field);
+ Extension(c?.field)?.field;
+}
+
+void indexAccess(Class c) {
+ throws(() => Extension(c)?.field[c]);
+ throws(() => Extension(c)?.field[c] = new Class());
+ throws(() => c = Extension(c)?.field[c] = new Class());
+ throws(() => Extension(c)?.field[c].method());
+ throws(() => Extension(c)?.field[c] += 0);
+ throws(() => c = Extension(c)?.field[c] += 0);
+ throws(() => Extension(c)?.field[c]++);
+ throws(() => c = Extension(c)?.field[c]++);
+ throws(() => ++Extension(c)?.field[c]);
+ throws(() => c = ++Extension(c)?.field[c]);
+
+ throws(() => Extension(c)?.field[c][c]);
+ throws(() => Extension(c)?.field[c][c] = new Class());
+ throws(() => c = Extension(c)?.field[c][c] = new Class());
+ throws(() => Extension(c)?.field[c][c].method());
+ throws(() => Extension(c)?.field[c][c] += 0);
+ throws(() => c = Extension(c)?.field[c][c] += 0);
+ throws(() => Extension(c)?.field[c][c]++);
+ throws(() => c = Extension(c)?.field[c][c]++);
+ throws(() => ++Extension(c)?.field[c][c]);
+ throws(() => c = ++Extension(c)?.field[c][c]);
+}
+
+void operatorAccess(Class c) {
+ throws(() => Extension(c)?.field + 0);
+ throws(() => -Extension(c)?.field);
+ Extension(c)?.field += 0;
+ c = Extension(c)?.field += 0;
+ throws(() => Extension(c)?.field.field += 0);
+ throws(() => c = Extension(c)?.field.field += 0);
+ Extension(c)?.field++;
+ c = Extension(c)?.field++;
+ ++Extension(c)?.field;
+ c = ++Extension(c)?.field;
+}
+
+void ifNull(Class c) {
+ Extension(c)?.field ??= c;
+ c = Extension(c)?.field ??= c;
+ throws(() => Extension(c)?.field.field ??= c);
+ throws(() => c = Extension(c)?.field.field ??= c);
+ throws(() => Extension(c)?.field[c] ??= c);
+ throws(() => c = Extension(c)?.field[c] ??= c);
+}
+
+void throws(void Function() f) {
+ try {
+ f();
+ } catch (_) {
+ return;
+ }
+ throw 'Expected exception.';
+}
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart.outline.expect b/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart.outline.expect
new file mode 100644
index 0000000..f7c609c
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart.outline.expect
@@ -0,0 +1,47 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class* _field;
+ synthetic constructor •() → self::Class*
+ ;
+}
+extension Extension on self::Class* {
+ get field = self::Extension|get#field;
+ method method = self::Extension|method;
+ tearoff method = self::Extension|get#method;
+ operator [] = self::Extension|[];
+ operator []= = self::Extension|[]=;
+ operator + = self::Extension|+;
+ operator unary- = self::Extension|unary-;
+ set field = self::Extension|set#field;
+}
+static method Extension|get#field(final self::Class* #this) → self::Class*
+ ;
+static method Extension|set#field(final self::Class* #this, self::Class* value) → void
+ ;
+static method Extension|method(final self::Class* #this) → self::Class*
+ ;
+static method Extension|get#method(final self::Class* #this) → () →* self::Class*
+ return () → self::Class* => self::Extension|method(#this);
+static method Extension|[](final self::Class* #this, self::Class* key) → self::Class*
+ ;
+static method Extension|[]=(final self::Class* #this, self::Class* key, self::Class* value) → void
+ ;
+static method Extension|+(final self::Class* #this, core::int* value) → self::Class*
+ ;
+static method Extension|unary-(final self::Class* #this) → self::Class*
+ ;
+static method main() → dynamic
+ ;
+static method propertyAccess(self::Class* c) → void
+ ;
+static method indexAccess(self::Class* c) → void
+ ;
+static method operatorAccess(self::Class* c) → void
+ ;
+static method ifNull(self::Class* c) → void
+ ;
+static method throws(() →* void f) → void
+ ;
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart.strong.expect b/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart.strong.expect
new file mode 100644
index 0000000..90b06d3
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart.strong.expect
@@ -0,0 +1,170 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class* _field = null;
+ synthetic constructor •() → self::Class*
+ : super core::Object::•()
+ ;
+}
+extension Extension on self::Class* {
+ get field = self::Extension|get#field;
+ method method = self::Extension|method;
+ tearoff method = self::Extension|get#method;
+ operator [] = self::Extension|[];
+ operator []= = self::Extension|[]=;
+ operator + = self::Extension|+;
+ operator unary- = self::Extension|unary-;
+ set field = self::Extension|set#field;
+}
+static method Extension|get#field(final self::Class* #this) → self::Class*
+ return #this.{self::Class::_field};
+static method Extension|set#field(final self::Class* #this, self::Class* value) → void {
+ #this.{self::Class::_field} = value;
+}
+static method Extension|method(final self::Class* #this) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|get#method(final self::Class* #this) → () →* self::Class*
+ return () → self::Class* => self::Extension|method(#this);
+static method Extension|[](final self::Class* #this, self::Class* key) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|[]=(final self::Class* #this, self::Class* key, self::Class* value) → void {
+ self::Extension|set#field(#this, value);
+}
+static method Extension|+(final self::Class* #this, core::int* value) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|unary-(final self::Class* #this) → self::Class*
+ return self::Extension|get#field(#this);
+static method main() → dynamic {
+ self::propertyAccess(null);
+ self::indexAccess(null);
+ self::operatorAccess(null);
+ self::ifNull(null);
+}
+static method propertyAccess(self::Class* c) → void {
+ let final self::Class* #t1 = c in #t1.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t1);
+ let final self::Class* #t2 = c in #t2.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t2, new self::Class::•());
+ c = let final self::Class* #t3 = c in #t3.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3, #t4) in #t4;
+ let final self::Class* #t6 = c in #t6.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t6);
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t7 = c in #t7.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t7)));
+ let final self::Class* #t8 = let final self::Class* #t9 = c in #t9.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t9) in #t8.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t8);
+ self::throws(() → self::Class* => let final self::Class* #t10 = self::Extension|get#field(let final self::Class* #t11 = c in #t11.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t11)) in #t10.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t10));
+ self::throws(() → self::Class* => let final self::Class* #t12 = new self::Class::•() in let final void #t13 = self::Extension|set#field(let final self::Class* #t14 = c in #t14.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t14), #t12) in #t12);
+ let final self::Class* #t15 = let final self::Class* #t16 = c in #t16.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t16) in #t15.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t15, new self::Class::•());
+ self::throws(() → self::Class* => let final self::Class* #t17 = self::Extension|get#field(let final self::Class* #t18 = c in #t18.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t18)) in #t17.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t19 = new self::Class::•() in let final void #t20 = self::Extension|set#field(#t17, #t19) in #t19);
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t21 = c in #t21.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t21)));
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t22 = c in #t22.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(#t22, #t23) in #t23));
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t25 = c in #t25.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t25)));
+ self::throws(() → self::Class* => c = let final self::Class* #t26 = new self::Class::•() in let final void #t27 = self::Extension|set#field(let final self::Class* #t28 = c in #t28.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t28), #t26) in #t26);
+ c = let final self::Class* #t29 = let final self::Class* #t30 = c in #t30.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t30) in #t29.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t31 = new self::Class::•() in let final void #t32 = self::Extension|set#field(#t29, #t31) in #t31;
+ self::throws(() → self::Class* => c = let final self::Class* #t33 = self::Extension|get#field(let final self::Class* #t34 = c in #t34.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t34)) in #t33.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t35 = new self::Class::•() in let final void #t36 = self::Extension|set#field(#t33, #t35) in #t35);
+ self::throws(() → self::Class* => self::Extension|method(let final self::Class* #t37 = c in #t37.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t37)));
+ let final self::Class* #t38 = c in #t38.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t38, self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class* #t39 = c in #t39.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t40 = self::Extension|get#field(new self::Class::•()) in let final void #t41 = self::Extension|set#field(#t39, #t40) in #t40;
+ let final self::Class* #t42 = c in #t42.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t42, let final self::Class* #t43 = new self::Class::•() in let final void #t44 = self::Extension|set#field(new self::Class::•(), #t43) in #t43);
+ c = let final self::Class* #t45 = c in #t45.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t46 = let final self::Class* #t47 = new self::Class::•() in let final void #t48 = self::Extension|set#field(new self::Class::•(), #t47) in #t47 in let final void #t49 = self::Extension|set#field(#t45, #t46) in #t46;
+ let final self::Class* #t50 = c in #t50.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t50, self::Extension|method(new self::Class::•()));
+ c = let final self::Class* #t51 = c in #t51.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t52 = self::Extension|method(new self::Class::•()) in let final void #t53 = self::Extension|set#field(#t51, #t52) in #t52;
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t54 = c in #t54.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t54)));
+ self::throws(() → self::Class* => let final self::Class* #t55 = new self::Class::•() in let final void #t56 = self::Extension|set#field(let final self::Class* #t57 = c in #t57.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t57), #t55) in #t55);
+ self::throws(() → self::Class* => self::Extension|method(let final self::Class* #t58 = c in #t58.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t58)));
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|get#field(let final self::Class* #t59 = c in #t59.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t59))));
+ self::throws(() → self::Class* => let final self::Class* #t60 = new self::Class::•() in let final void #t61 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t62 = c in #t62.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t62)), #t60) in #t60);
+ self::throws(() → self::Class* => c = let final self::Class* #t63 = new self::Class::•() in let final void #t64 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t65 = c in #t65.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t65)), #t63) in #t63);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|get#field(let final self::Class* #t66 = c in #t66.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t66))));
+ let final self::Class* #t67 = c in #t67.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t67, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class* #t68 = c in #t68.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t69 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t70 = self::Extension|set#field(#t68, #t69) in #t69;
+ let final self::Class* #t71 = c in #t71.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t71, let final self::Class* #t72 = new self::Class::•() in let final void #t73 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t72) in #t72);
+ c = let final self::Class* #t74 = c in #t74.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t75 = let final self::Class* #t76 = new self::Class::•() in let final void #t77 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t76) in #t76 in let final void #t78 = self::Extension|set#field(#t74, #t75) in #t75;
+ let final self::Class* #t79 = c in #t79.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t79, self::Extension|method(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class* #t80 = c in #t80.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t81 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t82 = self::Extension|set#field(#t80, #t81) in #t81;
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|get#field(let final self::Class* #t83 = c in #t83.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t83))));
+ self::throws(() → self::Class* => let final self::Class* #t84 = new self::Class::•() in let final void #t85 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t86 = c in #t86.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t86)), #t84) in #t84);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|get#field(let final self::Class* #t87 = c in #t87.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t87))));
+ self::throws(() → self::Class* => let final self::Class* #t88 = self::Extension|get#field(new self::Class::•()) in let final void #t89 = self::Extension|set#field(let final self::Class* #t90 = c in #t90.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t90), #t88) in #t88);
+ self::throws(() → self::Class* => c = let final self::Class* #t91 = self::Extension|get#field(new self::Class::•()) in let final void #t92 = self::Extension|set#field(let final self::Class* #t93 = c in #t93.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t93), #t91) in #t91);
+ self::throws(() → self::Class* => let final self::Class* #t94 = let final self::Class* #t95 = new self::Class::•() in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t95) in #t95 in let final void #t97 = self::Extension|set#field(let final self::Class* #t98 = c in #t98.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t98), #t94) in #t94);
+ self::throws(() → self::Class* => c = let final self::Class* #t99 = let final self::Class* #t100 = new self::Class::•() in let final void #t101 = self::Extension|set#field(new self::Class::•(), #t100) in #t100 in let final void #t102 = self::Extension|set#field(let final self::Class* #t103 = c in #t103.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t103), #t99) in #t99);
+ self::throws(() → self::Class* => let final self::Class* #t104 = self::Extension|method(new self::Class::•()) in let final void #t105 = self::Extension|set#field(let final self::Class* #t106 = c in #t106.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t106), #t104) in #t104);
+ self::throws(() → self::Class* => c = let final self::Class* #t107 = self::Extension|method(new self::Class::•()) in let final void #t108 = self::Extension|set#field(let final self::Class* #t109 = c in #t109.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t109), #t107) in #t107);
+ let final self::Class* #t110 = c in #t110.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t110, let final self::Class* #t111 = self::Extension|get#field(new self::Class::•()) in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t111) in #t111);
+ c = let final self::Class* #t113 = c in #t113.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t114 = let final self::Class* #t115 = self::Extension|get#field(new self::Class::•()) in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115 in let final void #t117 = self::Extension|set#field(#t113, #t114) in #t114;
+ let final self::Class* #t118 = c in #t118.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t118, let final self::Class* #t119 = let final self::Class* #t120 = new self::Class::•() in let final void #t121 = self::Extension|set#field(new self::Class::•(), #t120) in #t120 in let final void #t122 = self::Extension|set#field(new self::Class::•(), #t119) in #t119);
+ c = let final self::Class* #t123 = c in #t123.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t124 = let final self::Class* #t125 = let final self::Class* #t126 = new self::Class::•() in let final void #t127 = self::Extension|set#field(new self::Class::•(), #t126) in #t126 in let final void #t128 = self::Extension|set#field(new self::Class::•(), #t125) in #t125 in let final void #t129 = self::Extension|set#field(#t123, #t124) in #t124;
+ let final self::Class* #t130 = c in #t130.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t130, let final self::Class* #t131 = self::Extension|method(new self::Class::•()) in let final void #t132 = self::Extension|set#field(new self::Class::•(), #t131) in #t131);
+ c = let final self::Class* #t133 = c in #t133.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t134 = let final self::Class* #t135 = self::Extension|method(new self::Class::•()) in let final void #t136 = self::Extension|set#field(new self::Class::•(), #t135) in #t135 in let final void #t137 = self::Extension|set#field(#t133, #t134) in #t134;
+ self::throws(() → self::Class* => let final self::Class* #t138 = self::Extension|get#field(new self::Class::•()) in let final void #t139 = self::Extension|set#field(let final self::Class* #t140 = c in #t140.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t140), #t138) in #t138);
+ self::throws(() → self::Class* => c = let final self::Class* #t141 = self::Extension|get#field(new self::Class::•()) in let final void #t142 = self::Extension|set#field(let final self::Class* #t143 = c in #t143.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t143), #t141) in #t141);
+ self::throws(() → self::Class* => let final self::Class* #t144 = let final self::Class* #t145 = new self::Class::•() in let final void #t146 = self::Extension|set#field(new self::Class::•(), #t145) in #t145 in let final void #t147 = self::Extension|set#field(let final self::Class* #t148 = c in #t148.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t148), #t144) in #t144);
+ self::throws(() → self::Class* => c = let final self::Class* #t149 = let final self::Class* #t150 = new self::Class::•() in let final void #t151 = self::Extension|set#field(new self::Class::•(), #t150) in #t150 in let final void #t152 = self::Extension|set#field(let final self::Class* #t153 = c in #t153.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t153), #t149) in #t149);
+ self::throws(() → self::Class* => let final self::Class* #t154 = self::Extension|method(new self::Class::•()) in let final void #t155 = self::Extension|set#field(let final self::Class* #t156 = c in #t156.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t156), #t154) in #t154);
+ self::throws(() → self::Class* => c = let final self::Class* #t157 = self::Extension|method(new self::Class::•()) in let final void #t158 = self::Extension|set#field(let final self::Class* #t159 = c in #t159.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t159), #t157) in #t157);
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|method(let final self::Class* #t160 = c in #t160.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t160))));
+ self::throws(() → self::Class* => let final self::Class* #t161 = new self::Class::•() in let final void #t162 = self::Extension|set#field(self::Extension|method(let final self::Class* #t163 = c in #t163.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t163)), #t161) in #t161);
+ self::throws(() → self::Class* => c = let final self::Class* #t164 = new self::Class::•() in let final void #t165 = self::Extension|set#field(self::Extension|method(let final self::Class* #t166 = c in #t166.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t166)), #t164) in #t164);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|method(let final self::Class* #t167 = c in #t167.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t167))));
+ let final self::Class* #t168 = c in #t168.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t168, self::Extension|get#field(self::Extension|method(new self::Class::•())));
+ c = let final self::Class* #t169 = c in #t169.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t170 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t171 = self::Extension|set#field(#t169, #t170) in #t170;
+ let final self::Class* #t172 = c in #t172.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t172, let final self::Class* #t173 = new self::Class::•() in let final void #t174 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t173) in #t173);
+ c = let final self::Class* #t175 = c in #t175.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t176 = let final self::Class* #t177 = new self::Class::•() in let final void #t178 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t177) in #t177 in let final void #t179 = self::Extension|set#field(#t175, #t176) in #t176;
+ let final self::Class* #t180 = c in #t180.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t180, self::Extension|method(self::Extension|method(new self::Class::•())));
+ c = let final self::Class* #t181 = c in #t181.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t182 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t183 = self::Extension|set#field(#t181, #t182) in #t182;
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|method(let final self::Class* #t184 = c in #t184.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t184))));
+ self::throws(() → self::Class* => let final self::Class* #t185 = new self::Class::•() in let final void #t186 = self::Extension|set#field(self::Extension|method(let final self::Class* #t187 = c in #t187.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t187)), #t185) in #t185);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|method(let final self::Class* #t188 = c in #t188.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t188))));
+ let final self::Class* #t189 = let final self::Class* #t190 = c in #t190.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t190) in #t189.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t189);
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t191 = c in #t191.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t191)));
+ let final self::Class* #t192 = let final self::Class* #t193 = c in #t193.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t193) in #t192.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t192);
+}
+static method indexAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => self::Extension|[](let final self::Class* #t194 = c in #t194.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t194), c));
+ self::throws(() → self::Class* => let final self::Class* #t195 = let final self::Class* #t196 = c in #t196.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t196) in let final self::Class* #t197 = c in let final self::Class* #t198 = new self::Class::•() in let final void #t199 = self::Extension|[]=(#t195, #t197, #t198) in #t198);
+ self::throws(() → self::Class* => c = let final self::Class* #t200 = let final self::Class* #t201 = c in #t201.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t201) in let final self::Class* #t202 = c in let final self::Class* #t203 = new self::Class::•() in let final void #t204 = self::Extension|[]=(#t200, #t202, #t203) in #t203);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|[](let final self::Class* #t205 = c in #t205.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t205), c)));
+ self::throws(() → self::Class* => let final self::Class* #t206 = let final self::Class* #t207 = c in #t207.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t207) in let final self::Class* #t208 = c in let final self::Class* #t209 = self::Extension|+(self::Extension|[](#t206, #t208), 0) in let final void #t210 = self::Extension|[]=(#t206, #t208, #t209) in #t209);
+ self::throws(() → self::Class* => c = let final self::Class* #t211 = let final self::Class* #t212 = c in #t212.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t212) in let final self::Class* #t213 = c in let final self::Class* #t214 = self::Extension|+(self::Extension|[](#t211, #t213), 0) in let final void #t215 = self::Extension|[]=(#t211, #t213, #t214) in #t214);
+ self::throws(() → self::Class* => let final self::Class* #t216 = let final self::Class* #t217 = c in #t217.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t217) in let final self::Class* #t218 = c in let final self::Class* #t219 = self::Extension|[](#t216, #t218) in let final void #t220 = self::Extension|[]=(#t216, #t218, self::Extension|+(#t219, 1)) in #t219);
+ self::throws(() → self::Class* => c = let final self::Class* #t221 = let final self::Class* #t222 = c in #t222.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t222) in let final self::Class* #t223 = c in let final self::Class* #t224 = self::Extension|[](#t221, #t223) in let final void #t225 = self::Extension|[]=(#t221, #t223, self::Extension|+(#t224, 1)) in #t224);
+ self::throws(() → self::Class* => let final self::Class* #t226 = let final self::Class* #t227 = c in #t227.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t227) in let final self::Class* #t228 = c in let final self::Class* #t229 = self::Extension|+(self::Extension|[](#t226, #t228), 1) in let final void #t230 = self::Extension|[]=(#t226, #t228, #t229) in #t229);
+ self::throws(() → self::Class* => c = let final self::Class* #t231 = let final self::Class* #t232 = c in #t232.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t232) in let final self::Class* #t233 = c in let final self::Class* #t234 = self::Extension|+(self::Extension|[](#t231, #t233), 1) in let final void #t235 = self::Extension|[]=(#t231, #t233, #t234) in #t234);
+ self::throws(() → self::Class* => self::Extension|[](self::Extension|[](let final self::Class* #t236 = c in #t236.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t236), c), c));
+ self::throws(() → self::Class* => let final self::Class* #t237 = self::Extension|[](let final self::Class* #t238 = c in #t238.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t238), c) in let final self::Class* #t239 = c in let final self::Class* #t240 = new self::Class::•() in let final void #t241 = self::Extension|[]=(#t237, #t239, #t240) in #t240);
+ self::throws(() → self::Class* => c = let final self::Class* #t242 = self::Extension|[](let final self::Class* #t243 = c in #t243.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t243), c) in let final self::Class* #t244 = c in let final self::Class* #t245 = new self::Class::•() in let final void #t246 = self::Extension|[]=(#t242, #t244, #t245) in #t245);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|[](self::Extension|[](let final self::Class* #t247 = c in #t247.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t247), c), c)));
+ self::throws(() → self::Class* => let final self::Class* #t248 = self::Extension|[](let final self::Class* #t249 = c in #t249.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t249), c) in let final self::Class* #t250 = c in let final self::Class* #t251 = self::Extension|+(self::Extension|[](#t248, #t250), 0) in let final void #t252 = self::Extension|[]=(#t248, #t250, #t251) in #t251);
+ self::throws(() → self::Class* => c = let final self::Class* #t253 = self::Extension|[](let final self::Class* #t254 = c in #t254.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t254), c) in let final self::Class* #t255 = c in let final self::Class* #t256 = self::Extension|+(self::Extension|[](#t253, #t255), 0) in let final void #t257 = self::Extension|[]=(#t253, #t255, #t256) in #t256);
+ self::throws(() → self::Class* => let final self::Class* #t258 = self::Extension|[](let final self::Class* #t259 = c in #t259.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t259), c) in let final self::Class* #t260 = c in let final self::Class* #t261 = self::Extension|[](#t258, #t260) in let final void #t262 = self::Extension|[]=(#t258, #t260, self::Extension|+(#t261, 1)) in #t261);
+ self::throws(() → self::Class* => c = let final self::Class* #t263 = self::Extension|[](let final self::Class* #t264 = c in #t264.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t264), c) in let final self::Class* #t265 = c in let final self::Class* #t266 = self::Extension|[](#t263, #t265) in let final void #t267 = self::Extension|[]=(#t263, #t265, self::Extension|+(#t266, 1)) in #t266);
+ self::throws(() → self::Class* => let final self::Class* #t268 = self::Extension|[](let final self::Class* #t269 = c in #t269.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t269), c) in let final self::Class* #t270 = c in let final self::Class* #t271 = self::Extension|+(self::Extension|[](#t268, #t270), 1) in let final void #t272 = self::Extension|[]=(#t268, #t270, #t271) in #t271);
+ self::throws(() → self::Class* => c = let final self::Class* #t273 = self::Extension|[](let final self::Class* #t274 = c in #t274.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t274), c) in let final self::Class* #t275 = c in let final self::Class* #t276 = self::Extension|+(self::Extension|[](#t273, #t275), 1) in let final void #t277 = self::Extension|[]=(#t273, #t275, #t276) in #t276);
+}
+static method operatorAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => self::Extension|+(let final self::Class* #t278 = c in #t278.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t278), 0));
+ self::throws(() → self::Class* => self::Extension|unary-(let final self::Class* #t279 = c in #t279.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t279)));
+ let final self::Class* #t280 = c in #t280.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t280, self::Extension|+(self::Extension|get#field(#t280), 0));
+ c = let final self::Class* #t281 = c in #t281.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t282 = self::Extension|+(self::Extension|get#field(#t281), 0) in let final void #t283 = self::Extension|set#field(#t281, #t282) in #t282;
+ self::throws(() → self::Class* => let final self::Class* #t284 = let final self::Class* #t285 = c in #t285.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t285) in let final self::Class* #t286 = self::Extension|+(self::Extension|get#field(#t284), 0) in let final void #t287 = self::Extension|set#field(#t284, #t286) in #t286);
+ self::throws(() → self::Class* => c = let final self::Class* #t288 = let final self::Class* #t289 = c in #t289.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t289) in let final self::Class* #t290 = self::Extension|+(self::Extension|get#field(#t288), 0) in let final void #t291 = self::Extension|set#field(#t288, #t290) in #t290);
+ let final self::Class* #t292 = c in #t292.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t292, self::Extension|+(self::Extension|get#field(#t292), 1));
+ c = let final self::Class* #t293 = c in #t293.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t294 = self::Extension|get#field(#t293) in let final self::Class* #t295 = let final self::Class* #t296 = self::Extension|+(#t294, 1) in let final void #t297 = self::Extension|set#field(#t293, #t296) in #t296 in #t294;
+ let final self::Class* #t298 = c in #t298.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t299 = self::Extension|+(self::Extension|get#field(#t298), 1) in let final void #t300 = self::Extension|set#field(#t298, #t299) in #t299;
+ c = let final self::Class* #t301 = c in #t301.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t302 = self::Extension|+(self::Extension|get#field(#t301), 1) in let final void #t303 = self::Extension|set#field(#t301, #t302) in #t302;
+}
+static method ifNull(self::Class* c) → void {
+ let final self::Class* #t304 = c in #t304.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t304).{core::Object::==}(null) ?{self::Class*} self::Extension|set#field(#t304, c) : null;
+ c = let final self::Class* #t305 = c in #t305.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t306 = self::Extension|get#field(#t305) in #t306.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t307 = c in let final void #t308 = self::Extension|set#field(#t305, #t307) in #t307 : #t306;
+ self::throws(() → self::Class* => let final self::Class* #t309 = let final self::Class* #t310 = c in #t310.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t310) in let final self::Class* #t311 = self::Extension|get#field(#t309) in #t311.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t312 = c in let final void #t313 = self::Extension|set#field(#t309, #t312) in #t312 : #t311);
+ self::throws(() → self::Class* => c = let final self::Class* #t314 = let final self::Class* #t315 = c in #t315.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t315) in let final self::Class* #t316 = self::Extension|get#field(#t314) in #t316.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t317 = c in let final void #t318 = self::Extension|set#field(#t314, #t317) in #t317 : #t316);
+ self::throws(() → self::Class* => let final self::Class* #t319 = let final self::Class* #t320 = c in #t320.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t320) in let final self::Class* #t321 = c in let final self::Class* #t322 = self::Extension|[](#t319, #t321) in #t322.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t323 = c in let final void #t324 = self::Extension|[]=(#t319, #t321, #t323) in #t323 : #t322);
+ self::throws(() → self::Class* => c = let final self::Class* #t325 = let final self::Class* #t326 = c in #t326.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t326) in let final self::Class* #t327 = c in let final self::Class* #t328 = self::Extension|[](#t325, #t327) in #t328.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t329 = c in let final void #t330 = self::Extension|[]=(#t325, #t327, #t329) in #t329 : #t328);
+}
+static method throws(() →* void f) → void {
+ try {
+ f.call();
+ }
+ on dynamic catch(final dynamic _) {
+ return;
+ }
+ throw "Expected exception.";
+}
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart.strong.transformed.expect
new file mode 100644
index 0000000..90b06d3
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting_explicit_extension.dart.strong.transformed.expect
@@ -0,0 +1,170 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class* _field = null;
+ synthetic constructor •() → self::Class*
+ : super core::Object::•()
+ ;
+}
+extension Extension on self::Class* {
+ get field = self::Extension|get#field;
+ method method = self::Extension|method;
+ tearoff method = self::Extension|get#method;
+ operator [] = self::Extension|[];
+ operator []= = self::Extension|[]=;
+ operator + = self::Extension|+;
+ operator unary- = self::Extension|unary-;
+ set field = self::Extension|set#field;
+}
+static method Extension|get#field(final self::Class* #this) → self::Class*
+ return #this.{self::Class::_field};
+static method Extension|set#field(final self::Class* #this, self::Class* value) → void {
+ #this.{self::Class::_field} = value;
+}
+static method Extension|method(final self::Class* #this) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|get#method(final self::Class* #this) → () →* self::Class*
+ return () → self::Class* => self::Extension|method(#this);
+static method Extension|[](final self::Class* #this, self::Class* key) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|[]=(final self::Class* #this, self::Class* key, self::Class* value) → void {
+ self::Extension|set#field(#this, value);
+}
+static method Extension|+(final self::Class* #this, core::int* value) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|unary-(final self::Class* #this) → self::Class*
+ return self::Extension|get#field(#this);
+static method main() → dynamic {
+ self::propertyAccess(null);
+ self::indexAccess(null);
+ self::operatorAccess(null);
+ self::ifNull(null);
+}
+static method propertyAccess(self::Class* c) → void {
+ let final self::Class* #t1 = c in #t1.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t1);
+ let final self::Class* #t2 = c in #t2.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t2, new self::Class::•());
+ c = let final self::Class* #t3 = c in #t3.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3, #t4) in #t4;
+ let final self::Class* #t6 = c in #t6.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t6);
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t7 = c in #t7.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t7)));
+ let final self::Class* #t8 = let final self::Class* #t9 = c in #t9.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t9) in #t8.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t8);
+ self::throws(() → self::Class* => let final self::Class* #t10 = self::Extension|get#field(let final self::Class* #t11 = c in #t11.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t11)) in #t10.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t10));
+ self::throws(() → self::Class* => let final self::Class* #t12 = new self::Class::•() in let final void #t13 = self::Extension|set#field(let final self::Class* #t14 = c in #t14.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t14), #t12) in #t12);
+ let final self::Class* #t15 = let final self::Class* #t16 = c in #t16.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t16) in #t15.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t15, new self::Class::•());
+ self::throws(() → self::Class* => let final self::Class* #t17 = self::Extension|get#field(let final self::Class* #t18 = c in #t18.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t18)) in #t17.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t19 = new self::Class::•() in let final void #t20 = self::Extension|set#field(#t17, #t19) in #t19);
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t21 = c in #t21.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t21)));
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t22 = c in #t22.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(#t22, #t23) in #t23));
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t25 = c in #t25.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t25)));
+ self::throws(() → self::Class* => c = let final self::Class* #t26 = new self::Class::•() in let final void #t27 = self::Extension|set#field(let final self::Class* #t28 = c in #t28.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t28), #t26) in #t26);
+ c = let final self::Class* #t29 = let final self::Class* #t30 = c in #t30.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t30) in #t29.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t31 = new self::Class::•() in let final void #t32 = self::Extension|set#field(#t29, #t31) in #t31;
+ self::throws(() → self::Class* => c = let final self::Class* #t33 = self::Extension|get#field(let final self::Class* #t34 = c in #t34.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t34)) in #t33.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t35 = new self::Class::•() in let final void #t36 = self::Extension|set#field(#t33, #t35) in #t35);
+ self::throws(() → self::Class* => self::Extension|method(let final self::Class* #t37 = c in #t37.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t37)));
+ let final self::Class* #t38 = c in #t38.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t38, self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class* #t39 = c in #t39.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t40 = self::Extension|get#field(new self::Class::•()) in let final void #t41 = self::Extension|set#field(#t39, #t40) in #t40;
+ let final self::Class* #t42 = c in #t42.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t42, let final self::Class* #t43 = new self::Class::•() in let final void #t44 = self::Extension|set#field(new self::Class::•(), #t43) in #t43);
+ c = let final self::Class* #t45 = c in #t45.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t46 = let final self::Class* #t47 = new self::Class::•() in let final void #t48 = self::Extension|set#field(new self::Class::•(), #t47) in #t47 in let final void #t49 = self::Extension|set#field(#t45, #t46) in #t46;
+ let final self::Class* #t50 = c in #t50.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t50, self::Extension|method(new self::Class::•()));
+ c = let final self::Class* #t51 = c in #t51.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t52 = self::Extension|method(new self::Class::•()) in let final void #t53 = self::Extension|set#field(#t51, #t52) in #t52;
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t54 = c in #t54.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t54)));
+ self::throws(() → self::Class* => let final self::Class* #t55 = new self::Class::•() in let final void #t56 = self::Extension|set#field(let final self::Class* #t57 = c in #t57.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t57), #t55) in #t55);
+ self::throws(() → self::Class* => self::Extension|method(let final self::Class* #t58 = c in #t58.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t58)));
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|get#field(let final self::Class* #t59 = c in #t59.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t59))));
+ self::throws(() → self::Class* => let final self::Class* #t60 = new self::Class::•() in let final void #t61 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t62 = c in #t62.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t62)), #t60) in #t60);
+ self::throws(() → self::Class* => c = let final self::Class* #t63 = new self::Class::•() in let final void #t64 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t65 = c in #t65.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t65)), #t63) in #t63);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|get#field(let final self::Class* #t66 = c in #t66.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t66))));
+ let final self::Class* #t67 = c in #t67.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t67, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class* #t68 = c in #t68.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t69 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t70 = self::Extension|set#field(#t68, #t69) in #t69;
+ let final self::Class* #t71 = c in #t71.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t71, let final self::Class* #t72 = new self::Class::•() in let final void #t73 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t72) in #t72);
+ c = let final self::Class* #t74 = c in #t74.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t75 = let final self::Class* #t76 = new self::Class::•() in let final void #t77 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t76) in #t76 in let final void #t78 = self::Extension|set#field(#t74, #t75) in #t75;
+ let final self::Class* #t79 = c in #t79.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t79, self::Extension|method(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class* #t80 = c in #t80.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t81 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t82 = self::Extension|set#field(#t80, #t81) in #t81;
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|get#field(let final self::Class* #t83 = c in #t83.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t83))));
+ self::throws(() → self::Class* => let final self::Class* #t84 = new self::Class::•() in let final void #t85 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t86 = c in #t86.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t86)), #t84) in #t84);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|get#field(let final self::Class* #t87 = c in #t87.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t87))));
+ self::throws(() → self::Class* => let final self::Class* #t88 = self::Extension|get#field(new self::Class::•()) in let final void #t89 = self::Extension|set#field(let final self::Class* #t90 = c in #t90.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t90), #t88) in #t88);
+ self::throws(() → self::Class* => c = let final self::Class* #t91 = self::Extension|get#field(new self::Class::•()) in let final void #t92 = self::Extension|set#field(let final self::Class* #t93 = c in #t93.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t93), #t91) in #t91);
+ self::throws(() → self::Class* => let final self::Class* #t94 = let final self::Class* #t95 = new self::Class::•() in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t95) in #t95 in let final void #t97 = self::Extension|set#field(let final self::Class* #t98 = c in #t98.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t98), #t94) in #t94);
+ self::throws(() → self::Class* => c = let final self::Class* #t99 = let final self::Class* #t100 = new self::Class::•() in let final void #t101 = self::Extension|set#field(new self::Class::•(), #t100) in #t100 in let final void #t102 = self::Extension|set#field(let final self::Class* #t103 = c in #t103.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t103), #t99) in #t99);
+ self::throws(() → self::Class* => let final self::Class* #t104 = self::Extension|method(new self::Class::•()) in let final void #t105 = self::Extension|set#field(let final self::Class* #t106 = c in #t106.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t106), #t104) in #t104);
+ self::throws(() → self::Class* => c = let final self::Class* #t107 = self::Extension|method(new self::Class::•()) in let final void #t108 = self::Extension|set#field(let final self::Class* #t109 = c in #t109.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t109), #t107) in #t107);
+ let final self::Class* #t110 = c in #t110.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t110, let final self::Class* #t111 = self::Extension|get#field(new self::Class::•()) in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t111) in #t111);
+ c = let final self::Class* #t113 = c in #t113.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t114 = let final self::Class* #t115 = self::Extension|get#field(new self::Class::•()) in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115 in let final void #t117 = self::Extension|set#field(#t113, #t114) in #t114;
+ let final self::Class* #t118 = c in #t118.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t118, let final self::Class* #t119 = let final self::Class* #t120 = new self::Class::•() in let final void #t121 = self::Extension|set#field(new self::Class::•(), #t120) in #t120 in let final void #t122 = self::Extension|set#field(new self::Class::•(), #t119) in #t119);
+ c = let final self::Class* #t123 = c in #t123.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t124 = let final self::Class* #t125 = let final self::Class* #t126 = new self::Class::•() in let final void #t127 = self::Extension|set#field(new self::Class::•(), #t126) in #t126 in let final void #t128 = self::Extension|set#field(new self::Class::•(), #t125) in #t125 in let final void #t129 = self::Extension|set#field(#t123, #t124) in #t124;
+ let final self::Class* #t130 = c in #t130.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t130, let final self::Class* #t131 = self::Extension|method(new self::Class::•()) in let final void #t132 = self::Extension|set#field(new self::Class::•(), #t131) in #t131);
+ c = let final self::Class* #t133 = c in #t133.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t134 = let final self::Class* #t135 = self::Extension|method(new self::Class::•()) in let final void #t136 = self::Extension|set#field(new self::Class::•(), #t135) in #t135 in let final void #t137 = self::Extension|set#field(#t133, #t134) in #t134;
+ self::throws(() → self::Class* => let final self::Class* #t138 = self::Extension|get#field(new self::Class::•()) in let final void #t139 = self::Extension|set#field(let final self::Class* #t140 = c in #t140.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t140), #t138) in #t138);
+ self::throws(() → self::Class* => c = let final self::Class* #t141 = self::Extension|get#field(new self::Class::•()) in let final void #t142 = self::Extension|set#field(let final self::Class* #t143 = c in #t143.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t143), #t141) in #t141);
+ self::throws(() → self::Class* => let final self::Class* #t144 = let final self::Class* #t145 = new self::Class::•() in let final void #t146 = self::Extension|set#field(new self::Class::•(), #t145) in #t145 in let final void #t147 = self::Extension|set#field(let final self::Class* #t148 = c in #t148.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t148), #t144) in #t144);
+ self::throws(() → self::Class* => c = let final self::Class* #t149 = let final self::Class* #t150 = new self::Class::•() in let final void #t151 = self::Extension|set#field(new self::Class::•(), #t150) in #t150 in let final void #t152 = self::Extension|set#field(let final self::Class* #t153 = c in #t153.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t153), #t149) in #t149);
+ self::throws(() → self::Class* => let final self::Class* #t154 = self::Extension|method(new self::Class::•()) in let final void #t155 = self::Extension|set#field(let final self::Class* #t156 = c in #t156.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t156), #t154) in #t154);
+ self::throws(() → self::Class* => c = let final self::Class* #t157 = self::Extension|method(new self::Class::•()) in let final void #t158 = self::Extension|set#field(let final self::Class* #t159 = c in #t159.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t159), #t157) in #t157);
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|method(let final self::Class* #t160 = c in #t160.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t160))));
+ self::throws(() → self::Class* => let final self::Class* #t161 = new self::Class::•() in let final void #t162 = self::Extension|set#field(self::Extension|method(let final self::Class* #t163 = c in #t163.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t163)), #t161) in #t161);
+ self::throws(() → self::Class* => c = let final self::Class* #t164 = new self::Class::•() in let final void #t165 = self::Extension|set#field(self::Extension|method(let final self::Class* #t166 = c in #t166.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t166)), #t164) in #t164);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|method(let final self::Class* #t167 = c in #t167.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t167))));
+ let final self::Class* #t168 = c in #t168.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t168, self::Extension|get#field(self::Extension|method(new self::Class::•())));
+ c = let final self::Class* #t169 = c in #t169.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t170 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t171 = self::Extension|set#field(#t169, #t170) in #t170;
+ let final self::Class* #t172 = c in #t172.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t172, let final self::Class* #t173 = new self::Class::•() in let final void #t174 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t173) in #t173);
+ c = let final self::Class* #t175 = c in #t175.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t176 = let final self::Class* #t177 = new self::Class::•() in let final void #t178 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t177) in #t177 in let final void #t179 = self::Extension|set#field(#t175, #t176) in #t176;
+ let final self::Class* #t180 = c in #t180.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t180, self::Extension|method(self::Extension|method(new self::Class::•())));
+ c = let final self::Class* #t181 = c in #t181.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t182 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t183 = self::Extension|set#field(#t181, #t182) in #t182;
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|method(let final self::Class* #t184 = c in #t184.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t184))));
+ self::throws(() → self::Class* => let final self::Class* #t185 = new self::Class::•() in let final void #t186 = self::Extension|set#field(self::Extension|method(let final self::Class* #t187 = c in #t187.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t187)), #t185) in #t185);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|method(let final self::Class* #t188 = c in #t188.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t188))));
+ let final self::Class* #t189 = let final self::Class* #t190 = c in #t190.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t190) in #t189.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t189);
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t191 = c in #t191.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t191)));
+ let final self::Class* #t192 = let final self::Class* #t193 = c in #t193.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t193) in #t192.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t192);
+}
+static method indexAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => self::Extension|[](let final self::Class* #t194 = c in #t194.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t194), c));
+ self::throws(() → self::Class* => let final self::Class* #t195 = let final self::Class* #t196 = c in #t196.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t196) in let final self::Class* #t197 = c in let final self::Class* #t198 = new self::Class::•() in let final void #t199 = self::Extension|[]=(#t195, #t197, #t198) in #t198);
+ self::throws(() → self::Class* => c = let final self::Class* #t200 = let final self::Class* #t201 = c in #t201.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t201) in let final self::Class* #t202 = c in let final self::Class* #t203 = new self::Class::•() in let final void #t204 = self::Extension|[]=(#t200, #t202, #t203) in #t203);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|[](let final self::Class* #t205 = c in #t205.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t205), c)));
+ self::throws(() → self::Class* => let final self::Class* #t206 = let final self::Class* #t207 = c in #t207.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t207) in let final self::Class* #t208 = c in let final self::Class* #t209 = self::Extension|+(self::Extension|[](#t206, #t208), 0) in let final void #t210 = self::Extension|[]=(#t206, #t208, #t209) in #t209);
+ self::throws(() → self::Class* => c = let final self::Class* #t211 = let final self::Class* #t212 = c in #t212.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t212) in let final self::Class* #t213 = c in let final self::Class* #t214 = self::Extension|+(self::Extension|[](#t211, #t213), 0) in let final void #t215 = self::Extension|[]=(#t211, #t213, #t214) in #t214);
+ self::throws(() → self::Class* => let final self::Class* #t216 = let final self::Class* #t217 = c in #t217.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t217) in let final self::Class* #t218 = c in let final self::Class* #t219 = self::Extension|[](#t216, #t218) in let final void #t220 = self::Extension|[]=(#t216, #t218, self::Extension|+(#t219, 1)) in #t219);
+ self::throws(() → self::Class* => c = let final self::Class* #t221 = let final self::Class* #t222 = c in #t222.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t222) in let final self::Class* #t223 = c in let final self::Class* #t224 = self::Extension|[](#t221, #t223) in let final void #t225 = self::Extension|[]=(#t221, #t223, self::Extension|+(#t224, 1)) in #t224);
+ self::throws(() → self::Class* => let final self::Class* #t226 = let final self::Class* #t227 = c in #t227.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t227) in let final self::Class* #t228 = c in let final self::Class* #t229 = self::Extension|+(self::Extension|[](#t226, #t228), 1) in let final void #t230 = self::Extension|[]=(#t226, #t228, #t229) in #t229);
+ self::throws(() → self::Class* => c = let final self::Class* #t231 = let final self::Class* #t232 = c in #t232.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t232) in let final self::Class* #t233 = c in let final self::Class* #t234 = self::Extension|+(self::Extension|[](#t231, #t233), 1) in let final void #t235 = self::Extension|[]=(#t231, #t233, #t234) in #t234);
+ self::throws(() → self::Class* => self::Extension|[](self::Extension|[](let final self::Class* #t236 = c in #t236.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t236), c), c));
+ self::throws(() → self::Class* => let final self::Class* #t237 = self::Extension|[](let final self::Class* #t238 = c in #t238.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t238), c) in let final self::Class* #t239 = c in let final self::Class* #t240 = new self::Class::•() in let final void #t241 = self::Extension|[]=(#t237, #t239, #t240) in #t240);
+ self::throws(() → self::Class* => c = let final self::Class* #t242 = self::Extension|[](let final self::Class* #t243 = c in #t243.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t243), c) in let final self::Class* #t244 = c in let final self::Class* #t245 = new self::Class::•() in let final void #t246 = self::Extension|[]=(#t242, #t244, #t245) in #t245);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|[](self::Extension|[](let final self::Class* #t247 = c in #t247.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t247), c), c)));
+ self::throws(() → self::Class* => let final self::Class* #t248 = self::Extension|[](let final self::Class* #t249 = c in #t249.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t249), c) in let final self::Class* #t250 = c in let final self::Class* #t251 = self::Extension|+(self::Extension|[](#t248, #t250), 0) in let final void #t252 = self::Extension|[]=(#t248, #t250, #t251) in #t251);
+ self::throws(() → self::Class* => c = let final self::Class* #t253 = self::Extension|[](let final self::Class* #t254 = c in #t254.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t254), c) in let final self::Class* #t255 = c in let final self::Class* #t256 = self::Extension|+(self::Extension|[](#t253, #t255), 0) in let final void #t257 = self::Extension|[]=(#t253, #t255, #t256) in #t256);
+ self::throws(() → self::Class* => let final self::Class* #t258 = self::Extension|[](let final self::Class* #t259 = c in #t259.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t259), c) in let final self::Class* #t260 = c in let final self::Class* #t261 = self::Extension|[](#t258, #t260) in let final void #t262 = self::Extension|[]=(#t258, #t260, self::Extension|+(#t261, 1)) in #t261);
+ self::throws(() → self::Class* => c = let final self::Class* #t263 = self::Extension|[](let final self::Class* #t264 = c in #t264.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t264), c) in let final self::Class* #t265 = c in let final self::Class* #t266 = self::Extension|[](#t263, #t265) in let final void #t267 = self::Extension|[]=(#t263, #t265, self::Extension|+(#t266, 1)) in #t266);
+ self::throws(() → self::Class* => let final self::Class* #t268 = self::Extension|[](let final self::Class* #t269 = c in #t269.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t269), c) in let final self::Class* #t270 = c in let final self::Class* #t271 = self::Extension|+(self::Extension|[](#t268, #t270), 1) in let final void #t272 = self::Extension|[]=(#t268, #t270, #t271) in #t271);
+ self::throws(() → self::Class* => c = let final self::Class* #t273 = self::Extension|[](let final self::Class* #t274 = c in #t274.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t274), c) in let final self::Class* #t275 = c in let final self::Class* #t276 = self::Extension|+(self::Extension|[](#t273, #t275), 1) in let final void #t277 = self::Extension|[]=(#t273, #t275, #t276) in #t276);
+}
+static method operatorAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => self::Extension|+(let final self::Class* #t278 = c in #t278.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t278), 0));
+ self::throws(() → self::Class* => self::Extension|unary-(let final self::Class* #t279 = c in #t279.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t279)));
+ let final self::Class* #t280 = c in #t280.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t280, self::Extension|+(self::Extension|get#field(#t280), 0));
+ c = let final self::Class* #t281 = c in #t281.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t282 = self::Extension|+(self::Extension|get#field(#t281), 0) in let final void #t283 = self::Extension|set#field(#t281, #t282) in #t282;
+ self::throws(() → self::Class* => let final self::Class* #t284 = let final self::Class* #t285 = c in #t285.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t285) in let final self::Class* #t286 = self::Extension|+(self::Extension|get#field(#t284), 0) in let final void #t287 = self::Extension|set#field(#t284, #t286) in #t286);
+ self::throws(() → self::Class* => c = let final self::Class* #t288 = let final self::Class* #t289 = c in #t289.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t289) in let final self::Class* #t290 = self::Extension|+(self::Extension|get#field(#t288), 0) in let final void #t291 = self::Extension|set#field(#t288, #t290) in #t290);
+ let final self::Class* #t292 = c in #t292.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t292, self::Extension|+(self::Extension|get#field(#t292), 1));
+ c = let final self::Class* #t293 = c in #t293.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t294 = self::Extension|get#field(#t293) in let final self::Class* #t295 = let final self::Class* #t296 = self::Extension|+(#t294, 1) in let final void #t297 = self::Extension|set#field(#t293, #t296) in #t296 in #t294;
+ let final self::Class* #t298 = c in #t298.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t299 = self::Extension|+(self::Extension|get#field(#t298), 1) in let final void #t300 = self::Extension|set#field(#t298, #t299) in #t299;
+ c = let final self::Class* #t301 = c in #t301.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t302 = self::Extension|+(self::Extension|get#field(#t301), 1) in let final void #t303 = self::Extension|set#field(#t301, #t302) in #t302;
+}
+static method ifNull(self::Class* c) → void {
+ let final self::Class* #t304 = c in #t304.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t304).{core::Object::==}(null) ?{self::Class*} self::Extension|set#field(#t304, c) : null;
+ c = let final self::Class* #t305 = c in #t305.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t306 = self::Extension|get#field(#t305) in #t306.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t307 = c in let final void #t308 = self::Extension|set#field(#t305, #t307) in #t307 : #t306;
+ self::throws(() → self::Class* => let final self::Class* #t309 = let final self::Class* #t310 = c in #t310.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t310) in let final self::Class* #t311 = self::Extension|get#field(#t309) in #t311.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t312 = c in let final void #t313 = self::Extension|set#field(#t309, #t312) in #t312 : #t311);
+ self::throws(() → self::Class* => c = let final self::Class* #t314 = let final self::Class* #t315 = c in #t315.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t315) in let final self::Class* #t316 = self::Extension|get#field(#t314) in #t316.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t317 = c in let final void #t318 = self::Extension|set#field(#t314, #t317) in #t317 : #t316);
+ self::throws(() → self::Class* => let final self::Class* #t319 = let final self::Class* #t320 = c in #t320.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t320) in let final self::Class* #t321 = c in let final self::Class* #t322 = self::Extension|[](#t319, #t321) in #t322.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t323 = c in let final void #t324 = self::Extension|[]=(#t319, #t321, #t323) in #t323 : #t322);
+ self::throws(() → self::Class* => c = let final self::Class* #t325 = let final self::Class* #t326 = c in #t326.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t326) in let final self::Class* #t327 = c in let final self::Class* #t328 = self::Extension|[](#t325, #t327) in #t328.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t329 = c in let final void #t330 = self::Extension|[]=(#t325, #t327, #t329) in #t329 : #t328);
+}
+static method throws(() →* void f) → void {
+ try {
+ f.call();
+ }
+ on dynamic catch(final dynamic _) {
+ return;
+ }
+ throw "Expected exception.";
+}
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart b/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart
new file mode 100644
index 0000000..b1a71c6
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart
@@ -0,0 +1,168 @@
+// Copyright (c) 2019, 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.
+
+// @dart=2.6
+
+class Class {
+ Class _field;
+}
+
+extension Extension on Class {
+ Class get field => _field;
+ void set field(Class value) {
+ _field = value;
+ }
+
+ Class method() => field;
+
+ Class operator [](Class key) => field;
+ void operator []=(Class key, Class value) {
+ field = value;
+ }
+
+ Class operator +(int value) => field;
+
+ Class operator -() => field;
+}
+
+main() {
+ propertyAccess(null);
+ indexAccess(null);
+ operatorAccess(null);
+ ifNull(null);
+}
+
+void propertyAccess(Class c) {
+ c?.field;
+ c?.field = new Class();
+ c = c?.field = new Class();
+ c?.method();
+
+ throws(() => c?.field.field);
+ c?.field?.field;
+ throws(() => c?.field.field?.field);
+ throws(() => c?.field.field = new Class());
+ c?.field?.field = new Class();
+ throws(() => c?.field.field?.field = new Class());
+ throws(() => (c?.field).field);
+ throws(() => (c?.field = new Class()).field);
+ throws(() => (c?.method()).field);
+ throws(() => c = c?.field.field = new Class());
+ c = c?.field?.field = new Class();
+ throws(() => c = c?.field.field?.field = new Class());
+ throws(() => c?.field.method());
+ c?.field = new Class().field;
+ c = c?.field = new Class().field;
+ c?.field = new Class().field = new Class();
+ c = c?.field = new Class().field = new Class();
+ c?.field = new Class().method();
+ c = c?.field = new Class().method();
+ throws(() => c?.method().field);
+ throws(() => c?.method().field = new Class());
+ throws(() => c?.method().method());
+
+ throws(() => c?.field.field.field);
+ throws(() => c?.field.field.field = new Class());
+ throws(() => c = c?.field.field.field = new Class());
+ throws(() => c?.field.field.method());
+ c?.field = new Class().field.field;
+ c = c?.field = new Class().field.field;
+ c?.field = new Class().field.field = new Class();
+ c = c?.field = new Class().field.field = new Class();
+ c?.field = new Class().field.method();
+ c = c?.field = new Class().field.method();
+ throws(() => c?.method().field.field);
+ throws(() => c?.method().field.field = new Class());
+ throws(() => c?.method().field.method());
+
+ throws(() => c?.field.field = new Class().field);
+ throws(() => c = c?.field.field = new Class().field);
+ throws(() => c?.field.field = new Class().field = new Class());
+ throws(() => c = c?.field.field = new Class().field = new Class());
+ throws(() => c?.field.field = new Class().method());
+ throws(() => c = c?.field.field = new Class().method());
+ c?.field = new Class().field = new Class().field;
+ c = c?.field = new Class().field = new Class().field;
+ c?.field = new Class().field = new Class().field = new Class();
+ c = c?.field = new Class().field = new Class().field = new Class();
+ c?.field = new Class().field = new Class().method();
+ c = c?.field = new Class().field = new Class().method();
+ throws(() => c?.method().field = new Class().field);
+ throws(() => c = c?.method().field = new Class().field);
+ throws(() => c?.method().field = new Class().field = new Class());
+ throws(() => c = c?.method().field = new Class().field = new Class());
+ throws(() => c?.method().field = new Class().method());
+ throws(() => c = c?.method().field = new Class().method());
+
+ throws(() => c?.field.method().field);
+ throws(() => c?.field.method().field = new Class());
+ throws(() => c = c?.field.method().field = new Class());
+ throws(() => c?.field.method().method());
+ c?.field = new Class().method().field;
+ c = c?.field = new Class().method().field;
+ c?.field = new Class().method().field = new Class();
+ c = c?.field = new Class().method().field = new Class();
+ c?.field = new Class().method().method();
+ c = c?.field = new Class().method().method();
+ throws(() => c?.method().method().field);
+ throws(() => c?.method().method().field = new Class());
+ throws(() => c?.method().method().method());
+
+ c?.method()?.method();
+}
+
+void indexAccess(Class c) {
+ throws(() => c?.field[c]);
+ throws(() => c?.field[c] = new Class());
+ throws(() => c = c?.field[c] = new Class());
+ throws(() => c?.field[c].method());
+ throws(() => c?.field[c] += 0);
+ throws(() => c = c?.field[c] += 0);
+ throws(() => c?.field[c]++);
+ throws(() => c = c?.field[c]++);
+ throws(() => ++c?.field[c]);
+ throws(() => c = ++c?.field[c]);
+
+ throws(() => c?.field[c][c]);
+ throws(() => c?.field[c][c] = new Class());
+ throws(() => c = c?.field[c][c] = new Class());
+ throws(() => c?.field[c][c].method());
+ throws(() => c?.field[c][c] += 0);
+ throws(() => c = c?.field[c][c] += 0);
+ throws(() => c?.field[c][c]++);
+ throws(() => c = c?.field[c][c]++);
+ throws(() => ++c?.field[c][c]);
+ throws(() => c = ++c?.field[c][c]);
+}
+
+void operatorAccess(Class c) {
+ throws(() => c?.field + 0);
+ throws(() => -c?.field);
+ c?.field += 0;
+ c = c?.field += 0;
+ throws(() => c?.field.field += 0);
+ throws(() => c = c?.field.field += 0);
+ c?.field++;
+ c = c?.field++;
+ ++c?.field;
+ c = ++c?.field;
+}
+
+void ifNull(Class c) {
+ c?.field ??= c;
+ c = c?.field ??= c;
+ throws(() => c?.field.field ??= c);
+ throws(() => c = c?.field.field ??= c);
+ throws(() => c?.field[c] ??= c);
+ throws(() => c = c?.field[c] ??= c);
+}
+
+void throws(void Function() f) {
+ try {
+ f();
+ } catch (_) {
+ return;
+ }
+ throw 'Expected exception.';
+}
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart.outline.expect b/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart.outline.expect
new file mode 100644
index 0000000..f7c609c
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart.outline.expect
@@ -0,0 +1,47 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class* _field;
+ synthetic constructor •() → self::Class*
+ ;
+}
+extension Extension on self::Class* {
+ get field = self::Extension|get#field;
+ method method = self::Extension|method;
+ tearoff method = self::Extension|get#method;
+ operator [] = self::Extension|[];
+ operator []= = self::Extension|[]=;
+ operator + = self::Extension|+;
+ operator unary- = self::Extension|unary-;
+ set field = self::Extension|set#field;
+}
+static method Extension|get#field(final self::Class* #this) → self::Class*
+ ;
+static method Extension|set#field(final self::Class* #this, self::Class* value) → void
+ ;
+static method Extension|method(final self::Class* #this) → self::Class*
+ ;
+static method Extension|get#method(final self::Class* #this) → () →* self::Class*
+ return () → self::Class* => self::Extension|method(#this);
+static method Extension|[](final self::Class* #this, self::Class* key) → self::Class*
+ ;
+static method Extension|[]=(final self::Class* #this, self::Class* key, self::Class* value) → void
+ ;
+static method Extension|+(final self::Class* #this, core::int* value) → self::Class*
+ ;
+static method Extension|unary-(final self::Class* #this) → self::Class*
+ ;
+static method main() → dynamic
+ ;
+static method propertyAccess(self::Class* c) → void
+ ;
+static method indexAccess(self::Class* c) → void
+ ;
+static method operatorAccess(self::Class* c) → void
+ ;
+static method ifNull(self::Class* c) → void
+ ;
+static method throws(() →* void f) → void
+ ;
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart.strong.expect b/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart.strong.expect
new file mode 100644
index 0000000..71b2eef
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart.strong.expect
@@ -0,0 +1,168 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class* _field = null;
+ synthetic constructor •() → self::Class*
+ : super core::Object::•()
+ ;
+}
+extension Extension on self::Class* {
+ get field = self::Extension|get#field;
+ method method = self::Extension|method;
+ tearoff method = self::Extension|get#method;
+ operator [] = self::Extension|[];
+ operator []= = self::Extension|[]=;
+ operator + = self::Extension|+;
+ operator unary- = self::Extension|unary-;
+ set field = self::Extension|set#field;
+}
+static method Extension|get#field(final self::Class* #this) → self::Class*
+ return #this.{self::Class::_field};
+static method Extension|set#field(final self::Class* #this, self::Class* value) → void {
+ #this.{self::Class::_field} = value;
+}
+static method Extension|method(final self::Class* #this) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|get#method(final self::Class* #this) → () →* self::Class*
+ return () → self::Class* => self::Extension|method(#this);
+static method Extension|[](final self::Class* #this, self::Class* key) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|[]=(final self::Class* #this, self::Class* key, self::Class* value) → void {
+ self::Extension|set#field(#this, value);
+}
+static method Extension|+(final self::Class* #this, core::int* value) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|unary-(final self::Class* #this) → self::Class*
+ return self::Extension|get#field(#this);
+static method main() → dynamic {
+ self::propertyAccess(null);
+ self::indexAccess(null);
+ self::operatorAccess(null);
+ self::ifNull(null);
+}
+static method propertyAccess(self::Class* c) → void {
+ let final self::Class* #t1 = c in #t1.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t1);
+ let final self::Class* #t2 = c in #t2.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t2, new self::Class::•());
+ c = let final self::Class* #t3 = c in #t3.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3, #t4) in #t4;
+ let final self::Class* #t6 = c in #t6.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t6);
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t7 = c in #t7.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t7)));
+ let final self::Class* #t8 = let final self::Class* #t9 = c in #t9.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t9) in #t8.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t8);
+ self::throws(() → self::Class* => let final self::Class* #t10 = self::Extension|get#field(let final self::Class* #t11 = c in #t11.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t11)) in #t10.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t10));
+ self::throws(() → self::Class* => let final self::Class* #t12 = new self::Class::•() in let final void #t13 = self::Extension|set#field(let final self::Class* #t14 = c in #t14.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t14), #t12) in #t12);
+ let final self::Class* #t15 = let final self::Class* #t16 = c in #t16.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t16) in #t15.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t15, new self::Class::•());
+ self::throws(() → self::Class* => let final self::Class* #t17 = self::Extension|get#field(let final self::Class* #t18 = c in #t18.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t18)) in #t17.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t19 = new self::Class::•() in let final void #t20 = self::Extension|set#field(#t17, #t19) in #t19);
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t21 = c in #t21.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t21)));
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t22 = c in #t22.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(#t22, #t23) in #t23));
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t25 = c in #t25.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t25)));
+ self::throws(() → self::Class* => c = let final self::Class* #t26 = new self::Class::•() in let final void #t27 = self::Extension|set#field(let final self::Class* #t28 = c in #t28.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t28), #t26) in #t26);
+ c = let final self::Class* #t29 = let final self::Class* #t30 = c in #t30.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t30) in #t29.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t31 = new self::Class::•() in let final void #t32 = self::Extension|set#field(#t29, #t31) in #t31;
+ self::throws(() → self::Class* => c = let final self::Class* #t33 = self::Extension|get#field(let final self::Class* #t34 = c in #t34.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t34)) in #t33.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t35 = new self::Class::•() in let final void #t36 = self::Extension|set#field(#t33, #t35) in #t35);
+ self::throws(() → self::Class* => self::Extension|method(let final self::Class* #t37 = c in #t37.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t37)));
+ let final self::Class* #t38 = c in #t38.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t38, self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class* #t39 = c in #t39.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t40 = self::Extension|get#field(new self::Class::•()) in let final void #t41 = self::Extension|set#field(#t39, #t40) in #t40;
+ let final self::Class* #t42 = c in #t42.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t42, let final self::Class* #t43 = new self::Class::•() in let final void #t44 = self::Extension|set#field(new self::Class::•(), #t43) in #t43);
+ c = let final self::Class* #t45 = c in #t45.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t46 = let final self::Class* #t47 = new self::Class::•() in let final void #t48 = self::Extension|set#field(new self::Class::•(), #t47) in #t47 in let final void #t49 = self::Extension|set#field(#t45, #t46) in #t46;
+ let final self::Class* #t50 = c in #t50.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t50, self::Extension|method(new self::Class::•()));
+ c = let final self::Class* #t51 = c in #t51.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t52 = self::Extension|method(new self::Class::•()) in let final void #t53 = self::Extension|set#field(#t51, #t52) in #t52;
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t54 = c in #t54.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t54)));
+ self::throws(() → self::Class* => let final self::Class* #t55 = new self::Class::•() in let final void #t56 = self::Extension|set#field(let final self::Class* #t57 = c in #t57.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t57), #t55) in #t55);
+ self::throws(() → self::Class* => self::Extension|method(let final self::Class* #t58 = c in #t58.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t58)));
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|get#field(let final self::Class* #t59 = c in #t59.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t59))));
+ self::throws(() → self::Class* => let final self::Class* #t60 = new self::Class::•() in let final void #t61 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t62 = c in #t62.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t62)), #t60) in #t60);
+ self::throws(() → self::Class* => c = let final self::Class* #t63 = new self::Class::•() in let final void #t64 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t65 = c in #t65.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t65)), #t63) in #t63);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|get#field(let final self::Class* #t66 = c in #t66.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t66))));
+ let final self::Class* #t67 = c in #t67.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t67, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class* #t68 = c in #t68.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t69 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t70 = self::Extension|set#field(#t68, #t69) in #t69;
+ let final self::Class* #t71 = c in #t71.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t71, let final self::Class* #t72 = new self::Class::•() in let final void #t73 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t72) in #t72);
+ c = let final self::Class* #t74 = c in #t74.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t75 = let final self::Class* #t76 = new self::Class::•() in let final void #t77 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t76) in #t76 in let final void #t78 = self::Extension|set#field(#t74, #t75) in #t75;
+ let final self::Class* #t79 = c in #t79.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t79, self::Extension|method(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class* #t80 = c in #t80.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t81 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t82 = self::Extension|set#field(#t80, #t81) in #t81;
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|get#field(let final self::Class* #t83 = c in #t83.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t83))));
+ self::throws(() → self::Class* => let final self::Class* #t84 = new self::Class::•() in let final void #t85 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t86 = c in #t86.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t86)), #t84) in #t84);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|get#field(let final self::Class* #t87 = c in #t87.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t87))));
+ self::throws(() → self::Class* => let final self::Class* #t88 = self::Extension|get#field(new self::Class::•()) in let final void #t89 = self::Extension|set#field(let final self::Class* #t90 = c in #t90.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t90), #t88) in #t88);
+ self::throws(() → self::Class* => c = let final self::Class* #t91 = self::Extension|get#field(new self::Class::•()) in let final void #t92 = self::Extension|set#field(let final self::Class* #t93 = c in #t93.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t93), #t91) in #t91);
+ self::throws(() → self::Class* => let final self::Class* #t94 = let final self::Class* #t95 = new self::Class::•() in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t95) in #t95 in let final void #t97 = self::Extension|set#field(let final self::Class* #t98 = c in #t98.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t98), #t94) in #t94);
+ self::throws(() → self::Class* => c = let final self::Class* #t99 = let final self::Class* #t100 = new self::Class::•() in let final void #t101 = self::Extension|set#field(new self::Class::•(), #t100) in #t100 in let final void #t102 = self::Extension|set#field(let final self::Class* #t103 = c in #t103.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t103), #t99) in #t99);
+ self::throws(() → self::Class* => let final self::Class* #t104 = self::Extension|method(new self::Class::•()) in let final void #t105 = self::Extension|set#field(let final self::Class* #t106 = c in #t106.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t106), #t104) in #t104);
+ self::throws(() → self::Class* => c = let final self::Class* #t107 = self::Extension|method(new self::Class::•()) in let final void #t108 = self::Extension|set#field(let final self::Class* #t109 = c in #t109.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t109), #t107) in #t107);
+ let final self::Class* #t110 = c in #t110.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t110, let final self::Class* #t111 = self::Extension|get#field(new self::Class::•()) in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t111) in #t111);
+ c = let final self::Class* #t113 = c in #t113.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t114 = let final self::Class* #t115 = self::Extension|get#field(new self::Class::•()) in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115 in let final void #t117 = self::Extension|set#field(#t113, #t114) in #t114;
+ let final self::Class* #t118 = c in #t118.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t118, let final self::Class* #t119 = let final self::Class* #t120 = new self::Class::•() in let final void #t121 = self::Extension|set#field(new self::Class::•(), #t120) in #t120 in let final void #t122 = self::Extension|set#field(new self::Class::•(), #t119) in #t119);
+ c = let final self::Class* #t123 = c in #t123.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t124 = let final self::Class* #t125 = let final self::Class* #t126 = new self::Class::•() in let final void #t127 = self::Extension|set#field(new self::Class::•(), #t126) in #t126 in let final void #t128 = self::Extension|set#field(new self::Class::•(), #t125) in #t125 in let final void #t129 = self::Extension|set#field(#t123, #t124) in #t124;
+ let final self::Class* #t130 = c in #t130.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t130, let final self::Class* #t131 = self::Extension|method(new self::Class::•()) in let final void #t132 = self::Extension|set#field(new self::Class::•(), #t131) in #t131);
+ c = let final self::Class* #t133 = c in #t133.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t134 = let final self::Class* #t135 = self::Extension|method(new self::Class::•()) in let final void #t136 = self::Extension|set#field(new self::Class::•(), #t135) in #t135 in let final void #t137 = self::Extension|set#field(#t133, #t134) in #t134;
+ self::throws(() → self::Class* => let final self::Class* #t138 = self::Extension|get#field(new self::Class::•()) in let final void #t139 = self::Extension|set#field(let final self::Class* #t140 = c in #t140.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t140), #t138) in #t138);
+ self::throws(() → self::Class* => c = let final self::Class* #t141 = self::Extension|get#field(new self::Class::•()) in let final void #t142 = self::Extension|set#field(let final self::Class* #t143 = c in #t143.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t143), #t141) in #t141);
+ self::throws(() → self::Class* => let final self::Class* #t144 = let final self::Class* #t145 = new self::Class::•() in let final void #t146 = self::Extension|set#field(new self::Class::•(), #t145) in #t145 in let final void #t147 = self::Extension|set#field(let final self::Class* #t148 = c in #t148.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t148), #t144) in #t144);
+ self::throws(() → self::Class* => c = let final self::Class* #t149 = let final self::Class* #t150 = new self::Class::•() in let final void #t151 = self::Extension|set#field(new self::Class::•(), #t150) in #t150 in let final void #t152 = self::Extension|set#field(let final self::Class* #t153 = c in #t153.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t153), #t149) in #t149);
+ self::throws(() → self::Class* => let final self::Class* #t154 = self::Extension|method(new self::Class::•()) in let final void #t155 = self::Extension|set#field(let final self::Class* #t156 = c in #t156.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t156), #t154) in #t154);
+ self::throws(() → self::Class* => c = let final self::Class* #t157 = self::Extension|method(new self::Class::•()) in let final void #t158 = self::Extension|set#field(let final self::Class* #t159 = c in #t159.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t159), #t157) in #t157);
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|method(let final self::Class* #t160 = c in #t160.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t160))));
+ self::throws(() → self::Class* => let final self::Class* #t161 = new self::Class::•() in let final void #t162 = self::Extension|set#field(self::Extension|method(let final self::Class* #t163 = c in #t163.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t163)), #t161) in #t161);
+ self::throws(() → self::Class* => c = let final self::Class* #t164 = new self::Class::•() in let final void #t165 = self::Extension|set#field(self::Extension|method(let final self::Class* #t166 = c in #t166.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t166)), #t164) in #t164);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|method(let final self::Class* #t167 = c in #t167.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t167))));
+ let final self::Class* #t168 = c in #t168.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t168, self::Extension|get#field(self::Extension|method(new self::Class::•())));
+ c = let final self::Class* #t169 = c in #t169.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t170 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t171 = self::Extension|set#field(#t169, #t170) in #t170;
+ let final self::Class* #t172 = c in #t172.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t172, let final self::Class* #t173 = new self::Class::•() in let final void #t174 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t173) in #t173);
+ c = let final self::Class* #t175 = c in #t175.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t176 = let final self::Class* #t177 = new self::Class::•() in let final void #t178 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t177) in #t177 in let final void #t179 = self::Extension|set#field(#t175, #t176) in #t176;
+ let final self::Class* #t180 = c in #t180.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t180, self::Extension|method(self::Extension|method(new self::Class::•())));
+ c = let final self::Class* #t181 = c in #t181.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t182 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t183 = self::Extension|set#field(#t181, #t182) in #t182;
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|method(let final self::Class* #t184 = c in #t184.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t184))));
+ self::throws(() → self::Class* => let final self::Class* #t185 = new self::Class::•() in let final void #t186 = self::Extension|set#field(self::Extension|method(let final self::Class* #t187 = c in #t187.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t187)), #t185) in #t185);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|method(let final self::Class* #t188 = c in #t188.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t188))));
+ let final self::Class* #t189 = let final self::Class* #t190 = c in #t190.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t190) in #t189.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t189);
+}
+static method indexAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => self::Extension|[](let final self::Class* #t191 = c in #t191.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t191), c));
+ self::throws(() → self::Class* => let final self::Class* #t192 = let final self::Class* #t193 = c in #t193.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t193) in let final self::Class* #t194 = c in let final self::Class* #t195 = new self::Class::•() in let final void #t196 = self::Extension|[]=(#t192, #t194, #t195) in #t195);
+ self::throws(() → self::Class* => c = let final self::Class* #t197 = let final self::Class* #t198 = c in #t198.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t198) in let final self::Class* #t199 = c in let final self::Class* #t200 = new self::Class::•() in let final void #t201 = self::Extension|[]=(#t197, #t199, #t200) in #t200);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|[](let final self::Class* #t202 = c in #t202.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t202), c)));
+ self::throws(() → self::Class* => let final self::Class* #t203 = let final self::Class* #t204 = c in #t204.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t204) in let final self::Class* #t205 = c in let final self::Class* #t206 = self::Extension|+(self::Extension|[](#t203, #t205), 0) in let final void #t207 = self::Extension|[]=(#t203, #t205, #t206) in #t206);
+ self::throws(() → self::Class* => c = let final self::Class* #t208 = let final self::Class* #t209 = c in #t209.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t209) in let final self::Class* #t210 = c in let final self::Class* #t211 = self::Extension|+(self::Extension|[](#t208, #t210), 0) in let final void #t212 = self::Extension|[]=(#t208, #t210, #t211) in #t211);
+ self::throws(() → self::Class* => let final self::Class* #t213 = let final self::Class* #t214 = c in #t214.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t214) in let final self::Class* #t215 = c in let final self::Class* #t216 = self::Extension|[](#t213, #t215) in let final void #t217 = self::Extension|[]=(#t213, #t215, self::Extension|+(#t216, 1)) in #t216);
+ self::throws(() → self::Class* => c = let final self::Class* #t218 = let final self::Class* #t219 = c in #t219.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t219) in let final self::Class* #t220 = c in let final self::Class* #t221 = self::Extension|[](#t218, #t220) in let final void #t222 = self::Extension|[]=(#t218, #t220, self::Extension|+(#t221, 1)) in #t221);
+ self::throws(() → self::Class* => let final self::Class* #t223 = let final self::Class* #t224 = c in #t224.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t224) in let final self::Class* #t225 = c in let final self::Class* #t226 = self::Extension|+(self::Extension|[](#t223, #t225), 1) in let final void #t227 = self::Extension|[]=(#t223, #t225, #t226) in #t226);
+ self::throws(() → self::Class* => c = let final self::Class* #t228 = let final self::Class* #t229 = c in #t229.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t229) in let final self::Class* #t230 = c in let final self::Class* #t231 = self::Extension|+(self::Extension|[](#t228, #t230), 1) in let final void #t232 = self::Extension|[]=(#t228, #t230, #t231) in #t231);
+ self::throws(() → self::Class* => self::Extension|[](self::Extension|[](let final self::Class* #t233 = c in #t233.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t233), c), c));
+ self::throws(() → self::Class* => let final self::Class* #t234 = self::Extension|[](let final self::Class* #t235 = c in #t235.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t235), c) in let final self::Class* #t236 = c in let final self::Class* #t237 = new self::Class::•() in let final void #t238 = self::Extension|[]=(#t234, #t236, #t237) in #t237);
+ self::throws(() → self::Class* => c = let final self::Class* #t239 = self::Extension|[](let final self::Class* #t240 = c in #t240.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t240), c) in let final self::Class* #t241 = c in let final self::Class* #t242 = new self::Class::•() in let final void #t243 = self::Extension|[]=(#t239, #t241, #t242) in #t242);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|[](self::Extension|[](let final self::Class* #t244 = c in #t244.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t244), c), c)));
+ self::throws(() → self::Class* => let final self::Class* #t245 = self::Extension|[](let final self::Class* #t246 = c in #t246.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t246), c) in let final self::Class* #t247 = c in let final self::Class* #t248 = self::Extension|+(self::Extension|[](#t245, #t247), 0) in let final void #t249 = self::Extension|[]=(#t245, #t247, #t248) in #t248);
+ self::throws(() → self::Class* => c = let final self::Class* #t250 = self::Extension|[](let final self::Class* #t251 = c in #t251.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t251), c) in let final self::Class* #t252 = c in let final self::Class* #t253 = self::Extension|+(self::Extension|[](#t250, #t252), 0) in let final void #t254 = self::Extension|[]=(#t250, #t252, #t253) in #t253);
+ self::throws(() → self::Class* => let final self::Class* #t255 = self::Extension|[](let final self::Class* #t256 = c in #t256.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t256), c) in let final self::Class* #t257 = c in let final self::Class* #t258 = self::Extension|[](#t255, #t257) in let final void #t259 = self::Extension|[]=(#t255, #t257, self::Extension|+(#t258, 1)) in #t258);
+ self::throws(() → self::Class* => c = let final self::Class* #t260 = self::Extension|[](let final self::Class* #t261 = c in #t261.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t261), c) in let final self::Class* #t262 = c in let final self::Class* #t263 = self::Extension|[](#t260, #t262) in let final void #t264 = self::Extension|[]=(#t260, #t262, self::Extension|+(#t263, 1)) in #t263);
+ self::throws(() → self::Class* => let final self::Class* #t265 = self::Extension|[](let final self::Class* #t266 = c in #t266.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t266), c) in let final self::Class* #t267 = c in let final self::Class* #t268 = self::Extension|+(self::Extension|[](#t265, #t267), 1) in let final void #t269 = self::Extension|[]=(#t265, #t267, #t268) in #t268);
+ self::throws(() → self::Class* => c = let final self::Class* #t270 = self::Extension|[](let final self::Class* #t271 = c in #t271.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t271), c) in let final self::Class* #t272 = c in let final self::Class* #t273 = self::Extension|+(self::Extension|[](#t270, #t272), 1) in let final void #t274 = self::Extension|[]=(#t270, #t272, #t273) in #t273);
+}
+static method operatorAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => self::Extension|+(let final self::Class* #t275 = c in #t275.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t275), 0));
+ self::throws(() → self::Class* => self::Extension|unary-(let final self::Class* #t276 = c in #t276.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t276)));
+ let final self::Class* #t277 = c in #t277.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t277, self::Extension|+(self::Extension|get#field(#t277), 0));
+ c = let final self::Class* #t278 = c in #t278.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t279 = self::Extension|+(self::Extension|get#field(#t278), 0) in let final void #t280 = self::Extension|set#field(#t278, #t279) in #t279;
+ self::throws(() → self::Class* => let final self::Class* #t281 = let final self::Class* #t282 = c in #t282.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t282) in let final self::Class* #t283 = self::Extension|+(self::Extension|get#field(#t281), 0) in let final void #t284 = self::Extension|set#field(#t281, #t283) in #t283);
+ self::throws(() → self::Class* => c = let final self::Class* #t285 = let final self::Class* #t286 = c in #t286.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t286) in let final self::Class* #t287 = self::Extension|+(self::Extension|get#field(#t285), 0) in let final void #t288 = self::Extension|set#field(#t285, #t287) in #t287);
+ let final self::Class* #t289 = c in #t289.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t289, self::Extension|+(self::Extension|get#field(#t289), 1));
+ c = let final self::Class* #t290 = c in #t290.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t291 = self::Extension|get#field(#t290) in let final void #t292 = self::Extension|set#field(#t290, self::Extension|+(#t291, 1)) in #t291;
+ let final self::Class* #t293 = c in #t293.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t294 = self::Extension|+(self::Extension|get#field(#t293), 1) in let final void #t295 = self::Extension|set#field(#t293, #t294) in #t294;
+ c = let final self::Class* #t296 = c in #t296.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t297 = self::Extension|+(self::Extension|get#field(#t296), 1) in let final void #t298 = self::Extension|set#field(#t296, #t297) in #t297;
+}
+static method ifNull(self::Class* c) → void {
+ let final self::Class* #t299 = c in #t299.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t299).{core::Object::==}(null) ?{self::Class*} self::Extension|set#field(#t299, c) : null;
+ c = let final self::Class* #t300 = c in #t300.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t301 = self::Extension|get#field(#t300) in #t301.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t302 = c in let final void #t303 = self::Extension|set#field(#t300, #t302) in #t302 : #t301;
+ self::throws(() → self::Class* => let final self::Class* #t304 = let final self::Class* #t305 = c in #t305.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t305) in let final self::Class* #t306 = self::Extension|get#field(#t304) in #t306.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t307 = c in let final void #t308 = self::Extension|set#field(#t304, #t307) in #t307 : #t306);
+ self::throws(() → self::Class* => c = let final self::Class* #t309 = let final self::Class* #t310 = c in #t310.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t310) in let final self::Class* #t311 = self::Extension|get#field(#t309) in #t311.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t312 = c in let final void #t313 = self::Extension|set#field(#t309, #t312) in #t312 : #t311);
+ self::throws(() → self::Class* => let final self::Class* #t314 = let final self::Class* #t315 = c in #t315.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t315) in let final self::Class* #t316 = c in let final self::Class* #t317 = self::Extension|[](#t314, #t316) in #t317.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t318 = c in let final void #t319 = self::Extension|[]=(#t314, #t316, #t318) in #t318 : #t317);
+ self::throws(() → self::Class* => c = let final self::Class* #t320 = let final self::Class* #t321 = c in #t321.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t321) in let final self::Class* #t322 = c in let final self::Class* #t323 = self::Extension|[](#t320, #t322) in #t323.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t324 = c in let final void #t325 = self::Extension|[]=(#t320, #t322, #t324) in #t324 : #t323);
+}
+static method throws(() →* void f) → void {
+ try {
+ f.call();
+ }
+ on dynamic catch(final dynamic _) {
+ return;
+ }
+ throw "Expected exception.";
+}
diff --git a/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart.strong.transformed.expect
new file mode 100644
index 0000000..71b2eef
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/no_null_shorting_extension.dart.strong.transformed.expect
@@ -0,0 +1,168 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class* _field = null;
+ synthetic constructor •() → self::Class*
+ : super core::Object::•()
+ ;
+}
+extension Extension on self::Class* {
+ get field = self::Extension|get#field;
+ method method = self::Extension|method;
+ tearoff method = self::Extension|get#method;
+ operator [] = self::Extension|[];
+ operator []= = self::Extension|[]=;
+ operator + = self::Extension|+;
+ operator unary- = self::Extension|unary-;
+ set field = self::Extension|set#field;
+}
+static method Extension|get#field(final self::Class* #this) → self::Class*
+ return #this.{self::Class::_field};
+static method Extension|set#field(final self::Class* #this, self::Class* value) → void {
+ #this.{self::Class::_field} = value;
+}
+static method Extension|method(final self::Class* #this) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|get#method(final self::Class* #this) → () →* self::Class*
+ return () → self::Class* => self::Extension|method(#this);
+static method Extension|[](final self::Class* #this, self::Class* key) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|[]=(final self::Class* #this, self::Class* key, self::Class* value) → void {
+ self::Extension|set#field(#this, value);
+}
+static method Extension|+(final self::Class* #this, core::int* value) → self::Class*
+ return self::Extension|get#field(#this);
+static method Extension|unary-(final self::Class* #this) → self::Class*
+ return self::Extension|get#field(#this);
+static method main() → dynamic {
+ self::propertyAccess(null);
+ self::indexAccess(null);
+ self::operatorAccess(null);
+ self::ifNull(null);
+}
+static method propertyAccess(self::Class* c) → void {
+ let final self::Class* #t1 = c in #t1.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t1);
+ let final self::Class* #t2 = c in #t2.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t2, new self::Class::•());
+ c = let final self::Class* #t3 = c in #t3.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3, #t4) in #t4;
+ let final self::Class* #t6 = c in #t6.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t6);
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t7 = c in #t7.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t7)));
+ let final self::Class* #t8 = let final self::Class* #t9 = c in #t9.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t9) in #t8.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t8);
+ self::throws(() → self::Class* => let final self::Class* #t10 = self::Extension|get#field(let final self::Class* #t11 = c in #t11.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t11)) in #t10.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t10));
+ self::throws(() → self::Class* => let final self::Class* #t12 = new self::Class::•() in let final void #t13 = self::Extension|set#field(let final self::Class* #t14 = c in #t14.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t14), #t12) in #t12);
+ let final self::Class* #t15 = let final self::Class* #t16 = c in #t16.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t16) in #t15.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t15, new self::Class::•());
+ self::throws(() → self::Class* => let final self::Class* #t17 = self::Extension|get#field(let final self::Class* #t18 = c in #t18.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t18)) in #t17.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t19 = new self::Class::•() in let final void #t20 = self::Extension|set#field(#t17, #t19) in #t19);
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t21 = c in #t21.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t21)));
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t22 = c in #t22.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(#t22, #t23) in #t23));
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t25 = c in #t25.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t25)));
+ self::throws(() → self::Class* => c = let final self::Class* #t26 = new self::Class::•() in let final void #t27 = self::Extension|set#field(let final self::Class* #t28 = c in #t28.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t28), #t26) in #t26);
+ c = let final self::Class* #t29 = let final self::Class* #t30 = c in #t30.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t30) in #t29.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t31 = new self::Class::•() in let final void #t32 = self::Extension|set#field(#t29, #t31) in #t31;
+ self::throws(() → self::Class* => c = let final self::Class* #t33 = self::Extension|get#field(let final self::Class* #t34 = c in #t34.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t34)) in #t33.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t35 = new self::Class::•() in let final void #t36 = self::Extension|set#field(#t33, #t35) in #t35);
+ self::throws(() → self::Class* => self::Extension|method(let final self::Class* #t37 = c in #t37.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t37)));
+ let final self::Class* #t38 = c in #t38.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t38, self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class* #t39 = c in #t39.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t40 = self::Extension|get#field(new self::Class::•()) in let final void #t41 = self::Extension|set#field(#t39, #t40) in #t40;
+ let final self::Class* #t42 = c in #t42.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t42, let final self::Class* #t43 = new self::Class::•() in let final void #t44 = self::Extension|set#field(new self::Class::•(), #t43) in #t43);
+ c = let final self::Class* #t45 = c in #t45.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t46 = let final self::Class* #t47 = new self::Class::•() in let final void #t48 = self::Extension|set#field(new self::Class::•(), #t47) in #t47 in let final void #t49 = self::Extension|set#field(#t45, #t46) in #t46;
+ let final self::Class* #t50 = c in #t50.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t50, self::Extension|method(new self::Class::•()));
+ c = let final self::Class* #t51 = c in #t51.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t52 = self::Extension|method(new self::Class::•()) in let final void #t53 = self::Extension|set#field(#t51, #t52) in #t52;
+ self::throws(() → self::Class* => self::Extension|get#field(let final self::Class* #t54 = c in #t54.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t54)));
+ self::throws(() → self::Class* => let final self::Class* #t55 = new self::Class::•() in let final void #t56 = self::Extension|set#field(let final self::Class* #t57 = c in #t57.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t57), #t55) in #t55);
+ self::throws(() → self::Class* => self::Extension|method(let final self::Class* #t58 = c in #t58.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t58)));
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|get#field(let final self::Class* #t59 = c in #t59.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t59))));
+ self::throws(() → self::Class* => let final self::Class* #t60 = new self::Class::•() in let final void #t61 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t62 = c in #t62.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t62)), #t60) in #t60);
+ self::throws(() → self::Class* => c = let final self::Class* #t63 = new self::Class::•() in let final void #t64 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t65 = c in #t65.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t65)), #t63) in #t63);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|get#field(let final self::Class* #t66 = c in #t66.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t66))));
+ let final self::Class* #t67 = c in #t67.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t67, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class* #t68 = c in #t68.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t69 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t70 = self::Extension|set#field(#t68, #t69) in #t69;
+ let final self::Class* #t71 = c in #t71.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t71, let final self::Class* #t72 = new self::Class::•() in let final void #t73 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t72) in #t72);
+ c = let final self::Class* #t74 = c in #t74.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t75 = let final self::Class* #t76 = new self::Class::•() in let final void #t77 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t76) in #t76 in let final void #t78 = self::Extension|set#field(#t74, #t75) in #t75;
+ let final self::Class* #t79 = c in #t79.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t79, self::Extension|method(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class* #t80 = c in #t80.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t81 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t82 = self::Extension|set#field(#t80, #t81) in #t81;
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|get#field(let final self::Class* #t83 = c in #t83.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t83))));
+ self::throws(() → self::Class* => let final self::Class* #t84 = new self::Class::•() in let final void #t85 = self::Extension|set#field(self::Extension|get#field(let final self::Class* #t86 = c in #t86.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t86)), #t84) in #t84);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|get#field(let final self::Class* #t87 = c in #t87.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t87))));
+ self::throws(() → self::Class* => let final self::Class* #t88 = self::Extension|get#field(new self::Class::•()) in let final void #t89 = self::Extension|set#field(let final self::Class* #t90 = c in #t90.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t90), #t88) in #t88);
+ self::throws(() → self::Class* => c = let final self::Class* #t91 = self::Extension|get#field(new self::Class::•()) in let final void #t92 = self::Extension|set#field(let final self::Class* #t93 = c in #t93.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t93), #t91) in #t91);
+ self::throws(() → self::Class* => let final self::Class* #t94 = let final self::Class* #t95 = new self::Class::•() in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t95) in #t95 in let final void #t97 = self::Extension|set#field(let final self::Class* #t98 = c in #t98.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t98), #t94) in #t94);
+ self::throws(() → self::Class* => c = let final self::Class* #t99 = let final self::Class* #t100 = new self::Class::•() in let final void #t101 = self::Extension|set#field(new self::Class::•(), #t100) in #t100 in let final void #t102 = self::Extension|set#field(let final self::Class* #t103 = c in #t103.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t103), #t99) in #t99);
+ self::throws(() → self::Class* => let final self::Class* #t104 = self::Extension|method(new self::Class::•()) in let final void #t105 = self::Extension|set#field(let final self::Class* #t106 = c in #t106.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t106), #t104) in #t104);
+ self::throws(() → self::Class* => c = let final self::Class* #t107 = self::Extension|method(new self::Class::•()) in let final void #t108 = self::Extension|set#field(let final self::Class* #t109 = c in #t109.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t109), #t107) in #t107);
+ let final self::Class* #t110 = c in #t110.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t110, let final self::Class* #t111 = self::Extension|get#field(new self::Class::•()) in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t111) in #t111);
+ c = let final self::Class* #t113 = c in #t113.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t114 = let final self::Class* #t115 = self::Extension|get#field(new self::Class::•()) in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115 in let final void #t117 = self::Extension|set#field(#t113, #t114) in #t114;
+ let final self::Class* #t118 = c in #t118.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t118, let final self::Class* #t119 = let final self::Class* #t120 = new self::Class::•() in let final void #t121 = self::Extension|set#field(new self::Class::•(), #t120) in #t120 in let final void #t122 = self::Extension|set#field(new self::Class::•(), #t119) in #t119);
+ c = let final self::Class* #t123 = c in #t123.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t124 = let final self::Class* #t125 = let final self::Class* #t126 = new self::Class::•() in let final void #t127 = self::Extension|set#field(new self::Class::•(), #t126) in #t126 in let final void #t128 = self::Extension|set#field(new self::Class::•(), #t125) in #t125 in let final void #t129 = self::Extension|set#field(#t123, #t124) in #t124;
+ let final self::Class* #t130 = c in #t130.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t130, let final self::Class* #t131 = self::Extension|method(new self::Class::•()) in let final void #t132 = self::Extension|set#field(new self::Class::•(), #t131) in #t131);
+ c = let final self::Class* #t133 = c in #t133.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t134 = let final self::Class* #t135 = self::Extension|method(new self::Class::•()) in let final void #t136 = self::Extension|set#field(new self::Class::•(), #t135) in #t135 in let final void #t137 = self::Extension|set#field(#t133, #t134) in #t134;
+ self::throws(() → self::Class* => let final self::Class* #t138 = self::Extension|get#field(new self::Class::•()) in let final void #t139 = self::Extension|set#field(let final self::Class* #t140 = c in #t140.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t140), #t138) in #t138);
+ self::throws(() → self::Class* => c = let final self::Class* #t141 = self::Extension|get#field(new self::Class::•()) in let final void #t142 = self::Extension|set#field(let final self::Class* #t143 = c in #t143.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t143), #t141) in #t141);
+ self::throws(() → self::Class* => let final self::Class* #t144 = let final self::Class* #t145 = new self::Class::•() in let final void #t146 = self::Extension|set#field(new self::Class::•(), #t145) in #t145 in let final void #t147 = self::Extension|set#field(let final self::Class* #t148 = c in #t148.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t148), #t144) in #t144);
+ self::throws(() → self::Class* => c = let final self::Class* #t149 = let final self::Class* #t150 = new self::Class::•() in let final void #t151 = self::Extension|set#field(new self::Class::•(), #t150) in #t150 in let final void #t152 = self::Extension|set#field(let final self::Class* #t153 = c in #t153.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t153), #t149) in #t149);
+ self::throws(() → self::Class* => let final self::Class* #t154 = self::Extension|method(new self::Class::•()) in let final void #t155 = self::Extension|set#field(let final self::Class* #t156 = c in #t156.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t156), #t154) in #t154);
+ self::throws(() → self::Class* => c = let final self::Class* #t157 = self::Extension|method(new self::Class::•()) in let final void #t158 = self::Extension|set#field(let final self::Class* #t159 = c in #t159.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t159), #t157) in #t157);
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|method(let final self::Class* #t160 = c in #t160.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t160))));
+ self::throws(() → self::Class* => let final self::Class* #t161 = new self::Class::•() in let final void #t162 = self::Extension|set#field(self::Extension|method(let final self::Class* #t163 = c in #t163.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t163)), #t161) in #t161);
+ self::throws(() → self::Class* => c = let final self::Class* #t164 = new self::Class::•() in let final void #t165 = self::Extension|set#field(self::Extension|method(let final self::Class* #t166 = c in #t166.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t166)), #t164) in #t164);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|method(let final self::Class* #t167 = c in #t167.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t167))));
+ let final self::Class* #t168 = c in #t168.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t168, self::Extension|get#field(self::Extension|method(new self::Class::•())));
+ c = let final self::Class* #t169 = c in #t169.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t170 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t171 = self::Extension|set#field(#t169, #t170) in #t170;
+ let final self::Class* #t172 = c in #t172.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t172, let final self::Class* #t173 = new self::Class::•() in let final void #t174 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t173) in #t173);
+ c = let final self::Class* #t175 = c in #t175.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t176 = let final self::Class* #t177 = new self::Class::•() in let final void #t178 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t177) in #t177 in let final void #t179 = self::Extension|set#field(#t175, #t176) in #t176;
+ let final self::Class* #t180 = c in #t180.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t180, self::Extension|method(self::Extension|method(new self::Class::•())));
+ c = let final self::Class* #t181 = c in #t181.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t182 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t183 = self::Extension|set#field(#t181, #t182) in #t182;
+ self::throws(() → self::Class* => self::Extension|get#field(self::Extension|method(let final self::Class* #t184 = c in #t184.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t184))));
+ self::throws(() → self::Class* => let final self::Class* #t185 = new self::Class::•() in let final void #t186 = self::Extension|set#field(self::Extension|method(let final self::Class* #t187 = c in #t187.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t187)), #t185) in #t185);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|method(let final self::Class* #t188 = c in #t188.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t188))));
+ let final self::Class* #t189 = let final self::Class* #t190 = c in #t190.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t190) in #t189.{core::Object::==}(null) ?{self::Class*} null : self::Extension|method(#t189);
+}
+static method indexAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => self::Extension|[](let final self::Class* #t191 = c in #t191.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t191), c));
+ self::throws(() → self::Class* => let final self::Class* #t192 = let final self::Class* #t193 = c in #t193.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t193) in let final self::Class* #t194 = c in let final self::Class* #t195 = new self::Class::•() in let final void #t196 = self::Extension|[]=(#t192, #t194, #t195) in #t195);
+ self::throws(() → self::Class* => c = let final self::Class* #t197 = let final self::Class* #t198 = c in #t198.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t198) in let final self::Class* #t199 = c in let final self::Class* #t200 = new self::Class::•() in let final void #t201 = self::Extension|[]=(#t197, #t199, #t200) in #t200);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|[](let final self::Class* #t202 = c in #t202.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t202), c)));
+ self::throws(() → self::Class* => let final self::Class* #t203 = let final self::Class* #t204 = c in #t204.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t204) in let final self::Class* #t205 = c in let final self::Class* #t206 = self::Extension|+(self::Extension|[](#t203, #t205), 0) in let final void #t207 = self::Extension|[]=(#t203, #t205, #t206) in #t206);
+ self::throws(() → self::Class* => c = let final self::Class* #t208 = let final self::Class* #t209 = c in #t209.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t209) in let final self::Class* #t210 = c in let final self::Class* #t211 = self::Extension|+(self::Extension|[](#t208, #t210), 0) in let final void #t212 = self::Extension|[]=(#t208, #t210, #t211) in #t211);
+ self::throws(() → self::Class* => let final self::Class* #t213 = let final self::Class* #t214 = c in #t214.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t214) in let final self::Class* #t215 = c in let final self::Class* #t216 = self::Extension|[](#t213, #t215) in let final void #t217 = self::Extension|[]=(#t213, #t215, self::Extension|+(#t216, 1)) in #t216);
+ self::throws(() → self::Class* => c = let final self::Class* #t218 = let final self::Class* #t219 = c in #t219.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t219) in let final self::Class* #t220 = c in let final self::Class* #t221 = self::Extension|[](#t218, #t220) in let final void #t222 = self::Extension|[]=(#t218, #t220, self::Extension|+(#t221, 1)) in #t221);
+ self::throws(() → self::Class* => let final self::Class* #t223 = let final self::Class* #t224 = c in #t224.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t224) in let final self::Class* #t225 = c in let final self::Class* #t226 = self::Extension|+(self::Extension|[](#t223, #t225), 1) in let final void #t227 = self::Extension|[]=(#t223, #t225, #t226) in #t226);
+ self::throws(() → self::Class* => c = let final self::Class* #t228 = let final self::Class* #t229 = c in #t229.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t229) in let final self::Class* #t230 = c in let final self::Class* #t231 = self::Extension|+(self::Extension|[](#t228, #t230), 1) in let final void #t232 = self::Extension|[]=(#t228, #t230, #t231) in #t231);
+ self::throws(() → self::Class* => self::Extension|[](self::Extension|[](let final self::Class* #t233 = c in #t233.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t233), c), c));
+ self::throws(() → self::Class* => let final self::Class* #t234 = self::Extension|[](let final self::Class* #t235 = c in #t235.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t235), c) in let final self::Class* #t236 = c in let final self::Class* #t237 = new self::Class::•() in let final void #t238 = self::Extension|[]=(#t234, #t236, #t237) in #t237);
+ self::throws(() → self::Class* => c = let final self::Class* #t239 = self::Extension|[](let final self::Class* #t240 = c in #t240.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t240), c) in let final self::Class* #t241 = c in let final self::Class* #t242 = new self::Class::•() in let final void #t243 = self::Extension|[]=(#t239, #t241, #t242) in #t242);
+ self::throws(() → self::Class* => self::Extension|method(self::Extension|[](self::Extension|[](let final self::Class* #t244 = c in #t244.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t244), c), c)));
+ self::throws(() → self::Class* => let final self::Class* #t245 = self::Extension|[](let final self::Class* #t246 = c in #t246.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t246), c) in let final self::Class* #t247 = c in let final self::Class* #t248 = self::Extension|+(self::Extension|[](#t245, #t247), 0) in let final void #t249 = self::Extension|[]=(#t245, #t247, #t248) in #t248);
+ self::throws(() → self::Class* => c = let final self::Class* #t250 = self::Extension|[](let final self::Class* #t251 = c in #t251.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t251), c) in let final self::Class* #t252 = c in let final self::Class* #t253 = self::Extension|+(self::Extension|[](#t250, #t252), 0) in let final void #t254 = self::Extension|[]=(#t250, #t252, #t253) in #t253);
+ self::throws(() → self::Class* => let final self::Class* #t255 = self::Extension|[](let final self::Class* #t256 = c in #t256.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t256), c) in let final self::Class* #t257 = c in let final self::Class* #t258 = self::Extension|[](#t255, #t257) in let final void #t259 = self::Extension|[]=(#t255, #t257, self::Extension|+(#t258, 1)) in #t258);
+ self::throws(() → self::Class* => c = let final self::Class* #t260 = self::Extension|[](let final self::Class* #t261 = c in #t261.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t261), c) in let final self::Class* #t262 = c in let final self::Class* #t263 = self::Extension|[](#t260, #t262) in let final void #t264 = self::Extension|[]=(#t260, #t262, self::Extension|+(#t263, 1)) in #t263);
+ self::throws(() → self::Class* => let final self::Class* #t265 = self::Extension|[](let final self::Class* #t266 = c in #t266.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t266), c) in let final self::Class* #t267 = c in let final self::Class* #t268 = self::Extension|+(self::Extension|[](#t265, #t267), 1) in let final void #t269 = self::Extension|[]=(#t265, #t267, #t268) in #t268);
+ self::throws(() → self::Class* => c = let final self::Class* #t270 = self::Extension|[](let final self::Class* #t271 = c in #t271.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t271), c) in let final self::Class* #t272 = c in let final self::Class* #t273 = self::Extension|+(self::Extension|[](#t270, #t272), 1) in let final void #t274 = self::Extension|[]=(#t270, #t272, #t273) in #t273);
+}
+static method operatorAccess(self::Class* c) → void {
+ self::throws(() → self::Class* => self::Extension|+(let final self::Class* #t275 = c in #t275.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t275), 0));
+ self::throws(() → self::Class* => self::Extension|unary-(let final self::Class* #t276 = c in #t276.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t276)));
+ let final self::Class* #t277 = c in #t277.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t277, self::Extension|+(self::Extension|get#field(#t277), 0));
+ c = let final self::Class* #t278 = c in #t278.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t279 = self::Extension|+(self::Extension|get#field(#t278), 0) in let final void #t280 = self::Extension|set#field(#t278, #t279) in #t279;
+ self::throws(() → self::Class* => let final self::Class* #t281 = let final self::Class* #t282 = c in #t282.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t282) in let final self::Class* #t283 = self::Extension|+(self::Extension|get#field(#t281), 0) in let final void #t284 = self::Extension|set#field(#t281, #t283) in #t283);
+ self::throws(() → self::Class* => c = let final self::Class* #t285 = let final self::Class* #t286 = c in #t286.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t286) in let final self::Class* #t287 = self::Extension|+(self::Extension|get#field(#t285), 0) in let final void #t288 = self::Extension|set#field(#t285, #t287) in #t287);
+ let final self::Class* #t289 = c in #t289.{core::Object::==}(null) ?{self::Class*} null : self::Extension|set#field(#t289, self::Extension|+(self::Extension|get#field(#t289), 1));
+ c = let final self::Class* #t290 = c in #t290.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t291 = self::Extension|get#field(#t290) in let final void #t292 = self::Extension|set#field(#t290, self::Extension|+(#t291, 1)) in #t291;
+ let final self::Class* #t293 = c in #t293.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t294 = self::Extension|+(self::Extension|get#field(#t293), 1) in let final void #t295 = self::Extension|set#field(#t293, #t294) in #t294;
+ c = let final self::Class* #t296 = c in #t296.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t297 = self::Extension|+(self::Extension|get#field(#t296), 1) in let final void #t298 = self::Extension|set#field(#t296, #t297) in #t297;
+}
+static method ifNull(self::Class* c) → void {
+ let final self::Class* #t299 = c in #t299.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t299).{core::Object::==}(null) ?{self::Class*} self::Extension|set#field(#t299, c) : null;
+ c = let final self::Class* #t300 = c in #t300.{core::Object::==}(null) ?{self::Class*} null : let final self::Class* #t301 = self::Extension|get#field(#t300) in #t301.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t302 = c in let final void #t303 = self::Extension|set#field(#t300, #t302) in #t302 : #t301;
+ self::throws(() → self::Class* => let final self::Class* #t304 = let final self::Class* #t305 = c in #t305.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t305) in let final self::Class* #t306 = self::Extension|get#field(#t304) in #t306.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t307 = c in let final void #t308 = self::Extension|set#field(#t304, #t307) in #t307 : #t306);
+ self::throws(() → self::Class* => c = let final self::Class* #t309 = let final self::Class* #t310 = c in #t310.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t310) in let final self::Class* #t311 = self::Extension|get#field(#t309) in #t311.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t312 = c in let final void #t313 = self::Extension|set#field(#t309, #t312) in #t312 : #t311);
+ self::throws(() → self::Class* => let final self::Class* #t314 = let final self::Class* #t315 = c in #t315.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t315) in let final self::Class* #t316 = c in let final self::Class* #t317 = self::Extension|[](#t314, #t316) in #t317.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t318 = c in let final void #t319 = self::Extension|[]=(#t314, #t316, #t318) in #t318 : #t317);
+ self::throws(() → self::Class* => c = let final self::Class* #t320 = let final self::Class* #t321 = c in #t321.{core::Object::==}(null) ?{self::Class*} null : self::Extension|get#field(#t321) in let final self::Class* #t322 = c in let final self::Class* #t323 = self::Extension|[](#t320, #t322) in #t323.{core::Object::==}(null) ?{self::Class*} let final self::Class* #t324 = c in let final void #t325 = self::Extension|[]=(#t320, #t322, #t324) in #t324 : #t323);
+}
+static method throws(() →* void f) → void {
+ try {
+ f.call();
+ }
+ on dynamic catch(final dynamic _) {
+ return;
+ }
+ throw "Expected exception.";
+}
diff --git a/pkg/front_end/testcases/nnbd/null_aware_chain.dart b/pkg/front_end/testcases/nnbd/null_aware_chain.dart
new file mode 100644
index 0000000..a53cacf
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/null_aware_chain.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2019, 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.
+
+class Class {
+ Class get getter1 => this;
+ Class? get getter2 => field;
+ Class? field;
+
+ Class([this.field]);
+}
+
+main() {
+ Class? c = new Class();
+ c?.getter1.getter2?.getter1.getter2?.field = c;
+}
diff --git a/pkg/front_end/testcases/nnbd/null_aware_chain.dart.outline.expect b/pkg/front_end/testcases/nnbd/null_aware_chain.dart.outline.expect
new file mode 100644
index 0000000..af3d1e9
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/null_aware_chain.dart.outline.expect
@@ -0,0 +1,15 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class? field;
+ constructor •([self::Class? field]) → self::Class
+ ;
+ get getter1() → self::Class
+ ;
+ get getter2() → self::Class?
+ ;
+}
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/nnbd/null_aware_chain.dart.strong.expect b/pkg/front_end/testcases/nnbd/null_aware_chain.dart.strong.expect
new file mode 100644
index 0000000..dbbbc73
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/null_aware_chain.dart.strong.expect
@@ -0,0 +1,22 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class? field;
+ constructor •([self::Class? field = #C1]) → self::Class
+ : self::Class::field = field, super core::Object::•()
+ ;
+ get getter1() → self::Class
+ return this;
+ get getter2() → self::Class?
+ return this.{self::Class::field};
+}
+static method main() → dynamic {
+ self::Class? c = new self::Class::•();
+ let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t2 = #t1{self::Class}.{self::Class::getter1}.{self::Class::getter2} in #t2.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t3 = #t2{self::Class}.{self::Class::getter1}.{self::Class::getter2} in #t3.{core::Object::==}(null) ?{self::Class} null : #t3{self::Class}.{self::Class::field} = c{self::Class};
+}
+
+constants {
+ #C1 = null
+}
diff --git a/pkg/front_end/testcases/nnbd/null_aware_chain.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/null_aware_chain.dart.strong.transformed.expect
new file mode 100644
index 0000000..dbbbc73
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/null_aware_chain.dart.strong.transformed.expect
@@ -0,0 +1,22 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field self::Class? field;
+ constructor •([self::Class? field = #C1]) → self::Class
+ : self::Class::field = field, super core::Object::•()
+ ;
+ get getter1() → self::Class
+ return this;
+ get getter2() → self::Class?
+ return this.{self::Class::field};
+}
+static method main() → dynamic {
+ self::Class? c = new self::Class::•();
+ let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t2 = #t1{self::Class}.{self::Class::getter1}.{self::Class::getter2} in #t2.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t3 = #t2{self::Class}.{self::Class::getter1}.{self::Class::getter2} in #t3.{core::Object::==}(null) ?{self::Class} null : #t3{self::Class}.{self::Class::field} = c{self::Class};
+}
+
+constants {
+ #C1 = null
+}
diff --git a/pkg/front_end/testcases/nnbd/null_check.dart.outline.expect b/pkg/front_end/testcases/nnbd/null_check.dart.outline.expect
index 5dd134e..aa7235a 100644
--- a/pkg/front_end/testcases/nnbd/null_check.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/null_check.dart.outline.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field core::int? field;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
method method() → core::int?
;
diff --git a/pkg/front_end/testcases/nnbd/null_check.dart.strong.expect b/pkg/front_end/testcases/nnbd/null_check.dart.strong.expect
index 8e7b90e..bffb6ce 100644
--- a/pkg/front_end/testcases/nnbd/null_check.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/null_check.dart.strong.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field core::int? field = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
method method() → core::int?
diff --git a/pkg/front_end/testcases/nnbd/null_check.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/null_check.dart.strong.transformed.expect
index 8e7b90e..bffb6ce 100644
--- a/pkg/front_end/testcases/nnbd/null_check.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/null_check.dart.strong.transformed.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field core::int? field = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
method method() → core::int?
diff --git a/pkg/front_end/testcases/nnbd/null_shorting.dart b/pkg/front_end/testcases/nnbd/null_shorting.dart
index edf2bda..999e7ba 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting.dart
+++ b/pkg/front_end/testcases/nnbd/null_shorting.dart
@@ -30,11 +30,17 @@
c?.method();
c?.field.field;
+ c?.field?.field;
+ c?.field.field?.field;
c?.field.field = new Class();
+ c?.field?.field = new Class();
+ c?.field.field?.field = new Class();
throws(() => (c?.field).field);
throws(() => (c?.field = new Class()).field);
throws(() => (c?.method()).field);
c = c?.field.field = new Class();
+ c = c?.field?.field = new Class();
+ c = c?.field.field?.field = new Class();
c?.field.method();
c?.field = new Class().field;
c = c?.field = new Class().field;
@@ -92,6 +98,8 @@
c?.method().method().field;
c?.method().method().field = new Class();
c?.method().method().method();
+
+ c?.method()?.method();
}
void indexAccess(Class? c) {
@@ -104,12 +112,51 @@
c?.field[c].method();
c?.field[c] += 0;
c = c?.field[c] += 0;
+ c?.[c] ??= c;
+ c = c?.[c] ??= c;
+ c?.[c] += 0;
+ c = c?.[c] += 0;
+ c?.[c] += 0;
+ c = c?.[c] += 0;
// TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
// update.
+ c?.[c]++;
+ c = c?.[c]++;
+ ++c?.[c];
+ c = ++c?.[c];
c?.field[c]++;
c = c?.field[c]++;
++c?.field[c];
c = ++c?.field[c];
+
+ c?.field[c][c];
+ c?.field[c][c] = new Class();
+ c = c?.field[c][c] = new Class();
+ c?.field[c][c].method();
+ c?.field[c][c] += 0;
+ c = c?.field[c][c] += 0;
+ // TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
+ // update.
+ c?.field[c][c]++;
+ c = c?.field[c][c]++;
+ ++c?.field[c][c];
+ c = ++c?.field[c][c];
+
+ c?.[c]?.[c];
+ c?.[c]?.[c] = new Class();
+ c = c?.[c]?.[c] = new Class();
+ c?.[c]?.[c].method();
+ c = c?.[c]?.[c].method();
+ c?.[c]?.[c] ??= c;
+ c = c?.[c]?.[c] ??= c;
+ c?.[c]?.[c] += 0;
+ c = c?.[c]?.[c] += 0;
+ // TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
+ // update.
+ c?.[c]?.[c]++;
+ c = c?.[c]?.[c]++;
+ ++c?.[c]?.[c];
+ c = ++c?.[c]?.[c];
}
void operatorAccess(Class? c) {
@@ -130,7 +177,10 @@
void ifNull(Class? c) {
c?.field ??= c;
c = c?.field ??= c;
+ c?.field.field ??= c;
+ c = c?.field.field ??= c;
c?.field[c] ??= c;
+ c = c?.field[c] ??= c;
}
void throws(void Function() f) {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting.dart.outline.expect b/pkg/front_end/testcases/nnbd/null_shorting.dart.outline.expect
index 4e95ca9d..c6e03e1 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting.dart.outline.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field self::Class? field;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
method method() → self::Class?
;
diff --git a/pkg/front_end/testcases/nnbd/null_shorting.dart.strong.expect b/pkg/front_end/testcases/nnbd/null_shorting.dart.strong.expect
index d50fc22..7ce23d4 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting.dart.strong.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field self::Class? field = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
method method() → self::Class?
@@ -26,102 +26,145 @@
self::ifNull(null);
}
static method propertyAccess(self::Class? c) → void {
- let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : #t1.{self::Class::field};
- let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : #t2.{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : #t3.{self::Class::field} = new self::Class::•();
- let final self::Class? #t4 = c in #t4.{core::Object::==}(null) ?{self::Class?} null : #t4.{self::Class::method}();
- let final self::Class? #t5 = c in #t5.{core::Object::==}(null) ?{self::Class?} null : #t5.{self::Class::field}.{self::Class::field};
- let final self::Class? #t6 = c in #t6.{core::Object::==}(null) ?{self::Class} null : #t6.{self::Class::field}.{self::Class::field} = new self::Class::•();
- self::throws(() → self::Class? => (let final self::Class? #t7 = c in #t7.{core::Object::==}(null) ?{self::Class?} null : #t7.{self::Class::field}).{self::Class::field});
- self::throws(() → self::Class? => (let final self::Class? #t8 = c in #t8.{core::Object::==}(null) ?{self::Class} null : #t8.{self::Class::field} = new self::Class::•()).{self::Class::field});
- self::throws(() → self::Class? => (let final self::Class? #t9 = c in #t9.{core::Object::==}(null) ?{self::Class?} null : #t9.{self::Class::method}()).{self::Class::field});
- c = let final self::Class? #t10 = c in #t10.{core::Object::==}(null) ?{self::Class} null : #t10.{self::Class::field}.{self::Class::field} = new self::Class::•();
- let final self::Class? #t11 = c in #t11.{core::Object::==}(null) ?{self::Class?} null : #t11.{self::Class::field}.{self::Class::method}();
- let final self::Class? #t12 = c in #t12.{core::Object::==}(null) ?{self::Class?} null : #t12.{self::Class::field} = new self::Class::•().{self::Class::field};
- c = let final self::Class? #t13 = c in #t13.{core::Object::==}(null) ?{self::Class?} null : #t13.{self::Class::field} = new self::Class::•().{self::Class::field};
- let final self::Class? #t14 = c in #t14.{core::Object::==}(null) ?{self::Class} null : #t14.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t15 = c in #t15.{core::Object::==}(null) ?{self::Class} null : #t15.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- let final self::Class? #t16 = c in #t16.{core::Object::==}(null) ?{self::Class?} null : #t16.{self::Class::field} = new self::Class::•().{self::Class::method}();
- c = let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : #t17.{self::Class::field} = new self::Class::•().{self::Class::method}();
- let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{self::Class?} null : #t18.{self::Class::method}().{self::Class::field};
- let final self::Class? #t19 = c in #t19.{core::Object::==}(null) ?{self::Class} null : #t19.{self::Class::method}().{self::Class::field} = new self::Class::•();
- let final self::Class? #t20 = c in #t20.{core::Object::==}(null) ?{self::Class?} null : #t20.{self::Class::method}().{self::Class::method}();
- let final self::Class? #t21 = c in #t21.{core::Object::==}(null) ?{self::Class?} null : #t21.{self::Class::field}.{self::Class::field}.{self::Class::field};
- let final self::Class? #t22 = c in #t22.{core::Object::==}(null) ?{self::Class} null : #t22.{self::Class::field}.{self::Class::field}.{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t23 = c in #t23.{core::Object::==}(null) ?{self::Class} null : #t23.{self::Class::field}.{self::Class::field}.{self::Class::field} = new self::Class::•();
- let final self::Class? #t24 = c in #t24.{core::Object::==}(null) ?{self::Class?} null : #t24.{self::Class::field}.{self::Class::field}.{self::Class::method}();
- let final self::Class? #t25 = c in #t25.{core::Object::==}(null) ?{self::Class?} null : #t25.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
- c = let final self::Class? #t26 = c in #t26.{core::Object::==}(null) ?{self::Class?} null : #t26.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
- let final self::Class? #t27 = c in #t27.{core::Object::==}(null) ?{self::Class} null : #t27.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t28 = c in #t28.{core::Object::==}(null) ?{self::Class} null : #t28.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
- let final self::Class? #t29 = c in #t29.{core::Object::==}(null) ?{self::Class?} null : #t29.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
- c = let final self::Class? #t30 = c in #t30.{core::Object::==}(null) ?{self::Class?} null : #t30.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
- let final self::Class? #t31 = c in #t31.{core::Object::==}(null) ?{self::Class?} null : #t31.{self::Class::method}().{self::Class::field}.{self::Class::field};
- let final self::Class? #t32 = c in #t32.{core::Object::==}(null) ?{self::Class} null : #t32.{self::Class::method}().{self::Class::field}.{self::Class::field} = new self::Class::•();
- let final self::Class? #t33 = c in #t33.{core::Object::==}(null) ?{self::Class?} null : #t33.{self::Class::method}().{self::Class::field}.{self::Class::method}();
- let final self::Class? #t34 = c in #t34.{core::Object::==}(null) ?{self::Class?} null : #t34.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field};
- c = let final self::Class? #t35 = c in #t35.{core::Object::==}(null) ?{self::Class?} null : #t35.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field};
- let final self::Class? #t36 = c in #t36.{core::Object::==}(null) ?{self::Class} null : #t36.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t37 = c in #t37.{core::Object::==}(null) ?{self::Class} null : #t37.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- let final self::Class? #t38 = c in #t38.{core::Object::==}(null) ?{self::Class?} null : #t38.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::method}();
- c = let final self::Class? #t39 = c in #t39.{core::Object::==}(null) ?{self::Class?} null : #t39.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::method}();
- let final self::Class? #t40 = c in #t40.{core::Object::==}(null) ?{self::Class?} null : #t40.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
- c = let final self::Class? #t41 = c in #t41.{core::Object::==}(null) ?{self::Class?} null : #t41.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
- let final self::Class? #t42 = c in #t42.{core::Object::==}(null) ?{self::Class} null : #t42.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t43 = c in #t43.{core::Object::==}(null) ?{self::Class} null : #t43.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- let final self::Class? #t44 = c in #t44.{core::Object::==}(null) ?{self::Class?} null : #t44.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
- c = let final self::Class? #t45 = c in #t45.{core::Object::==}(null) ?{self::Class?} null : #t45.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
- let final self::Class? #t46 = c in #t46.{core::Object::==}(null) ?{self::Class?} null : #t46.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field};
- c = let final self::Class? #t47 = c in #t47.{core::Object::==}(null) ?{self::Class?} null : #t47.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field};
- let final self::Class? #t48 = c in #t48.{core::Object::==}(null) ?{self::Class} null : #t48.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t49 = c in #t49.{core::Object::==}(null) ?{self::Class} null : #t49.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- let final self::Class? #t50 = c in #t50.{core::Object::==}(null) ?{self::Class?} null : #t50.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::method}();
- c = let final self::Class? #t51 = c in #t51.{core::Object::==}(null) ?{self::Class?} null : #t51.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::method}();
- let final self::Class? #t52 = c in #t52.{core::Object::==}(null) ?{self::Class?} null : #t52.{self::Class::field}.{self::Class::method}().{self::Class::field};
- let final self::Class? #t53 = c in #t53.{core::Object::==}(null) ?{self::Class} null : #t53.{self::Class::field}.{self::Class::method}().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t54 = c in #t54.{core::Object::==}(null) ?{self::Class} null : #t54.{self::Class::field}.{self::Class::method}().{self::Class::field} = new self::Class::•();
- let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class?} null : #t55.{self::Class::field}.{self::Class::method}().{self::Class::method}();
- let final self::Class? #t56 = c in #t56.{core::Object::==}(null) ?{self::Class?} null : #t56.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
- c = let final self::Class? #t57 = c in #t57.{core::Object::==}(null) ?{self::Class?} null : #t57.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
- let final self::Class? #t58 = c in #t58.{core::Object::==}(null) ?{self::Class} null : #t58.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t59 = c in #t59.{core::Object::==}(null) ?{self::Class} null : #t59.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
- let final self::Class? #t60 = c in #t60.{core::Object::==}(null) ?{self::Class?} null : #t60.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
- c = let final self::Class? #t61 = c in #t61.{core::Object::==}(null) ?{self::Class?} null : #t61.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
- let final self::Class? #t62 = c in #t62.{core::Object::==}(null) ?{self::Class?} null : #t62.{self::Class::method}().{self::Class::method}().{self::Class::field};
- let final self::Class? #t63 = c in #t63.{core::Object::==}(null) ?{self::Class} null : #t63.{self::Class::method}().{self::Class::method}().{self::Class::field} = new self::Class::•();
- let final self::Class? #t64 = c in #t64.{core::Object::==}(null) ?{self::Class?} null : #t64.{self::Class::method}().{self::Class::method}().{self::Class::method}();
+ let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : #t1{self::Class}.{self::Class::field};
+ let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : #t2{self::Class}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : #t3{self::Class}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t4 = c{self::Class} in #t4.{core::Object::==}(null) ?{self::Class?} null : #t4.{self::Class::method}();
+ let final self::Class #t5 = c{self::Class} in #t5.{core::Object::==}(null) ?{self::Class?} null : #t5.{self::Class::field}.{self::Class::field};
+ let final self::Class #t6 = c{self::Class} in #t6.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t7 = #t6.{self::Class::field} in #t7.{core::Object::==}(null) ?{self::Class?} null : #t7{self::Class}.{self::Class::field};
+ let final self::Class #t8 = c{self::Class} in #t8.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t9 = #t8.{self::Class::field}.{self::Class::field} in #t9.{core::Object::==}(null) ?{self::Class?} null : #t9{self::Class}.{self::Class::field};
+ let final self::Class #t10 = c{self::Class} in #t10.{core::Object::==}(null) ?{self::Class} null : #t10.{self::Class::field}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t11 = c{self::Class} in #t11.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t12 = #t11.{self::Class::field} in #t12.{core::Object::==}(null) ?{self::Class} null : #t12{self::Class}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t13 = c{self::Class} in #t13.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t14 = #t13.{self::Class::field}.{self::Class::field} in #t14.{core::Object::==}(null) ?{self::Class} null : #t14{self::Class}.{self::Class::field} = new self::Class::•();
+ self::throws(() → self::Class? => (let final self::Class? #t15 = c in #t15.{core::Object::==}(null) ?{self::Class?} null : #t15{self::Class}.{self::Class::field}).{self::Class::field});
+ self::throws(() → self::Class? => (let final self::Class? #t16 = c in #t16.{core::Object::==}(null) ?{self::Class} null : #t16{self::Class}.{self::Class::field} = new self::Class::•()).{self::Class::field});
+ self::throws(() → self::Class? => (let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : #t17{self::Class}.{self::Class::method}()).{self::Class::field});
+ c = let final self::Class #t18 = c{self::Class} in #t18.{core::Object::==}(null) ?{self::Class} null : #t18.{self::Class::field}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class #t19 = c{self::Class} in #t19.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t20 = #t19.{self::Class::field} in #t20.{core::Object::==}(null) ?{self::Class} null : #t20{self::Class}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class #t21 = c{self::Class} in #t21.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t22 = #t21.{self::Class::field}.{self::Class::field} in #t22.{core::Object::==}(null) ?{self::Class} null : #t22{self::Class}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t23 = c{self::Class} in #t23.{core::Object::==}(null) ?{self::Class?} null : #t23.{self::Class::field}.{self::Class::method}();
+ let final self::Class #t24 = c{self::Class} in #t24.{core::Object::==}(null) ?{self::Class?} null : #t24.{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class #t25 = c{self::Class} in #t25.{core::Object::==}(null) ?{self::Class?} null : #t25.{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class? #t26 = c in #t26.{core::Object::==}(null) ?{self::Class} null : #t26{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t27 = c in #t27.{core::Object::==}(null) ?{self::Class} null : #t27{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class #t28 = c{self::Class} in #t28.{core::Object::==}(null) ?{self::Class?} null : #t28.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class #t29 = c{self::Class} in #t29.{core::Object::==}(null) ?{self::Class?} null : #t29.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ let final self::Class? #t30 = c in #t30.{core::Object::==}(null) ?{self::Class?} null : #t30{self::Class}.{self::Class::method}().{self::Class::field};
+ let final self::Class? #t31 = c in #t31.{core::Object::==}(null) ?{self::Class} null : #t31{self::Class}.{self::Class::method}().{self::Class::field} = new self::Class::•();
+ let final self::Class? #t32 = c in #t32.{core::Object::==}(null) ?{self::Class?} null : #t32{self::Class}.{self::Class::method}().{self::Class::method}();
+ let final self::Class? #t33 = c in #t33.{core::Object::==}(null) ?{self::Class?} null : #t33{self::Class}.{self::Class::field}.{self::Class::field}.{self::Class::field};
+ let final self::Class? #t34 = c in #t34.{core::Object::==}(null) ?{self::Class} null : #t34{self::Class}.{self::Class::field}.{self::Class::field}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t35 = c in #t35.{core::Object::==}(null) ?{self::Class} null : #t35{self::Class}.{self::Class::field}.{self::Class::field}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t36 = c{self::Class} in #t36.{core::Object::==}(null) ?{self::Class?} null : #t36.{self::Class::field}.{self::Class::field}.{self::Class::method}();
+ let final self::Class #t37 = c{self::Class} in #t37.{core::Object::==}(null) ?{self::Class?} null : #t37.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
+ c = let final self::Class #t38 = c{self::Class} in #t38.{core::Object::==}(null) ?{self::Class?} null : #t38.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
+ let final self::Class? #t39 = c in #t39.{core::Object::==}(null) ?{self::Class} null : #t39{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t40 = c in #t40.{core::Object::==}(null) ?{self::Class} null : #t40{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t41 = c{self::Class} in #t41.{core::Object::==}(null) ?{self::Class?} null : #t41.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
+ c = let final self::Class #t42 = c{self::Class} in #t42.{core::Object::==}(null) ?{self::Class?} null : #t42.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
+ let final self::Class? #t43 = c in #t43.{core::Object::==}(null) ?{self::Class?} null : #t43{self::Class}.{self::Class::method}().{self::Class::field}.{self::Class::field};
+ let final self::Class? #t44 = c in #t44.{core::Object::==}(null) ?{self::Class} null : #t44{self::Class}.{self::Class::method}().{self::Class::field}.{self::Class::field} = new self::Class::•();
+ let final self::Class? #t45 = c in #t45.{core::Object::==}(null) ?{self::Class?} null : #t45{self::Class}.{self::Class::method}().{self::Class::field}.{self::Class::method}();
+ let final self::Class? #t46 = c in #t46.{core::Object::==}(null) ?{self::Class?} null : #t46{self::Class}.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class? #t47 = c in #t47.{core::Object::==}(null) ?{self::Class?} null : #t47{self::Class}.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class? #t48 = c in #t48.{core::Object::==}(null) ?{self::Class} null : #t48{self::Class}.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t49 = c in #t49.{core::Object::==}(null) ?{self::Class} null : #t49{self::Class}.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class #t50 = c{self::Class} in #t50.{core::Object::==}(null) ?{self::Class?} null : #t50.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class #t51 = c{self::Class} in #t51.{core::Object::==}(null) ?{self::Class?} null : #t51.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ let final self::Class? #t52 = c in #t52.{core::Object::==}(null) ?{self::Class?} null : #t52{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class? #t53 = c in #t53.{core::Object::==}(null) ?{self::Class?} null : #t53{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class? #t54 = c in #t54.{core::Object::==}(null) ?{self::Class} null : #t54{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class} null : #t55{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class #t56 = c{self::Class} in #t56.{core::Object::==}(null) ?{self::Class?} null : #t56.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class #t57 = c{self::Class} in #t57.{core::Object::==}(null) ?{self::Class?} null : #t57.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ let final self::Class? #t58 = c in #t58.{core::Object::==}(null) ?{self::Class?} null : #t58{self::Class}.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class? #t59 = c in #t59.{core::Object::==}(null) ?{self::Class?} null : #t59{self::Class}.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class? #t60 = c in #t60.{core::Object::==}(null) ?{self::Class} null : #t60{self::Class}.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t61 = c in #t61.{core::Object::==}(null) ?{self::Class} null : #t61{self::Class}.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class #t62 = c{self::Class} in #t62.{core::Object::==}(null) ?{self::Class?} null : #t62.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class #t63 = c{self::Class} in #t63.{core::Object::==}(null) ?{self::Class?} null : #t63.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ let final self::Class? #t64 = c in #t64.{core::Object::==}(null) ?{self::Class?} null : #t64{self::Class}.{self::Class::field}.{self::Class::method}().{self::Class::field};
+ let final self::Class? #t65 = c in #t65.{core::Object::==}(null) ?{self::Class} null : #t65{self::Class}.{self::Class::field}.{self::Class::method}().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : #t66{self::Class}.{self::Class::field}.{self::Class::method}().{self::Class::field} = new self::Class::•();
+ let final self::Class #t67 = c{self::Class} in #t67.{core::Object::==}(null) ?{self::Class?} null : #t67.{self::Class::field}.{self::Class::method}().{self::Class::method}();
+ let final self::Class #t68 = c{self::Class} in #t68.{core::Object::==}(null) ?{self::Class?} null : #t68.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
+ c = let final self::Class #t69 = c{self::Class} in #t69.{core::Object::==}(null) ?{self::Class?} null : #t69.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
+ let final self::Class? #t70 = c in #t70.{core::Object::==}(null) ?{self::Class} null : #t70{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t71 = c in #t71.{core::Object::==}(null) ?{self::Class} null : #t71{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
+ let final self::Class #t72 = c{self::Class} in #t72.{core::Object::==}(null) ?{self::Class?} null : #t72.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
+ c = let final self::Class #t73 = c{self::Class} in #t73.{core::Object::==}(null) ?{self::Class?} null : #t73.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
+ let final self::Class? #t74 = c in #t74.{core::Object::==}(null) ?{self::Class?} null : #t74{self::Class}.{self::Class::method}().{self::Class::method}().{self::Class::field};
+ let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class} null : #t75{self::Class}.{self::Class::method}().{self::Class::method}().{self::Class::field} = new self::Class::•();
+ let final self::Class? #t76 = c in #t76.{core::Object::==}(null) ?{self::Class?} null : #t76{self::Class}.{self::Class::method}().{self::Class::method}().{self::Class::method}();
+ let final self::Class? #t77 = c in #t77.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t78 = #t77{self::Class}.{self::Class::method}() in #t78.{core::Object::==}(null) ?{self::Class?} null : #t78{self::Class}.{self::Class::method}();
}
static method indexAccess(self::Class? c) → void {
- let final self::Class? #t65 = c in #t65.{core::Object::==}(null) ?{self::Class?} null : #t65.{self::Class::[]}(c);
- let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : #t66.{self::Class::[]=}(c, new self::Class::•());
- let final self::Class? #t67 = c in #t67.{core::Object::==}(null) ?{self::Class?} null : #t67.{self::Class::[]}(c).{self::Class::method}();
- let final self::Class? #t68 = c in #t68.{core::Object::==}(null) ?{self::Class?} null : #t68.{self::Class::field}.{self::Class::[]}(c);
- let final self::Class? #t69 = c in #t69.{core::Object::==}(null) ?{self::Class} null : #t69.{self::Class::field}.{self::Class::[]=}(c, new self::Class::•());
- c = let final self::Class? #t70 = c in #t70.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t71 = #t70.{self::Class::field} in let final self::Class? #t72 = c in let final self::Class #t73 = new self::Class::•() in let final void #t74 = #t71.{self::Class::[]=}(#t72, #t73) in #t73;
- let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class?} null : #t75.{self::Class::field}.{self::Class::[]}(c).{self::Class::method}();
- let final self::Class? #t76 = c in #t76.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t77 = #t76.{self::Class::field} in let final self::Class? #t78 = c in #t77.{self::Class::[]=}(#t78, #t77.{self::Class::[]}(#t78).{self::Class::+}(0));
- c = let final self::Class? #t79 = c in #t79.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t80 = #t79.{self::Class::field} in let final self::Class? #t81 = c in let final self::Class? #t82 = #t80.{self::Class::[]}(#t81).{self::Class::+}(0) in let final void #t83 = #t80.{self::Class::[]=}(#t81, #t82) in #t82;
- let final self::Class? #t84 = c in #t84.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t85 = #t84.{self::Class::field} in let final self::Class? #t86 = c in #t85.{self::Class::[]=}(#t86, #t85.{self::Class::[]}(#t86).{self::Class::+}(1));
- c = let final self::Class? #t87 = c in #t87.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t88 = #t87.{self::Class::field} in let final self::Class? #t89 = c in let final self::Class? #t90 = #t88.{self::Class::[]}(#t89) in let final void #t91 = #t88.{self::Class::[]=}(#t89, #t90.{self::Class::+}(1)) in #t90;
- let final self::Class? #t92 = c in #t92.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t93 = #t92.{self::Class::field} in let final self::Class? #t94 = c in let final self::Class? #t95 = #t93.{self::Class::[]}(#t94).{self::Class::+}(1) in let final void #t96 = #t93.{self::Class::[]=}(#t94, #t95) in #t95;
- c = let final self::Class? #t97 = c in #t97.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t98 = #t97.{self::Class::field} in let final self::Class? #t99 = c in let final self::Class? #t100 = #t98.{self::Class::[]}(#t99).{self::Class::+}(1) in let final void #t101 = #t98.{self::Class::[]=}(#t99, #t100) in #t100;
+ let final self::Class? #t79 = c in #t79.{core::Object::==}(null) ?{self::Class?} null : #t79{self::Class}.{self::Class::[]}(c{self::Class});
+ let final self::Class? #t80 = c in #t80.{core::Object::==}(null) ?{self::Class} null : #t80{self::Class}.{self::Class::[]=}(c{self::Class}, new self::Class::•());
+ let final self::Class? #t81 = c in #t81.{core::Object::==}(null) ?{self::Class?} null : #t81{self::Class}.{self::Class::[]}(c{self::Class}).{self::Class::method}();
+ let final self::Class? #t82 = c in #t82.{core::Object::==}(null) ?{self::Class?} null : #t82{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class});
+ let final self::Class? #t83 = c in #t83.{core::Object::==}(null) ?{self::Class} null : #t83{self::Class}.{self::Class::field}.{self::Class::[]=}(c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t84 = c in #t84.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t85 = #t84{self::Class}.{self::Class::field} in let final self::Class #t86 = c{self::Class} in let final self::Class #t87 = new self::Class::•() in let final void #t88 = #t85.{self::Class::[]=}(#t86, #t87) in #t87;
+ let final self::Class #t89 = c{self::Class} in #t89.{core::Object::==}(null) ?{self::Class?} null : #t89.{self::Class::field}.{self::Class::[]}(c{self::Class}).{self::Class::method}();
+ let final self::Class #t90 = c{self::Class} in #t90.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t91 = #t90.{self::Class::field} in let final self::Class #t92 = c{self::Class} in #t91.{self::Class::[]=}(#t92, #t91.{self::Class::[]}(#t92).{self::Class::+}(0));
+ c = let final self::Class #t93 = c{self::Class} in #t93.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t94 = #t93.{self::Class::field} in let final self::Class #t95 = c{self::Class} in let final self::Class? #t96 = #t94.{self::Class::[]}(#t95).{self::Class::+}(0) in let final void #t97 = #t94.{self::Class::[]=}(#t95, #t96) in #t96;
+ let final self::Class? #t98 = c in #t98.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t99 = c{self::Class} in #t98{self::Class}.{self::Class::[]}(#t99).{core::Object::==}(null) ?{self::Class} #t98{self::Class}.{self::Class::[]=}(#t99, c{self::Class}) : null;
+ c = let final self::Class? #t100 = c in #t100.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t101 = c{self::Class} in let final self::Class? #t102 = #t100{self::Class}.{self::Class::[]}(#t101) in #t102.{core::Object::==}(null) ?{self::Class} let final self::Class #t103 = c{self::Class} in let final void #t104 = #t100{self::Class}.{self::Class::[]=}(#t101, #t103) in #t103 : #t102;
+ let final self::Class #t105 = c{self::Class} in #t105.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t106 = c{self::Class} in #t105.{self::Class::[]=}(#t106, #t105.{self::Class::[]}(#t106).{self::Class::+}(0));
+ c = let final self::Class #t107 = c{self::Class} in #t107.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t108 = c{self::Class} in let final self::Class? #t109 = #t107.{self::Class::[]}(#t108).{self::Class::+}(0) in let final void #t110 = #t107.{self::Class::[]=}(#t108, #t109) in #t109;
+ let final self::Class? #t111 = c in #t111.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t112 = c{self::Class} in #t111{self::Class}.{self::Class::[]=}(#t112, #t111{self::Class}.{self::Class::[]}(#t112).{self::Class::+}(0));
+ c = let final self::Class? #t113 = c in #t113.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t114 = c{self::Class} in let final self::Class? #t115 = #t113{self::Class}.{self::Class::[]}(#t114).{self::Class::+}(0) in let final void #t116 = #t113{self::Class}.{self::Class::[]=}(#t114, #t115) in #t115;
+ let final self::Class? #t117 = c in #t117.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t118 = c{self::Class} in #t117{self::Class}.{self::Class::[]=}(#t118, #t117{self::Class}.{self::Class::[]}(#t118).{self::Class::+}(1));
+ c = let final self::Class? #t119 = c in #t119.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t120 = c{self::Class} in let final self::Class? #t121 = #t119{self::Class}.{self::Class::[]}(#t120) in let final void #t122 = #t119{self::Class}.{self::Class::[]=}(#t120, #t121.{self::Class::+}(1)) in #t121;
+ let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t124 = c{self::Class} in let final self::Class? #t125 = #t123{self::Class}.{self::Class::[]}(#t124).{self::Class::+}(1) in let final void #t126 = #t123{self::Class}.{self::Class::[]=}(#t124, #t125) in #t125;
+ c = let final self::Class? #t127 = c in #t127.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t128 = c{self::Class} in let final self::Class? #t129 = #t127{self::Class}.{self::Class::[]}(#t128).{self::Class::+}(1) in let final void #t130 = #t127{self::Class}.{self::Class::[]=}(#t128, #t129) in #t129;
+ let final self::Class? #t131 = c in #t131.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t132 = #t131{self::Class}.{self::Class::field} in let final self::Class #t133 = c{self::Class} in #t132.{self::Class::[]=}(#t133, #t132.{self::Class::[]}(#t133).{self::Class::+}(1));
+ c = let final self::Class? #t134 = c in #t134.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t135 = #t134{self::Class}.{self::Class::field} in let final self::Class #t136 = c{self::Class} in let final self::Class? #t137 = #t135.{self::Class::[]}(#t136) in let final void #t138 = #t135.{self::Class::[]=}(#t136, #t137.{self::Class::+}(1)) in #t137;
+ let final self::Class? #t139 = c in #t139.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t140 = #t139{self::Class}.{self::Class::field} in let final self::Class #t141 = c{self::Class} in let final self::Class? #t142 = #t140.{self::Class::[]}(#t141).{self::Class::+}(1) in let final void #t143 = #t140.{self::Class::[]=}(#t141, #t142) in #t142;
+ c = let final self::Class? #t144 = c in #t144.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t145 = #t144{self::Class}.{self::Class::field} in let final self::Class #t146 = c{self::Class} in let final self::Class? #t147 = #t145.{self::Class::[]}(#t146).{self::Class::+}(1) in let final void #t148 = #t145.{self::Class::[]=}(#t146, #t147) in #t147;
+ let final self::Class? #t149 = c in #t149.{core::Object::==}(null) ?{self::Class?} null : #t149{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}).{self::Class::[]}(c{self::Class});
+ let final self::Class? #t150 = c in #t150.{core::Object::==}(null) ?{self::Class} null : #t150{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}).{self::Class::[]=}(c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t151 = c in #t151.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t152 = #t151{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t153 = c{self::Class} in let final self::Class #t154 = new self::Class::•() in let final void #t155 = #t152.{self::Class::[]=}(#t153, #t154) in #t154;
+ let final self::Class #t156 = c{self::Class} in #t156.{core::Object::==}(null) ?{self::Class?} null : #t156.{self::Class::field}.{self::Class::[]}(c{self::Class}).{self::Class::[]}(c{self::Class}).{self::Class::method}();
+ let final self::Class #t157 = c{self::Class} in #t157.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t158 = #t157.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t159 = c{self::Class} in #t158.{self::Class::[]=}(#t159, #t158.{self::Class::[]}(#t159).{self::Class::+}(0));
+ c = let final self::Class #t160 = c{self::Class} in #t160.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t161 = #t160.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t162 = c{self::Class} in let final self::Class? #t163 = #t161.{self::Class::[]}(#t162).{self::Class::+}(0) in let final void #t164 = #t161.{self::Class::[]=}(#t162, #t163) in #t163;
+ let final self::Class? #t165 = c in #t165.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t166 = #t165{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t167 = c{self::Class} in #t166.{self::Class::[]=}(#t167, #t166.{self::Class::[]}(#t167).{self::Class::+}(1));
+ c = let final self::Class? #t168 = c in #t168.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t169 = #t168{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t170 = c{self::Class} in let final self::Class? #t171 = #t169.{self::Class::[]}(#t170) in let final void #t172 = #t169.{self::Class::[]=}(#t170, #t171.{self::Class::+}(1)) in #t171;
+ let final self::Class? #t173 = c in #t173.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t174 = #t173{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t175 = c{self::Class} in let final self::Class? #t176 = #t174.{self::Class::[]}(#t175).{self::Class::+}(1) in let final void #t177 = #t174.{self::Class::[]=}(#t175, #t176) in #t176;
+ c = let final self::Class? #t178 = c in #t178.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t179 = #t178{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t180 = c{self::Class} in let final self::Class? #t181 = #t179.{self::Class::[]}(#t180).{self::Class::+}(1) in let final void #t182 = #t179.{self::Class::[]=}(#t180, #t181) in #t181;
+ let final self::Class? #t183 = c in #t183.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t184 = #t183{self::Class}.{self::Class::[]}(c{self::Class}) in #t184.{core::Object::==}(null) ?{self::Class?} null : #t184{self::Class}.{self::Class::[]}(c{self::Class});
+ let final self::Class? #t185 = c in #t185.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t186 = #t185{self::Class}.{self::Class::[]}(c{self::Class}) in #t186.{core::Object::==}(null) ?{self::Class} null : #t186{self::Class}.{self::Class::[]=}(c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t187 = c in #t187.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t188 = #t187{self::Class}.{self::Class::[]}(c{self::Class}) in #t188.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t189 = c{self::Class} in let final self::Class #t190 = new self::Class::•() in let final void #t191 = #t188{self::Class}.{self::Class::[]=}(#t189, #t190) in #t190;
+ let final self::Class #t192 = c{self::Class} in #t192.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t193 = #t192.{self::Class::[]}(c{self::Class}) in #t193.{core::Object::==}(null) ?{self::Class?} null : #t193{self::Class}.{self::Class::[]}(c{self::Class}).{self::Class::method}();
+ c = let final self::Class #t194 = c{self::Class} in #t194.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t195 = #t194.{self::Class::[]}(c{self::Class}) in #t195.{core::Object::==}(null) ?{self::Class?} null : #t195{self::Class}.{self::Class::[]}(c{self::Class}).{self::Class::method}();
+ let final self::Class? #t196 = c in #t196.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t197 = #t196{self::Class}.{self::Class::[]}(c{self::Class}) in #t197.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t198 = c{self::Class} in #t197{self::Class}.{self::Class::[]}(#t198).{core::Object::==}(null) ?{self::Class} #t197{self::Class}.{self::Class::[]=}(#t198, c{self::Class}) : null;
+ c = let final self::Class? #t199 = c in #t199.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t200 = #t199{self::Class}.{self::Class::[]}(c{self::Class}) in #t200.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t201 = c{self::Class} in let final self::Class? #t202 = #t200{self::Class}.{self::Class::[]}(#t201) in #t202.{core::Object::==}(null) ?{self::Class} let final self::Class #t203 = c{self::Class} in let final void #t204 = #t200{self::Class}.{self::Class::[]=}(#t201, #t203) in #t203 : #t202;
+ let final self::Class #t205 = c{self::Class} in #t205.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t206 = #t205.{self::Class::[]}(c{self::Class}) in #t206.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t207 = c{self::Class} in #t206{self::Class}.{self::Class::[]=}(#t207, #t206{self::Class}.{self::Class::[]}(#t207).{self::Class::+}(0));
+ c = let final self::Class #t208 = c{self::Class} in #t208.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t209 = #t208.{self::Class::[]}(c{self::Class}) in #t209.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t210 = c{self::Class} in let final self::Class? #t211 = #t209{self::Class}.{self::Class::[]}(#t210).{self::Class::+}(0) in let final void #t212 = #t209{self::Class}.{self::Class::[]=}(#t210, #t211) in #t211;
+ let final self::Class? #t213 = c in #t213.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t214 = #t213{self::Class}.{self::Class::[]}(c{self::Class}) in #t214.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t215 = c{self::Class} in #t214{self::Class}.{self::Class::[]=}(#t215, #t214{self::Class}.{self::Class::[]}(#t215).{self::Class::+}(1));
+ c = let final self::Class? #t216 = c in #t216.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t217 = #t216{self::Class}.{self::Class::[]}(c{self::Class}) in #t217.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t218 = c{self::Class} in let final self::Class? #t219 = #t217{self::Class}.{self::Class::[]}(#t218) in let final void #t220 = #t217{self::Class}.{self::Class::[]=}(#t218, #t219.{self::Class::+}(1)) in #t219;
+ let final self::Class? #t221 = c in #t221.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t222 = #t221{self::Class}.{self::Class::[]}(c{self::Class}) in #t222.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t223 = c{self::Class} in let final self::Class? #t224 = #t222{self::Class}.{self::Class::[]}(#t223).{self::Class::+}(1) in let final void #t225 = #t222{self::Class}.{self::Class::[]=}(#t223, #t224) in #t224;
+ c = let final self::Class? #t226 = c in #t226.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t227 = #t226{self::Class}.{self::Class::[]}(c{self::Class}) in #t227.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t228 = c{self::Class} in let final self::Class? #t229 = #t227{self::Class}.{self::Class::[]}(#t228).{self::Class::+}(1) in let final void #t230 = #t227{self::Class}.{self::Class::[]=}(#t228, #t229) in #t229;
}
static method operatorAccess(self::Class? c) → void {
- self::throws(() → self::Class? => (let final self::Class? #t102 = c in #t102.{core::Object::==}(null) ?{self::Class?} null : #t102.{self::Class::field}).{self::Class::+}(0));
- self::throws(() → self::Class? => (let final self::Class? #t103 = c in #t103.{core::Object::==}(null) ?{self::Class?} null : #t103.{self::Class::field}).{self::Class::unary-}());
- let final self::Class? #t104 = c in #t104.{core::Object::==}(null) ?{self::Class?} null : #t104.{self::Class::field} = #t104.{self::Class::field}.{self::Class::+}(0);
- c = let final self::Class? #t105 = c in #t105.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t106 = #t105.{self::Class::field}.{self::Class::+}(0) in let final void #t107 = #t105.{self::Class::field} = #t106 in #t106;
- let final self::Class? #t108 = c in #t108.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t109 = #t108.{self::Class::field} in #t109.{self::Class::field} = #t109.{self::Class::field}.{self::Class::+}(0);
- c = let final self::Class? #t110 = c in #t110.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t111 = #t110.{self::Class::field} in #t111.{self::Class::field} = #t111.{self::Class::field}.{self::Class::+}(0);
- let final self::Class? #t112 = c in #t112.{core::Object::==}(null) ?{self::Class?} null : #t112.{self::Class::field} = #t112.{self::Class::field}.{self::Class::+}(1);
- c = let final self::Class? #t113 = c in #t113.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t114 = #t113.{self::Class::field} in let final void #t115 = #t113.{self::Class::field} = #t114.{self::Class::+}(1) in #t114;
- let final self::Class? #t116 = c in #t116.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t117 = #t116.{self::Class::field}.{self::Class::+}(1) in let final void #t118 = #t116.{self::Class::field} = #t117 in #t117;
- c = let final self::Class? #t119 = c in #t119.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t120 = #t119.{self::Class::field}.{self::Class::+}(1) in let final void #t121 = #t119.{self::Class::field} = #t120 in #t120;
+ self::throws(() → self::Class? => (let final self::Class? #t231 = c in #t231.{core::Object::==}(null) ?{self::Class?} null : #t231{self::Class}.{self::Class::field}).{self::Class::+}(0));
+ self::throws(() → self::Class? => (let final self::Class? #t232 = c in #t232.{core::Object::==}(null) ?{self::Class?} null : #t232{self::Class}.{self::Class::field}).{self::Class::unary-}());
+ let final self::Class? #t233 = c in #t233.{core::Object::==}(null) ?{self::Class?} null : #t233.{self::Class::field} = #t233.{self::Class::field}.{self::Class::+}(0);
+ c = let final self::Class? #t234 = c in #t234.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t235 = #t234.{self::Class::field}.{self::Class::+}(0) in let final void #t236 = #t234.{self::Class::field} = #t235 in #t235;
+ let final self::Class? #t237 = c in #t237.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t238 = #t237{self::Class}.{self::Class::field} in #t238.{self::Class::field} = #t238.{self::Class::field}.{self::Class::+}(0);
+ c = let final self::Class? #t239 = c in #t239.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t240 = #t239{self::Class}.{self::Class::field} in #t240.{self::Class::field} = #t240.{self::Class::field}.{self::Class::+}(0);
+ let final self::Class? #t241 = c in #t241.{core::Object::==}(null) ?{self::Class?} null : #t241.{self::Class::field} = #t241.{self::Class::field}.{self::Class::+}(1);
+ c = let final self::Class? #t242 = c in #t242.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t243 = #t242.{self::Class::field} in let final void #t244 = #t242.{self::Class::field} = #t243.{self::Class::+}(1) in #t243;
+ let final self::Class? #t245 = c in #t245.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t246 = #t245.{self::Class::field}.{self::Class::+}(1) in let final void #t247 = #t245.{self::Class::field} = #t246 in #t246;
+ c = let final self::Class? #t248 = c in #t248.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t249 = #t248.{self::Class::field}.{self::Class::+}(1) in let final void #t250 = #t248.{self::Class::field} = #t249 in #t249;
}
static method ifNull(self::Class? c) → void {
- let final self::Class? #t122 = c in #t122.{core::Object::==}(null) ?{self::Class?} null : #t122.{self::Class::field}.{core::Object::==}(null) ?{self::Class?} #t122.{self::Class::field} = c : null;
- c = let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t124 = #t123.{self::Class::field} in #t124.{core::Object::==}(null) ?{self::Class?} #t123.{self::Class::field} = c : #t124;
- let final self::Class? #t125 = c in #t125.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t126 = #t125.{self::Class::field} in let final self::Class? #t127 = c in #t126.{self::Class::[]}(#t127).{core::Object::==}(null) ?{self::Class?} #t126.{self::Class::[]=}(#t127, c) : null;
+ let final self::Class? #t251 = c in #t251.{core::Object::==}(null) ?{self::Class} null : #t251.{self::Class::field}.{core::Object::==}(null) ?{self::Class} #t251.{self::Class::field} = c{self::Class} : null;
+ c = let final self::Class? #t252 = c in #t252.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t253 = #t252.{self::Class::field} in #t253.{core::Object::==}(null) ?{self::Class} #t252.{self::Class::field} = c{self::Class} : #t253;
+ let final self::Class #t254 = c{self::Class} in #t254.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t255 = #t254.{self::Class::field} in #t255.{self::Class::field}.{core::Object::==}(null) ?{self::Class} #t255.{self::Class::field} = c{self::Class} : null;
+ c = let final self::Class #t256 = c{self::Class} in #t256.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t257 = #t256.{self::Class::field} in let final self::Class? #t258 = #t257.{self::Class::field} in #t258.{core::Object::==}(null) ?{self::Class} #t257.{self::Class::field} = c{self::Class} : #t258;
+ let final self::Class #t259 = c{self::Class} in #t259.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t260 = #t259.{self::Class::field} in let final self::Class #t261 = c{self::Class} in #t260.{self::Class::[]}(#t261).{core::Object::==}(null) ?{self::Class} #t260.{self::Class::[]=}(#t261, c{self::Class}) : null;
+ c = let final self::Class #t262 = c{self::Class} in #t262.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t263 = #t262.{self::Class::field} in let final self::Class #t264 = c{self::Class} in let final self::Class? #t265 = #t263.{self::Class::[]}(#t264) in #t265.{core::Object::==}(null) ?{self::Class} let final self::Class #t266 = c{self::Class} in let final void #t267 = #t263.{self::Class::[]=}(#t264, #t266) in #t266 : #t265;
}
static method throws(() → void f) → void {
try {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/null_shorting.dart.strong.transformed.expect
index d50fc22..7ce23d4 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting.dart.strong.transformed.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field self::Class? field = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
method method() → self::Class?
@@ -26,102 +26,145 @@
self::ifNull(null);
}
static method propertyAccess(self::Class? c) → void {
- let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : #t1.{self::Class::field};
- let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : #t2.{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : #t3.{self::Class::field} = new self::Class::•();
- let final self::Class? #t4 = c in #t4.{core::Object::==}(null) ?{self::Class?} null : #t4.{self::Class::method}();
- let final self::Class? #t5 = c in #t5.{core::Object::==}(null) ?{self::Class?} null : #t5.{self::Class::field}.{self::Class::field};
- let final self::Class? #t6 = c in #t6.{core::Object::==}(null) ?{self::Class} null : #t6.{self::Class::field}.{self::Class::field} = new self::Class::•();
- self::throws(() → self::Class? => (let final self::Class? #t7 = c in #t7.{core::Object::==}(null) ?{self::Class?} null : #t7.{self::Class::field}).{self::Class::field});
- self::throws(() → self::Class? => (let final self::Class? #t8 = c in #t8.{core::Object::==}(null) ?{self::Class} null : #t8.{self::Class::field} = new self::Class::•()).{self::Class::field});
- self::throws(() → self::Class? => (let final self::Class? #t9 = c in #t9.{core::Object::==}(null) ?{self::Class?} null : #t9.{self::Class::method}()).{self::Class::field});
- c = let final self::Class? #t10 = c in #t10.{core::Object::==}(null) ?{self::Class} null : #t10.{self::Class::field}.{self::Class::field} = new self::Class::•();
- let final self::Class? #t11 = c in #t11.{core::Object::==}(null) ?{self::Class?} null : #t11.{self::Class::field}.{self::Class::method}();
- let final self::Class? #t12 = c in #t12.{core::Object::==}(null) ?{self::Class?} null : #t12.{self::Class::field} = new self::Class::•().{self::Class::field};
- c = let final self::Class? #t13 = c in #t13.{core::Object::==}(null) ?{self::Class?} null : #t13.{self::Class::field} = new self::Class::•().{self::Class::field};
- let final self::Class? #t14 = c in #t14.{core::Object::==}(null) ?{self::Class} null : #t14.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t15 = c in #t15.{core::Object::==}(null) ?{self::Class} null : #t15.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- let final self::Class? #t16 = c in #t16.{core::Object::==}(null) ?{self::Class?} null : #t16.{self::Class::field} = new self::Class::•().{self::Class::method}();
- c = let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : #t17.{self::Class::field} = new self::Class::•().{self::Class::method}();
- let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{self::Class?} null : #t18.{self::Class::method}().{self::Class::field};
- let final self::Class? #t19 = c in #t19.{core::Object::==}(null) ?{self::Class} null : #t19.{self::Class::method}().{self::Class::field} = new self::Class::•();
- let final self::Class? #t20 = c in #t20.{core::Object::==}(null) ?{self::Class?} null : #t20.{self::Class::method}().{self::Class::method}();
- let final self::Class? #t21 = c in #t21.{core::Object::==}(null) ?{self::Class?} null : #t21.{self::Class::field}.{self::Class::field}.{self::Class::field};
- let final self::Class? #t22 = c in #t22.{core::Object::==}(null) ?{self::Class} null : #t22.{self::Class::field}.{self::Class::field}.{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t23 = c in #t23.{core::Object::==}(null) ?{self::Class} null : #t23.{self::Class::field}.{self::Class::field}.{self::Class::field} = new self::Class::•();
- let final self::Class? #t24 = c in #t24.{core::Object::==}(null) ?{self::Class?} null : #t24.{self::Class::field}.{self::Class::field}.{self::Class::method}();
- let final self::Class? #t25 = c in #t25.{core::Object::==}(null) ?{self::Class?} null : #t25.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
- c = let final self::Class? #t26 = c in #t26.{core::Object::==}(null) ?{self::Class?} null : #t26.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
- let final self::Class? #t27 = c in #t27.{core::Object::==}(null) ?{self::Class} null : #t27.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t28 = c in #t28.{core::Object::==}(null) ?{self::Class} null : #t28.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
- let final self::Class? #t29 = c in #t29.{core::Object::==}(null) ?{self::Class?} null : #t29.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
- c = let final self::Class? #t30 = c in #t30.{core::Object::==}(null) ?{self::Class?} null : #t30.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
- let final self::Class? #t31 = c in #t31.{core::Object::==}(null) ?{self::Class?} null : #t31.{self::Class::method}().{self::Class::field}.{self::Class::field};
- let final self::Class? #t32 = c in #t32.{core::Object::==}(null) ?{self::Class} null : #t32.{self::Class::method}().{self::Class::field}.{self::Class::field} = new self::Class::•();
- let final self::Class? #t33 = c in #t33.{core::Object::==}(null) ?{self::Class?} null : #t33.{self::Class::method}().{self::Class::field}.{self::Class::method}();
- let final self::Class? #t34 = c in #t34.{core::Object::==}(null) ?{self::Class?} null : #t34.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field};
- c = let final self::Class? #t35 = c in #t35.{core::Object::==}(null) ?{self::Class?} null : #t35.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field};
- let final self::Class? #t36 = c in #t36.{core::Object::==}(null) ?{self::Class} null : #t36.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t37 = c in #t37.{core::Object::==}(null) ?{self::Class} null : #t37.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- let final self::Class? #t38 = c in #t38.{core::Object::==}(null) ?{self::Class?} null : #t38.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::method}();
- c = let final self::Class? #t39 = c in #t39.{core::Object::==}(null) ?{self::Class?} null : #t39.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::method}();
- let final self::Class? #t40 = c in #t40.{core::Object::==}(null) ?{self::Class?} null : #t40.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
- c = let final self::Class? #t41 = c in #t41.{core::Object::==}(null) ?{self::Class?} null : #t41.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
- let final self::Class? #t42 = c in #t42.{core::Object::==}(null) ?{self::Class} null : #t42.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t43 = c in #t43.{core::Object::==}(null) ?{self::Class} null : #t43.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- let final self::Class? #t44 = c in #t44.{core::Object::==}(null) ?{self::Class?} null : #t44.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
- c = let final self::Class? #t45 = c in #t45.{core::Object::==}(null) ?{self::Class?} null : #t45.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
- let final self::Class? #t46 = c in #t46.{core::Object::==}(null) ?{self::Class?} null : #t46.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field};
- c = let final self::Class? #t47 = c in #t47.{core::Object::==}(null) ?{self::Class?} null : #t47.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field};
- let final self::Class? #t48 = c in #t48.{core::Object::==}(null) ?{self::Class} null : #t48.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t49 = c in #t49.{core::Object::==}(null) ?{self::Class} null : #t49.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
- let final self::Class? #t50 = c in #t50.{core::Object::==}(null) ?{self::Class?} null : #t50.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::method}();
- c = let final self::Class? #t51 = c in #t51.{core::Object::==}(null) ?{self::Class?} null : #t51.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::method}();
- let final self::Class? #t52 = c in #t52.{core::Object::==}(null) ?{self::Class?} null : #t52.{self::Class::field}.{self::Class::method}().{self::Class::field};
- let final self::Class? #t53 = c in #t53.{core::Object::==}(null) ?{self::Class} null : #t53.{self::Class::field}.{self::Class::method}().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t54 = c in #t54.{core::Object::==}(null) ?{self::Class} null : #t54.{self::Class::field}.{self::Class::method}().{self::Class::field} = new self::Class::•();
- let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class?} null : #t55.{self::Class::field}.{self::Class::method}().{self::Class::method}();
- let final self::Class? #t56 = c in #t56.{core::Object::==}(null) ?{self::Class?} null : #t56.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
- c = let final self::Class? #t57 = c in #t57.{core::Object::==}(null) ?{self::Class?} null : #t57.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
- let final self::Class? #t58 = c in #t58.{core::Object::==}(null) ?{self::Class} null : #t58.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
- c = let final self::Class? #t59 = c in #t59.{core::Object::==}(null) ?{self::Class} null : #t59.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
- let final self::Class? #t60 = c in #t60.{core::Object::==}(null) ?{self::Class?} null : #t60.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
- c = let final self::Class? #t61 = c in #t61.{core::Object::==}(null) ?{self::Class?} null : #t61.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
- let final self::Class? #t62 = c in #t62.{core::Object::==}(null) ?{self::Class?} null : #t62.{self::Class::method}().{self::Class::method}().{self::Class::field};
- let final self::Class? #t63 = c in #t63.{core::Object::==}(null) ?{self::Class} null : #t63.{self::Class::method}().{self::Class::method}().{self::Class::field} = new self::Class::•();
- let final self::Class? #t64 = c in #t64.{core::Object::==}(null) ?{self::Class?} null : #t64.{self::Class::method}().{self::Class::method}().{self::Class::method}();
+ let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : #t1{self::Class}.{self::Class::field};
+ let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : #t2{self::Class}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : #t3{self::Class}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t4 = c{self::Class} in #t4.{core::Object::==}(null) ?{self::Class?} null : #t4.{self::Class::method}();
+ let final self::Class #t5 = c{self::Class} in #t5.{core::Object::==}(null) ?{self::Class?} null : #t5.{self::Class::field}.{self::Class::field};
+ let final self::Class #t6 = c{self::Class} in #t6.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t7 = #t6.{self::Class::field} in #t7.{core::Object::==}(null) ?{self::Class?} null : #t7{self::Class}.{self::Class::field};
+ let final self::Class #t8 = c{self::Class} in #t8.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t9 = #t8.{self::Class::field}.{self::Class::field} in #t9.{core::Object::==}(null) ?{self::Class?} null : #t9{self::Class}.{self::Class::field};
+ let final self::Class #t10 = c{self::Class} in #t10.{core::Object::==}(null) ?{self::Class} null : #t10.{self::Class::field}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t11 = c{self::Class} in #t11.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t12 = #t11.{self::Class::field} in #t12.{core::Object::==}(null) ?{self::Class} null : #t12{self::Class}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t13 = c{self::Class} in #t13.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t14 = #t13.{self::Class::field}.{self::Class::field} in #t14.{core::Object::==}(null) ?{self::Class} null : #t14{self::Class}.{self::Class::field} = new self::Class::•();
+ self::throws(() → self::Class? => (let final self::Class? #t15 = c in #t15.{core::Object::==}(null) ?{self::Class?} null : #t15{self::Class}.{self::Class::field}).{self::Class::field});
+ self::throws(() → self::Class? => (let final self::Class? #t16 = c in #t16.{core::Object::==}(null) ?{self::Class} null : #t16{self::Class}.{self::Class::field} = new self::Class::•()).{self::Class::field});
+ self::throws(() → self::Class? => (let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : #t17{self::Class}.{self::Class::method}()).{self::Class::field});
+ c = let final self::Class #t18 = c{self::Class} in #t18.{core::Object::==}(null) ?{self::Class} null : #t18.{self::Class::field}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class #t19 = c{self::Class} in #t19.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t20 = #t19.{self::Class::field} in #t20.{core::Object::==}(null) ?{self::Class} null : #t20{self::Class}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class #t21 = c{self::Class} in #t21.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t22 = #t21.{self::Class::field}.{self::Class::field} in #t22.{core::Object::==}(null) ?{self::Class} null : #t22{self::Class}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t23 = c{self::Class} in #t23.{core::Object::==}(null) ?{self::Class?} null : #t23.{self::Class::field}.{self::Class::method}();
+ let final self::Class #t24 = c{self::Class} in #t24.{core::Object::==}(null) ?{self::Class?} null : #t24.{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class #t25 = c{self::Class} in #t25.{core::Object::==}(null) ?{self::Class?} null : #t25.{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class? #t26 = c in #t26.{core::Object::==}(null) ?{self::Class} null : #t26{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t27 = c in #t27.{core::Object::==}(null) ?{self::Class} null : #t27{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class #t28 = c{self::Class} in #t28.{core::Object::==}(null) ?{self::Class?} null : #t28.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class #t29 = c{self::Class} in #t29.{core::Object::==}(null) ?{self::Class?} null : #t29.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ let final self::Class? #t30 = c in #t30.{core::Object::==}(null) ?{self::Class?} null : #t30{self::Class}.{self::Class::method}().{self::Class::field};
+ let final self::Class? #t31 = c in #t31.{core::Object::==}(null) ?{self::Class} null : #t31{self::Class}.{self::Class::method}().{self::Class::field} = new self::Class::•();
+ let final self::Class? #t32 = c in #t32.{core::Object::==}(null) ?{self::Class?} null : #t32{self::Class}.{self::Class::method}().{self::Class::method}();
+ let final self::Class? #t33 = c in #t33.{core::Object::==}(null) ?{self::Class?} null : #t33{self::Class}.{self::Class::field}.{self::Class::field}.{self::Class::field};
+ let final self::Class? #t34 = c in #t34.{core::Object::==}(null) ?{self::Class} null : #t34{self::Class}.{self::Class::field}.{self::Class::field}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t35 = c in #t35.{core::Object::==}(null) ?{self::Class} null : #t35{self::Class}.{self::Class::field}.{self::Class::field}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t36 = c{self::Class} in #t36.{core::Object::==}(null) ?{self::Class?} null : #t36.{self::Class::field}.{self::Class::field}.{self::Class::method}();
+ let final self::Class #t37 = c{self::Class} in #t37.{core::Object::==}(null) ?{self::Class?} null : #t37.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
+ c = let final self::Class #t38 = c{self::Class} in #t38.{core::Object::==}(null) ?{self::Class?} null : #t38.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field};
+ let final self::Class? #t39 = c in #t39.{core::Object::==}(null) ?{self::Class} null : #t39{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t40 = c in #t40.{core::Object::==}(null) ?{self::Class} null : #t40{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::field} = new self::Class::•();
+ let final self::Class #t41 = c{self::Class} in #t41.{core::Object::==}(null) ?{self::Class?} null : #t41.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
+ c = let final self::Class #t42 = c{self::Class} in #t42.{core::Object::==}(null) ?{self::Class?} null : #t42.{self::Class::field} = new self::Class::•().{self::Class::field}.{self::Class::method}();
+ let final self::Class? #t43 = c in #t43.{core::Object::==}(null) ?{self::Class?} null : #t43{self::Class}.{self::Class::method}().{self::Class::field}.{self::Class::field};
+ let final self::Class? #t44 = c in #t44.{core::Object::==}(null) ?{self::Class} null : #t44{self::Class}.{self::Class::method}().{self::Class::field}.{self::Class::field} = new self::Class::•();
+ let final self::Class? #t45 = c in #t45.{core::Object::==}(null) ?{self::Class?} null : #t45{self::Class}.{self::Class::method}().{self::Class::field}.{self::Class::method}();
+ let final self::Class? #t46 = c in #t46.{core::Object::==}(null) ?{self::Class?} null : #t46{self::Class}.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class? #t47 = c in #t47.{core::Object::==}(null) ?{self::Class?} null : #t47{self::Class}.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class? #t48 = c in #t48.{core::Object::==}(null) ?{self::Class} null : #t48{self::Class}.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t49 = c in #t49.{core::Object::==}(null) ?{self::Class} null : #t49{self::Class}.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class #t50 = c{self::Class} in #t50.{core::Object::==}(null) ?{self::Class?} null : #t50.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class #t51 = c{self::Class} in #t51.{core::Object::==}(null) ?{self::Class?} null : #t51.{self::Class::field}.{self::Class::field} = new self::Class::•().{self::Class::method}();
+ let final self::Class? #t52 = c in #t52.{core::Object::==}(null) ?{self::Class?} null : #t52{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class? #t53 = c in #t53.{core::Object::==}(null) ?{self::Class?} null : #t53{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class? #t54 = c in #t54.{core::Object::==}(null) ?{self::Class} null : #t54{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class} null : #t55{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class #t56 = c{self::Class} in #t56.{core::Object::==}(null) ?{self::Class?} null : #t56.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class #t57 = c{self::Class} in #t57.{core::Object::==}(null) ?{self::Class?} null : #t57.{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ let final self::Class? #t58 = c in #t58.{core::Object::==}(null) ?{self::Class?} null : #t58{self::Class}.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field};
+ c = let final self::Class? #t59 = c in #t59.{core::Object::==}(null) ?{self::Class?} null : #t59{self::Class}.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field};
+ let final self::Class? #t60 = c in #t60.{core::Object::==}(null) ?{self::Class} null : #t60{self::Class}.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t61 = c in #t61.{core::Object::==}(null) ?{self::Class} null : #t61{self::Class}.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::field} = new self::Class::•();
+ let final self::Class #t62 = c{self::Class} in #t62.{core::Object::==}(null) ?{self::Class?} null : #t62.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ c = let final self::Class #t63 = c{self::Class} in #t63.{core::Object::==}(null) ?{self::Class?} null : #t63.{self::Class::method}().{self::Class::field} = new self::Class::•().{self::Class::method}();
+ let final self::Class? #t64 = c in #t64.{core::Object::==}(null) ?{self::Class?} null : #t64{self::Class}.{self::Class::field}.{self::Class::method}().{self::Class::field};
+ let final self::Class? #t65 = c in #t65.{core::Object::==}(null) ?{self::Class} null : #t65{self::Class}.{self::Class::field}.{self::Class::method}().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : #t66{self::Class}.{self::Class::field}.{self::Class::method}().{self::Class::field} = new self::Class::•();
+ let final self::Class #t67 = c{self::Class} in #t67.{core::Object::==}(null) ?{self::Class?} null : #t67.{self::Class::field}.{self::Class::method}().{self::Class::method}();
+ let final self::Class #t68 = c{self::Class} in #t68.{core::Object::==}(null) ?{self::Class?} null : #t68.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
+ c = let final self::Class #t69 = c{self::Class} in #t69.{core::Object::==}(null) ?{self::Class?} null : #t69.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field};
+ let final self::Class? #t70 = c in #t70.{core::Object::==}(null) ?{self::Class} null : #t70{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
+ c = let final self::Class? #t71 = c in #t71.{core::Object::==}(null) ?{self::Class} null : #t71{self::Class}.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::field} = new self::Class::•();
+ let final self::Class #t72 = c{self::Class} in #t72.{core::Object::==}(null) ?{self::Class?} null : #t72.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
+ c = let final self::Class #t73 = c{self::Class} in #t73.{core::Object::==}(null) ?{self::Class?} null : #t73.{self::Class::field} = new self::Class::•().{self::Class::method}().{self::Class::method}();
+ let final self::Class? #t74 = c in #t74.{core::Object::==}(null) ?{self::Class?} null : #t74{self::Class}.{self::Class::method}().{self::Class::method}().{self::Class::field};
+ let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class} null : #t75{self::Class}.{self::Class::method}().{self::Class::method}().{self::Class::field} = new self::Class::•();
+ let final self::Class? #t76 = c in #t76.{core::Object::==}(null) ?{self::Class?} null : #t76{self::Class}.{self::Class::method}().{self::Class::method}().{self::Class::method}();
+ let final self::Class? #t77 = c in #t77.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t78 = #t77{self::Class}.{self::Class::method}() in #t78.{core::Object::==}(null) ?{self::Class?} null : #t78{self::Class}.{self::Class::method}();
}
static method indexAccess(self::Class? c) → void {
- let final self::Class? #t65 = c in #t65.{core::Object::==}(null) ?{self::Class?} null : #t65.{self::Class::[]}(c);
- let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : #t66.{self::Class::[]=}(c, new self::Class::•());
- let final self::Class? #t67 = c in #t67.{core::Object::==}(null) ?{self::Class?} null : #t67.{self::Class::[]}(c).{self::Class::method}();
- let final self::Class? #t68 = c in #t68.{core::Object::==}(null) ?{self::Class?} null : #t68.{self::Class::field}.{self::Class::[]}(c);
- let final self::Class? #t69 = c in #t69.{core::Object::==}(null) ?{self::Class} null : #t69.{self::Class::field}.{self::Class::[]=}(c, new self::Class::•());
- c = let final self::Class? #t70 = c in #t70.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t71 = #t70.{self::Class::field} in let final self::Class? #t72 = c in let final self::Class #t73 = new self::Class::•() in let final void #t74 = #t71.{self::Class::[]=}(#t72, #t73) in #t73;
- let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class?} null : #t75.{self::Class::field}.{self::Class::[]}(c).{self::Class::method}();
- let final self::Class? #t76 = c in #t76.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t77 = #t76.{self::Class::field} in let final self::Class? #t78 = c in #t77.{self::Class::[]=}(#t78, #t77.{self::Class::[]}(#t78).{self::Class::+}(0));
- c = let final self::Class? #t79 = c in #t79.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t80 = #t79.{self::Class::field} in let final self::Class? #t81 = c in let final self::Class? #t82 = #t80.{self::Class::[]}(#t81).{self::Class::+}(0) in let final void #t83 = #t80.{self::Class::[]=}(#t81, #t82) in #t82;
- let final self::Class? #t84 = c in #t84.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t85 = #t84.{self::Class::field} in let final self::Class? #t86 = c in #t85.{self::Class::[]=}(#t86, #t85.{self::Class::[]}(#t86).{self::Class::+}(1));
- c = let final self::Class? #t87 = c in #t87.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t88 = #t87.{self::Class::field} in let final self::Class? #t89 = c in let final self::Class? #t90 = #t88.{self::Class::[]}(#t89) in let final void #t91 = #t88.{self::Class::[]=}(#t89, #t90.{self::Class::+}(1)) in #t90;
- let final self::Class? #t92 = c in #t92.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t93 = #t92.{self::Class::field} in let final self::Class? #t94 = c in let final self::Class? #t95 = #t93.{self::Class::[]}(#t94).{self::Class::+}(1) in let final void #t96 = #t93.{self::Class::[]=}(#t94, #t95) in #t95;
- c = let final self::Class? #t97 = c in #t97.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t98 = #t97.{self::Class::field} in let final self::Class? #t99 = c in let final self::Class? #t100 = #t98.{self::Class::[]}(#t99).{self::Class::+}(1) in let final void #t101 = #t98.{self::Class::[]=}(#t99, #t100) in #t100;
+ let final self::Class? #t79 = c in #t79.{core::Object::==}(null) ?{self::Class?} null : #t79{self::Class}.{self::Class::[]}(c{self::Class});
+ let final self::Class? #t80 = c in #t80.{core::Object::==}(null) ?{self::Class} null : #t80{self::Class}.{self::Class::[]=}(c{self::Class}, new self::Class::•());
+ let final self::Class? #t81 = c in #t81.{core::Object::==}(null) ?{self::Class?} null : #t81{self::Class}.{self::Class::[]}(c{self::Class}).{self::Class::method}();
+ let final self::Class? #t82 = c in #t82.{core::Object::==}(null) ?{self::Class?} null : #t82{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class});
+ let final self::Class? #t83 = c in #t83.{core::Object::==}(null) ?{self::Class} null : #t83{self::Class}.{self::Class::field}.{self::Class::[]=}(c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t84 = c in #t84.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t85 = #t84{self::Class}.{self::Class::field} in let final self::Class #t86 = c{self::Class} in let final self::Class #t87 = new self::Class::•() in let final void #t88 = #t85.{self::Class::[]=}(#t86, #t87) in #t87;
+ let final self::Class #t89 = c{self::Class} in #t89.{core::Object::==}(null) ?{self::Class?} null : #t89.{self::Class::field}.{self::Class::[]}(c{self::Class}).{self::Class::method}();
+ let final self::Class #t90 = c{self::Class} in #t90.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t91 = #t90.{self::Class::field} in let final self::Class #t92 = c{self::Class} in #t91.{self::Class::[]=}(#t92, #t91.{self::Class::[]}(#t92).{self::Class::+}(0));
+ c = let final self::Class #t93 = c{self::Class} in #t93.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t94 = #t93.{self::Class::field} in let final self::Class #t95 = c{self::Class} in let final self::Class? #t96 = #t94.{self::Class::[]}(#t95).{self::Class::+}(0) in let final void #t97 = #t94.{self::Class::[]=}(#t95, #t96) in #t96;
+ let final self::Class? #t98 = c in #t98.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t99 = c{self::Class} in #t98{self::Class}.{self::Class::[]}(#t99).{core::Object::==}(null) ?{self::Class} #t98{self::Class}.{self::Class::[]=}(#t99, c{self::Class}) : null;
+ c = let final self::Class? #t100 = c in #t100.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t101 = c{self::Class} in let final self::Class? #t102 = #t100{self::Class}.{self::Class::[]}(#t101) in #t102.{core::Object::==}(null) ?{self::Class} let final self::Class #t103 = c{self::Class} in let final void #t104 = #t100{self::Class}.{self::Class::[]=}(#t101, #t103) in #t103 : #t102;
+ let final self::Class #t105 = c{self::Class} in #t105.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t106 = c{self::Class} in #t105.{self::Class::[]=}(#t106, #t105.{self::Class::[]}(#t106).{self::Class::+}(0));
+ c = let final self::Class #t107 = c{self::Class} in #t107.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t108 = c{self::Class} in let final self::Class? #t109 = #t107.{self::Class::[]}(#t108).{self::Class::+}(0) in let final void #t110 = #t107.{self::Class::[]=}(#t108, #t109) in #t109;
+ let final self::Class? #t111 = c in #t111.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t112 = c{self::Class} in #t111{self::Class}.{self::Class::[]=}(#t112, #t111{self::Class}.{self::Class::[]}(#t112).{self::Class::+}(0));
+ c = let final self::Class? #t113 = c in #t113.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t114 = c{self::Class} in let final self::Class? #t115 = #t113{self::Class}.{self::Class::[]}(#t114).{self::Class::+}(0) in let final void #t116 = #t113{self::Class}.{self::Class::[]=}(#t114, #t115) in #t115;
+ let final self::Class? #t117 = c in #t117.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t118 = c{self::Class} in #t117{self::Class}.{self::Class::[]=}(#t118, #t117{self::Class}.{self::Class::[]}(#t118).{self::Class::+}(1));
+ c = let final self::Class? #t119 = c in #t119.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t120 = c{self::Class} in let final self::Class? #t121 = #t119{self::Class}.{self::Class::[]}(#t120) in let final void #t122 = #t119{self::Class}.{self::Class::[]=}(#t120, #t121.{self::Class::+}(1)) in #t121;
+ let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t124 = c{self::Class} in let final self::Class? #t125 = #t123{self::Class}.{self::Class::[]}(#t124).{self::Class::+}(1) in let final void #t126 = #t123{self::Class}.{self::Class::[]=}(#t124, #t125) in #t125;
+ c = let final self::Class? #t127 = c in #t127.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t128 = c{self::Class} in let final self::Class? #t129 = #t127{self::Class}.{self::Class::[]}(#t128).{self::Class::+}(1) in let final void #t130 = #t127{self::Class}.{self::Class::[]=}(#t128, #t129) in #t129;
+ let final self::Class? #t131 = c in #t131.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t132 = #t131{self::Class}.{self::Class::field} in let final self::Class #t133 = c{self::Class} in #t132.{self::Class::[]=}(#t133, #t132.{self::Class::[]}(#t133).{self::Class::+}(1));
+ c = let final self::Class? #t134 = c in #t134.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t135 = #t134{self::Class}.{self::Class::field} in let final self::Class #t136 = c{self::Class} in let final self::Class? #t137 = #t135.{self::Class::[]}(#t136) in let final void #t138 = #t135.{self::Class::[]=}(#t136, #t137.{self::Class::+}(1)) in #t137;
+ let final self::Class? #t139 = c in #t139.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t140 = #t139{self::Class}.{self::Class::field} in let final self::Class #t141 = c{self::Class} in let final self::Class? #t142 = #t140.{self::Class::[]}(#t141).{self::Class::+}(1) in let final void #t143 = #t140.{self::Class::[]=}(#t141, #t142) in #t142;
+ c = let final self::Class? #t144 = c in #t144.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t145 = #t144{self::Class}.{self::Class::field} in let final self::Class #t146 = c{self::Class} in let final self::Class? #t147 = #t145.{self::Class::[]}(#t146).{self::Class::+}(1) in let final void #t148 = #t145.{self::Class::[]=}(#t146, #t147) in #t147;
+ let final self::Class? #t149 = c in #t149.{core::Object::==}(null) ?{self::Class?} null : #t149{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}).{self::Class::[]}(c{self::Class});
+ let final self::Class? #t150 = c in #t150.{core::Object::==}(null) ?{self::Class} null : #t150{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}).{self::Class::[]=}(c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t151 = c in #t151.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t152 = #t151{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t153 = c{self::Class} in let final self::Class #t154 = new self::Class::•() in let final void #t155 = #t152.{self::Class::[]=}(#t153, #t154) in #t154;
+ let final self::Class #t156 = c{self::Class} in #t156.{core::Object::==}(null) ?{self::Class?} null : #t156.{self::Class::field}.{self::Class::[]}(c{self::Class}).{self::Class::[]}(c{self::Class}).{self::Class::method}();
+ let final self::Class #t157 = c{self::Class} in #t157.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t158 = #t157.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t159 = c{self::Class} in #t158.{self::Class::[]=}(#t159, #t158.{self::Class::[]}(#t159).{self::Class::+}(0));
+ c = let final self::Class #t160 = c{self::Class} in #t160.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t161 = #t160.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t162 = c{self::Class} in let final self::Class? #t163 = #t161.{self::Class::[]}(#t162).{self::Class::+}(0) in let final void #t164 = #t161.{self::Class::[]=}(#t162, #t163) in #t163;
+ let final self::Class? #t165 = c in #t165.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t166 = #t165{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t167 = c{self::Class} in #t166.{self::Class::[]=}(#t167, #t166.{self::Class::[]}(#t167).{self::Class::+}(1));
+ c = let final self::Class? #t168 = c in #t168.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t169 = #t168{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t170 = c{self::Class} in let final self::Class? #t171 = #t169.{self::Class::[]}(#t170) in let final void #t172 = #t169.{self::Class::[]=}(#t170, #t171.{self::Class::+}(1)) in #t171;
+ let final self::Class? #t173 = c in #t173.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t174 = #t173{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t175 = c{self::Class} in let final self::Class? #t176 = #t174.{self::Class::[]}(#t175).{self::Class::+}(1) in let final void #t177 = #t174.{self::Class::[]=}(#t175, #t176) in #t176;
+ c = let final self::Class? #t178 = c in #t178.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t179 = #t178{self::Class}.{self::Class::field}.{self::Class::[]}(c{self::Class}) in let final self::Class #t180 = c{self::Class} in let final self::Class? #t181 = #t179.{self::Class::[]}(#t180).{self::Class::+}(1) in let final void #t182 = #t179.{self::Class::[]=}(#t180, #t181) in #t181;
+ let final self::Class? #t183 = c in #t183.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t184 = #t183{self::Class}.{self::Class::[]}(c{self::Class}) in #t184.{core::Object::==}(null) ?{self::Class?} null : #t184{self::Class}.{self::Class::[]}(c{self::Class});
+ let final self::Class? #t185 = c in #t185.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t186 = #t185{self::Class}.{self::Class::[]}(c{self::Class}) in #t186.{core::Object::==}(null) ?{self::Class} null : #t186{self::Class}.{self::Class::[]=}(c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t187 = c in #t187.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t188 = #t187{self::Class}.{self::Class::[]}(c{self::Class}) in #t188.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t189 = c{self::Class} in let final self::Class #t190 = new self::Class::•() in let final void #t191 = #t188{self::Class}.{self::Class::[]=}(#t189, #t190) in #t190;
+ let final self::Class #t192 = c{self::Class} in #t192.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t193 = #t192.{self::Class::[]}(c{self::Class}) in #t193.{core::Object::==}(null) ?{self::Class?} null : #t193{self::Class}.{self::Class::[]}(c{self::Class}).{self::Class::method}();
+ c = let final self::Class #t194 = c{self::Class} in #t194.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t195 = #t194.{self::Class::[]}(c{self::Class}) in #t195.{core::Object::==}(null) ?{self::Class?} null : #t195{self::Class}.{self::Class::[]}(c{self::Class}).{self::Class::method}();
+ let final self::Class? #t196 = c in #t196.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t197 = #t196{self::Class}.{self::Class::[]}(c{self::Class}) in #t197.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t198 = c{self::Class} in #t197{self::Class}.{self::Class::[]}(#t198).{core::Object::==}(null) ?{self::Class} #t197{self::Class}.{self::Class::[]=}(#t198, c{self::Class}) : null;
+ c = let final self::Class? #t199 = c in #t199.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t200 = #t199{self::Class}.{self::Class::[]}(c{self::Class}) in #t200.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t201 = c{self::Class} in let final self::Class? #t202 = #t200{self::Class}.{self::Class::[]}(#t201) in #t202.{core::Object::==}(null) ?{self::Class} let final self::Class #t203 = c{self::Class} in let final void #t204 = #t200{self::Class}.{self::Class::[]=}(#t201, #t203) in #t203 : #t202;
+ let final self::Class #t205 = c{self::Class} in #t205.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t206 = #t205.{self::Class::[]}(c{self::Class}) in #t206.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t207 = c{self::Class} in #t206{self::Class}.{self::Class::[]=}(#t207, #t206{self::Class}.{self::Class::[]}(#t207).{self::Class::+}(0));
+ c = let final self::Class #t208 = c{self::Class} in #t208.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t209 = #t208.{self::Class::[]}(c{self::Class}) in #t209.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t210 = c{self::Class} in let final self::Class? #t211 = #t209{self::Class}.{self::Class::[]}(#t210).{self::Class::+}(0) in let final void #t212 = #t209{self::Class}.{self::Class::[]=}(#t210, #t211) in #t211;
+ let final self::Class? #t213 = c in #t213.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t214 = #t213{self::Class}.{self::Class::[]}(c{self::Class}) in #t214.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t215 = c{self::Class} in #t214{self::Class}.{self::Class::[]=}(#t215, #t214{self::Class}.{self::Class::[]}(#t215).{self::Class::+}(1));
+ c = let final self::Class? #t216 = c in #t216.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t217 = #t216{self::Class}.{self::Class::[]}(c{self::Class}) in #t217.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t218 = c{self::Class} in let final self::Class? #t219 = #t217{self::Class}.{self::Class::[]}(#t218) in let final void #t220 = #t217{self::Class}.{self::Class::[]=}(#t218, #t219.{self::Class::+}(1)) in #t219;
+ let final self::Class? #t221 = c in #t221.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t222 = #t221{self::Class}.{self::Class::[]}(c{self::Class}) in #t222.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t223 = c{self::Class} in let final self::Class? #t224 = #t222{self::Class}.{self::Class::[]}(#t223).{self::Class::+}(1) in let final void #t225 = #t222{self::Class}.{self::Class::[]=}(#t223, #t224) in #t224;
+ c = let final self::Class? #t226 = c in #t226.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t227 = #t226{self::Class}.{self::Class::[]}(c{self::Class}) in #t227.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t228 = c{self::Class} in let final self::Class? #t229 = #t227{self::Class}.{self::Class::[]}(#t228).{self::Class::+}(1) in let final void #t230 = #t227{self::Class}.{self::Class::[]=}(#t228, #t229) in #t229;
}
static method operatorAccess(self::Class? c) → void {
- self::throws(() → self::Class? => (let final self::Class? #t102 = c in #t102.{core::Object::==}(null) ?{self::Class?} null : #t102.{self::Class::field}).{self::Class::+}(0));
- self::throws(() → self::Class? => (let final self::Class? #t103 = c in #t103.{core::Object::==}(null) ?{self::Class?} null : #t103.{self::Class::field}).{self::Class::unary-}());
- let final self::Class? #t104 = c in #t104.{core::Object::==}(null) ?{self::Class?} null : #t104.{self::Class::field} = #t104.{self::Class::field}.{self::Class::+}(0);
- c = let final self::Class? #t105 = c in #t105.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t106 = #t105.{self::Class::field}.{self::Class::+}(0) in let final void #t107 = #t105.{self::Class::field} = #t106 in #t106;
- let final self::Class? #t108 = c in #t108.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t109 = #t108.{self::Class::field} in #t109.{self::Class::field} = #t109.{self::Class::field}.{self::Class::+}(0);
- c = let final self::Class? #t110 = c in #t110.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t111 = #t110.{self::Class::field} in #t111.{self::Class::field} = #t111.{self::Class::field}.{self::Class::+}(0);
- let final self::Class? #t112 = c in #t112.{core::Object::==}(null) ?{self::Class?} null : #t112.{self::Class::field} = #t112.{self::Class::field}.{self::Class::+}(1);
- c = let final self::Class? #t113 = c in #t113.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t114 = #t113.{self::Class::field} in let final void #t115 = #t113.{self::Class::field} = #t114.{self::Class::+}(1) in #t114;
- let final self::Class? #t116 = c in #t116.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t117 = #t116.{self::Class::field}.{self::Class::+}(1) in let final void #t118 = #t116.{self::Class::field} = #t117 in #t117;
- c = let final self::Class? #t119 = c in #t119.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t120 = #t119.{self::Class::field}.{self::Class::+}(1) in let final void #t121 = #t119.{self::Class::field} = #t120 in #t120;
+ self::throws(() → self::Class? => (let final self::Class? #t231 = c in #t231.{core::Object::==}(null) ?{self::Class?} null : #t231{self::Class}.{self::Class::field}).{self::Class::+}(0));
+ self::throws(() → self::Class? => (let final self::Class? #t232 = c in #t232.{core::Object::==}(null) ?{self::Class?} null : #t232{self::Class}.{self::Class::field}).{self::Class::unary-}());
+ let final self::Class? #t233 = c in #t233.{core::Object::==}(null) ?{self::Class?} null : #t233.{self::Class::field} = #t233.{self::Class::field}.{self::Class::+}(0);
+ c = let final self::Class? #t234 = c in #t234.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t235 = #t234.{self::Class::field}.{self::Class::+}(0) in let final void #t236 = #t234.{self::Class::field} = #t235 in #t235;
+ let final self::Class? #t237 = c in #t237.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t238 = #t237{self::Class}.{self::Class::field} in #t238.{self::Class::field} = #t238.{self::Class::field}.{self::Class::+}(0);
+ c = let final self::Class? #t239 = c in #t239.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t240 = #t239{self::Class}.{self::Class::field} in #t240.{self::Class::field} = #t240.{self::Class::field}.{self::Class::+}(0);
+ let final self::Class? #t241 = c in #t241.{core::Object::==}(null) ?{self::Class?} null : #t241.{self::Class::field} = #t241.{self::Class::field}.{self::Class::+}(1);
+ c = let final self::Class? #t242 = c in #t242.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t243 = #t242.{self::Class::field} in let final void #t244 = #t242.{self::Class::field} = #t243.{self::Class::+}(1) in #t243;
+ let final self::Class? #t245 = c in #t245.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t246 = #t245.{self::Class::field}.{self::Class::+}(1) in let final void #t247 = #t245.{self::Class::field} = #t246 in #t246;
+ c = let final self::Class? #t248 = c in #t248.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t249 = #t248.{self::Class::field}.{self::Class::+}(1) in let final void #t250 = #t248.{self::Class::field} = #t249 in #t249;
}
static method ifNull(self::Class? c) → void {
- let final self::Class? #t122 = c in #t122.{core::Object::==}(null) ?{self::Class?} null : #t122.{self::Class::field}.{core::Object::==}(null) ?{self::Class?} #t122.{self::Class::field} = c : null;
- c = let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t124 = #t123.{self::Class::field} in #t124.{core::Object::==}(null) ?{self::Class?} #t123.{self::Class::field} = c : #t124;
- let final self::Class? #t125 = c in #t125.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t126 = #t125.{self::Class::field} in let final self::Class? #t127 = c in #t126.{self::Class::[]}(#t127).{core::Object::==}(null) ?{self::Class?} #t126.{self::Class::[]=}(#t127, c) : null;
+ let final self::Class? #t251 = c in #t251.{core::Object::==}(null) ?{self::Class} null : #t251.{self::Class::field}.{core::Object::==}(null) ?{self::Class} #t251.{self::Class::field} = c{self::Class} : null;
+ c = let final self::Class? #t252 = c in #t252.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t253 = #t252.{self::Class::field} in #t253.{core::Object::==}(null) ?{self::Class} #t252.{self::Class::field} = c{self::Class} : #t253;
+ let final self::Class #t254 = c{self::Class} in #t254.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t255 = #t254.{self::Class::field} in #t255.{self::Class::field}.{core::Object::==}(null) ?{self::Class} #t255.{self::Class::field} = c{self::Class} : null;
+ c = let final self::Class #t256 = c{self::Class} in #t256.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t257 = #t256.{self::Class::field} in let final self::Class? #t258 = #t257.{self::Class::field} in #t258.{core::Object::==}(null) ?{self::Class} #t257.{self::Class::field} = c{self::Class} : #t258;
+ let final self::Class #t259 = c{self::Class} in #t259.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t260 = #t259.{self::Class::field} in let final self::Class #t261 = c{self::Class} in #t260.{self::Class::[]}(#t261).{core::Object::==}(null) ?{self::Class} #t260.{self::Class::[]=}(#t261, c{self::Class}) : null;
+ c = let final self::Class #t262 = c{self::Class} in #t262.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t263 = #t262.{self::Class::field} in let final self::Class #t264 = c{self::Class} in let final self::Class? #t265 = #t263.{self::Class::[]}(#t264) in #t265.{core::Object::==}(null) ?{self::Class} let final self::Class #t266 = c{self::Class} in let final void #t267 = #t263.{self::Class::[]=}(#t264, #t266) in #t266 : #t265;
}
static method throws(() → void f) → void {
try {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.outline.expect b/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.outline.expect
index 3538ffe..99caa31 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.outline.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class Class extends core::Object {
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
method method() → self::Class
;
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.strong.expect b/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.strong.expect
index d51a286..f45240b 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.strong.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class Class extends core::Object {
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
method method() → self::Class
@@ -19,8 +19,8 @@
return () → self::Class => self::Extension|extensionMethod(#this);
static method main() → dynamic {
self::Class? c;
- let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : let final void #t2 = #t1.{self::Class::method}() in #t1;
- let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class?} null : let final void #t4 = #t3.{self::Class::method}() in let final void #t5 = #t3.{self::Class::method}() in #t3;
- let final self::Class? #t6 = c in #t6.{core::Object::==}(null) ?{self::Class?} null : let final void #t7 = self::Extension|extensionMethod(#t6) in #t6;
- let final self::Class? #t8 = c in #t8.{core::Object::==}(null) ?{self::Class?} null : let final void #t9 = self::Extension|extensionMethod(#t8) in let final void #t10 = self::Extension|extensionMethod(#t8) in #t8;
+ let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : let final void #t2 = #t1{self::Class}.{self::Class::method}() in #t1;
+ let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class?} null : let final void #t4 = #t3{self::Class}.{self::Class::method}() in let final void #t5 = #t3{self::Class}.{self::Class::method}() in #t3;
+ let final self::Class? #t6 = c in #t6.{core::Object::==}(null) ?{self::Class?} null : let final void #t7 = self::Extension|extensionMethod(#t6{self::Class}) in #t6;
+ let final self::Class? #t8 = c in #t8.{core::Object::==}(null) ?{self::Class?} null : let final void #t9 = self::Extension|extensionMethod(#t8{self::Class}) in let final void #t10 = self::Extension|extensionMethod(#t8{self::Class}) in #t8;
}
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.strong.transformed.expect
index d51a286..f45240b 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_cascade.dart.strong.transformed.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class Class extends core::Object {
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
method method() → self::Class
@@ -19,8 +19,8 @@
return () → self::Class => self::Extension|extensionMethod(#this);
static method main() → dynamic {
self::Class? c;
- let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : let final void #t2 = #t1.{self::Class::method}() in #t1;
- let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class?} null : let final void #t4 = #t3.{self::Class::method}() in let final void #t5 = #t3.{self::Class::method}() in #t3;
- let final self::Class? #t6 = c in #t6.{core::Object::==}(null) ?{self::Class?} null : let final void #t7 = self::Extension|extensionMethod(#t6) in #t6;
- let final self::Class? #t8 = c in #t8.{core::Object::==}(null) ?{self::Class?} null : let final void #t9 = self::Extension|extensionMethod(#t8) in let final void #t10 = self::Extension|extensionMethod(#t8) in #t8;
+ let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : let final void #t2 = #t1{self::Class}.{self::Class::method}() in #t1;
+ let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class?} null : let final void #t4 = #t3{self::Class}.{self::Class::method}() in let final void #t5 = #t3{self::Class}.{self::Class::method}() in #t3;
+ let final self::Class? #t6 = c in #t6.{core::Object::==}(null) ?{self::Class?} null : let final void #t7 = self::Extension|extensionMethod(#t6{self::Class}) in #t6;
+ let final self::Class? #t8 = c in #t8.{core::Object::==}(null) ?{self::Class?} null : let final void #t9 = self::Extension|extensionMethod(#t8{self::Class}) in let final void #t10 = self::Extension|extensionMethod(#t8{self::Class}) in #t8;
}
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart b/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart
index 0ea13c5..db507ca 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart
+++ b/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart
@@ -38,11 +38,17 @@
Extension(c)?.method();
Extension(c)?.field.field;
+ Extension(c)?.field?.field;
+ Extension(c)?.field.field?.field;
Extension(c)?.field.field = new Class();
+ Extension(c)?.field?.field = new Class();
+ Extension(c)?.field.field?.field = new Class();
throws(() => (Extension(c)?.field).field);
throws(() => (Extension(c)?.field = new Class()).field);
throws(() => (Extension(c)?.method()).field);
c = Extension(c)?.field.field = new Class();
+ c = Extension(c)?.field?.field = new Class();
+ c = Extension(c)?.field.field?.field = new Class();
Extension(c)?.field.method();
Extension(c)?.field = new Class().field;
c = Extension(c)?.field = new Class().field;
@@ -100,6 +106,11 @@
Extension(c)?.method().method().field;
Extension(c)?.method().method().field = new Class();
Extension(c)?.method().method().method();
+
+ Extension(c)?.method()?.method();
+
+ throws(() => Extension(c?.field).field);
+ Extension(c?.field)?.field;
}
void indexAccess(Class? c) {
@@ -112,12 +123,51 @@
Extension(c)?.field[c].method();
Extension(c)?.field[c] += 0;
c = Extension(c)?.field[c] += 0;
+ Extension(c)?.[c] ??= c;
+ c = Extension(c)?.[c] ??= c;
+ Extension(c)?.[c] += 0;
+ c = Extension(c)?.[c] += 0;
+ Extension(c)?.[c] += 0;
+ c = Extension(c)?.[c] += 0;
// TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
// update.
+ Extension(c)?.[c]++;
+ c = Extension(c)?.[c]++;
+ Extension(c)?.[c];
+ c = ++Extension(c)?.[c];
Extension(c)?.field[c]++;
c = Extension(c)?.field[c]++;
++Extension(c)?.field[c];
c = ++Extension(c)?.field[c];
+
+ Extension(c)?.field[c][c];
+ Extension(c)?.field[c][c] = new Class();
+ c = Extension(c)?.field[c][c] = new Class();
+ Extension(c)?.field[c][c].method();
+ Extension(c)?.field[c][c] += 0;
+ c = Extension(c)?.field[c][c] += 0;
+ // TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
+ // update.
+ Extension(c)?.field[c][c]++;
+ c = Extension(c)?.field[c][c]++;
+ ++Extension(c)?.field[c][c];
+ c = ++Extension(c)?.field[c][c];
+
+ Extension(c)?.[c]?.[c];
+ Extension(c)?.[c]?.[c] = new Class();
+ c = Extension(c)?.[c]?.[c] = new Class();
+ Extension(c)?.[c]?.[c].method();
+ c = Extension(c)?.[c]?.[c].method();
+ Extension(c)?.[c]?.[c] ??= c;
+ c = Extension(c)?.[c]?.[c] ??= c;
+ Extension(c)?.[c]?.[c] += 0;
+ c = Extension(c)?.[c]?.[c] += 0;
+ // TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
+ // update.
+ Extension(c)?.[c]?.[c]++;
+ c = Extension(c)?.[c]?.[c]++;
+ ++Extension(c)?.[c]?.[c];
+ c = ++Extension(c)?.[c]?.[c];
}
void operatorAccess(Class? c) {
@@ -138,7 +188,10 @@
void ifNull(Class? c) {
Extension(c)?.field ??= c;
c = Extension(c)?.field ??= c;
+ Extension(c)?.field.field ??= c;
+ c = Extension(c)?.field.field ??= c;
Extension(c)?.field[c] ??= c;
+ c = Extension(c)?.field[c] ??= c;
}
void throws(void Function() f) {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.outline.expect b/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.outline.expect
index 8a55652..2262232 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.outline.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field self::Class? _field;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
}
extension Extension on self::Class {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.strong.expect b/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.strong.expect
index fc4fcc8..c57069c 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.strong.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field self::Class? _field = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
}
@@ -43,102 +43,147 @@
self::ifNull(null);
}
static method propertyAccess(self::Class? c) → void {
- let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t1);
- let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t2, new self::Class::•());
- c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3, #t4) in #t4;
- let final self::Class? #t6 = c in #t6.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t6);
- let final self::Class? #t7 = c in #t7.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(#t7));
- let final self::Class? #t8 = c in #t8.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t8), new self::Class::•());
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t9 = c in #t9.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t9)));
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t10 = c in #t10.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t11 = new self::Class::•() in let final void #t12 = self::Extension|set#field(#t10, #t11) in #t11));
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t13 = c in #t13.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t13)));
- c = let final self::Class? #t14 = c in #t14.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t15 = new self::Class::•() in let final void #t16 = self::Extension|set#field(self::Extension|get#field(#t14), #t15) in #t15;
- let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(#t17));
- let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t18, self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t19 = c in #t19.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t20 = self::Extension|get#field(new self::Class::•()) in let final void #t21 = self::Extension|set#field(#t19, #t20) in #t20;
- let final self::Class? #t22 = c in #t22.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t22, let final self::Class #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(new self::Class::•(), #t23) in #t23);
- c = let final self::Class? #t25 = c in #t25.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t26 = let final self::Class #t27 = new self::Class::•() in let final void #t28 = self::Extension|set#field(new self::Class::•(), #t27) in #t27 in let final void #t29 = self::Extension|set#field(#t25, #t26) in #t26;
- let final self::Class? #t30 = c in #t30.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t30, self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t31 = c in #t31.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t32 = self::Extension|method(new self::Class::•()) in let final void #t33 = self::Extension|set#field(#t31, #t32) in #t32;
- let final self::Class? #t34 = c in #t34.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(#t34));
- let final self::Class? #t35 = c in #t35.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t35), new self::Class::•());
- let final self::Class? #t36 = c in #t36.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(#t36));
- let final self::Class? #t37 = c in #t37.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|get#field(#t37)));
- let final self::Class? #t38 = c in #t38.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t38)), new self::Class::•());
- c = let final self::Class? #t39 = c in #t39.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t40 = new self::Class::•() in let final void #t41 = self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t39)), #t40) in #t40;
- let final self::Class? #t42 = c in #t42.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|get#field(#t42)));
- let final self::Class? #t43 = c in #t43.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t43, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
- c = let final self::Class? #t44 = c in #t44.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t45 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t46 = self::Extension|set#field(#t44, #t45) in #t45;
- let final self::Class? #t47 = c in #t47.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t47, let final self::Class #t48 = new self::Class::•() in let final void #t49 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t48) in #t48);
- c = let final self::Class? #t50 = c in #t50.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t51 = let final self::Class #t52 = new self::Class::•() in let final void #t53 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t52) in #t52 in let final void #t54 = self::Extension|set#field(#t50, #t51) in #t51;
- let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t55, self::Extension|method(self::Extension|get#field(new self::Class::•())));
- c = let final self::Class? #t56 = c in #t56.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t57 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t58 = self::Extension|set#field(#t56, #t57) in #t57;
- let final self::Class? #t59 = c in #t59.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|method(#t59)));
- let final self::Class? #t60 = c in #t60.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|method(#t60)), new self::Class::•());
- let final self::Class? #t61 = c in #t61.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|method(#t61)));
- let final self::Class? #t62 = c in #t62.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t62), self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t63 = c in #t63.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t64 = self::Extension|get#field(new self::Class::•()) in let final void #t65 = self::Extension|set#field(self::Extension|get#field(#t63), #t64) in #t64;
- let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t66), let final self::Class #t67 = new self::Class::•() in let final void #t68 = self::Extension|set#field(new self::Class::•(), #t67) in #t67);
- c = let final self::Class? #t69 = c in #t69.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t70 = let final self::Class #t71 = new self::Class::•() in let final void #t72 = self::Extension|set#field(new self::Class::•(), #t71) in #t71 in let final void #t73 = self::Extension|set#field(self::Extension|get#field(#t69), #t70) in #t70;
- let final self::Class? #t74 = c in #t74.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t74), self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t76 = self::Extension|method(new self::Class::•()) in let final void #t77 = self::Extension|set#field(self::Extension|get#field(#t75), #t76) in #t76;
- let final self::Class? #t78 = c in #t78.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t78, let final self::Class? #t79 = self::Extension|get#field(new self::Class::•()) in let final void #t80 = self::Extension|set#field(new self::Class::•(), #t79) in #t79);
- c = let final self::Class? #t81 = c in #t81.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t82 = let final self::Class? #t83 = self::Extension|get#field(new self::Class::•()) in let final void #t84 = self::Extension|set#field(new self::Class::•(), #t83) in #t83 in let final void #t85 = self::Extension|set#field(#t81, #t82) in #t82;
- let final self::Class? #t86 = c in #t86.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t86, let final self::Class #t87 = let final self::Class #t88 = new self::Class::•() in let final void #t89 = self::Extension|set#field(new self::Class::•(), #t88) in #t88 in let final void #t90 = self::Extension|set#field(new self::Class::•(), #t87) in #t87);
- c = let final self::Class? #t91 = c in #t91.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t92 = let final self::Class #t93 = let final self::Class #t94 = new self::Class::•() in let final void #t95 = self::Extension|set#field(new self::Class::•(), #t94) in #t94 in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t93) in #t93 in let final void #t97 = self::Extension|set#field(#t91, #t92) in #t92;
- let final self::Class? #t98 = c in #t98.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t98, let final self::Class? #t99 = self::Extension|method(new self::Class::•()) in let final void #t100 = self::Extension|set#field(new self::Class::•(), #t99) in #t99);
- c = let final self::Class? #t101 = c in #t101.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t102 = let final self::Class? #t103 = self::Extension|method(new self::Class::•()) in let final void #t104 = self::Extension|set#field(new self::Class::•(), #t103) in #t103 in let final void #t105 = self::Extension|set#field(#t101, #t102) in #t102;
- let final self::Class? #t106 = c in #t106.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t106), self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t107 = c in #t107.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t108 = self::Extension|get#field(new self::Class::•()) in let final void #t109 = self::Extension|set#field(self::Extension|method(#t107), #t108) in #t108;
- let final self::Class? #t110 = c in #t110.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t110), let final self::Class #t111 = new self::Class::•() in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t111) in #t111);
- c = let final self::Class? #t113 = c in #t113.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t114 = let final self::Class #t115 = new self::Class::•() in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115 in let final void #t117 = self::Extension|set#field(self::Extension|method(#t113), #t114) in #t114;
- let final self::Class? #t118 = c in #t118.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t118), self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t119 = c in #t119.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t120 = self::Extension|method(new self::Class::•()) in let final void #t121 = self::Extension|set#field(self::Extension|method(#t119), #t120) in #t120;
- let final self::Class? #t122 = c in #t122.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|get#field(#t122)));
- let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t123)), new self::Class::•());
- c = let final self::Class? #t124 = c in #t124.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t125 = new self::Class::•() in let final void #t126 = self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t124)), #t125) in #t125;
- let final self::Class? #t127 = c in #t127.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|get#field(#t127)));
- let final self::Class? #t128 = c in #t128.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t128, self::Extension|get#field(self::Extension|method(new self::Class::•())));
- c = let final self::Class? #t129 = c in #t129.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t130 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t131 = self::Extension|set#field(#t129, #t130) in #t130;
- let final self::Class? #t132 = c in #t132.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t132, let final self::Class #t133 = new self::Class::•() in let final void #t134 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t133) in #t133);
- c = let final self::Class? #t135 = c in #t135.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t136 = let final self::Class #t137 = new self::Class::•() in let final void #t138 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t137) in #t137 in let final void #t139 = self::Extension|set#field(#t135, #t136) in #t136;
- let final self::Class? #t140 = c in #t140.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t140, self::Extension|method(self::Extension|method(new self::Class::•())));
- c = let final self::Class? #t141 = c in #t141.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t142 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t143 = self::Extension|set#field(#t141, #t142) in #t142;
- let final self::Class? #t144 = c in #t144.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|method(#t144)));
- let final self::Class? #t145 = c in #t145.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|method(#t145)), new self::Class::•());
- let final self::Class? #t146 = c in #t146.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|method(#t146)));
+ let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t1{self::Class});
+ let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t2{self::Class}, new self::Class::•());
+ c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3{self::Class}, #t4) in #t4;
+ let final self::Class #t6 = c{self::Class} in #t6.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t6);
+ let final self::Class #t7 = c{self::Class} in #t7.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(#t7));
+ let final self::Class #t8 = c{self::Class} in #t8.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t9 = self::Extension|get#field(#t8) in #t9.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t9{self::Class});
+ let final self::Class #t10 = c{self::Class} in #t10.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t11 = self::Extension|get#field(self::Extension|get#field(#t10)) in #t11.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t11{self::Class});
+ let final self::Class #t12 = c{self::Class} in #t12.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t12), new self::Class::•());
+ let final self::Class #t13 = c{self::Class} in #t13.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t14 = self::Extension|get#field(#t13) in #t14.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t14{self::Class}, new self::Class::•());
+ let final self::Class #t15 = c{self::Class} in #t15.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t16 = self::Extension|get#field(self::Extension|get#field(#t15)) in #t16.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t16{self::Class}, new self::Class::•());
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t17{self::Class})));
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t19 = new self::Class::•() in let final void #t20 = self::Extension|set#field(#t18{self::Class}, #t19) in #t19));
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t21 = c in #t21.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t21{self::Class})));
+ c = let final self::Class #t22 = c{self::Class} in #t22.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(self::Extension|get#field(#t22), #t23) in #t23;
+ c = let final self::Class #t25 = c{self::Class} in #t25.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t26 = self::Extension|get#field(#t25) in #t26.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t27 = new self::Class::•() in let final void #t28 = self::Extension|set#field(#t26{self::Class}, #t27) in #t27;
+ c = let final self::Class #t29 = c{self::Class} in #t29.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t30 = self::Extension|get#field(self::Extension|get#field(#t29)) in #t30.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t31 = new self::Class::•() in let final void #t32 = self::Extension|set#field(#t30{self::Class}, #t31) in #t31;
+ let final self::Class #t33 = c{self::Class} in #t33.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(#t33));
+ let final self::Class #t34 = c{self::Class} in #t34.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t34, self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class #t35 = c{self::Class} in #t35.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t36 = self::Extension|get#field(new self::Class::•()) in let final void #t37 = self::Extension|set#field(#t35, #t36) in #t36;
+ let final self::Class? #t38 = c in #t38.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t38{self::Class}, let final self::Class #t39 = new self::Class::•() in let final void #t40 = self::Extension|set#field(new self::Class::•(), #t39) in #t39);
+ c = let final self::Class? #t41 = c in #t41.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t42 = let final self::Class #t43 = new self::Class::•() in let final void #t44 = self::Extension|set#field(new self::Class::•(), #t43) in #t43 in let final void #t45 = self::Extension|set#field(#t41{self::Class}, #t42) in #t42;
+ let final self::Class #t46 = c{self::Class} in #t46.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t46, self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t47 = c{self::Class} in #t47.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t48 = self::Extension|method(new self::Class::•()) in let final void #t49 = self::Extension|set#field(#t47, #t48) in #t48;
+ let final self::Class? #t50 = c in #t50.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(#t50{self::Class}));
+ let final self::Class? #t51 = c in #t51.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t51{self::Class}), new self::Class::•());
+ let final self::Class? #t52 = c in #t52.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(#t52{self::Class}));
+ let final self::Class? #t53 = c in #t53.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|get#field(#t53{self::Class})));
+ let final self::Class? #t54 = c in #t54.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t54{self::Class})), new self::Class::•());
+ c = let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t56 = new self::Class::•() in let final void #t57 = self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t55{self::Class})), #t56) in #t56;
+ let final self::Class #t58 = c{self::Class} in #t58.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|get#field(#t58)));
+ let final self::Class #t59 = c{self::Class} in #t59.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t59, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class #t60 = c{self::Class} in #t60.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t61 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t62 = self::Extension|set#field(#t60, #t61) in #t61;
+ let final self::Class? #t63 = c in #t63.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t63{self::Class}, let final self::Class #t64 = new self::Class::•() in let final void #t65 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t64) in #t64);
+ c = let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t67 = let final self::Class #t68 = new self::Class::•() in let final void #t69 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t68) in #t68 in let final void #t70 = self::Extension|set#field(#t66{self::Class}, #t67) in #t67;
+ let final self::Class #t71 = c{self::Class} in #t71.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t71, self::Extension|method(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class #t72 = c{self::Class} in #t72.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t73 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t74 = self::Extension|set#field(#t72, #t73) in #t73;
+ let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|method(#t75{self::Class})));
+ let final self::Class? #t76 = c in #t76.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|method(#t76{self::Class})), new self::Class::•());
+ let final self::Class? #t77 = c in #t77.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|method(#t77{self::Class})));
+ let final self::Class? #t78 = c in #t78.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t78{self::Class}), self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class? #t79 = c in #t79.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t80 = self::Extension|get#field(new self::Class::•()) in let final void #t81 = self::Extension|set#field(self::Extension|get#field(#t79{self::Class}), #t80) in #t80;
+ let final self::Class? #t82 = c in #t82.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t82{self::Class}), let final self::Class #t83 = new self::Class::•() in let final void #t84 = self::Extension|set#field(new self::Class::•(), #t83) in #t83);
+ c = let final self::Class? #t85 = c in #t85.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t86 = let final self::Class #t87 = new self::Class::•() in let final void #t88 = self::Extension|set#field(new self::Class::•(), #t87) in #t87 in let final void #t89 = self::Extension|set#field(self::Extension|get#field(#t85{self::Class}), #t86) in #t86;
+ let final self::Class #t90 = c{self::Class} in #t90.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t90), self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t91 = c{self::Class} in #t91.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t92 = self::Extension|method(new self::Class::•()) in let final void #t93 = self::Extension|set#field(self::Extension|get#field(#t91), #t92) in #t92;
+ let final self::Class? #t94 = c in #t94.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t94{self::Class}, let final self::Class? #t95 = self::Extension|get#field(new self::Class::•()) in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t95) in #t95);
+ c = let final self::Class? #t97 = c in #t97.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t98 = let final self::Class? #t99 = self::Extension|get#field(new self::Class::•()) in let final void #t100 = self::Extension|set#field(new self::Class::•(), #t99) in #t99 in let final void #t101 = self::Extension|set#field(#t97{self::Class}, #t98) in #t98;
+ let final self::Class? #t102 = c in #t102.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t102{self::Class}, let final self::Class #t103 = let final self::Class #t104 = new self::Class::•() in let final void #t105 = self::Extension|set#field(new self::Class::•(), #t104) in #t104 in let final void #t106 = self::Extension|set#field(new self::Class::•(), #t103) in #t103);
+ c = let final self::Class? #t107 = c in #t107.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t108 = let final self::Class #t109 = let final self::Class #t110 = new self::Class::•() in let final void #t111 = self::Extension|set#field(new self::Class::•(), #t110) in #t110 in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t109) in #t109 in let final void #t113 = self::Extension|set#field(#t107{self::Class}, #t108) in #t108;
+ let final self::Class #t114 = c{self::Class} in #t114.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t114, let final self::Class? #t115 = self::Extension|method(new self::Class::•()) in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115);
+ c = let final self::Class #t117 = c{self::Class} in #t117.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t118 = let final self::Class? #t119 = self::Extension|method(new self::Class::•()) in let final void #t120 = self::Extension|set#field(new self::Class::•(), #t119) in #t119 in let final void #t121 = self::Extension|set#field(#t117, #t118) in #t118;
+ let final self::Class? #t122 = c in #t122.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t122{self::Class}), self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t124 = self::Extension|get#field(new self::Class::•()) in let final void #t125 = self::Extension|set#field(self::Extension|method(#t123{self::Class}), #t124) in #t124;
+ let final self::Class? #t126 = c in #t126.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t126{self::Class}), let final self::Class #t127 = new self::Class::•() in let final void #t128 = self::Extension|set#field(new self::Class::•(), #t127) in #t127);
+ c = let final self::Class? #t129 = c in #t129.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t130 = let final self::Class #t131 = new self::Class::•() in let final void #t132 = self::Extension|set#field(new self::Class::•(), #t131) in #t131 in let final void #t133 = self::Extension|set#field(self::Extension|method(#t129{self::Class}), #t130) in #t130;
+ let final self::Class #t134 = c{self::Class} in #t134.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t134), self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t135 = c{self::Class} in #t135.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t136 = self::Extension|method(new self::Class::•()) in let final void #t137 = self::Extension|set#field(self::Extension|method(#t135), #t136) in #t136;
+ let final self::Class? #t138 = c in #t138.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|get#field(#t138{self::Class})));
+ let final self::Class? #t139 = c in #t139.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t139{self::Class})), new self::Class::•());
+ c = let final self::Class? #t140 = c in #t140.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t141 = new self::Class::•() in let final void #t142 = self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t140{self::Class})), #t141) in #t141;
+ let final self::Class #t143 = c{self::Class} in #t143.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|get#field(#t143)));
+ let final self::Class #t144 = c{self::Class} in #t144.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t144, self::Extension|get#field(self::Extension|method(new self::Class::•())));
+ c = let final self::Class #t145 = c{self::Class} in #t145.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t146 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t147 = self::Extension|set#field(#t145, #t146) in #t146;
+ let final self::Class? #t148 = c in #t148.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t148{self::Class}, let final self::Class #t149 = new self::Class::•() in let final void #t150 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t149) in #t149);
+ c = let final self::Class? #t151 = c in #t151.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t152 = let final self::Class #t153 = new self::Class::•() in let final void #t154 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t153) in #t153 in let final void #t155 = self::Extension|set#field(#t151{self::Class}, #t152) in #t152;
+ let final self::Class #t156 = c{self::Class} in #t156.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t156, self::Extension|method(self::Extension|method(new self::Class::•())));
+ c = let final self::Class #t157 = c{self::Class} in #t157.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t158 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t159 = self::Extension|set#field(#t157, #t158) in #t158;
+ let final self::Class? #t160 = c in #t160.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|method(#t160{self::Class})));
+ let final self::Class? #t161 = c in #t161.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|method(#t161{self::Class})), new self::Class::•());
+ let final self::Class? #t162 = c in #t162.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|method(#t162{self::Class})));
+ let final self::Class? #t163 = c in #t163.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t164 = self::Extension|method(#t163{self::Class}) in #t164.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t164{self::Class});
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t165 = c in #t165.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t165{self::Class})));
+ let final self::Class? #t166 = let final self::Class? #t167 = c in #t167.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t167{self::Class}) in #t166.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t166{self::Class});
}
static method indexAccess(self::Class? c) → void {
- let final self::Class? #t147 = c in #t147.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t147, c);
- let final self::Class? #t148 = c in #t148.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t148, c, new self::Class::•());
- let final self::Class? #t149 = c in #t149.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t149, c));
- let final self::Class? #t150 = c in #t150.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|get#field(#t150), c);
- let final self::Class? #t151 = c in #t151.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|get#field(#t151), c, new self::Class::•());
- c = let final self::Class? #t152 = c in #t152.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t153 = self::Extension|get#field(#t152) in let final self::Class? #t154 = c in let final self::Class #t155 = new self::Class::•() in let final void #t156 = self::Extension|[]=(#t153, #t154, #t155) in #t155;
- let final self::Class? #t157 = c in #t157.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|get#field(#t157), c));
- let final self::Class? #t158 = c in #t158.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t159 = self::Extension|get#field(#t158) in let final self::Class? #t160 = c in self::Extension|[]=(#t159, #t160, self::Extension|+(self::Extension|[](#t159, #t160), 0));
- c = let final self::Class? #t161 = c in #t161.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t162 = self::Extension|get#field(#t161) in let final self::Class? #t163 = c in let final self::Class? #t164 = self::Extension|+(self::Extension|[](#t162, #t163), 0) in let final void #t165 = self::Extension|[]=(#t162, #t163, #t164) in #t164;
- let final self::Class? #t166 = c in #t166.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t167 = self::Extension|get#field(#t166) in let final self::Class? #t168 = c in self::Extension|[]=(#t167, #t168, self::Extension|+(self::Extension|[](#t167, #t168), 1));
- c = let final self::Class? #t169 = c in #t169.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t170 = self::Extension|get#field(#t169) in let final self::Class? #t171 = c in let final self::Class? #t172 = self::Extension|[](#t170, #t171) in let final void #t173 = self::Extension|[]=(#t170, #t171, self::Extension|+(#t172, 1)) in #t172;
- let final self::Class? #t174 = c in #t174.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t175 = self::Extension|get#field(#t174) in let final self::Class? #t176 = c in let final self::Class? #t177 = self::Extension|+(self::Extension|[](#t175, #t176), 1) in let final void #t178 = self::Extension|[]=(#t175, #t176, #t177) in #t177;
- c = let final self::Class? #t179 = c in #t179.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t180 = self::Extension|get#field(#t179) in let final self::Class? #t181 = c in let final self::Class? #t182 = self::Extension|+(self::Extension|[](#t180, #t181), 1) in let final void #t183 = self::Extension|[]=(#t180, #t181, #t182) in #t182;
+ let final self::Class? #t168 = c in #t168.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t168{self::Class}, c{self::Class});
+ let final self::Class? #t169 = c in #t169.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t169{self::Class}, c{self::Class}, new self::Class::•());
+ let final self::Class? #t170 = c in #t170.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t170{self::Class}, c{self::Class}));
+ let final self::Class? #t171 = c in #t171.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|get#field(#t171{self::Class}), c{self::Class});
+ let final self::Class? #t172 = c in #t172.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|get#field(#t172{self::Class}), c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t173 = c in #t173.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t174 = self::Extension|get#field(#t173{self::Class}) in let final self::Class #t175 = c{self::Class} in let final self::Class #t176 = new self::Class::•() in let final void #t177 = self::Extension|[]=(#t174, #t175, #t176) in #t176;
+ let final self::Class #t178 = c{self::Class} in #t178.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|get#field(#t178), c{self::Class}));
+ let final self::Class #t179 = c{self::Class} in #t179.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t180 = self::Extension|get#field(#t179) in let final self::Class #t181 = c{self::Class} in self::Extension|[]=(#t180, #t181, self::Extension|+(self::Extension|[](#t180, #t181), 0));
+ c = let final self::Class #t182 = c{self::Class} in #t182.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t183 = self::Extension|get#field(#t182) in let final self::Class #t184 = c{self::Class} in let final self::Class? #t185 = self::Extension|+(self::Extension|[](#t183, #t184), 0) in let final void #t186 = self::Extension|[]=(#t183, #t184, #t185) in #t185;
+ let final self::Class? #t187 = c in #t187.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t188 = c{self::Class} in self::Extension|[](#t187{self::Class}, #t188).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t187{self::Class}, #t188, c{self::Class}) : null;
+ c = let final self::Class? #t189 = c in #t189.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t190 = c{self::Class} in let final self::Class? #t191 = self::Extension|[](#t189{self::Class}, #t190) in #t191.{core::Object::==}(null) ?{self::Class} let final self::Class #t192 = c{self::Class} in let final void #t193 = self::Extension|[]=(#t189{self::Class}, #t190, #t192) in #t192 : #t191;
+ let final self::Class #t194 = c{self::Class} in #t194.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t195 = c{self::Class} in self::Extension|[]=(#t194, #t195, self::Extension|+(self::Extension|[](#t194, #t195), 0));
+ c = let final self::Class #t196 = c{self::Class} in #t196.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t197 = c{self::Class} in let final self::Class? #t198 = self::Extension|+(self::Extension|[](#t196, #t197), 0) in let final void #t199 = self::Extension|[]=(#t196, #t197, #t198) in #t198;
+ let final self::Class? #t200 = c in #t200.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t201 = c{self::Class} in self::Extension|[]=(#t200{self::Class}, #t201, self::Extension|+(self::Extension|[](#t200{self::Class}, #t201), 0));
+ c = let final self::Class? #t202 = c in #t202.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t203 = c{self::Class} in let final self::Class? #t204 = self::Extension|+(self::Extension|[](#t202{self::Class}, #t203), 0) in let final void #t205 = self::Extension|[]=(#t202{self::Class}, #t203, #t204) in #t204;
+ let final self::Class? #t206 = c in #t206.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t207 = c{self::Class} in self::Extension|[]=(#t206{self::Class}, #t207, self::Extension|+(self::Extension|[](#t206{self::Class}, #t207), 1));
+ c = let final self::Class? #t208 = c in #t208.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t209 = c{self::Class} in let final self::Class? #t210 = self::Extension|[](#t208{self::Class}, #t209) in let final void #t211 = self::Extension|[]=(#t208{self::Class}, #t209, self::Extension|+(#t210, 1)) in #t210;
+ let final self::Class? #t212 = c in #t212.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t212{self::Class}, c{self::Class});
+ c = let final self::Class? #t213 = c in #t213.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t214 = c{self::Class} in let final self::Class? #t215 = self::Extension|+(self::Extension|[](#t213{self::Class}, #t214), 1) in let final void #t216 = self::Extension|[]=(#t213{self::Class}, #t214, #t215) in #t215;
+ let final self::Class? #t217 = c in #t217.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t218 = self::Extension|get#field(#t217{self::Class}) in let final self::Class #t219 = c{self::Class} in self::Extension|[]=(#t218, #t219, self::Extension|+(self::Extension|[](#t218, #t219), 1));
+ c = let final self::Class? #t220 = c in #t220.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t221 = self::Extension|get#field(#t220{self::Class}) in let final self::Class #t222 = c{self::Class} in let final self::Class? #t223 = self::Extension|[](#t221, #t222) in let final void #t224 = self::Extension|[]=(#t221, #t222, self::Extension|+(#t223, 1)) in #t223;
+ let final self::Class? #t225 = c in #t225.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t226 = self::Extension|get#field(#t225{self::Class}) in let final self::Class #t227 = c{self::Class} in let final self::Class? #t228 = self::Extension|+(self::Extension|[](#t226, #t227), 1) in let final void #t229 = self::Extension|[]=(#t226, #t227, #t228) in #t228;
+ c = let final self::Class? #t230 = c in #t230.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t231 = self::Extension|get#field(#t230{self::Class}) in let final self::Class #t232 = c{self::Class} in let final self::Class? #t233 = self::Extension|+(self::Extension|[](#t231, #t232), 1) in let final void #t234 = self::Extension|[]=(#t231, #t232, #t233) in #t233;
+ let final self::Class? #t235 = c in #t235.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|[](self::Extension|get#field(#t235{self::Class}), c{self::Class}), c{self::Class});
+ let final self::Class? #t236 = c in #t236.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|[](self::Extension|get#field(#t236{self::Class}), c{self::Class}), c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t237 = c in #t237.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t238 = self::Extension|[](self::Extension|get#field(#t237{self::Class}), c{self::Class}) in let final self::Class #t239 = c{self::Class} in let final self::Class #t240 = new self::Class::•() in let final void #t241 = self::Extension|[]=(#t238, #t239, #t240) in #t240;
+ let final self::Class #t242 = c{self::Class} in #t242.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|[](self::Extension|get#field(#t242), c{self::Class}), c{self::Class}));
+ let final self::Class #t243 = c{self::Class} in #t243.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t244 = self::Extension|[](self::Extension|get#field(#t243), c{self::Class}) in let final self::Class #t245 = c{self::Class} in self::Extension|[]=(#t244, #t245, self::Extension|+(self::Extension|[](#t244, #t245), 0));
+ c = let final self::Class #t246 = c{self::Class} in #t246.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t247 = self::Extension|[](self::Extension|get#field(#t246), c{self::Class}) in let final self::Class #t248 = c{self::Class} in let final self::Class? #t249 = self::Extension|+(self::Extension|[](#t247, #t248), 0) in let final void #t250 = self::Extension|[]=(#t247, #t248, #t249) in #t249;
+ let final self::Class? #t251 = c in #t251.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t252 = self::Extension|[](self::Extension|get#field(#t251{self::Class}), c{self::Class}) in let final self::Class #t253 = c{self::Class} in self::Extension|[]=(#t252, #t253, self::Extension|+(self::Extension|[](#t252, #t253), 1));
+ c = let final self::Class? #t254 = c in #t254.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t255 = self::Extension|[](self::Extension|get#field(#t254{self::Class}), c{self::Class}) in let final self::Class #t256 = c{self::Class} in let final self::Class? #t257 = self::Extension|[](#t255, #t256) in let final void #t258 = self::Extension|[]=(#t255, #t256, self::Extension|+(#t257, 1)) in #t257;
+ let final self::Class? #t259 = c in #t259.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t260 = self::Extension|[](self::Extension|get#field(#t259{self::Class}), c{self::Class}) in let final self::Class #t261 = c{self::Class} in let final self::Class? #t262 = self::Extension|+(self::Extension|[](#t260, #t261), 1) in let final void #t263 = self::Extension|[]=(#t260, #t261, #t262) in #t262;
+ c = let final self::Class? #t264 = c in #t264.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t265 = self::Extension|[](self::Extension|get#field(#t264{self::Class}), c{self::Class}) in let final self::Class #t266 = c{self::Class} in let final self::Class? #t267 = self::Extension|+(self::Extension|[](#t265, #t266), 1) in let final void #t268 = self::Extension|[]=(#t265, #t266, #t267) in #t267;
+ let final self::Class? #t269 = c in #t269.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t270 = self::Extension|[](#t269{self::Class}, c{self::Class}) in #t270.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t270{self::Class}, c{self::Class});
+ let final self::Class? #t271 = c in #t271.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t272 = self::Extension|[](#t271{self::Class}, c{self::Class}) in #t272.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(#t272{self::Class}, c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t273 = c in #t273.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t274 = self::Extension|[](#t273{self::Class}, c{self::Class}) in #t274.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t275 = c{self::Class} in let final self::Class #t276 = new self::Class::•() in let final void #t277 = self::Extension|[]=(#t274{self::Class}, #t275, #t276) in #t276;
+ let final self::Class #t278 = c{self::Class} in #t278.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t279 = self::Extension|[](#t278, c{self::Class}) in #t279.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t279{self::Class}, c{self::Class}));
+ c = let final self::Class #t280 = c{self::Class} in #t280.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t281 = self::Extension|[](#t280, c{self::Class}) in #t281.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t281{self::Class}, c{self::Class}));
+ let final self::Class? #t282 = c in #t282.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t283 = self::Extension|[](#t282{self::Class}, c{self::Class}) in #t283.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t284 = c{self::Class} in self::Extension|[](#t283{self::Class}, #t284).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t283{self::Class}, #t284, c{self::Class}) : null;
+ c = let final self::Class? #t285 = c in #t285.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t286 = self::Extension|[](#t285{self::Class}, c{self::Class}) in #t286.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t287 = c{self::Class} in let final self::Class? #t288 = self::Extension|[](#t286{self::Class}, #t287) in #t288.{core::Object::==}(null) ?{self::Class} let final self::Class #t289 = c{self::Class} in let final void #t290 = self::Extension|[]=(#t286{self::Class}, #t287, #t289) in #t289 : #t288;
+ let final self::Class #t291 = c{self::Class} in #t291.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t292 = self::Extension|[](#t291, c{self::Class}) in #t292.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t293 = c{self::Class} in self::Extension|[]=(#t292{self::Class}, #t293, self::Extension|+(self::Extension|[](#t292{self::Class}, #t293), 0));
+ c = let final self::Class #t294 = c{self::Class} in #t294.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t295 = self::Extension|[](#t294, c{self::Class}) in #t295.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t296 = c{self::Class} in let final self::Class? #t297 = self::Extension|+(self::Extension|[](#t295{self::Class}, #t296), 0) in let final void #t298 = self::Extension|[]=(#t295{self::Class}, #t296, #t297) in #t297;
+ let final self::Class? #t299 = c in #t299.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t300 = self::Extension|[](#t299{self::Class}, c{self::Class}) in #t300.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t301 = c{self::Class} in self::Extension|[]=(#t300{self::Class}, #t301, self::Extension|+(self::Extension|[](#t300{self::Class}, #t301), 1));
+ c = let final self::Class? #t302 = c in #t302.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t303 = self::Extension|[](#t302{self::Class}, c{self::Class}) in #t303.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t304 = c{self::Class} in let final self::Class? #t305 = self::Extension|[](#t303{self::Class}, #t304) in let final void #t306 = self::Extension|[]=(#t303{self::Class}, #t304, self::Extension|+(#t305, 1)) in #t305;
+ let final self::Class? #t307 = c in #t307.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t308 = self::Extension|[](#t307{self::Class}, c{self::Class}) in #t308.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t309 = c{self::Class} in let final self::Class? #t310 = self::Extension|+(self::Extension|[](#t308{self::Class}, #t309), 1) in let final void #t311 = self::Extension|[]=(#t308{self::Class}, #t309, #t310) in #t310;
+ c = let final self::Class? #t312 = c in #t312.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t313 = self::Extension|[](#t312{self::Class}, c{self::Class}) in #t313.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t314 = c{self::Class} in let final self::Class? #t315 = self::Extension|+(self::Extension|[](#t313{self::Class}, #t314), 1) in let final void #t316 = self::Extension|[]=(#t313{self::Class}, #t314, #t315) in #t315;
}
static method operatorAccess(self::Class? c) → void {
- self::throws(() → self::Class? => self::Extension|+(let final self::Class? #t184 = c in #t184.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t184), 0));
- self::throws(() → self::Class? => self::Extension|unary-(let final self::Class? #t185 = c in #t185.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t185)));
- let final self::Class? #t186 = c in #t186.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t186, self::Extension|+(self::Extension|get#field(#t186), 0));
- c = let final self::Class? #t187 = c in #t187.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t188 = self::Extension|+(self::Extension|get#field(#t187), 0) in let final void #t189 = self::Extension|set#field(#t187, #t188) in #t188;
- let final self::Class? #t190 = c in #t190.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t191 = self::Extension|get#field(#t190) in self::Extension|set#field(#t191, self::Extension|+(self::Extension|get#field(#t191), 0));
- c = let final self::Class? #t192 = c in #t192.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t193 = self::Extension|get#field(#t192) in let final self::Class? #t194 = self::Extension|+(self::Extension|get#field(#t193), 0) in let final void #t195 = self::Extension|set#field(#t193, #t194) in #t194;
- let final self::Class? #t196 = c in #t196.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t196, self::Extension|+(self::Extension|get#field(#t196), 1));
- c = let final self::Class? #t197 = c in #t197.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t198 = self::Extension|get#field(#t197) in let final self::Class? #t199 = let final self::Class? #t200 = self::Extension|+(#t198, 1) in let final void #t201 = self::Extension|set#field(#t197, #t200) in #t200 in #t198;
- let final self::Class? #t202 = c in #t202.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t203 = self::Extension|+(self::Extension|get#field(#t202), 1) in let final void #t204 = self::Extension|set#field(#t202, #t203) in #t203;
- c = let final self::Class? #t205 = c in #t205.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t206 = self::Extension|+(self::Extension|get#field(#t205), 1) in let final void #t207 = self::Extension|set#field(#t205, #t206) in #t206;
+ self::throws(() → self::Class? => self::Extension|+(let final self::Class? #t317 = c in #t317.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t317{self::Class}), 0));
+ self::throws(() → self::Class? => self::Extension|unary-(let final self::Class? #t318 = c in #t318.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t318{self::Class})));
+ let final self::Class? #t319 = c in #t319.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t319{self::Class}, self::Extension|+(self::Extension|get#field(#t319{self::Class}), 0));
+ c = let final self::Class? #t320 = c in #t320.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t321 = self::Extension|+(self::Extension|get#field(#t320{self::Class}), 0) in let final void #t322 = self::Extension|set#field(#t320{self::Class}, #t321) in #t321;
+ let final self::Class? #t323 = c in #t323.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t324 = self::Extension|get#field(#t323{self::Class}) in self::Extension|set#field(#t324, self::Extension|+(self::Extension|get#field(#t324), 0));
+ c = let final self::Class? #t325 = c in #t325.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t326 = self::Extension|get#field(#t325{self::Class}) in let final self::Class? #t327 = self::Extension|+(self::Extension|get#field(#t326), 0) in let final void #t328 = self::Extension|set#field(#t326, #t327) in #t327;
+ let final self::Class? #t329 = c in #t329.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t329{self::Class}, self::Extension|+(self::Extension|get#field(#t329{self::Class}), 1));
+ c = let final self::Class? #t330 = c in #t330.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t331 = self::Extension|get#field(#t330{self::Class}) in let final self::Class? #t332 = let final self::Class? #t333 = self::Extension|+(#t331, 1) in let final void #t334 = self::Extension|set#field(#t330{self::Class}, #t333) in #t333 in #t331;
+ let final self::Class? #t335 = c in #t335.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t336 = self::Extension|+(self::Extension|get#field(#t335{self::Class}), 1) in let final void #t337 = self::Extension|set#field(#t335{self::Class}, #t336) in #t336;
+ c = let final self::Class? #t338 = c in #t338.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t339 = self::Extension|+(self::Extension|get#field(#t338{self::Class}), 1) in let final void #t340 = self::Extension|set#field(#t338{self::Class}, #t339) in #t339;
}
static method ifNull(self::Class? c) → void {
- let final self::Class? #t208 = c in #t208.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t208).{core::Object::==}(null) ?{self::Class?} self::Extension|set#field(#t208, c) : null;
- c = let final self::Class? #t209 = c in #t209.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t210 = self::Extension|get#field(#t209) in #t210.{core::Object::==}(null) ?{self::Class?} let final self::Class? #t211 = c in let final void #t212 = self::Extension|set#field(#t209, #t211) in #t211 : #t210;
- let final self::Class? #t213 = c in #t213.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t214 = self::Extension|get#field(#t213) in let final self::Class? #t215 = c in self::Extension|[](#t214, #t215).{core::Object::==}(null) ?{self::Class?} self::Extension|[]=(#t214, #t215, c) : null;
+ let final self::Class? #t341 = c in #t341.{core::Object::==}(null) ?{self::Class} null : self::Extension|get#field(#t341{self::Class}).{core::Object::==}(null) ?{self::Class} self::Extension|set#field(#t341{self::Class}, c{self::Class}) : null;
+ c = let final self::Class? #t342 = c in #t342.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t343 = self::Extension|get#field(#t342{self::Class}) in #t343.{core::Object::==}(null) ?{self::Class} let final self::Class #t344 = c{self::Class} in let final void #t345 = self::Extension|set#field(#t342{self::Class}, #t344) in #t344 : #t343;
+ let final self::Class #t346 = c{self::Class} in #t346.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t347 = self::Extension|get#field(#t346) in self::Extension|get#field(#t347).{core::Object::==}(null) ?{self::Class} self::Extension|set#field(#t347, c{self::Class}) : null;
+ c = let final self::Class #t348 = c{self::Class} in #t348.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t349 = self::Extension|get#field(#t348) in let final self::Class? #t350 = self::Extension|get#field(#t349) in #t350.{core::Object::==}(null) ?{self::Class} let final self::Class #t351 = c{self::Class} in let final void #t352 = self::Extension|set#field(#t349, #t351) in #t351 : #t350;
+ let final self::Class #t353 = c{self::Class} in #t353.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t354 = self::Extension|get#field(#t353) in let final self::Class #t355 = c{self::Class} in self::Extension|[](#t354, #t355).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t354, #t355, c{self::Class}) : null;
+ c = let final self::Class #t356 = c{self::Class} in #t356.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t357 = self::Extension|get#field(#t356) in let final self::Class #t358 = c{self::Class} in let final self::Class? #t359 = self::Extension|[](#t357, #t358) in #t359.{core::Object::==}(null) ?{self::Class} let final self::Class #t360 = c{self::Class} in let final void #t361 = self::Extension|[]=(#t357, #t358, #t360) in #t360 : #t359;
}
static method throws(() → void f) → void {
try {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.strong.transformed.expect
index fc4fcc8..c57069c 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_explicit_extension.dart.strong.transformed.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field self::Class? _field = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
}
@@ -43,102 +43,147 @@
self::ifNull(null);
}
static method propertyAccess(self::Class? c) → void {
- let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t1);
- let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t2, new self::Class::•());
- c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3, #t4) in #t4;
- let final self::Class? #t6 = c in #t6.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t6);
- let final self::Class? #t7 = c in #t7.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(#t7));
- let final self::Class? #t8 = c in #t8.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t8), new self::Class::•());
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t9 = c in #t9.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t9)));
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t10 = c in #t10.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t11 = new self::Class::•() in let final void #t12 = self::Extension|set#field(#t10, #t11) in #t11));
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t13 = c in #t13.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t13)));
- c = let final self::Class? #t14 = c in #t14.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t15 = new self::Class::•() in let final void #t16 = self::Extension|set#field(self::Extension|get#field(#t14), #t15) in #t15;
- let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(#t17));
- let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t18, self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t19 = c in #t19.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t20 = self::Extension|get#field(new self::Class::•()) in let final void #t21 = self::Extension|set#field(#t19, #t20) in #t20;
- let final self::Class? #t22 = c in #t22.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t22, let final self::Class #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(new self::Class::•(), #t23) in #t23);
- c = let final self::Class? #t25 = c in #t25.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t26 = let final self::Class #t27 = new self::Class::•() in let final void #t28 = self::Extension|set#field(new self::Class::•(), #t27) in #t27 in let final void #t29 = self::Extension|set#field(#t25, #t26) in #t26;
- let final self::Class? #t30 = c in #t30.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t30, self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t31 = c in #t31.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t32 = self::Extension|method(new self::Class::•()) in let final void #t33 = self::Extension|set#field(#t31, #t32) in #t32;
- let final self::Class? #t34 = c in #t34.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(#t34));
- let final self::Class? #t35 = c in #t35.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t35), new self::Class::•());
- let final self::Class? #t36 = c in #t36.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(#t36));
- let final self::Class? #t37 = c in #t37.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|get#field(#t37)));
- let final self::Class? #t38 = c in #t38.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t38)), new self::Class::•());
- c = let final self::Class? #t39 = c in #t39.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t40 = new self::Class::•() in let final void #t41 = self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t39)), #t40) in #t40;
- let final self::Class? #t42 = c in #t42.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|get#field(#t42)));
- let final self::Class? #t43 = c in #t43.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t43, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
- c = let final self::Class? #t44 = c in #t44.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t45 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t46 = self::Extension|set#field(#t44, #t45) in #t45;
- let final self::Class? #t47 = c in #t47.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t47, let final self::Class #t48 = new self::Class::•() in let final void #t49 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t48) in #t48);
- c = let final self::Class? #t50 = c in #t50.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t51 = let final self::Class #t52 = new self::Class::•() in let final void #t53 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t52) in #t52 in let final void #t54 = self::Extension|set#field(#t50, #t51) in #t51;
- let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t55, self::Extension|method(self::Extension|get#field(new self::Class::•())));
- c = let final self::Class? #t56 = c in #t56.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t57 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t58 = self::Extension|set#field(#t56, #t57) in #t57;
- let final self::Class? #t59 = c in #t59.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|method(#t59)));
- let final self::Class? #t60 = c in #t60.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|method(#t60)), new self::Class::•());
- let final self::Class? #t61 = c in #t61.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|method(#t61)));
- let final self::Class? #t62 = c in #t62.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t62), self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t63 = c in #t63.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t64 = self::Extension|get#field(new self::Class::•()) in let final void #t65 = self::Extension|set#field(self::Extension|get#field(#t63), #t64) in #t64;
- let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t66), let final self::Class #t67 = new self::Class::•() in let final void #t68 = self::Extension|set#field(new self::Class::•(), #t67) in #t67);
- c = let final self::Class? #t69 = c in #t69.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t70 = let final self::Class #t71 = new self::Class::•() in let final void #t72 = self::Extension|set#field(new self::Class::•(), #t71) in #t71 in let final void #t73 = self::Extension|set#field(self::Extension|get#field(#t69), #t70) in #t70;
- let final self::Class? #t74 = c in #t74.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t74), self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t76 = self::Extension|method(new self::Class::•()) in let final void #t77 = self::Extension|set#field(self::Extension|get#field(#t75), #t76) in #t76;
- let final self::Class? #t78 = c in #t78.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t78, let final self::Class? #t79 = self::Extension|get#field(new self::Class::•()) in let final void #t80 = self::Extension|set#field(new self::Class::•(), #t79) in #t79);
- c = let final self::Class? #t81 = c in #t81.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t82 = let final self::Class? #t83 = self::Extension|get#field(new self::Class::•()) in let final void #t84 = self::Extension|set#field(new self::Class::•(), #t83) in #t83 in let final void #t85 = self::Extension|set#field(#t81, #t82) in #t82;
- let final self::Class? #t86 = c in #t86.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t86, let final self::Class #t87 = let final self::Class #t88 = new self::Class::•() in let final void #t89 = self::Extension|set#field(new self::Class::•(), #t88) in #t88 in let final void #t90 = self::Extension|set#field(new self::Class::•(), #t87) in #t87);
- c = let final self::Class? #t91 = c in #t91.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t92 = let final self::Class #t93 = let final self::Class #t94 = new self::Class::•() in let final void #t95 = self::Extension|set#field(new self::Class::•(), #t94) in #t94 in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t93) in #t93 in let final void #t97 = self::Extension|set#field(#t91, #t92) in #t92;
- let final self::Class? #t98 = c in #t98.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t98, let final self::Class? #t99 = self::Extension|method(new self::Class::•()) in let final void #t100 = self::Extension|set#field(new self::Class::•(), #t99) in #t99);
- c = let final self::Class? #t101 = c in #t101.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t102 = let final self::Class? #t103 = self::Extension|method(new self::Class::•()) in let final void #t104 = self::Extension|set#field(new self::Class::•(), #t103) in #t103 in let final void #t105 = self::Extension|set#field(#t101, #t102) in #t102;
- let final self::Class? #t106 = c in #t106.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t106), self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t107 = c in #t107.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t108 = self::Extension|get#field(new self::Class::•()) in let final void #t109 = self::Extension|set#field(self::Extension|method(#t107), #t108) in #t108;
- let final self::Class? #t110 = c in #t110.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t110), let final self::Class #t111 = new self::Class::•() in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t111) in #t111);
- c = let final self::Class? #t113 = c in #t113.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t114 = let final self::Class #t115 = new self::Class::•() in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115 in let final void #t117 = self::Extension|set#field(self::Extension|method(#t113), #t114) in #t114;
- let final self::Class? #t118 = c in #t118.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t118), self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t119 = c in #t119.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t120 = self::Extension|method(new self::Class::•()) in let final void #t121 = self::Extension|set#field(self::Extension|method(#t119), #t120) in #t120;
- let final self::Class? #t122 = c in #t122.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|get#field(#t122)));
- let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t123)), new self::Class::•());
- c = let final self::Class? #t124 = c in #t124.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t125 = new self::Class::•() in let final void #t126 = self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t124)), #t125) in #t125;
- let final self::Class? #t127 = c in #t127.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|get#field(#t127)));
- let final self::Class? #t128 = c in #t128.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t128, self::Extension|get#field(self::Extension|method(new self::Class::•())));
- c = let final self::Class? #t129 = c in #t129.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t130 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t131 = self::Extension|set#field(#t129, #t130) in #t130;
- let final self::Class? #t132 = c in #t132.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t132, let final self::Class #t133 = new self::Class::•() in let final void #t134 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t133) in #t133);
- c = let final self::Class? #t135 = c in #t135.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t136 = let final self::Class #t137 = new self::Class::•() in let final void #t138 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t137) in #t137 in let final void #t139 = self::Extension|set#field(#t135, #t136) in #t136;
- let final self::Class? #t140 = c in #t140.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t140, self::Extension|method(self::Extension|method(new self::Class::•())));
- c = let final self::Class? #t141 = c in #t141.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t142 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t143 = self::Extension|set#field(#t141, #t142) in #t142;
- let final self::Class? #t144 = c in #t144.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|method(#t144)));
- let final self::Class? #t145 = c in #t145.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|method(#t145)), new self::Class::•());
- let final self::Class? #t146 = c in #t146.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|method(#t146)));
+ let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t1{self::Class});
+ let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t2{self::Class}, new self::Class::•());
+ c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3{self::Class}, #t4) in #t4;
+ let final self::Class #t6 = c{self::Class} in #t6.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t6);
+ let final self::Class #t7 = c{self::Class} in #t7.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(#t7));
+ let final self::Class #t8 = c{self::Class} in #t8.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t9 = self::Extension|get#field(#t8) in #t9.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t9{self::Class});
+ let final self::Class #t10 = c{self::Class} in #t10.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t11 = self::Extension|get#field(self::Extension|get#field(#t10)) in #t11.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t11{self::Class});
+ let final self::Class #t12 = c{self::Class} in #t12.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t12), new self::Class::•());
+ let final self::Class #t13 = c{self::Class} in #t13.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t14 = self::Extension|get#field(#t13) in #t14.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t14{self::Class}, new self::Class::•());
+ let final self::Class #t15 = c{self::Class} in #t15.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t16 = self::Extension|get#field(self::Extension|get#field(#t15)) in #t16.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t16{self::Class}, new self::Class::•());
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t17{self::Class})));
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t19 = new self::Class::•() in let final void #t20 = self::Extension|set#field(#t18{self::Class}, #t19) in #t19));
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t21 = c in #t21.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t21{self::Class})));
+ c = let final self::Class #t22 = c{self::Class} in #t22.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(self::Extension|get#field(#t22), #t23) in #t23;
+ c = let final self::Class #t25 = c{self::Class} in #t25.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t26 = self::Extension|get#field(#t25) in #t26.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t27 = new self::Class::•() in let final void #t28 = self::Extension|set#field(#t26{self::Class}, #t27) in #t27;
+ c = let final self::Class #t29 = c{self::Class} in #t29.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t30 = self::Extension|get#field(self::Extension|get#field(#t29)) in #t30.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t31 = new self::Class::•() in let final void #t32 = self::Extension|set#field(#t30{self::Class}, #t31) in #t31;
+ let final self::Class #t33 = c{self::Class} in #t33.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(#t33));
+ let final self::Class #t34 = c{self::Class} in #t34.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t34, self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class #t35 = c{self::Class} in #t35.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t36 = self::Extension|get#field(new self::Class::•()) in let final void #t37 = self::Extension|set#field(#t35, #t36) in #t36;
+ let final self::Class? #t38 = c in #t38.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t38{self::Class}, let final self::Class #t39 = new self::Class::•() in let final void #t40 = self::Extension|set#field(new self::Class::•(), #t39) in #t39);
+ c = let final self::Class? #t41 = c in #t41.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t42 = let final self::Class #t43 = new self::Class::•() in let final void #t44 = self::Extension|set#field(new self::Class::•(), #t43) in #t43 in let final void #t45 = self::Extension|set#field(#t41{self::Class}, #t42) in #t42;
+ let final self::Class #t46 = c{self::Class} in #t46.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t46, self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t47 = c{self::Class} in #t47.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t48 = self::Extension|method(new self::Class::•()) in let final void #t49 = self::Extension|set#field(#t47, #t48) in #t48;
+ let final self::Class? #t50 = c in #t50.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(#t50{self::Class}));
+ let final self::Class? #t51 = c in #t51.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t51{self::Class}), new self::Class::•());
+ let final self::Class? #t52 = c in #t52.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(#t52{self::Class}));
+ let final self::Class? #t53 = c in #t53.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|get#field(#t53{self::Class})));
+ let final self::Class? #t54 = c in #t54.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t54{self::Class})), new self::Class::•());
+ c = let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t56 = new self::Class::•() in let final void #t57 = self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t55{self::Class})), #t56) in #t56;
+ let final self::Class #t58 = c{self::Class} in #t58.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|get#field(#t58)));
+ let final self::Class #t59 = c{self::Class} in #t59.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t59, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class #t60 = c{self::Class} in #t60.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t61 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t62 = self::Extension|set#field(#t60, #t61) in #t61;
+ let final self::Class? #t63 = c in #t63.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t63{self::Class}, let final self::Class #t64 = new self::Class::•() in let final void #t65 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t64) in #t64);
+ c = let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t67 = let final self::Class #t68 = new self::Class::•() in let final void #t69 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t68) in #t68 in let final void #t70 = self::Extension|set#field(#t66{self::Class}, #t67) in #t67;
+ let final self::Class #t71 = c{self::Class} in #t71.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t71, self::Extension|method(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class #t72 = c{self::Class} in #t72.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t73 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t74 = self::Extension|set#field(#t72, #t73) in #t73;
+ let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|method(#t75{self::Class})));
+ let final self::Class? #t76 = c in #t76.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|method(#t76{self::Class})), new self::Class::•());
+ let final self::Class? #t77 = c in #t77.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|method(#t77{self::Class})));
+ let final self::Class? #t78 = c in #t78.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t78{self::Class}), self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class? #t79 = c in #t79.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t80 = self::Extension|get#field(new self::Class::•()) in let final void #t81 = self::Extension|set#field(self::Extension|get#field(#t79{self::Class}), #t80) in #t80;
+ let final self::Class? #t82 = c in #t82.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t82{self::Class}), let final self::Class #t83 = new self::Class::•() in let final void #t84 = self::Extension|set#field(new self::Class::•(), #t83) in #t83);
+ c = let final self::Class? #t85 = c in #t85.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t86 = let final self::Class #t87 = new self::Class::•() in let final void #t88 = self::Extension|set#field(new self::Class::•(), #t87) in #t87 in let final void #t89 = self::Extension|set#field(self::Extension|get#field(#t85{self::Class}), #t86) in #t86;
+ let final self::Class #t90 = c{self::Class} in #t90.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t90), self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t91 = c{self::Class} in #t91.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t92 = self::Extension|method(new self::Class::•()) in let final void #t93 = self::Extension|set#field(self::Extension|get#field(#t91), #t92) in #t92;
+ let final self::Class? #t94 = c in #t94.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t94{self::Class}, let final self::Class? #t95 = self::Extension|get#field(new self::Class::•()) in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t95) in #t95);
+ c = let final self::Class? #t97 = c in #t97.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t98 = let final self::Class? #t99 = self::Extension|get#field(new self::Class::•()) in let final void #t100 = self::Extension|set#field(new self::Class::•(), #t99) in #t99 in let final void #t101 = self::Extension|set#field(#t97{self::Class}, #t98) in #t98;
+ let final self::Class? #t102 = c in #t102.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t102{self::Class}, let final self::Class #t103 = let final self::Class #t104 = new self::Class::•() in let final void #t105 = self::Extension|set#field(new self::Class::•(), #t104) in #t104 in let final void #t106 = self::Extension|set#field(new self::Class::•(), #t103) in #t103);
+ c = let final self::Class? #t107 = c in #t107.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t108 = let final self::Class #t109 = let final self::Class #t110 = new self::Class::•() in let final void #t111 = self::Extension|set#field(new self::Class::•(), #t110) in #t110 in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t109) in #t109 in let final void #t113 = self::Extension|set#field(#t107{self::Class}, #t108) in #t108;
+ let final self::Class #t114 = c{self::Class} in #t114.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t114, let final self::Class? #t115 = self::Extension|method(new self::Class::•()) in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115);
+ c = let final self::Class #t117 = c{self::Class} in #t117.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t118 = let final self::Class? #t119 = self::Extension|method(new self::Class::•()) in let final void #t120 = self::Extension|set#field(new self::Class::•(), #t119) in #t119 in let final void #t121 = self::Extension|set#field(#t117, #t118) in #t118;
+ let final self::Class? #t122 = c in #t122.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t122{self::Class}), self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t124 = self::Extension|get#field(new self::Class::•()) in let final void #t125 = self::Extension|set#field(self::Extension|method(#t123{self::Class}), #t124) in #t124;
+ let final self::Class? #t126 = c in #t126.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t126{self::Class}), let final self::Class #t127 = new self::Class::•() in let final void #t128 = self::Extension|set#field(new self::Class::•(), #t127) in #t127);
+ c = let final self::Class? #t129 = c in #t129.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t130 = let final self::Class #t131 = new self::Class::•() in let final void #t132 = self::Extension|set#field(new self::Class::•(), #t131) in #t131 in let final void #t133 = self::Extension|set#field(self::Extension|method(#t129{self::Class}), #t130) in #t130;
+ let final self::Class #t134 = c{self::Class} in #t134.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t134), self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t135 = c{self::Class} in #t135.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t136 = self::Extension|method(new self::Class::•()) in let final void #t137 = self::Extension|set#field(self::Extension|method(#t135), #t136) in #t136;
+ let final self::Class? #t138 = c in #t138.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|get#field(#t138{self::Class})));
+ let final self::Class? #t139 = c in #t139.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t139{self::Class})), new self::Class::•());
+ c = let final self::Class? #t140 = c in #t140.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t141 = new self::Class::•() in let final void #t142 = self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t140{self::Class})), #t141) in #t141;
+ let final self::Class #t143 = c{self::Class} in #t143.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|get#field(#t143)));
+ let final self::Class #t144 = c{self::Class} in #t144.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t144, self::Extension|get#field(self::Extension|method(new self::Class::•())));
+ c = let final self::Class #t145 = c{self::Class} in #t145.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t146 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t147 = self::Extension|set#field(#t145, #t146) in #t146;
+ let final self::Class? #t148 = c in #t148.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t148{self::Class}, let final self::Class #t149 = new self::Class::•() in let final void #t150 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t149) in #t149);
+ c = let final self::Class? #t151 = c in #t151.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t152 = let final self::Class #t153 = new self::Class::•() in let final void #t154 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t153) in #t153 in let final void #t155 = self::Extension|set#field(#t151{self::Class}, #t152) in #t152;
+ let final self::Class #t156 = c{self::Class} in #t156.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t156, self::Extension|method(self::Extension|method(new self::Class::•())));
+ c = let final self::Class #t157 = c{self::Class} in #t157.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t158 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t159 = self::Extension|set#field(#t157, #t158) in #t158;
+ let final self::Class? #t160 = c in #t160.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|method(#t160{self::Class})));
+ let final self::Class? #t161 = c in #t161.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|method(#t161{self::Class})), new self::Class::•());
+ let final self::Class? #t162 = c in #t162.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|method(#t162{self::Class})));
+ let final self::Class? #t163 = c in #t163.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t164 = self::Extension|method(#t163{self::Class}) in #t164.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t164{self::Class});
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t165 = c in #t165.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t165{self::Class})));
+ let final self::Class? #t166 = let final self::Class? #t167 = c in #t167.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t167{self::Class}) in #t166.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t166{self::Class});
}
static method indexAccess(self::Class? c) → void {
- let final self::Class? #t147 = c in #t147.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t147, c);
- let final self::Class? #t148 = c in #t148.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t148, c, new self::Class::•());
- let final self::Class? #t149 = c in #t149.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t149, c));
- let final self::Class? #t150 = c in #t150.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|get#field(#t150), c);
- let final self::Class? #t151 = c in #t151.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|get#field(#t151), c, new self::Class::•());
- c = let final self::Class? #t152 = c in #t152.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t153 = self::Extension|get#field(#t152) in let final self::Class? #t154 = c in let final self::Class #t155 = new self::Class::•() in let final void #t156 = self::Extension|[]=(#t153, #t154, #t155) in #t155;
- let final self::Class? #t157 = c in #t157.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|get#field(#t157), c));
- let final self::Class? #t158 = c in #t158.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t159 = self::Extension|get#field(#t158) in let final self::Class? #t160 = c in self::Extension|[]=(#t159, #t160, self::Extension|+(self::Extension|[](#t159, #t160), 0));
- c = let final self::Class? #t161 = c in #t161.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t162 = self::Extension|get#field(#t161) in let final self::Class? #t163 = c in let final self::Class? #t164 = self::Extension|+(self::Extension|[](#t162, #t163), 0) in let final void #t165 = self::Extension|[]=(#t162, #t163, #t164) in #t164;
- let final self::Class? #t166 = c in #t166.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t167 = self::Extension|get#field(#t166) in let final self::Class? #t168 = c in self::Extension|[]=(#t167, #t168, self::Extension|+(self::Extension|[](#t167, #t168), 1));
- c = let final self::Class? #t169 = c in #t169.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t170 = self::Extension|get#field(#t169) in let final self::Class? #t171 = c in let final self::Class? #t172 = self::Extension|[](#t170, #t171) in let final void #t173 = self::Extension|[]=(#t170, #t171, self::Extension|+(#t172, 1)) in #t172;
- let final self::Class? #t174 = c in #t174.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t175 = self::Extension|get#field(#t174) in let final self::Class? #t176 = c in let final self::Class? #t177 = self::Extension|+(self::Extension|[](#t175, #t176), 1) in let final void #t178 = self::Extension|[]=(#t175, #t176, #t177) in #t177;
- c = let final self::Class? #t179 = c in #t179.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t180 = self::Extension|get#field(#t179) in let final self::Class? #t181 = c in let final self::Class? #t182 = self::Extension|+(self::Extension|[](#t180, #t181), 1) in let final void #t183 = self::Extension|[]=(#t180, #t181, #t182) in #t182;
+ let final self::Class? #t168 = c in #t168.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t168{self::Class}, c{self::Class});
+ let final self::Class? #t169 = c in #t169.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t169{self::Class}, c{self::Class}, new self::Class::•());
+ let final self::Class? #t170 = c in #t170.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t170{self::Class}, c{self::Class}));
+ let final self::Class? #t171 = c in #t171.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|get#field(#t171{self::Class}), c{self::Class});
+ let final self::Class? #t172 = c in #t172.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|get#field(#t172{self::Class}), c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t173 = c in #t173.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t174 = self::Extension|get#field(#t173{self::Class}) in let final self::Class #t175 = c{self::Class} in let final self::Class #t176 = new self::Class::•() in let final void #t177 = self::Extension|[]=(#t174, #t175, #t176) in #t176;
+ let final self::Class #t178 = c{self::Class} in #t178.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|get#field(#t178), c{self::Class}));
+ let final self::Class #t179 = c{self::Class} in #t179.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t180 = self::Extension|get#field(#t179) in let final self::Class #t181 = c{self::Class} in self::Extension|[]=(#t180, #t181, self::Extension|+(self::Extension|[](#t180, #t181), 0));
+ c = let final self::Class #t182 = c{self::Class} in #t182.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t183 = self::Extension|get#field(#t182) in let final self::Class #t184 = c{self::Class} in let final self::Class? #t185 = self::Extension|+(self::Extension|[](#t183, #t184), 0) in let final void #t186 = self::Extension|[]=(#t183, #t184, #t185) in #t185;
+ let final self::Class? #t187 = c in #t187.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t188 = c{self::Class} in self::Extension|[](#t187{self::Class}, #t188).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t187{self::Class}, #t188, c{self::Class}) : null;
+ c = let final self::Class? #t189 = c in #t189.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t190 = c{self::Class} in let final self::Class? #t191 = self::Extension|[](#t189{self::Class}, #t190) in #t191.{core::Object::==}(null) ?{self::Class} let final self::Class #t192 = c{self::Class} in let final void #t193 = self::Extension|[]=(#t189{self::Class}, #t190, #t192) in #t192 : #t191;
+ let final self::Class #t194 = c{self::Class} in #t194.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t195 = c{self::Class} in self::Extension|[]=(#t194, #t195, self::Extension|+(self::Extension|[](#t194, #t195), 0));
+ c = let final self::Class #t196 = c{self::Class} in #t196.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t197 = c{self::Class} in let final self::Class? #t198 = self::Extension|+(self::Extension|[](#t196, #t197), 0) in let final void #t199 = self::Extension|[]=(#t196, #t197, #t198) in #t198;
+ let final self::Class? #t200 = c in #t200.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t201 = c{self::Class} in self::Extension|[]=(#t200{self::Class}, #t201, self::Extension|+(self::Extension|[](#t200{self::Class}, #t201), 0));
+ c = let final self::Class? #t202 = c in #t202.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t203 = c{self::Class} in let final self::Class? #t204 = self::Extension|+(self::Extension|[](#t202{self::Class}, #t203), 0) in let final void #t205 = self::Extension|[]=(#t202{self::Class}, #t203, #t204) in #t204;
+ let final self::Class? #t206 = c in #t206.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t207 = c{self::Class} in self::Extension|[]=(#t206{self::Class}, #t207, self::Extension|+(self::Extension|[](#t206{self::Class}, #t207), 1));
+ c = let final self::Class? #t208 = c in #t208.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t209 = c{self::Class} in let final self::Class? #t210 = self::Extension|[](#t208{self::Class}, #t209) in let final void #t211 = self::Extension|[]=(#t208{self::Class}, #t209, self::Extension|+(#t210, 1)) in #t210;
+ let final self::Class? #t212 = c in #t212.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t212{self::Class}, c{self::Class});
+ c = let final self::Class? #t213 = c in #t213.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t214 = c{self::Class} in let final self::Class? #t215 = self::Extension|+(self::Extension|[](#t213{self::Class}, #t214), 1) in let final void #t216 = self::Extension|[]=(#t213{self::Class}, #t214, #t215) in #t215;
+ let final self::Class? #t217 = c in #t217.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t218 = self::Extension|get#field(#t217{self::Class}) in let final self::Class #t219 = c{self::Class} in self::Extension|[]=(#t218, #t219, self::Extension|+(self::Extension|[](#t218, #t219), 1));
+ c = let final self::Class? #t220 = c in #t220.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t221 = self::Extension|get#field(#t220{self::Class}) in let final self::Class #t222 = c{self::Class} in let final self::Class? #t223 = self::Extension|[](#t221, #t222) in let final void #t224 = self::Extension|[]=(#t221, #t222, self::Extension|+(#t223, 1)) in #t223;
+ let final self::Class? #t225 = c in #t225.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t226 = self::Extension|get#field(#t225{self::Class}) in let final self::Class #t227 = c{self::Class} in let final self::Class? #t228 = self::Extension|+(self::Extension|[](#t226, #t227), 1) in let final void #t229 = self::Extension|[]=(#t226, #t227, #t228) in #t228;
+ c = let final self::Class? #t230 = c in #t230.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t231 = self::Extension|get#field(#t230{self::Class}) in let final self::Class #t232 = c{self::Class} in let final self::Class? #t233 = self::Extension|+(self::Extension|[](#t231, #t232), 1) in let final void #t234 = self::Extension|[]=(#t231, #t232, #t233) in #t233;
+ let final self::Class? #t235 = c in #t235.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|[](self::Extension|get#field(#t235{self::Class}), c{self::Class}), c{self::Class});
+ let final self::Class? #t236 = c in #t236.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|[](self::Extension|get#field(#t236{self::Class}), c{self::Class}), c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t237 = c in #t237.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t238 = self::Extension|[](self::Extension|get#field(#t237{self::Class}), c{self::Class}) in let final self::Class #t239 = c{self::Class} in let final self::Class #t240 = new self::Class::•() in let final void #t241 = self::Extension|[]=(#t238, #t239, #t240) in #t240;
+ let final self::Class #t242 = c{self::Class} in #t242.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|[](self::Extension|get#field(#t242), c{self::Class}), c{self::Class}));
+ let final self::Class #t243 = c{self::Class} in #t243.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t244 = self::Extension|[](self::Extension|get#field(#t243), c{self::Class}) in let final self::Class #t245 = c{self::Class} in self::Extension|[]=(#t244, #t245, self::Extension|+(self::Extension|[](#t244, #t245), 0));
+ c = let final self::Class #t246 = c{self::Class} in #t246.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t247 = self::Extension|[](self::Extension|get#field(#t246), c{self::Class}) in let final self::Class #t248 = c{self::Class} in let final self::Class? #t249 = self::Extension|+(self::Extension|[](#t247, #t248), 0) in let final void #t250 = self::Extension|[]=(#t247, #t248, #t249) in #t249;
+ let final self::Class? #t251 = c in #t251.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t252 = self::Extension|[](self::Extension|get#field(#t251{self::Class}), c{self::Class}) in let final self::Class #t253 = c{self::Class} in self::Extension|[]=(#t252, #t253, self::Extension|+(self::Extension|[](#t252, #t253), 1));
+ c = let final self::Class? #t254 = c in #t254.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t255 = self::Extension|[](self::Extension|get#field(#t254{self::Class}), c{self::Class}) in let final self::Class #t256 = c{self::Class} in let final self::Class? #t257 = self::Extension|[](#t255, #t256) in let final void #t258 = self::Extension|[]=(#t255, #t256, self::Extension|+(#t257, 1)) in #t257;
+ let final self::Class? #t259 = c in #t259.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t260 = self::Extension|[](self::Extension|get#field(#t259{self::Class}), c{self::Class}) in let final self::Class #t261 = c{self::Class} in let final self::Class? #t262 = self::Extension|+(self::Extension|[](#t260, #t261), 1) in let final void #t263 = self::Extension|[]=(#t260, #t261, #t262) in #t262;
+ c = let final self::Class? #t264 = c in #t264.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t265 = self::Extension|[](self::Extension|get#field(#t264{self::Class}), c{self::Class}) in let final self::Class #t266 = c{self::Class} in let final self::Class? #t267 = self::Extension|+(self::Extension|[](#t265, #t266), 1) in let final void #t268 = self::Extension|[]=(#t265, #t266, #t267) in #t267;
+ let final self::Class? #t269 = c in #t269.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t270 = self::Extension|[](#t269{self::Class}, c{self::Class}) in #t270.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t270{self::Class}, c{self::Class});
+ let final self::Class? #t271 = c in #t271.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t272 = self::Extension|[](#t271{self::Class}, c{self::Class}) in #t272.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(#t272{self::Class}, c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t273 = c in #t273.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t274 = self::Extension|[](#t273{self::Class}, c{self::Class}) in #t274.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t275 = c{self::Class} in let final self::Class #t276 = new self::Class::•() in let final void #t277 = self::Extension|[]=(#t274{self::Class}, #t275, #t276) in #t276;
+ let final self::Class #t278 = c{self::Class} in #t278.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t279 = self::Extension|[](#t278, c{self::Class}) in #t279.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t279{self::Class}, c{self::Class}));
+ c = let final self::Class #t280 = c{self::Class} in #t280.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t281 = self::Extension|[](#t280, c{self::Class}) in #t281.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t281{self::Class}, c{self::Class}));
+ let final self::Class? #t282 = c in #t282.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t283 = self::Extension|[](#t282{self::Class}, c{self::Class}) in #t283.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t284 = c{self::Class} in self::Extension|[](#t283{self::Class}, #t284).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t283{self::Class}, #t284, c{self::Class}) : null;
+ c = let final self::Class? #t285 = c in #t285.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t286 = self::Extension|[](#t285{self::Class}, c{self::Class}) in #t286.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t287 = c{self::Class} in let final self::Class? #t288 = self::Extension|[](#t286{self::Class}, #t287) in #t288.{core::Object::==}(null) ?{self::Class} let final self::Class #t289 = c{self::Class} in let final void #t290 = self::Extension|[]=(#t286{self::Class}, #t287, #t289) in #t289 : #t288;
+ let final self::Class #t291 = c{self::Class} in #t291.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t292 = self::Extension|[](#t291, c{self::Class}) in #t292.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t293 = c{self::Class} in self::Extension|[]=(#t292{self::Class}, #t293, self::Extension|+(self::Extension|[](#t292{self::Class}, #t293), 0));
+ c = let final self::Class #t294 = c{self::Class} in #t294.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t295 = self::Extension|[](#t294, c{self::Class}) in #t295.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t296 = c{self::Class} in let final self::Class? #t297 = self::Extension|+(self::Extension|[](#t295{self::Class}, #t296), 0) in let final void #t298 = self::Extension|[]=(#t295{self::Class}, #t296, #t297) in #t297;
+ let final self::Class? #t299 = c in #t299.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t300 = self::Extension|[](#t299{self::Class}, c{self::Class}) in #t300.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t301 = c{self::Class} in self::Extension|[]=(#t300{self::Class}, #t301, self::Extension|+(self::Extension|[](#t300{self::Class}, #t301), 1));
+ c = let final self::Class? #t302 = c in #t302.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t303 = self::Extension|[](#t302{self::Class}, c{self::Class}) in #t303.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t304 = c{self::Class} in let final self::Class? #t305 = self::Extension|[](#t303{self::Class}, #t304) in let final void #t306 = self::Extension|[]=(#t303{self::Class}, #t304, self::Extension|+(#t305, 1)) in #t305;
+ let final self::Class? #t307 = c in #t307.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t308 = self::Extension|[](#t307{self::Class}, c{self::Class}) in #t308.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t309 = c{self::Class} in let final self::Class? #t310 = self::Extension|+(self::Extension|[](#t308{self::Class}, #t309), 1) in let final void #t311 = self::Extension|[]=(#t308{self::Class}, #t309, #t310) in #t310;
+ c = let final self::Class? #t312 = c in #t312.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t313 = self::Extension|[](#t312{self::Class}, c{self::Class}) in #t313.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t314 = c{self::Class} in let final self::Class? #t315 = self::Extension|+(self::Extension|[](#t313{self::Class}, #t314), 1) in let final void #t316 = self::Extension|[]=(#t313{self::Class}, #t314, #t315) in #t315;
}
static method operatorAccess(self::Class? c) → void {
- self::throws(() → self::Class? => self::Extension|+(let final self::Class? #t184 = c in #t184.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t184), 0));
- self::throws(() → self::Class? => self::Extension|unary-(let final self::Class? #t185 = c in #t185.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t185)));
- let final self::Class? #t186 = c in #t186.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t186, self::Extension|+(self::Extension|get#field(#t186), 0));
- c = let final self::Class? #t187 = c in #t187.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t188 = self::Extension|+(self::Extension|get#field(#t187), 0) in let final void #t189 = self::Extension|set#field(#t187, #t188) in #t188;
- let final self::Class? #t190 = c in #t190.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t191 = self::Extension|get#field(#t190) in self::Extension|set#field(#t191, self::Extension|+(self::Extension|get#field(#t191), 0));
- c = let final self::Class? #t192 = c in #t192.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t193 = self::Extension|get#field(#t192) in let final self::Class? #t194 = self::Extension|+(self::Extension|get#field(#t193), 0) in let final void #t195 = self::Extension|set#field(#t193, #t194) in #t194;
- let final self::Class? #t196 = c in #t196.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t196, self::Extension|+(self::Extension|get#field(#t196), 1));
- c = let final self::Class? #t197 = c in #t197.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t198 = self::Extension|get#field(#t197) in let final self::Class? #t199 = let final self::Class? #t200 = self::Extension|+(#t198, 1) in let final void #t201 = self::Extension|set#field(#t197, #t200) in #t200 in #t198;
- let final self::Class? #t202 = c in #t202.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t203 = self::Extension|+(self::Extension|get#field(#t202), 1) in let final void #t204 = self::Extension|set#field(#t202, #t203) in #t203;
- c = let final self::Class? #t205 = c in #t205.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t206 = self::Extension|+(self::Extension|get#field(#t205), 1) in let final void #t207 = self::Extension|set#field(#t205, #t206) in #t206;
+ self::throws(() → self::Class? => self::Extension|+(let final self::Class? #t317 = c in #t317.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t317{self::Class}), 0));
+ self::throws(() → self::Class? => self::Extension|unary-(let final self::Class? #t318 = c in #t318.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t318{self::Class})));
+ let final self::Class? #t319 = c in #t319.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t319{self::Class}, self::Extension|+(self::Extension|get#field(#t319{self::Class}), 0));
+ c = let final self::Class? #t320 = c in #t320.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t321 = self::Extension|+(self::Extension|get#field(#t320{self::Class}), 0) in let final void #t322 = self::Extension|set#field(#t320{self::Class}, #t321) in #t321;
+ let final self::Class? #t323 = c in #t323.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t324 = self::Extension|get#field(#t323{self::Class}) in self::Extension|set#field(#t324, self::Extension|+(self::Extension|get#field(#t324), 0));
+ c = let final self::Class? #t325 = c in #t325.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t326 = self::Extension|get#field(#t325{self::Class}) in let final self::Class? #t327 = self::Extension|+(self::Extension|get#field(#t326), 0) in let final void #t328 = self::Extension|set#field(#t326, #t327) in #t327;
+ let final self::Class? #t329 = c in #t329.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t329{self::Class}, self::Extension|+(self::Extension|get#field(#t329{self::Class}), 1));
+ c = let final self::Class? #t330 = c in #t330.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t331 = self::Extension|get#field(#t330{self::Class}) in let final self::Class? #t332 = let final self::Class? #t333 = self::Extension|+(#t331, 1) in let final void #t334 = self::Extension|set#field(#t330{self::Class}, #t333) in #t333 in #t331;
+ let final self::Class? #t335 = c in #t335.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t336 = self::Extension|+(self::Extension|get#field(#t335{self::Class}), 1) in let final void #t337 = self::Extension|set#field(#t335{self::Class}, #t336) in #t336;
+ c = let final self::Class? #t338 = c in #t338.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t339 = self::Extension|+(self::Extension|get#field(#t338{self::Class}), 1) in let final void #t340 = self::Extension|set#field(#t338{self::Class}, #t339) in #t339;
}
static method ifNull(self::Class? c) → void {
- let final self::Class? #t208 = c in #t208.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t208).{core::Object::==}(null) ?{self::Class?} self::Extension|set#field(#t208, c) : null;
- c = let final self::Class? #t209 = c in #t209.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t210 = self::Extension|get#field(#t209) in #t210.{core::Object::==}(null) ?{self::Class?} let final self::Class? #t211 = c in let final void #t212 = self::Extension|set#field(#t209, #t211) in #t211 : #t210;
- let final self::Class? #t213 = c in #t213.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t214 = self::Extension|get#field(#t213) in let final self::Class? #t215 = c in self::Extension|[](#t214, #t215).{core::Object::==}(null) ?{self::Class?} self::Extension|[]=(#t214, #t215, c) : null;
+ let final self::Class? #t341 = c in #t341.{core::Object::==}(null) ?{self::Class} null : self::Extension|get#field(#t341{self::Class}).{core::Object::==}(null) ?{self::Class} self::Extension|set#field(#t341{self::Class}, c{self::Class}) : null;
+ c = let final self::Class? #t342 = c in #t342.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t343 = self::Extension|get#field(#t342{self::Class}) in #t343.{core::Object::==}(null) ?{self::Class} let final self::Class #t344 = c{self::Class} in let final void #t345 = self::Extension|set#field(#t342{self::Class}, #t344) in #t344 : #t343;
+ let final self::Class #t346 = c{self::Class} in #t346.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t347 = self::Extension|get#field(#t346) in self::Extension|get#field(#t347).{core::Object::==}(null) ?{self::Class} self::Extension|set#field(#t347, c{self::Class}) : null;
+ c = let final self::Class #t348 = c{self::Class} in #t348.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t349 = self::Extension|get#field(#t348) in let final self::Class? #t350 = self::Extension|get#field(#t349) in #t350.{core::Object::==}(null) ?{self::Class} let final self::Class #t351 = c{self::Class} in let final void #t352 = self::Extension|set#field(#t349, #t351) in #t351 : #t350;
+ let final self::Class #t353 = c{self::Class} in #t353.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t354 = self::Extension|get#field(#t353) in let final self::Class #t355 = c{self::Class} in self::Extension|[](#t354, #t355).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t354, #t355, c{self::Class}) : null;
+ c = let final self::Class #t356 = c{self::Class} in #t356.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t357 = self::Extension|get#field(#t356) in let final self::Class #t358 = c{self::Class} in let final self::Class? #t359 = self::Extension|[](#t357, #t358) in #t359.{core::Object::==}(null) ?{self::Class} let final self::Class #t360 = c{self::Class} in let final void #t361 = self::Extension|[]=(#t357, #t358, #t360) in #t360 : #t359;
}
static method throws(() → void f) → void {
try {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_extension.dart b/pkg/front_end/testcases/nnbd/null_shorting_extension.dart
index f7a2f33..397a233 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_extension.dart
+++ b/pkg/front_end/testcases/nnbd/null_shorting_extension.dart
@@ -38,11 +38,17 @@
c?.method();
c?.field.field;
+ c?.field?.field;
+ c?.field.field?.field;
c?.field.field = new Class();
+ c?.field?.field = new Class();
+ c?.field.field?.field = new Class();
throws(() => (c?.field).field);
throws(() => (c?.field = new Class()).field);
throws(() => (c?.method()).field);
c = c?.field.field = new Class();
+ c = c?.field?.field = new Class();
+ c = c?.field.field?.field = new Class();
c?.field.method();
c?.field = new Class().field;
c = c?.field = new Class().field;
@@ -100,6 +106,8 @@
c?.method().method().field;
c?.method().method().field = new Class();
c?.method().method().method();
+
+ c?.method()?.method();
}
void indexAccess(Class? c) {
@@ -112,12 +120,51 @@
c?.field[c].method();
c?.field[c] += 0;
c = c?.field[c] += 0;
+ c?.[c] ??= c;
+ c = c?.[c] ??= c;
+ c?.[c] += 0;
+ c = c?.[c] += 0;
+ c?.[c] += 0;
+ c = c?.[c] += 0;
// TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
// update.
+ c?.[c]++;
+ c = c?.[c]++;
+ ++c?.[c];
+ c = ++c?.[c];
c?.field[c]++;
c = c?.field[c]++;
++c?.field[c];
c = ++c?.field[c];
+
+ c?.field[c][c];
+ c?.field[c][c] = new Class();
+ c = c?.field[c][c] = new Class();
+ c?.field[c][c].method();
+ c?.field[c][c] += 0;
+ c = c?.field[c][c] += 0;
+ // TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
+ // update.
+ c?.field[c][c]++;
+ c = c?.field[c][c]++;
+ ++c?.field[c][c];
+ c = ++c?.field[c][c];
+
+ c?.[c]?.[c];
+ c?.[c]?.[c] = new Class();
+ c = c?.[c]?.[c] = new Class();
+ c?.[c]?.[c].method();
+ c = c?.[c]?.[c].method();
+ c?.[c]?.[c] ??= c;
+ c = c?.[c]?.[c] ??= c;
+ c?.[c]?.[c] += 0;
+ c = c?.[c]?.[c] += 0;
+ // TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
+ // update.
+ c?.[c]?.[c]++;
+ c = c?.[c]?.[c]++;
+ ++c?.[c]?.[c];
+ c = ++c?.[c]?.[c];
}
void operatorAccess(Class? c) {
@@ -138,7 +185,10 @@
void ifNull(Class? c) {
c?.field ??= c;
c = c?.field ??= c;
+ c?.field.field ??= c;
+ c = c?.field.field ??= c;
c?.field[c] ??= c;
+ c = c?.field[c] ??= c;
}
void throws(void Function() f) {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.outline.expect b/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.outline.expect
index 8a55652..2262232 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.outline.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field self::Class? _field;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
}
extension Extension on self::Class {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.strong.expect b/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.strong.expect
index e45d0bc..e86404b 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.strong.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field self::Class? _field = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
}
@@ -43,102 +43,145 @@
self::ifNull(null);
}
static method propertyAccess(self::Class? c) → void {
- let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t1);
- let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t2, new self::Class::•());
- c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3, #t4) in #t4;
- let final self::Class? #t6 = c in #t6.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t6);
- let final self::Class? #t7 = c in #t7.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(#t7));
- let final self::Class? #t8 = c in #t8.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t8), new self::Class::•());
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t9 = c in #t9.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t9)));
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t10 = c in #t10.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t11 = new self::Class::•() in let final void #t12 = self::Extension|set#field(#t10, #t11) in #t11));
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t13 = c in #t13.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t13)));
- c = let final self::Class? #t14 = c in #t14.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t15 = new self::Class::•() in let final void #t16 = self::Extension|set#field(self::Extension|get#field(#t14), #t15) in #t15;
- let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(#t17));
- let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t18, self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t19 = c in #t19.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t20 = self::Extension|get#field(new self::Class::•()) in let final void #t21 = self::Extension|set#field(#t19, #t20) in #t20;
- let final self::Class? #t22 = c in #t22.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t22, let final self::Class #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(new self::Class::•(), #t23) in #t23);
- c = let final self::Class? #t25 = c in #t25.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t26 = let final self::Class #t27 = new self::Class::•() in let final void #t28 = self::Extension|set#field(new self::Class::•(), #t27) in #t27 in let final void #t29 = self::Extension|set#field(#t25, #t26) in #t26;
- let final self::Class? #t30 = c in #t30.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t30, self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t31 = c in #t31.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t32 = self::Extension|method(new self::Class::•()) in let final void #t33 = self::Extension|set#field(#t31, #t32) in #t32;
- let final self::Class? #t34 = c in #t34.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(#t34));
- let final self::Class? #t35 = c in #t35.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t35), new self::Class::•());
- let final self::Class? #t36 = c in #t36.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(#t36));
- let final self::Class? #t37 = c in #t37.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|get#field(#t37)));
- let final self::Class? #t38 = c in #t38.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t38)), new self::Class::•());
- c = let final self::Class? #t39 = c in #t39.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t40 = new self::Class::•() in let final void #t41 = self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t39)), #t40) in #t40;
- let final self::Class? #t42 = c in #t42.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|get#field(#t42)));
- let final self::Class? #t43 = c in #t43.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t43, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
- c = let final self::Class? #t44 = c in #t44.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t45 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t46 = self::Extension|set#field(#t44, #t45) in #t45;
- let final self::Class? #t47 = c in #t47.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t47, let final self::Class #t48 = new self::Class::•() in let final void #t49 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t48) in #t48);
- c = let final self::Class? #t50 = c in #t50.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t51 = let final self::Class #t52 = new self::Class::•() in let final void #t53 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t52) in #t52 in let final void #t54 = self::Extension|set#field(#t50, #t51) in #t51;
- let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t55, self::Extension|method(self::Extension|get#field(new self::Class::•())));
- c = let final self::Class? #t56 = c in #t56.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t57 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t58 = self::Extension|set#field(#t56, #t57) in #t57;
- let final self::Class? #t59 = c in #t59.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|method(#t59)));
- let final self::Class? #t60 = c in #t60.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|method(#t60)), new self::Class::•());
- let final self::Class? #t61 = c in #t61.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|method(#t61)));
- let final self::Class? #t62 = c in #t62.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t62), self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t63 = c in #t63.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t64 = self::Extension|get#field(new self::Class::•()) in let final void #t65 = self::Extension|set#field(self::Extension|get#field(#t63), #t64) in #t64;
- let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t66), let final self::Class #t67 = new self::Class::•() in let final void #t68 = self::Extension|set#field(new self::Class::•(), #t67) in #t67);
- c = let final self::Class? #t69 = c in #t69.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t70 = let final self::Class #t71 = new self::Class::•() in let final void #t72 = self::Extension|set#field(new self::Class::•(), #t71) in #t71 in let final void #t73 = self::Extension|set#field(self::Extension|get#field(#t69), #t70) in #t70;
- let final self::Class? #t74 = c in #t74.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t74), self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t76 = self::Extension|method(new self::Class::•()) in let final void #t77 = self::Extension|set#field(self::Extension|get#field(#t75), #t76) in #t76;
- let final self::Class? #t78 = c in #t78.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t78, let final self::Class? #t79 = self::Extension|get#field(new self::Class::•()) in let final void #t80 = self::Extension|set#field(new self::Class::•(), #t79) in #t79);
- c = let final self::Class? #t81 = c in #t81.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t82 = let final self::Class? #t83 = self::Extension|get#field(new self::Class::•()) in let final void #t84 = self::Extension|set#field(new self::Class::•(), #t83) in #t83 in let final void #t85 = self::Extension|set#field(#t81, #t82) in #t82;
- let final self::Class? #t86 = c in #t86.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t86, let final self::Class #t87 = let final self::Class #t88 = new self::Class::•() in let final void #t89 = self::Extension|set#field(new self::Class::•(), #t88) in #t88 in let final void #t90 = self::Extension|set#field(new self::Class::•(), #t87) in #t87);
- c = let final self::Class? #t91 = c in #t91.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t92 = let final self::Class #t93 = let final self::Class #t94 = new self::Class::•() in let final void #t95 = self::Extension|set#field(new self::Class::•(), #t94) in #t94 in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t93) in #t93 in let final void #t97 = self::Extension|set#field(#t91, #t92) in #t92;
- let final self::Class? #t98 = c in #t98.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t98, let final self::Class? #t99 = self::Extension|method(new self::Class::•()) in let final void #t100 = self::Extension|set#field(new self::Class::•(), #t99) in #t99);
- c = let final self::Class? #t101 = c in #t101.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t102 = let final self::Class? #t103 = self::Extension|method(new self::Class::•()) in let final void #t104 = self::Extension|set#field(new self::Class::•(), #t103) in #t103 in let final void #t105 = self::Extension|set#field(#t101, #t102) in #t102;
- let final self::Class? #t106 = c in #t106.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t106), self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t107 = c in #t107.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t108 = self::Extension|get#field(new self::Class::•()) in let final void #t109 = self::Extension|set#field(self::Extension|method(#t107), #t108) in #t108;
- let final self::Class? #t110 = c in #t110.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t110), let final self::Class #t111 = new self::Class::•() in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t111) in #t111);
- c = let final self::Class? #t113 = c in #t113.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t114 = let final self::Class #t115 = new self::Class::•() in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115 in let final void #t117 = self::Extension|set#field(self::Extension|method(#t113), #t114) in #t114;
- let final self::Class? #t118 = c in #t118.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t118), self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t119 = c in #t119.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t120 = self::Extension|method(new self::Class::•()) in let final void #t121 = self::Extension|set#field(self::Extension|method(#t119), #t120) in #t120;
- let final self::Class? #t122 = c in #t122.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|get#field(#t122)));
- let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t123)), new self::Class::•());
- c = let final self::Class? #t124 = c in #t124.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t125 = new self::Class::•() in let final void #t126 = self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t124)), #t125) in #t125;
- let final self::Class? #t127 = c in #t127.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|get#field(#t127)));
- let final self::Class? #t128 = c in #t128.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t128, self::Extension|get#field(self::Extension|method(new self::Class::•())));
- c = let final self::Class? #t129 = c in #t129.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t130 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t131 = self::Extension|set#field(#t129, #t130) in #t130;
- let final self::Class? #t132 = c in #t132.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t132, let final self::Class #t133 = new self::Class::•() in let final void #t134 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t133) in #t133);
- c = let final self::Class? #t135 = c in #t135.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t136 = let final self::Class #t137 = new self::Class::•() in let final void #t138 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t137) in #t137 in let final void #t139 = self::Extension|set#field(#t135, #t136) in #t136;
- let final self::Class? #t140 = c in #t140.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t140, self::Extension|method(self::Extension|method(new self::Class::•())));
- c = let final self::Class? #t141 = c in #t141.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t142 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t143 = self::Extension|set#field(#t141, #t142) in #t142;
- let final self::Class? #t144 = c in #t144.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|method(#t144)));
- let final self::Class? #t145 = c in #t145.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|method(#t145)), new self::Class::•());
- let final self::Class? #t146 = c in #t146.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|method(#t146)));
+ let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t1{self::Class});
+ let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t2{self::Class}, new self::Class::•());
+ c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3{self::Class}, #t4) in #t4;
+ let final self::Class #t6 = c{self::Class} in #t6.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t6);
+ let final self::Class #t7 = c{self::Class} in #t7.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(#t7));
+ let final self::Class #t8 = c{self::Class} in #t8.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t9 = self::Extension|get#field(#t8) in #t9.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t9{self::Class});
+ let final self::Class #t10 = c{self::Class} in #t10.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t11 = self::Extension|get#field(self::Extension|get#field(#t10)) in #t11.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t11{self::Class});
+ let final self::Class #t12 = c{self::Class} in #t12.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t12), new self::Class::•());
+ let final self::Class #t13 = c{self::Class} in #t13.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t14 = self::Extension|get#field(#t13) in #t14.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t14{self::Class}, new self::Class::•());
+ let final self::Class #t15 = c{self::Class} in #t15.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t16 = self::Extension|get#field(self::Extension|get#field(#t15)) in #t16.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t16{self::Class}, new self::Class::•());
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t17{self::Class})));
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t19 = new self::Class::•() in let final void #t20 = self::Extension|set#field(#t18{self::Class}, #t19) in #t19));
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t21 = c in #t21.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t21{self::Class})));
+ c = let final self::Class #t22 = c{self::Class} in #t22.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(self::Extension|get#field(#t22), #t23) in #t23;
+ c = let final self::Class #t25 = c{self::Class} in #t25.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t26 = self::Extension|get#field(#t25) in #t26.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t27 = new self::Class::•() in let final void #t28 = self::Extension|set#field(#t26{self::Class}, #t27) in #t27;
+ c = let final self::Class #t29 = c{self::Class} in #t29.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t30 = self::Extension|get#field(self::Extension|get#field(#t29)) in #t30.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t31 = new self::Class::•() in let final void #t32 = self::Extension|set#field(#t30{self::Class}, #t31) in #t31;
+ let final self::Class #t33 = c{self::Class} in #t33.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(#t33));
+ let final self::Class #t34 = c{self::Class} in #t34.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t34, self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class #t35 = c{self::Class} in #t35.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t36 = self::Extension|get#field(new self::Class::•()) in let final void #t37 = self::Extension|set#field(#t35, #t36) in #t36;
+ let final self::Class? #t38 = c in #t38.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t38{self::Class}, let final self::Class #t39 = new self::Class::•() in let final void #t40 = self::Extension|set#field(new self::Class::•(), #t39) in #t39);
+ c = let final self::Class? #t41 = c in #t41.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t42 = let final self::Class #t43 = new self::Class::•() in let final void #t44 = self::Extension|set#field(new self::Class::•(), #t43) in #t43 in let final void #t45 = self::Extension|set#field(#t41{self::Class}, #t42) in #t42;
+ let final self::Class #t46 = c{self::Class} in #t46.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t46, self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t47 = c{self::Class} in #t47.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t48 = self::Extension|method(new self::Class::•()) in let final void #t49 = self::Extension|set#field(#t47, #t48) in #t48;
+ let final self::Class? #t50 = c in #t50.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(#t50{self::Class}));
+ let final self::Class? #t51 = c in #t51.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t51{self::Class}), new self::Class::•());
+ let final self::Class? #t52 = c in #t52.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(#t52{self::Class}));
+ let final self::Class? #t53 = c in #t53.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|get#field(#t53{self::Class})));
+ let final self::Class? #t54 = c in #t54.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t54{self::Class})), new self::Class::•());
+ c = let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t56 = new self::Class::•() in let final void #t57 = self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t55{self::Class})), #t56) in #t56;
+ let final self::Class #t58 = c{self::Class} in #t58.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|get#field(#t58)));
+ let final self::Class #t59 = c{self::Class} in #t59.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t59, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class #t60 = c{self::Class} in #t60.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t61 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t62 = self::Extension|set#field(#t60, #t61) in #t61;
+ let final self::Class? #t63 = c in #t63.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t63{self::Class}, let final self::Class #t64 = new self::Class::•() in let final void #t65 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t64) in #t64);
+ c = let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t67 = let final self::Class #t68 = new self::Class::•() in let final void #t69 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t68) in #t68 in let final void #t70 = self::Extension|set#field(#t66{self::Class}, #t67) in #t67;
+ let final self::Class #t71 = c{self::Class} in #t71.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t71, self::Extension|method(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class #t72 = c{self::Class} in #t72.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t73 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t74 = self::Extension|set#field(#t72, #t73) in #t73;
+ let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|method(#t75{self::Class})));
+ let final self::Class? #t76 = c in #t76.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|method(#t76{self::Class})), new self::Class::•());
+ let final self::Class? #t77 = c in #t77.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|method(#t77{self::Class})));
+ let final self::Class? #t78 = c in #t78.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t78{self::Class}), self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class? #t79 = c in #t79.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t80 = self::Extension|get#field(new self::Class::•()) in let final void #t81 = self::Extension|set#field(self::Extension|get#field(#t79{self::Class}), #t80) in #t80;
+ let final self::Class? #t82 = c in #t82.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t82{self::Class}), let final self::Class #t83 = new self::Class::•() in let final void #t84 = self::Extension|set#field(new self::Class::•(), #t83) in #t83);
+ c = let final self::Class? #t85 = c in #t85.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t86 = let final self::Class #t87 = new self::Class::•() in let final void #t88 = self::Extension|set#field(new self::Class::•(), #t87) in #t87 in let final void #t89 = self::Extension|set#field(self::Extension|get#field(#t85{self::Class}), #t86) in #t86;
+ let final self::Class #t90 = c{self::Class} in #t90.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t90), self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t91 = c{self::Class} in #t91.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t92 = self::Extension|method(new self::Class::•()) in let final void #t93 = self::Extension|set#field(self::Extension|get#field(#t91), #t92) in #t92;
+ let final self::Class? #t94 = c in #t94.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t94{self::Class}, let final self::Class? #t95 = self::Extension|get#field(new self::Class::•()) in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t95) in #t95);
+ c = let final self::Class? #t97 = c in #t97.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t98 = let final self::Class? #t99 = self::Extension|get#field(new self::Class::•()) in let final void #t100 = self::Extension|set#field(new self::Class::•(), #t99) in #t99 in let final void #t101 = self::Extension|set#field(#t97{self::Class}, #t98) in #t98;
+ let final self::Class? #t102 = c in #t102.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t102{self::Class}, let final self::Class #t103 = let final self::Class #t104 = new self::Class::•() in let final void #t105 = self::Extension|set#field(new self::Class::•(), #t104) in #t104 in let final void #t106 = self::Extension|set#field(new self::Class::•(), #t103) in #t103);
+ c = let final self::Class? #t107 = c in #t107.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t108 = let final self::Class #t109 = let final self::Class #t110 = new self::Class::•() in let final void #t111 = self::Extension|set#field(new self::Class::•(), #t110) in #t110 in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t109) in #t109 in let final void #t113 = self::Extension|set#field(#t107{self::Class}, #t108) in #t108;
+ let final self::Class #t114 = c{self::Class} in #t114.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t114, let final self::Class? #t115 = self::Extension|method(new self::Class::•()) in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115);
+ c = let final self::Class #t117 = c{self::Class} in #t117.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t118 = let final self::Class? #t119 = self::Extension|method(new self::Class::•()) in let final void #t120 = self::Extension|set#field(new self::Class::•(), #t119) in #t119 in let final void #t121 = self::Extension|set#field(#t117, #t118) in #t118;
+ let final self::Class? #t122 = c in #t122.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t122{self::Class}), self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t124 = self::Extension|get#field(new self::Class::•()) in let final void #t125 = self::Extension|set#field(self::Extension|method(#t123{self::Class}), #t124) in #t124;
+ let final self::Class? #t126 = c in #t126.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t126{self::Class}), let final self::Class #t127 = new self::Class::•() in let final void #t128 = self::Extension|set#field(new self::Class::•(), #t127) in #t127);
+ c = let final self::Class? #t129 = c in #t129.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t130 = let final self::Class #t131 = new self::Class::•() in let final void #t132 = self::Extension|set#field(new self::Class::•(), #t131) in #t131 in let final void #t133 = self::Extension|set#field(self::Extension|method(#t129{self::Class}), #t130) in #t130;
+ let final self::Class #t134 = c{self::Class} in #t134.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t134), self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t135 = c{self::Class} in #t135.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t136 = self::Extension|method(new self::Class::•()) in let final void #t137 = self::Extension|set#field(self::Extension|method(#t135), #t136) in #t136;
+ let final self::Class? #t138 = c in #t138.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|get#field(#t138{self::Class})));
+ let final self::Class? #t139 = c in #t139.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t139{self::Class})), new self::Class::•());
+ c = let final self::Class? #t140 = c in #t140.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t141 = new self::Class::•() in let final void #t142 = self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t140{self::Class})), #t141) in #t141;
+ let final self::Class #t143 = c{self::Class} in #t143.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|get#field(#t143)));
+ let final self::Class #t144 = c{self::Class} in #t144.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t144, self::Extension|get#field(self::Extension|method(new self::Class::•())));
+ c = let final self::Class #t145 = c{self::Class} in #t145.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t146 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t147 = self::Extension|set#field(#t145, #t146) in #t146;
+ let final self::Class? #t148 = c in #t148.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t148{self::Class}, let final self::Class #t149 = new self::Class::•() in let final void #t150 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t149) in #t149);
+ c = let final self::Class? #t151 = c in #t151.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t152 = let final self::Class #t153 = new self::Class::•() in let final void #t154 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t153) in #t153 in let final void #t155 = self::Extension|set#field(#t151{self::Class}, #t152) in #t152;
+ let final self::Class #t156 = c{self::Class} in #t156.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t156, self::Extension|method(self::Extension|method(new self::Class::•())));
+ c = let final self::Class #t157 = c{self::Class} in #t157.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t158 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t159 = self::Extension|set#field(#t157, #t158) in #t158;
+ let final self::Class? #t160 = c in #t160.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|method(#t160{self::Class})));
+ let final self::Class? #t161 = c in #t161.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|method(#t161{self::Class})), new self::Class::•());
+ let final self::Class? #t162 = c in #t162.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|method(#t162{self::Class})));
+ let final self::Class? #t163 = c in #t163.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t164 = self::Extension|method(#t163{self::Class}) in #t164.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t164{self::Class});
}
static method indexAccess(self::Class? c) → void {
- let final self::Class? #t147 = c in #t147.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t147, c);
- let final self::Class? #t148 = c in #t148.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(#t148, c, new self::Class::•());
- let final self::Class? #t149 = c in #t149.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t149, c));
- let final self::Class? #t150 = c in #t150.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|get#field(#t150), c);
- let final self::Class? #t151 = c in #t151.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|get#field(#t151), c, new self::Class::•());
- c = let final self::Class? #t152 = c in #t152.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t153 = self::Extension|get#field(#t152) in let final self::Class? #t154 = c in let final self::Class #t155 = new self::Class::•() in let final void #t156 = self::Extension|[]=(#t153, #t154, #t155) in #t155;
- let final self::Class? #t157 = c in #t157.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|get#field(#t157), c));
- let final self::Class? #t158 = c in #t158.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t159 = self::Extension|get#field(#t158) in let final self::Class? #t160 = c in self::Extension|[]=(#t159, #t160, self::Extension|+(self::Extension|[](#t159, #t160), 0));
- c = let final self::Class? #t161 = c in #t161.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t162 = self::Extension|get#field(#t161) in let final self::Class? #t163 = c in let final self::Class? #t164 = self::Extension|+(self::Extension|[](#t162, #t163), 0) in let final void #t165 = self::Extension|[]=(#t162, #t163, #t164) in #t164;
- let final self::Class? #t166 = c in #t166.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t167 = self::Extension|get#field(#t166) in let final self::Class? #t168 = c in self::Extension|[]=(#t167, #t168, self::Extension|+(self::Extension|[](#t167, #t168), 1));
- c = let final self::Class? #t169 = c in #t169.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t170 = self::Extension|get#field(#t169) in let final self::Class? #t171 = c in let final self::Class? #t172 = self::Extension|[](#t170, #t171) in let final void #t173 = self::Extension|[]=(#t170, #t171, self::Extension|+(#t172, 1)) in #t172;
- let final self::Class? #t174 = c in #t174.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t175 = self::Extension|get#field(#t174) in let final self::Class? #t176 = c in let final self::Class? #t177 = self::Extension|+(self::Extension|[](#t175, #t176), 1) in let final void #t178 = self::Extension|[]=(#t175, #t176, #t177) in #t177;
- c = let final self::Class? #t179 = c in #t179.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t180 = self::Extension|get#field(#t179) in let final self::Class? #t181 = c in let final self::Class? #t182 = self::Extension|+(self::Extension|[](#t180, #t181), 1) in let final void #t183 = self::Extension|[]=(#t180, #t181, #t182) in #t182;
+ let final self::Class? #t165 = c in #t165.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t165{self::Class}, c{self::Class});
+ let final self::Class? #t166 = c in #t166.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(#t166{self::Class}, c{self::Class}, new self::Class::•());
+ let final self::Class? #t167 = c in #t167.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t167{self::Class}, c{self::Class}));
+ let final self::Class? #t168 = c in #t168.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|get#field(#t168{self::Class}), c{self::Class});
+ let final self::Class? #t169 = c in #t169.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|get#field(#t169{self::Class}), c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t170 = c in #t170.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t171 = self::Extension|get#field(#t170{self::Class}) in let final self::Class #t172 = c{self::Class} in let final self::Class #t173 = new self::Class::•() in let final void #t174 = self::Extension|[]=(#t171, #t172, #t173) in #t173;
+ let final self::Class #t175 = c{self::Class} in #t175.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|get#field(#t175), c{self::Class}));
+ let final self::Class #t176 = c{self::Class} in #t176.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t177 = self::Extension|get#field(#t176) in let final self::Class #t178 = c{self::Class} in self::Extension|[]=(#t177, #t178, self::Extension|+(self::Extension|[](#t177, #t178), 0));
+ c = let final self::Class #t179 = c{self::Class} in #t179.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t180 = self::Extension|get#field(#t179) in let final self::Class #t181 = c{self::Class} in let final self::Class? #t182 = self::Extension|+(self::Extension|[](#t180, #t181), 0) in let final void #t183 = self::Extension|[]=(#t180, #t181, #t182) in #t182;
+ let final self::Class? #t184 = c in #t184.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t185 = c{self::Class} in self::Extension|[](#t184{self::Class}, #t185).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t184{self::Class}, #t185, c{self::Class}) : null;
+ c = let final self::Class? #t186 = c in #t186.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t187 = c{self::Class} in let final self::Class? #t188 = self::Extension|[](#t186{self::Class}, #t187) in #t188.{core::Object::==}(null) ?{self::Class} let final self::Class #t189 = c{self::Class} in let final void #t190 = self::Extension|[]=(#t186{self::Class}, #t187, #t189) in #t189 : #t188;
+ let final self::Class #t191 = c{self::Class} in #t191.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t192 = c{self::Class} in self::Extension|[]=(#t191, #t192, self::Extension|+(self::Extension|[](#t191, #t192), 0));
+ c = let final self::Class #t193 = c{self::Class} in #t193.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t194 = c{self::Class} in let final self::Class? #t195 = self::Extension|+(self::Extension|[](#t193, #t194), 0) in let final void #t196 = self::Extension|[]=(#t193, #t194, #t195) in #t195;
+ let final self::Class? #t197 = c in #t197.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t198 = c{self::Class} in self::Extension|[]=(#t197{self::Class}, #t198, self::Extension|+(self::Extension|[](#t197{self::Class}, #t198), 0));
+ c = let final self::Class? #t199 = c in #t199.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t200 = c{self::Class} in let final self::Class? #t201 = self::Extension|+(self::Extension|[](#t199{self::Class}, #t200), 0) in let final void #t202 = self::Extension|[]=(#t199{self::Class}, #t200, #t201) in #t201;
+ let final self::Class? #t203 = c in #t203.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t204 = c{self::Class} in self::Extension|[]=(#t203{self::Class}, #t204, self::Extension|+(self::Extension|[](#t203{self::Class}, #t204), 1));
+ c = let final self::Class? #t205 = c in #t205.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t206 = c{self::Class} in let final self::Class? #t207 = self::Extension|[](#t205{self::Class}, #t206) in let final void #t208 = self::Extension|[]=(#t205{self::Class}, #t206, self::Extension|+(#t207, 1)) in #t207;
+ let final self::Class? #t209 = c in #t209.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t210 = c{self::Class} in let final self::Class? #t211 = self::Extension|+(self::Extension|[](#t209{self::Class}, #t210), 1) in let final void #t212 = self::Extension|[]=(#t209{self::Class}, #t210, #t211) in #t211;
+ c = let final self::Class? #t213 = c in #t213.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t214 = c{self::Class} in let final self::Class? #t215 = self::Extension|+(self::Extension|[](#t213{self::Class}, #t214), 1) in let final void #t216 = self::Extension|[]=(#t213{self::Class}, #t214, #t215) in #t215;
+ let final self::Class? #t217 = c in #t217.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t218 = self::Extension|get#field(#t217{self::Class}) in let final self::Class #t219 = c{self::Class} in self::Extension|[]=(#t218, #t219, self::Extension|+(self::Extension|[](#t218, #t219), 1));
+ c = let final self::Class? #t220 = c in #t220.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t221 = self::Extension|get#field(#t220{self::Class}) in let final self::Class #t222 = c{self::Class} in let final self::Class? #t223 = self::Extension|[](#t221, #t222) in let final void #t224 = self::Extension|[]=(#t221, #t222, self::Extension|+(#t223, 1)) in #t223;
+ let final self::Class? #t225 = c in #t225.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t226 = self::Extension|get#field(#t225{self::Class}) in let final self::Class #t227 = c{self::Class} in let final self::Class? #t228 = self::Extension|+(self::Extension|[](#t226, #t227), 1) in let final void #t229 = self::Extension|[]=(#t226, #t227, #t228) in #t228;
+ c = let final self::Class? #t230 = c in #t230.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t231 = self::Extension|get#field(#t230{self::Class}) in let final self::Class #t232 = c{self::Class} in let final self::Class? #t233 = self::Extension|+(self::Extension|[](#t231, #t232), 1) in let final void #t234 = self::Extension|[]=(#t231, #t232, #t233) in #t233;
+ let final self::Class? #t235 = c in #t235.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|[](self::Extension|get#field(#t235{self::Class}), c{self::Class}), c{self::Class});
+ let final self::Class? #t236 = c in #t236.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|[](self::Extension|get#field(#t236{self::Class}), c{self::Class}), c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t237 = c in #t237.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t238 = self::Extension|[](self::Extension|get#field(#t237{self::Class}), c{self::Class}) in let final self::Class #t239 = c{self::Class} in let final self::Class #t240 = new self::Class::•() in let final void #t241 = self::Extension|[]=(#t238, #t239, #t240) in #t240;
+ let final self::Class #t242 = c{self::Class} in #t242.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|[](self::Extension|get#field(#t242), c{self::Class}), c{self::Class}));
+ let final self::Class #t243 = c{self::Class} in #t243.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t244 = self::Extension|[](self::Extension|get#field(#t243), c{self::Class}) in let final self::Class #t245 = c{self::Class} in self::Extension|[]=(#t244, #t245, self::Extension|+(self::Extension|[](#t244, #t245), 0));
+ c = let final self::Class #t246 = c{self::Class} in #t246.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t247 = self::Extension|[](self::Extension|get#field(#t246), c{self::Class}) in let final self::Class #t248 = c{self::Class} in let final self::Class? #t249 = self::Extension|+(self::Extension|[](#t247, #t248), 0) in let final void #t250 = self::Extension|[]=(#t247, #t248, #t249) in #t249;
+ let final self::Class? #t251 = c in #t251.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t252 = self::Extension|[](self::Extension|get#field(#t251{self::Class}), c{self::Class}) in let final self::Class #t253 = c{self::Class} in self::Extension|[]=(#t252, #t253, self::Extension|+(self::Extension|[](#t252, #t253), 1));
+ c = let final self::Class? #t254 = c in #t254.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t255 = self::Extension|[](self::Extension|get#field(#t254{self::Class}), c{self::Class}) in let final self::Class #t256 = c{self::Class} in let final self::Class? #t257 = self::Extension|[](#t255, #t256) in let final void #t258 = self::Extension|[]=(#t255, #t256, self::Extension|+(#t257, 1)) in #t257;
+ let final self::Class? #t259 = c in #t259.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t260 = self::Extension|[](self::Extension|get#field(#t259{self::Class}), c{self::Class}) in let final self::Class #t261 = c{self::Class} in let final self::Class? #t262 = self::Extension|+(self::Extension|[](#t260, #t261), 1) in let final void #t263 = self::Extension|[]=(#t260, #t261, #t262) in #t262;
+ c = let final self::Class? #t264 = c in #t264.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t265 = self::Extension|[](self::Extension|get#field(#t264{self::Class}), c{self::Class}) in let final self::Class #t266 = c{self::Class} in let final self::Class? #t267 = self::Extension|+(self::Extension|[](#t265, #t266), 1) in let final void #t268 = self::Extension|[]=(#t265, #t266, #t267) in #t267;
+ let final self::Class? #t269 = c in #t269.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t270 = self::Extension|[](#t269{self::Class}, c{self::Class}) in #t270.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t270{self::Class}, c{self::Class});
+ let final self::Class? #t271 = c in #t271.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t272 = self::Extension|[](#t271{self::Class}, c{self::Class}) in #t272.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(#t272{self::Class}, c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t273 = c in #t273.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t274 = self::Extension|[](#t273{self::Class}, c{self::Class}) in #t274.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t275 = c{self::Class} in let final self::Class #t276 = new self::Class::•() in let final void #t277 = self::Extension|[]=(#t274{self::Class}, #t275, #t276) in #t276;
+ let final self::Class #t278 = c{self::Class} in #t278.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t279 = self::Extension|[](#t278, c{self::Class}) in #t279.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t279{self::Class}, c{self::Class}));
+ c = let final self::Class #t280 = c{self::Class} in #t280.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t281 = self::Extension|[](#t280, c{self::Class}) in #t281.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t281{self::Class}, c{self::Class}));
+ let final self::Class? #t282 = c in #t282.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t283 = self::Extension|[](#t282{self::Class}, c{self::Class}) in #t283.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t284 = c{self::Class} in self::Extension|[](#t283{self::Class}, #t284).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t283{self::Class}, #t284, c{self::Class}) : null;
+ c = let final self::Class? #t285 = c in #t285.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t286 = self::Extension|[](#t285{self::Class}, c{self::Class}) in #t286.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t287 = c{self::Class} in let final self::Class? #t288 = self::Extension|[](#t286{self::Class}, #t287) in #t288.{core::Object::==}(null) ?{self::Class} let final self::Class #t289 = c{self::Class} in let final void #t290 = self::Extension|[]=(#t286{self::Class}, #t287, #t289) in #t289 : #t288;
+ let final self::Class #t291 = c{self::Class} in #t291.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t292 = self::Extension|[](#t291, c{self::Class}) in #t292.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t293 = c{self::Class} in self::Extension|[]=(#t292{self::Class}, #t293, self::Extension|+(self::Extension|[](#t292{self::Class}, #t293), 0));
+ c = let final self::Class #t294 = c{self::Class} in #t294.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t295 = self::Extension|[](#t294, c{self::Class}) in #t295.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t296 = c{self::Class} in let final self::Class? #t297 = self::Extension|+(self::Extension|[](#t295{self::Class}, #t296), 0) in let final void #t298 = self::Extension|[]=(#t295{self::Class}, #t296, #t297) in #t297;
+ let final self::Class? #t299 = c in #t299.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t300 = self::Extension|[](#t299{self::Class}, c{self::Class}) in #t300.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t301 = c{self::Class} in self::Extension|[]=(#t300{self::Class}, #t301, self::Extension|+(self::Extension|[](#t300{self::Class}, #t301), 1));
+ c = let final self::Class? #t302 = c in #t302.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t303 = self::Extension|[](#t302{self::Class}, c{self::Class}) in #t303.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t304 = c{self::Class} in let final self::Class? #t305 = self::Extension|[](#t303{self::Class}, #t304) in let final void #t306 = self::Extension|[]=(#t303{self::Class}, #t304, self::Extension|+(#t305, 1)) in #t305;
+ let final self::Class? #t307 = c in #t307.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t308 = self::Extension|[](#t307{self::Class}, c{self::Class}) in #t308.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t309 = c{self::Class} in let final self::Class? #t310 = self::Extension|+(self::Extension|[](#t308{self::Class}, #t309), 1) in let final void #t311 = self::Extension|[]=(#t308{self::Class}, #t309, #t310) in #t310;
+ c = let final self::Class? #t312 = c in #t312.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t313 = self::Extension|[](#t312{self::Class}, c{self::Class}) in #t313.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t314 = c{self::Class} in let final self::Class? #t315 = self::Extension|+(self::Extension|[](#t313{self::Class}, #t314), 1) in let final void #t316 = self::Extension|[]=(#t313{self::Class}, #t314, #t315) in #t315;
}
static method operatorAccess(self::Class? c) → void {
- self::throws(() → self::Class? => self::Extension|+(let final self::Class? #t184 = c in #t184.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t184), 0));
- self::throws(() → self::Class? => self::Extension|unary-(let final self::Class? #t185 = c in #t185.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t185)));
- let final self::Class? #t186 = c in #t186.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t186, self::Extension|+(self::Extension|get#field(#t186), 0));
- c = let final self::Class? #t187 = c in #t187.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t188 = self::Extension|+(self::Extension|get#field(#t187), 0) in let final void #t189 = self::Extension|set#field(#t187, #t188) in #t188;
- let final self::Class? #t190 = c in #t190.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t191 = self::Extension|get#field(#t190) in self::Extension|set#field(#t191, self::Extension|+(self::Extension|get#field(#t191), 0));
- c = let final self::Class? #t192 = c in #t192.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t193 = self::Extension|get#field(#t192) in let final self::Class? #t194 = self::Extension|+(self::Extension|get#field(#t193), 0) in let final void #t195 = self::Extension|set#field(#t193, #t194) in #t194;
- let final self::Class? #t196 = c in #t196.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t196, self::Extension|+(self::Extension|get#field(#t196), 1));
- c = let final self::Class? #t197 = c in #t197.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t198 = self::Extension|get#field(#t197) in let final void #t199 = self::Extension|set#field(#t197, self::Extension|+(#t198, 1)) in #t198;
- let final self::Class? #t200 = c in #t200.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t201 = self::Extension|+(self::Extension|get#field(#t200), 1) in let final void #t202 = self::Extension|set#field(#t200, #t201) in #t201;
- c = let final self::Class? #t203 = c in #t203.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t204 = self::Extension|+(self::Extension|get#field(#t203), 1) in let final void #t205 = self::Extension|set#field(#t203, #t204) in #t204;
+ self::throws(() → self::Class? => self::Extension|+(let final self::Class? #t317 = c in #t317.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t317{self::Class}), 0));
+ self::throws(() → self::Class? => self::Extension|unary-(let final self::Class? #t318 = c in #t318.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t318{self::Class})));
+ let final self::Class? #t319 = c in #t319.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t319, self::Extension|+(self::Extension|get#field(#t319), 0));
+ c = let final self::Class? #t320 = c in #t320.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t321 = self::Extension|+(self::Extension|get#field(#t320), 0) in let final void #t322 = self::Extension|set#field(#t320, #t321) in #t321;
+ let final self::Class? #t323 = c in #t323.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t324 = self::Extension|get#field(#t323{self::Class}) in self::Extension|set#field(#t324, self::Extension|+(self::Extension|get#field(#t324), 0));
+ c = let final self::Class? #t325 = c in #t325.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t326 = self::Extension|get#field(#t325{self::Class}) in let final self::Class? #t327 = self::Extension|+(self::Extension|get#field(#t326), 0) in let final void #t328 = self::Extension|set#field(#t326, #t327) in #t327;
+ let final self::Class? #t329 = c in #t329.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t329, self::Extension|+(self::Extension|get#field(#t329), 1));
+ c = let final self::Class? #t330 = c in #t330.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t331 = self::Extension|get#field(#t330) in let final void #t332 = self::Extension|set#field(#t330, self::Extension|+(#t331, 1)) in #t331;
+ let final self::Class? #t333 = c in #t333.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t334 = self::Extension|+(self::Extension|get#field(#t333), 1) in let final void #t335 = self::Extension|set#field(#t333, #t334) in #t334;
+ c = let final self::Class? #t336 = c in #t336.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t337 = self::Extension|+(self::Extension|get#field(#t336), 1) in let final void #t338 = self::Extension|set#field(#t336, #t337) in #t337;
}
static method ifNull(self::Class? c) → void {
- let final self::Class? #t206 = c in #t206.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t206).{core::Object::==}(null) ?{self::Class?} self::Extension|set#field(#t206, c) : null;
- c = let final self::Class? #t207 = c in #t207.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t208 = self::Extension|get#field(#t207) in #t208.{core::Object::==}(null) ?{self::Class?} let final self::Class? #t209 = c in let final void #t210 = self::Extension|set#field(#t207, #t209) in #t209 : #t208;
- let final self::Class? #t211 = c in #t211.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t212 = self::Extension|get#field(#t211) in let final self::Class? #t213 = c in self::Extension|[](#t212, #t213).{core::Object::==}(null) ?{self::Class?} self::Extension|[]=(#t212, #t213, c) : null;
+ let final self::Class? #t339 = c in #t339.{core::Object::==}(null) ?{self::Class} null : self::Extension|get#field(#t339).{core::Object::==}(null) ?{self::Class} self::Extension|set#field(#t339, c{self::Class}) : null;
+ c = let final self::Class? #t340 = c in #t340.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t341 = self::Extension|get#field(#t340) in #t341.{core::Object::==}(null) ?{self::Class} let final self::Class #t342 = c{self::Class} in let final void #t343 = self::Extension|set#field(#t340, #t342) in #t342 : #t341;
+ let final self::Class #t344 = c{self::Class} in #t344.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t345 = self::Extension|get#field(#t344) in self::Extension|get#field(#t345).{core::Object::==}(null) ?{self::Class} self::Extension|set#field(#t345, c{self::Class}) : null;
+ c = let final self::Class #t346 = c{self::Class} in #t346.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t347 = self::Extension|get#field(#t346) in let final self::Class? #t348 = self::Extension|get#field(#t347) in #t348.{core::Object::==}(null) ?{self::Class} let final self::Class #t349 = c{self::Class} in let final void #t350 = self::Extension|set#field(#t347, #t349) in #t349 : #t348;
+ let final self::Class #t351 = c{self::Class} in #t351.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t352 = self::Extension|get#field(#t351) in let final self::Class #t353 = c{self::Class} in self::Extension|[](#t352, #t353).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t352, #t353, c{self::Class}) : null;
+ c = let final self::Class #t354 = c{self::Class} in #t354.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t355 = self::Extension|get#field(#t354) in let final self::Class #t356 = c{self::Class} in let final self::Class? #t357 = self::Extension|[](#t355, #t356) in #t357.{core::Object::==}(null) ?{self::Class} let final self::Class #t358 = c{self::Class} in let final void #t359 = self::Extension|[]=(#t355, #t356, #t358) in #t358 : #t357;
}
static method throws(() → void f) → void {
try {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.strong.transformed.expect
index e45d0bc..e86404b 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_extension.dart.strong.transformed.expect
@@ -4,7 +4,7 @@
class Class extends core::Object {
field self::Class? _field = null;
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
}
@@ -43,102 +43,145 @@
self::ifNull(null);
}
static method propertyAccess(self::Class? c) → void {
- let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t1);
- let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t2, new self::Class::•());
- c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3, #t4) in #t4;
- let final self::Class? #t6 = c in #t6.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t6);
- let final self::Class? #t7 = c in #t7.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(#t7));
- let final self::Class? #t8 = c in #t8.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t8), new self::Class::•());
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t9 = c in #t9.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t9)));
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t10 = c in #t10.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t11 = new self::Class::•() in let final void #t12 = self::Extension|set#field(#t10, #t11) in #t11));
- self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t13 = c in #t13.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t13)));
- c = let final self::Class? #t14 = c in #t14.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t15 = new self::Class::•() in let final void #t16 = self::Extension|set#field(self::Extension|get#field(#t14), #t15) in #t15;
- let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(#t17));
- let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t18, self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t19 = c in #t19.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t20 = self::Extension|get#field(new self::Class::•()) in let final void #t21 = self::Extension|set#field(#t19, #t20) in #t20;
- let final self::Class? #t22 = c in #t22.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t22, let final self::Class #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(new self::Class::•(), #t23) in #t23);
- c = let final self::Class? #t25 = c in #t25.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t26 = let final self::Class #t27 = new self::Class::•() in let final void #t28 = self::Extension|set#field(new self::Class::•(), #t27) in #t27 in let final void #t29 = self::Extension|set#field(#t25, #t26) in #t26;
- let final self::Class? #t30 = c in #t30.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t30, self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t31 = c in #t31.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t32 = self::Extension|method(new self::Class::•()) in let final void #t33 = self::Extension|set#field(#t31, #t32) in #t32;
- let final self::Class? #t34 = c in #t34.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(#t34));
- let final self::Class? #t35 = c in #t35.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t35), new self::Class::•());
- let final self::Class? #t36 = c in #t36.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(#t36));
- let final self::Class? #t37 = c in #t37.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|get#field(#t37)));
- let final self::Class? #t38 = c in #t38.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t38)), new self::Class::•());
- c = let final self::Class? #t39 = c in #t39.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t40 = new self::Class::•() in let final void #t41 = self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t39)), #t40) in #t40;
- let final self::Class? #t42 = c in #t42.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|get#field(#t42)));
- let final self::Class? #t43 = c in #t43.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t43, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
- c = let final self::Class? #t44 = c in #t44.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t45 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t46 = self::Extension|set#field(#t44, #t45) in #t45;
- let final self::Class? #t47 = c in #t47.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t47, let final self::Class #t48 = new self::Class::•() in let final void #t49 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t48) in #t48);
- c = let final self::Class? #t50 = c in #t50.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t51 = let final self::Class #t52 = new self::Class::•() in let final void #t53 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t52) in #t52 in let final void #t54 = self::Extension|set#field(#t50, #t51) in #t51;
- let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t55, self::Extension|method(self::Extension|get#field(new self::Class::•())));
- c = let final self::Class? #t56 = c in #t56.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t57 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t58 = self::Extension|set#field(#t56, #t57) in #t57;
- let final self::Class? #t59 = c in #t59.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|method(#t59)));
- let final self::Class? #t60 = c in #t60.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|method(#t60)), new self::Class::•());
- let final self::Class? #t61 = c in #t61.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|method(#t61)));
- let final self::Class? #t62 = c in #t62.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t62), self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t63 = c in #t63.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t64 = self::Extension|get#field(new self::Class::•()) in let final void #t65 = self::Extension|set#field(self::Extension|get#field(#t63), #t64) in #t64;
- let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t66), let final self::Class #t67 = new self::Class::•() in let final void #t68 = self::Extension|set#field(new self::Class::•(), #t67) in #t67);
- c = let final self::Class? #t69 = c in #t69.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t70 = let final self::Class #t71 = new self::Class::•() in let final void #t72 = self::Extension|set#field(new self::Class::•(), #t71) in #t71 in let final void #t73 = self::Extension|set#field(self::Extension|get#field(#t69), #t70) in #t70;
- let final self::Class? #t74 = c in #t74.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t74), self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t76 = self::Extension|method(new self::Class::•()) in let final void #t77 = self::Extension|set#field(self::Extension|get#field(#t75), #t76) in #t76;
- let final self::Class? #t78 = c in #t78.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t78, let final self::Class? #t79 = self::Extension|get#field(new self::Class::•()) in let final void #t80 = self::Extension|set#field(new self::Class::•(), #t79) in #t79);
- c = let final self::Class? #t81 = c in #t81.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t82 = let final self::Class? #t83 = self::Extension|get#field(new self::Class::•()) in let final void #t84 = self::Extension|set#field(new self::Class::•(), #t83) in #t83 in let final void #t85 = self::Extension|set#field(#t81, #t82) in #t82;
- let final self::Class? #t86 = c in #t86.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t86, let final self::Class #t87 = let final self::Class #t88 = new self::Class::•() in let final void #t89 = self::Extension|set#field(new self::Class::•(), #t88) in #t88 in let final void #t90 = self::Extension|set#field(new self::Class::•(), #t87) in #t87);
- c = let final self::Class? #t91 = c in #t91.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t92 = let final self::Class #t93 = let final self::Class #t94 = new self::Class::•() in let final void #t95 = self::Extension|set#field(new self::Class::•(), #t94) in #t94 in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t93) in #t93 in let final void #t97 = self::Extension|set#field(#t91, #t92) in #t92;
- let final self::Class? #t98 = c in #t98.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t98, let final self::Class? #t99 = self::Extension|method(new self::Class::•()) in let final void #t100 = self::Extension|set#field(new self::Class::•(), #t99) in #t99);
- c = let final self::Class? #t101 = c in #t101.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t102 = let final self::Class? #t103 = self::Extension|method(new self::Class::•()) in let final void #t104 = self::Extension|set#field(new self::Class::•(), #t103) in #t103 in let final void #t105 = self::Extension|set#field(#t101, #t102) in #t102;
- let final self::Class? #t106 = c in #t106.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t106), self::Extension|get#field(new self::Class::•()));
- c = let final self::Class? #t107 = c in #t107.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t108 = self::Extension|get#field(new self::Class::•()) in let final void #t109 = self::Extension|set#field(self::Extension|method(#t107), #t108) in #t108;
- let final self::Class? #t110 = c in #t110.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t110), let final self::Class #t111 = new self::Class::•() in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t111) in #t111);
- c = let final self::Class? #t113 = c in #t113.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t114 = let final self::Class #t115 = new self::Class::•() in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115 in let final void #t117 = self::Extension|set#field(self::Extension|method(#t113), #t114) in #t114;
- let final self::Class? #t118 = c in #t118.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t118), self::Extension|method(new self::Class::•()));
- c = let final self::Class? #t119 = c in #t119.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t120 = self::Extension|method(new self::Class::•()) in let final void #t121 = self::Extension|set#field(self::Extension|method(#t119), #t120) in #t120;
- let final self::Class? #t122 = c in #t122.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|get#field(#t122)));
- let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t123)), new self::Class::•());
- c = let final self::Class? #t124 = c in #t124.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t125 = new self::Class::•() in let final void #t126 = self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t124)), #t125) in #t125;
- let final self::Class? #t127 = c in #t127.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|get#field(#t127)));
- let final self::Class? #t128 = c in #t128.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t128, self::Extension|get#field(self::Extension|method(new self::Class::•())));
- c = let final self::Class? #t129 = c in #t129.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t130 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t131 = self::Extension|set#field(#t129, #t130) in #t130;
- let final self::Class? #t132 = c in #t132.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t132, let final self::Class #t133 = new self::Class::•() in let final void #t134 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t133) in #t133);
- c = let final self::Class? #t135 = c in #t135.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t136 = let final self::Class #t137 = new self::Class::•() in let final void #t138 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t137) in #t137 in let final void #t139 = self::Extension|set#field(#t135, #t136) in #t136;
- let final self::Class? #t140 = c in #t140.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t140, self::Extension|method(self::Extension|method(new self::Class::•())));
- c = let final self::Class? #t141 = c in #t141.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t142 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t143 = self::Extension|set#field(#t141, #t142) in #t142;
- let final self::Class? #t144 = c in #t144.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|method(#t144)));
- let final self::Class? #t145 = c in #t145.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|method(#t145)), new self::Class::•());
- let final self::Class? #t146 = c in #t146.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|method(#t146)));
+ let final self::Class? #t1 = c in #t1.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t1{self::Class});
+ let final self::Class? #t2 = c in #t2.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t2{self::Class}, new self::Class::•());
+ c = let final self::Class? #t3 = c in #t3.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t4 = new self::Class::•() in let final void #t5 = self::Extension|set#field(#t3{self::Class}, #t4) in #t4;
+ let final self::Class #t6 = c{self::Class} in #t6.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t6);
+ let final self::Class #t7 = c{self::Class} in #t7.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(#t7));
+ let final self::Class #t8 = c{self::Class} in #t8.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t9 = self::Extension|get#field(#t8) in #t9.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t9{self::Class});
+ let final self::Class #t10 = c{self::Class} in #t10.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t11 = self::Extension|get#field(self::Extension|get#field(#t10)) in #t11.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t11{self::Class});
+ let final self::Class #t12 = c{self::Class} in #t12.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t12), new self::Class::•());
+ let final self::Class #t13 = c{self::Class} in #t13.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t14 = self::Extension|get#field(#t13) in #t14.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t14{self::Class}, new self::Class::•());
+ let final self::Class #t15 = c{self::Class} in #t15.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t16 = self::Extension|get#field(self::Extension|get#field(#t15)) in #t16.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t16{self::Class}, new self::Class::•());
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t17 = c in #t17.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t17{self::Class})));
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t19 = new self::Class::•() in let final void #t20 = self::Extension|set#field(#t18{self::Class}, #t19) in #t19));
+ self::throws(() → self::Class? => self::Extension|get#field(let final self::Class? #t21 = c in #t21.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t21{self::Class})));
+ c = let final self::Class #t22 = c{self::Class} in #t22.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t23 = new self::Class::•() in let final void #t24 = self::Extension|set#field(self::Extension|get#field(#t22), #t23) in #t23;
+ c = let final self::Class #t25 = c{self::Class} in #t25.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t26 = self::Extension|get#field(#t25) in #t26.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t27 = new self::Class::•() in let final void #t28 = self::Extension|set#field(#t26{self::Class}, #t27) in #t27;
+ c = let final self::Class #t29 = c{self::Class} in #t29.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t30 = self::Extension|get#field(self::Extension|get#field(#t29)) in #t30.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t31 = new self::Class::•() in let final void #t32 = self::Extension|set#field(#t30{self::Class}, #t31) in #t31;
+ let final self::Class #t33 = c{self::Class} in #t33.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(#t33));
+ let final self::Class #t34 = c{self::Class} in #t34.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t34, self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class #t35 = c{self::Class} in #t35.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t36 = self::Extension|get#field(new self::Class::•()) in let final void #t37 = self::Extension|set#field(#t35, #t36) in #t36;
+ let final self::Class? #t38 = c in #t38.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t38{self::Class}, let final self::Class #t39 = new self::Class::•() in let final void #t40 = self::Extension|set#field(new self::Class::•(), #t39) in #t39);
+ c = let final self::Class? #t41 = c in #t41.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t42 = let final self::Class #t43 = new self::Class::•() in let final void #t44 = self::Extension|set#field(new self::Class::•(), #t43) in #t43 in let final void #t45 = self::Extension|set#field(#t41{self::Class}, #t42) in #t42;
+ let final self::Class #t46 = c{self::Class} in #t46.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t46, self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t47 = c{self::Class} in #t47.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t48 = self::Extension|method(new self::Class::•()) in let final void #t49 = self::Extension|set#field(#t47, #t48) in #t48;
+ let final self::Class? #t50 = c in #t50.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(#t50{self::Class}));
+ let final self::Class? #t51 = c in #t51.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t51{self::Class}), new self::Class::•());
+ let final self::Class? #t52 = c in #t52.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(#t52{self::Class}));
+ let final self::Class? #t53 = c in #t53.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|get#field(#t53{self::Class})));
+ let final self::Class? #t54 = c in #t54.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t54{self::Class})), new self::Class::•());
+ c = let final self::Class? #t55 = c in #t55.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t56 = new self::Class::•() in let final void #t57 = self::Extension|set#field(self::Extension|get#field(self::Extension|get#field(#t55{self::Class})), #t56) in #t56;
+ let final self::Class #t58 = c{self::Class} in #t58.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|get#field(#t58)));
+ let final self::Class #t59 = c{self::Class} in #t59.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t59, self::Extension|get#field(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class #t60 = c{self::Class} in #t60.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t61 = self::Extension|get#field(self::Extension|get#field(new self::Class::•())) in let final void #t62 = self::Extension|set#field(#t60, #t61) in #t61;
+ let final self::Class? #t63 = c in #t63.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t63{self::Class}, let final self::Class #t64 = new self::Class::•() in let final void #t65 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t64) in #t64);
+ c = let final self::Class? #t66 = c in #t66.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t67 = let final self::Class #t68 = new self::Class::•() in let final void #t69 = self::Extension|set#field(self::Extension|get#field(new self::Class::•()), #t68) in #t68 in let final void #t70 = self::Extension|set#field(#t66{self::Class}, #t67) in #t67;
+ let final self::Class #t71 = c{self::Class} in #t71.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t71, self::Extension|method(self::Extension|get#field(new self::Class::•())));
+ c = let final self::Class #t72 = c{self::Class} in #t72.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t73 = self::Extension|method(self::Extension|get#field(new self::Class::•())) in let final void #t74 = self::Extension|set#field(#t72, #t73) in #t73;
+ let final self::Class? #t75 = c in #t75.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|get#field(self::Extension|method(#t75{self::Class})));
+ let final self::Class? #t76 = c in #t76.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(self::Extension|method(#t76{self::Class})), new self::Class::•());
+ let final self::Class? #t77 = c in #t77.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|get#field(self::Extension|method(#t77{self::Class})));
+ let final self::Class? #t78 = c in #t78.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t78{self::Class}), self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class? #t79 = c in #t79.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t80 = self::Extension|get#field(new self::Class::•()) in let final void #t81 = self::Extension|set#field(self::Extension|get#field(#t79{self::Class}), #t80) in #t80;
+ let final self::Class? #t82 = c in #t82.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|get#field(#t82{self::Class}), let final self::Class #t83 = new self::Class::•() in let final void #t84 = self::Extension|set#field(new self::Class::•(), #t83) in #t83);
+ c = let final self::Class? #t85 = c in #t85.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t86 = let final self::Class #t87 = new self::Class::•() in let final void #t88 = self::Extension|set#field(new self::Class::•(), #t87) in #t87 in let final void #t89 = self::Extension|set#field(self::Extension|get#field(#t85{self::Class}), #t86) in #t86;
+ let final self::Class #t90 = c{self::Class} in #t90.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|get#field(#t90), self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t91 = c{self::Class} in #t91.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t92 = self::Extension|method(new self::Class::•()) in let final void #t93 = self::Extension|set#field(self::Extension|get#field(#t91), #t92) in #t92;
+ let final self::Class? #t94 = c in #t94.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t94{self::Class}, let final self::Class? #t95 = self::Extension|get#field(new self::Class::•()) in let final void #t96 = self::Extension|set#field(new self::Class::•(), #t95) in #t95);
+ c = let final self::Class? #t97 = c in #t97.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t98 = let final self::Class? #t99 = self::Extension|get#field(new self::Class::•()) in let final void #t100 = self::Extension|set#field(new self::Class::•(), #t99) in #t99 in let final void #t101 = self::Extension|set#field(#t97{self::Class}, #t98) in #t98;
+ let final self::Class? #t102 = c in #t102.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t102{self::Class}, let final self::Class #t103 = let final self::Class #t104 = new self::Class::•() in let final void #t105 = self::Extension|set#field(new self::Class::•(), #t104) in #t104 in let final void #t106 = self::Extension|set#field(new self::Class::•(), #t103) in #t103);
+ c = let final self::Class? #t107 = c in #t107.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t108 = let final self::Class #t109 = let final self::Class #t110 = new self::Class::•() in let final void #t111 = self::Extension|set#field(new self::Class::•(), #t110) in #t110 in let final void #t112 = self::Extension|set#field(new self::Class::•(), #t109) in #t109 in let final void #t113 = self::Extension|set#field(#t107{self::Class}, #t108) in #t108;
+ let final self::Class #t114 = c{self::Class} in #t114.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t114, let final self::Class? #t115 = self::Extension|method(new self::Class::•()) in let final void #t116 = self::Extension|set#field(new self::Class::•(), #t115) in #t115);
+ c = let final self::Class #t117 = c{self::Class} in #t117.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t118 = let final self::Class? #t119 = self::Extension|method(new self::Class::•()) in let final void #t120 = self::Extension|set#field(new self::Class::•(), #t119) in #t119 in let final void #t121 = self::Extension|set#field(#t117, #t118) in #t118;
+ let final self::Class? #t122 = c in #t122.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t122{self::Class}), self::Extension|get#field(new self::Class::•()));
+ c = let final self::Class? #t123 = c in #t123.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t124 = self::Extension|get#field(new self::Class::•()) in let final void #t125 = self::Extension|set#field(self::Extension|method(#t123{self::Class}), #t124) in #t124;
+ let final self::Class? #t126 = c in #t126.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(#t126{self::Class}), let final self::Class #t127 = new self::Class::•() in let final void #t128 = self::Extension|set#field(new self::Class::•(), #t127) in #t127);
+ c = let final self::Class? #t129 = c in #t129.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t130 = let final self::Class #t131 = new self::Class::•() in let final void #t132 = self::Extension|set#field(new self::Class::•(), #t131) in #t131 in let final void #t133 = self::Extension|set#field(self::Extension|method(#t129{self::Class}), #t130) in #t130;
+ let final self::Class #t134 = c{self::Class} in #t134.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(self::Extension|method(#t134), self::Extension|method(new self::Class::•()));
+ c = let final self::Class #t135 = c{self::Class} in #t135.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t136 = self::Extension|method(new self::Class::•()) in let final void #t137 = self::Extension|set#field(self::Extension|method(#t135), #t136) in #t136;
+ let final self::Class? #t138 = c in #t138.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|get#field(#t138{self::Class})));
+ let final self::Class? #t139 = c in #t139.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t139{self::Class})), new self::Class::•());
+ c = let final self::Class? #t140 = c in #t140.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t141 = new self::Class::•() in let final void #t142 = self::Extension|set#field(self::Extension|method(self::Extension|get#field(#t140{self::Class})), #t141) in #t141;
+ let final self::Class #t143 = c{self::Class} in #t143.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|get#field(#t143)));
+ let final self::Class #t144 = c{self::Class} in #t144.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t144, self::Extension|get#field(self::Extension|method(new self::Class::•())));
+ c = let final self::Class #t145 = c{self::Class} in #t145.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t146 = self::Extension|get#field(self::Extension|method(new self::Class::•())) in let final void #t147 = self::Extension|set#field(#t145, #t146) in #t146;
+ let final self::Class? #t148 = c in #t148.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(#t148{self::Class}, let final self::Class #t149 = new self::Class::•() in let final void #t150 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t149) in #t149);
+ c = let final self::Class? #t151 = c in #t151.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t152 = let final self::Class #t153 = new self::Class::•() in let final void #t154 = self::Extension|set#field(self::Extension|method(new self::Class::•()), #t153) in #t153 in let final void #t155 = self::Extension|set#field(#t151{self::Class}, #t152) in #t152;
+ let final self::Class #t156 = c{self::Class} in #t156.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t156, self::Extension|method(self::Extension|method(new self::Class::•())));
+ c = let final self::Class #t157 = c{self::Class} in #t157.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t158 = self::Extension|method(self::Extension|method(new self::Class::•())) in let final void #t159 = self::Extension|set#field(#t157, #t158) in #t158;
+ let final self::Class? #t160 = c in #t160.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(self::Extension|method(self::Extension|method(#t160{self::Class})));
+ let final self::Class? #t161 = c in #t161.{core::Object::==}(null) ?{self::Class} null : self::Extension|set#field(self::Extension|method(self::Extension|method(#t161{self::Class})), new self::Class::•());
+ let final self::Class? #t162 = c in #t162.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|method(self::Extension|method(#t162{self::Class})));
+ let final self::Class? #t163 = c in #t163.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t164 = self::Extension|method(#t163{self::Class}) in #t164.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(#t164{self::Class});
}
static method indexAccess(self::Class? c) → void {
- let final self::Class? #t147 = c in #t147.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t147, c);
- let final self::Class? #t148 = c in #t148.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(#t148, c, new self::Class::•());
- let final self::Class? #t149 = c in #t149.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t149, c));
- let final self::Class? #t150 = c in #t150.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|get#field(#t150), c);
- let final self::Class? #t151 = c in #t151.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|get#field(#t151), c, new self::Class::•());
- c = let final self::Class? #t152 = c in #t152.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t153 = self::Extension|get#field(#t152) in let final self::Class? #t154 = c in let final self::Class #t155 = new self::Class::•() in let final void #t156 = self::Extension|[]=(#t153, #t154, #t155) in #t155;
- let final self::Class? #t157 = c in #t157.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|get#field(#t157), c));
- let final self::Class? #t158 = c in #t158.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t159 = self::Extension|get#field(#t158) in let final self::Class? #t160 = c in self::Extension|[]=(#t159, #t160, self::Extension|+(self::Extension|[](#t159, #t160), 0));
- c = let final self::Class? #t161 = c in #t161.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t162 = self::Extension|get#field(#t161) in let final self::Class? #t163 = c in let final self::Class? #t164 = self::Extension|+(self::Extension|[](#t162, #t163), 0) in let final void #t165 = self::Extension|[]=(#t162, #t163, #t164) in #t164;
- let final self::Class? #t166 = c in #t166.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t167 = self::Extension|get#field(#t166) in let final self::Class? #t168 = c in self::Extension|[]=(#t167, #t168, self::Extension|+(self::Extension|[](#t167, #t168), 1));
- c = let final self::Class? #t169 = c in #t169.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t170 = self::Extension|get#field(#t169) in let final self::Class? #t171 = c in let final self::Class? #t172 = self::Extension|[](#t170, #t171) in let final void #t173 = self::Extension|[]=(#t170, #t171, self::Extension|+(#t172, 1)) in #t172;
- let final self::Class? #t174 = c in #t174.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t175 = self::Extension|get#field(#t174) in let final self::Class? #t176 = c in let final self::Class? #t177 = self::Extension|+(self::Extension|[](#t175, #t176), 1) in let final void #t178 = self::Extension|[]=(#t175, #t176, #t177) in #t177;
- c = let final self::Class? #t179 = c in #t179.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t180 = self::Extension|get#field(#t179) in let final self::Class? #t181 = c in let final self::Class? #t182 = self::Extension|+(self::Extension|[](#t180, #t181), 1) in let final void #t183 = self::Extension|[]=(#t180, #t181, #t182) in #t182;
+ let final self::Class? #t165 = c in #t165.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t165{self::Class}, c{self::Class});
+ let final self::Class? #t166 = c in #t166.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(#t166{self::Class}, c{self::Class}, new self::Class::•());
+ let final self::Class? #t167 = c in #t167.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t167{self::Class}, c{self::Class}));
+ let final self::Class? #t168 = c in #t168.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|get#field(#t168{self::Class}), c{self::Class});
+ let final self::Class? #t169 = c in #t169.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|get#field(#t169{self::Class}), c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t170 = c in #t170.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t171 = self::Extension|get#field(#t170{self::Class}) in let final self::Class #t172 = c{self::Class} in let final self::Class #t173 = new self::Class::•() in let final void #t174 = self::Extension|[]=(#t171, #t172, #t173) in #t173;
+ let final self::Class #t175 = c{self::Class} in #t175.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|get#field(#t175), c{self::Class}));
+ let final self::Class #t176 = c{self::Class} in #t176.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t177 = self::Extension|get#field(#t176) in let final self::Class #t178 = c{self::Class} in self::Extension|[]=(#t177, #t178, self::Extension|+(self::Extension|[](#t177, #t178), 0));
+ c = let final self::Class #t179 = c{self::Class} in #t179.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t180 = self::Extension|get#field(#t179) in let final self::Class #t181 = c{self::Class} in let final self::Class? #t182 = self::Extension|+(self::Extension|[](#t180, #t181), 0) in let final void #t183 = self::Extension|[]=(#t180, #t181, #t182) in #t182;
+ let final self::Class? #t184 = c in #t184.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t185 = c{self::Class} in self::Extension|[](#t184{self::Class}, #t185).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t184{self::Class}, #t185, c{self::Class}) : null;
+ c = let final self::Class? #t186 = c in #t186.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t187 = c{self::Class} in let final self::Class? #t188 = self::Extension|[](#t186{self::Class}, #t187) in #t188.{core::Object::==}(null) ?{self::Class} let final self::Class #t189 = c{self::Class} in let final void #t190 = self::Extension|[]=(#t186{self::Class}, #t187, #t189) in #t189 : #t188;
+ let final self::Class #t191 = c{self::Class} in #t191.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t192 = c{self::Class} in self::Extension|[]=(#t191, #t192, self::Extension|+(self::Extension|[](#t191, #t192), 0));
+ c = let final self::Class #t193 = c{self::Class} in #t193.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t194 = c{self::Class} in let final self::Class? #t195 = self::Extension|+(self::Extension|[](#t193, #t194), 0) in let final void #t196 = self::Extension|[]=(#t193, #t194, #t195) in #t195;
+ let final self::Class? #t197 = c in #t197.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t198 = c{self::Class} in self::Extension|[]=(#t197{self::Class}, #t198, self::Extension|+(self::Extension|[](#t197{self::Class}, #t198), 0));
+ c = let final self::Class? #t199 = c in #t199.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t200 = c{self::Class} in let final self::Class? #t201 = self::Extension|+(self::Extension|[](#t199{self::Class}, #t200), 0) in let final void #t202 = self::Extension|[]=(#t199{self::Class}, #t200, #t201) in #t201;
+ let final self::Class? #t203 = c in #t203.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t204 = c{self::Class} in self::Extension|[]=(#t203{self::Class}, #t204, self::Extension|+(self::Extension|[](#t203{self::Class}, #t204), 1));
+ c = let final self::Class? #t205 = c in #t205.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t206 = c{self::Class} in let final self::Class? #t207 = self::Extension|[](#t205{self::Class}, #t206) in let final void #t208 = self::Extension|[]=(#t205{self::Class}, #t206, self::Extension|+(#t207, 1)) in #t207;
+ let final self::Class? #t209 = c in #t209.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t210 = c{self::Class} in let final self::Class? #t211 = self::Extension|+(self::Extension|[](#t209{self::Class}, #t210), 1) in let final void #t212 = self::Extension|[]=(#t209{self::Class}, #t210, #t211) in #t211;
+ c = let final self::Class? #t213 = c in #t213.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t214 = c{self::Class} in let final self::Class? #t215 = self::Extension|+(self::Extension|[](#t213{self::Class}, #t214), 1) in let final void #t216 = self::Extension|[]=(#t213{self::Class}, #t214, #t215) in #t215;
+ let final self::Class? #t217 = c in #t217.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t218 = self::Extension|get#field(#t217{self::Class}) in let final self::Class #t219 = c{self::Class} in self::Extension|[]=(#t218, #t219, self::Extension|+(self::Extension|[](#t218, #t219), 1));
+ c = let final self::Class? #t220 = c in #t220.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t221 = self::Extension|get#field(#t220{self::Class}) in let final self::Class #t222 = c{self::Class} in let final self::Class? #t223 = self::Extension|[](#t221, #t222) in let final void #t224 = self::Extension|[]=(#t221, #t222, self::Extension|+(#t223, 1)) in #t223;
+ let final self::Class? #t225 = c in #t225.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t226 = self::Extension|get#field(#t225{self::Class}) in let final self::Class #t227 = c{self::Class} in let final self::Class? #t228 = self::Extension|+(self::Extension|[](#t226, #t227), 1) in let final void #t229 = self::Extension|[]=(#t226, #t227, #t228) in #t228;
+ c = let final self::Class? #t230 = c in #t230.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t231 = self::Extension|get#field(#t230{self::Class}) in let final self::Class #t232 = c{self::Class} in let final self::Class? #t233 = self::Extension|+(self::Extension|[](#t231, #t232), 1) in let final void #t234 = self::Extension|[]=(#t231, #t232, #t233) in #t233;
+ let final self::Class? #t235 = c in #t235.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](self::Extension|[](self::Extension|get#field(#t235{self::Class}), c{self::Class}), c{self::Class});
+ let final self::Class? #t236 = c in #t236.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(self::Extension|[](self::Extension|get#field(#t236{self::Class}), c{self::Class}), c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t237 = c in #t237.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t238 = self::Extension|[](self::Extension|get#field(#t237{self::Class}), c{self::Class}) in let final self::Class #t239 = c{self::Class} in let final self::Class #t240 = new self::Class::•() in let final void #t241 = self::Extension|[]=(#t238, #t239, #t240) in #t240;
+ let final self::Class #t242 = c{self::Class} in #t242.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](self::Extension|[](self::Extension|get#field(#t242), c{self::Class}), c{self::Class}));
+ let final self::Class #t243 = c{self::Class} in #t243.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t244 = self::Extension|[](self::Extension|get#field(#t243), c{self::Class}) in let final self::Class #t245 = c{self::Class} in self::Extension|[]=(#t244, #t245, self::Extension|+(self::Extension|[](#t244, #t245), 0));
+ c = let final self::Class #t246 = c{self::Class} in #t246.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t247 = self::Extension|[](self::Extension|get#field(#t246), c{self::Class}) in let final self::Class #t248 = c{self::Class} in let final self::Class? #t249 = self::Extension|+(self::Extension|[](#t247, #t248), 0) in let final void #t250 = self::Extension|[]=(#t247, #t248, #t249) in #t249;
+ let final self::Class? #t251 = c in #t251.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t252 = self::Extension|[](self::Extension|get#field(#t251{self::Class}), c{self::Class}) in let final self::Class #t253 = c{self::Class} in self::Extension|[]=(#t252, #t253, self::Extension|+(self::Extension|[](#t252, #t253), 1));
+ c = let final self::Class? #t254 = c in #t254.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t255 = self::Extension|[](self::Extension|get#field(#t254{self::Class}), c{self::Class}) in let final self::Class #t256 = c{self::Class} in let final self::Class? #t257 = self::Extension|[](#t255, #t256) in let final void #t258 = self::Extension|[]=(#t255, #t256, self::Extension|+(#t257, 1)) in #t257;
+ let final self::Class? #t259 = c in #t259.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t260 = self::Extension|[](self::Extension|get#field(#t259{self::Class}), c{self::Class}) in let final self::Class #t261 = c{self::Class} in let final self::Class? #t262 = self::Extension|+(self::Extension|[](#t260, #t261), 1) in let final void #t263 = self::Extension|[]=(#t260, #t261, #t262) in #t262;
+ c = let final self::Class? #t264 = c in #t264.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t265 = self::Extension|[](self::Extension|get#field(#t264{self::Class}), c{self::Class}) in let final self::Class #t266 = c{self::Class} in let final self::Class? #t267 = self::Extension|+(self::Extension|[](#t265, #t266), 1) in let final void #t268 = self::Extension|[]=(#t265, #t266, #t267) in #t267;
+ let final self::Class? #t269 = c in #t269.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t270 = self::Extension|[](#t269{self::Class}, c{self::Class}) in #t270.{core::Object::==}(null) ?{self::Class?} null : self::Extension|[](#t270{self::Class}, c{self::Class});
+ let final self::Class? #t271 = c in #t271.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t272 = self::Extension|[](#t271{self::Class}, c{self::Class}) in #t272.{core::Object::==}(null) ?{self::Class} null : self::Extension|[]=(#t272{self::Class}, c{self::Class}, new self::Class::•());
+ c = let final self::Class? #t273 = c in #t273.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t274 = self::Extension|[](#t273{self::Class}, c{self::Class}) in #t274.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t275 = c{self::Class} in let final self::Class #t276 = new self::Class::•() in let final void #t277 = self::Extension|[]=(#t274{self::Class}, #t275, #t276) in #t276;
+ let final self::Class #t278 = c{self::Class} in #t278.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t279 = self::Extension|[](#t278, c{self::Class}) in #t279.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t279{self::Class}, c{self::Class}));
+ c = let final self::Class #t280 = c{self::Class} in #t280.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t281 = self::Extension|[](#t280, c{self::Class}) in #t281.{core::Object::==}(null) ?{self::Class?} null : self::Extension|method(self::Extension|[](#t281{self::Class}, c{self::Class}));
+ let final self::Class? #t282 = c in #t282.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t283 = self::Extension|[](#t282{self::Class}, c{self::Class}) in #t283.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t284 = c{self::Class} in self::Extension|[](#t283{self::Class}, #t284).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t283{self::Class}, #t284, c{self::Class}) : null;
+ c = let final self::Class? #t285 = c in #t285.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t286 = self::Extension|[](#t285{self::Class}, c{self::Class}) in #t286.{core::Object::==}(null) ?{self::Class} null : let final self::Class #t287 = c{self::Class} in let final self::Class? #t288 = self::Extension|[](#t286{self::Class}, #t287) in #t288.{core::Object::==}(null) ?{self::Class} let final self::Class #t289 = c{self::Class} in let final void #t290 = self::Extension|[]=(#t286{self::Class}, #t287, #t289) in #t289 : #t288;
+ let final self::Class #t291 = c{self::Class} in #t291.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t292 = self::Extension|[](#t291, c{self::Class}) in #t292.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t293 = c{self::Class} in self::Extension|[]=(#t292{self::Class}, #t293, self::Extension|+(self::Extension|[](#t292{self::Class}, #t293), 0));
+ c = let final self::Class #t294 = c{self::Class} in #t294.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t295 = self::Extension|[](#t294, c{self::Class}) in #t295.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t296 = c{self::Class} in let final self::Class? #t297 = self::Extension|+(self::Extension|[](#t295{self::Class}, #t296), 0) in let final void #t298 = self::Extension|[]=(#t295{self::Class}, #t296, #t297) in #t297;
+ let final self::Class? #t299 = c in #t299.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t300 = self::Extension|[](#t299{self::Class}, c{self::Class}) in #t300.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t301 = c{self::Class} in self::Extension|[]=(#t300{self::Class}, #t301, self::Extension|+(self::Extension|[](#t300{self::Class}, #t301), 1));
+ c = let final self::Class? #t302 = c in #t302.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t303 = self::Extension|[](#t302{self::Class}, c{self::Class}) in #t303.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t304 = c{self::Class} in let final self::Class? #t305 = self::Extension|[](#t303{self::Class}, #t304) in let final void #t306 = self::Extension|[]=(#t303{self::Class}, #t304, self::Extension|+(#t305, 1)) in #t305;
+ let final self::Class? #t307 = c in #t307.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t308 = self::Extension|[](#t307{self::Class}, c{self::Class}) in #t308.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t309 = c{self::Class} in let final self::Class? #t310 = self::Extension|+(self::Extension|[](#t308{self::Class}, #t309), 1) in let final void #t311 = self::Extension|[]=(#t308{self::Class}, #t309, #t310) in #t310;
+ c = let final self::Class? #t312 = c in #t312.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t313 = self::Extension|[](#t312{self::Class}, c{self::Class}) in #t313.{core::Object::==}(null) ?{self::Class?} null : let final self::Class #t314 = c{self::Class} in let final self::Class? #t315 = self::Extension|+(self::Extension|[](#t313{self::Class}, #t314), 1) in let final void #t316 = self::Extension|[]=(#t313{self::Class}, #t314, #t315) in #t315;
}
static method operatorAccess(self::Class? c) → void {
- self::throws(() → self::Class? => self::Extension|+(let final self::Class? #t184 = c in #t184.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t184), 0));
- self::throws(() → self::Class? => self::Extension|unary-(let final self::Class? #t185 = c in #t185.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t185)));
- let final self::Class? #t186 = c in #t186.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t186, self::Extension|+(self::Extension|get#field(#t186), 0));
- c = let final self::Class? #t187 = c in #t187.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t188 = self::Extension|+(self::Extension|get#field(#t187), 0) in let final void #t189 = self::Extension|set#field(#t187, #t188) in #t188;
- let final self::Class? #t190 = c in #t190.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t191 = self::Extension|get#field(#t190) in self::Extension|set#field(#t191, self::Extension|+(self::Extension|get#field(#t191), 0));
- c = let final self::Class? #t192 = c in #t192.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t193 = self::Extension|get#field(#t192) in let final self::Class? #t194 = self::Extension|+(self::Extension|get#field(#t193), 0) in let final void #t195 = self::Extension|set#field(#t193, #t194) in #t194;
- let final self::Class? #t196 = c in #t196.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t196, self::Extension|+(self::Extension|get#field(#t196), 1));
- c = let final self::Class? #t197 = c in #t197.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t198 = self::Extension|get#field(#t197) in let final void #t199 = self::Extension|set#field(#t197, self::Extension|+(#t198, 1)) in #t198;
- let final self::Class? #t200 = c in #t200.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t201 = self::Extension|+(self::Extension|get#field(#t200), 1) in let final void #t202 = self::Extension|set#field(#t200, #t201) in #t201;
- c = let final self::Class? #t203 = c in #t203.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t204 = self::Extension|+(self::Extension|get#field(#t203), 1) in let final void #t205 = self::Extension|set#field(#t203, #t204) in #t204;
+ self::throws(() → self::Class? => self::Extension|+(let final self::Class? #t317 = c in #t317.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t317{self::Class}), 0));
+ self::throws(() → self::Class? => self::Extension|unary-(let final self::Class? #t318 = c in #t318.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t318{self::Class})));
+ let final self::Class? #t319 = c in #t319.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t319, self::Extension|+(self::Extension|get#field(#t319), 0));
+ c = let final self::Class? #t320 = c in #t320.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t321 = self::Extension|+(self::Extension|get#field(#t320), 0) in let final void #t322 = self::Extension|set#field(#t320, #t321) in #t321;
+ let final self::Class? #t323 = c in #t323.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t324 = self::Extension|get#field(#t323{self::Class}) in self::Extension|set#field(#t324, self::Extension|+(self::Extension|get#field(#t324), 0));
+ c = let final self::Class? #t325 = c in #t325.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t326 = self::Extension|get#field(#t325{self::Class}) in let final self::Class? #t327 = self::Extension|+(self::Extension|get#field(#t326), 0) in let final void #t328 = self::Extension|set#field(#t326, #t327) in #t327;
+ let final self::Class? #t329 = c in #t329.{core::Object::==}(null) ?{self::Class?} null : self::Extension|set#field(#t329, self::Extension|+(self::Extension|get#field(#t329), 1));
+ c = let final self::Class? #t330 = c in #t330.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t331 = self::Extension|get#field(#t330) in let final void #t332 = self::Extension|set#field(#t330, self::Extension|+(#t331, 1)) in #t331;
+ let final self::Class? #t333 = c in #t333.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t334 = self::Extension|+(self::Extension|get#field(#t333), 1) in let final void #t335 = self::Extension|set#field(#t333, #t334) in #t334;
+ c = let final self::Class? #t336 = c in #t336.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t337 = self::Extension|+(self::Extension|get#field(#t336), 1) in let final void #t338 = self::Extension|set#field(#t336, #t337) in #t337;
}
static method ifNull(self::Class? c) → void {
- let final self::Class? #t206 = c in #t206.{core::Object::==}(null) ?{self::Class?} null : self::Extension|get#field(#t206).{core::Object::==}(null) ?{self::Class?} self::Extension|set#field(#t206, c) : null;
- c = let final self::Class? #t207 = c in #t207.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t208 = self::Extension|get#field(#t207) in #t208.{core::Object::==}(null) ?{self::Class?} let final self::Class? #t209 = c in let final void #t210 = self::Extension|set#field(#t207, #t209) in #t209 : #t208;
- let final self::Class? #t211 = c in #t211.{core::Object::==}(null) ?{self::Class?} null : let final self::Class? #t212 = self::Extension|get#field(#t211) in let final self::Class? #t213 = c in self::Extension|[](#t212, #t213).{core::Object::==}(null) ?{self::Class?} self::Extension|[]=(#t212, #t213, c) : null;
+ let final self::Class? #t339 = c in #t339.{core::Object::==}(null) ?{self::Class} null : self::Extension|get#field(#t339).{core::Object::==}(null) ?{self::Class} self::Extension|set#field(#t339, c{self::Class}) : null;
+ c = let final self::Class? #t340 = c in #t340.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t341 = self::Extension|get#field(#t340) in #t341.{core::Object::==}(null) ?{self::Class} let final self::Class #t342 = c{self::Class} in let final void #t343 = self::Extension|set#field(#t340, #t342) in #t342 : #t341;
+ let final self::Class #t344 = c{self::Class} in #t344.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t345 = self::Extension|get#field(#t344) in self::Extension|get#field(#t345).{core::Object::==}(null) ?{self::Class} self::Extension|set#field(#t345, c{self::Class}) : null;
+ c = let final self::Class #t346 = c{self::Class} in #t346.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t347 = self::Extension|get#field(#t346) in let final self::Class? #t348 = self::Extension|get#field(#t347) in #t348.{core::Object::==}(null) ?{self::Class} let final self::Class #t349 = c{self::Class} in let final void #t350 = self::Extension|set#field(#t347, #t349) in #t349 : #t348;
+ let final self::Class #t351 = c{self::Class} in #t351.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t352 = self::Extension|get#field(#t351) in let final self::Class #t353 = c{self::Class} in self::Extension|[](#t352, #t353).{core::Object::==}(null) ?{self::Class} self::Extension|[]=(#t352, #t353, c{self::Class}) : null;
+ c = let final self::Class #t354 = c{self::Class} in #t354.{core::Object::==}(null) ?{self::Class} null : let final self::Class? #t355 = self::Extension|get#field(#t354) in let final self::Class #t356 = c{self::Class} in let final self::Class? #t357 = self::Extension|[](#t355, #t356) in #t357.{core::Object::==}(null) ?{self::Class} let final self::Class #t358 = c{self::Class} in let final void #t359 = self::Extension|[]=(#t355, #t356, #t358) in #t358 : #t357;
}
static method throws(() → void f) → void {
try {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_index.dart b/pkg/front_end/testcases/nnbd/null_shorting_index.dart
index ce4173d..bb70d4d 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_index.dart
+++ b/pkg/front_end/testcases/nnbd/null_shorting_index.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
class Class1 {
+ Class2? get field => null;
int operator [](int index) => index;
void operator []=(int index, int value) {}
}
@@ -56,4 +57,28 @@
Extension(c2)?.[0]++;
Extension(c2)?.[0] ??= 1;
Extension(c2)?.[0] ??= 1 + Extension(c2)[1];
+
+ c1?.field?.[0];
+ c1?.field?.[0] = 1;
+ c1?.field?.[0] = 1 + c1[0];
+ c1?.field?.[0] += 1;
+ c1?.field?.[0] += 1 + c1[0];
+ // TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
+ // update.
+ ++c1?.field?.[0];
+ c1?.field?.[0]++;
+ c1?.field?.[0] ??= 1;
+ c1?.field?.[0] ??= 1 + c1[1];
+
+ Extension(c1?.field)?.[0];
+ Extension(c1?.field)?.[0] = 1;
+ Extension(c1?.field)?.[0] = 1 + Extension(c2)[0];
+ Extension(c1?.field)?.[0] += 1;
+ Extension(c1?.field)?.[0] += 1 + Extension(c2)[0];
+ // TODO(johnniwinther): ++ should probably not be null-shorted, awaiting spec
+ // update.
+ ++Extension(c1?.field)?.[0];
+ Extension(c1?.field)?.[0]++;
+ Extension(c1?.field)?.[0] ??= 1;
+ Extension(c1?.field)?.[0] ??= 1 + Extension(c2)[1];
}
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_index.dart.outline.expect b/pkg/front_end/testcases/nnbd/null_shorting_index.dart.outline.expect
index f96ff24..6b81c57 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_index.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_index.dart.outline.expect
@@ -3,7 +3,9 @@
import "dart:core" as core;
class Class1 extends core::Object {
- synthetic constructor •() → self::Class1*
+ synthetic constructor •() → self::Class1
+ ;
+ get field() → self::Class2?
;
operator [](core::int index) → core::int
;
@@ -12,7 +14,7 @@
}
class Class2 extends core::Object {
field core::int field;
- synthetic constructor •() → self::Class2*
+ synthetic constructor •() → self::Class2
;
}
extension Extension on self::Class2 {
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_index.dart.strong.expect b/pkg/front_end/testcases/nnbd/null_shorting_index.dart.strong.expect
index ebb3975..4352c28 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_index.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_index.dart.strong.expect
@@ -3,16 +3,18 @@
import "dart:core" as core;
class Class1 extends core::Object {
- synthetic constructor •() → self::Class1*
+ synthetic constructor •() → self::Class1
: super core::Object::•()
;
+ get field() → self::Class2?
+ return null;
operator [](core::int index) → core::int
return index;
operator []=(core::int index, core::int value) → void {}
}
class Class2 extends core::Object {
field core::int field = null;
- synthetic constructor •() → self::Class2*
+ synthetic constructor •() → self::Class2
: super core::Object::•()
;
}
@@ -27,32 +29,50 @@
}
static method main() → dynamic {
self::Class1? c1;
- let final self::Class1? #t1 = c1 in #t1.{core::Object::==}(null) ?{core::int} null : #t1.{self::Class1::[]}(0);
- let final self::Class1? #t2 = c1 in #t2.{core::Object::==}(null) ?{core::int} null : #t2.{self::Class1::[]=}(0, 1);
- let final self::Class1? #t3 = c1 in #t3.{core::Object::==}(null) ?{core::int} null : #t3.{self::Class1::[]=}(0, 1.{core::num::+}(c1.{self::Class1::[]}(0)));
- let final self::Class1? #t4 = c1 in #t4.{core::Object::==}(null) ?{core::int} null : let final core::int #t5 = 0 in #t4.{self::Class1::[]=}(#t5, #t4.{self::Class1::[]}(#t5).{core::num::+}(1));
- let final self::Class1? #t6 = c1 in #t6.{core::Object::==}(null) ?{core::int} null : let final core::int #t7 = 0 in #t6.{self::Class1::[]=}(#t7, #t6.{self::Class1::[]}(#t7).{core::num::+}(1.{core::num::+}(c1.{self::Class1::[]}(0))));
- let final self::Class1? #t8 = c1 in #t8.{core::Object::==}(null) ?{core::int} null : let final core::int #t9 = 0 in let final core::int #t10 = #t8.{self::Class1::[]}(#t9).{core::num::+}(1) in let final void #t11 = #t8.{self::Class1::[]=}(#t9, #t10) in #t10;
- let final self::Class1? #t12 = c1 in #t12.{core::Object::==}(null) ?{core::int} null : let final core::int #t13 = 0 in #t12.{self::Class1::[]=}(#t13, #t12.{self::Class1::[]}(#t13).{core::num::+}(1));
- let final self::Class1? #t14 = c1 in #t14.{core::Object::==}(null) ?{core::int} null : let final core::int #t15 = 0 in #t14.{self::Class1::[]}(#t15).{core::num::==}(null) ?{core::int} #t14.{self::Class1::[]=}(#t15, 1) : null;
- let final self::Class1? #t16 = c1 in #t16.{core::Object::==}(null) ?{core::int} null : let final core::int #t17 = 0 in #t16.{self::Class1::[]}(#t17).{core::num::==}(null) ?{core::int} #t16.{self::Class1::[]=}(#t17, 1.{core::num::+}(c1.{self::Class1::[]}(1))) : null;
+ let final self::Class1? #t1 = c1 in #t1.{core::Object::==}(null) ?{core::int} null : #t1{self::Class1}.{self::Class1::[]}(0);
+ let final self::Class1? #t2 = c1 in #t2.{core::Object::==}(null) ?{core::int} null : #t2{self::Class1}.{self::Class1::[]=}(0, 1);
+ let final self::Class1? #t3 = c1 in #t3.{core::Object::==}(null) ?{core::int} null : #t3{self::Class1}.{self::Class1::[]=}(0, 1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(0)));
+ let final self::Class1? #t4 = c1 in #t4.{core::Object::==}(null) ?{core::int} null : let final core::int #t5 = 0 in #t4{self::Class1}.{self::Class1::[]=}(#t5, #t4{self::Class1}.{self::Class1::[]}(#t5).{core::num::+}(1));
+ let final self::Class1? #t6 = c1 in #t6.{core::Object::==}(null) ?{core::int} null : let final core::int #t7 = 0 in #t6{self::Class1}.{self::Class1::[]=}(#t7, #t6{self::Class1}.{self::Class1::[]}(#t7).{core::num::+}(1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(0))));
+ let final self::Class1? #t8 = c1 in #t8.{core::Object::==}(null) ?{core::int} null : let final core::int #t9 = 0 in let final core::int #t10 = #t8{self::Class1}.{self::Class1::[]}(#t9).{core::num::+}(1) in let final void #t11 = #t8{self::Class1}.{self::Class1::[]=}(#t9, #t10) in #t10;
+ let final self::Class1? #t12 = c1 in #t12.{core::Object::==}(null) ?{core::int} null : let final core::int #t13 = 0 in #t12{self::Class1}.{self::Class1::[]=}(#t13, #t12{self::Class1}.{self::Class1::[]}(#t13).{core::num::+}(1));
+ let final self::Class1? #t14 = c1 in #t14.{core::Object::==}(null) ?{core::int} null : let final core::int #t15 = 0 in #t14{self::Class1}.{self::Class1::[]}(#t15).{core::num::==}(null) ?{core::int} #t14{self::Class1}.{self::Class1::[]=}(#t15, 1) : null;
+ let final self::Class1? #t16 = c1 in #t16.{core::Object::==}(null) ?{core::int} null : let final core::int #t17 = 0 in #t16{self::Class1}.{self::Class1::[]}(#t17).{core::num::==}(null) ?{core::int} #t16{self::Class1}.{self::Class1::[]=}(#t17, 1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(1))) : null;
self::Class2? c2;
- let final self::Class2? #t18 = c2 in #t18.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t18, 0);
- let final self::Class2? #t19 = c2 in #t19.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t19, 0, 1);
- let final self::Class2? #t20 = c2 in #t20.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t20, 0, 1.{core::num::+}(self::Extension|[](c2, 0)));
- let final self::Class2? #t21 = c2 in #t21.{core::Object::==}(null) ?{core::int} null : let final core::int #t22 = 0 in self::Extension|[]=(#t21, #t22, self::Extension|[](#t21, #t22).{core::num::+}(1));
- let final self::Class2? #t23 = c2 in #t23.{core::Object::==}(null) ?{core::int} null : let final core::int #t24 = 0 in self::Extension|[]=(#t23, #t24, self::Extension|[](#t23, #t24).{core::num::+}(1.{core::num::+}(self::Extension|[](c2, 0))));
- let final self::Class2? #t25 = c2 in #t25.{core::Object::==}(null) ?{core::int} null : let final core::int #t26 = 0 in let final core::int #t27 = self::Extension|[](#t25, #t26).{core::num::+}(1) in let final void #t28 = self::Extension|[]=(#t25, #t26, #t27) in #t27;
- let final self::Class2? #t29 = c2 in #t29.{core::Object::==}(null) ?{core::int} null : let final core::int #t30 = 0 in self::Extension|[]=(#t29, #t30, self::Extension|[](#t29, #t30).{core::num::+}(1));
- let final self::Class2? #t31 = c2 in #t31.{core::Object::==}(null) ?{core::int} null : let final core::int #t32 = 0 in self::Extension|[](#t31, #t32).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t31, #t32, 1) : null;
- let final self::Class2? #t33 = c2 in #t33.{core::Object::==}(null) ?{core::int} null : let final core::int #t34 = 0 in self::Extension|[](#t33, #t34).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t33, #t34, 1.{core::num::+}(self::Extension|[](c2, 1))) : null;
- let final self::Class2? #t35 = c2 in #t35.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t35, 0);
- let final self::Class2? #t36 = c2 in #t36.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t36, 0, 1);
- let final self::Class2? #t37 = c2 in #t37.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t37, 0, 1.{core::num::+}(self::Extension|[](c2, 0)));
- let final self::Class2? #t38 = c2 in #t38.{core::Object::==}(null) ?{core::int} null : let final core::int #t39 = 0 in self::Extension|[]=(#t38, #t39, self::Extension|[](#t38, #t39).{core::num::+}(1));
- let final self::Class2? #t40 = c2 in #t40.{core::Object::==}(null) ?{core::int} null : let final core::int #t41 = 0 in self::Extension|[]=(#t40, #t41, self::Extension|[](#t40, #t41).{core::num::+}(1.{core::num::+}(self::Extension|[](c2, 0))));
- let final self::Class2? #t42 = c2 in #t42.{core::Object::==}(null) ?{core::int} null : let final core::int #t43 = 0 in let final core::int #t44 = self::Extension|[](#t42, #t43).{core::num::+}(1) in let final void #t45 = self::Extension|[]=(#t42, #t43, #t44) in #t44;
- let final self::Class2? #t46 = c2 in #t46.{core::Object::==}(null) ?{core::int} null : let final core::int #t47 = 0 in self::Extension|[]=(#t46, #t47, self::Extension|[](#t46, #t47).{core::num::+}(1));
- let final self::Class2? #t48 = c2 in #t48.{core::Object::==}(null) ?{core::int} null : let final core::int #t49 = 0 in self::Extension|[](#t48, #t49).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t48, #t49, 1) : null;
- let final self::Class2? #t50 = c2 in #t50.{core::Object::==}(null) ?{core::int} null : let final core::int #t51 = 0 in self::Extension|[](#t50, #t51).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t50, #t51, 1.{core::num::+}(self::Extension|[](c2, 1))) : null;
+ let final self::Class2? #t18 = c2 in #t18.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t18{self::Class2}, 0);
+ let final self::Class2? #t19 = c2 in #t19.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t19{self::Class2}, 0, 1);
+ let final self::Class2? #t20 = c2 in #t20.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t20{self::Class2}, 0, 1.{core::num::+}(self::Extension|[](c2{self::Class2}, 0)));
+ let final self::Class2? #t21 = c2 in #t21.{core::Object::==}(null) ?{core::int} null : let final core::int #t22 = 0 in self::Extension|[]=(#t21{self::Class2}, #t22, self::Extension|[](#t21{self::Class2}, #t22).{core::num::+}(1));
+ let final self::Class2? #t23 = c2 in #t23.{core::Object::==}(null) ?{core::int} null : let final core::int #t24 = 0 in self::Extension|[]=(#t23{self::Class2}, #t24, self::Extension|[](#t23{self::Class2}, #t24).{core::num::+}(1.{core::num::+}(self::Extension|[](c2{self::Class2}, 0))));
+ let final self::Class2? #t25 = c2 in #t25.{core::Object::==}(null) ?{core::int} null : let final core::int #t26 = 0 in let final core::int #t27 = self::Extension|[](#t25{self::Class2}, #t26).{core::num::+}(1) in let final void #t28 = self::Extension|[]=(#t25{self::Class2}, #t26, #t27) in #t27;
+ let final self::Class2? #t29 = c2 in #t29.{core::Object::==}(null) ?{core::int} null : let final core::int #t30 = 0 in self::Extension|[]=(#t29{self::Class2}, #t30, self::Extension|[](#t29{self::Class2}, #t30).{core::num::+}(1));
+ let final self::Class2? #t31 = c2 in #t31.{core::Object::==}(null) ?{core::int} null : let final core::int #t32 = 0 in self::Extension|[](#t31{self::Class2}, #t32).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t31{self::Class2}, #t32, 1) : null;
+ let final self::Class2? #t33 = c2 in #t33.{core::Object::==}(null) ?{core::int} null : let final core::int #t34 = 0 in self::Extension|[](#t33{self::Class2}, #t34).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t33{self::Class2}, #t34, 1.{core::num::+}(self::Extension|[](c2{self::Class2}, 1))) : null;
+ let final self::Class2? #t35 = c2 in #t35.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t35{self::Class2}, 0);
+ let final self::Class2? #t36 = c2 in #t36.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t36{self::Class2}, 0, 1);
+ let final self::Class2? #t37 = c2 in #t37.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t37{self::Class2}, 0, 1.{core::num::+}(self::Extension|[](c2{self::Class2}, 0)));
+ let final self::Class2? #t38 = c2 in #t38.{core::Object::==}(null) ?{core::int} null : let final core::int #t39 = 0 in self::Extension|[]=(#t38{self::Class2}, #t39, self::Extension|[](#t38{self::Class2}, #t39).{core::num::+}(1));
+ let final self::Class2? #t40 = c2 in #t40.{core::Object::==}(null) ?{core::int} null : let final core::int #t41 = 0 in self::Extension|[]=(#t40{self::Class2}, #t41, self::Extension|[](#t40{self::Class2}, #t41).{core::num::+}(1.{core::num::+}(self::Extension|[](c2{self::Class2}, 0))));
+ let final self::Class2? #t42 = c2 in #t42.{core::Object::==}(null) ?{core::int} null : let final core::int #t43 = 0 in let final core::int #t44 = self::Extension|[](#t42{self::Class2}, #t43).{core::num::+}(1) in let final void #t45 = self::Extension|[]=(#t42{self::Class2}, #t43, #t44) in #t44;
+ let final self::Class2? #t46 = c2 in #t46.{core::Object::==}(null) ?{core::int} null : let final core::int #t47 = 0 in self::Extension|[]=(#t46{self::Class2}, #t47, self::Extension|[](#t46{self::Class2}, #t47).{core::num::+}(1));
+ let final self::Class2? #t48 = c2 in #t48.{core::Object::==}(null) ?{core::int} null : let final core::int #t49 = 0 in self::Extension|[](#t48{self::Class2}, #t49).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t48{self::Class2}, #t49, 1) : null;
+ let final self::Class2? #t50 = c2 in #t50.{core::Object::==}(null) ?{core::int} null : let final core::int #t51 = 0 in self::Extension|[](#t50{self::Class2}, #t51).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t50{self::Class2}, #t51, 1.{core::num::+}(self::Extension|[](c2{self::Class2}, 1))) : null;
+ let final self::Class1? #t52 = c1 in #t52.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t53 = #t52{self::Class1}.{self::Class1::field} in #t53.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t53{self::Class2}, 0);
+ let final self::Class1? #t54 = c1 in #t54.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t55 = #t54{self::Class1}.{self::Class1::field} in #t55.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t55{self::Class2}, 0, 1);
+ let final self::Class1? #t56 = c1 in #t56.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t57 = #t56{self::Class1}.{self::Class1::field} in #t57.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t57{self::Class2}, 0, 1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(0)));
+ let final self::Class1? #t58 = c1 in #t58.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t59 = #t58{self::Class1}.{self::Class1::field} in #t59.{core::Object::==}(null) ?{core::int} null : let final core::int #t60 = 0 in self::Extension|[]=(#t59{self::Class2}, #t60, self::Extension|[](#t59{self::Class2}, #t60).{core::num::+}(1));
+ let final self::Class1? #t61 = c1 in #t61.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t62 = #t61{self::Class1}.{self::Class1::field} in #t62.{core::Object::==}(null) ?{core::int} null : let final core::int #t63 = 0 in self::Extension|[]=(#t62{self::Class2}, #t63, self::Extension|[](#t62{self::Class2}, #t63).{core::num::+}(1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(0))));
+ let final self::Class1? #t64 = c1 in #t64.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t65 = #t64{self::Class1}.{self::Class1::field} in #t65.{core::Object::==}(null) ?{core::int} null : let final core::int #t66 = 0 in let final core::int #t67 = self::Extension|[](#t65{self::Class2}, #t66).{core::num::+}(1) in let final void #t68 = self::Extension|[]=(#t65{self::Class2}, #t66, #t67) in #t67;
+ let final self::Class1? #t69 = c1 in #t69.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t70 = #t69{self::Class1}.{self::Class1::field} in #t70.{core::Object::==}(null) ?{core::int} null : let final core::int #t71 = 0 in self::Extension|[]=(#t70{self::Class2}, #t71, self::Extension|[](#t70{self::Class2}, #t71).{core::num::+}(1));
+ let final self::Class1? #t72 = c1 in #t72.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t73 = #t72{self::Class1}.{self::Class1::field} in #t73.{core::Object::==}(null) ?{core::int} null : let final core::int #t74 = 0 in self::Extension|[](#t73{self::Class2}, #t74).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t73{self::Class2}, #t74, 1) : null;
+ let final self::Class1? #t75 = c1 in #t75.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t76 = #t75{self::Class1}.{self::Class1::field} in #t76.{core::Object::==}(null) ?{core::int} null : let final core::int #t77 = 0 in self::Extension|[](#t76{self::Class2}, #t77).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t76{self::Class2}, #t77, 1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(1))) : null;
+ let final self::Class1? #t78 = c1 in #t78.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t79 = #t78{self::Class1}.{self::Class1::field} in #t79.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t79{self::Class2}, 0);
+ let final self::Class1? #t80 = c1 in #t80.{core::Object::==}(null) ?{void} null : let final self::Class2? #t81 = #t80{self::Class1}.{self::Class1::field} in #t81.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t81{self::Class2}, 0, 1);
+ let final self::Class1? #t82 = c1 in #t82.{core::Object::==}(null) ?{void} null : let final self::Class2? #t83 = #t82{self::Class1}.{self::Class1::field} in #t83.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t83{self::Class2}, 0, 1.{core::num::+}(self::Extension|[](c2, 0)));
+ let final self::Class1? #t84 = c1 in #t84.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t85 = #t84{self::Class1}.{self::Class1::field} in #t85.{core::Object::==}(null) ?{core::int} null : let final core::int #t86 = 0 in self::Extension|[]=(#t85{self::Class2}, #t86, self::Extension|[](#t85{self::Class2}, #t86).{core::num::+}(1));
+ let final self::Class1? #t87 = c1 in #t87.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t88 = #t87{self::Class1}.{self::Class1::field} in #t88.{core::Object::==}(null) ?{core::int} null : let final core::int #t89 = 0 in self::Extension|[]=(#t88{self::Class2}, #t89, self::Extension|[](#t88{self::Class2}, #t89).{core::num::+}(1.{core::num::+}(self::Extension|[](c2, 0))));
+ let final self::Class1? #t90 = c1 in #t90.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t91 = #t90{self::Class1}.{self::Class1::field} in #t91.{core::Object::==}(null) ?{core::int} null : let final core::int #t92 = 0 in let final core::int #t93 = self::Extension|[](#t91{self::Class2}, #t92).{core::num::+}(1) in let final void #t94 = self::Extension|[]=(#t91{self::Class2}, #t92, #t93) in #t93;
+ let final self::Class1? #t95 = c1 in #t95.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t96 = #t95{self::Class1}.{self::Class1::field} in #t96.{core::Object::==}(null) ?{core::int} null : let final core::int #t97 = 0 in self::Extension|[]=(#t96{self::Class2}, #t97, self::Extension|[](#t96{self::Class2}, #t97).{core::num::+}(1));
+ let final self::Class1? #t98 = c1 in #t98.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t99 = #t98{self::Class1}.{self::Class1::field} in #t99.{core::Object::==}(null) ?{core::int} null : let final core::int #t100 = 0 in self::Extension|[](#t99{self::Class2}, #t100).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t99{self::Class2}, #t100, 1) : null;
+ let final self::Class1? #t101 = c1 in #t101.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t102 = #t101{self::Class1}.{self::Class1::field} in #t102.{core::Object::==}(null) ?{core::int} null : let final core::int #t103 = 0 in self::Extension|[](#t102{self::Class2}, #t103).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t102{self::Class2}, #t103, 1.{core::num::+}(self::Extension|[](c2, 1))) : null;
}
diff --git a/pkg/front_end/testcases/nnbd/null_shorting_index.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/null_shorting_index.dart.strong.transformed.expect
index ebb3975..4352c28 100644
--- a/pkg/front_end/testcases/nnbd/null_shorting_index.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/null_shorting_index.dart.strong.transformed.expect
@@ -3,16 +3,18 @@
import "dart:core" as core;
class Class1 extends core::Object {
- synthetic constructor •() → self::Class1*
+ synthetic constructor •() → self::Class1
: super core::Object::•()
;
+ get field() → self::Class2?
+ return null;
operator [](core::int index) → core::int
return index;
operator []=(core::int index, core::int value) → void {}
}
class Class2 extends core::Object {
field core::int field = null;
- synthetic constructor •() → self::Class2*
+ synthetic constructor •() → self::Class2
: super core::Object::•()
;
}
@@ -27,32 +29,50 @@
}
static method main() → dynamic {
self::Class1? c1;
- let final self::Class1? #t1 = c1 in #t1.{core::Object::==}(null) ?{core::int} null : #t1.{self::Class1::[]}(0);
- let final self::Class1? #t2 = c1 in #t2.{core::Object::==}(null) ?{core::int} null : #t2.{self::Class1::[]=}(0, 1);
- let final self::Class1? #t3 = c1 in #t3.{core::Object::==}(null) ?{core::int} null : #t3.{self::Class1::[]=}(0, 1.{core::num::+}(c1.{self::Class1::[]}(0)));
- let final self::Class1? #t4 = c1 in #t4.{core::Object::==}(null) ?{core::int} null : let final core::int #t5 = 0 in #t4.{self::Class1::[]=}(#t5, #t4.{self::Class1::[]}(#t5).{core::num::+}(1));
- let final self::Class1? #t6 = c1 in #t6.{core::Object::==}(null) ?{core::int} null : let final core::int #t7 = 0 in #t6.{self::Class1::[]=}(#t7, #t6.{self::Class1::[]}(#t7).{core::num::+}(1.{core::num::+}(c1.{self::Class1::[]}(0))));
- let final self::Class1? #t8 = c1 in #t8.{core::Object::==}(null) ?{core::int} null : let final core::int #t9 = 0 in let final core::int #t10 = #t8.{self::Class1::[]}(#t9).{core::num::+}(1) in let final void #t11 = #t8.{self::Class1::[]=}(#t9, #t10) in #t10;
- let final self::Class1? #t12 = c1 in #t12.{core::Object::==}(null) ?{core::int} null : let final core::int #t13 = 0 in #t12.{self::Class1::[]=}(#t13, #t12.{self::Class1::[]}(#t13).{core::num::+}(1));
- let final self::Class1? #t14 = c1 in #t14.{core::Object::==}(null) ?{core::int} null : let final core::int #t15 = 0 in #t14.{self::Class1::[]}(#t15).{core::num::==}(null) ?{core::int} #t14.{self::Class1::[]=}(#t15, 1) : null;
- let final self::Class1? #t16 = c1 in #t16.{core::Object::==}(null) ?{core::int} null : let final core::int #t17 = 0 in #t16.{self::Class1::[]}(#t17).{core::num::==}(null) ?{core::int} #t16.{self::Class1::[]=}(#t17, 1.{core::num::+}(c1.{self::Class1::[]}(1))) : null;
+ let final self::Class1? #t1 = c1 in #t1.{core::Object::==}(null) ?{core::int} null : #t1{self::Class1}.{self::Class1::[]}(0);
+ let final self::Class1? #t2 = c1 in #t2.{core::Object::==}(null) ?{core::int} null : #t2{self::Class1}.{self::Class1::[]=}(0, 1);
+ let final self::Class1? #t3 = c1 in #t3.{core::Object::==}(null) ?{core::int} null : #t3{self::Class1}.{self::Class1::[]=}(0, 1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(0)));
+ let final self::Class1? #t4 = c1 in #t4.{core::Object::==}(null) ?{core::int} null : let final core::int #t5 = 0 in #t4{self::Class1}.{self::Class1::[]=}(#t5, #t4{self::Class1}.{self::Class1::[]}(#t5).{core::num::+}(1));
+ let final self::Class1? #t6 = c1 in #t6.{core::Object::==}(null) ?{core::int} null : let final core::int #t7 = 0 in #t6{self::Class1}.{self::Class1::[]=}(#t7, #t6{self::Class1}.{self::Class1::[]}(#t7).{core::num::+}(1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(0))));
+ let final self::Class1? #t8 = c1 in #t8.{core::Object::==}(null) ?{core::int} null : let final core::int #t9 = 0 in let final core::int #t10 = #t8{self::Class1}.{self::Class1::[]}(#t9).{core::num::+}(1) in let final void #t11 = #t8{self::Class1}.{self::Class1::[]=}(#t9, #t10) in #t10;
+ let final self::Class1? #t12 = c1 in #t12.{core::Object::==}(null) ?{core::int} null : let final core::int #t13 = 0 in #t12{self::Class1}.{self::Class1::[]=}(#t13, #t12{self::Class1}.{self::Class1::[]}(#t13).{core::num::+}(1));
+ let final self::Class1? #t14 = c1 in #t14.{core::Object::==}(null) ?{core::int} null : let final core::int #t15 = 0 in #t14{self::Class1}.{self::Class1::[]}(#t15).{core::num::==}(null) ?{core::int} #t14{self::Class1}.{self::Class1::[]=}(#t15, 1) : null;
+ let final self::Class1? #t16 = c1 in #t16.{core::Object::==}(null) ?{core::int} null : let final core::int #t17 = 0 in #t16{self::Class1}.{self::Class1::[]}(#t17).{core::num::==}(null) ?{core::int} #t16{self::Class1}.{self::Class1::[]=}(#t17, 1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(1))) : null;
self::Class2? c2;
- let final self::Class2? #t18 = c2 in #t18.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t18, 0);
- let final self::Class2? #t19 = c2 in #t19.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t19, 0, 1);
- let final self::Class2? #t20 = c2 in #t20.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t20, 0, 1.{core::num::+}(self::Extension|[](c2, 0)));
- let final self::Class2? #t21 = c2 in #t21.{core::Object::==}(null) ?{core::int} null : let final core::int #t22 = 0 in self::Extension|[]=(#t21, #t22, self::Extension|[](#t21, #t22).{core::num::+}(1));
- let final self::Class2? #t23 = c2 in #t23.{core::Object::==}(null) ?{core::int} null : let final core::int #t24 = 0 in self::Extension|[]=(#t23, #t24, self::Extension|[](#t23, #t24).{core::num::+}(1.{core::num::+}(self::Extension|[](c2, 0))));
- let final self::Class2? #t25 = c2 in #t25.{core::Object::==}(null) ?{core::int} null : let final core::int #t26 = 0 in let final core::int #t27 = self::Extension|[](#t25, #t26).{core::num::+}(1) in let final void #t28 = self::Extension|[]=(#t25, #t26, #t27) in #t27;
- let final self::Class2? #t29 = c2 in #t29.{core::Object::==}(null) ?{core::int} null : let final core::int #t30 = 0 in self::Extension|[]=(#t29, #t30, self::Extension|[](#t29, #t30).{core::num::+}(1));
- let final self::Class2? #t31 = c2 in #t31.{core::Object::==}(null) ?{core::int} null : let final core::int #t32 = 0 in self::Extension|[](#t31, #t32).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t31, #t32, 1) : null;
- let final self::Class2? #t33 = c2 in #t33.{core::Object::==}(null) ?{core::int} null : let final core::int #t34 = 0 in self::Extension|[](#t33, #t34).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t33, #t34, 1.{core::num::+}(self::Extension|[](c2, 1))) : null;
- let final self::Class2? #t35 = c2 in #t35.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t35, 0);
- let final self::Class2? #t36 = c2 in #t36.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t36, 0, 1);
- let final self::Class2? #t37 = c2 in #t37.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t37, 0, 1.{core::num::+}(self::Extension|[](c2, 0)));
- let final self::Class2? #t38 = c2 in #t38.{core::Object::==}(null) ?{core::int} null : let final core::int #t39 = 0 in self::Extension|[]=(#t38, #t39, self::Extension|[](#t38, #t39).{core::num::+}(1));
- let final self::Class2? #t40 = c2 in #t40.{core::Object::==}(null) ?{core::int} null : let final core::int #t41 = 0 in self::Extension|[]=(#t40, #t41, self::Extension|[](#t40, #t41).{core::num::+}(1.{core::num::+}(self::Extension|[](c2, 0))));
- let final self::Class2? #t42 = c2 in #t42.{core::Object::==}(null) ?{core::int} null : let final core::int #t43 = 0 in let final core::int #t44 = self::Extension|[](#t42, #t43).{core::num::+}(1) in let final void #t45 = self::Extension|[]=(#t42, #t43, #t44) in #t44;
- let final self::Class2? #t46 = c2 in #t46.{core::Object::==}(null) ?{core::int} null : let final core::int #t47 = 0 in self::Extension|[]=(#t46, #t47, self::Extension|[](#t46, #t47).{core::num::+}(1));
- let final self::Class2? #t48 = c2 in #t48.{core::Object::==}(null) ?{core::int} null : let final core::int #t49 = 0 in self::Extension|[](#t48, #t49).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t48, #t49, 1) : null;
- let final self::Class2? #t50 = c2 in #t50.{core::Object::==}(null) ?{core::int} null : let final core::int #t51 = 0 in self::Extension|[](#t50, #t51).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t50, #t51, 1.{core::num::+}(self::Extension|[](c2, 1))) : null;
+ let final self::Class2? #t18 = c2 in #t18.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t18{self::Class2}, 0);
+ let final self::Class2? #t19 = c2 in #t19.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t19{self::Class2}, 0, 1);
+ let final self::Class2? #t20 = c2 in #t20.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t20{self::Class2}, 0, 1.{core::num::+}(self::Extension|[](c2{self::Class2}, 0)));
+ let final self::Class2? #t21 = c2 in #t21.{core::Object::==}(null) ?{core::int} null : let final core::int #t22 = 0 in self::Extension|[]=(#t21{self::Class2}, #t22, self::Extension|[](#t21{self::Class2}, #t22).{core::num::+}(1));
+ let final self::Class2? #t23 = c2 in #t23.{core::Object::==}(null) ?{core::int} null : let final core::int #t24 = 0 in self::Extension|[]=(#t23{self::Class2}, #t24, self::Extension|[](#t23{self::Class2}, #t24).{core::num::+}(1.{core::num::+}(self::Extension|[](c2{self::Class2}, 0))));
+ let final self::Class2? #t25 = c2 in #t25.{core::Object::==}(null) ?{core::int} null : let final core::int #t26 = 0 in let final core::int #t27 = self::Extension|[](#t25{self::Class2}, #t26).{core::num::+}(1) in let final void #t28 = self::Extension|[]=(#t25{self::Class2}, #t26, #t27) in #t27;
+ let final self::Class2? #t29 = c2 in #t29.{core::Object::==}(null) ?{core::int} null : let final core::int #t30 = 0 in self::Extension|[]=(#t29{self::Class2}, #t30, self::Extension|[](#t29{self::Class2}, #t30).{core::num::+}(1));
+ let final self::Class2? #t31 = c2 in #t31.{core::Object::==}(null) ?{core::int} null : let final core::int #t32 = 0 in self::Extension|[](#t31{self::Class2}, #t32).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t31{self::Class2}, #t32, 1) : null;
+ let final self::Class2? #t33 = c2 in #t33.{core::Object::==}(null) ?{core::int} null : let final core::int #t34 = 0 in self::Extension|[](#t33{self::Class2}, #t34).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t33{self::Class2}, #t34, 1.{core::num::+}(self::Extension|[](c2{self::Class2}, 1))) : null;
+ let final self::Class2? #t35 = c2 in #t35.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t35{self::Class2}, 0);
+ let final self::Class2? #t36 = c2 in #t36.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t36{self::Class2}, 0, 1);
+ let final self::Class2? #t37 = c2 in #t37.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t37{self::Class2}, 0, 1.{core::num::+}(self::Extension|[](c2{self::Class2}, 0)));
+ let final self::Class2? #t38 = c2 in #t38.{core::Object::==}(null) ?{core::int} null : let final core::int #t39 = 0 in self::Extension|[]=(#t38{self::Class2}, #t39, self::Extension|[](#t38{self::Class2}, #t39).{core::num::+}(1));
+ let final self::Class2? #t40 = c2 in #t40.{core::Object::==}(null) ?{core::int} null : let final core::int #t41 = 0 in self::Extension|[]=(#t40{self::Class2}, #t41, self::Extension|[](#t40{self::Class2}, #t41).{core::num::+}(1.{core::num::+}(self::Extension|[](c2{self::Class2}, 0))));
+ let final self::Class2? #t42 = c2 in #t42.{core::Object::==}(null) ?{core::int} null : let final core::int #t43 = 0 in let final core::int #t44 = self::Extension|[](#t42{self::Class2}, #t43).{core::num::+}(1) in let final void #t45 = self::Extension|[]=(#t42{self::Class2}, #t43, #t44) in #t44;
+ let final self::Class2? #t46 = c2 in #t46.{core::Object::==}(null) ?{core::int} null : let final core::int #t47 = 0 in self::Extension|[]=(#t46{self::Class2}, #t47, self::Extension|[](#t46{self::Class2}, #t47).{core::num::+}(1));
+ let final self::Class2? #t48 = c2 in #t48.{core::Object::==}(null) ?{core::int} null : let final core::int #t49 = 0 in self::Extension|[](#t48{self::Class2}, #t49).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t48{self::Class2}, #t49, 1) : null;
+ let final self::Class2? #t50 = c2 in #t50.{core::Object::==}(null) ?{core::int} null : let final core::int #t51 = 0 in self::Extension|[](#t50{self::Class2}, #t51).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t50{self::Class2}, #t51, 1.{core::num::+}(self::Extension|[](c2{self::Class2}, 1))) : null;
+ let final self::Class1? #t52 = c1 in #t52.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t53 = #t52{self::Class1}.{self::Class1::field} in #t53.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t53{self::Class2}, 0);
+ let final self::Class1? #t54 = c1 in #t54.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t55 = #t54{self::Class1}.{self::Class1::field} in #t55.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t55{self::Class2}, 0, 1);
+ let final self::Class1? #t56 = c1 in #t56.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t57 = #t56{self::Class1}.{self::Class1::field} in #t57.{core::Object::==}(null) ?{core::int} null : self::Extension|[]=(#t57{self::Class2}, 0, 1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(0)));
+ let final self::Class1? #t58 = c1 in #t58.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t59 = #t58{self::Class1}.{self::Class1::field} in #t59.{core::Object::==}(null) ?{core::int} null : let final core::int #t60 = 0 in self::Extension|[]=(#t59{self::Class2}, #t60, self::Extension|[](#t59{self::Class2}, #t60).{core::num::+}(1));
+ let final self::Class1? #t61 = c1 in #t61.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t62 = #t61{self::Class1}.{self::Class1::field} in #t62.{core::Object::==}(null) ?{core::int} null : let final core::int #t63 = 0 in self::Extension|[]=(#t62{self::Class2}, #t63, self::Extension|[](#t62{self::Class2}, #t63).{core::num::+}(1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(0))));
+ let final self::Class1? #t64 = c1 in #t64.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t65 = #t64{self::Class1}.{self::Class1::field} in #t65.{core::Object::==}(null) ?{core::int} null : let final core::int #t66 = 0 in let final core::int #t67 = self::Extension|[](#t65{self::Class2}, #t66).{core::num::+}(1) in let final void #t68 = self::Extension|[]=(#t65{self::Class2}, #t66, #t67) in #t67;
+ let final self::Class1? #t69 = c1 in #t69.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t70 = #t69{self::Class1}.{self::Class1::field} in #t70.{core::Object::==}(null) ?{core::int} null : let final core::int #t71 = 0 in self::Extension|[]=(#t70{self::Class2}, #t71, self::Extension|[](#t70{self::Class2}, #t71).{core::num::+}(1));
+ let final self::Class1? #t72 = c1 in #t72.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t73 = #t72{self::Class1}.{self::Class1::field} in #t73.{core::Object::==}(null) ?{core::int} null : let final core::int #t74 = 0 in self::Extension|[](#t73{self::Class2}, #t74).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t73{self::Class2}, #t74, 1) : null;
+ let final self::Class1? #t75 = c1 in #t75.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t76 = #t75{self::Class1}.{self::Class1::field} in #t76.{core::Object::==}(null) ?{core::int} null : let final core::int #t77 = 0 in self::Extension|[](#t76{self::Class2}, #t77).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t76{self::Class2}, #t77, 1.{core::num::+}(c1{self::Class1}.{self::Class1::[]}(1))) : null;
+ let final self::Class1? #t78 = c1 in #t78.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t79 = #t78{self::Class1}.{self::Class1::field} in #t79.{core::Object::==}(null) ?{core::int} null : self::Extension|[](#t79{self::Class2}, 0);
+ let final self::Class1? #t80 = c1 in #t80.{core::Object::==}(null) ?{void} null : let final self::Class2? #t81 = #t80{self::Class1}.{self::Class1::field} in #t81.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t81{self::Class2}, 0, 1);
+ let final self::Class1? #t82 = c1 in #t82.{core::Object::==}(null) ?{void} null : let final self::Class2? #t83 = #t82{self::Class1}.{self::Class1::field} in #t83.{core::Object::==}(null) ?{void} null : self::Extension|[]=(#t83{self::Class2}, 0, 1.{core::num::+}(self::Extension|[](c2, 0)));
+ let final self::Class1? #t84 = c1 in #t84.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t85 = #t84{self::Class1}.{self::Class1::field} in #t85.{core::Object::==}(null) ?{core::int} null : let final core::int #t86 = 0 in self::Extension|[]=(#t85{self::Class2}, #t86, self::Extension|[](#t85{self::Class2}, #t86).{core::num::+}(1));
+ let final self::Class1? #t87 = c1 in #t87.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t88 = #t87{self::Class1}.{self::Class1::field} in #t88.{core::Object::==}(null) ?{core::int} null : let final core::int #t89 = 0 in self::Extension|[]=(#t88{self::Class2}, #t89, self::Extension|[](#t88{self::Class2}, #t89).{core::num::+}(1.{core::num::+}(self::Extension|[](c2, 0))));
+ let final self::Class1? #t90 = c1 in #t90.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t91 = #t90{self::Class1}.{self::Class1::field} in #t91.{core::Object::==}(null) ?{core::int} null : let final core::int #t92 = 0 in let final core::int #t93 = self::Extension|[](#t91{self::Class2}, #t92).{core::num::+}(1) in let final void #t94 = self::Extension|[]=(#t91{self::Class2}, #t92, #t93) in #t93;
+ let final self::Class1? #t95 = c1 in #t95.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t96 = #t95{self::Class1}.{self::Class1::field} in #t96.{core::Object::==}(null) ?{core::int} null : let final core::int #t97 = 0 in self::Extension|[]=(#t96{self::Class2}, #t97, self::Extension|[](#t96{self::Class2}, #t97).{core::num::+}(1));
+ let final self::Class1? #t98 = c1 in #t98.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t99 = #t98{self::Class1}.{self::Class1::field} in #t99.{core::Object::==}(null) ?{core::int} null : let final core::int #t100 = 0 in self::Extension|[](#t99{self::Class2}, #t100).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t99{self::Class2}, #t100, 1) : null;
+ let final self::Class1? #t101 = c1 in #t101.{core::Object::==}(null) ?{core::int} null : let final self::Class2? #t102 = #t101{self::Class1}.{self::Class1::field} in #t102.{core::Object::==}(null) ?{core::int} null : let final core::int #t103 = 0 in self::Extension|[](#t102{self::Class2}, #t103).{core::num::==}(null) ?{core::int} self::Extension|[]=(#t102{self::Class2}, #t103, 1.{core::num::+}(self::Extension|[](c2, 1))) : null;
}
diff --git a/pkg/front_end/testcases/nnbd/nullable_null.dart.outline.expect b/pkg/front_end/testcases/nnbd/nullable_null.dart.outline.expect
index 9c9d87a..937afc3 100644
--- a/pkg/front_end/testcases/nnbd/nullable_null.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/nullable_null.dart.outline.expect
@@ -3,15 +3,15 @@
import "dart:core" as core;
class A<X extends core::Object? = dynamic> extends core::Object {
- synthetic constructor •() → self::A<self::A::X%>*
+ synthetic constructor •() → self::A<self::A::X%>
;
}
class B extends self::A<core::Null?> {
- synthetic constructor •() → self::B*
+ synthetic constructor •() → self::B
;
}
class C extends core::Object {
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
;
method foo(core::Null? n, self::A<core::Null?> an) → core::Null?
;
diff --git a/pkg/front_end/testcases/nnbd/nullable_null.dart.strong.expect b/pkg/front_end/testcases/nnbd/nullable_null.dart.strong.expect
index 263e44a..f4e4282 100644
--- a/pkg/front_end/testcases/nnbd/nullable_null.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/nullable_null.dart.strong.expect
@@ -3,17 +3,17 @@
import "dart:core" as core;
class A<X extends core::Object? = dynamic> extends core::Object {
- synthetic constructor •() → self::A<self::A::X%>*
+ synthetic constructor •() → self::A<self::A::X%>
: super core::Object::•()
;
}
class B extends self::A<core::Null?> {
- synthetic constructor •() → self::B*
+ synthetic constructor •() → self::B
: super self::A::•()
;
}
class C extends core::Object {
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
: super core::Object::•()
;
method foo(core::Null? n, self::A<core::Null?> an) → core::Null?
diff --git a/pkg/front_end/testcases/nnbd/nullable_null.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/nullable_null.dart.strong.transformed.expect
index 263e44a..f4e4282 100644
--- a/pkg/front_end/testcases/nnbd/nullable_null.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/nullable_null.dart.strong.transformed.expect
@@ -3,17 +3,17 @@
import "dart:core" as core;
class A<X extends core::Object? = dynamic> extends core::Object {
- synthetic constructor •() → self::A<self::A::X%>*
+ synthetic constructor •() → self::A<self::A::X%>
: super core::Object::•()
;
}
class B extends self::A<core::Null?> {
- synthetic constructor •() → self::B*
+ synthetic constructor •() → self::B
: super self::A::•()
;
}
class C extends core::Object {
- synthetic constructor •() → self::C*
+ synthetic constructor •() → self::C
: super core::Object::•()
;
method foo(core::Null? n, self::A<core::Null?> an) → core::Null?
diff --git a/pkg/front_end/testcases/nnbd/nullable_param.dart.outline.expect b/pkg/front_end/testcases/nnbd/nullable_param.dart.outline.expect
index a40317e..42f3eca 100644
--- a/pkg/front_end/testcases/nnbd/nullable_param.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/nullable_param.dart.outline.expect
@@ -21,7 +21,7 @@
class Foo extends core::Object {
field core::int? field;
- synthetic constructor •() → self::Foo*
+ synthetic constructor •() → self::Foo
;
abstract method bar(core::int? x) → core::int?;
}
diff --git a/pkg/front_end/testcases/nnbd/nullable_param.dart.strong.expect b/pkg/front_end/testcases/nnbd/nullable_param.dart.strong.expect
index 610a9ee..ffa36e4 100644
--- a/pkg/front_end/testcases/nnbd/nullable_param.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/nullable_param.dart.strong.expect
@@ -21,7 +21,7 @@
class Foo extends core::Object {
field core::int? field = null;
- synthetic constructor •() → self::Foo*
+ synthetic constructor •() → self::Foo
: super core::Object::•()
;
abstract method bar(core::int? x) → core::int?;
diff --git a/pkg/front_end/testcases/nnbd/nullable_param.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/nullable_param.dart.strong.transformed.expect
index 610a9ee..ffa36e4 100644
--- a/pkg/front_end/testcases/nnbd/nullable_param.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/nullable_param.dart.strong.transformed.expect
@@ -21,7 +21,7 @@
class Foo extends core::Object {
field core::int? field = null;
- synthetic constructor •() → self::Foo*
+ synthetic constructor •() → self::Foo
: super core::Object::•()
;
abstract method bar(core::int? x) → core::int?;
diff --git a/pkg/front_end/testcases/nnbd/regress_null_aware.dart b/pkg/front_end/testcases/nnbd/regress_null_aware.dart
new file mode 100644
index 0000000..02b27e7
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/regress_null_aware.dart
@@ -0,0 +1,19 @@
+// Copyright (c) 2019, 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.md file.
+
+// Regression test for failure on CFE null-aware encoding.
+
+// @dart=2.6
+
+class Class {
+ Map<String, Set<String>> map;
+
+ List<String> method(String node, Set<String> set) => set.add(node)
+ ? [node, ...?map[node]?.expand((node) => method(node, set))?.toList()]
+ : [];
+}
+
+main(args) {
+ if (false) new Class().method('', <String>{});
+}
diff --git a/pkg/front_end/testcases/nnbd/regress_null_aware.dart.outline.expect b/pkg/front_end/testcases/nnbd/regress_null_aware.dart.outline.expect
new file mode 100644
index 0000000..73efd69
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/regress_null_aware.dart.outline.expect
@@ -0,0 +1,13 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Class extends core::Object {
+ field core::Map<core::String*, core::Set<core::String*>*>* map;
+ synthetic constructor •() → self::Class*
+ ;
+ method method(core::String* node, core::Set<core::String*>* set) → core::List<core::String*>*
+ ;
+}
+static method main(dynamic args) → dynamic
+ ;
diff --git a/pkg/front_end/testcases/nnbd/regress_null_aware.dart.strong.expect b/pkg/front_end/testcases/nnbd/regress_null_aware.dart.strong.expect
new file mode 100644
index 0000000..69301ed
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/regress_null_aware.dart.strong.expect
@@ -0,0 +1,24 @@
+library;
+import self as self;
+import "dart:core" as core;
+import "dart:collection" as col;
+
+class Class extends core::Object {
+ field core::Map<core::String*, core::Set<core::String*>*>* map = null;
+ synthetic constructor •() → self::Class*
+ : super core::Object::•()
+ ;
+ method method(core::String* node, core::Set<core::String*>* set) → core::List<core::String*>*
+ return set.{core::Set::add}(node) ?{core::List<core::String*>*} block {
+ final core::List<core::String*>* #t1 = <core::String*>[];
+ #t1.{core::List::add}(node);
+ final dynamic #t2 = let final core::Iterable<core::String*>* #t3 = let final core::Set<core::String*>* #t4 = this.{self::Class::map}.{core::Map::[]}(node) in #t4.{core::Object::==}(null) ?{core::Iterable<core::String*>*} null : #t4.{core::Iterable::expand}<core::String*>((core::String* node) → core::List<core::String*>* => this.{self::Class::method}(node, set)) in #t3.{core::Object::==}(null) ?{core::List<core::String*>*} null : #t3.{core::Iterable::toList}();
+ if(!#t2.{core::Object::==}(null))
+ for (final core::String* #t5 in #t2)
+ #t1.{core::List::add}(#t5);
+ } =>#t1 : <core::String*>[];
+}
+static method main(dynamic args) → dynamic {
+ if(false)
+ new self::Class::•().{self::Class::method}("", let final core::Set<core::String*>* #t6 = col::LinkedHashSet::•<core::String*>() in #t6);
+}
diff --git a/pkg/front_end/testcases/nnbd/regress_null_aware.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/regress_null_aware.dart.strong.transformed.expect
new file mode 100644
index 0000000..6f3bcfd
--- /dev/null
+++ b/pkg/front_end/testcases/nnbd/regress_null_aware.dart.strong.transformed.expect
@@ -0,0 +1,29 @@
+library;
+import self as self;
+import "dart:core" as core;
+import "dart:_internal" as _in;
+import "dart:collection" as col;
+
+class Class extends core::Object {
+ field core::Map<core::String*, core::Set<core::String*>*>* map = null;
+ synthetic constructor •() → self::Class*
+ : super core::Object::•()
+ ;
+ method method(core::String* node, core::Set<core::String*>* set) → core::List<core::String*>*
+ return set.{core::Set::add}(node) ?{core::List<core::String*>*} block {
+ final core::List<core::String*>* #t1 = <core::String*>[];
+ #t1.{core::List::add}(node);
+ final dynamic #t2 = let final core::Iterable<core::String*>* #t3 = let final core::Set<core::String*>* #t4 = this.{self::Class::map}.{core::Map::[]}(node) in #t4.{core::Object::==}(null) ?{core::Iterable<core::String*>*} null : #t4.{core::Iterable::expand}<core::String*>((core::String* node) → core::List<core::String*>* => this.{self::Class::method}(node, set)) in #t3.{core::Object::==}(null) ?{core::List<core::String*>*} null : #t3.{core::Iterable::toList}();
+ if(!#t2.{core::Object::==}(null)) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(#t2).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::String* #t5 = :sync-for-iterator.{core::Iterator::current};
+ #t1.{core::List::add}(#t5);
+ }
+ }
+ } =>#t1 : <core::String*>[];
+}
+static method main(dynamic args) → dynamic {
+ if(false)
+ new self::Class::•().{self::Class::method}("", let final core::Set<core::String*>* #t6 = col::LinkedHashSet::•<core::String*>() in #t6);
+}
diff --git a/pkg/front_end/testcases/nnbd/required.dart.outline.expect b/pkg/front_end/testcases/nnbd/required.dart.outline.expect
index d5dda81..d196109 100644
--- a/pkg/front_end/testcases/nnbd/required.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/required.dart.outline.expect
@@ -5,7 +5,7 @@
typedef Typedef1 = ({a: core::int, required b: core::int}) → dynamic;
typedef Typedef2 = ({a: core::int, required b: core::int}) → dynamic;
class Class extends core::Object {
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
;
method method({core::int a, required core::int b, required final core::int c, required covariant final core::int d}) → dynamic
;
diff --git a/pkg/front_end/testcases/nnbd/required.dart.strong.expect b/pkg/front_end/testcases/nnbd/required.dart.strong.expect
index 4ce5b20..b495798 100644
--- a/pkg/front_end/testcases/nnbd/required.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/required.dart.strong.expect
@@ -5,7 +5,7 @@
typedef Typedef1 = ({a: core::int, required b: core::int}) → dynamic;
typedef Typedef2 = ({a: core::int, required b: core::int}) → dynamic;
class Class extends core::Object {
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int a = #C1, required core::int b = #C1, required final core::int c = #C1, required covariant final core::int d = #C1}) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/required.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/required.dart.strong.transformed.expect
index 4ce5b20..b495798 100644
--- a/pkg/front_end/testcases/nnbd/required.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/required.dart.strong.transformed.expect
@@ -5,7 +5,7 @@
typedef Typedef1 = ({a: core::int, required b: core::int}) → dynamic;
typedef Typedef2 = ({a: core::int, required b: core::int}) → dynamic;
class Class extends core::Object {
- synthetic constructor •() → self::Class*
+ synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int a = #C1, required core::int b = #C1, required final core::int c = #C1, required covariant final core::int d = #C1}) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.outline.expect b/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.outline.expect
index 537af02..78939a7 100644
--- a/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.outline.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class A<T extends core::Object? = core::Object?, S extends core::Object = core::Object> extends core::Object {
- synthetic constructor •() → self::A<self::A::T%, self::A::S>*
+ synthetic constructor •() → self::A<self::A::T%, self::A::S>
;
method hest<generic-covariant-impl X extends self::A::T% = self::A::T%, Y extends core::List<self::A::hest::X%> = core::List<self::A::T%>, Z extends core::List<self::A::hest::X?> = core::List<self::A::T?>>() → dynamic
;
diff --git a/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.strong.expect b/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.strong.expect
index cbc95c4..b23b0d3 100644
--- a/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.strong.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class A<T extends core::Object? = core::Object?, S extends core::Object = core::Object> extends core::Object {
- synthetic constructor •() → self::A<self::A::T%, self::A::S>*
+ synthetic constructor •() → self::A<self::A::T%, self::A::S>
: super core::Object::•()
;
method hest<generic-covariant-impl X extends self::A::T% = self::A::T%, Y extends core::List<self::A::hest::X%> = core::List<self::A::T%>, Z extends core::List<self::A::hest::X?> = core::List<self::A::T?>>() → dynamic
diff --git a/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.strong.transformed.expect
index cbc95c4..b23b0d3 100644
--- a/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/substitution_in_inference.dart.strong.transformed.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class A<T extends core::Object? = core::Object?, S extends core::Object = core::Object> extends core::Object {
- synthetic constructor •() → self::A<self::A::T%, self::A::S>*
+ synthetic constructor •() → self::A<self::A::T%, self::A::S>
: super core::Object::•()
;
method hest<generic-covariant-impl X extends self::A::T% = self::A::T%, Y extends core::List<self::A::hest::X%> = core::List<self::A::T%>, Z extends core::List<self::A::hest::X?> = core::List<self::A::T?>>() → dynamic
diff --git a/pkg/front_end/testcases/nnbd/type_parameter_types.dart.outline.expect b/pkg/front_end/testcases/nnbd/type_parameter_types.dart.outline.expect
index 54c224f..0ae7b83 100644
--- a/pkg/front_end/testcases/nnbd/type_parameter_types.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/type_parameter_types.dart.outline.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class A<X extends core::Object = core::Object, Y extends core::Object? = core::Object?> extends core::Object {
- synthetic constructor •() → self::A<self::A::X, self::A::Y%>*
+ synthetic constructor •() → self::A<self::A::X, self::A::Y%>
;
method foo() → self::A::X
;
@@ -13,19 +13,19 @@
;
}
class B<X extends core::List<self::B::Y%> = core::List<core::Object?>, Y extends core::Object? = core::Object?> extends core::Object {
- synthetic constructor •() → self::B<self::B::X, self::B::Y%>*
+ synthetic constructor •() → self::B<self::B::X, self::B::Y%>
;
method foo(generic-covariant-impl self::B::X x, generic-covariant-impl self::B::Y% y) → dynamic
;
}
class C<X extends core::List<self::C::Y%>? = core::List<dynamic>?, Y extends core::List<self::C::X%>? = core::List<dynamic>?> extends core::Object {
- synthetic constructor •() → self::C<self::C::X%, self::C::Y%>*
+ synthetic constructor •() → self::C<self::C::X%, self::C::Y%>
;
method foo(generic-covariant-impl self::C::X% x, generic-covariant-impl self::C::Y% y) → dynamic
;
}
class D<X extends self::D::Y% = dynamic, Y extends self::D::Z% = dynamic, Z extends core::Object? = dynamic> extends core::Object {
- synthetic constructor •() → self::D<self::D::X%, self::D::Y%, self::D::Z%>*
+ synthetic constructor •() → self::D<self::D::X%, self::D::Y%, self::D::Z%>
;
method foo(generic-covariant-impl self::D::X% x, generic-covariant-impl self::D::Y% y, generic-covariant-impl self::D::Z% z) → dynamic
;
diff --git a/pkg/front_end/testcases/nnbd/type_parameter_types.dart.strong.expect b/pkg/front_end/testcases/nnbd/type_parameter_types.dart.strong.expect
index da778be..9b7ac71 100644
--- a/pkg/front_end/testcases/nnbd/type_parameter_types.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/type_parameter_types.dart.strong.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class A<X extends core::Object = core::Object, Y extends core::Object? = core::Object?> extends core::Object {
- synthetic constructor •() → self::A<self::A::X, self::A::Y%>*
+ synthetic constructor •() → self::A<self::A::X, self::A::Y%>
: super core::Object::•()
;
method foo() → self::A::X
@@ -14,19 +14,19 @@
return null;
}
class B<X extends core::List<self::B::Y%> = core::List<core::Object?>, Y extends core::Object? = core::Object?> extends core::Object {
- synthetic constructor •() → self::B<self::B::X, self::B::Y%>*
+ synthetic constructor •() → self::B<self::B::X, self::B::Y%>
: super core::Object::•()
;
method foo(generic-covariant-impl self::B::X x, generic-covariant-impl self::B::Y% y) → dynamic {}
}
class C<X extends core::List<self::C::Y%>? = core::List<dynamic>?, Y extends core::List<self::C::X%>? = core::List<dynamic>?> extends core::Object {
- synthetic constructor •() → self::C<self::C::X%, self::C::Y%>*
+ synthetic constructor •() → self::C<self::C::X%, self::C::Y%>
: super core::Object::•()
;
method foo(generic-covariant-impl self::C::X% x, generic-covariant-impl self::C::Y% y) → dynamic {}
}
class D<X extends self::D::Y% = dynamic, Y extends self::D::Z% = dynamic, Z extends core::Object? = dynamic> extends core::Object {
- synthetic constructor •() → self::D<self::D::X%, self::D::Y%, self::D::Z%>*
+ synthetic constructor •() → self::D<self::D::X%, self::D::Y%, self::D::Z%>
: super core::Object::•()
;
method foo(generic-covariant-impl self::D::X% x, generic-covariant-impl self::D::Y% y, generic-covariant-impl self::D::Z% z) → dynamic {}
diff --git a/pkg/front_end/testcases/nnbd/type_parameter_types.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/type_parameter_types.dart.strong.transformed.expect
index da778be..9b7ac71 100644
--- a/pkg/front_end/testcases/nnbd/type_parameter_types.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/nnbd/type_parameter_types.dart.strong.transformed.expect
@@ -3,7 +3,7 @@
import "dart:core" as core;
class A<X extends core::Object = core::Object, Y extends core::Object? = core::Object?> extends core::Object {
- synthetic constructor •() → self::A<self::A::X, self::A::Y%>*
+ synthetic constructor •() → self::A<self::A::X, self::A::Y%>
: super core::Object::•()
;
method foo() → self::A::X
@@ -14,19 +14,19 @@
return null;
}
class B<X extends core::List<self::B::Y%> = core::List<core::Object?>, Y extends core::Object? = core::Object?> extends core::Object {
- synthetic constructor •() → self::B<self::B::X, self::B::Y%>*
+ synthetic constructor •() → self::B<self::B::X, self::B::Y%>
: super core::Object::•()
;
method foo(generic-covariant-impl self::B::X x, generic-covariant-impl self::B::Y% y) → dynamic {}
}
class C<X extends core::List<self::C::Y%>? = core::List<dynamic>?, Y extends core::List<self::C::X%>? = core::List<dynamic>?> extends core::Object {
- synthetic constructor •() → self::C<self::C::X%, self::C::Y%>*
+ synthetic constructor •() → self::C<self::C::X%, self::C::Y%>
: super core::Object::•()
;
method foo(generic-covariant-impl self::C::X% x, generic-covariant-impl self::C::Y% y) → dynamic {}
}
class D<X extends self::D::Y% = dynamic, Y extends self::D::Z% = dynamic, Z extends core::Object? = dynamic> extends core::Object {
- synthetic constructor •() → self::D<self::D::X%, self::D::Y%, self::D::Z%>*
+ synthetic constructor •() → self::D<self::D::X%, self::D::Y%, self::D::Z%>
: super core::Object::•()
;
method foo(generic-covariant-impl self::D::X% x, generic-covariant-impl self::D::Y% y, generic-covariant-impl self::D::Z% z) → dynamic {}
diff --git a/pkg/front_end/testcases/outline.status b/pkg/front_end/testcases/outline.status
index c400d6f..7185f12 100644
--- a/pkg/front_end/testcases/outline.status
+++ b/pkg/front_end/testcases/outline.status
@@ -38,6 +38,8 @@
inference_new/infer_field_override_getter_overrides_setter: TypeCheckError
nnbd/inheritance_from_opt_out: TypeCheckError
+nnbd/messages_with_types_opt_in: TypeCheckError
+nnbd/messages_with_types_opt_out: TypeCheckError
rasta/native_is_illegal: Pass # Issue 29763
diff --git a/pkg/front_end/testcases/rasta/issue_000004.dart.strong.transformed.expect b/pkg/front_end/testcases/rasta/issue_000004.dart.strong.transformed.expect
index ee3a0ca..024a770 100644
--- a/pkg/front_end/testcases/rasta/issue_000004.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/rasta/issue_000004.dart.strong.transformed.expect
@@ -1,6 +1,7 @@
library;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
import "package:expect/expect.dart" as exp;
import "package:expect/expect.dart";
@@ -8,25 +9,43 @@
static field dynamic global;
static method fact4() → dynamic {
core::int* f = 1;
- for (core::int* n in <core::int*>[1, 2, 3, 4]) {
- f = f.{core::num::*}(n);
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[1, 2, 3, 4]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* n = :sync-for-iterator.{core::Iterator::current};
+ {
+ f = f.{core::num::*}(n);
+ }
+ }
}
return f;
}
static method fact5() → dynamic {
core::int* f = 1;
dynamic n;
- for (final dynamic #t1 in <dynamic>[1, 2, 3, 4, 5]) {
- n = #t1;
- f = f.{core::num::*}(n as{TypeError} core::num*) as{TypeError} core::int*;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[1, 2, 3, 4, 5]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t1 = :sync-for-iterator.{core::Iterator::current};
+ {
+ n = #t1;
+ f = f.{core::num::*}(n as{TypeError} core::num*) as{TypeError} core::int*;
+ }
+ }
}
return f;
}
static method fact6() → dynamic {
core::int* f = 1;
- for (final dynamic #t2 in <dynamic>[1, 2, 3, 4, 5, 6]) {
- self::global = #t2;
- f = f.{core::num::*}(self::global as{TypeError} core::num*) as{TypeError} core::int*;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[1, 2, 3, 4, 5, 6]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t2 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::global = #t2;
+ f = f.{core::num::*}(self::global as{TypeError} core::num*) as{TypeError} core::int*;
+ }
+ }
}
return f;
}
diff --git a/pkg/front_end/testcases/rasta/issue_000042.dart.strong.transformed.expect b/pkg/front_end/testcases/rasta/issue_000042.dart.strong.transformed.expect
index 2abfb5d..e81f7fc 100644
--- a/pkg/front_end/testcases/rasta/issue_000042.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/rasta/issue_000042.dart.strong.transformed.expect
@@ -22,18 +22,25 @@
//
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static method main() → dynamic {
{
invalid-expression "pkg/front_end/testcases/rasta/issue_000042.dart:6:8: Error: A for-in loop can't have more than one loop variable.
for (var x, y in []) {}
^^^";
- for (final dynamic #t1 in <dynamic>[]) {
- invalid-expression "pkg/front_end/testcases/rasta/issue_000042.dart:6:8: Error: A for-in loop can't have more than one loop variable.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t1 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/issue_000042.dart:6:8: Error: A for-in loop can't have more than one loop variable.
for (var x, y in []) {}
^^^";
- dynamic x;
- dynamic y;
+ dynamic x;
+ dynamic y;
+ }
+ }
}
}
#L1:
diff --git a/pkg/front_end/testcases/rasta/unresolved_for_in.dart.strong.transformed.expect b/pkg/front_end/testcases/rasta/unresolved_for_in.dart.strong.transformed.expect
index c41f760..e5f407f 100644
--- a/pkg/front_end/testcases/rasta/unresolved_for_in.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/rasta/unresolved_for_in.dart.strong.transformed.expect
@@ -82,6 +82,7 @@
//
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
import "dart:collection" as collection;
@@ -91,98 +92,158 @@
: super core::Object::•()
;
method it1(dynamic x) → dynamic {
- for (final dynamic #t1 in x as{TypeError} core::Iterable<dynamic>*) {
- invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:11:10: Error: The setter 'key' isn't defined for the class 'Fisk'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(x as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t1 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:11:10: Error: The setter 'key' isn't defined for the class 'Fisk'.
- 'Fisk' is from 'pkg/front_end/testcases/rasta/unresolved_for_in.dart'.
Try correcting the name to the name of an existing setter, or defining a setter or field named 'key'.
for (key in x) {
^^^";
- core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:12:13: Error: The getter 'key' isn't defined for the class 'Fisk'.
+ core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:12:13: Error: The getter 'key' isn't defined for the class 'Fisk'.
- 'Fisk' is from 'pkg/front_end/testcases/rasta/unresolved_for_in.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'key'.
print(key);
^^^");
+ }
+ }
}
- for (final dynamic #t2 in x as{TypeError} core::Iterable<dynamic>*) {
- invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:14:10: Error: Setter not found: 'Fisk'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(x as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t2 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:14:10: Error: Setter not found: 'Fisk'.
for (Fisk in x) {
^^^^";
- core::print(self::Fisk*);
+ core::print(self::Fisk*);
+ }
+ }
}
- for (final dynamic #t3 in x as{TypeError} core::Iterable<dynamic>*) {
- invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:17:10: Error: A prefix can't be used as an expression.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(x as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t3 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:17:10: Error: A prefix can't be used as an expression.
for (collection in x) {
^^^^^^^^^^";
- core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:18:13: Error: A prefix can't be used as an expression.
+ core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:18:13: Error: A prefix can't be used as an expression.
print(collection);
^^^^^^^^^^");
+ }
+ }
}
- for (final dynamic #t4 in x as{TypeError} core::Iterable<dynamic>*) {
- invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:20:10: Error: Setter not found: 'VoidFunction'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(x as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t4 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:20:10: Error: Setter not found: 'VoidFunction'.
for (VoidFunction in x) {
^^^^^^^^^^^^";
- core::print(() →* void);
+ core::print(() →* void);
+ }
+ }
}
{
invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:23:10: Error: Can't assign to this, so it can't be used in a for-in loop.
for (1 in x) {
^";
- for (final dynamic #t5 in x as{TypeError} core::Iterable<dynamic>*) {
- invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:23:10: Error: Can't assign to this, so it can't be used in a for-in loop.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(x as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t5 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:23:10: Error: Can't assign to this, so it can't be used in a for-in loop.
for (1 in x) {
^";
- 1;
- core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:24:13: Error: The getter 'key' isn't defined for the class 'Fisk'.
+ 1;
+ core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:24:13: Error: The getter 'key' isn't defined for the class 'Fisk'.
- 'Fisk' is from 'pkg/front_end/testcases/rasta/unresolved_for_in.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'key'.
print(key);
^^^");
+ }
+ }
}
}
}
}
static method main(dynamic arguments) → dynamic {
new self::Fisk::•();
- for (final dynamic #t6 in arguments as{TypeError} core::Iterable<dynamic>*) {
- invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:31:8: Error: Setter not found: 'key'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(arguments as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t6 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:31:8: Error: Setter not found: 'key'.
for (key in arguments) {
^^^";
- core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:32:11: Error: Getter not found: 'key'.
+ core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:32:11: Error: Getter not found: 'key'.
print(key);
^^^");
+ }
+ }
}
- for (final dynamic #t7 in arguments as{TypeError} core::Iterable<dynamic>*) {
- invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:34:8: Error: Setter not found: 'Fisk'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(arguments as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t7 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:34:8: Error: Setter not found: 'Fisk'.
for (Fisk in arguments) {
^^^^";
- core::print(self::Fisk*);
+ core::print(self::Fisk*);
+ }
+ }
}
- for (final dynamic #t8 in arguments as{TypeError} core::Iterable<dynamic>*) {
- invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:37:8: Error: A prefix can't be used as an expression.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(arguments as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t8 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:37:8: Error: A prefix can't be used as an expression.
for (collection in arguments) {
^^^^^^^^^^";
- core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:38:11: Error: A prefix can't be used as an expression.
+ core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:38:11: Error: A prefix can't be used as an expression.
print(collection);
^^^^^^^^^^");
+ }
+ }
}
- for (final dynamic #t9 in arguments as{TypeError} core::Iterable<dynamic>*) {
- invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:40:8: Error: Setter not found: 'VoidFunction'.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(arguments as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t9 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:40:8: Error: Setter not found: 'VoidFunction'.
for (VoidFunction in arguments) {
^^^^^^^^^^^^";
- core::print(() →* void);
+ core::print(() →* void);
+ }
+ }
}
{
invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:43:8: Error: Can't assign to this, so it can't be used in a for-in loop.
for (1 in arguments) {
^";
- for (final dynamic #t10 in arguments as{TypeError} core::Iterable<dynamic>*) {
- invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:43:8: Error: Can't assign to this, so it can't be used in a for-in loop.
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(arguments as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t10 = :sync-for-iterator.{core::Iterator::current};
+ {
+ invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:43:8: Error: Can't assign to this, so it can't be used in a for-in loop.
for (1 in arguments) {
^";
- 1;
- core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:44:11: Error: Getter not found: 'key'.
+ 1;
+ core::print(invalid-expression "pkg/front_end/testcases/rasta/unresolved_for_in.dart:44:11: Error: Getter not found: 'key'.
print(key);
^^^");
+ }
+ }
}
}
}
diff --git a/pkg/front_end/testcases/regress/issue_37681.dart.strong.transformed.expect b/pkg/front_end/testcases/regress/issue_37681.dart.strong.transformed.expect
index 519cf0e..12c970e 100644
--- a/pkg/front_end/testcases/regress/issue_37681.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/regress/issue_37681.dart.strong.transformed.expect
@@ -137,8 +137,14 @@
}
return new core::_SyncIterable::•<dynamic>(:sync_op);
}
- for (dynamic x in (f_sync_star.call() as dynamic) as{TypeError} core::Iterable<dynamic>*) {
- core::print(x);
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>((f_sync_star.call() as dynamic) as{TypeError} core::Iterable<dynamic>*).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic x = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::print(x);
+ }
+ }
}
}
asy::_completeOnAsyncReturn(:async_completer, :return_value);
diff --git a/pkg/front_end/testcases/runtime_checks_new/for_in_call_kinds.dart.strong.transformed.expect b/pkg/front_end/testcases/runtime_checks_new/for_in_call_kinds.dart.strong.transformed.expect
index 7c5b3c9..5ae1f55 100644
--- a/pkg/front_end/testcases/runtime_checks_new/for_in_call_kinds.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/runtime_checks_new/for_in_call_kinds.dart.strong.transformed.expect
@@ -1,6 +1,7 @@
library test;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class C extends core::Object {
static field dynamic staticField = null;
@@ -12,26 +13,68 @@
set instanceSetter(dynamic x) → void {}
method test() → void {
dynamic localVar;
- for (final dynamic #t1 in <dynamic>[]) {
- self::topLevel = #t1;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t1 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::topLevel = #t1;
+ }
+ }
}
- for (final dynamic #t2 in <dynamic>[]) {
- self::topLevelSetter = #t2;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t2 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::topLevelSetter = #t2;
+ }
+ }
}
- for (final dynamic #t3 in <dynamic>[]) {
- self::C::staticField = #t3;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t3 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::C::staticField = #t3;
+ }
+ }
}
- for (final dynamic #t4 in <dynamic>[]) {
- self::C::staticSetter = #t4;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t4 = :sync-for-iterator.{core::Iterator::current};
+ {
+ self::C::staticSetter = #t4;
+ }
+ }
}
- for (final dynamic #t5 in <dynamic>[]) {
- this.{self::C::instanceField} = #t5;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t5 = :sync-for-iterator.{core::Iterator::current};
+ {
+ this.{self::C::instanceField} = #t5;
+ }
+ }
}
- for (final dynamic #t6 in <dynamic>[]) {
- this.{self::C::instanceSetter} = #t6;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t6 = :sync-for-iterator.{core::Iterator::current};
+ {
+ this.{self::C::instanceSetter} = #t6;
+ }
+ }
}
- for (final dynamic #t7 in <dynamic>[]) {
- localVar = #t7;
+ {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(<dynamic>[]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final dynamic #t7 = :sync-for-iterator.{core::Iterator::current};
+ {
+ localVar = #t7;
+ }
+ }
}
}
}
diff --git a/pkg/front_end/testcases/strong.status b/pkg/front_end/testcases/strong.status
index a50207f..3f609e1 100644
--- a/pkg/front_end/testcases/strong.status
+++ b/pkg/front_end/testcases/strong.status
@@ -112,6 +112,8 @@
instantiate_to_bound/non_simple_class_parametrized_typedef_cycle: RuntimeError # Expected
instantiate_to_bound/non_simple_generic_function_in_bound_regress: RuntimeError # Expected
nnbd/inheritance_from_opt_out: TypeCheckError
+nnbd/messages_with_types_opt_in: TypeCheckError
+nnbd/messages_with_types_opt_out: TypeCheckError
nnbd/nullable_param: RuntimeError
rasta/abstract_constructor: RuntimeError
rasta/bad_constructor_redirection: RuntimeError
diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status
index 02dd58d..cf7ff4b 100644
--- a/pkg/front_end/testcases/text_serialization.status
+++ b/pkg/front_end/testcases/text_serialization.status
@@ -231,6 +231,7 @@
general/missing_constructor: TextSerializationFailure # Was: Pass
general/missing_toplevel: TextSerializationFailure
general/mixin: TextSerializationFailure # Was: Pass
+general/mixin_application_inferred_parameter_type: TextSerializationFailure
general/mixin_application_override: ExpectationFileMismatch
general/mixin_application_override: TypeCheckError
general/mixin_conflicts: TextSerializationFailure
@@ -818,6 +819,7 @@
inference_new/list_literals_can_infer_null_top_level: TextSerializationFailure # Was: Pass
inference_new/map_literals_can_infer_null_top_level: TextSerializationFailure # Was: Pass
inference_new/multiple_interface_inheritance: TextSerializationFailure # Was: Pass
+inference_new/null_aware_property_get: TextSerializationFailure
inference_new/property_assign_combiner: TextSerializationFailure # Was: Pass
inference_new/property_get_toplevel: TextSerializationFailure # Was: Pass
inference_new/static_assign_combiner: TextSerializationFailure # Was: Pass
@@ -924,6 +926,12 @@
nnbd/issue_39286: TextSerializationFailure
nnbd/issue_39286_2: TextSerializationFailure
nnbd/late: TextSerializationFailure
+nnbd/messages_with_types_opt_in: TypeCheckError
+nnbd/messages_with_types_opt_out: TypeCheckError
+nnbd/no_null_shorting: TextSerializationFailure
+nnbd/no_null_shorting_explicit_extension: TextSerializationFailure
+nnbd/no_null_shorting_extension: TextSerializationFailure
+nnbd/null_aware_chain: TextSerializationFailure
nnbd/null_check: TextSerializationFailure
nnbd/null_shorting: TextSerializationFailure
nnbd/null_shorting_cascade: TextSerializationFailure
@@ -934,6 +942,7 @@
nnbd/nullable_param: TextSerializationFailure
nnbd/opt_out: TextSerializationFailure
nnbd/required: TextSerializationFailure
+nnbd/regress_null_aware: TextSerializationFailure
nnbd/simple_never: TextSerializationFailure
nnbd/substitution_in_inference: TextSerializationFailure
nnbd/type_parameter_types: TextSerializationFailure
diff --git a/pkg/front_end/testcases/unified_collections/mixed_entries.dart.strong.transformed.expect b/pkg/front_end/testcases/unified_collections/mixed_entries.dart.strong.transformed.expect
index 6852242..083afec 100644
--- a/pkg/front_end/testcases/unified_collections/mixed_entries.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/unified_collections/mixed_entries.dart.strong.transformed.expect
@@ -40,6 +40,7 @@
//
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
static field core::bool* b = false;
static field core::List<dynamic>* list = <dynamic>[];
@@ -48,40 +49,64 @@
final core::Map<dynamic, dynamic>* #t1 = <dynamic, dynamic>{};
if(self::b)
#t1.{core::Map::[]=}(0, 1);
- else
- for (final core::MapEntry<dynamic, dynamic>* #t2 in self::map0.{core::Map::entries})
+ else {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>(self::map0.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t2 = :sync-for-iterator.{core::Iterator::current};
#t1.{core::Map::[]=}(#t2.{core::MapEntry::key}, #t2.{core::MapEntry::value});
+ }
+ }
} =>#t1;
static field core::Map<dynamic, dynamic>* map2 = block {
final core::Map<dynamic, dynamic>* #t3 = <dynamic, dynamic>{};
- if(self::b)
- for (final core::MapEntry<dynamic, dynamic>* #t4 in self::map0.{core::Map::entries})
+ if(self::b) {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>(self::map0.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t4 = :sync-for-iterator.{core::Iterator::current};
#t3.{core::Map::[]=}(#t4.{core::MapEntry::key}, #t4.{core::MapEntry::value});
+ }
+ }
else
#t3.{core::Map::[]=}(0, 1);
} =>#t3;
static field core::Map<dynamic, dynamic>* map3 = block {
final core::Map<dynamic, dynamic>* #t5 = <dynamic, dynamic>{};
- if(self::b)
- for (final core::MapEntry<dynamic, dynamic>* #t6 in self::map0.{core::Map::entries})
+ if(self::b) {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>(self::map0.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t6 = :sync-for-iterator.{core::Iterator::current};
#t5.{core::Map::[]=}(#t6.{core::MapEntry::key}, #t6.{core::MapEntry::value});
- else
- for (final core::MapEntry<dynamic, dynamic>* #t7 in self::map0.{core::Map::entries})
+ }
+ }
+ else {
+ core::Iterator<core::MapEntry<dynamic, dynamic>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, dynamic>*>*>(self::map0.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, dynamic>* #t7 = :sync-for-iterator.{core::Iterator::current};
#t5.{core::Map::[]=}(#t7.{core::MapEntry::key}, #t7.{core::MapEntry::value});
+ }
+ }
} =>#t5;
static field core::Map<dynamic, core::int*>* map4 = block {
final core::Map<dynamic, core::int*>* #t8 = <dynamic, core::int*>{};
if(self::b)
#t8.{core::Map::[]=}(0, 1);
- else
- for (dynamic a in self::list)
+ else {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(self::list).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic a = :sync-for-iterator.{core::Iterator::current};
#t8.{core::Map::[]=}(a, 1);
+ }
+ }
} =>#t8;
static field core::Map<dynamic, core::int*>* map5 = block {
final core::Map<dynamic, core::int*>* #t9 = <dynamic, core::int*>{};
- if(self::b)
- for (dynamic a in self::list)
+ if(self::b) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(self::list).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic a = :sync-for-iterator.{core::Iterator::current};
#t9.{core::Map::[]=}(a, 1);
+ }
+ }
else
#t9.{core::Map::[]=}(0, 1);
} =>#t9;
@@ -89,17 +114,35 @@
final core::Map<dynamic, core::int*>* #t10 = <dynamic, core::int*>{};
if(self::b)
#t10.{core::Map::[]=}(0, 1);
- else
- for (dynamic a in self::list)
- for (final core::MapEntry<dynamic, core::int*>* #t11 in <dynamic, core::int*>{a: 1}.{core::Map::entries})
- #t10.{core::Map::[]=}(#t11.{core::MapEntry::key}, #t11.{core::MapEntry::value});
+ else {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(self::list).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic a = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::Iterator<core::MapEntry<dynamic, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, core::int*>*>*>(<dynamic, core::int*>{a: 1}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, core::int*>* #t11 = :sync-for-iterator.{core::Iterator::current};
+ #t10.{core::Map::[]=}(#t11.{core::MapEntry::key}, #t11.{core::MapEntry::value});
+ }
+ }
+ }
+ }
} =>#t10;
static field core::Map<dynamic, core::int*>* map7 = block {
final core::Map<dynamic, core::int*>* #t12 = <dynamic, core::int*>{};
- if(self::b)
- for (dynamic a in self::list)
- for (final core::MapEntry<dynamic, core::int*>* #t13 in <dynamic, core::int*>{a: 1}.{core::Map::entries})
- #t12.{core::Map::[]=}(#t13.{core::MapEntry::key}, #t13.{core::MapEntry::value});
+ if(self::b) {
+ core::Iterator<dynamic>* :sync-for-iterator = _in::unsafeCast<core::Iterable<dynamic>*>(self::list).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ dynamic a = :sync-for-iterator.{core::Iterator::current};
+ {
+ core::Iterator<core::MapEntry<dynamic, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, core::int*>*>*>(<dynamic, core::int*>{a: 1}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, core::int*>* #t13 = :sync-for-iterator.{core::Iterator::current};
+ #t12.{core::Map::[]=}(#t13.{core::MapEntry::key}, #t13.{core::MapEntry::value});
+ }
+ }
+ }
+ }
else
#t12.{core::Map::[]=}(0, 1);
} =>#t12;
@@ -124,16 +167,24 @@
if(self::b)
#t16.{core::Map::[]=}(0, 1);
else
- for (core::int* i = 0; i.{core::num::<}(self::list.{core::List::length}); i = i.{core::num::+}(1))
- for (final core::MapEntry<dynamic, core::int*>* #t17 in <dynamic, core::int*>{self::list.{core::List::[]}(i): 1}.{core::Map::entries})
+ for (core::int* i = 0; i.{core::num::<}(self::list.{core::List::length}); i = i.{core::num::+}(1)) {
+ core::Iterator<core::MapEntry<dynamic, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, core::int*>*>*>(<dynamic, core::int*>{self::list.{core::List::[]}(i): 1}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, core::int*>* #t17 = :sync-for-iterator.{core::Iterator::current};
#t16.{core::Map::[]=}(#t17.{core::MapEntry::key}, #t17.{core::MapEntry::value});
+ }
+ }
} =>#t16;
static field core::Map<dynamic, core::int*>* map11 = block {
final core::Map<dynamic, core::int*>* #t18 = <dynamic, core::int*>{};
if(self::b)
- for (core::int* i = 0; i.{core::num::<}(self::list.{core::List::length}); i = i.{core::num::+}(1))
- for (final core::MapEntry<dynamic, core::int*>* #t19 in <dynamic, core::int*>{self::list.{core::List::[]}(i): 1}.{core::Map::entries})
+ for (core::int* i = 0; i.{core::num::<}(self::list.{core::List::length}); i = i.{core::num::+}(1)) {
+ core::Iterator<core::MapEntry<dynamic, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<dynamic, core::int*>*>*>(<dynamic, core::int*>{self::list.{core::List::[]}(i): 1}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<dynamic, core::int*>* #t19 = :sync-for-iterator.{core::Iterator::current};
#t18.{core::Map::[]=}(#t19.{core::MapEntry::key}, #t19.{core::MapEntry::value});
+ }
+ }
else
#t18.{core::Map::[]=}(0, 1);
} =>#t18;
@@ -142,9 +193,13 @@
if(self::b)
#t20.{core::Map::[]=}(0, 1);
else
- if(self::b)
- for (final core::MapEntry<core::int*, core::int*>* #t21 in <core::int*, core::int*>{0: 1}.{core::Map::entries})
+ if(self::b) {
+ core::Iterator<core::MapEntry<core::int*, core::int*>*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::MapEntry<core::int*, core::int*>*>*>(<core::int*, core::int*>{0: 1}.{core::Map::entries}).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ final core::MapEntry<core::int*, core::int*>* #t21 = :sync-for-iterator.{core::Iterator::current};
#t20.{core::Map::[]=}(#t21.{core::MapEntry::key}, #t21.{core::MapEntry::value});
+ }
+ }
} =>#t20;
static field core::Map<dynamic, core::Null?>* error4 = <dynamic, core::Null?>{invalid-expression "pkg/front_end/testcases/unified_collections/mixed_entries.dart:33:32: Error: Both Iterable and Map spread elements encountered in ambiguous literal.
var error4 = {if (b) 0: 1 else for (var a in list) a};
diff --git a/pkg/front_end/testing.json b/pkg/front_end/testing.json
index 47b4925..a5a63d1 100644
--- a/pkg/front_end/testing.json
+++ b/pkg/front_end/testing.json
@@ -99,7 +99,7 @@
{
"name": "text_serialization",
"kind": "Chain",
- "source": "test/fasta/text_serialization_suite.dart",
+ "source": "test/fasta/text_serialization_tester.dart",
"path": "testcases/",
"status": "testcases/text_serialization.status",
"pattern": [
@@ -229,12 +229,15 @@
"path": "../",
"status": "test/spelling_test.status",
"pattern": [
+ "_fe_analyzer_shared/lib/.*\\.dart$",
"front_end/lib/.*\\.dart$",
"kernel/lib/.*\\.dart$"
],
"exclude": [
- "src/fasta/fasta_codes_generated\\.dart$",
- "src/fasta/fasta_codes_cfe_generated\\.dart$"
+ "kernel/lib/vm/.*\\.dart$",
+ "kernel/lib/transformations/.*\\.dart$",
+ "_fe_analyzer_shared/lib/src/messages/codes_generated\\.dart$",
+ "front_end/lib/src/fasta/fasta_codes_cfe_generated\\.dart$"
]
},
{
diff --git a/pkg/front_end/tool/_fasta/dump_partial.dart b/pkg/front_end/tool/_fasta/dump_partial.dart
deleted file mode 100644
index af8db5a..0000000
--- a/pkg/front_end/tool/_fasta/dump_partial.dart
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2017, 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.
-
-/// Utility to dump a truncated .dill file generated by the incremental kernel
-/// generator or by the VM's kernel service.
-
-import 'dart:io' show File, exitCode;
-
-import 'package:kernel/kernel.dart'
- show
- Component,
- loadComponentFromBinary,
- loadComponentFromBytes,
- writeComponentToText;
-
-import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent;
-
-main(List<String> args) {
- if (args.length == 0) {
- print('usage: pkg/front_end/tool/fasta dump_partial '
- 'partial.dill [extra1.dill] ... [extraN.dill]');
- exitCode = 1;
- return;
- }
-
- var component = _loadComponent(args);
- writeComponentToText(component);
-}
-
-/// Creates a component that contains all of the context code marked as
-/// external, and all libraries defined in partial.dill as they are written in
-/// that file.
-Component _loadComponent(List<String> args) {
- List<int> partialInput = new File(args[0]).readAsBytesSync();
-
- var context = new Component();
- for (var i = 1; i < args.length; i++) {
- loadComponentFromBinary(args[i], context);
- }
-
- Set<Uri> libraries = _definedLibraries(partialInput, context);
-
- // By default `package:kernel/binary/ast_from_binary.dart` merges the contents
- // of libraries that are mentioned in more than one .dill file. In order to
- // keep the contents of partial.dill intact, we build a new context that
- // excludes those libraries defined in partial.dill.
- List<int> contextBytes = serializeComponent(context,
- filter: (l) => !libraries.contains(l.importUri));
- var component = new Component();
- loadComponentFromBytes(contextBytes, component);
- _updateIsExternal(component, true);
- loadComponentFromBytes(partialInput, component);
- return component;
-}
-
-/// Compute the set of libraries defined in [partialDill].
-///
-/// The [context] component contains all other libraries that may be needed to
-/// properly deserialize partialDill.
-///
-/// Note: This function will mutate [context] in place.
-// TODO(sigmund): simplify and get rid of [context]. We could do that with a
-// custom deserialization, but it will be easier to do once .dill has
-// random-access support.
-Set<Uri> _definedLibraries(List<int> partialDill, Component context) {
- _updateIsExternal(context, true);
-
- // This implicitly sets `isExternal = false` on all libraries defined in the
- // partial.dill file.
- loadComponentFromBytes(partialDill, context);
- var result = context.libraries
- // ignore: DEPRECATED_MEMBER_USE
- .where((l) => !l.isExternal)
- .map((l) => l.importUri)
- .toSet();
- _updateIsExternal(context, false);
- return result;
-}
-
-void _updateIsExternal(Component component, bool toValue) {
- // ignore: DEPRECATED_MEMBER_USE
- component.libraries.forEach((lib) => lib.isExternal = toValue);
-}
diff --git a/pkg/front_end/tool/_fasta/entry_points.dart b/pkg/front_end/tool/_fasta/entry_points.dart
index 15e2e6e..4bb712b 100644
--- a/pkg/front_end/tool/_fasta/entry_points.dart
+++ b/pkg/front_end/tool/_fasta/entry_points.dart
@@ -343,9 +343,7 @@
component = createFreshComponentWithBytecode(component);
}
- await writeComponentToFile(component, fullOutput,
- // ignore: DEPRECATED_MEMBER_USE
- filter: (lib) => !lib.isExternal);
+ await writeComponentToFile(component, fullOutput);
c.options.ticker.logMs("Wrote component to ${fullOutput.toFilePath()}");
diff --git a/pkg/front_end/tool/_fasta/generate_messages.dart b/pkg/front_end/tool/_fasta/generate_messages.dart
index 9b78a88..2a47606 100644
--- a/pkg/front_end/tool/_fasta/generate_messages.dart
+++ b/pkg/front_end/tool/_fasta/generate_messages.dart
@@ -171,7 +171,8 @@
bool canBeShared = true;
void ensureLabeler() {
if (hasLabeler) return;
- conversions.add("TypeLabeler labeler = new TypeLabeler();");
+ conversions
+ .add("TypeLabeler labeler = new TypeLabeler(isNonNullableByDefault);");
hasLabeler = true;
canBeShared = false;
}
@@ -358,6 +359,10 @@
}
}
+ if (hasLabeler) {
+ parameters.add("bool isNonNullableByDefault");
+ }
+
conversions.addAll(conversions2);
String interpolate(String text) {
diff --git a/pkg/front_end/tool/fasta b/pkg/front_end/tool/fasta
index aa970c3..29d5544 100755
--- a/pkg/front_end/tool/fasta
+++ b/pkg/front_end/tool/fasta
@@ -39,7 +39,6 @@
outline) SCRIPT="${TOOL_DIR}/outline.dart";;
parser) SCRIPT="${TOOL_DIR}/parser.dart";;
scanner) SCRIPT="${TOOL_DIR}/scanner.dart";;
- dump-partial) SCRIPT="${TOOL_DIR}/dump_partial.dart";;
dump-ir)
SCRIPT="${KERNEL_BIN}/dump.dart"
if [ "$#" = "2" ]; then
diff --git a/pkg/front_end/tool/fasta.dart b/pkg/front_end/tool/fasta.dart
index a136179..f2ecaaf 100644
--- a/pkg/front_end/tool/fasta.dart
+++ b/pkg/front_end/tool/fasta.dart
@@ -60,9 +60,6 @@
case 'scanner':
script = '${toolDir}/scanner.dart';
break;
- case 'dump-partial':
- script = '${toolDir}/dump_partial.dart';
- break;
case 'dump-ir':
script = '${kernelBin}/dump.dart';
if (remainingArguments.isEmpty || remainingArguments.length > 2) {
diff --git a/pkg/front_end/tool/smoke_test_quick.dart b/pkg/front_end/tool/smoke_test_quick.dart
index e2f411d..a9d4ae3 100644
--- a/pkg/front_end/tool/smoke_test_quick.dart
+++ b/pkg/front_end/tool/smoke_test_quick.dart
@@ -20,7 +20,8 @@
["-DfastOnly=true"],
));
futures.add(run("pkg/front_end/test/spelling_test_not_src_suite.dart", []));
- futures.add(run("pkg/front_end/test/spelling_test_src_suite.dart", []));
+ futures.add(run("pkg/front_end/test/spelling_test_src_suite.dart",
+ ["--", "spelling_test_src/front_end/..."]));
futures.add(run("pkg/front_end/test/lint_suite.dart", []));
futures.add(run("pkg/front_end/test/deps_test.dart", [], filter: false));
await Future.wait(futures);
diff --git a/pkg/frontend_server/test/src/javascript_bundle_test.dart b/pkg/frontend_server/test/src/javascript_bundle_test.dart
index 7c491da..79f3ac8 100644
--- a/pkg/frontend_server/test/src/javascript_bundle_test.dart
+++ b/pkg/frontend_server/test/src/javascript_bundle_test.dart
@@ -28,6 +28,7 @@
'dart:_native_typed_data': [],
'dart:collection': [
'ListMixin',
+ 'MapMixin',
'LinkedHashSet',
'_HashSet',
'_IdentityHashSet',
diff --git a/pkg/frontend_server/test/src/strong_components_test.dart b/pkg/frontend_server/test/src/strong_components_test.dart
index 6d36691..9bb6596 100644
--- a/pkg/frontend_server/test/src/strong_components_test.dart
+++ b/pkg/frontend_server/test/src/strong_components_test.dart
@@ -97,11 +97,10 @@
});
});
- test('does not index loaded , dart:, or unimported libraries', () {
+ test('does not index loaded, dart:, or unimported libraries', () {
final libraryLoaded = Library(
Uri.file('a.dart'),
fileUri: Uri.file('/a.dart'),
- isExternal: true,
);
final libraryDart = Library(
Uri.parse('dart:foo'),
diff --git a/pkg/kernel/PRESUBMIT.py b/pkg/kernel/PRESUBMIT.py
index 9d898e4..ee42fc8 100644
--- a/pkg/kernel/PRESUBMIT.py
+++ b/pkg/kernel/PRESUBMIT.py
@@ -1,7 +1,7 @@
# Copyright (c) 2019, 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.
-"""Front-end specific presubmit script.
+"""Kernel specific presubmit script.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into gcl.
diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md
index 40f1ea1..865b677 100644
--- a/pkg/kernel/binary.md
+++ b/pkg/kernel/binary.md
@@ -228,7 +228,7 @@
}
type Library {
- Byte flags (isExternal, isSynthetic, isNonNullableByDefault);
+ Byte flags (_unused_, isSynthetic, isNonNullableByDefault);
UInt languageVersionMajor;
UInt languageVersionMinor;
CanonicalNameReference canonicalName;
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 1c993e3..971bc21 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -190,6 +190,15 @@
}
CanonicalName get canonicalName => reference?.canonicalName;
+
+ /// This is an advanced feature.
+ ///
+ /// See [Component.relink] for a comprehensive description.
+ ///
+ /// Makes sure the reference in this named node points to itself.
+ void _relinkNode() {
+ this.reference.node = this;
+ }
}
abstract class FileUriNode extends TreeNode {
@@ -319,7 +328,7 @@
// TODO(jensj): Do we have a better option than this?
static int defaultLanguageVersionMajor = 2;
- static int defaultLanguageVersionMinor = 7;
+ static int defaultLanguageVersionMinor = 8;
int _languageVersionMajor;
int _languageVersionMinor;
@@ -335,29 +344,11 @@
_languageVersionMinor = languageVersionMinor;
}
- static const int ExternalFlag = 1 << 0;
static const int SyntheticFlag = 1 << 1;
static const int NonNullableByDefaultFlag = 1 << 2;
int flags = 0;
- /// If true, the library is part of another build unit and its contents
- /// are only partially loaded.
- ///
- /// Classes of an external library are loaded at one of the [ClassLevel]s
- /// other than [ClassLevel.Body]. Members in an external library have no
- /// body, but have their typed interface present.
- ///
- /// If the library is non-external, then its classes are at [ClassLevel.Body]
- /// and all members are loaded.
- @Deprecated("Library.isExternal is going away.")
- bool get isExternal => (flags & ExternalFlag) != 0;
-
- @Deprecated("Library.isExternal is going away.")
- void set isExternal(bool value) {
- flags = value ? (flags | ExternalFlag) : (flags & ~ExternalFlag);
- }
-
/// If true, the library is synthetic, for instance library that doesn't
/// represents an actual file and is created as the result of error recovery.
bool get isSynthetic => flags & SyntheticFlag != 0;
@@ -400,7 +391,6 @@
Library(this.importUri,
{this.name,
- bool isExternal: false,
List<Expression> annotations,
List<LibraryDependency> dependencies,
List<LibraryPart> parts,
@@ -420,8 +410,6 @@
this.procedures = procedures ?? <Procedure>[],
this.fields = fields ?? <Field>[],
super(reference) {
- // ignore: DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
- this.isExternal = isExternal;
setParents(this.dependencies, this);
setParents(this.parts, this);
setParents(this.typedefs, this);
@@ -521,6 +509,38 @@
}
}
+ /// This is an advanced feature. Use of this method should be coordinated
+ /// with the kernel team.
+ ///
+ /// See [Component.relink] for a comprehensive description.
+ ///
+ /// Makes sure all references in named nodes in this library points to said
+ /// named node.
+ void relink() {
+ _relinkNode();
+ assert(canonicalName != null);
+ for (int i = 0; i < typedefs.length; ++i) {
+ Typedef typedef_ = typedefs[i];
+ typedef_._relinkNode();
+ }
+ for (int i = 0; i < fields.length; ++i) {
+ Field field = fields[i];
+ field._relinkNode();
+ }
+ for (int i = 0; i < procedures.length; ++i) {
+ Procedure member = procedures[i];
+ member._relinkNode();
+ }
+ for (int i = 0; i < classes.length; ++i) {
+ Class class_ = classes[i];
+ class_.relink();
+ }
+ for (int i = 0; i < extensions.length; ++i) {
+ Extension extension = extensions[i];
+ extension._relinkNode();
+ }
+ }
+
void addDependency(LibraryDependency node) {
dependencies.add(node..parent = this);
}
@@ -1127,6 +1147,34 @@
dirty = false;
}
+ /// This is an advanced feature. Use of this method should be coordinated
+ /// with the kernel team.
+ ///
+ /// See [Component.relink] for a comprehensive description.
+ ///
+ /// Makes sure all references in named nodes in this class points to said
+ /// named node.
+ void relink() {
+ this.reference.node = this;
+ for (int i = 0; i < fields.length; ++i) {
+ Field member = fields[i];
+ member._relinkNode();
+ }
+ for (int i = 0; i < procedures.length; ++i) {
+ Procedure member = procedures[i];
+ member._relinkNode();
+ }
+ for (int i = 0; i < constructors.length; ++i) {
+ Constructor member = constructors[i];
+ member._relinkNode();
+ }
+ for (int i = 0; i < redirectingFactoryConstructors.length; ++i) {
+ RedirectingFactoryConstructor member = redirectingFactoryConstructors[i];
+ member._relinkNode();
+ }
+ dirty = false;
+ }
+
/// The immediate super class, or `null` if this is the root class.
Class get superclass => supertype?.classNode;
@@ -1233,12 +1281,6 @@
return coreTypes.thisInterfaceType(this, nullability);
}
- InterfaceType _bottomType;
- InterfaceType get bottomType {
- return _bottomType ??= new InterfaceType(this, Nullability.legacy,
- new List<DartType>.filled(typeParameters.length, const BottomType()));
- }
-
/// Returns a possibly synthesized name for this class, consistent with
/// the names used across all [toString] calls.
String toString() => debugQualifiedClassName(this);
@@ -2599,14 +2641,19 @@
typeParameterType.promotedBound ?? typeParameterType.parameter.bound;
}
if (type == context.typeEnvironment.nullType) {
- return superclass.bottomType;
+ return context.typeEnvironment.coreTypes
+ .bottomInterfaceType(superclass, context.nullable);
}
if (type is InterfaceType) {
- var upcastType =
- context.typeEnvironment.getTypeAsInstanceOf(type, superclass);
- if (upcastType != null) return upcastType;
+ List<DartType> upcastTypeArguments = context.typeEnvironment
+ .getTypeArgumentsAsInstanceOf(type, superclass);
+ if (upcastTypeArguments != null) {
+ return new InterfaceType(
+ superclass, type.nullability, upcastTypeArguments);
+ }
} else if (type is BottomType) {
- return superclass.bottomType;
+ return context.typeEnvironment.coreTypes
+ .bottomInterfaceType(superclass, context.nonNullable);
}
context.typeEnvironment
.typeError(this, '$type is not a subtype of $superclass');
@@ -2990,9 +3037,10 @@
if (declaringClass.typeParameters.isEmpty) {
return interfaceTarget.getterType;
}
- var receiver = context.typeEnvironment
- .getTypeAsInstanceOf(context.thisType, declaringClass);
- return Substitution.fromInterfaceType(receiver)
+ List<DartType> receiverArguments = context.typeEnvironment
+ .getTypeArgumentsAsInstanceOf(context.thisType, declaringClass);
+ return Substitution.fromPairs(
+ declaringClass.typeParameters, receiverArguments)
.substituteType(interfaceTarget.getterType);
}
@@ -3349,10 +3397,11 @@
DartType getStaticType(StaticTypeContext context) {
if (interfaceTarget == null) return const DynamicType();
Class superclass = interfaceTarget.enclosingClass;
- var receiverType = context.typeEnvironment
- .getTypeAsInstanceOf(context.thisType, superclass);
- var returnType = Substitution.fromInterfaceType(receiverType)
- .substituteType(interfaceTarget.function.returnType);
+ List<DartType> receiverTypeArguments = context.typeEnvironment
+ .getTypeArgumentsAsInstanceOf(context.thisType, superclass);
+ DartType returnType =
+ Substitution.fromPairs(superclass.typeParameters, receiverTypeArguments)
+ .substituteType(interfaceTarget.function.returnType);
return Substitution.fromPairs(
interfaceTarget.function.typeParameters, arguments.types)
.substituteType(returnType);
@@ -6908,6 +6957,38 @@
}
}
+ /// This is an advanced feature. Use of this method should be coordinated
+ /// with the kernel team.
+ ///
+ /// Makes sure all references in named nodes in this component points to said
+ /// named node.
+ ///
+ /// The use case is advanced incremental compilation, where we want to rebuild
+ /// a single library and make all other libraries use the new library and the
+ /// content therein *while* having the option to go back to pointing (be
+ /// "linked") to the old library if the delta is rejected.
+ ///
+ /// Please note that calling this is a potentially dangerous thing to do,
+ /// and that stuff *can* go wrong, and you could end up in a situation where
+ /// you point to several versions of "the same" library. Examples:
+ /// * If you only relink part (e.g. a class) if your component you can wind
+ /// up in an unfortunate situation where if the library (say libA) contains
+ /// class 'B' and class 'C', you only replace 'B' (with one in library
+ /// 'libAPrime'), everything pointing to 'B' via parent pointers talks
+ /// about 'libAPrime', whereas everything pointing to 'C' would still
+ /// ultimately point to 'libA'.
+ /// * If you relink to a library that doesn't have exactly the same members
+ /// as the one you're "linking from" you can wind up in an unfortunate
+ /// situation, e.g. if the thing you relink two is missing a static method,
+ /// any links to that static method will still point to the old static
+ /// method and thus (via parent pointers) to the old library.
+ /// * (probably more).
+ void relink() {
+ for (int i = 0; i < libraries.length; ++i) {
+ libraries[i].relink();
+ }
+ }
+
void computeCanonicalNamesForLibrary(Library library) {
root.getChildFromUri(library.importUri).bindTo(library.reference);
library.computeCanonicalNames();
@@ -7024,6 +7105,7 @@
void writeStringReference(String str);
void writeName(Name node);
void writeDartType(DartType type);
+ void writeConstantReference(Constant constant);
void writeNode(Node node);
void enterScope(
@@ -7052,6 +7134,7 @@
String readStringReference();
Name readName();
DartType readDartType();
+ Constant readConstantReference();
FunctionNode readFunctionNode();
void enterScope({List<TypeParameter> typeParameters});
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index 2178093..4604782 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -90,7 +90,6 @@
// class, and member was being built.
List<String> debugPath = <String>[];
- bool _isReadingLibraryImplementation = false;
final bool alwaysCreateNewNamedNodes;
/// If binary contains metadata section with payloads referencing other nodes
@@ -387,13 +386,6 @@
}
}
- void _skipNodeList(Node skipObject()) {
- var length = readUInt();
- for (int i = 0; i < length; ++i) {
- skipObject();
- }
- }
-
/// Reads a list of named nodes, reusing any existing objects already in the
/// linking tree. The nodes are merged into [list], and if reading the library
/// implementation, the order is corrected.
@@ -403,24 +395,9 @@
/// must be reused and returned.
void _mergeNamedNodeList(
List<NamedNode> list, NamedNode readObject(int index), TreeNode parent) {
- if (_isReadingLibraryImplementation) {
- // When reading the library implementation, overwrite the whole list
- // with the new one.
- _fillTreeNodeList(list, readObject, parent);
- } else {
- // When reading an external library, the results should either be:
- // - merged with the existing external library definition (if any)
- // - ignored if the library implementation is already in memory
- int numberOfNodes = readUInt();
- for (int i = 0; i < numberOfNodes; ++i) {
- var value = readObject(i);
- // We use the parent pointer of a node to determine if it already is in
- // the AST and hence should not be added again.
- if (value.parent == null) {
- list.add(value..parent = parent);
- }
- }
- }
+ // When reading the library implementation, overwrite the whole list
+ // with the new one.
+ _fillTreeNodeList(list, readObject, parent);
}
void readLinkTable(CanonicalName linkRoot) {
@@ -898,8 +875,6 @@
_byteOffset = savedByteOffset;
int flags = readByte();
- bool isExternal = (flags & Library.ExternalFlag) != 0;
- _isReadingLibraryImplementation = !isExternal;
int languageVersionMajor = readUInt();
int languageVersionMinor = readUInt();
@@ -910,7 +885,6 @@
if (alwaysCreateNewNamedNodes) {
library = null;
}
- bool shouldWriteData = library == null || _isReadingLibraryImplementation;
if (library == null) {
library =
new Library(Uri.parse(canonicalName.name), reference: reference);
@@ -924,25 +898,19 @@
List<String> problemsAsJson = readListOfStrings();
- if (shouldWriteData) {
- library.flags = flags;
- library.setLanguageVersion(languageVersionMajor, languageVersionMinor);
- library.name = name;
- library.fileUri = fileUri;
- library.problemsAsJson = problemsAsJson;
- }
+ library.flags = flags;
+ library.setLanguageVersion(languageVersionMajor, languageVersionMinor);
+ library.name = name;
+ library.fileUri = fileUri;
+ library.problemsAsJson = problemsAsJson;
assert(() {
debugPath.add(library.name ?? library.importUri?.toString() ?? 'library');
return true;
}());
- if (shouldWriteData) {
- _fillTreeNodeList(
- library.annotations, (index) => readExpression(), library);
- } else {
- _skipNodeList(readExpression);
- }
+ _fillTreeNodeList(
+ library.annotations, (index) => readExpression(), library);
_readLibraryDependencies(library);
_readAdditionalExports(library);
_readLibraryParts(library);
@@ -1040,7 +1008,6 @@
if (alwaysCreateNewNamedNodes) {
node = null;
}
- bool shouldWriteData = node == null || _isReadingLibraryImplementation;
if (node == null) {
node = new Typedef(null, null, reference: reference);
}
@@ -1057,12 +1024,10 @@
node.namedParameters.addAll(readAndPushVariableDeclarationList());
typeParameterStack.length = 0;
variableStack.length = 0;
- if (shouldWriteData) {
- node.fileOffset = fileOffset;
- node.name = name;
- node.fileUri = fileUri;
- node.type = type;
- }
+ node.fileOffset = fileOffset;
+ node.name = name;
+ node.fileUri = fileUri;
+ node.type = type;
return node;
}
@@ -1090,7 +1055,6 @@
if (alwaysCreateNewNamedNodes) {
node = null;
}
- bool shouldWriteData = node == null || _isReadingLibraryImplementation;
if (node == null) {
node = new Class(reference: reference)
..level = ClassLevel.Temporary
@@ -1120,11 +1084,7 @@
readAndPushTypeParameterList(node.typeParameters, node);
var supertype = readSupertypeOption();
var mixedInType = readSupertypeOption();
- if (shouldWriteData) {
- _fillNonTreeNodeList(node.implementedTypes, readSupertype);
- } else {
- _skipNodeList(readSupertype);
- }
+ _fillNonTreeNodeList(node.implementedTypes, readSupertype);
if (_disableLazyClassReading) {
readClassPartialContent(node, procedureOffsets);
} else {
@@ -1133,13 +1093,11 @@
typeParameterStack.length = 0;
assert(debugPath.removeLast() != null);
- if (shouldWriteData) {
- node.name = name;
- node.fileUri = fileUri;
- node.annotations = annotations;
- node.supertype = supertype;
- node.mixedInType = mixedInType;
- }
+ node.name = name;
+ node.fileUri = fileUri;
+ node.annotations = annotations;
+ node.supertype = supertype;
+ node.mixedInType = mixedInType;
_byteOffset = endOffset;
@@ -1156,7 +1114,6 @@
if (alwaysCreateNewNamedNodes) {
node = null;
}
- bool shouldWriteData = node == null || _isReadingLibraryImplementation;
if (node == null) {
node = new Extension(reference: reference);
}
@@ -1174,28 +1131,22 @@
DartType onType = readDartType();
typeParameterStack.length = 0;
- if (shouldWriteData) {
- node.name = name;
- node.fileUri = fileUri;
- node.onType = onType;
- }
+ node.name = name;
+ node.fileUri = fileUri;
+ node.onType = onType;
int length = readUInt();
- if (shouldWriteData) {
- node.members.length = length;
- }
+ node.members.length = length;
for (int i = 0; i < length; i++) {
Name name = readName();
int kind = readByte();
int flags = readByte();
CanonicalName canonicalName = readCanonicalNameReference();
- if (shouldWriteData) {
- node.members[i] = new ExtensionMemberDescriptor(
- name: name,
- kind: ExtensionMemberKind.values[kind],
- member: canonicalName.getReference())
- ..flags = flags;
- }
+ node.members[i] = new ExtensionMemberDescriptor(
+ name: name,
+ kind: ExtensionMemberKind.values[kind],
+ member: canonicalName.getReference())
+ ..flags = flags;
}
return node;
}
@@ -1253,7 +1204,6 @@
if (alwaysCreateNewNamedNodes) {
node = null;
}
- bool shouldWriteData = node == null || _isReadingLibraryImplementation;
if (node == null) {
node = new Field(null, reference: reference);
}
@@ -1271,18 +1221,16 @@
var initializer = readExpressionOption();
int transformerFlags = getAndResetTransformerFlags();
assert(((_) => true)(debugPath.removeLast()));
- if (shouldWriteData) {
- node.fileOffset = fileOffset;
- node.fileEndOffset = fileEndOffset;
- node.flags = flags;
- node.name = name;
- node.fileUri = fileUri;
- node.annotations = annotations;
- node.type = type;
- node.initializer = initializer;
- node.initializer?.parent = node;
- node.transformerFlags = transformerFlags;
- }
+ node.fileOffset = fileOffset;
+ node.fileEndOffset = fileEndOffset;
+ node.flags = flags;
+ node.name = name;
+ node.fileUri = fileUri;
+ node.annotations = annotations;
+ node.type = type;
+ node.initializer = initializer;
+ node.initializer?.parent = node;
+ node.transformerFlags = transformerFlags;
return node;
}
@@ -1295,7 +1243,6 @@
if (alwaysCreateNewNamedNodes) {
node = null;
}
- bool shouldWriteData = node == null || _isReadingLibraryImplementation;
if (node == null) {
node = new Constructor(null, reference: reference);
}
@@ -1313,25 +1260,19 @@
var function = readFunctionNode();
pushVariableDeclarations(function.positionalParameters);
pushVariableDeclarations(function.namedParameters);
- if (shouldWriteData) {
- _fillTreeNodeList(node.initializers, (index) => readInitializer(), node);
- } else {
- _skipNodeList(readInitializer);
- }
+ _fillTreeNodeList(node.initializers, (index) => readInitializer(), node);
variableStack.length = 0;
var transformerFlags = getAndResetTransformerFlags();
assert(((_) => true)(debugPath.removeLast()));
- if (shouldWriteData) {
- node.startFileOffset = startFileOffset;
- node.fileOffset = fileOffset;
- node.fileEndOffset = fileEndOffset;
- node.flags = flags;
- node.name = name;
- node.fileUri = fileUri;
- node.annotations = annotations;
- node.function = function..parent = node;
- node.transformerFlags = transformerFlags;
- }
+ node.startFileOffset = startFileOffset;
+ node.fileOffset = fileOffset;
+ node.fileEndOffset = fileEndOffset;
+ node.flags = flags;
+ node.name = name;
+ node.fileUri = fileUri;
+ node.annotations = annotations;
+ node.function = function..parent = node;
+ node.transformerFlags = transformerFlags;
return node;
}
@@ -1344,7 +1285,6 @@
if (alwaysCreateNewNamedNodes) {
node = null;
}
- bool shouldWriteData = node == null || _isReadingLibraryImplementation;
if (node == null) {
node = new Procedure(null, null, null, reference: reference);
}
@@ -1373,26 +1313,24 @@
var function = readFunctionNodeOption(!readFunctionNodeNow, endOffset);
var transformerFlags = getAndResetTransformerFlags();
assert(((_) => true)(debugPath.removeLast()));
- if (shouldWriteData) {
- node.startFileOffset = startFileOffset;
- node.fileOffset = fileOffset;
- node.fileEndOffset = fileEndOffset;
- node.kind = kind;
- node.flags = flags;
- node.name = name;
- node.fileUri = fileUri;
- node.annotations = annotations;
- node.function = function;
- function?.parent = node;
- node.setTransformerFlagsWithoutLazyLoading(transformerFlags);
- node.forwardingStubSuperTargetReference =
- forwardingStubSuperTargetReference;
- node.forwardingStubInterfaceTargetReference =
- forwardingStubInterfaceTargetReference;
+ node.startFileOffset = startFileOffset;
+ node.fileOffset = fileOffset;
+ node.fileEndOffset = fileEndOffset;
+ node.kind = kind;
+ node.flags = flags;
+ node.name = name;
+ node.fileUri = fileUri;
+ node.annotations = annotations;
+ node.function = function;
+ function?.parent = node;
+ node.setTransformerFlagsWithoutLazyLoading(transformerFlags);
+ node.forwardingStubSuperTargetReference =
+ forwardingStubSuperTargetReference;
+ node.forwardingStubInterfaceTargetReference =
+ forwardingStubInterfaceTargetReference;
- assert((node.forwardingStubSuperTargetReference != null) ||
- !(node.isForwardingStub && node.function.body != null));
- }
+ assert((node.forwardingStubSuperTargetReference != null) ||
+ !(node.isForwardingStub && node.function.body != null));
_byteOffset = endOffset;
return node;
}
@@ -1406,7 +1344,6 @@
if (alwaysCreateNewNamedNodes) {
node = null;
}
- bool shouldWriteData = node == null || _isReadingLibraryImplementation;
if (node == null) {
node = new RedirectingFactoryConstructor(null, reference: reference);
}
@@ -1432,20 +1369,18 @@
variableStack.length = variableStackHeight;
typeParameterStack.length = typeParameterStackHeight;
debugPath.removeLast();
- if (shouldWriteData) {
- node.fileOffset = fileOffset;
- node.fileEndOffset = fileEndOffset;
- node.flags = flags;
- node.name = name;
- node.fileUri = fileUri;
- node.annotations = annotations;
- node.targetReference = targetReference;
- node.typeArguments.addAll(typeArguments);
- node.typeParameters = typeParameters;
- node.requiredParameterCount = requiredParameterCount;
- node.positionalParameters = positional;
- node.namedParameters = named;
- }
+ node.fileOffset = fileOffset;
+ node.fileEndOffset = fileEndOffset;
+ node.flags = flags;
+ node.name = name;
+ node.fileUri = fileUri;
+ node.annotations = annotations;
+ node.targetReference = targetReference;
+ node.typeArguments.addAll(typeArguments);
+ node.typeParameters = typeParameters;
+ node.requiredParameterCount = requiredParameterCount;
+ node.positionalParameters = positional;
+ node.namedParameters = named;
return node;
}
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart
index 50ad84c..fdefbc1 100644
--- a/pkg/kernel/lib/binary/ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart
@@ -934,8 +934,6 @@
void visitLibrary(Library node) {
_currentLibrary = node;
- // ignore: DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
- insideExternalLibrary = node.isExternal;
libraryOffsets.add(getBufferOffset());
writeByte(node.flags);
diff --git a/pkg/kernel/lib/class_hierarchy.dart b/pkg/kernel/lib/class_hierarchy.dart
index b2431be..2e2a7fc 100644
--- a/pkg/kernel/lib/class_hierarchy.dart
+++ b/pkg/kernel/lib/class_hierarchy.dart
@@ -9,8 +9,9 @@
import 'ast.dart';
import 'core_types.dart';
-import 'src/heap.dart';
import 'type_algebra.dart';
+import 'src/heap.dart';
+import 'src/future_or.dart';
typedef HandleAmbiguousSupertypes = void Function(Class, Supertype, Supertype);
@@ -62,8 +63,8 @@
/// Dart 2 least upper bound, which has special behaviors in the case where
/// one type is a subtype of the other, or where both types are based on the
/// same class.
- InterfaceType getLegacyLeastUpperBound(
- InterfaceType type1, InterfaceType type2, CoreTypes coreTypes);
+ InterfaceType getLegacyLeastUpperBound(InterfaceType type1,
+ InterfaceType type2, Library clientLibrary, CoreTypes coreTypes);
/// Returns the instantiation of [superclass] that is implemented by [class_],
/// or `null` if [class_] does not implement [superclass] at all.
@@ -71,7 +72,14 @@
/// Returns the instantiation of [superclass] that is implemented by [type],
/// or `null` if [type] does not implement [superclass] at all.
- InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass);
+ InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass,
+ Library clientLibrary, CoreTypes coreTypes);
+
+ /// Returns the type arguments of the instantiation of [superclass] that is
+ /// implemented by [type], or `null` if [type] does not implement [superclass]
+ /// at all.
+ List<DartType> getTypeArgumentsAsInstanceOf(
+ InterfaceType type, Class superclass);
/// Returns the instantiation of [superclass] that is implemented by [type],
/// or `null` if [type] does not implement [superclass]. [superclass] must
@@ -540,8 +548,8 @@
}
@override
- InterfaceType getLegacyLeastUpperBound(
- InterfaceType type1, InterfaceType type2, CoreTypes coreTypes) {
+ InterfaceType getLegacyLeastUpperBound(InterfaceType type1,
+ InterfaceType type2, Library clientLibrary, CoreTypes coreTypes) {
// The algorithm is: first we compute a list of superclasses for both types,
// ordered from greatest to least depth, and ordered by topological sort
// index within each depth. Due to the sort order, we can find the
@@ -561,6 +569,16 @@
// Compute the list of superclasses for both types, with the above
// optimization.
+
+ // LLUB(Null, List<dynamic>*) works differently for opt-in and opt-out
+ // libraries. In opt-out libraries the legacy behavior is preserved, so
+ // LLUB(Null, List<dynamic>*) = List<dynamic>*. In opt-in libraries the
+ // rules imply that LLUB(Null, List<dynamic>*) = List<dynamic>?.
+ if (!clientLibrary.isNonNullableByDefault) {
+ if (type1 == coreTypes.nullType) return type2;
+ if (type2 == coreTypes.nullType) return type1;
+ }
+
_ClassInfo info1 = infoFor(type1.classNode);
_ClassInfo info2 = infoFor(type2.classNode);
List<_ClassInfo> classes1;
@@ -615,8 +633,8 @@
// immediately. Since all interface types are subtypes of Object, this
// ensures the loop terminates.
if (next.classNode.typeParameters.isEmpty) {
- // TODO(dmitryas): Update nullability as necessary for the LUB spec.
- candidate = coreTypes.legacyRawType(next.classNode);
+ candidate = coreTypes.rawType(next.classNode,
+ uniteNullabilities(type1.nullability, type2.nullability));
if (currentDepth == 0) return candidate;
++numCandidatesAtThisDepth;
} else {
@@ -629,7 +647,8 @@
: Substitution.fromInterfaceType(type2).substituteType(
info2.genericSuperTypes[next.classNode].first.asInterfaceType);
if (superType1 == superType2) {
- candidate = superType1;
+ candidate = superType1.withNullability(
+ uniteNullabilities(type1.nullability, type2.nullability));
++numCandidatesAtThisDepth;
}
}
@@ -653,11 +672,30 @@
}
@override
- InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass) {
+ InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass,
+ Library clientLibrary, CoreTypes coreTypes) {
+ List<DartType> typeArguments =
+ getTypeArgumentsAsInstanceOf(type, superclass);
+ if (typeArguments == null) return null;
+ // The return value should be a legacy type if it's computed for an
+ // opted-out library, unless the return value is Null? which is always
+ // nullable.
+ Nullability nullability = superclass == coreTypes.nullClass ||
+ clientLibrary.isNonNullableByDefault
+ ? type.nullability
+ : Nullability.legacy;
+ return new InterfaceType(superclass, nullability, typeArguments);
+ }
+
+ @override
+ List<DartType> getTypeArgumentsAsInstanceOf(
+ InterfaceType type, Class superclass) {
Supertype castedType = getClassAsInstanceOf(type.classNode, superclass);
if (castedType == null) return null;
+ if (superclass.typeParameters.isEmpty) return const <DartType>[];
return Substitution.fromInterfaceType(type)
- .substituteType(castedType.asInterfaceType);
+ .substituteSupertype(castedType)
+ .typeArguments;
}
@override
diff --git a/pkg/kernel/lib/core_types.dart b/pkg/kernel/lib/core_types.dart
index 059e579..635c160 100644
--- a/pkg/kernel/lib/core_types.dart
+++ b/pkg/kernel/lib/core_types.dart
@@ -28,6 +28,7 @@
'FallThroughError',
],
'dart:_internal': [
+ 'LateInitializationErrorImpl',
'Symbol',
],
'dart:async': [
@@ -64,6 +65,9 @@
Constructor _fallThroughErrorUrlAndLineConstructor;
Procedure _objectEquals;
Procedure _mapUnmodifiable;
+ Procedure _iterableGetIterator;
+ Procedure _iteratorMoveNext;
+ Procedure _iteratorGetCurrent;
Class _internalSymbolClass;
@@ -86,6 +90,7 @@
Procedure _asyncErrorWrapperHelperProcedure;
Procedure _awaitHelperProcedure;
Procedure _boolFromEnvironment;
+ Constructor _lateInitializationErrorConstructor;
/// The `dart:mirrors` library, or `null` if the component does not use it.
Library _mirrorsLibrary;
@@ -153,9 +158,6 @@
InterfaceType _streamLegacyRawType;
InterfaceType _streamNullableRawType;
InterfaceType _streamNonNullableRawType;
- InterfaceType _asyncAwaitCompleterLegacyRawType;
- InterfaceType _asyncAwaitCompleterNullableRawType;
- InterfaceType _asyncAwaitCompleterNonNullableRawType;
InterfaceType _futureOrLegacyRawType;
InterfaceType _futureOrNullableRawType;
InterfaceType _futureOrNonNullableRawType;
@@ -172,6 +174,8 @@
new Map<Class, InterfaceType>.identity();
final Map<Typedef, TypedefType> _thisTypedefTypes =
new Map<Typedef, TypedefType>.identity();
+ final Map<Class, InterfaceType> _bottomInterfaceTypes =
+ new Map<Class, InterfaceType>.identity();
CoreTypes(Component component)
: index = new LibraryIndex.coreLibraries(component);
@@ -322,10 +326,25 @@
return _iterableClass ??= index.getClass('dart:core', 'Iterable');
}
+ Procedure get iterableGetIterator {
+ return _iterableGetIterator ??=
+ index.getMember('dart:core', 'Iterable', 'get:iterator');
+ }
+
Class get iteratorClass {
return _iteratorClass ??= index.getClass('dart:core', 'Iterator');
}
+ Procedure get iteratorMoveNext {
+ return _iteratorMoveNext ??=
+ index.getMember('dart:core', 'Iterator', 'moveNext');
+ }
+
+ Procedure get iteratorGetCurrent {
+ return _iteratorGetCurrent ??=
+ index.getMember('dart:core', 'Iterator', 'get:current');
+ }
+
Class get listClass {
return _listClass ??= index.getClass('dart:core', 'List');
}
@@ -1088,45 +1107,6 @@
}
}
- InterfaceType get asyncAwaitCompleterLegacyRawType {
- return _asyncAwaitCompleterLegacyRawType ??=
- _legacyRawTypes[asyncAwaitCompleterClass] ??= new InterfaceType(
- asyncAwaitCompleterClass,
- Nullability.legacy,
- const <DartType>[const DynamicType()]);
- }
-
- InterfaceType get asyncAwaitCompleterNullableRawType {
- return _asyncAwaitCompleterNullableRawType ??=
- _nullableRawTypes[asyncAwaitCompleterClass] ??= new InterfaceType(
- asyncAwaitCompleterClass,
- Nullability.nullable,
- const <DartType>[const DynamicType()]);
- }
-
- InterfaceType get asyncAwaitCompleterNonNullableRawType {
- return _asyncAwaitCompleterNonNullableRawType ??=
- _nonNullableRawTypes[asyncAwaitCompleterClass] ??= new InterfaceType(
- asyncAwaitCompleterClass,
- Nullability.nonNullable,
- const <DartType>[const DynamicType()]);
- }
-
- InterfaceType asyncAwaitCompleterRawType(Nullability nullability) {
- switch (nullability) {
- case Nullability.legacy:
- return asyncAwaitCompleterLegacyRawType;
- case Nullability.nullable:
- return asyncAwaitCompleterNullableRawType;
- case Nullability.nonNullable:
- return asyncAwaitCompleterNonNullableRawType;
- case Nullability.undetermined:
- default:
- throw new StateError(
- "Unsupported nullability $nullability on an InterfaceType.");
- }
- }
-
InterfaceType get futureOrLegacyRawType {
return _futureOrLegacyRawType ??= _legacyRawTypes[futureOrClass] ??=
new InterfaceType(futureOrClass, Nullability.legacy,
@@ -1257,4 +1237,24 @@
}
return result;
}
+
+ Constructor get lateInitializationErrorConstructor {
+ return _lateInitializationErrorConstructor ??=
+ index.getMember('dart:_internal', 'LateInitializationErrorImpl', '');
+ }
+
+ InterfaceType bottomInterfaceType(Class klass, Nullability nullability) {
+ InterfaceType result = _bottomInterfaceTypes[klass];
+ if (result == null) {
+ return _bottomInterfaceTypes[klass] = new InterfaceType(
+ klass,
+ nullability,
+ new List<DartType>.filled(
+ klass.typeParameters.length, const BottomType()));
+ }
+ if (result.nullability != nullability) {
+ return _bottomInterfaceTypes[klass] = result.withNullability(nullability);
+ }
+ return result;
+ }
}
diff --git a/pkg/kernel/lib/kernel.dart b/pkg/kernel/lib/kernel.dart
index aa2a903..d93c688 100644
--- a/pkg/kernel/lib/kernel.dart
+++ b/pkg/kernel/lib/kernel.dart
@@ -72,15 +72,9 @@
}
void writeComponentToText(Component component,
- {String path,
- bool showExternal: false,
- bool showOffsets: false,
- bool showMetadata: false}) {
+ {String path, bool showOffsets: false, bool showMetadata: false}) {
StringBuffer buffer = new StringBuffer();
- new Printer(buffer,
- showExternal: showExternal,
- showOffsets: showOffsets,
- showMetadata: showMetadata)
+ new Printer(buffer, showOffsets: showOffsets, showMetadata: showMetadata)
.writeComponentFile(component);
if (path == null) {
print(buffer);
diff --git a/pkg/kernel/lib/library_index.dart b/pkg/kernel/lib/library_index.dart
index ce66691..823f3ba 100644
--- a/pkg/kernel/lib/library_index.dart
+++ b/pkg/kernel/lib/library_index.dart
@@ -152,14 +152,7 @@
}
String get containerName {
- // For useful error messages, it can be helpful to indicate if the library
- // is external. If a class or member was not found in an external library,
- // it might be that it exists in the actual library, but its interface was
- // not included in this build unit.
- // ignore: DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
- return library.isExternal
- ? "external library '${library.importUri}'"
- : "library '${library.importUri}'";
+ return "library '${library.importUri}'";
}
_MemberTable _getClassIndex(String name) {
diff --git a/pkg/kernel/lib/src/hierarchy_based_type_environment.dart b/pkg/kernel/lib/src/hierarchy_based_type_environment.dart
index 5ef4e9f..a7358c2 100644
--- a/pkg/kernel/lib/src/hierarchy_based_type_environment.dart
+++ b/pkg/kernel/lib/src/hierarchy_based_type_environment.dart
@@ -4,7 +4,7 @@
library kernel.hierarchy_based_type_environment;
-import '../ast.dart' show Class, InterfaceType, Member, Name;
+import '../ast.dart' show Class, DartType, InterfaceType, Library, Member, Name;
import '../class_hierarchy.dart' show ClassHierarchy;
@@ -19,8 +19,16 @@
: super.fromSubclass(coreTypes);
@override
- InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass) {
- return hierarchy.getTypeAsInstanceOf(type, superclass);
+ InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass,
+ Library clientLibrary, CoreTypes coreTypes) {
+ return hierarchy.getTypeAsInstanceOf(
+ type, superclass, clientLibrary, coreTypes);
+ }
+
+ @override
+ List<DartType> getTypeArgumentsAsInstanceOf(
+ InterfaceType type, Class superclass) {
+ return hierarchy.getTypeArgumentsAsInstanceOf(type, superclass);
}
@override
diff --git a/pkg/kernel/lib/target/targets.dart b/pkg/kernel/lib/target/targets.dart
index afc3160..6eb6338 100644
--- a/pkg/kernel/lib/target/targets.dart
+++ b/pkg/kernel/lib/target/targets.dart
@@ -264,6 +264,7 @@
Class concreteConstMapLiteralClass(CoreTypes coreTypes) => null;
Class concreteIntLiteralClass(CoreTypes coreTypes, int value) => null;
+ Class concreteDoubleLiteralClass(CoreTypes coreTypes, double value) => null;
Class concreteStringLiteralClass(CoreTypes coreTypes, String value) => null;
ConstantsBackend constantsBackend(CoreTypes coreTypes);
diff --git a/pkg/kernel/lib/text/ast_to_text.dart b/pkg/kernel/lib/text/ast_to_text.dart
index 88e1512..5ae2df6 100644
--- a/pkg/kernel/lib/text/ast_to_text.dart
+++ b/pkg/kernel/lib/text/ast_to_text.dart
@@ -261,7 +261,6 @@
ImportTable importTable;
int indentation = 0;
int column = 0;
- bool showExternal;
bool showOffsets;
bool showMetadata;
@@ -272,7 +271,6 @@
Printer(this.sink,
{NameSystem syntheticNames,
- this.showExternal,
this.showOffsets: false,
this.showMetadata: false,
this.importTable,
@@ -287,7 +285,6 @@
metadata: metadata,
syntheticNames: syntheticNames,
annotator: annotator,
- showExternal: showExternal,
showOffsets: showOffsets,
showMetadata: showMetadata);
}
@@ -509,13 +506,6 @@
}
writeComponentProblems(component);
for (var library in component.libraries) {
- // ignore: DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
- if (library.isExternal) {
- if (!showExternal) {
- continue;
- }
- writeWord('external');
- }
if (showMetadata) {
inner.writeMetadata(library);
}
diff --git a/pkg/kernel/lib/transformations/continuation.dart b/pkg/kernel/lib/transformations/continuation.dart
index 71bba56..25d1d41 100644
--- a/pkg/kernel/lib/transformations/continuation.dart
+++ b/pkg/kernel/lib/transformations/continuation.dart
@@ -15,8 +15,10 @@
class ContinuationVariables {
static const awaitJumpVar = ':await_jump_var';
+ static const asyncCompleter = ':async_completer';
static const awaitContextVar = ':await_ctx_var';
static const asyncStackTraceVar = ':async_stack_trace';
+ static const controller = ':controller';
static const controllerStreamVar = ':controller_stream';
static const exceptionParam = ':exception';
static const stackTraceParam = ':stack_trace';
@@ -130,6 +132,65 @@
return null;
}
}
+
+ @override
+ TreeNode visitForInStatement(ForInStatement stmt) {
+ if (stmt.isAsync) {
+ return super.visitForInStatement(stmt);
+ }
+
+ // Transform
+ //
+ // for ({var/final} T <variable> in <iterable>) { ... }
+ //
+ // Into
+ //
+ // {
+ // final Iterator<T> :sync-for-iterator = <iterable>.iterator;
+ // for (; :sync-for-iterator.moveNext() ;) {
+ // {var/final} T variable = :iterator.current;
+ // ...
+ // }
+ // }
+ // }
+ final CoreTypes coreTypes = staticTypeContext.typeEnvironment.coreTypes;
+
+ // TODO(39565): We should be able to use forInElementType.
+ helper.unsafeCast;
+ final DartType iterableType =
+ stmt.iterable.getStaticType(staticTypeContext);
+ final DartType iterationType = iterableType is InterfaceType
+ ? staticTypeContext.typeEnvironment.forInElementType(stmt, iterableType)
+ : DynamicType();
+ final expectedIterableType = InterfaceType(
+ coreTypes.iterableClass, Nullability.legacy, [iterationType]);
+ final iteratorType = InterfaceType(
+ coreTypes.iteratorClass, Nullability.legacy, [iterationType]);
+
+ // TODO(39566): Iterable expression is not always well typed in the AST.
+ final typedIterable = StaticInvocation(helper.unsafeCast,
+ Arguments([stmt.iterable], types: [expectedIterableType]));
+ final iterator = VariableDeclaration(':sync-for-iterator',
+ initializer: PropertyGet(
+ typedIterable, Name('iterator'), coreTypes.iterableGetIterator)
+ ..fileOffset = stmt.iterable.fileOffset,
+ type: iteratorType)
+ ..fileOffset = stmt.iterable.fileOffset;
+
+ final condition = MethodInvocation(VariableGet(iterator), Name('moveNext'),
+ Arguments([]), coreTypes.iteratorMoveNext)
+ ..fileOffset = stmt.iterable.fileOffset;
+
+ final variable = stmt.variable
+ ..initializer = (PropertyGet(
+ VariableGet(iterator), Name('current'), coreTypes.iteratorGetCurrent)
+ ..fileOffset = stmt.bodyOffset);
+
+ final Block body = Block([variable, stmt.body]);
+
+ return Block([iterator, ForStatement([], condition, [], body)])
+ .accept<TreeNode>(this);
+ }
}
abstract class ContinuationRewriterBase extends RecursiveContinuationRewriter {
@@ -863,13 +924,11 @@
tryFinally
]);
block.accept<TreeNode>(this);
+ return null;
} else {
- stmt.iterable = expressionRewriter.rewrite(stmt.iterable, statements)
- ..parent = stmt;
- stmt.body = visitDelimited(stmt.body)..parent = stmt;
- statements.add(stmt);
+ super.visitForInStatement(stmt);
+ return null;
}
- return null;
}
TreeNode visitSwitchStatement(SwitchStatement stmt) {
@@ -964,7 +1023,8 @@
final elementType = elementTypeFromReturnType(helper.streamClass);
// _AsyncStarStreamController<T> :controller;
- controllerVariable = new VariableDeclaration(":controller",
+ controllerVariable = new VariableDeclaration(
+ ContinuationVariables.controller,
type: new InterfaceType(helper.asyncStarStreamControllerClass,
staticTypeContext.nullable, [elementType]));
statements.add(controllerVariable);
diff --git a/pkg/kernel/lib/transformations/mixin_full_resolution.dart b/pkg/kernel/lib/transformations/mixin_full_resolution.dart
index cbeb3d1..6188b5e 100644
--- a/pkg/kernel/lib/transformations/mixin_full_resolution.dart
+++ b/pkg/kernel/lib/transformations/mixin_full_resolution.dart
@@ -55,9 +55,6 @@
// the mixin and constructors from the base class.
var processedClasses = new Set<Class>();
for (var library in libraries) {
- // ignore: DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
- if (library.isExternal) continue;
-
for (var class_ in library.classes) {
transformClass(libraries, processedClasses, transformedClasses, class_);
}
@@ -72,9 +69,6 @@
}
// Resolve all super call expressions and super initializers.
for (var library in libraries) {
- // ignore: DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
- if (library.isExternal) continue;
-
for (var class_ in library.classes) {
for (var procedure in class_.procedures) {
if (procedure.containsSuperCalls) {
diff --git a/pkg/kernel/lib/transformations/track_widget_constructor_locations.dart b/pkg/kernel/lib/transformations/track_widget_constructor_locations.dart
index 46c0f61..44a7285 100644
--- a/pkg/kernel/lib/transformations/track_widget_constructor_locations.dart
+++ b/pkg/kernel/lib/transformations/track_widget_constructor_locations.dart
@@ -456,10 +456,6 @@
..addAll(libraries);
for (Library library in libraries) {
- // ignore: DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
- if (library.isExternal) {
- continue;
- }
for (Class class_ in library.classes) {
_transformWidgetConstructors(
librariesToTransform,
@@ -477,10 +473,6 @@
tracker: this);
for (Library library in libraries) {
- // ignore: DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
- if (library.isExternal) {
- continue;
- }
callsiteTransformer.enterLibrary(library);
library.transformChildren(callsiteTransformer);
callsiteTransformer.exitLibrary();
diff --git a/pkg/kernel/lib/type_algebra.dart b/pkg/kernel/lib/type_algebra.dart
index 87ac4a0..5a89298 100644
--- a/pkg/kernel/lib/type_algebra.dart
+++ b/pkg/kernel/lib/type_algebra.dart
@@ -4,7 +4,6 @@
library kernel.type_algebra;
import 'ast.dart';
-import 'clone.dart';
/// Returns a type where all occurrences of the given type parameters have been
/// replaced with the corresponding types.
@@ -117,7 +116,6 @@
map[typeParameters[i]] = new TypeParameterType.forAlphaRenaming(
typeParameters[i], freshParameters[i]);
}
- CloneVisitor cloner;
for (int i = 0; i < typeParameters.length; ++i) {
TypeParameter typeParameter = typeParameters[i];
TypeParameter freshTypeParameter = freshParameters[i];
@@ -128,16 +126,9 @@
: null;
freshTypeParameter.variance =
typeParameter.isLegacyCovariant ? null : typeParameter.variance;
- if (typeParameter.annotations.isNotEmpty) {
- // Annotations can't refer to type parameters, so the cloner shouldn't
- // perform the substitution.
- // TODO(dmitryas): Consider rewriting getFreshTypeParameters using cloner
- // for copying typeParameters as well.
- cloner ??= new CloneVisitor();
- for (Expression annotation in typeParameter.annotations) {
- freshTypeParameter.addAnnotation(cloner.clone(annotation));
- }
- }
+ // Annotations on a type parameter are specific to the declaration of the
+ // type parameter, rather than the type parameter as such, and therefore
+ // should not be copied here.
}
return new FreshTypeParameters(freshParameters, Substitution.fromMap(map));
}
diff --git a/pkg/kernel/lib/type_checker.dart b/pkg/kernel/lib/type_checker.dart
index ba3e192..59c41e6 100644
--- a/pkg/kernel/lib/type_checker.dart
+++ b/pkg/kernel/lib/type_checker.dart
@@ -255,9 +255,11 @@
}
if (type is InterfaceType) {
// The receiver type should implement the interface declaring the member.
- var upcastType = hierarchy.getTypeAsInstanceOf(type, superclass);
- if (upcastType != null) {
- return Substitution.fromInterfaceType(upcastType);
+ List<DartType> upcastTypeArguments =
+ hierarchy.getTypeArgumentsAsInstanceOf(type, superclass);
+ if (upcastTypeArguments != null) {
+ return Substitution.fromPairs(
+ superclass.typeParameters, upcastTypeArguments);
}
}
if (type is FunctionType && superclass == coreTypes.functionClass) {
@@ -909,17 +911,23 @@
var iteratorGetter =
hierarchy.getInterfaceMember(iterable.classNode, iteratorName);
if (iteratorGetter == null) return const DynamicType();
- var castedIterable = hierarchy.getTypeAsInstanceOf(
- iterable, iteratorGetter.enclosingClass);
- var iteratorType = Substitution.fromInterfaceType(castedIterable)
+ List<DartType> castedIterableArguments =
+ hierarchy.getTypeArgumentsAsInstanceOf(
+ iterable, iteratorGetter.enclosingClass);
+ DartType iteratorType = Substitution.fromPairs(
+ iteratorGetter.enclosingClass.typeParameters,
+ castedIterableArguments)
.substituteType(iteratorGetter.getterType);
if (iteratorType is InterfaceType) {
var currentGetter =
hierarchy.getInterfaceMember(iteratorType.classNode, currentName);
if (currentGetter == null) return const DynamicType();
- var castedIteratorType = hierarchy.getTypeAsInstanceOf(
- iteratorType, currentGetter.enclosingClass);
- return Substitution.fromInterfaceType(castedIteratorType)
+ List<DartType> castedIteratorTypeArguments =
+ hierarchy.getTypeArgumentsAsInstanceOf(
+ iteratorType, currentGetter.enclosingClass);
+ return Substitution.fromPairs(
+ currentGetter.enclosingClass.typeParameters,
+ castedIteratorTypeArguments)
.substituteType(currentGetter.getterType);
}
}
@@ -928,10 +936,10 @@
DartType getStreamElementType(DartType stream) {
if (stream is InterfaceType) {
- var asStream =
- hierarchy.getTypeAsInstanceOf(stream, coreTypes.streamClass);
- if (asStream == null) return const DynamicType();
- return asStream.typeArguments.single;
+ List<DartType> asStreamArguments =
+ hierarchy.getTypeArgumentsAsInstanceOf(stream, coreTypes.streamClass);
+ if (asStreamArguments == null) return const DynamicType();
+ return asStreamArguments.single;
}
return const DynamicType();
}
@@ -1026,13 +1034,13 @@
Class container = currentAsyncMarker == AsyncMarker.AsyncStar
? coreTypes.streamClass
: coreTypes.iterableClass;
- var type = visitExpression(node.expression);
- var asContainer = type is InterfaceType
- ? hierarchy.getTypeAsInstanceOf(type, container)
+ DartType type = visitExpression(node.expression);
+ List<DartType> asContainerArguments = type is InterfaceType
+ ? hierarchy.getTypeArgumentsAsInstanceOf(type, container)
: null;
- if (asContainer != null) {
+ if (asContainerArguments != null) {
checkAssignable(
- node.expression, asContainer.typeArguments[0], currentYieldType);
+ node.expression, asContainerArguments[0], currentYieldType);
} else {
fail(node.expression, '$type is not an instance of $container');
}
diff --git a/pkg/kernel/lib/type_environment.dart b/pkg/kernel/lib/type_environment.dart
index dabc13c..9180254 100644
--- a/pkg/kernel/lib/type_environment.dart
+++ b/pkg/kernel/lib/type_environment.dart
@@ -83,14 +83,39 @@
// we aren't concerned with it. If a class implements multiple
// instantiations of Future, getTypeAsInstanceOf is responsible for
// picking the least one in the sense required by the spec.
- InterfaceType future = getTypeAsInstanceOf(type, coreTypes.futureClass);
- if (future != null) {
- return future.typeArguments[0];
+ List<DartType> futureArguments =
+ getTypeArgumentsAsInstanceOf(type, coreTypes.futureClass);
+ if (futureArguments != null) {
+ return futureArguments[0];
}
}
return type;
}
+ /// Returns the type of the element in the for-in statement [node] with
+ /// [iterableType] as the static type of the iterable expression.
+ ///
+ /// The [iterableType] must be a subclass of `Stream` or `Iterable` depending
+ /// on whether `node.isAsync` is `true` or not.
+ DartType forInElementType(ForInStatement node, DartType iterableType) {
+ // TODO(johnniwinther): Update this to use the type of
+ // `iterable.iterator.current` if inference is updated accordingly.
+ while (iterableType is TypeParameterType) {
+ TypeParameterType typeParameterType = iterableType;
+ iterableType =
+ typeParameterType.promotedBound ?? typeParameterType.parameter.bound;
+ }
+ if (node.isAsync) {
+ List<DartType> typeArguments =
+ getTypeArgumentsAsInstanceOf(iterableType, coreTypes.streamClass);
+ return typeArguments.single;
+ } else {
+ List<DartType> typeArguments =
+ getTypeArgumentsAsInstanceOf(iterableType, coreTypes.iterableClass);
+ return typeArguments.single;
+ }
+ }
+
/// Called if the computation of a static type failed due to a type error.
///
/// This should never happen in production. The frontend should report type
@@ -351,7 +376,11 @@
static List<Object> typeChecks;
- InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass);
+ InterfaceType getTypeAsInstanceOf(InterfaceType type, Class superclass,
+ Library clientLibrary, CoreTypes coreTypes);
+
+ List<DartType> getTypeArgumentsAsInstanceOf(
+ InterfaceType type, Class superclass);
/// Determines if the given type is at the top of the type hierarchy. May be
/// overridden in subclasses.
@@ -463,13 +492,15 @@
}
if (subtype is InterfaceType && supertype is InterfaceType) {
- var upcastType = getTypeAsInstanceOf(subtype, supertype.classNode);
- if (upcastType == null) return const IsSubtypeOf.never();
+ Class supertypeClass = supertype.classNode;
+ List<DartType> upcastTypeArguments =
+ getTypeArgumentsAsInstanceOf(subtype, supertypeClass);
+ if (upcastTypeArguments == null) return const IsSubtypeOf.never();
IsSubtypeOf result = const IsSubtypeOf.always();
- for (int i = 0; i < upcastType.typeArguments.length; ++i) {
+ for (int i = 0; i < upcastTypeArguments.length; ++i) {
// Termination: the 'supertype' parameter decreases in size.
- int variance = upcastType.classNode.typeParameters[i].variance;
- DartType leftType = upcastType.typeArguments[i];
+ int variance = supertypeClass.typeParameters[i].variance;
+ DartType leftType = upcastTypeArguments[i];
DartType rightType = supertype.typeArguments[i];
if (variance == Variance.contravariant) {
result = result
diff --git a/pkg/kernel/lib/verifier.dart b/pkg/kernel/lib/verifier.dart
index c37656d..59cec06 100644
--- a/pkg/kernel/lib/verifier.dart
+++ b/pkg/kernel/lib/verifier.dart
@@ -351,6 +351,10 @@
declareTypeParameters(node.typeParameters);
for (var typeParameter in node.typeParameters) {
typeParameter.bound?.accept(this);
+ if (typeParameter.annotations.isNotEmpty) {
+ problem(
+ typeParameter, "Annotation on type parameter in function type.");
+ }
}
visitList(node.positionalParameters, this);
visitList(node.namedParameters, this);
diff --git a/pkg/kernel/test/binary/library_flags_test.dart b/pkg/kernel/test/binary/library_flags_test.dart
index bca2e52..658f532 100644
--- a/pkg/kernel/test/binary/library_flags_test.dart
+++ b/pkg/kernel/test/binary/library_flags_test.dart
@@ -4,44 +4,18 @@
import 'utils.dart';
-// ignore_for_file: DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE
-
/// Test that library flags (external, synthetic)
/// are serialized and read correctly.
main() {
Library lib = new Library(Uri.parse("foo://bar.dart"));
- lib.isExternal = false;
lib.isSynthetic = false;
Library lib2 = libRoundTrip(lib);
- if (lib2.isExternal != false)
- throw "Serialized and re-read library had change in external flag.";
if (lib2.isSynthetic != false)
throw "Serialized and re-read library had change in synthetic flag.";
lib = new Library(Uri.parse("foo://bar.dart"));
- lib.isExternal = true;
- lib.isSynthetic = false;
- lib2 = libRoundTrip(lib);
- if (lib2.isExternal != true)
- throw "Serialized and re-read library had change in external flag.";
- if (lib2.isSynthetic != false)
- throw "Serialized and re-read library had change in synthetic flag.";
-
- lib = new Library(Uri.parse("foo://bar.dart"));
- lib.isExternal = false;
lib.isSynthetic = true;
lib2 = libRoundTrip(lib);
- if (lib2.isExternal != false)
- throw "Serialized and re-read library had change in external flag.";
- if (lib2.isSynthetic != true)
- throw "Serialized and re-read library had change in synthetic flag.";
-
- lib = new Library(Uri.parse("foo://bar.dart"));
- lib.isExternal = true;
- lib.isSynthetic = true;
- lib2 = libRoundTrip(lib);
- if (lib2.isExternal != true)
- throw "Serialized and re-read library had change in external flag.";
if (lib2.isSynthetic != true)
throw "Serialized and re-read library had change in synthetic flag.";
}
diff --git a/pkg/kernel/test/class_hierarchy_test.dart b/pkg/kernel/test/class_hierarchy_test.dart
index d6be1b2..52c931c 100644
--- a/pkg/kernel/test/class_hierarchy_test.dart
+++ b/pkg/kernel/test/class_hierarchy_test.dart
@@ -1214,9 +1214,10 @@
''');
var b_int = new InterfaceType(b, Nullability.legacy, [int]);
- expect(hierarchy.getTypeAsInstanceOf(b_int, a),
+ expect(hierarchy.getTypeAsInstanceOf(b_int, a, library, coreTypes),
new InterfaceType(a, Nullability.legacy, [int, bool]));
- expect(hierarchy.getTypeAsInstanceOf(b_int, objectClass),
+ expect(
+ hierarchy.getTypeAsInstanceOf(b_int, objectClass, library, coreTypes),
new InterfaceType(objectClass, Nullability.legacy));
}
diff --git a/pkg/kernel/test/relink_test.dart b/pkg/kernel/test/relink_test.dart
new file mode 100644
index 0000000..8f448cc
--- /dev/null
+++ b/pkg/kernel/test/relink_test.dart
@@ -0,0 +1,118 @@
+// Copyright (c) 2019, 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.
+
+import 'dart:io';
+
+import 'package:kernel/ast.dart';
+import 'package:kernel/binary/ast_from_binary.dart';
+import 'package:kernel/binary/ast_to_binary.dart';
+
+main() {
+ Component component1 = createComponent(42);
+ Component component2 = createComponent(43);
+
+ ByteSink sink = new ByteSink();
+ new BinaryPrinter(sink).writeComponentFile(component1);
+ List<int> writtenBytes1 = sink.builder.takeBytes();
+ sink = new ByteSink();
+ new BinaryPrinter(sink).writeComponentFile(component2);
+ List<int> writtenBytes2 = sink.builder.takeBytes();
+
+ // Loading a single one works as one would expect: It's linked to itself.
+ Component component1Prime = new Component();
+ new BinaryBuilder(writtenBytes1).readSingleFileComponent(component1Prime);
+ Procedure target1 = getMainTarget(component1Prime);
+ Procedure procedureLib1 = getLibProcedure(component1Prime);
+ if (target1 != procedureLib1) throw "Unexpected target.";
+
+ // Loading another one saying it should overwrite works as one would expect
+ // for this component: It gives a component that is linked to itself that is
+ // different from the one loaded "on top of".
+ Component component2Prime = new Component(nameRoot: component1Prime.root);
+ new BinaryBuilder(writtenBytes2, alwaysCreateNewNamedNodes: true)
+ .readSingleFileComponent(component2Prime);
+ Procedure target2 = getMainTarget(component2Prime);
+ Procedure procedureLib2 = getLibProcedure(component2Prime);
+ if (procedureLib2 == procedureLib1) throw "Unexpected procedure.";
+ if (target2 != procedureLib2) throw "Unexpected target.";
+
+ // The old one that was loaded on top of was re-linked so it also points to
+ // procedureLib2.
+ target1 = getMainTarget(component1Prime);
+ if (target1 != procedureLib2) throw "Unexpected target.";
+
+ // Relink back and forth a number of times: It keeps working as expected.
+ for (int i = 0; i < 6; i++) {
+ // Relinking component1Prime works as one would expected: Both components
+ // main now points to procedureLib1.
+ component1Prime.relink();
+ target1 = getMainTarget(component1Prime);
+ if (target1 != procedureLib1) throw "Unexpected target.";
+ target2 = getMainTarget(component2Prime);
+ if (target2 != procedureLib1) throw "Unexpected target.";
+
+ // Relinking component2Prime works as one would expected: Both components
+ // main now points to procedureLib2.
+ component2Prime.relink();
+ target1 = getMainTarget(component1Prime);
+ if (target1 != procedureLib2) throw "Unexpected target.";
+ target2 = getMainTarget(component2Prime);
+ if (target2 != procedureLib2) throw "Unexpected target.";
+ }
+}
+
+Procedure getLibProcedure(Component component1Prime) {
+ if (component1Prime.libraries[1].importUri !=
+ Uri.parse('org-dartlang:///lib.dart')) {
+ throw "Expected lib second, got ${component1Prime.libraries[1].importUri}";
+ }
+ Procedure procedureLib = component1Prime.libraries[1].procedures[0];
+ return procedureLib;
+}
+
+Procedure getMainTarget(Component component1Prime) {
+ if (component1Prime.libraries[0].importUri !=
+ Uri.parse('org-dartlang:///main.dart')) {
+ throw "Expected main first, got ${component1Prime.libraries[0].importUri}";
+ }
+ Block block = component1Prime.libraries[0].procedures[0].function.body;
+ ReturnStatement returnStatement = block.statements[0];
+ StaticInvocation staticInvocation = returnStatement.expression;
+ Procedure target = staticInvocation.target;
+ return target;
+}
+
+Component createComponent(int literal) {
+ final Library lib = new Library(Uri.parse('org-dartlang:///lib.dart'));
+ final Block libProcedureBody =
+ new Block([new ReturnStatement(new IntLiteral(literal))]);
+ final Procedure libProcedure = new Procedure(
+ new Name("method"),
+ ProcedureKind.Method,
+ new FunctionNode(libProcedureBody, returnType: new DynamicType()));
+ lib.addMember(libProcedure);
+
+ final Library main = new Library(Uri.parse('org-dartlang:///main.dart'));
+ final Block mainProcedureBody = new Block([
+ new ReturnStatement(
+ new StaticInvocation(libProcedure, new Arguments.empty()))
+ ]);
+ final Procedure mainProcedure = new Procedure(
+ new Name("method"),
+ ProcedureKind.Method,
+ new FunctionNode(mainProcedureBody, returnType: new DynamicType()));
+ main.addMember(mainProcedure);
+ return new Component(libraries: [main, lib]);
+}
+
+/// A [Sink] that directly writes data into a byte builder.
+class ByteSink implements Sink<List<int>> {
+ final BytesBuilder builder = new BytesBuilder();
+
+ void add(List<int> data) {
+ builder.add(data);
+ }
+
+ void close() {}
+}
diff --git a/pkg/kernel/tool/smoke_test_quick.dart b/pkg/kernel/tool/smoke_test_quick.dart
index c775f36..53cfae1 100644
--- a/pkg/kernel/tool/smoke_test_quick.dart
+++ b/pkg/kernel/tool/smoke_test_quick.dart
@@ -12,6 +12,8 @@
Stopwatch stopwatch = new Stopwatch()..start();
List<Future> futures = new List<Future>();
futures.add(run("pkg/front_end/test/old_dill_suite.dart", ["--checkDill"]));
+ futures.add(run("pkg/front_end/test/spelling_test_src_suite.dart",
+ ["--", "spelling_test_src/kernel/..."]));
await Future.wait(futures);
print("\n-----------------------\n");
print("Done with exitcode $exitCode in ${stopwatch.elapsedMilliseconds} ms");
diff --git a/pkg/nnbd_migration/lib/src/edge_builder.dart b/pkg/nnbd_migration/lib/src/edge_builder.dart
index f44ba67..d26eb68 100644
--- a/pkg/nnbd_migration/lib/src/edge_builder.dart
+++ b/pkg/nnbd_migration/lib/src/edge_builder.dart
@@ -32,6 +32,12 @@
import 'decorated_type_operations.dart';
+/// A potentially reversible decision is that downcasts and sidecasts should
+/// assume non-nullability. This could be changed such that we assume the
+/// widest type, or the narrowest type. For now we assume non-nullability, but
+/// have a flag to isolate that work.
+const _assumeNonNullabilityInCasts = true;
+
/// Test class mixing in _AssignmentChecker, to allow [checkAssignment] to be
/// more easily unit tested.
@visibleForTesting
@@ -636,6 +642,7 @@
@override
DecoratedType visitFunctionDeclaration(FunctionDeclaration node) {
+ node.metadata.accept(this);
if (_flowAnalysis != null) {
// This is a local function.
node.functionExpression.accept(this);
@@ -841,14 +848,10 @@
// Making it nullable could change runtime behavior.
_graph.makeNonNullable(
decoratedType.node, IsCheckMainTypeOrigin(source, type));
- if (type.typeArguments != null) {
- // TODO(mfairhurst): connect arguments to the expression type when they
- // relate.
- type.typeArguments.arguments.forEach((argument) {
- _graph.makeNullable(
- _variables.decoratedTypeAnnotation(source, argument).node,
- IsCheckComponentTypeOrigin(source, argument));
- });
+ if (!_assumeNonNullabilityInCasts) {
+ // TODO(mfairhurst): wire this to handleDowncast if we do not assume
+ // nullability.
+ assert(false);
}
} else if (type is GenericFunctionType) {
// TODO(brianwilkerson)
@@ -1201,7 +1204,8 @@
}
return type;
} else if (staticElement is FunctionElement ||
- staticElement is MethodElement) {
+ staticElement is MethodElement ||
+ staticElement is ConstructorElement) {
return getOrComputeElementType(staticElement);
} else if (staticElement is PropertyAccessorElement) {
var elementType = getOrComputeElementType(staticElement);
@@ -1259,6 +1263,23 @@
}
@override
+ DecoratedType visitSuperConstructorInvocation(
+ SuperConstructorInvocation node) {
+ var callee = node.staticElement;
+ var nullabilityNode = NullabilityNode.forInferredType();
+ var createdType = DecoratedType(callee.returnType, nullabilityNode);
+ var calleeType = getOrComputeElementType(callee, targetType: createdType);
+ _handleInvocationArguments(
+ node,
+ node.argumentList.arguments,
+ null /* typeArguments */,
+ [] /* typeArgumentTypes */,
+ calleeType,
+ [] /* constructorTypeParameters */);
+ return null;
+ }
+
+ @override
DecoratedType visitSuperExpression(SuperExpression node) {
return _handleThisOrSuper(node);
}
@@ -1930,7 +1951,7 @@
}
}
- /// Creates the necessary constraint(s) for an [argumentList] when invoking an
+ /// Creates the necessary constraint(s) for an [ArgumentList] when invoking an
/// executable element whose type is [calleeType].
///
/// Returns the decorated return type of the invocation, after any necessary
@@ -2236,9 +2257,13 @@
source: source, destination: destination, hard: hard);
return;
}
- // Neither a proper upcast assignment nor an implicit downcast (some
- // illegal code, or we did something wrong to get here).
- assert(false, 'side cast not supported: $sourceType to $destinationType');
+ // A side cast. This may be an explicit side cast, or illegal code. There
+ // is no nullability we can infer here.
+ assert(
+ _assumeNonNullabilityInCasts,
+ 'side cast not supported without assuming non-nullability:'
+ ' $sourceType to $destinationType');
+ _connect(source.node, destination.node, origin, hard: hard);
return;
}
_connect(source.node, destination.node, origin, hard: hard);
diff --git a/pkg/nnbd_migration/lib/src/edge_origin.dart b/pkg/nnbd_migration/lib/src/edge_origin.dart
index e593c40..1df2093 100644
--- a/pkg/nnbd_migration/lib/src/edge_origin.dart
+++ b/pkg/nnbd_migration/lib/src/edge_origin.dart
@@ -216,25 +216,11 @@
EdgeOriginKind get kind => EdgeOriginKind.instantiateToBounds;
}
-/// Edge origin resulting from the use of a type as a component type in an 'is'
-/// check.
-///
-/// Somewhat opposite of the principle type, allowing improper non-null type
-/// parameters etc. in an is check (`is List<int>` instead of `is List<int?>`)
-/// could introduce a change to runtime behavior.
-class IsCheckComponentTypeOrigin extends EdgeOrigin {
- IsCheckComponentTypeOrigin(Source source, TypeAnnotation node)
- : super(source, node);
-
- @override
- EdgeOriginKind get kind => EdgeOriginKind.isCheckComponentType;
-}
-
/// Edge origin resulting from the use of a type as the main type in an 'is'
/// check.
///
/// Before the migration, there was no way to say `is int?`, and therefore,
-// `is int` should migrate to non-null int.
+/// `is int` should migrate to non-null int.
class IsCheckMainTypeOrigin extends EdgeOrigin {
IsCheckMainTypeOrigin(Source source, TypeAnnotation node)
: super(source, node);
diff --git a/pkg/nnbd_migration/pubspec.yaml b/pkg/nnbd_migration/pubspec.yaml
index d975520..c848cc7 100644
--- a/pkg/nnbd_migration/pubspec.yaml
+++ b/pkg/nnbd_migration/pubspec.yaml
@@ -5,3 +5,6 @@
dependencies:
_fe_analyzer_shared: 1.0.0
analyzer: ^0.37.0
+dev_dependencies:
+ args: ^1.5.2
+ path: ^1.6.2
diff --git a/pkg/nnbd_migration/test/api_test.dart b/pkg/nnbd_migration/test/api_test.dart
index a2efe64..463a0d5 100644
--- a/pkg/nnbd_migration/test/api_test.dart
+++ b/pkg/nnbd_migration/test/api_test.dart
@@ -1126,6 +1126,17 @@
await _checkSingleFileChanges(content, expected);
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/39609')
+ test_dynamic_toString() async {
+ var content = '''
+String f(dynamic x) => x.toString();
+''';
+ var expected = '''
+String f(dynamic x) => x.toString();
+''';
+ await _checkSingleFileChanges(content, expected);
+ }
+
test_explicit_nullable_overrides_hard_edge() async {
var content = '''
int f(int/*?*/ i) => i + 1;
@@ -1974,7 +1985,7 @@
bool f(a) => a is List<int>;
''';
var expected = '''
-bool f(a) => a is List<int?>;
+bool f(a) => a is List<int>;
''';
await _checkSingleFileChanges(content, expected);
}
diff --git a/pkg/nnbd_migration/test/edge_builder_test.dart b/pkg/nnbd_migration/test/edge_builder_test.dart
index 3ccc983..1aa5c5b 100644
--- a/pkg/nnbd_migration/test/edge_builder_test.dart
+++ b/pkg/nnbd_migration/test/edge_builder_test.dart
@@ -434,6 +434,44 @@
assertEdge(decoratedTypeAnnotation('int').node, never, hard: false);
}
+ test_as_side_cast() async {
+ await analyze('''
+class A {}
+class B {}
+class C implements A, B {}
+B f(A a) {
+ // possible via f(C());
+ return a as B;
+}
+''');
+ assertEdge(
+ decoratedTypeAnnotation('A a').node, decoratedTypeAnnotation('B;').node,
+ hard: true);
+ }
+
+ test_as_side_cast_generics() async {
+ await analyze('''
+class A<T> {}
+class B<T> {}
+class C implements A<int>, B<bool> {}
+B<bool> f(A<int> a) {
+ // possible via f(C());
+ return a as B<bool>;
+}
+''');
+ assertEdge(decoratedTypeAnnotation('A<int> a').node,
+ decoratedTypeAnnotation('B<bool>;').node,
+ hard: true);
+ assertEdge(decoratedTypeAnnotation('bool>;').node,
+ decoratedTypeAnnotation('bool> f').node,
+ hard: false);
+ assertNoEdge(anyNode, decoratedTypeAnnotation('bool>;').node);
+ assertNoEdge(anyNode, decoratedTypeAnnotation('int> a').node);
+ // int> a should be connected to the bound of T in A<T>, but nothing else.
+ expect(
+ decoratedTypeAnnotation('int> a').node.downstreamEdges, hasLength(1));
+ }
+
test_assert_demonstrates_non_null_intent() async {
await analyze('''
void f(int i) {
@@ -1627,6 +1665,66 @@
// exception to be thrown.
}
+ test_constructor_withRedirectingSuperInitializer() async {
+ await analyze('''
+class C {
+ C.named(int i);
+}
+class D extends C {
+ D(int j) : super.named(j);
+}
+''');
+
+ var namedConstructor = findElement.constructor('named', of: 'C');
+ var constructorType = variables.decoratedElementType(namedConstructor);
+ var constructorParameterType = constructorType.positionalParameters[0];
+ assertEdge(
+ decoratedTypeAnnotation('int j').node, constructorParameterType.node,
+ hard: true);
+ }
+
+ @FailingTest(
+ reason: 'Need to pass type arguments along in '
+ 'EdgeBuilder.visitSuperConstructorInvocation')
+ test_constructor_withRedirectingSuperInitializer_withTypeArgument() async {
+ await analyze('''
+class C<T> {
+ C.named(T i);
+}
+class D extends C<int> {
+ D(int j) : super.named(j);
+}
+''');
+
+ var namedConstructor = findElement.constructor('named', of: 'C');
+ var constructorType = variables.decoratedElementType(namedConstructor);
+ var constructorParameterType = constructorType.positionalParameters[0];
+ assertEdge(
+ decoratedTypeAnnotation('int j').node, constructorParameterType.node,
+ hard: true);
+ }
+
+ @FailingTest(
+ reason: 'Need to pass type arguments along in '
+ 'EdgeBuilder.visitSuperConstructorInvocation')
+ test_constructor_withRedirectingSuperInitializer_withTypeVariable() async {
+ await analyze('''
+class C<T> {
+ C.named(T i);
+}
+class D<T> extends C<T> {
+ D(T j) : super.named(j);
+}
+''');
+
+ var namedConstructor = findElement.constructor('named', of: 'C');
+ var constructorType = variables.decoratedElementType(namedConstructor);
+ var constructorParameterType = constructorType.positionalParameters[0];
+ assertEdge(
+ decoratedTypeAnnotation('int j').node, constructorParameterType.node,
+ hard: true);
+ }
+
test_constructorDeclaration_returnType_generic() async {
await analyze('''
class C<T, U> {
@@ -2039,6 +2137,15 @@
expect(type.returnType, isNotNull);
}
+ test_function_metadata() async {
+ await analyze('''
+@deprecated
+void f() {}
+''');
+ // No assertions needed; the AnnotationTracker mixin verifies that the
+ // metadata was visited.
+ }
+
test_functionDeclaration_expression_body() async {
await analyze('''
int/*1*/ f(int/*2*/ i) => i/*3*/;
@@ -2903,7 +3010,7 @@
''');
assertNoUpstreamNullability(decoratedTypeAnnotation('bool').node);
assertEdge(decoratedTypeAnnotation('List').node, never, hard: true);
- assertEdge(always, decoratedTypeAnnotation('int').node, hard: false);
+ assertNoEdge(always, decoratedTypeAnnotation('int').node);
}
test_library_metadata() async {
diff --git a/pkg/nnbd_migration/tool/trial_migration.dart b/pkg/nnbd_migration/tool/trial_migration.dart
index b26acb9..83b3fe7 100644
--- a/pkg/nnbd_migration/tool/trial_migration.dart
+++ b/pkg/nnbd_migration/tool/trial_migration.dart
@@ -8,21 +8,51 @@
// result of migration, as well as categories (and counts) of exceptions that
// occurred.
+import 'dart:convert';
import 'dart:io';
-import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
+import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
+import 'package:args/args.dart';
import 'package:nnbd_migration/nnbd_migration.dart';
+import 'package:path/path.dart' as path;
main(List<String> args) async {
- if (args.length > 1) {
+ ArgParser argParser = ArgParser();
+ ArgResults parsedArgs;
+
+ argParser.addFlag('help', abbr: 'h', help: 'Display options');
+
+ argParser.addOption('sdk',
+ abbr: 's',
+ defaultsTo: path.dirname(path.dirname(Platform.resolvedExecutable)),
+ help: 'Select the root of the SDK to analyze against for this run '
+ '(compiled with --nnbd). For example: ../../xcodebuild/DebugX64NNBD/dart-sdk');
+
+ try {
+ parsedArgs = argParser.parse(args);
+ } on ArgParserException {
+ stderr.writeln(argParser.usage);
+ exit(1);
+ }
+ if (parsedArgs['help'] as bool) {
+ print(argParser.usage);
+ exit(0);
+ }
+
+ if (parsedArgs.rest.length > 1) {
throw 'invalid args. Specify *one* argument to get exceptions of interest.';
}
+ String sdkPath = path.canonicalize(parsedArgs['sdk'] as String);
+
warnOnNoAssertions();
- String categoryOfInterest = args.isEmpty ? null : args.single;
+ warnOnNoSdkNnbd(sdkPath);
+
+ String categoryOfInterest =
+ parsedArgs.rest.isEmpty ? null : parsedArgs.rest.single;
var rootUri = Platform.script.resolve('../../..');
var listener = _Listener(categoryOfInterest);
for (var testPath in [
@@ -32,7 +62,7 @@
'pkg/meta',
'third_party/pkg/path',
'third_party/pkg/term_glyph',
-// 'third_party/pkg/typed_data', - TODO(paulberry): fatal exception
+ 'third_party/pkg/typed_data',
'third_party/pkg/async',
'third_party/pkg/source_span',
'third_party/pkg/stack_trace',
@@ -43,8 +73,8 @@
]) {
print('Migrating $testPath');
var testUri = rootUri.resolve(testPath);
- var contextCollection =
- AnalysisContextCollection(includedPaths: [testUri.toFilePath()]);
+ var contextCollection = AnalysisContextCollectionImpl(
+ includedPaths: [testUri.toFilePath()], sdkPath: sdkPath);
var context = contextCollection.contexts.single;
var files = context.contextRoot
.analyzedFiles()
@@ -85,6 +115,14 @@
}
}
+void printWarning(String warn) {
+ stderr.writeln('''
+!!!
+!!! Warning! $warn
+!!!
+''');
+}
+
void warnOnNoAssertions() {
try {
assert(false);
@@ -92,11 +130,20 @@
return;
}
- print('''
-!!!
-!!! Warning! You didn't --enable-asserts!
-!!!
-''');
+ printWarning("You didn't --enable-asserts!");
+}
+
+void warnOnNoSdkNnbd(String sdkPath) {
+ // TODO(jcollins-g): contact eng-prod for a more foolproof detection method
+ String libraries = path.join(sdkPath, 'lib', 'libraries.json');
+ try {
+ var decodedJson = JsonDecoder().convert(File(libraries).readAsStringSync());
+ if ((decodedJson['comment:1'] as String).contains('sdk_nnbd')) return;
+ } on Exception {
+ printWarning('Unable to determine whether this SDK supports NNBD');
+ return;
+ }
+ printWarning('SDK at $sdkPath not compiled with --nnbd, use --sdk option');
}
class _Listener implements NullabilityMigrationListener {
diff --git a/pkg/telemetry/lib/crash_reporting.dart b/pkg/telemetry/lib/crash_reporting.dart
index 285e5ac..6e44d8e 100644
--- a/pkg/telemetry/lib/crash_reporting.dart
+++ b/pkg/telemetry/lib/crash_reporting.dart
@@ -4,8 +4,10 @@
import 'dart:async';
import 'dart:io';
+import 'dart:math' as math;
import 'package:http/http.dart' as http;
+import 'package:meta/meta.dart';
import 'package:stack_trace/stack_trace.dart';
import 'src/utils.dart';
@@ -42,9 +44,11 @@
final String crashProductId;
final EnablementCallback shouldSend;
final http.Client _httpClient;
+ final Stopwatch _processStopwatch = new Stopwatch()..start();
final ThrottlingBucket _throttle = ThrottlingBucket(10, Duration(minutes: 1));
- int _reportsSend = 0;
+ int _reportsSent = 0;
+ int _skippedReports = 0;
/// Create a new [CrashReportSender].
CrashReportSender(
@@ -56,21 +60,36 @@
/// Sends one crash report.
///
/// The report is populated from data in [error] and [stackTrace].
- Future sendReport(dynamic error, {StackTrace stackTrace}) async {
+ ///
+ /// Additional context about the crash can optionally be passed in via
+ /// [comment]. Note that this field should not include PII.
+ Future sendReport(
+ dynamic error,
+ StackTrace stackTrace, {
+ String comment,
+ }) async {
if (!shouldSend()) {
return;
}
// Check if we've sent too many reports recently.
if (!_throttle.removeDrop()) {
+ _skippedReports++;
return;
}
// Don't send too many total reports to crash reporting.
- if (_reportsSend >= _maxReportsToSend) {
+ if (_reportsSent >= _maxReportsToSend) {
return;
}
+ _reportsSent++;
+
+ // Calculate the 'weight' of the this report; we increase the weight of a
+ // report if we had throttled previous reports.
+ int weight = math.min(_skippedReports + 1, 10000);
+ _skippedReports = 0;
+
try {
final String dartVersion = Platform.version.split(' ').first;
@@ -82,13 +101,28 @@
);
final http.MultipartRequest req = new http.MultipartRequest('POST', uri);
- req.fields['product'] = crashProductId;
- req.fields['version'] = dartVersion;
- req.fields['osName'] = Platform.operatingSystem;
- req.fields['osVersion'] = Platform.operatingSystemVersion;
- req.fields['type'] = _dartTypeId;
- req.fields['error_runtime_type'] = '${error.runtimeType}';
- req.fields['error_message'] = '$error';
+
+ Map<String, String> fields = req.fields;
+ fields['product'] = crashProductId;
+ fields['version'] = dartVersion;
+ fields['osName'] = Platform.operatingSystem;
+ fields['osVersion'] = Platform.operatingSystemVersion;
+ fields['type'] = _dartTypeId;
+ fields['error_runtime_type'] = '${error.runtimeType}';
+ fields['error_message'] = '$error';
+
+ // Optional comments.
+ if (comment != null) {
+ fields['comments'] = comment;
+ }
+
+ // The uptime of the process before it crashed (in milliseconds).
+ fields['ptime'] = _processStopwatch.elapsedMilliseconds.toString();
+
+ // Send the amount to weight this report.
+ if (weight > 1) {
+ fields['weight'] = weight.toString();
+ }
final Chain chain = new Chain.forTrace(stackTrace);
req.files.add(new http.MultipartFile.fromString(
@@ -108,6 +142,9 @@
}
}
+ @visibleForTesting
+ int get reportsSent => _reportsSent;
+
/// Closes the client and cleans up any resources associated with it. This
/// will close the associated [http.Client].
void dispose() {
diff --git a/pkg/telemetry/test/crash_reporting_test.dart b/pkg/telemetry/test/crash_reporting_test.dart
index f4867e4..9d48324 100644
--- a/pkg/telemetry/test/crash_reporting_test.dart
+++ b/pkg/telemetry/test/crash_reporting_test.dart
@@ -11,8 +11,9 @@
import 'package:usage/usage.dart';
void main() {
- group('crash_reporting', () {
+ group('CrashReportSender', () {
MockClient mockClient;
+ AnalyticsMock analytics;
Request request;
@@ -21,23 +22,65 @@
request = r;
return new Response('crash-report-001', 200);
});
+
+ analytics = new AnalyticsMock()..enabled = true;
});
- test('CrashReportSender', () async {
- EnablementCallback shouldSend = () {
- return true;
- };
+ EnablementCallback shouldSend = () {
+ return true;
+ };
- AnalyticsMock analytics = new AnalyticsMock()..enabled = true;
+ test('general', () async {
CrashReportSender sender = new CrashReportSender(
analytics.trackingId, shouldSend,
httpClient: mockClient);
- await sender.sendReport('test-error', stackTrace: StackTrace.current);
+ await sender.sendReport('test-error', StackTrace.current);
String body = utf8.decode(request.bodyBytes);
expect(body, contains('String')); // error.runtimeType
expect(body, contains('test-error'));
});
+
+ test('reportsSent', () async {
+ CrashReportSender sender = new CrashReportSender(
+ analytics.trackingId, shouldSend,
+ httpClient: mockClient);
+
+ expect(sender.reportsSent, 0);
+
+ await sender.sendReport('test-error', StackTrace.current);
+
+ expect(sender.reportsSent, 1);
+
+ String body = utf8.decode(request.bodyBytes);
+ expect(body, contains('String'));
+ expect(body, contains('test-error'));
+ });
+
+ test('contains message', () async {
+ CrashReportSender sender = new CrashReportSender(
+ analytics.trackingId, shouldSend,
+ httpClient: mockClient);
+
+ await sender.sendReport('test-error', StackTrace.current,
+ comment: 'additional message');
+
+ String body = utf8.decode(request.bodyBytes);
+ expect(body, contains('String'));
+ expect(body, contains('test-error'));
+ expect(body, contains('additional message'));
+ });
+
+ test('has ptime', () async {
+ CrashReportSender sender = new CrashReportSender(
+ analytics.trackingId, shouldSend,
+ httpClient: mockClient);
+
+ await sender.sendReport('test-error', StackTrace.current);
+
+ String body = utf8.decode(request.bodyBytes);
+ expect(body, contains('name="ptime"'));
+ });
});
}
diff --git a/pkg/test_runner/lib/src/multitest.dart b/pkg/test_runner/lib/src/multitest.dart
index 0031d5e..7cd62eb 100644
--- a/pkg/test_runner/lib/src/multitest.dart
+++ b/pkg/test_runner/lib/src/multitest.dart
@@ -76,7 +76,7 @@
import "utils.dart";
/// Until legacy multitests are ported we need to support both /// and //#
-final _multitestMarker = RegExp(r"//[/#]");
+final multitestMarker = RegExp(r"//[/#]");
final _multitestOutcomes = {
'ok',
@@ -110,7 +110,7 @@
var lineCount = 0;
for (var line in lines) {
lineCount++;
- var annotation = _Annotation.tryParse(line);
+ var annotation = Annotation.tryParse(line);
if (annotation != null) {
testsAsLines.putIfAbsent(
annotation.key, () => List<String>.from(testsAsLines["none"]));
@@ -172,7 +172,7 @@
/// for each of those generated tests.
List<TestFile> splitMultitest(
TestFile multitest, String outputDir, Path suiteDir,
- {bool hotReload}) {
+ {bool hotReload = false}) {
// Each key in the map tests is a multitest tag or "none", and the texts of
// the generated test is its value.
var tests = <String, String>{};
@@ -247,16 +247,16 @@
}
/// A multitest annotation in the special `//#` comment.
-class _Annotation {
+class Annotation {
/// Parses the annotation in [line] or returns `null` if the line isn't a
/// multitest annotation.
- static _Annotation tryParse(String line) {
+ static Annotation tryParse(String line) {
// Do an early return with "null" if this is not a valid multitest
// annotation.
- if (!line.contains(_multitestMarker)) return null;
+ if (!line.contains(multitestMarker)) return null;
var parts = line
- .split(_multitestMarker)[1]
+ .split(multitestMarker)[1]
.split(':')
.map((s) => s.trim())
.where((s) => s.isNotEmpty)
@@ -264,7 +264,7 @@
if (parts.length <= 1) return null;
- return _Annotation._(parts[0], parts[1]);
+ return Annotation._(parts[0], parts[1]);
}
final String key;
@@ -274,7 +274,7 @@
// need to support more than a single outcome for each test.
final List<String> outcomes = [];
- _Annotation._(this.key, this.rest) {
+ Annotation._(this.key, this.rest) {
outcomes.addAll(rest.split(',').map((s) => s.trim()));
}
}
diff --git a/pkg/test_runner/lib/src/static_error.dart b/pkg/test_runner/lib/src/static_error.dart
index 8d06966..6deb30f 100644
--- a/pkg/test_runner/lib/src/static_error.dart
+++ b/pkg/test_runner/lib/src/static_error.dart
@@ -270,6 +270,18 @@
return thisMessage.compareTo(otherMessage);
}
+ @override
+ bool operator ==(other) => other is StaticError && compareTo(other) == 0;
+
+ @override
+ int get hashCode {
+ return 3 * line.hashCode +
+ 5 * column.hashCode +
+ 7 * (length ?? 0).hashCode +
+ 11 * (code ?? "").hashCode +
+ 13 * (message ?? "").hashCode;
+ }
+
/// Whether this error expectation is a specified error for the front end
/// reported by [actual].
bool isSpecifiedFor(StaticError actual) {
diff --git a/pkg/test_runner/tool/convert_multitest.dart b/pkg/test_runner/tool/convert_multitest.dart
new file mode 100644
index 0000000..11a427f
--- /dev/null
+++ b/pkg/test_runner/tool/convert_multitest.dart
@@ -0,0 +1,248 @@
+// Copyright (c) 2019, 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.
+
+/// Converts a multi-test to a test using the new static error test framework
+/// (see https://github.com/dart-lang/sdk/wiki/Testing#static-error-tests)
+/// and a copy of the '/none' test.
+
+import 'dart:collection';
+import 'dart:convert';
+import 'dart:io';
+
+import 'package:path/path.dart';
+import 'package:test_runner/src/multitest.dart';
+import 'package:test_runner/src/path.dart';
+import 'package:test_runner/src/static_error.dart';
+import 'package:test_runner/src/test_file.dart';
+import 'package:test_runner/src/update_errors.dart';
+import 'package:test_runner/src/vendored_pkg/args/args.dart';
+
+import 'update_static_error_tests.dart' show runAnalyzer, runCfe;
+
+Future<List<StaticError>> getErrors(
+ List<String> options, String filePath) async {
+ return [
+ ...await runAnalyzer(filePath, options),
+ ...await runCfe(filePath, options)
+ ];
+}
+
+bool areSameErrors(List<StaticError> first, List<StaticError> second) {
+ if (first.length != second.length) return false;
+ for (int i = 0; i < first.length; ++i) {
+ if (first[i].compareTo(second[i]) != 0) return false;
+ }
+ return true;
+}
+
+/// Merges a list of error lists into a single list. The result is sorted with
+/// respect to [StaticError.compareTo].
+List<StaticError> mergeErrors(Iterable<List<StaticError>> errors) {
+ // Using a [SplayTreeSet] here results in a sorted list.
+ var result = SplayTreeSet<StaticError>();
+ for (var list in errors) {
+ result.addAll(list);
+ }
+ return result.toList();
+}
+
+const staticOutcomes = [
+ "syntax error",
+ "compile-time error",
+ "static type warning",
+];
+
+class UnableToConvertException {
+ final String message;
+ UnableToConvertException(this.message);
+ String toString() => "unable to convert: $message";
+}
+
+class CleanedMultiTest {
+ final String text;
+ final Map<String, String> subTests;
+ CleanedMultiTest(this.text, this.subTests);
+}
+
+CleanedMultiTest removeMultiTestMarker(String test) {
+ StringBuffer sb = StringBuffer();
+ var subTests = <String, String>{};
+ List<String> lines = LineSplitter.split(test)
+ .where((line) => !line.startsWith("// Test created from multitest named"))
+ .toList();
+ if (lines.length > 1 && lines.last.isEmpty) {
+ // If the file ends with a newline, remove the empty line - the loop below
+ // will add a newline to the end.
+ lines.length--;
+ }
+ for (String line in lines) {
+ var matches = multitestMarker.allMatches(line);
+ if (matches.length > 1) {
+ throw "internal error: cannot process line '$line'";
+ } else if (matches.length == 1) {
+ var match = matches.single;
+ var annotation = Annotation.tryParse(line);
+ if (annotation.outcomes.length != 1) {
+ throw UnableToConvertException("annotation has multiple outcomes");
+ }
+ var outcome = annotation.outcomes.single;
+ if (outcome == "continued" ||
+ outcome == "ok" ||
+ staticOutcomes.contains(outcome)) {
+ line = line.substring(0, match.start).trimRight();
+ if (line.endsWith("//")) {
+ line = line.substring(0, line.length - 2).trimRight();
+ }
+ if (outcome != "continued") {
+ subTests[annotation.key] = outcome;
+ }
+ } else {
+ throw UnableToConvertException("test contains dynamic outcome");
+ }
+ }
+ sb.writeln(line);
+ }
+ return CleanedMultiTest(sb.toString(), subTests);
+}
+
+Future createRuntimeTest(
+ String testFilePath, String multiTestPath, bool writeToFile) async {
+ var testName = basename(testFilePath);
+ String runtimeTestBase;
+ if (testName.endsWith("_test.dart")) {
+ runtimeTestBase =
+ testName.substring(0, testName.length - "_test.dart".length);
+ } else if (testName.endsWith(".dart")) {
+ runtimeTestBase = testName.substring(0, testName.length - ".dart".length);
+ } else {
+ runtimeTestBase = testName;
+ }
+ var runtimeTestPath = "${dirname(testFilePath)}/$runtimeTestBase"
+ "_runtime_test.dart";
+ int n = 1;
+ while (await File(runtimeTestPath).exists()) {
+ runtimeTestPath = "${dirname(testFilePath)}/$runtimeTestBase"
+ "_runtime_${n++}_test.dart";
+ }
+ var testContent = await File(multiTestPath).readAsString();
+ var cleanedMultiTest = removeMultiTestMarker(testContent);
+ var runtimeTestContent = """
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+${cleanedMultiTest.text}""";
+ if (writeToFile) {
+ File outputFile = File(runtimeTestPath);
+ await outputFile.writeAsString(runtimeTestContent, mode: FileMode.append);
+ print("Runtime part of the test written to '$runtimeTestPath'.");
+ } else {
+ print("-- $runtimeTestPath:");
+ print(runtimeTestContent);
+ }
+}
+
+Future<void> main(List<String> arguments) async {
+ var parser = ArgParser();
+ parser.addFlag("verbose", abbr: "v", help: "print additional information");
+ parser.addFlag("write", abbr: "w", help: "write output to input file");
+ var results = parser.parse(arguments);
+ if (results.rest.length != 1) {
+ print("Usage: convert_multi_test.dart [-v] [-w] <input file>");
+ exitCode = 1;
+ return;
+ }
+ var verbose = results["verbose"] as bool;
+ var testFilePath = Uri.base.resolve(results.rest.single).toFilePath();
+ var testFile = File(testFilePath);
+ if (!await testFile.exists()) {
+ print("File '${testFile.uri.toFilePath()}' not found");
+ exitCode = 1;
+ return;
+ }
+ // Read test file and setup output directory.
+ var suiteDirectory = Path.raw(Uri.base.path);
+ var content = await testFile.readAsString();
+ var test = TestFile.parse(suiteDirectory, testFilePath, content);
+ if (!multitestMarker.hasMatch(content)) {
+ print("Test ${test.path.toNativePath()} is not a multi-test.");
+ exitCode = 1;
+ return;
+ }
+ Directory outputDirectory =
+ await Directory(dirname(testFilePath)).createTemp();
+ if (verbose) {
+ print("Output directory for generated files: ${outputDirectory.uri.path}");
+ }
+ try {
+ // Generate the sub-tests of the multi-test in [outputDirectory].
+ var tests = [
+ test,
+ ...splitMultitest(test, outputDirectory.uri.toFilePath(), suiteDirectory)
+ ];
+ if (!tests[1].name.endsWith("/none")) {
+ throw "internal error: expected second test to be the '/none' test";
+ }
+ // Remove the multi-test marker from the test. We do this here to fail fast
+ // for cases we do not support, because generating the front-end errors is
+ // quite slow.
+ var cleanedTest = removeMultiTestMarker(content);
+ var contentWithoutMarkers = cleanedTest.text;
+ // Get the reported errors for the multi-test and all generated sub-tests
+ // from the analyser and the common front-end.
+ var options = test.sharedOptions;
+ var errors = <List<StaticError>>[];
+ for (TestFile test in tests) {
+ if (verbose) {
+ print("Processing ${test.path}");
+ }
+ errors.add(await getErrors(options, test.path.toNativePath()));
+ }
+ if (errors[1].isNotEmpty) {
+ throw "internal error: errors in '/none' test";
+ }
+ // Check that the multi-test generates the same errors as all sub-tests
+ // together - otherwise converting the test would be unsound.
+ var sortedOriginalErrors = errors[0].toList()..sort();
+ var mergedErrors = mergeErrors(errors.skip(2));
+ if (!areSameErrors(sortedOriginalErrors, mergedErrors)) {
+ if (verbose) {
+ print("Sub-tests have different errors!\n\n"
+ "Errors in sub-tests:\n$mergedErrors\n\n"
+ "Errors in original test:\n$sortedOriginalErrors\n");
+ }
+ throw UnableToConvertException(
+ "Test produces different errors than its sub-tests.");
+ }
+ // Insert the error message annotations for the static testing framework
+ // and output the result.
+ var annotatedContent =
+ updateErrorExpectations(contentWithoutMarkers, errors[0]);
+ bool writeToFile = results["write"] as bool;
+ if (writeToFile) {
+ await testFile.writeAsString(annotatedContent);
+ print("Converted test '${test.path.toNativePath()}'.");
+ } else {
+ print("-- ${test.path.toNativePath()}:");
+ print(annotatedContent);
+ }
+ // Generate runtime tests for all sub-tests that are generated from the
+ // 'none' case and those with 'ok' annotations.
+ for (int i = 1; i < tests.length; ++i) {
+ String test = tests[i].path.toNativePath();
+ String base = basenameWithoutExtension(test);
+ String key = base.split("_").last;
+ if (key == "none" || cleanedTest.subTests[key] == "ok") {
+ await createRuntimeTest(
+ testFilePath, tests[i].path.toNativePath(), writeToFile);
+ }
+ }
+ } on UnableToConvertException catch (exception) {
+ print(
+ "Could not convert ${test.path.toNativePath()}: ${exception.message}");
+ exitCode = 1;
+ return;
+ } finally {
+ outputDirectory.delete(recursive: true);
+ }
+}
diff --git a/pkg/test_runner/tool/update_static_error_tests.dart b/pkg/test_runner/tool/update_static_error_tests.dart
index 4547df3..e4b798e 100644
--- a/pkg/test_runner/tool/update_static_error_tests.dart
+++ b/pkg/test_runner/tool/update_static_error_tests.dart
@@ -152,14 +152,14 @@
var errors = <StaticError>[];
if (insertAnalyzer) {
stdout.write("\r${file.path} (Running analyzer...)");
- errors.addAll(await _runAnalyzer(file.absolute.path, options));
+ errors.addAll(await runAnalyzer(file.absolute.path, options));
}
if (insertCfe) {
// Clear the previous line.
stdout.write("\r${file.path} ");
stdout.write("\r${file.path} (Running CFE...)");
- errors.addAll(await _runCfe(file.absolute.path, options));
+ errors.addAll(await runCfe(file.absolute.path, options));
}
errors = StaticError.simplify(errors);
@@ -177,8 +177,7 @@
}
/// Invoke analyzer on [path] and gather all static errors it reports.
-Future<List<StaticError>> _runAnalyzer(
- String path, List<String> options) async {
+Future<List<StaticError>> runAnalyzer(String path, List<String> options) async {
// TODO(rnystrom): Running the analyzer command line each time is very slow.
// Either import the analyzer as a library, or at least invoke it in a batch
// mode.
@@ -197,7 +196,7 @@
}
/// Invoke CFE on [path] and gather all static errors it reports.
-Future<List<StaticError>> _runCfe(String path, List<String> options) async {
+Future<List<StaticError>> runCfe(String path, List<String> options) async {
// TODO(rnystrom): Running the CFE command line each time is slow and wastes
// time generating code, which we don't care about. Import it as a library or
// at least run it in batch mode.
@@ -211,6 +210,9 @@
path,
]);
+ // TODO(karlklose): handle exit codes != 0. This can happen if the dart
+ // executable is not compatible with the kernel package version.
+
var errors = <StaticError>[];
FastaCommandOutput.parseErrors(result.stdout as String, errors);
return errors;
diff --git a/pkg/testing/lib/src/chain.dart b/pkg/testing/lib/src/chain.dart
index 56d0b23..289135b 100644
--- a/pkg/testing/lib/src/chain.dart
+++ b/pkg/testing/lib/src/chain.dart
@@ -248,6 +248,7 @@
print("${suite.name}/${description.shortName}: ${result.outcome}");
});
}
+ postRun();
}
Stream<TestDescription> list(Chain suite) async* {
@@ -311,6 +312,8 @@
}
Future<void> cleanUp(TestDescription description, Result result) => null;
+
+ Future<void> postRun() => null;
}
abstract class Step<I, O, C extends ChainContext> {
diff --git a/pkg/vm/bin/convert_stack_traces.dart b/pkg/vm/bin/convert_stack_traces.dart
new file mode 100644
index 0000000..1ca4db4
--- /dev/null
+++ b/pkg/vm/bin/convert_stack_traces.dart
@@ -0,0 +1,123 @@
+// Copyright (c) 2019, 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.
+
+import "dart:async";
+import "dart:convert";
+import "dart:io" as io;
+
+import 'package:args/args.dart' show ArgParser, ArgResults;
+import 'package:vm/elf/convert.dart';
+import 'package:vm/elf/dwarf.dart';
+
+final ArgParser _argParser = new ArgParser(allowTrailingOptions: true)
+ ..addOption('elf',
+ abbr: 'e',
+ help: 'Path to ELF file with debugging information',
+ defaultsTo: null,
+ valueHelp: 'FILE')
+ ..addOption('input',
+ abbr: 'i',
+ help: 'Path to input file',
+ defaultsTo: null,
+ valueHelp: 'FILE')
+ ..addOption('location',
+ abbr: 'l',
+ help: 'PC address to convert to a file name and line number',
+ defaultsTo: null,
+ valueHelp: 'INT')
+ ..addOption('output',
+ abbr: 'o',
+ help: 'Path to output file',
+ defaultsTo: null,
+ valueHelp: 'FILE')
+ ..addFlag('verbose',
+ abbr: 'v',
+ help: 'Translate all frames, not just frames for user or library code',
+ defaultsTo: false);
+
+final String _usage = '''
+Usage: convert_stack_traces [options]
+
+Takes text that includes DWARF-based stack traces with PC addresses and
+outputs the same text, but with the DWARF stack traces converted to stack traces
+that contain function names, file names, and line numbers.
+
+Reads from the file named by the argument to -i/--input as input, or stdin if
+no input flag is given.
+
+Outputs the converted contents to the file named by the argument to
+-o/--output, or stdout if no output flag is given.
+
+The -e/-elf option must be provided, and DWARF debugging information is
+read from the file named by its argument.
+
+When the -v/--verbose option is given, the converter translates all frames, not
+just those corresponding to user or library code.
+
+If an -l/--location option is provided, then the file and line number
+information for the given location is looked up and output instead.
+
+Options:
+${_argParser.usage}
+''';
+
+const int _badUsageExitCode = 1;
+
+Future<void> main(List<String> arguments) async {
+ final ArgResults options = _argParser.parse(arguments);
+
+ if ((options.rest.length > 0) || (options['elf'] == null)) {
+ print(_usage);
+ io.exitCode = _badUsageExitCode;
+ return;
+ }
+
+ int location = null;
+ if (options['location'] != null) {
+ location = int.tryParse(options['location']);
+ if (location == null) {
+ // Try adding an initial "0x", as DWARF stack traces don't normally
+ // include the hex marker on the PC addresses.
+ location = int.tryParse("0x" + options['location']);
+ }
+ if (location == null) {
+ print("Location could not be parsed as an int: ${options['location']}\n");
+ print(_usage);
+ io.exitCode = _badUsageExitCode;
+ return;
+ }
+ }
+
+ final dwarf = Dwarf.fromFile(options['elf']);
+
+ final output = options['output'] != null
+ ? io.File(options['output']).openWrite()
+ : io.stdout;
+ final verbose = options['verbose'];
+
+ var convertedStream;
+ if (location != null) {
+ final frames = dwarf
+ .callInfo(location, includeInternalFrames: verbose)
+ ?.map((CallInfo c) => c.toString());
+ if (frames == null) {
+ throw "No call information found for PC 0x${location.toRadixString(16)}";
+ }
+ convertedStream = Stream.fromIterable(frames);
+ } else {
+ final input = options['input'] != null
+ ? io.File(options['input']).openRead()
+ : io.stdin;
+
+ convertedStream = input
+ .transform(utf8.decoder)
+ .transform(const LineSplitter())
+ .transform(
+ DwarfStackTraceDecoder(dwarf, includeInternalFrames: verbose));
+ }
+
+ await convertedStream.forEach(output.writeln);
+ await output.flush();
+ await output.close();
+}
diff --git a/pkg/vm/bin/dump_kernel.dart b/pkg/vm/bin/dump_kernel.dart
index 6a6b448..f6efcfa 100644
--- a/pkg/vm/bin/dump_kernel.dart
+++ b/pkg/vm/bin/dump_kernel.dart
@@ -46,6 +46,5 @@
final List<int> bytes = new File(input).readAsBytesSync();
new BinaryBuilderWithMetadata(bytes).readComponent(component);
- writeComponentToText(component,
- path: output, showExternal: true, showMetadata: true);
+ writeComponentToText(component, path: output, showMetadata: true);
}
diff --git a/pkg/vm/lib/bytecode/gen_bytecode.dart b/pkg/vm/lib/bytecode/gen_bytecode.dart
index dce21ec..a8aa797 100644
--- a/pkg/vm/lib/bytecode/gen_bytecode.dart
+++ b/pkg/vm/lib/bytecode/gen_bytecode.dart
@@ -99,15 +99,18 @@
final savedGlobalDebuggingNames = globalDebuggingNames;
globalDebuggingNames = new NameSystem();
+ Library library;
try {
final bytecodeGenerator = new BytecodeGenerator(
component, coreTypes, hierarchy, typeEnvironment, options);
- for (var library in libraries) {
+ for (library in libraries) {
bytecodeGenerator.visitLibrary(library);
}
} on IllegalRecursiveTypeException catch (e) {
CompilerContext.current.options.report(
- templateIllegalRecursiveType.withArguments(e.type).withoutLocation(),
+ templateIllegalRecursiveType
+ .withArguments(e.type, library.isNonNullableByDefault)
+ .withoutLocation(),
Severity.error);
} finally {
globalDebuggingNames = savedGlobalDebuggingNames;
@@ -1282,8 +1285,7 @@
throw 'Expected constant, got ${expr.runtimeType}';
}
- void _genPushConstExpr(Expression expr) {
- final constant = _getConstant(expr);
+ void _genPushConstant(Constant constant) {
if (constant is NullConstant) {
asm.emitPushNull();
} else if (constant is BoolConstant) {
@@ -1295,6 +1297,20 @@
}
}
+ void _genPushConstExpr(Expression expr) {
+ if (expr is ConstantExpression) {
+ _genPushConstant(expr.constant);
+ } else if (expr is NullLiteral) {
+ asm.emitPushNull();
+ } else if (expr is BoolLiteral) {
+ _genPushBool(expr.value);
+ } else if (expr is IntLiteral) {
+ _genPushInt(expr.value);
+ } else {
+ _genPushConstant(_getConstant(expr));
+ }
+ }
+
void _genReturnTOS([int yieldSourcePosition = null]) {
if (options.causalAsyncStacks &&
parentFunction != null &&
@@ -1337,6 +1353,9 @@
} else {
asm.emitDirectCall(cpIndex, totalArgCount);
}
+ if (inferredTypeMetadata != null && node != null) {
+ _replaceWithConstantValue(node);
+ }
}
void _genDirectCallWithArgs(Member target, Arguments args,
@@ -1791,7 +1810,20 @@
} else {
inferredTypesAttribute.add(NullConstant());
}
- inferredTypesAttribute.add(IntConstant(md.flags));
+ // Inferred constant values are handled in bytecode generator
+ // (_replaceWithConstantValue, _initConstantParameters) and
+ // not propagated to VM.
+ final flags = md.flags & ~InferredType.flagConstant;
+ inferredTypesAttribute.add(IntConstant(flags));
+ }
+
+ void _replaceWithConstantValue(TreeNode node) {
+ final InferredType md = inferredTypeMetadata[node];
+ if (md == null || md.constantValue == null || asm.isUnreachable) {
+ return;
+ }
+ asm.emitDrop1();
+ _genPushConstant(md.constantValue);
}
// Generate additional code for 'operator ==' to handle nulls.
@@ -2027,6 +2059,10 @@
asm.emitPopLocal(locals.functionTypeArgsVarIndexInFrame);
}
}
+
+ if (inferredTypeMetadata != null && function != null) {
+ _initConstantParameters(function);
+ }
}
void _handleDelayedTypeArguments(Label doneCheckingTypeArguments) {
@@ -2070,6 +2106,21 @@
asm.emitPopLocal(locals.functionTypeArgsVarIndexInFrame);
}
+ void _initConstantParameters(FunctionNode function) {
+ function.positionalParameters.forEach(_initParameterIfConstant);
+ locals.sortedNamedParameters.forEach(_initParameterIfConstant);
+ }
+
+ void _initParameterIfConstant(VariableDeclaration variable) {
+ final md = inferredTypeMetadata[variable];
+ if (md != null && md.constantValue != null) {
+ _genPushConstant(md.constantValue);
+ asm.emitPopLocal(locals.isCaptured(variable)
+ ? locals.getOriginalParamSlotIndex(variable)
+ : locals.getVarIndexInFrame(variable));
+ }
+ }
+
void _setupInitialContext(FunctionNode function) {
_allocateContextIfNeeded();
@@ -3276,25 +3327,32 @@
_appendInferredType(node, asm.offset);
}
+ bool generated = false;
if (invocationKind != InvocationKind.getter && !isDynamic && !isUnchecked) {
final staticReceiverType = getStaticType(receiver, staticTypeContext);
if (isInstantiatedInterfaceCall(interfaceTarget, staticReceiverType)) {
final callCpIndex = cp.addInstantiatedInterfaceCall(
invocationKind, interfaceTarget, argDesc, staticReceiverType);
asm.emitInstantiatedInterfaceCall(callCpIndex, totalArgCount);
- return;
+ generated = true;
}
}
- final callCpIndex = cp.addInstanceCall(
- invocationKind, interfaceTarget, targetName, argDesc);
- if (isDynamic) {
- assert(!isUnchecked);
- asm.emitDynamicCall(callCpIndex, totalArgCount);
- } else if (isUnchecked) {
- asm.emitUncheckedInterfaceCall(callCpIndex, totalArgCount);
- } else {
- asm.emitInterfaceCall(callCpIndex, totalArgCount);
+ if (!generated) {
+ final callCpIndex = cp.addInstanceCall(
+ invocationKind, interfaceTarget, targetName, argDesc);
+ if (isDynamic) {
+ assert(!isUnchecked);
+ asm.emitDynamicCall(callCpIndex, totalArgCount);
+ } else if (isUnchecked) {
+ asm.emitUncheckedInterfaceCall(callCpIndex, totalArgCount);
+ } else {
+ asm.emitInterfaceCall(callCpIndex, totalArgCount);
+ }
+ }
+
+ if (inferredTypeMetadata != null && node != null) {
+ _replaceWithConstantValue(node);
}
}
@@ -3616,6 +3674,13 @@
if (target.isConst) {
_genPushConstExpr(target.initializer);
} else if (!_needsGetter(target)) {
+ if (inferredTypeMetadata != null) {
+ final InferredType md = inferredTypeMetadata[node];
+ if (md != null && md.constantValue != null) {
+ _genPushConstant(md.constantValue);
+ return;
+ }
+ }
asm.emitLoadStatic(cp.addStaticField(target));
} else {
_genDirectCall(target, objectTable.getArgDescHandle(0), 0,
@@ -4011,71 +4076,8 @@
@override
visitForInStatement(ForInStatement node) {
- _generateNode(node.iterable);
-
- // Front-end inserts implicit cast (type check) which ensures that
- // result of iterable expression is Iterable<dynamic>.
- _recordSourcePosition(node.iterable.fileOffset);
- asm.emitInterfaceCall(
- cp.addInterfaceCall(InvocationKind.getter, iterableIterator,
- objectTable.getArgDescHandle(1)),
- 1);
-
- final iteratorTemp = locals.tempIndexInFrame(node);
- asm.emitPopLocal(iteratorTemp);
-
- final capturedIteratorVar = locals.capturedIteratorVar(node);
- if (capturedIteratorVar != null) {
- _genPushContextForVariable(capturedIteratorVar);
- asm.emitPush(iteratorTemp);
- _genStoreVar(capturedIteratorVar);
- }
-
- if (asm.isUnreachable) {
- // Bail out before binding a label which allows backward jumps,
- // as it is not handled by local unreachable code elimination.
- return;
- }
-
- final Label done = new Label();
- final Label join = new Label(allowsBackwardJumps: true);
-
- asm.bind(join);
- asm.emitCheckStack(++currentLoopDepth);
-
- if (capturedIteratorVar != null) {
- _genLoadVar(capturedIteratorVar);
- asm.emitStoreLocal(iteratorTemp);
- } else {
- asm.emitPush(iteratorTemp);
- }
-
- asm.emitInterfaceCall(
- cp.addInterfaceCall(InvocationKind.method, iteratorMoveNext,
- objectTable.getArgDescHandle(1)),
- 1);
- asm.emitJumpIfFalse(done);
-
- _enterScope(node);
- _recordSourcePosition(node.bodyOffset);
-
- _genPushContextIfCaptured(node.variable);
-
- asm.emitPush(iteratorTemp);
- asm.emitInterfaceCall(
- cp.addInterfaceCall(InvocationKind.getter, iteratorCurrent,
- objectTable.getArgDescHandle(1)),
- 1);
-
- _genStoreVar(node.variable);
-
- _generateNode(node.body);
-
- _leaveScope();
- asm.emitJump(join);
-
- asm.bind(done);
- --currentLoopDepth;
+ // Should be lowered by the async transformation.
+ throw "unreachable";
}
@override
@@ -4673,7 +4675,7 @@
@override
visitConstantExpression(ConstantExpression node) {
- _genPushConstExpr(node);
+ _genPushConstant(node.constant);
}
}
diff --git a/pkg/vm/lib/bytecode/local_vars.dart b/pkg/vm/lib/bytecode/local_vars.dart
index 304fd0e..0e59577 100644
--- a/pkg/vm/lib/bytecode/local_vars.dart
+++ b/pkg/vm/lib/bytecode/local_vars.dart
@@ -16,6 +16,11 @@
import 'options.dart' show BytecodeOptions;
import '../metadata/direct_call.dart' show DirectCallMetadata;
+// Keep in sync with runtime/vm/object.h:Context::kAwaitJumpVarIndex.
+const int awaitJumpVarContextIndex = 0;
+const int asyncCompleterContextIndex = 1;
+const int controllerContextIndex = 1;
+
class LocalVariables {
final _scopes = new Map<TreeNode, Scope>();
final _vars = new Map<VariableDeclaration, VarDesc>();
@@ -220,7 +225,7 @@
class VarDesc {
final VariableDeclaration declaration;
- final Scope scope;
+ Scope scope;
bool isCaptured = false;
int index;
int originalParamSlotIndex;
@@ -238,6 +243,13 @@
isCaptured = true;
}
+ void moveToScope(Scope newScope) {
+ assert(index == null);
+ scope.vars.remove(this);
+ newScope.vars.add(this);
+ scope = newScope;
+ }
+
String toString() => 'var ${declaration.name}';
}
@@ -424,6 +436,26 @@
}
function.body?.accept(this);
+
+ if (_currentFrame.dartAsyncMarker == AsyncMarker.Async ||
+ _currentFrame.dartAsyncMarker == AsyncMarker.SyncStar ||
+ _currentFrame.dartAsyncMarker == AsyncMarker.AsyncStar) {
+ locals
+ ._getVarDesc(_currentFrame
+ .getSyntheticVar(ContinuationVariables.awaitJumpVar))
+ .moveToScope(_currentScope);
+ if (_currentFrame.dartAsyncMarker == AsyncMarker.Async) {
+ locals
+ ._getVarDesc(_currentFrame
+ .getSyntheticVar(ContinuationVariables.asyncCompleter))
+ .moveToScope(_currentScope);
+ } else if (_currentFrame.dartAsyncMarker == AsyncMarker.AsyncStar) {
+ locals
+ ._getVarDesc(_currentFrame
+ .getSyntheticVar(ContinuationVariables.controller))
+ .moveToScope(_currentScope);
+ }
+ }
}
if (node is FunctionDeclaration ||
@@ -1068,6 +1100,28 @@
final FunctionNode function = (node as dynamic).function;
assert(function != null);
+ if (_currentFrame.dartAsyncMarker == AsyncMarker.Async ||
+ _currentFrame.dartAsyncMarker == AsyncMarker.SyncStar ||
+ _currentFrame.dartAsyncMarker == AsyncMarker.AsyncStar) {
+ final awaitJumpVar =
+ _currentFrame.getSyntheticVar(ContinuationVariables.awaitJumpVar);
+ _allocateVariable(awaitJumpVar);
+ assert(
+ locals._getVarDesc(awaitJumpVar).index == awaitJumpVarContextIndex);
+ }
+ if (_currentFrame.dartAsyncMarker == AsyncMarker.Async) {
+ final asyncCompleter =
+ _currentFrame.getSyntheticVar(ContinuationVariables.asyncCompleter);
+ _allocateVariable(asyncCompleter);
+ assert(locals._getVarDesc(asyncCompleter).index ==
+ asyncCompleterContextIndex);
+ }
+ if (_currentFrame.dartAsyncMarker == AsyncMarker.AsyncStar) {
+ final controller =
+ _currentFrame.getSyntheticVar(ContinuationVariables.controller);
+ _allocateVariable(controller);
+ assert(locals._getVarDesc(controller).index == controllerContextIndex);
+ }
_allocateParameters(node, function);
_allocateSpecialVariables();
@@ -1126,7 +1180,15 @@
@override
visitVariableDeclaration(VariableDeclaration node) {
- _allocateVariable(node);
+ if (node.name == ContinuationVariables.awaitJumpVar) {
+ assert(locals._getVarDesc(node).index == awaitJumpVarContextIndex);
+ } else if (node.name == ContinuationVariables.asyncCompleter) {
+ assert(locals._getVarDesc(node).index == asyncCompleterContextIndex);
+ } else if (node.name == ContinuationVariables.controller) {
+ assert(locals._getVarDesc(node).index == controllerContextIndex);
+ } else {
+ _allocateVariable(node);
+ }
node.visitChildren(this);
}
diff --git a/pkg/vm/lib/elf/convert.dart b/pkg/vm/lib/elf/convert.dart
new file mode 100644
index 0000000..cce90d5
--- /dev/null
+++ b/pkg/vm/lib/elf/convert.dart
@@ -0,0 +1,95 @@
+// Copyright (c) 2019, 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.
+
+import "dart:async";
+
+import "dwarf.dart";
+
+String _stackTracePiece(CallInfo call, int depth) => "#${depth}\t${call}";
+
+final _traceLineRE = RegExp(r' #(\d{2}) pc ([0-9a-f]+) (.*)$');
+
+Iterable<int> collectPCAddresses(Iterable<String> lines) {
+ final ret = <int>[];
+ for (var line in lines) {
+ final match = _traceLineRE.firstMatch(line);
+ if (match == null) continue;
+ ret.add(int.parse("0x" + match[2]));
+ }
+ return ret;
+}
+
+// Scans a stream of lines for Dart DWARF-based stack traces (i.e., Dart stack
+// traces where the frame entries include PC addresses). For each stack frame
+// found, the transformer attempts to locate a function name, file name and line
+// number using the provided DWARF information.
+//
+// If no information is found, or the line is not a stack frame, the line is
+// output to the sink unchanged.
+//
+// If the located information corresponds to Dart internals, the frame will be
+// dropped.
+//
+// Otherwise, at least one altered stack frame is generated and replaces the
+// stack frame portion of the original line. If the PC address corresponds to
+// inlined code, then multiple stack frames may be generated. When multiple
+// stack frames are generated, only the first replaces the stack frame portion
+// of the original line, and the remaining frames are separately output.
+class DwarfStackTraceDecoder extends StreamTransformerBase<String, String> {
+ final Dwarf _dwarf;
+ final bool includeInternalFrames;
+
+ DwarfStackTraceDecoder(this._dwarf, {this.includeInternalFrames = false});
+
+ Stream<String> bind(Stream<String> stream) => Stream<String>.eventTransformed(
+ stream,
+ (sink) => _DwarfStackTraceEventSink(sink, _dwarf,
+ includeInternalFrames: includeInternalFrames));
+}
+
+class _DwarfStackTraceEventSink implements EventSink<String> {
+ final EventSink<String> _sink;
+ final Dwarf _dwarf;
+ final bool includeInternalFrames;
+ int _cachedDepth = 0;
+
+ _DwarfStackTraceEventSink(this._sink, this._dwarf,
+ {this.includeInternalFrames = false});
+
+ void close() => _sink.close();
+ void addError(Object e, [StackTrace st]) => _sink.addError(e, st);
+ Future addStream(Stream<String> stream) => stream.forEach(add);
+
+ void add(String line) {
+ final match = _traceLineRE.firstMatch(line);
+ if (match == null) {
+ _sink.add(line);
+ return;
+ }
+ // We don't use the original frame depths because we may elide frames.
+ // If we match a stack frame with a depth of 0, then we're starting a
+ // new stack frame.
+ if (int.parse(match[1]) == 0) {
+ _cachedDepth = 0;
+ }
+ final location = int.parse("0x" + match[2]);
+ final callInfo = _dwarf
+ .callInfo(location, includeInternalFrames: includeInternalFrames)
+ ?.toList();
+ if (callInfo == null) {
+ // If we can't get appropriate information for the stack trace line,
+ // then just return the line unchanged.
+ _sink.add(line);
+ return;
+ } else if (callInfo.isEmpty) {
+ // No lines to output (as this corresponds to Dart internals).
+ return;
+ }
+ _sink.add(line.substring(0, match.start) +
+ _stackTracePiece(callInfo.first, _cachedDepth++));
+ for (int i = 1; i < callInfo.length; i++) {
+ _sink.add(_stackTracePiece(callInfo[i], _cachedDepth++));
+ }
+ }
+}
diff --git a/pkg/vm/lib/elf/dwarf.dart b/pkg/vm/lib/elf/dwarf.dart
new file mode 100644
index 0000000..012246d
--- /dev/null
+++ b/pkg/vm/lib/elf/dwarf.dart
@@ -0,0 +1,1018 @@
+// Copyright (c) 2019, 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.
+
+import 'dart:math';
+
+import 'elf.dart';
+import 'reader.dart';
+
+int _initialLengthValue(Reader reader) {
+ final length = reader.readBytes(4);
+ if (length == 0xffffffff) {
+ throw FormatException("64-bit DWARF format detected");
+ } else if (length > 0xfffffff0) {
+ throw FormatException("Unrecognized reserved initial length value");
+ }
+ return length;
+}
+
+enum _Tag {
+ compileUnit,
+ inlinedSubroutine,
+ subprogram,
+}
+
+const _tags = <int, _Tag>{
+ 0x11: _Tag.compileUnit,
+ 0x1d: _Tag.inlinedSubroutine,
+ 0x2e: _Tag.subprogram,
+};
+
+const _tagStrings = <_Tag, String>{
+ _Tag.compileUnit: "DW_TAG_compile_unit",
+ _Tag.inlinedSubroutine: "DW_TAG_inlined_subroutine",
+ _Tag.subprogram: "DW_TAG_subroutine",
+};
+
+enum _AttributeName {
+ abstractOrigin,
+ callColumn,
+ callFile,
+ callLine,
+ compilationDirectory,
+ declarationColumn,
+ declarationFile,
+ declarationLine,
+ highProgramCounter,
+ lowProgramCounter,
+ inline,
+ name,
+ producer,
+ sibling,
+ statementList,
+}
+
+const _attributeNames = <int, _AttributeName>{
+ 0x01: _AttributeName.sibling,
+ 0x03: _AttributeName.name,
+ 0x10: _AttributeName.statementList,
+ 0x11: _AttributeName.lowProgramCounter,
+ 0x12: _AttributeName.highProgramCounter,
+ 0x1b: _AttributeName.compilationDirectory,
+ 0x20: _AttributeName.inline,
+ 0x25: _AttributeName.producer,
+ 0x31: _AttributeName.abstractOrigin,
+ 0x39: _AttributeName.declarationColumn,
+ 0x3a: _AttributeName.declarationFile,
+ 0x3b: _AttributeName.declarationLine,
+ 0x57: _AttributeName.callColumn,
+ 0x58: _AttributeName.callFile,
+ 0x59: _AttributeName.callLine,
+};
+
+const _attributeNameStrings = <_AttributeName, String>{
+ _AttributeName.sibling: "DW_AT_sibling",
+ _AttributeName.name: "DW_AT_name",
+ _AttributeName.statementList: "DW_AT_stmt_list",
+ _AttributeName.lowProgramCounter: "DW_AT_low_pc",
+ _AttributeName.highProgramCounter: "DW_AT_high_pc",
+ _AttributeName.compilationDirectory: "DW_AT_comp_dir",
+ _AttributeName.inline: "DW_AT_inline",
+ _AttributeName.producer: "DW_AT_producer",
+ _AttributeName.abstractOrigin: "DW_AT_abstract_origin",
+ _AttributeName.declarationColumn: "DW_AT_decl_column",
+ _AttributeName.declarationFile: "DW_AT_decl_file",
+ _AttributeName.declarationLine: "DW_AT_decl_line",
+ _AttributeName.callColumn: "DW_AT_call_column",
+ _AttributeName.callFile: "DW_AT_call_file",
+ _AttributeName.callLine: "DW_AT_call_line",
+};
+
+enum _AttributeForm {
+ address,
+ constant,
+ reference4,
+ sectionOffset,
+ string,
+}
+
+const _attributeForms = <int, _AttributeForm>{
+ 0x01: _AttributeForm.address,
+ 0x08: _AttributeForm.string,
+ 0x0f: _AttributeForm.constant,
+ 0x13: _AttributeForm.reference4,
+ 0x17: _AttributeForm.sectionOffset,
+};
+
+const _attributeFormStrings = <_AttributeForm, String>{
+ _AttributeForm.address: "DW_FORM_addr",
+ _AttributeForm.string: "DW_FORM_string",
+ _AttributeForm.constant: "DW_FORM_udata",
+ _AttributeForm.reference4: "DW_FORM_ref4",
+ _AttributeForm.sectionOffset: "DW_FORM_sec_offset",
+};
+
+class _Attribute {
+ final _AttributeName name;
+ final _AttributeForm form;
+
+ _Attribute(this.name, this.form);
+}
+
+class _Abbreviation {
+ final Reader reader;
+
+ _Tag tag;
+ bool children;
+ List<_Attribute> attributes;
+
+ _Abbreviation.fromReader(Reader this.reader) {
+ _read();
+ }
+
+ // Constants from the DWARF specification.
+ static const _DW_CHILDREN_no = 0x00;
+ static const _DW_CHILDREN_yes = 0x01;
+
+ bool _readChildren() {
+ switch (reader.readByte()) {
+ case _DW_CHILDREN_no:
+ return false;
+ case _DW_CHILDREN_yes:
+ return true;
+ default:
+ throw FormatException("Expected DW_CHILDREN_no or DW_CHILDREN_yes");
+ }
+ }
+
+ void _read() {
+ reader.reset();
+ final tagInt = reader.readLEB128EncodedInteger();
+ if (!_tags.containsKey(tagInt)) {
+ throw FormatException("Unexpected DW_TAG value 0x${paddedHex(tagInt)}");
+ }
+ tag = _tags[tagInt];
+ children = _readChildren();
+ attributes = <_Attribute>[];
+ while (!reader.done) {
+ final nameInt = reader.readLEB128EncodedInteger();
+ final formInt = reader.readLEB128EncodedInteger();
+ if (nameInt == 0 && formInt == 0) {
+ break;
+ }
+ if (!_attributeNames.containsKey(nameInt)) {
+ throw FormatException("Unexpected DW_AT value 0x${paddedHex(nameInt)}");
+ }
+ if (!_attributeForms.containsKey(formInt)) {
+ throw FormatException(
+ "Unexpected DW_FORM value 0x${paddedHex(formInt)}");
+ }
+ attributes
+ .add(_Attribute(_attributeNames[nameInt], _attributeForms[formInt]));
+ }
+ }
+
+ String toString() {
+ var ret = " Tag: ${_tagStrings[tag]}\n"
+ " Children: ${children ? "DW_CHILDREN_yes" : "DW_CHILDREN_no"}\n"
+ " Attributes:\n";
+ for (final attribute in attributes) {
+ ret += " ${_attributeNameStrings[attribute.name]}: "
+ "${_attributeFormStrings[attribute.form]}\n";
+ }
+ return ret;
+ }
+}
+
+class _AbbreviationsTable {
+ final Reader reader;
+
+ Map<int, _Abbreviation> _abbreviations;
+
+ _AbbreviationsTable.fromReader(this.reader) {
+ _read();
+ }
+
+ bool containsKey(int code) => _abbreviations.containsKey(code);
+ _Abbreviation operator [](int code) => _abbreviations[code];
+
+ void _read() {
+ reader.reset();
+ _abbreviations = <int, _Abbreviation>{};
+ while (!reader.done) {
+ final code = reader.readLEB128EncodedInteger();
+ // Code of 0 marks end of abbreviations table.
+ if (code == 0) {
+ break;
+ }
+ final abbrev = _Abbreviation.fromReader(reader.shrink(reader.offset));
+ _abbreviations[code] = abbrev;
+ reader.seek(abbrev.reader.offset);
+ }
+ }
+
+ String toString() =>
+ "Abbreviations table:\n\n" +
+ _abbreviations.keys
+ .map((k) => " Abbreviation $k:\n" + _abbreviations[k].toString())
+ .join("\n");
+}
+
+class DebugInformationEntry {
+ final Reader reader;
+ final CompilationUnit compilationUnit;
+
+ // The index of the entry in the abbreviation table for this DIE. If 0, then
+ // this is not actually a full DIE, but an end marker for a list of entries.
+ int code;
+ Map<_Attribute, Object> attributes;
+ List<DebugInformationEntry> children;
+
+ DebugInformationEntry.fromReader(this.reader, this.compilationUnit) {
+ _read();
+ }
+
+ Object _readAttribute(_Attribute attribute) {
+ switch (attribute.form) {
+ case _AttributeForm.string:
+ return reader.readNullTerminatedString();
+ case _AttributeForm.address:
+ return reader.readBytes(compilationUnit.addressSize);
+ case _AttributeForm.sectionOffset:
+ return reader.readBytes(4);
+ case _AttributeForm.constant:
+ return reader.readLEB128EncodedInteger();
+ case _AttributeForm.reference4:
+ return reader.readBytes(4);
+ }
+ }
+
+ String _nameOfOrigin(int offset) {
+ if (!compilationUnit.referenceTable.containsKey(offset)) {
+ throw ArgumentError(
+ "${paddedHex(offset)} is not the offset of an abbreviated unit");
+ }
+ final origin = compilationUnit.referenceTable[offset];
+ assert(origin.containsKey(_AttributeName.name));
+ return origin[_AttributeName.name] as String;
+ }
+
+ String _attributeValueToString(_Attribute attribute, Object value) {
+ switch (attribute.form) {
+ case _AttributeForm.string:
+ return value as String;
+ case _AttributeForm.address:
+ return paddedHex(value as int, compilationUnit.addressSize);
+ case _AttributeForm.sectionOffset:
+ return paddedHex(value as int, 4);
+ case _AttributeForm.constant:
+ return value.toString();
+ case _AttributeForm.reference4:
+ return paddedHex(value as int, 4) +
+ " (origin: ${_nameOfOrigin(value as int)})";
+ }
+ }
+
+ int get _unitOffset => reader.start - compilationUnit.reader.start;
+
+ void _read() {
+ reader.reset();
+ code = reader.readLEB128EncodedInteger();
+ // DIEs with an abbreviation table index of 0 are list end markers.
+ if (code == 0) {
+ return;
+ }
+ if (!compilationUnit.abbreviations.containsKey(code)) {
+ throw FormatException("Unknown abbreviation code 0x${paddedHex(code)}");
+ }
+ final abbreviation = compilationUnit.abbreviations[code];
+ attributes = <_Attribute, Object>{};
+ for (final attribute in abbreviation.attributes) {
+ attributes[attribute] = _readAttribute(attribute);
+ }
+ compilationUnit.referenceTable[_unitOffset] = this;
+ if (!abbreviation.children) return;
+ children = <DebugInformationEntry>[];
+ while (!reader.done) {
+ final child = DebugInformationEntry.fromReader(
+ reader.shrink(reader.offset), compilationUnit);
+ reader.seek(child.reader.offset);
+ if (child.code == 0) {
+ break;
+ }
+ children.add(child);
+ }
+ }
+
+ _Attribute _attributeForName(_AttributeName name) => attributes.keys
+ .firstWhere((_Attribute k) => k.name == name, orElse: () => null);
+
+ bool containsKey(_AttributeName name) => _attributeForName(name) != null;
+
+ Object operator [](_AttributeName name) {
+ final key = _attributeForName(name);
+ if (key == null) {
+ return null;
+ }
+ return attributes[key];
+ }
+
+ DebugInformationEntry get abstractOrigin {
+ final index = this[_AttributeName.abstractOrigin] as int;
+ return compilationUnit.referenceTable[index];
+ }
+
+ int get lowPC => this[_AttributeName.lowProgramCounter] as int;
+
+ int get highPC => this[_AttributeName.highProgramCounter] as int;
+
+ bool containsPC(int virtualAddress) =>
+ lowPC != null && lowPC <= virtualAddress && virtualAddress < highPC;
+
+ String get name => this[_AttributeName.name] as String;
+
+ int get callFileIndex => this[_AttributeName.callFile] as int;
+
+ int get callLine => this[_AttributeName.callLine] as int;
+
+ _Tag get tag => compilationUnit.abbreviations[code].tag;
+
+ List<CallInfo> callInfo(int address, LineNumberProgram lineNumberProgram) {
+ String callFilename(int index) => lineNumberProgram.filesInfo[index].name;
+ if (!containsPC(address)) {
+ return null;
+ }
+ final inlined = tag == _Tag.inlinedSubroutine;
+ for (final unit in children) {
+ final callInfo = unit.callInfo(address, lineNumberProgram);
+ if (callInfo == null) {
+ continue;
+ }
+ if (tag != _Tag.compileUnit) {
+ callInfo.add(CallInfo(
+ function: abstractOrigin.name,
+ inlined: inlined,
+ filename: callFilename(unit.callFileIndex),
+ line: unit.callLine));
+ }
+ return callInfo;
+ }
+ if (tag == _Tag.compileUnit) {
+ return null;
+ }
+ final filename = lineNumberProgram.filename(address);
+ final line = lineNumberProgram.lineNumber(address);
+ return [
+ CallInfo(
+ function: abstractOrigin.name,
+ inlined: inlined,
+ filename: filename,
+ line: line)
+ ];
+ }
+
+ String toString() {
+ var ret =
+ "Abbreviated unit (code $code, offset ${paddedHex(_unitOffset)}):\n";
+ for (final attribute in attributes.keys) {
+ ret += " ${_attributeNameStrings[attribute.name]} => "
+ "${_attributeValueToString(attribute, attributes[attribute])}\n";
+ }
+ if (children == null || children.length == 0) {
+ ret += "Has no children.\n\n";
+ return ret;
+ }
+ ret += "Has ${children.length} " +
+ (children.length == 1 ? "child" : "children") +
+ "\n\n";
+ for (int i = 0; i < children.length; i++) {
+ ret += "Child ${i} of unit at offset ${paddedHex(_unitOffset)}:\n";
+ ret += children[i].toString();
+ }
+ return ret;
+ }
+}
+
+class CompilationUnit {
+ final Reader reader;
+ final Dwarf dwarf;
+
+ int size;
+ int version;
+ int abbreviationOffset;
+ int addressSize;
+ List<DebugInformationEntry> contents;
+ Map<int, DebugInformationEntry> referenceTable;
+
+ CompilationUnit.fromReader(this.reader, this.dwarf) {
+ _read();
+ }
+
+ void _read() {
+ reader.reset();
+ size = _initialLengthValue(reader);
+ // An empty unit is an ending marker.
+ if (size == 0) {
+ return;
+ }
+ version = reader.readBytes(2);
+ if (version != 2) {
+ throw FormatException("Expected DWARF version 2, got $version");
+ }
+ abbreviationOffset = reader.readBytes(4);
+ if (!dwarf.abbreviationTables.containsKey(abbreviationOffset)) {
+ throw FormatException("No abbreviation table found for offset "
+ "0x${paddedHex(abbreviationOffset, 4)}");
+ }
+ addressSize = reader.readByte();
+ contents = <DebugInformationEntry>[];
+ referenceTable = <int, DebugInformationEntry>{};
+ while (!reader.done) {
+ final subunit =
+ DebugInformationEntry.fromReader(reader.shrink(reader.offset), this);
+ reader.seek(subunit.reader.offset);
+ if (subunit.code == 0) {
+ break;
+ }
+ assert(subunit.tag == _Tag.compileUnit);
+ contents.add(subunit);
+ }
+ }
+
+ Iterable<CallInfo> callInfo(int address) {
+ for (final unit in contents) {
+ final lineNumberProgram =
+ dwarf.lineNumberInfo[unit[_AttributeName.statementList]];
+ final callInfo = unit.callInfo(address, lineNumberProgram);
+ if (callInfo != null) {
+ return callInfo;
+ }
+ }
+ return null;
+ }
+
+ _AbbreviationsTable get abbreviations =>
+ dwarf.abbreviationTables[abbreviationOffset];
+
+ String toString() =>
+ "Compilation unit:\n"
+ " Version: $version\n"
+ " Abbreviation offset: ${paddedHex(abbreviationOffset, 4)}\n"
+ " Address size: $addressSize\n\n" +
+ contents.map((DebugInformationEntry u) => u.toString()).join();
+}
+
+class DebugInfo {
+ final Reader reader;
+ final Dwarf dwarf;
+
+ List<CompilationUnit> units;
+
+ DebugInfo.fromReader(this.reader, this.dwarf) {
+ _read();
+ }
+
+ void _read() {
+ reader.reset();
+ units = <CompilationUnit>[];
+ while (!reader.done) {
+ final unit =
+ CompilationUnit.fromReader(reader.shrink(reader.offset), dwarf);
+ reader.seek(unit.reader.offset);
+ if (unit.size == 0) {
+ break;
+ }
+ units.add(unit);
+ }
+ }
+
+ Iterable<CallInfo> callInfo(int address) {
+ for (final unit in units) {
+ final callInfo = unit.callInfo(address);
+ if (callInfo != null) {
+ return callInfo;
+ }
+ }
+ return null;
+ }
+
+ String toString() =>
+ "Debug information:\n\n" +
+ units.map((CompilationUnit u) => u.toString()).join();
+}
+
+class FileEntry {
+ final Reader reader;
+
+ String name;
+ int directoryIndex;
+ int lastModified;
+ int size;
+
+ FileEntry.fromReader(this.reader) {
+ _read();
+ }
+
+ void _read() {
+ reader.reset();
+ name = reader.readNullTerminatedString();
+ if (name == "") {
+ return;
+ }
+ directoryIndex = reader.readLEB128EncodedInteger();
+ lastModified = reader.readLEB128EncodedInteger();
+ size = reader.readLEB128EncodedInteger();
+ }
+
+ String toString() => "File name: $name\n"
+ " Directory index: $directoryIndex\n"
+ " Last modified: $lastModified\n"
+ " Size: $size\n";
+}
+
+class FileInfo {
+ final Reader reader;
+
+ Map<int, FileEntry> _files;
+
+ FileInfo.fromReader(this.reader) {
+ _read();
+ }
+
+ void _read() {
+ reader.reset();
+ _files = <int, FileEntry>{};
+ int index = 1;
+ while (!reader.done) {
+ final file = FileEntry.fromReader(reader.shrink(reader.offset));
+ reader.seek(file.reader.offset);
+ // An empty null-terminated string marks the table end.
+ if (file.name == "") {
+ break;
+ }
+ _files[index] = file;
+ index++;
+ }
+ }
+
+ bool containsKey(int index) => _files.containsKey(index);
+ FileEntry operator [](int index) => _files[index];
+
+ String toString() {
+ if (_files.isEmpty) {
+ return "No file information.\n";
+ }
+
+ var ret = "File information:\n";
+
+ final indexHeader = "Entry";
+ final dirIndexHeader = "Dir";
+ final modifiedHeader = "Time";
+ final sizeHeader = "Size";
+ final nameHeader = "Name";
+
+ final indexStrings = _files
+ .map((int i, FileEntry f) => MapEntry<int, String>(i, i.toString()));
+ final dirIndexStrings = _files.map((int i, FileEntry f) =>
+ MapEntry<int, String>(i, f.directoryIndex.toString()));
+ final modifiedStrings = _files.map((int i, FileEntry f) =>
+ MapEntry<int, String>(i, f.lastModified.toString()));
+ final sizeStrings = _files.map(
+ (int i, FileEntry f) => MapEntry<int, String>(i, f.size.toString()));
+
+ final maxIndexLength = indexStrings.values
+ .fold(indexHeader.length, (int acc, String s) => max(acc, s.length));
+ final maxDirIndexLength = dirIndexStrings.values
+ .fold(dirIndexHeader.length, (int acc, String s) => max(acc, s.length));
+ final maxModifiedLength = modifiedStrings.values
+ .fold(modifiedHeader.length, (int acc, String s) => max(acc, s.length));
+ final maxSizeLength = sizeStrings.values
+ .fold(sizeHeader.length, (int acc, String s) => max(acc, s.length));
+
+ ret += " ${indexHeader.padRight(maxIndexLength)}";
+ ret += " ${dirIndexHeader.padRight(maxDirIndexLength)}";
+ ret += " ${modifiedHeader.padRight(maxModifiedLength)}";
+ ret += " ${sizeHeader.padRight(maxSizeLength)}";
+ ret += " $nameHeader\n";
+
+ for (final index in _files.keys) {
+ ret += " ${indexStrings[index].padRight(maxIndexLength)}";
+ ret += " ${dirIndexStrings[index].padRight(maxDirIndexLength)}";
+ ret += " ${modifiedStrings[index].padRight(maxModifiedLength)}";
+ ret += " ${sizeStrings[index].padRight(maxSizeLength)}";
+ ret += " ${_files[index].name}\n";
+ }
+
+ return ret;
+ }
+}
+
+class LineNumberState {
+ final defaultIsStatement;
+
+ int address;
+ int fileIndex;
+ int line;
+ int column;
+ bool isStatement;
+ bool basicBlock;
+ bool endSequence;
+
+ LineNumberState(bool this.defaultIsStatement) {
+ reset();
+ }
+
+ void reset() {
+ address = 0;
+ fileIndex = 1;
+ line = 1;
+ column = 0;
+ isStatement = defaultIsStatement;
+ basicBlock = false;
+ endSequence = false;
+ }
+
+ LineNumberState clone() {
+ final clone = LineNumberState(defaultIsStatement);
+ clone.address = address;
+ clone.fileIndex = fileIndex;
+ clone.line = line;
+ clone.column = column;
+ clone.isStatement = isStatement;
+ clone.basicBlock = basicBlock;
+ clone.endSequence = endSequence;
+ return clone;
+ }
+
+ String toString() => "Current line number state machine registers:\n"
+ " Address: ${paddedHex(address)}\n"
+ " File index: $fileIndex\n"
+ " Line number: $line\n"
+ " Column number: $column\n"
+ " Is ${isStatement ? "" : "not "}a statement.\n"
+ " Is ${basicBlock ? "" : "not "}at the beginning of a basic block.\n"
+ " Is ${endSequence ? "" : "not "}just after the end of a sequence.\n";
+}
+
+class LineNumberProgram {
+ final Reader reader;
+
+ int size;
+ int version;
+ int headerLength;
+ int minimumInstructionLength;
+ bool defaultIsStatement;
+ int lineBase;
+ int lineRange;
+ int opcodeBase;
+ Map<int, int> standardOpcodeLengths;
+ List<String> includeDirectories;
+ FileInfo filesInfo;
+ List<LineNumberState> calculatedMatrix;
+ Map<int, LineNumberState> cachedLookups;
+
+ LineNumberProgram.fromReader(this.reader) {
+ _read();
+ }
+
+ void _read() {
+ reader.reset();
+ size = _initialLengthValue(reader);
+ if (size == 0) {
+ return;
+ }
+ version = reader.readBytes(2);
+ headerLength = reader.readBytes(4);
+ minimumInstructionLength = reader.readByte();
+ switch (reader.readByte()) {
+ case 0:
+ defaultIsStatement = false;
+ break;
+ case 1:
+ defaultIsStatement = true;
+ break;
+ default:
+ throw FormatException("Unexpected value for default_is_stmt");
+ }
+ lineBase = reader.readByte(signed: true);
+ lineRange = reader.readByte();
+ opcodeBase = reader.readByte();
+ standardOpcodeLengths = <int, int>{};
+ // Standard opcode numbering starts at 1.
+ for (int i = 1; i < opcodeBase; i++) {
+ standardOpcodeLengths[i] = reader.readLEB128EncodedInteger();
+ }
+ includeDirectories = <String>[];
+ while (!reader.done) {
+ final directory = reader.readNullTerminatedString();
+ if (directory == "") {
+ break;
+ }
+ includeDirectories.add(directory);
+ }
+ filesInfo = FileInfo.fromReader(reader.shrink(reader.offset));
+ reader.seek(filesInfo.reader.offset);
+ // Header length doesn't include the 4-byte length or 2-byte version fields.
+ assert(reader.offset == headerLength + 6);
+ calculatedMatrix = <LineNumberState>[];
+ final currentState = LineNumberState(defaultIsStatement);
+ while (!reader.done) {
+ _applyNextOpcode(currentState);
+ }
+ if (calculatedMatrix.length == 0) {
+ throw FormatException("No line number information generated by program");
+ }
+ // Set the offset to the declared size in case of padding. The declared
+ // size does not include the size of the size field itself.
+ reader.seek(size + 4);
+ cachedLookups = <int, LineNumberState>{};
+ }
+
+ void _addStateToMatrix(LineNumberState state) {
+ calculatedMatrix.add(state.clone());
+ }
+
+ void _applyNextOpcode(LineNumberState state) {
+ void applySpecialOpcode(int opcode) {
+ final adjustedOpcode = opcode - opcodeBase;
+ state.address = adjustedOpcode ~/ lineRange;
+ state.line += lineBase + (adjustedOpcode % lineRange);
+ }
+
+ final opcode = reader.readByte();
+ if (opcode >= opcodeBase) {
+ return applySpecialOpcode(opcode);
+ }
+ switch (opcode) {
+ case 0: // Extended opcodes
+ final extendedLength = reader.readByte();
+ final subOpcode = reader.readByte();
+ switch (subOpcode) {
+ case 0:
+ throw FormatException(
+ "Attempted to execute extended opcode ${subOpcode} (padding?)");
+ case 1: // DW_LNE_end_sequence
+ state.endSequence = true;
+ _addStateToMatrix(state);
+ state.reset();
+ break;
+ case 2: // DW_LNE_set_address
+ // The length includes the subopcode.
+ final valueLength = extendedLength - 1;
+ assert(valueLength == 4 || valueLength == 8);
+ final newAddress = reader.readBytes(valueLength);
+ state.address = newAddress;
+ break;
+ case 3: // DW_LNE_define_file
+ throw FormatException("DW_LNE_define_file instruction not handled");
+ default:
+ throw FormatException(
+ "Extended opcode ${subOpcode} not in DWARF 2");
+ }
+ break;
+ case 1: // DW_LNS_copy
+ _addStateToMatrix(state);
+ state.basicBlock = false;
+ break;
+ case 2: // DW_LNS_advance_pc
+ final increment = reader.readLEB128EncodedInteger();
+ state.address += minimumInstructionLength * increment;
+ break;
+ case 3: // DW_LNS_advance_line
+ state.line += reader.readLEB128EncodedInteger(signed: true);
+ break;
+ case 4: // DW_LNS_set_file
+ state.fileIndex = reader.readLEB128EncodedInteger();
+ break;
+ case 5: // DW_LNS_set_column
+ state.column = reader.readLEB128EncodedInteger();
+ break;
+ case 6: // DW_LNS_negate_stmt
+ state.isStatement = !state.isStatement;
+ break;
+ case 7: // DW_LNS_set_basic_block
+ state.basicBlock = true;
+ break;
+ case 8: // DW_LNS_const_add_pc
+ applySpecialOpcode(255);
+ break;
+ case 9: // DW_LNS_fixed_advance_pc
+ state.address += reader.readBytes(2);
+ break;
+ default:
+ throw FormatException("Standard opcode ${opcode} not in DWARF 2");
+ }
+ }
+
+ bool containsKey(int address) {
+ assert(calculatedMatrix.last.endSequence);
+ return address >= calculatedMatrix.first.address &&
+ address < calculatedMatrix.last.address;
+ }
+
+ LineNumberState operator [](int address) {
+ if (cachedLookups.containsKey(address)) {
+ return cachedLookups[address];
+ }
+ if (!containsKey(address)) {
+ return null;
+ }
+ // Since the addresses are generated in increasing order, we can do a
+ // binary search to find the right state.
+ assert(calculatedMatrix != null && calculatedMatrix.isNotEmpty);
+ var minIndex = 0;
+ var maxIndex = calculatedMatrix.length - 1;
+ while (true) {
+ if (minIndex == maxIndex || minIndex + 1 == maxIndex) {
+ final found = calculatedMatrix[minIndex];
+ cachedLookups[address] = found;
+ return found;
+ }
+ final index = minIndex + ((maxIndex - minIndex) ~/ 2);
+ final compared = calculatedMatrix[index].address.compareTo(address);
+ if (compared == 0) {
+ return calculatedMatrix[index];
+ } else if (compared < 0) {
+ minIndex = index;
+ } else if (compared > 0) {
+ maxIndex = index;
+ }
+ }
+ }
+
+ String filename(int address) {
+ final state = this[address];
+ if (state == null) {
+ return null;
+ }
+ return filesInfo[state.fileIndex].name;
+ }
+
+ int lineNumber(int address) {
+ final state = this[address];
+ if (state == null) {
+ return null;
+ }
+ return state.line;
+ }
+
+ String toString() {
+ var ret = " Size: $size\n"
+ " Version: $version\n"
+ " Header length: $headerLength\n"
+ " Min instruction length: $minimumInstructionLength\n"
+ " Default value of is_stmt: $defaultIsStatement\n"
+ " Line base: $lineBase\n"
+ " Line range: $lineRange\n"
+ " Opcode base: $opcodeBase\n"
+ " Standard opcode lengths:\n";
+ for (int i = 1; i < opcodeBase; i++) {
+ ret += " Opcode $i: ${standardOpcodeLengths[i]}\n";
+ }
+
+ if (includeDirectories.isEmpty) {
+ ret += "No include directories.\n";
+ } else {
+ ret += "Include directories:\n";
+ for (final dir in includeDirectories) {
+ ret += " $dir\n";
+ }
+ }
+
+ ret += "${filesInfo}\nResults of line number program:\n";
+ ret += calculatedMatrix.map((LineNumberState s) => s.toString()).join();
+
+ return ret;
+ }
+}
+
+class LineNumberInfo {
+ final Reader reader;
+
+ Map<int, LineNumberProgram> programs;
+
+ LineNumberInfo.fromReader(this.reader) {
+ _read();
+ }
+
+ void _read() {
+ reader.reset();
+ programs = <int, LineNumberProgram>{};
+ while (!reader.done) {
+ final start = reader.offset;
+ final program = LineNumberProgram.fromReader(reader.shrink(start));
+ reader.seek(program.reader.offset);
+ if (program.size == 0) {
+ break;
+ }
+ programs[start] = program;
+ }
+ }
+
+ bool containsKey(int address) => programs.containsKey(address);
+ LineNumberProgram operator [](int address) => programs[address];
+
+ String toString() =>
+ "Line number information:\n\n" +
+ programs
+ .map((int i, LineNumberProgram p) =>
+ MapEntry(i, "Line number program @ 0x${paddedHex(i)}:\n$p\n"))
+ .values
+ .join();
+}
+
+// TODO(11617): Replace calls to these functions with a general hashing solution
+// once available.
+int _hashCombine(int hash, int value) {
+ hash = 0x1fffffff & (hash + value);
+ hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
+ return hash ^ (hash >> 6);
+}
+
+int _hashFinish(int hash) {
+ hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
+ hash = hash ^ (hash >> 11);
+ return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
+}
+
+class CallInfo {
+ final bool inlined;
+ final String function;
+ final String filename;
+ final int line;
+
+ CallInfo({this.inlined = false, this.function, this.filename, this.line});
+
+ int get hashCode => _hashFinish(_hashCombine(
+ _hashCombine(
+ _hashCombine(_hashCombine(0, inlined.hashCode), function.hashCode),
+ filename.hashCode),
+ line.hashCode));
+
+ bool operator ==(Object other) {
+ if (other is CallInfo) {
+ return inlined == other.inlined &&
+ function == other.function &&
+ filename == other.filename &&
+ line == other.line;
+ }
+ return false;
+ }
+
+ String toString() =>
+ "${function} (${filename}:${line <= 0 ? "??" : line.toString()})";
+}
+
+class Dwarf {
+ final Elf elf;
+ Map<int, _AbbreviationsTable> abbreviationTables;
+ DebugInfo debugInfo;
+ LineNumberInfo lineNumberInfo;
+
+ Dwarf.fromElf(Elf this.elf) {
+ _loadSections();
+ }
+
+ factory Dwarf.fromFile(String filename) {
+ final elf = Elf.fromFile(filename);
+ return Dwarf.fromElf(elf);
+ }
+
+ void _loadSections() {
+ final abbrevSection = elf.namedSection(".debug_abbrev");
+ abbreviationTables = <int, _AbbreviationsTable>{};
+ var abbreviationOffset = 0;
+ while (abbreviationOffset < abbrevSection.reader.length) {
+ final table = _AbbreviationsTable.fromReader(
+ abbrevSection.reader.shrink(abbreviationOffset));
+ abbreviationTables[abbreviationOffset] = table;
+ abbreviationOffset += table.reader.offset;
+ }
+ assert(abbreviationOffset == abbrevSection.reader.length);
+
+ final lineNumberSection = elf.namedSection(".debug_line");
+ lineNumberInfo = LineNumberInfo.fromReader(lineNumberSection.reader);
+
+ final infoSection = elf.namedSection(".debug_info");
+ debugInfo = DebugInfo.fromReader(infoSection.reader, this);
+ }
+
+ Iterable<CallInfo> callInfo(int address,
+ {bool includeInternalFrames = false}) {
+ final calls = debugInfo.callInfo(address);
+ if (calls != null && !includeInternalFrames) {
+ return calls.where((CallInfo c) => c.line > 0);
+ }
+ return calls;
+ }
+
+ String toString() =>
+ "DWARF debugging information:\n\n" +
+ abbreviationTables
+ .map((int i, _AbbreviationsTable t) =>
+ MapEntry(i, "(Offset ${paddedHex(i)}) $t"))
+ .values
+ .join() +
+ "\n$debugInfo\n$lineNumberInfo";
+}
diff --git a/pkg/vm/lib/elf/elf.dart b/pkg/vm/lib/elf/elf.dart
new file mode 100644
index 0000000..0cf5672
--- /dev/null
+++ b/pkg/vm/lib/elf/elf.dart
@@ -0,0 +1,570 @@
+// Copyright (c) 2019, 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.
+
+import 'dart:typed_data';
+import 'dart:io';
+
+import 'reader.dart';
+
+int _readElfBytes(Reader reader, int bytes, int alignment) {
+ final alignOffset = reader.offset % alignment;
+ if (alignOffset != 0) {
+ // Move the reader to the next aligned position.
+ reader.seek(reader.offset - alignOffset + alignment);
+ }
+ return reader.readBytes(bytes);
+}
+
+// Reads an Elf{32,64}_Addr.
+int _readElfAddress(Reader reader) {
+ return _readElfBytes(reader, reader.wordSize, reader.wordSize);
+}
+
+// Reads an Elf{32,64}_Off.
+int _readElfOffset(Reader reader) {
+ return _readElfBytes(reader, reader.wordSize, reader.wordSize);
+}
+
+// Reads an Elf{32,64}_Half.
+int _readElfHalf(Reader reader) {
+ return _readElfBytes(reader, 2, 2);
+}
+
+// Reads an Elf{32,64}_Word.
+int _readElfWord(Reader reader) {
+ return _readElfBytes(reader, 4, 4);
+}
+
+// Reads an Elf64_Xword.
+int _readElfXword(Reader reader) {
+ switch (reader.wordSize) {
+ case 4:
+ throw "Internal reader error: reading Elf64_Xword in 32-bit ELF file";
+ case 8:
+ return _readElfBytes(reader, 8, 8);
+ default:
+ throw "Unsupported word size ${reader.wordSize}";
+ }
+}
+
+// Used in cases where the value read for a given field is Elf32_Word on 32-bit
+// and Elf64_Xword on 64-bit.
+int _readElfNative(Reader reader) {
+ switch (reader.wordSize) {
+ case 4:
+ return _readElfWord(reader);
+ case 8:
+ return _readElfXword(reader);
+ default:
+ throw "Unsupported word size ${reader.wordSize}";
+ }
+}
+
+class ElfHeader {
+ final Reader startingReader;
+
+ int wordSize;
+ Endian endian;
+ int entry;
+ int flags;
+ int headerSize;
+ int programHeaderOffset;
+ int sectionHeaderOffset;
+ int programHeaderCount;
+ int sectionHeaderCount;
+ int programHeaderEntrySize;
+ int sectionHeaderEntrySize;
+ int sectionHeaderStringsIndex;
+
+ int get programHeaderSize => programHeaderCount * programHeaderEntrySize;
+ int get sectionHeaderSize => sectionHeaderCount * sectionHeaderEntrySize;
+
+ // Constants used within the ELF specification.
+ static const _ELFMAG = "\x7fELF";
+ static const _ELFCLASS32 = 0x01;
+ static const _ELFCLASS64 = 0x02;
+ static const _ELFDATA2LSB = 0x01;
+ static const _ELFDATA2MSB = 0x02;
+
+ ElfHeader.fromReader(Reader this.startingReader) {
+ _read();
+ }
+
+ static bool startsWithMagicNumber(Reader reader) {
+ reader.reset();
+ for (final sigByte in _ELFMAG.codeUnits) {
+ if (reader.readByte() != sigByte) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ int _readWordSize(Reader reader) {
+ switch (reader.readByte()) {
+ case _ELFCLASS32:
+ return 4;
+ case _ELFCLASS64:
+ return 8;
+ default:
+ throw FormatException("Unexpected e_ident[EI_CLASS] value");
+ }
+ }
+
+ int get calculatedHeaderSize => 0x18 + 3 * wordSize + 0x10;
+
+ Endian _readEndian(Reader reader) {
+ switch (reader.readByte()) {
+ case _ELFDATA2LSB:
+ return Endian.little;
+ case _ELFDATA2MSB:
+ return Endian.big;
+ default:
+ throw FormatException("Unexpected e_indent[EI_DATA] value");
+ }
+ }
+
+ void _read() {
+ startingReader.reset();
+ for (final sigByte in _ELFMAG.codeUnits) {
+ if (startingReader.readByte() != sigByte) {
+ throw FormatException("Not an ELF file");
+ }
+ }
+ wordSize = _readWordSize(startingReader);
+ final fileSize = startingReader.bdata.buffer.lengthInBytes;
+ if (fileSize < calculatedHeaderSize) {
+ throw FormatException("ELF file too small for header: "
+ "file size ${fileSize} < "
+ "calculated header size $calculatedHeaderSize");
+ }
+ endian = _readEndian(startingReader);
+ if (startingReader.readByte() != 0x01) {
+ throw FormatException("Unexpected e_ident[EI_VERSION] value");
+ }
+
+ // After this point, we need the reader to be correctly set up re: word
+ // size and endianness, since we start reading more than single bytes.
+ final reader = Reader.fromTypedData(startingReader.bdata,
+ wordSize: wordSize, endian: endian);
+ reader.seek(startingReader.offset);
+
+ // Skip rest of e_ident/e_type/e_machine, i.e. move to e_version.
+ reader.seek(0x14, absolute: true);
+ if (_readElfWord(reader) != 0x01) {
+ throw FormatException("Unexpected e_version value");
+ }
+
+ entry = _readElfAddress(reader);
+ programHeaderOffset = _readElfOffset(reader);
+ sectionHeaderOffset = _readElfOffset(reader);
+ flags = _readElfWord(reader);
+ headerSize = _readElfHalf(reader);
+ programHeaderEntrySize = _readElfHalf(reader);
+ programHeaderCount = _readElfHalf(reader);
+ sectionHeaderEntrySize = _readElfHalf(reader);
+ sectionHeaderCount = _readElfHalf(reader);
+ sectionHeaderStringsIndex = _readElfHalf(reader);
+
+ if (headerSize != calculatedHeaderSize) {
+ throw FormatException("Stored ELF header size ${headerSize} != "
+ "calculated ELF header size $calculatedHeaderSize");
+ }
+ if (fileSize < programHeaderOffset) {
+ throw FormatException("File is truncated before program header");
+ }
+ if (fileSize < programHeaderOffset + programHeaderSize) {
+ throw FormatException("File is truncated within the program header");
+ }
+ if (fileSize < sectionHeaderOffset) {
+ throw FormatException("File is truncated before section header");
+ }
+ if (fileSize < sectionHeaderOffset + sectionHeaderSize) {
+ throw FormatException("File is truncated within the section header");
+ }
+ }
+
+ String toString() {
+ var ret = "Format is ${wordSize * 8} bits\n";
+ switch (endian) {
+ case Endian.little:
+ ret += "Little-endian format\n";
+ break;
+ case Endian.big:
+ ret += "Big-endian format\n";
+ break;
+ }
+ ret += "Entry point: 0x${paddedHex(entry, wordSize)}\n"
+ "Flags: 0x${paddedHex(flags, 4)}\n"
+ "Header size: ${headerSize}\n"
+ "Program header offset: "
+ "0x${paddedHex(programHeaderOffset, wordSize)}\n"
+ "Program header entry size: ${programHeaderEntrySize}\n"
+ "Program header entry count: ${programHeaderCount}\n"
+ "Section header offset: "
+ "0x${paddedHex(sectionHeaderOffset, wordSize)}\n"
+ "Section header entry size: ${sectionHeaderEntrySize}\n"
+ "Section header entry count: ${sectionHeaderCount}\n"
+ "Section header strings index: ${sectionHeaderStringsIndex}\n";
+ return ret;
+ }
+}
+
+class ProgramHeaderEntry {
+ Reader reader;
+
+ int type;
+ int flags;
+ int offset;
+ int vaddr;
+ int paddr;
+ int filesz;
+ int memsz;
+ int align;
+
+ // p_type constants from ELF specification.
+ static const _PT_NULL = 0;
+ static const _PT_LOAD = 1;
+ static const _PT_DYNAMIC = 2;
+ static const _PT_PHDR = 6;
+
+ ProgramHeaderEntry.fromReader(Reader this.reader) {
+ assert(reader.wordSize == 4 || reader.wordSize == 8);
+ _read();
+ }
+
+ void _read() {
+ reader.reset();
+ type = _readElfWord(reader);
+ if (reader.wordSize == 8) {
+ flags = _readElfWord(reader);
+ }
+ offset = _readElfOffset(reader);
+ vaddr = _readElfAddress(reader);
+ paddr = _readElfAddress(reader);
+ filesz = _readElfNative(reader);
+ memsz = _readElfNative(reader);
+ if (reader.wordSize == 4) {
+ flags = _readElfWord(reader);
+ }
+ align = _readElfNative(reader);
+ }
+
+ static const _typeStrings = <int, String>{
+ _PT_NULL: "PT_NULL",
+ _PT_LOAD: "PT_LOAD",
+ _PT_DYNAMIC: "PT_DYNAMIC",
+ _PT_PHDR: "PT_PHDR",
+ };
+
+ static String _typeToString(int type) {
+ if (_typeStrings.containsKey(type)) {
+ return _typeStrings[type];
+ }
+ return "unknown (${paddedHex(type, 4)})";
+ }
+
+ String toString() => "Type: ${_typeToString(type)}\n"
+ "Flags: 0x${paddedHex(flags, 4)}\n"
+ "Offset: $offset (0x${paddedHex(offset, reader.wordSize)})\n"
+ "Virtual address: 0x${paddedHex(vaddr, reader.wordSize)}\n"
+ "Physical address: 0x${paddedHex(paddr, reader.wordSize)}\n"
+ "Size in file: $filesz\n"
+ "Size in memory: $memsz\n"
+ "Alignment: 0x${paddedHex(align, reader.wordSize)}\n";
+}
+
+class ProgramHeader {
+ final Reader reader;
+ final int entrySize;
+ final int entryCount;
+
+ List<ProgramHeaderEntry> _entries;
+
+ ProgramHeader.fromReader(Reader this.reader,
+ {int this.entrySize, int this.entryCount}) {
+ _read();
+ }
+
+ int get length => _entries.length;
+ ProgramHeaderEntry operator [](int index) => _entries[index];
+
+ void _read() {
+ reader.reset();
+ _entries = <ProgramHeaderEntry>[];
+ for (var i = 0; i < entryCount; i++) {
+ final entry = ProgramHeaderEntry.fromReader(
+ reader.shrink(i * entrySize, entrySize));
+ _entries.add(entry);
+ }
+ }
+
+ String toString() {
+ var ret = "";
+ for (var i = 0; i < length; i++) {
+ ret += "Entry $i:\n${this[i]}\n";
+ }
+ return ret;
+ }
+}
+
+class SectionHeaderEntry {
+ final Reader reader;
+
+ int nameIndex;
+ String name;
+ int type;
+ int flags;
+ int addr;
+ int offset;
+ int size;
+ int link;
+ int info;
+ int addrAlign;
+ int entrySize;
+
+ SectionHeaderEntry.fromReader(this.reader) {
+ _read();
+ }
+
+ // sh_type constants from ELF specification.
+ static const _SHT_NULL = 0;
+ static const _SHT_PROGBITS = 1;
+ static const _SHT_SYMTAB = 2;
+ static const _SHT_STRTAB = 3;
+ static const _SHT_HASH = 5;
+ static const _SHT_DYNAMIC = 6;
+ static const _SHT_NOBITS = 8;
+ static const _SHT_DYNSYM = 11;
+
+ void _read() {
+ reader.reset();
+ nameIndex = _readElfWord(reader);
+ type = _readElfWord(reader);
+ flags = _readElfNative(reader);
+ addr = _readElfAddress(reader);
+ offset = _readElfOffset(reader);
+ size = _readElfNative(reader);
+ link = _readElfWord(reader);
+ info = _readElfWord(reader);
+ addrAlign = _readElfNative(reader);
+ entrySize = _readElfNative(reader);
+ }
+
+ void setName(StringTable nameTable) {
+ name = nameTable[nameIndex];
+ }
+
+ static const _typeStrings = <int, String>{
+ _SHT_NULL: "SHT_NULL",
+ _SHT_PROGBITS: "SHT_PROGBITS",
+ _SHT_SYMTAB: "SHT_SYMTAB",
+ _SHT_STRTAB: "SHT_STRTAB",
+ _SHT_HASH: "SHT_HASH",
+ _SHT_DYNAMIC: "SHT_DYNAMIC",
+ _SHT_NOBITS: "SHT_NOBITS",
+ _SHT_DYNSYM: "SHT_DYNSYM",
+ };
+
+ static String _typeToString(int type) {
+ if (_typeStrings.containsKey(type)) {
+ return _typeStrings[type];
+ }
+ return "unknown (${paddedHex(type, 4)})";
+ }
+
+ String toString() => "Name: ${name} (@ ${nameIndex})\n"
+ "Type: ${_typeToString(type)}\n"
+ "Flags: 0x${paddedHex(flags, reader.wordSize)}\n"
+ "Address: 0x${paddedHex(addr, reader.wordSize)}\n"
+ "Offset: $offset (0x${paddedHex(offset, reader.wordSize)})\n"
+ "Size: $size\n"
+ "Link: $link\n"
+ "Info: 0x${paddedHex(info, 4)}\n"
+ "Address alignment: 0x${paddedHex(addrAlign, reader.wordSize)}\n"
+ "Entry size: ${entrySize}\n";
+}
+
+class SectionHeader {
+ final Reader reader;
+ final int entrySize;
+ final int entryCount;
+ final int stringsIndex;
+
+ List<SectionHeaderEntry> _entries;
+ StringTable nameTable = null;
+
+ SectionHeader.fromReader(this.reader,
+ {this.entrySize, this.entryCount, this.stringsIndex}) {
+ _read();
+ }
+
+ SectionHeaderEntry _readSectionHeaderEntry(int index) {
+ final ret = SectionHeaderEntry.fromReader(
+ reader.shrink(index * entrySize, entrySize));
+ if (nameTable != null) {
+ ret.setName(nameTable);
+ }
+ return ret;
+ }
+
+ void _read() {
+ reader.reset();
+ // Set up the section header string table first so we can use it
+ // for the other section header entries.
+ final nameTableEntry = _readSectionHeaderEntry(stringsIndex);
+ assert(nameTableEntry.type == SectionHeaderEntry._SHT_STRTAB);
+ nameTable = StringTable.fromReader(
+ reader.refocus(nameTableEntry.offset, nameTableEntry.size));
+ nameTableEntry.setName(nameTable);
+
+ _entries = <SectionHeaderEntry>[];
+ for (var i = 0; i < entryCount; i++) {
+ // We don't need to reparse the shstrtab entry.
+ if (i == stringsIndex) {
+ _entries.add(nameTableEntry);
+ } else {
+ _entries.add(_readSectionHeaderEntry(i));
+ }
+ }
+ }
+
+ int get length => _entries.length;
+ SectionHeaderEntry operator [](int index) => _entries[index];
+
+ String toString() {
+ var ret = "";
+ for (var i = 0; i < length; i++) {
+ ret += "Entry $i:\n${this[i]}\n";
+ }
+ return ret;
+ }
+}
+
+class Section {
+ final Reader reader;
+
+ Section.fromReader(Reader this.reader);
+
+ factory Section.fromEntryAndReader(SectionHeaderEntry entry, Reader reader) {
+ switch (entry.type) {
+ case SectionHeaderEntry._SHT_NULL:
+ return NullSection.fromReader(reader.refocus(entry.offset, 0));
+ case SectionHeaderEntry._SHT_NOBITS:
+ return NoBits.fromReader(reader.refocus(entry.offset, 0));
+ case SectionHeaderEntry._SHT_STRTAB:
+ return StringTable.fromReader(reader.refocus(entry.offset, entry.size));
+ default:
+ return Section.fromReader(reader.refocus(entry.offset, entry.size));
+ }
+ }
+
+ int get length => reader.bdata.lengthInBytes;
+ String toString() => "an unparsed section of ${length} bytes\n";
+}
+
+class NullSection extends Section {
+ NullSection.fromReader(Reader reader) : super.fromReader(reader);
+
+ String toString() => "a null section\n";
+}
+
+class NoBits extends Section {
+ NoBits.fromReader(Reader reader) : super.fromReader(reader);
+
+ String toString() => "a section with no bits in file\n";
+}
+
+class StringTable extends Section {
+ final _entries = Map<int, String>();
+
+ StringTable.fromReader(Reader reader) : super.fromReader(reader) {
+ while (!reader.done) {
+ _entries[reader.offset] = reader.readNullTerminatedString();
+ }
+ }
+
+ String operator [](int index) => _entries[index];
+
+ String toString() => _entries.keys.fold("a string table:\n",
+ (String acc, int key) => acc + " $key => ${_entries[key]}\n");
+}
+
+class Elf {
+ final Reader startingReader;
+
+ ElfHeader header;
+ ProgramHeader programHeader;
+ SectionHeader sectionHeader;
+
+ Map<SectionHeaderEntry, Section> sections;
+
+ Elf.fromReader(this.startingReader) {
+ _read();
+ }
+ Elf.fromFile(String filename)
+ : this.fromReader(Reader.fromTypedData(File(filename).readAsBytesSync(),
+ // We provide null for the wordSize and endianness to ensure
+ // we don't accidentally call any methods that use them until
+ // we have gotten that information from the ELF header.
+ wordSize: null,
+ endian: null));
+
+ static bool startsWithMagicNumber(String filename) {
+ final file = File(filename).openSync();
+ var ret = true;
+ for (int code in ElfHeader._ELFMAG.codeUnits) {
+ if (file.readByteSync() != code) {
+ ret = false;
+ break;
+ }
+ }
+ file.closeSync();
+ return ret;
+ }
+
+ Section namedSection(String name) {
+ for (var entry in sections.keys) {
+ if (entry.name == name) {
+ return sections[entry];
+ }
+ }
+ throw FormatException("No section named $name found in ELF file");
+ }
+
+ void _read() {
+ startingReader.reset();
+ header = ElfHeader.fromReader(startingReader.copy());
+ // Now use the word size and endianness information from the header.
+ final reader = Reader.fromTypedData(startingReader.bdata,
+ wordSize: header.wordSize, endian: header.endian);
+ programHeader = ProgramHeader.fromReader(
+ reader.refocus(header.programHeaderOffset, header.programHeaderSize),
+ entrySize: header.programHeaderEntrySize,
+ entryCount: header.programHeaderCount);
+ sectionHeader = SectionHeader.fromReader(
+ reader.refocus(header.sectionHeaderOffset, header.sectionHeaderSize),
+ entrySize: header.sectionHeaderEntrySize,
+ entryCount: header.sectionHeaderCount,
+ stringsIndex: header.sectionHeaderStringsIndex);
+ sections = <SectionHeaderEntry, Section>{};
+ for (var i = 0; i < sectionHeader.length; i++) {
+ final entry = sectionHeader[i];
+ if (i == header.sectionHeaderStringsIndex) {
+ sections[entry] = sectionHeader.nameTable;
+ } else {
+ sections[entry] = Section.fromEntryAndReader(entry, reader.copy());
+ }
+ }
+ }
+
+ String toString() {
+ String accumulateSection(String acc, SectionHeaderEntry entry) =>
+ acc + "\nSection ${entry.name} is ${sections[entry]}";
+ return "Header information:\n\n${header}"
+ "\nProgram header information:\n\n${programHeader}"
+ "\nSection header information:\n\n${sectionHeader}"
+ "${sections.keys.fold("", accumulateSection)}";
+ }
+}
diff --git a/pkg/vm/lib/elf/reader.dart b/pkg/vm/lib/elf/reader.dart
new file mode 100644
index 0000000..c950ef5
--- /dev/null
+++ b/pkg/vm/lib/elf/reader.dart
@@ -0,0 +1,147 @@
+// Copyright (c) 2019, 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.
+
+library vm.elf.reader;
+
+import 'dart:typed_data';
+import 'dart:math';
+
+String paddedHex(int value, [int bytes = 0]) {
+ return value.toRadixString(16).padLeft(2 * bytes, '0');
+}
+
+class Reader {
+ final ByteData bdata;
+ final Endian endian;
+ final int wordSize;
+
+ int _offset = 0;
+
+ Reader.fromTypedData(TypedData data, {int this.wordSize, Endian this.endian})
+ : bdata =
+ ByteData.view(data.buffer, data.offsetInBytes, data.lengthInBytes);
+
+ Reader copy() =>
+ Reader.fromTypedData(bdata, wordSize: wordSize, endian: endian);
+
+ Reader shrink(int offset, [int size = -1]) {
+ if (size < 0) size = bdata.lengthInBytes - offset;
+ assert(offset >= 0 && offset < bdata.lengthInBytes);
+ assert(size >= 0 && (offset + size) <= bdata.lengthInBytes);
+ return Reader.fromTypedData(
+ ByteData.view(bdata.buffer, bdata.offsetInBytes + offset, size),
+ wordSize: wordSize,
+ endian: endian);
+ }
+
+ Reader refocus(int pos, [int size = -1]) {
+ if (size < 0) size = bdata.lengthInBytes - pos;
+ assert(pos >= 0 && pos < bdata.buffer.lengthInBytes);
+ assert(size >= 0 && (pos + size) <= bdata.buffer.lengthInBytes);
+ return Reader.fromTypedData(ByteData.view(bdata.buffer, pos, size),
+ wordSize: wordSize, endian: endian);
+ }
+
+ int get start => bdata.offsetInBytes;
+ int get offset => _offset;
+ int get length => bdata.lengthInBytes;
+ bool get done => _offset >= length;
+
+ void seek(int offset, {bool absolute = false}) {
+ final newOffset = (absolute ? 0 : _offset) + offset;
+ assert(newOffset >= 0 && newOffset < bdata.lengthInBytes);
+ _offset = newOffset;
+ }
+
+ void reset() {
+ seek(0, absolute: true);
+ }
+
+ int readBytes(int size, {bool signed = false}) {
+ assert(_offset + size < length);
+ int ret;
+ switch (size) {
+ case 1:
+ ret = signed ? bdata.getInt8(_offset) : bdata.getUint8(_offset);
+ break;
+ case 2:
+ ret = signed
+ ? bdata.getInt16(_offset, endian)
+ : bdata.getUint16(_offset, endian);
+ break;
+ case 4:
+ ret = signed
+ ? bdata.getInt32(_offset, endian)
+ : bdata.getUint32(_offset, endian);
+ break;
+ case 8:
+ ret = signed
+ ? bdata.getInt64(_offset, endian)
+ : bdata.getUint64(_offset, endian);
+ break;
+ default:
+ throw ArgumentError("invalid request to read $size bytes");
+ }
+ _offset += size;
+ return ret;
+ }
+
+ int readByte({bool signed = false}) => readBytes(1, signed: signed);
+ int readWord() => readBytes(wordSize);
+ String readNullTerminatedString() {
+ final start = bdata.offsetInBytes + _offset;
+ for (int i = 0; _offset + i < bdata.lengthInBytes; i++) {
+ if (bdata.getUint8(_offset + i) == 0) {
+ _offset += i + 1;
+ return String.fromCharCodes(bdata.buffer.asUint8List(start, i));
+ }
+ }
+ return String.fromCharCodes(
+ bdata.buffer.asUint8List(start, bdata.lengthInBytes - _offset));
+ }
+
+ int readLEB128EncodedInteger({bool signed = false}) {
+ var ret = 0;
+ var shift = 0;
+ for (var byte = readByte(); !done; byte = readByte()) {
+ ret |= (byte & 0x7f) << shift;
+ shift += 7;
+ if (byte & 0x80 == 0) {
+ if (signed && byte & 0x40 != 0) {
+ ret |= -(1 << shift);
+ }
+ break;
+ }
+ }
+ return ret;
+ }
+
+ String dumpCurrentReaderPosition({int maxSize = 0, int bytesPerLine = 16}) {
+ var baseData = ByteData.view(bdata.buffer, 0, bdata.buffer.lengthInBytes);
+ var startOffset = 0;
+ var endOffset = baseData.lengthInBytes;
+ final currentOffset = start + _offset;
+ if (maxSize != 0 && maxSize < baseData.lengthInBytes) {
+ var lowerWindow = currentOffset - (maxSize >> 1);
+ // Adjust so that we always start at the beginning of a line.
+ lowerWindow -= lowerWindow % bytesPerLine;
+ final upperWindow = lowerWindow + maxSize;
+ startOffset = max(startOffset, lowerWindow);
+ endOffset = min(endOffset, upperWindow);
+ }
+ var ret = "";
+ for (int i = startOffset; i < endOffset; i += bytesPerLine) {
+ ret += "0x" + paddedHex(i, 8) + " ";
+ for (int j = 0; j < bytesPerLine && i + j < endOffset; j++) {
+ var byte = baseData.getUint8(i + j);
+ ret += (i + j == currentOffset) ? "|" : " ";
+ ret += paddedHex(byte, 1);
+ }
+ ret += "\n";
+ }
+ return ret;
+ }
+
+ String toString() => dumpCurrentReaderPosition();
+}
diff --git a/pkg/vm/lib/metadata/inferred_type.dart b/pkg/vm/lib/metadata/inferred_type.dart
index 432f693..00b5947 100644
--- a/pkg/vm/lib/metadata/inferred_type.dart
+++ b/pkg/vm/lib/metadata/inferred_type.dart
@@ -9,6 +9,7 @@
/// Metadata for annotating nodes with an inferred type information.
class InferredType {
final Reference _concreteClassReference;
+ final Constant _constantValue;
final int _flags;
static const int flagNullable = 1 << 0;
@@ -17,6 +18,8 @@
// For invocations: whether to use the unchecked entry-point.
static const int flagSkipCheck = 1 << 2;
+ static const int flagConstant = 1 << 3;
+
// Entire list may be null if no type arguments were inferred.
// Will always be null if `concreteClass` is null.
//
@@ -27,22 +30,28 @@
// argument (in the runtime type) is always exactly a particular `DartType`.
final List<DartType> exactTypeArguments;
- InferredType(Class concreteClass, bool nullable, bool isInt,
+ InferredType(
+ Class concreteClass, bool nullable, bool isInt, Constant constantValue,
{List<DartType> exactTypeArguments, bool skipCheck: false})
: this._byReference(
getClassReference(concreteClass),
+ constantValue,
(nullable ? flagNullable : 0) |
(isInt ? flagInt : 0) |
- (skipCheck ? flagSkipCheck : 0),
+ (skipCheck ? flagSkipCheck : 0) |
+ (constantValue != null ? flagConstant : 0),
exactTypeArguments);
- InferredType._byReference(
- this._concreteClassReference, this._flags, this.exactTypeArguments) {
+ InferredType._byReference(this._concreteClassReference, this._constantValue,
+ this._flags, this.exactTypeArguments) {
assert(exactTypeArguments == null || _concreteClassReference != null);
+ assert(_constantValue == null || _concreteClassReference != null);
}
Class get concreteClass => _concreteClassReference?.asClass;
+ Constant get constantValue => _constantValue;
+
bool get nullable => (_flags & flagNullable) != 0;
bool get isInt => (_flags & flagInt) != 0;
bool get skipCheck => (_flags & flagSkipCheck) != 0;
@@ -51,17 +60,30 @@
@override
String toString() {
- final base =
- "${concreteClass != null ? concreteClass : (isInt ? 'int' : '!')}";
- final suffix = "${nullable ? '?' : ''}";
- String typeArgs = "";
- if (exactTypeArguments != null) {
- typeArgs =
- exactTypeArguments.map((t) => t != null ? "$t" : "?").join(", ");
- typeArgs = "<" + typeArgs + ">";
+ final StringBuffer buf = new StringBuffer();
+ if (concreteClass != null) {
+ buf.write(concreteClass);
+ } else if (isInt) {
+ buf.write('int');
+ } else {
+ buf.write('!');
}
- final skip = skipCheck ? " (skip check)" : "";
- return base + suffix + typeArgs + skip;
+ if (nullable) {
+ buf.write('?');
+ }
+ if (exactTypeArguments != null) {
+ buf.write('<');
+ buf.write(
+ exactTypeArguments.map((t) => t != null ? "$t" : "?").join(", "));
+ buf.write('>');
+ }
+ if (skipCheck) {
+ buf.write(' (skip check)');
+ }
+ if (_constantValue != null) {
+ buf.write(' (value: $_constantValue)');
+ }
+ return buf.toString();
}
}
@@ -82,6 +104,9 @@
sink.writeNullAllowedCanonicalNameReference(
getCanonicalNameOfClass(metadata.concreteClass));
sink.writeByte(metadata._flags);
+ if (metadata.constantValue != null) {
+ sink.writeConstantReference(metadata.constantValue);
+ }
}
@override
@@ -91,6 +116,10 @@
final concreteClassReference =
source.readCanonicalNameReference()?.getReference();
final flags = source.readByte();
- return new InferredType._byReference(concreteClassReference, flags, null);
+ final constantValue = (flags & InferredType.flagConstant) != 0
+ ? source.readConstantReference()
+ : null;
+ return new InferredType._byReference(
+ concreteClassReference, constantValue, flags, null);
}
}
diff --git a/pkg/vm/lib/target/vm.dart b/pkg/vm/lib/target/vm.dart
index bd70be0..567101f 100644
--- a/pkg/vm/lib/target/vm.dart
+++ b/pkg/vm/lib/target/vm.dart
@@ -41,6 +41,7 @@
Class _oneByteString;
Class _twoByteString;
Class _smi;
+ Class _double; // _Double, not double.
VmTarget(this.flags);
@@ -424,6 +425,11 @@
}
@override
+ Class concreteDoubleLiteralClass(CoreTypes coreTypes, double value) {
+ return _double ??= coreTypes.index.getClass('dart:core', '_Double');
+ }
+
+ @override
Class concreteStringLiteralClass(CoreTypes coreTypes, String value) {
const int maxLatin1 = 0xff;
for (int i = 0; i < value.length; ++i) {
diff --git a/pkg/vm/lib/transformations/ffi_definitions.dart b/pkg/vm/lib/transformations/ffi_definitions.dart
index e7da53d..2bc59e5 100644
--- a/pkg/vm/lib/transformations/ffi_definitions.dart
+++ b/pkg/vm/lib/transformations/ffi_definitions.dart
@@ -175,8 +175,8 @@
!env.isSubtypeOf(dartType, shouldBeDartType,
SubtypeCheckMode.ignoringNullabilities)) {
diagnosticReporter.report(
- templateFfiTypeMismatch.withArguments(
- dartType, shouldBeDartType, nativeType),
+ templateFfiTypeMismatch.withArguments(dartType, shouldBeDartType,
+ nativeType, node.enclosingLibrary.isNonNullableByDefault),
f.fileOffset,
1,
f.location.file);
diff --git a/pkg/vm/lib/transformations/ffi_use_sites.dart b/pkg/vm/lib/transformations/ffi_use_sites.dart
index 5568750..ad0d3fd 100644
--- a/pkg/vm/lib/transformations/ffi_use_sites.dart
+++ b/pkg/vm/lib/transformations/ffi_use_sites.dart
@@ -169,8 +169,8 @@
expectedReturn == NativeType.kPointer) {
if (node.arguments.positional.length > 1) {
diagnosticReporter.report(
- templateFfiExpectedNoExceptionalReturn
- .withArguments(funcType.returnType),
+ templateFfiExpectedNoExceptionalReturn.withArguments(
+ funcType.returnType, currentLibrary.isNonNullableByDefault),
node.fileOffset,
1,
node.location.file);
@@ -182,8 +182,8 @@
// types.
if (node.arguments.positional.length < 2) {
diagnosticReporter.report(
- templateFfiExpectedExceptionalReturn
- .withArguments(funcType.returnType),
+ templateFfiExpectedExceptionalReturn.withArguments(
+ funcType.returnType, currentLibrary.isNonNullableByDefault),
node.fileOffset,
1,
node.location.file);
@@ -217,8 +217,8 @@
if (!env.isSubtypeOf(returnType, funcType.returnType,
SubtypeCheckMode.ignoringNullabilities)) {
diagnosticReporter.report(
- templateFfiDartTypeMismatch.withArguments(
- returnType, funcType.returnType),
+ templateFfiDartTypeMismatch.withArguments(returnType,
+ funcType.returnType, currentLibrary.isNonNullableByDefault),
exceptionalReturn.fileOffset,
1,
exceptionalReturn.location.file);
@@ -382,8 +382,8 @@
return;
}
diagnosticReporter.report(
- templateFfiTypeMismatch.withArguments(
- dartType, correspondingDartType, nativeType),
+ templateFfiTypeMismatch.withArguments(dartType, correspondingDartType,
+ nativeType, currentLibrary.isNonNullableByDefault),
node.fileOffset,
1,
node.location.file);
@@ -394,7 +394,8 @@
{bool allowStructs: false}) {
if (!_nativeTypeValid(nativeType, allowStructs: allowStructs)) {
diagnosticReporter.report(
- templateFfiTypeInvalid.withArguments(nativeType),
+ templateFfiTypeInvalid.withArguments(
+ nativeType, currentLibrary.isNonNullableByDefault),
node.fileOffset,
1,
node.location.file);
diff --git a/pkg/vm/lib/transformations/late_var_init_transformer.dart b/pkg/vm/lib/transformations/late_var_init_transformer.dart
index 2e916d0..7187f25 100644
--- a/pkg/vm/lib/transformations/late_var_init_transformer.dart
+++ b/pkg/vm/lib/transformations/late_var_init_transformer.dart
@@ -13,30 +13,32 @@
class _LateVarInitTransformer extends Transformer {
const _LateVarInitTransformer();
- bool _shouldApplyTransform(VariableDeclaration v) {
- // This transform only applies to late variables.
- if (!v.isLate) return false;
+ bool _shouldApplyTransform(Statement s) {
+ if (s is VariableDeclaration) {
+ // This transform only applies to late variables.
+ if (!s.isLate) return false;
- // Const variables are ignored.
- if (v.isConst) return false;
+ // Const variables are ignored.
+ if (s.isConst) return false;
- // Variables with no initializer or a trivial initializer are ignored.
- if (v.initializer == null) return false;
- final Expression init = v.initializer;
- if (init is StringLiteral) return false;
- if (init is BoolLiteral) return false;
- if (init is IntLiteral) return false;
- if (init is DoubleLiteral) return false;
- if (init is NullLiteral) return false;
- if (init is ConstantExpression && init.constant is PrimitiveConstant) {
- return false;
+ // Variables with no initializer or a trivial initializer are ignored.
+ if (s.initializer == null) return false;
+ final Expression init = s.initializer;
+ if (init is StringLiteral) return false;
+ if (init is BoolLiteral) return false;
+ if (init is IntLiteral) return false;
+ if (init is DoubleLiteral) return false;
+ if (init is NullLiteral) return false;
+ if (init is ConstantExpression && init.constant is PrimitiveConstant) {
+ return false;
+ }
+
+ return true;
}
-
- return true;
+ return false;
}
- List<Statement> _transformVariableDeclaration(
- TreeNode parent, VariableDeclaration node) {
+ List<Statement> _transformVariableDeclaration(VariableDeclaration node) {
super.visitVariableDeclaration(node);
final fnNode =
@@ -44,8 +46,7 @@
final fn = FunctionDeclaration(
VariableDeclaration("#${node.name}#initializer",
type: fnNode.thisFunctionType),
- fnNode)
- ..parent = parent;
+ fnNode);
node.initializer =
MethodInvocation(VariableGet(fn.variable), Name("call"), Arguments([]))
..parent = node;
@@ -53,33 +54,32 @@
return [fn, node];
}
- void _transformStatements(TreeNode parent, List<Statement> statements) {
- List<Statement> oldStatements = statements;
- for (var i = 0; i < oldStatements.length; ++i) {
- Statement s = oldStatements[i];
- if (s is VariableDeclaration && _shouldApplyTransform(s)) {
- if (oldStatements == statements) {
- oldStatements = List<Statement>.of(statements);
- statements.clear();
- }
- statements.addAll(_transformVariableDeclaration(parent, s));
- } else if (oldStatements != statements) {
- statements.add(s.accept<TreeNode>(this)..parent = parent);
+ List<Statement> _transformStatements(List<Statement> statements) {
+ if (!statements.any((s) => _shouldApplyTransform(s))) return null;
+ final List<Statement> newStatements = List<Statement>();
+ for (Statement s in statements) {
+ if (_shouldApplyTransform(s)) {
+ newStatements.addAll(_transformVariableDeclaration(s));
} else {
- statements[i] = s.accept<TreeNode>(this)..parent = parent;
+ newStatements.add(s);
}
}
+ return newStatements;
}
@override
visitBlock(Block node) {
- _transformStatements(node, node.statements);
- return node;
+ super.visitBlock(node);
+ final statements = _transformStatements(node.statements);
+ if (statements == null) return node;
+ return Block(statements)..fileOffset = node.fileOffset;
}
@override
visitAssertBlock(AssertBlock node) {
- _transformStatements(node, node.statements);
- return node;
+ super.visitAssertBlock(node);
+ final statements = _transformStatements(node.statements);
+ if (statements == null) return node;
+ return AssertBlock(statements)..fileOffset = node.fileOffset;
}
}
diff --git a/pkg/vm/lib/transformations/type_flow/summary_collector.dart b/pkg/vm/lib/transformations/type_flow/summary_collector.dart
index 3385c08..ae0d2a9 100644
--- a/pkg/vm/lib/transformations/type_flow/summary_collector.dart
+++ b/pkg/vm/lib/transformations/type_flow/summary_collector.dart
@@ -620,8 +620,12 @@
if (initializer is ConstantExpression) {
param.defaultValue =
constantAllocationCollector.typeFor(initializer.constant);
+ } else if (initializer is BasicLiteral ||
+ initializer is SymbolLiteral ||
+ initializer is TypeLiteral) {
+ param.defaultValue = _visit(initializer);
} else {
- param.defaultValue = _staticType(initializer);
+ throw 'Unexpected parameter $name default value ${initializer.runtimeType} $initializer';
}
} else {
param.defaultValue = _nullType;
@@ -707,9 +711,17 @@
Type _staticType(Expression node) =>
_typesBuilder.fromStaticType(_staticDartType(node), true);
- Type _cachedBoolType;
- Type get _boolType => _cachedBoolType ??=
- new ConeType(_typesBuilder.getTFClass(_environment.coreTypes.boolClass));
+ ConcreteType _cachedBoolType;
+ ConcreteType get _boolType => _cachedBoolType ??=
+ _entryPointsListener.addAllocatedClass(_environment.coreTypes.boolClass);
+
+ ConcreteType _cachedBoolTrue;
+ ConcreteType get _boolTrue => _cachedBoolTrue ??=
+ new ConcreteType(_boolType.cls, null, BoolConstant(true));
+
+ ConcreteType _cachedBoolFalse;
+ ConcreteType get _boolFalse => _cachedBoolFalse ??=
+ new ConcreteType(_boolType.cls, null, BoolConstant(false));
Type _cachedDoubleType;
Type get _doubleType => _cachedDoubleType ??= new ConeType(
@@ -737,20 +749,45 @@
Class get _superclass => _staticTypeContext.thisType.classNode.superclass;
- Type _intLiteralType(int value) {
- Class concreteClass =
+ Type _boolLiteralType(bool value) => value ? _boolTrue : _boolFalse;
+
+ Type _intLiteralType(int value, Constant constant) {
+ final Class concreteClass =
target.concreteIntLiteralClass(_environment.coreTypes, value);
- return concreteClass != null
- ? _entryPointsListener.addAllocatedClass(concreteClass)
- : _intType;
+ if (concreteClass != null) {
+ constant ??= IntConstant(value);
+ return new ConcreteType(
+ _entryPointsListener.addAllocatedClass(concreteClass).cls,
+ null,
+ constant);
+ }
+ return _intType;
}
- Type _stringLiteralType(String value) {
- Class concreteClass =
+ Type _doubleLiteralType(double value, Constant constant) {
+ final Class concreteClass =
+ target.concreteDoubleLiteralClass(_environment.coreTypes, value);
+ if (concreteClass != null) {
+ constant ??= DoubleConstant(value);
+ return new ConcreteType(
+ _entryPointsListener.addAllocatedClass(concreteClass).cls,
+ null,
+ constant);
+ }
+ return _doubleType;
+ }
+
+ Type _stringLiteralType(String value, Constant constant) {
+ final Class concreteClass =
target.concreteStringLiteralClass(_environment.coreTypes, value);
- return concreteClass != null
- ? _entryPointsListener.addAllocatedClass(concreteClass)
- : _stringType;
+ if (concreteClass != null) {
+ constant ??= StringConstant(value);
+ return new ConcreteType(
+ _entryPointsListener.addAllocatedClass(concreteClass).cls,
+ null,
+ constant);
+ }
+ return _stringType;
}
void _handleNestedFunctionNode(FunctionNode node) {
@@ -792,17 +829,17 @@
@override
TypeExpr visitBoolLiteral(BoolLiteral node) {
- return _boolType;
+ return _boolLiteralType(node.value);
}
@override
TypeExpr visitIntLiteral(IntLiteral node) {
- return _intLiteralType(node.value);
+ return _intLiteralType(node.value, null);
}
@override
TypeExpr visitDoubleLiteral(DoubleLiteral node) {
- return _doubleType;
+ return _doubleLiteralType(node.value, null);
}
@override
@@ -1174,7 +1211,7 @@
@override
TypeExpr visitStringLiteral(StringLiteral node) {
- return _stringLiteralType(node.value);
+ return _stringLiteralType(node.value, null);
}
@override
@@ -1618,22 +1655,22 @@
@override
Type visitBoolConstant(BoolConstant constant) {
- return summaryCollector._boolType;
+ return summaryCollector._boolLiteralType(constant.value);
}
@override
Type visitIntConstant(IntConstant constant) {
- return summaryCollector._intLiteralType(constant.value);
+ return summaryCollector._intLiteralType(constant.value, constant);
}
@override
Type visitDoubleConstant(DoubleConstant constant) {
- return summaryCollector._doubleType;
+ return summaryCollector._doubleLiteralType(constant.value, constant);
}
@override
Type visitStringConstant(StringConstant constant) {
- return summaryCollector._stringLiteralType(constant.value);
+ return summaryCollector._stringLiteralType(constant.value, constant);
}
@override
@@ -1651,22 +1688,28 @@
for (final Constant entry in constant.entries) {
typeFor(entry);
}
- Class concreteClass = summaryCollector.target
+ final Class concreteClass = summaryCollector.target
.concreteConstListLiteralClass(summaryCollector._environment.coreTypes);
- return concreteClass != null
- ? summaryCollector._entryPointsListener.addAllocatedClass(concreteClass)
- : _getStaticType(constant);
+ if (concreteClass != null) {
+ return new ConcreteType(
+ summaryCollector._entryPointsListener
+ .addAllocatedClass(concreteClass)
+ .cls,
+ null,
+ constant);
+ }
+ return _getStaticType(constant);
}
@override
Type visitInstanceConstant(InstanceConstant constant) {
- final resultType = summaryCollector._entryPointsListener
+ final resultClass = summaryCollector._entryPointsListener
.addAllocatedClass(constant.classNode);
constant.fieldValues.forEach((Reference fieldReference, Constant value) {
summaryCollector._entryPointsListener
.addDirectFieldAccess(fieldReference.asField, typeFor(value));
});
- return resultType;
+ return new ConcreteType(resultClass.cls, null, constant);
}
@override
diff --git a/pkg/vm/lib/transformations/type_flow/transformer.dart b/pkg/vm/lib/transformations/type_flow/transformer.dart
index a6289ea..7e066e18 100644
--- a/pkg/vm/lib/transformations/type_flow/transformer.dart
+++ b/pkg/vm/lib/transformations/type_flow/transformer.dart
@@ -113,6 +113,7 @@
final UnreachableNodeMetadataRepository _unreachableNodeMetadata;
final ProcedureAttributesMetadataRepository _procedureAttributesMetadata;
final Class _intClass;
+ Constant _nullConstant;
AnnotateKernel(Component component, this._typeFlowAnalysis)
: _inferredTypeMetadata = new InferredTypeMetadataRepository(),
@@ -129,6 +130,7 @@
assertx(type != null);
Class concreteClass;
+ Constant constantValue;
bool isInt = false;
final nullable = type is NullableType;
@@ -138,12 +140,17 @@
if (nullable && type == const EmptyType()) {
concreteClass = _typeFlowAnalysis.environment.coreTypes.nullClass;
+ constantValue = _nullConstant ??= new NullConstant();
} else {
concreteClass = type.getConcreteClass(_typeFlowAnalysis.hierarchyCache);
if (concreteClass == null) {
isInt = type.isSubtypeOf(_typeFlowAnalysis.hierarchyCache, _intClass);
}
+
+ if (type is ConcreteType && !nullable) {
+ constantValue = type.constant;
+ }
}
List<DartType> typeArgs;
@@ -154,8 +161,12 @@
.toList();
}
- if ((concreteClass != null) || !nullable || isInt || skipCheck) {
- return new InferredType(concreteClass, nullable, isInt,
+ if (concreteClass != null ||
+ !nullable ||
+ isInt ||
+ constantValue != null ||
+ skipCheck) {
+ return new InferredType(concreteClass, nullable, isInt, constantValue,
exactTypeArguments: typeArgs, skipCheck: skipCheck);
}
diff --git a/pkg/vm/lib/transformations/type_flow/types.dart b/pkg/vm/lib/transformations/type_flow/types.dart
index 35ec3c5..1c737a9 100644
--- a/pkg/vm/lib/transformations/type_flow/types.dart
+++ b/pkg/vm/lib/transformations/type_flow/types.dart
@@ -415,7 +415,10 @@
} else if (id1 > id2) {
++i2;
} else {
- if (t1.typeArgs == null && t2.typeArgs == null) {
+ if (t1.typeArgs == null &&
+ t1.constant == null &&
+ t2.typeArgs == null &&
+ t2.constant == null) {
types.add(t1);
} else {
final intersect = t1.intersection(t2, null);
@@ -600,7 +603,10 @@
final int numImmediateTypeArgs;
final List<Type> typeArgs;
- ConcreteType(this.cls, [List<Type> typeArgs_])
+ // May be null if constant value is not inferred.
+ final Constant constant;
+
+ ConcreteType(this.cls, [List<Type> typeArgs_, this.constant])
: typeArgs = typeArgs_,
numImmediateTypeArgs =
typeArgs_ != null ? cls.classNode.typeParameters.length : 0 {
@@ -689,6 +695,7 @@
for (int i = 0; i < numImmediateTypeArgs; ++i) {
hash = (((hash * 31) & kHashMask) + typeArgs[i].hashCode) & kHashMask;
}
+ hash = ((hash * 31) & kHashMask) + constant.hashCode;
return hash;
}
@@ -707,6 +714,9 @@
}
}
}
+ if (this.constant != other.constant) {
+ return false;
+ }
return true;
} else {
return false;
@@ -719,9 +729,21 @@
int compareTo(ConcreteType other) => cls.id.compareTo(other.cls.id);
@override
- String toString() => typeArgs == null
- ? "_T (${cls})"
- : "_T (${cls}<${typeArgs.take(numImmediateTypeArgs).join(', ')}>)";
+ String toString() {
+ if (typeArgs == null && constant == null) {
+ return "_T (${cls})";
+ }
+ final StringBuffer buf = new StringBuffer();
+ buf.write("_T (${cls}");
+ if (typeArgs != null) {
+ buf.write("<${typeArgs.take(numImmediateTypeArgs).join(', ')}>");
+ }
+ if (constant != null) {
+ buf.write(", $constant");
+ }
+ buf.write(")");
+ return buf.toString();
+ }
@override
int get order => TypeOrder.Concrete.index;
@@ -740,7 +762,10 @@
: <ConcreteType>[other, this];
return new SetType(types);
} else {
- assertx(typeArgs != null || other.typeArgs != null);
+ assertx(typeArgs != null ||
+ constant != null ||
+ other.typeArgs != null ||
+ other.constant != null);
return raw;
}
} else {
@@ -760,27 +785,44 @@
if (!identical(this.cls, other.cls)) {
return EmptyType();
}
- assertx(typeArgs != null || other.typeArgs != null);
- if (typeArgs == null) {
+ if (typeArgs == null && constant == null) {
return other;
- } else if (other.typeArgs == null) {
+ } else if (other.typeArgs == null && other.constant == null) {
return this;
}
- final mergedTypeArgs = new List<Type>(typeArgs.length);
- bool hasRuntimeType = false;
- for (int i = 0; i < typeArgs.length; ++i) {
- final merged =
- typeArgs[i].intersection(other.typeArgs[i], typeHierarchy);
- if (merged is EmptyType) {
- return EmptyType();
- } else if (merged is RuntimeType) {
- hasRuntimeType = true;
+ List<Type> mergedTypeArgs;
+ if (typeArgs == null) {
+ mergedTypeArgs = other.typeArgs;
+ } else if (other.typeArgs == null) {
+ mergedTypeArgs = typeArgs;
+ } else {
+ mergedTypeArgs = new List<Type>(typeArgs.length);
+ bool hasRuntimeType = false;
+ for (int i = 0; i < typeArgs.length; ++i) {
+ final merged =
+ typeArgs[i].intersection(other.typeArgs[i], typeHierarchy);
+ if (merged is EmptyType) {
+ return const EmptyType();
+ } else if (merged is RuntimeType) {
+ hasRuntimeType = true;
+ }
+ mergedTypeArgs[i] = merged;
}
- mergedTypeArgs[i] = merged;
+ if (!hasRuntimeType) {
+ mergedTypeArgs = null;
+ }
}
- if (!hasRuntimeType) return raw;
- return new ConcreteType(cls, mergedTypeArgs);
+
+ Constant mergedConstant;
+ if (constant == null) {
+ mergedConstant = other.constant;
+ } else if (other.constant == null || constant == other.constant) {
+ mergedConstant = constant;
+ } else {
+ return const EmptyType();
+ }
+ return new ConcreteType(cls, mergedTypeArgs, mergedConstant);
} else {
throw 'Unexpected type $other';
}
diff --git a/pkg/vm/test/common_test_utils.dart b/pkg/vm/test/common_test_utils.dart
index aa0001e..afa5e6b 100644
--- a/pkg/vm/test/common_test_utils.dart
+++ b/pkg/vm/test/common_test_utils.dart
@@ -61,8 +61,7 @@
String kernelLibraryToString(Library library) {
final StringBuffer buffer = new StringBuffer();
- new Printer(buffer, showExternal: false, showMetadata: true)
- .writeLibraryFile(library);
+ new Printer(buffer, showMetadata: true).writeLibraryFile(library);
return buffer
.toString()
.replaceAll(library.importUri.toString(), library.name);
@@ -70,8 +69,7 @@
String kernelComponentToString(Component component) {
final StringBuffer buffer = new StringBuffer();
- new Printer(buffer, showExternal: false, showMetadata: true)
- .writeComponentFile(component);
+ new Printer(buffer, showMetadata: true).writeComponentFile(component);
final mainLibrary = component.mainMethod.enclosingLibrary;
return buffer
.toString()
diff --git a/pkg/vm/test/incremental_compiler_test.dart b/pkg/vm/test/incremental_compiler_test.dart
index e699954..eb5f6bf 100644
--- a/pkg/vm/test/incremental_compiler_test.dart
+++ b/pkg/vm/test/incremental_compiler_test.dart
@@ -59,7 +59,7 @@
Component component = await compiler.compile();
final StringBuffer buffer = new StringBuffer();
- new Printer(buffer, showExternal: false, showMetadata: true)
+ new Printer(buffer, showMetadata: true)
.writeLibraryFile(component.mainMethod.enclosingLibrary);
expect(
buffer.toString(),
@@ -86,7 +86,7 @@
}
final StringBuffer buffer = new StringBuffer();
- new Printer(buffer, showExternal: false, showMetadata: true)
+ new Printer(buffer, showMetadata: true)
.writeLibraryFile(component.mainMethod.enclosingLibrary);
expect(
buffer.toString(),
diff --git a/pkg/vm/testcases/bytecode/async.dart.expect b/pkg/vm/testcases/bytecode/async.dart.expect
index 3dc478d..831596f 100644
--- a/pkg/vm/testcases/bytecode/async.dart.expect
+++ b/pkg/vm/testcases/bytecode/async.dart.expect
@@ -79,7 +79,7 @@
PopLocal r0
Push r0
Push FP[-5]
- StoreContextVar 0, 0
+ StoreContextVar 0, 2
JumpIfUnchecked L1
Push FP[-5]
PushConstant CP#3
@@ -102,7 +102,7 @@
PopLocal r3
Push r0
PushInt 0
- StoreContextVar 0, 5
+ StoreContextVar 0, 0
Push r0
AllocateClosure CP#10
StoreLocal r2
@@ -125,12 +125,12 @@
Push r0
LoadContextVar 0, 8
DirectCall CP#26, 1
- StoreContextVar 0, 3
+ StoreContextVar 0, 4
Push r0
Push r0
LoadContextVar 0, 8
DirectCall CP#28, 1
- StoreContextVar 0, 4
+ StoreContextVar 0, 5
Push r0
LoadContextVar 0, 1
Push r0
@@ -155,7 +155,7 @@
PopLocal r4
CheckStack 0
Push r4
- LoadContextVar 0, 5
+ LoadContextVar 0, 0
StoreLocal r5
PushInt 0
JumpIfNeStrict L1
@@ -165,17 +165,17 @@
Try #0 start:
Push r4
PushInt 1
- StoreContextVar 0, 5
+ StoreContextVar 0, 0
Push r4
Push r4
StoreContextVar 0, 6
Push r4
- LoadContextVar 0, 0
- Push r4
- LoadContextVar 0, 3
+ LoadContextVar 0, 2
Push r4
LoadContextVar 0, 4
Push r4
+ LoadContextVar 0, 5
+ Push r4
LoadContextVar 0, 8
DirectCall CP#12, 4
PopLocal r8
@@ -193,7 +193,7 @@
Push r4
LoadContextVar 0, 1
Push r4
- LoadContextVar 0, 2
+ LoadContextVar 0, 3
DirectCall CP#14, 2
Drop1
PushNull
@@ -248,7 +248,7 @@
Push r2
DirectCall CP#2, 1
Drop1
- StoreContextVar 0, 0
+ StoreContextVar 0, 1
PushNull
PopLocal r3
PushNull
@@ -257,7 +257,7 @@
PopLocal r5
Push r0
PushInt 0
- StoreContextVar 0, 2
+ StoreContextVar 0, 0
AllocateClosure CP#4
StoreLocal r2
Push r2
@@ -282,12 +282,12 @@
DirectCall CP#22, 1
PopLocal r5
Push r0
- LoadContextVar 0, 0
+ LoadContextVar 0, 1
Push r6
DynamicCall CP#24, 2
Drop1
Push r0
- LoadContextVar 0, 0
+ LoadContextVar 0, 1
InterfaceCall CP#26, 1
ReturnTOS
}
@@ -333,7 +333,7 @@
PopLocal r4
CheckStack 0
Push r4
- LoadContextVar 0, 2
+ LoadContextVar 0, 0
StoreLocal r5
PushInt 0
JumpIfNeStrict L1
@@ -342,13 +342,13 @@
Try #0 start:
Push r4
PushInt 42
- StoreContextVar 0, 1
+ StoreContextVar 0, 2
Jump L2
L2:
Push r4
- LoadContextVar 0, 0
- Push r4
LoadContextVar 0, 1
+ Push r4
+ LoadContextVar 0, 2
DirectCall CP#8, 2
Drop1
PushNull
@@ -365,7 +365,7 @@
Push r7
PopLocal r9
Push r4
- LoadContextVar 0, 0
+ LoadContextVar 0, 1
Push r8
Push r9
InterfaceCall CP#11, 3
@@ -390,10 +390,10 @@
PopLocal r0
Push r0
Push FP[-6]
- StoreContextVar 0, 0
+ StoreContextVar 0, 2
Push r0
Push FP[-5]
- StoreContextVar 0, 1
+ StoreContextVar 0, 3
Push r0
PushConstant CP#1
PushConstant CP#0
@@ -402,12 +402,12 @@
Push r2
DirectCall CP#2, 1
Drop1
- StoreContextVar 0, 2
+ StoreContextVar 0, 1
PushNull
PopLocal r3
Push r0
PushInt 0
- StoreContextVar 0, 6
+ StoreContextVar 0, 0
Push r0
AllocateClosure CP#4
StoreLocal r2
@@ -430,20 +430,20 @@
Push r0
LoadContextVar 0, 10
DirectCall CP#22, 1
- StoreContextVar 0, 4
+ StoreContextVar 0, 5
Push r0
Push r0
LoadContextVar 0, 10
DirectCall CP#24, 1
- StoreContextVar 0, 5
+ StoreContextVar 0, 6
Push r0
- LoadContextVar 0, 2
+ LoadContextVar 0, 1
Push r0
LoadContextVar 0, 10
DynamicCall CP#26, 2
Drop1
Push r0
- LoadContextVar 0, 2
+ LoadContextVar 0, 1
InterfaceCall CP#28, 1
ReturnTOS
}
@@ -491,7 +491,7 @@
PopLocal r4
CheckStack 0
Push r4
- LoadContextVar 0, 6
+ LoadContextVar 0, 0
StoreLocal r5
PushInt 0
JumpIfNeStrict L1
@@ -501,17 +501,17 @@
Try #0 start:
Push r4
PushInt 1
- StoreContextVar 0, 6
+ StoreContextVar 0, 0
Push r4
Push r4
StoreContextVar 0, 7
Push r4
- LoadContextVar 0, 0
- Push r4
- LoadContextVar 0, 4
+ LoadContextVar 0, 2
Push r4
LoadContextVar 0, 5
Push r4
+ LoadContextVar 0, 6
+ Push r4
LoadContextVar 0, 10
DirectCall CP#8, 4
PopLocal r8
@@ -529,17 +529,17 @@
StoreContextVar 0, 9
Push r4
PushInt 2
- StoreContextVar 0, 6
+ StoreContextVar 0, 0
Push r4
Push r4
StoreContextVar 0, 7
Push r4
- LoadContextVar 0, 1
- Push r4
- LoadContextVar 0, 4
+ LoadContextVar 0, 3
Push r4
LoadContextVar 0, 5
Push r4
+ LoadContextVar 0, 6
+ Push r4
LoadContextVar 0, 10
DirectCall CP#8, 4
PopLocal r9
@@ -557,13 +557,13 @@
LoadContextVar 0, 9
Push r1
AddInt
- StoreContextVar 0, 3
+ StoreContextVar 0, 4
Jump L4
L4:
Push r4
- LoadContextVar 0, 2
+ LoadContextVar 0, 1
Push r4
- LoadContextVar 0, 3
+ LoadContextVar 0, 4
DirectCall CP#10, 2
Drop1
PushNull
@@ -584,7 +584,7 @@
Push r7
PopLocal r9
Push r4
- LoadContextVar 0, 2
+ LoadContextVar 0, 1
Push r8
Push r9
InterfaceCall CP#13, 3
@@ -615,7 +615,7 @@
PopLocal r0
Push r0
Push FP[-5]
- StoreContextVar 0, 0
+ StoreContextVar 0, 2
Push r0
PushConstant CP#1
PushConstant CP#0
@@ -629,7 +629,7 @@
PopLocal r3
Push r0
PushInt 0
- StoreContextVar 0, 5
+ StoreContextVar 0, 0
Push r0
AllocateClosure CP#4
StoreLocal r2
@@ -652,12 +652,12 @@
Push r0
LoadContextVar 0, 10
DirectCall CP#30, 1
- StoreContextVar 0, 3
+ StoreContextVar 0, 4
Push r0
Push r0
LoadContextVar 0, 10
DirectCall CP#32, 1
- StoreContextVar 0, 4
+ StoreContextVar 0, 5
Push r0
LoadContextVar 0, 1
Push r0
@@ -715,13 +715,13 @@
LoadConstant r1, CP#5
LoadConstant r2, CP#5
LoadConstant r3, CP#5
- Frame 7
+ Frame 6
Push r0
LoadFieldTOS CP#6
PopLocal r4
CheckStack 0
Push r4
- LoadContextVar 0, 5
+ LoadContextVar 0, 0
StoreLocal r5
PushInt 0
JumpIfNeStrict L1
@@ -755,20 +755,18 @@
CompareIntLt
JumpIfFalse L2
Push r4
- LoadContextParent
- LoadContextParent
- LoadContextVar 0, 0
- InterfaceCall CP#8, 1
- PopLocal r8
Push r4
- Push r8
+ LoadContextParent
+ LoadContextParent
+ LoadContextVar 0, 2
+ InterfaceCall CP#8, 1
StoreContextVar 2, 1
L5:
CheckStack 2
Push r4
LoadContextVar 2, 1
- StoreLocal r8
InterfaceCall CP#10, 1
+ AssertBoolean 0
JumpIfFalse L3
AllocateContext 3, 1
StoreLocal r5
@@ -777,7 +775,9 @@
StoreContextParent
PopLocal r4
Push r4
- Push r8
+ Push r4
+ LoadContextParent
+ LoadContextVar 2, 1
InterfaceCall CP#12, 1
StoreContextVar 3, 0
Push r4
@@ -805,7 +805,7 @@
LoadContextParent
LoadContextParent
PushInt 1
- StoreContextVar 0, 5
+ StoreContextVar 0, 0
Push r4
LoadContextParent
LoadContextParent
@@ -817,19 +817,19 @@
LoadContextParent
LoadContextParent
LoadContextParent
- LoadContextVar 0, 3
+ LoadContextVar 0, 4
Push r4
LoadContextParent
LoadContextParent
LoadContextParent
- LoadContextVar 0, 4
+ LoadContextVar 0, 5
Push r4
LoadContextParent
LoadContextParent
LoadContextParent
LoadContextVar 0, 10
DirectCall CP#16, 4
- PopLocal r10
+ PopLocal r9
PushNull
ReturnTOS
L11:
@@ -903,7 +903,7 @@
LoadContextParent
Push r4
LoadContextVar 1, 0
- StoreContextVar 0, 2
+ StoreContextVar 0, 3
Push r4
LoadContextParent
PopLocal r4
@@ -912,14 +912,14 @@
Push r4
LoadContextVar 0, 1
Push r4
- LoadContextVar 0, 2
+ LoadContextVar 0, 3
DirectCall CP#18, 2
Drop1
PushNull
ReturnTOS
Try #0 end:
Try #0 handler:
- SetFrame 11
+ SetFrame 10
Push r0
LoadFieldTOS CP#6
PopLocal r4
@@ -961,13 +961,13 @@
PopLocal r0
Push r0
Push FP[-7]
- StoreContextVar 0, 0
+ StoreContextVar 0, 2
Push r0
Push FP[-6]
- StoreContextVar 0, 1
+ StoreContextVar 0, 3
Push r0
Push FP[-5]
- StoreContextVar 0, 2
+ StoreContextVar 0, 4
Push r0
PushConstant CP#1
PushConstant CP#0
@@ -976,12 +976,12 @@
Push r2
DirectCall CP#2, 1
Drop1
- StoreContextVar 0, 3
+ StoreContextVar 0, 1
PushNull
PopLocal r3
Push r0
PushInt 0
- StoreContextVar 0, 7
+ StoreContextVar 0, 0
Push r0
AllocateClosure CP#4
StoreLocal r2
@@ -1004,20 +1004,20 @@
Push r0
LoadContextVar 0, 17
DirectCall CP#28, 1
- StoreContextVar 0, 5
+ StoreContextVar 0, 6
Push r0
Push r0
LoadContextVar 0, 17
DirectCall CP#30, 1
- StoreContextVar 0, 6
+ StoreContextVar 0, 7
Push r0
- LoadContextVar 0, 3
+ LoadContextVar 0, 1
Push r0
LoadContextVar 0, 17
DynamicCall CP#32, 2
Drop1
Push r0
- LoadContextVar 0, 3
+ LoadContextVar 0, 1
InterfaceCall CP#34, 1
ReturnTOS
}
@@ -1071,7 +1071,7 @@
PopLocal r4
CheckStack 0
Push r4
- LoadContextVar 0, 7
+ LoadContextVar 0, 0
StoreLocal r5
PushInt 0
JumpIfNeStrict L1
@@ -1106,22 +1106,22 @@
Push r4
LoadContextParent
PushInt 1
- StoreContextVar 0, 7
+ StoreContextVar 0, 0
Push r4
LoadContextParent
Push r4
StoreContextVar 0, 8
Push r4
LoadContextParent
- LoadContextVar 0, 0
- Push r4
- LoadContextParent
- LoadContextVar 0, 5
+ LoadContextVar 0, 2
Push r4
LoadContextParent
LoadContextVar 0, 6
Push r4
LoadContextParent
+ LoadContextVar 0, 7
+ Push r4
+ LoadContextParent
LoadContextVar 0, 17
DirectCall CP#8, 4
PopLocal r13
@@ -1172,7 +1172,7 @@
Push r4
LoadContextParent
PushInt 42
- StoreContextVar 0, 4
+ StoreContextVar 0, 5
Jump L5
L4:
Push r4
@@ -1183,22 +1183,22 @@
Push r4
LoadContextParent
PushInt 2
- StoreContextVar 0, 7
+ StoreContextVar 0, 0
Push r4
LoadContextParent
Push r4
StoreContextVar 0, 8
Push r4
LoadContextParent
- LoadContextVar 0, 1
- Push r4
- LoadContextParent
- LoadContextVar 0, 5
+ LoadContextVar 0, 3
Push r4
LoadContextParent
LoadContextVar 0, 6
Push r4
LoadContextParent
+ LoadContextVar 0, 7
+ Push r4
+ LoadContextParent
LoadContextVar 0, 17
DirectCall CP#8, 4
PopLocal r13
@@ -1257,22 +1257,22 @@
Push r4
LoadContextParent
PushInt 3
- StoreContextVar 0, 7
+ StoreContextVar 0, 0
Push r4
LoadContextParent
Push r4
StoreContextVar 0, 8
Push r4
LoadContextParent
- LoadContextVar 0, 2
- Push r4
- LoadContextParent
- LoadContextVar 0, 5
+ LoadContextVar 0, 4
Push r4
LoadContextParent
LoadContextVar 0, 6
Push r4
LoadContextParent
+ LoadContextVar 0, 7
+ Push r4
+ LoadContextParent
LoadContextVar 0, 17
DirectCall CP#8, 4
PopLocal r12
@@ -1296,7 +1296,7 @@
LoadContextParent
Push r4
LoadContextVar 1, 0
- StoreContextVar 0, 4
+ StoreContextVar 0, 5
Push r4
LoadContextParent
PopLocal r4
@@ -1319,22 +1319,22 @@
Push r4
LoadContextParent
PushInt 4
- StoreContextVar 0, 7
+ StoreContextVar 0, 0
Push r4
LoadContextParent
Push r4
StoreContextVar 0, 8
Push r4
LoadContextParent
- LoadContextVar 0, 2
- Push r4
- LoadContextParent
- LoadContextVar 0, 5
+ LoadContextVar 0, 4
Push r4
LoadContextParent
LoadContextVar 0, 6
Push r4
LoadContextParent
+ LoadContextVar 0, 7
+ Push r4
+ LoadContextParent
LoadContextVar 0, 17
DirectCall CP#8, 4
PopLocal r12
@@ -1358,7 +1358,7 @@
LoadContextParent
Push r4
LoadContextVar 1, 0
- StoreContextVar 0, 4
+ StoreContextVar 0, 5
Push r4
LoadContextParent
PopLocal r4
@@ -1381,22 +1381,22 @@
Push r4
LoadContextParent
PushInt 5
- StoreContextVar 0, 7
+ StoreContextVar 0, 0
Push r4
LoadContextParent
Push r4
StoreContextVar 0, 8
Push r4
LoadContextParent
- LoadContextVar 0, 2
- Push r4
- LoadContextParent
- LoadContextVar 0, 5
+ LoadContextVar 0, 4
Push r4
LoadContextParent
LoadContextVar 0, 6
Push r4
LoadContextParent
+ LoadContextVar 0, 7
+ Push r4
+ LoadContextParent
LoadContextVar 0, 17
DirectCall CP#8, 4
PopLocal r12
@@ -1420,16 +1420,16 @@
LoadContextParent
Push r4
LoadContextVar 1, 0
- StoreContextVar 0, 4
+ StoreContextVar 0, 5
Push r4
LoadContextParent
PopLocal r4
Jump L9
L9:
Push r4
- LoadContextVar 0, 3
+ LoadContextVar 0, 1
Push r4
- LoadContextVar 0, 4
+ LoadContextVar 0, 5
DirectCall CP#17, 2
Drop1
PushNull
@@ -1450,7 +1450,7 @@
Push r7
PopLocal r9
Push r4
- LoadContextVar 0, 3
+ LoadContextVar 0, 1
Push r8
Push r9
InterfaceCall CP#19, 3
@@ -1571,12 +1571,12 @@
Push r2
DirectCall CP#5, 1
Drop1
- StoreContextVar 1, 0
+ StoreContextVar 1, 1
PushNull
PopLocal r3
Push r0
PushInt 0
- StoreContextVar 1, 4
+ StoreContextVar 1, 0
Push r0
AllocateClosure CP#7
StoreLocal r2
@@ -1599,20 +1599,20 @@
Push r0
LoadContextVar 1, 8
DirectCall CP#26, 1
- StoreContextVar 1, 2
+ StoreContextVar 1, 3
Push r0
Push r0
LoadContextVar 1, 8
DirectCall CP#28, 1
- StoreContextVar 1, 3
+ StoreContextVar 1, 4
Push r0
- LoadContextVar 1, 0
+ LoadContextVar 1, 1
Push r0
LoadContextVar 1, 8
DynamicCall CP#30, 2
Drop1
Push r0
- LoadContextVar 1, 0
+ LoadContextVar 1, 1
InterfaceCall CP#32, 1
ReturnTOS
}
@@ -1629,7 +1629,7 @@
PopLocal r4
CheckStack 0
Push r4
- LoadContextVar 1, 4
+ LoadContextVar 1, 0
StoreLocal r5
PushInt 0
JumpIfNeStrict L1
@@ -1659,7 +1659,7 @@
Push r4
LoadContextParent
PushInt 1
- StoreContextVar 1, 4
+ StoreContextVar 1, 0
Push r4
LoadContextParent
Push r4
@@ -1670,10 +1670,10 @@
LoadContextVar 0, 0
Push r4
LoadContextParent
- LoadContextVar 1, 2
+ LoadContextVar 1, 3
Push r4
LoadContextParent
- LoadContextVar 1, 3
+ LoadContextVar 1, 4
Push r4
LoadContextParent
LoadContextVar 1, 8
@@ -1700,7 +1700,7 @@
Push r4
LoadContextVar 2, 0
AddInt
- StoreContextVar 1, 1
+ StoreContextVar 1, 2
Jump L3
Try #1 end:
Try #1 handler:
@@ -1735,9 +1735,9 @@
Jump L4
L4:
Push r4
- LoadContextVar 1, 0
- Push r4
LoadContextVar 1, 1
+ Push r4
+ LoadContextVar 1, 2
DirectCall CP#15, 2
Drop1
PushNull
@@ -1758,7 +1758,7 @@
Push r7
PopLocal r9
Push r4
- LoadContextVar 1, 0
+ LoadContextVar 1, 1
Push r8
Push r9
InterfaceCall CP#17, 3
@@ -1786,7 +1786,7 @@
PopLocal r0
Push r0
Push FP[-5]
- StoreContextVar 0, 0
+ StoreContextVar 0, 2
Push r0
PushConstant CP#1
PushConstant CP#0
@@ -1800,7 +1800,7 @@
PopLocal r3
Push r0
PushInt 0
- StoreContextVar 0, 5
+ StoreContextVar 0, 0
Push r0
AllocateClosure CP#4
StoreLocal r2
@@ -1823,12 +1823,12 @@
Push r0
LoadContextVar 0, 8
DirectCall CP#24, 1
- StoreContextVar 0, 3
+ StoreContextVar 0, 4
Push r0
Push r0
LoadContextVar 0, 8
DirectCall CP#26, 1
- StoreContextVar 0, 4
+ StoreContextVar 0, 5
Push r0
LoadContextVar 0, 1
Push r0
@@ -1886,7 +1886,7 @@
PopLocal r4
CheckStack 0
Push r4
- LoadContextVar 0, 5
+ LoadContextVar 0, 0
StoreLocal r5
PushInt 0
JumpIfNeStrict L1
@@ -1897,17 +1897,17 @@
JumpIfNoAsserts L2
Push r4
PushInt 1
- StoreContextVar 0, 5
+ StoreContextVar 0, 0
Push r4
Push r4
StoreContextVar 0, 6
Push r4
- LoadContextVar 0, 0
- Push r4
- LoadContextVar 0, 3
+ LoadContextVar 0, 2
Push r4
LoadContextVar 0, 4
Push r4
+ LoadContextVar 0, 5
+ Push r4
LoadContextVar 0, 8
DirectCall CP#8, 4
PopLocal r8
@@ -1933,13 +1933,13 @@
L2:
Push r4
PushInt 7
- StoreContextVar 0, 2
+ StoreContextVar 0, 3
Jump L4
L4:
Push r4
LoadContextVar 0, 1
Push r4
- LoadContextVar 0, 2
+ LoadContextVar 0, 3
DirectCall CP#12, 2
Drop1
PushNull
@@ -2100,11 +2100,17 @@
{
dart.core::int* sum = 0;
for (dart.core::int* i = 0; i.{dart.core::num::<}(10); i = i.{dart.core::num::+}(1)) {
- for (dart.core::int* j in list) {
- :async_temporary_1 = sum;
- :async_temporary_0 = i.{dart.core::num::+}(j);
- [yield] let dynamic #t4 = dart.async::_awaitHelper(#lib::foo(), :async_op_then, :async_op_error, :async_op) in null;
- sum = :async_temporary_1.{dart.core::num::+}(:async_temporary_0.{dart.core::num::+}(dart._internal::unsafeCast<dart.core::int*>(:result)));
+ {
+ dart.core::Iterator<dart.core::int*>* :sync-for-iterator = dart._internal::unsafeCast<dart.core::Iterable<dart.core::int*>*>(list).{dart.core::Iterable::iterator};
+ for (; :sync-for-iterator.{dart.core::Iterator::moveNext}(); ) {
+ dart.core::int* j = :sync-for-iterator.{dart.core::Iterator::current};
+ {
+ :async_temporary_1 = sum;
+ :async_temporary_0 = i.{dart.core::num::+}(j);
+ [yield] let dynamic #t4 = dart.async::_awaitHelper(#lib::foo(), :async_op_then, :async_op_error, :async_op) in null;
+ sum = :async_temporary_1.{dart.core::num::+}(:async_temporary_0.{dart.core::num::+}(dart._internal::unsafeCast<dart.core::int*>(:result)));
+ }
+ }
}
}
for (dart.core::int* k = 0; k.{dart.core::num::<}(10); k = k.{dart.core::num::+}(1)) {
diff --git a/pkg/vm/testcases/bytecode/closures.dart.expect b/pkg/vm/testcases/bytecode/closures.dart.expect
index 383b1c0..5207c3e 100644
--- a/pkg/vm/testcases/bytecode/closures.dart.expect
+++ b/pkg/vm/testcases/bytecode/closures.dart.expect
@@ -1301,6 +1301,7 @@
CheckStack 1
Push r2
InterfaceCall CP#2, 1
+ AssertBoolean 0
JumpIfFalse L1
AllocateContext 0, 1
PopLocal r0
@@ -1840,12 +1841,18 @@
}
}
method testForInLoop(dart.core::List<dart.core::int*>* list) → void {
- for (dart.core::int* i in list) {
- () →* dart.core::Null? inc = () → dart.core::Null? {
- i = i.{dart.core::num::+}(1);
- };
- [@vm.call-site-attributes.metadata=receiverType:() →* dart.core::Null?] inc.call();
- dart.core::print(i);
+ {
+ dart.core::Iterator<dart.core::int*>* :sync-for-iterator = dart._internal::unsafeCast<dart.core::Iterable<dart.core::int*>*>(list).{dart.core::Iterable::iterator};
+ for (; :sync-for-iterator.{dart.core::Iterator::moveNext}(); ) {
+ dart.core::int* i = :sync-for-iterator.{dart.core::Iterator::current};
+ {
+ () →* dart.core::Null? inc = () → dart.core::Null? {
+ i = i.{dart.core::num::+}(1);
+ };
+ [@vm.call-site-attributes.metadata=receiverType:() →* dart.core::Null?] inc.call();
+ dart.core::print(i);
+ }
+ }
}
}
}
diff --git a/pkg/vm/testcases/bytecode/loops.dart.expect b/pkg/vm/testcases/bytecode/loops.dart.expect
index 2985990..cb40ac2 100644
--- a/pkg/vm/testcases/bytecode/loops.dart.expect
+++ b/pkg/vm/testcases/bytecode/loops.dart.expect
@@ -249,6 +249,7 @@
CheckStack 1
Push r1
InterfaceCall CP#2, 1
+ AssertBoolean 0
JumpIfFalse L1
Push r1
InterfaceCall CP#4, 1
@@ -290,6 +291,7 @@
CheckStack 1
Push r2
InterfaceCall CP#2, 1
+ AssertBoolean 0
JumpIfFalse L1
Push r2
InterfaceCall CP#4, 1
@@ -382,17 +384,29 @@
}
static method test_for_in(dart.core::List<dart.core::int*>* list) → dart.core::int* {
dart.core::int* sum = 0;
- for (dart.core::int* e in list) {
- sum = sum.{dart.core::num::+}(e);
+ {
+ dart.core::Iterator<dart.core::int*>* :sync-for-iterator = dart._internal::unsafeCast<dart.core::Iterable<dart.core::int*>*>(list).{dart.core::Iterable::iterator};
+ for (; :sync-for-iterator.{dart.core::Iterator::moveNext}(); ) {
+ dart.core::int* e = :sync-for-iterator.{dart.core::Iterator::current};
+ {
+ sum = sum.{dart.core::num::+}(e);
+ }
+ }
}
return sum;
}
static method test_for_in_with_outer_var(dart.core::List<dart.core::int*>* list) → dart.core::int* {
dart.core::int* sum = 0;
dart.core::int* e = 42;
- for (final dart.core::int* #t3 in list) {
- e = #t3;
- sum = sum.{dart.core::num::+}(e);
+ {
+ dart.core::Iterator<dart.core::int*>* :sync-for-iterator = dart._internal::unsafeCast<dart.core::Iterable<dart.core::int*>*>(list).{dart.core::Iterable::iterator};
+ for (; :sync-for-iterator.{dart.core::Iterator::moveNext}(); ) {
+ final dart.core::int* #t3 = :sync-for-iterator.{dart.core::Iterator::current};
+ {
+ e = #t3;
+ sum = sum.{dart.core::num::+}(e);
+ }
+ }
}
return sum;
}
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/bool_expressions.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/bool_expressions.dart.expect
index 96a9042..12eb6e9 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/bool_expressions.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/bool_expressions.dart.expect
@@ -8,13 +8,13 @@
t0* = _Call direct [#lib::foo] ()
t1 = _TypeCheck (t0 against dart.core::bool) (for #lib::foo() as{TypeError} dart.core::bool*)
t2* = _Call direct [#lib::bar] ()
-t3* = _Call [dart.core::num::+] (_T (dart.core::int)+?, _T (dart.core::_Smi))
-i = _Join [dart.core::int*] (_T (dart.core::_Smi), t3)
-t5* = _Call [dart.core::num::<] (i, _T (dart.core::_Smi))
+t3* = _Call [dart.core::num::+] (_T (dart.core::int)+?, _T (dart.core::_Smi, 1))
+i = _Join [dart.core::int*] (_T (dart.core::_Smi, 0), t3)
+t5* = _Call [dart.core::num::<] (i, _T (dart.core::_Smi, 10))
t6* = _Call direct [#lib::bar] ()
-x = _Join [dart.core::bool*] (t6, _T (dart.core::bool)+)
+x = _Join [dart.core::bool*] (t6, _T (dart.core::bool))
t8* = _Call direct [#lib::foo] ()
-t9 = _Join [dynamic] (_T (dart.core::bool)+, t8)
+t9 = _Join [dynamic] (_T (dart.core::bool, true), t8)
t10 = _Narrow (t9 to _T ANY?)
t11 = _TypeCheck (t10 against dart.core::bool) (for (x{dart.core::bool*} ?{dynamic} true : #lib::foo()) as{TypeError} dart.core::bool*)
t12* = _Call direct [#lib::bar] ()
@@ -23,7 +23,7 @@
t15 = _TypeCheck (t14 against dart.core::bool) (for #lib::foo() as{TypeError} dart.core::bool*)
t16* = _Call direct [#lib::foo] ()
t17 = _TypeCheck (t16 against dart.core::bool) (for #lib::foo() as{TypeError} dart.core::bool*)
-y = _Join [dart.core::bool*] (_T (dart.core::bool)+, t11, _T (dart.core::bool)+, _T (dart.core::bool)+)
+y = _Join [dart.core::bool*] (_T (dart.core::bool, true), t11, _T (dart.core::bool), _T (dart.core::bool))
RESULT: _T {}?
------------ #lib::main ------------
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/class_generics_basic.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/class_generics_basic.dart.expect
index 75d7a9e..d127a8a 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/class_generics_basic.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/class_generics_basic.dart.expect
@@ -102,7 +102,7 @@
t11 = _Call direct [#lib::Z::] (_T (#lib::Z))
t12 = _Call [#lib::C::id2] (_T (#lib::C<#lib::Y>), _T (#lib::Z))
t13 = _Call direct [#lib::C2::] (_T (#lib::C2<dart.core::num>))
-t14 = _Call [#lib::C2::id3] (_T (#lib::C2<dart.core::num>), _T (dart.core::double)+)
+t14 = _Call [#lib::C2::id3] (_T (#lib::C2<dart.core::num>), _T (dart.core::_Double, 3.0))
t15 = _Call direct [#lib::K::] (_T (#lib::K<#lib::J>))
t16 = _Call [#lib::C2::id4] (_T (#lib::C2<dart.core::num>), _T (#lib::K<#lib::J>))
used = _Join [dynamic] (_T {}?, t1, t3, t5, t7)
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/class_generics_case1.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/class_generics_case1.dart.expect
index 6c510f9..f92bee4 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/class_generics_case1.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/class_generics_case1.dart.expect
@@ -38,7 +38,7 @@
RESULT: t1
------------ #lib::main ------------
t0 = _Call direct [#lib::InheritedElement::] (_T (#lib::InheritedElement))
-t1 = _Call [#lib::InheritedElement::setDependencies] (_T (#lib::InheritedElement), _T (#lib::InheritedElement), _T (dart.core::_Smi))
+t1 = _Call [#lib::InheritedElement::setDependencies] (_T (#lib::InheritedElement), _T (#lib::InheritedElement), _T (dart.core::_Smi, 0))
t2 = _Call direct [#lib::Element::] (_T (#lib::Element))
t3 = _Call [#lib::InheritedElement::setDependencies] (_T (#lib::InheritedElement), _T (#lib::Element), _T {}?)
RESULT: _T {}?
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/constants.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/constants.dart.expect
index 40d9eb1..7741659 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/constants.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/constants.dart.expect
@@ -1,25 +1,26 @@
------------ #lib::smiLiteral ------------
-RESULT: _T (dart.core::_Smi)
+RESULT: _T (dart.core::_Smi, 42)
------------ #lib::intLiteral ------------
RESULT: _T (dart.core::int)+
------------ #lib::strLiteral ------------
-RESULT: _T (dart.core::_OneByteString)
+RESULT: _T (dart.core::_OneByteString, abc)
------------ #lib::indexingIntoConstantList1 ------------
%i = _Parameter #0 [_T (dart.core::int)+?]
-RESULT: _T (dart.core::_Smi)
+t1 = _Join [dart.core::int*] (_T (dart.core::_Smi, 1), _T (dart.core::_Smi, 2), _T (dart.core::_Smi, 3))
+RESULT: t1
------------ #lib::indexingIntoConstantList2 ------------
%i = _Parameter #0 [_T (dart.core::int)+?]
-t1 = _Join [dart.core::Object*] (_T (dart.core::_OneByteString), _T (dart.core::_Smi), _T {}?)
+t1 = _Join [dart.core::Object*] (_T (dart.core::_OneByteString, hi), _T (dart.core::_Smi, 33), _T {}?, _T (dart.core::_Smi, -5))
RESULT: t1
------------ #lib::main ------------
RESULT: _T {}?
------------ #lib::_constList1 ------------
-RESULT: _T (dart.core::_ImmutableList)
+RESULT: _T (dart.core::_ImmutableList, ListConstant<dart.core::int*>([1, 2, 3]))
------------ #lib::_constList2 ------------
-RESULT: _T (dart.core::_ImmutableList)
+RESULT: _T (dart.core::_ImmutableList, ListConstant<dart.core::Object*>([hi, 33, null, -5]))
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/hello.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/hello.dart.expect
index 31ccb74..504cd3b 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/hello.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/hello.dart.expect
@@ -1,4 +1,4 @@
------------ #lib::main ------------
%args = _Parameter #0 [_T (dart.core::List)+?]
-t1 = _Call direct [dart.core::print] (_T (dart.core::_OneByteString))
+t1 = _Call direct [dart.core::print] (_T (dart.core::_OneByteString, Hello, world!))
RESULT: _T {}?
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart.expect
index 9a3e510..aaced22 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart.expect
@@ -19,7 +19,7 @@
RESULT: _T (#lib::T)
------------ #lib::return2 ------------
%i = _Parameter #0 [_T (dart.core::int)+?]
-t1* = _Call [dart.core::num::-] (%i, _T (dart.core::_Smi))
+t1* = _Call [dart.core::num::-] (%i, _T (dart.core::_Smi, 1))
t2* = _Call direct [#lib::return2] (t1)
RESULT: t2
------------ #lib::return3 ------------
@@ -93,7 +93,7 @@
------------ #lib::if5 ------------
%c = _Parameter #0 [_T (dart.core::bool)+?]
t1* = _Call direct [#lib::if5] (%c)
-t2* = _Call direct [#lib::if5] (_T (dart.core::bool)+)
+t2* = _Call direct [#lib::if5] (_T (dart.core::bool))
%result = _Join [void] (t1, t2, _T {}?)
RESULT: %result
------------ #lib::label1 ------------
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/vars.dart.expect b/pkg/vm/testcases/transformations/type_flow/summary_collector/vars.dart.expect
index 107564e..ff8eaf9 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/vars.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/vars.dart.expect
@@ -12,7 +12,7 @@
t2* = _Call direct get [#lib::someStatic] ()
t3 = _Call direct [#lib::A::] (_T (#lib::A))
a1 = _Join [dart.core::Object*] (%a1, _T (#lib::A), _T (#lib::B))
-t5 = _Call direct [#lib::bar] (a1, _T (dart.core::_Smi))
+t5 = _Call direct [#lib::bar] (a1, _T (dart.core::_Smi, 42))
t6 = _Call direct [#lib::B::] (_T (#lib::B))
t7* = _Call [dart.core::Object::==] (a1, %a2)
t8 = _Join [dart.core::Object*] (a1, %a2)
@@ -23,8 +23,8 @@
%a2 = _Parameter #1 [_T (dart.core::int)+?]
t2 = _Narrow (%a1 to _T (dart.core::int)+)
t3* = _Call [dart.core::num::+] (t2, %a2)
-t4* = _Call [dart.core::num::*] (t3, _T (dart.core::_Smi))
-t5* = _Call [dart.core::int::unary-] (_T (dart.core::_Smi))
+t4* = _Call [dart.core::num::*] (t3, _T (dart.core::_Smi, 3))
+t5* = _Call [dart.core::int::unary-] (_T (dart.core::_Smi, 1))
%result = _Join [dart.core::int*] (t4, t5)
RESULT: %result
------------ #lib::loop1 ------------
@@ -35,10 +35,10 @@
RESULT: x
------------ #lib::loop2 ------------
%x = _Parameter #0 [_T (dart.core::int)+?]
-t1* = _Call [dart.core::num::+] (_T (dart.core::int)+?, _T (dart.core::_Smi))
-i = _Join [dart.core::int*] (_T (dart.core::_Smi), t1)
-t3* = _Call [dart.core::num::<] (i, _T (dart.core::_Smi))
-t4* = _Call [dart.core::num::+] (_T (dart.core::int)+?, _T (dart.core::_Smi))
+t1* = _Call [dart.core::num::+] (_T (dart.core::int)+?, _T (dart.core::_Smi, 1))
+i = _Join [dart.core::int*] (_T (dart.core::_Smi, 0), t1)
+t3* = _Call [dart.core::num::<] (i, _T (dart.core::_Smi, 5))
+t4* = _Call [dart.core::num::+] (_T (dart.core::int)+?, _T (dart.core::_Smi, 10))
x = _Join [dart.core::int*] (%x, t4)
RESULT: x
------------ #lib::main ------------
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/annotation.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/annotation.dart.expect
index 62fdd38..5263f59 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/annotation.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/annotation.dart.expect
@@ -28,7 +28,7 @@
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] @#C8
method instanceMethod() → void {}
}
-static method foo([@vm.inferred-type.metadata=dart.core::Null?] (core::List<core::int*>*) →* void a) → core::int* {
+static method foo([@vm.inferred-type.metadata=dart.core::Null? (value: null)] (core::List<core::int*>*) →* void a) → core::int* {
@#C9 core::int* x = 2;
return [@vm.direct-call.metadata=dart.core::_IntegerImplementation::+] [@vm.inferred-type.metadata=int (skip check)] x.{core::num::+}(2);
}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/bench_is_prime.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/bench_is_prime.dart.expect
index 7f4e53f..7944a4a 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/bench_is_prime.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/bench_is_prime.dart.expect
@@ -12,7 +12,7 @@
}
return true;
}
-static method nThPrimeNumber([@vm.inferred-type.metadata=dart.core::_Smi] core::int* n) → core::int* {
+static method nThPrimeNumber([@vm.inferred-type.metadata=dart.core::_Smi (value: 50000)] core::int* n) → core::int* {
core::int* counter = 0;
for (core::int* i = 1; ; i = [@vm.direct-call.metadata=dart.core::_IntegerImplementation::+??] [@vm.inferred-type.metadata=int (skip check)] i.{core::num::+}(1)) {
if([@vm.inferred-type.metadata=dart.core::bool] self::isPrime(i))
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/bench_vector.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/bench_vector.dart.expect
index e9ee2e6..6efba39 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/bench_vector.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/bench_vector.dart.expect
@@ -6,20 +6,20 @@
import "dart:typed_data";
class _Vector extends core::Object {
-[@vm.inferred-type.metadata=dart.core::_Smi] [@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false] final field core::int* _offset;
-[@vm.inferred-type.metadata=dart.core::_Smi] [@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false] final field core::int* _length;
+[@vm.inferred-type.metadata=dart.core::_Smi (value: 0)] [@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false] final field core::int* _offset;
+[@vm.inferred-type.metadata=dart.core::_Smi (value: 10)] [@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false] final field core::int* _length;
[@vm.inferred-type.metadata=dart.typed_data::_Float64List] [@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false] final field core::List<core::double*>* _elements;
- constructor •([@vm.inferred-type.metadata=dart.core::_Smi] core::int* size) → self::_Vector*
+ constructor •([@vm.inferred-type.metadata=dart.core::_Smi (value: 10)] core::int* size) → self::_Vector*
: self::_Vector::_offset = 0, self::_Vector::_length = size, self::_Vector::_elements = [@vm.inferred-type.metadata=dart.typed_data::_Float64List] typ::Float64List::•(size), super core::Object::•()
;
[@vm.procedure-attributes.metadata=hasTearOffUses:false] operator []([@vm.inferred-type.metadata=!] core::int* i) → core::double*
- return [@vm.direct-call.metadata=dart.typed_data::_Float64List::[]] [@vm.inferred-type.metadata=dart.core::_Double (skip check)] [@vm.direct-call.metadata=#lib::_Vector::_elements] [@vm.inferred-type.metadata=dart.typed_data::_Float64List] this.{self::_Vector::_elements}.{core::List::[]}([@vm.direct-call.metadata=dart.core::_IntegerImplementation::+] [@vm.inferred-type.metadata=int (skip check)] i.{core::num::+}([@vm.direct-call.metadata=#lib::_Vector::_offset] [@vm.inferred-type.metadata=dart.core::_Smi] this.{self::_Vector::_offset}));
+ return [@vm.direct-call.metadata=dart.typed_data::_Float64List::[]] [@vm.inferred-type.metadata=dart.core::_Double (skip check)] [@vm.direct-call.metadata=#lib::_Vector::_elements] [@vm.inferred-type.metadata=dart.typed_data::_Float64List] this.{self::_Vector::_elements}.{core::List::[]}([@vm.direct-call.metadata=dart.core::_IntegerImplementation::+] [@vm.inferred-type.metadata=int (skip check)] i.{core::num::+}([@vm.direct-call.metadata=#lib::_Vector::_offset] [@vm.inferred-type.metadata=dart.core::_Smi (value: 0)] this.{self::_Vector::_offset}));
[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false] operator []=([@vm.inferred-type.metadata=dart.core::_OneByteString] core::int* i, core::double* value) → void {
- let dynamic #t1 = [@vm.direct-call.metadata=#lib::_Vector::_elements] [@vm.inferred-type.metadata=dart.typed_data::_Float64List] this.{self::_Vector::_elements} in let dynamic #t2 = i in let dynamic #t3 = [@vm.direct-call.metadata=#lib::_Vector::_offset] [@vm.inferred-type.metadata=dart.core::_Smi] this.{self::_Vector::_offset} in throw "Attempt to execute code removed by Dart AOT compiler (TFA)";
+ let dynamic #t1 = [@vm.direct-call.metadata=#lib::_Vector::_elements] [@vm.inferred-type.metadata=dart.typed_data::_Float64List] this.{self::_Vector::_elements} in let dynamic #t2 = i in let dynamic #t3 = [@vm.direct-call.metadata=#lib::_Vector::_offset] [@vm.inferred-type.metadata=dart.core::_Smi (value: 0)] this.{self::_Vector::_offset} in throw "Attempt to execute code removed by Dart AOT compiler (TFA)";
}
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] operator *([@vm.inferred-type.metadata=#lib::_Vector?] self::_Vector* a) → core::double* {
core::double* result = 0.0;
- for (core::int* i = 0; [@vm.direct-call.metadata=dart.core::_IntegerImplementation::<] [@vm.inferred-type.metadata=dart.core::bool (skip check)] i.{core::num::<}([@vm.direct-call.metadata=#lib::_Vector::_length] [@vm.inferred-type.metadata=dart.core::_Smi] this.{self::_Vector::_length}); i = [@vm.direct-call.metadata=dart.core::_IntegerImplementation::+??] [@vm.inferred-type.metadata=int (skip check)] i.{core::num::+}(1))
+ for (core::int* i = 0; [@vm.direct-call.metadata=dart.core::_IntegerImplementation::<] [@vm.inferred-type.metadata=dart.core::bool (skip check)] i.{core::num::<}([@vm.direct-call.metadata=#lib::_Vector::_length] [@vm.inferred-type.metadata=dart.core::_Smi (value: 10)] this.{self::_Vector::_length}); i = [@vm.direct-call.metadata=dart.core::_IntegerImplementation::+??] [@vm.inferred-type.metadata=int (skip check)] i.{core::num::+}(1))
result = [@vm.direct-call.metadata=dart.core::_Double::+??] [@vm.inferred-type.metadata=dart.core::_Double (skip check)] result.{core::double::+}([@vm.direct-call.metadata=dart.core::_Double::*] [@vm.inferred-type.metadata=dart.core::_Double (skip check)] [@vm.direct-call.metadata=#lib::_Vector::[]] [@vm.inferred-type.metadata=dart.core::_Double (skip check)] this.{self::_Vector::[]}(i).{core::double::*}([@vm.direct-call.metadata=#lib::_Vector::[]??] [@vm.inferred-type.metadata=dart.core::_Double (skip check)] a.{self::_Vector::[]}(i)));
return result;
}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/class_generics_basic.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/class_generics_basic.dart.expect
index ab12ab8..8bf5b99 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/class_generics_basic.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/class_generics_basic.dart.expect
@@ -57,7 +57,7 @@
synthetic constructor •() → self::C2<self::C2::T*>*
: super core::Object::•()
;
-[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method id3([@vm.inferred-type.metadata=dart.core::_Double (skip check)] generic-covariant-impl core::Comparable<self::C2::T*>* x) → dynamic
+[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method id3([@vm.inferred-type.metadata=dart.core::_Double (skip check) (value: 3.0)] generic-covariant-impl core::Comparable<self::C2::T*>* x) → dynamic
return x;
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method id4([@vm.inferred-type.metadata=#lib::K<#lib::J*> (skip check)] generic-covariant-impl self::K<self::I<self::C2::T*>*>* x) → dynamic
return x;
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/const_prop.dart b/pkg/vm/testcases/transformations/type_flow/transformer/const_prop.dart
new file mode 100644
index 0000000..18527f1
--- /dev/null
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/const_prop.dart
@@ -0,0 +1,62 @@
+// Copyright (c) 2019, 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.
+
+// This test verifies constant propagation.
+
+void test0(int arg) {
+ print(arg);
+}
+
+void test1([int arg = 42]) {
+ print(arg);
+}
+
+void test2({int arg = 43}) {
+ print(arg);
+}
+
+get getD => 100.0;
+
+void testDouble(double arg) {
+ print(arg);
+ print(getD);
+}
+
+class A {
+ String get foo => 'foo';
+ String getBar() => 'bar';
+}
+
+void testStrings(A a0, String a1) {
+ print(a0.foo);
+ print(a0.getBar());
+ print(a1);
+}
+
+enum B { b1, b2, b3 }
+
+void testPassEnum(B arg) {
+ testPassEnum2(arg);
+}
+
+void testPassEnum2(B arg) {
+ print(arg);
+}
+
+getList() => const [1, 2, 3];
+
+void testList(arg1, [arg2 = const [4, 5]]) {
+ print(arg1);
+ print(arg2);
+}
+
+main() {
+ test0(40);
+ test1();
+ test2();
+ testDouble(3.14);
+ testStrings(new A(), 'bazz');
+ testPassEnum(B.b2);
+ testList(getList());
+}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/const_prop.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/const_prop.dart.expect
new file mode 100644
index 0000000..fc8bc63
--- /dev/null
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/const_prop.dart.expect
@@ -0,0 +1,60 @@
+library #lib;
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object {
+ synthetic constructor •() → self::A*
+ : super core::Object::•()
+ ;
+ get foo() → core::String*
+ return "foo";
+[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method getBar() → core::String*
+ return "bar";
+}
+class B extends core::Object {
+[@vm.inferred-type.metadata=dart.core::_Smi (value: 1)] [@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false] final field core::int* index;
+[@vm.inferred-type.metadata=dart.core::_OneByteString (value: B.b2)] [@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false] final field core::String* _name;
+[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method toString() → core::String*
+ return [@vm.inferred-type.metadata=dart.core::_OneByteString (value: B.b2)] this.{=self::B::_name};
+}
+static method test0([@vm.inferred-type.metadata=dart.core::_Smi (value: 40)] core::int* arg) → void {
+ core::print(arg);
+}
+static method test1([[@vm.inferred-type.metadata=dart.core::_Smi (value: 42)] core::int* arg = #C1]) → void {
+ core::print(arg);
+}
+static method test2({[@vm.inferred-type.metadata=dart.core::_Smi (value: 43)] core::int* arg = #C2}) → void {
+ core::print(arg);
+}
+static get getD() → dynamic
+ return 100.0;
+static method testDouble([@vm.inferred-type.metadata=dart.core::_Double (value: 3.14)] core::double* arg) → void {
+ core::print(arg);
+ core::print([@vm.inferred-type.metadata=dart.core::_Double (value: 100.0)] self::getD);
+}
+static method testStrings([@vm.inferred-type.metadata=#lib::A] self::A* a0, [@vm.inferred-type.metadata=dart.core::_OneByteString (value: bazz)] core::String* a1) → void {
+ core::print([@vm.direct-call.metadata=#lib::A::foo] [@vm.inferred-type.metadata=dart.core::_OneByteString (value: foo)] a0.{self::A::foo});
+ core::print([@vm.direct-call.metadata=#lib::A::getBar] [@vm.inferred-type.metadata=dart.core::_OneByteString (skip check) (value: bar)] a0.{self::A::getBar}());
+ core::print(a1);
+}
+static method testPassEnum([@vm.inferred-type.metadata=#lib::B (value: #lib::B {index: 1, #lib::_name: B.b2, })] self::B* arg) → void {
+ self::testPassEnum2(arg);
+}
+static method testPassEnum2([@vm.inferred-type.metadata=#lib::B (value: #lib::B {index: 1, #lib::_name: B.b2, })] self::B* arg) → void {
+ core::print(arg);
+}
+static method getList() → dynamic
+ return #C6;
+static method testList([@vm.inferred-type.metadata=dart.core::_ImmutableList (value: ListConstant<dart.core::int*>([1, 2, 3]))] dynamic arg1, [[@vm.inferred-type.metadata=dart.core::_ImmutableList (value: ListConstant<dart.core::int*>([4, 5]))] dynamic arg2 = #C9]) → void {
+ core::print(arg1);
+ core::print(arg2);
+}
+static method main() → dynamic {
+ self::test0(40);
+ self::test1();
+ self::test2();
+ self::testDouble(3.14);
+ self::testStrings(new self::A::•(), "bazz");
+ self::testPassEnum(#C11);
+ self::testList([@vm.inferred-type.metadata=dart.core::_ImmutableList (value: ListConstant<dart.core::int*>([1, 2, 3]))] self::getList());
+}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/devirt.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/devirt.dart.expect
index 23bd874..47da18a 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/devirt.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/devirt.dart.expect
@@ -48,7 +48,7 @@
static method callerA4([@vm.inferred-type.metadata=#lib::D?] self::A* aa) → void {
[@vm.direct-call.metadata=#lib::C::foo??] [@vm.inferred-type.metadata=!? (skip check)] aa.{self::A::foo}();
}
-static method callerE1([@vm.inferred-type.metadata=dart.core::_OneByteString] dynamic x) → void {
+static method callerE1([@vm.inferred-type.metadata=dart.core::_OneByteString (value: abc)] dynamic x) → void {
[@vm.direct-call.metadata=dart.core::_StringBase::toString] [@vm.inferred-type.metadata=!? (skip check)] x.{core::Object::toString}();
}
static method callerE2([@vm.inferred-type.metadata=#lib::E?] dynamic x) → void {
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/future.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/future.dart.expect
index 32d4ec1..59187c9 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/future.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/future.dart.expect
@@ -9,7 +9,7 @@
synthetic constructor •() → self::C<self::C::T*>*
: super core::Object::•()
;
-[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false] method test2c([@vm.inferred-type.metadata=dart.core::_Smi (skip check)] generic-covariant-impl asy::FutureOr<self::C::T*>* x) → void {}
+[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false] method test2c([@vm.inferred-type.metadata=dart.core::_Smi (skip check) (value: 3)] generic-covariant-impl asy::FutureOr<self::C::T*>* x) → void {}
[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false] method test3c([@vm.inferred-type.metadata=dart.async::_Future<dart.core::int*> (skip check)] generic-covariant-impl asy::Future<self::C::T*>* x) → void {}
[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false] method test4c([@vm.inferred-type.metadata=dart.async::_Future<dart.core::int*> (skip check)] generic-covariant-impl asy::FutureOr<self::C::T*>* x) → void {}
[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false] method test2r([@vm.inferred-type.metadata=#lib::C<dart.core::int*> (skip check)] generic-covariant-impl self::C<asy::FutureOr<self::C::T*>*>* x) → void {}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/future_or.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/future_or.dart.expect
index 4426ce7..2e9bc45 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/future_or.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/future_or.dart.expect
@@ -15,7 +15,7 @@
: super self::A::•()
;
}
-[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function* unknown;
+[@vm.inferred-type.metadata=dart.core::Null? (value: null)]static field core::Function* unknown;
static method foo1_a1([@vm.inferred-type.metadata=dart.async::_Future<#lib::B*>] dynamic x) → void {}
static method foo1_a2([@vm.inferred-type.metadata=#lib::B] dynamic x) → void {}
static method foo1_a3([@vm.inferred-type.metadata=dart.async::_Future<#lib::B*>] dynamic x) → void {}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_cycle.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_cycle.dart.expect
index 1efb873..fdc5ffb 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_cycle.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_cycle.dart.expect
@@ -27,7 +27,7 @@
synthetic constructor •() → self::_StreamImpl*
: super self::Stream::•()
;
-[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method foobar([@vm.inferred-type.metadata=dart.core::Null?] (dynamic) →* void onData, {[@vm.inferred-type.metadata=dart.core::Null?] core::Function* onError = #C1}) → self::StreamSubscription* {
+[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method foobar([@vm.inferred-type.metadata=dart.core::Null? (value: null)] (dynamic) →* void onData, {[@vm.inferred-type.metadata=dart.core::Null? (value: null)] core::Function* onError = #C1}) → self::StreamSubscription* {
return [@vm.inferred-type.metadata=!] this.{self::_StreamImpl::_createSubscription}();
}
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasNonThisUses:false,hasTearOffUses:false] method _createSubscription() → self::StreamSubscription* {
@@ -52,7 +52,7 @@
constructor •([@vm.inferred-type.metadata=!] self::Stream* stream) → self::StreamView*
: self::StreamView::_stream = stream, super self::Stream::•()
;
-[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasTearOffUses:false] method foobar([@vm.inferred-type.metadata=dart.core::Null?] (dynamic) →* void onData, {[@vm.inferred-type.metadata=dart.core::Null?] core::Function* onError = #C1}) → self::StreamSubscription* {
+[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasTearOffUses:false] method foobar([@vm.inferred-type.metadata=dart.core::Null? (value: null)] (dynamic) →* void onData, {[@vm.inferred-type.metadata=dart.core::Null? (value: null)] core::Function* onError = #C1}) → self::StreamSubscription* {
return [@vm.direct-call.metadata=#lib::StreamView::_stream] [@vm.inferred-type.metadata=!] this.{self::StreamView::_stream}.{self::Stream::foobar}(onData, onError: onError);
}
}
@@ -60,13 +60,13 @@
constructor •([@vm.inferred-type.metadata=!] self::Stream* stream) → self::ByteStream*
: super self::StreamView::•(stream)
;
-[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method super_foobar1([@vm.inferred-type.metadata=dart.core::Null?] (dynamic) →* void onData) → dynamic {
+[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method super_foobar1([@vm.inferred-type.metadata=dart.core::Null? (value: null)] (dynamic) →* void onData) → dynamic {
super.{self::StreamView::foobar}(onData);
}
-[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method super_foobar2([@vm.inferred-type.metadata=dart.core::Null?] (dynamic) →* void onData) → dynamic {
+[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method super_foobar2([@vm.inferred-type.metadata=dart.core::Null? (value: null)] (dynamic) →* void onData) → dynamic {
super.{self::StreamView::foobar}(onData);
}
-[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method super_foobar3({[@vm.inferred-type.metadata=dart.core::Null?] (dynamic) →* void onData = #C1, [@vm.inferred-type.metadata=dart.core::Null?] core::Function* onError = #C1}) → dynamic {
+[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method super_foobar3({[@vm.inferred-type.metadata=dart.core::Null? (value: null)] (dynamic) →* void onData = #C1, [@vm.inferred-type.metadata=dart.core::Null? (value: null)] core::Function* onError = #C1}) → dynamic {
super.{self::StreamView::foobar}(onData, onError: onError);
}
get super_stream() → self::Stream*
@@ -80,23 +80,23 @@
static method round0() → void {
new self::ByteStream::•(new self::ByteStream::•(new self::_GeneratedStreamImpl::•()));
}
-static method round1({[@vm.inferred-type.metadata=dart.core::Null?] (dynamic) →* void onData = #C1}) → void {
+static method round1({[@vm.inferred-type.metadata=dart.core::Null? (value: null)] (dynamic) →* void onData = #C1}) → void {
self::ByteStream* x = new self::ByteStream::•(new self::ByteStream::•(new self::_GeneratedStreamImpl::•()));
[@vm.direct-call.metadata=#lib::ByteStream::super_foobar1] [@vm.inferred-type.metadata=!? (skip check)] x.{self::ByteStream::super_foobar1}(onData);
}
-static method round2({[@vm.inferred-type.metadata=dart.core::Null?] (dynamic) →* void onData = #C1, [@vm.inferred-type.metadata=dart.core::Null?] core::Function* onError = #C1}) → void {
+static method round2({[@vm.inferred-type.metadata=dart.core::Null? (value: null)] (dynamic) →* void onData = #C1, [@vm.inferred-type.metadata=dart.core::Null? (value: null)] core::Function* onError = #C1}) → void {
new self::_ControllerStream::•();
self::Stream* x = new self::_GeneratedStreamImpl::•();
x = new self::ByteStream::•(x);
x.{self::Stream::foobar}(onData, onError: onError);
}
-static method round3({[@vm.inferred-type.metadata=dart.core::Null?] (dynamic) →* void onData = #C1, [@vm.inferred-type.metadata=dart.core::Null?] core::Function* onError = #C1}) → void {
+static method round3({[@vm.inferred-type.metadata=dart.core::Null? (value: null)] (dynamic) →* void onData = #C1, [@vm.inferred-type.metadata=dart.core::Null? (value: null)] core::Function* onError = #C1}) → void {
self::Stream* x = new self::_GeneratedStreamImpl::•();
x = new self::ByteStream::•(x);
x = new self::_ControllerStream::•();
x.{self::Stream::foobar}(onData, onError: onError);
}
-static method round4({[@vm.inferred-type.metadata=dart.core::Null?] (dynamic) →* void onData = #C1}) → void {
+static method round4({[@vm.inferred-type.metadata=dart.core::Null? (value: null)] (dynamic) →* void onData = #C1}) → void {
self::ByteStream* x = new self::ByteStream::•(new self::_ControllerStream::•());
self::Stream* y = [@vm.direct-call.metadata=#lib::ByteStream::super_stream] [@vm.inferred-type.metadata=!] x.{self::ByteStream::super_stream};
self::Stream* z = [@vm.direct-call.metadata=#lib::StreamView::_stream] [@vm.inferred-type.metadata=!] x.{self::StreamView::_stream};
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect
index 1b9657b..21d4662 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect
@@ -61,7 +61,7 @@
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasNonThisUses:false,hasTearOffUses:false] method barL4([@vm.inferred-type.metadata=#lib::D] self::D* dd) → dynamic
return [@vm.direct-call.metadata=#lib::D::field2] [@vm.inferred-type.metadata=!] dd.{self::D::field2};
}
-[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function* unknown;
+[@vm.inferred-type.metadata=dart.core::Null? (value: null)]static field core::Function* unknown;
static field core::Object* field1 = [@vm.inferred-type.metadata=!] self::getValue();
static method getDynamic() → dynamic
return [@vm.call-site-attributes.metadata=receiverType:dart.core::Function*] self::unknown.call();
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class1.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class1.dart.expect
index 1a6e574..934ad1b 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class1.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class1.dart.expect
@@ -27,7 +27,7 @@
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method bar([@vm.inferred-type.metadata=#lib::B?] self::A* aa) → dynamic
return [@vm.direct-call.metadata=#lib::B::foo??] [@vm.inferred-type.metadata=#lib::T1 (skip check)] aa.{self::A::foo}();
}
-[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function* unknown;
+[@vm.inferred-type.metadata=dart.core::Null? (value: null)]static field core::Function* unknown;
static method use1([@vm.inferred-type.metadata=#lib::Intermediate] self::Intermediate* i, [@vm.inferred-type.metadata=#lib::B?] self::A* aa) → dynamic
return [@vm.direct-call.metadata=#lib::Intermediate::bar] [@vm.inferred-type.metadata=#lib::T1 (skip check)] i.{self::Intermediate::bar}(aa);
static method use2([@vm.inferred-type.metadata=#lib::Intermediate] self::Intermediate* i, [@vm.inferred-type.metadata=#lib::B?] self::A* aa) → dynamic
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class2.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class2.dart.expect
index 9ecc788..7c66149 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class2.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_class2.dart.expect
@@ -51,7 +51,7 @@
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method bar(self::A* aa) → dynamic
return [@vm.inferred-type.metadata=!] aa.{self::A::foo}();
}
-[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function* unknown;
+[@vm.inferred-type.metadata=dart.core::Null? (value: null)]static field core::Function* unknown;
static method use1([@vm.inferred-type.metadata=#lib::Intermediate] self::Intermediate* i, self::A* aa) → dynamic
return [@vm.direct-call.metadata=#lib::Intermediate::bar] [@vm.inferred-type.metadata=! (skip check)] i.{self::Intermediate::bar}(aa);
static method use2([@vm.inferred-type.metadata=#lib::Intermediate] self::Intermediate* i, self::A* aa) → dynamic
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_dynamic_target.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_dynamic_target.dart.expect
index 3eed2e7..c1b42e3 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_dynamic_target.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_new_dynamic_target.dart.expect
@@ -39,7 +39,7 @@
[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false] method bazz() → dynamic
return new self::T3::•();
}
-[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function* unknown;
+[@vm.inferred-type.metadata=dart.core::Null? (value: null)]static field core::Function* unknown;
static method use_foo1(dynamic x) → dynamic
return [@vm.inferred-type.metadata=#lib::T1] x.foo();
static method use_foo2(dynamic x) → dynamic
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect
index 277cd40..cd59c76 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect
@@ -45,7 +45,7 @@
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasNonThisUses:false,hasTearOffUses:false] method barL4([@vm.inferred-type.metadata=#lib::A?] self::A* aa) → dynamic
return [@vm.direct-call.metadata=#lib::A::field2??] [@vm.inferred-type.metadata=!] aa.{self::A::field2};
}
-[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function* unknown;
+[@vm.inferred-type.metadata=dart.core::Null? (value: null)]static field core::Function* unknown;
static method use1([@vm.inferred-type.metadata=#lib::DeepCaller1] self::DeepCaller1* x, [@vm.inferred-type.metadata=#lib::A?] self::A* aa) → dynamic
return [@vm.direct-call.metadata=#lib::DeepCaller1::barL1] [@vm.inferred-type.metadata=#lib::T1 (skip check)] x.{self::DeepCaller1::barL1}(aa);
static method use2([@vm.inferred-type.metadata=#lib::DeepCaller2] self::DeepCaller2* x, [@vm.inferred-type.metadata=#lib::A?] self::A* aa) → dynamic
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/no_such_method.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/no_such_method.dart.expect
index 5425f6a..5a3cf29 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/no_such_method.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/no_such_method.dart.expect
@@ -52,7 +52,7 @@
return _in::unsafeCast<dynamic>([@vm.direct-call.metadata=#lib::B::noSuchMethod] [@vm.inferred-type.metadata=#lib::T1 (skip check)] this.{self::B::noSuchMethod}(new core::_InvocationMirror::_withType(#C2, 1, #C3, #C4, [@vm.inferred-type.metadata=dart.collection::UnmodifiableMapView<dart.core::Symbol*, dynamic>] core::Map::unmodifiable<core::Symbol*, dynamic>(#C5))));
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] no-such-method-forwarder method foo() → dynamic
return _in::unsafeCast<dynamic>([@vm.direct-call.metadata=#lib::B::noSuchMethod] [@vm.inferred-type.metadata=#lib::T1 (skip check)] this.{self::B::noSuchMethod}(new core::_InvocationMirror::_withType(#C6, 0, #C3, #C4, [@vm.inferred-type.metadata=dart.collection::UnmodifiableMapView<dart.core::Symbol*, dynamic>] core::Map::unmodifiable<core::Symbol*, dynamic>(#C5))));
-[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] no-such-method-forwarder method bazz([@vm.inferred-type.metadata=dart.core::_Smi] dynamic a1, [@vm.inferred-type.metadata=dart.core::_Smi] dynamic a2, [@vm.inferred-type.metadata=dart.core::_Smi] dynamic a3, [[@vm.inferred-type.metadata=dart.core::_Smi] dynamic a4 = #C1, [@vm.inferred-type.metadata=dart.core::Null?] dynamic a5 = #C1]) → dynamic
+[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] no-such-method-forwarder method bazz([@vm.inferred-type.metadata=dart.core::_Smi (value: 1)] dynamic a1, [@vm.inferred-type.metadata=dart.core::_Smi (value: 2)] dynamic a2, [@vm.inferred-type.metadata=dart.core::_Smi (value: 3)] dynamic a3, [[@vm.inferred-type.metadata=dart.core::_Smi (value: 4)] dynamic a4 = #C1, [@vm.inferred-type.metadata=dart.core::Null? (value: null)] dynamic a5 = #C1]) → dynamic
return _in::unsafeCast<dynamic>([@vm.direct-call.metadata=#lib::B::noSuchMethod] [@vm.inferred-type.metadata=#lib::T1 (skip check)] this.{self::B::noSuchMethod}(new core::_InvocationMirror::_withType(#C7, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[a1, a2, a3, a4, a5]), [@vm.inferred-type.metadata=dart.collection::UnmodifiableMapView<dart.core::Symbol*, dynamic>] core::Map::unmodifiable<core::Symbol*, dynamic>(#C5))));
}
abstract class C extends core::Object {
@@ -71,7 +71,7 @@
return _in::unsafeCast<dynamic>([@vm.direct-call.metadata=#lib::C::noSuchMethod] [@vm.inferred-type.metadata=#lib::T2 (skip check)] this.{self::C::noSuchMethod}(new core::_InvocationMirror::_withType(#C2, 1, #C3, #C4, [@vm.inferred-type.metadata=dart.collection::UnmodifiableMapView<dart.core::Symbol*, dynamic>] core::Map::unmodifiable<core::Symbol*, dynamic>(#C5))));
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] no-such-method-forwarder method foo() → dynamic
return _in::unsafeCast<dynamic>([@vm.direct-call.metadata=#lib::C::noSuchMethod] [@vm.inferred-type.metadata=#lib::T2 (skip check)] this.{self::C::noSuchMethod}(new core::_InvocationMirror::_withType(#C6, 0, #C3, #C4, [@vm.inferred-type.metadata=dart.collection::UnmodifiableMapView<dart.core::Symbol*, dynamic>] core::Map::unmodifiable<core::Symbol*, dynamic>(#C5))));
-[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] no-such-method-forwarder method bazz([@vm.inferred-type.metadata=dart.core::_Smi] dynamic a1, [@vm.inferred-type.metadata=dart.core::_Smi] dynamic a2, [@vm.inferred-type.metadata=dart.core::_Smi] dynamic a3, [[@vm.inferred-type.metadata=dart.core::_Smi] dynamic a4 = #C1, [@vm.inferred-type.metadata=dart.core::Null?] dynamic a5 = #C1]) → dynamic
+[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] no-such-method-forwarder method bazz([@vm.inferred-type.metadata=dart.core::_Smi (value: 1)] dynamic a1, [@vm.inferred-type.metadata=dart.core::_Smi (value: 2)] dynamic a2, [@vm.inferred-type.metadata=dart.core::_Smi (value: 3)] dynamic a3, [[@vm.inferred-type.metadata=dart.core::_Smi (value: 4)] dynamic a4 = #C1, [@vm.inferred-type.metadata=dart.core::Null? (value: null)] dynamic a5 = #C1]) → dynamic
return _in::unsafeCast<dynamic>([@vm.direct-call.metadata=#lib::C::noSuchMethod] [@vm.inferred-type.metadata=#lib::T2 (skip check)] this.{self::C::noSuchMethod}(new core::_InvocationMirror::_withType(#C7, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[a1, a2, a3, a4, a5]), [@vm.inferred-type.metadata=dart.collection::UnmodifiableMapView<dart.core::Symbol*, dynamic>] core::Map::unmodifiable<core::Symbol*, dynamic>(#C5))));
}
class E extends core::Object implements self::A {
@@ -104,7 +104,7 @@
synthetic constructor •() → self::H*
: super core::Object::•()
;
-[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false] method foo({[@vm.inferred-type.metadata=dart.core::_Smi] dynamic left = #C1, [@vm.inferred-type.metadata=dart.core::_Smi] dynamic right = #C1}) → dynamic
+[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false] method foo({[@vm.inferred-type.metadata=dart.core::_Smi (value: 1)] dynamic left = #C1, [@vm.inferred-type.metadata=dart.core::_Smi (value: 2)] dynamic right = #C1}) → dynamic
return new self::T6::•();
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasTearOffUses:false] method noSuchMethod(core::Invocation* invocation) → dynamic {
return new self::T7::•();
@@ -112,7 +112,7 @@
}
[@vm.inferred-type.metadata=#lib::B?]static field self::A* bb = new self::B::•();
[@vm.inferred-type.metadata=#lib::D?]static field self::A* dd = new self::D::•();
-[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function* unknown;
+[@vm.inferred-type.metadata=dart.core::Null? (value: null)]static field core::Function* unknown;
static method getDynamic() → dynamic
return [@vm.call-site-attributes.metadata=receiverType:dart.core::Function*] self::unknown.call();
static method main(core::List<core::String*>* args) → dynamic {
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/param_types_before_strong_mode_checks.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/param_types_before_strong_mode_checks.dart.expect
index d02ed1d..9fbf8c0 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/param_types_before_strong_mode_checks.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/param_types_before_strong_mode_checks.dart.expect
@@ -41,7 +41,7 @@
[@vm.direct-call.metadata=#lib::T2::foo??] [@vm.inferred-type.metadata=!? (skip check)] t0.{self::T0::foo}();
}
}
-[@vm.inferred-type.metadata=dart.core::Null?]static field core::Function* unknown;
+[@vm.inferred-type.metadata=dart.core::Null? (value: null)]static field core::Function* unknown;
static method func1([@vm.inferred-type.metadata=#lib::T2?] self::T0* t0) → void {
[@vm.direct-call.metadata=#lib::T2::foo??] [@vm.inferred-type.metadata=!? (skip check)] t0.{self::T0::foo}();
}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/regress_37719.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/regress_37719.dart.expect
index adc2258..2cbbfed 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/regress_37719.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/regress_37719.dart.expect
@@ -5,4 +5,4 @@
static method foo([@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::List<core::int*>* x) → dynamic
return [@vm.direct-call.metadata=dart.core::_IntegerImplementation::+] [@vm.inferred-type.metadata=int (skip check)] 1.{core::num::+}([@vm.direct-call.metadata=dart.core::_GrowableList::[]] [@vm.inferred-type.metadata=int? (skip check)] x.{core::List::[]}(0));
static method main() → dynamic
- return [@vm.inferred-type.metadata=dart.core::Null?] core::print([@vm.inferred-type.metadata=int] self::foo(<core::int*>[1]));
+ return [@vm.inferred-type.metadata=dart.core::Null? (value: null)] core::print([@vm.inferred-type.metadata=int] self::foo(<core::int*>[1]));
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_interface_method.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_interface_method.dart.expect
index 67aa12d..7423d9e 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_interface_method.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/tear_off_interface_method.dart.expect
@@ -14,7 +14,7 @@
: super self::A::•()
;
[@vm.procedure-attributes.metadata=hasDynamicUses:false,hasThisUses:false,hasNonThisUses:false] method foo() → core::int*
- return _in::unsafeCast<core::int*>([@vm.direct-call.metadata=dart.core::_IntegerImplementation::+] [@vm.inferred-type.metadata=int (skip check)] 1.{core::num::+}(_in::unsafeCast<core::num*>([@vm.direct-call.metadata=#lib::B::bar] [@vm.inferred-type.metadata=dart.core::_Smi] [@vm.inferred-type.metadata=#lib::B] self::knownResult().bar())));
+ return _in::unsafeCast<core::int*>([@vm.direct-call.metadata=dart.core::_IntegerImplementation::+] [@vm.inferred-type.metadata=int (skip check)] 1.{core::num::+}(_in::unsafeCast<core::num*>([@vm.direct-call.metadata=#lib::B::bar] [@vm.inferred-type.metadata=dart.core::_Smi (value: 3)] [@vm.inferred-type.metadata=#lib::B] self::knownResult().bar())));
[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false] method bar() → core::int*
return 3;
}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/unfinished_static_field_init.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/unfinished_static_field_init.dart.expect
index 11b242e..74d3bb3 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/unfinished_static_field_init.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/unfinished_static_field_init.dart.expect
@@ -8,12 +8,12 @@
;
}
[@vm.inferred-type.metadata=#lib::A?]static field dynamic static_field_good = [@vm.inferred-type.metadata=#lib::A] self::good();
-[@vm.inferred-type.metadata=dart.core::Null?]static field dynamic static_field_bad = [@vm.inferred-type.metadata=!] self::bad();
+[@vm.inferred-type.metadata=dart.core::Null? (value: null)]static field dynamic static_field_bad = [@vm.inferred-type.metadata=!] self::bad();
static method good() → dynamic
return new self::A::•();
static method bad() → dynamic
return throw "No return!";
static method main(core::List<core::String*>* args) → dynamic {
core::print([@vm.inferred-type.metadata=#lib::A?] self::static_field_good);
- core::print([@vm.inferred-type.metadata=dart.core::Null?] self::static_field_bad);
+ core::print([@vm.inferred-type.metadata=dart.core::Null? (value: null)] self::static_field_bad);
}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field.dart.expect
index c856b98..4cfb596 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field.dart.expect
@@ -16,7 +16,7 @@
: super core::Object::•()
;
}
-[@vm.inferred-type.metadata=dart.core::Null?]static field self::A* field = throw "Attempt to execute code removed by Dart AOT compiler (TFA)";
+[@vm.inferred-type.metadata=dart.core::Null? (value: null)]static field self::A* field = throw "Attempt to execute code removed by Dart AOT compiler (TFA)";
static method main() → void {
self::field = null;
[@vm.direct-call.metadata=#lib::C::instanceField] new self::C::•().{self::C::instanceField} = null;
diff --git a/pkg/vm/testcases/transformations/unreachable_code_elimination/uce_testcases.dart.expect b/pkg/vm/testcases/transformations/unreachable_code_elimination/uce_testcases.dart.expect
index 075f92e..bea1e0c 100644
--- a/pkg/vm/testcases/transformations/unreachable_code_elimination/uce_testcases.dart.expect
+++ b/pkg/vm/testcases/transformations/unreachable_code_elimination/uce_testcases.dart.expect
@@ -1,6 +1,7 @@
library #lib;
import self as self;
import "dart:core" as core;
+import "dart:_internal" as _in;
class TestAssertInitializer extends core::Object {
constructor •() → self::TestAssertInitializer*
@@ -56,7 +57,11 @@
while (self::foo())
for (; ; ) {
}
- for (core::int* i in <core::int*>[1, 2]) {
+ {
+ core::Iterator<core::int*>* :sync-for-iterator = _in::unsafeCast<core::Iterable<core::int*>*>(<core::int*>[1, 2]).{core::Iterable::iterator};
+ for (; :sync-for-iterator.{core::Iterator::moveNext}(); ) {
+ core::int* i = :sync-for-iterator.{core::Iterator::current};
+ }
}
try {
}
diff --git a/pkg/vm_service/CHANGELOG.md b/pkg/vm_service/CHANGELOG.md
index 98241e7..4dcc594 100644
--- a/pkg/vm_service/CHANGELOG.md
+++ b/pkg/vm_service/CHANGELOG.md
@@ -1,4 +1,14 @@
# Changelog
+## 2.1.3
+- Fixed issue where exception would be thrown when attempting to parse a
+ List entry in a response which is not present. This occurs when connected to
+ a service which does not yet support the latest service protocol supported by
+ this package.
+
+## 2.1.2
+- Requests which have not yet completed when `VmService.dispose` is invoked will
+ now complete with an `RPCError` exception rather than a `String` exception.
+
## 2.1.1
- Added `getLineNumberFromTokenPos` and `getColumnNumberFromTokenPos` methods
to `Script`.
diff --git a/pkg/vm_service/lib/vm_service.dart b/pkg/vm_service/lib/vm_service.dart
index c77250b5..b35fb4a 100644
--- a/pkg/vm_service/lib/vm_service.dart
+++ b/pkg/vm_service/lib/vm_service.dart
@@ -1749,7 +1749,11 @@
void dispose() {
_streamSub.cancel();
- _completers.values.forEach((c) => c.completeError('disposed'));
+ _completers.forEach((id, c) {
+ final method = _methodCalls[id];
+ return c.completeError(
+ RPCError(method, -32000, 'Service connection disposed'));
+ });
_completers.clear();
if (_disposeHandler != null) {
_disposeHandler();
@@ -2275,7 +2279,7 @@
AllocationProfile._fromJson(Map<String, dynamic> json)
: super._fromJson(json) {
members = List<ClassHeapStats>.from(
- createServiceObject(json['members'], const ['ClassHeapStats']));
+ createServiceObject(json['members'], const ['ClassHeapStats']) ?? []);
memoryUsage =
createServiceObject(json['memoryUsage'], const ['MemoryUsage']);
dateLastAccumulatorReset = json['dateLastAccumulatorReset'] is String
@@ -2583,14 +2587,14 @@
superClass = createServiceObject(json['super'], const ['ClassRef']);
superType = createServiceObject(json['superType'], const ['InstanceRef']);
interfaces = List<InstanceRef>.from(
- createServiceObject(json['interfaces'], const ['InstanceRef']));
+ createServiceObject(json['interfaces'], const ['InstanceRef']) ?? []);
mixin = createServiceObject(json['mixin'], const ['InstanceRef']);
fields = List<FieldRef>.from(
- createServiceObject(json['fields'], const ['FieldRef']));
+ createServiceObject(json['fields'], const ['FieldRef']) ?? []);
functions = List<FuncRef>.from(
- createServiceObject(json['functions'], const ['FuncRef']));
+ createServiceObject(json['functions'], const ['FuncRef']) ?? []);
subclasses = List<ClassRef>.from(
- createServiceObject(json['subclasses'], const ['ClassRef']));
+ createServiceObject(json['subclasses'], const ['ClassRef']) ?? []);
}
@override
@@ -2688,7 +2692,7 @@
});
ClassList._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
classes = List<ClassRef>.from(
- createServiceObject(json['classes'], const ['ClassRef']));
+ createServiceObject(json['classes'], const ['ClassRef']) ?? []);
}
@override
@@ -2839,7 +2843,7 @@
length = json['length'];
parent = createServiceObject(json['parent'], const ['Context']);
variables = List<ContextElement>.from(
- createServiceObject(json['variables'], const ['ContextElement']));
+ createServiceObject(json['variables'], const ['ContextElement']) ?? []);
}
@override
@@ -2944,9 +2948,10 @@
timeExtentMicros = json['timeExtentMicros'];
pid = json['pid'];
functions = List<ProfileFunction>.from(
- createServiceObject(json['functions'], const ['ProfileFunction']));
+ createServiceObject(json['functions'], const ['ProfileFunction']) ??
+ []);
samples = List<CpuSample>.from(
- createServiceObject(json['samples'], const ['CpuSample']));
+ createServiceObject(json['samples'], const ['CpuSample']) ?? []);
}
@override
@@ -3626,7 +3631,8 @@
@required this.flags,
});
FlagList._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
- flags = List<Flag>.from(createServiceObject(json['flags'], const ['Flag']));
+ flags = List<Flag>.from(
+ createServiceObject(json['flags'], const ['Flag']) ?? []);
}
@override
@@ -4455,9 +4461,9 @@
pauseEvent = createServiceObject(json['pauseEvent'], const ['Event']);
rootLib = createServiceObject(json['rootLib'], const ['LibraryRef']);
libraries = List<LibraryRef>.from(
- createServiceObject(json['libraries'], const ['LibraryRef']));
+ createServiceObject(json['libraries'], const ['LibraryRef']) ?? []);
breakpoints = List<Breakpoint>.from(
- createServiceObject(json['breakpoints'], const ['Breakpoint']));
+ createServiceObject(json['breakpoints'], const ['Breakpoint']) ?? []);
error = createServiceObject(json['error'], const ['Error']);
exceptionPauseMode = json['exceptionPauseMode'];
extensionRPCs = json['extensionRPCs'] == null
@@ -4570,7 +4576,7 @@
number = json['number'];
name = json['name'];
isolates = List<IsolateRef>.from(
- createServiceObject(json['isolates'], const ['IsolateRef']));
+ createServiceObject(json['isolates'], const ['IsolateRef']) ?? []);
}
@override
@@ -4609,7 +4615,8 @@
InboundReferences._fromJson(Map<String, dynamic> json)
: super._fromJson(json) {
references = List<InboundReference>.from(
- createServiceObject(json['references'], const ['InboundReference']));
+ createServiceObject(json['references'], const ['InboundReference']) ??
+ []);
}
@override
@@ -4791,13 +4798,13 @@
dependencies = List<LibraryDependency>.from(
_createSpecificObject(json['dependencies'], LibraryDependency.parse));
scripts = List<ScriptRef>.from(
- createServiceObject(json['scripts'], const ['ScriptRef']));
+ createServiceObject(json['scripts'], const ['ScriptRef']) ?? []);
variables = List<FieldRef>.from(
- createServiceObject(json['variables'], const ['FieldRef']));
+ createServiceObject(json['variables'], const ['FieldRef']) ?? []);
functions = List<FuncRef>.from(
- createServiceObject(json['functions'], const ['FuncRef']));
+ createServiceObject(json['functions'], const ['FuncRef']) ?? []);
classes = List<ClassRef>.from(
- createServiceObject(json['classes'], const ['ClassRef']));
+ createServiceObject(json['classes'], const ['ClassRef']) ?? []);
}
@override
@@ -5454,7 +5461,7 @@
length = json['length'];
gcRootType = json['gcRootType'];
elements = List<RetainingObject>.from(
- createServiceObject(json['elements'], const ['RetainingObject']));
+ createServiceObject(json['elements'], const ['RetainingObject']) ?? []);
}
@override
@@ -5715,7 +5722,7 @@
});
ScriptList._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
scripts = List<ScriptRef>.from(
- createServiceObject(json['scripts'], const ['ScriptRef']));
+ createServiceObject(json['scripts'], const ['ScriptRef']) ?? []);
}
@override
@@ -5801,7 +5808,7 @@
ranges = List<SourceReportRange>.from(
_createSpecificObject(json['ranges'], SourceReportRange.parse));
scripts = List<ScriptRef>.from(
- createServiceObject(json['scripts'], const ['ScriptRef']));
+ createServiceObject(json['scripts'], const ['ScriptRef']) ?? []);
}
@override
@@ -5961,8 +5968,8 @@
this.awaiterFrames,
});
Stack._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
- frames =
- List<Frame>.from(createServiceObject(json['frames'], const ['Frame']));
+ frames = List<Frame>.from(
+ createServiceObject(json['frames'], const ['Frame']) ?? []);
asyncCausalFrames = json['asyncCausalFrames'] == null
? null
: List<Frame>.from(
@@ -5972,7 +5979,7 @@
: List<Frame>.from(
createServiceObject(json['awaiterFrames'], const ['Frame']));
messages = List<Message>.from(
- createServiceObject(json['messages'], const ['Message']));
+ createServiceObject(json['messages'], const ['Message']) ?? []);
}
@override
@@ -6033,7 +6040,8 @@
});
Timeline._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
traceEvents = List<TimelineEvent>.from(
- createServiceObject(json['traceEvents'], const ['TimelineEvent']));
+ createServiceObject(json['traceEvents'], const ['TimelineEvent']) ??
+ []);
timeOriginMicros = json['timeOriginMicros'];
timeExtentMicros = json['timeExtentMicros'];
}
@@ -6198,7 +6206,7 @@
TypeArguments._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
name = json['name'];
types = List<InstanceRef>.from(
- createServiceObject(json['types'], const ['InstanceRef']));
+ createServiceObject(json['types'], const ['InstanceRef']) ?? []);
}
@override
@@ -6412,9 +6420,10 @@
pid = json['pid'];
startTime = json['startTime'];
isolates = List<IsolateRef>.from(
- createServiceObject(json['isolates'], const ['IsolateRef']));
+ createServiceObject(json['isolates'], const ['IsolateRef']) ?? []);
isolateGroups = List<IsolateGroupRef>.from(
- createServiceObject(json['isolateGroups'], const ['IsolateGroupRef']));
+ createServiceObject(json['isolateGroups'], const ['IsolateGroupRef']) ??
+ []);
}
@override
diff --git a/pkg/vm_service/pubspec.yaml b/pkg/vm_service/pubspec.yaml
index e570276..bf8c4da 100644
--- a/pkg/vm_service/pubspec.yaml
+++ b/pkg/vm_service/pubspec.yaml
@@ -2,9 +2,8 @@
description: >-
A library to communicate with a service implementing the Dart VM
service protocol.
-version: 2.1.1
+version: 2.1.3
-author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/vm_service
environment:
diff --git a/pkg/vm_service/tool/dart/generate_dart.dart b/pkg/vm_service/tool/dart/generate_dart.dart
index c85e941..13eb06f 100644
--- a/pkg/vm_service/tool/dart/generate_dart.dart
+++ b/pkg/vm_service/tool/dart/generate_dart.dart
@@ -103,7 +103,11 @@
void dispose() {
_streamSub.cancel();
- _completers.values.forEach((c) => c.completeError('disposed'));
+ _completers.forEach((id, c) {
+ final method = _methodCalls[id];
+ return c.completeError(
+ RPCError(method, -32000, 'Service connection disposed'));
+ });
_completers.clear();
if (_disposeHandler != null) {
_disposeHandler();
@@ -1461,7 +1465,7 @@
"List<${fieldType.listTypeArg}>.from(createServiceObject($ref ?? json['samples'], $typesList));");
} else {
gen.writeln("${field.generatableName} = "
- "List<${fieldType.listTypeArg}>.from(createServiceObject($ref, $typesList));");
+ "List<${fieldType.listTypeArg}>.from(createServiceObject($ref, $typesList) ?? []);");
}
}
}
diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn
index 50a049d..3ab24c4 100644
--- a/runtime/bin/BUILD.gn
+++ b/runtime/bin/BUILD.gn
@@ -1120,8 +1120,14 @@
deps = [
":dart",
]
+
+ # The two files here do not depend on each other.
+ # flutter/flutter integration tests will only use `ffi_test_functions.cc` -
+ # any test functionality using `dart_api.h` has to go into
+ # `ffi_test_functions_vmspecific.cc`.
sources = [
"ffi_test/ffi_test_functions.cc",
+ "ffi_test/ffi_test_functions_vmspecific.cc",
]
if (is_win && current_cpu == "x64") {
sources += [ "ffi_test/clobber_x64_win.S" ]
diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc
index d85f6f3..4331e19 100644
--- a/runtime/bin/dartutils.cc
+++ b/runtime/bin/dartutils.cc
@@ -524,21 +524,10 @@
return Builtin::SetLoadPort(load_port);
}
-Dart_Handle DartUtils::SetupPackageRoot(const char* package_root,
- const char* packages_config) {
+Dart_Handle DartUtils::SetupPackageConfig(const char* packages_config) {
Dart_Handle result = Dart_Null();
- // Set up package root if specified.
- if (package_root != NULL) {
- ASSERT(packages_config == NULL);
- result = NewString(package_root);
- RETURN_IF_ERROR(result);
- const int kNumArgs = 1;
- Dart_Handle dart_args[kNumArgs];
- dart_args[0] = result;
- result = Dart_Invoke(DartUtils::LookupBuiltinLib(),
- NewString("_setPackageRoot"), kNumArgs, dart_args);
- } else if (packages_config != NULL) {
+ if (packages_config != NULL) {
result = NewString(packages_config);
RETURN_IF_ERROR(result);
const int kNumArgs = 1;
@@ -635,6 +624,7 @@
Dart_SetField(platform_type, script_name, dart_script);
RETURN_IF_ERROR(set_script_name);
+#if !defined(PRODUCT)
Dart_Handle network_profiling_type =
GetDartType(DartUtils::kIOLibURL, "_NetworkProfiling");
RETURN_IF_ERROR(network_profiling_type);
@@ -642,7 +632,7 @@
Dart_Invoke(network_profiling_type,
NewString("_registerServiceExtension"), 0, nullptr);
RETURN_IF_ERROR(result);
-
+#endif // !defined(PRODUCT)
return Dart_Null();
}
diff --git a/runtime/bin/dartutils.h b/runtime/bin/dartutils.h
index 6dd1c5b..10cfa71 100644
--- a/runtime/bin/dartutils.h
+++ b/runtime/bin/dartutils.h
@@ -152,8 +152,8 @@
static Dart_Handle PrepareForScriptLoading(bool is_service_isolate,
bool trace_loading);
static Dart_Handle SetupServiceLoadPort();
- static Dart_Handle SetupPackageRoot(const char* package_root,
- const char* packages_file);
+ static Dart_Handle SetupPackageConfig(const char* packages_file);
+
static Dart_Handle SetupIOLibrary(const char* namespc_path,
const char* script_uri,
bool disable_exit);
diff --git a/runtime/bin/ffi_test/ffi_test_dynamic_library.cc b/runtime/bin/ffi_test/ffi_test_dynamic_library.cc
index c925300..c812c6d 100644
--- a/runtime/bin/ffi_test/ffi_test_dynamic_library.cc
+++ b/runtime/bin/ffi_test/ffi_test_dynamic_library.cc
@@ -2,7 +2,12 @@
// 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.
-#include "include/dart_api.h"
+#if defined(_WIN32)
+#define DART_EXPORT extern "C" __declspec(dllexport)
+#else
+#define DART_EXPORT \
+ extern "C" __attribute__((visibility("default"))) __attribute((used))
+#endif
DART_EXPORT int return42() {
return 42;
diff --git a/runtime/bin/ffi_test/ffi_test_functions.cc b/runtime/bin/ffi_test/ffi_test_functions.cc
index f673f13..0f52f7c 100644
--- a/runtime/bin/ffi_test/ffi_test_functions.cc
+++ b/runtime/bin/ffi_test/ffi_test_functions.cc
@@ -3,32 +3,24 @@
// BSD-style license that can be found in the LICENSE file.
// This file contains test functions for the dart:ffi test cases.
+// This file is not allowed to depend on any symbols from the embedder and is
+// therefore not allowed to use `dart_api.h`. (The flutter/flutter integration
+// tests will run dart tests using this library only.)
#include <stddef.h>
#include <stdlib.h>
#include <sys/types.h>
-#include <csignal>
-#include "platform/globals.h"
-#if defined(HOST_OS_WINDOWS)
-#include <psapi.h>
-#else
-#include <unistd.h>
-
-// Only OK to use here because this is test code.
-#include <condition_variable> // NOLINT(build/c++11)
-#include <functional> // NOLINT(build/c++11)
-#include <mutex> // NOLINT(build/c++11)
-#include <thread> // NOLINT(build/c++11)
-#endif
-
-#include <setjmp.h>
-#include <signal.h>
+#include <cmath>
#include <iostream>
#include <limits>
-#include "include/dart_api.h"
-#include "include/dart_native_api.h"
+#if defined(_WIN32)
+#define DART_EXPORT extern "C" __declspec(dllexport)
+#else
+#define DART_EXPORT \
+ extern "C" __attribute__((visibility("default"))) __attribute((used))
+#endif
namespace dart {
@@ -108,7 +100,7 @@
}
DART_EXPORT intptr_t TakeMinInt32(int32_t x) {
- const int64_t expected = kMinInt32;
+ const int64_t expected = INT32_MIN;
const int64_t received = x;
return expected == received ? 1 : 0;
}
@@ -510,125 +502,6 @@
}
////////////////////////////////////////////////////////////////////////////////
-// Functions for stress-testing.
-
-DART_EXPORT int64_t MinInt64() {
- Dart_ExecuteInternalCommand("gc-on-nth-allocation",
- reinterpret_cast<void*>(1));
- return 0x8000000000000000;
-}
-
-DART_EXPORT int64_t MinInt32() {
- Dart_ExecuteInternalCommand("gc-on-nth-allocation",
- reinterpret_cast<void*>(1));
- return 0x80000000;
-}
-
-DART_EXPORT double SmallDouble() {
- Dart_ExecuteInternalCommand("gc-on-nth-allocation",
- reinterpret_cast<void*>(1));
- return 0x80000000 * -1.0;
-}
-
-// Requires boxing on 32-bit and 64-bit systems, even if the top 32-bits are
-// truncated.
-DART_EXPORT void* LargePointer() {
- Dart_ExecuteInternalCommand("gc-on-nth-allocation",
- reinterpret_cast<void*>(1));
- uint64_t origin = 0x8100000082000000;
- return reinterpret_cast<void*>(origin);
-}
-
-DART_EXPORT void TriggerGC(uint64_t count) {
- Dart_ExecuteInternalCommand("gc-now", nullptr);
-}
-
-DART_EXPORT void CollectOnNthAllocation(intptr_t num_allocations) {
- Dart_ExecuteInternalCommand("gc-on-nth-allocation",
- reinterpret_cast<void*>(num_allocations));
-}
-
-// Triggers GC. Has 11 dummy arguments as unboxed odd integers which should be
-// ignored by GC.
-DART_EXPORT void Regress37069(uint64_t a,
- uint64_t b,
- uint64_t c,
- uint64_t d,
- uint64_t e,
- uint64_t f,
- uint64_t g,
- uint64_t h,
- uint64_t i,
- uint64_t j,
- uint64_t k) {
- Dart_ExecuteInternalCommand("gc-now", nullptr);
-}
-
-#if !defined(HOST_OS_WINDOWS)
-DART_EXPORT void* UnprotectCodeOtherThread(void* isolate,
- std::condition_variable* var,
- std::mutex* mut) {
- std::function<void()> callback = [&]() {
- mut->lock();
- var->notify_all();
- mut->unlock();
-
- // Wait for mutator thread to continue (and block) before leaving the
- // safepoint.
- while (Dart_ExecuteInternalCommand("is-mutator-in-native", isolate) !=
- nullptr) {
- usleep(10 * 1000 /*10 ms*/);
- }
- };
-
- struct {
- void* isolate;
- std::function<void()>* callback;
- } args = {.isolate = isolate, .callback = &callback};
-
- Dart_ExecuteInternalCommand("run-in-safepoint-and-rw-code", &args);
- return nullptr;
-}
-
-struct HelperThreadState {
- std::mutex mutex;
- std::condition_variable cvar;
- std::unique_ptr<std::thread> helper;
-};
-
-DART_EXPORT void* TestUnprotectCode(void (*fn)(void*)) {
- HelperThreadState* state = new HelperThreadState;
-
- {
- std::unique_lock<std::mutex> lock(state->mutex); // locks the mutex
- state->helper.reset(new std::thread(UnprotectCodeOtherThread,
- Dart_CurrentIsolate(), &state->cvar,
- &state->mutex));
-
- state->cvar.wait(lock);
- }
-
- if (fn != nullptr) {
- fn(state);
- return nullptr;
- } else {
- return state;
- }
-}
-
-DART_EXPORT void WaitForHelper(HelperThreadState* helper) {
- helper->helper->join();
- delete helper;
-}
-#else
-// Our version of VSC++ doesn't support std::thread yet.
-DART_EXPORT void WaitForHelper(void* helper) {}
-DART_EXPORT void* TestUnprotectCode(void (*fn)(void)) {
- return nullptr;
-}
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
// Tests for callbacks.
// Sanity test.
@@ -663,7 +536,7 @@
}
DART_EXPORT int TestSimpleMultiplyFloat(float (*fn)(float)) {
- CHECK(std::abs(fn(2.0) - 2.0 * 1.337) < 0.001);
+ CHECK(::std::abs(fn(2.0) - 2.0 * 1.337) < 0.001);
return 0;
}
@@ -741,24 +614,6 @@
return 0;
}
-// Defined in ffi_test_functions.S.
-//
-// Clobbers some registers with special meaning in Dart before re-entry, for
-// stress-testing. Not used on 32-bit Windows due to complications with Windows
-// "safeseh".
-#if defined(TARGET_OS_WINDOWS) && defined(HOST_ARCH_IA32)
-void ClobberAndCall(void (*fn)()) {
- fn();
-}
-#else
-extern "C" void ClobberAndCall(void (*fn)());
-#endif
-
-DART_EXPORT int TestGC(void (*do_gc)()) {
- ClobberAndCall(do_gc);
- return 0;
-}
-
DART_EXPORT int TestReturnVoid(int (*return_void)()) {
CHECK_EQ(return_void(), 0);
return 0;
@@ -779,93 +634,6 @@
return 0;
}
-struct CallbackTestData {
- int success;
- void (*callback)();
-};
-
-#if defined(TARGET_OS_LINUX)
-
-thread_local sigjmp_buf buf;
-void CallbackTestSignalHandler(int) {
- siglongjmp(buf, 1);
-}
-
-int ExpectAbort(void (*fn)()) {
- fprintf(stderr, "**** EXPECT STACKTRACE TO FOLLOW. THIS IS OK. ****\n");
-
- struct sigaction old_action = {};
- int result = __sigsetjmp(buf, /*savesigs=*/1);
- if (result == 0) {
- // Install signal handler.
- struct sigaction handler = {};
- handler.sa_handler = CallbackTestSignalHandler;
- sigemptyset(&handler.sa_mask);
- handler.sa_flags = 0;
-
- sigaction(SIGABRT, &handler, &old_action);
-
- fn();
- } else {
- // Caught the setjmp.
- sigaction(SIGABRT, &old_action, NULL);
- exit(0);
- }
- fprintf(stderr, "Expected abort!!!\n");
- exit(1);
-}
-
-void* TestCallbackOnThreadOutsideIsolate(void* parameter) {
- CallbackTestData* data = reinterpret_cast<CallbackTestData*>(parameter);
- data->success = ExpectAbort(data->callback);
- return NULL;
-}
-
-int TestCallbackOtherThreadHelper(void* (*tester)(void*), void (*fn)()) {
- CallbackTestData data = {1, fn};
- pthread_attr_t attr;
- int result = pthread_attr_init(&attr);
- CHECK_EQ(result, 0);
-
- pthread_t tid;
- result = pthread_create(&tid, &attr, tester, &data);
- CHECK_EQ(result, 0);
-
- result = pthread_attr_destroy(&attr);
- CHECK_EQ(result, 0);
-
- void* retval;
- result = pthread_join(tid, &retval);
-
- // Doesn't actually return because the other thread will exit when the test is
- // finished.
- return 1;
-}
-
-// Run a callback on another thread and verify that it triggers SIGABRT.
-DART_EXPORT int TestCallbackWrongThread(void (*fn)()) {
- return TestCallbackOtherThreadHelper(&TestCallbackOnThreadOutsideIsolate, fn);
-}
-
-// Verify that we get SIGABRT when invoking a native callback outside an
-// isolate.
-DART_EXPORT int TestCallbackOutsideIsolate(void (*fn)()) {
- Dart_Isolate current = Dart_CurrentIsolate();
-
- Dart_ExitIsolate();
- CallbackTestData data = {1, fn};
- TestCallbackOnThreadOutsideIsolate(&data);
- Dart_EnterIsolate(current);
-
- return data.success;
-}
-
-DART_EXPORT int TestCallbackWrongIsolate(void (*fn)()) {
- return ExpectAbort(fn);
-}
-
-#endif // defined(TARGET_OS_LINUX)
-
// Receives some pointer (Pointer<NativeType> in Dart) and writes some bits.
DART_EXPORT void NativeTypePointerParam(void* p) {
uint8_t* p2 = reinterpret_cast<uint8_t*>(p);
diff --git a/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc b/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc
new file mode 100644
index 0000000..8e13bf1
--- /dev/null
+++ b/runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc
@@ -0,0 +1,267 @@
+// Copyright (c) 2019, 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.
+
+// This file contains test functions for the dart:ffi test cases.
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <csignal>
+
+#include "platform/globals.h"
+#if defined(HOST_OS_WINDOWS)
+#include <psapi.h>
+#else
+#include <unistd.h>
+
+// Only OK to use here because this is test code.
+#include <condition_variable> // NOLINT(build/c++11)
+#include <functional> // NOLINT(build/c++11)
+#include <mutex> // NOLINT(build/c++11)
+#include <thread> // NOLINT(build/c++11)
+#endif
+
+#include <setjmp.h>
+#include <signal.h>
+#include <iostream>
+#include <limits>
+
+#include "include/dart_api.h"
+#include "include/dart_native_api.h"
+
+namespace dart {
+
+#define CHECK(X) \
+ if (!(X)) { \
+ fprintf(stderr, "%s\n", "Check failed: " #X); \
+ return 1; \
+ }
+
+#define CHECK_EQ(X, Y) CHECK((X) == (Y))
+
+////////////////////////////////////////////////////////////////////////////////
+// Functions for stress-testing.
+
+DART_EXPORT int64_t MinInt64() {
+ Dart_ExecuteInternalCommand("gc-on-nth-allocation",
+ reinterpret_cast<void*>(1));
+ return 0x8000000000000000;
+}
+
+DART_EXPORT int64_t MinInt32() {
+ Dart_ExecuteInternalCommand("gc-on-nth-allocation",
+ reinterpret_cast<void*>(1));
+ return 0x80000000;
+}
+
+DART_EXPORT double SmallDouble() {
+ Dart_ExecuteInternalCommand("gc-on-nth-allocation",
+ reinterpret_cast<void*>(1));
+ return 0x80000000 * -1.0;
+}
+
+// Requires boxing on 32-bit and 64-bit systems, even if the top 32-bits are
+// truncated.
+DART_EXPORT void* LargePointer() {
+ Dart_ExecuteInternalCommand("gc-on-nth-allocation",
+ reinterpret_cast<void*>(1));
+ uint64_t origin = 0x8100000082000000;
+ return reinterpret_cast<void*>(origin);
+}
+
+DART_EXPORT void TriggerGC(uint64_t count) {
+ Dart_ExecuteInternalCommand("gc-now", nullptr);
+}
+
+DART_EXPORT void CollectOnNthAllocation(intptr_t num_allocations) {
+ Dart_ExecuteInternalCommand("gc-on-nth-allocation",
+ reinterpret_cast<void*>(num_allocations));
+}
+
+// Triggers GC. Has 11 dummy arguments as unboxed odd integers which should be
+// ignored by GC.
+DART_EXPORT void Regress37069(uint64_t a,
+ uint64_t b,
+ uint64_t c,
+ uint64_t d,
+ uint64_t e,
+ uint64_t f,
+ uint64_t g,
+ uint64_t h,
+ uint64_t i,
+ uint64_t j,
+ uint64_t k) {
+ Dart_ExecuteInternalCommand("gc-now", nullptr);
+}
+
+#if !defined(HOST_OS_WINDOWS)
+DART_EXPORT void* UnprotectCodeOtherThread(void* isolate,
+ std::condition_variable* var,
+ std::mutex* mut) {
+ std::function<void()> callback = [&]() {
+ mut->lock();
+ var->notify_all();
+ mut->unlock();
+
+ // Wait for mutator thread to continue (and block) before leaving the
+ // safepoint.
+ while (Dart_ExecuteInternalCommand("is-mutator-in-native", isolate) !=
+ nullptr) {
+ usleep(10 * 1000 /*10 ms*/);
+ }
+ };
+
+ struct {
+ void* isolate;
+ std::function<void()>* callback;
+ } args = {.isolate = isolate, .callback = &callback};
+
+ Dart_ExecuteInternalCommand("run-in-safepoint-and-rw-code", &args);
+ return nullptr;
+}
+
+struct HelperThreadState {
+ std::mutex mutex;
+ std::condition_variable cvar;
+ std::unique_ptr<std::thread> helper;
+};
+
+DART_EXPORT void* TestUnprotectCode(void (*fn)(void*)) {
+ HelperThreadState* state = new HelperThreadState;
+
+ {
+ std::unique_lock<std::mutex> lock(state->mutex); // locks the mutex
+ state->helper.reset(new std::thread(UnprotectCodeOtherThread,
+ Dart_CurrentIsolate(), &state->cvar,
+ &state->mutex));
+
+ state->cvar.wait(lock);
+ }
+
+ if (fn != nullptr) {
+ fn(state);
+ return nullptr;
+ } else {
+ return state;
+ }
+}
+
+DART_EXPORT void WaitForHelper(HelperThreadState* helper) {
+ helper->helper->join();
+ delete helper;
+}
+#else
+// Our version of VSC++ doesn't support std::thread yet.
+DART_EXPORT void WaitForHelper(void* helper) {}
+DART_EXPORT void* TestUnprotectCode(void (*fn)(void)) {
+ return nullptr;
+}
+#endif
+
+// Defined in ffi_test_functions.S.
+//
+// Clobbers some registers with special meaning in Dart before re-entry, for
+// stress-testing. Not used on 32-bit Windows due to complications with Windows
+// "safeseh".
+#if defined(TARGET_OS_WINDOWS) && defined(HOST_ARCH_IA32)
+void ClobberAndCall(void (*fn)()) {
+ fn();
+}
+#else
+extern "C" void ClobberAndCall(void (*fn)());
+#endif
+
+DART_EXPORT int TestGC(void (*do_gc)()) {
+ ClobberAndCall(do_gc);
+ return 0;
+}
+
+struct CallbackTestData {
+ int success;
+ void (*callback)();
+};
+
+#if defined(TARGET_OS_LINUX)
+
+thread_local sigjmp_buf buf;
+void CallbackTestSignalHandler(int) {
+ siglongjmp(buf, 1);
+}
+
+int ExpectAbort(void (*fn)()) {
+ fprintf(stderr, "**** EXPECT STACKTRACE TO FOLLOW. THIS IS OK. ****\n");
+
+ struct sigaction old_action = {};
+ int result = __sigsetjmp(buf, /*savesigs=*/1);
+ if (result == 0) {
+ // Install signal handler.
+ struct sigaction handler = {};
+ handler.sa_handler = CallbackTestSignalHandler;
+ sigemptyset(&handler.sa_mask);
+ handler.sa_flags = 0;
+
+ sigaction(SIGABRT, &handler, &old_action);
+
+ fn();
+ } else {
+ // Caught the setjmp.
+ sigaction(SIGABRT, &old_action, NULL);
+ exit(0);
+ }
+ fprintf(stderr, "Expected abort!!!\n");
+ exit(1);
+}
+
+void* TestCallbackOnThreadOutsideIsolate(void* parameter) {
+ CallbackTestData* data = reinterpret_cast<CallbackTestData*>(parameter);
+ data->success = ExpectAbort(data->callback);
+ return NULL;
+}
+
+int TestCallbackOtherThreadHelper(void* (*tester)(void*), void (*fn)()) {
+ CallbackTestData data = {1, fn};
+ pthread_attr_t attr;
+ int result = pthread_attr_init(&attr);
+ CHECK_EQ(result, 0);
+
+ pthread_t tid;
+ result = pthread_create(&tid, &attr, tester, &data);
+ CHECK_EQ(result, 0);
+
+ result = pthread_attr_destroy(&attr);
+ CHECK_EQ(result, 0);
+
+ void* retval;
+ result = pthread_join(tid, &retval);
+
+ // Doesn't actually return because the other thread will exit when the test is
+ // finished.
+ return 1;
+}
+
+// Run a callback on another thread and verify that it triggers SIGABRT.
+DART_EXPORT int TestCallbackWrongThread(void (*fn)()) {
+ return TestCallbackOtherThreadHelper(&TestCallbackOnThreadOutsideIsolate, fn);
+}
+
+// Verify that we get SIGABRT when invoking a native callback outside an
+// isolate.
+DART_EXPORT int TestCallbackOutsideIsolate(void (*fn)()) {
+ Dart_Isolate current = Dart_CurrentIsolate();
+
+ Dart_ExitIsolate();
+ CallbackTestData data = {1, fn};
+ TestCallbackOnThreadOutsideIsolate(&data);
+ Dart_EnterIsolate(current);
+
+ return data.success;
+}
+
+DART_EXPORT int TestCallbackWrongIsolate(void (*fn)()) {
+ return ExpectAbort(fn);
+}
+
+#endif // defined(TARGET_OS_LINUX)
+
+} // namespace dart
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index 8af1215..2712450 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -199,14 +199,13 @@
if (Dart_IsError(result)) return result;
}
- // Setup package root if specified.
- result = DartUtils::SetupPackageRoot(nullptr, packages_file);
+ // Setup packages config if specified.
+ result = DartUtils::SetupPackageConfig(packages_file);
if (Dart_IsError(result)) return result;
if (!Dart_IsNull(result) && resolved_packages_config != nullptr) {
result = Dart_StringToCString(result, resolved_packages_config);
if (Dart_IsError(result)) return result;
ASSERT(*resolved_packages_config != nullptr);
-
#if !defined(DART_PRECOMPILED_RUNTIME)
if (is_isolate_group_start) {
isolate_group_data->set_resolved_packages_config(
diff --git a/runtime/bin/vmservice/loader.dart b/runtime/bin/vmservice/loader.dart
index 7407e50..35a5fdc 100644
--- a/runtime/bin/vmservice/loader.dart
+++ b/runtime/bin/vmservice/loader.dart
@@ -30,44 +30,8 @@
return fixedPath;
}
-_trimWindowsPath(path) {
- // Convert /X:/ to X:/.
- if (_isWindows == false) {
- // Do nothing when not running Windows.
- return path;
- }
- if (!path.startsWith('/') || (path.length < 3)) {
- return path;
- }
- // Match '/?:'.
- if ((path[0] == '/') && (path[2] == ':')) {
- // Remove leading '/'.
- return path.substring(1);
- }
- return path;
-}
-
-// Ensure we have a trailing slash character.
-_enforceTrailingSlash(uri) {
- if (!uri.endsWith('/')) {
- return '$uri/';
- }
- return uri;
-}
-
-class FileRequest {
- final SendPort sp;
- final int tag;
- final Uri uri;
- final Uri resolvedUri;
- final String libraryUrl;
- FileRequest(this.sp, this.tag, this.uri, this.resolvedUri, this.libraryUrl);
-}
-
@pragma("vm:entry-point")
bool _traceLoading = false;
-@pragma("vm:entry-point")
-bool _deterministic = false;
// State associated with the isolate that is used for loading.
class IsolateLoaderState extends IsolateEmbedderData {
@@ -87,10 +51,6 @@
if (rootScript != null) {
_rootScript = Uri.parse(rootScript);
}
- // If the --package-root flag was passed.
- if (packageRootFlag != null) {
- _setPackageRoot(packageRootFlag);
- }
// If the --packages flag was passed.
if (packagesConfigFlag != null) {
_setPackagesConfig(packagesConfigFlag);
@@ -139,40 +99,6 @@
Uri _packageConfig = null;
Map<String, Uri> _packageMap = null;
- // We issue only 16 concurrent calls to File.readAsBytes() to stay within
- // platform-specific resource limits (e.g. max open files). The rest go on
- // _fileRequestQueue and are processed when we can safely issue them.
- static final int _maxFileRequests = _deterministic ? 1 : 16;
- int currentFileRequests = 0;
- final List<FileRequest> _fileRequestQueue = new List<FileRequest>();
-
- bool get shouldIssueFileRequest => currentFileRequests < _maxFileRequests;
- void enqueueFileRequest(FileRequest fr) {
- _fileRequestQueue.add(fr);
- }
-
- FileRequest dequeueFileRequest() {
- if (_fileRequestQueue.length == 0) {
- return null;
- }
- return _fileRequestQueue.removeAt(0);
- }
-
- _setPackageRoot(String packageRoot) {
- packageRoot = _sanitizeWindowsPath(packageRoot);
- if (packageRoot.startsWith('file:') ||
- packageRoot.startsWith('http:') ||
- packageRoot.startsWith('https:')) {
- packageRoot = _enforceTrailingSlash(packageRoot);
- _packageRoot = _workingDirectory.resolve(packageRoot);
- } else {
- packageRoot = _sanitizeWindowsPath(packageRoot);
- packageRoot = _trimWindowsPath(packageRoot);
- _packageRoot =
- _workingDirectory.resolveUri(new Uri.directory(packageRoot));
- }
- }
-
_setPackagesConfig(String packagesParam) {
var packagesName = _sanitizeWindowsPath(packagesParam);
var packagesUri = Uri.parse(packagesName);
@@ -396,150 +322,6 @@
sp.send(msg);
}
-void _loadHttp(
- SendPort sp, int tag, Uri uri, Uri resolvedUri, String libraryUrl) {
- if (_httpClient == null) {
- _httpClient = new HttpClient()..maxConnectionsPerHost = 6;
- }
- _httpClient
- .getUrl(resolvedUri)
- .then((HttpClientRequest request) => request.close())
- .then((HttpClientResponse response) {
- var builder = new BytesBuilder(copy: false);
- response.listen(builder.add, onDone: () {
- if (response.statusCode != 200) {
- var msg = "Failure getting $resolvedUri:\n"
- " ${response.statusCode} ${response.reasonPhrase}";
- _sendResourceResponse(sp, tag, uri, resolvedUri, libraryUrl, msg);
- } else {
- _sendResourceResponse(
- sp, tag, uri, resolvedUri, libraryUrl, builder.takeBytes());
- }
- }, onError: (e) {
- _sendResourceResponse(
- sp, tag, uri, resolvedUri, libraryUrl, e.toString());
- });
- }).catchError((e) {
- _sendResourceResponse(sp, tag, uri, resolvedUri, libraryUrl, e.toString());
- });
- // It's just here to push an event on the event loop so that we invoke the
- // scheduled microtasks.
- Timer.run(() {});
-}
-
-void _loadFile(IsolateLoaderState loaderState, SendPort sp, int tag, Uri uri,
- Uri resolvedUri, String libraryUrl) {
- var path = resolvedUri.toFilePath();
- var sourceFile = new File(path);
- sourceFile.readAsBytes().then((data) {
- _sendResourceResponse(sp, tag, uri, resolvedUri, libraryUrl, data);
- }, onError: (e) {
- _sendResourceResponse(sp, tag, uri, resolvedUri, libraryUrl, e.toString());
- }).whenComplete(() {
- loaderState.currentFileRequests--;
- while (loaderState.shouldIssueFileRequest) {
- FileRequest fr = loaderState.dequeueFileRequest();
- if (fr == null) {
- break;
- }
- _loadFile(
- loaderState, fr.sp, fr.tag, fr.uri, fr.resolvedUri, fr.libraryUrl);
- loaderState.currentFileRequests++;
- }
- });
-}
-
-void _loadDataUri(
- SendPort sp, int tag, Uri uri, Uri resolvedUri, String libraryUrl) {
- try {
- var mime = uri.data.mimeType;
- if ((mime != "application/dart") && (mime != "text/plain")) {
- throw "MIME-type must be application/dart or text/plain: $mime given.";
- }
- var charset = uri.data.charset;
- if ((charset != "utf-8") && (charset != "US-ASCII")) {
- // The C++ portion of the embedder assumes UTF-8.
- throw "Only utf-8 or US-ASCII encodings are supported: $charset given.";
- }
- _sendResourceResponse(
- sp, tag, uri, resolvedUri, libraryUrl, uri.data.contentAsBytes());
- } catch (e) {
- _sendResourceResponse(sp, tag, uri, resolvedUri, libraryUrl,
- "Invalid data uri ($uri):\n $e");
- }
-}
-
-// Loading a package URI needs to first map the package name to a loadable
-// URI.
-_loadPackage(IsolateLoaderState loaderState, SendPort sp, bool traceLoading,
- int tag, Uri uri, Uri resolvedUri, String libraryUrl) {
- if (loaderState._packagesReady) {
- var resolvedUri;
- try {
- resolvedUri = loaderState._resolvePackageUri(uri);
- } catch (e, s) {
- if (traceLoading) {
- _log("Exception ($e) when resolving package URI: $uri");
- }
- // Report error.
- _sendResourceResponse(
- sp, tag, uri, resolvedUri, libraryUrl, e.toString());
- return;
- }
- // Recursively call with the new resolved uri.
- _handleResourceRequest(
- loaderState, sp, traceLoading, tag, uri, resolvedUri, libraryUrl);
- } else {
- if (loaderState._pendingPackageLoads.isEmpty) {
- // Package resolution has not been setup yet, and this is the first
- // request for package resolution & loading.
- loaderState._requestPackagesMap();
- }
- // Register the action of loading this package once the package resolution
- // is ready.
- loaderState._pendingPackageLoads.add(() {
- _handleResourceRequest(
- loaderState, sp, traceLoading, tag, uri, uri, libraryUrl);
- });
- if (traceLoading) {
- _log("Pending package load of '$uri': "
- "${loaderState._pendingPackageLoads.length} pending");
- }
- }
-}
-
-// TODO(johnmccutchan): This and most other top level functions in this file
-// should be turned into methods on the IsolateLoaderState class.
-_handleResourceRequest(IsolateLoaderState loaderState, SendPort sp,
- bool traceLoading, int tag, Uri uri, Uri resolvedUri, String libraryUrl) {
- if (resolvedUri.scheme == '' || resolvedUri.scheme == 'file') {
- if (loaderState.shouldIssueFileRequest) {
- _loadFile(loaderState, sp, tag, uri, resolvedUri, libraryUrl);
- loaderState.currentFileRequests++;
- } else {
- FileRequest fr = new FileRequest(sp, tag, uri, resolvedUri, libraryUrl);
- loaderState.enqueueFileRequest(fr);
- }
- } else if ((resolvedUri.scheme == 'http') ||
- (resolvedUri.scheme == 'https')) {
- _loadHttp(sp, tag, uri, resolvedUri, libraryUrl);
- } else if ((resolvedUri.scheme == 'data')) {
- _loadDataUri(sp, tag, uri, resolvedUri, libraryUrl);
- } else if ((resolvedUri.scheme == 'package')) {
- _loadPackage(
- loaderState, sp, traceLoading, tag, uri, resolvedUri, libraryUrl);
- } else {
- _sendResourceResponse(
- sp,
- tag,
- uri,
- resolvedUri,
- libraryUrl,
- 'Unknown scheme (${resolvedUri.scheme}) for '
- '$resolvedUri');
- }
-}
-
// Handling of packages requests. Finding and parsing of .packages file or
// packages/ directories.
const _LF = 0x0A;
@@ -957,8 +739,6 @@
// Extra requests. Keep these in sync between loader.dart and builtin.dart.
const _Dart_kInitLoader = 4; // Initialize the loader.
-const _Dart_kResourceLoad = 5; // Resource class support.
-const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory.
const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file.
const _Dart_kResolvePackageUri = 8; // Resolve a package: uri.
@@ -1009,19 +789,6 @@
assert(isolateEmbedderData[isolateId] == loaderState);
}
break;
- case _Dart_kResourceLoad:
- {
- Uri uri = Uri.parse(request[4]);
- _handleResourceRequest(
- loaderState, sp, traceLoading, tag, uri, uri, null);
- }
- break;
- case _Dart_kGetPackageRootUri:
- loaderState._triggerPackageResolution(() {
- // The package root is deprecated and now always returns null.
- sp.send(null);
- });
- break;
case _Dart_kGetPackageConfigUri:
loaderState._triggerPackageResolution(() {
// Respond with the packages config (if any) after package resolution.
diff --git a/runtime/bin/vmservice_impl.cc b/runtime/bin/vmservice_impl.cc
index b5387a7..4c9c9a9 100644
--- a/runtime/bin/vmservice_impl.cc
+++ b/runtime/bin/vmservice_impl.cc
@@ -202,12 +202,6 @@
Dart_SetField(library, DartUtils::NewString("_isFuchsia"), is_fuchsia);
SHUTDOWN_ON_ERROR(result);
- if (deterministic) {
- result = Dart_SetField(library, DartUtils::NewString("_deterministic"),
- Dart_True());
- SHUTDOWN_ON_ERROR(result);
- }
-
// Get _getWatchSignalInternal from dart:io.
Dart_Handle dart_io_str = Dart_NewStringFromCString(DartUtils::kIOLibURL);
SHUTDOWN_ON_ERROR(dart_io_str);
diff --git a/runtime/docs/snapshot_profiling.md b/runtime/docs/snapshot_profiling.md
index 596bda2..a5b1cf5 100644
--- a/runtime/docs/snapshot_profiling.md
+++ b/runtime/docs/snapshot_profiling.md
@@ -6,7 +6,7 @@
To generate a snapshot profile, simply pass the `--write-v8-snapshot-profile-to=<filename>` flag to `gen_snapshot`.
The profile will be written in JSON format to the requested file.
-Make sure to use the ".heapsnaphsot" extension for the file to open it in Chrome DevTools.
+Make sure to use the ".heapsnapshot" extension for the file to open it in Chrome DevTools.
## Examining a profile in Chrome
diff --git a/runtime/lib/stacktrace.cc b/runtime/lib/stacktrace.cc
index 1df0056..dfe1f585 100644
--- a/runtime/lib/stacktrace.cc
+++ b/runtime/lib/stacktrace.cc
@@ -16,6 +16,29 @@
DECLARE_FLAG(bool, show_invisible_frames);
+static const intptr_t kDefaultStackAllocation = 8;
+
+static RawStackTrace* CurrentSyncStackTraceLazy(Thread* thread,
+ intptr_t skip_frames = 1) {
+ Zone* zone = thread->zone();
+
+ const auto& code_array = GrowableObjectArray::ZoneHandle(
+ zone, GrowableObjectArray::New(kDefaultStackAllocation));
+ const auto& pc_offset_array = GrowableObjectArray::ZoneHandle(
+ zone, GrowableObjectArray::New(kDefaultStackAllocation));
+
+ // Collect the frames.
+ StackTraceUtils::CollectFramesLazy(thread, code_array, pc_offset_array,
+ skip_frames);
+
+ const auto& code_array_fixed =
+ Array::Handle(zone, Array::MakeFixedLength(code_array));
+ const auto& pc_offset_array_fixed =
+ Array::Handle(zone, Array::MakeFixedLength(pc_offset_array));
+
+ return StackTrace::New(code_array_fixed, pc_offset_array_fixed);
+}
+
static RawStackTrace* CurrentSyncStackTrace(Thread* thread,
intptr_t skip_frames = 1) {
Zone* zone = thread->zone();
@@ -45,6 +68,9 @@
bool for_async_function,
intptr_t skip_frames = 1,
bool causal_async_stacks = FLAG_causal_async_stacks) {
+ if (FLAG_lazy_async_stacks) {
+ return CurrentSyncStackTraceLazy(thread, skip_frames);
+ }
if (!causal_async_stacks) {
// Return the synchronous stack trace.
return CurrentSyncStackTrace(thread, skip_frames);
diff --git a/runtime/observatory/lib/src/repositories/timeline_base.dart b/runtime/observatory/lib/src/repositories/timeline_base.dart
index 9f6e113..8fde0d7 100644
--- a/runtime/observatory/lib/src/repositories/timeline_base.dart
+++ b/runtime/observatory/lib/src/repositories/timeline_base.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file
import 'dart:async';
+import 'package:logging/logging.dart';
import 'package:observatory/sample_profile.dart';
import 'package:observatory/models.dart' as M;
import 'package:observatory/service.dart' as S;
@@ -92,11 +93,24 @@
await vm.invokeRpc('getVMTimeline', {});
final timeOriginMicros = vmTimelineResponse[kTimeOriginMicros];
final timeExtentMicros = vmTimelineResponse[kTimeExtentMicros];
- final traceObject = await getCpuProfileTimeline(
- vm,
- timeOriginMicros: timeOriginMicros,
- timeExtentMicros: timeExtentMicros,
- );
+ var traceObject = <String, dynamic>{
+ _kStackFrames: {},
+ _kTraceEvents: [],
+ };
+ try {
+ final cpuProfile = await getCpuProfileTimeline(
+ vm,
+ timeOriginMicros: timeOriginMicros,
+ timeExtentMicros: timeExtentMicros,
+ );
+ traceObject = cpuProfile;
+ } on S.ServerRpcException catch (e) {
+ if (e.code != S.ServerRpcException.kFeatureDisabled) {
+ rethrow;
+ }
+ Logger.root.info(
+ "CPU profiler is disabled. Creating timeline without CPU profile.");
+ }
traceObject[_kTraceEvents].addAll(vmTimelineResponse[_kTraceEvents]);
return traceObject;
}
diff --git a/runtime/observatory/tests/service/evaluate_with_escaping_closure_test.dart b/runtime/observatory/tests/service/evaluate_with_escaping_closure_test.dart
new file mode 100644
index 0000000..bb87130
--- /dev/null
+++ b/runtime/observatory/tests/service/evaluate_with_escaping_closure_test.dart
@@ -0,0 +1,29 @@
+// Copyright (c) 2019, 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.
+
+import 'package:observatory/service_io.dart';
+import 'package:unittest/unittest.dart';
+import 'test_helper.dart';
+
+dynamic escapedClosure;
+
+testeeMain() {}
+
+var tests = <IsolateTest>[
+ (Isolate isolate) async {
+ Library lib = await isolate.rootLibrary.load();
+
+ Instance result = await lib.evaluate("escapedClosure = (x, y) => x + y");
+ print(result);
+ expect(result.clazz.name, startsWith('_Closure'));
+
+ for (var i = 0; i < 100; i++) {
+ result = await lib.evaluate("escapedClosure(3, 4)");
+ print(result);
+ expect(result.valueAsString, equals('7'));
+ }
+ },
+];
+
+main(args) => runIsolateTests(args, tests, testeeBefore: testeeMain);
diff --git a/runtime/observatory/tests/service/network_profiling_test.dart b/runtime/observatory/tests/service/network_profiling_test.dart
index 1705af9..4944d0c 100644
--- a/runtime/observatory/tests/service/network_profiling_test.dart
+++ b/runtime/observatory/tests/service/network_profiling_test.dart
@@ -5,34 +5,197 @@
import 'dart:async';
import 'dart:convert';
import 'dart:developer';
+import 'dart:io' as io;
+import 'dart:isolate';
import 'package:observatory/service_io.dart';
-import 'package:observatory/sample_profile.dart';
import 'package:unittest/unittest.dart';
import 'service_test_common.dart';
import 'test_helper.dart';
-void test() {
- // TODO(bkonyi): do actual network operations.
- print('hello world!');
+const String content = 'some random content';
+const String udpContent = 'aghfkjdb';
+const String kClearSocketProfileRPC = 'ext.dart.io.clearSocketProfile';
+const String kGetSocketProfileRPC = 'ext.dart.io.getSocketProfile';
+const String kGetVersionRPC = 'ext.dart.io.getVersion';
+const String kPauseSocketProfilingRPC = 'ext.dart.io.pauseSocketProfiling';
+const String kStartSocketProfilingRPC = 'ext.dart.io.startSocketProfiling';
+const String localhost = '127.0.0.1';
+
+Future<void> setup() async {}
+
+Future<void> socketTest() async {
+ // Socket
+ var serverSocket = await io.ServerSocket.bind(localhost, 0);
+ var socket = await io.Socket.connect(localhost, serverSocket.port);
+ socket.write(content);
+ await socket.flush();
+ await socket.destroy();
+
+ // rawDatagram
+ final doneCompleter = Completer<void>();
+ var server = await io.RawDatagramSocket.bind(localhost, 0);
+ server.listen((io.RawSocketEvent event) {
+ if (event == io.RawSocketEvent.read) {
+ io.Datagram dg = server.receive();
+ if (!doneCompleter.isCompleted) {
+ doneCompleter.complete();
+ }
+ }
+ });
+ var client = await io.RawDatagramSocket.bind(localhost, 0);
+ client.send(utf8.encoder.convert(udpContent), io.InternetAddress(localhost),
+ server.port);
+ client.send([1, 2, 3], io.InternetAddress(localhost), server.port);
+
+ // Wait for datagram to arrive.
+ await doneCompleter.future;
+ // Post finish event
+ postEvent('socketTest', {'socket': 'test'});
+}
+
+Future<void> checkFinishEvent(ServiceEvent event) {
+ expect(event.kind, equals(ServiceEvent.kExtension));
+ expect(event.extensionKind, equals('socketTest'));
+ expect(event.extensionData, isInstanceOf<Map>());
+ expect(event.extensionData['socket'], equals('test'));
}
var tests = <IsolateTest>[
(Isolate isolate) async {
await isolate.load();
-
// Ensure all network profiling service extensions are registered.
- const kGetHttpProfileRPC = 'ext.dart.io.getHttpProfile';
- const kGetSocketProfileRPC = 'ext.dart.io.getSocketProfile';
- expect(isolate.extensionRPCs.length, greaterThanOrEqualTo(2));
- expect(isolate.extensionRPCs.contains(kGetHttpProfileRPC), isTrue);
- expect(isolate.extensionRPCs.contains(kGetSocketProfileRPC), isTrue);
+ expect(isolate.extensionRPCs.length, greaterThanOrEqualTo(5));
+ expect(isolate.extensionRPCs.contains(kClearSocketProfileRPC), isTrue);
+ expect(isolate.extensionRPCs.contains(kGetVersionRPC), isTrue);
+ expect(isolate.extensionRPCs.contains(kPauseSocketProfilingRPC), isTrue);
+ expect(isolate.extensionRPCs.contains(kStartSocketProfilingRPC), isTrue);
+ expect(isolate.extensionRPCs.contains(kPauseSocketProfilingRPC), isTrue);
+ },
- // Test invocations (will throw on failure).
- var response = await isolate.invokeRpcNoUpgrade(kGetHttpProfileRPC, {});
- expect(response['type'], 'HttpProfile');
+ // Test getSocketProfiler
+ (Isolate isolate) async {
+ await isolate.load();
+ Library lib = isolate.rootLibrary;
+ await lib.load();
+
+ var response = await isolate.invokeRpcNoUpgrade(kGetSocketProfileRPC, {});
+ expect(response['type'], 'SocketProfile');
+ // returns an empty list in 'sockets'
+ expect(response['sockets'].length, 0);
+ },
+
+ // Test getSocketProfile and startSocketProfiling
+ (Isolate isolate) async {
+ await isolate.load();
+ Library lib = isolate.rootLibrary;
+ await lib.load();
+
+ var response =
+ await isolate.invokeRpcNoUpgrade(kStartSocketProfilingRPC, {});
+ expect(response['type'], 'Success');
+
+ // Check whether socketTest has finished.
+ Completer completer = Completer();
+ var sub;
+ sub = await isolate.vm.listenEventStream(Isolate.kExtensionStream,
+ (ServiceEvent event) {
+ checkFinishEvent(event);
+ sub.cancel();
+ completer.complete();
+ });
+
+ dynamic result = await isolate.invokeRpc("invoke",
+ {"targetId": lib.id, "selector": "socketTest", "argumentIds": []});
+ await completer.future;
+
response = await isolate.invokeRpcNoUpgrade(kGetSocketProfileRPC, {});
expect(response['type'], 'SocketProfile');
+ var stats = response['sockets'];
+ // 1 tcp socket, 2 udp datagrams
+ expect(stats.length, 3);
+ stats.forEach((socket) {
+ expect(socket['address'], contains(localhost));
+ if (socket['socketType'] == 'tcp') {
+ expect(socket['writeBytes'], content.length);
+ } else {
+ // 2 udp sockets, one of them is writing and the other is listening.
+ expect(socket['socketType'], 'udp');
+ if (socket['readBytes'] == 0) {
+ // [1, 2, 3] was sent.
+ expect(socket['writeBytes'], 3 + udpContent.length);
+ } else {
+ // [1, 2, 3] was sent.
+ expect(socket['writeBytes'], 0);
+ expect(socket['readBytes'], 3 + udpContent.length);
+ }
+ }
+ });
+
+ // run 99 more times and check we have 100 sockets statistic.
+ for (int i = 0; i < 99; i++) {
+ completer = Completer();
+ sub = await isolate.vm.listenEventStream(Isolate.kExtensionStream,
+ (ServiceEvent event) {
+ checkFinishEvent(event);
+ sub.cancel();
+ completer.complete();
+ });
+ dynamic result = await isolate.invokeRpc("invoke",
+ {"targetId": lib.id, "selector": "socketTest", "argumentIds": []});
+ await completer.future;
+ }
+
+ response = await isolate.invokeRpcNoUpgrade(kGetSocketProfileRPC, {});
+ expect(response['type'], 'SocketProfile');
+ // 1 tcp socket, 2 udp datagrams
+ expect(response['sockets'].length, 3 * 100);
},
+
+ // Test clearSocketProfiler
+ (Isolate isolate) async {
+ await isolate.load();
+ Library lib = isolate.rootLibrary;
+ await lib.load();
+
+ var response = await isolate.invokeRpcNoUpgrade(kClearSocketProfileRPC, {});
+ expect(response['type'], 'Success');
+
+ response = await isolate.invokeRpcNoUpgrade(kGetSocketProfileRPC, {});
+ expect(response['type'], 'SocketProfile');
+ expect(response['sockets'].length, 0);
+ },
+
+ // Test pauseSocketProfiling
+ (Isolate isolate) async {
+ await isolate.load();
+ Library lib = isolate.rootLibrary;
+ await lib.load();
+
+ var response =
+ await isolate.invokeRpcNoUpgrade(kStartSocketProfilingRPC, {});
+ expect(response['type'], 'Success');
+
+ response = await isolate.invokeRpcNoUpgrade(kPauseSocketProfilingRPC, {});
+ expect(response['type'], 'Success');
+
+ // Check whether socketTest has finished.
+ Completer completer = Completer();
+ var sub;
+ sub = await isolate.vm.listenEventStream(Isolate.kExtensionStream,
+ (ServiceEvent event) {
+ checkFinishEvent(event);
+ sub.cancel();
+ completer.complete();
+ });
+
+ dynamic result = await isolate.invokeRpc("invoke",
+ {"targetId": lib.id, "selector": "socketTest", "argumentIds": []});
+ await completer.future;
+
+ response = await isolate.invokeRpcNoUpgrade(kGetSocketProfileRPC, {});
+ expect(response['type'], 'SocketProfile');
+ expect(response['sockets'].length, 0);
+ }
];
-main(args) async => runIsolateTests(args, tests, testeeConcurrent: test);
+main(args) async => runIsolateTests(args, tests, testeeBefore: setup);
diff --git a/runtime/tests/vm/dart/causal_stacks/async_throws_stack_lazy_test.dart b/runtime/tests/vm/dart/causal_stacks/async_throws_stack_lazy_test.dart
new file mode 100644
index 0000000..3155257
--- /dev/null
+++ b/runtime/tests/vm/dart/causal_stacks/async_throws_stack_lazy_test.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2019, 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.
+
+// VMOptions=--lazy-async-stacks --no-causal-async-stacks
+
+import 'dart:async';
+
+import 'utils.dart';
+
+Future<void> main(List<String> args) async => await doTestsLazy();
diff --git a/runtime/tests/vm/dart/causal_stacks/async_throws_stack_no_causal_test.dart b/runtime/tests/vm/dart/causal_stacks/async_throws_stack_no_causal_test.dart
index 62e72dc..8c776ce 100644
--- a/runtime/tests/vm/dart/causal_stacks/async_throws_stack_no_causal_test.dart
+++ b/runtime/tests/vm/dart/causal_stacks/async_throws_stack_no_causal_test.dart
@@ -8,4 +8,4 @@
import 'utils.dart';
-Future<void> main(List<String> args) async => doTestsNoCausal();
+Future<void> main(List<String> args) async => await doTestsNoCausal();
diff --git a/runtime/tests/vm/dart/causal_stacks/async_throws_stack_test.dart b/runtime/tests/vm/dart/causal_stacks/async_throws_stack_test.dart
index eb1f207..cf856ce 100644
--- a/runtime/tests/vm/dart/causal_stacks/async_throws_stack_test.dart
+++ b/runtime/tests/vm/dart/causal_stacks/async_throws_stack_test.dart
@@ -8,4 +8,4 @@
import 'utils.dart';
-Future<void> main(List<String> args) async => doTestsCausal();
+Future<void> main(List<String> args) async => await doTestsCausal();
diff --git a/runtime/tests/vm/dart/causal_stacks/utils.dart b/runtime/tests/vm/dart/causal_stacks/utils.dart
index ce5116b..6d4ccc29 100644
--- a/runtime/tests/vm/dart/causal_stacks/utils.dart
+++ b/runtime/tests/vm/dart/causal_stacks/utils.dart
@@ -9,52 +9,6 @@
import 'package:path/path.dart' as path;
import 'package:expect/expect.dart';
-import 'package:expect/matchers_lite.dart';
-
-Matcher startsWith(String expected) {
- return (Object actual) {
- if (actual is String) {
- Expect.equals(
- expected, actual.substring(0, min(expected.length, actual.length)));
- return;
- }
- Expect.fail('Expected String.');
- };
-}
-
-void assertStack(Map expected, StackTrace stack_trace) {
- final List<String> frames = stack_trace.toString().split('\n');
- for (int i in expected.keys) {
- expect(frames[i], startsWith(expected[i]));
- }
-}
-
-Future<void> doTest(Future f(), Map<int, String> expected_stack) async {
- // Caller catches exception.
- try {
- await f();
- Expect.fail('No exception thrown!');
- } on String catch (e, s) {
- assertStack(expected_stack, s);
- }
-
- // Caller catches but a then is set.
- try {
- await f().then((e) {
- // Ignore.
- });
- Expect.fail('No exception thrown!');
- } on String catch (e, s) {
- assertStack(expected_stack, s);
- }
-
- // Caller doesn't catch, but we have a catchError set.
- StackTrace stack_trace;
- await f().catchError((e, s) {
- stack_trace = s;
- });
- assertStack(expected_stack, stack_trace);
-}
// Test functions:
@@ -85,26 +39,6 @@
throwSync();
}
-// For: --causal-async-stacks
-Map<int, String> allYieldMapCausal = {
- 0: '#0 throwSync ',
- 1: '#1 allYield3 ',
- 2: '<asynchronous suspension>',
- 3: '#2 allYield2 ',
- 4: '<asynchronous suspension>',
- 5: '#3 allYield ',
- 4: '<asynchronous suspension>',
- // Callers, like doTest and main ..
-};
-
-// For: --no-causal-async-stacks
-Map<int, String> allYieldMapNoCausal = {
- 0: '#0 throwSync ',
- 1: '#1 allYield3 ',
- 2: '#2 _RootZone.runUnary ',
- // The rest are more Dart internal async mechanisms..
-};
-
// ----
// Scenario: None of the async functions yieled before the throw:
// ----
@@ -120,30 +54,6 @@
throwSync();
}
-// For: --causal-async-stacks
-Map<int, String> noYieldsMapCausal = {
- 0: '#0 throwSync ',
- 1: '#1 noYields3 ',
- 2: '#2 noYields2 ',
- 3: '#3 noYields ',
- // Callers, like doTest and main ..
-};
-
-// For: --no-causal-async-stacks
-Map<int, String> noYieldsMapNoCausal = {
- 0: '#0 throwSync ',
- 1: '#1 noYields3 ',
- // Skip: _AsyncAwaitCompleter.start
- 3: '#3 noYields3 ',
- 4: '#4 noYields2 ',
- // Skip: _AsyncAwaitCompleter.start
- 6: '#6 noYields2 ',
- 7: '#7 noYields ',
- // Skip: _AsyncAwaitCompleter.start
- 9: '#9 noYields ',
- // Calling functions like doTest and main ..
-};
-
// ----
// Scenario: Mixed yielding and non-yielding frames:
// ----
@@ -160,24 +70,6 @@
return throwAsync();
}
-// For: --causal-async-stacks
-Map<int, String> mixedYieldsMapCausal = {
- 0: '#0 throwAsync ',
- 1: '<asynchronous suspension>',
- 2: '#1 mixedYields3 ',
- 3: '#2 mixedYields2 ',
- 4: '<asynchronous suspension>',
- 5: '#3 mixedYields ',
- // Callers, like doTest and main ..
-};
-
-// For: --no-causal-async-stacks
-Map<int, String> mixedYieldsMapNoCausal = {
- 0: '#0 throwAsync ',
- 1: '#1 _RootZone.runUnary ',
- // The rest are more Dart internal async mechanisms..
-};
-
// ----
// Scenario: Non-async frame:
// ----
@@ -194,24 +86,6 @@
return throwAsync();
}
-// For: --causal-async-stacks
-Map<int, String> syncSuffixMapCausal = {
- 0: '#0 throwAsync ',
- 1: '<asynchronous suspension>',
- 2: '#1 syncSuffix3 ',
- 3: '#2 syncSuffix2 ',
- 4: '<asynchronous suspension>',
- 5: '#3 syncSuffix ',
- // Callers, like doTest and main ..
-};
-
-// For: --no-causal-async-stacks
-Map<int, String> syncSuffixMapNoCausal = {
- 0: '#0 throwAsync ',
- 1: '#1 _RootZone.runUnary ',
- // The rest are more Dart internal async mechanisms..
-};
-
// ----
// Scenario: Caller is non-async, has no upwards stack:
// ----
@@ -222,38 +96,839 @@
Future nonAsyncNoStack2() async => Future.value(0).then((_) => throwAsync());
-// For: --causal-async-stacks
-Map<int, String> nonAsyncNoStackMapCausal = {
- 0: '#0 throwAsync ',
- 1: '<asynchronous suspension>',
- 2: '#1 nonAsyncNoStack2.<anonymous closure> ',
- 3: '#2 _RootZone.runUnary ',
- // The rest are more Dart internal async mechanisms..
-};
+// ----
+// Scenario: async*:
+// ----
-// For: --no-causal-async-stacks
-Map<int, String> nonAsyncNoStackMapNoCausal = {
- 0: '#0 throwAsync ',
- 1: '#1 _RootZone.runUnary ',
- // The rest are more Dart internal async mechanisms..
-};
+Future awaitEveryAsyncStarThrowSync() async {
+ await for (Future v in asyncStarThrowSync()) {
+ await v;
+ }
+}
+
+Stream<Future> asyncStarThrowSync() async* {
+ for (int i = 0; i < 2; i++) {
+ await i;
+ yield throwSync();
+ }
+}
+
+Future awaitEveryAsyncStarThrowAsync() async {
+ await for (Future v in asyncStarThrowAsync()) {
+ await v;
+ }
+}
+
+Stream<Future> asyncStarThrowAsync() async* {
+ for (int i = 0; i < 2; i++) {
+ await i;
+ yield Future.value(i);
+ await throwAsync();
+ }
+}
+
+// Helpers:
+
+void assertStack(List<String> expects, StackTrace stackTrace) {
+ final List<String> frames = stackTrace.toString().split('\n');
+ if (frames.length < expects.length) {
+ print('Actual stack:');
+ print(stackTrace.toString());
+ Expect.fail('Expected ${expects.length} frames, found ${frames.length}!');
+ }
+ for (int i = 0; i < expects.length; i++) {
+ try {
+ Expect.isTrue(RegExp(expects[i]).hasMatch(frames[i]));
+ } on ExpectException catch (e) {
+ // On failed expect, print full stack for reference.
+ print('Actual stack:');
+ print(stackTrace.toString());
+ print('Expected line ${i + 1} to match:');
+ print(expects[i]);
+ rethrow;
+ }
+ }
+}
+
+Future<void> doTestAwait(Future f(), List<String> expectedStack) async {
+ // Caller catches exception.
+ try {
+ await f();
+ Expect.fail('No exception thrown!');
+ } on String catch (e, s) {
+ assertStack(expectedStack, s);
+ }
+}
+
+Future<void> doTestAwaitThen(Future f(), List<String> expectedStack) async {
+ // Caller catches but a then is set.
+ try {
+ await f().then((e) {
+ // Ignore.
+ });
+ Expect.fail('No exception thrown!');
+ } on String catch (e, s) {
+ assertStack(expectedStack, s);
+ }
+}
+
+Future<void> doTestAwaitCatchError(
+ Future f(), List<String> expectedStack) async {
+ // Caller doesn't catch, but we have a catchError set.
+ StackTrace stackTrace;
+ await f().catchError((e, s) {
+ stackTrace = s;
+ });
+ assertStack(expectedStack, stackTrace);
+}
// ----
// Test "Suites":
// ----
+// For: --causal-async-stacks
Future<void> doTestsCausal() async {
- await doTest(allYield, allYieldMapCausal);
- await doTest(noYields, noYieldsMapCausal);
- await doTest(mixedYields, mixedYieldsMapCausal);
- await doTest(syncSuffix, syncSuffixMapCausal);
- await doTest(nonAsyncNoStack, nonAsyncNoStackMapCausal);
+ final allYieldExpected = const <String>[
+ r'^#0 throwSync \(.*/utils.dart:(16|16:3)\)$',
+ r'^#1 allYield3 \(.*/utils.dart:(39|39:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#2 allYield2 \(.*/utils.dart:(34|34:9)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#3 allYield \(.*/utils.dart:(29|29:9)\)$',
+ r'^<asynchronous suspension>$',
+ ];
+ await doTestAwait(
+ allYield,
+ allYieldExpected +
+ const <String>[
+ r'^#4 doTestAwait ',
+ r'^#5 doTestsCausal ',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ allYield,
+ allYieldExpected +
+ const <String>[
+ r'^#4 doTestAwaitThen ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ allYield,
+ allYieldExpected +
+ const <String>[
+ r'^#4 doTestAwaitCatchError ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+
+ final noYieldsExpected = const <String>[
+ r'^#0 throwSync \(.*/utils.dart:(16|16:3)\)$',
+ r'^#1 noYields3 \(.*/utils.dart:(54|54:3)\)$',
+ r'^#2 noYields2 \(.*/utils.dart:(50|50:9)\)$',
+ r'^#3 noYields \(.*/utils.dart:(46|46:9)\)$',
+ ];
+ await doTestAwait(
+ noYields,
+ noYieldsExpected +
+ const <String>[
+ r'^#4 doTestAwait ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ noYields,
+ noYieldsExpected +
+ const <String>[
+ r'^#4 doTestAwaitThen ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ noYields,
+ noYieldsExpected +
+ const <String>[
+ r'^#4 doTestAwaitCatchError ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+
+ final mixedYieldsExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#1 mixedYields3 \(.*/utils.dart:(70|70:10)\)$',
+ r'^#2 mixedYields2 \(.*/utils.dart:(66|66:9)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#3 mixedYields \(.*/utils.dart:(61|61:9)\)$',
+ ];
+ await doTestAwait(
+ mixedYields,
+ mixedYieldsExpected +
+ const <String>[
+ r'^#4 doTestAwait ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ mixedYields,
+ mixedYieldsExpected +
+ const <String>[
+ r'^#4 doTestAwaitThen ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ mixedYields,
+ mixedYieldsExpected +
+ const <String>[
+ r'^#4 doTestAwaitCatchError ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+
+ final syncSuffixExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#1 syncSuffix3 \(.*/utils.dart:(86|86:10)\)$',
+ r'^#2 syncSuffix2 \(.*/utils.dart:(82|82:9)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#3 syncSuffix \(.*/utils.dart:(77|77:9)\)$',
+ ];
+ await doTestAwait(
+ syncSuffix,
+ syncSuffixExpected +
+ const <String>[
+ r'^#4 doTestAwait ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ syncSuffix,
+ syncSuffixExpected +
+ const <String>[
+ r'^#4 doTestAwaitThen ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ syncSuffix,
+ syncSuffixExpected +
+ const <String>[
+ r'^#4 doTestAwaitCatchError ',
+ r'^#5 doTestsCausal ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^#7 _startIsolate.<anonymous closure> ',
+ r'^#8 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+
+ final nonAsyncNoStackExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#1 nonAsyncNoStack2.<anonymous closure> ',
+ r'^#2 _RootZone.runUnary ',
+ r'^#3 _FutureListener.handleValue ',
+ r'^#4 Future._propagateToListeners.handleValueCallback ',
+ r'^#5 Future._propagateToListeners ',
+ r'^#6 Future._completeWithValue ',
+ r'^#7 Future._asyncComplete.<anonymous closure> ',
+ r'^#8 _microtaskLoop ',
+ r'^#9 _startMicrotaskLoop ',
+ r'^#10 _runPendingImmediateCallback ',
+ r'^#11 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ];
+ await doTestAwait(nonAsyncNoStack, nonAsyncNoStackExpected);
+ await doTestAwaitThen(nonAsyncNoStack, nonAsyncNoStackExpected);
+ await doTestAwaitCatchError(nonAsyncNoStack, nonAsyncNoStackExpected);
+
+ final asyncStarThrowSyncExpected = const <String>[
+ r'^#0 throwSync \(.*/utils.dart:(16|16:3)\)$',
+ r'^#1 asyncStarThrowSync \(.*/utils.dart:(112|112:11)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#2 awaitEveryAsyncStarThrowSync \(.+\)$',
+ ];
+ await doTestAwait(
+ awaitEveryAsyncStarThrowSync,
+ asyncStarThrowSyncExpected +
+ const <String>[
+ r'^#3 doTestAwait \(.+\)$',
+ r'^#4 doTestsCausal \(.+\)$',
+ r'^<asynchronous suspension>$',
+ r'^#5 main \(.+\)$',
+ r'^#6 _startIsolate.<anonymous closure> \(.+\)$',
+ r'^#7 _RawReceivePortImpl._handleMessage \(.+\)$',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ awaitEveryAsyncStarThrowSync,
+ asyncStarThrowSyncExpected +
+ const <String>[
+ r'^#3 doTestAwaitThen \(.+\)$',
+ r'^#4 doTestsCausal \(.+\)$',
+ r'^<asynchronous suspension>$',
+ r'^#5 main \(.+\)$',
+ r'^#6 _startIsolate.<anonymous closure> \(.+\)$',
+ r'^#7 _RawReceivePortImpl._handleMessage \(.+\)$',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ awaitEveryAsyncStarThrowSync,
+ asyncStarThrowSyncExpected +
+ const <String>[
+ r'^#3 doTestAwaitCatchError \(.+\)$',
+ r'^#4 doTestsCausal \(.+\)$',
+ r'^<asynchronous suspension>$',
+ r'^#5 main \(.+\)$',
+ r'^#6 _startIsolate.<anonymous closure> \(.+\)$',
+ r'^#7 _RawReceivePortImpl._handleMessage \(.+\)$',
+ r'^$',
+ ]);
+
+ final asyncStarThrowAsyncExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#1 asyncStarThrowAsync \(.*/utils.dart:(126|126:11)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#2 awaitEveryAsyncStarThrowAsync \(.+\)$',
+ ];
+ await doTestAwait(
+ awaitEveryAsyncStarThrowAsync,
+ asyncStarThrowAsyncExpected +
+ const <String>[
+ r'^#3 doTestAwait \(.+\)$',
+ r'^#4 doTestsCausal \(.+\)$',
+ r'^<asynchronous suspension>$',
+ r'^#5 main \(.+\)$',
+ r'^#6 _startIsolate.<anonymous closure> \(.+\)$',
+ r'^#7 _RawReceivePortImpl._handleMessage \(.+\)$',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ awaitEveryAsyncStarThrowAsync,
+ asyncStarThrowAsyncExpected +
+ const <String>[
+ r'^#3 doTestAwaitThen \(.+\)$',
+ r'^#4 doTestsCausal \(.+\)$',
+ r'^<asynchronous suspension>$',
+ r'^#5 main \(.+\)$',
+ r'^#6 _startIsolate.<anonymous closure> \(.+\)$',
+ r'^#7 _RawReceivePortImpl._handleMessage \(.+\)$',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ awaitEveryAsyncStarThrowAsync,
+ asyncStarThrowAsyncExpected +
+ const <String>[
+ r'^#3 doTestAwaitCatchError \(.+\)$',
+ r'^#4 doTestsCausal \(.+\)$',
+ r'^<asynchronous suspension>$',
+ r'^#5 main \(.+\)$',
+ r'^#6 _startIsolate.<anonymous closure> \(.+\)$',
+ r'^#7 _RawReceivePortImpl._handleMessage \(.+\)$',
+ r'^$',
+ ]);
}
+// For: --no-causal-async-stacks
Future<void> doTestsNoCausal() async {
- await doTest(allYield, allYieldMapNoCausal);
- await doTest(noYields, noYieldsMapNoCausal);
- await doTest(mixedYields, mixedYieldsMapNoCausal);
- await doTest(syncSuffix, syncSuffixMapNoCausal);
- await doTest(nonAsyncNoStack, nonAsyncNoStackMapNoCausal);
+ final allYieldExpected = const <String>[
+ r'^#0 throwSync \(.*/utils.dart:(16|16:3)\)$',
+ r'^#1 allYield3 \(.*/utils.dart:(39|39:3)\)$',
+ r'^#2 _RootZone.runUnary ',
+ r'^#3 _FutureListener.handleValue ',
+ r'^#4 Future._propagateToListeners.handleValueCallback ',
+ r'^#5 Future._propagateToListeners ',
+ // TODO(dart-vm): Figure out why this is inconsistent:
+ r'^#6 Future.(_addListener|_prependListeners).<anonymous closure> ',
+ r'^#7 _microtaskLoop ',
+ r'^#8 _startMicrotaskLoop ',
+ r'^#9 _runPendingImmediateCallback ',
+ r'^#10 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ];
+ await doTestAwait(allYield, allYieldExpected);
+ await doTestAwaitThen(allYield, allYieldExpected);
+ await doTestAwaitCatchError(allYield, allYieldExpected);
+
+ final noYieldsExpected = const <String>[
+ r'^#0 throwSync \(.*/utils.dart:(16|16:3)\)$',
+ r'^#1 noYields3 \(.*/utils.dart:(54|54:3)\)$',
+ r'^#2 _AsyncAwaitCompleter.start ',
+ r'^#3 noYields3 \(.*/utils.dart:(53|53:23)\)$',
+ r'^#4 noYields2 \(.*/utils.dart:(50|50:9)\)$',
+ r'^#5 _AsyncAwaitCompleter.start ',
+ r'^#6 noYields2 \(.*/utils.dart:(49|49:23)\)$',
+ r'^#7 noYields \(.*/utils.dart:(46|46:9)\)$',
+ r'^#8 _AsyncAwaitCompleter.start ',
+ r'^#9 noYields \(.*/utils.dart:(45|45:22)\)$',
+ ];
+ await doTestAwait(
+ noYields,
+ noYieldsExpected +
+ const <String>[
+ r'^#10 doTestAwait ',
+ r'^#11 _AsyncAwaitCompleter.start ',
+ r'^#12 doTestAwait ',
+ r'^#13 doTestsNoCausal ',
+ r'^#14 _RootZone.runUnary ',
+ r'^#15 _FutureListener.handleValue ',
+ r'^#16 Future._propagateToListeners.handleValueCallback ',
+ r'^#17 Future._propagateToListeners ',
+ r'^#18 Future._completeWithValue ',
+ r'^#19 _AsyncAwaitCompleter.complete ',
+ r'^#20 _completeOnAsyncReturn ',
+ r'^#21 doTestAwaitCatchError ',
+ r'^#22 _RootZone.runUnary ',
+ r'^#23 _FutureListener.handleValue ',
+ r'^#24 Future._propagateToListeners.handleValueCallback ',
+ r'^#25 Future._propagateToListeners ',
+ r'^#26 Future._completeError ',
+ r'^#27 _AsyncAwaitCompleter.completeError ',
+ r'^#28 allYield ',
+ r'^#29 _asyncErrorWrapperHelper.<anonymous closure> ',
+ r'^#30 _RootZone.runBinary ',
+ r'^#31 _FutureListener.handleError ',
+ r'^#32 Future._propagateToListeners.handleError ',
+ r'^#33 Future._propagateToListeners ',
+ r'^#34 Future._completeError ',
+ r'^#35 _AsyncAwaitCompleter.completeError ',
+ r'^#36 allYield2 ',
+ r'^#37 _asyncErrorWrapperHelper.<anonymous closure> ',
+ r'^#38 _RootZone.runBinary ',
+ r'^#39 _FutureListener.handleError ',
+ r'^#40 Future._propagateToListeners.handleError ',
+ r'^#41 Future._propagateToListeners ',
+ r'^#42 Future._completeError ',
+ r'^#43 _AsyncAwaitCompleter.completeError ',
+ r'^#44 allYield3 ',
+ r'^#45 _RootZone.runUnary ',
+ r'^#46 _FutureListener.handleValue ',
+ r'^#47 Future._propagateToListeners.handleValueCallback ',
+ r'^#48 Future._propagateToListeners ',
+ // TODO(dart-vm): Figure out why this is inconsistent:
+ r'^#49 Future.(_addListener|_prependListeners).<anonymous closure> ',
+ r'^#50 _microtaskLoop ',
+ r'^#51 _startMicrotaskLoop ',
+ r'^#52 _runPendingImmediateCallback ',
+ r'^#53 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ noYields,
+ noYieldsExpected +
+ const <String>[
+ r'^#10 doTestAwaitThen ',
+ r'^#11 _AsyncAwaitCompleter.start ',
+ r'^#12 doTestAwaitThen ',
+ r'^#13 doTestsNoCausal ',
+ r'^#14 _RootZone.runUnary ',
+ r'^#15 _FutureListener.handleValue ',
+ r'^#16 Future._propagateToListeners.handleValueCallback ',
+ r'^#17 Future._propagateToListeners ',
+ r'^#18 Future._completeWithValue ',
+ r'^#19 _AsyncAwaitCompleter.complete ',
+ r'^#20 _completeOnAsyncReturn ',
+ r'^#21 doTestAwait ',
+ r'^#22 _asyncErrorWrapperHelper.<anonymous closure> ',
+ r'^#23 _RootZone.runBinary ',
+ r'^#24 _FutureListener.handleError ',
+ r'^#25 Future._propagateToListeners.handleError ',
+ r'^#26 Future._propagateToListeners ',
+ r'^#27 Future._completeError ',
+ r'^#28 _AsyncAwaitCompleter.completeError ',
+ r'^#29 noYields ',
+ r'^#30 _asyncErrorWrapperHelper.<anonymous closure> ',
+ r'^#31 _RootZone.runBinary ',
+ r'^#32 _FutureListener.handleError ',
+ r'^#33 Future._propagateToListeners.handleError ',
+ r'^#34 Future._propagateToListeners ',
+ r'^#35 Future._completeError ',
+ r'^#36 _AsyncAwaitCompleter.completeError ',
+ r'^#37 noYields2 ',
+ r'^#38 _asyncErrorWrapperHelper.<anonymous closure> ',
+ r'^#39 _RootZone.runBinary ',
+ r'^#40 _FutureListener.handleError ',
+ r'^#41 Future._propagateToListeners.handleError ',
+ r'^#42 Future._propagateToListeners ',
+ r'^#43 Future._completeError ',
+ // TODO(dart-vm): Figure out why this is inconsistent:
+ r'^#44 Future.(_asyncCompleteError|_chainForeignFuture).<anonymous closure> ',
+ r'^#45 _microtaskLoop ',
+ r'^#46 _startMicrotaskLoop ',
+ r'^#47 _runPendingImmediateCallback ',
+ r'^#48 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ noYields,
+ noYieldsExpected +
+ const <String>[
+ r'^#10 doTestAwaitCatchError ',
+ r'^#11 _AsyncAwaitCompleter.start ',
+ r'^#12 doTestAwaitCatchError ',
+ r'^#13 doTestsNoCausal ',
+ r'^#14 _RootZone.runUnary ',
+ r'^#15 _FutureListener.handleValue ',
+ r'^#16 Future._propagateToListeners.handleValueCallback ',
+ r'^#17 Future._propagateToListeners ',
+ r'^#18 Future._completeWithValue ',
+ r'^#19 _AsyncAwaitCompleter.complete ',
+ r'^#20 _completeOnAsyncReturn ',
+ r'^#21 doTestAwaitThen ',
+ r'^#22 _asyncErrorWrapperHelper.<anonymous closure> ',
+ r'^#23 _RootZone.runBinary ',
+ r'^#24 _FutureListener.handleError ',
+ r'^#25 Future._propagateToListeners.handleError ',
+ r'^#26 Future._propagateToListeners ',
+ r'^#27 Future._completeError ',
+ r'^#28 _AsyncAwaitCompleter.completeError ',
+ r'^#29 noYields ',
+ r'^#30 _asyncErrorWrapperHelper.<anonymous closure> ',
+ r'^#31 _RootZone.runBinary ',
+ r'^#32 _FutureListener.handleError ',
+ r'^#33 Future._propagateToListeners.handleError ',
+ r'^#34 Future._propagateToListeners ',
+ r'^#35 Future._completeError ',
+ r'^#36 _AsyncAwaitCompleter.completeError ',
+ r'^#37 noYields2 ',
+ r'^#38 _asyncErrorWrapperHelper.<anonymous closure> ',
+ r'^#39 _RootZone.runBinary ',
+ r'^#40 _FutureListener.handleError ',
+ r'^#41 Future._propagateToListeners.handleError ',
+ r'^#42 Future._propagateToListeners ',
+ r'^#43 Future._completeError ',
+ // TODO(dart-vm): Figure out why this is inconsistent:
+ r'^#44 Future.(_asyncCompleteError|_chainForeignFuture).<anonymous closure> ',
+ r'^#45 _microtaskLoop ',
+ r'^#46 _startMicrotaskLoop ',
+ r'^#47 _runPendingImmediateCallback ',
+ r'^#48 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ]);
+
+ final mixedYieldsExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^#1 _RootZone.runUnary ',
+ r'^#2 _FutureListener.handleValue ',
+ r'^#3 Future._propagateToListeners.handleValueCallback ',
+ r'^#4 Future._propagateToListeners ',
+ // TODO(dart-vm): Figure out why this is inconsistent:
+ r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ',
+ r'^#6 _microtaskLoop ',
+ r'^#7 _startMicrotaskLoop ',
+ r'^#8 _runPendingImmediateCallback ',
+ r'^#9 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ];
+ await doTestAwait(mixedYields, mixedYieldsExpected);
+ await doTestAwaitThen(mixedYields, mixedYieldsExpected);
+ await doTestAwaitCatchError(mixedYields, mixedYieldsExpected);
+
+ final syncSuffixExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^#1 _RootZone.runUnary ',
+ r'^#2 _FutureListener.handleValue ',
+ r'^#3 Future._propagateToListeners.handleValueCallback ',
+ r'^#4 Future._propagateToListeners ',
+ // TODO(dart-vm): Figure out why this is inconsistent:
+ r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ',
+ r'^#6 _microtaskLoop ',
+ r'^#7 _startMicrotaskLoop ',
+ r'^#8 _runPendingImmediateCallback ',
+ r'^#9 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ];
+ await doTestAwait(syncSuffix, syncSuffixExpected);
+ await doTestAwaitThen(syncSuffix, syncSuffixExpected);
+ await doTestAwaitCatchError(syncSuffix, syncSuffixExpected);
+
+ final nonAsyncNoStackExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^#1 _RootZone.runUnary ',
+ r'^#2 _FutureListener.handleValue ',
+ r'^#3 Future._propagateToListeners.handleValueCallback ',
+ r'^#4 Future._propagateToListeners ',
+ // TODO(dart-vm): Figure out why this is inconsistent:
+ r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ',
+ r'^#6 _microtaskLoop ',
+ r'^#7 _startMicrotaskLoop ',
+ r'^#8 _runPendingImmediateCallback ',
+ r'^#9 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ];
+ await doTestAwait(nonAsyncNoStack, nonAsyncNoStackExpected);
+ await doTestAwaitThen(nonAsyncNoStack, nonAsyncNoStackExpected);
+ await doTestAwaitCatchError(nonAsyncNoStack, nonAsyncNoStackExpected);
+
+ final asyncStarThrowSyncExpected = const <String>[
+ r'^#0 throwSync \(.+/utils.dart:(16|16:3)\)$',
+ r'^#1 asyncStarThrowSync \(.+/utils.dart:(112|112:11)\)$',
+ r'^#2 _RootZone.runUnary \(.+\)$',
+ r'^#3 _FutureListener.handleValue \(.+\)$',
+ r'^#4 Future._propagateToListeners.handleValueCallback \(.+\)$',
+ r'^#5 Future._propagateToListeners \(.+\)$',
+ // TODO(dart-vm): Figure out why this is inconsistent:
+ r'^#6 Future.(_addListener|_prependListeners).<anonymous closure> \(.+\)$',
+ r'^#7 _microtaskLoop \(.+\)$',
+ r'^#8 _startMicrotaskLoop \(.+\)$',
+ r'^#9 _runPendingImmediateCallback \(.+\)$',
+ r'^#10 _RawReceivePortImpl._handleMessage \(.+\)$',
+ r'^$',
+ ];
+ await doTestAwait(awaitEveryAsyncStarThrowSync, asyncStarThrowSyncExpected);
+ await doTestAwaitThen(
+ awaitEveryAsyncStarThrowSync, asyncStarThrowSyncExpected);
+ await doTestAwaitCatchError(
+ awaitEveryAsyncStarThrowSync, asyncStarThrowSyncExpected);
+
+ final asyncStarThrowAsyncExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^#1 _RootZone.runUnary ',
+ r'^#2 _FutureListener.handleValue ',
+ r'^#3 Future._propagateToListeners.handleValueCallback ',
+ r'^#4 Future._propagateToListeners ',
+ // TODO(dart-vm): Figure out why this is inconsistent:
+ r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ',
+ r'^#6 _microtaskLoop ',
+ r'^#7 _startMicrotaskLoop ',
+ r'^#8 _runPendingImmediateCallback ',
+ r'^#9 _RawReceivePortImpl._handleMessage ',
+ r'^$',
+ ];
+ await doTestAwait(awaitEveryAsyncStarThrowAsync, asyncStarThrowAsyncExpected);
+ await doTestAwaitThen(
+ awaitEveryAsyncStarThrowAsync, asyncStarThrowAsyncExpected);
+ await doTestAwaitCatchError(
+ awaitEveryAsyncStarThrowAsync, asyncStarThrowAsyncExpected);
+}
+
+// For: --lazy-async-stacks
+Future<void> doTestsLazy() async {
+ final allYieldExpected = const <String>[
+ r'^#0 throwSync \(.*/utils.dart:(16|16:3)\)$',
+ r'^#1 allYield3 \(.*/utils.dart:(39|39:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#2 allYield2 \(.*/utils.dart:(0|34|34:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#3 allYield \(.*/utils.dart:(0|29|29:3)\)$',
+ r'^<asynchronous suspension>$',
+ ];
+ await doTestAwait(
+ allYield,
+ allYieldExpected +
+ const <String>[
+ r'^#4 doTestAwait ',
+ r'^<asynchronous suspension>$',
+ r'^#5 doTestsLazy ',
+ r'^<asynchronous suspension>$',
+ r'^#6 main ',
+ r'^<asynchronous suspension>$',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ allYield,
+ allYieldExpected +
+ const <String>[
+ r'^#4 doTestAwaitThen.<anonymous closure> ',
+ r'^<asynchronous suspension>$',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ allYield,
+ allYieldExpected +
+ const <String>[
+ r'^$',
+ ]);
+
+ final noYieldsExpected = const <String>[
+ r'^#0 throwSync \(.*/utils.dart:(16|16:3)\)$',
+ r'^#1 noYields3 \(.*/utils.dart:(54|54:3)\)$',
+ // TODO(dart-vm): Figure out why this frame is flaky:
+ r'^#2 _AsyncAwaitCompleter.start ',
+ r'^#3 noYields3 \(.*/utils.dart:(53|53:23)\)$',
+ r'^#4 noYields2 \(.*/utils.dart:(50|50:9)\)$',
+ r'^<asynchronous suspension>$',
+ r'^$',
+ ];
+ await doTestAwait(noYields, noYieldsExpected);
+ await doTestAwaitThen(noYields, noYieldsExpected);
+ await doTestAwaitCatchError(noYields, noYieldsExpected);
+
+ final mixedYieldsExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#1 mixedYields2 \(.*/utils.dart:(0|66|66:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#2 mixedYields \(.*/utils.dart:(0|61|61:3)\)$',
+ r'^<asynchronous suspension>$',
+ ];
+ await doTestAwait(
+ mixedYields,
+ mixedYieldsExpected +
+ const <String>[
+ r'^#3 doTestAwait ',
+ r'^<asynchronous suspension>$',
+ r'^#4 doTestsLazy ',
+ r'^<asynchronous suspension>$',
+ r'^#5 main ',
+ r'^<asynchronous suspension>$',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ mixedYields,
+ mixedYieldsExpected +
+ const <String>[
+ r'^#3 doTestAwaitThen.<anonymous closure> ',
+ r'^<asynchronous suspension>$',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ mixedYields,
+ mixedYieldsExpected +
+ const <String>[
+ r'^$',
+ ]);
+
+ final syncSuffixExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#1 syncSuffix2 \(.*/utils.dart:(0|82|82:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#2 syncSuffix \(.*/utils.dart:(0|77|77:3)\)$',
+ r'^<asynchronous suspension>$',
+ ];
+ await doTestAwait(
+ syncSuffix,
+ syncSuffixExpected +
+ const <String>[
+ r'^#3 doTestAwait ',
+ r'^<asynchronous suspension>$',
+ r'^#4 doTestsLazy ',
+ r'^<asynchronous suspension>$',
+ r'^#5 main ',
+ r'^<asynchronous suspension>$',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ syncSuffix,
+ syncSuffixExpected +
+ const <String>[
+ r'^#3 doTestAwaitThen.<anonymous closure> ',
+ r'^<asynchronous suspension>$',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ syncSuffix,
+ syncSuffixExpected +
+ const <String>[
+ r'^$',
+ ]);
+
+ final nonAsyncNoStackExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#1 nonAsyncNoStack1 \(.*/utils.dart:(0|95|95:36)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#2 nonAsyncNoStack \(.*/utils.dart:(0|93|93:35)\)$',
+ r'^<asynchronous suspension>$',
+ ];
+ await doTestAwait(
+ nonAsyncNoStack,
+ nonAsyncNoStackExpected +
+ const <String>[
+ r'^#3 doTestAwait ',
+ r'^<asynchronous suspension>$',
+ r'^#4 doTestsLazy ',
+ r'^<asynchronous suspension>$',
+ r'^#5 main ',
+ r'^<asynchronous suspension>$',
+ r'^$',
+ ]);
+ await doTestAwaitThen(
+ nonAsyncNoStack,
+ nonAsyncNoStackExpected +
+ const <String>[
+ r'^#3 doTestAwaitThen.<anonymous closure> ',
+ r'^<asynchronous suspension>$',
+ r'^$',
+ ]);
+ await doTestAwaitCatchError(
+ nonAsyncNoStack,
+ nonAsyncNoStackExpected +
+ const <String>[
+ r'^$',
+ ]);
+
+ final asyncStarThrowSyncExpected = const <String>[
+ r'^#0 throwSync \(.+/utils.dart:(16|16:3)\)$',
+ r'^#1 asyncStarThrowSync \(.+/utils.dart:(112|112:11)\)$',
+ r'^<asynchronous suspension>$',
+ // Non-visible _onData frame.
+ r'^<asynchronous suspension>$',
+ r'^$',
+ ];
+ await doTestAwait(awaitEveryAsyncStarThrowSync, asyncStarThrowSyncExpected);
+ await doTestAwaitThen(
+ awaitEveryAsyncStarThrowSync, asyncStarThrowSyncExpected);
+ await doTestAwaitCatchError(
+ awaitEveryAsyncStarThrowSync, asyncStarThrowSyncExpected);
+
+ final asyncStarThrowAsyncExpected = const <String>[
+ r'^#0 throwAsync \(.*/utils.dart:(21|21:3)\)$',
+ r'^<asynchronous suspension>$',
+ r'^#1 asyncStarThrowAsync \(.*/utils.dart:(0|126|126:5)\)$',
+ r'^<asynchronous suspension>$',
+ // Non-visible _onData frame.
+ r'^<asynchronous suspension>$',
+ ];
+ await doTestAwait(awaitEveryAsyncStarThrowAsync, asyncStarThrowAsyncExpected);
+ await doTestAwaitThen(
+ awaitEveryAsyncStarThrowAsync, asyncStarThrowAsyncExpected);
+ await doTestAwaitCatchError(
+ awaitEveryAsyncStarThrowAsync, asyncStarThrowAsyncExpected);
}
diff --git a/runtime/tests/vm/dart/entrypoints/aot/static_this_test.dart b/runtime/tests/vm/dart/entrypoints/aot/static_this_test.dart
index a938ed4..f46906f 100644
--- a/runtime/tests/vm/dart/entrypoints/aot/static_this_test.dart
+++ b/runtime/tests/vm/dart/entrypoints/aot/static_this_test.dart
@@ -2,7 +2,7 @@
// 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.
//
-// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=5 -Denable_inlining=true
+// VMOptions=--enable-testing-pragmas -Denable_inlining=true
import '../static_this.dart';
diff --git a/runtime/tests/vm/dart/entrypoints/aot/super_test.dart b/runtime/tests/vm/dart/entrypoints/aot/super_test.dart
index 96c4aeb..fae9243 100644
--- a/runtime/tests/vm/dart/entrypoints/aot/super_test.dart
+++ b/runtime/tests/vm/dart/entrypoints/aot/super_test.dart
@@ -2,7 +2,7 @@
// 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.
//
-// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=5 -Denable_inlining=true
+// VMOptions=--enable-testing-pragmas -Denable_inlining=true
import "../super.dart";
diff --git a/runtime/tests/vm/dart/entrypoints/common.dart b/runtime/tests/vm/dart/entrypoints/common.dart
index 3c1ccf6..bc8822a 100644
--- a/runtime/tests/vm/dart/entrypoints/common.dart
+++ b/runtime/tests/vm/dart/entrypoints/common.dart
@@ -23,41 +23,53 @@
// iterations.
const bool benchmarkMode = const bool.fromEnvironment("benchmark_mode");
-int expectedEntryPoint = -1;
-int expectedTearoffEntryPoint = -1;
+class TargetCalls {
+ int checked = 0;
+ int unchecked = 0;
-// We check that this is true at the end of the test to ensure that the
-// introspection machinery is operational.
-bool validateRan = false;
+ // Leave a little room for some cases which always use the checked entry, like
+ // lazy compile stub or interpreter warm-up.
+ static const int wiggle = 10;
-_validateHelper(int expected, int ep) {
- validateRan = true;
+ void expectChecked(int iterations) {
+ print("$checked, $unchecked");
+ Expect.isTrue(checked >= iterations - wiggle && unchecked == 0);
+ }
+
+ void expectUnchecked(int iterations) {
+ print("$checked, $unchecked");
+ Expect.isTrue(checked <= wiggle && unchecked >= iterations - wiggle);
+ }
+}
+
+TargetCalls entryPoint = TargetCalls();
+TargetCalls tearoffEntryPoint = TargetCalls();
+
+_validateHelper(int ep, TargetCalls calls) {
+ calls ??= entryPoint;
+
if (ep < 0 || ep > 2) {
Expect.fail("ERROR: invalid entry-point ($ep) passed by VM.");
}
- if (expected < -1 || expected > 2) {
- Expect.fail("ERROR: invalid expected entry-point set ($expected)");
+ if (ep == 0) {
+ calls.checked++;
+ } else {
+ calls.unchecked++;
}
- if (expected == -1) return;
- Expect.equals(expected, ep);
}
-void _validateFn(String _, int ep) => _validateHelper(expectedEntryPoint, ep);
+void _validateFn(String _, int ep) => _validateHelper(ep, null);
// Invocation of tearoffs go through a tearoff wrapper. We want to independently
// test which entrypoint was used for the tearoff wrapper vs. which was used for
// actual target.
-_validateTearoffFn(String name, int entryPoint) {
+_validateTearoffFn(String name, int ep) {
_validateHelper(
- name.endsWith("#tearoff")
- ? expectedTearoffEntryPoint
- : expectedEntryPoint,
- entryPoint);
+ ep, name.endsWith("#tearoff") ? tearoffEntryPoint : entryPoint);
}
@pragma("vm:entry-point", "get")
const validate = benchmarkMode ? null : _validateFn;
+
@pragma("vm:entry-point", "get")
const validateTearoff = benchmarkMode ? null : _validateTearoffFn;
-
-void bumpUsageCounter() {}
diff --git a/runtime/tests/vm/dart/entrypoints/jit/polymorphic_optional_this_test.dart b/runtime/tests/vm/dart/entrypoints/jit/polymorphic_optional_this_test.dart
index 44e6179..3599dba 100644
--- a/runtime/tests/vm/dart/entrypoints/jit/polymorphic_optional_this_test.dart
+++ b/runtime/tests/vm/dart/entrypoints/jit/polymorphic_optional_this_test.dart
@@ -2,8 +2,9 @@
// 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.
//
-// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10 -Denable_inlining=true
-// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10 -Denable_inlining=true --compilation-counter-threshold=1
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10 --compilation-counter-threshold=1
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=-1 --compilation-counter-threshold=1
// Test that 'PolymorphicInstanceCall's against "this" go through the unchecked
// entrypoint. The use of optional arguments here encourages prologue sharing
@@ -15,14 +16,6 @@
abstract class C<T> {
@NeverInline
void samir1(T x) {
- // Make sure this method gets optimized before main.
- // Otherwise it might get inlined into warm-up loop, and subsequent
- // loop will call an unoptimized version (which is not guaranteed to
- // dispatch to unchecked entry point).
- bumpUsageCounter();
- bumpUsageCounter();
- bumpUsageCounter();
-
samir2(x, y: "hi");
}
@@ -62,17 +55,10 @@
}
main(List<String> args) {
- // Warmup.
- expectedEntryPoint = -1;
- for (int i = 0; i < 100; ++i) {
- getC().samir1(i);
- }
-
- expectedEntryPoint = 2;
const int iterations = benchmarkMode ? 100000000 : 100;
for (int i = 0; i < iterations; ++i) {
getC().samir1(i);
}
- Expect.isTrue(validateRan);
+ entryPoint.expectUnchecked(iterations);
}
diff --git a/runtime/tests/vm/dart/entrypoints/jit/polymorphic_this_test.dart b/runtime/tests/vm/dart/entrypoints/jit/polymorphic_this_test.dart
index 6b45a0d..5793419 100644
--- a/runtime/tests/vm/dart/entrypoints/jit/polymorphic_this_test.dart
+++ b/runtime/tests/vm/dart/entrypoints/jit/polymorphic_this_test.dart
@@ -2,8 +2,9 @@
// 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.
//
-// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10 -Denable_inlining=true
-// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10 -Denable_inlining=true --compilation-counter-threshold=1
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10 --compilation-counter-threshold=1
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=-1 --compilation-counter-threshold=1
// Test that 'PolymorphicInstanceCall's against "this" go through the unchecked
// entrypoint.
@@ -14,14 +15,6 @@
abstract class C<T> {
@NeverInline
void target1(T x) {
- // Make sure this method gets optimized before main.
- // Otherwise it might get inlined into warm-up loop, and subsequent
- // loop will call an unoptimized version (which is not guaranteed to
- // dispatch to unchecked entry point).
- bumpUsageCounter();
- bumpUsageCounter();
- bumpUsageCounter();
-
target2(x);
}
@@ -57,24 +50,10 @@
}
main(List<String> args) {
- // Warmup.
- expectedEntryPoint = -1;
- for (int i = 0; i < 100; ++i) {
- getC().target1(0);
- }
-
- expectedEntryPoint = 1;
const int iterations = benchmarkMode ? 200000000 : 100;
for (int i = 0; i < iterations; ++i) {
getC().target1(i);
}
- // Once for D and once for E.
- expectedEntryPoint = 0;
- dynamic x = getC();
- x.target2(0);
- x = getC();
- x.target2(0);
-
- Expect.isTrue(validateRan);
+ entryPoint.expectUnchecked(iterations);
}
diff --git a/runtime/tests/vm/dart/entrypoints/jit/static_this_test.dart b/runtime/tests/vm/dart/entrypoints/jit/static_this_test.dart
index 0c1aa19..29094e4 100644
--- a/runtime/tests/vm/dart/entrypoints/jit/static_this_test.dart
+++ b/runtime/tests/vm/dart/entrypoints/jit/static_this_test.dart
@@ -2,8 +2,9 @@
// 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.
//
-// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=5
-// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=5 -Denable_inlining=true
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=5 --compilation-counter-threshold=5
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=5 -Denable_inlining=true --compilation-counter-threshold=5
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=-1 --compilation-counter-threshold=5
import '../static_this.dart';
diff --git a/runtime/tests/vm/dart/entrypoints/jit/super_test.dart b/runtime/tests/vm/dart/entrypoints/jit/super_test.dart
index d6d8a1a..be8d2d9 100644
--- a/runtime/tests/vm/dart/entrypoints/jit/super_test.dart
+++ b/runtime/tests/vm/dart/entrypoints/jit/super_test.dart
@@ -2,8 +2,9 @@
// 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.
//
-// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=5 -Denable_inlining=true
-// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=5
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=5 -Denable_inlining=true --compilation-counter-threshold=5
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=5 --compilation-counter-threshold=5
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=-1 --compilation-counter-threshold=5
import "../super.dart";
diff --git a/runtime/tests/vm/dart/entrypoints/static_this.dart b/runtime/tests/vm/dart/entrypoints/static_this.dart
index dc9f958..38a8307 100644
--- a/runtime/tests/vm/dart/entrypoints/static_this.dart
+++ b/runtime/tests/vm/dart/entrypoints/static_this.dart
@@ -9,6 +9,7 @@
class C<T> {
@pragma("vm:testing.unsafe.trace-entrypoints-fn", validate)
+ @pragma("vm:entry-point")
@NeverInline
@AlwaysInline
void target2(T x) {
@@ -17,14 +18,6 @@
@NeverInline
void target1(T x) {
- // Make sure this method gets optimized before main.
- // Otherwise it might get inlined into warm-up loop, and subsequent
- // loop will call an unoptimized version (which is not guaranteed to
- // dispatch to unchecked entry point).
- bumpUsageCounter();
- bumpUsageCounter();
- bumpUsageCounter();
-
target2(x);
}
}
@@ -33,21 +26,10 @@
// Make sure the precise runtime-type of C is not known below.
C c = args.length == 0 ? C<int>() : C<String>();
- // Warmup.
- expectedEntryPoint = -1;
- for (int i = 0; i < 100; ++i) {
- c.target1(i);
- }
-
- expectedEntryPoint = 1;
const int iterations = benchmarkMode ? 400000000 : 100;
for (int i = 0; i < iterations; ++i) {
c.target1(i);
}
- expectedEntryPoint = 0;
- dynamic x = c;
- x.target2(0);
-
- Expect.isTrue(validateRan);
+ entryPoint.expectUnchecked(iterations);
}
diff --git a/runtime/tests/vm/dart/entrypoints/super.dart b/runtime/tests/vm/dart/entrypoints/super.dart
index a31fd70..2ba7af0 100644
--- a/runtime/tests/vm/dart/entrypoints/super.dart
+++ b/runtime/tests/vm/dart/entrypoints/super.dart
@@ -19,14 +19,6 @@
class D<T> extends C<T> {
@NeverInline
void target1(T x) {
- // Make sure this method gets optimized before main.
- // Otherwise it might get inlined into warm-up loop, and subsequent
- // loop will call an unoptimized version (which is not guaranteed to
- // dispatch to unchecked entry point).
- bumpUsageCounter();
- bumpUsageCounter();
- bumpUsageCounter();
-
super.target1(x);
}
}
@@ -34,14 +26,6 @@
class E<T> extends C<T> {
@NeverInline
void target1(T x) {
- // Make sure this method gets optimized before main.
- // Otherwise it might get inlined into warm-up loop, and subsequent
- // loop will call an unoptimized version (which is not guaranteed to
- // dispatch to unchecked entry point).
- bumpUsageCounter();
- bumpUsageCounter();
- bumpUsageCounter();
-
super.target1(x);
}
}
@@ -60,26 +44,16 @@
}
}
-// This works around issues with OSR not totally respecting the optimization
-// counter threshold.
-void testOneC(C x, int i) => x.target1(i);
-
test(List<String> args) {
// Make sure the check on target1.x is not completely eliminated.
if (args.length > 0) {
(C<int>() as C<num>).target1(1.0);
}
- expectedEntryPoint = -1;
- for (int i = 0; i < 100; ++i) {
- testOneC(getC(), i);
- }
-
- expectedEntryPoint = 1;
const int iterations = benchmarkMode ? 200000000 : 100;
for (int i = 0; i < iterations; ++i) {
- testOneC(getC(), i);
+ getC().target1(i);
}
- Expect.isTrue(validateRan);
+ entryPoint.expectUnchecked(iterations);
}
diff --git a/runtime/tests/vm/dart/entrypoints/tearoff_prologue_test.dart b/runtime/tests/vm/dart/entrypoints/tearoff_prologue_test.dart
index 3b2195b..2cf7278 100644
--- a/runtime/tests/vm/dart/entrypoints/tearoff_prologue_test.dart
+++ b/runtime/tests/vm/dart/entrypoints/tearoff_prologue_test.dart
@@ -5,6 +5,7 @@
// No type checks are removed here, but we can skip the argument count check.
// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10
// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10 -Denable_inlining=true
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=-1
import "package:expect/expect.dart";
import "common.dart";
@@ -20,23 +21,19 @@
}
}
+void run(void Function(int) test, int i) {
+ test(i);
+}
+
main(List<String> args) {
var c = new C<int>();
var f = c.samir1;
- // Warmup.
- expectedEntryPoint = -1;
- expectedTearoffEntryPoint = -1;
- for (int i = 0; i < 100; ++i) {
- f(i);
- }
-
- expectedEntryPoint = 0;
- expectedTearoffEntryPoint = 1;
- int iterations = benchmarkMode ? 100000000 : 100;
+ const int iterations = benchmarkMode ? 100000000 : 100;
for (int i = 0; i < iterations; ++i) {
- f(i);
+ run(f, i);
}
- Expect.isTrue(validateRan);
+ entryPoint.expectChecked(iterations);
+ tearoffEntryPoint.expectUnchecked(iterations);
}
diff --git a/runtime/tests/vm/dart/entrypoints/tearoff_test.dart b/runtime/tests/vm/dart/entrypoints/tearoff_test.dart
index b42369e..d0bd88a 100644
--- a/runtime/tests/vm/dart/entrypoints/tearoff_test.dart
+++ b/runtime/tests/vm/dart/entrypoints/tearoff_test.dart
@@ -4,6 +4,7 @@
//
// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10
// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=10 -Denable_inlining=true
+// VMOptions=--enable-testing-pragmas --no-background-compilation --optimization-counter-threshold=-1
// Test that typed calls against tearoffs go into the unchecked entrypoint.
@@ -20,22 +21,18 @@
}
}
+void run(void Function(int, String) fn, int i) {
+ fn(i, "foo");
+}
+
main(List<String> args) {
var f = (new C<int>()).target1;
- // Warmup.
- expectedEntryPoint = -1;
- expectedTearoffEntryPoint = -1;
- for (int i = 0; i < 100; ++i) {
- f(i, "foo");
- }
-
- expectedEntryPoint = 0;
- expectedTearoffEntryPoint = 1;
const int iterations = benchmarkMode ? 100000000 : 100;
for (int i = 0; i < iterations; ++i) {
- f(i, "foo");
+ run(f, i);
}
- Expect.isTrue(validateRan);
+ entryPoint.expectChecked(iterations);
+ tearoffEntryPoint.expectUnchecked(iterations);
}
diff --git a/runtime/tests/vm/dart/issue_31959_31960_test.dart b/runtime/tests/vm/dart/issue_31959_31960_test.dart
index fddff48..d63a16f 100644
--- a/runtime/tests/vm/dart/issue_31959_31960_test.dart
+++ b/runtime/tests/vm/dart/issue_31959_31960_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:async';
import 'dart:isolate';
import 'dart:math';
diff --git a/runtime/tests/vm/dart/product_aot_kernel_test.dart b/runtime/tests/vm/dart/product_aot_kernel_test.dart
new file mode 100644
index 0000000..99c21ed
--- /dev/null
+++ b/runtime/tests/vm/dart/product_aot_kernel_test.dart
@@ -0,0 +1,68 @@
+// Copyright (c) 2019, 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.
+
+// This test ensures that certain core libraries are "empty" in product mode (thereby
+// ensuring the right conditional pragma annotations were used).
+
+import "dart:async";
+import "dart:io";
+
+import 'package:path/path.dart' as path;
+import 'package:kernel/kernel.dart';
+import 'package:expect/expect.dart';
+
+import 'use_bare_instructions_flag_test.dart' show run, withTempDir;
+
+const platformFilename = 'vm_platform_strong.dill';
+
+Future main(List<String> args) async {
+ final buildDir = path.dirname(Platform.resolvedExecutable);
+
+ if (!buildDir.contains('Product')) {
+ print('Skipping test due to running in non-PRODUCT configuration.');
+ return;
+ }
+
+ if (Platform.isAndroid) {
+ print('Skipping test due missing "$platformFilename".');
+ return;
+ }
+
+ final platformDill = path.join(buildDir, platformFilename);
+ await withTempDir((String tempDir) async {
+ final helloFile = path.join(tempDir, 'hello.dart');
+ final helloDillFile = path.join(tempDir, 'hello.dart.dill');
+
+ // Compile script to Kernel IR.
+ await File(helloFile).writeAsString('main() => print("Hello");');
+ final genKernel = Platform.isWindows ?
+ "pkg\\vm\\tool\\gen_kernel.bat" : 'pkg/vm/tool/gen_kernel';
+ await run(genKernel, <String>[
+ '--aot',
+ '--platform=$platformDill',
+ '-o',
+ helloDillFile,
+ helloFile,
+ ]);
+
+ // Ensure the AOT dill file will have effectively empty service related
+ // libraries.
+ final Component component = loadComponentFromBinary(helloDillFile);
+
+ final libVmService = component.libraries
+ .singleWhere((lib) => lib.importUri.toString() == 'dart:_vmservice');
+ Expect.isTrue(libVmService.procedures.isEmpty);
+ Expect.isTrue(libVmService.classes.isEmpty);
+ Expect.isTrue(libVmService.fields.isEmpty);
+
+ final libVmServiceIo = component.libraries
+ .singleWhere((lib) => lib.importUri.toString() == 'dart:vmservice_io');
+ Expect.isTrue(libVmServiceIo.procedures.isEmpty);
+ Expect.isTrue(libVmServiceIo.classes.isEmpty);
+
+ // Those fields are currently accessed by by the embedder, even in product
+ // mode.
+ Expect.isTrue(libVmServiceIo.fields.length <= 11);
+ });
+}
diff --git a/runtime/tests/vm/dart/spawn_infinite_loop_test.dart b/runtime/tests/vm/dart/spawn_infinite_loop_test.dart
index cc0fb42..3a89e80 100644
--- a/runtime/tests/vm/dart/spawn_infinite_loop_test.dart
+++ b/runtime/tests/vm/dart/spawn_infinite_loop_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:isolate';
// This test ensures that the VM can kill the spawned isolate during VM
diff --git a/runtime/tests/vm/dart/transferable_test.dart b/runtime/tests/vm/dart/transferable_test.dart
index a9a97d7..b8d6bfe 100644
--- a/runtime/tests/vm/dart/transferable_test.dart
+++ b/runtime/tests/vm/dart/transferable_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Test that validates that transferables are faster than regular typed data.
import 'dart:async';
diff --git a/runtime/tests/vm/dart/transferable_throws_test.dart b/runtime/tests/vm/dart/transferable_throws_test.dart
index 860965a..6f4d55b 100644
--- a/runtime/tests/vm/dart/transferable_throws_test.dart
+++ b/runtime/tests/vm/dart/transferable_throws_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Test that ensures correct exceptions are thrown when misusing
// [TransferableTypedData].
diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status
index 1801067..b265ab8 100644
--- a/runtime/tests/vm/vm.status
+++ b/runtime/tests/vm/vm.status
@@ -225,8 +225,8 @@
[ $compiler == dartkb ]
dart/generic_field_invocation_test: SkipByDesign # KBC interpreters do not support --no_lazy_dispatchers
-[ $builder_tag == bytecode_interpreter || $builder_tag == bytecode_mixed || $builder_tag == optimization_counter_threshold || $hot_reload || $hot_reload_rollback || $arch != arm && $arch != simarm && $arch != x64 || $compiler != dartk && $compiler != dartkb && $compiler != dartkp ]
-dart/entrypoints/*: SkipByDesign # These tests are for compiler optimizations and very sensible to when functions are optimized, so they are disabled on hotreload, optcounter and bytecode interpreter bots.
+[ $builder_tag == bytecode_interpreter || $hot_reload || $hot_reload_rollback || $arch != arm && $arch != simarm && $arch != x64 || $compiler != dartk && $compiler != dartkp && $compiler != dartkb ]
+dart/entrypoints/*: SkipByDesign # These tests are for compiler optimizations and very sensitive to when functions are optimized, so they are disabled on hotreload and optcounter bots.
[ $builder_tag == crossword || $builder_tag == crossword_ast || $compiler != dartkp || $system != linux && $system != macos && $system != windows ]
dart/run_appended_aot_snapshot_test: SkipByDesign # Tests the precompiled runtime.
diff --git a/runtime/tools/dartfuzz/collect_data.py b/runtime/tools/dartfuzz/collect_data.py
index 6ce118f..03ca8c1 100755
--- a/runtime/tools/dartfuzz/collect_data.py
+++ b/runtime/tools/dartfuzz/collect_data.py
@@ -76,7 +76,7 @@
print_reencoded(x[0])
-def print_output_sum(shard, text, s=[0, 0, 0, 0, 0, 0], divs=[]):
+def get_output_sum(shard, text, should_print, s=[0, 0, 0, 0, 0, 0], divs=[]):
m = P_SUM.findall(text)
if not m:
sys.stderr.write("Failed to parse shard %s stdout for summary" % shard)
@@ -86,14 +86,16 @@
divs.append(shard)
for i in range(len(s)):
s[i] += int(test[i])
- print(
- "Tests: %d Success: %d (Rerun: %d) Skipped: %d Timeout: %d "
- "Divergences: %d (failing shards: %s) \r" %
- tuple(s + [", ".join(divs) if divs else "none"]),
- end="")
+ if should_print:
+ print(
+ "Tests: %d Success: %d (Rerun: %d) Skipped: %d Timeout: %d "
+ "Divergences: %d (failing shards: %s) \r" %
+ tuple(s + [", ".join(divs) if divs else "none"]),
+ end="")
+ return s
-def get_stats(uri, output_type, keywords):
+def get_stats(uri, output_type, keywords, output_csv):
resp = requests.get(uri)
if output_type == "all":
@@ -103,7 +105,9 @@
print_output_div(shard, resp.text, keywords)
elif output_type == "sum":
shard = P_SHARD.findall(uri)[0]
- print_output_sum(shard, resp.text)
+ should_print = not output_csv
+ return get_output_sum(shard, resp.text, should_print)
+ return None
def main():
@@ -121,16 +125,37 @@
default=[],
help="Do not include divergences containing these keywords.")
parser.add_argument(
+ "--output-csv",
+ dest="output_csv",
+ action="store_true",
+ default=False,
+ help=
+ "Print output in CSV format to stdout. Only supported for --type=sum")
+ parser.add_argument(
"uri",
type=str,
help=
"Uri of one make_a_fuzz run from https://ci.chromium.org/p/dart/builders/ci.sandbox/fuzz-linux."
)
args = parser.parse_args()
+ if args.type != 'sum' and args.output_csv:
+ print('Error: --output-csv can only be provided for --type=sum')
+ return
+
shard_links = get_shard_links(args.uri)
+
+ if len(shard_links) == 0:
+ print("Invalid run")
+ sys.exit(-1)
+ return
+
for link in shard_links:
- get_stats(link, args.type, args.filter)
- print("")
+ stats = get_stats(link, args.type, args.filter, args.output_csv)
+ if args.output_csv:
+ print("%d,%d,%d,%d,%d,%d" % tuple(stats))
+ else:
+ print("")
+ sys.exit(0)
if __name__ == "__main__":
diff --git a/runtime/tools/dartfuzz/dartfuzz.dart b/runtime/tools/dartfuzz/dartfuzz.dart
index 82d0316..c344ccb 100644
--- a/runtime/tools/dartfuzz/dartfuzz.dart
+++ b/runtime/tools/dartfuzz/dartfuzz.dart
@@ -14,7 +14,7 @@
// Version of DartFuzz. Increase this each time changes are made
// to preserve the property that a given version of DartFuzz yields
// the same fuzzed program for a deterministic random seed.
-const String version = '1.71';
+const String version = '1.75';
// Restriction on statements and expressions.
const int stmtDepth = 1;
@@ -37,7 +37,13 @@
const methodName = 'foo';
/// Enum for the different types of methods generated by the fuzzer.
-enum MethodType { globalMethod, ffiMethod, instanceMethod, extensionMethod }
+enum MethodType {
+ globalMethod,
+ ffiMethod,
+ instanceMethod,
+ callMethod,
+ extensionMethod
+}
/// Base class for all methods in the program generated by DartFuzz.
abstract class Method {
@@ -153,6 +159,34 @@
final String className;
}
+class CallMethod extends Method {
+ CallMethod(List<DartType> parameters, DartFuzz fuzzer, this.className)
+ : super("call", parameters, fuzzer) {}
+
+ @override
+ String emitCall(int depth,
+ {RhsFilter rhsFilter, bool includeSemicolon = false}) {
+ String outputName;
+ outputName = "${className}()";
+ fuzzer.emitLn(outputName, newline: false);
+ fuzzer.emitExprList(depth + 1, parameters, rhsFilter: rhsFilter);
+ if (includeSemicolon) {
+ fuzzer.emit(';');
+ }
+ return outputName;
+ }
+
+ @override
+ void emit() {
+ // Override the parent class' call method.
+ fuzzer.emit("@override");
+ fuzzer.emitNewline();
+ emitFunctionDefinition();
+ }
+
+ final String className;
+}
+
// Class for extension methods generated by DartFuzz.
class ExtensionMethod extends Method {
ExtensionMethod(String name, List<DartType> parameters, DartFuzz fuzzer,
@@ -293,8 +327,8 @@
namePrefix: methodName);
classFields = fillTypes2(limit2: numClasses, limit1: numLocalVars);
final int numClassMethods = 1 + numClasses - classFields.length;
- classMethods =
- getClassMethods(classFields.length, numClassMethods, numMethodParams);
+ classMethods = getClassMethods(classFields.length, numClassMethods,
+ numMethodParams, fillTypes1(limit: numMethodParams));
virtualClassMethods = <Map<int, List<int>>>[];
classParents = <int>[];
// Setup optional ffi methods and types.
@@ -347,18 +381,30 @@
list.add(ExtensionMethod("${namePrefix}${i}", params, this, className,
extensionName, type));
break;
+ default:
+ break;
}
}
return list;
}
- List<List<Method>> getClassMethods(
- int numClasses, int maxMethods, int maxParams) =>
- [
- for (int i = 0; i < numClasses; i++)
- getMethods(maxMethods, maxParams, MethodType.instanceMethod,
- className: "X${i}", namePrefix: "${methodName}${i}_")
- ];
+ List<List<Method>> getClassMethods(int numClasses, int maxMethods,
+ int maxParams, List<DartType> callMethodParams) {
+ final methodsForAllClasses = <List<Method>>[];
+ for (int i = 0; i < numClasses; i++) {
+ final methodsForCurrentClass = getMethods(
+ maxMethods, maxParams, MethodType.instanceMethod,
+ className: "X${i}", namePrefix: "${methodName}${i}_");
+ // Add the call method for the current class. The prototype for the call
+ // method is pre-decided. This is because we are possibly overriding the
+ // parent class' call method, in which case the prototype should be the
+ // same. To simplify the dartfuzz logic, all call methods have the same
+ // prototype.
+ methodsForCurrentClass.add(CallMethod(callMethodParams, this, "X${i}"));
+ methodsForAllClasses.add(methodsForCurrentClass);
+ }
+ return methodsForAllClasses;
+ }
//
// General Helpers.
@@ -679,7 +725,9 @@
while (parentClass >= 0) {
vcm[parentClass] = <int>[];
for (int j = 0, n = classMethods[parentClass].length; j < n; j++) {
- if (rollDice(8)) {
+ // Call methods are presently always already overriden, so we
+ // shouldn't override them here.
+ if (rollDice(8) && !(classMethods[parentClass][j] is CallMethod)) {
currentClass = parentClass;
currentMethod = j;
classMethods[parentClass][j].emit();
@@ -707,7 +755,7 @@
} else {
final int parentClass = choose(i);
classParents.add(parentClass);
- if (choose(2) != 0) {
+ if (coinFlip()) {
// Inheritance
emit('class X$i extends X${parentClass} ');
} else {
diff --git a/runtime/tools/dartfuzz/dartfuzz_api_table.dart b/runtime/tools/dartfuzz/dartfuzz_api_table.dart
index c2f5948..e3f4093 100644
--- a/runtime/tools/dartfuzz/dartfuzz_api_table.dart
+++ b/runtime/tools/dartfuzz/dartfuzz_api_table.dart
@@ -62,7 +62,6 @@
'A': DartType.INT8LIST,
'C': DartType.INT16LIST,
'E': DartType.INT32LIST,
- 'F': DartType.INT32X4,
'G': DartType.INT32X4LIST,
'H': DartType.INT64LIST,
'J': DartType.FLOAT32LIST,
@@ -89,7 +88,6 @@
DartType.INT8LIST: int8ListLibs,
DartType.INT16LIST: int16ListLibs,
DartType.INT32LIST: int32ListLibs,
- DartType.INT32X4: int32x4Libs,
DartType.INT32X4LIST: int32x4ListLibs,
DartType.INT64LIST: int64ListLibs,
DartType.FLOAT32LIST: float32ListLibs,
@@ -130,10 +128,6 @@
DartLib('add', 'XI'),
DartLib('bool.fromEnvironment', 'VS'),
DartLib('endsWith', 'SS'),
- DartLib('flagW', 'Fv'),
- DartLib('flagX', 'Fv'),
- DartLib('flagY', 'Fv'),
- DartLib('flagZ', 'Fv'),
DartLib('isEmpty', 'Mv'),
DartLib('isEmpty', 'Sv'),
DartLib('isEven', 'Iv'),
@@ -754,10 +748,10 @@
DartLib('ceil', 'DV'),
DartLib('ceil', 'IV'),
DartLib('codeUnitAt', 'SI'),
- DartLib('compareTo', 'SS'),
DartLib('compareTo', 'DD'),
- DartLib('floor', 'IV'),
+ DartLib('compareTo', 'SS'),
DartLib('floor', 'DV'),
+ DartLib('floor', 'IV'),
DartLib('floor', 'DV'),
DartLib('gcd', 'II'),
DartLib('indexOf', 'LII'),
@@ -766,8 +760,8 @@
DartLib('int.tryParse', 'VS'),
DartLib('lastIndexOf', 'LII'),
DartLib('length', 'Mv'),
- DartLib('length', 'Sv'),
DartLib('length', 'Lv'),
+ DartLib('length', 'Sv'),
DartLib('modInverse', 'II'),
DartLib('modPow', 'III'),
DartLib('removeAt', 'LI'),
@@ -778,7 +772,6 @@
DartLib('sign', 'Iv'),
DartLib('signMask', 'Pv'),
DartLib('signMask', 'Kv'),
- DartLib('signMask', 'Fv'),
DartLib('toInt', 'DV'),
DartLib('toSigned', 'II'),
DartLib('toUnsigned', 'II'),
@@ -787,10 +780,6 @@
DartLib('truncate', 'DV'),
DartLib('unicodeBomCharacterRune', 'Vv'),
DartLib('unicodeReplacementCharacterRune', 'Vv'),
- DartLib('w', 'Fv'),
- DartLib('x', 'Fv'),
- DartLib('y', 'Fv'),
- DartLib('z', 'Fv'),
];
static const doubleLibs = [
DartLib('abs', 'DV'),
@@ -911,26 +900,6 @@
DartLib('Int32List.fromList', 'VL'),
DartLib('sublist', 'EII'),
];
- static const int32x4Libs = [
- DartLib('Int32x4.bool', 'VBBBB'),
- DartLib('Int32x4.fromFloat32x4Bits', 'VK'),
- DartLib('equal', 'KK'),
- DartLib('greaterThan', 'KK'),
- DartLib('greaterThanOrEqual', 'KK'),
- DartLib('lessThan', 'KK'),
- DartLib('lessThanOrEqual', 'KK'),
- DartLib('notEqual', 'KK'),
- DartLib('shuffle', 'FI'),
- DartLib('shuffleMix', 'FFI'),
- DartLib('withFlagW', 'FB'),
- DartLib('withFlagX', 'FB'),
- DartLib('withFlagY', 'FB'),
- DartLib('withFlagZ', 'FB'),
- DartLib('withW', 'FI'),
- DartLib('withX', 'FI'),
- DartLib('withY', 'FI'),
- DartLib('withZ', 'FI'),
- ];
static const int32x4ListLibs = [
DartLib('sublist', 'GII'),
];
@@ -943,17 +912,13 @@
];
static const float32x4Libs = [
DartLib('Float32x4.fromFloat64x2', 'VP'),
- DartLib('Float32x4.fromInt32x4Bits', 'VF'),
DartLib('Float32x4.splat', 'VD'),
DartLib('Float32x4.zero', 'VV'),
DartLib('abs', 'KV'),
DartLib('clamp', 'KKK'),
DartLib('max', 'KK'),
DartLib('min', 'KK'),
- DartLib('reciprocal', 'KV'),
- DartLib('reciprocalSqrt', 'KV'),
DartLib('scale', 'KD'),
- DartLib('select', 'FKK'),
DartLib('shuffle', 'KI'),
DartLib('shuffleMix', 'KKI'),
DartLib('sqrt', 'KV'),
diff --git a/runtime/tools/dartfuzz/gen_api_table.dart b/runtime/tools/dartfuzz/gen_api_table.dart
index a2f7a6b..e3f35ec 100644
--- a/runtime/tools/dartfuzz/gen_api_table.dart
+++ b/runtime/tools/dartfuzz/gen_api_table.dart
@@ -119,7 +119,7 @@
int8ListEncoding: 'DartType.INT8LIST',
int16ListEncoding: 'DartType.INT16LIST',
int32ListEncoding: 'DartType.INT32LIST',
- int32x4Encoding: 'DartType.INT32X4',
+ // int32x4Encoding: 'DartType.INT32X4',
int32x4ListEncoding: 'DartType.INT32X4LIST',
int64ListEncoding: 'DartType.INT64LIST',
float32ListEncoding: 'DartType.FLOAT32LIST',
@@ -147,7 +147,7 @@
'DartType.INT8LIST': int8ListLibs,
'DartType.INT16LIST': int16ListLibs,
'DartType.INT32LIST': int32ListLibs,
- 'DartType.INT32X4': int32x4Libs,
+ // 'DartType.INT32X4': int32x4Libs,
'DartType.INT32X4LIST': int32x4ListLibs,
'DartType.INT64LIST': int64ListLibs,
'DartType.FLOAT32LIST': float32ListLibs,
@@ -202,7 +202,7 @@
dumpTable(int8ListLibs, int8ListTable);
dumpTable(int16ListLibs, int16ListTable);
dumpTable(int32ListLibs, int32ListTable);
- dumpTable(int32x4Libs, int32x4Table);
+ // dumpTable(int32x4Libs, int32x4Table);
dumpTable(int32x4ListLibs, int32x4ListTable);
dumpTable(int64ListLibs, int64ListTable);
dumpTable(float32ListLibs, float32ListTable);
@@ -370,8 +370,10 @@
return int16ListEncoding;
case 'Int32List':
return int32ListEncoding;
- case 'Int32x4':
- return int32x4Encoding;
+ // TODO(fizaaluthra): Re-enable Int32x4 after we fix
+ // https://github.com/dart-lang/sdk/issues/39520
+ // case 'Int32x4':
+ // return int32x4Encoding;
case 'Int32x4List':
return int32x4ListEncoding;
case 'Int64List':
@@ -483,7 +485,11 @@
if (name == 'exit' ||
name == 'pid' ||
name == 'hashCode' ||
- name == 'exitCode') {
+ name == 'exitCode' ||
+ // TODO(fizaaluthra): Enable reciprocal and reciprocalSqrt after we resolve
+ // https://github.com/dart-lang/sdk/issues/39551
+ name == 'reciprocal' ||
+ name == 'reciprocalSqrt') {
return;
}
// Restrict parameters for a few hardcoded cases,
diff --git a/runtime/tools/dartfuzz/update_spreadsheet.py b/runtime/tools/dartfuzz/update_spreadsheet.py
new file mode 100755
index 0000000..508159d
--- /dev/null
+++ b/runtime/tools/dartfuzz/update_spreadsheet.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python3
+# Copyright (c) 2019, 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.
+#
+"""Tool to automatically update the DartFuzzStats spreadsheet
+
+Requires a one-time authentication step with a @google account.
+"""
+from __future__ import print_function
+import pickle
+import os.path
+import subprocess
+from googleapiclient.discovery import build
+from google_auth_oauthlib.flow import InstalledAppFlow
+from google.auth.transport.requests import Request
+
+# This script may require a one time install of Google API libraries:
+# pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
+
+# If modifying these scopes, delete the file token.pickle.
+SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
+
+# The ID and range of a spreadsheet.
+SPREADSHEET_ID = '1nDoK-dCuEmf6yo55a303UClRd7AwjbzPkRr37ijWcC8'
+RANGE_NAME = 'Sheet1!A3:H'
+
+VERIFY_CURRENT_ROW_FORMULA = '=B:B-C:C-D:D-E:E-F:F'
+
+
+def authenticate():
+ creds = None
+ # The file token.pickle stores the user's access and refresh tokens, and is
+ # created automatically when the authorization flow completes for the first
+ # time.
+ if os.path.exists('token.pickle'):
+ with open('token.pickle', 'rb') as token:
+ creds = pickle.load(token)
+ # If there are no (valid) credentials available, let the user log in.
+ if not creds or not creds.valid:
+ if creds and creds.expired and creds.refresh_token:
+ creds.refresh(Request())
+ else:
+ flow = InstalledAppFlow.from_client_secrets_file(
+ 'credentials.json', SCOPES)
+ creds = flow.run_local_server(port=0)
+ # Save the credentials for the next run
+ with open('token.pickle', 'wb') as token:
+ pickle.dump(creds, token)
+ return build('sheets', 'v4', credentials=creds)
+
+
+# Returns the next run ID based on the last run ID found in the fuzzing
+# spreadsheet.
+def get_next_run_id(sheet):
+ result = sheet.values().get(
+ spreadsheetId=SPREADSHEET_ID, range=RANGE_NAME).execute()
+ values = result.get('values', [])
+ return int(values[-1][0]) + 1
+
+
+# Inserts a new entry into the fuzzing spreadsheet.
+def add_new_fuzzing_entry(sheet, run, tests, success, rerun, skipped, timeout,
+ divergences):
+
+ entry = [run, tests, success, skipped, timeout, divergences, rerun]
+ print(
+ 'Adding entry for run %d. Tests: %d Successes: %d Skipped: %d Timeouts: %d, Divergences: %d Re-runs: %d'
+ % tuple(entry))
+
+ values = {'values': [entry + [VERIFY_CURRENT_ROW_FORMULA]]}
+ sheet.values().append(
+ spreadsheetId=SPREADSHEET_ID,
+ range=RANGE_NAME,
+ body=values,
+ valueInputOption='USER_ENTERED').execute()
+
+
+# Scrapes the fuzzing shards for fuzzing run statistics.
+#
+# Returns a list of statistics in the following order:
+#
+# - # of tests
+# - # of successes
+# - # of re-runs
+# - # of skipped runs
+# - # of timeouts
+# - # of divergences
+#
+def get_run_statistic_summary(run):
+ output = subprocess.check_output([
+ 'python3', 'collect_data.py', '--output-csv', '--type=sum',
+ 'https://ci.chromium.org/p/dart/builders/ci.sandbox/fuzz-linux/%d' % run
+ ])
+ return list(map(int, output.decode('UTF-8').rstrip().split(',')))
+
+
+def main():
+ service = authenticate()
+ # Call the Sheets API
+ sheet = service.spreadsheets()
+ while True:
+ try:
+ next_id = get_next_run_id(sheet)
+ summary = get_run_statistic_summary(next_id)
+ add_new_fuzzing_entry(sheet, next_id, *summary)
+ except:
+ # get_run_statistic_summary exits with non-zero exit code if we're out
+ # of runs to check.
+ print('No more runs to process. Exiting.')
+ break
+
+
+if __name__ == '__main__':
+ main()
diff --git a/runtime/vm/base64.cc b/runtime/vm/base64.cc
index 60e919d..ec003ae 100644
--- a/runtime/vm/base64.cc
+++ b/runtime/vm/base64.cc
@@ -35,7 +35,7 @@
static const char PAD = '=';
-uint8_t* DecodeBase64(Zone* zone, const char* str, intptr_t* out_decoded_len) {
+uint8_t* DecodeBase64(const char* str, intptr_t* out_decoded_len) {
intptr_t len = strlen(str);
if (len == 0 || (len % 4 != 0)) {
return nullptr;
@@ -48,7 +48,7 @@
if (current_code_unit == PAD) pad_length++;
}
intptr_t decoded_en = ((len * 6) >> 3) - pad_length;
- uint8_t* bytes = zone->Alloc<uint8_t>(decoded_en);
+ uint8_t* bytes = static_cast<uint8_t*>(malloc(decoded_en));
for (int i = 0, o = 0; o < decoded_en;) {
// Accumulate 4 valid 6 bit Base 64 characters into an int.
diff --git a/runtime/vm/base64.h b/runtime/vm/base64.h
index 575b61b..079850f 100644
--- a/runtime/vm/base64.h
+++ b/runtime/vm/base64.h
@@ -5,11 +5,11 @@
#ifndef RUNTIME_VM_BASE64_H_
#define RUNTIME_VM_BASE64_H_
-#include "vm/zone.h"
+#include "vm/globals.h"
namespace dart {
-uint8_t* DecodeBase64(Zone* zone, const char* str, intptr_t* out_decoded_len);
+uint8_t* DecodeBase64(const char* str, intptr_t* out_decoded_len);
} // namespace dart
diff --git a/runtime/vm/base64_test.cc b/runtime/vm/base64_test.cc
index 406a431..cd501ca 100644
--- a/runtime/vm/base64_test.cc
+++ b/runtime/vm/base64_test.cc
@@ -11,22 +11,21 @@
TEST_CASE(Base64Decode) {
intptr_t decoded_len;
- uint8_t* decoded_bytes =
- DecodeBase64(thread->zone(), "SGVsbG8sIHdvcmxkIQo=", &decoded_len);
+ uint8_t* decoded_bytes = DecodeBase64("SGVsbG8sIHdvcmxkIQo=", &decoded_len);
const char expected_bytes[] = "Hello, world!\n";
intptr_t expected_len = strlen(expected_bytes);
EXPECT(!memcmp(expected_bytes, decoded_bytes, expected_len));
EXPECT_EQ(expected_len, decoded_len);
+ free(decoded_bytes);
}
TEST_CASE(Base64DecodeMalformed) {
intptr_t decoded_len;
- EXPECT(DecodeBase64(thread->zone(), "SomethingMalformed", &decoded_len) ==
- nullptr);
+ EXPECT(DecodeBase64("SomethingMalformed", &decoded_len) == nullptr);
}
TEST_CASE(Base64DecodeEmpty) {
intptr_t decoded_len;
- EXPECT(DecodeBase64(thread->zone(), "", &decoded_len) == nullptr);
+ EXPECT(DecodeBase64("", &decoded_len) == nullptr);
}
} // namespace dart
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index 109732d..873e664 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -2202,6 +2202,13 @@
}
void Precompiler::FinalizeAllClasses() {
+ // Create a fresh Zone because kernel reading during class finalization
+ // may create zone handles. Those handles may prevent garbage collection of
+ // otherwise unreachable constants of dropped classes, which would
+ // cause assertion failures during GC after classes are dropped.
+ StackZone stack_zone(thread());
+ HANDLESCOPE(thread());
+
error_ = Library::FinalizeAllClasses();
if (!error_.IsNull()) {
Jump(error_);
@@ -2257,6 +2264,17 @@
}
}
+// Generate allocation stubs referenced by AllocateObject instructions.
+static void GenerateNecessaryAllocationStubs(FlowGraph* flow_graph) {
+ for (auto block : flow_graph->reverse_postorder()) {
+ for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
+ if (auto allocation = it.Current()->AsAllocateObject()) {
+ StubCode::GetAllocationStubForClass(allocation->cls());
+ }
+ }
+ }
+}
+
// Return false if bailed out.
// If optimized_result_code is not NULL then it is caller's responsibility
// to install code.
@@ -2349,13 +2367,35 @@
ASSERT(!FLAG_use_bare_instructions || precompiler_ != nullptr);
- compiler::ObjectPoolBuilder object_pool;
- compiler::ObjectPoolBuilder* active_object_pool_builder =
+ if (FLAG_use_bare_instructions) {
+ // When generating code in bare instruction mode all code objects
+ // share the same global object pool. To reduce interleaving of
+ // unrelated object pool entries from different code objects
+ // we attempt to pregenerate stubs referenced by the code
+ // we are going to generate.
+ //
+ // Reducing interleaving means reducing recompilations triggered by
+ // failure to commit object pool into the global object pool.
+ GenerateNecessaryAllocationStubs(flow_graph);
+ }
+
+ // Even in bare instructions mode we don't directly add objects into
+ // the global object pool because code generation can bail out
+ // (e.g. due to speculative optimization or branch offsets being
+ // too big). If we were adding objects into the global pool directly
+ // these recompilations would leave dead entries behind.
+ // Instead we add objects into an intermediary pool which gets
+ // commited into the global object pool at the end of the compilation.
+ // This makes an assumption that global object pool itself does not
+ // grow during code generation - unfortunately this is not the case
+ // becase we might have nested code generation (i.e. we might generate
+ // some stubs). If this indeed happens we retry the compilation.
+ // (See TryCommitToParent invocation below).
+ compiler::ObjectPoolBuilder object_pool_builder(
FLAG_use_bare_instructions
? precompiler_->global_object_pool_builder()
- : &object_pool;
- compiler::Assembler assembler(active_object_pool_builder,
- use_far_branches);
+ : nullptr);
+ compiler::Assembler assembler(&object_pool_builder, use_far_branches);
CodeStatistics* function_stats = NULL;
if (FLAG_print_instruction_stats) {
@@ -2380,6 +2420,25 @@
FinalizeCompilation(&assembler, &graph_compiler, flow_graph,
function_stats);
}
+
+ // In bare instructions mode try adding all entries from the object
+ // pool into the global object pool. This might fail if we have
+ // nested code generation (i.e. we generated some stubs) whichs means
+ // that some of the object indices we used are already occupied in the
+ // global object pool.
+ //
+ // In this case we simply retry compilation assuming that we are not
+ // going to hit this problem on the second attempt.
+ //
+ // Note: currently we can't assume that two compilations of the same
+ // method will lead to the same IR due to instability of inlining
+ // heuristics (under some conditions we might end up inlining
+ // more aggressively on the second attempt).
+ if (FLAG_use_bare_instructions &&
+ !object_pool_builder.TryCommitToParent()) {
+ done = false;
+ continue;
+ }
// Exit the loop and the function with the correct result value.
is_compiled = true;
done = true;
diff --git a/runtime/vm/compiler/assembler/assembler.cc b/runtime/vm/compiler/assembler/assembler.cc
index 9dfdf2e..26287cb 100644
--- a/runtime/vm/compiler/assembler/assembler.cc
+++ b/runtime/vm/compiler/assembler/assembler.cc
@@ -287,7 +287,7 @@
if (entry.type() == ObjectPoolBuilderEntry::kTaggedObject) {
// If the owner of the object pool wrapper specified a specific zone we
- // shoulld use we'll do so.
+ // should use we'll do so.
if (zone_ != NULL) {
entry.obj_ = &NewZoneHandle(zone_, *entry.obj_);
if (entry.equivalence_ != NULL) {
@@ -296,20 +296,28 @@
}
}
+ const intptr_t idx = base_index_ + object_pool_.length();
object_pool_.Add(entry);
if (entry.patchable() == ObjectPoolBuilderEntry::kNotPatchable) {
// The object isn't patchable. Record the index for fast lookup.
- object_pool_index_table_.Insert(
- ObjIndexPair(entry, object_pool_.length() - 1));
+ object_pool_index_table_.Insert(ObjIndexPair(entry, idx));
}
- return object_pool_.length() - 1;
+ return idx;
}
intptr_t ObjectPoolBuilder::FindObject(ObjectPoolBuilderEntry entry) {
// If the object is not patchable, check if we've already got it in the
// object pool.
if (entry.patchable() == ObjectPoolBuilderEntry::kNotPatchable) {
- intptr_t idx = object_pool_index_table_.LookupValue(entry);
+ // First check in the parent pool if we have one.
+ if (parent_ != nullptr) {
+ const intptr_t idx = parent_->object_pool_index_table_.LookupValue(entry);
+ if (idx != ObjIndexPair::kNoIndex) {
+ return idx;
+ }
+ }
+
+ const intptr_t idx = object_pool_index_table_.LookupValue(entry);
if (idx != ObjIndexPair::kNoIndex) {
return idx;
}
@@ -350,6 +358,18 @@
patchable));
}
+bool ObjectPoolBuilder::TryCommitToParent() {
+ ASSERT(parent_ != nullptr);
+ if (parent_->CurrentLength() != base_index_) {
+ return false;
+ }
+ for (intptr_t i = 0; i < object_pool_.length(); i++) {
+ intptr_t idx = parent_->AddObject(object_pool_[i]);
+ ASSERT(idx == (base_index_ + i));
+ }
+ return true;
+}
+
} // namespace compiler
} // namespace dart
diff --git a/runtime/vm/compiler/assembler/assembler.h b/runtime/vm/compiler/assembler/assembler.h
index c5100dc..96ed82e 100644
--- a/runtime/vm/compiler/assembler/assembler.h
+++ b/runtime/vm/compiler/assembler/assembler.h
@@ -358,11 +358,22 @@
const GrowableArray<CodeComment*>& comments() const { return comments_; }
+ void BindUncheckedEntryPoint() {
+ ASSERT(unchecked_entry_offset_ == 0);
+ unchecked_entry_offset_ = CodeSize();
+ }
+
+ // Returns the offset (from the very beginning of the instructions) to the
+ // unchecked entry point (incl. prologue/frame setup, etc.).
+ intptr_t UncheckedEntryOffset() const { return unchecked_entry_offset_; }
+
protected:
AssemblerBuffer buffer_; // Contains position independent code.
int32_t prologue_offset_;
bool has_single_entry_point_;
+ intptr_t unchecked_entry_offset_ = 0;
+
private:
GrowableArray<CodeComment*> comments_;
ObjectPoolBuilder* object_pool_builder_;
diff --git a/runtime/vm/compiler/assembler/assembler_arm.h b/runtime/vm/compiler/assembler/assembler_arm.h
index 2e9f016..e488dfa 100644
--- a/runtime/vm/compiler/assembler/assembler_arm.h
+++ b/runtime/vm/compiler/assembler/assembler_arm.h
@@ -370,6 +370,28 @@
void PushRegister(Register r) { Push(r); }
void PopRegister(Register r) { Pop(r); }
+ // Push two registers to the stack; r0 to lower address location.
+ void PushRegisterPair(Register r0, Register r1) {
+ if ((r0 < r1) && (r0 != SP) && (r1 != SP)) {
+ RegList reg_list = (1 << r0) | (1 << r1);
+ PushList(reg_list);
+ } else {
+ PushRegister(r1);
+ PushRegister(r0);
+ }
+ }
+
+ // Pop two registers from the stack; r0 from lower address location.
+ void PopRegisterPair(Register r0, Register r1) {
+ if ((r0 < r1) && (r0 != SP) && (r1 != SP)) {
+ RegList reg_list = (1 << r0) | (1 << r1);
+ PopList(reg_list);
+ } else {
+ PopRegister(r0);
+ PopRegister(r1);
+ }
+ }
+
void Bind(Label* label);
void Jump(Label* label) { b(label); }
diff --git a/runtime/vm/compiler/assembler/assembler_arm64.h b/runtime/vm/compiler/assembler/assembler_arm64.h
index 719b520..dd7419c 100644
--- a/runtime/vm/compiler/assembler/assembler_arm64.h
+++ b/runtime/vm/compiler/assembler/assembler_arm64.h
@@ -446,6 +446,9 @@
void PushRegister(Register r) { Push(r); }
void PopRegister(Register r) { Pop(r); }
+ void PushRegisterPair(Register r0, Register r1) { PushPair(r0, r1); }
+ void PopRegisterPair(Register r0, Register r1) { PopPair(r0, r1); }
+
void PushRegisters(const RegisterSet& registers);
void PopRegisters(const RegisterSet& registers);
@@ -1502,14 +1505,22 @@
const ExternalLabel* label,
ObjectPoolBuilderEntry::Patchability patchable);
void LoadIsolate(Register dst);
+
+ // Note: the function never clobbers TMP, TMP2 scratch registers.
void LoadObject(Register dst, const Object& obj);
+ // Note: the function never clobbers TMP, TMP2 scratch registers.
void LoadUniqueObject(Register dst, const Object& obj);
+ // Note: the function never clobbers TMP, TMP2 scratch registers.
void LoadImmediate(Register reg, int64_t imm);
+
void LoadDImmediate(VRegister reg, double immd);
// Load word from pool from the given offset using encoding that
// InstructionPattern::DecodeLoadWordFromPool can decode.
+ //
+ // Note: the function never clobbers TMP, TMP2 scratch registers.
void LoadWordFromPoolOffset(Register dst, uint32_t offset, Register pp = PP);
+
void LoadDoubleWordFromPoolOffset(Register lower,
Register upper,
uint32_t offset);
@@ -1685,6 +1696,7 @@
void LoadWordFromPoolOffsetFixed(Register dst, uint32_t offset);
+ // Note: the function never clobbers TMP, TMP2 scratch registers.
void LoadObjectHelper(Register dst, const Object& obj, bool is_unique);
void AddSubHelper(OperandSize os,
diff --git a/runtime/vm/compiler/assembler/assembler_arm64_test.cc b/runtime/vm/compiler/assembler/assembler_arm64_test.cc
index 310e20e..11c255f 100644
--- a/runtime/vm/compiler/assembler/assembler_arm64_test.cc
+++ b/runtime/vm/compiler/assembler/assembler_arm64_test.cc
@@ -512,6 +512,76 @@
EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry()));
}
+ASSEMBLER_TEST_GENERATE(PushRegisterPair, assembler) {
+ __ SetupDartSP();
+ __ LoadImmediate(R2, 12);
+ __ LoadImmediate(R3, 21);
+ __ PushRegisterPair(R2, R3);
+ __ Pop(R0);
+ __ Pop(R1);
+ __ RestoreCSP();
+ __ ret();
+}
+
+ASSEMBLER_TEST_RUN(PushRegisterPair, test) {
+ EXPECT(test != NULL);
+ typedef int (*PushRegisterPair)() DART_UNUSED;
+ EXPECT_EQ(12, EXECUTE_TEST_CODE_INT64(PushRegisterPair, test->entry()));
+}
+
+ASSEMBLER_TEST_GENERATE(PushRegisterPairReversed, assembler) {
+ __ SetupDartSP();
+ __ LoadImmediate(R3, 12);
+ __ LoadImmediate(R2, 21);
+ __ PushRegisterPair(R3, R2);
+ __ Pop(R0);
+ __ Pop(R1);
+ __ RestoreCSP();
+ __ ret();
+}
+
+ASSEMBLER_TEST_RUN(PushRegisterPairReversed, test) {
+ EXPECT(test != NULL);
+ typedef int (*PushRegisterPairReversed)() DART_UNUSED;
+ EXPECT_EQ(12,
+ EXECUTE_TEST_CODE_INT64(PushRegisterPairReversed, test->entry()));
+}
+
+ASSEMBLER_TEST_GENERATE(PopRegisterPair, assembler) {
+ __ SetupDartSP();
+ __ LoadImmediate(R2, 12);
+ __ LoadImmediate(R3, 21);
+ __ Push(R3);
+ __ Push(R2);
+ __ PopRegisterPair(R0, R1);
+ __ RestoreCSP();
+ __ ret();
+}
+
+ASSEMBLER_TEST_RUN(PopRegisterPair, test) {
+ EXPECT(test != NULL);
+ typedef int (*PopRegisterPair)() DART_UNUSED;
+ EXPECT_EQ(12, EXECUTE_TEST_CODE_INT64(PopRegisterPair, test->entry()));
+}
+
+ASSEMBLER_TEST_GENERATE(PopRegisterPairReversed, assembler) {
+ __ SetupDartSP();
+ __ LoadImmediate(R3, 12);
+ __ LoadImmediate(R2, 21);
+ __ Push(R3);
+ __ Push(R2);
+ __ PopRegisterPair(R1, R0);
+ __ RestoreCSP();
+ __ ret();
+}
+
+ASSEMBLER_TEST_RUN(PopRegisterPairReversed, test) {
+ EXPECT(test != NULL);
+ typedef int (*PopRegisterPairReversed)() DART_UNUSED;
+ EXPECT_EQ(12,
+ EXECUTE_TEST_CODE_INT64(PopRegisterPairReversed, test->entry()));
+}
+
ASSEMBLER_TEST_GENERATE(Semaphore, assembler) {
__ SetupDartSP();
__ movz(R0, Immediate(40), 0);
diff --git a/runtime/vm/compiler/assembler/assembler_arm_test.cc b/runtime/vm/compiler/assembler/assembler_arm_test.cc
index b11603f..7f5f85d 100644
--- a/runtime/vm/compiler/assembler/assembler_arm_test.cc
+++ b/runtime/vm/compiler/assembler/assembler_arm_test.cc
@@ -748,6 +748,68 @@
EXPECT_EQ(123, EXECUTE_TEST_CODE_INT32(LoadStore, test->entry()));
}
+ASSEMBLER_TEST_GENERATE(PushRegisterPair, assembler) {
+ __ mov(R2, Operand(12));
+ __ mov(R3, Operand(21));
+ __ PushRegisterPair(R2, R3);
+ __ Pop(R0);
+ __ Pop(R1);
+ __ bx(LR);
+}
+
+ASSEMBLER_TEST_RUN(PushRegisterPair, test) {
+ EXPECT(test != NULL);
+ typedef int (*PushRegisterPair)() DART_UNUSED;
+ EXPECT_EQ(12, EXECUTE_TEST_CODE_INT32(PushRegisterPair, test->entry()));
+}
+
+ASSEMBLER_TEST_GENERATE(PushRegisterPairReversed, assembler) {
+ __ mov(R3, Operand(12));
+ __ mov(R2, Operand(21));
+ __ PushRegisterPair(R3, R2);
+ __ Pop(R0);
+ __ Pop(R1);
+ __ bx(LR);
+}
+
+ASSEMBLER_TEST_RUN(PushRegisterPairReversed, test) {
+ EXPECT(test != NULL);
+ typedef int (*PushRegisterPairReversed)() DART_UNUSED;
+ EXPECT_EQ(12,
+ EXECUTE_TEST_CODE_INT32(PushRegisterPairReversed, test->entry()));
+}
+
+ASSEMBLER_TEST_GENERATE(PopRegisterPair, assembler) {
+ __ mov(R2, Operand(12));
+ __ mov(R3, Operand(21));
+ __ Push(R3);
+ __ Push(R2);
+ __ PopRegisterPair(R0, R1);
+ __ bx(LR);
+}
+
+ASSEMBLER_TEST_RUN(PopRegisterPair, test) {
+ EXPECT(test != NULL);
+ typedef int (*PopRegisterPair)() DART_UNUSED;
+ EXPECT_EQ(12, EXECUTE_TEST_CODE_INT32(PopRegisterPair, test->entry()));
+}
+
+ASSEMBLER_TEST_GENERATE(PopRegisterPairReversed, assembler) {
+ __ mov(R3, Operand(12));
+ __ mov(R2, Operand(21));
+ __ Push(R3);
+ __ Push(R2);
+ __ PopRegisterPair(R1, R0);
+ __ bx(LR);
+}
+
+ASSEMBLER_TEST_RUN(PopRegisterPairReversed, test) {
+ EXPECT(test != NULL);
+ typedef int (*PopRegisterPairReversed)() DART_UNUSED;
+ EXPECT_EQ(12,
+ EXECUTE_TEST_CODE_INT32(PopRegisterPairReversed, test->entry()));
+}
+
ASSEMBLER_TEST_GENERATE(Semaphore, assembler) {
__ mov(R0, Operand(40));
__ mov(R1, Operand(42));
diff --git a/runtime/vm/compiler/assembler/assembler_ia32.h b/runtime/vm/compiler/assembler/assembler_ia32.h
index d8fca975..f7750e7 100644
--- a/runtime/vm/compiler/assembler/assembler_ia32.h
+++ b/runtime/vm/compiler/assembler/assembler_ia32.h
@@ -574,6 +574,15 @@
void PushRegister(Register r);
void PopRegister(Register r);
+ void PushRegisterPair(Register r0, Register r1) {
+ PushRegister(r1);
+ PushRegister(r0);
+ }
+ void PopRegisterPair(Register r0, Register r1) {
+ PopRegister(r0);
+ PopRegister(r1);
+ }
+
void AddImmediate(Register reg, const Immediate& imm);
void SubImmediate(Register reg, const Immediate& imm);
diff --git a/runtime/vm/compiler/assembler/assembler_x64.h b/runtime/vm/compiler/assembler/assembler_x64.h
index af51403..a22780c 100644
--- a/runtime/vm/compiler/assembler/assembler_x64.h
+++ b/runtime/vm/compiler/assembler/assembler_x64.h
@@ -678,6 +678,15 @@
void PushRegister(Register r);
void PopRegister(Register r);
+ void PushRegisterPair(Register r0, Register r1) {
+ PushRegister(r1);
+ PushRegister(r0);
+ }
+ void PopRegisterPair(Register r0, Register r1) {
+ PopRegister(r0);
+ PopRegister(r1);
+ }
+
// Methods for adding/subtracting an immediate value that may be loaded from
// the constant pool.
// TODO(koda): Assert that these are not used for heap objects.
diff --git a/runtime/vm/compiler/assembler/object_pool_builder.h b/runtime/vm/compiler/assembler/object_pool_builder.h
index 7b74b70..2cf9e41 100644
--- a/runtime/vm/compiler/assembler/object_pool_builder.h
+++ b/runtime/vm/compiler/assembler/object_pool_builder.h
@@ -114,7 +114,17 @@
class ObjectPoolBuilder : public ValueObject {
public:
- ObjectPoolBuilder() : zone_(nullptr) {}
+ // When generating AOT code in the bare instructions mode we might use a two
+ // stage process of forming the pool - first accumulate objects in the
+ // intermediary pool and then commit them into the global pool at the
+ // end of a successful compilation. Here [parent] is the pool into which
+ // we are going to commit objects.
+ // See PrecompileParsedFunctionHelper::Compile for more information.
+ explicit ObjectPoolBuilder(ObjectPoolBuilder* parent = nullptr)
+ : parent_(parent),
+ base_index_(parent != nullptr ? parent->CurrentLength() : 0),
+ zone_(nullptr) {}
+
~ObjectPoolBuilder() {
if (zone_ != nullptr) {
Reset();
@@ -161,9 +171,23 @@
intptr_t AddObject(ObjectPoolBuilderEntry entry);
+ // Try appending all entries from this pool into the parent pool.
+ // This might fail if parent pool was modified invalidating indices which
+ // we produced. In this case this function will return false.
+ bool TryCommitToParent();
+
private:
intptr_t FindObject(ObjectPoolBuilderEntry entry);
+ // Parent pool into which all entries from this pool will be added at
+ // the end of the successful compilation.
+ ObjectPoolBuilder* const parent_;
+
+ // Base index at which entries will be inserted into the parent pool.
+ // Should be equal to parent_->CurrentLength() - but is cached here
+ // to detect cases when parent pool grows due to nested code generations.
+ const intptr_t base_index_;
+
// Objects and jump targets.
GrowableArray<ObjectPoolBuilderEntry> object_pool_;
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler.cc b/runtime/vm/compiler/backend/flow_graph_compiler.cc
index 68f33f5..ad5f27a 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler.cc
@@ -327,30 +327,6 @@
block_info->set_next_nonempty_label(nonempty_label);
}
-intptr_t FlowGraphCompiler::UncheckedEntryOffset() const {
- BlockEntryInstr* entry = flow_graph().graph_entry()->unchecked_entry();
- if (entry == nullptr) {
- entry = flow_graph().graph_entry()->normal_entry();
- }
- if (entry == nullptr) {
- entry = flow_graph().graph_entry()->osr_entry();
- }
- ASSERT(entry != nullptr);
- compiler::Label* target = GetJumpLabel(entry);
-
- if (target->IsBound()) {
- return target->Position();
- }
-
- // Intrinsification happened.
- if (parsed_function().function().IsDynamicFunction()) {
- return FLAG_precompiled_mode ? Instructions::kPolymorphicEntryOffsetAOT
- : Instructions::kPolymorphicEntryOffsetJIT;
- }
-
- return 0;
-}
-
#if defined(DART_PRECOMPILER)
static intptr_t LocationToStackIndex(const Location& src) {
ASSERT(src.HasStackIndex());
@@ -1399,7 +1375,7 @@
}
AddCurrentDescriptor(RawPcDescriptors::kRewind, deopt_id, token_pos);
EmitUnoptimizedStaticCall(args_info.count_with_type_args, deopt_id,
- token_pos, locs, call_ic_data);
+ token_pos, locs, call_ic_data, entry_kind);
}
}
@@ -2059,9 +2035,8 @@
} else {
const ICData& unary_checks = ICData::ZoneHandle(
zone(), original_call.ic_data()->AsUnaryClassChecks());
- // TODO(sjindel/entrypoints): Support skiping type checks on switchable
- // calls.
- EmitInstanceCallAOT(unary_checks, deopt_id, token_pos, locs);
+ EmitInstanceCallAOT(unary_checks, deopt_id, token_pos, locs,
+ original_call.entry_kind());
}
}
}
@@ -2429,8 +2404,13 @@
if (!use_shared_stub) {
compiler->SaveLiveRegisters(locs);
}
- for (intptr_t i = 0; i < num_args_; ++i) {
+ intptr_t i = 0;
+ if (num_args_ % 2 != 0) {
__ PushRegister(locs->in(i).reg());
+ ++i;
+ }
+ for (; i < num_args_; i += 2) {
+ __ PushRegisterPair(locs->in(i + 1).reg(), locs->in(i).reg());
}
if (use_shared_stub) {
EmitSharedStubCall(compiler, live_fpu_registers);
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler.h b/runtime/vm/compiler/backend/flow_graph_compiler.h
index 13c0cfe..f82b24d 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler.h
+++ b/runtime/vm/compiler/backend/flow_graph_compiler.h
@@ -837,10 +837,6 @@
int bias,
bool jump_on_miss = true);
- // Returns the offset (from the very beginning of the instructions) to the
- // unchecked entry point (incl. prologue/frame setup, etc.).
- intptr_t UncheckedEntryOffset() const;
-
bool IsEmptyBlock(BlockEntryInstr* block) const;
private:
@@ -879,11 +875,13 @@
LocationSummary* locs,
Code::EntryKind entry_kind = Code::EntryKind::kNormal);
- void EmitUnoptimizedStaticCall(intptr_t count_with_type_args,
- intptr_t deopt_id,
- TokenPosition token_pos,
- LocationSummary* locs,
- const ICData& ic_data);
+ void EmitUnoptimizedStaticCall(
+ intptr_t count_with_type_args,
+ intptr_t deopt_id,
+ TokenPosition token_pos,
+ LocationSummary* locs,
+ const ICData& ic_data,
+ Code::EntryKind entry_kind = Code::EntryKind::kNormal);
// Helper for TestAndCall that calculates a good bias that
// allows more compact instructions to be emitted.
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc b/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
index c681c1b..61db41a 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
@@ -1192,12 +1192,13 @@
intptr_t deopt_id,
TokenPosition token_pos,
LocationSummary* locs,
- const ICData& ic_data) {
+ const ICData& ic_data,
+ Code::EntryKind entry_kind) {
const Code& stub =
StubCode::UnoptimizedStaticCallEntry(ic_data.NumArgsTested());
__ LoadObject(R9, ic_data);
GenerateDartCall(deopt_id, token_pos, stub,
- RawPcDescriptors::kUnoptStaticCall, locs);
+ RawPcDescriptors::kUnoptStaticCall, locs, entry_kind);
__ Drop(count_with_type_args);
}
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc b/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
index f5b6813..ade44f8 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
@@ -633,12 +633,13 @@
const Register kFunctionTypeArgumentsReg = R2;
__ ldp(kFunctionTypeArgumentsReg, kInstantiatorTypeArgumentsReg,
compiler::Address(SP, 0 * kWordSize, compiler::Address::PairOffset));
- __ PushObject(Object::null_object()); // Make room for the result.
- __ Push(R0); // Push the instance.
- __ PushObject(type); // Push the type.
- __ PushPair(kFunctionTypeArgumentsReg, kInstantiatorTypeArgumentsReg);
+ __ PushPair(R0, NULL_REG); // Make room for the result and
+ // push the instance.
+ __ LoadObject(TMP, type); // Push the type.
+
+ __ PushPair(kInstantiatorTypeArgumentsReg, TMP);
__ LoadUniqueObject(R0, test_cache);
- __ Push(R0);
+ __ PushPair(R0, kFunctionTypeArgumentsReg);
GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 5, locs);
// Pop the parameters supplied to the runtime entry. The result of the
// instanceof runtime call will be left as the result of the operation.
@@ -703,14 +704,16 @@
__ Bind(&runtime_call);
__ ldp(kFunctionTypeArgumentsReg, kInstantiatorTypeArgumentsReg,
compiler::Address(SP, 0 * kWordSize, compiler::Address::PairOffset));
- __ PushObject(Object::null_object()); // Make room for the result.
- __ Push(R0); // Push the source object.
- __ PushObject(dst_type); // Push the type of the destination.
- __ PushPair(kFunctionTypeArgumentsReg, kInstantiatorTypeArgumentsReg);
- __ PushObject(dst_name); // Push the name of the destination.
+ __ PushPair(R0, NULL_REG); // Make room for the result and
+ // push the source object.
+ __ LoadObject(TMP, dst_type); // Push the type of the dest.
+ __ PushPair(kInstantiatorTypeArgumentsReg, TMP);
+ __ LoadObject(TMP, dst_name); // Push the name of the destination.
+ __ PushPair(TMP, kFunctionTypeArgumentsReg);
+
__ LoadUniqueObject(R0, test_cache);
- __ Push(R0);
- __ PushObject(Smi::ZoneHandle(zone(), Smi::New(kTypeCheckFromInline)));
+ __ LoadObject(TMP, Smi::ZoneHandle(zone(), Smi::New(kTypeCheckFromInline)));
+ __ PushPair(TMP, R0);
GenerateRuntimeCall(token_pos, deopt_id, kTypeCheckRuntimeEntry, 7, locs);
// Pop the parameters supplied to the runtime entry. The result of the
// type check runtime call is the checked value.
@@ -1158,7 +1161,9 @@
intptr_t deopt_id,
TokenPosition token_pos,
LocationSummary* locs,
- const ICData& ic_data) {
+ const ICData& ic_data,
+ Code::EntryKind entry_kind) {
+ // TODO(34162): Support multiple entry-points on ARM64.
const Code& stub =
StubCode::UnoptimizedStaticCallEntry(ic_data.NumArgsTested());
__ LoadObject(R5, ic_data);
@@ -1199,8 +1204,8 @@
intptr_t deopt_id) {
if (needs_number_check) {
ASSERT(!obj.IsMint() && !obj.IsDouble());
- __ Push(reg);
- __ PushObject(obj);
+ __ LoadObject(TMP, obj);
+ __ PushPair(TMP, reg);
if (is_optimizing()) {
__ BranchLinkPatchable(StubCode::OptimizedIdenticalWithNumberCheck());
} else {
@@ -1208,8 +1213,9 @@
}
AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, deopt_id, token_pos);
// Stub returns result in flags (result of a cmp, we need Z computed).
- __ Drop(1); // Discard constant.
- __ Pop(reg); // Restore 'reg'.
+ // Discard constant.
+ // Restore 'reg'.
+ __ PopPair(ZR, reg);
} else {
__ CompareObject(reg, obj);
}
@@ -1222,8 +1228,7 @@
TokenPosition token_pos,
intptr_t deopt_id) {
if (needs_number_check) {
- __ Push(left);
- __ Push(right);
+ __ PushPair(right, left);
if (is_optimizing()) {
__ BranchLinkPatchable(StubCode::OptimizedIdenticalWithNumberCheck());
} else {
@@ -1231,8 +1236,7 @@
}
AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, deopt_id, token_pos);
// Stub returns result in flags (result of a cmp, we need Z computed).
- __ Pop(right);
- __ Pop(left);
+ __ PopPair(right, left);
} else {
__ CompareRegisters(left, right);
}
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc b/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc
index ff849d8..3d376cc 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc
@@ -894,7 +894,9 @@
intptr_t deopt_id,
TokenPosition token_pos,
LocationSummary* locs,
- const ICData& ic_data) {
+ const ICData& ic_data,
+ Code::EntryKind entry_kind) {
+ // TODO(34162): Support multiple entry-points on IA32.
const Code& stub =
StubCode::UnoptimizedStaticCallEntry(ic_data.NumArgsTested());
__ LoadObject(ECX, ic_data);
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc b/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
index 1937d593..587ca08 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
@@ -1018,12 +1018,13 @@
intptr_t deopt_id,
TokenPosition token_pos,
LocationSummary* locs,
- const ICData& ic_data) {
+ const ICData& ic_data,
+ Code::EntryKind entry_kind) {
const Code& stub =
StubCode::UnoptimizedStaticCallEntry(ic_data.NumArgsTested());
__ LoadObject(RBX, ic_data);
GenerateDartCall(deopt_id, token_pos, stub,
- RawPcDescriptors::kUnoptStaticCall, locs);
+ RawPcDescriptors::kUnoptStaticCall, locs, entry_kind);
__ Drop(count_with_type_args, RCX);
}
diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc
index 06000ae..bf02499 100644
--- a/runtime/vm/compiler/backend/il.cc
+++ b/runtime/vm/compiler/backend/il.cc
@@ -3924,6 +3924,10 @@
__ Bind(compiler->GetJumpLabel(this));
}
+ if (this == compiler->flow_graph().graph_entry()->unchecked_entry()) {
+ __ BindUncheckedEntryPoint();
+ }
+
// In the AOT compiler we want to reduce code size, so generate no
// fall-through code in [FlowGraphCompiler::CompileGraph()].
// (As opposed to here where we don't check for the return value of
@@ -4326,7 +4330,7 @@
token_pos(), locs(), entry_kind());
} else {
compiler->GenerateInstanceCall(deopt_id(), token_pos(), locs(),
- *call_ic_data);
+ *call_ic_data, entry_kind());
}
}
}
diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc
index 5f4adbd..f5056a3 100644
--- a/runtime/vm/compiler/backend/il_arm64.cc
+++ b/runtime/vm/compiler/backend/il_arm64.cc
@@ -965,10 +965,8 @@
// These can be anything besides the return register (R0) and THR (R26).
const Register vm_tag_reg = R1, old_exit_frame_reg = R2, tmp = R3;
- __ Pop(old_exit_frame_reg);
-
// Restore top_resource.
- __ Pop(tmp);
+ __ PopPair(old_exit_frame_reg, tmp);
__ StoreToOffset(tmp, THR, compiler::target::Thread::top_resource_offset());
__ Pop(vm_tag_reg);
@@ -1104,12 +1102,11 @@
__ RestorePinnedRegisters();
// Save the current VMTag on the stack.
- __ LoadFromOffset(R0, THR, compiler::target::Thread::vm_tag_offset());
- __ Push(R0);
-
+ __ LoadFromOffset(TMP, THR, compiler::target::Thread::vm_tag_offset());
// Save the top resource.
__ LoadFromOffset(R0, THR, compiler::target::Thread::top_resource_offset());
- __ Push(R0);
+ __ PushPair(R0, TMP);
+
__ StoreToOffset(ZR, THR, compiler::target::Thread::top_resource_offset());
// Save the top exit frame info. We don't set it to 0 yet:
@@ -1862,8 +1859,7 @@
__ CompareImmediate(TMP, kDynamicCid);
__ b(&ok, EQ);
- __ Push(field_reg);
- __ Push(value_reg);
+ __ PushPair(value_reg, field_reg);
__ CallRuntime(kUpdateFieldCidRuntimeEntry, 2);
__ Drop(2); // Drop the field and the value.
} else {
@@ -1963,8 +1959,7 @@
if (deopt == NULL) {
__ b(&ok, EQ);
- __ Push(field_reg);
- __ Push(value_reg);
+ __ PushPair(value_reg, field_reg);
__ CallRuntime(kUpdateFieldCidRuntimeEntry, 2);
__ Drop(2); // Drop the field and the value.
} else {
@@ -2406,9 +2401,8 @@
compiler::Label slow_path, done;
InlineArrayAllocation(compiler, length, &slow_path, &done);
__ Bind(&slow_path);
- __ PushObject(Object::null_object()); // Make room for the result.
- __ Push(kLengthReg); // length.
- __ Push(kElemTypeReg);
+ __ PushObject(Object::null_object()); // Make room for the result.
+ __ PushPair(kElemTypeReg, kLengthReg); // length.
compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
kAllocateArrayRuntimeEntry, 2, locs());
__ Drop(2);
@@ -2565,8 +2559,8 @@
// 'instantiator_type_args_reg' is a TypeArguments object (or null).
// 'function_type_args_reg' is a TypeArguments object (or null).
// A runtime call to instantiate the type is required.
- __ PushObject(Object::null_object()); // Make room for the result.
- __ PushObject(type());
+ __ LoadObject(TMP, type());
+ __ PushPair(TMP, NULL_REG);
__ PushPair(function_type_args_reg, instantiator_type_args_reg);
compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
kInstantiateTypeRuntimeEntry, 3, locs());
@@ -2644,8 +2638,8 @@
__ Bind(&slow_case);
// Instantiate non-null type arguments.
// A runtime call to instantiate the type arguments is required.
- __ PushObject(Object::null_object()); // Make room for the result.
- __ PushObject(type_arguments());
+ __ LoadObject(TMP, type_arguments());
+ __ PushPair(TMP, NULL_REG);
__ PushPair(function_type_args_reg, instantiator_type_args_reg);
compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
kInstantiateTypeArgumentsRuntimeEntry, 3,
@@ -2759,8 +2753,7 @@
__ CompareObject(temp, Object::sentinel());
__ b(&no_call, NE);
- __ Push(ZR); // Make room for (unused) result.
- __ Push(instance);
+ __ PushPair(instance, ZR); // Make room for (unused) result.
__ PushObject(Field::ZoneHandle(field().Original()));
compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
kInitInstanceFieldRuntimeEntry, 2, locs());
@@ -2792,8 +2785,7 @@
__ b(&no_call, NE);
__ Bind(&call_runtime);
- __ PushObject(Object::null_object()); // Make room for (unused) result.
- __ Push(field);
+ __ PushPair(field, NULL_REG);
compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
kInitStaticFieldRuntimeEntry, 1, locs());
__ Drop(2); // Remove argument and result placeholder.
@@ -2815,12 +2807,11 @@
const Register context_value = locs()->in(0).reg();
const Register result = locs()->out(0).reg();
- __ PushObject(Object::null_object()); // Make room for the result.
- __ Push(context_value);
+ __ PushPair(context_value, NULL_REG);
compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
kCloneContextRuntimeEntry, 1, locs());
- __ Drop(1); // Remove argument.
- __ Pop(result); // Get result (cloned context).
+ // Remove argument and result (cloned context).
+ __ PopPair(ZR, result);
}
LocationSummary* CatchBlockEntryInstr::MakeLocationSummary(Zone* zone,
@@ -3121,8 +3112,7 @@
compiler->SlowPathEnvironmentFor(instruction(), kNumSlowPathArgs);
compiler->pending_deoptimization_env_ = env;
}
- __ Push(locs->in(0).reg());
- __ Push(locs->in(1).reg());
+ __ PushPair(locs->in(1).reg(), locs->in(0).reg());
const auto& selector = String::Handle(instruction()->call()->Selector());
const auto& arguments_descriptor = Array::Handle(
ArgumentsDescriptor::New(/*type_args_len=*/0, /*num_arguments=*/2));
@@ -3269,8 +3259,7 @@
compiler->pending_deoptimization_env_ =
compiler->SlowPathEnvironmentFor(env_, locs, kNumSlowPathArgs);
}
- __ Push(locs->in(0).reg());
- __ Push(locs->in(1).reg());
+ __ PushPair(locs->in(1).reg(), locs->in(0).reg());
const auto& selector = String::Handle(instruction()->call()->Selector());
const auto& arguments_descriptor = Array::Handle(
ArgumentsDescriptor::New(/*type_args_len=*/0, /*num_arguments=*/2));
diff --git a/runtime/vm/compiler/backend/il_printer.cc b/runtime/vm/compiler/backend/il_printer.cc
index e2153dc..1879563 100644
--- a/runtime/vm/compiler/backend/il_printer.cc
+++ b/runtime/vm/compiler/backend/il_printer.cc
@@ -521,6 +521,9 @@
if (result_type() != nullptr) {
f->Print(", result_type = %s", result_type()->ToCString());
}
+ if (entry_kind() == Code::EntryKind::kUnchecked) {
+ f->Print(" using unchecked entrypoint");
+ }
}
void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const {
diff --git a/runtime/vm/compiler/backend/range_analysis.cc b/runtime/vm/compiler/backend/range_analysis.cc
index 0178cbd..c42431a3 100644
--- a/runtime/vm/compiler/backend/range_analysis.cc
+++ b/runtime/vm/compiler/backend/range_analysis.cc
@@ -1814,10 +1814,12 @@
int64_t limit = 64 - shift_count;
int64_t value = value_boundary.ConstantValue();
- if ((value == 0) || (shift_count == 0) ||
- ((limit > 0) && Utils::IsInt(static_cast<int>(limit), value))) {
+ if (value == 0) {
+ return RangeBoundary(0);
+ } else if (shift_count == 0 ||
+ (limit > 0 && Utils::IsInt(static_cast<int>(limit), value))) {
// Result stays in 64 bit range.
- int64_t result = value << shift_count;
+ const int64_t result = value << shift_count;
return RangeBoundary(result);
}
diff --git a/runtime/vm/compiler/backend/slot.cc b/runtime/vm/compiler/backend/slot.cc
index bd7d94b..00468cc 100644
--- a/runtime/vm/compiler/backend/slot.cc
+++ b/runtime/vm/compiler/backend/slot.cc
@@ -159,16 +159,12 @@
const Slot& Slot::GetContextVariableSlotFor(Thread* thread,
const LocalVariable& variable) {
ASSERT(variable.is_captured());
- // TODO(vegorov) Can't assign static type to local variables because
- // for captured parameters we generate the code that first stores a
- // variable into the context and then loads it from the context to perform
- // the type check.
return SlotCache::Instance(thread).Canonicalize(Slot(
Kind::kCapturedVariable,
IsImmutableBit::encode(variable.is_final()) | IsNullableBit::encode(true),
kDynamicCid,
compiler::target::Context::variable_offset(variable.index().value()),
- &variable.name(), /*static_type=*/nullptr));
+ &variable.name(), &variable.type()));
}
const Slot& Slot::GetTypeArgumentsIndexSlot(Thread* thread, intptr_t index) {
diff --git a/runtime/vm/compiler/backend/slot_test.cc b/runtime/vm/compiler/backend/slot_test.cc
index 9e81ee5..f8b3637 100644
--- a/runtime/vm/compiler/backend/slot_test.cc
+++ b/runtime/vm/compiler/backend/slot_test.cc
@@ -54,8 +54,9 @@
const Field& field = Field::Handle(
Field::New(String::Handle(Symbols::New(thread, "field")),
/*is_static=*/false, /*is_final=*/false, /*is_const=*/false,
- /*is_reflectable=*/true, dummy_class, Object::dynamic_type(),
- TokenPosition::kMinSource, TokenPosition::kMinSource));
+ /*is_reflectable=*/true, /*is_late=*/false, dummy_class,
+ Object::dynamic_type(), TokenPosition::kMinSource,
+ TokenPosition::kMinSource));
// Set non-trivial guarded state on the field.
field.set_guarded_cid(kSmiCid);
diff --git a/runtime/vm/compiler/backend/type_propagator_test.cc b/runtime/vm/compiler/backend/type_propagator_test.cc
index c3b9909..796d977 100644
--- a/runtime/vm/compiler/backend/type_propagator_test.cc
+++ b/runtime/vm/compiler/backend/type_propagator_test.cc
@@ -184,7 +184,8 @@
/*is_static=*/true,
/*is_final=*/false,
/*is_const=*/false,
- /*is_reflectable=*/true, object_class, Object::dynamic_type(),
+ /*is_reflectable=*/true,
+ /*is_late=*/false, object_class, Object::dynamic_type(),
TokenPosition::kNoSource, TokenPosition::kNoSource));
FlowGraphBuilderHelper H;
diff --git a/runtime/vm/compiler/frontend/base_flow_graph_builder.cc b/runtime/vm/compiler/frontend/base_flow_graph_builder.cc
index 9425b5c..ee92faa 100644
--- a/runtime/vm/compiler/frontend/base_flow_graph_builder.cc
+++ b/runtime/vm/compiler/frontend/base_flow_graph_builder.cc
@@ -1121,6 +1121,21 @@
return Fragment(instr);
}
+Fragment BaseFlowGraphBuilder::InitConstantParameters() {
+ Fragment instructions;
+ const intptr_t parameter_count = parsed_function_->function().NumParameters();
+ for (intptr_t i = 0; i < parameter_count; ++i) {
+ LocalVariable* raw_parameter = parsed_function_->RawParameterVariable(i);
+ const Object* param_value = raw_parameter->parameter_value();
+ if (param_value != nullptr) {
+ instructions += Constant(*param_value);
+ instructions += StoreLocalRaw(TokenPosition::kNoSource, raw_parameter);
+ instructions += Drop();
+ }
+ }
+ return instructions;
+}
+
} // namespace kernel
} // namespace dart
diff --git a/runtime/vm/compiler/frontend/base_flow_graph_builder.h b/runtime/vm/compiler/frontend/base_flow_graph_builder.h
index fe89441..f39fb34 100644
--- a/runtime/vm/compiler/frontend/base_flow_graph_builder.h
+++ b/runtime/vm/compiler/frontend/base_flow_graph_builder.h
@@ -410,6 +410,9 @@
// Reset context level for the given deopt id (which was allocated earlier).
void reset_context_depth_for_deopt_id(intptr_t deopt_id);
+ // Sets raw parameter variables to inferred constant values.
+ Fragment InitConstantParameters();
+
protected:
intptr_t AllocateBlockId() { return ++last_used_block_id_; }
diff --git a/runtime/vm/compiler/frontend/bytecode_reader.cc b/runtime/vm/compiler/frontend/bytecode_reader.cc
index f702f9b..eff7d9d 100644
--- a/runtime/vm/compiler/frontend/bytecode_reader.cc
+++ b/runtime/vm/compiler/frontend/bytecode_reader.cc
@@ -489,10 +489,12 @@
closure.set_modifier(RawFunction::kSyncGen);
} else if ((flags & kIsAsyncFlag) != 0) {
closure.set_modifier(RawFunction::kAsync);
- closure.set_is_inlinable(!FLAG_causal_async_stacks);
+ closure.set_is_inlinable(!FLAG_causal_async_stacks &&
+ !FLAG_lazy_async_stacks);
} else if ((flags & kIsAsyncStarFlag) != 0) {
closure.set_modifier(RawFunction::kAsyncGen);
- closure.set_is_inlinable(!FLAG_causal_async_stacks);
+ closure.set_is_inlinable(!FLAG_causal_async_stacks &&
+ !FLAG_lazy_async_stacks);
}
if (Function::Cast(parent).IsAsyncOrGenerator()) {
closure.set_is_generated_body(true);
@@ -2015,8 +2017,8 @@
}
field = Field::New(name, is_static, is_final, is_const,
- (flags & kIsReflectableFlag) != 0, script_class, type,
- position, end_position);
+ (flags & kIsReflectableFlag) != 0, is_late, script_class,
+ type, position, end_position);
field.set_is_declared_in_bytecode(true);
field.set_has_pragma(has_pragma);
@@ -2024,7 +2026,6 @@
field.set_is_generic_covariant_impl((flags & kIsGenericCovariantImplFlag) !=
0);
field.set_has_nontrivial_initializer(has_nontrivial_initializer);
- field.set_is_late((flags & kIsLateFlag) != 0);
field.set_is_extension_member(is_extension_member);
field.set_has_initializer(has_initializer);
@@ -2132,13 +2133,13 @@
if (cls.is_enum_class()) {
// Add static field 'const _deleted_enum_sentinel'.
- field =
- Field::New(Symbols::_DeletedEnumSentinel(),
- /* is_static = */ true,
- /* is_final = */ true,
- /* is_const = */ true,
- /* is_reflectable = */ false, cls, Object::dynamic_type(),
- TokenPosition::kNoSource, TokenPosition::kNoSource);
+ field = Field::New(Symbols::_DeletedEnumSentinel(),
+ /* is_static = */ true,
+ /* is_final = */ true,
+ /* is_const = */ true,
+ /* is_reflectable = */ false,
+ /* is_late = */ false, cls, Object::dynamic_type(),
+ TokenPosition::kNoSource, TokenPosition::kNoSource);
fields.SetAt(num_fields, field);
}
@@ -2275,10 +2276,12 @@
function.set_modifier(RawFunction::kSyncGen);
} else if ((flags & kIsAsyncFlag) != 0) {
function.set_modifier(RawFunction::kAsync);
- function.set_is_inlinable(!FLAG_causal_async_stacks);
+ function.set_is_inlinable(!FLAG_causal_async_stacks &&
+ !FLAG_lazy_async_stacks);
} else if ((flags & kIsAsyncStarFlag) != 0) {
function.set_modifier(RawFunction::kAsyncGen);
- function.set_is_inlinable(!FLAG_causal_async_stacks);
+ function.set_is_inlinable(!FLAG_causal_async_stacks &&
+ !FLAG_lazy_async_stacks);
}
if ((flags & kHasTypeParamsFlag) != 0) {
diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
index 555d02c..fd86730 100644
--- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
+++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
@@ -188,6 +188,27 @@
return instructions;
}
+Fragment StreamingFlowGraphBuilder::BuildLateFieldInitializer(
+ const Field& field,
+ bool has_initializer) {
+ if (has_initializer && PeekTag() == kNullLiteral) {
+ SkipExpression(); // read past the null literal.
+ if (H.thread()->IsMutatorThread()) {
+ field.RecordStore(Object::null_object());
+ } else {
+ ASSERT(field.is_nullable(/* silence_assert = */ true));
+ }
+ return Fragment();
+ }
+
+ Fragment instructions;
+ instructions += LoadLocal(parsed_function()->receiver_var());
+ instructions += flow_graph_builder_->Constant(Object::sentinel());
+ instructions += flow_graph_builder_->StoreInstanceField(
+ field, StoreInstanceFieldInstr::Kind::kInitializing);
+ return instructions;
+}
+
Fragment StreamingFlowGraphBuilder::BuildInitializers(
const Class& parent_class) {
ASSERT(Error::Handle(Z, H.thread()->sticky_error()).IsNull());
@@ -292,7 +313,11 @@
FieldHelper field_helper(this);
field_helper.ReadUntilExcluding(FieldHelper::kInitializer);
const Tag initializer_tag = ReadTag();
- if (initializer_tag == kSomething) {
+ if (class_field.is_late()) {
+ instructions +=
+ BuildLateFieldInitializer(Field::ZoneHandle(Z, class_field.raw()),
+ initializer_tag == kSomething);
+ } else if (initializer_tag == kSomething) {
EnterScope(field_offset);
// If this field is initialized in constructor then we can ignore the
// value produced by the field initializer. However we still need to
@@ -663,18 +688,13 @@
raw_parameter.owner() == NULL));
ASSERT(!raw_parameter.is_captured());
- // Copy the parameter from the stack to the context. Overwrite it
- // with a null constant on the stack so the original value is
- // eligible for garbage collection.
+ // Copy the parameter from the stack to the context.
body += LoadLocal(context);
body += LoadLocal(&raw_parameter);
body += flow_graph_builder_->StoreInstanceField(
TokenPosition::kNoSource,
Slot::GetContextVariableSlotFor(thread(), *variable),
StoreInstanceFieldInstr::Kind::kInitializing);
- body += NullConstant();
- body += StoreLocal(TokenPosition::kNoSource, &raw_parameter);
- body += Drop();
}
}
body += Drop(); // The context.
@@ -788,6 +808,7 @@
F += CheckStackOverflowInPrologue(dart_function);
F += DebugStepCheckInPrologue(dart_function, token_position);
F += SetAsyncStackTrace(dart_function);
+ F += B->InitConstantParameters();
return F;
}
@@ -801,6 +822,31 @@
return F;
}
+Fragment StreamingFlowGraphBuilder::ClearRawParameters(
+ const Function& dart_function) {
+ const ParsedFunction& pf = *flow_graph_builder_->parsed_function_;
+ Fragment code;
+ for (intptr_t i = 0; i < dart_function.NumParameters(); ++i) {
+ LocalVariable* variable = pf.ParameterVariable(i);
+
+ if (!variable->is_captured()) continue;
+
+ // Captured 'this' is immutable, so within the outer method we don't need to
+ // load it from the context. Therefore we don't reset it to null.
+ if (pf.function().HasThisParameter() && pf.has_receiver_var() &&
+ variable == pf.receiver_var()) {
+ ASSERT(i == 0);
+ continue;
+ }
+
+ variable = pf.RawParameterVariable(i);
+ code += NullConstant();
+ code += StoreLocal(TokenPosition::kNoSource, variable);
+ code += Drop();
+ }
+ return code;
+}
+
UncheckedEntryPointStyle StreamingFlowGraphBuilder::ChooseEntryPointStyle(
const Function& dart_function,
const Fragment& implicit_type_checks,
@@ -890,7 +936,10 @@
&explicit_type_checks, &implicit_type_checks,
&implicit_redefinitions);
+ // The RawParameter variables should be set to null to avoid retaining more
+ // objects than necessary during GC.
const Fragment body =
+ ClearRawParameters(dart_function) +
BuildFunctionBody(dart_function, first_parameter, is_constructor);
auto extra_entry_point_style = ChooseEntryPointStyle(
@@ -2611,12 +2660,15 @@
const String& getter_name = H.DartGetterName(target);
const Function& getter =
Function::ZoneHandle(Z, owner.LookupStaticFunction(getter_name));
- if (getter.IsNull() || !field.has_nontrivial_initializer()) {
- Fragment instructions = Constant(field);
- return instructions + LoadStaticField();
- } else {
+ if (!getter.IsNull() && field.NeedsGetter()) {
return StaticCall(position, getter, 0, Array::null_array(),
ICData::kStatic, &result_type);
+ } else {
+ if (result_type.IsConstant()) {
+ return Constant(result_type.constant_value);
+ }
+ Fragment instructions = Constant(field);
+ return instructions + LoadStaticField();
}
}
} else {
@@ -2649,13 +2701,24 @@
if (H.IsField(target)) {
const Field& field =
Field::ZoneHandle(Z, H.LookupFieldByKernelField(target));
+ const Class& owner = Class::Handle(Z, field.Owner());
+ const String& setter_name = H.DartSetterName(target);
+ const Function& setter =
+ Function::ZoneHandle(Z, owner.LookupStaticFunction(setter_name));
Fragment instructions = BuildExpression(); // read expression.
if (NeedsDebugStepCheck(stack(), position)) {
instructions = DebugStepCheck(position) + instructions;
}
LocalVariable* variable = MakeTemporary();
instructions += LoadLocal(variable);
- return instructions + StoreStaticField(position, field);
+ if (!setter.IsNull() && field.NeedsSetter()) {
+ instructions += PushArgument();
+ instructions += StaticCall(position, setter, 1, ICData::kStatic);
+ instructions += Drop();
+ } else {
+ instructions += StoreStaticField(position, field);
+ }
+ return instructions;
} else {
ASSERT(H.IsProcedure(target));
diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h
index f04298e..f7d21e8 100644
--- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h
+++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.h
@@ -38,7 +38,7 @@
constant_reader_(this, active_class_),
bytecode_metadata_helper_(this, active_class_),
direct_call_metadata_helper_(this),
- inferred_type_metadata_helper_(this),
+ inferred_type_metadata_helper_(this, &constant_reader_),
procedure_attributes_metadata_helper_(this),
call_site_attributes_metadata_helper_(this, &type_translator_),
closure_owner_(Object::Handle(flow_graph_builder->zone_)) {}
@@ -63,6 +63,7 @@
FlowGraph* BuildGraphOfFieldInitializer();
Fragment BuildFieldInitializer(const Field& field,
bool only_for_side_effects);
+ Fragment BuildLateFieldInitializer(const Field& field, bool has_initializer);
Fragment BuildInitializers(const Class& parent_class);
FlowGraph* BuildGraphOfFunction(bool constructor);
@@ -82,6 +83,7 @@
Fragment BuildFirstTimePrologue(const Function& dart_function,
LocalVariable* first_parameter,
intptr_t type_parameters_offset);
+ Fragment ClearRawParameters(const Function& dart_function);
Fragment DebugStepCheckInPrologue(const Function& dart_function,
TokenPosition position);
Fragment SetAsyncStackTrace(const Function& dart_function);
diff --git a/runtime/vm/compiler/frontend/kernel_to_il.cc b/runtime/vm/compiler/frontend/kernel_to_il.cc
index 1426f50..f64d10c 100644
--- a/runtime/vm/compiler/frontend/kernel_to_il.cc
+++ b/runtime/vm/compiler/frontend/kernel_to_il.cc
@@ -357,6 +357,12 @@
call->set_receivers_static_type(&type);
}
Push(call);
+ if (result_type != nullptr && result_type->IsConstant()) {
+ Fragment instructions(call);
+ instructions += Drop();
+ instructions += Constant(result_type->constant_value);
+ return instructions;
+ }
return Fragment(call);
}
@@ -398,6 +404,14 @@
}
Fragment FlowGraphBuilder::LoadLocal(LocalVariable* variable) {
+ // Captured 'this' is immutable, so within the outer method we don't need to
+ // load it from the context.
+ const ParsedFunction* pf = parsed_function_;
+ if (pf->function().HasThisParameter() && pf->has_receiver_var() &&
+ variable == pf->receiver_var()) {
+ ASSERT(variable == pf->ParameterVariable(0));
+ variable = pf->RawParameterVariable(0);
+ }
if (variable->is_captured()) {
Fragment instructions;
instructions += LoadContextAt(variable->owner()->context_level());
@@ -651,6 +665,12 @@
call->set_entry_kind(Code::EntryKind::kUnchecked);
}
Push(call);
+ if (result_type != nullptr && result_type->IsConstant()) {
+ Fragment instructions(call);
+ instructions += Drop();
+ instructions += Constant(result_type->constant_value);
+ return instructions;
+ }
return Fragment(call);
}
@@ -1749,9 +1769,13 @@
for (intptr_t i = dart_function.NumImplicitParameters(); i < num_params;
++i) {
LocalVariable* param = parsed_function_->ParameterVariable(i);
+ const String& name = param->name();
if (!param->needs_type_check()) {
continue;
}
+ if (param->is_captured()) {
+ param = parsed_function_->RawParameterVariable(i);
+ }
const AbstractType* target_type = ¶m->type();
if (forwarding_target != NULL) {
@@ -1766,7 +1790,7 @@
Fragment* checks = is_covariant ? explicit_checks : implicit_checks;
*checks += LoadLocal(param);
- *checks += CheckAssignable(*target_type, param->name(),
+ *checks += CheckAssignable(*target_type, name,
AssertAssignableInstr::kParameterCheck);
*checks += Drop();
diff --git a/runtime/vm/compiler/frontend/kernel_translation_helper.cc b/runtime/vm/compiler/frontend/kernel_translation_helper.cc
index 1886995..232c48f 100644
--- a/runtime/vm/compiler/frontend/kernel_translation_helper.cc
+++ b/runtime/vm/compiler/frontend/kernel_translation_helper.cc
@@ -6,6 +6,7 @@
#include "vm/class_finalizer.h"
#include "vm/compiler/aot/precompiler.h"
+#include "vm/compiler/frontend/constant_reader.h"
#include "vm/log.h"
#include "vm/object_store.h"
#include "vm/parser.h" // for ParsedFunction
@@ -675,13 +676,13 @@
Function& function =
Function::Handle(Z, klass.LookupFunctionAllowPrivate(method_name));
- CheckStaticLookup(function);
#ifdef DEBUG
if (function.IsNull()) {
THR_Print("Unable to find \'%s\' in %s\n", method_name.ToCString(),
klass.ToCString());
}
#endif
+ CheckStaticLookup(function);
ASSERT(!function.IsNull());
return function.raw();
}
@@ -1684,8 +1685,10 @@
}
InferredTypeMetadataHelper::InferredTypeMetadataHelper(
- KernelReaderHelper* helper)
- : MetadataHelper(helper, tag(), /* precompiler_only = */ true) {}
+ KernelReaderHelper* helper,
+ ConstantReader* constant_reader)
+ : MetadataHelper(helper, tag(), /* precompiler_only = */ true),
+ constant_reader_(constant_reader) {}
InferredTypeMetadata InferredTypeMetadataHelper::GetInferredType(
intptr_t node_offset) {
@@ -1701,7 +1704,15 @@
const NameIndex kernel_name = helper_->ReadCanonicalNameReference();
const uint8_t flags = helper_->ReadByte();
+ const Object* constant_value = &Object::null_object();
+ if ((flags & InferredTypeMetadata::kFlagConstant) != 0) {
+ const intptr_t constant_offset = helper_->ReadUInt();
+ constant_value = &Object::ZoneHandle(
+ H.zone(), constant_reader_->ReadConstant(constant_offset));
+ }
+
if (H.IsRoot(kernel_name)) {
+ ASSERT((flags & InferredTypeMetadata::kFlagConstant) == 0);
return InferredTypeMetadata(kDynamicCid, flags);
}
@@ -1716,7 +1727,7 @@
cid = kDynamicCid;
}
- return InferredTypeMetadata(cid, flags);
+ return InferredTypeMetadata(cid, flags, *constant_value);
}
void ProcedureAttributesMetadata::InitializeFromFlags(uint8_t flags) {
diff --git a/runtime/vm/compiler/frontend/kernel_translation_helper.h b/runtime/vm/compiler/frontend/kernel_translation_helper.h
index c17bd59..0035663 100644
--- a/runtime/vm/compiler/frontend/kernel_translation_helper.h
+++ b/runtime/vm/compiler/frontend/kernel_translation_helper.h
@@ -15,6 +15,7 @@
namespace dart {
namespace kernel {
+class ConstantReader;
class KernelReaderHelper;
class TypeTranslator;
@@ -906,13 +907,17 @@
kFlagNullable = 1 << 0,
kFlagInt = 1 << 1,
kFlagSkipCheck = 1 << 2,
+ kFlagConstant = 1 << 3,
};
- InferredTypeMetadata(intptr_t cid_, uint8_t flags_)
- : cid(cid_), flags(flags_) {}
+ InferredTypeMetadata(intptr_t cid_,
+ uint8_t flags_,
+ const Object& constant_value_ = Object::null_object())
+ : cid(cid_), flags(flags_), constant_value(constant_value_) {}
const intptr_t cid;
const uint8_t flags;
+ const Object& constant_value;
bool IsTrivial() const {
return (cid == kDynamicCid) && (flags == kFlagNullable);
@@ -920,6 +925,7 @@
bool IsNullable() const { return (flags & kFlagNullable) != 0; }
bool IsInt() const { return (flags & kFlagInt) != 0; }
bool IsSkipCheck() const { return (flags & kFlagSkipCheck) != 0; }
+ bool IsConstant() const { return (flags & kFlagConstant) != 0; }
CompileType ToCompileType(Zone* zone) const {
if (IsInt()) {
@@ -936,11 +942,14 @@
public:
static const char* tag() { return "vm.inferred-type.metadata"; }
- explicit InferredTypeMetadataHelper(KernelReaderHelper* helper);
+ explicit InferredTypeMetadataHelper(KernelReaderHelper* helper,
+ ConstantReader* constant_reader);
InferredTypeMetadata GetInferredType(intptr_t node_offset);
private:
+ ConstantReader* constant_reader_;
+
DISALLOW_COPY_AND_ASSIGN(InferredTypeMetadataHelper);
};
diff --git a/runtime/vm/compiler/frontend/scope_builder.cc b/runtime/vm/compiler/frontend/scope_builder.cc
index a1d2df1..adf7779 100644
--- a/runtime/vm/compiler/frontend/scope_builder.cc
+++ b/runtime/vm/compiler/frontend/scope_builder.cc
@@ -61,7 +61,8 @@
ExternalTypedData::Handle(Z,
parsed_function->function().KernelData()),
parsed_function->function().KernelDataProgramOffset()),
- inferred_type_metadata_helper_(&helper_),
+ constant_reader_(&helper_, &active_class_),
+ inferred_type_metadata_helper_(&helper_, &constant_reader_),
procedure_attributes_metadata_helper_(&helper_),
type_translator_(&helper_,
&active_class_,
@@ -184,7 +185,7 @@
Field& class_field = Field::Handle(Z);
for (intptr_t i = 0; i < class_fields.Length(); ++i) {
class_field ^= class_fields.At(i);
- if (!class_field.is_static() && !class_field.is_late()) {
+ if (!class_field.is_static()) {
ExternalTypedData& kernel_data =
ExternalTypedData::Handle(Z, class_field.KernelData());
ASSERT(!kernel_data.IsNull());
@@ -469,7 +470,7 @@
Field& class_field = Field::Handle(Z);
for (intptr_t i = 0; i < class_fields.Length(); ++i) {
class_field ^= class_fields.At(i);
- if (!class_field.is_static() && !class_field.is_late()) {
+ if (!class_field.is_static()) {
ExternalTypedData& kernel_data =
ExternalTypedData::Handle(Z, class_field.KernelData());
ASSERT(!kernel_data.IsNull());
@@ -1275,7 +1276,17 @@
if (helper.IsFinal()) {
variable->set_is_final();
}
- scope_->AddVariable(variable);
+ // Lift the two special async vars out of the function body scope, into the
+ // outer function declaration scope.
+ // This way we can allocate them in the outermost context at fixed indices,
+ // allowing support for --lazy-async-stacks implementation to find awaiters.
+ if (name.Equals(Symbols::AwaitJumpVar()) ||
+ name.Equals(Symbols::AsyncCompleter()) ||
+ name.Equals(Symbols::Controller())) {
+ scope_->parent()->AddVariable(variable);
+ } else {
+ scope_->AddVariable(variable);
+ }
result_->locals.Insert(helper_.data_program_offset_ + kernel_offset_no_tag,
variable);
}
@@ -1572,12 +1583,16 @@
const String& name,
const AbstractType& type,
const InferredTypeMetadata* param_type_md /* = NULL */) {
- CompileType* param_type = NULL;
- if ((param_type_md != NULL) && !param_type_md->IsTrivial()) {
+ CompileType* param_type = nullptr;
+ const Object* param_value = nullptr;
+ if (param_type_md != nullptr && !param_type_md->IsTrivial()) {
param_type = new (Z) CompileType(param_type_md->ToCompileType(Z));
+ if (param_type_md->IsConstant()) {
+ param_value = ¶m_type_md->constant_value;
+ }
}
- return new (Z)
- LocalVariable(declaration_pos, token_pos, name, type, param_type);
+ return new (Z) LocalVariable(declaration_pos, token_pos, name, type,
+ param_type, param_value);
}
void ScopeBuilder::AddExceptionVariable(
diff --git a/runtime/vm/compiler/frontend/scope_builder.h b/runtime/vm/compiler/frontend/scope_builder.h
index b2227aa..278de2f 100644
--- a/runtime/vm/compiler/frontend/scope_builder.h
+++ b/runtime/vm/compiler/frontend/scope_builder.h
@@ -7,6 +7,7 @@
#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/frontend/constant_reader.h"
#include "vm/compiler/frontend/kernel_translation_helper.h"
#include "vm/hash_map.h"
#include "vm/object.h"
@@ -157,6 +158,7 @@
TokenPosition first_body_token_position_;
KernelReaderHelper helper_;
+ ConstantReader constant_reader_;
InferredTypeMetadataHelper inferred_type_metadata_helper_;
ProcedureAttributesMetadataHelper procedure_attributes_metadata_helper_;
TypeTranslator type_translator_;
diff --git a/runtime/vm/compiler/recognized_methods_list.h b/runtime/vm/compiler/recognized_methods_list.h
index afec50c..ec4d2fd 100644
--- a/runtime/vm/compiler/recognized_methods_list.h
+++ b/runtime/vm/compiler/recognized_methods_list.h
@@ -182,11 +182,11 @@
V(_BigIntImpl, _rsh, Bigint_rsh, 0x2bf277fc) \
V(_BigIntImpl, _absAdd, Bigint_absAdd, 0x147eb8ec) \
V(_BigIntImpl, _absSub, Bigint_absSub, 0xed4c4e74) \
- V(_BigIntImpl, _mulAdd, Bigint_mulAdd, 0xc8dcc37e) \
- V(_BigIntImpl, _sqrAdd, Bigint_sqrAdd, 0x45be1228) \
+ V(_BigIntImpl, _mulAdd, Bigint_mulAdd, 0x634f75a0) \
+ V(_BigIntImpl, _sqrAdd, Bigint_sqrAdd, 0xc0a29ed4) \
V(_BigIntImpl, _estimateQuotientDigit, Bigint_estimateQuotientDigit, \
- 0xd7c44af1) \
- V(_BigIntMontgomeryReduction, _mulMod, Montgomery_mulMod, 0xa1a5caf3) \
+ 0x03b20399) \
+ V(_BigIntMontgomeryReduction, _mulMod, Montgomery_mulMod, 0x3b707797) \
V(_Double, >, Double_greaterThan, 0x682a02bc) \
V(_Double, >=, Double_greaterEqualThan, 0x2961f8ee) \
V(_Double, <, Double_lessThan, 0xcbff42e5) \
diff --git a/runtime/vm/compiler/stub_code_compiler_arm.cc b/runtime/vm/compiler/stub_code_compiler_arm.cc
index 901940d..d77d0cf 100644
--- a/runtime/vm/compiler/stub_code_compiler_arm.cc
+++ b/runtime/vm/compiler/stub_code_compiler_arm.cc
@@ -1973,6 +1973,20 @@
__ Ret();
}
+// Saves the offset of the target entry-point (from the Function) into R3.
+//
+// Must be the first code generated, since any code before will be skipped in
+// the unchecked entry-point.
+static void GenerateRecordEntryPoint(Assembler* assembler) {
+ Label done;
+ __ mov(R3, Operand(target::Function::entry_point_offset() - kHeapObjectTag));
+ __ b(&done);
+ __ BindUncheckedEntryPoint();
+ __ mov(R3, Operand(target::Function::unchecked_entry_point_offset() -
+ kHeapObjectTag));
+ __ Bind(&done);
+}
+
// Generate inline cache check for 'num_args'.
// R0: receiver (if instance call)
// R9: ICData
@@ -1992,6 +2006,14 @@
Optimized optimized,
CallType type,
Exactness exactness) {
+ GenerateRecordEntryPoint(assembler);
+
+ if (optimized == kOptimized) {
+ GenerateOptimizedUsageCounterIncrement(assembler);
+ } else {
+ GenerateUsageCounterIncrement(assembler, /* scratch */ R8);
+ }
+
ASSERT(exactness == kIgnoreExactness); // Unimplemented.
__ CheckCodePointer();
ASSERT(num_args == 1 || num_args == 2);
@@ -2119,7 +2141,8 @@
__ LoadImmediate(R0, 0);
// Preserve IC data object and arguments descriptor array and
// setup space on stack for result (target code object).
- __ PushList((1 << R0) | (1 << R4) | (1 << R9));
+ __ SmiTag(R3);
+ __ PushList((1 << R0) | (1 << R4) | (1 << R9) | (1 << R3));
// Push call arguments.
for (intptr_t i = 0; i < num_args; i++) {
__ LoadFromOffset(kWord, IP, NOTFP, -i * target::kWordSize);
@@ -2132,7 +2155,8 @@
__ Drop(num_args + 1);
// Pop returned function object into R0.
// Restore arguments descriptor array and IC data array.
- __ PopList((1 << R0) | (1 << R4) | (1 << R9));
+ __ PopList((1 << R0) | (1 << R4) | (1 << R9) | (1 << R3));
+ __ SmiUntag(R3);
__ RestoreCodePointer();
__ LeaveStubFrame();
Label call_target_function;
@@ -2162,7 +2186,8 @@
__ Bind(&call_target_function);
// R0: target function.
__ ldr(CODE_REG, FieldAddress(R0, target::Function::code_offset()));
- __ Branch(FieldAddress(R0, target::Function::entry_point_offset()));
+
+ __ Branch(Address(R0, R3));
#if !defined(PRODUCT)
if (optimized == kUnoptimized) {
@@ -2171,9 +2196,11 @@
if (type == kInstanceCall) {
__ Push(R0); // Preserve receiver.
}
- __ Push(R9); // Preserve IC data.
+ __ SmiTag(R3); // Entry-point is not Smi.
+ __ PushList((1 << R3) | (1 << R9)); // Preserve IC data and entry-point.
__ CallRuntime(kSingleStepHandlerRuntimeEntry, 0);
- __ Pop(R9);
+ __ PopList((1 << R3) | (1 << R9)); // Restore IC data and entry-point
+ __ SmiUntag(R3);
if (type == kInstanceCall) {
__ Pop(R0);
}
@@ -2189,7 +2216,6 @@
// LR: return address
void StubCodeCompiler::GenerateOneArgCheckInlineCacheStub(
Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ R8);
GenerateNArgsCheckInlineCacheStub(
assembler, 1, kInlineCacheMissHandlerOneArgRuntimeEntry, Token::kILLEGAL,
kUnoptimized, kInstanceCall, kIgnoreExactness);
@@ -2208,7 +2234,6 @@
// LR: return address
void StubCodeCompiler::GenerateTwoArgsCheckInlineCacheStub(
Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ R8);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kInlineCacheMissHandlerTwoArgsRuntimeEntry, Token::kILLEGAL,
kUnoptimized, kInstanceCall, kIgnoreExactness);
@@ -2218,7 +2243,6 @@
// R9: ICData
// LR: return address
void StubCodeCompiler::GenerateSmiAddInlineCacheStub(Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ R8);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kInlineCacheMissHandlerTwoArgsRuntimeEntry, Token::kADD,
kUnoptimized, kInstanceCall, kIgnoreExactness);
@@ -2228,7 +2252,6 @@
// R9: ICData
// LR: return address
void StubCodeCompiler::GenerateSmiLessInlineCacheStub(Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ R8);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kInlineCacheMissHandlerTwoArgsRuntimeEntry, Token::kLT,
kUnoptimized, kInstanceCall, kIgnoreExactness);
@@ -2238,7 +2261,6 @@
// R9: ICData
// LR: return address
void StubCodeCompiler::GenerateSmiEqualInlineCacheStub(Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ R8);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kInlineCacheMissHandlerTwoArgsRuntimeEntry, Token::kEQ,
kUnoptimized, kInstanceCall, kIgnoreExactness);
@@ -2250,7 +2272,6 @@
// LR: return address
void StubCodeCompiler::GenerateOneArgOptimizedCheckInlineCacheStub(
Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ R8);
GenerateNArgsCheckInlineCacheStub(
assembler, 1, kInlineCacheMissHandlerOneArgRuntimeEntry, Token::kILLEGAL,
kOptimized, kInstanceCall, kIgnoreExactness);
@@ -2272,7 +2293,6 @@
// LR: return address
void StubCodeCompiler::GenerateTwoArgsOptimizedCheckInlineCacheStub(
Assembler* assembler) {
- GenerateOptimizedUsageCounterIncrement(assembler);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kInlineCacheMissHandlerTwoArgsRuntimeEntry, Token::kILLEGAL,
kOptimized, kInstanceCall, kIgnoreExactness);
@@ -2282,6 +2302,7 @@
// LR: return address
void StubCodeCompiler::GenerateZeroArgsUnoptimizedStaticCallStub(
Assembler* assembler) {
+ GenerateRecordEntryPoint(assembler);
GenerateUsageCounterIncrement(assembler, /* scratch */ R8);
#if defined(DEBUG)
{
@@ -2331,14 +2352,17 @@
// Get function and call it, if possible.
__ LoadFromOffset(kWord, R0, R8, target_offset);
__ ldr(CODE_REG, FieldAddress(R0, target::Function::code_offset()));
- __ Branch(FieldAddress(R0, target::Function::entry_point_offset()));
+
+ __ Branch(Address(R0, R3));
#if !defined(PRODUCT)
__ Bind(&stepping);
__ EnterStubFrame();
- __ Push(R9); // Preserve IC data.
+ __ SmiTag(R3); // Entry-point is not Smi.
+ __ PushList((1 << R9) | (1 << R3)); // Preserve IC data and entry-point.
__ CallRuntime(kSingleStepHandlerRuntimeEntry, 0);
- __ Pop(R9);
+ __ PopList((1 << R9) | (1 << R3));
+ __ SmiUntag(R3);
__ RestoreCodePointer();
__ LeaveStubFrame();
__ b(&done_stepping);
diff --git a/runtime/vm/compiler/stub_code_compiler_x64.cc b/runtime/vm/compiler/stub_code_compiler_x64.cc
index b73316a..393af1d 100644
--- a/runtime/vm/compiler/stub_code_compiler_x64.cc
+++ b/runtime/vm/compiler/stub_code_compiler_x64.cc
@@ -1348,8 +1348,8 @@
__ movq(Address(THR, target::Thread::top_exit_frame_info_offset()),
Immediate(0));
- // The constant target::frame_layout.exit_link_slot_from_entry_fp must be kept
- // in sync with the code below.
+// The constant target::frame_layout.exit_link_slot_from_entry_fp must be kept
+// in sync with the code below.
#if defined(DEBUG)
{
Label ok;
@@ -2049,6 +2049,21 @@
__ ret();
}
+// Saves the offset of the target entry-point (from the Function) into R8.
+//
+// Must be the first code generated, since any code before will be skipped in
+// the unchecked entry-point.
+static void GenerateRecordEntryPoint(Assembler* assembler) {
+ Label done;
+ __ movq(R8,
+ Immediate(target::Function::entry_point_offset() - kHeapObjectTag));
+ __ jmp(&done);
+ __ BindUncheckedEntryPoint();
+ __ movq(R8, Immediate(target::Function::unchecked_entry_point_offset() -
+ kHeapObjectTag));
+ __ Bind(&done);
+}
+
// Generate inline cache check for 'num_args'.
// RDX: receiver (if instance call)
// RBX: ICData
@@ -2068,6 +2083,14 @@
Optimized optimized,
CallType type,
Exactness exactness) {
+ GenerateRecordEntryPoint(assembler);
+
+ if (optimized == kOptimized) {
+ GenerateOptimizedUsageCounterIncrement(assembler);
+ } else {
+ GenerateUsageCounterIncrement(assembler, /* scratch */ RCX);
+ }
+
ASSERT(num_args == 1 || num_args == 2);
#if defined(DEBUG)
{
@@ -2182,6 +2205,8 @@
__ movq(RAX, FieldAddress(R10, target::ArgumentsDescriptor::count_offset()));
__ leaq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX is Smi.
__ EnterStubFrame();
+ __ SmiTag(R8); // Entry-point offset is not Smi.
+ __ pushq(R8); // Preserve entry point.
__ pushq(R10); // Preserve arguments descriptor array.
__ pushq(RBX); // Preserve IC data object.
__ pushq(Immediate(0)); // Result slot.
@@ -2196,9 +2221,11 @@
for (intptr_t i = 0; i < num_args + 1; i++) {
__ popq(RAX);
}
- __ popq(RAX); // Pop returned function object into RAX.
- __ popq(RBX); // Restore IC data array.
- __ popq(R10); // Restore arguments descriptor array.
+ __ popq(RAX); // Pop returned function object into RAX.
+ __ popq(RBX); // Restore IC data array.
+ __ popq(R10); // Restore arguments descriptor array.
+ __ popq(R8); // Restore entry point.
+ __ SmiUntag(R8); // Entry-point offset is not Smi.
__ RestoreCodePointer();
__ LeaveStubFrame();
Label call_target_function;
@@ -2246,11 +2273,12 @@
__ addq(Address(R13, count_offset), Immediate(target::ToRawSmi(1)));
}
- __ Comment("Call target (via checked entry point)");
+ __ Comment("Call target (via specified entry point)");
__ Bind(&call_target_function);
// RAX: Target function.
__ movq(CODE_REG, FieldAddress(RAX, target::Function::code_offset()));
- __ jmp(FieldAddress(RAX, target::Function::entry_point_offset()));
+ __ addq(R8, RAX);
+ __ jmp(Address(R8, 0));
if (exactness == kCheckExactness) {
__ Bind(&call_target_function_through_unchecked_entry);
@@ -2273,7 +2301,11 @@
__ pushq(RDX); // Preserve receiver.
}
__ pushq(RBX); // Preserve ICData.
+ __ SmiTag(R8); // Entry-point offset is not Smi.
+ __ pushq(R8); // Preserve entry point.
__ CallRuntime(kSingleStepHandlerRuntimeEntry, 0);
+ __ popq(R8); // Restore entry point.
+ __ SmiUntag(R8);
__ popq(RBX); // Restore ICData.
if (type == kInstanceCall) {
__ popq(RDX); // Restore receiver.
@@ -2290,7 +2322,6 @@
// RSP[0]: return address
void StubCodeCompiler::GenerateOneArgCheckInlineCacheStub(
Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ RCX);
GenerateNArgsCheckInlineCacheStub(
assembler, 1, kInlineCacheMissHandlerOneArgRuntimeEntry, Token::kILLEGAL,
kUnoptimized, kInstanceCall, kIgnoreExactness);
@@ -2301,7 +2332,6 @@
// RSP[0]: return address
void StubCodeCompiler::GenerateOneArgCheckInlineCacheWithExactnessCheckStub(
Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ RCX);
GenerateNArgsCheckInlineCacheStub(
assembler, 1, kInlineCacheMissHandlerOneArgRuntimeEntry, Token::kILLEGAL,
kUnoptimized, kInstanceCall, kCheckExactness);
@@ -2312,7 +2342,6 @@
// RSP[0]: return address
void StubCodeCompiler::GenerateTwoArgsCheckInlineCacheStub(
Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ RCX);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kInlineCacheMissHandlerTwoArgsRuntimeEntry, Token::kILLEGAL,
kUnoptimized, kInstanceCall, kIgnoreExactness);
@@ -2322,7 +2351,6 @@
// RBX: ICData
// RSP[0]: return address
void StubCodeCompiler::GenerateSmiAddInlineCacheStub(Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ RCX);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kInlineCacheMissHandlerTwoArgsRuntimeEntry, Token::kADD,
kUnoptimized, kInstanceCall, kIgnoreExactness);
@@ -2332,7 +2360,6 @@
// RBX: ICData
// RSP[0]: return address
void StubCodeCompiler::GenerateSmiLessInlineCacheStub(Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ RCX);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kInlineCacheMissHandlerTwoArgsRuntimeEntry, Token::kLT,
kUnoptimized, kInstanceCall, kIgnoreExactness);
@@ -2342,7 +2369,6 @@
// RBX: ICData
// RSP[0]: return address
void StubCodeCompiler::GenerateSmiEqualInlineCacheStub(Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ RCX);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kInlineCacheMissHandlerTwoArgsRuntimeEntry, Token::kEQ,
kUnoptimized, kInstanceCall, kIgnoreExactness);
@@ -2354,7 +2380,6 @@
// RSP[0]: return address
void StubCodeCompiler::GenerateOneArgOptimizedCheckInlineCacheStub(
Assembler* assembler) {
- GenerateOptimizedUsageCounterIncrement(assembler);
GenerateNArgsCheckInlineCacheStub(
assembler, 1, kInlineCacheMissHandlerOneArgRuntimeEntry, Token::kILLEGAL,
kOptimized, kInstanceCall, kIgnoreExactness);
@@ -2367,7 +2392,6 @@
void StubCodeCompiler::
GenerateOneArgOptimizedCheckInlineCacheWithExactnessCheckStub(
Assembler* assembler) {
- GenerateOptimizedUsageCounterIncrement(assembler);
GenerateNArgsCheckInlineCacheStub(
assembler, 1, kInlineCacheMissHandlerOneArgRuntimeEntry, Token::kILLEGAL,
kOptimized, kInstanceCall, kCheckExactness);
@@ -2379,7 +2403,6 @@
// RSP[0]: return address
void StubCodeCompiler::GenerateTwoArgsOptimizedCheckInlineCacheStub(
Assembler* assembler) {
- GenerateOptimizedUsageCounterIncrement(assembler);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kInlineCacheMissHandlerTwoArgsRuntimeEntry, Token::kILLEGAL,
kOptimized, kInstanceCall, kIgnoreExactness);
@@ -2389,6 +2412,7 @@
// RSP[0]: return address
void StubCodeCompiler::GenerateZeroArgsUnoptimizedStaticCallStub(
Assembler* assembler) {
+ GenerateRecordEntryPoint(assembler);
GenerateUsageCounterIncrement(assembler, /* scratch */ RCX);
#if defined(DEBUG)
{
@@ -2442,14 +2466,19 @@
// Get function and call it, if possible.
__ movq(RAX, Address(R12, target_offset));
__ movq(CODE_REG, FieldAddress(RAX, target::Function::code_offset()));
- __ movq(RCX, FieldAddress(RAX, target::Function::entry_point_offset()));
- __ jmp(RCX);
+
+ __ addq(R8, RAX);
+ __ jmp(Address(R8, 0));
#if !defined(PRODUCT)
__ Bind(&stepping);
__ EnterStubFrame();
__ pushq(RBX); // Preserve IC data object.
+ __ SmiTag(R8); // Entry-point is not Smi.
+ __ pushq(R8); // Preserve entry-point.
__ CallRuntime(kSingleStepHandlerRuntimeEntry, 0);
+ __ popq(R8); // Restore entry-point.
+ __ SmiUntag(R8);
__ popq(RBX);
__ RestoreCodePointer();
__ LeaveStubFrame();
@@ -2461,7 +2490,6 @@
// RSP[0]: return address
void StubCodeCompiler::GenerateOneArgUnoptimizedStaticCallStub(
Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ RCX);
GenerateNArgsCheckInlineCacheStub(
assembler, 1, kStaticCallMissHandlerOneArgRuntimeEntry, Token::kILLEGAL,
kUnoptimized, kStaticCall, kIgnoreExactness);
@@ -2471,7 +2499,6 @@
// RSP[0]: return address
void StubCodeCompiler::GenerateTwoArgsUnoptimizedStaticCallStub(
Assembler* assembler) {
- GenerateUsageCounterIncrement(assembler, /* scratch */ RCX);
GenerateNArgsCheckInlineCacheStub(
assembler, 2, kStaticCallMissHandlerTwoArgsRuntimeEntry, Token::kILLEGAL,
kUnoptimized, kStaticCall, kIgnoreExactness);
diff --git a/runtime/vm/compiler_test.cc b/runtime/vm/compiler_test.cc
index 9155f08..2ea85b1 100644
--- a/runtime/vm/compiler_test.cc
+++ b/runtime/vm/compiler_test.cc
@@ -230,13 +230,14 @@
/* is_static= */ false);
EXPECT_EQ(Dart_KernelCompilationStatus_Ok, compilation_result.status);
- const uint8_t* kernel_bytes = compilation_result.kernel;
- intptr_t kernel_length = compilation_result.kernel_size;
+ const ExternalTypedData& kernel_buffer =
+ ExternalTypedData::Handle(ExternalTypedData::NewFinalizeWithFree(
+ const_cast<uint8_t*>(compilation_result.kernel),
+ compilation_result.kernel_size));
val = Instance::Cast(obj).EvaluateCompiledExpression(
- receiver_cls, kernel_bytes, kernel_length, Array::empty_array(),
- Array::empty_array(), TypeArguments::null_type_arguments());
- free(const_cast<uint8_t*>(kernel_bytes));
+ receiver_cls, kernel_buffer, Array::empty_array(), Array::empty_array(),
+ TypeArguments::null_type_arguments());
}
EXPECT(!val.IsNull());
EXPECT(!val.IsError());
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc
index 63b9e59..e90b749 100644
--- a/runtime/vm/dart.cc
+++ b/runtime/vm/dart.cc
@@ -158,6 +158,11 @@
return strdup("VM already initialized or flags not initialized.");
}
+ if (FLAG_causal_async_stacks && FLAG_lazy_async_stacks) {
+ return strdup(
+ "To use --lazy-async-stacks, please disable --causal-async-stacks!");
+ }
+
const Snapshot* snapshot = nullptr;
if (vm_isolate_snapshot != nullptr) {
snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot);
diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc
index c5ce88a..2efdac3 100644
--- a/runtime/vm/debugger.cc
+++ b/runtime/vm/debugger.cc
@@ -1463,16 +1463,14 @@
}
RawObject* ActivationFrame::EvaluateCompiledExpression(
- const uint8_t* kernel_bytes,
- intptr_t kernel_length,
+ const ExternalTypedData& kernel_buffer,
const Array& type_definitions,
const Array& arguments,
const TypeArguments& type_arguments) {
if (function().is_static()) {
const Class& cls = Class::Handle(function().Owner());
- return cls.EvaluateCompiledExpression(kernel_bytes, kernel_length,
- type_definitions, arguments,
- type_arguments);
+ return cls.EvaluateCompiledExpression(kernel_buffer, type_definitions,
+ arguments, type_arguments);
} else {
const Object& receiver = Object::Handle(GetReceiver());
const Class& method_cls = Class::Handle(function().origin());
@@ -1481,9 +1479,8 @@
return Object::null();
}
const Instance& inst = Instance::Cast(receiver);
- return inst.EvaluateCompiledExpression(method_cls, kernel_bytes,
- kernel_length, type_definitions,
- arguments, type_arguments);
+ return inst.EvaluateCompiledExpression(
+ method_cls, kernel_buffer, type_definitions, arguments, type_arguments);
}
}
diff --git a/runtime/vm/debugger.h b/runtime/vm/debugger.h
index b1fdd40..390b124 100644
--- a/runtime/vm/debugger.h
+++ b/runtime/vm/debugger.h
@@ -353,8 +353,7 @@
const GrowableObjectArray& param_values,
const GrowableObjectArray& type_params_names);
- RawObject* EvaluateCompiledExpression(const uint8_t* kernel_bytes,
- intptr_t kernel_length,
+ RawObject* EvaluateCompiledExpression(const ExternalTypedData& kernel_data,
const Array& arguments,
const Array& type_definitions,
const TypeArguments& type_arguments);
diff --git a/runtime/vm/debugger_api_impl_test.cc b/runtime/vm/debugger_api_impl_test.cc
index ddcbb7c..8ca5a67 100644
--- a/runtime/vm/debugger_api_impl_test.cc
+++ b/runtime/vm/debugger_api_impl_test.cc
@@ -190,18 +190,20 @@
return Api::NewError("Failed to compile expression.");
}
- const uint8_t* kernel_bytes = compilation_result.kernel;
- intptr_t kernel_length = compilation_result.kernel_size;
+ const ExternalTypedData& kernel_buffer =
+ ExternalTypedData::Handle(ExternalTypedData::NewFinalizeWithFree(
+ const_cast<uint8_t*>(compilation_result.kernel),
+ compilation_result.kernel_size));
+
Dart_Handle result = Api::NewHandle(
T,
- lib.EvaluateCompiledExpression(kernel_bytes, kernel_length,
+ lib.EvaluateCompiledExpression(kernel_buffer,
/* type_definitions= */
Array::empty_array(),
/* param_values= */
Array::empty_array(),
/* type_param_values= */
TypeArguments::null_type_arguments()));
- free(const_cast<uint8_t*>(kernel_bytes));
return result;
}
}
diff --git a/runtime/vm/dwarf.cc b/runtime/vm/dwarf.cc
index 2093b90..a54f96a 100644
--- a/runtime/vm/dwarf.cc
+++ b/runtime/vm/dwarf.cc
@@ -421,7 +421,7 @@
if (node != NULL) {
for (InliningNode* child = node->children_head; child != NULL;
child = child->children_next) {
- WriteInliningNode(child, i, script, &namer);
+ WriteInliningNode(child, i, code_offset, script, &namer);
}
}
@@ -512,6 +512,7 @@
void Dwarf::WriteInliningNode(InliningNode* node,
intptr_t root_code_index,
+ intptr_t root_code_offset,
const Script& parent_script,
AssemblyCodeNamer* namer) {
intptr_t file = LookupScript(parent_script);
@@ -541,9 +542,9 @@
Print(FORM_ADDR " %s + %d\n", asm_name, node->end_pc_offset);
} else {
// DW_AT_low_pc
- addr(root_code_index + node->start_pc_offset);
- // DW_AT_high_pc
- addr(root_code_index + node->end_pc_offset);
+ addr(root_code_offset + node->start_pc_offset);
+ // DW_AT_high_pc
+ addr(root_code_offset + node->end_pc_offset);
}
// DW_AT_call_file
@@ -553,7 +554,7 @@
for (InliningNode* child = node->children_head; child != NULL;
child = child->children_next) {
- WriteInliningNode(child, root_code_index, script, namer);
+ WriteInliningNode(child, root_code_index, root_code_offset, script, namer);
}
uleb128(0); // End of children.
diff --git a/runtime/vm/dwarf.h b/runtime/vm/dwarf.h
index 14eac01..ddbc287 100644
--- a/runtime/vm/dwarf.h
+++ b/runtime/vm/dwarf.h
@@ -286,6 +286,7 @@
InliningNode* ExpandInliningTree(const Code& code);
void WriteInliningNode(InliningNode* node,
intptr_t root_code_index,
+ intptr_t root_code_offset,
const Script& parent_script,
AssemblyCodeNamer* namer);
void WriteLines();
diff --git a/runtime/vm/flag_list.h b/runtime/vm/flag_list.h
index 6912711..c211f9d 100644
--- a/runtime/vm/flag_list.h
+++ b/runtime/vm/flag_list.h
@@ -115,6 +115,7 @@
P(idle_duration_micros, int, 500 * kMicrosecondsPerMillisecond, \
"Allow idle tasks to run for this long.") \
P(interpret_irregexp, bool, false, "Use irregexp bytecode interpreter") \
+ P(lazy_async_stacks, bool, false, "Reconstruct async stacks from listeners") \
P(lazy_dispatchers, bool, true, "Generate dispatchers lazily") \
P(link_natives_lazily, bool, false, "Link native calls lazily") \
R(log_marker_tasks, false, bool, false, \
diff --git a/runtime/vm/heap/heap.cc b/runtime/vm/heap/heap.cc
index 26a8a5e..057a8ff 100644
--- a/runtime/vm/heap/heap.cc
+++ b/runtime/vm/heap/heap.cc
@@ -135,7 +135,7 @@
// If we are in the process of running a sweep, wait for the sweeper to free
// memory.
Thread* thread = Thread::Current();
- if (thread->CanCollectGarbage()) {
+ if (old_space_.GrowthControlState()) {
// Wait for any GC tasks that are in progress.
WaitForSweeperTasks(thread);
addr = old_space_.TryAllocate(size, type);
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index a63c300..a7dda01 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -65,14 +65,6 @@
DECLARE_FLAG(bool, trace_service);
DECLARE_FLAG(bool, warn_on_pause_with_no_debugger);
-// TODO(bkonyi): remove this flag around Nov 2019 after UX studies are
-// complete. See issue 38535.
-DEFINE_FLAG(int,
- object_id_ring_size,
- ObjectIdRing::kDefaultCapacity,
- "(EXPERIMENTAL) Manually set the size of the service protocol's "
- "object ID ring buffer. Set to be removed by Nov 2019.");
-
// Reload flags.
DECLARE_FLAG(int, reload_every);
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
@@ -1266,7 +1258,6 @@
tag_table_(GrowableObjectArray::null()),
deoptimized_code_array_(GrowableObjectArray::null()),
sticky_error_(Error::null()),
- reloaded_kernel_blobs_(GrowableObjectArray::null()),
field_list_mutex_(NOT_IN_PRODUCT("Isolate::field_list_mutex_")),
boxed_field_list_(GrowableObjectArray::null()),
spawn_count_monitor_(),
@@ -1475,12 +1466,7 @@
#ifndef PRODUCT
if (FLAG_support_service) {
- if (FLAG_object_id_ring_size != ObjectIdRing::kDefaultCapacity) {
- OS::Print(
- "WARNING: this flag is temporary, is not supported, and should"
- " only be used for UX studies. Use at your own risk!\n");
- }
- ObjectIdRing::Init(result, FLAG_object_id_ring_size);
+ ObjectIdRing::Init(result);
}
#endif // !PRODUCT
@@ -1502,14 +1488,6 @@
return result;
}
-void Isolate::RetainKernelBlob(const ExternalTypedData& kernel_blob) {
- if (reloaded_kernel_blobs_ == Object::null()) {
- reloaded_kernel_blobs_ = GrowableObjectArray::New();
- }
- auto& kernel_blobs = GrowableObjectArray::Handle(reloaded_kernel_blobs_);
- kernel_blobs.Add(kernel_blob);
-}
-
Thread* Isolate::mutator_thread() const {
ASSERT(thread_registry() != nullptr);
return mutator_thread_;
@@ -2343,7 +2321,6 @@
visitor->VisitPointer(
reinterpret_cast<RawObject**>(&deoptimized_code_array_));
visitor->VisitPointer(reinterpret_cast<RawObject**>(&sticky_error_));
- visitor->VisitPointer(reinterpret_cast<RawObject**>(&reloaded_kernel_blobs_));
#if !defined(PRODUCT)
visitor->VisitPointer(
reinterpret_cast<RawObject**>(&pending_service_extension_calls_));
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index b5913f8..c8cf025 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -868,8 +868,6 @@
RawError* sticky_error() const { return sticky_error_; }
DART_WARN_UNUSED_RESULT RawError* StealStickyError();
- void RetainKernelBlob(const ExternalTypedData& kernel_blob);
-
bool compilation_allowed() const {
return CompilationAllowedBit::decode(isolate_flags_);
}
@@ -1269,12 +1267,6 @@
RawError* sticky_error_;
- // Issue(dartbug.com/33973): We keep a reference to [ExternalTypedData]s with
- // finalizers to ensure we keep the hot-reloaded kernel blobs alive.
- //
- // -> We should get rid of this field once Issue 33973 is fixed.
- RawGrowableObjectArray* reloaded_kernel_blobs_;
-
// Isolate list next pointer.
Isolate* next_ = nullptr;
diff --git a/runtime/vm/isolate_reload.cc b/runtime/vm/isolate_reload.cc
index 7cb3ca6..c93c263 100644
--- a/runtime/vm/isolate_reload.cc
+++ b/runtime/vm/isolate_reload.cc
@@ -597,7 +597,9 @@
}
}
const auto& typed_data = ExternalTypedData::Handle(
- Z, MakeRetainedTypedData(kernel_buffer, kernel_buffer_size));
+ Z, ExternalTypedData::NewFinalizeWithFree(
+ const_cast<uint8_t*>(kernel_buffer), kernel_buffer_size));
+
kernel_program = kernel::Program::ReadFromTypedData(typed_data);
}
@@ -936,30 +938,6 @@
return nullptr;
}
-RawExternalTypedData* IsolateGroupReloadContext::MakeRetainedTypedData(
- const uint8_t* kernel_buffer,
- intptr_t kernel_buffer_size) {
- // The ownership of the kernel buffer goes now to the VM.
- const auto& typed_data = ExternalTypedData::Handle(
- Z, ExternalTypedData::New(kExternalTypedDataUint8ArrayCid,
- const_cast<uint8_t*>(kernel_buffer),
- kernel_buffer_size, Heap::kOld));
- typed_data.AddFinalizer(
- const_cast<uint8_t*>(kernel_buffer),
- [](void* isolate_callback_data, Dart_WeakPersistentHandle handle,
- void* data) { free(data); },
- kernel_buffer_size);
-
- // TODO(dartbug.com/33973): Change the heap objects to have a proper
- // retaining path to the kernel blob and ensure the finalizer will free it
- // once there are no longer references to it.
- // (The [ExternalTypedData] currently referenced by e.g. functions point
- // into the middle of c-allocated buffer and don't have a finalizer).
- first_isolate_->RetainKernelBlob(typed_data);
-
- return typed_data.raw();
-}
-
void IsolateReloadContext::ReloadPhase1AllocateStorageMapsAndCheckpoint() {
// Preallocate storage for maps.
old_classes_set_storage_ =
diff --git a/runtime/vm/isolate_reload.h b/runtime/vm/isolate_reload.h
index bd3f86d..ba6ba59 100644
--- a/runtime/vm/isolate_reload.h
+++ b/runtime/vm/isolate_reload.h
@@ -216,8 +216,6 @@
const char* packages_url,
const uint8_t** kernel_buffer,
intptr_t* kernel_buffer_size);
- RawExternalTypedData* MakeRetainedTypedData(const uint8_t* kernel_buffer,
- intptr_t kernel_buffer_size);
void FindModifiedSources(bool force_reload,
Dart_SourceFile** modified_sources,
intptr_t* count,
diff --git a/runtime/vm/kernel.h b/runtime/vm/kernel.h
index 9afdc32..43babb8 100644
--- a/runtime/vm/kernel.h
+++ b/runtime/vm/kernel.h
@@ -88,12 +88,13 @@
return metadata_mappings_offset_;
}
intptr_t constant_table_offset() { return constant_table_offset_; }
+ const ExternalTypedData* typed_data() { return typed_data_; }
const uint8_t* kernel_data() { return kernel_data_; }
intptr_t kernel_data_size() { return kernel_data_size_; }
intptr_t library_count() { return library_count_; }
private:
- Program() : kernel_data_(NULL), kernel_data_size_(-1) {}
+ Program() : typed_data_(NULL), kernel_data_(NULL), kernel_data_size_(-1) {}
bool single_program_;
uint32_t binary_version_;
@@ -118,6 +119,7 @@
// The offset from the start of the binary to the start of the string table.
intptr_t string_table_offset_;
+ const ExternalTypedData* typed_data_;
const uint8_t* kernel_data_;
intptr_t kernel_data_size_;
diff --git a/runtime/vm/kernel_binary.cc b/runtime/vm/kernel_binary.cc
index 50e5e42..c1103d1 100644
--- a/runtime/vm/kernel_binary.cc
+++ b/runtime/vm/kernel_binary.cc
@@ -124,6 +124,7 @@
std::unique_ptr<Program> program(new Program());
program->binary_version_ = formatVersion;
+ program->typed_data_ = reader->typed_data();
program->kernel_data_ = reader->buffer();
program->kernel_data_size_ = reader->size();
diff --git a/runtime/vm/kernel_loader.cc b/runtime/vm/kernel_loader.cc
index cfca523..97eebb3 100644
--- a/runtime/vm/kernel_loader.cc
+++ b/runtime/vm/kernel_loader.cc
@@ -204,7 +204,8 @@
program_->kernel_data_size(),
0),
type_translator_(&helper_, &active_class_, /* finalize= */ false),
- inferred_type_metadata_helper_(&helper_),
+ constant_reader_(&helper_, &active_class_),
+ inferred_type_metadata_helper_(&helper_, &constant_reader_),
bytecode_metadata_helper_(&helper_, &active_class_),
external_name_class_(Class::Handle(Z)),
external_name_field_(Field::Handle(Z)),
@@ -418,6 +419,8 @@
kernel_program_info_ = KernelProgramInfo::New(
offsets, data, names, metadata_payloads, metadata_mappings,
constants_table, scripts, libraries_cache, classes_cache,
+ program_->typed_data() == nullptr ? Object::null_object()
+ : *program_->typed_data(),
program_->binary_version());
H.InitFromKernelProgramInfo(kernel_program_info_);
@@ -450,7 +453,8 @@
translation_helper_(this, thread_, Heap::kOld),
helper_(zone_, &translation_helper_, script, kernel_data, 0),
type_translator_(&helper_, &active_class_, /* finalize= */ false),
- inferred_type_metadata_helper_(&helper_),
+ constant_reader_(&helper_, &active_class_),
+ inferred_type_metadata_helper_(&helper_, &constant_reader_),
bytecode_metadata_helper_(&helper_, &active_class_),
external_name_class_(Class::Handle(Z)),
external_name_field_(Field::Handle(Z)),
@@ -948,6 +952,7 @@
void KernelLoader::CheckForInitializer(const Field& field) {
if (helper_.PeekTag() == kSomething) {
+ field.set_has_initializer(true);
SimpleExpressionConverter converter(&H, &helper_);
const bool has_simple_initializer =
converter.IsSimple(helper_.ReaderOffset() + 1);
@@ -956,6 +961,7 @@
return;
}
}
+ field.set_has_initializer(false);
field.set_has_nontrivial_initializer(false);
}
@@ -1181,12 +1187,11 @@
const bool is_late = field_helper.IsLate();
const bool is_extension_member = field_helper.IsExtensionMember();
const Field& field = Field::Handle(
- Z,
- Field::NewTopLevel(name, is_final, field_helper.IsConst(), script_class,
- field_helper.position_, field_helper.end_position_));
+ Z, Field::NewTopLevel(name, is_final, field_helper.IsConst(), is_late,
+ script_class, field_helper.position_,
+ field_helper.end_position_));
field.set_kernel_offset(field_offset);
field.set_has_pragma(has_pragma_annotation);
- field.set_is_late(is_late);
field.set_is_extension_member(is_extension_member);
const AbstractType& type = T.BuildType(); // read type.
field.SetFieldType(type);
@@ -1535,16 +1540,15 @@
const bool is_late = field_helper.IsLate();
const bool is_extension_member = field_helper.IsExtensionMember();
Field& field = Field::Handle(
- Z,
- Field::New(name, field_helper.IsStatic(), is_final,
- field_helper.IsConst(), is_reflectable, script_class, type,
- field_helper.position_, field_helper.end_position_));
+ Z, Field::New(name, field_helper.IsStatic(), is_final,
+ field_helper.IsConst(), is_reflectable, is_late,
+ script_class, type, field_helper.position_,
+ field_helper.end_position_));
field.set_kernel_offset(field_offset);
field.set_has_pragma(has_pragma_annotation);
field.set_is_covariant(field_helper.IsCovariant());
field.set_is_generic_covariant_impl(
field_helper.IsGenericCovariantImpl());
- field.set_is_late(is_late);
field.set_is_extension_member(is_extension_member);
ReadInferredType(field, field_offset + library_kernel_offset_);
CheckForInitializer(field);
@@ -1569,13 +1573,14 @@
// Add static field 'const _deleted_enum_sentinel'.
// This field does not need to be of type E.
Field& deleted_enum_sentinel = Field::ZoneHandle(Z);
- deleted_enum_sentinel = Field::New(
- Symbols::_DeletedEnumSentinel(),
- /* is_static = */ true,
- /* is_final = */ true,
- /* is_const = */ true,
- /* is_reflectable = */ false, klass, Object::dynamic_type(),
- TokenPosition::kNoSource, TokenPosition::kNoSource);
+ deleted_enum_sentinel =
+ Field::New(Symbols::_DeletedEnumSentinel(),
+ /* is_static = */ true,
+ /* is_final = */ true,
+ /* is_const = */ true,
+ /* is_reflectable = */ false,
+ /* is_late = */ false, klass, Object::dynamic_type(),
+ TokenPosition::kNoSource, TokenPosition::kNoSource);
fields_.Add(&deleted_enum_sentinel);
}
@@ -1937,11 +1942,13 @@
break;
case FunctionNodeHelper::kAsync:
function.set_modifier(RawFunction::kAsync);
- function.set_is_inlinable(!FLAG_causal_async_stacks);
+ function.set_is_inlinable(!FLAG_causal_async_stacks &&
+ !FLAG_lazy_async_stacks);
break;
case FunctionNodeHelper::kAsyncStar:
function.set_modifier(RawFunction::kAsyncGen);
- function.set_is_inlinable(!FLAG_causal_async_stacks);
+ function.set_is_inlinable(!FLAG_causal_async_stacks &&
+ !FLAG_lazy_async_stacks);
break;
default:
// no special modifier
@@ -2063,8 +2070,9 @@
void KernelLoader::GenerateFieldAccessors(const Class& klass,
const Field& field,
FieldHelper* field_helper) {
- Tag tag = helper_.PeekTag();
- if (tag == kSomething) {
+ const Tag tag = helper_.PeekTag();
+ const bool has_initializer = (tag == kSomething);
+ if (has_initializer) {
SimpleExpressionConverter converter(&H, &helper_);
const bool has_simple_initializer =
converter.IsSimple(helper_.ReaderOffset() + 1); // ignore the tag.
@@ -2087,9 +2095,7 @@
}
if (field_helper->IsStatic()) {
- bool has_initializer = (tag == kSomething);
-
- if (!has_initializer) {
+ if (!has_initializer && !field_helper->IsLate()) {
// Static fields without an initializer are implicitly initialized to
// null. We do not need a getter.
field.SetStaticValue(Instance::null_instance(), true);
@@ -2099,6 +2105,7 @@
// We do need a getter that evaluates the initializer if necessary.
field.SetStaticValue(Object::sentinel(), true);
}
+ ASSERT(field.NeedsGetter());
const String& getter_name = H.DartGetterName(field_helper->canonical_name_);
const Object& script_class =
@@ -2112,8 +2119,7 @@
field_helper->IsStatic(),
// The functions created by the parser have is_const for static fields
// that are const (not just final) and they have is_const for
- // non-static
- // fields that are final.
+ // non-static fields that are final.
field_helper->IsStatic() ? field_helper->IsConst()
: field_helper->IsFinal(),
false, // is_abstract
@@ -2130,13 +2136,13 @@
getter.set_is_extension_member(field.is_extension_member());
H.SetupFieldAccessorFunction(klass, getter, field_type);
- if (!field_helper->IsStatic() && !field_helper->IsFinal()) {
+ if (field.NeedsSetter()) {
// Only static fields can be const.
ASSERT(!field_helper->IsConst());
const String& setter_name = H.DartSetterName(field_helper->canonical_name_);
Function& setter = Function::ZoneHandle(
Z, Function::New(setter_name, RawFunction::kImplicitSetter,
- false, // is_static
+ field_helper->IsStatic(),
false, // is_const
false, // is_abstract
false, // is_external
diff --git a/runtime/vm/kernel_loader.h b/runtime/vm/kernel_loader.h
index a6f3c75..3c9431f 100644
--- a/runtime/vm/kernel_loader.h
+++ b/runtime/vm/kernel_loader.h
@@ -9,6 +9,7 @@
#include "vm/bit_vector.h"
#include "vm/compiler/frontend/bytecode_reader.h"
+#include "vm/compiler/frontend/constant_reader.h"
#include "vm/compiler/frontend/kernel_translation_helper.h"
#include "vm/hash_map.h"
#include "vm/kernel.h"
@@ -333,6 +334,7 @@
void GenerateFieldAccessors(const Class& klass,
const Field& field,
FieldHelper* field_helper);
+ bool FieldNeedsSetter(FieldHelper* field_helper);
void LoadLibraryImportsAndExports(Library* library,
const Class& toplevel_class);
@@ -405,6 +407,7 @@
BuildingTranslationHelper translation_helper_;
KernelReaderHelper helper_;
TypeTranslator type_translator_;
+ ConstantReader constant_reader_;
InferredTypeMetadataHelper inferred_type_metadata_helper_;
BytecodeMetadataHelper bytecode_metadata_helper_;
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index b03021b..7f2d30a 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -3698,8 +3698,7 @@
}
static RawObject* EvaluateCompiledExpressionHelper(
- const uint8_t* kernel_bytes,
- intptr_t kernel_length,
+ const ExternalTypedData& kernel_buffer,
const Array& type_definitions,
const String& library_url,
const String& klass,
@@ -3707,8 +3706,7 @@
const TypeArguments& type_arguments);
RawObject* Class::EvaluateCompiledExpression(
- const uint8_t* kernel_bytes,
- intptr_t kernel_length,
+ const ExternalTypedData& kernel_buffer,
const Array& type_definitions,
const Array& arguments,
const TypeArguments& type_arguments) const {
@@ -3721,7 +3719,7 @@
}
return EvaluateCompiledExpressionHelper(
- kernel_bytes, kernel_length, type_definitions,
+ kernel_buffer, type_definitions,
String::Handle(Library::Handle(library()).url()),
IsTopLevel() ? String::Handle() : String::Handle(UserVisibleName()),
arguments, type_arguments);
@@ -3836,7 +3834,11 @@
const AbstractType& field_type = Type::Handle(zone, Type::IntType());
for (size_t i = 0; i < ARRAY_SIZE(cid_fields); i++) {
field_name = Symbols::New(thread, cid_fields[i].field_name);
- field = Field::New(field_name, true, false, true, false, *this, field_type,
+ field = Field::New(field_name, /* is_static = */ true,
+ /* is_final = */ false,
+ /* is_const = */ true,
+ /* is_reflectable = */ false,
+ /* is_late = */ false, *this, field_type,
TokenPosition::kMinSource, TokenPosition::kMinSource);
value = Smi::New(cid_fields[i].cid);
field.SetStaticValue(value, true);
@@ -8748,6 +8750,7 @@
bool is_final,
bool is_const,
bool is_reflectable,
+ bool is_late,
const Object& owner,
TokenPosition token_pos,
TokenPosition end_token_pos) {
@@ -8760,13 +8763,14 @@
result.set_is_final(is_final);
result.set_is_const(is_const);
result.set_is_reflectable(is_reflectable);
+ result.set_is_late(is_late);
result.set_is_double_initialized(false);
result.set_owner(owner);
result.set_token_pos(token_pos);
result.set_end_token_pos(end_token_pos);
result.set_has_nontrivial_initializer(false);
result.set_has_initializer(false);
- result.set_is_unboxing_candidate(!is_final);
+ result.set_is_unboxing_candidate(!is_final && !is_late);
result.set_initializer_changed_after_initialization(false);
NOT_IN_PRECOMPILED(result.set_is_declared_in_bytecode(false));
NOT_IN_PRECOMPILED(result.set_binary_declaration_offset(0));
@@ -8802,6 +8806,7 @@
bool is_final,
bool is_const,
bool is_reflectable,
+ bool is_late,
const Object& owner,
const AbstractType& type,
TokenPosition token_pos,
@@ -8809,7 +8814,7 @@
ASSERT(!owner.IsNull());
const Field& result = Field::Handle(Field::New());
InitializeNew(result, name, is_static, is_final, is_const, is_reflectable,
- owner, token_pos, end_token_pos);
+ is_late, owner, token_pos, end_token_pos);
result.SetFieldType(type);
return result.raw();
}
@@ -8817,6 +8822,7 @@
RawField* Field::NewTopLevel(const String& name,
bool is_final,
bool is_const,
+ bool is_late,
const Object& owner,
TokenPosition token_pos,
TokenPosition end_token_pos) {
@@ -8824,7 +8830,7 @@
const Field& result = Field::Handle(Field::New());
InitializeNew(result, name, true, /* is_static */
is_final, is_const, true, /* is_reflectable */
- owner, token_pos, end_token_pos);
+ is_late, owner, token_pos, end_token_pos);
return result.raw();
}
@@ -8887,18 +8893,50 @@
ASSERT(guarded_list_length_in_object_offset() == list_length_offset);
}
+bool Field::NeedsSetter() const {
+ // Late fields always need a setter, unless they're static and non-final.
+ if (is_late()) {
+ if (is_static() && !is_final()) {
+ return false;
+ }
+ return true;
+ }
+
+ // Non-late static fields never need a setter.
+ if (is_static()) {
+ return false;
+ }
+
+ // Otherwise, the field only needs a setter if it isn't final.
+ return !is_final();
+}
+
+bool Field::NeedsGetter() const {
+ // All instance fields need a getter.
+ if (!is_static()) return true;
+
+ // Static fields also need a getter if they have a non-trivial initializer,
+ // because it needs to be initialized lazily.
+ if (has_nontrivial_initializer()) return true;
+
+ // Static late fields with no initializer also need a getter, to check if it's
+ // been initialized.
+ return is_late() && !has_initializer();
+}
+
const char* Field::ToCString() const {
if (IsNull()) {
return "Field: null";
}
const char* kF0 = is_static() ? " static" : "";
- const char* kF1 = is_final() ? " final" : "";
- const char* kF2 = is_const() ? " const" : "";
+ const char* kF1 = is_late() ? " late" : "";
+ const char* kF2 = is_final() ? " final" : "";
+ const char* kF3 = is_const() ? " const" : "";
const char* field_name = String::Handle(name()).ToCString();
const Class& cls = Class::Handle(Owner());
const char* cls_name = String::Handle(cls.Name()).ToCString();
- return OS::SCreate(Thread::Current()->zone(), "Field <%s.%s>:%s%s%s",
- cls_name, field_name, kF0, kF1, kF2);
+ return OS::SCreate(Thread::Current()->zone(), "Field <%s.%s>:%s%s%s%s",
+ cls_name, field_name, kF0, kF1, kF2, kF3);
}
// Build a closure object that gets (or sets) the contents of a static
@@ -10210,6 +10248,7 @@
Field::Handle(zone, Field::NewTopLevel(metaname,
false, // is_final
false, // is_const
+ false, // is_late
owner, token_pos, token_pos));
field.SetFieldType(Object::dynamic_type());
field.set_is_reflectable(false);
@@ -11506,14 +11545,13 @@
}
RawObject* Library::EvaluateCompiledExpression(
- const uint8_t* kernel_bytes,
- intptr_t kernel_length,
+ const ExternalTypedData& kernel_buffer,
const Array& type_definitions,
const Array& arguments,
const TypeArguments& type_arguments) const {
return EvaluateCompiledExpressionHelper(
- kernel_bytes, kernel_length, type_definitions, String::Handle(url()),
- String::Handle(), arguments, type_arguments);
+ kernel_buffer, type_definitions, String::Handle(url()), String::Handle(),
+ arguments, type_arguments);
}
void Library::InitNativeWrappersLibrary(Isolate* isolate, bool is_kernel) {
@@ -11571,8 +11609,7 @@
typedef UnorderedHashMap<LibraryLookupTraits> LibraryLookupMap;
static RawObject* EvaluateCompiledExpressionHelper(
- const uint8_t* kernel_bytes,
- intptr_t kernel_length,
+ const ExternalTypedData& kernel_buffer,
const Array& type_definitions,
const String& library_url,
const String& klass,
@@ -11586,7 +11623,7 @@
return ApiError::New(error_str);
#else
std::unique_ptr<kernel::Program> kernel_pgm =
- kernel::Program::ReadFromBuffer(kernel_bytes, kernel_length);
+ kernel::Program::ReadFromTypedData(kernel_buffer);
if (kernel_pgm == NULL) {
return ApiError::New(String::Handle(
@@ -11974,6 +12011,7 @@
Field& field = Field::Handle(Field::NewTopLevel(Symbols::TopLevel(),
false, // is_final
false, // is_const
+ false, // is_late
owner, token_pos, token_pos));
field.set_is_reflectable(false);
field.SetFieldType(Object::dynamic_type());
@@ -12154,6 +12192,7 @@
const Array& scripts,
const Array& libraries_cache,
const Array& classes_cache,
+ const Object& retained_kernel_blob,
const uint32_t binary_version) {
const KernelProgramInfo& info =
KernelProgramInfo::Handle(KernelProgramInfo::New());
@@ -12168,6 +12207,8 @@
info.StorePointer(&info.raw_ptr()->constants_table_, constants_table.raw());
info.StorePointer(&info.raw_ptr()->libraries_cache_, libraries_cache.raw());
info.StorePointer(&info.raw_ptr()->classes_cache_, classes_cache.raw());
+ info.StorePointer(&info.raw_ptr()->retained_kernel_blob_,
+ retained_kernel_blob.raw());
info.set_kernel_binary_version(binary_version);
return info.raw();
}
@@ -14894,7 +14935,7 @@
#endif
Instructions& instrs = Instructions::ZoneHandle(Instructions::New(
assembler->CodeSize(), assembler->has_single_entry_point(),
- compiler == nullptr ? 0 : compiler->UncheckedEntryOffset()));
+ assembler->UncheckedEntryOffset()));
{
// Important: if GC is triggerred at any point between Instructions::New
@@ -16441,8 +16482,7 @@
RawObject* Instance::EvaluateCompiledExpression(
const Class& method_cls,
- const uint8_t* kernel_bytes,
- intptr_t kernel_length,
+ const ExternalTypedData& kernel_buffer,
const Array& type_definitions,
const Array& arguments,
const TypeArguments& type_arguments) const {
@@ -16456,7 +16496,7 @@
}
return EvaluateCompiledExpressionHelper(
- kernel_bytes, kernel_length, type_definitions,
+ kernel_buffer, type_definitions,
String::Handle(Library::Handle(method_cls.library()).url()),
String::Handle(method_cls.UserVisibleName()), arguments_with_receiver,
type_arguments);
@@ -21654,6 +21694,18 @@
return result.raw();
}
+RawExternalTypedData* ExternalTypedData::NewFinalizeWithFree(uint8_t* data,
+ intptr_t len) {
+ ExternalTypedData& result = ExternalTypedData::Handle(ExternalTypedData::New(
+ kExternalTypedDataUint8ArrayCid, data, len, Heap::kOld));
+ result.AddFinalizer(
+ data,
+ [](void* isolate_callback_data, Dart_WeakPersistentHandle handle,
+ void* data) { free(data); },
+ len);
+ return result.raw();
+}
+
RawTypedDataView* TypedDataView::New(intptr_t class_id, Heap::Space space) {
auto& result = TypedDataView::Handle();
{
@@ -22128,10 +22180,15 @@
}
} else if (code_object.raw() == StubCode::AsynchronousGapMarker().raw()) {
buffer.AddString("<asynchronous suspension>\n");
- // The frame immediately after the asynchronous gap marker is the
- // identical to the frame above the marker. Skip the frame to enhance
- // the readability of the trace.
- i++;
+ // With lazy_async_stacks we're constructing the stack correctly
+ // (see `StackTraceUtils::CollectFramesLazy`) so there are no extra
+ // frames to skip.
+ if (!FLAG_lazy_async_stacks) {
+ // The frame immediately after the asynchronous gap marker is the
+ // identical to the frame above the marker. Skip the frame to enhance
+ // the readability of the trace.
+ i++;
+ }
} else {
intptr_t pc_offset = Smi::Value(stack_trace.PcOffsetAtFrame(i));
if (code_object.IsCode()) {
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index ba6dfb7..8402bdb 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -719,10 +719,10 @@
// isolates. They are all allocated in the non-GC'd Dart::vm_isolate_.
static RawObject* null_;
- static RawClass* class_class_; // Class of the Class vm object.
- static RawClass* dynamic_class_; // Class of the 'dynamic' type.
- static RawClass* void_class_; // Class of the 'void' type.
- static RawClass* never_class_; // Class of the 'Never' type.
+ static RawClass* class_class_; // Class of the Class vm object.
+ static RawClass* dynamic_class_; // Class of the 'dynamic' type.
+ static RawClass* void_class_; // Class of the 'void' type.
+ static RawClass* never_class_; // Class of the 'Never' type.
static RawClass* type_arguments_class_; // Class of TypeArguments vm object.
static RawClass* patch_class_class_; // Class of the PatchClass vm object.
static RawClass* function_class_; // Class of the Function vm object.
@@ -731,10 +731,10 @@
static RawClass* redirection_data_class_; // Class of RedirectionData vm obj.
static RawClass* ffi_trampoline_data_class_; // Class of FfiTrampolineData
// vm obj.
- static RawClass* field_class_; // Class of the Field vm object.
- static RawClass* script_class_; // Class of the Script vm object.
- static RawClass* library_class_; // Class of the Library vm object.
- static RawClass* namespace_class_; // Class of Namespace vm object.
+ static RawClass* field_class_; // Class of the Field vm object.
+ static RawClass* script_class_; // Class of the Script vm object.
+ static RawClass* library_class_; // Class of the Library vm object.
+ static RawClass* namespace_class_; // Class of Namespace vm object.
static RawClass* kernel_program_info_class_; // Class of KernelProgramInfo vm
// object.
static RawClass* code_class_; // Class of the Code vm object.
@@ -744,13 +744,13 @@
static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object.
static RawClass* code_source_map_class_; // Class of CodeSourceMap vm object.
static RawClass*
- compressed_stackmaps_class_; // Class of CompressedStackMaps.
- static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors.
+ compressed_stackmaps_class_; // Class of CompressedStackMaps.
+ static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors.
static RawClass* exception_handlers_class_; // Class of ExceptionHandlers.
static RawClass* deopt_info_class_; // Class of DeoptInfo.
- static RawClass* context_class_; // Class of the Context vm object.
- static RawClass* context_scope_class_; // Class of ContextScope vm object.
- static RawClass* dyncalltypecheck_class_; // Class of ParameterTypeCheck.
+ static RawClass* context_class_; // Class of the Context vm object.
+ static RawClass* context_scope_class_; // Class of ContextScope vm object.
+ static RawClass* dyncalltypecheck_class_; // Class of ParameterTypeCheck.
static RawClass* singletargetcache_class_; // Class of SingleTargetCache.
static RawClass* unlinkedcall_class_; // Class of UnlinkedCall.
static RawClass* icdata_class_; // Class of ICData.
@@ -1374,8 +1374,7 @@
// (type_)param_names, and is invoked with the (type)argument values given in
// (type_)param_values.
RawObject* EvaluateCompiledExpression(
- const uint8_t* kernel_bytes,
- intptr_t kernel_length,
+ const ExternalTypedData& kernel_buffer,
const Array& type_definitions,
const Array& param_values,
const TypeArguments& type_param_values) const;
@@ -2505,6 +2504,10 @@
return IsClosureFunction() || IsFfiTrampoline();
}
+ bool HasThisParameter() const {
+ return IsDynamicFunction() || IsGenerativeConstructor();
+ }
+
bool IsDynamicFunction(bool allow_abstract = false) const {
if (is_static() || (!allow_abstract && is_abstract())) {
return false;
@@ -3600,6 +3603,7 @@
bool is_final,
bool is_const,
bool is_reflectable,
+ bool is_late,
const Object& owner,
const AbstractType& type,
TokenPosition token_pos,
@@ -3608,6 +3612,7 @@
static RawField* NewTopLevel(const String& name,
bool is_final,
bool is_const,
+ bool is_late,
const Object& owner,
TokenPosition token_pos,
TokenPosition end_token_pos);
@@ -3719,6 +3724,9 @@
return r;
}
+ bool NeedsSetter() const;
+ bool NeedsGetter() const;
+
const char* GuardedPropertiesAsCString() const;
intptr_t UnboxedFieldCid() const { return guarded_cid(); }
@@ -3848,6 +3856,7 @@
bool is_final,
bool is_const,
bool is_reflectable,
+ bool is_late,
const Object& owner,
TokenPosition token_pos,
TokenPosition end_token_pos);
@@ -4147,8 +4156,7 @@
// parameters given in (type_)param_names, and is invoked with the (type)
// argument values given in (type_)param_values.
RawObject* EvaluateCompiledExpression(
- const uint8_t* kernel_bytes,
- intptr_t kernel_length,
+ const ExternalTypedData& kernel_buffer,
const Array& type_definitions,
const Array& param_values,
const TypeArguments& type_param_values) const;
@@ -4574,6 +4582,7 @@
const Array& scripts,
const Array& libraries_cache,
const Array& classes_cache,
+ const Object& retained_kernel_blob,
const uint32_t binary_version);
static intptr_t InstanceSize() {
@@ -5590,7 +5599,7 @@
intptr_t pc_offset,
GrowableArray<const Function*>* functions,
GrowableArray<TokenPosition>* token_positions) const;
- // Same as above, expect the pc is interpreted as a return address (as needed
+ // Same as above, except the pc is interpreted as a return address (as needed
// for a stack trace or the bottom frames of a profiler sample).
void GetInlinedFunctionsAtReturnAddress(
intptr_t pc_offset,
@@ -5845,8 +5854,8 @@
friend class CodeDeserializationCluster;
friend class StubCode; // for set_object_pool
friend class MegamorphicCacheTable; // for set_object_pool
- friend class CodePatcher; // for set_instructions
- friend class ProgramVisitor; // for set_instructions
+ friend class CodePatcher; // for set_instructions
+ friend class ProgramVisitor; // for set_instructions
// So that the RawFunction pointer visitor can determine whether code the
// function points to is optimized.
friend class RawFunction;
@@ -6028,6 +6037,10 @@
static const intptr_t kBytesPerElement = kWordSize;
static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
+ static const intptr_t kAwaitJumpVarIndex = 0;
+ static const intptr_t kAsyncCompleterIndex = 1;
+ static const intptr_t kControllerIndex = 1;
+
static intptr_t variable_offset(intptr_t context_index) {
return OFFSET_OF_RETURNED_VALUE(RawContext, data) +
(kWordSize * context_index);
@@ -6543,8 +6556,7 @@
// argument values given in (type_)param_values.
RawObject* EvaluateCompiledExpression(
const Class& method_cls,
- const uint8_t* kernel_bytes,
- intptr_t kernel_length,
+ const ExternalTypedData& kernel_buffer,
const Array& type_definitions,
const Array& param_values,
const TypeArguments& type_param_values) const;
@@ -9222,6 +9234,8 @@
intptr_t len,
Heap::Space space = Heap::kNew);
+ static RawExternalTypedData* NewFinalizeWithFree(uint8_t* data, intptr_t len);
+
static bool IsExternalTypedData(const Instance& obj) {
ASSERT(!obj.IsNull());
intptr_t cid = obj.raw()->GetClassId();
@@ -10352,8 +10366,7 @@
class TupleView {
public:
TupleView(const Array& array, intptr_t index)
- : array_(array), index_(index) {
- }
+ : array_(array), index_(index) {}
template <EnumType kElement>
typename std::tuple_element<kElement, TupleT>::type::RawObjectType* Get()
diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc
index 1b66b14..e50edab 100644
--- a/runtime/vm/object_test.cc
+++ b/runtime/vm/object_test.cc
@@ -234,7 +234,7 @@
const Array& one_fields = Array::Handle(Array::New(1));
const String& field_name = String::Handle(Symbols::New(thread, "the_field"));
const Field& field = Field::Handle(
- Field::New(field_name, false, false, false, true, one_field_class,
+ Field::New(field_name, false, false, false, true, false, one_field_class,
Object::dynamic_type(), TokenPosition::kMinSource,
TokenPosition::kMinSource));
one_fields.SetAt(0, field);
@@ -2852,7 +2852,7 @@
const String& field_name =
String::Handle(Symbols::New(Thread::Current(), name));
const Field& field = Field::Handle(Field::New(
- field_name, true, false, false, true, cls, Object::dynamic_type(),
+ field_name, true, false, false, true, false, cls, Object::dynamic_type(),
TokenPosition::kMinSource, TokenPosition::kMinSource));
return field.raw();
}
diff --git a/runtime/vm/os_thread_android.cc b/runtime/vm/os_thread_android.cc
index b8354e7..1d53af3 100644
--- a/runtime/vm/os_thread_android.cc
+++ b/runtime/vm/os_thread_android.cc
@@ -8,7 +8,8 @@
#include "vm/os_thread.h"
-#include <errno.h> // NOLINT
+#include <errno.h> // NOLINT
+#include <stdio.h>
#include <sys/time.h> // NOLINT
#include "platform/address_sanitizer.h"
@@ -119,8 +120,10 @@
uword parameter = data->parameter();
delete data;
- // Set the thread name.
- pthread_setname_np(pthread_self(), name);
+ // Set the thread name. There is 16 bytes limit on the name (including \0).
+ char truncated_name[16];
+ snprintf(truncated_name, ARRAY_SIZE(truncated_name), "%s", name);
+ pthread_setname_np(pthread_self(), truncated_name);
// Create new OSThread object and set as TLS for new thread.
OSThread* thread = OSThread::CreateOSThread();
diff --git a/runtime/vm/os_thread_linux.cc b/runtime/vm/os_thread_linux.cc
index 0003ee2..7622669 100644
--- a/runtime/vm/os_thread_linux.cc
+++ b/runtime/vm/os_thread_linux.cc
@@ -8,7 +8,8 @@
#include "vm/os_thread.h"
-#include <errno.h> // NOLINT
+#include <errno.h> // NOLINT
+#include <stdio.h>
#include <sys/resource.h> // NOLINT
#include <sys/syscall.h> // NOLINT
#include <sys/time.h> // NOLINT
@@ -121,8 +122,10 @@
uword parameter = data->parameter();
delete data;
- // Set the thread name.
- pthread_setname_np(pthread_self(), name);
+ // Set the thread name. There is 16 bytes limit on the name (including \0).
+ char truncated_name[16];
+ snprintf(truncated_name, ARRAY_SIZE(truncated_name), "%s", name);
+ pthread_setname_np(pthread_self(), truncated_name);
// Create new OSThread object and set as TLS for new thread.
OSThread* thread = OSThread::CreateOSThread();
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index ae99c87..a415a8c 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -204,9 +204,10 @@
tmp = Symbols::FromConcat(T, Symbols::OriginalParam(), variable->name());
RELEASE_ASSERT(scope->LocalLookupVariable(tmp) == NULL);
- raw_parameter =
- new LocalVariable(variable->declaration_token_pos(),
- variable->token_pos(), tmp, variable->type());
+ raw_parameter = new LocalVariable(
+ variable->declaration_token_pos(), variable->token_pos(), tmp,
+ variable->type(), variable->parameter_type(),
+ variable->parameter_value());
if (variable->is_explicit_covariant_parameter()) {
raw_parameter->set_is_explicit_covariant_parameter();
}
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index 23d384a..2a0f479 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -1287,7 +1287,8 @@
RawExternalTypedData* constants_table_;
RawArray* libraries_cache_;
RawArray* classes_cache_;
- VISIT_TO(RawObject*, classes_cache_);
+ RawObject* retained_kernel_blob_;
+ VISIT_TO(RawObject*, retained_kernel_blob_);
uint32_t kernel_binary_version_;
diff --git a/runtime/vm/raw_object_fields.cc b/runtime/vm/raw_object_fields.cc
index 079cbe7..c46b086 100644
--- a/runtime/vm/raw_object_fields.cc
+++ b/runtime/vm/raw_object_fields.cc
@@ -93,6 +93,7 @@
F(KernelProgramInfo, constants_table_) \
F(KernelProgramInfo, libraries_cache_) \
F(KernelProgramInfo, classes_cache_) \
+ F(KernelProgramInfo, retained_kernel_blob_) \
F(Code, object_pool_) \
F(Code, instructions_) \
F(Code, owner_) \
diff --git a/runtime/vm/scopes.cc b/runtime/vm/scopes.cc
index 6264031..bd68c5e 100644
--- a/runtime/vm/scopes.cc
+++ b/runtime/vm/scopes.cc
@@ -207,6 +207,42 @@
int pos = 0; // Current variable position.
VariableIndex next_index =
first_parameter_index; // Current free frame index.
+
+ LocalVariable* await_jump_var = nullptr;
+ LocalVariable* async_completer = nullptr;
+ LocalVariable* controller = nullptr;
+ for (intptr_t i = 0; i < num_variables(); i++) {
+ LocalVariable* variable = VariableAt(i);
+ if (variable->owner() == this) {
+ if (variable->is_captured()) {
+ if (variable->name().Equals(Symbols::AwaitJumpVar())) {
+ await_jump_var = variable;
+ } else if (variable->name().Equals(Symbols::AsyncCompleter())) {
+ async_completer = variable;
+ } else if (variable->name().Equals(Symbols::Controller())) {
+ controller = variable;
+ }
+ }
+ }
+ }
+ // If we are in an async/async* function, force :await_jump_var and
+ // :async_completer_var to be at fixed locations in the slot.
+ if (await_jump_var != nullptr) {
+ AllocateContextVariable(await_jump_var, &context_owner);
+ *found_captured_variables = true;
+ ASSERT(await_jump_var->index().value() == Context::kAwaitJumpVarIndex);
+ }
+ if (async_completer != nullptr) {
+ AllocateContextVariable(async_completer, &context_owner);
+ *found_captured_variables = true;
+ ASSERT(async_completer->index().value() == Context::kAsyncCompleterIndex);
+ }
+ if (controller != nullptr) {
+ AllocateContextVariable(controller, &context_owner);
+ *found_captured_variables = true;
+ ASSERT(controller->index().value() == Context::kControllerIndex);
+ }
+
while (pos < num_parameters) {
LocalVariable* parameter = VariableAt(pos);
pos++;
@@ -234,8 +270,12 @@
LocalVariable* variable = VariableAt(pos);
if (variable->owner() == this) {
if (variable->is_captured()) {
- AllocateContextVariable(variable, &context_owner);
- *found_captured_variables = true;
+ // Skip the two variables already pre-allocated above.
+ if (variable != await_jump_var && variable != async_completer &&
+ variable != controller) {
+ AllocateContextVariable(variable, &context_owner);
+ *found_captured_variables = true;
+ }
} else {
variable->set_index(next_index);
next_index = VariableIndex(next_index.value() - 1);
diff --git a/runtime/vm/scopes.h b/runtime/vm/scopes.h
index 69e8510..46c2de5 100644
--- a/runtime/vm/scopes.h
+++ b/runtime/vm/scopes.h
@@ -76,13 +76,15 @@
TokenPosition token_pos,
const String& name,
const AbstractType& type,
- CompileType* parameter_type = NULL)
+ CompileType* parameter_type = nullptr,
+ const Object* parameter_value = nullptr)
: declaration_pos_(declaration_pos),
token_pos_(token_pos),
name_(name),
owner_(NULL),
type_(type),
parameter_type_(parameter_type),
+ parameter_value_(parameter_value),
const_value_(NULL),
is_final_(false),
is_captured_(false),
@@ -109,6 +111,7 @@
const AbstractType& type() const { return type_; }
CompileType* parameter_type() const { return parameter_type_; }
+ const Object* parameter_value() const { return parameter_value_; }
bool is_final() const { return is_final_; }
void set_is_final() { is_final_ = true; }
@@ -198,6 +201,7 @@
const AbstractType& type_; // Declaration type of local variable.
CompileType* const parameter_type_; // NULL or incoming parameter type.
+ const Object* parameter_value_; // NULL or incoming parameter value.
const Instance* const_value_; // NULL or compile-time const value.
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index a90b073..02c49f9 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -2870,6 +2870,12 @@
NULL,
};
+RawExternalTypedData* DecodeKernelBuffer(const char* kernel_buffer_base64) {
+ intptr_t kernel_length;
+ uint8_t* kernel_buffer = DecodeBase64(kernel_buffer_base64, &kernel_length);
+ return ExternalTypedData::NewFinalizeWithFree(kernel_buffer, kernel_length);
+}
+
static bool EvaluateCompiledExpression(Thread* thread, JSONStream* js) {
if (CheckDebuggerDisabled(thread, js)) {
return true;
@@ -2898,9 +2904,8 @@
const GrowableObjectArray& type_params_names =
GrowableObjectArray::Handle(zone, GrowableObjectArray::New());
- intptr_t kernel_length;
- const char* kernel_bytes_str = js->LookupParam("kernelBytes");
- uint8_t* kernel_bytes = DecodeBase64(zone, kernel_bytes_str, &kernel_length);
+ const ExternalTypedData& kernel_data = ExternalTypedData::Handle(
+ zone, DecodeKernelBuffer(js->LookupParam("kernelBytes")));
if (js->HasParam("frameIndex")) {
DebuggerStackTrace* stack = isolate->debugger()->StackTrace();
@@ -2918,7 +2923,7 @@
const Object& result = Object::Handle(
zone,
frame->EvaluateCompiledExpression(
- kernel_bytes, kernel_length,
+ kernel_data,
Array::Handle(zone, Array::MakeFixedLength(type_params_names)),
Array::Handle(zone, Array::MakeFixedLength(param_values)),
type_arguments));
@@ -2951,7 +2956,7 @@
const Object& result = Object::Handle(
zone,
lib.EvaluateCompiledExpression(
- kernel_bytes, kernel_length,
+ kernel_data,
Array::Handle(zone, Array::MakeFixedLength(type_params_names)),
Array::Handle(zone, Array::MakeFixedLength(param_values)),
type_arguments));
@@ -2963,7 +2968,7 @@
const Object& result = Object::Handle(
zone,
cls.EvaluateCompiledExpression(
- kernel_bytes, kernel_length,
+ kernel_data,
Array::Handle(zone, Array::MakeFixedLength(type_params_names)),
Array::Handle(zone, Array::MakeFixedLength(param_values)),
type_arguments));
@@ -2978,7 +2983,7 @@
const Object& result = Object::Handle(
zone,
instance.EvaluateCompiledExpression(
- receiver_cls, kernel_bytes, kernel_length,
+ receiver_cls, kernel_data,
Array::Handle(zone, Array::MakeFixedLength(type_params_names)),
Array::Handle(zone, Array::MakeFixedLength(param_values)),
type_arguments));
diff --git a/runtime/vm/service/service.md b/runtime/vm/service/service.md
index 671d781..e8648c2 100644
--- a/runtime/vm/service/service.md
+++ b/runtime/vm/service/service.md
@@ -11,6 +11,10 @@
but this does not allow access to VM _events_ and is not documented
here.
+[Service Protocol Extension](service_extension.md) provides similar ways to
+communicate with the VM except these may be only accessible through some
+libraries.
+
The Service Protocol uses [JSON-RPC 2.0][].
[JSON-RPC 2.0]: http://www.jsonrpc.org/specification
diff --git a/runtime/vm/service/service_extension.md b/runtime/vm/service/service_extension.md
new file mode 100644
index 0000000..bdf14e4
--- /dev/null
+++ b/runtime/vm/service/service_extension.md
@@ -0,0 +1,143 @@
+# Dart VM Service Protocol Extension
+
+This protocol describes service extensions that are made available through
+the Dart core libraries, but are not part of the core
+[Dart VM Service Protocol](service.md). Service extension methods are
+invoked by prepending the service extension name (e.g.,
+"ext.dart.libraryName") to the RPC to be invoked. For example, the
+`getSocketProfile` RPC exposed through dart:io can be executed by invoking
+`ext.dart.io.getSocketProfile`.
+
+## dart:io Extensions
+
+This section describes _version 1.0_ of the dart:io service protocol extensions.
+
+### getVersion
+
+```
+Version getVersion()
+```
+
+The _getVersion_ RPC returns the available version of the dart:io service protocol extensions.
+
+See [Version](#version).
+
+### startSocketProfiling
+
+```
+Success startSocketProfiling()
+```
+
+Start profiling new socket connections. Statistics for sockets created before profiling was enabled will not be recorded.
+
+See [Success](#success).
+
+### pauseSocketProfiling
+
+```
+Success pauseSocketProfiling()
+```
+
+Pause recording socket statistics. [clearSocketProfile](#clearsocketprofile) must be called in order for collected statistics to be cleared.
+
+See [Success](#success).
+
+### clearSocketProfile
+
+```
+Success clearSocketProfile()
+```
+
+Removes all statistics associated with prior and current sockets.
+
+See [Success](#success).
+
+### getSocketProfile
+
+```
+SocketProfile getSocketProfile()
+```
+
+The _getSocketProfile_ RPC is used to retrieve socket statistics collected by
+the socket profiler. Only samples collected after the initial [startSocketProfiling](#startsocketprofiling) or the last call to [clearSocketProfile](#clearsocketprofile) will be reported.
+
+## Public Types
+
+### Response
+
+```
+class Response {
+ // Every response returned by the VM Service has the
+ // type property. This allows the client distinguish
+ // between different kinds of responses.
+ string type;
+}
+```
+
+### SocketProfile
+
+```
+class SocketProfile extends Response {
+ // List of socket statistics
+ SocketStatistic[] sockets;
+}
+```
+
+A _SocketProfile_ provides information about statistics of sockets.
+See [getSocketProfile](#getSocketProfile) and
+[SocketStatistic](#SocketStatistic).
+
+### SocketStatistic
+
+```
+class SocketStatistic {
+ // The unique ID associated with this socket.
+ int id;
+
+ // The time, in microseconds, that this socket was created.
+ int startTime;
+
+ // The time, in microseconds, that this socket was closed.
+ int endTime [optional];
+
+ // The address of socket.
+ String address;
+
+ // The port of socket.
+ int port;
+
+ // The type of socket. The value is `tcp` or `udp`.
+ String socketType;
+
+ // The number of bytes read from this socket.
+ int readBytes;
+
+ // The number of bytes written to this socket.
+ int writeBytes;
+}
+```
+
+See [SocketProfile](#SocketProfile) and [getSocketProfile](#getSocketProfile).
+
+### Success
+
+```
+class Success extends Response {
+}
+```
+
+The _Success_ type is used to indicate that an operation completed successfully.
+
+### Version
+
+```
+class Version extends Response {
+ // The major version number is incremented when the protocol is changed
+ // in a potentially incompatible way.
+ int major;
+
+ // The minor version number is incremented when the protocol is changed
+ // in a backwards compatible way.
+ int minor;
+}
+```
\ No newline at end of file
diff --git a/runtime/vm/stack_trace.cc b/runtime/vm/stack_trace.cc
index 449c323..9581646 100644
--- a/runtime/vm/stack_trace.cc
+++ b/runtime/vm/stack_trace.cc
@@ -3,11 +3,399 @@
// BSD-style license that can be found in the LICENSE file.
#include "vm/stack_trace.h"
+
+#include "vm/compiler/frontend/bytecode_reader.h"
+#include "vm/dart_api_impl.h"
#include "vm/stack_frame.h"
#include "vm/symbols.h"
namespace dart {
+// Keep in sync with
+// sdk/lib/async/stream_controller.dart:_StreamController._STATE_SUBSCRIBED.
+const intptr_t kStreamController_StateSubscribed = 1;
+
+RawClosure* FindClosureInFrame(RawObject** last_object_in_caller,
+ const Function& function,
+ bool is_interpreted) {
+ NoSafepointScope nsp;
+
+ // The callee has function signature
+ // :async_op([result, exception, stack])
+ // So we are guaranteed to
+ // a) have only tagged arguments on the stack until we find the :async_op
+ // closure, and
+ // b) find the async closure.
+ auto& closure = Closure::Handle();
+ for (intptr_t i = 0; i < 4; i++) {
+ // KBC builds the stack upwards instead of the usual downwards stack.
+ RawObject* arg = last_object_in_caller[(is_interpreted ? -i : i)];
+ if (arg->IsHeapObject() && arg->GetClassId() == kClosureCid) {
+ closure = Closure::RawCast(arg);
+ if (closure.function() == function.raw()) {
+ return closure.raw();
+ }
+ }
+ }
+ UNREACHABLE();
+}
+
+// Find current yield index from async closure.
+// Async closures contains a variable, :await_jump_var that holds the index into
+// async wrapper.
+intptr_t GetYieldIndex(const Closure& receiver_closure) {
+ const auto& function = Function::Handle(receiver_closure.function());
+ if (!function.IsAsyncClosure() && !function.IsAsyncGenClosure()) {
+ return RawPcDescriptors::kInvalidYieldIndex;
+ }
+ const auto& await_jump_var =
+ Object::Handle(Context::Handle(receiver_closure.context())
+ .At(Context::kAwaitJumpVarIndex));
+ ASSERT(await_jump_var.IsSmi());
+ return Smi::Cast(await_jump_var).Value();
+}
+
+intptr_t FindPcOffset(const PcDescriptors& pc_descs, intptr_t yield_index) {
+ if (yield_index == RawPcDescriptors::kInvalidYieldIndex) {
+ return 0;
+ }
+ PcDescriptors::Iterator iter(pc_descs, RawPcDescriptors::kAnyKind);
+ while (iter.MoveNext()) {
+ if (iter.YieldIndex() == yield_index) {
+ return iter.PcOffset();
+ }
+ }
+ UNREACHABLE(); // If we cannot find it we have a bug.
+}
+
+#if !defined(DART_PRECOMPILED_RUNTIME)
+intptr_t FindPcOffset(const Bytecode& bytecode, intptr_t yield_index) {
+ if (yield_index == RawPcDescriptors::kInvalidYieldIndex) {
+ return 0;
+ }
+ intptr_t last_yield_point = 0;
+ kernel::BytecodeSourcePositionsIterator iter(Thread::Current()->zone(),
+ bytecode);
+ while (iter.MoveNext()) {
+ if (iter.IsYieldPoint()) {
+ last_yield_point++;
+ }
+ if (last_yield_point == yield_index) {
+ return iter.PcOffset();
+ }
+ }
+ UNREACHABLE(); // If we cannot find it we have a bug.
+}
+#endif
+
+// Helper class for finding the closure of the caller.
+// This is done via the _AsyncAwaitCompleter which holds a
+// FutureResultOrListeners which in turn holds a callback.
+class CallerClosureFinder {
+ public:
+ // Instance caches library and field references.
+ // This way we don't have to do the look-ups for every frame in the stack.
+ explicit CallerClosureFinder(Zone* zone)
+ : receiver_context_(Context::Handle(zone)),
+ receiver_function_(Function::Handle(zone)),
+ context_entry_(Object::Handle(zone)),
+ future_(Object::Handle(zone)),
+ listener_(Object::Handle(zone)),
+ callback_(Object::Handle(zone)),
+ controller_(Object::Handle(zone)),
+ state_(Object::Handle(zone)),
+ var_data_(Object::Handle(zone)),
+ future_impl_class(Class::Handle(zone)),
+ async_await_completer_class(Class::Handle(zone)),
+ future_listener_class(Class::Handle(zone)),
+ async_start_stream_controller_class(Class::Handle(zone)),
+ stream_controller_class(Class::Handle(zone)),
+ controller_subscription_class(Class::Handle(zone)),
+ buffering_stream_subscription_class(Class::Handle(zone)),
+ async_stream_controller_class(Class::Handle(zone)),
+ completer_future_field(Field::Handle(zone)),
+ future_result_or_listeners_field(Field::Handle(zone)),
+ callback_field(Field::Handle(zone)),
+ controller_controller_field(Field::Handle(zone)),
+ var_data_field(Field::Handle(zone)),
+ state_field(Field::Handle(zone)),
+ on_data_field(Field::Handle(zone)) {
+ const auto& async_lib = Library::Handle(zone, Library::AsyncLibrary());
+ // Look up classes:
+ // - async:
+ future_impl_class =
+ async_lib.LookupClassAllowPrivate(Symbols::FutureImpl());
+ ASSERT(!future_impl_class.IsNull());
+ async_await_completer_class =
+ async_lib.LookupClassAllowPrivate(Symbols::_AsyncAwaitCompleter());
+ ASSERT(!async_await_completer_class.IsNull());
+ future_listener_class =
+ async_lib.LookupClassAllowPrivate(Symbols::_FutureListener());
+ ASSERT(!future_listener_class.IsNull());
+ // - async*:
+ async_start_stream_controller_class = async_lib.LookupClassAllowPrivate(
+ Symbols::_AsyncStarStreamController());
+ ASSERT(!async_start_stream_controller_class.IsNull());
+ stream_controller_class =
+ async_lib.LookupClassAllowPrivate(Symbols::_StreamController());
+ ASSERT(!stream_controller_class.IsNull());
+ async_stream_controller_class =
+ async_lib.LookupClassAllowPrivate(Symbols::_AsyncStreamController());
+ ASSERT(!async_stream_controller_class.IsNull());
+ controller_subscription_class =
+ async_lib.LookupClassAllowPrivate(Symbols::_ControllerSubscription());
+ ASSERT(!controller_subscription_class.IsNull());
+ buffering_stream_subscription_class = async_lib.LookupClassAllowPrivate(
+ Symbols::_BufferingStreamSubscription());
+ ASSERT(!buffering_stream_subscription_class.IsNull());
+
+ // Look up fields:
+ // - async:
+ completer_future_field =
+ async_await_completer_class.LookupFieldAllowPrivate(Symbols::_future());
+ ASSERT(!completer_future_field.IsNull());
+ future_result_or_listeners_field =
+ future_impl_class.LookupFieldAllowPrivate(
+ Symbols::_resultOrListeners());
+ ASSERT(!future_result_or_listeners_field.IsNull());
+ callback_field =
+ future_listener_class.LookupFieldAllowPrivate(Symbols::callback());
+ ASSERT(!callback_field.IsNull());
+ // - async*:
+ controller_controller_field =
+ async_start_stream_controller_class.LookupFieldAllowPrivate(
+ Symbols::controller());
+ ASSERT(!controller_controller_field.IsNull());
+ state_field =
+ stream_controller_class.LookupFieldAllowPrivate(Symbols::_state());
+ ASSERT(!state_field.IsNull());
+ var_data_field =
+ stream_controller_class.LookupFieldAllowPrivate(Symbols::_varData());
+ ASSERT(!var_data_field.IsNull());
+ on_data_field = buffering_stream_subscription_class.LookupFieldAllowPrivate(
+ Symbols::_onData());
+ ASSERT(!on_data_field.IsNull());
+ }
+
+ RawClosure* FindCallerInAsyncClosure(const Context& receiver_context) {
+ context_entry_ = receiver_context.At(Context::kAsyncCompleterIndex);
+ ASSERT(context_entry_.IsInstance());
+ ASSERT(context_entry_.GetClassId() == async_await_completer_class.id());
+
+ const Instance& completer = Instance::Cast(context_entry_);
+ future_ = completer.GetField(completer_future_field);
+ ASSERT(!future_.IsNull());
+ ASSERT(future_.GetClassId() == future_impl_class.id());
+
+ listener_ =
+ Instance::Cast(future_).GetField(future_result_or_listeners_field);
+ if (listener_.GetClassId() != future_listener_class.id()) {
+ return Closure::null();
+ }
+
+ callback_ = Instance::Cast(listener_).GetField(callback_field);
+ // This happens for e.g.: await f().catchError(..);
+ if (callback_.IsNull()) {
+ return Closure::null();
+ }
+ ASSERT(callback_.IsClosure());
+
+ return Closure::Cast(callback_).raw();
+ }
+
+ RawClosure* FindCallerInAsyncGenClosure(const Context& receiver_context) {
+ context_entry_ = receiver_context.At(Context::kControllerIndex);
+ ASSERT(context_entry_.IsInstance());
+ ASSERT(context_entry_.GetClassId() ==
+ async_start_stream_controller_class.id());
+
+ const Instance& controller = Instance::Cast(context_entry_);
+ controller_ = controller.GetField(controller_controller_field);
+ ASSERT(!controller_.IsNull());
+ ASSERT(controller_.GetClassId() == async_stream_controller_class.id());
+
+ state_ = Instance::Cast(controller_).GetField(state_field);
+ ASSERT(state_.IsSmi());
+ if (Smi::Cast(state_).Value() != kStreamController_StateSubscribed) {
+ return Closure::null();
+ }
+
+ var_data_ = Instance::Cast(controller_).GetField(var_data_field);
+ ASSERT(var_data_.GetClassId() == controller_subscription_class.id());
+
+ callback_ = Instance::Cast(var_data_).GetField(on_data_field);
+ ASSERT(callback_.IsClosure());
+
+ return Closure::Cast(callback_).raw();
+ }
+
+ RawClosure* FindCaller(const Closure& receiver_closure) {
+ receiver_function_ = receiver_closure.function();
+ receiver_context_ = receiver_closure.context();
+
+ if (receiver_function_.IsAsyncClosure()) {
+ return FindCallerInAsyncClosure(receiver_context_);
+ } else if (receiver_function_.IsAsyncGenClosure()) {
+ return FindCallerInAsyncGenClosure(receiver_context_);
+ }
+
+ return Closure::null();
+ }
+
+ private:
+ Context& receiver_context_;
+ Function& receiver_function_;
+
+ Object& context_entry_;
+ Object& future_;
+ Object& listener_;
+ Object& callback_;
+ Object& controller_;
+ Object& state_;
+ Object& var_data_;
+
+ Class& future_impl_class;
+ Class& async_await_completer_class;
+ Class& future_listener_class;
+ Class& async_start_stream_controller_class;
+ Class& stream_controller_class;
+ Class& controller_subscription_class;
+ Class& buffering_stream_subscription_class;
+ Class& async_stream_controller_class;
+
+ Field& completer_future_field;
+ Field& future_result_or_listeners_field;
+ Field& callback_field;
+ Field& controller_controller_field;
+ Field& var_data_field;
+ Field& state_field;
+ Field& on_data_field;
+};
+
+void StackTraceUtils::CollectFramesLazy(
+ Thread* thread,
+ const GrowableObjectArray& code_array,
+ const GrowableObjectArray& pc_offset_array,
+ int skip_frames) {
+ Zone* zone = thread->zone();
+ DartFrameIterator frames(thread, StackFrameIterator::kNoCrossThreadIteration);
+ StackFrame* frame = frames.NextFrame();
+ ASSERT(frame != nullptr); // We expect to find a dart invocation frame.
+ auto& function = Function::Handle(zone);
+ auto& code = Code::Handle(zone);
+ auto& bytecode = Bytecode::Handle(zone);
+ auto& offset = Smi::Handle(zone);
+
+ auto& closure = Closure::Handle(zone);
+ CallerClosureFinder caller_closure_finder(zone);
+ auto& pc_descs = PcDescriptors::Handle();
+
+ for (; frame != nullptr;) {
+ if (skip_frames > 0) {
+ skip_frames--;
+ frame = frames.NextFrame();
+ continue;
+ }
+
+ function = frame->LookupDartFunction();
+
+ // Case 1: This is an async frame; Follow callbacks instead of stack.
+ if (function.IsAsyncClosure() || function.IsAsyncGenClosure()) {
+ // Start by adding the async function in the frame.
+ if (frame->is_interpreted()) {
+ bytecode = frame->LookupDartBytecode();
+ ASSERT(function.raw() == bytecode.function());
+ code_array.Add(bytecode);
+ const intptr_t pc_offset = frame->pc() - bytecode.PayloadStart();
+ ASSERT(pc_offset >= 0 && pc_offset < bytecode.Size());
+ offset = Smi::New(pc_offset);
+ } else {
+ code = frame->LookupDartCode();
+ ASSERT(function.raw() == code.function());
+ code_array.Add(code);
+ offset = Smi::New(frame->pc() - code.PayloadStart());
+ }
+ pc_offset_array.Add(offset);
+
+ // Next, look up caller's closure on the stack and walk backwards through
+ // the yields.
+ frame = frames.NextFrame();
+ RawObject** last_caller_obj = reinterpret_cast<RawObject**>(frame->sp());
+ closure = FindClosureInFrame(last_caller_obj, function,
+ frame->is_interpreted());
+
+ // If this async function hasn't yielded yet, we're still dealing with a
+ // normal stack. Continue to next frame as usual.
+ if (GetYieldIndex(closure) <= 0) {
+ // Don't advance frame since we already did so just above.
+ continue;
+ }
+
+ // Inject async suspension marker.
+ code_array.Add(StubCode::AsynchronousGapMarker());
+ offset = Smi::New(0);
+ pc_offset_array.Add(offset);
+
+ // Skip: Already handled this frame's function above.
+ closure = caller_closure_finder.FindCaller(closure);
+
+ for (; !closure.IsNull();
+ closure = caller_closure_finder.FindCaller(closure)) {
+ function = closure.function();
+ // In hot-reload-test-mode we sometimes have to do this:
+ if (!function.HasCode() && !function.HasBytecode()) {
+ function.EnsureHasCode();
+ }
+ if (function.HasBytecode()) {
+#if !defined(DART_PRECOMPILED_RUNTIME)
+ bytecode = function.bytecode();
+ code_array.Add(bytecode);
+ offset = Smi::New(FindPcOffset(bytecode, GetYieldIndex(closure)));
+#else
+ UNREACHABLE();
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+ } else if (function.HasCode()) {
+ code = function.CurrentCode();
+ code_array.Add(code);
+ pc_descs = code.pc_descriptors();
+ offset = Smi::New(FindPcOffset(pc_descs, GetYieldIndex(closure)));
+ } else {
+ UNREACHABLE();
+ }
+ ASSERT(offset.Value() >= 0);
+ pc_offset_array.Add(offset);
+ // Inject async suspension marker.
+ code_array.Add(StubCode::AsynchronousGapMarker());
+ offset = Smi::New(0);
+ pc_offset_array.Add(offset);
+ }
+
+ // Ignore the rest of the stack; already unwound all async calls.
+ return;
+ } else {
+ // Case 2: This is a sync frame; handle normally.
+
+ if (frame->is_interpreted()) {
+ bytecode = frame->LookupDartBytecode();
+ ASSERT(function.raw() == bytecode.function());
+ code_array.Add(bytecode);
+ offset = Smi::New(frame->pc() - bytecode.PayloadStart());
+ pc_offset_array.Add(offset);
+ } else {
+ code = frame->LookupDartCode();
+ ASSERT(function.raw() == code.function());
+ code_array.Add(code);
+ offset = Smi::New(frame->pc() - code.PayloadStart());
+ pc_offset_array.Add(offset);
+ }
+ }
+
+ frame = frames.NextFrame();
+ }
+
+ return;
+}
+
// Count the number of frames that are on the stack.
intptr_t StackTraceUtils::CountFrames(Thread* thread,
int skip_frames,
diff --git a/runtime/vm/stack_trace.h b/runtime/vm/stack_trace.h
index ea4ed29..2de8619 100644
--- a/runtime/vm/stack_trace.h
+++ b/runtime/vm/stack_trace.h
@@ -14,6 +14,24 @@
class StackTraceUtils : public AllStatic {
public:
+ /// Collects all frames on the current stack until an async/async* frame is
+ /// hit which has yielded before (i.e. is not in sync-async case).
+ ///
+ /// From there on finds the closure of the async/async* frame and starts
+ /// traversing the listeners:
+ /// while (closure != null) {
+ /// yield_index = closure.context[Context::kAsyncJumpVarIndex]
+ /// pc = closure.function.code.pc_descriptors.LookupPcFromYieldIndex(
+ /// yield_index);
+ /// <emit pc in frame>
+ /// closure = closure.context[Context::kAsyncCompleterVarIndex]._future
+ /// ._resultOrListeners.callback;
+ /// }
+ static void CollectFramesLazy(Thread* thread,
+ const GrowableObjectArray& code_array,
+ const GrowableObjectArray& pc_offset_array,
+ int skip_frames);
+
/// Counts the number of stack frames.
/// Skips over the first |skip_frames|.
/// If |async_function| is not null, stops at the function that has
diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h
index cb64951..3f47d8f 100644
--- a/runtime/vm/symbols.h
+++ b/runtime/vm/symbols.h
@@ -61,6 +61,7 @@
V(ConstructorStacktracePrefix, "new ") \
V(Context, "Context") \
V(ContextScope, "ContextScope") \
+ V(Controller, ":controller") \
V(ControllerStream, ":controller_stream") \
V(Current, "current") \
V(CurrentContextVar, ":current_context_var") \
@@ -252,6 +253,7 @@
V(StackTraceParameter, ":stack_trace") \
V(StackTraceVar, ":stack_trace_var") \
V(Stream, "stream") \
+ V(StreamController, "StreamController") \
V(StreamIterator, "StreamIterator") \
V(StreamIteratorConstructor, "StreamIterator.") \
V(StringBase, "_StringBase") \
@@ -300,7 +302,9 @@
V(_AsyncStarListenHelper, "_asyncStarListenHelper") \
V(_AsyncStarStreamController, "_AsyncStarStreamController") \
V(_AsyncStarStreamControllerConstructor, "_AsyncStarStreamController.") \
+ V(_AsyncStreamController, "_AsyncStreamController") \
V(_Awaiter, "_awaiter") \
+ V(_BufferingStreamSubscription, "_BufferingStreamSubscription") \
V(_ByteBuffer, "_ByteBuffer") \
V(_ByteBufferDot_New, "_ByteBuffer._New") \
V(_ByteDataView, "_ByteDataView") \
@@ -311,6 +315,7 @@
V(_CombinatorMirror, "_CombinatorMirror") \
V(_CompileTimeError, "_CompileTimeError") \
V(_CompleteOnAsyncReturn, "_completeOnAsyncReturn") \
+ V(_ControllerSubscription, "_ControllerSubscription") \
V(_DeletedEnumPrefix, "Deleted enum value from ") \
V(_DeletedEnumSentinel, "_deleted_enum_sentinel") \
V(_Double, "_Double") \
@@ -343,6 +348,7 @@
V(_Float64x2ArrayView, "_Float64x2ArrayView") \
V(_Float64x2List, "_Float64x2List") \
V(_FunctionTypeMirror, "_FunctionTypeMirror") \
+ V(_FutureListener, "_FutureListener") \
V(_GrowableList, "_GrowableList") \
V(_GrowableListFactory, "_GrowableList.") \
V(_GrowableListWithData, "_GrowableList._withData") \
@@ -385,6 +391,7 @@
V(_SourceLocation, "_SourceLocation") \
V(_SpecialTypeMirror, "_SpecialTypeMirror") \
V(_StackTrace, "_StackTrace") \
+ V(_StreamController, "_StreamController") \
V(_StreamImpl, "_StreamImpl") \
V(_String, "String") \
V(_SyncIterable, "_SyncIterable") \
@@ -417,12 +424,15 @@
V(_classRangeCheck, "_classRangeCheck") \
V(_current, "_current") \
V(_ensureScheduleImmediate, "_ensureScheduleImmediate") \
+ V(_future, "_future") \
V(_get, "_get") \
V(_handleMessage, "_handleMessage") \
V(_instanceOf, "_instanceOf") \
V(_lookupHandler, "_lookupHandler") \
V(_name, "_name") \
+ V(_onData, "_onData") \
V(_rehashObjects, "_rehashObjects") \
+ V(_resultOrListeners, "_resultOrListeners") \
V(_runExtension, "_runExtension") \
V(_runPendingImmediateCallback, "_runPendingImmediateCallback") \
V(_setLength, "_setLength") \
@@ -431,13 +441,16 @@
V(_simpleInstanceOfTrue, "_simpleInstanceOfTrue") \
V(_stackTrace, "_stackTrace") \
V(_state, "_state") \
+ V(_varData, "_varData") \
V(_wordCharacterMap, "_wordCharacterMap") \
V(add, "add") \
+ V(callback, "callback") \
V(capture_length, ":capture_length") \
V(capture_start_index, ":capture_start_index") \
V(char_in_capture, ":char_in_capture") \
V(char_in_match, ":char_in_match") \
V(clear, "clear") \
+ V(controller, "controller") \
V(current_character, ":current_character") \
V(current_position, ":current_position") \
V(getID, "getID") \
diff --git a/runtime/vm/thread_pool.cc b/runtime/vm/thread_pool.cc
index 8353648..22f62ca 100644
--- a/runtime/vm/thread_pool.cc
+++ b/runtime/vm/thread_pool.cc
@@ -335,7 +335,7 @@
ASSERT(task_ != nullptr);
}
#endif
- int result = OSThread::Start("Dart ThreadPool Worker", &Worker::Main,
+ int result = OSThread::Start("DartWorker", &Worker::Main,
reinterpret_cast<uword>(this));
if (result != 0) {
FATAL1("Could not start worker thread: result = %d.", result);
diff --git a/runtime/vm/unit_test.cc b/runtime/vm/unit_test.cc
index e6b60bb..0efeee5 100644
--- a/runtime/vm/unit_test.cc
+++ b/runtime/vm/unit_test.cc
@@ -157,13 +157,6 @@
RELEASE_ASSERT(!Dart_IsError(result));
}
-static const char* kPackageScheme = "package:";
-
-static bool IsPackageSchemeURL(const char* url_name) {
- static const intptr_t kPackageSchemeLen = strlen(kPackageScheme);
- return (strncmp(url_name, kPackageScheme, kPackageSchemeLen) == 0);
-}
-
struct TestLibEntry {
const char* url;
const char* source;
@@ -212,13 +205,6 @@
return "test:isolate_reload_helper";
}
-static bool IsIsolateReloadTestLib(const char* url_name) {
- static const intptr_t kIsolateReloadTestLibUriLen =
- strlen(IsolateReloadTestLibUri());
- return (strncmp(url_name, IsolateReloadTestLibUri(),
- kIsolateReloadTestLibUriLen) == 0);
-}
-
static void ReloadTest(Dart_NativeArguments native_args) {
Dart_Handle result = TestCase::TriggerReload(/* kernel_buffer= */ NULL,
/* kernel_buffer_size= */ 0);
@@ -241,15 +227,6 @@
}
#endif // !PRODUCT
-static Dart_Handle ResolvePackageUri(const char* uri_chars) {
- const int kNumArgs = 1;
- Dart_Handle dart_args[kNumArgs];
- dart_args[0] = DartUtils::NewString(uri_chars);
- return Dart_Invoke(DartUtils::LookupBuiltinLib(),
- DartUtils::NewString("_filePathFromUri"), kNumArgs,
- dart_args);
-}
-
char* TestCase::CompileTestScriptWithDFE(const char* url,
const char* source,
const uint8_t** kernel_buffer,
@@ -273,54 +250,6 @@
multiroot_filepaths, multiroot_scheme);
}
-#if 0
-
-char* TestCase::CompileTestScriptWithDFE(const char* url,
- int sourcefiles_count,
- Dart_SourceFile sourcefiles[],
- void** kernel_pgm,
- bool incrementally,
- bool allow_compile_errors) {
- Zone* zone = Thread::Current()->zone();
- Dart_KernelCompilationResult compilation_result = Dart_CompileSourcesToKernel(
- url, platform_strong_dill, platform_strong_dill_size,
- sourcefiles_count, sourcefiles, incrementally, NULL);
- return ValidateCompilationResult(zone, compilation_result, kernel_pgm);
-}
-
-char* TestCase::ValidateCompilationResult(
- Zone* zone,
- Dart_KernelCompilationResult compilation_result,
- void** kernel_pgm,
- bool allow_compile_errors) {
- if (!allow_compile_errors &&
- (compilation_result.status != Dart_KernelCompilationStatus_Ok)) {
- char* result =
- OS::SCreate(zone, "Compilation failed %s", compilation_result.error);
- free(compilation_result.error);
- return result;
- }
-
- const uint8_t* kernel_file = compilation_result.kernel;
- intptr_t kernel_length = compilation_result.kernel_size;
- if (kernel_file == NULL) {
- return OS::SCreate(zone, "front end generated a NULL kernel file");
- }
- *kernel_pgm =
- Dart_ReadKernelBinary(kernel_file, kernel_length, ReleaseFetchedBytes);
- if (*kernel_pgm == NULL) {
- return OS::SCreate(zone, "Failed to read generated kernel binary");
- }
- if (compilation_result.status != Dart_KernelCompilationStatus_Ok) {
- char* result =
- OS::SCreate(zone, "Compilation failed %s", compilation_result.error);
- free(compilation_result.error);
- return result;
- }
- return NULL;
-}
-#endif
-
char* TestCase::CompileTestScriptWithDFE(const char* url,
int sourcefiles_count,
Dart_SourceFile sourcefiles[],
@@ -377,70 +306,6 @@
}
return Dart_DefaultCanonicalizeUrl(library_url, url);
}
- if (!Dart_IsLibrary(library)) {
- return Dart_NewApiError("not a library");
- }
- if (!Dart_IsString(url)) {
- return Dart_NewApiError("url is not a string");
- }
- const char* url_chars = NULL;
- Dart_Handle result = Dart_StringToCString(url, &url_chars);
- if (Dart_IsError(result)) {
- return Dart_NewApiError("accessing url characters failed");
- }
- Dart_Handle library_url = Dart_LibraryUrl(library);
- const char* library_url_string = NULL;
- result = Dart_StringToCString(library_url, &library_url_string);
- if (Dart_IsError(result)) {
- return result;
- }
-
- bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_chars);
- bool is_io_library = DartUtils::IsDartIOLibURL(library_url_string);
- bool is_standalone_library = DartUtils::IsDartCLILibURL(library_url_string);
- if (is_dart_scheme_url) {
- ASSERT(tag == Dart_kImportTag);
- // Handle imports of other built-in libraries present in the SDK.
- if (DartUtils::IsDartIOLibURL(url_chars)) {
- return Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary);
- } else if (DartUtils::IsDartBuiltinLibURL(url_chars)) {
- return Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
- } else if (DartUtils::IsDartCLILibURL(url_chars)) {
- return Builtin::LoadAndCheckLibrary(Builtin::kCLILibrary);
- } else {
- return DartUtils::NewError("Do not know how to load '%s'", url_chars);
- }
- }
- const char* lib_source = TestCase::GetTestLib(url_chars);
- if (lib_source != NULL) {
- UNREACHABLE();
- }
-#if !defined(PRODUCT)
- if (IsIsolateReloadTestLib(url_chars)) {
- UNREACHABLE();
- return Dart_Null();
- }
-#endif
- if (is_io_library) {
- UNREACHABLE();
- return Dart_Null();
- }
- if (is_standalone_library) {
- UNREACHABLE();
- return Dart_Null();
- }
- Dart_Handle resolved_url = url;
- const char* resolved_url_chars = url_chars;
- if (IsPackageSchemeURL(url_chars)) {
- resolved_url = ResolvePackageUri(url_chars);
- EXPECT_VALID(resolved_url);
- if (Dart_IsError(Dart_StringToCString(resolved_url, &resolved_url_chars))) {
- return Dart_NewApiError("unable to convert resolved uri to string");
- }
- }
- // Do sync loading since unit_test doesn't support async.
- Dart_Handle source = DartUtils::ReadStringFromFile(resolved_url_chars);
- EXPECT_VALID(source);
UNREACHABLE();
return Dart_Null();
}
@@ -700,13 +565,14 @@
return Api::NewError("%s", compilation_result.error);
}
- const uint8_t* kernel_bytes = compilation_result.kernel;
- intptr_t kernel_length = compilation_result.kernel_size;
+ const ExternalTypedData& kernel_buffer =
+ ExternalTypedData::Handle(ExternalTypedData::NewFinalizeWithFree(
+ const_cast<uint8_t*>(compilation_result.kernel),
+ compilation_result.kernel_size));
- val = lib.EvaluateCompiledExpression(kernel_bytes, kernel_length,
- Array::empty_array(), param_values,
+ val = lib.EvaluateCompiledExpression(kernel_buffer, Array::empty_array(),
+ param_values,
TypeArguments::null_type_arguments());
- free(const_cast<uint8_t*>(kernel_bytes));
}
return Api::NewHandle(thread, val.raw());
}
diff --git a/sdk/lib/_internal/js_dev_runtime/private/debugger.dart b/sdk/lib/_internal/js_dev_runtime/private/debugger.dart
index 9bdca7a..db11479 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/debugger.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/debugger.dart
@@ -12,7 +12,6 @@
import 'dart:_runtime' as dart;
import 'dart:core';
import 'dart:collection';
-import 'dart:html' as html;
import 'dart:math';
part 'profile.dart';
@@ -343,7 +342,7 @@
// Treat Node objects as a native JavaScript type as the regular DOM render
// in devtools is superior to the dart specific view.
- return object is html.Node;
+ return JS<bool>('!', '# instanceof Node', object);
}
/// Class implementing the Devtools Formatter API described by:
@@ -490,7 +489,7 @@
} catch (e, trace) {
// Log formatter internal errors as unfortunately the devtools cannot
// be used to debug formatter errors.
- html.window.console.error("Caught exception $e\n trace:\n$trace");
+ _printConsoleError("Caught exception $e\n trace:\n$trace");
}
return null;
@@ -505,8 +504,7 @@
}
} catch (e, trace) {
// See comment for preview.
- html.window.console
- .error("[hasChildren] Caught exception $e\n trace:\n$trace");
+ _printConsoleError("[hasChildren] Caught exception $e\n trace:\n$trace");
}
return false;
}
@@ -521,10 +519,13 @@
}
} catch (e, trace) {
// See comment for preview.
- html.window.console.error("Caught exception $e\n trace:\n$trace");
+ _printConsoleError("Caught exception $e\n trace:\n$trace");
}
return <NameValuePair>[];
}
+
+ void _printConsoleError(String message) =>
+ JS('', 'window.console.error(#)', message);
}
/// Default formatter for Dart Objects.
diff --git a/sdk/lib/_internal/js_runtime/lib/rti.dart b/sdk/lib/_internal/js_runtime/lib/rti.dart
index 8174aea..a43e942 100644
--- a/sdk/lib/_internal/js_runtime/lib/rti.dart
+++ b/sdk/lib/_internal/js_runtime/lib/rti.dart
@@ -1315,11 +1315,13 @@
'#: new Map(),'
'#: {},'
'#: {},'
+ '#: {},'
'#: [],' // shared empty array.
'}',
RtiUniverseFieldNames.evalCache,
RtiUniverseFieldNames.typeRules,
RtiUniverseFieldNames.erasedTypes,
+ RtiUniverseFieldNames.typeParameterVariances,
RtiUniverseFieldNames.sharedEmptyArray);
}
@@ -1334,6 +1336,9 @@
static Object erasedTypes(universe) =>
JS('', '#.#', universe, RtiUniverseFieldNames.erasedTypes);
+ static Object typeParameterVariances(universe) =>
+ JS('', '#.#', universe, RtiUniverseFieldNames.typeParameterVariances);
+
static Object _findRule(universe, String targetType) =>
JS('', '#.#', typeRules(universe), targetType);
@@ -1365,12 +1370,18 @@
}
}
+ static Object findTypeParameterVariances(universe, String cls) =>
+ JS('', '#.#', typeParameterVariances(universe), cls);
+
static void addRules(universe, rules) =>
_Utils.objectAssign(typeRules(universe), rules);
static void addErasedTypes(universe, types) =>
_Utils.objectAssign(erasedTypes(universe), types);
+ static void addTypeParameterVariances(universe, variances) =>
+ _Utils.objectAssign(typeParameterVariances(universe), variances);
+
static Object sharedEmptyArray(universe) =>
JS('JSArray', '#.#', universe, RtiUniverseFieldNames.sharedEmptyArray);
@@ -2247,6 +2258,15 @@
JS('', '#.#', rule, supertype);
}
+// This needs to be kept in sync with `Variance` in `entities.dart`.
+class Variance {
+ // TODO(fishythefish): Try bitmask representation.
+ static const legacyCovariant = 0;
+ static const covariant = 1;
+ static const contravariant = 2;
+ static const invariant = 3;
+}
+
// -------- Subtype tests ------------------------------------------------------
// Future entry point from compiled code.
@@ -2431,10 +2451,41 @@
var sArgs = Rti._getInterfaceTypeArguments(s);
int length = _Utils.arrayLength(sArgs);
assert(length == _Utils.arrayLength(tArgs));
+
+ var sVariances;
+ bool hasVariances;
+ if (JS_GET_FLAG("VARIANCE")) {
+ sVariances = _Universe.findTypeParameterVariances(universe, sName);
+ hasVariances = sVariances != null;
+ assert(!hasVariances || length == _Utils.arrayLength(sVariances));
+ }
+
for (int i = 0; i < length; i++) {
Rti sArg = _castToRti(_Utils.arrayAt(sArgs, i));
Rti tArg = _castToRti(_Utils.arrayAt(tArgs, i));
- if (!_isSubtype(universe, sArg, sEnv, tArg, tEnv)) return false;
+ if (JS_GET_FLAG("VARIANCE")) {
+ int sVariance = hasVariances
+ ? _Utils.asInt(_Utils.arrayAt(sVariances, i))
+ : Variance.legacyCovariant;
+ switch (sVariance) {
+ case Variance.legacyCovariant:
+ case Variance.covariant:
+ if (!_isSubtype(universe, sArg, sEnv, tArg, tEnv)) return false;
+ break;
+ case Variance.contravariant:
+ if (!_isSubtype(universe, tArg, tEnv, sArg, sEnv)) return false;
+ break;
+ case Variance.invariant:
+ if (!_isSubtype(universe, sArg, sEnv, tArg, tEnv) ||
+ !_isSubtype(universe, tArg, tEnv, sArg, sEnv)) return false;
+ break;
+ default:
+ throw StateError(
+ "Unknown variance given for subtype check: $sVariance");
+ }
+ } else {
+ if (!_isSubtype(universe, sArg, sEnv, tArg, tEnv)) return false;
+ }
}
return true;
}
@@ -2665,6 +2716,10 @@
_Universe.addRules(universe, rules);
}
+void testingAddTypeParameterVariances(universe, variances) {
+ _Universe.addTypeParameterVariances(universe, variances);
+}
+
bool testingIsSubtype(universe, rti1, rti2) {
return isSubtype(universe, _castToRti(rti1), _castToRti(rti2));
}
diff --git a/sdk/lib/_internal/js_runtime/lib/shared/embedded_names.dart b/sdk/lib/_internal/js_runtime/lib/shared/embedded_names.dart
index 0ac7488..d49bab5 100644
--- a/sdk/lib/_internal/js_runtime/lib/shared/embedded_names.dart
+++ b/sdk/lib/_internal/js_runtime/lib/shared/embedded_names.dart
@@ -461,5 +461,6 @@
static String evalCache = 'eC';
static String typeRules = 'tR';
static String erasedTypes = 'eT';
+ static String typeParameterVariances = 'tPV';
static String sharedEmptyArray = 'sEA';
}
diff --git a/sdk/lib/_internal/vm/bin/builtin.dart b/sdk/lib/_internal/vm/bin/builtin.dart
index dde9727..6977c89 100644
--- a/sdk/lib/_internal/vm/bin/builtin.dart
+++ b/sdk/lib/_internal/vm/bin/builtin.dart
@@ -47,8 +47,6 @@
// Requests made to the service isolate over the load port.
// Extra requests. Keep these in sync between loader.dart and builtin.dart.
-const _Dart_kResourceLoad = 5; // Resource class support.
-const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory.
const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file.
const _Dart_kResolvePackageUri = 8; // Resolve a package: uri.
@@ -76,8 +74,6 @@
// package imports can be resolved relative to it. The root script is the basis
// for the root library in the VM.
Uri _rootScript;
-// The package root set on the command line.
-Uri _packageRoot;
// Special handling for Windows paths so that they are compatible with URI
// handling.
@@ -157,38 +153,6 @@
}
// Embedder Entrypoint:
-// The embedder calls this method with a custom package root.
-@pragma("vm:entry-point")
-String _setPackageRoot(String packageRoot) {
- if (!_setupCompleted) {
- _setupHooks();
- }
- if (_traceLoading) {
- _log('Setting package root: $packageRoot');
- }
- if (packageRoot.startsWith('file:') ||
- packageRoot.startsWith('http:') ||
- packageRoot.startsWith('https:')) {
- packageRoot = _enforceTrailingSlash(packageRoot);
- _packageRoot = _workingDirectory.resolve(packageRoot);
- } else {
- packageRoot = _sanitizeWindowsPath(packageRoot);
- packageRoot = _trimWindowsPath(packageRoot);
- _packageRoot = _workingDirectory.resolveUri(new Uri.directory(packageRoot));
- }
- // Now that we have determined the packageRoot value being used, set it
- // up for use in Platform.packageRoot. This is only set when the embedder
- // sets up the package root. Automatically discovered package root will
- // not update the VMLibraryHooks value.
- var packageRootStr = _packageRoot.toString();
- VMLibraryHooks.packageRootString = packageRootStr;
- if (_traceLoading) {
- _log('Package root URI: $_packageRoot');
- }
- return packageRootStr;
-}
-
-// Embedder Entrypoint:
@pragma("vm:entry-point")
String _setPackagesMap(String packagesParam) {
if (!_setupCompleted) {
@@ -248,72 +212,14 @@
return scriptUri.toString();
}
-// Only used by vm/cc unit tests.
-Uri _resolvePackageUri(Uri uri) {
- assert(_packageRoot != null);
- return _packageRoot.resolve(uri.path);
-}
-
-// Returns either a file path or a URI starting with http[s]:, as a String.
-String _filePathFromUri(String userUri) {
- var uri = Uri.parse(userUri);
- if (_traceLoading) {
- _log('Getting file path from: $uri');
- }
-
- var path;
- switch (uri.scheme) {
- case '':
- case 'file':
- return uri.toFilePath();
- case 'package':
- return _filePathFromUri(_resolvePackageUri(uri).toString());
- case 'data':
- case 'http':
- case 'https':
- return uri.toString();
- default:
- // Only handling file, http, and package URIs
- // in standalone binary.
- if (_traceLoading) {
- _log('Unknown scheme (${uri.scheme}) in $uri.');
- }
- throw 'Not a known scheme: $uri';
- }
-}
-
// Register callbacks and hooks with the rest of the core libraries.
@pragma("vm:entry-point")
_setupHooks() {
_setupCompleted = true;
- VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes;
-
- VMLibraryHooks.packageRootUriFuture = _getPackageRootFuture;
VMLibraryHooks.packageConfigUriFuture = _getPackageConfigFuture;
VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture;
}
-// Handling of Resource class by dispatching to the load port.
-Future<List<int>> _resourceReadAsBytes(Uri uri) async {
- List response =
- await _makeLoaderRequest<List<int>>(_Dart_kResourceLoad, uri.toString());
- if (response[4] is String) {
- // Throw the error.
- throw response[4];
- } else {
- return response[4];
- }
-}
-
-// TODO(mfairhurst): remove this
-Future<Uri> _getPackageRootFuture() {
- if (_traceLoading) {
- _log("Request for package root from user code.");
- }
- // Return null, as the `packages/` directory is not supported in dart 2.
- return new Future.value(null);
-}
-
Future<Uri> _getPackageConfigFuture() {
if (_traceLoading) {
_log("Request for package config from user code.");
diff --git a/sdk/lib/_internal/vm/bin/socket_patch.dart b/sdk/lib/_internal/vm/bin/socket_patch.dart
index 5771c76..e8e2bd1 100644
--- a/sdk/lib/_internal/vm/bin/socket_patch.dart
+++ b/sdk/lib/_internal/vm/bin/socket_patch.dart
@@ -130,11 +130,11 @@
static const int _IPv6AddrLength = 16;
static _InternetAddress loopbackIPv4 =
- new _InternetAddress.fixed(_addressLoopbackIPv4);
+ _InternetAddress.fixed(_addressLoopbackIPv4);
static _InternetAddress loopbackIPv6 =
- new _InternetAddress.fixed(_addressLoopbackIPv6);
- static _InternetAddress anyIPv4 = new _InternetAddress.fixed(_addressAnyIPv4);
- static _InternetAddress anyIPv6 = new _InternetAddress.fixed(_addressAnyIPv6);
+ _InternetAddress.fixed(_addressLoopbackIPv6);
+ static _InternetAddress anyIPv4 = _InternetAddress.fixed(_addressAnyIPv4);
+ static _InternetAddress anyIPv6 = _InternetAddress.fixed(_addressAnyIPv6);
final String address;
final String _host;
@@ -731,6 +731,10 @@
if (resourceInfo != null) {
resourceInfo.didRead();
}
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(
+ nativeGetSocketId(), _SocketProfileType.readBytes, result?.length);
+ }
return result;
}
@@ -758,6 +762,10 @@
if (resourceInfo != null) {
resourceInfo.didRead();
}
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(nativeGetSocketId(),
+ _SocketProfileType.readBytes, result?.data?.length);
+ }
return result;
}
@@ -782,6 +790,12 @@
if (bytes == 0) return 0;
_BufferAndStart bufferAndStart =
_ensureFastAndSerializableByteData(buffer, offset, offset + bytes);
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(
+ nativeGetSocketId(),
+ _SocketProfileType.writeBytes,
+ bufferAndStart.buffer.length - bufferAndStart.start);
+ }
var result =
nativeWrite(bufferAndStart.buffer, bufferAndStart.start, bytes);
if (result is OSError) {
@@ -812,6 +826,12 @@
if (isClosing || isClosed) return 0;
_BufferAndStart bufferAndStart =
_ensureFastAndSerializableByteData(buffer, offset, bytes);
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(
+ nativeGetSocketId(),
+ _SocketProfileType.writeBytes,
+ bufferAndStart.buffer.length - bufferAndStart.start);
+ }
var result = nativeSendTo(bufferAndStart.buffer, bufferAndStart.start,
bytes, (address as _InternetAddress)._in_addr, port);
if (result is OSError) {
@@ -1281,7 +1301,11 @@
while (_socket.available > 0) {
var socket = _socket.accept();
if (socket == null) return;
- _controller.add(new _RawSocket(socket));
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectNewSocket(socket.nativeGetSocketId(),
+ _tcpSocket, socket.address, socket.port);
+ }
+ _controller.add(_RawSocket(socket));
if (_controller.isPaused) return;
}
}), error: zone.bindBinaryCallbackGuarded((e, st) {
@@ -1353,16 +1377,28 @@
static Future<RawSocket> connect(
host, int port, sourceAddress, Duration timeout) {
return _NativeSocket.connect(host, port, sourceAddress, timeout)
- .then((socket) => new _RawSocket(socket));
+ .then((socket) {
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectNewSocket(
+ socket.nativeGetSocketId(), _tcpSocket, socket.address, port);
+ }
+ return _RawSocket(socket);
+ });
}
static Future<ConnectionTask<_RawSocket>> startConnect(
host, int port, sourceAddress) {
return _NativeSocket.startConnect(host, port, sourceAddress)
.then((ConnectionTask<_NativeSocket> nativeTask) {
- final Future<_RawSocket> raw = nativeTask.socket
- .then((_NativeSocket nativeSocket) => new _RawSocket(nativeSocket));
- return new ConnectionTask<_RawSocket>._(
+ final Future<_RawSocket> raw =
+ nativeTask.socket.then((_NativeSocket nativeSocket) {
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectNewSocket(nativeSocket.nativeGetSocketId(),
+ _tcpSocket, nativeSocket.address, port);
+ }
+ return _RawSocket(nativeSocket);
+ });
+ return ConnectionTask<_RawSocket>._(
socket: raw, onCancel: nativeTask._onCancel);
});
}
@@ -1441,7 +1477,13 @@
int write(List<int> buffer, [int offset, int count]) =>
_socket.write(buffer, offset, count);
- Future<RawSocket> close() => _socket.close().then<RawSocket>((_) => this);
+ Future<RawSocket> close() => _socket.close().then<RawSocket>((_) {
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(
+ _socket.nativeGetSocketId(), _SocketProfileType.endTime);
+ }
+ return this;
+ });
void shutdown(SocketDirection direction) => _socket.shutdown(direction);
@@ -1942,7 +1984,13 @@
_throwOnBadPort(port);
_throwOnBadTtl(ttl);
return _NativeSocket.bindDatagram(host, port, reuseAddress, reusePort, ttl)
- .then((socket) => new _RawDatagramSocket(socket));
+ .then((socket) {
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectNewSocket(
+ socket.nativeGetSocketId(), _udpSocket, socket.address, port);
+ }
+ return _RawDatagramSocket(socket);
+ });
}
StreamSubscription<RawSocketEvent> listen(void onData(RawSocketEvent event),
@@ -1951,7 +1999,13 @@
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
}
- Future close() => _socket.close().then<RawDatagramSocket>((_) => this);
+ Future close() => _socket.close().then<RawDatagramSocket>((_) {
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(
+ _socket.nativeGetSocketId(), _SocketProfileType.endTime);
+ }
+ return this;
+ });
int send(List<int> buffer, InternetAddress address, int port) =>
_socket.send(buffer, 0, buffer.length, address, port);
diff --git a/sdk/lib/_internal/vm/lib/async_patch.dart b/sdk/lib/_internal/vm/lib/async_patch.dart
index 7e9aff7..c4266f4 100644
--- a/sdk/lib/_internal/vm/lib/async_patch.dart
+++ b/sdk/lib/_internal/vm/lib/async_patch.dart
@@ -20,6 +20,7 @@
_fatal(msg) native "DartAsync_fatal";
class _AsyncAwaitCompleter<T> implements Completer<T> {
+ @pragma("vm:entry-point")
final _future = new _Future<T>();
bool isSync;
@@ -133,6 +134,7 @@
// async* generator functions.
@pragma("vm:entry-point")
class _AsyncStarStreamController<T> {
+ @pragma("vm:entry-point")
StreamController<T> controller;
Function asyncStarBody;
bool isAdding = false;
diff --git a/sdk/lib/_internal/vm/lib/bigint_patch.dart b/sdk/lib/_internal/vm/lib/bigint_patch.dart
index 61958dc..eee71b8 100644
--- a/sdk/lib/_internal/vm/lib/bigint_patch.dart
+++ b/sdk/lib/_internal/vm/lib/bigint_patch.dart
@@ -96,6 +96,18 @@
static const int _minInt = -0x8000000000000000;
static const int _maxInt = 0x7fffffffffffffff;
+ /// Certain methods of _BigIntImpl class are intrinsified by the VM
+ /// depending on the runtime flags. They return number of processed
+ /// digits (2) which is different from non-intrinsic implementation (1).
+ /// This flag is used to confuse constant propagation at compile time and
+ /// avoid propagating return value to the callers. It should not be
+ /// evaluated to a constant.
+ /// Note that [_isIntrinsified] is still false if intrinsification occurs,
+ /// so it should be used only inside methods which are replaced by
+ /// intrinsification.
+ static final bool _isIntrinsified =
+ new bool.fromEnvironment('dart.vm.not.a.compile.time.constant');
+
// Result cache for last _divRem call.
// Result cache for last _divRem call.
static Uint32List _lastDividendDigits;
@@ -1114,7 +1126,7 @@
int x = xDigits[xIndex];
if (x == 0) {
// No-op if x is 0.
- return 1;
+ return _isIntrinsified ? 2 : 1;
}
int carry = 0;
int xl = x & _halfDigitMask;
@@ -1135,7 +1147,7 @@
carry = l >> _digitBits;
accumulatorDigits[j++] = l & _digitMask;
}
- return 1;
+ return _isIntrinsified ? 2 : 1;
}
/// Multiplies `xDigits[i]` with `xDigits` and adds the result to
@@ -1158,7 +1170,7 @@
static int _sqrAdd(
Uint32List xDigits, int i, Uint32List acculumatorDigits, int used) {
int x = xDigits[i];
- if (x == 0) return 1;
+ if (x == 0) return _isIntrinsified ? 2 : 1;
int j = 2 * i;
int carry = 0;
int xl = x & _halfDigitMask;
@@ -1193,7 +1205,7 @@
} else {
acculumatorDigits[i + used] = carry;
}
- return 1;
+ return _isIntrinsified ? 2 : 1;
}
/// Multiplication operator.
@@ -1293,7 +1305,7 @@
args[_quotientDigit] = quotientDigit;
}
}
- return 1;
+ return _isIntrinsified ? 2 : 1;
}
/// Returns `trunc(this / other)`, with `other != 0`.
@@ -2627,7 +2639,7 @@
(((dl * rhoh + dh * rhol) & _BigIntImpl._halfDigitMask) <<
_BigIntImpl._halfDigitBits)) &
_BigIntImpl._digitMask;
- return 1;
+ return _BigIntImpl._isIntrinsified ? 2 : 1;
}
// result = x*R mod _modulus.
diff --git a/sdk/lib/_internal/vm/lib/isolate_patch.dart b/sdk/lib/_internal/vm/lib/isolate_patch.dart
index f5e75c9..9590c35 100644
--- a/sdk/lib/_internal/vm/lib/isolate_patch.dart
+++ b/sdk/lib/_internal/vm/lib/isolate_patch.dart
@@ -327,11 +327,7 @@
@patch
static Future<Uri> get packageRoot {
- var hook = VMLibraryHooks.packageRootUriFuture;
- if (hook == null) {
- throw new UnsupportedError("Isolate.packageRoot");
- }
- return hook();
+ return Future.value(null);
}
@patch
diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart
index a915b96..4481da5 100644
--- a/sdk/lib/async/future_impl.dart
+++ b/sdk/lib/async/future_impl.dart
@@ -79,6 +79,7 @@
// Which fields means what.
final int state;
// Used for then/whenDone callback and error test
+ @pragma("vm:entry-point")
final Function callback;
// Used for error callbacks.
final Function errorCallback;
@@ -213,6 +214,7 @@
* will complete with the same result.
* All listeners are forwarded to the other future.
*/
+ @pragma("vm:entry-point")
var _resultOrListeners;
// This constructor is used by async/await.
diff --git a/sdk/lib/async/stream_controller.dart b/sdk/lib/async/stream_controller.dart
index f2854a9..50e9aa3 100644
--- a/sdk/lib/async/stream_controller.dart
+++ b/sdk/lib/async/stream_controller.dart
@@ -409,7 +409,12 @@
/** The controller is in its initial state with no subscription. */
static const int _STATE_INITIAL = 0;
- /** The controller has a subscription, but hasn't been closed or canceled. */
+ /**
+ * The controller has a subscription, but hasn't been closed or canceled.
+ *
+ * Keep in sync with
+ * runtime/vm/stack_trace.cc:kStreamController_StateSubscribed.
+ */
static const int _STATE_SUBSCRIBED = 1;
/** The subscription is canceled. */
static const int _STATE_CANCELED = 2;
@@ -447,9 +452,11 @@
*
* When [_state] is [_STATE_CANCELED] the field is currently not used.
*/
+ @pragma("vm:entry-point")
var _varData;
/** Current state of the controller. */
+ @pragma("vm:entry-point")
int _state = _STATE_INITIAL;
/**
diff --git a/sdk/lib/async/stream_impl.dart b/sdk/lib/async/stream_impl.dart
index b3969fc..0b7cc5a 100644
--- a/sdk/lib/async/stream_impl.dart
+++ b/sdk/lib/async/stream_impl.dart
@@ -89,6 +89,7 @@
static const int _STATE_PAUSE_COUNT = 128;
/* Event handlers provided in constructor. */
+ @pragma("vm:entry-point")
_DataHandler<T> _onData;
Function _onError;
_DoneHandler _onDone;
diff --git a/sdk/lib/internal/errors.dart b/sdk/lib/internal/errors.dart
new file mode 100644
index 0000000..f88b413
--- /dev/null
+++ b/sdk/lib/internal/errors.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2019, 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.
+
+// @dart = 2.6
+
+part of dart._internal;
+
+class LateInitializationErrorImpl extends Error
+ implements LateInitializationError {
+ final String _message;
+
+ LateInitializationErrorImpl([this._message]);
+
+ String toString() {
+ var message = _message;
+ return (message != null)
+ ? "LateInitializationError: $message"
+ : "LateInitializationError";
+ }
+}
diff --git a/sdk/lib/internal/internal.dart b/sdk/lib/internal/internal.dart
index bee60d6..b3ecbe7 100644
--- a/sdk/lib/internal/internal.dart
+++ b/sdk/lib/internal/internal.dart
@@ -23,6 +23,7 @@
part 'async_cast.dart';
part 'cast.dart';
+part 'errors.dart';
part 'iterable.dart';
part 'list.dart';
part 'print.dart';
diff --git a/sdk/lib/internal/internal_sources.gni b/sdk/lib/internal/internal_sources.gni
index 7c8af46..4311341 100644
--- a/sdk/lib/internal/internal_sources.gni
+++ b/sdk/lib/internal/internal_sources.gni
@@ -9,6 +9,7 @@
# The above file needs to be first as it lists the parts below.
"async_cast.dart",
"cast.dart",
+ "errors.dart",
"iterable.dart",
"list.dart",
"linked_list.dart",
diff --git a/sdk/lib/io/network_profiling.dart b/sdk/lib/io/network_profiling.dart
index f303c9d..05e81b5 100644
--- a/sdk/lib/io/network_profiling.dart
+++ b/sdk/lib/io/network_profiling.dart
@@ -6,15 +6,32 @@
part of dart.io;
-@pragma('vm:entry-point')
+const String _tcpSocket = 'tcp';
+const String _udpSocket = 'udp';
+
+@pragma('vm:entry-point', !const bool.fromEnvironment("dart.vm.product"))
abstract class _NetworkProfiling {
+ // Http relative RPCs
static const _kGetHttpProfileRPC = 'ext.dart.io.getHttpProfile';
+ // Socket relative RPCs
+ static const _kClearSocketProfileRPC = 'ext.dart.io.clearSocketProfile';
static const _kGetSocketProfileRPC = 'ext.dart.io.getSocketProfile';
+ static const _kPauseSocketProfilingRPC = 'ext.dart.io.pauseSocketProfiling';
+ static const _kStartSocketProfilingRPC = 'ext.dart.io.startSocketProfiling';
+
+ // TODO(zichangguo): This version number represents the version of service
+ // extension of dart:io. Consider moving this out of web profiler class,
+ // if more methods added to dart:io,
+ static const _kGetVersionRPC = 'ext.dart.io.getVersion';
@pragma('vm:entry-point')
static void _registerServiceExtension() {
registerExtension(_kGetHttpProfileRPC, _serviceExtensionHandler);
registerExtension(_kGetSocketProfileRPC, _serviceExtensionHandler);
+ registerExtension(_kStartSocketProfilingRPC, _serviceExtensionHandler);
+ registerExtension(_kPauseSocketProfilingRPC, _serviceExtensionHandler);
+ registerExtension(_kClearSocketProfileRPC, _serviceExtensionHandler);
+ registerExtension(_kGetVersionRPC, _serviceExtensionHandler);
}
static Future<ServiceExtensionResponse> _serviceExtensionHandler(
@@ -22,10 +39,22 @@
String responseJson;
switch (method) {
case _kGetHttpProfileRPC:
- responseJson = _HttpProfile.toJSON();
+ responseJson = _HttpProfile.toJson();
break;
case _kGetSocketProfileRPC:
- responseJson = _SocketProfile.toJSON();
+ responseJson = _SocketProfile.toJson();
+ break;
+ case _kStartSocketProfilingRPC:
+ responseJson = _SocketProfile.start();
+ break;
+ case _kPauseSocketProfilingRPC:
+ responseJson = _SocketProfile.pause();
+ break;
+ case _kClearSocketProfileRPC:
+ responseJson = _SocketProfile.clear();
+ break;
+ case _kGetVersionRPC:
+ responseJson = getVersion();
break;
default:
return Future.value(ServiceExtensionResponse.error(
@@ -34,12 +63,18 @@
}
return Future.value(ServiceExtensionResponse.result(responseJson));
}
+
+ static String getVersion() => json.encode({
+ 'type': 'Version',
+ 'major': 1,
+ 'minor': 0,
+ });
}
abstract class _HttpProfile {
static const _kType = 'HttpProfile';
// TODO(bkonyi): implement.
- static String toJSON() {
+ static String toJson() {
final response = <String, dynamic>{
'type': _kType,
};
@@ -49,11 +84,131 @@
abstract class _SocketProfile {
static const _kType = 'SocketProfile';
- // TODO(bkonyi): implement.
- static String toJSON() {
- final response = <String, dynamic>{
- 'type': _kType,
+ static bool _enableSocketProfiling = false;
+ static Map<int, _SocketStatistic> _idToSocketStatistic = {};
+
+ static String toJson() => json.encode({
+ 'type': _kType,
+ 'sockets': _idToSocketStatistic.values.map((f) => f.toMap()).toList(),
+ });
+
+ static void collectNewSocket(
+ int id, String type, InternetAddress addr, int port) {
+ _SocketProfile.collectStatistic(id, _SocketProfileType.startTime);
+ _SocketProfile.collectStatistic(id, _SocketProfileType.socketType, type);
+ _SocketProfile.collectStatistic(id, _SocketProfileType.address, addr);
+ _SocketProfile.collectStatistic(id, _SocketProfileType.port, port);
+ }
+
+ static void collectStatistic(int id, _SocketProfileType type,
+ [dynamic object]) {
+ if (!_enableSocketProfiling) {
+ return;
+ }
+ // Skip socket that started before _enableSocketProfiling turned on.
+ if (!_idToSocketStatistic.containsKey(id) &&
+ type != _SocketProfileType.startTime) return;
+ _idToSocketStatistic[id] ??= _SocketStatistic(id);
+ _SocketStatistic stats = _idToSocketStatistic[id];
+ switch (type) {
+ case _SocketProfileType.startTime:
+ stats.startTime = Timeline.now;
+ break;
+ case _SocketProfileType.endTime:
+ stats.endTime = Timeline.now;
+ break;
+ case _SocketProfileType.address:
+ assert(object is InternetAddress);
+ stats.address = (object as InternetAddress).toString();
+ break;
+ case _SocketProfileType.port:
+ assert(object is int);
+ stats.port = object;
+ break;
+ case _SocketProfileType.socketType:
+ assert(object is String);
+ stats.socketType = object;
+ break;
+ case _SocketProfileType.readBytes:
+ if (object == null) return;
+ assert(object is int);
+ stats.readBytes ??= 0;
+ stats.readBytes += object;
+ break;
+ case _SocketProfileType.writeBytes:
+ if (object == null) return;
+ assert(object is int);
+ stats.writeBytes ??= 0;
+ stats.writeBytes += object;
+ break;
+ default:
+ throw ArgumentError('type ${type} does not exist');
+ break;
+ }
+ }
+
+ static String start() {
+ _enableSocketProfiling = true;
+ return success();
+ }
+
+ static String pause() {
+ _enableSocketProfiling = false;
+ return success();
+ }
+
+ // clear the storage if _idToSocketStatistic has been initialized.
+ static String clear() {
+ _idToSocketStatistic?.clear();
+ return success();
+ }
+
+ static String success() => json.encode({
+ 'type': 'Success',
+ });
+}
+
+/// The [_SocketProfileType] is used as a parameter for
+/// [_SocketProfile.collectStatistic] to determine the type of statistic.
+enum _SocketProfileType {
+ startTime,
+ endTime,
+ address,
+ port,
+ socketType,
+ readBytes,
+ writeBytes
+}
+
+/// Socket statistic
+class _SocketStatistic {
+ final int id;
+ int startTime;
+ int endTime;
+ String address;
+ int port;
+ String socketType;
+ int readBytes = 0;
+ int writeBytes = 0;
+
+ _SocketStatistic(this.id);
+
+ Map<String, dynamic> toMap() {
+ final map = <String, dynamic>{
+ 'id': id,
};
- return json.encode(response);
+ _setIfNotNull(map, 'startTime', startTime.toString());
+ _setIfNotNull(map, 'endTime', endTime.toString());
+ _setIfNotNull(map, 'address', address);
+ _setIfNotNull(map, 'port', port);
+ _setIfNotNull(map, 'socketType', socketType);
+ _setIfNotNull(map, 'readBytes', readBytes);
+ _setIfNotNull(map, 'writeBytes', writeBytes);
+ return map;
+ }
+
+ void _setIfNotNull(Map<String, Object> json, String key, Object value) {
+ if (value == null) return;
+ json[key] = value;
}
}
diff --git a/sdk/lib/vmservice/vmservice.dart b/sdk/lib/vmservice/vmservice.dart
index 3c5bcbe..410406c 100644
--- a/sdk/lib/vmservice/vmservice.dart
+++ b/sdk/lib/vmservice/vmservice.dart
@@ -650,7 +650,8 @@
}
}
-@pragma("vm:entry-point", "call")
+@pragma("vm:entry-point",
+ const bool.fromEnvironment("dart.vm.product") ? false : "call")
RawReceivePort boot() {
// Return the port we expect isolate control messages on.
return isolateControlPort;
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/libraries.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/libraries.dart
deleted file mode 100644
index ce023f1..0000000
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/libraries.dart
+++ /dev/null
@@ -1,312 +0,0 @@
-// Copyright (c) 2012, 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.
-
-// @dart = 2.5
-
-library libraries;
-
-/**
- * A bit flag used by [LibraryInfo] indicating that a library is used by dart2js
- */
-const int DART2JS_PLATFORM = 1;
-
-/**
- * A bit flag used by [LibraryInfo] indicating that a library is used by the VM
- */
-const int VM_PLATFORM = 2;
-
-/// The contexts that a library can be used from.
-enum Category {
- /// Indicates that a library can be used in a browser context.
- client,
-
- /// Indicates that a library can be used in a command line context.
- server,
-
- /// Indicates that a library can be used from embedded devices.
- embedded
-}
-
-Category parseCategory(String name) {
- switch (name) {
- case "Client":
- return Category.client;
- case "Server":
- return Category.server;
- case "Embedded":
- return Category.embedded;
- }
- return null;
-}
-
-/// Mapping of "dart:" library name (e.g. "core") to information about that
-/// library.
-const Map<String, LibraryInfo> libraries = const {
- "async": const LibraryInfo("async/async.dart",
- categories: "Client,Server",
- maturity: Maturity.STABLE,
- dart2jsPatchPath: "_internal/js_runtime/lib/async_patch.dart"),
- "collection": const LibraryInfo("collection/collection.dart",
- categories: "Client,Server,Embedded",
- maturity: Maturity.STABLE,
- dart2jsPatchPath: "_internal/js_runtime/lib/collection_patch.dart"),
- "convert": const LibraryInfo("convert/convert.dart",
- categories: "Client,Server",
- maturity: Maturity.STABLE,
- dart2jsPatchPath: "_internal/js_runtime/lib/convert_patch.dart"),
- "core": const LibraryInfo("core/core.dart",
- categories: "Client,Server,Embedded",
- maturity: Maturity.STABLE,
- dart2jsPatchPath: "_internal/js_runtime/lib/core_patch.dart"),
- "developer": const LibraryInfo("developer/developer.dart",
- categories: "Client,Server,Embedded",
- maturity: Maturity.UNSTABLE,
- dart2jsPatchPath: "_internal/js_runtime/lib/developer_patch.dart"),
- "html": const LibraryInfo("html/dart2js/html_dart2js.dart",
- categories: "Client",
- maturity: Maturity.WEB_STABLE,
- platforms: DART2JS_PLATFORM),
- "html_common": const LibraryInfo("html/html_common/html_common.dart",
- categories: "Client",
- maturity: Maturity.WEB_STABLE,
- dart2jsPath: "html/html_common/html_common_dart2js.dart",
- documented: false,
- implementation: true),
- "indexed_db": const LibraryInfo("indexed_db/dart2js/indexed_db_dart2js.dart",
- categories: "Client",
- maturity: Maturity.WEB_STABLE,
- platforms: DART2JS_PLATFORM),
- "_http":
- const LibraryInfo("_http/http.dart", categories: "", documented: false),
- "io": const LibraryInfo("io/io.dart",
- categories: "Server",
- dart2jsPatchPath: "_internal/js_runtime/lib/io_patch.dart"),
- "isolate": const LibraryInfo("isolate/isolate.dart",
- categories: "Client,Server",
- maturity: Maturity.STABLE,
- dart2jsPatchPath: "_internal/js_runtime/lib/isolate_patch.dart"),
- "js": const LibraryInfo("js/dart2js/js_dart2js.dart",
- categories: "Client",
- maturity: Maturity.STABLE,
- platforms: DART2JS_PLATFORM),
- "js_util": const LibraryInfo("js_util/dart2js/js_util_dart2js.dart",
- categories: "Client",
- maturity: Maturity.STABLE,
- platforms: DART2JS_PLATFORM),
- "math": const LibraryInfo("math/math.dart",
- categories: "Client,Server,Embedded",
- maturity: Maturity.STABLE,
- dart2jsPatchPath: "_internal/js_runtime/lib/math_patch.dart"),
- "mirrors": const LibraryInfo("mirrors/mirrors.dart",
- categories: "Client,Server",
- maturity: Maturity.UNSTABLE,
- dart2jsPatchPath: "_internal/js_runtime/lib/mirrors_patch.dart"),
- "nativewrappers": const LibraryInfo("html/dartium/nativewrappers.dart",
- categories: "Client",
- implementation: true,
- documented: false,
- platforms: DART2JS_PLATFORM),
- "typed_data": const LibraryInfo("typed_data/typed_data.dart",
- categories: "Client,Server,Embedded",
- maturity: Maturity.STABLE,
- dart2jsPatchPath: "_internal/js_runtime/lib/typed_data_patch.dart"),
- "_native_typed_data": const LibraryInfo(
- "_internal/js_runtime/lib/native_typed_data.dart",
- categories: "",
- implementation: true,
- documented: false,
- platforms: DART2JS_PLATFORM),
- "cli": const LibraryInfo("cli/cli.dart",
- categories: "Server",
- dart2jsPatchPath: "_internal/js_runtime/lib/cli_patch.dart"),
- "svg": const LibraryInfo("svg/dart2js/svg_dart2js.dart",
- categories: "Client",
- maturity: Maturity.WEB_STABLE,
- platforms: DART2JS_PLATFORM),
- "web_audio": const LibraryInfo("web_audio/dart2js/web_audio_dart2js.dart",
- categories: "Client",
- maturity: Maturity.WEB_STABLE,
- platforms: DART2JS_PLATFORM),
- "web_gl": const LibraryInfo("web_gl/dart2js/web_gl_dart2js.dart",
- categories: "Client",
- maturity: Maturity.WEB_STABLE,
- platforms: DART2JS_PLATFORM),
- "web_sql": const LibraryInfo("web_sql/dart2js/web_sql_dart2js.dart",
- categories: "Client",
- maturity: Maturity.WEB_STABLE,
- platforms: DART2JS_PLATFORM),
- "_internal": const LibraryInfo("internal/internal.dart",
- categories: "",
- documented: false,
- dart2jsPatchPath: "_internal/js_runtime/lib/internal_patch.dart"),
- "_js_helper": const LibraryInfo("_internal/js_runtime/lib/js_helper.dart",
- categories: "", documented: false, platforms: DART2JS_PLATFORM),
- "_interceptors": const LibraryInfo(
- "_internal/js_runtime/lib/interceptors.dart",
- categories: "",
- documented: false,
- platforms: DART2JS_PLATFORM),
- "_foreign_helper": const LibraryInfo(
- "_internal/js_runtime/lib/foreign_helper.dart",
- categories: "",
- documented: false,
- platforms: DART2JS_PLATFORM),
- "_isolate_helper": const LibraryInfo(
- "_internal/js_runtime/lib/isolate_helper.dart",
- categories: "",
- documented: false,
- platforms: DART2JS_PLATFORM),
- "_js_mirrors": const LibraryInfo("_internal/js_runtime/lib/js_mirrors.dart",
- categories: "", documented: false, platforms: DART2JS_PLATFORM),
- "_js_primitives": const LibraryInfo(
- "_internal/js_runtime/lib/js_primitives.dart",
- categories: "",
- documented: false,
- platforms: DART2JS_PLATFORM),
- "_metadata": const LibraryInfo("html/html_common/metadata.dart",
- categories: "", documented: false, platforms: DART2JS_PLATFORM),
- "_debugger": const LibraryInfo("_internal/js_runtime/lib/debugger.dart",
- category: "", documented: false, platforms: DART2JS_PLATFORM),
- "_runtime": const LibraryInfo(
- "_internal/js_runtime/lib/ddc_runtime/runtime.dart",
- category: "",
- documented: false,
- platforms: DART2JS_PLATFORM),
-};
-
-/**
- * Information about a "dart:" library.
- */
-class LibraryInfo {
- /**
- * Path to the library's *.dart file relative to this file.
- */
- final String path;
-
- /**
- * The categories in which the library can be used encoded as a
- * comma-separated String.
- */
- final String _categories;
-
- /**
- * Path to the dart2js library's *.dart file relative to this file
- * or null if dart2js uses the common library path defined above.
- * Access using the [#getDart2JsPath()] method.
- */
- final String dart2jsPath;
-
- /**
- * Path to the dart2js library's patch file relative to this file
- * or null if no dart2js patch file associated with this library.
- * Access using the [#getDart2JsPatchPath()] method.
- */
- final String dart2jsPatchPath;
-
- /**
- * True if this library is documented and should be shown to the user.
- */
- final bool documented;
-
- /**
- * Bit flags indicating which platforms consume this library.
- * See [DART2JS_LIBRARY] and [VM_LIBRARY].
- */
- final int platforms;
-
- /**
- * True if the library contains implementation details for another library.
- * The implication is that these libraries are less commonly used
- * and that tools like Dart Editor should not show these libraries
- * in a list of all libraries unless the user specifically asks the tool to
- * do so.
- */
- final bool implementation;
-
- /**
- * States the current maturity of this library.
- */
- final Maturity maturity;
-
- const LibraryInfo(this.path,
- {String categories: "",
- this.dart2jsPath,
- this.dart2jsPatchPath,
- this.implementation: false,
- this.documented: true,
- this.maturity: Maturity.UNSPECIFIED,
- this.platforms: DART2JS_PLATFORM | VM_PLATFORM})
- : _categories = categories;
-
- bool get isDart2jsLibrary => (platforms & DART2JS_PLATFORM) != 0;
- bool get isVmLibrary => (platforms & VM_PLATFORM) != 0;
-
- /**
- * The categories in which the library can be used.
- *
- * If no categories are specified, the library is internal and can not be
- * loaded by user code.
- */
- List<Category> get categories {
- // `"".split(,)` returns [""] not [], so we handle that case separately.
- if (_categories == "") return const <Category>[];
- return _categories.split(",").map(parseCategory).toList();
- }
-
- bool get isInternal => categories.isEmpty;
-
- /// The original "categories" String that was passed to the constructor.
- ///
- /// Can be used to construct a slightly modified copy of this LibraryInfo.
- String get categoriesString {
- return _categories;
- }
-}
-
-/**
- * Abstraction to capture the maturity of a library.
- */
-class Maturity {
- final int level;
- final String name;
- final String description;
-
- const Maturity(this.level, this.name, this.description);
-
- String toString() => "$name: $level\n$description\n";
-
- static const Maturity DEPRECATED = const Maturity(0, "Deprecated",
- "This library will be remove before next major release.");
-
- static const Maturity EXPERIMENTAL = const Maturity(
- 1,
- "Experimental",
- "This library is experimental and will likely change or be removed\n"
- "in future versions.");
-
- static const Maturity UNSTABLE = const Maturity(
- 2,
- "Unstable",
- "This library is in still changing and have not yet endured\n"
- "sufficient real-world testing.\n"
- "Backwards-compatibility is NOT guaranteed.");
-
- static const Maturity WEB_STABLE = const Maturity(
- 3,
- "Web Stable",
- "This library is tracking the DOM evolution as defined by WC3.\n"
- "Backwards-compatibility is NOT guaranteed.");
-
- static const Maturity STABLE = const Maturity(
- 4,
- "Stable",
- "The library is stable. API backwards-compatibility is guaranteed.\n"
- "However implementation details might change.");
-
- static const Maturity LOCKED = const Maturity(5, "Locked",
- "This library will not change except when serious bugs are encountered.");
-
- static const Maturity UNSPECIFIED = const Maturity(-1, "Unspecified",
- "The maturity for this library has not been specified.");
-}
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/patch/collection_patch.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/patch/collection_patch.dart
index daa3bf8..12dcbb5 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/patch/collection_patch.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/patch/collection_patch.dart
@@ -24,9 +24,9 @@
class HashMap<K, V> {
@patch
factory HashMap(
- {bool equals(K key1, K key2),
- int hashCode(K key),
- bool isValidKey(Object potentialKey)}) {
+ {bool Function(K, K)? equals,
+ int Function(K)? hashCode,
+ bool Function(dynamic)? isValidKey}) {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
@@ -54,9 +54,9 @@
class LinkedHashMap<K, V> {
@patch
factory LinkedHashMap(
- {bool equals(K key1, K key2),
- int hashCode(K key),
- bool isValidKey(Object potentialKey)}) {
+ {bool Function(K, K)? equals,
+ int Function(K)? hashCode,
+ bool Function(dynamic)? isValidKey}) {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
@@ -84,9 +84,9 @@
class HashSet<E> {
@patch
factory HashSet(
- {bool equals(E e1, E e2),
- int hashCode(E e),
- bool isValidKey(Object potentialKey)}) {
+ {bool Function(E, E)? equals,
+ int Function(E)? hashCode,
+ bool Function(dynamic)? isValidKey}) {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
@@ -115,9 +115,9 @@
class LinkedHashSet<E> {
@patch
factory LinkedHashSet(
- {bool equals(E e1, E e2),
- int hashCode(E e),
- bool isValidKey(Object potentialKey)}) {
+ {bool Function(E, E)? equals,
+ int Function(E)? hashCode,
+ bool Function(dynamic)? isValidKey}) {
if (isValidKey == null) {
if (hashCode == null) {
if (equals == null) {
@@ -178,13 +178,14 @@
Set<R> _newSimilarSet<R>() => _HashSet<R>();
- bool contains(Object key) {
+ bool contains(Object? key) {
if (key == null) {
+ // Convert undefined to null, if needed.
key = null;
} else if (JS<bool>('!', '#[#] !== #', key, dart.extensionSymbol('_equals'),
dart.identityEquals)) {
@notNull
- var k = key;
+ Object? k = key;
var buckets = JS('', '#.get(# & 0x3ffffff)', _keyMap, k.hashCode);
if (buckets != null) {
for (int i = 0, n = JS('!', '#.length', buckets); i < n; i++) {
@@ -197,12 +198,12 @@
return JS<bool>('!', '#.has(#)', _map, key);
}
- E lookup(Object key) {
+ E? lookup(Object? key) {
if (key == null) return null;
if (JS<bool>('!', '#[#] !== #', key, dart.extensionSymbol('_equals'),
dart.identityEquals)) {
@notNull
- var k = key;
+ Object? k = key;
var buckets = JS('', '#.get(# & 0x3ffffff)', _keyMap, k.hashCode);
if (buckets != null) {
for (int i = 0, n = JS('!', '#.length', buckets); i < n; i++) {
@@ -219,7 +220,8 @@
var map = _map;
if (key == null) {
if (JS('', '#.has(null)', map)) return false;
- key = null;
+ // Convert undefined to null, if needed.
+ JS('', '# = null', key);
} else if (JS<bool>('!', '#[#] !== #', key, dart.extensionSymbol('_equals'),
dart.identityEquals)) {
var keyMap = _keyMap;
@@ -249,7 +251,8 @@
int length = JS('', '#.size', map);
for (E key in objects) {
if (key == null) {
- key = null; // converts undefined to null, if needed.
+ // Convert undefined to null, if needed.
+ JS('', '# = null', key);
} else if (JS<bool>('!', '#[#] !== #', key,
dart.extensionSymbol('_equals'), dart.identityEquals)) {
key = putLinkedMapKey(key, _keyMap);
@@ -261,13 +264,14 @@
}
}
- bool remove(Object key) {
+ bool remove(Object? key) {
if (key == null) {
+ // Convert undefined to null, if needed.
key = null;
} else if (JS<bool>('!', '#[#] !== #', key, dart.extensionSymbol('_equals'),
dart.identityEquals)) {
@notNull
- var k = key;
+ Object? k = key;
int hash = JS('!', '# & 0x3ffffff', k.hashCode);
var buckets = JS('', '#.get(#)', _keyMap, hash);
if (buckets == null) return false; // not found
@@ -309,7 +313,8 @@
var map = _map;
for (Object key in entries) {
if (key == null) {
- key = null; // converts undefined to null, if needed.
+ // Convert undefined to null, if needed.
+ JS('', '# = null', key);
} else if (JS<bool>('!', '#[#] !== #', key,
dart.extensionSymbol('_equals'), dart.identityEquals)) {
key = putLinkedMapKey(key, _keyMap);
@@ -318,10 +323,10 @@
}
}
- bool add(Object other) => throw _unsupported();
- void addAll(Object other) => throw _unsupported();
+ bool add(E value) => throw _unsupported();
+ void addAll(Iterable<E> elements) => throw _unsupported();
void clear() => throw _unsupported();
- bool remove(Object key) => throw _unsupported();
+ bool remove(Object? value) => throw _unsupported();
static Error _unsupported() =>
UnsupportedError("Cannot modify unmodifiable set");
@@ -342,12 +347,14 @@
Set<R> _newSimilarSet<R>() => _IdentityHashSet<R>();
- bool contains(Object element) {
- return JS('', '#.has(#)', _map, element);
+ bool contains(Object? element) {
+ return JS<bool>('!', '#.has(#)', _map, element);
}
- E lookup(Object element) {
- return JS('', '#.has(#)', _map, element) ? element : null;
+ E? lookup(Object? element) {
+ return element is E && JS<bool>('!', '#.has(#)', _map, element)
+ ? element
+ : null;
}
bool add(E element) {
@@ -369,7 +376,7 @@
}
}
- bool remove(Object element) {
+ bool remove(Object? element) {
if (JS<bool>('!', '#.delete(#)', _map, element)) {
_modifications = (_modifications + 1) & 0x3ffffff;
return true;
@@ -387,7 +394,7 @@
}
class _CustomKeyHashSet<E> extends _CustomHashSet<E> {
- _Predicate<Object> _validKey;
+ _Predicate<Object?> _validKey;
_CustomKeyHashSet(_Equality<E> equals, _Hasher<E> hashCode, this._validKey)
: super(equals, hashCode);
@@ -395,7 +402,7 @@
Set<R> _newSimilarSet<R>() => _HashSet<R>();
- bool contains(Object element) {
+ bool contains(Object? element) {
// TODO(jmesserly): there is a subtle difference here compared to Dart 1.
// See the comment on CustomKeyHashMap.containsKey for more information.
// Treatment of `null` is different due to strong mode's requirement to
@@ -404,12 +411,12 @@
return super.contains(element);
}
- E lookup(Object element) {
+ E? lookup(Object? element) {
if (!_validKey(element)) return null;
return super.lookup(element);
}
- bool remove(Object element) {
+ bool remove(Object? element) {
if (!_validKey(element)) return false;
return super.remove(element);
}
@@ -445,7 +452,7 @@
Set<E> _newSet() => _CustomHashSet<E>(_equals, _hashCode);
Set<R> _newSimilarSet<R>() => _HashSet<R>();
- bool contains(Object key) {
+ bool contains(Object? key) {
if (key is E) {
var buckets = JS('', '#.get(# & 0x3ffffff)', _keyMap, _hashCode(key));
if (buckets != null) {
@@ -459,7 +466,7 @@
return false;
}
- E lookup(Object key) {
+ E? lookup(Object? key) {
if (key is E) {
var buckets = JS('', '#.get(# & 0x3ffffff)', _keyMap, _hashCode(key));
if (buckets != null) {
@@ -497,7 +504,7 @@
for (E element in objects) add(element);
}
- bool remove(Object key) {
+ bool remove(Object? key) {
if (key is E) {
var hash = JS<int>('!', '# & 0x3ffffff', _hashCode(key));
var keyMap = _keyMap;
@@ -578,24 +585,24 @@
abstract class _SplayTree<K, Node extends _SplayTreeNode<K>> {
@patch
Node _splayMin(Node node) {
- Node current = node;
+ var current = node;
while (current.left != null) {
- Node left = current.left;
+ var left = current.left!;
current.left = left.right;
left.right = current;
- current = left;
+ current = left as Node;
}
return current;
}
@patch
Node _splayMax(Node node) {
- Node current = node;
+ var current = node;
while (current.right != null) {
- Node right = current.right;
+ var right = current.right!;
current.right = right.left;
right.left = current;
- current = right;
+ current = right as Node;
}
return current;
}
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/patch/core_patch.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/patch/core_patch.dart
index a8e6e12..78b414b 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/patch/core_patch.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/patch/core_patch.dart
@@ -188,7 +188,7 @@
@patch
static int parse(String source,
{int? radix, @deprecated int onError(String source)?}) {
- return Primitives.parseInt(source, radix, onError);
+ return Primitives.parseInt(source, radix, onError)!;
}
@patch
@@ -234,7 +234,7 @@
@patch
static double parse(String source,
[@deprecated double onError(String source)?]) {
- return Primitives.parseDouble(source, onError);
+ return Primitives.parseDouble(source, onError)!;
}
@patch
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/patch/internal_patch.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/patch/internal_patch.dart
index 6ab95c4..58ff179 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/patch/internal_patch.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/patch/internal_patch.dart
@@ -2,6 +2,8 @@
// 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.
+import 'dart:core' hide Symbol;
+import 'dart:core' as core show Symbol;
import 'dart:_js_primitives' show printString;
import 'dart:_js_helper' show patch;
import 'dart:_interceptors' show JSArray;
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/annotations.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/annotations.dart
index 1673fd1..9062f31 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/annotations.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/annotations.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
part of dart._js_helper;
/// Tells the optimizing compiler to always inline the annotated method.
@@ -83,7 +81,7 @@
/// Used for classes where Dart subclasses should be callable from JavaScript
/// matching the JavaScript calling conventions.
final String name;
- const JsPeerInterface({this.name});
+ const JsPeerInterface({required this.name});
}
/// A Dart interface may only be implemented by a native JavaScript object
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/custom_hash_map.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/custom_hash_map.dart
index 07fc5c6..14444e3 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/custom_hash_map.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/custom_hash_map.dart
@@ -2,30 +2,28 @@
// 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.
-// @dart = 2.5
-
part of dart._js_helper;
class CustomKeyHashMap<K, V> extends CustomHashMap<K, V> {
- final _Predicate<Object> _validKey;
+ final _Predicate<Object?> _validKey;
CustomKeyHashMap(_Equality<K> equals, _Hasher<K> hashCode, this._validKey)
: super(equals, hashCode);
@override
@notNull
- bool containsKey(Object key) {
+ bool containsKey(Object? key) {
if (!_validKey(key)) return false;
return super.containsKey(key);
}
@override
- V operator [](Object key) {
+ V? operator [](Object? key) {
if (!_validKey(key)) return null;
return super[key];
}
@override
- V remove(Object key) {
+ V? remove(Object? key) {
if (!_validKey(key)) return null;
return super.remove(key);
}
@@ -69,7 +67,7 @@
Iterable<V> get values => _JSMapIterable<V>(this, false);
@notNull
- bool containsKey(Object key) {
+ bool containsKey(Object? key) {
if (key is K) {
var buckets = JS('', '#.get(# & 0x3ffffff)', _keyMap, _hashCode(key));
if (buckets != null) {
@@ -83,7 +81,7 @@
return false;
}
- bool containsValue(Object value) {
+ bool containsValue(Object? value) {
for (var v in JS('', '#.values()', _map)) {
if (value == v) return true;
}
@@ -96,7 +94,7 @@
});
}
- V operator [](Object key) {
+ V? operator [](Object? key) {
if (key is K) {
var buckets = JS('', '#.get(# & 0x3ffffff)', _keyMap, _hashCode(key));
if (buckets != null) {
@@ -152,13 +150,13 @@
JS('', '#.push(#)', buckets, key);
}
V value = ifAbsent();
- if (value == null) value = null; // coerce undefined to null.
+ if (value == null) JS('', '# = null', value); // coerce undefined to null.
JS('', '#.set(#, #)', _map, key, value);
_modifications = (_modifications + 1) & 0x3ffffff;
return value;
}
- V remove(Object key) {
+ V? remove(Object? key) {
if (key is K) {
int hash = JS('!', '# & 0x3ffffff', _hashCode(key));
var keyMap = _keyMap;
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/debugger.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/debugger.dart
index f6ec3b3..0e3d787 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/debugger.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/debugger.dart
@@ -10,7 +10,6 @@
import 'dart:_runtime' as dart;
import 'dart:core';
import 'dart:collection';
-import 'dart:html' as html;
import 'dart:math';
part 'profile.dart';
@@ -341,7 +340,7 @@
// Treat Node objects as a native JavaScript type as the regular DOM render
// in devtools is superior to the dart specific view.
- return object is html.Node;
+ return JS<bool>('!', '# instanceof Node', object);
}
/// Class implementing the Devtools Formatter API described by:
@@ -486,7 +485,7 @@
} catch (e, trace) {
// Log formatter internal errors as unfortunately the devtools cannot
// be used to debug formatter errors.
- html.window.console.error("Caught exception $e\n trace:\n$trace");
+ _printConsoleError("Caught exception $e\n trace:\n$trace");
}
return null;
@@ -501,8 +500,7 @@
}
} catch (e, trace) {
// See comment for preview.
- html.window.console
- .error("[hasChildren] Caught exception $e\n trace:\n$trace");
+ _printConsoleError("[hasChildren] Caught exception $e\n trace:\n$trace");
}
return false;
}
@@ -517,10 +515,13 @@
}
} catch (e, trace) {
// See comment for preview.
- html.window.console.error("Caught exception $e\n trace:\n$trace");
+ _printConsoleError("Caught exception $e\n trace:\n$trace");
}
return <NameValuePair>[];
}
+
+ void _printConsoleError(String message) =>
+ JS('', 'window.console.error(#)', message);
}
/// Default formatter for Dart Objects.
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/identity_hash_map.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/identity_hash_map.dart
index 3918bea..eda6c44 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/identity_hash_map.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/identity_hash_map.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
part of dart._js_helper;
class IdentityMap<K, V> extends InternalMap<K, V> {
@@ -35,11 +33,11 @@
Iterable<K> get keys => _JSMapIterable<K>(this, true);
Iterable<V> get values => _JSMapIterable<V>(this, false);
- bool containsKey(Object key) {
+ bool containsKey(Object? key) {
return JS<bool>('!', '#.has(#)', _map, key);
}
- bool containsValue(Object value) {
+ bool containsValue(Object? value) {
for (var v in JS('', '#.values()', _map)) {
if (v == value) return true;
}
@@ -56,7 +54,7 @@
}
}
- V operator [](Object key) {
+ V? operator [](Object? key) {
V value = JS('', '#.get(#)', _map, key);
return value == null ? null : value; // coerce undefined to null.
}
@@ -75,13 +73,13 @@
return JS('', '#.get(#)', _map, key);
}
V value = ifAbsent();
- if (value == null) value = null; // coerce undefined to null.
+ if (value == null) JS('', '# = null', value);
JS('', '#.set(#, #)', _map, key, value);
_modifications = (_modifications + 1) & 0x3ffffff;
return value;
}
- V remove(Object key) {
+ V? remove(Object? key) {
V value = JS('', '#.get(#)', _map, key);
if (JS<bool>('!', '#.delete(#)', _map, key)) {
_modifications = (_modifications + 1) & 0x3ffffff;
@@ -130,10 +128,10 @@
Iterator<E> get iterator => DartIterator<E>(_jsIterator());
- bool contains(Object element) =>
+ bool contains(Object? element) =>
_isKeys ? _map.containsKey(element) : _map.containsValue(element);
- void forEach(void f(E element)) {
+ void forEach(void Function(E) f) {
for (var entry in this) f(entry);
}
}
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/interceptors.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/interceptors.dart
index 1de2473..d41ab6a 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/interceptors.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/interceptors.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
library dart._interceptors;
import 'dart:collection';
@@ -122,7 +120,7 @@
static final _extensionName = RegExp(r"^Symbol\(dartx\.(.+)\)$");
static final _privateName = RegExp(r"^Symbol\((_.+)\)$");
- String _fieldName(String message) {
+ String? _fieldName(String message) {
var match = _nullError.firstMatch(message);
if (match == null) return null;
var name = match[1];
@@ -130,7 +128,7 @@
return match != null ? match[1] : name;
}
- String _functionCallTarget(String message) {
+ String? _functionCallTarget(String message) {
var match = _notAFunction.firstMatch(message);
return match != null ? match[1] : null;
}
@@ -180,7 +178,7 @@
// TODO(jmesserly): remove these once we canonicalize tearoffs.
operator ==(other) {
if (other == null) return false;
- var boundObj = JS<Object>('', '#._boundObject', this);
+ var boundObj = JS<Object?>('', '#._boundObject', this);
if (boundObj == null) return JS<bool>('!', '# === #', this, other);
return JS(
'bool',
@@ -192,7 +190,7 @@
}
get hashCode {
- var boundObj = JS<Object>('', '#._boundObject', this);
+ var boundObj = JS<Object?>('', '#._boundObject', this);
if (boundObj == null) return identityHashCode(this);
var boundMethod = JS<Object>('!', '#._boundMethod', this);
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_array.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_array.dart
index 1818f08..f064b24 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_array.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_array.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
part of dart._interceptors;
/**
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_helper.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_helper.dart
index dcf1866..b9c1f7a 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_helper.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_helper.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
library dart._js_helper;
import 'dart:collection';
@@ -45,11 +43,11 @@
// https://github.com/dart-lang/sdk/issues/28320
class DartIterator<E> implements Iterator<E> {
final _jsIterator;
- E _current;
+ E? _current;
DartIterator(this._jsIterator);
- E get current => _current;
+ E get current => _current as E;
bool moveNext() {
final ret = JS('', '#.next()', _jsIterator);
@@ -71,17 +69,18 @@
class Primitives {
@NoInline()
- static int _parseIntError(String source, int handleError(String source)) {
+ static int? _parseIntError(
+ String source, int? Function(String)? handleError) {
if (handleError == null) throw FormatException(source);
return handleError(source);
}
- static int parseInt(
- @nullCheck String source, int _radix, int handleError(String source)) {
+ static int? parseInt(@nullCheck String source, int? _radix,
+ int? Function(String)? handleError) {
var re = JS('', r'/^\s*[+-]?((0x[a-f0-9]+)|(\d+)|([a-z0-9]+))\s*$/i');
// TODO(jmesserly): this isn't reified List<String>, but it's safe to use as
// long as we use it locally and don't expose it to user code.
- List<String> match = JS('', '#.exec(#)', re, source);
+ List<String>? match = JS('', '#.exec(#)', re, source);
int digitsIndex = 1;
int hexIndex = 2;
int decimalIndex = 3;
@@ -91,7 +90,7 @@
// again.
return _parseIntError(source, handleError);
}
- String decimalMatch = match[decimalIndex];
+ String? decimalMatch = match[decimalIndex];
if (_radix == null) {
if (decimalMatch != null) {
// Cannot fail because we know that the digits are all decimal.
@@ -148,16 +147,16 @@
}
@NoInline()
- static double _parseDoubleError(
- String source, double handleError(String source)) {
+ static double? _parseDoubleError(
+ String source, double? Function(String)? handleError) {
if (handleError == null) {
throw FormatException('Invalid double', source);
}
return handleError(source);
}
- static double parseDouble(
- @nullCheck String source, double handleError(String source)) {
+ static double? parseDouble(
+ @nullCheck String source, double? Function(String)? handleError) {
// Notice that JS parseFloat accepts garbage at the end of the string.
// Accept only:
// - [+/-]NaN
@@ -171,7 +170,7 @@
source)) {
return _parseDoubleError(source, handleError);
}
- num result = JS('!', r'parseFloat(#)', source);
+ double result = JS('!', r'parseFloat(#)', source);
if (result.isNaN) {
var trimmed = source.trim();
if (trimmed == 'NaN' || trimmed == '+NaN' || trimmed == '-NaN') {
@@ -188,7 +187,7 @@
static int dateNow() => JS<int>('!', r'Date.now()');
static void initTicker() {
- if (timerFrequency != null) return;
+ if (timerFrequency != 0) return;
// Start with low-resolution. We overwrite the fields if we find better.
timerFrequency = 1000;
timerTicks = dateNow;
@@ -202,8 +201,9 @@
timerTicks = () => (1000 * JS<num>('!', '#.now()', performance)).floor();
}
- static int timerFrequency;
- static int Function() timerTicks;
+ /// 0 frequency indicates the default uninitialized state.
+ static int timerFrequency = 0;
+ static late int Function() timerTicks;
static bool get isD8 {
return JS(
@@ -268,7 +268,7 @@
}
@notNull
- static String stringFromCharCodes(List<int> charCodes) {
+ static String stringFromCharCodes(JSArray<int> charCodes) {
for (@nullCheck var i in charCodes) {
if (i < 0) throw argumentErrorValue(i);
if (i > 0xffff) return stringFromCodePoints(charCodes);
@@ -327,7 +327,7 @@
// Example: "Wed May 16 2012 21:13:00 GMT+0200 (CEST)".
// We extract this name using a regexp.
var d = lazyAsJsDate(receiver);
- List match = JS('JSArray|Null', r'/\((.*)\)/.exec(#.toString())', d);
+ List? match = JS('JSArray|Null', r'/\((.*)\)/.exec(#.toString())', d);
if (match != null) return match[1];
// Internet Explorer 10+ emits the zone name without parenthesis:
@@ -362,7 +362,7 @@
return -JS<int>('!', r'#.getTimezoneOffset()', lazyAsJsDate(receiver));
}
- static int valueFromDecomposedDate(
+ static int? valueFromDecomposedDate(
@nullCheck int years,
@nullCheck int month,
@nullCheck int day,
@@ -373,7 +373,7 @@
@nullCheck bool isUtc) {
final int MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000;
var jsMonth = month - 1;
- num value;
+ int value;
if (isUtc) {
value = JS<int>('!', r'Date.UTC(#, #, #, #, #, #, #)', years, jsMonth,
day, hours, minutes, seconds, milliseconds);
@@ -506,7 +506,7 @@
* describes the problem.
*/
@NoInline()
-Error diagnoseRangeError(int start, int end, int length) {
+Error diagnoseRangeError(int? start, int? end, int length) {
if (start == null) {
return ArgumentError.value(start, 'start');
}
@@ -555,9 +555,9 @@
}
class JsNoSuchMethodError extends Error implements NoSuchMethodError {
- final String _message;
- final String _method;
- final String _receiver;
+ final String? _message;
+ final String? _method;
+ final String? _receiver;
JsNoSuchMethodError(this._message, match)
: _method = match == null ? null : JS('String|Null', '#.method', match),
@@ -599,11 +599,11 @@
return result;
}
-bool jsHasOwnProperty(var jsObject, String property) {
+bool jsHasOwnProperty(jsObject, String property) {
return JS<bool>('!', r'#.hasOwnProperty(#)', jsObject, property);
}
-jsPropertyAccess(var jsObject, String property) {
+jsPropertyAccess(jsObject, String property) {
return JS('var', r'#[#]', jsObject, property);
}
@@ -740,12 +740,12 @@
/// Error thrown by DDC when an `assert()` fails (with or without a message).
class AssertionErrorImpl extends AssertionError {
- final String _fileUri;
- final int _line;
- final int _column;
- final String _conditionSource;
+ final String? _fileUri;
+ final int? _line;
+ final int? _column;
+ final String? _conditionSource;
- AssertionErrorImpl(Object message,
+ AssertionErrorImpl(Object? message,
[this._fileUri, this._line, this._column, this._conditionSource])
: super(message);
@@ -811,7 +811,7 @@
static String getName(Symbol symbol) => (symbol as PrivateSymbol)._name;
- static Object getNativeSymbol(Symbol symbol) {
+ static Object? getNativeSymbol(Symbol symbol) {
if (symbol is PrivateSymbol) return symbol._nativeSymbol;
return null;
}
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_number.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_number.dart
index 36350b6..5f8c7e0 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_number.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_number.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
part of dart._interceptors;
/**
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_primitives.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_primitives.dart
index addcd83..1347b62 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_primitives.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_primitives.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
/// dart2js "primitives", that is, features that cannot be implemented without
/// access to JavaScript features.
library dart2js._js_primitives;
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_rti.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_rti.dart
index 37a9644..483e721 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_rti.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_rti.dart
@@ -2,28 +2,26 @@
// 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.
-// @dart = 2.5
-
part of dart._js_helper;
// TODO(leafp): Maybe get rid of this? Currently used by the interceptors
// library, but that should probably be culled as well.
-Type getRuntimeType(var object) =>
+Type? getRuntimeType(object) =>
JS('Type|null', 'dart.getReifiedType(#)', object);
/// Returns the property [index] of the JavaScript array [array].
-getIndex(var array, int index) {
+getIndex(array, int index) {
assert(isJsArray(array));
return JS('var', r'#[#]', array, index);
}
/// Returns the length of the JavaScript array [array].
-int getLength(var array) {
+int getLength(array) {
assert(isJsArray(array));
return JS<int>('!', r'#.length', array);
}
/// Returns whether [value] is a JavaScript array.
-bool isJsArray(var value) {
+bool isJsArray(value) {
return value is JSArray;
}
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_string.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_string.dart
index 90e39ae..1574e59 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_string.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/js_string.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
part of dart._interceptors;
/**
@@ -37,7 +35,7 @@
return allMatchesInStringUnchecked(this, string, start);
}
- Match matchAsPrefix(@nullCheck String string, [@nullCheck int start = 0]) {
+ Match? matchAsPrefix(@nullCheck String string, [@nullCheck int start = 0]) {
int stringLength = JS('!', '#.length', string);
if (start < 0 || start > stringLength) {
throw RangeError.range(start, 0, stringLength);
@@ -71,13 +69,13 @@
}
@notNull
- String replaceAllMapped(Pattern from, String convert(Match match)) {
+ String replaceAllMapped(Pattern from, String Function(Match) convert) {
return this.splitMapJoin(from, onMatch: convert);
}
@notNull
String splitMapJoin(Pattern from,
- {String onMatch(Match match), String onNonMatch(String nonMatch)}) {
+ {String Function(Match)? onMatch, String Function(String)? onNonMatch}) {
return stringReplaceAllFuncUnchecked(this, from, onMatch, onNonMatch);
}
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/linked_hash_map.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/linked_hash_map.dart
index 04f8a5c..405e38c 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/linked_hash_map.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/linked_hash_map.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
// Efficient JavaScript based implementation of a linked hash map used as a
// backing map for constant maps and the [LinkedHashMap] patch
@@ -74,7 +72,7 @@
K key = JS('', '#[#]', entries, i);
V value = JS('', '#[#]', entries, i + 1);
if (key == null) {
- key = null;
+ JS('', '# = null', key);
} else if (JS<bool>('!', '#[#] !== #', key,
dart.extensionSymbol('_equals'), dart.identityEquals)) {
key = putLinkedMapKey(key, keyMap);
@@ -96,17 +94,16 @@
Iterable<V> get values => _JSMapIterable<V>(this, false);
@notNull
- bool containsKey(Object key) {
+ bool containsKey(Object? key) {
if (key == null) {
- key = null;
+ JS('', '# = null', key);
} else if (JS<bool>('!', '#[#] !== #', key, dart.extensionSymbol('_equals'),
dart.identityEquals)) {
@notNull
- var k = key;
- var buckets = JS('', '#.get(# & 0x3ffffff)', _keyMap, k.hashCode);
+ var buckets = JS('', '#.get(# & 0x3ffffff)', _keyMap, key.hashCode);
if (buckets != null) {
for (int i = 0, n = JS('!', '#.length', buckets); i < n; i++) {
- k = JS('', '#[#]', buckets, i);
+ K k = JS('', '#[#]', buckets, i);
if (k == key) return true;
}
}
@@ -115,7 +112,7 @@
return JS<bool>('!', '#.has(#)', _map, key);
}
- bool containsValue(Object value) {
+ bool containsValue(Object? value) {
for (var v in JS('', '#.values()', _map)) {
if (v == value) return true;
}
@@ -127,7 +124,7 @@
int length = JS('', '#.size', map);
other.forEach((K key, V value) {
if (key == null) {
- key = null;
+ JS('', '# = null', key);
} else if (JS<bool>('!', '#[#] !== #', key,
dart.extensionSymbol('_equals'), dart.identityEquals)) {
key = putLinkedMapKey(key, _keyMap);
@@ -139,17 +136,16 @@
}
}
- V operator [](Object key) {
+ V? operator [](Object? key) {
if (key == null) {
- key = null;
+ JS('', '# = null', key);
} else if (JS<bool>('!', '#[#] !== #', key, dart.extensionSymbol('_equals'),
dart.identityEquals)) {
@notNull
- var k = key;
- var buckets = JS('', '#.get(# & 0x3ffffff)', _keyMap, k.hashCode);
+ var buckets = JS('', '#.get(# & 0x3ffffff)', _keyMap, key.hashCode);
if (buckets != null) {
for (int i = 0, n = JS('!', '#.length', buckets); i < n; i++) {
- k = JS('', '#[#]', buckets, i);
+ K k = JS('', '#[#]', buckets, i);
if (k == key) return JS('', '#.get(#)', _map, k);
}
}
@@ -161,7 +157,7 @@
void operator []=(K key, V value) {
if (key == null) {
- key = null;
+ JS('', '# = null', key);
} else if (JS<bool>('!', '#[#] !== #', key, dart.extensionSymbol('_equals'),
dart.identityEquals)) {
key = putLinkedMapKey(key, _keyMap);
@@ -177,7 +173,7 @@
V putIfAbsent(K key, V ifAbsent()) {
var map = _map;
if (key == null) {
- key = null;
+ JS('', '# = null', key);
if (JS<bool>('!', '#.has(null)', map)) return JS('', '#.get(null)', map);
} else if (JS<bool>('!', '#[#] !== #', key, dart.extensionSymbol('_equals'),
dart.identityEquals)) {
@@ -198,24 +194,23 @@
return JS('', '#.get(#)', map, key);
}
V value = ifAbsent();
- if (value == null) value = null; // coerce undefined to null.
+ if (value == null) JS('', '# = null', value);
JS('', '#.set(#, #)', map, key, value);
_modifications = (_modifications + 1) & 0x3ffffff;
return value;
}
- V remove(Object key) {
+ V? remove(Object? key) {
if (key == null) {
- key = null;
+ JS('', '# = null', key);
} else if (JS<bool>('!', '#[#] !== #', key, dart.extensionSymbol('_equals'),
dart.identityEquals)) {
@notNull
- var k = key;
- var hash = JS<int>('!', '# & 0x3ffffff', k.hashCode);
+ var hash = JS<int>('!', '# & 0x3ffffff', key.hashCode);
var buckets = JS('', '#.get(#)', _keyMap, hash);
if (buckets == null) return null; // not found
for (int i = 0, n = JS('!', '#.length', buckets);;) {
- k = JS('', '#[#]', buckets, i);
+ K k = JS('', '#[#]', buckets, i);
if (k == key) {
key = k;
if (n == 1) {
@@ -266,14 +261,14 @@
class ImmutableMap<K, V> extends LinkedMap<K, V> {
ImmutableMap.from(JSArray entries) : super.from(entries);
- void operator []=(Object key, Object value) {
+ void operator []=(K key, V value) {
throw _unsupported();
}
void addAll(Object other) => throw _unsupported();
void clear() => throw _unsupported();
- V remove(Object key) => throw _unsupported();
- V putIfAbsent(Object key, Object ifAbsent()) => throw _unsupported();
+ V? remove(Object? key) => throw _unsupported();
+ V putIfAbsent(K key, V ifAbsent()) => throw _unsupported();
static Error _unsupported() =>
UnsupportedError("Cannot modify unmodifiable map");
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/native_helper.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/native_helper.dart
index c36cd41..cc214e8 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/native_helper.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/native_helper.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
part of dart._js_helper;
// Obsolete in dart dev compiler. Added only so that the same version of
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/regexp_helper.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/regexp_helper.dart
index ecd69c65..2c90cdf 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/regexp_helper.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/regexp_helper.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
part of dart._js_helper;
// Helper method used by internal libraries.
@@ -117,8 +115,8 @@
throw FormatException("Illegal RegExp pattern: $source, $errorMessage");
}
- RegExpMatch firstMatch(@nullCheck String string) {
- List m = JS('JSExtendableArray|Null', r'#.exec(#)', _nativeRegExp, string);
+ RegExpMatch? firstMatch(@nullCheck String string) {
+ List? m = JS('JSExtendableArray|Null', r'#.exec(#)', _nativeRegExp, string);
if (m == null) return null;
return _MatchImplementation(this, JSArray<String>.of(m));
}
@@ -128,7 +126,7 @@
return JS<bool>('!', r'#.test(#)', _nativeRegExp, string);
}
- String stringMatch(String string) {
+ String? stringMatch(String string) {
var match = firstMatch(string);
if (match != null) return match.group(0);
return null;
@@ -142,18 +140,18 @@
return _AllMatchesIterable(this, string, start);
}
- RegExpMatch _execGlobal(String string, int start) {
+ RegExpMatch? _execGlobal(String string, int start) {
Object regexp = _nativeGlobalVersion;
JS("void", "#.lastIndex = #", regexp, start);
- List match = JS("JSExtendableArray|Null", "#.exec(#)", regexp, string);
+ List? match = JS("JSExtendableArray|Null", "#.exec(#)", regexp, string);
if (match == null) return null;
return _MatchImplementation(this, JSArray<String>.of(match));
}
- RegExpMatch _execAnchored(String string, int start) {
+ RegExpMatch? _execAnchored(String string, int start) {
Object regexp = _nativeAnchoredVersion;
JS("void", "#.lastIndex = #", regexp, start);
- List match = JS("JSExtendableArray|Null", "#.exec(#)", regexp, string);
+ List? match = JS("JSExtendableArray|Null", "#.exec(#)", regexp, string);
if (match == null) return null;
// If the last capture group participated, the original regexp did not
// match at the start position.
@@ -162,7 +160,7 @@
return _MatchImplementation(this, JSArray<String>.of(match));
}
- RegExpMatch matchAsPrefix(String string, [int start = 0]) {
+ RegExpMatch? matchAsPrefix(String string, [int start = 0]) {
if (start < 0 || start > string.length) {
throw RangeError.range(start, 0, string.length);
}
@@ -236,13 +234,13 @@
class _AllMatchesIterator implements Iterator<RegExpMatch> {
final JSSyntaxRegExp _regExp;
- String _string;
+ String? _string;
int _nextIndex;
- RegExpMatch _current;
+ RegExpMatch? _current;
_AllMatchesIterator(this._regExp, this._string, this._nextIndex);
- RegExpMatch get current => _current;
+ RegExpMatch get current => _current as RegExpMatch;
static bool _isLeadSurrogate(int c) {
return c >= 0xd800 && c <= 0xdbff;
@@ -253,9 +251,10 @@
}
bool moveNext() {
- if (_string == null) return false;
- if (_nextIndex <= _string.length) {
- var match = _regExp._execGlobal(_string, _nextIndex);
+ var string = _string;
+ if (string == null) return false;
+ if (_nextIndex <= string.length) {
+ var match = _regExp._execGlobal(string, _nextIndex);
if (match != null) {
_current = match;
int nextIndex = match.end;
@@ -264,9 +263,9 @@
// is in unicode mode and it would put us within a surrogate
// pair. In that case, advance past the code point as a whole.
if (_regExp.isUnicode &&
- _nextIndex + 1 < _string.length &&
- _isLeadSurrogate(_string.codeUnitAt(_nextIndex)) &&
- _isTrailSurrogate(_string.codeUnitAt(_nextIndex + 1))) {
+ _nextIndex + 1 < string.length &&
+ _isLeadSurrogate(string.codeUnitAt(_nextIndex)) &&
+ _isTrailSurrogate(string.codeUnitAt(_nextIndex + 1))) {
nextIndex++;
}
nextIndex++;
@@ -282,6 +281,6 @@
}
/** Find the first match of [regExp] in [string] at or after [start]. */
-RegExpMatch firstMatchAfter(JSSyntaxRegExp regExp, String string, int start) {
+RegExpMatch? firstMatchAfter(JSSyntaxRegExp regExp, String string, int start) {
return regExp._execGlobal(string, start);
}
diff --git a/sdk_nnbd/lib/_internal/js_dev_runtime/private/string_helper.dart b/sdk_nnbd/lib/_internal/js_dev_runtime/private/string_helper.dart
index 81bc0c7..ceb9f11 100644
--- a/sdk_nnbd/lib/_internal/js_dev_runtime/private/string_helper.dart
+++ b/sdk_nnbd/lib/_internal/js_dev_runtime/private/string_helper.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.5
-
part of dart._js_helper;
@notNull
@@ -81,7 +79,7 @@
final String _input;
final String _pattern;
int _index;
- Match _current;
+ Match? _current;
_StringAllMatchesIterator(this._input, this._pattern, this._index);
@@ -104,7 +102,7 @@
return true;
}
- Match get current => _current;
+ Match get current => _current!;
}
@notNull
@@ -176,15 +174,15 @@
}
}
-String _matchString(Match match) => match[0];
+String _matchString(Match match) => match[0]!;
String _stringIdentity(String string) => string;
@notNull
String stringReplaceAllFuncUnchecked(
String receiver,
@nullCheck Pattern pattern,
- String onMatch(Match match),
- String onNonMatch(String nonMatch)) {
+ String Function(Match)? onMatch,
+ String Function(String)? onNonMatch) {
if (onMatch == null) onMatch = _matchString;
if (onNonMatch == null) onNonMatch = _stringIdentity;
if (pattern is String) {
diff --git a/sdk_nnbd/lib/_internal/js_runtime/lib/rti.dart b/sdk_nnbd/lib/_internal/js_runtime/lib/rti.dart
index 9b9e648..fdd1aef 100644
--- a/sdk_nnbd/lib/_internal/js_runtime/lib/rti.dart
+++ b/sdk_nnbd/lib/_internal/js_runtime/lib/rti.dart
@@ -1315,11 +1315,13 @@
'#: new Map(),'
'#: {},'
'#: {},'
+ '#: {},'
'#: [],' // shared empty array.
'}',
RtiUniverseFieldNames.evalCache,
RtiUniverseFieldNames.typeRules,
RtiUniverseFieldNames.erasedTypes,
+ RtiUniverseFieldNames.typeParameterVariances,
RtiUniverseFieldNames.sharedEmptyArray);
}
@@ -1334,6 +1336,9 @@
static Object erasedTypes(universe) =>
JS('', '#.#', universe, RtiUniverseFieldNames.erasedTypes);
+ static Object typeParameterVariances(universe) =>
+ JS('', '#.#', universe, RtiUniverseFieldNames.typeParameterVariances);
+
static Object _findRule(universe, String targetType) =>
JS('', '#.#', typeRules(universe), targetType);
@@ -1365,12 +1370,18 @@
}
}
+ static Object findTypeParameterVariances(universe, String cls) =>
+ JS('', '#.#', typeParameterVariances(universe), cls);
+
static void addRules(universe, rules) =>
_Utils.objectAssign(typeRules(universe), rules);
static void addErasedTypes(universe, types) =>
_Utils.objectAssign(erasedTypes(universe), types);
+ static void addTypeParameterVariances(universe, variances) =>
+ _Utils.objectAssign(typeParameterVariances(universe), variances);
+
static Object sharedEmptyArray(universe) =>
JS('JSArray', '#.#', universe, RtiUniverseFieldNames.sharedEmptyArray);
@@ -2247,6 +2258,15 @@
JS('', '#.#', rule, supertype);
}
+// This needs to be kept in sync with `Variance` in `entities.dart`.
+class Variance {
+ // TODO(fishythefish): Try bitmask representation.
+ static const legacyCovariant = 0;
+ static const covariant = 1;
+ static const contravariant = 2;
+ static const invariant = 3;
+}
+
// -------- Subtype tests ------------------------------------------------------
// Future entry point from compiled code.
@@ -2431,10 +2451,41 @@
var sArgs = Rti._getInterfaceTypeArguments(s);
int length = _Utils.arrayLength(sArgs);
assert(length == _Utils.arrayLength(tArgs));
+
+ var sVariances;
+ bool hasVariances;
+ if (JS_GET_FLAG("VARIANCE")) {
+ sVariances = _Universe.findTypeParameterVariances(universe, sName);
+ hasVariances = sVariances != null;
+ assert(!hasVariances || length == _Utils.arrayLength(sVariances));
+ }
+
for (int i = 0; i < length; i++) {
Rti sArg = _castToRti(_Utils.arrayAt(sArgs, i));
Rti tArg = _castToRti(_Utils.arrayAt(tArgs, i));
- if (!_isSubtype(universe, sArg, sEnv, tArg, tEnv)) return false;
+ if (JS_GET_FLAG("VARIANCE")) {
+ int sVariance = hasVariances
+ ? _Utils.asInt(_Utils.arrayAt(sVariances, i))
+ : Variance.legacyCovariant;
+ switch (sVariance) {
+ case Variance.legacyCovariant:
+ case Variance.covariant:
+ if (!_isSubtype(universe, sArg, sEnv, tArg, tEnv)) return false;
+ break;
+ case Variance.contravariant:
+ if (!_isSubtype(universe, tArg, tEnv, sArg, sEnv)) return false;
+ break;
+ case Variance.invariant:
+ if (!_isSubtype(universe, sArg, sEnv, tArg, tEnv) ||
+ !_isSubtype(universe, tArg, tEnv, sArg, sEnv)) return false;
+ break;
+ default:
+ throw StateError(
+ "Unknown variance given for subtype check: $sVariance");
+ }
+ } else {
+ if (!_isSubtype(universe, sArg, sEnv, tArg, tEnv)) return false;
+ }
}
return true;
}
@@ -2665,6 +2716,10 @@
_Universe.addRules(universe, rules);
}
+void testingAddTypeParameterVariances(universe, variances) {
+ _Universe.addTypeParameterVariances(universe, variances);
+}
+
bool testingIsSubtype(universe, rti1, rti2) {
return isSubtype(universe, _castToRti(rti1), _castToRti(rti2));
}
diff --git a/sdk_nnbd/lib/_internal/js_runtime/lib/shared/embedded_names.dart b/sdk_nnbd/lib/_internal/js_runtime/lib/shared/embedded_names.dart
index 99435c0..fd2477a 100644
--- a/sdk_nnbd/lib/_internal/js_runtime/lib/shared/embedded_names.dart
+++ b/sdk_nnbd/lib/_internal/js_runtime/lib/shared/embedded_names.dart
@@ -461,5 +461,6 @@
static String evalCache = 'eC';
static String typeRules = 'tR';
static String erasedTypes = 'eT';
+ static String typeParameterVariances = 'tPV';
static String sharedEmptyArray = 'sEA';
}
diff --git a/sdk_nnbd/lib/_internal/vm/bin/builtin.dart b/sdk_nnbd/lib/_internal/vm/bin/builtin.dart
index 84a91cb..a569688 100644
--- a/sdk_nnbd/lib/_internal/vm/bin/builtin.dart
+++ b/sdk_nnbd/lib/_internal/vm/bin/builtin.dart
@@ -47,8 +47,6 @@
// Requests made to the service isolate over the load port.
// Extra requests. Keep these in sync between loader.dart and builtin.dart.
-const _Dart_kResourceLoad = 5; // Resource class support.
-const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory.
const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file.
const _Dart_kResolvePackageUri = 8; // Resolve a package: uri.
@@ -76,8 +74,6 @@
// package imports can be resolved relative to it. The root script is the basis
// for the root library in the VM.
Uri _rootScript;
-// The package root set on the command line.
-Uri _packageRoot;
// Special handling for Windows paths so that they are compatible with URI
// handling.
@@ -157,38 +153,6 @@
}
// Embedder Entrypoint:
-// The embedder calls this method with a custom package root.
-@pragma("vm:entry-point")
-String _setPackageRoot(String packageRoot) {
- if (!_setupCompleted) {
- _setupHooks();
- }
- if (_traceLoading) {
- _log('Setting package root: $packageRoot');
- }
- if (packageRoot.startsWith('file:') ||
- packageRoot.startsWith('http:') ||
- packageRoot.startsWith('https:')) {
- packageRoot = _enforceTrailingSlash(packageRoot);
- _packageRoot = _workingDirectory.resolve(packageRoot);
- } else {
- packageRoot = _sanitizeWindowsPath(packageRoot);
- packageRoot = _trimWindowsPath(packageRoot);
- _packageRoot = _workingDirectory.resolveUri(new Uri.directory(packageRoot));
- }
- // Now that we have determined the packageRoot value being used, set it
- // up for use in Platform.packageRoot. This is only set when the embedder
- // sets up the package root. Automatically discovered package root will
- // not update the VMLibraryHooks value.
- var packageRootStr = _packageRoot.toString();
- VMLibraryHooks.packageRootString = packageRootStr;
- if (_traceLoading) {
- _log('Package root URI: $_packageRoot');
- }
- return packageRootStr;
-}
-
-// Embedder Entrypoint:
@pragma("vm:entry-point")
String _setPackagesMap(String packagesParam) {
if (!_setupCompleted) {
@@ -248,72 +212,14 @@
return scriptUri.toString();
}
-// Only used by vm/cc unit tests.
-Uri _resolvePackageUri(Uri uri) {
- assert(_packageRoot != null);
- return _packageRoot.resolve(uri.path);
-}
-
-// Returns either a file path or a URI starting with http[s]:, as a String.
-String _filePathFromUri(String userUri) {
- var uri = Uri.parse(userUri);
- if (_traceLoading) {
- _log('Getting file path from: $uri');
- }
-
- var path;
- switch (uri.scheme) {
- case '':
- case 'file':
- return uri.toFilePath();
- case 'package':
- return _filePathFromUri(_resolvePackageUri(uri).toString());
- case 'data':
- case 'http':
- case 'https':
- return uri.toString();
- default:
- // Only handling file, http, and package URIs
- // in standalone binary.
- if (_traceLoading) {
- _log('Unknown scheme (${uri.scheme}) in $uri.');
- }
- throw 'Not a known scheme: $uri';
- }
-}
-
// Register callbacks and hooks with the rest of the core libraries.
@pragma("vm:entry-point")
_setupHooks() {
_setupCompleted = true;
- VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes;
-
- VMLibraryHooks.packageRootUriFuture = _getPackageRootFuture;
VMLibraryHooks.packageConfigUriFuture = _getPackageConfigFuture;
VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture;
}
-// Handling of Resource class by dispatching to the load port.
-Future<List<int>> _resourceReadAsBytes(Uri uri) async {
- List response =
- await _makeLoaderRequest<List<int>>(_Dart_kResourceLoad, uri.toString());
- if (response[4] is String) {
- // Throw the error.
- throw response[4];
- } else {
- return response[4];
- }
-}
-
-// TODO(mfairhurst): remove this
-Future<Uri> _getPackageRootFuture() {
- if (_traceLoading) {
- _log("Request for package root from user code.");
- }
- // Return null, as the `packages/` directory is not supported in dart 2.
- return new Future.value(null);
-}
-
Future<Uri> _getPackageConfigFuture() {
if (_traceLoading) {
_log("Request for package config from user code.");
diff --git a/sdk_nnbd/lib/_internal/vm/bin/socket_patch.dart b/sdk_nnbd/lib/_internal/vm/bin/socket_patch.dart
index 750aca8..84baa46 100644
--- a/sdk_nnbd/lib/_internal/vm/bin/socket_patch.dart
+++ b/sdk_nnbd/lib/_internal/vm/bin/socket_patch.dart
@@ -130,11 +130,11 @@
static const int _IPv6AddrLength = 16;
static _InternetAddress loopbackIPv4 =
- new _InternetAddress.fixed(_addressLoopbackIPv4);
+ _InternetAddress.fixed(_addressLoopbackIPv4);
static _InternetAddress loopbackIPv6 =
- new _InternetAddress.fixed(_addressLoopbackIPv6);
- static _InternetAddress anyIPv4 = new _InternetAddress.fixed(_addressAnyIPv4);
- static _InternetAddress anyIPv6 = new _InternetAddress.fixed(_addressAnyIPv6);
+ _InternetAddress.fixed(_addressLoopbackIPv6);
+ static _InternetAddress anyIPv4 = _InternetAddress.fixed(_addressAnyIPv4);
+ static _InternetAddress anyIPv6 = _InternetAddress.fixed(_addressAnyIPv6);
final String address;
final String _host;
@@ -731,6 +731,10 @@
if (resourceInfo != null) {
resourceInfo.didRead();
}
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(
+ nativeGetSocketId(), _SocketProfileType.readBytes, result?.length);
+ }
return result;
}
@@ -758,6 +762,10 @@
if (resourceInfo != null) {
resourceInfo.didRead();
}
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(nativeGetSocketId(),
+ _SocketProfileType.readBytes, result?.data?.length);
+ }
return result;
}
@@ -782,6 +790,12 @@
if (bytes == 0) return 0;
_BufferAndStart bufferAndStart =
_ensureFastAndSerializableByteData(buffer, offset, offset + bytes);
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(
+ nativeGetSocketId(),
+ _SocketProfileType.writeBytes,
+ bufferAndStart.buffer.length - bufferAndStart.start);
+ }
var result =
nativeWrite(bufferAndStart.buffer, bufferAndStart.start, bytes);
if (result is OSError) {
@@ -812,6 +826,12 @@
if (isClosing || isClosed) return 0;
_BufferAndStart bufferAndStart =
_ensureFastAndSerializableByteData(buffer, offset, bytes);
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(
+ nativeGetSocketId(),
+ _SocketProfileType.writeBytes,
+ bufferAndStart.buffer.length - bufferAndStart.start);
+ }
var result = nativeSendTo(bufferAndStart.buffer, bufferAndStart.start,
bytes, (address as _InternetAddress)._in_addr, port);
if (result is OSError) {
@@ -1281,7 +1301,11 @@
while (_socket.available > 0) {
var socket = _socket.accept();
if (socket == null) return;
- _controller.add(new _RawSocket(socket));
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectNewSocket(socket.nativeGetSocketId(),
+ _tcpSocket, socket.address, socket.port);
+ }
+ _controller.add(_RawSocket(socket));
if (_controller.isPaused) return;
}
}), error: zone.bindBinaryCallbackGuarded((e, st) {
@@ -1353,16 +1377,28 @@
static Future<RawSocket> connect(
host, int port, sourceAddress, Duration timeout) {
return _NativeSocket.connect(host, port, sourceAddress, timeout)
- .then((socket) => new _RawSocket(socket));
+ .then((socket) {
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectNewSocket(
+ socket.nativeGetSocketId(), _tcpSocket, socket.address, port);
+ }
+ return _RawSocket(socket);
+ });
}
static Future<ConnectionTask<_RawSocket>> startConnect(
host, int port, sourceAddress) {
return _NativeSocket.startConnect(host, port, sourceAddress)
.then((ConnectionTask<_NativeSocket> nativeTask) {
- final Future<_RawSocket> raw = nativeTask.socket
- .then((_NativeSocket nativeSocket) => new _RawSocket(nativeSocket));
- return new ConnectionTask<_RawSocket>._(
+ final Future<_RawSocket> raw =
+ nativeTask.socket.then((_NativeSocket nativeSocket) {
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectNewSocket(nativeSocket.nativeGetSocketId(),
+ _tcpSocket, nativeSocket.address, port);
+ }
+ return _RawSocket(nativeSocket);
+ });
+ return ConnectionTask<_RawSocket>._(
socket: raw, onCancel: nativeTask._onCancel);
});
}
@@ -1441,7 +1477,13 @@
int write(List<int> buffer, [int offset, int count]) =>
_socket.write(buffer, offset, count);
- Future<RawSocket> close() => _socket.close().then<RawSocket>((_) => this);
+ Future<RawSocket> close() => _socket.close().then<RawSocket>((_) {
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(
+ _socket.nativeGetSocketId(), _SocketProfileType.endTime);
+ }
+ return this;
+ });
void shutdown(SocketDirection direction) => _socket.shutdown(direction);
@@ -1942,7 +1984,13 @@
_throwOnBadPort(port);
_throwOnBadTtl(ttl);
return _NativeSocket.bindDatagram(host, port, reuseAddress, reusePort, ttl)
- .then((socket) => new _RawDatagramSocket(socket));
+ .then((socket) {
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectNewSocket(
+ socket.nativeGetSocketId(), _udpSocket, socket.address, port);
+ }
+ return _RawDatagramSocket(socket);
+ });
}
StreamSubscription<RawSocketEvent> listen(void onData(RawSocketEvent event),
@@ -1951,7 +1999,13 @@
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
}
- Future close() => _socket.close().then<RawDatagramSocket>((_) => this);
+ Future close() => _socket.close().then<RawDatagramSocket>((_) {
+ if (!const bool.fromEnvironment("dart.vm.product")) {
+ _SocketProfile.collectStatistic(
+ _socket.nativeGetSocketId(), _SocketProfileType.endTime);
+ }
+ return this;
+ });
int send(List<int> buffer, InternetAddress address, int port) =>
_socket.send(buffer, 0, buffer.length, address, port);
diff --git a/sdk_nnbd/lib/_internal/vm/lib/async_patch.dart b/sdk_nnbd/lib/_internal/vm/lib/async_patch.dart
index f51fa04..fa10ad4 100644
--- a/sdk_nnbd/lib/_internal/vm/lib/async_patch.dart
+++ b/sdk_nnbd/lib/_internal/vm/lib/async_patch.dart
@@ -20,6 +20,7 @@
_fatal(msg) native "DartAsync_fatal";
class _AsyncAwaitCompleter<T> implements Completer<T> {
+ @pragma("vm:entry-point")
final _future = new _Future<T>();
bool isSync;
@@ -133,6 +134,7 @@
// async* generator functions.
@pragma("vm:entry-point")
class _AsyncStarStreamController<T> {
+ @pragma("vm:entry-point")
StreamController<T> controller;
Function asyncStarBody;
bool isAdding = false;
diff --git a/sdk_nnbd/lib/_internal/vm/lib/bigint_patch.dart b/sdk_nnbd/lib/_internal/vm/lib/bigint_patch.dart
index b5d3093..8bff4f0 100644
--- a/sdk_nnbd/lib/_internal/vm/lib/bigint_patch.dart
+++ b/sdk_nnbd/lib/_internal/vm/lib/bigint_patch.dart
@@ -96,6 +96,18 @@
static const int _minInt = -0x8000000000000000;
static const int _maxInt = 0x7fffffffffffffff;
+ /// Certain methods of _BigIntImpl class are intrinsified by the VM
+ /// depending on the runtime flags. They return number of processed
+ /// digits (2) which is different from non-intrinsic implementation (1).
+ /// This flag is used to confuse constant propagation at compile time and
+ /// avoid propagating return value to the callers. It should not be
+ /// evaluated to a constant.
+ /// Note that [_isIntrinsified] is still false if intrinsification occurs,
+ /// so it should be used only inside methods which are replaced by
+ /// intrinsification.
+ static final bool _isIntrinsified =
+ new bool.fromEnvironment('dart.vm.not.a.compile.time.constant');
+
// Result cache for last _divRem call.
// Result cache for last _divRem call.
static Uint32List _lastDividendDigits;
@@ -1114,7 +1126,7 @@
int x = xDigits[xIndex];
if (x == 0) {
// No-op if x is 0.
- return 1;
+ return _isIntrinsified ? 2 : 1;
}
int carry = 0;
int xl = x & _halfDigitMask;
@@ -1135,7 +1147,7 @@
carry = l >> _digitBits;
accumulatorDigits[j++] = l & _digitMask;
}
- return 1;
+ return _isIntrinsified ? 2 : 1;
}
/// Multiplies `xDigits[i]` with `xDigits` and adds the result to
@@ -1158,7 +1170,7 @@
static int _sqrAdd(
Uint32List xDigits, int i, Uint32List acculumatorDigits, int used) {
int x = xDigits[i];
- if (x == 0) return 1;
+ if (x == 0) return _isIntrinsified ? 2 : 1;
int j = 2 * i;
int carry = 0;
int xl = x & _halfDigitMask;
@@ -1193,7 +1205,7 @@
} else {
acculumatorDigits[i + used] = carry;
}
- return 1;
+ return _isIntrinsified ? 2 : 1;
}
/// Multiplication operator.
@@ -1293,7 +1305,7 @@
args[_quotientDigit] = quotientDigit;
}
}
- return 1;
+ return _isIntrinsified ? 2 : 1;
}
/// Returns `trunc(this / other)`, with `other != 0`.
@@ -2627,7 +2639,7 @@
(((dl * rhoh + dh * rhol) & _BigIntImpl._halfDigitMask) <<
_BigIntImpl._halfDigitBits)) &
_BigIntImpl._digitMask;
- return 1;
+ return _BigIntImpl._isIntrinsified ? 2 : 1;
}
// result = x*R mod _modulus.
diff --git a/sdk_nnbd/lib/_internal/vm/lib/isolate_patch.dart b/sdk_nnbd/lib/_internal/vm/lib/isolate_patch.dart
index ec4bcf1..d647ba6 100644
--- a/sdk_nnbd/lib/_internal/vm/lib/isolate_patch.dart
+++ b/sdk_nnbd/lib/_internal/vm/lib/isolate_patch.dart
@@ -327,11 +327,7 @@
@patch
static Future<Uri> get packageRoot {
- var hook = VMLibraryHooks.packageRootUriFuture;
- if (hook == null) {
- throw new UnsupportedError("Isolate.packageRoot");
- }
- return hook();
+ return Future.value(null);
}
@patch
diff --git a/sdk_nnbd/lib/async/future_impl.dart b/sdk_nnbd/lib/async/future_impl.dart
index a4be169..e803094 100644
--- a/sdk_nnbd/lib/async/future_impl.dart
+++ b/sdk_nnbd/lib/async/future_impl.dart
@@ -76,6 +76,7 @@
// Which fields means what.
final int state;
// Used for then/whenDone callback and error test
+ @pragma("vm:entry-point")
final Function? callback;
// Used for error callbacks.
final Function? errorCallback;
@@ -211,6 +212,7 @@
* will complete with the same result.
* All listeners are forwarded to the other future.
*/
+ @pragma("vm:entry-point")
var _resultOrListeners;
// This constructor is used by async/await.
diff --git a/sdk_nnbd/lib/async/stream_controller.dart b/sdk_nnbd/lib/async/stream_controller.dart
index 9303b86..6f09d5d 100644
--- a/sdk_nnbd/lib/async/stream_controller.dart
+++ b/sdk_nnbd/lib/async/stream_controller.dart
@@ -407,7 +407,12 @@
/** The controller is in its initial state with no subscription. */
static const int _STATE_INITIAL = 0;
- /** The controller has a subscription, but hasn't been closed or canceled. */
+ /**
+ * The controller has a subscription, but hasn't been closed or canceled.
+ *
+ * Keep in sync with
+ * runtime/vm/stack_trace.cc:kStreamController_StateSubscribed.
+ */
static const int _STATE_SUBSCRIBED = 1;
/** The subscription is canceled. */
static const int _STATE_CANCELED = 2;
@@ -446,9 +451,11 @@
* When [_state] is [_STATE_CANCELED] the field is currently not used,
* and will contain `null`.
*/
+ @pragma("vm:entry-point")
Object? _varData;
/** Current state of the controller. */
+ @pragma("vm:entry-point")
int _state = _STATE_INITIAL;
/**
diff --git a/sdk_nnbd/lib/async/stream_impl.dart b/sdk_nnbd/lib/async/stream_impl.dart
index 5011a82..f8a4437 100644
--- a/sdk_nnbd/lib/async/stream_impl.dart
+++ b/sdk_nnbd/lib/async/stream_impl.dart
@@ -87,6 +87,7 @@
static const int _STATE_PAUSE_COUNT = 128;
/* Event handlers provided in constructor. */
+ @pragma("vm:entry-point")
_DataHandler<T> _onData;
Function _onError;
_DoneHandler _onDone;
diff --git a/sdk_nnbd/lib/async/zone.dart b/sdk_nnbd/lib/async/zone.dart
index 31644f2..8be575d1 100644
--- a/sdk_nnbd/lib/async/zone.dart
+++ b/sdk_nnbd/lib/async/zone.dart
@@ -110,14 +110,16 @@
ForkHandler? fork}) {
return new ZoneSpecification(
handleUncaughtError: handleUncaughtError ?? other.handleUncaughtError,
- run: run ?? other.run,
- runUnary: runUnary ?? other.runUnary,
- runBinary: runBinary ?? other.runBinary,
- registerCallback: registerCallback ?? other.registerCallback,
+ // TODO(#39534) Cleanup casts to dynamic when CFE can find the LUB.
+ run: (run ?? other.run) as dynamic,
+ runUnary: (runUnary ?? other.runUnary) as dynamic,
+ runBinary: (runBinary ?? other.runBinary) as dynamic,
+ registerCallback:
+ (registerCallback ?? other.registerCallback) as dynamic,
registerUnaryCallback:
- registerUnaryCallback ?? other.registerUnaryCallback,
+ (registerUnaryCallback ?? other.registerUnaryCallback) as dynamic,
registerBinaryCallback:
- registerBinaryCallback ?? other.registerBinaryCallback,
+ (registerBinaryCallback ?? other.registerBinaryCallback) as dynamic,
errorCallback: errorCallback ?? other.errorCallback,
scheduleMicrotask: scheduleMicrotask ?? other.scheduleMicrotask,
createTimer: createTimer ?? other.createTimer,
diff --git a/sdk_nnbd/lib/collection/hash_map.dart b/sdk_nnbd/lib/collection/hash_map.dart
index 7339deb..3990cd2 100644
--- a/sdk_nnbd/lib/collection/hash_map.dart
+++ b/sdk_nnbd/lib/collection/hash_map.dart
@@ -83,9 +83,9 @@
/// If you supply one of [equals] and [hashCode],
/// you should generally also to supply the other.
external factory HashMap(
- {bool Function(K key1, K key2)? equals,
- int Function(K key)? hashCode,
- bool Function(dynamic potentialKey)? isValidKey});
+ {bool Function(K, K)? equals,
+ int Function(K)? hashCode,
+ bool Function(dynamic)? isValidKey});
/// Creates an unordered identity-based map.
///
diff --git a/sdk_nnbd/lib/collection/hash_set.dart b/sdk_nnbd/lib/collection/hash_set.dart
index 6007fa8..6ebb04e 100644
--- a/sdk_nnbd/lib/collection/hash_set.dart
+++ b/sdk_nnbd/lib/collection/hash_set.dart
@@ -64,9 +64,9 @@
/// and the `isValidKey` defaults to accepting all keys.
/// Such a map can be created directly using [HashSet.identity].
external factory HashSet(
- {bool Function(E e1, E e2)? equals,
- int Function(E e)? hashCode,
- bool Function(dynamic potentialKey)? isValidKey});
+ {bool Function(E, E)? equals,
+ int Function(E)? hashCode,
+ bool Function(dynamic)? isValidKey});
/// Creates an unordered identity-based set.
///
diff --git a/sdk_nnbd/lib/collection/iterable.dart b/sdk_nnbd/lib/collection/iterable.dart
index 9a03fac..17f84a2 100644
--- a/sdk_nnbd/lib/collection/iterable.dart
+++ b/sdk_nnbd/lib/collection/iterable.dart
@@ -33,7 +33,7 @@
return FollowedByIterable<E>(this, other);
}
- bool contains(Object element) {
+ bool contains(Object? element) {
for (E e in this) {
if (e == element) return true;
}
diff --git a/sdk_nnbd/lib/collection/linked_hash_map.dart b/sdk_nnbd/lib/collection/linked_hash_map.dart
index 195480e..9dfdb99 100644
--- a/sdk_nnbd/lib/collection/linked_hash_map.dart
+++ b/sdk_nnbd/lib/collection/linked_hash_map.dart
@@ -67,9 +67,9 @@
/// If you supply one of [equals] and [hashCode],
/// you should generally also to supply the other.
external factory LinkedHashMap(
- {bool Function(K key1, K key2)? equals,
- int Function(K key)? hashCode,
- bool Function(dynamic potentialKey)? isValidKey});
+ {bool Function(K, K)? equals,
+ int Function(K)? hashCode,
+ bool Function(dynamic)? isValidKey});
/// Creates an insertion-ordered identity-based map.
///
diff --git a/sdk_nnbd/lib/collection/linked_hash_set.dart b/sdk_nnbd/lib/collection/linked_hash_set.dart
index 19e374f..c4f6818 100644
--- a/sdk_nnbd/lib/collection/linked_hash_set.dart
+++ b/sdk_nnbd/lib/collection/linked_hash_set.dart
@@ -71,9 +71,9 @@
/// and the `isValidKey` defaults to accepting all keys.
/// Such a map can be created directly using [LinkedHashSet.identity].
external factory LinkedHashSet(
- {bool Function(E e1, E e2)? equals,
- int Function(E e)? hashCode,
- bool Function(dynamic potentialKey)? isValidKey});
+ {bool Function(E, E)? equals,
+ int Function(E)? hashCode,
+ bool Function(dynamic)? isValidKey});
/// Creates an insertion-ordered identity-based set.
///
diff --git a/sdk_nnbd/lib/collection/linked_list.dart b/sdk_nnbd/lib/collection/linked_list.dart
index a273edb..71e0226 100644
--- a/sdk_nnbd/lib/collection/linked_list.dart
+++ b/sdk_nnbd/lib/collection/linked_list.dart
@@ -143,7 +143,7 @@
return;
}
E predecessor = entry!._previous!;
- E successor = entry!;
+ E successor = entry;
newEntry._previous = predecessor;
newEntry._next = successor;
predecessor._next = newEntry;
diff --git a/sdk_nnbd/lib/collection/maps.dart b/sdk_nnbd/lib/collection/maps.dart
index 7ca8eeb..90ecb6a 100644
--- a/sdk_nnbd/lib/collection/maps.dart
+++ b/sdk_nnbd/lib/collection/maps.dart
@@ -126,7 +126,7 @@
void addAll(Map<K, V> other) {
for (K key in other.keys) {
- this[key] = other[key];
+ this[key] = other[key] as V;
}
}
@@ -229,9 +229,9 @@
int get length => _map.length;
bool get isEmpty => _map.isEmpty;
bool get isNotEmpty => _map.isNotEmpty;
- V get first => _map[_map.keys.first];
- V get single => _map[_map.keys.single];
- V get last => _map[_map.keys.last];
+ V get first => _map[_map.keys.first] as V;
+ V get single => _map[_map.keys.single] as V;
+ V get last => _map[_map.keys.last] as V;
Iterator<V> get iterator => _MapBaseValueIterator<K, V>(_map);
}
@@ -322,7 +322,7 @@
const MapView(Map<K, V> map) : _map = map;
Map<RK, RV> cast<RK, RV>() => _map.cast<RK, RV>();
- V operator [](Object key) => _map[key];
+ V? operator [](Object? key) => _map[key];
void operator []=(K key, V value) {
_map[key] = value;
}
@@ -336,8 +336,8 @@
}
V putIfAbsent(K key, V ifAbsent()) => _map.putIfAbsent(key, ifAbsent);
- bool containsKey(Object key) => _map.containsKey(key);
- bool containsValue(Object value) => _map.containsValue(value);
+ bool containsKey(Object? key) => _map.containsKey(key);
+ bool containsValue(Object? value) => _map.containsValue(value);
void forEach(void action(K key, V value)) {
_map.forEach(action);
}
@@ -346,7 +346,7 @@
bool get isNotEmpty => _map.isNotEmpty;
int get length => _map.length;
Iterable<K> get keys => _map.keys;
- V remove(Object key) => _map.remove(key);
+ V? remove(Object? key) => _map.remove(key);
String toString() => _map.toString();
Iterable<V> get values => _map.values;
diff --git a/sdk_nnbd/lib/collection/queue.dart b/sdk_nnbd/lib/collection/queue.dart
index c2fc394..365713c 100644
--- a/sdk_nnbd/lib/collection/queue.dart
+++ b/sdk_nnbd/lib/collection/queue.dart
@@ -116,8 +116,8 @@
void _link(Link? previous, Link? next) {
_nextLink = next;
_previousLink = previous;
- if (previous != null) previous!._nextLink = this as Link;
- if (next != null) next!._previousLink = this as Link;
+ if (previous != null) previous._nextLink = this as Link;
+ if (next != null) next._previousLink = this as Link;
}
void _unlink() {
@@ -344,7 +344,7 @@
return result;
}
- bool remove(Object o) {
+ bool remove(Object? o) {
_DoubleLinkedQueueEntry<E> entry =
_sentinel._nextLink as _DoubleLinkedQueueEntry<E>;
while (!identical(entry, _sentinel)) {
diff --git a/sdk_nnbd/lib/collection/set.dart b/sdk_nnbd/lib/collection/set.dart
index 7ac5bd7..1eb7491 100644
--- a/sdk_nnbd/lib/collection/set.dart
+++ b/sdk_nnbd/lib/collection/set.dart
@@ -87,8 +87,8 @@
removeAll(toRemove);
}
- bool containsAll(Iterable<Object> other) {
- for (Object o in other) {
+ bool containsAll(Iterable<Object?> other) {
+ for (var o in other) {
if (!contains(o)) return false;
}
return true;
@@ -98,7 +98,7 @@
return toSet()..addAll(other);
}
- Set<E> intersection(Set<Object> other) {
+ Set<E> intersection(Set<Object?> other) {
Set<E> result = toSet();
for (E element in this) {
if (!other.contains(element)) result.remove(element);
@@ -106,7 +106,7 @@
return result;
}
- Set<E> difference(Set<Object> other) {
+ Set<E> difference(Set<Object?> other) {
Set<E> result = toSet();
for (E element in this) {
if (other.contains(element)) result.remove(element);
@@ -323,7 +323,7 @@
Set<R> cast<R>() => Set.castFrom<E, R>(this, newSet: _newSimilarSet);
- Set<E> difference(Set<Object> other) {
+ Set<E> difference(Set<Object?> other) {
Set<E> result = _newSet();
for (var element in this) {
if (!other.contains(element)) result.add(element);
@@ -331,7 +331,7 @@
return result;
}
- Set<E> intersection(Set<Object> other) {
+ Set<E> intersection(Set<Object?> other) {
Set<E> result = _newSet();
for (var element in this) {
if (other.contains(element)) result.add(element);
diff --git a/sdk_nnbd/lib/collection/splay_tree.dart b/sdk_nnbd/lib/collection/splay_tree.dart
index 5d74080..8268ced 100644
--- a/sdk_nnbd/lib/collection/splay_tree.dart
+++ b/sdk_nnbd/lib/collection/splay_tree.dart
@@ -528,12 +528,12 @@
// Don't include the root, start at the next element after the root.
_findLeftMostDescendent(tree._root!.right);
} else {
- _workList.add(tree._root);
+ _workList.add(tree._root!);
}
}
- T? get current {
- if (_currentNode == null) return null;
+ T get current {
+ if (_currentNode == null) return null as T;
return _getValue(_currentNode!);
}
diff --git a/sdk_nnbd/lib/core/invocation.dart b/sdk_nnbd/lib/core/invocation.dart
index 5959201..0df60f8 100644
--- a/sdk_nnbd/lib/core/invocation.dart
+++ b/sdk_nnbd/lib/core/invocation.dart
@@ -21,7 +21,7 @@
* If the named arguments are omitted, they default to no named arguments.
*/
factory Invocation.method(
- Symbol memberName, Iterable<Object?> positionalArguments,
+ Symbol memberName, Iterable<Object?>? positionalArguments,
[Map<Symbol, Object?>? namedArguments]) =>
_Invocation.method(memberName, null, positionalArguments, namedArguments);
@@ -35,7 +35,7 @@
* If the named arguments are omitted, they default to no named arguments.
*/
factory Invocation.genericMethod(Symbol memberName,
- Iterable<Type> typeArguments, Iterable<Object?> positionalArguments,
+ Iterable<Type>? typeArguments, Iterable<Object?>? positionalArguments,
[Map<Symbol, Object?>? namedArguments]) =>
_Invocation.method(
memberName, typeArguments, positionalArguments, namedArguments);
diff --git a/sdk_nnbd/lib/core/string.dart b/sdk_nnbd/lib/core/string.dart
index 1a838aa..95f27b6 100644
--- a/sdk_nnbd/lib/core/string.dart
+++ b/sdk_nnbd/lib/core/string.dart
@@ -507,7 +507,7 @@
*
* pigLatin('I have a secret now!'); // 'Iway avehay away ecretsay ownay!'
*/
- String replaceAllMapped(Pattern from, String replace(Match match));
+ String replaceAllMapped(Pattern from, String Function(Match match) replace);
/**
* Replaces the substring from [start] to [end] with [replacement].
@@ -589,7 +589,7 @@
* onNonMatch: (n) => '*'); // *shoots*
*/
String splitMapJoin(Pattern pattern,
- {String onMatch(Match match)?, String onNonMatch(String nonMatch)?});
+ {String Function(Match)? onMatch, String Function(String)? onNonMatch});
/**
* Returns an unmodifiable list of the UTF-16 code units of this string.
@@ -723,18 +723,19 @@
/**
* Returns the starting position of the current rune in the string.
*
- * Returns null if the [current] rune is null.
+ * Returns -1 if the [current] rune is `null`.
*/
- int get rawIndex => (_position != _nextPosition) ? _position : null;
+ int get rawIndex => (_position != _nextPosition) ? _position : -1;
/**
* Resets the iterator to the rune at the specified index of the string.
*
* Setting a negative [rawIndex], or one greater than or equal to
- * [:string.length:],
- * is an error. So is setting it in the middle of a surrogate pair.
+ * `string.length`, is an error. So is setting it in the middle of a surrogate
+ * pair.
*
- * Setting the position to the end of then string will set [current] to null.
+ * Setting the position to the end of then string will set [current] to
+ * `null`.
*/
void set rawIndex(int rawIndex) {
RangeError.checkValidIndex(rawIndex, string, "rawIndex");
diff --git a/sdk_nnbd/lib/core/uri.dart b/sdk_nnbd/lib/core/uri.dart
index 8e3100f..5079216 100644
--- a/sdk_nnbd/lib/core/uri.dart
+++ b/sdk_nnbd/lib/core/uri.dart
@@ -2668,7 +2668,7 @@
}
}
}
- String fragment = reference.hasFragment ? reference.fragment : null;
+ String? fragment = reference.hasFragment ? reference.fragment : null;
return _Uri._internal(targetScheme, targetUserInfo, targetHost, targetPort,
targetPath, targetQuery, fragment);
}
diff --git a/sdk_nnbd/lib/internal/cast.dart b/sdk_nnbd/lib/internal/cast.dart
index f994dab..d99b687 100644
--- a/sdk_nnbd/lib/internal/cast.dart
+++ b/sdk_nnbd/lib/internal/cast.dart
@@ -270,8 +270,8 @@
_source[key as SK] = value as SV;
}
- V putIfAbsent(K key, V ifAbsent()) => _source.putIfAbsent(
- key as SK, (ifAbsent == null) ? null : () => ifAbsent() as SV) as V;
+ V putIfAbsent(K key, V Function() ifAbsent) =>
+ _source.putIfAbsent(key as SK, () => ifAbsent() as SV) as V;
void addAll(Map<K, V> other) {
_source.addAll(new CastMap<K, V, SK, SV>(other));
diff --git a/sdk_nnbd/lib/internal/errors.dart b/sdk_nnbd/lib/internal/errors.dart
new file mode 100644
index 0000000..9010622
--- /dev/null
+++ b/sdk_nnbd/lib/internal/errors.dart
@@ -0,0 +1,19 @@
+// Copyright (c) 2019, 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.
+
+part of dart._internal;
+
+class LateInitializationErrorImpl extends Error
+ implements LateInitializationError {
+ final String? _message;
+
+ LateInitializationErrorImpl([this._message]);
+
+ String toString() {
+ var message = _message;
+ return (message != null)
+ ? "LateInitializationError: $message"
+ : "LateInitializationError";
+ }
+}
diff --git a/sdk_nnbd/lib/internal/internal.dart b/sdk_nnbd/lib/internal/internal.dart
index 1a92f98..f646b60 100644
--- a/sdk_nnbd/lib/internal/internal.dart
+++ b/sdk_nnbd/lib/internal/internal.dart
@@ -21,6 +21,7 @@
part 'async_cast.dart';
part 'cast.dart';
+part 'errors.dart';
part 'iterable.dart';
part 'list.dart';
part 'print.dart';
diff --git a/sdk_nnbd/lib/internal/internal_sources.gni b/sdk_nnbd/lib/internal/internal_sources.gni
index 7c8af46..4311341 100644
--- a/sdk_nnbd/lib/internal/internal_sources.gni
+++ b/sdk_nnbd/lib/internal/internal_sources.gni
@@ -9,6 +9,7 @@
# The above file needs to be first as it lists the parts below.
"async_cast.dart",
"cast.dart",
+ "errors.dart",
"iterable.dart",
"list.dart",
"linked_list.dart",
diff --git a/sdk_nnbd/lib/io/network_profiling.dart b/sdk_nnbd/lib/io/network_profiling.dart
index c32f2b6..eebd8ff 100644
--- a/sdk_nnbd/lib/io/network_profiling.dart
+++ b/sdk_nnbd/lib/io/network_profiling.dart
@@ -6,15 +6,32 @@
part of dart.io;
-@pragma('vm:entry-point')
+const String _tcpSocket = 'tcp';
+const String _udpSocket = 'udp';
+
+@pragma('vm:entry-point', !const bool.fromEnvironment("dart.vm.product"))
abstract class _NetworkProfiling {
+ // Http relative RPCs
static const _kGetHttpProfileRPC = 'ext.dart.io.getHttpProfile';
+ // Socket relative RPCs
+ static const _kClearSocketProfileRPC = 'ext.dart.io.clearSocketProfile';
static const _kGetSocketProfileRPC = 'ext.dart.io.getSocketProfile';
+ static const _kPauseSocketProfilingRPC = 'ext.dart.io.pauseSocketProfiling';
+ static const _kStartSocketProfilingRPC = 'ext.dart.io.startSocketProfiling';
+
+ // TODO(zichangguo): This version number represents the version of service
+ // extension of dart:io. Consider moving this out of web profiler class,
+ // if more methods added to dart:io,
+ static const _kGetVersionRPC = 'ext.dart.io.getVersion';
@pragma('vm:entry-point')
static void _registerServiceExtension() {
registerExtension(_kGetHttpProfileRPC, _serviceExtensionHandler);
registerExtension(_kGetSocketProfileRPC, _serviceExtensionHandler);
+ registerExtension(_kStartSocketProfilingRPC, _serviceExtensionHandler);
+ registerExtension(_kPauseSocketProfilingRPC, _serviceExtensionHandler);
+ registerExtension(_kClearSocketProfileRPC, _serviceExtensionHandler);
+ registerExtension(_kGetVersionRPC, _serviceExtensionHandler);
}
static Future<ServiceExtensionResponse> _serviceExtensionHandler(
@@ -22,10 +39,22 @@
String responseJson;
switch (method) {
case _kGetHttpProfileRPC:
- responseJson = _HttpProfile.toJSON();
+ responseJson = _HttpProfile.toJson();
break;
case _kGetSocketProfileRPC:
- responseJson = _SocketProfile.toJSON();
+ responseJson = _SocketProfile.toJson();
+ break;
+ case _kStartSocketProfilingRPC:
+ responseJson = _SocketProfile.start();
+ break;
+ case _kPauseSocketProfilingRPC:
+ responseJson = _SocketProfile.pause();
+ break;
+ case _kClearSocketProfileRPC:
+ responseJson = _SocketProfile.clear();
+ break;
+ case _kGetVersionRPC:
+ responseJson = getVersion();
break;
default:
return Future.value(ServiceExtensionResponse.error(
@@ -34,12 +63,18 @@
}
return Future.value(ServiceExtensionResponse.result(responseJson));
}
+
+ static String getVersion() => json.encode({
+ 'type': 'Version',
+ 'major': 1,
+ 'minor': 0,
+ });
}
abstract class _HttpProfile {
static const _kType = 'HttpProfile';
// TODO(bkonyi): implement.
- static String toJSON() {
+ static String toJson() {
final response = <String, dynamic>{
'type': _kType,
};
@@ -49,11 +84,131 @@
abstract class _SocketProfile {
static const _kType = 'SocketProfile';
- // TODO(bkonyi): implement.
- static String toJSON() {
- final response = <String, dynamic>{
- 'type': _kType,
+ static bool _enableSocketProfiling = false;
+ static Map<int, _SocketStatistic> _idToSocketStatistic = {};
+
+ static String toJson() => json.encode({
+ 'type': _kType,
+ 'sockets': _idToSocketStatistic.values.map((f) => f.toMap()).toList(),
+ });
+
+ static void collectNewSocket(
+ int id, String type, InternetAddress addr, int port) {
+ _SocketProfile.collectStatistic(id, _SocketProfileType.startTime);
+ _SocketProfile.collectStatistic(id, _SocketProfileType.socketType, type);
+ _SocketProfile.collectStatistic(id, _SocketProfileType.address, addr);
+ _SocketProfile.collectStatistic(id, _SocketProfileType.port, port);
+ }
+
+ static void collectStatistic(int id, _SocketProfileType type,
+ [dynamic object]) {
+ if (!_enableSocketProfiling) {
+ return;
+ }
+ // Skip socket that started before _enableSocketProfiling turned on.
+ if (!_idToSocketStatistic.containsKey(id) &&
+ type != _SocketProfileType.startTime) return;
+ _idToSocketStatistic[id] ??= _SocketStatistic(id);
+ _SocketStatistic stats = _idToSocketStatistic[id];
+ switch (type) {
+ case _SocketProfileType.startTime:
+ stats.startTime = Timeline.now;
+ break;
+ case _SocketProfileType.endTime:
+ stats.endTime = Timeline.now;
+ break;
+ case _SocketProfileType.address:
+ assert(object is InternetAddress);
+ stats.address = (object as InternetAddress).toString();
+ break;
+ case _SocketProfileType.port:
+ assert(object is int);
+ stats.port = object;
+ break;
+ case _SocketProfileType.socketType:
+ assert(object is String);
+ stats.socketType = object;
+ break;
+ case _SocketProfileType.readBytes:
+ if (object == null) return;
+ assert(object is int);
+ stats.readBytes ??= 0;
+ stats.readBytes += object;
+ break;
+ case _SocketProfileType.writeBytes:
+ if (object == null) return;
+ assert(object is int);
+ stats.writeBytes ??= 0;
+ stats.writeBytes += object;
+ break;
+ default:
+ throw ArgumentError('type ${type} does not exist');
+ break;
+ }
+ }
+
+ static String start() {
+ _enableSocketProfiling = true;
+ return success();
+ }
+
+ static String pause() {
+ _enableSocketProfiling = false;
+ return success();
+ }
+
+ // clear the storage if _idToSocketStatistic has been initialized.
+ static String clear() {
+ _idToSocketStatistic?.clear();
+ return success();
+ }
+
+ static String success() => json.encode({
+ 'type': 'Success',
+ });
+}
+
+/// The [_SocketProfileType] is used as a parameter for
+/// [_SocketProfile.collectStatistic] to determine the type of statistic.
+enum _SocketProfileType {
+ startTime,
+ endTime,
+ address,
+ port,
+ socketType,
+ readBytes,
+ writeBytes
+}
+
+/// Socket statistic
+class _SocketStatistic {
+ final int id;
+ int startTime;
+ int endTime;
+ String address;
+ int port;
+ String socketType;
+ int readBytes = 0;
+ int writeBytes = 0;
+
+ _SocketStatistic(this.id);
+
+ Map<String, dynamic> toMap() {
+ final map = <String, dynamic>{
+ 'id': id,
};
- return json.encode(response);
+ _setIfNotNull(map, 'startTime', startTime.toString());
+ _setIfNotNull(map, 'endTime', endTime.toString());
+ _setIfNotNull(map, 'address', address);
+ _setIfNotNull(map, 'port', port);
+ _setIfNotNull(map, 'socketType', socketType);
+ _setIfNotNull(map, 'readBytes', readBytes);
+ _setIfNotNull(map, 'writeBytes', writeBytes);
+ return map;
+ }
+
+ void _setIfNotNull(Map<String, Object> json, String key, Object value) {
+ if (value == null) return;
+ json[key] = value;
}
}
diff --git a/sdk_nnbd/lib/vmservice/vmservice.dart b/sdk_nnbd/lib/vmservice/vmservice.dart
index c1540ab..aa7878f 100644
--- a/sdk_nnbd/lib/vmservice/vmservice.dart
+++ b/sdk_nnbd/lib/vmservice/vmservice.dart
@@ -650,7 +650,8 @@
}
}
-@pragma("vm:entry-point", "call")
+@pragma("vm:entry-point",
+ const bool.fromEnvironment("dart.vm.product") ? false : "call")
RawReceivePort boot() {
// Return the port we expect isolate control messages on.
return isolateControlPort;
diff --git a/tests/co19/.gitignore b/tests/co19/.gitignore
new file mode 100644
index 0000000..a57582c
--- /dev/null
+++ b/tests/co19/.gitignore
@@ -0,0 +1 @@
+/src
diff --git a/tests/co19/update.sh b/tests/co19/update.sh
index b4b5ff0..e9aef51 100755
--- a/tests/co19/update.sh
+++ b/tests/co19/update.sh
@@ -26,8 +26,7 @@
-commit https://dart.googlesource.com/co19/+/$NEW \
-json \
dart/ci/co19-roller \
- | jq '.id' \
- | tr -d '"')
+ | jq -r '.id')
bb collect -interval 10s $BUILD_ID
# Update DEPS:
diff --git a/tests/co19_2/update.sh b/tests/co19_2/update.sh
index db2c88f..a482bf3 100755
--- a/tests/co19_2/update.sh
+++ b/tests/co19_2/update.sh
@@ -27,8 +27,7 @@
-json \
-p variant=legacy \
dart/ci/co19-roller \
- | jq '.id' \
- | tr -d '"')
+ | jq -r '.id')
bb collect -interval 10s $BUILD_ID
# Update DEPS:
diff --git a/tests/compiler/dart2js/codegen/variance_subtype_cast_test.dart b/tests/compiler/dart2js/codegen/variance_subtype_cast_test.dart
new file mode 100644
index 0000000..fcf0d17
--- /dev/null
+++ b/tests/compiler/dart2js/codegen/variance_subtype_cast_test.dart
@@ -0,0 +1,132 @@
+// Copyright (c) 2019, 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.
+
+import 'package:async_helper/async_helper.dart';
+import '../helpers/compiler_helper.dart';
+
+const String LEGACY_COV_CAST = r"""
+class LegacyCovariant<T> {
+ void method() {}
+}
+foo(param) {
+ LegacyCovariant<num> c = LegacyCovariant<num>();
+ (c as LegacyCovariant<int>).method();
+ // present: 'LegacyCovariant_int._as'
+}
+""";
+
+const String LEGACY_COV_NO_CAST = r"""
+class LegacyCovariant<T> {
+ void method() {}
+}
+foo(param) {
+ LegacyCovariant<num> c = LegacyCovariant<num>();
+ (c as LegacyCovariant<Object>).method();
+ // absent: 'LegacyCovariant_Object._as'
+}
+""";
+
+const String COV_CAST = r"""
+class Covariant<out T> {
+ void method() {}
+}
+foo(param) {
+ Covariant<num> c = Covariant<num>();
+ (c as Covariant<int>).method();
+ // present: 'Covariant_int._as'
+}
+""";
+
+const String COV_NO_CAST = r"""
+class Covariant<out T> {
+ void method() {}
+}
+foo(param) {
+ Covariant<num> c = Covariant<num>();
+ (c as Covariant<Object>).method();
+ // absent: 'Covariant_Object._as'
+}
+""";
+
+const String CONTRA_CAST = r"""
+class Contravariant<in T> {
+ void method() {}
+}
+foo(param) {
+ Contravariant<num> c = Contravariant<num>();
+ (c as Contravariant<Object>).method();
+ // present: 'Contravariant_Object._as'
+}
+""";
+
+const String CONTRA_NO_CAST = r"""
+class Contravariant<in T> {
+ void method() {}
+}
+foo(param) {
+ Contravariant<num> c = Contravariant<num>();
+ (c as Contravariant<int>).method();
+ // absent: 'Contravariant_int._as'
+}
+""";
+
+const String INV_CAST1 = r"""
+class Invariant<inout T> {
+ void method() {}
+}
+foo(param) {
+ Invariant<num> i = Invariant<num>();
+ (i as Invariant<Object>).method();
+ // present: 'Invariant_Object._as'
+}
+""";
+
+const String INV_CAST2 = r"""
+class Invariant<inout T> {
+ void method() {}
+}
+foo(param) {
+ Invariant<num> i = Invariant<num>();
+ (i as Invariant<int>).method();
+ // present: 'Invariant_int._as'
+}
+""";
+
+const String INV_NO_CAST = r"""
+class Invariant<inout T> {
+ void method() {}
+}
+foo(param) {
+ Invariant<num> i = Invariant<num>();
+ (i as Invariant<num>).method();
+ // absent: 'Invariant_num._as'
+}
+""";
+
+main() {
+ runTests() async {
+ Future check(String test) {
+ return compile(test,
+ entry: 'foo',
+ check: checkerForAbsentPresent(test),
+ newRti: true,
+ enableVariance: true);
+ }
+
+ await check(LEGACY_COV_CAST);
+ await check(LEGACY_COV_NO_CAST);
+ await check(COV_CAST);
+ await check(COV_NO_CAST);
+ await check(CONTRA_CAST);
+ await check(CONTRA_NO_CAST);
+ await check(INV_CAST1);
+ await check(INV_CAST2);
+ await check(INV_NO_CAST);
+ }
+
+ asyncTest(() async {
+ print('--test from kernel------------------------------------------------');
+ await runTests();
+ });
+}
diff --git a/tests/compiler/dart2js/helpers/compiler_helper.dart b/tests/compiler/dart2js/helpers/compiler_helper.dart
index 2180d4c..c19cda5 100644
--- a/tests/compiler/dart2js/helpers/compiler_helper.dart
+++ b/tests/compiler/dart2js/helpers/compiler_helper.dart
@@ -38,6 +38,7 @@
bool disableTypeInference: true,
bool omitImplicitChecks: true,
bool newRti: false,
+ bool enableVariance: false,
void check(String generatedEntry),
bool returnAll: false}) async {
OutputCollector outputCollector = returnAll ? new OutputCollector() : null;
@@ -63,6 +64,9 @@
if (newRti) {
options.add(Flags.experimentNewRti);
}
+ if (enableVariance) {
+ options.add('${Flags.enableLanguageExperiments}=variance');
+ }
// Pretend this is a dart2js_native test to allow use of 'native' keyword
// and import of private libraries.
diff --git a/tests/compiler/dart2js_extra/regress_null_aware_test.dart b/tests/compiler/dart2js_extra/regress_null_aware_test.dart
new file mode 100644
index 0000000..4ef8dc3
--- /dev/null
+++ b/tests/compiler/dart2js_extra/regress_null_aware_test.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2019, 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.md file.
+
+// Regression test for failure on CFE null-aware encoding.
+
+class Class {
+ Map<String, Set<String>> map;
+
+ List<String> method(String node, Set<String> set) =>
+ set.add(node)
+ ? [
+ node,
+ ...?map[node]
+ ?.expand((node) => method(node, set))
+ ?.toList()
+ ]
+ : [];
+}
+
+main(args) {
+ if (args != null && args.isNotEmpty) new Class().method('', <String>{});
+}
diff --git a/tests/compiler/dart2js_extra/rti/subtype_test.dart b/tests/compiler/dart2js_extra/rti/subtype_test.dart
index 06a624f..23eb12a 100644
--- a/tests/compiler/dart2js_extra/rti/subtype_test.dart
+++ b/tests/compiler/dart2js_extra/rti/subtype_test.dart
@@ -5,7 +5,8 @@
import 'dart:_foreign_helper' show JS, JS_GET_NAME;
import 'dart:_js_embedded_names' show JsGetName;
import 'dart:_rti' as rti;
-import "package:expect/expect.dart";
+
+import 'subtype_utils.dart';
final String objectName = JS_GET_NAME(JsGetName.OBJECT_CLASS_TYPE_NAME);
final String futureName = JS_GET_NAME(JsGetName.FUTURE_CLASS_TYPE_NAME);
@@ -23,7 +24,6 @@
}
''';
final typeRules = JS('=Object', 'JSON.parse(#)', typeRulesJson);
-final universe = rti.testingCreateUniverse();
main() {
rti.testingAddRules(universe, typeRules);
@@ -144,26 +144,3 @@
equivalent('~()<List<@/>>', '~()<List<~/>>');
unrelated('~()<List<int/>>', '~()<List<num/>>');
}
-
-String reason(String s, String t) => "$s <: $t";
-
-void strictSubtype(String s, String t) {
- var sRti = rti.testingUniverseEval(universe, s);
- var tRti = rti.testingUniverseEval(universe, t);
- Expect.isTrue(rti.testingIsSubtype(universe, sRti, tRti), reason(s, t));
- Expect.isFalse(rti.testingIsSubtype(universe, tRti, sRti), reason(t, s));
-}
-
-void unrelated(String s, String t) {
- var sRti = rti.testingUniverseEval(universe, s);
- var tRti = rti.testingUniverseEval(universe, t);
- Expect.isFalse(rti.testingIsSubtype(universe, sRti, tRti), reason(s, t));
- Expect.isFalse(rti.testingIsSubtype(universe, tRti, sRti), reason(t, s));
-}
-
-void equivalent(String s, String t) {
- var sRti = rti.testingUniverseEval(universe, s);
- var tRti = rti.testingUniverseEval(universe, t);
- Expect.isTrue(rti.testingIsSubtype(universe, sRti, tRti), reason(s, t));
- Expect.isTrue(rti.testingIsSubtype(universe, tRti, sRti), reason(t, s));
-}
diff --git a/tests/compiler/dart2js_extra/rti/subtype_utils.dart b/tests/compiler/dart2js_extra/rti/subtype_utils.dart
new file mode 100644
index 0000000..dc4f608
--- /dev/null
+++ b/tests/compiler/dart2js_extra/rti/subtype_utils.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2019, 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.
+
+import 'dart:_rti' as rti;
+import "package:expect/expect.dart";
+
+final universe = rti.testingCreateUniverse();
+
+String reason(String s, String t) => "$s <: $t";
+
+void strictSubtype(String s, String t) {
+ var sRti = rti.testingUniverseEval(universe, s);
+ var tRti = rti.testingUniverseEval(universe, t);
+ Expect.isTrue(rti.testingIsSubtype(universe, sRti, tRti), reason(s, t));
+ Expect.isFalse(rti.testingIsSubtype(universe, tRti, sRti), reason(t, s));
+}
+
+void unrelated(String s, String t) {
+ var sRti = rti.testingUniverseEval(universe, s);
+ var tRti = rti.testingUniverseEval(universe, t);
+ Expect.isFalse(rti.testingIsSubtype(universe, sRti, tRti), reason(s, t));
+ Expect.isFalse(rti.testingIsSubtype(universe, tRti, sRti), reason(t, s));
+}
+
+void equivalent(String s, String t) {
+ var sRti = rti.testingUniverseEval(universe, s);
+ var tRti = rti.testingUniverseEval(universe, t);
+ Expect.isTrue(rti.testingIsSubtype(universe, sRti, tRti), reason(s, t));
+ Expect.isTrue(rti.testingIsSubtype(universe, tRti, sRti), reason(t, s));
+}
diff --git a/tests/compiler/dart2js_extra/rti/variance_subtype_test.dart b/tests/compiler/dart2js_extra/rti/variance_subtype_test.dart
new file mode 100644
index 0000000..a42ab3f
--- /dev/null
+++ b/tests/compiler/dart2js_extra/rti/variance_subtype_test.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2019, 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.
+
+// dart2jsOptions= --enable-experiment=variance
+
+import 'dart:_foreign_helper' show JS;
+import 'dart:_rti' as rti;
+
+import 'subtype_utils.dart';
+
+const typeRulesJson = r'''
+{
+ "int": {"num": []}
+}
+''';
+final typeRules = JS('=Object', 'JSON.parse(#)', typeRulesJson);
+
+const typeParameterVariancesJson = '''
+{
+ "Covariant": [${rti.Variance.covariant}],
+ "Contravariant": [${rti.Variance.contravariant}],
+ "Invariant": [${rti.Variance.invariant}],
+ "MultiVariant":[${rti.Variance.legacyCovariant}, ${rti.Variance.invariant},
+ ${rti.Variance.contravariant}, ${rti.Variance.covariant}]
+}
+''';
+final typeParameterVariances =
+ JS('=Object', 'JSON.parse(#)', typeParameterVariancesJson);
+
+main() {
+ rti.testingAddRules(universe, typeRules);
+ rti.testingAddTypeParameterVariances(universe, typeParameterVariances);
+ testInterfacesWithVariance();
+ testInterfacesWithVariance(); // Ensure caching didn't change anything.
+}
+
+void testInterfacesWithVariance() {
+ strictSubtype('LegacyCovariant<int>', 'LegacyCovariant<num>');
+ strictSubtype('Covariant<int>', 'Covariant<num>');
+ strictSubtype('Contravariant<num>', 'Contravariant<int>');
+ equivalent('Invariant<num>', 'Invariant<num>');
+ unrelated('Invariant<int>', 'Invariant<num>');
+ unrelated('Invariant<num>', 'Invariant<int>');
+ strictSubtype(
+ 'MultiVariant<int,num,num,int>', 'MultiVariant<num,num,int,num>');
+}
diff --git a/tests/corelib/bigint_from_test.dart b/tests/corelib/bigint_from_test.dart
new file mode 100644
index 0000000..babceff
--- /dev/null
+++ b/tests/corelib/bigint_from_test.dart
@@ -0,0 +1,81 @@
+// Copyright (c) 2018, 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.
+
+// Testing Bigints with and without intrinsics.
+// VMOptions=--intrinsify --no-enable-asserts
+// VMOptions=--intrinsify --enable-asserts
+// VMOptions=--no-intrinsify --enable-asserts
+// VMOptions=--optimization-counter-threshold=5 --no-background-compilation
+
+import "package:expect/expect.dart";
+
+import 'dart:math' show pow;
+
+main() {
+ // Test integers.
+ testInt(0);
+ for (int i = 0; i < 63; i++) {
+ var n = pow(2, i) as int;
+ testInt(-n - 1);
+ testInt(-n);
+ testInt(-n + 1);
+ testInt(n - 1);
+ testInt(n);
+ testInt(n + 1);
+ }
+ testInt(-0x8000000000000000);
+
+ double dPow(num x, num exponent) => pow(x, exponent) as double;
+
+ // Test doubles.
+ testDouble(0.0);
+ testDouble(-0.0, 0.0);
+ for (double d in [
+ 1.0,
+ 2.0,
+ dPow(2.0, 30) - 1,
+ dPow(2.0, 30),
+ dPow(2.0, 31) - 1,
+ dPow(2.0, 31),
+ dPow(2.0, 31) + 1,
+ dPow(2.0, 32) - 1,
+ dPow(2.0, 32),
+ dPow(2.0, 32) + 1,
+ dPow(2.0, 52) - 1,
+ dPow(2.0, 52),
+ dPow(2.0, 52) + 1,
+ dPow(2.0, 53) - 1,
+ dPow(2.0, 53),
+ ]) {
+ for (int p = 0; p < 1024; p++) {
+ var value = (d * pow(2.0, p)); // Valid integer value.
+ if (!value.isFinite) break;
+ testDouble(-value);
+ testDouble(value);
+ }
+ }
+ Expect.equals(BigInt.zero, new BigInt.from(0.5));
+ Expect.equals(BigInt.one, new BigInt.from(1.5));
+
+ Expect.throws(() => new BigInt.from(double.infinity));
+ Expect.throws(() => new BigInt.from(-double.infinity));
+ Expect.throws(() => new BigInt.from(double.nan));
+}
+
+testInt(int n) {
+ var bigint = new BigInt.from(n);
+ Expect.equals(n, bigint.toInt());
+
+ // If the integers are inexact (e.g. > 2^53 when represented by doubles as
+ // when compiled to JavaScript numbers) then the 'toString' might be rounded
+ // to the nearest equivalent 'nicer looking' number.
+ if (n == n + 1 || n == n - 1) return;
+
+ Expect.equals("$n", "$bigint");
+}
+
+testDouble(double input, [double? expectation]) {
+ var bigint = new BigInt.from(input);
+ Expect.equals(expectation ?? input, bigint.toDouble());
+}
diff --git a/tests/corelib/bigint_js_test.dart b/tests/corelib/bigint_js_test.dart
new file mode 100644
index 0000000..ebebc25d
--- /dev/null
+++ b/tests/corelib/bigint_js_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2018, 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.
+
+// Testing Bigints with and without intrinsics.
+// VMOptions=--intrinsify --no-enable-asserts
+// VMOptions=--intrinsify --enable-asserts
+// VMOptions=--no-intrinsify --enable-asserts
+// VMOptions=--optimization-counter-threshold=5 --no-background-compilation
+
+// Test for JavaScript specific BigInt behaviour. Any JavaScript number (double)
+// that is an integral value is a Dart 'int' value, so any BigInt that has a
+// value that is exactly a double integral value should return `true` for
+// [BigInt.isValidInt].
+
+import "package:expect/expect.dart";
+
+int intPow(int a, int p) {
+ int result = 1;
+ for (int i = 0; i < p; i++) result *= a;
+ return result;
+}
+
+int pow2_53 = intPow(2, 53);
+
+test(int n1, int n2, int shift, [bool expectedIsValidInt = true]) {
+ var n = (new BigInt.from(n1) * new BigInt.from(n2)) << shift;
+ Expect.equals(expectedIsValidInt, n.isValidInt, '${n}.isValidInt');
+ if (n >= new BigInt.from(pow2_53)) {
+ var nplus1 = n + BigInt.one;
+ Expect.isFalse(nplus1.isValidInt, '${nplus1}.isValidInt');
+ }
+}
+
+main() {
+ test(13, 19, 1);
+ test(19997, 19993, 100);
+ test(19997, pow2_53 ~/ 19997, 0);
+ test(19997, pow2_53 ~/ 19997, 1);
+ test(19997, pow2_53 ~/ 19997, 100);
+ test(1, 1, 100);
+ test(1, 1, 10000, false);
+
+ // More than 53 bits in product,
+ test(pow2_53 ~/ 3, pow2_53 ~/ 5, 0, false);
+}
diff --git a/tests/corelib/bigint_parse_radix_test.dart b/tests/corelib/bigint_parse_radix_test.dart
new file mode 100644
index 0000000..57057e2
--- /dev/null
+++ b/tests/corelib/bigint_parse_radix_test.dart
@@ -0,0 +1,140 @@
+// Copyright (c) 2017, 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.
+
+// Testing Bigints with and without intrinsics.
+// VMOptions=--intrinsify --no-enable-asserts
+// VMOptions=--intrinsify --enable-asserts
+// VMOptions=--no-intrinsify --enable-asserts
+// VMOptions=--optimization-counter-threshold=5 --no-background-compilation
+
+import "package:expect/expect.dart";
+
+import 'dart:math' show pow;
+
+void testParseRadix() {
+ bool checkedMode = false;
+ assert((checkedMode = true));
+ const String oneByteWhiteSpace = "\x09\x0a\x0b\x0c\x0d\x20"
+ // "\x85" // Might make troubles on some systems. Was marked as OK test.
+ "\xa0";
+ const String whiteSpace = "$oneByteWhiteSpace\u1680"
+ "\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a"
+ "\u2028\u2029\u202f\u205f\u3000\ufeff";
+
+ var digits = "0123456789abcdefghijklmnopqrstuvwxyz";
+ var zeros = "0" * 64;
+
+ for (int i = 0; i < whiteSpace.length; i++) {
+ var ws = whiteSpace[i];
+ Expect.equals(BigInt.zero, BigInt.parse("${ws}0${ws}", radix: 2));
+ }
+
+ void testParse(BigInt result, String radixString, int radix) {
+ var m = "$radixString/$radix->$result";
+ Expect.equals(
+ result, BigInt.parse(radixString.toLowerCase(), radix: radix), m);
+ Expect.equals(
+ result, BigInt.parse(radixString.toUpperCase(), radix: radix), m);
+ Expect.equals(result, BigInt.parse(" $radixString", radix: radix), m);
+ Expect.equals(result, BigInt.parse("$radixString ", radix: radix), m);
+ Expect.equals(result, BigInt.parse(" $radixString ", radix: radix), m);
+ Expect.equals(result, BigInt.parse("+$radixString", radix: radix), m);
+ Expect.equals(result, BigInt.parse(" +$radixString", radix: radix), m);
+ Expect.equals(result, BigInt.parse("+$radixString ", radix: radix), m);
+ Expect.equals(result, BigInt.parse(" +$radixString ", radix: radix), m);
+ Expect.equals(-result, BigInt.parse("-$radixString", radix: radix), m);
+ Expect.equals(-result, BigInt.parse(" -$radixString", radix: radix), m);
+ Expect.equals(-result, BigInt.parse("-$radixString ", radix: radix), m);
+ Expect.equals(-result, BigInt.parse(" -$radixString ", radix: radix), m);
+ Expect.equals(
+ result,
+ BigInt.parse("$oneByteWhiteSpace$radixString$oneByteWhiteSpace",
+ radix: radix),
+ m);
+ Expect.equals(
+ -result,
+ BigInt.parse("$oneByteWhiteSpace-$radixString$oneByteWhiteSpace",
+ radix: radix),
+ m);
+ Expect.equals(result,
+ BigInt.parse("$whiteSpace$radixString$whiteSpace", radix: radix), m);
+ Expect.equals(-result,
+ BigInt.parse("$whiteSpace-$radixString$whiteSpace", radix: radix), m);
+
+ Expect.equals(result, BigInt.parse("$zeros$radixString", radix: radix), m);
+ Expect.equals(result, BigInt.parse("+$zeros$radixString", radix: radix), m);
+ Expect.equals(
+ -result, BigInt.parse("-$zeros$radixString", radix: radix), m);
+ }
+
+ for (int r = 2; r <= 36; r++) {
+ for (var i = BigInt.zero; i <= new BigInt.from(r * r); i += BigInt.one) {
+ String radixString = i.toRadixString(r);
+ testParse(i, radixString, r);
+ }
+ }
+
+ for (int i = 2; i <= 36; i++) {
+ var digit = digits[i - 1];
+ testParse(new BigInt.from(i).pow(64) - BigInt.one, digit * 64, i);
+ testParse(BigInt.zero, zeros, i);
+ }
+
+ // Allow both upper- and lower-case letters.
+ Expect.equals(new BigInt.from(0xABCD), BigInt.parse("ABCD", radix: 16));
+ Expect.equals(new BigInt.from(0xABCD), BigInt.parse("abcd", radix: 16));
+ Expect.equals(new BigInt.from(15628859), BigInt.parse("09azAZ", radix: 36));
+
+ Expect.equals(
+ (new BigInt.from(0x12345678) << 96) +
+ (new BigInt.from(0x12345678) << 64) +
+ (new BigInt.from(0x12345678) << 32) +
+ new BigInt.from(0x12345678),
+ BigInt.parse("0x12345678123456781234567812345678"));
+
+ // Allow whitespace before and after the number.
+ Expect.equals(BigInt.one, BigInt.parse(" 1", radix: 2));
+ Expect.equals(BigInt.one, BigInt.parse("1 ", radix: 2));
+ Expect.equals(BigInt.one, BigInt.parse(" 1 ", radix: 2));
+ Expect.equals(BigInt.one, BigInt.parse("\n1", radix: 2));
+ Expect.equals(BigInt.one, BigInt.parse("1\n", radix: 2));
+ Expect.equals(BigInt.one, BigInt.parse("\n1\n", radix: 2));
+ Expect.equals(BigInt.one, BigInt.parse("+1", radix: 2));
+
+ void testFails(String source, int? radix) {
+ Expect.throws(() {
+ BigInt.parse(source, radix: radix);
+ }, (e) => e is FormatException, "$source/$radix");
+ }
+
+ for (int i = 2; i < 36; i++) {
+ var char = i.toRadixString(36);
+ testFails(char.toLowerCase(), i);
+ testFails(char.toUpperCase(), i);
+ }
+ testFails("", 2);
+ testFails("+ 1", 2); // No space between sign and digits.
+ testFails("- 1", 2); // No space between sign and digits.
+ testFails("0x", null);
+ for (int i = 2; i <= 33; i++) {
+ // No 0x specially allowed.
+ // At radix 34 and above, "x" is a valid digit.
+ testFails("0x10", i);
+ }
+
+ testBadArguments(String source, int radix) {
+ // If the types match, it should be an ArgumentError of some sort.
+ Expect.throws(
+ () => BigInt.parse(source, radix: radix), (e) => e is ArgumentError);
+ }
+
+ testBadArguments("0", -1);
+ testBadArguments("0", 0);
+ testBadArguments("0", 1);
+ testBadArguments("0", 37);
+}
+
+main() {
+ testParseRadix();
+}
diff --git a/tests/corelib/bigint_test.dart b/tests/corelib/bigint_test.dart
new file mode 100644
index 0000000..ccabdb8
--- /dev/null
+++ b/tests/corelib/bigint_test.dart
@@ -0,0 +1,1084 @@
+// Copyright (c) 2017, 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.
+
+// Testing Bigints with and without intrinsics.
+// VMOptions=--intrinsify --no-enable-asserts
+// VMOptions=--intrinsify --enable-asserts
+// VMOptions=--no-intrinsify --enable-asserts
+// VMOptions=--optimization-counter-threshold=5 --no-background-compilation
+
+import "package:expect/expect.dart";
+
+import 'dart:math' show pow;
+
+var smallNumber = new BigInt.from(1234567890); // is 31-bit integer.
+var mediumNumber = new BigInt.from(1234567890123456); // is 53-bit integer
+var bigNumber = BigInt.parse("590295810358705600000"); // > 64-bit integer
+
+testModPow() {
+ void test(BigInt x, BigInt e, BigInt m, BigInt expectedResult) {
+ // Check that expected result is correct, using an unoptimized version.
+ assert(() {
+ slowModPow(BigInt x, BigInt e, BigInt m) {
+ var r = BigInt.one;
+ while (e > BigInt.zero) {
+ if (e.isOdd) r = (r * x) % m;
+ e >>= 1;
+ x = (x * x) % m;
+ }
+ return r;
+ }
+
+ return slowModPow(x, e, m) == expectedResult;
+ }());
+ var result = x.modPow(e, m);
+ Expect.equals(expectedResult, result, "$x.modPow($e, $m)");
+ }
+
+ test(new BigInt.from(10), new BigInt.from(20), BigInt.one, BigInt.zero);
+ test(new BigInt.from(1234567890), new BigInt.from(1000000001),
+ new BigInt.from(19), new BigInt.from(11));
+ test(new BigInt.from(1234567890), new BigInt.from(19),
+ new BigInt.from(1000000001), new BigInt.from(122998977));
+ test(new BigInt.from(19), new BigInt.from(1234567890),
+ new BigInt.from(1000000001), new BigInt.from(619059596));
+ test(new BigInt.from(19), new BigInt.from(1000000001),
+ new BigInt.from(1234567890), new BigInt.from(84910879));
+ test(new BigInt.from(1000000001), new BigInt.from(19),
+ new BigInt.from(1234567890), new BigInt.from(872984351));
+ test(new BigInt.from(1000000001), new BigInt.from(1234567890),
+ new BigInt.from(19), BigInt.zero);
+ test(BigInt.parse("12345678901234567890"),
+ BigInt.parse("10000000000000000001"), new BigInt.from(19), BigInt.two);
+ test(
+ BigInt.parse("12345678901234567890"),
+ new BigInt.from(19),
+ BigInt.parse("10000000000000000001"),
+ BigInt.parse("3239137215315834625"));
+ test(
+ new BigInt.from(19),
+ BigInt.parse("12345678901234567890"),
+ BigInt.parse("10000000000000000001"),
+ BigInt.parse("4544207837373941034"));
+ test(
+ new BigInt.from(19),
+ BigInt.parse("10000000000000000001"),
+ BigInt.parse("12345678901234567890"),
+ BigInt.parse("11135411705397624859"));
+ test(
+ BigInt.parse("10000000000000000001"),
+ new BigInt.from(19),
+ BigInt.parse("12345678901234567890"),
+ BigInt.parse("2034013733189773841"));
+ test(BigInt.parse("10000000000000000001"),
+ BigInt.parse("12345678901234567890"), new BigInt.from(19), BigInt.one);
+ test(
+ BigInt.parse("12345678901234567890"),
+ new BigInt.from(19),
+ BigInt.parse("10000000000000000001"),
+ BigInt.parse("3239137215315834625"));
+ test(BigInt.parse("12345678901234567890"),
+ BigInt.parse("10000000000000000001"), new BigInt.from(19), BigInt.two);
+ test(
+ BigInt.parse("123456789012345678901234567890"),
+ BigInt.parse("123456789012345678901234567891"),
+ BigInt.parse("123456789012345678901234567899"),
+ BigInt.parse("116401406051033429924651549616"));
+ test(
+ BigInt.parse("123456789012345678901234567890"),
+ BigInt.parse("123456789012345678901234567899"),
+ BigInt.parse("123456789012345678901234567891"),
+ BigInt.parse("123456789012345678901234567890"));
+ test(
+ BigInt.parse("123456789012345678901234567899"),
+ BigInt.parse("123456789012345678901234567890"),
+ BigInt.parse("123456789012345678901234567891"),
+ BigInt.parse("35088523091000351053091545070"));
+ test(
+ BigInt.parse("123456789012345678901234567899"),
+ BigInt.parse("123456789012345678901234567891"),
+ BigInt.parse("123456789012345678901234567890"),
+ BigInt.parse("18310047270234132455316941949"));
+ test(
+ BigInt.parse("123456789012345678901234567891"),
+ BigInt.parse("123456789012345678901234567899"),
+ BigInt.parse("123456789012345678901234567890"),
+ BigInt.one);
+ test(
+ BigInt.parse("123456789012345678901234567891"),
+ BigInt.parse("123456789012345678901234567890"),
+ BigInt.parse("123456789012345678901234567899"),
+ BigInt.parse("40128068573873018143207285483"));
+ test(
+ BigInt.parse(
+ "-7003a3cac2bac4e494d749ae101f7ede8f11dac594fea5f51e15826021d734df6ec"
+ "b6f67d74e2bb0f47ee39cb79fae059734c95d1eacb0340af64c05b83a4f70a737363"
+ "c3799d38c23b7833622d89036b4649bcc7b749037f4954dac6abe5566c97cb6ac81f"
+ "f8a09f8c71c7f08061720483b592517a608088ddb4c2e460ad1a73abbadbda077922"
+ "1751cf22f1191e3be531505c833fede908a17581a9ae96f3c0258edcfe71786b7cf3"
+ "07f67eb9ecd8656d0fd397b0215bfb79efb314299d3e9db70b31a34f5f67e6c5e166"
+ "cfa3e0bf45837c5d64fa3930a91a06b94840b4773d81280ed2af141747a6ac99d882"
+ "a59f47b15ce8c1d716ead646b139b928869902225c85ea220b90e290181f271ed087"
+ "bb6972dfe7d674b09e44c268128340d9172182732990a70af51d589c89f39d8f5dac"
+ "659161aa0a32774728e15e25bad2960b4eacb8b670581b1c431201192c8bdbcc9256"
+ "ef9e863b589f22813158050cdaf5da69f83819639f5a183c7ffe61ba1582d6ace35c"
+ "8318dfdc597d016e70b7bb115fc1a7a3481c3a6296f1504e5ccd9b14e641acb2aa32"
+ "9c3d69b5e8f1609eec8b5b5a2b0192e9f21e7e3960c52975a70cf934c32e67799c40"
+ "863b23c9579a551df4b179e6e2094f86c9fffa4bb5634202e094d380565b44cec833"
+ "db25721010dd5df766204ae8d1e8680075f261801aee047d0ac576b9b10710de54e6"
+ "eaa94648a7fba1576e66ea44f4bb7f6b941268a8d920bfc2727f82457f92cc2a016c"
+ "b",
+ radix: 16),
+ BigInt.parse(
+ "73ac14b30fe9cb8275a7410a06ce5de8a60fe0a02e236197182996ca5886fd4e6937"
+ "555f1f02ed4183ff7f097f76051f286dbb1b24751795cb793b1b81ac259",
+ radix: 16),
+ BigInt.parse(
+ "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020b"
+ "bea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d"
+ "6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a89"
+ "9fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a"
+ "69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c"
+ "354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2"
+ "ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa"
+ "051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a"
+ "8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3"
+ "d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe11757"
+ "7a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a921"
+ "08011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda"
+ "2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2"
+ "964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127"
+ "d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffff"
+ "ffff",
+ radix: 16),
+ BigInt.parse(
+ "b1b35af289290c92fcd3d22fca66016f6db7aa21508991c97f0e53fddc2f7ece7088"
+ "5e935259c28d317be14c0378e2ebd103600e2e1f55b111703fc75217836e24f9bfd8"
+ "63d47cdb26882f491949b1906c2cb016c0e9e9d77c3a9c4a3e85b9ac34057eeb993d"
+ "d048d8ed90b1eea78f84ee48febb1281384c739b1c60dda475395e3928b7081af890"
+ "d2c58eac70d11d7f14c0e98fd168735425d233b7c07506b54149482261067079f82a"
+ "b531a072ede523aca1765c1a587c160f638aa3ccab8cd1f3358c5bac3ed0a6062e92"
+ "94df2322864f6a8e58b4a2d40b600a0f09065d34bd49e60b5656d2c6dcb3af751f4a"
+ "9c10dc7df46215f3043b4077fc2be7f648d388843db9cf94f31b2eb376cf22033a23"
+ "e8984b5b1702f9e5af99507ad3d8d624a104c18af275949e7e88c16651103a2a7620"
+ "c5c8356f1f2311a9cab2c61d30b0af22d7961e42cb13679bf0d52f35b41a0f7c341a"
+ "c414a76a9a85408c39836657594180ffbb4d5a38e4b6eeea125fcde370478f6b7cd8"
+ "903fc8a822075f6e766d83337e6db2eb6605d514327294ec1e076d576eee08220acd"
+ "f4f9ffa31f1aa7b4639eb11797c8f39956b5e4dbca98a0a15eb29136b66917cfdbfb"
+ "dd8ba20475ad401a6f1022a04bed3c8d5227cd7385e9b67096261fcc2ccf2632a4c2"
+ "f5ef640b1f37966f855f8314c97c8ef7a136e54565e95bfe253e579753f5a14c2a01"
+ "6c1",
+ radix: 16));
+}
+
+testModInverse() {
+ void test(BigInt x, BigInt m, BigInt expectedResult) {
+ //print("$x op $m == $expectedResult");
+ // Check that expectedResult is an inverse.
+ assert(expectedResult < m);
+ // The 1 % m handles the m = 1 special case.
+ assert((((x % m) * expectedResult) - BigInt.one) % m == BigInt.zero);
+
+ var result = x.modInverse(m);
+ Expect.equals(expectedResult, result, "$x modinv $m");
+
+ if (x > m) {
+ x = x % m;
+ var result = x.modInverse(m);
+ Expect.equals(expectedResult, result, "$x modinv $m");
+ }
+ }
+
+ void testThrows(BigInt x, BigInt m) {
+ // Throws if not co-prime, which is a symmetric property.
+ Expect.throws(() => x.modInverse(m));
+ Expect.throws(() => m.modInverse(x));
+ }
+
+ test(BigInt.one, BigInt.one, BigInt.zero);
+
+ testThrows(BigInt.zero, new BigInt.from(1000000001));
+ testThrows(BigInt.two, new BigInt.from(4));
+ testThrows(new BigInt.from(99), new BigInt.from(9));
+ testThrows(new BigInt.from(19), new BigInt.from(1000000001));
+ testThrows(BigInt.parse("123456789012345678901234567890"),
+ BigInt.parse("123456789012345678901234567899"));
+
+ // Co-prime numbers
+ test(new BigInt.from(1234567890), new BigInt.from(19), new BigInt.from(11));
+ test(new BigInt.from(1234567890), new BigInt.from(1000000001),
+ new BigInt.from(189108911));
+ test(new BigInt.from(19), new BigInt.from(1234567890),
+ new BigInt.from(519818059));
+ test(new BigInt.from(1000000001), new BigInt.from(1234567890),
+ new BigInt.from(1001100101));
+
+ test(new BigInt.from(12345), new BigInt.from(12346), new BigInt.from(12345));
+ test(new BigInt.from(12345), new BigInt.from(12346), new BigInt.from(12345));
+
+ test(smallNumber, new BigInt.from(137), new BigInt.from(42));
+ test(new BigInt.from(137), smallNumber, new BigInt.from(856087223));
+ test(mediumNumber, new BigInt.from(137), new BigInt.from(77));
+ test(new BigInt.from(137), mediumNumber, new BigInt.from(540686667207353));
+ test(bigNumber, new BigInt.from(137), new BigInt.from(128));
+ var x = BigInt.parse(
+ "28ea16430c1f1072754aa5ebbfda0d790605a507c6c9758e88697b0b5dd9e74c",
+ radix: 16);
+ var m = BigInt.parse(
+ "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
+ radix: 16);
+ var r = BigInt.parse("95929095851002583825372225918533539673793386278"
+ "360575987103577151530201707061", radix: 10);
+ test(x, m, r);
+}
+
+testGcd() {
+ // Call testFunc with all combinations and orders of plus/minus
+ // value and other.
+ void callCombos(
+ BigInt value, BigInt other, void testFunc(BigInt a, BigInt b)) {
+ testFunc(value, other);
+ testFunc(value, -other);
+ testFunc(-value, other);
+ testFunc(-value, -other);
+ if (value == other) return;
+ testFunc(other, value);
+ testFunc(other, -value);
+ testFunc(-other, value);
+ testFunc(-other, -value);
+ }
+
+ // Test that gcd of value and other (non-negative) is expectedResult.
+ // Tests all combinations of positive and negative values and order of
+ // operands, so use positive values and order is not important.
+ void test(BigInt value, BigInt other, BigInt expectedResult) {
+ // Check for bug in test.
+ assert(
+ expectedResult == BigInt.zero || value % expectedResult == BigInt.zero);
+ assert(
+ expectedResult == BigInt.zero || other % expectedResult == BigInt.zero);
+
+ callCombos(value, other, (BigInt a, BigInt b) {
+ var result = a.gcd(b);
+
+ /// Check that the result is a divisor.
+ Expect.equals(
+ BigInt.zero, result == BigInt.zero ? a : a % result, "$result | $a");
+ Expect.equals(
+ BigInt.zero, result == BigInt.zero ? b : b % result, "$result | $b");
+ // Check for bug in test. If assert fails, the expected value is too low,
+ // and the gcd call has found a greater common divisor.
+ assert(result >= expectedResult);
+ Expect.equals(expectedResult, result, "$a.gcd($b)");
+ });
+ }
+
+ // Test that gcd of value and other (non-negative) throws.
+ testThrows(value, other) {
+ callCombos(value, other, (a, b) {
+ Expect.throws(() => a.gcd(b));
+ });
+ }
+
+ // Format:
+ // test(value1, value2, expectedResult);
+ test(BigInt.one, BigInt.one, BigInt.one); // both are 1
+ test(BigInt.one, BigInt.two, BigInt.one); // one is 1
+ test(new BigInt.from(3), new BigInt.from(5), BigInt.one); // coprime.
+ test(new BigInt.from(37), new BigInt.from(37),
+ new BigInt.from(37)); // Same larger prime.
+
+ test(new BigInt.from(9999), new BigInt.from(7272),
+ new BigInt.from(909)); // Larger numbers
+
+ test(BigInt.zero, new BigInt.from(1000),
+ new BigInt.from(1000)); // One operand is zero.
+ test(BigInt.zero, BigInt.zero, BigInt.zero); // Both operands are zero.
+
+ // Multiplying both operands by a number multiplies result by same number.
+ test(new BigInt.from(693), new BigInt.from(609), new BigInt.from(21));
+ test(new BigInt.from(693) << 5, new BigInt.from(609) << 5,
+ new BigInt.from(21) << 5);
+ test(
+ new BigInt.from(693) * new BigInt.from(937),
+ new BigInt.from(609) * new BigInt.from(937),
+ new BigInt.from(21) * new BigInt.from(937));
+ test(
+ new BigInt.from(693) * new BigInt.from(pow(2, 32)),
+ new BigInt.from(609) * new BigInt.from(pow(2, 32)),
+ new BigInt.from(21) * new BigInt.from(pow(2, 32)));
+ test(
+ new BigInt.from(693) * BigInt.two.pow(52),
+ new BigInt.from(609) * BigInt.two.pow(52),
+ new BigInt.from(21) * BigInt.two.pow(52));
+ test(
+ new BigInt.from(693) * BigInt.two.pow(53),
+ new BigInt.from(609) * BigInt.two.pow(53),
+ new BigInt.from(21) * BigInt.two.pow(53)); // Regression.
+ test(
+ new BigInt.from(693) * BigInt.two.pow(99),
+ new BigInt.from(609) * BigInt.two.pow(99),
+ new BigInt.from(21) * BigInt.two.pow(99));
+
+ test(new BigInt.from(1234567890), new BigInt.from(19), BigInt.one);
+ test(new BigInt.from(1234567890), new BigInt.from(1000000001), BigInt.one);
+ test(new BigInt.from(19), new BigInt.from(1000000001), new BigInt.from(19));
+
+ test(new BigInt.from(0x3FFFFFFF), new BigInt.from(0x3FFFFFFF),
+ new BigInt.from(0x3FFFFFFF));
+ test(new BigInt.from(0x3FFFFFFF), new BigInt.from(0x40000000), BigInt.one);
+
+ test(BigInt.two.pow(54), BigInt.two.pow(53), BigInt.two.pow(53));
+
+ test(
+ (BigInt.two.pow(52) - BigInt.one) * BigInt.two.pow(14),
+ (BigInt.two.pow(26) - BigInt.one) * BigInt.two.pow(22),
+ (BigInt.two.pow(26) - BigInt.one) * BigInt.two.pow(14));
+}
+
+foo() => BigInt.parse("1234567890123456789");
+bar() => BigInt.parse("12345678901234567890");
+
+testSmiOverflow() {
+ var a = new BigInt.from(1073741823);
+ var b = new BigInt.from(1073741822);
+ Expect.equals(new BigInt.from(2147483645), a + b);
+ a = -new BigInt.from(1000000000);
+ b = new BigInt.from(1000000001);
+ Expect.equals(-new BigInt.from(2000000001), a - b);
+ Expect.equals(-BigInt.parse("1000000001000000000"), a * b);
+}
+
+testBigintAnd() {
+ var a = BigInt.parse("0x55555555555555555555");
+ var b = BigInt.parse("0x33333333333333333333");
+ var c = BigInt.parse("0x11111111111111111111");
+ Expect.equals(BigInt.zero, BigInt.zero & a);
+ Expect.equals(BigInt.zero, a & BigInt.zero);
+ Expect.equals(c, a & b);
+}
+
+testBigintOr() {
+ var a = BigInt.parse("0x33333333333333333333");
+ var b = BigInt.parse("0x55555555555555555555");
+ var c = BigInt.parse("0x77777777777777777777");
+ Expect.equals(a, BigInt.zero | a);
+ Expect.equals(a, a | BigInt.zero);
+ Expect.equals(c, a | b);
+}
+
+testBigintXor() {
+ var a = BigInt.parse("0x33333333333333333333");
+ var b = BigInt.parse("0x55555555555555555555");
+ var c = BigInt.parse("0x66666666666666666666");
+ Expect.equals(a, BigInt.zero ^ a);
+ Expect.equals(a, a ^ BigInt.zero);
+ Expect.equals(c, a ^ b);
+}
+
+testBigintAdd() {
+ // Bigint and Smi.
+ var a = BigInt.parse("12345678901234567890");
+ var b = BigInt.two;
+ Expect.equals(BigInt.parse("12345678901234567892"), a + b);
+ Expect.equals(BigInt.parse("12345678901234567892"), b + a);
+ // Bigint and Bigint.
+ a = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.parse("20000000000000000002"), a + a);
+ Expect.equals(a, BigInt.zero + a);
+ Expect.equals(a, a + BigInt.zero);
+}
+
+testBigintSub() {
+ // Bigint and Smi.
+ var a = BigInt.parse("12345678901234567890");
+ var b = BigInt.two;
+ Expect.equals(BigInt.parse("12345678901234567888"), a - b);
+ Expect.equals(-BigInt.parse("12345678901234567888"), b - a);
+ // Bigint and Bigint.
+ a = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.parse("20000000000000000002"), a + a);
+ Expect.equals(-a, BigInt.zero - a);
+ Expect.equals(a, a - BigInt.zero);
+}
+
+testBigintMul() {
+ // Bigint and Smi.
+ var a = BigInt.parse("12345678901234567890");
+ var b = new BigInt.from(10);
+ Expect.equals(BigInt.parse("123456789012345678900"), a * b);
+ Expect.equals(BigInt.parse("123456789012345678900"), b * a);
+ // Bigint and Bigint.
+ a = BigInt.parse("12345678901234567890");
+ b = BigInt.parse("10000000000000000");
+ Expect.equals(BigInt.parse("123456789012345678900000000000000000"), a * b);
+}
+
+testBigintTruncDiv() {
+ var a = BigInt.parse("12345678901234567890");
+ var b = new BigInt.from(10);
+ // Bigint and Smi.
+ Expect.equals(BigInt.parse("1234567890123456789"), a ~/ b);
+ Expect.equals(BigInt.zero, b ~/ a);
+ Expect.equals(new BigInt.from(123456789),
+ BigInt.parse("123456789012345678") ~/ new BigInt.from(1000000000));
+ // TruncDiv as used in toString().
+ a = BigInt.parse("4503599627370496"); // 0x10000000000000
+ b = new BigInt.from(10000);
+ Expect.equals(new BigInt.from(450359962737), a ~/ b);
+ b = new BigInt.from(1000000000);
+ Expect.equals(new BigInt.from(4503599), a ~/ b);
+ // Bigint and Bigint.
+ a = BigInt.parse("12345678901234567890");
+ b = BigInt.parse("10000000000000000");
+ Expect.equals(new BigInt.from(1234), a ~/ b);
+ a = BigInt.parse("9173112362840293939050000000000000000");
+ b = BigInt.parse("50000000000000000");
+ Expect.equals(BigInt.parse("183462247256805878781"), a ~/ b);
+}
+
+testBigintDiv() {
+ // Bigint and Smi.
+ Expect.equals(1234567890123456789.1,
+ BigInt.parse("12345678901234567891") / new BigInt.from(10));
+ Expect.equals(
+ 0.000000001234, new BigInt.from(1234) / new BigInt.from(1000000000000));
+ Expect.equals(12345678901234000000.0,
+ BigInt.parse("123456789012340000000") / new BigInt.from(10));
+ // Bigint and Bigint.
+ var a = BigInt.parse("12345670000000000000");
+ var b = BigInt.parse("10000000000000000");
+ Expect.equals(1234.567, a / b);
+}
+
+testBigintModulo() {
+ // Bigint and Smi.
+ var a = new BigInt.from(1000000000005);
+ var b = new BigInt.from(10);
+ Expect.equals(new BigInt.from(5), a % b);
+ Expect.equals(new BigInt.from(10), b % a);
+ // Modulo as used in toString().
+ a = BigInt.parse("4503599627370496"); // 0x10000000000000
+ b = new BigInt.from(10000);
+ Expect.equals(new BigInt.from(496), a % b);
+ b = new BigInt.from(1000000000);
+ Expect.equals(new BigInt.from(627370496), a % b);
+ // Bigint & Bigint
+ a = BigInt.parse("10000000000000000001");
+ b = BigInt.parse("10000000000000000000");
+ Expect.equals(BigInt.one, a % b);
+ Expect.equals(BigInt.parse("10000000000000000000"), b % a);
+ a = BigInt.parse("2432363650");
+ b = BigInt.parse("2201792050");
+ Expect.equals(BigInt.parse("230571600"), a % b);
+ Expect.equals(BigInt.parse("2201792050"), b % a);
+}
+
+testBigintModPow() {
+ var x, e, m;
+ x = new BigInt.from(1234567890);
+ e = new BigInt.from(1000000001);
+ m = new BigInt.from(19);
+ Expect.equals(new BigInt.from(11), x.modPow(e, m));
+ x = new BigInt.from(1234567890);
+ e = new BigInt.from(19);
+ m = new BigInt.from(1000000001);
+ Expect.equals(new BigInt.from(122998977), x.modPow(e, m));
+ x = new BigInt.from(19);
+ e = new BigInt.from(1234567890);
+ m = new BigInt.from(1000000001);
+ Expect.equals(new BigInt.from(619059596), x.modPow(e, m));
+ x = new BigInt.from(19);
+ e = new BigInt.from(1000000001);
+ m = new BigInt.from(1234567890);
+ Expect.equals(new BigInt.from(84910879), x.modPow(e, m));
+ x = new BigInt.from(1000000001);
+ e = new BigInt.from(19);
+ m = new BigInt.from(1234567890);
+ Expect.equals(new BigInt.from(872984351), x.modPow(e, m));
+ x = new BigInt.from(1000000001);
+ e = new BigInt.from(1234567890);
+ m = new BigInt.from(19);
+ Expect.equals(BigInt.zero, x.modPow(e, m));
+ x = BigInt.parse("12345678901234567890");
+ e = BigInt.parse("10000000000000000001");
+ m = new BigInt.from(19);
+ Expect.equals(BigInt.two, x.modPow(e, m));
+ x = BigInt.parse("12345678901234567890");
+ e = new BigInt.from(19);
+ m = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.parse("3239137215315834625"), x.modPow(e, m));
+ x = new BigInt.from(19);
+ e = BigInt.parse("12345678901234567890");
+ m = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.parse("4544207837373941034"), x.modPow(e, m));
+ x = new BigInt.from(19);
+ e = BigInt.parse("10000000000000000001");
+ m = BigInt.parse("12345678901234567890");
+ Expect.equals(BigInt.parse("11135411705397624859"), x.modPow(e, m));
+ x = BigInt.parse("10000000000000000001");
+ e = new BigInt.from(19);
+ m = BigInt.parse("12345678901234567890");
+ Expect.equals(BigInt.parse("2034013733189773841"), x.modPow(e, m));
+ x = BigInt.parse("10000000000000000001");
+ e = BigInt.parse("12345678901234567890");
+ m = new BigInt.from(19);
+ Expect.equals(BigInt.one, x.modPow(e, m));
+ x = BigInt.parse("12345678901234567890");
+ e = new BigInt.from(19);
+ m = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.parse("3239137215315834625"), x.modPow(e, m));
+ x = BigInt.parse("12345678901234567890");
+ e = BigInt.parse("10000000000000000001");
+ m = new BigInt.from(19);
+ Expect.equals(BigInt.two, x.modPow(e, m));
+ x = BigInt.parse("123456789012345678901234567890");
+ e = BigInt.parse("123456789012345678901234567891");
+ m = BigInt.parse("123456789012345678901234567899");
+ Expect.equals(BigInt.parse("116401406051033429924651549616"), x.modPow(e, m));
+ x = BigInt.parse("123456789012345678901234567890");
+ e = BigInt.parse("123456789012345678901234567899");
+ m = BigInt.parse("123456789012345678901234567891");
+ Expect.equals(BigInt.parse("123456789012345678901234567890"), x.modPow(e, m));
+ x = BigInt.parse("123456789012345678901234567899");
+ e = BigInt.parse("123456789012345678901234567890");
+ m = BigInt.parse("123456789012345678901234567891");
+ Expect.equals(BigInt.parse("35088523091000351053091545070"), x.modPow(e, m));
+ x = BigInt.parse("123456789012345678901234567899");
+ e = BigInt.parse("123456789012345678901234567891");
+ m = BigInt.parse("123456789012345678901234567890");
+ Expect.equals(BigInt.parse("18310047270234132455316941949"), x.modPow(e, m));
+ x = BigInt.parse("123456789012345678901234567891");
+ e = BigInt.parse("123456789012345678901234567899");
+ m = BigInt.parse("123456789012345678901234567890");
+ Expect.equals(BigInt.one, x.modPow(e, m));
+ x = BigInt.parse("123456789012345678901234567891");
+ e = BigInt.parse("123456789012345678901234567890");
+ m = BigInt.parse("123456789012345678901234567899");
+ Expect.equals(BigInt.parse("40128068573873018143207285483"), x.modPow(e, m));
+ x = BigInt.parse(
+ "142223781135477974841804437037182877109549636480215350570761436386728140"
+ "00321219503871352719175100865184619168128345594681547640115731246638");
+ e = BigInt.parse(
+ "688057170495263083245752731085731160016625265771524738691797062279575950"
+ "919479651156310413084174304361991240273181430924411258203766946639349880"
+ "404106504114953688890200429043051936362182997575167191584461538746041795"
+ "019663740246921124383173799957296515067912829778249931473903780958741032"
+ "64534184571632120755");
+ m = BigInt.parse(
+ "144173682842817587002196172066264549138375068078359231382946906898412792"
+ "452632726597279520229873489736777248181678202636100459215718497240474064"
+ "366927544074501134727745837254834206456400508719134610847814227274992298"
+ "238973375146473350157304285346424982280927848339601514720098577525635486"
+ "320547905945936448443");
+ Expect.equals(
+ BigInt.parse(
+ "41228476947144730491819644448449646627743926889389391986712371102685"
+ "14984467753960109321610008533258676279344318597060690521027646613453"
+ "25674994677820913027869835916005689276806408148698486814119894325284"
+ "18918299321385420296108046942018595594076729397423805685944237555128"
+ "652606412065971965116137839721723231"),
+ x.modPow(e, m));
+}
+
+testBigintModInverse() {
+ var x, m;
+ x = BigInt.one;
+ m = BigInt.one;
+ Expect.equals(BigInt.zero, x.modInverse(m));
+ x = BigInt.zero;
+ m = new BigInt.from(1000000001);
+ Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
+ x = new BigInt.from(1234567890);
+ m = new BigInt.from(19);
+ Expect.equals(new BigInt.from(11), x.modInverse(m));
+ x = new BigInt.from(1234567890);
+ m = new BigInt.from(1000000001);
+ Expect.equals(new BigInt.from(189108911), x.modInverse(m));
+ x = new BigInt.from(19);
+ m = new BigInt.from(1000000001);
+ Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
+ x = new BigInt.from(19);
+ m = new BigInt.from(1234567890);
+ Expect.equals(new BigInt.from(519818059), x.modInverse(m));
+ x = new BigInt.from(1000000001);
+ m = new BigInt.from(1234567890);
+ Expect.equals(new BigInt.from(1001100101), x.modInverse(m));
+ x = new BigInt.from(1000000001);
+ m = new BigInt.from(19);
+ Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
+ x = BigInt.parse("12345678901234567890");
+ m = new BigInt.from(19);
+ Expect.equals(new BigInt.from(3), x.modInverse(m));
+ x = BigInt.parse("12345678901234567890");
+ m = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.parse("9736746307686209582"), x.modInverse(m));
+ x = new BigInt.from(19);
+ m = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.parse("6315789473684210527"), x.modInverse(m));
+ x = new BigInt.from(19);
+ m = BigInt.parse("12345678901234567890");
+ Expect.equals(BigInt.parse("10396361179987004539"), x.modInverse(m));
+ x = BigInt.parse("10000000000000000001");
+ m = BigInt.parse("12345678901234567890");
+ Expect.equals(BigInt.parse("325004555487045911"), x.modInverse(m));
+ x = BigInt.parse("10000000000000000001");
+ m = new BigInt.from(19);
+ Expect.equals(new BigInt.from(7), x.modInverse(m));
+ x = BigInt.parse("12345678901234567890");
+ m = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.parse("9736746307686209582"), x.modInverse(m));
+ x = BigInt.parse("12345678901234567890");
+ m = new BigInt.from(19);
+ Expect.equals(new BigInt.from(3), x.modInverse(m));
+ x = BigInt.parse("123456789012345678901234567890");
+ m = BigInt.parse("123456789012345678901234567899");
+ Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
+ x = BigInt.parse("123456789012345678901234567890");
+ m = BigInt.parse("123456789012345678901234567891");
+ Expect.equals(
+ BigInt.parse("123456789012345678901234567890"), x.modInverse(m));
+ x = BigInt.parse("123456789012345678901234567899");
+ m = BigInt.parse("123456789012345678901234567891");
+ Expect.equals(BigInt.parse("77160493132716049313271604932"), x.modInverse(m));
+ x = BigInt.parse("123456789012345678901234567899");
+ m = BigInt.parse("123456789012345678901234567890");
+ Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
+ x = BigInt.parse("123456789012345678901234567891");
+ m = BigInt.parse("123456789012345678901234567890");
+ Expect.equals(BigInt.one, x.modInverse(m));
+ x = BigInt.parse("123456789012345678901234567891");
+ m = BigInt.parse("123456789012345678901234567899");
+ Expect.equals(BigInt.parse("46296295879629629587962962962"), x.modInverse(m));
+}
+
+testBigintGcd() {
+ var x, m;
+ x = BigInt.one;
+ m = BigInt.one;
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = new BigInt.from(693);
+ m = new BigInt.from(609);
+ Expect.equals(new BigInt.from(21), x.gcd(m));
+ x = new BigInt.from(693) << 40;
+ m = new BigInt.from(609) << 40;
+ Expect.equals(new BigInt.from(21) << 40, x.gcd(m));
+ x = new BigInt.from(609) << 40;
+ m = new BigInt.from(693) << 40;
+ Expect.equals(new BigInt.from(21) << 40, x.gcd(m));
+ x = BigInt.zero;
+ m = new BigInt.from(1000000001);
+ Expect.equals(m, x.gcd(m));
+ x = new BigInt.from(1000000001);
+ m = BigInt.zero;
+ Expect.equals(x, x.gcd(m));
+ x = BigInt.zero;
+ m = -new BigInt.from(1000000001);
+ Expect.equals(-m, x.gcd(m));
+ x = -new BigInt.from(1000000001);
+ m = BigInt.zero;
+ Expect.equals(-x, x.gcd(m));
+ x = BigInt.zero;
+ m = BigInt.zero;
+ Expect.equals(BigInt.zero, x.gcd(m));
+ x = BigInt.zero;
+ m = BigInt.parse("123456789012345678901234567890");
+ Expect.equals(m, x.gcd(m));
+ x = BigInt.parse("123456789012345678901234567890");
+ m = BigInt.zero;
+ Expect.equals(x, x.gcd(m));
+ x = BigInt.zero;
+ m = -BigInt.parse("123456789012345678901234567890");
+ Expect.equals(-m, x.gcd(m));
+ x = -BigInt.parse("123456789012345678901234567890");
+ m = BigInt.zero;
+ Expect.equals(-x, x.gcd(m));
+ x = new BigInt.from(1234567890);
+ m = new BigInt.from(19);
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = new BigInt.from(1234567890);
+ m = new BigInt.from(1000000001);
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = new BigInt.from(19);
+ m = new BigInt.from(1000000001);
+ Expect.equals(new BigInt.from(19), x.gcd(m));
+ x = new BigInt.from(19);
+ m = new BigInt.from(1234567890);
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = new BigInt.from(1000000001);
+ m = new BigInt.from(1234567890);
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = new BigInt.from(1000000001);
+ m = new BigInt.from(19);
+ Expect.equals(new BigInt.from(19), x.gcd(m));
+ x = BigInt.parse("12345678901234567890");
+ m = new BigInt.from(19);
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = BigInt.parse("12345678901234567890");
+ m = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = new BigInt.from(19);
+ m = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = new BigInt.from(19);
+ m = BigInt.parse("12345678901234567890");
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = BigInt.parse("10000000000000000001");
+ m = BigInt.parse("12345678901234567890");
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = BigInt.parse("10000000000000000001");
+ m = new BigInt.from(19);
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = BigInt.parse("12345678901234567890");
+ m = BigInt.parse("10000000000000000001");
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = BigInt.parse("12345678901234567890");
+ m = new BigInt.from(19);
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = BigInt.parse("123456789012345678901234567890");
+ m = BigInt.parse("123456789012345678901234567899");
+ Expect.equals(new BigInt.from(9), x.gcd(m));
+ x = BigInt.parse("123456789012345678901234567890");
+ m = BigInt.parse("123456789012345678901234567891");
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = BigInt.parse("123456789012345678901234567899");
+ m = BigInt.parse("123456789012345678901234567891");
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = BigInt.parse("123456789012345678901234567899");
+ m = BigInt.parse("123456789012345678901234567890");
+ Expect.equals(new BigInt.from(9), x.gcd(m));
+ x = BigInt.parse("123456789012345678901234567891");
+ m = BigInt.parse("123456789012345678901234567890");
+ Expect.equals(BigInt.one, x.gcd(m));
+ x = BigInt.parse("123456789012345678901234567891");
+ m = BigInt.parse("123456789012345678901234567899");
+ Expect.equals(BigInt.one, x.gcd(m));
+}
+
+testBigintNegate() {
+ var a = BigInt.parse("0xF000000000000000F");
+ var b = ~a; // negate.
+ Expect.equals(BigInt.parse("-0xF0000000000000010"), b);
+ Expect.equals(BigInt.zero, a & b);
+ Expect.equals(-BigInt.one, a | b);
+}
+
+testShiftAmount() {
+ Expect.equals(BigInt.zero, BigInt.zero << 0);
+ Expect.equals(BigInt.zero, BigInt.zero >> 0);
+ Expect.equals(BigInt.zero, BigInt.zero << 1234567890);
+ Expect.equals(BigInt.zero, BigInt.zero >> 1234567890);
+ Expect.equals(BigInt.two.pow(999), BigInt.one << 999);
+ Expect.equals(BigInt.one, BigInt.two.pow(999) >> 999);
+ // 0x7FFFFFFFFFFFFFFF on VM, slightly rounded up on web platform.
+ const int maxInt64 = 0x7FFFFFFFFFFFF000 + 0xFFF;
+ Expect.equals(BigInt.zero, new BigInt.from(12) >> maxInt64);
+ Expect.equals(-BigInt.one, -new BigInt.from(12) >> maxInt64);
+ bool exceptionCaught = false;
+ try {
+ var a = BigInt.one << maxInt64;
+ } on OutOfMemoryError catch (e) {
+ exceptionCaught = true;
+ } catch (e) {
+ // In JavaScript the allocation of the internal array throws different
+ // kind of errors. Just assume it's the right one.
+ exceptionCaught = true;
+ }
+ Expect.equals(true, exceptionCaught);
+}
+
+void testPow() {
+ Expect.throws(() => BigInt.zero.pow(-1), (e) => e is ArgumentError);
+ Expect.throws(() => BigInt.one.pow(-1), (e) => e is ArgumentError);
+ Expect.equals(BigInt.one, BigInt.zero.pow(0));
+ Expect.equals(BigInt.one, BigInt.one.pow(0));
+ Expect.equals(BigInt.one, BigInt.two.pow(0));
+
+ Expect.equals(
+ BigInt.parse("6208695403009031808124000434786599466508260573005"
+ "3508480680160632742505079094163654310415168343540278191693"
+ "5380629274547924077088101599462083663373536705603680787010"
+ "0454231036999140164473780469056908670815701571304455697970"
+ "9971709527651446612272365411298758026041094781651768636427"
+ "4780767345075500515905845436036697865291662016364446907149"
+ "5652136304764312997430969058854587555188117728022873502683"
+ "6327099687782677885098446991121805146733387058565662606025"
+ "2854981418159051193843689364388302820905062090182919338371"
+ "8783490348348213313279505263650976040646393394551465619437"
+ "7126646818740571207346633109049097273375955956480091920939"
+ "5595130499375022416542475049562151695680373438890512164488"
+ "6567991220660935537691145761690539808578087290707813875567"
+ "9145826183642842261374804672283964244725240865733938342036"
+ "1216219271232461693264437901347421563392441043817990067322"
+ "88"),
+ BigInt.parse("90218646930912603144382974164422").pow(27));
+ ;
+}
+
+void testToRadixString() {
+ // Test that we accept radix 2 to 36 and that we use lower-case
+ // letters.
+ var expected = [
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', //
+ 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', //
+ 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' //
+ ];
+ for (var radix = 2; radix <= 36; radix++) {
+ for (var i = 0; i < radix; i++) {
+ Expect.equals(expected[i], new BigInt.from(i).toRadixString(radix));
+ }
+ }
+
+ var illegalRadices = [-1, 0, 1, 37];
+ for (var radix in illegalRadices) {
+ try {
+ new BigInt.from(42).toRadixString(radix);
+ Expect.fail("Exception expected");
+ } on ArgumentError catch (e) {
+ // Nothing to do.
+ }
+ }
+
+ // Try large numbers (regression test for issue 15316).
+ var bignums = [
+ BigInt.parse("0x80000000"),
+ BigInt.parse("0x100000000"),
+ BigInt.parse("0x10000000000000"),
+ BigInt.parse("0x10000000000001"), // 53 significant bits.
+ BigInt.parse("0x20000000000000"),
+ BigInt.parse("0x20000000000002"),
+ BigInt.parse("0x1000000000000000"),
+ BigInt.parse("0x1000000000000100"),
+ BigInt.parse("0x2000000000000000"),
+ BigInt.parse("0x2000000000000200"),
+ BigInt.parse("0x8000000000000000"),
+ BigInt.parse("0x8000000000000800"),
+ BigInt.parse("0x10000000000000000"),
+ BigInt.parse("0x10000000000001000"),
+ BigInt.parse("0x100000000000010000"),
+ BigInt.parse("0x1000000000000100000"),
+ BigInt.parse("0x10000000000001000000"),
+ BigInt.parse("0x100000000000010000000"),
+ BigInt.parse("0x1000000000000100000000"),
+ BigInt.parse("0x10000000000001000000000"),
+ ];
+ for (var bignum in bignums) {
+ for (int radix = 2; radix <= 36; radix++) {
+ String digits = bignum.toRadixString(radix);
+ BigInt result = BigInt.parse(digits, radix: radix);
+ Expect.equals(
+ bignum, result, "${bignum.toRadixString(16)} -> $digits/$radix");
+ }
+ }
+}
+
+testToString() {
+ /// Test that converting [value] to a string gives [expect].
+ /// Also test that `-value` gives `"-"+expect`.
+ test(BigInt value, String expect) {
+ Expect.equals(expect, value.toString());
+ Expect.equals(expect, "$value");
+ Expect.equals(expect, (new StringBuffer()..write(value)).toString());
+ if (value == BigInt.zero) return;
+ expect = "-$expect";
+ value = -value;
+ Expect.equals(expect, value.toString());
+ Expect.equals(expect, "$value");
+ Expect.equals(expect, (new StringBuffer()..write(value)).toString());
+ }
+
+ // Very simple tests.
+ test(BigInt.zero, "0");
+ test(BigInt.one, "1");
+ test(BigInt.two, "2");
+ test(new BigInt.from(5), "5");
+
+ // Binary special cases.
+
+ // ~2^30.
+ test(BigInt.parse("0x3fffffff"), "1073741823");
+ test(BigInt.parse("0x40000000"), "1073741824");
+ test(BigInt.parse("0x40000001"), "1073741825");
+ // ~2^31.
+ test(BigInt.parse("0x7fffffff"), "2147483647");
+ test(BigInt.parse("0x80000000"), "2147483648");
+ test(BigInt.parse("0x80000001"), "2147483649");
+ // ~2^32.
+ test(BigInt.parse("0xffffffff"), "4294967295");
+ test(BigInt.parse("0x100000000"), "4294967296");
+ test(BigInt.parse("0x100000001"), "4294967297");
+
+ // ~2^51.
+ test(BigInt.parse("0x7ffffffffffff"), "2251799813685247");
+ test(BigInt.parse("0x8000000000000"), "2251799813685248");
+ test(BigInt.parse("0x8000000000001"), "2251799813685249");
+ // ~2^52.
+ test(BigInt.parse("0xfffffffffffff"), "4503599627370495");
+ test(BigInt.parse("0x10000000000000"), "4503599627370496");
+ test(BigInt.parse("0x10000000000001"), "4503599627370497");
+ // ~2^53.
+ test(BigInt.parse("0x1fffffffffffff"), "9007199254740991");
+ test(BigInt.parse("0x20000000000000"), "9007199254740992");
+ test(BigInt.parse("0x20000000000001"), "9007199254740993");
+ // ~2^62.
+ test(BigInt.parse("0x3fffffffffffffff"), "4611686018427387903");
+ test(BigInt.parse("0x4000000000000000"), "4611686018427387904");
+ test(BigInt.parse("0x4000000000000001"), "4611686018427387905");
+ // ~2^63.
+ test(BigInt.parse("0x7fffffffffffffff"), "9223372036854775807");
+ test(BigInt.parse("0x8000000000000000"), "9223372036854775808");
+ test(BigInt.parse("0x8000000000000001"), "9223372036854775809");
+ // ~2^64.
+ test(BigInt.parse("0xffffffffffffffff"), "18446744073709551615");
+ test(BigInt.parse("0x10000000000000000"), "18446744073709551616");
+ test(BigInt.parse("0x10000000000000001"), "18446744073709551617");
+ // Big bignum.
+ test(BigInt.parse("123456789012345678901234567890"),
+ "123456789012345678901234567890");
+
+ // Decimal special cases.
+
+ BigInt number = new BigInt.from(10);
+ // Numbers 99..99, 100...00, and 100..01 up to 23 digits.
+ for (int i = 1; i < 22; i++) {
+ test(number - BigInt.one, "9" * i);
+ test(number, "1" + "0" * i);
+ test(number + BigInt.one, "1" + "0" * (i - 1) + "1");
+ number *= new BigInt.from(10);
+ }
+}
+
+void testFromToInt() {
+ void test(int x) {
+ var bigFrom = new BigInt.from(x);
+ var bigStr = bigFrom.toString();
+ Expect.equals(x, bigFrom.toInt());
+ Expect.equals(x, int.parse(bigStr));
+ }
+
+ for (int i = 0; i < 20; i++) {
+ test(i);
+ // Dart2js doesn't know that -0 should stay 0.
+ if (i != 0) test(-i);
+ }
+
+ // For now just test "easy" integers since there is no check yet that clamps
+ // the returned integer.
+ for (int i = 0; i < 2000000; i += 10000) {
+ test(i);
+ // Dart2js doesn't know that -0 should stay 0.
+ if (i != 0) test(-i);
+ }
+
+ const minInt64 = -0x80000000 * 0x100000000;
+ test(minInt64);
+}
+
+void testFromToDouble() {
+ Expect.equals(-1.0, (-BigInt.one).toDouble());
+
+ Expect.throws(() => new BigInt.from(double.nan));
+ Expect.throws(() => new BigInt.from(double.infinity));
+ Expect.throws(() => new BigInt.from(-double.infinity));
+
+ const double maxDouble = 1.7976931348623157e+308;
+ const String maxDoubleHexStr = "0xfffffffffffff8000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000";
+
+ // The following value lies directly on the boundary between max double and
+ // infinity. It rounds to infinity. Any value below rounds to a finite double
+ // value.
+ const String maxDoubleBoundaryStr = "0xfffffffffffffc0000000000"
+ "00000000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000";
+
+ var bigMax = BigInt.parse(maxDoubleHexStr);
+ var bigBoundary = BigInt.parse(maxDoubleBoundaryStr);
+ Expect.equals(maxDouble, bigMax.toDouble());
+ Expect.equals(bigMax, new BigInt.from(maxDouble));
+ Expect.equals(double.infinity, bigBoundary.toDouble());
+ Expect.equals(maxDouble, (bigBoundary - BigInt.one).toDouble());
+
+ Expect.equals(-maxDouble, (-bigMax).toDouble());
+ Expect.equals(-bigMax, new BigInt.from(-maxDouble));
+ Expect.equals(-double.infinity, (-bigBoundary).toDouble());
+ Expect.equals(-maxDouble, (-(bigBoundary - BigInt.one)).toDouble());
+
+ void test(int x) {
+ var str = x.toString();
+ var big = BigInt.parse(str);
+ Expect.equals(x, big.toDouble());
+ }
+
+ for (int i = 0; i < 20; i++) {
+ test(i);
+ // Dart2js doesn't know that -0 should stay 0.
+ if (i != 0) test(-i);
+ }
+
+ for (int i = 0; i < 2000000; i += 10000) {
+ test(i);
+ // Dart2js doesn't know that -0 should stay 0.
+ if (i != 0) test(-i);
+ }
+
+ for (int i = 1000; i < 100000; i += 1000) {
+ var d = 1 / i;
+ Expect.equals(BigInt.zero, new BigInt.from(d));
+ }
+
+ // Non-integer values are truncated.
+ Expect.equals(BigInt.one, new BigInt.from(1.5));
+ Expect.equals(-BigInt.one, new BigInt.from(-1.5));
+
+ Expect.equals(BigInt.zero, new BigInt.from(0.9999999999999999));
+ Expect.equals(BigInt.zero, new BigInt.from(-0.9999999999999999));
+}
+
+main() {
+ for (int i = 0; i < 8; i++) {
+ Expect.equals(BigInt.parse("1234567890123456789"), foo()); //# 01: ok
+ Expect.equals(BigInt.parse("12345678901234567890"), bar()); //# 02: ok
+ testModPow(); //# 03: ok
+ testModInverse(); //# 04: ok
+ testGcd(); //# 05: ok
+ testSmiOverflow(); //# 06: ok
+ testBigintAnd(); //# 07: ok
+ testBigintOr(); //# 08: ok
+ testBigintXor(); //# 09: ok
+ testBigintAdd(); //# 10: ok
+ testBigintSub(); //# 11: ok
+ testBigintMul(); //# 12: ok
+ testBigintTruncDiv(); //# 12: ok
+ testBigintDiv(); //# 13: ok
+ testBigintModulo(); //# 14: ok
+ testBigintModPow(); //# 15: ok
+ testBigintModInverse(); //# 16: ok
+ testBigintGcd(); //# 17: ok
+ testBigintNegate(); //# 18: ok
+ testShiftAmount(); //# 19: ok
+ testPow(); //# 20: ok
+ testToRadixString(); //# 21: ok
+ testToString(); //# 22: ok
+ testFromToInt(); //# 23: ok
+ testFromToDouble(); //# 24: ok
+ Expect.equals(BigInt.parse("12345678901234567890"), //# 25: ok
+ BigInt.parse("12345678901234567890").abs()); //# 25: ok
+ Expect.equals(BigInt.parse("12345678901234567890"), //# 26: ok
+ BigInt.parse("-12345678901234567890").abs()); //# 26: ok
+ var a = BigInt.parse("10000000000000000000"); //# 27: ok
+ var b = BigInt.parse("10000000000000000001"); //# 27: ok
+ Expect.equals(false, a.hashCode == b.hashCode); //# 27: ok
+ Expect.equals(true, a.hashCode == (b - BigInt.one).hashCode); //# 27: ok
+
+ // Regression test for http://dartbug.com/36105
+ var overbig = -BigInt.from(10).pow(309);
+ Expect.equals(overbig.toDouble(), double.negativeInfinity);
+ }
+}
diff --git a/tests/corelib/bit_twiddling_test.dart b/tests/corelib/bit_twiddling_test.dart
new file mode 100644
index 0000000..fab41d9
--- /dev/null
+++ b/tests/corelib/bit_twiddling_test.dart
@@ -0,0 +1,184 @@
+// Copyright (c) 2013, 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.
+// Testing int.bitLength, int.toUnsigned and int.toSigned.
+
+library bit_twiddling_test;
+
+import "package:expect/expect.dart";
+
+testBitLength() {
+ check(int i, width) {
+ Expect.equals(width, i.bitLength, '$i.bitLength == $width');
+ // (~i) written as (-i-1) to avoid issues with limited range of dart2js ops.
+ Expect.equals(width, (-i - 1).bitLength, '(~$i).bitLength == $width');
+ }
+
+ check(0, 0);
+ check(1, 1);
+ check(2, 2);
+ check(3, 2);
+ check(4, 3);
+ check(5, 3);
+ check(6, 3);
+ check(7, 3);
+ check(8, 4);
+ check(127, 7);
+ check(128, 8);
+ check(129, 8);
+ check(2147483646, 31);
+ check(2147483647, 31);
+ check(2147483648, 32);
+ check(2147483649, 32);
+ check(4294967295, 32);
+ check(4294967296, 33);
+ check(0xffffffffff, 40);
+ check(0xfffffffffff, 44);
+ check(0xffffffffffff, 48);
+ check(0x1000000000000, 49);
+ check(0x1000000000001, 49);
+ check(0x1ffffffffffff, 49);
+ check(0x2000000000000, 50);
+ check(0x2000000000001, 50);
+
+ check(0xffffffffffffff, 56); // //# int64: ok
+ check(0x7fffffffffffffff, 63); // //# int64: continued
+ check(0xffffffffffffffff, 0); // //# int64: continued
+}
+
+testToUnsigned() {
+ checkU(src, width, expected) {
+ Expect.equals(expected, src.toUnsigned(width));
+ }
+
+ checkU(1, 8, 1);
+ checkU(0xff, 8, 0xff);
+ checkU(0xffff, 8, 0xff);
+ checkU(-1, 8, 0xff);
+ checkU(0xffffffff, 32, 0xffffffff);
+
+ checkU(0x7fffffff, 30, 0x3fffffff);
+ checkU(0x7fffffff, 31, 0x7fffffff);
+ checkU(0x7fffffff, 32, 0x7fffffff);
+ checkU(0x80000000, 30, 0);
+ checkU(0x80000000, 31, 0);
+ checkU(0x80000000, 32, 0x80000000);
+ checkU(0xffffffff, 30, 0x3fffffff);
+ checkU(0xffffffff, 31, 0x7fffffff);
+ checkU(0xffffffff, 32, 0xffffffff);
+ checkU(0x100000000, 30, 0);
+ checkU(0x100000000, 31, 0);
+ checkU(0x100000000, 32, 0);
+ checkU(0x1ffffffff, 30, 0x3fffffff);
+ checkU(0x1ffffffff, 31, 0x7fffffff);
+ checkU(0x1ffffffff, 32, 0xffffffff);
+
+ checkU(-1, 0, 0);
+ checkU(0, 0, 0);
+ checkU(1, 0, 0);
+ checkU(2, 0, 0);
+ checkU(3, 0, 0);
+
+ checkU(-1, 1, 1);
+ checkU(0, 1, 0);
+ checkU(1, 1, 1);
+ checkU(2, 1, 0);
+ checkU(3, 1, 1);
+ checkU(4, 1, 0);
+
+ checkU(-1, 2, 3);
+ checkU(0, 2, 0);
+ checkU(1, 2, 1);
+ checkU(2, 2, 2);
+ checkU(3, 2, 3);
+ checkU(4, 2, 0);
+
+ checkU(-1, 3, 7);
+ checkU(0, 3, 0);
+ checkU(1, 3, 1);
+ checkU(2, 3, 2);
+ checkU(3, 3, 3);
+ checkU(4, 3, 4);
+
+ checkU(0x0100000000000001, 2, 1); // //# int64: continued
+ checkU(0x0200000000000001, 60, 0x200000000000001); // //# int64: continued
+ checkU(0x0200000000000001, 59, 0x200000000000001); // //# int64: continued
+ checkU(0x0200000000000001, 58, 0x200000000000001); // //# int64: continued
+ checkU(0x0200000000000001, 57, 1); // //# int64: continued
+
+ checkU(0x8100000000000001, 2, 1); // //# int64: continued
+ checkU(0x8200000000000001, 60, 0x200000000000001); // //# int64: continued
+ checkU(0x8200000000000001, 59, 0x200000000000001); // //# int64: continued
+ checkU(0x8200000000000001, 58, 0x200000000000001); // //# int64: continued
+ checkU(0x8200000000000001, 57, 1); // //# int64: continued
+}
+
+testToSigned() {
+ checkS(src, width, expected) {
+ Expect.equals(
+ expected, src.toSigned(width), '$src.toSigned($width) == $expected');
+ }
+
+ checkS(1, 8, 1);
+ checkS(0xff, 8, -1);
+ checkS(0xffff, 8, -1);
+ checkS(-1, 8, -1);
+ checkS(128, 8, -128);
+ checkS(0xffffffff, 32, -1);
+
+ checkS(0x7fffffff, 30, -1);
+ checkS(0x7fffffff, 31, -1);
+ checkS(0x7fffffff, 32, 0x7fffffff);
+ checkS(0x80000000, 30, 0);
+ checkS(0x80000000, 31, 0);
+ checkS(0x80000000, 32, -2147483648);
+ checkS(0xffffffff, 30, -1);
+ checkS(0xffffffff, 31, -1);
+ checkS(0xffffffff, 32, -1);
+
+ checkS(0x100000000, 30, 0);
+ checkS(0x100000000, 31, 0);
+ checkS(0x100000000, 32, 0);
+ checkS(0x1ffffffff, 30, -1);
+ checkS(0x1ffffffff, 31, -1);
+ checkS(0x1ffffffff, 32, -1);
+
+ checkS(-1, 1, -1);
+ checkS(0, 1, 0);
+ checkS(1, 1, -1); // The only bit is the sign bit.
+ checkS(2, 1, 0);
+ checkS(3, 1, -1);
+ checkS(4, 1, 0);
+
+ checkS(-1, 2, -1);
+ checkS(0, 2, 0);
+ checkS(1, 2, 1);
+ checkS(2, 2, -2);
+ checkS(3, 2, -1);
+ checkS(4, 2, 0);
+
+ checkS(-1, 3, -1);
+ checkS(0, 3, 0);
+ checkS(1, 3, 1);
+ checkS(2, 3, 2);
+ checkS(3, 3, 3);
+ checkS(4, 3, -4);
+
+ checkS(0x0100000000000001, 2, 1); // //# int64: continued
+ checkS(0x0200000000000001, 60, 0x200000000000001); // //# int64: continued
+ checkS(0x0200000000000001, 59, 0x200000000000001); // //# int64: continued
+ checkS(0x0200000000000001, 58, -0x200000000000000 + 1); // //# int64: continued
+ checkS(0x0200000000000001, 57, 1); // //# int64: continued
+
+ checkS(0x8100000000000001, 2, 1); // //# int64: continued
+ checkS(0x8200000000000001, 60, 0x200000000000001); // //# int64: continued
+ checkS(0x8200000000000001, 59, 0x200000000000001); // //# int64: continued
+ checkS(0x8200000000000001, 58, -0x200000000000000 + 1); // //# int64: continued
+ checkS(0x8200000000000001, 57, 1); // //# int64: continued
+}
+
+main() {
+ testBitLength();
+ testToUnsigned();
+ testToSigned();
+}
diff --git a/tests/corelib/bool_from_environment2_test.dart b/tests/corelib/bool_from_environment2_test.dart
new file mode 100644
index 0000000..0329c54
--- /dev/null
+++ b/tests/corelib/bool_from_environment2_test.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2013, 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.
+
+main() {
+ const bool.fromEnvironment('NOT_FOUND', defaultValue: ''); // //# 01: compile-time error
+ const bool.fromEnvironment('NOT_FOUND', defaultValue: 1); // //# 02: compile-time error
+ const bool.fromEnvironment(null); // //# 03: compile-time error
+ const bool.fromEnvironment(1); // //# 04: compile-time error
+ const bool.fromEnvironment([]); // //# 05: compile-time error
+}
diff --git a/tests/corelib/bool_from_environment_test.dart b/tests/corelib/bool_from_environment_test.dart
new file mode 100644
index 0000000..5d01bde
--- /dev/null
+++ b/tests/corelib/bool_from_environment_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2013, 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.
+// SharedOptions=-Da=true -Db=false -Dc=NOTBOOL -Dd=True
+
+import "package:expect/expect.dart";
+
+main() {
+ Expect.isTrue(const bool.fromEnvironment('a'));
+ Expect.isFalse(const bool.fromEnvironment('b'));
+ Expect.isTrue(const bool.fromEnvironment('c', defaultValue: true));
+ Expect.isFalse(const bool.fromEnvironment('c', defaultValue: false));
+ Expect.isFalse(const bool.fromEnvironment('d', defaultValue: false));
+ Expect.equals(const bool.fromEnvironment('dart.isVM'), !identical(1.0, 1));
+}
diff --git a/tests/corelib/bool_hashcode_test.dart b/tests/corelib/bool_hashcode_test.dart
new file mode 100644
index 0000000..d33b14a
--- /dev/null
+++ b/tests/corelib/bool_hashcode_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+class BoolHashCodeTest {
+ static testMain() {
+ Expect.notEquals(true.hashCode, false.hashCode);
+ }
+}
+
+main() {
+ BoolHashCodeTest.testMain();
+}
diff --git a/tests/corelib/bool_operator_test.dart b/tests/corelib/bool_operator_test.dart
new file mode 100644
index 0000000..3d5e3de
--- /dev/null
+++ b/tests/corelib/bool_operator_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ void test(bool b1, bool b2) {
+ var and1 = b1 && b2;
+ var and2 = b1 & b2;
+ var and3 = b1 ? b2 ? true : false : false;
+ var or1 = b1 || b2;
+ var or2 = b1 | b2;
+ var or3 = b1 ? true : b2 ? true : false;
+ var xor1 = b1 != b2;
+ var xor2 = b1 ^ b2;
+ var xor3 = b1 ? b2 ? false : true : b2 ? true : false;
+ var nb1 = !b1;
+ var nb2 = !b2;
+ Expect.equals(and3, and1);
+ Expect.equals(and3, and2);
+ Expect.equals(or3, or1);
+ Expect.equals(or3, or2);
+ Expect.equals(xor3, xor1);
+ Expect.equals(xor3, xor2);
+ Expect.notEquals(nb1, b1);
+ Expect.notEquals(nb2, b2);
+ }
+
+ test(true, false);
+ test(true, true);
+ test(false, true);
+ test(false, false);
+
+ Expect.isTrue(true || (throw "unreachable"));
+ Expect.throws(() => false || (throw "unreachable"));
+
+ Expect.isFalse(false && (throw "unreachable"));
+ Expect.throws(() => true && (throw "unreachable"));
+
+ Expect.throws(() => true | (throw "unreachable"));
+ Expect.throws(() => false | (throw "unreachable"));
+
+ Expect.throws(() => true & (throw "unreachable"));
+ Expect.throws(() => false & (throw "unreachable"));
+}
diff --git a/tests/corelib/cast_test.dart b/tests/corelib/cast_test.dart
new file mode 100644
index 0000000..7f17351
--- /dev/null
+++ b/tests/corelib/cast_test.dart
@@ -0,0 +1,189 @@
+// Copyright (c) 2011, 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.
+
+import "dart:collection";
+import "dart:typed_data";
+import "package:expect/expect.dart";
+
+// TODO(rnystrom): Not migrated to NNBD yet.
+// See https://github.com/dart-lang/sdk/issues/39517.
+
+void main() {
+ testIterable();
+ testList();
+}
+
+final elements = <C>[c, d, e, f, null];
+
+void testIterable() {
+ var iterable = new Iterable<C>.generate(elements.length, (n) => elements[n]);
+ // Down-cast
+ {
+ // An iterable that (likely) can do direct access.
+ var dIterable = Iterable.castFrom<C, D>(iterable);
+
+ Expect.throws(() => dIterable.first, null, "1.first");
+ Expect.equals(d, dIterable.elementAt(1));
+ Expect.throws(() => dIterable.elementAt(2), null, "1.2"); // E is not D.
+ Expect.equals(f, dIterable.skip(3).first); // Skip does not access element.
+ Expect.equals(null, dIterable.skip(3).elementAt(1));
+
+ Expect.throws(() => dIterable.toList(), null, "1.toList");
+ }
+
+ {
+ // An iterable that cannot do direct access.
+ var dIterable2 = Iterable.castFrom<C, D>(iterable.where((_) => true));
+
+ Expect.throws(() => dIterable2.first, null, "2.first");
+ Expect.equals(d, dIterable2.elementAt(1));
+ Expect.throws(() => dIterable2.elementAt(2), null, "2.2"); // E is not D.
+ Expect.equals(f, dIterable2.skip(3).first); // Skip does not access element.
+ Expect.equals(null, dIterable2.skip(3).elementAt(1));
+
+ Expect.throws(() => dIterable2.toList(), null, "2.toList");
+ }
+
+ {
+ // Iterable that definitely won't survive accessing element 2.
+ var iterable3 = new Iterable<C>.generate(
+ elements.length, (n) => n == 3 ? throw "untouchable" : elements[n]);
+ var dIterable3 = Iterable.castFrom<C, D>(iterable3);
+
+ Expect.throws(() => dIterable3.first, null, "3.first");
+ Expect.equals(d, dIterable3.elementAt(1));
+ Expect.throws(() => dIterable3.elementAt(3), null, "3.3");
+ // Skip does not access element.
+ Expect.equals(null, dIterable3.skip(4).first);
+ Expect.equals(null, dIterable3.skip(3).elementAt(1));
+
+ Expect.throws(() => dIterable3.toList(), null, "3.toList");
+ }
+
+ // Up-cast.
+ {
+ var oIterable4 = Iterable.castFrom<C, Object>(iterable);
+ Expect.listEquals(elements, oIterable4.toList());
+ }
+}
+
+void testList() {
+ // Down-cast.
+ var list = new List<C>.from(elements);
+ var dList = List.castFrom<C, D>(list);
+
+ Expect.throws(() => dList.first); // C is not D.
+ Expect.equals(d, dList[1]);
+ Expect.throws(() => dList[2]); // E is not D.
+ Expect.equals(f, dList[3]);
+ Expect.equals(null, dList.last);
+
+ Expect.throws(() => dList.toList());
+
+ dList[2] = d;
+ Expect.equals(d, dList[2]); // Setting works.
+
+ // Up-cast.
+ var list2 = new List<C>.from(elements);
+ var dList2 = List.castFrom<C, Object>(list2);
+ Expect.listEquals(elements, dList2);
+ Expect.throws(() => dList2[2] = new Object()); // Cannot set non-C.
+ Expect.listEquals(elements, dList2);
+
+ // Regression test.
+ var list3 = <num>[4, 3, 2, 1];
+ var dList3 = list3.cast<int>();
+ dList3.sort(null);
+ Expect.listEquals([1, 2, 3, 4], list3);
+}
+
+void testSet() {
+ var set = new Set<C>.from(elements); // Linked HashSet.
+ Expect.listEquals(elements, set.toList()); // Preserves order.
+
+ var dSet = Set.castFrom<C, D>(set);
+
+ // Preserves order.
+ Expect.throws(() => dSet.first); // C is not D.
+ Expect.equals(d, dSet.elementAt(1));
+ Expect.throws(() => dSet.elementAt(2)); // E is not D.
+
+ Expect.throws(() => dSet.toList());
+
+ // Contains is not typed.
+ var newC = new C();
+ Expect.isFalse(dSet.contains(newC));
+ dSet.add(newC);
+ Expect.isTrue(dSet.contains(newC));
+
+ Expect.equals(5, dSet.length);
+ dSet.remove(newC);
+ Expect.equals(5, dSet.length);
+ dSet.remove(c); // Success, no type checks.
+ Expect.equals(4, dSet.length);
+
+ // Up-cast
+ var set2 = new Set<C>.from(elements);
+ var dSet2 = Set.castFrom<C, Object>(set2);
+
+ var newObject = new Object();
+ Expect.throws(() => dSet2.add(newObject));
+ Expect.isFalse(dSet.contains(newObject));
+
+ var toSet2 = dSet2.toSet();
+ Expect.isTrue(toSet2 is LinkedHashSet<Object>);
+ Expect.isTrue(toSet2 is! LinkedHashSet<C>);
+
+ // Custom emptySet.
+
+ var set3 = new Set<C>.from(elements);
+ var dSet3 = Set.castFrom<C, Object>(set3, newSet: <T>() => new HashSet<T>());
+
+ var toSet3 = dSet3.toSet();
+ Expect.isTrue(toSet3 is HashSet<Object>);
+ Expect.isTrue(toSet3 is HashSet<C>);
+ Expect.isTrue(toSet3 is! LinkedHashSet<Object>);
+}
+
+void testMap() {
+ var map = new Map.fromIterables(elements, elements);
+
+ var dMap = Map.castFrom<C, C, D, D>(map);
+
+ Expect.isTrue(dMap is Map<D, D>);
+
+ Expect.equals(null, dMap[new C()]);
+ Expect.throws(() => dMap[c]);
+ Expect.isTrue(dMap.containsKey(c));
+ Expect.equals(d, dMap[d]);
+ Expect.throws(() => dMap[e]);
+ Expect.equals(null, dMap[null]);
+
+ Expect.equals(5, dMap.length);
+ dMap.remove(c); // Success, no type checks along the way.
+ Expect.equals(4, dMap.length);
+ Expect.equals(null, dMap[c]);
+
+ Expect.throws(() => dMap[c] = d);
+ Expect.throws(() => dMap[d] = c);
+ Expect.equals(4, dMap.length);
+
+ Expect.isTrue(dMap.keys is Iterable<D>);
+ Expect.isTrue(dMap.values is Iterable<D>);
+ Expect.throws(() => dMap.keys.toList());
+ Expect.throws(() => dMap.values.toList());
+}
+
+class C {}
+
+class D extends C {}
+
+class E extends C {}
+
+class F implements D, E {}
+
+final c = new C();
+final d = new D();
+final e = new E();
+final f = new F();
diff --git a/tests/corelib/collection_from_test.dart b/tests/corelib/collection_from_test.dart
new file mode 100644
index 0000000..bc7dc7a
--- /dev/null
+++ b/tests/corelib/collection_from_test.dart
@@ -0,0 +1,93 @@
+// Copyright (c) 2011, 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.
+
+library collection.from.test;
+
+import "package:expect/expect.dart";
+import 'dart:collection';
+
+main() {
+ for (Iterable<num> elements in [
+ new Set<num>(),
+ <num>[],
+ const <num>[],
+ const <num, int>{}.keys,
+ const <int, num>{}.values,
+ new Iterable<num>.generate(0),
+ new Set<num>()..add(1)..add(2)..add(4),
+ <num>[1, 2, 4],
+ new Iterable<num>.generate(3, (i) => [1, 2, 4][i]),
+ const <num>[1, 2, 4],
+ const <num, int>{1: 0, 2: 0, 4: 0}.keys,
+ const <int, num>{1: 1, 2: 2, 4: 4}.values,
+ ]) {
+ int elementCount = elements.length;
+ check(elements, new List<num>.from(elements));
+ check(elements, new List<int>.from(elements));
+ check(elements, new List<Object>.from(elements));
+ check(elements, new List<num>.from(elements, growable: true));
+ check(elements, new List<int>.from(elements, growable: true));
+ check(elements, new List<Object>.from(elements, growable: true));
+ check(elements, new List<num>.from(elements, growable: false));
+ check(elements, new List<int>.from(elements, growable: false));
+ check(elements, new List<Object>.from(elements, growable: false));
+ check(elements, new Queue<num>.from(elements));
+ check(elements, new Queue<int>.from(elements));
+ check(elements, new Queue<Object>.from(elements));
+ check(elements, new ListQueue<num>.from(elements));
+ check(elements, new ListQueue<int>.from(elements));
+ check(elements, new ListQueue<Object>.from(elements));
+ check(elements, new DoubleLinkedQueue<num>.from(elements));
+ check(elements, new DoubleLinkedQueue<int>.from(elements));
+ check(elements, new DoubleLinkedQueue<Object>.from(elements));
+ check(elements, new Set<num>.from(elements));
+ check(elements, new Set<int>.from(elements));
+ check(elements, new Set<Object>.from(elements));
+ check(elements, new HashSet<num>.from(elements));
+ check(elements, new HashSet<int>.from(elements));
+ check(elements, new HashSet<Object>.from(elements));
+ check(elements, new LinkedHashSet<num>.from(elements));
+ check(elements, new LinkedHashSet<int>.from(elements));
+ check(elements, new LinkedHashSet<Object>.from(elements));
+ check(elements, new SplayTreeSet<num>.from(elements));
+ check(elements, new SplayTreeSet<int>.from(elements));
+ check(elements, new SplayTreeSet<Object>.from(elements));
+ // Sanity check that elements didn't change.
+ Expect.equals(elementCount, elements.length);
+
+ // Lists may be growable or not growable.
+ {
+ var list = new List<num>.from(elements, growable: true);
+ Expect.equals(elementCount, list.length);
+ list.add(42);
+ Expect.equals(elementCount + 1, list.length);
+ }
+ {
+ var list = new List<num>.from(elements);
+ Expect.equals(elementCount, list.length);
+ list.add(42);
+ Expect.equals(elementCount + 1, list.length);
+ }
+ {
+ var list = new List<num>.from(elements, growable: false);
+ Expect.equals(elementCount, list.length);
+ Expect.throwsUnsupportedError(() {
+ list.add(42);
+ });
+ Expect.equals(elementCount, list.length);
+ }
+ }
+}
+
+void check(Iterable<num> initial, Iterable other) {
+ Expect.equals(initial.length, other.length);
+
+ for (var element in other) {
+ initial.contains(element);
+ }
+
+ for (var element in initial) {
+ other.contains(element);
+ }
+}
diff --git a/tests/corelib/collection_length_test.dart b/tests/corelib/collection_length_test.dart
new file mode 100644
index 0000000..27dae6e
--- /dev/null
+++ b/tests/corelib/collection_length_test.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2013, 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.
+
+library map_test;
+
+import 'dart:collection';
+
+// Test that length/isEmpty opertions are constant time on
+// maps, strings and collections.
+
+void testString(int n) {
+ String s = "x";
+ String string = "";
+ int length = n;
+ while (true) {
+ if ((length & 1) == 1) {
+ string += s;
+ }
+ length >>= 1;
+ if (length == 0) break;
+ s += s;
+ }
+ testLength(string, n);
+ testLength(string.codeUnits, n);
+}
+
+void testMap(Map map, int n) {
+ for (int i = 0; i < n; i++) {
+ map[i] = i;
+ }
+ testLength(map, n);
+ testLength(map.keys, n);
+ testLength(map.values, n);
+}
+
+void testCollection(var collection, n) {
+ for (int i = 0; i < n; i++) {
+ collection.add(i);
+ }
+ testLength(collection, n);
+}
+
+void testList(List list, n) {
+ // Works even if list is fixed-length.
+ for (int i = 0; i < n; i++) {
+ list[i] = i;
+ }
+ testLength(list, n);
+}
+
+void testLength(dynamic lengthable, int size) {
+ print(lengthable.runtimeType); // Show what hangs the test.
+ int length = 0;
+ // If length, isEmpty or isNotEmpty is not a constant-time (or very fast)
+ // operation, this will timeout.
+ for (int i = 0; i < 100000; i++) {
+ if (!lengthable.isEmpty) length += lengthable.length as int;
+ if (lengthable.isNotEmpty) length += lengthable.length as int;
+ }
+ if (length != size * 200000) throw "Bad length: $length / size: $size";
+}
+
+main() {
+ const int N = 100000;
+ testMap(new HashMap(), N);
+ testMap(new LinkedHashMap(), N);
+ testMap(new SplayTreeMap(), N);
+ testCollection(new HashSet(), N);
+ testCollection(new LinkedHashSet(), N);
+ testCollection(new ListQueue(), N);
+ testCollection(new DoubleLinkedQueue(), N);
+ testList(new List()..length = N, N);
+ testList(new List(N), N);
+ testString(N);
+}
diff --git a/tests/corelib/collection_of_test.dart b/tests/corelib/collection_of_test.dart
new file mode 100644
index 0000000..03cabed
--- /dev/null
+++ b/tests/corelib/collection_of_test.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2018, 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.
+
+library collection.from.test;
+
+import "package:expect/expect.dart";
+import 'dart:collection';
+
+main() {
+ for (Iterable<num> elements in [
+ new Set<num>(),
+ <num>[],
+ const <num>[],
+ const <num, int>{}.keys,
+ const <int, num>{}.values,
+ new Iterable<num>.generate(0),
+ new Set<num>()..add(1)..add(2)..add(4),
+ <num>[1, 2, 4],
+ new Iterable<num>.generate(3, (i) => [1, 2, 4][i]),
+ const <num>[1, 2, 4],
+ const <num, int>{1: 0, 2: 0, 4: 0}.keys,
+ const <int, num>{1: 1, 2: 2, 4: 4}.values,
+ ]) {
+ String sourceType = elements.runtimeType.toString();
+ check(sourceType, elements, new List<num>.of(elements));
+ check(sourceType, elements, new List<Object>.of(elements));
+ check(sourceType, elements, new Queue<num>.of(elements));
+ check(sourceType, elements, new Queue<Object>.of(elements));
+ check(sourceType, elements, new ListQueue<num>.of(elements));
+ check(sourceType, elements, new ListQueue<Object>.of(elements));
+ check(sourceType, elements, new DoubleLinkedQueue<num>.of(elements));
+ check(sourceType, elements, new DoubleLinkedQueue<Object>.of(elements));
+ check(sourceType, elements, new Set<num>.of(elements));
+ check(sourceType, elements, new Set<Object>.of(elements));
+ check(sourceType, elements, new HashSet<num>.of(elements));
+ check(sourceType, elements, new HashSet<Object>.of(elements));
+ check(sourceType, elements, new LinkedHashSet<num>.of(elements));
+ check(sourceType, elements, new LinkedHashSet<Object>.of(elements));
+ check(sourceType, elements, new SplayTreeSet<num>.of(elements));
+ check(sourceType, elements, new SplayTreeSet<Object>.of(elements));
+
+ // Inference applies to the `of` constructor, unlike the `from` constructor.
+ Expect.isTrue(new List.of(elements) is Iterable<num>);
+ Expect.isTrue(new Queue.of(elements) is Iterable<num>);
+ Expect.isTrue(new ListQueue.of(elements) is Iterable<num>);
+ Expect.isTrue(new DoubleLinkedQueue.of(elements) is Iterable<num>);
+ Expect.isTrue(new Set.of(elements) is Iterable<num>);
+ Expect.isTrue(new HashSet.of(elements) is Iterable<num>);
+ Expect.isTrue(new LinkedHashSet.of(elements) is Iterable<num>);
+ Expect.isTrue(new SplayTreeSet.of(elements) is Iterable<num>);
+
+ Expect.isTrue(new List.of(elements) is! Iterable<int>);
+ Expect.isTrue(new Queue.of(elements) is! Iterable<int>);
+ Expect.isTrue(new ListQueue.of(elements) is! Iterable<int>);
+ Expect.isTrue(new DoubleLinkedQueue.of(elements) is! Iterable<int>);
+ Expect.isTrue(new Set.of(elements) is! Iterable<int>);
+ Expect.isTrue(new HashSet.of(elements) is! Iterable<int>);
+ Expect.isTrue(new LinkedHashSet.of(elements) is! Iterable<int>);
+ Expect.isTrue(new SplayTreeSet.of(elements) is! Iterable<int>);
+ }
+}
+
+void check(String sourceType, Iterable<num> source, Iterable target) {
+ String targetType = target.runtimeType.toString();
+ String name = "$sourceType->$targetType";
+ Expect.equals(source.length, target.length, "$name.length");
+
+ for (var element in target) {
+ Expect.isTrue(source.contains(element), "$name:$element in source");
+ }
+
+ for (var element in source) {
+ Expect.isTrue(target.contains(element), "$name:$element in target");
+ }
+}
diff --git a/tests/corelib/collection_removes_test.dart b/tests/corelib/collection_removes_test.dart
new file mode 100644
index 0000000..793696d
--- /dev/null
+++ b/tests/corelib/collection_removes_test.dart
@@ -0,0 +1,130 @@
+// Copyright (c) 2011, 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.
+
+import 'dart:collection';
+import "package:expect/expect.dart";
+
+testRemove(base) {
+ int length = base.length;
+ for (int i = 0; i < length; i++) {
+ Expect.isFalse(base.isEmpty);
+ base.remove(base.first);
+ }
+ Expect.isTrue(base.isEmpty);
+}
+
+testRemoveAll(base, Iterable removes) {
+ Set retained = new Set();
+ for (var element in base) {
+ if (!removes.contains(element)) {
+ retained.add(element);
+ }
+ }
+ String name = "$base.removeAll($removes) -> $retained";
+ base.removeAll(removes);
+ for (var value in base) {
+ Expect.isFalse(removes.contains(value), "$name: Found $value");
+ }
+ for (var value in retained) {
+ Expect.isTrue(base.contains(value), "$name: Found $value");
+ }
+}
+
+testRetainAll(base, Iterable retains) {
+ Set retained = new Set();
+ for (var element in base) {
+ if (retains.contains(element)) {
+ retained.add(element);
+ }
+ }
+ String name = "$base.retainAll($retains) -> $retained";
+ base.retainAll(retains);
+ for (var value in base) {
+ Expect.isTrue(retains.contains(value), "$name: Found $value");
+ }
+ for (var value in retained) {
+ Expect.isTrue(base.contains(value), "$name: Found $value");
+ }
+}
+
+testRemoveWhere(base, bool test(value)) {
+ Set retained = new Set();
+ for (var element in base) {
+ if (!test(element)) {
+ retained.add(element);
+ }
+ }
+ String name = "$base.removeWhere(...) -> $retained";
+ base.removeWhere(test);
+ for (var value in base) {
+ Expect.isFalse(test(value), "$name: Found $value");
+ }
+ for (var value in retained) {
+ Expect.isTrue(base.contains(value), "$name: Found $value");
+ }
+}
+
+testRetainWhere(base, bool test(value)) {
+ Set retained = new Set();
+ for (var element in base) {
+ if (test(element)) {
+ retained.add(element);
+ }
+ }
+ String name = "$base.retainWhere(...) -> $retained";
+ base.retainWhere(test);
+ for (var value in base) {
+ Expect.isTrue(test(value), "$name: Found $value");
+ }
+ for (var value in retained) {
+ Expect.isTrue(base.contains(value), "$name: Found $value");
+ }
+}
+
+void main() {
+ var collections = [
+ [],
+ [1],
+ [2],
+ [1, 2],
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
+ [1, 3, 5, 7, 9],
+ [2, 4, 6, 8, 10]
+ ];
+ for (var base in collections) {
+ for (var delta in collections) {
+ testRemove(base.toList());
+ testRemove(base.toSet());
+
+ var deltaSet = delta.toSet();
+ testRemoveWhere(base.toList(), deltaSet.contains);
+ testRetainWhere(base.toList(), (e) => !deltaSet.contains(e));
+
+ testRemoveAll(base.toSet(), delta);
+ testRemoveAll(base.toSet(), deltaSet);
+ testRetainAll(base.toSet(), delta);
+ testRetainAll(base.toSet(), deltaSet);
+ testRemoveWhere(base.toSet(), deltaSet.contains);
+ testRetainWhere(base.toSet(), (e) => !deltaSet.contains(e));
+
+ // Test the ListBase class's List implementation.
+ testRemoveWhere(new MyList(base.toList()), deltaSet.contains);
+ testRetainWhere(new MyList(base.toList()), (e) => !deltaSet.contains(e));
+ }
+ }
+}
+
+class MyList<E> extends ListBase<E> {
+ List<E> _source;
+ MyList(this._source);
+ int get length => _source.length;
+ void set length(int length) {
+ _source.length = length;
+ }
+
+ E operator [](int index) => _source[index];
+ void operator []=(int index, E value) {
+ _source[index] = value;
+ }
+}
diff --git a/tests/corelib/collection_test.dart b/tests/corelib/collection_test.dart
new file mode 100644
index 0000000..74d9c30
--- /dev/null
+++ b/tests/corelib/collection_test.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2011, 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.
+
+library collection_test;
+
+import "package:expect/expect.dart";
+import 'dart:collection' show Queue;
+
+class CollectionTest {
+ CollectionTest(Iterable<int> iterable) {
+ testFold(iterable);
+ }
+
+ void testFold(Iterable<int> iterable) {
+ Expect.equals(
+ 28, iterable.fold<int>(0, (prev, element) => prev + element));
+ Expect.equals(
+ 3024, iterable.fold<int>(1, (prev, element) => prev * element));
+ }
+}
+
+main() {
+ final TEST_ELEMENTS = const [4, 2, 6, 7, 9];
+ // Const list.
+ new CollectionTest(TEST_ELEMENTS);
+
+ // Fixed size list.
+ var fixedList = new List<int>.of(TEST_ELEMENTS, growable: false);
+ new CollectionTest(fixedList);
+
+ // Growable list.
+ new CollectionTest(new List.from(TEST_ELEMENTS));
+
+ // Set.
+ new CollectionTest(new Set.from(TEST_ELEMENTS));
+
+ // Queue.
+ new CollectionTest(new Queue.from(TEST_ELEMENTS));
+}
diff --git a/tests/corelib/collection_to_string_test.dart b/tests/corelib/collection_to_string_test.dart
new file mode 100644
index 0000000..29ab226
--- /dev/null
+++ b/tests/corelib/collection_to_string_test.dart
@@ -0,0 +1,386 @@
+// Copyright (c) 2012, 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.
+
+/**
+ * Tests for the toString methods on collections and maps.
+ */
+
+library collection_to_string;
+
+import "package:expect/expect.dart";
+import 'dart:collection' show Queue, LinkedHashMap;
+import 'dart:math' as Math;
+
+// TODO(jjb): seed random number generator when API allows it
+
+const int NUM_TESTS = 300;
+const int MAX_COLLECTION_SIZE = 7;
+
+final rand = Math.Random();
+
+main() {
+ smokeTest();
+ exactTest();
+ inexactTest();
+}
+
+/**
+ * Test a few simple examples.
+ */
+void smokeTest() {
+ // Non-const lists
+ Expect.equals([].toString(), '[]');
+ Expect.equals([1].toString(), '[1]');
+ Expect.equals(['Elvis'].toString(), '[Elvis]');
+ Expect.equals([null].toString(), '[null]');
+ Expect.equals([1, 2].toString(), '[1, 2]');
+ Expect.equals(['I', 'II'].toString(), '[I, II]');
+ Expect.equals(
+ [
+ [1, 2],
+ [3, 4],
+ [5, 6]
+ ].toString(),
+ '[[1, 2], [3, 4], [5, 6]]');
+
+ // Const lists
+ Expect.equals((const []).toString(), '[]');
+ Expect.equals((const [1]).toString(), '[1]');
+ Expect.equals((const ['Elvis']).toString(), '[Elvis]');
+ Expect.equals((const [null]).toString(), '[null]');
+ Expect.equals((const [1, 2]).toString(), '[1, 2]');
+ Expect.equals((const ['I', 'II']).toString(), '[I, II]');
+ Expect.equals(
+ (const [
+ const [1, 2],
+ const [3, 4],
+ const [5, 6]
+ ])
+ .toString(),
+ '[[1, 2], [3, 4], [5, 6]]');
+
+ // Non-const maps - Note that all keys are strings; the spec currently demands this
+ Expect.equals({}.toString(), '{}');
+ Expect.equals({'Elvis': 'King'}.toString(), '{Elvis: King}');
+ Expect.equals({'Elvis': null}.toString(), '{Elvis: null}');
+ Expect.equals({'I': 1, 'II': 2}.toString(), '{I: 1, II: 2}');
+ Expect.equals(
+ {
+ 'X': {'I': 1, 'II': 2},
+ 'Y': {'III': 3, 'IV': 4},
+ 'Z': {'V': 5, 'VI': 6}
+ }.toString(),
+ '{X: {I: 1, II: 2}, Y: {III: 3, IV: 4}, Z: {V: 5, VI: 6}}');
+
+ // Const maps
+ Expect.equals(const {}.toString(), '{}');
+ Expect.equals(const {'Elvis': 'King'}.toString(), '{Elvis: King}');
+ Expect.equals({'Elvis': null}.toString(), '{Elvis: null}');
+ Expect.equals(const {'I': 1, 'II': 2}.toString(), '{I: 1, II: 2}');
+ Expect.equals(
+ const {
+ 'X': const {'I': 1, 'II': 2},
+ 'Y': const {'III': 3, 'IV': 4},
+ 'Z': const {'V': 5, 'VI': 6}
+ }.toString(),
+ '{X: {I: 1, II: 2}, Y: {III: 3, IV: 4}, Z: {V: 5, VI: 6}}');
+}
+
+// SERIOUS "BASHER" TESTS
+
+/**
+ * Generate a bunch of random collections (including Maps), and test that
+ * there string form is as expected. The collections include collections
+ * as elements, keys, and values, and include recursive references.
+ *
+ * This test restricts itself to collections with well-defined iteration
+ * orders (i.e., no HashSet, HashMap).
+ */
+void exactTest() {
+ for (int i = 0; i < NUM_TESTS; i++) {
+ // Choose a size from 0 to MAX_COLLECTION_SIZE, favoring larger sizes
+ int size =
+ Math.sqrt(random(MAX_COLLECTION_SIZE * MAX_COLLECTION_SIZE)).toInt();
+
+ StringBuffer stringRep = new StringBuffer();
+ Object o = randomCollection(size, stringRep, exact: true);
+ print(stringRep);
+ print(o);
+ Expect.equals(o.toString(), stringRep.toString());
+ }
+}
+
+/**
+ * Generate a bunch of random collections (including Maps), and test that
+ * there string form is as expected. The collections include collections
+ * as elements, keys, and values, and include recursive references.
+ *
+ * This test includes collections with ill-defined iteration orders (i.e.,
+ * HashSet, HashMap). As a consequence, it can't use equality tests on the
+ * string form. Instead, it performs equality tests on their "alphagrams."
+ * This might allow false positives, but it does give a fair amount of
+ * confidence.
+ */
+void inexactTest() {
+ for (int i = 0; i < NUM_TESTS; i++) {
+ // Choose a size from 0 to MAX_COLLECTION_SIZE, favoring larger sizes
+ int size =
+ Math.sqrt(random(MAX_COLLECTION_SIZE * MAX_COLLECTION_SIZE)).toInt();
+
+ StringBuffer stringRep = new StringBuffer();
+ Object o = randomCollection(size, stringRep, exact: false);
+ print(stringRep);
+ print(o);
+ Expect.equals(alphagram(o.toString()), alphagram(stringRep.toString()));
+ }
+}
+
+/**
+ * Return a random collection (or Map) of the specified size, placing its
+ * string representation into the given string buffer.
+ *
+ * If exact is true, the returned collections will not be, and will not contain
+ * a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
+ */
+Object randomCollection(int size, StringBuffer stringRep, {bool exact = false}) {
+ return randomCollectionHelper(size, exact, stringRep, []);
+}
+
+/**
+ * Return a random collection (or map) of the specified size, placing its
+ * string representation into the given string buffer. The beingMade
+ * parameter is a list of collections currently under construction, i.e.,
+ * candidates for recursive references.
+ *
+ * If exact is true, the returned collections will not be, and will not contain
+ * a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
+ */
+Object randomCollectionHelper(
+ int size, bool exact, StringBuffer stringRep, List beingMade) {
+ double interfaceFrac = rand.nextDouble();
+
+ if (exact) {
+ if (interfaceFrac < 1 / 3) {
+ return randomList(size, exact, stringRep, beingMade);
+ } else if (interfaceFrac < 2 / 3) {
+ return randomQueue(size, exact, stringRep, beingMade);
+ } else {
+ return randomMap(size, exact, stringRep, beingMade);
+ }
+ } else {
+ if (interfaceFrac < 1 / 4) {
+ return randomList(size, exact, stringRep, beingMade);
+ } else if (interfaceFrac < 2 / 4) {
+ return randomQueue(size, exact, stringRep, beingMade);
+ } else if (interfaceFrac < 3 / 4) {
+ return randomSet(size, exact, stringRep, beingMade);
+ } else {
+ return randomMap(size, exact, stringRep, beingMade);
+ }
+ }
+}
+
+/**
+ * Return a random List of the specified size, placing its string
+ * representation into the given string buffer. The beingMade
+ * parameter is a list of collections currently under construction, i.e.,
+ * candidates for recursive references.
+ *
+ * If exact is true, the returned collections will not be, and will not contain
+ * a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
+ */
+List randomList(int size, bool exact, StringBuffer stringRep, List beingMade) {
+ return populateRandomCollection(size, exact, stringRep, beingMade, [], "[]");
+}
+
+/**
+ * Like randomList, but returns a queue.
+ */
+Queue randomQueue(
+ int size, bool exact, StringBuffer stringRep, List beingMade) {
+ return populateRandomCollection(
+ size, exact, stringRep, beingMade, new Queue(), "{}");
+}
+
+/**
+ * Like randomList, but returns a Set.
+ */
+Set randomSet(int size, bool exact, StringBuffer stringRep, List beingMade) {
+ // Until we have LinkedHashSet, method will only be called with exact==true
+ return populateRandomSet(size, exact, stringRep, beingMade, new Set());
+}
+
+/**
+ * Like randomList, but returns a map.
+ */
+Map randomMap(int size, bool exact, StringBuffer stringRep, List beingMade) {
+ if (exact) {
+ return populateRandomMap(
+ size, exact, stringRep, beingMade, new LinkedHashMap());
+ } else {
+ return populateRandomMap(size, exact, stringRep, beingMade,
+ randomBool() ? new Map() : new LinkedHashMap());
+ }
+}
+
+/**
+ * Populates the given empty collection with elements, emitting the string
+ * representation of the collection to stringRep. The beingMade parameter is
+ * a list of collections currently under construction, i.e., candidates for
+ * recursive references.
+ *
+ * If exact is true, the elements of the returned collections will not be,
+ * and will not contain a collection with ill-defined iteration order
+ * (i.e., a HashSet or HashMap).
+ */
+populateRandomCollection(int size, bool exact, StringBuffer stringRep,
+ List beingMade, var coll, String delimiters) {
+ beingMade.add(coll);
+ int start = stringRep.length;
+
+ stringRep.write(delimiters[0]);
+
+ List<int> indices = [];
+ for (int i = 0; i < size; i++) {
+ indices.add(stringRep.length);
+ if (i != 0) stringRep.write(', ');
+ coll.add(randomElement(random(size), exact, stringRep, beingMade));
+ }
+ if (size > 5 && delimiters == "()") {
+ const int MAX_LENGTH = 80;
+ const int MIN_COUNT = 3;
+ const int MAX_COUNT = 100;
+ // It's an iterable, it may omit some elements.
+ int end = stringRep.length;
+ if (size > MAX_COUNT) {
+ // Last two elements are also omitted, just find the first three or
+ // first 60 characters.
+ for (int i = MIN_COUNT; i < size; i++) {
+ int startIndex = indices[i];
+ if (startIndex - start > MAX_LENGTH - 6) {
+ // Limit - ", ...)".length.
+ String prefix = stringRep.toString().substring(0, startIndex);
+ stringRep.clear();
+ stringRep.write(prefix);
+ stringRep.write(", ...");
+ }
+ }
+ } else if (stringRep.length - start > MAX_LENGTH - 1) {
+ // 80 - ")".length.
+ // Last two elements are always included. Middle ones may be omitted.
+ int lastTwoLength = end - indices[indices.length - 2];
+ // Try to find first element to omit.
+ for (int i = 3; i <= size - 3; i++) {
+ int elementEnd = indices[i + 1];
+ int lengthAfter = elementEnd - start;
+ int ellipsisSize = 5; // ", ...".length
+ if (i == size - 3) ellipsisSize = 0; // No ellipsis if we hit the end.
+ if (lengthAfter + ellipsisSize + lastTwoLength > MAX_LENGTH - 1) {
+ // Omit this element and everything up to the last two.
+ int elementStart = indices[i];
+ // Rewrite string buffer by copying it out, clearing, and putting
+ // the parts back in.
+ String buffer = stringRep.toString();
+ String prefix = buffer.substring(0, elementStart);
+ String suffix = buffer.substring(end - lastTwoLength, end);
+ stringRep.clear();
+ stringRep.write(prefix);
+ stringRep.write(", ...");
+ stringRep.write(suffix);
+ break;
+ }
+ }
+ }
+ }
+
+ stringRep.write(delimiters[1]);
+ beingMade.removeLast();
+ return coll;
+}
+
+/** Like populateRandomCollection, but for sets (elements must be hashable) */
+Set populateRandomSet(
+ int size, bool exact, StringBuffer stringRep, List beingMade, Set set) {
+ stringRep.write('{');
+
+ for (int i = 0; i < size; i++) {
+ if (i != 0) stringRep.write(', ');
+ set.add(i);
+ stringRep.write(i);
+ }
+
+ stringRep.write('}');
+ return set;
+}
+
+/** Like populateRandomCollection, but for maps. */
+Map populateRandomMap(
+ int size, bool exact, StringBuffer stringRep, List beingMade, Map map) {
+ beingMade.add(map);
+ stringRep.write('{');
+
+ for (int i = 0; i < size; i++) {
+ if (i != 0) stringRep.write(', ');
+
+ int key = i; // Ensures no duplicates
+ stringRep.write(key);
+ stringRep.write(': ');
+ Object val = randomElement(random(size), exact, stringRep, beingMade);
+ map[key] = val;
+ }
+
+ stringRep.write('}');
+ beingMade.removeLast();
+ return map;
+}
+
+/**
+ * Generates a random element which can be an int, a collection, or a map,
+ * and emits it to StringRep. The beingMade parameter is a list of collections
+ * currently under construction, i.e., candidates for recursive references.
+ *
+ * If exact is true, the returned element will not be, and will not contain
+ * a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
+ */
+Object randomElement(
+ int size, bool exact, StringBuffer stringRep, List beingMade) {
+ Object result;
+ double elementTypeFrac = rand.nextDouble();
+ if (elementTypeFrac < 1 / 3) {
+ result = random(1000);
+ stringRep.write(result);
+ } else if (elementTypeFrac < 2 / 3) {
+ // Element is a random (new) collection
+ result = randomCollectionHelper(size, exact, stringRep, beingMade);
+ } else {
+ // Element is a random recursive ref
+ result = beingMade[random(beingMade.length)];
+ if (result is List) {
+ stringRep.write('[...]');
+ } else if (result is Set || result is Map || result is Queue) {
+ stringRep.write('{...}');
+ } else {
+ stringRep.write('(...)');
+ }
+ }
+ return result;
+}
+
+/** Returns a random int on [0, max) */
+int random(int max) {
+ return rand.nextInt(max);
+}
+
+/** Returns a random boolean value. */
+bool randomBool() {
+ return rand.nextBool();
+}
+
+/** Returns the alphabetized characters in a string. */
+String alphagram(String s) {
+ // Calling [toList] to convert unmodifiable list to normal list.
+ List<int> chars = s.codeUnits.toList();
+ chars.sort((int a, int b) => a - b);
+ return new String.fromCharCodes(chars);
+}
diff --git a/tests/corelib/compare_to2_test.dart b/tests/corelib/compare_to2_test.dart
new file mode 100644
index 0000000..f9d66fb
--- /dev/null
+++ b/tests/corelib/compare_to2_test.dart
@@ -0,0 +1,96 @@
+// Copyright (c) 2012, 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.
+// Dart test for testing Math.min and Math.max.
+
+import "package:expect/expect.dart";
+
+negate(x) => -x;
+
+main() {
+ // Test matrix:
+ var minNonZero = 5e-324;
+ var maxDenormal = 2.225073858507201e-308;
+ var minNormal = 2.2250738585072014e-308;
+ var maxFraction = 0.9999999999999999;
+ var minAbove1 = 1.0000000000000002;
+ var maxNonInt = 4503599627370495.5;
+ var maxNonIntFloorAsInt = maxNonInt.floor();
+ var maxNonIntFloorAsDouble = maxNonIntFloorAsInt.toDouble();
+ var maxExactIntAsDouble = 9007199254740992.0;
+ var maxExactIntAsInt = 9007199254740992;
+ var two53 = 1 << 53; // Same as maxExactIntAsInt.
+ var two53p1 = two53 + 1;
+ var maxFiniteAsDouble = 1.7976931348623157e+308;
+ var maxFiniteAsInt = maxFiniteAsDouble.truncate();
+ var inf = double.infinity;
+ var nan = double.nan;
+ var mnan = negate(nan);
+ var minInt64 = -0x8000000000000000;
+ var minInt64AsDouble = minInt64.toDouble();
+ var maxInt64 = 0x7fffffffffffffff;
+ var maxInt64AsDouble = maxInt64.toDouble(); // 1 << 63
+ var matrix = [
+ -inf,
+ -maxFiniteAsDouble,
+ [minInt64, minInt64AsDouble],
+ [-maxInt64, -maxFiniteAsInt],
+ -two53p1,
+ [-two53, -maxExactIntAsInt, -maxExactIntAsDouble],
+ -maxNonInt,
+ [-maxNonIntFloorAsDouble, -maxNonIntFloorAsInt],
+ [-499.0, -499],
+ -minAbove1,
+ [-1.0, -1],
+ -maxFraction,
+ -minNormal,
+ -maxDenormal,
+ -minNonZero,
+ -0.0,
+ [0, 0, 0],
+ minNonZero,
+ maxDenormal,
+ minNormal,
+ maxFraction,
+ [1.0, 1],
+ minAbove1,
+ [499.0, 499],
+ [maxNonIntFloorAsDouble, maxNonIntFloorAsInt],
+ maxNonInt,
+ [two53, maxExactIntAsInt, maxExactIntAsDouble],
+ two53p1,
+ [maxInt64, maxFiniteAsInt],
+ maxInt64AsDouble,
+ maxFiniteAsDouble,
+ inf,
+ [nan, mnan],
+ ];
+
+ check(left, right, expectedResult) {
+ if (left is List) {
+ for (var x in left) check(x, right, expectedResult);
+ return;
+ }
+ if (right is List) {
+ for (var x in right) check(left, x, expectedResult);
+ return;
+ }
+ int actual = left.compareTo(right);
+ Expect.equals(
+ expectedResult,
+ actual,
+ "($left).compareTo($right) failed "
+ "(should have been $expectedResult, was $actual");
+ }
+
+ for (int i = 0; i < matrix.length; i++) {
+ for (int j = 0; j < matrix.length; j++) {
+ var left = matrix[i];
+ var right = matrix[j];
+ if (left is List) {
+ check(left, left, 0);
+ }
+ check(left, right, i == j ? 0 : (i < j ? -1 : 1));
+ }
+ }
+}
diff --git a/tests/corelib/compare_to_test.dart b/tests/corelib/compare_to_test.dart
new file mode 100644
index 0000000..318a39f
--- /dev/null
+++ b/tests/corelib/compare_to_test.dart
@@ -0,0 +1,136 @@
+// Copyright (c) 2012, 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.
+// Dart test for testing Math.min and Math.max.
+
+import "package:expect/expect.dart";
+
+negate(x) => -x;
+
+main() {
+ // Test matrix:
+ // -inf < -499.0 == -499 < -0.0 < 0.0 == 0 < 499.0 == 499 < +inf < -NaN, NaN.
+ var inf = double.infinity;
+ var nan = double.nan;
+ var mnan = negate(nan);
+
+ Expect.equals(0, (-inf).compareTo(-inf));
+ Expect.equals(-1, (-inf).compareTo(-499.0));
+ Expect.equals(-1, (-inf).compareTo(-499));
+ Expect.equals(-1, (-inf).compareTo(-0.0));
+ Expect.equals(-1, (-inf).compareTo(0));
+ Expect.equals(-1, (-inf).compareTo(0.0));
+ Expect.equals(-1, (-inf).compareTo(499.0));
+ Expect.equals(-1, (-inf).compareTo(499));
+ Expect.equals(-1, (-inf).compareTo(inf));
+ Expect.equals(-1, (-inf).compareTo(nan));
+ Expect.equals(-1, (-inf).compareTo(mnan));
+
+ Expect.equals(1, (-499.0).compareTo(-inf));
+ Expect.equals(0, (-499.0).compareTo(-499.0));
+ Expect.equals(0, (-499.0).compareTo(-499));
+ Expect.equals(-1, (-499.0).compareTo(-0.0));
+ Expect.equals(-1, (-499.0).compareTo(0));
+ Expect.equals(-1, (-499.0).compareTo(0.0));
+ Expect.equals(-1, (-499.0).compareTo(499.0));
+ Expect.equals(-1, (-499.0).compareTo(499));
+ Expect.equals(-1, (-499.0).compareTo(inf));
+ Expect.equals(-1, (-499.0).compareTo(nan));
+ Expect.equals(-1, (-499.0).compareTo(mnan));
+
+ Expect.equals(1, (-499).compareTo(-inf));
+ Expect.equals(0, (-499).compareTo(-499.0));
+ Expect.equals(0, (-499).compareTo(-499));
+ Expect.equals(-1, (-499).compareTo(-0.0));
+ Expect.equals(-1, (-499).compareTo(0));
+ Expect.equals(-1, (-499).compareTo(0.0));
+ Expect.equals(-1, (-499).compareTo(499.0));
+ Expect.equals(-1, (-499).compareTo(499));
+ Expect.equals(-1, (-499).compareTo(inf));
+ Expect.equals(-1, (-499).compareTo(nan));
+ Expect.equals(-1, (-499).compareTo(mnan));
+
+ Expect.equals(1, (-0.0).compareTo(-inf));
+ Expect.equals(1, (-0.0).compareTo(-499.0));
+ Expect.equals(1, (-0.0).compareTo(-499));
+ Expect.equals(0, (-0.0).compareTo(-0.0));
+ Expect.equals(-1, (-0.0).compareTo(0));
+ Expect.equals(-1, (-0.0).compareTo(0.0));
+ Expect.equals(-1, (-0.0).compareTo(499.0));
+ Expect.equals(-1, (-0.0).compareTo(499));
+ Expect.equals(-1, (-0.0).compareTo(inf));
+ Expect.equals(-1, (-0.0).compareTo(nan));
+ Expect.equals(-1, (-0.0).compareTo(mnan));
+
+ Expect.equals(1, (0).compareTo(-inf));
+ Expect.equals(1, (0).compareTo(-499.0));
+ Expect.equals(1, (0).compareTo(-499));
+ Expect.equals(1, (0).compareTo(-0.0));
+ Expect.equals(0, (0).compareTo(0));
+ Expect.equals(0, (0).compareTo(0.0));
+ Expect.equals(-1, (0).compareTo(499.0));
+ Expect.equals(-1, (0).compareTo(499));
+ Expect.equals(-1, (0).compareTo(inf));
+ Expect.equals(-1, (0).compareTo(nan));
+ Expect.equals(-1, (0).compareTo(mnan));
+
+ Expect.equals(1, (0.0).compareTo(-inf));
+ Expect.equals(1, (0.0).compareTo(-499.0));
+ Expect.equals(1, (0.0).compareTo(-499));
+ Expect.equals(1, (0.0).compareTo(-0.0));
+ Expect.equals(0, (0.0).compareTo(0));
+ Expect.equals(0, (0.0).compareTo(0.0));
+ Expect.equals(-1, (0.0).compareTo(499.0));
+ Expect.equals(-1, (0.0).compareTo(499));
+ Expect.equals(-1, (0.0).compareTo(inf));
+ Expect.equals(-1, (0.0).compareTo(nan));
+ Expect.equals(-1, (0.0).compareTo(mnan));
+
+ Expect.equals(1, (499.0).compareTo(-inf));
+ Expect.equals(1, (499.0).compareTo(-499.0));
+ Expect.equals(1, (499.0).compareTo(-499));
+ Expect.equals(1, (499.0).compareTo(-0.0));
+ Expect.equals(1, (499.0).compareTo(0));
+ Expect.equals(1, (499.0).compareTo(0.0));
+ Expect.equals(0, (499.0).compareTo(499.0));
+ Expect.equals(0, (499.0).compareTo(499));
+ Expect.equals(-1, (499.0).compareTo(inf));
+ Expect.equals(-1, (499.0).compareTo(nan));
+ Expect.equals(-1, (499.0).compareTo(mnan));
+
+ Expect.equals(1, (499).compareTo(-inf));
+ Expect.equals(1, (499).compareTo(-499.0));
+ Expect.equals(1, (499).compareTo(-499));
+ Expect.equals(1, (499).compareTo(-0.0));
+ Expect.equals(1, (499).compareTo(0));
+ Expect.equals(1, (499).compareTo(0.0));
+ Expect.equals(0, (499).compareTo(499.0));
+ Expect.equals(0, (499).compareTo(499));
+ Expect.equals(-1, (499).compareTo(inf));
+ Expect.equals(-1, (499).compareTo(nan));
+ Expect.equals(-1, (499).compareTo(mnan));
+
+ Expect.equals(1, inf.compareTo(-inf));
+ Expect.equals(1, inf.compareTo(-499.0));
+ Expect.equals(1, inf.compareTo(-499));
+ Expect.equals(1, inf.compareTo(-0.0));
+ Expect.equals(1, inf.compareTo(0));
+ Expect.equals(1, inf.compareTo(0.0));
+ Expect.equals(1, inf.compareTo(499.0));
+ Expect.equals(1, inf.compareTo(499));
+ Expect.equals(0, inf.compareTo(inf));
+ Expect.equals(-1, inf.compareTo(nan));
+ Expect.equals(-1, inf.compareTo(mnan));
+
+ Expect.equals(1, nan.compareTo(-inf));
+ Expect.equals(1, nan.compareTo(-499.0));
+ Expect.equals(1, nan.compareTo(-499));
+ Expect.equals(1, nan.compareTo(-0.0));
+ Expect.equals(1, nan.compareTo(0));
+ Expect.equals(1, nan.compareTo(0.0));
+ Expect.equals(1, nan.compareTo(499.0));
+ Expect.equals(1, nan.compareTo(499));
+ Expect.equals(1, nan.compareTo(inf));
+ Expect.equals(0, nan.compareTo(nan));
+ Expect.equals(0, nan.compareTo(mnan));
+}
diff --git a/tests/corelib/const_list_literal_test.dart b/tests/corelib/const_list_literal_test.dart
new file mode 100644
index 0000000..cf61c4f
--- /dev/null
+++ b/tests/corelib/const_list_literal_test.dart
@@ -0,0 +1,80 @@
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+// Test that a final list literal is not expandable nor modifiable.
+
+class ConstListLiteralTest {
+ static void testMain() {
+ var list = const [4, 2, 3];
+ Expect.equals(3, list.length);
+
+ var exception = null;
+ try {
+ list.add(4);
+ } on UnsupportedError catch (e) {
+ exception = e;
+ }
+ Expect.equals(true, exception != null);
+ Expect.equals(3, list.length);
+ exception = null;
+
+ exception = null;
+ try {
+ list.addAll([4, 5]);
+ } on UnsupportedError catch (e) {
+ exception = e;
+ }
+ Expect.equals(true, exception != null);
+ Expect.equals(3, list.length);
+
+ exception = null;
+ try {
+ list[0] = 0;
+ } on UnsupportedError catch (e) {
+ exception = e;
+ }
+ Expect.equals(true, exception != null);
+ Expect.equals(3, list.length);
+
+ exception = null;
+ try {
+ list.sort((a, b) => a - b);
+ } on UnsupportedError catch (e) {
+ exception = e;
+ }
+ Expect.equals(true, exception != null);
+ Expect.equals(3, list.length);
+ Expect.equals(4, list[0]);
+ Expect.equals(2, list[1]);
+ Expect.equals(3, list[2]);
+
+ exception = null;
+ try {
+ list.setRange(0, 1, [1], 0);
+ } on UnsupportedError catch (e) {
+ exception = e;
+ }
+ Expect.equals(true, exception != null);
+ Expect.equals(3, list.length);
+ Expect.equals(4, list[0]);
+ Expect.equals(2, list[1]);
+ Expect.equals(3, list[2]);
+
+ // Note: the next check is a regression test for dart2js. The immutable list
+ // overrides the 'length' property of List, but relies on using the native
+ // 'forEach' construct in Array. This test ensures that our strategy works
+ // correctly.
+ int x = 0;
+ list.forEach((e) {
+ x += e;
+ });
+ Expect.equals(9, x);
+ }
+}
+
+main() {
+ ConstListLiteralTest.testMain();
+}
diff --git a/tests/corelib/const_list_remove_range_test.dart b/tests/corelib/const_list_remove_range_test.dart
new file mode 100644
index 0000000..e3c257c
--- /dev/null
+++ b/tests/corelib/const_list_remove_range_test.dart
@@ -0,0 +1,17 @@
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ testImmutable(const []);
+ testImmutable(const [1]);
+ testImmutable(const [1, 2]);
+}
+
+testImmutable(var list) {
+ Expect.throwsUnsupportedError(() => list.removeRange(0, 0));
+ Expect.throwsUnsupportedError(() => list.removeRange(0, 1));
+ Expect.throwsUnsupportedError(() => list.removeRange(-1, 1));
+}
diff --git a/tests/corelib/const_list_set_range_test.dart b/tests/corelib/const_list_set_range_test.dart
new file mode 100644
index 0000000..9bba324
--- /dev/null
+++ b/tests/corelib/const_list_set_range_test.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ testImmutable(const []);
+ testImmutable(const [1]);
+ testImmutable(const [1, 2]);
+}
+
+testImmutable(List list) {
+ Expect.throwsUnsupportedError(() => list.setRange(0, 0, const []));
+ Expect.throwsUnsupportedError(() => list.setRange(0, 1, const [], 1));
+ Expect.throwsUnsupportedError(() => list.setRange(0, 1, const []));
+ Expect.throwsUnsupportedError(() => list.setRange(0, 0, []));
+ Expect.throwsUnsupportedError(() => list.setRange(0, 1, [], 1));
+ Expect.throwsUnsupportedError(() => list.setRange(0, 1, []));
+ Expect.throwsUnsupportedError(() => list.setRange(0, 0, const [1]));
+ Expect.throwsUnsupportedError(() => list.setRange(0, 1, const [1]));
+ Expect.throwsUnsupportedError(() => list.setRange(0, 0, [1]));
+ Expect.throwsUnsupportedError(() => list.setRange(0, 1, [1]));
+ Expect.throwsUnsupportedError(() => list.setRange(0, 1, [1], 1));
+}
diff --git a/tests/corelib/core_runtime_types_static_test.dart b/tests/corelib/core_runtime_types_static_test.dart
new file mode 100644
index 0000000..8bb96c2
--- /dev/null
+++ b/tests/corelib/core_runtime_types_static_test.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+/**
+ * Verify static compilation errors on strings and lists.
+ */
+class CoreStaticTypesTest {
+ static testMain() {
+ testStringOperators();
+ testStringMethods();
+ testListOperators();
+ }
+
+ static testStringOperators() {
+ var q = "abcdef";
+ /*@compile-error=unspecified*/ q['hello'];
+ /*@compile-error=unspecified*/ q[0] = 'x';
+ }
+
+ static testStringMethods() {
+ var s = "abcdef";
+ /*@compile-error=unspecified*/ s.startsWith(1);
+ /*@compile-error=unspecified*/ s.endsWith(1);
+ }
+
+ static testListOperators() {
+ var a = [1, 2, 3, 4];
+ /*@compile-error=unspecified*/ a['0'];
+ /*@compile-error=unspecified*/ a['0'] = 99;
+ }
+}
+
+main() {
+ CoreStaticTypesTest.testMain();
+}
diff --git a/tests/corelib/core_runtime_types_test.dart b/tests/corelib/core_runtime_types_test.dart
new file mode 100644
index 0000000..8ce8892
--- /dev/null
+++ b/tests/corelib/core_runtime_types_test.dart
@@ -0,0 +1,333 @@
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+/**
+ * A test of simple runtime behavior on numbers, strings and lists with
+ * a focus on both correct behavior and runtime errors.
+ *
+ * This file is written to use minimal type declarations to match a
+ * typical dynamic language coding style.
+ */
+class CoreRuntimeTypesTest {
+ static testMain() {
+ testBooleanOperators();
+ testRationalOperators();
+ testIntegerOperators();
+ testOperatorErrors();
+ testRationalMethods();
+ testIntegerMethods();
+ testStringOperators();
+ testStringMethods();
+ testListOperators();
+ testListMethods();
+ testMapOperators();
+ testMapMethods();
+ testLiterals();
+ testDateMethods();
+ }
+
+ static assertEquals(a, b) {
+ Expect.equals(b, a);
+ }
+
+ static assertListEquals(List a, List b) {
+ Expect.equals(b.length, a.length);
+ for (int i = 0; i < a.length; i++) {
+ Expect.equals(b[i], a[i]);
+ }
+ }
+
+ static assertListContains(List a, List b) {
+ a.sort((x, y) => x.compareTo(y));
+ b.sort((x, y) => x.compareTo(y));
+ assertListEquals(a, b);
+ }
+
+ static assertTypeError(void f(), [String? message]) {
+ Expect.throws<Error>(
+ f,
+ (exception) =>
+ (exception is TypeError) ||
+ (exception is CastError) ||
+ (exception is AssertionError) ||
+ (exception is NoSuchMethodError) ||
+ (exception is ArgumentError),
+ message ?? "");
+ }
+
+ static testBooleanOperators() {
+ var x = true, y = false;
+ assertEquals(x, true);
+ assertEquals(y, false);
+ assertEquals(x, !y);
+ assertEquals(!x, y);
+ }
+
+ static testRationalOperators() {
+ var x = 10, y = 20;
+ assertEquals(x + y, 30);
+ assertEquals(x - y, -10);
+ assertEquals(x * y, 200);
+ assertEquals(x / y, 0.5);
+ assertEquals(x ~/ y, 0);
+ assertEquals(x % y, 10);
+ }
+
+ static testIntegerOperators() {
+ var x = 18, y = 17;
+ assertEquals(x | y, 19);
+ assertEquals(x & y, 16);
+ assertEquals(x ^ y, 3);
+ assertEquals(2 >> 1, 1);
+ assertEquals(1 << 1, 2);
+ }
+
+ static testOperatorErrors() {
+ var objs = [
+ 1,
+ '2',
+ [3],
+ null,
+ true,
+ new Map()
+ ];
+ for (var i = 0; i < objs.length; i++) {
+ for (var j = i + 1; j < objs.length; j++) {
+ testBinaryOperatorErrors(objs[i], objs[j]);
+ testBinaryOperatorErrors(objs[j], objs[i]);
+ }
+ testUnaryOperatorErrors(objs[i]);
+ }
+ }
+
+ static testBinaryOperatorErrors(dynamic x, dynamic y) {
+ assertTypeError(() {
+ x + y;
+ }, "$x+$y");
+ assertTypeError(() {
+ x - y;
+ }, "$x-$y");
+ // String.* is the only non-same-type binary operator we have.
+ if (x is! String && y is! int) {
+ assertTypeError(() {
+ x * y;
+ }, "$x*$y");
+ }
+ assertTypeError(() {
+ x / y;
+ }, "$x/$y");
+ assertTypeError(() {
+ x | y;
+ }, "$x|$y");
+ assertTypeError(() {
+ x ^ y;
+ }, "$x^$y");
+ assertTypeError(() {
+ x & y;
+ }, "$x&$y");
+ assertTypeError(() {
+ x << y;
+ }, "$x<<$y");
+ assertTypeError(() {
+ x >> y;
+ }, "$x>>$y");
+ assertTypeError(() {
+ x ~/ y;
+ }, "$x~/$y");
+ assertTypeError(() {
+ x % y;
+ }, "$x%$y");
+
+ testComparisonOperatorErrors(x, y);
+ }
+
+ static testComparisonOperatorErrors(x, y) {
+ assertEquals(x == y, false);
+ assertEquals(x != y, true);
+ assertTypeError(() {
+ x < y;
+ }, "$x<$y");
+ assertTypeError(() {
+ x <= y;
+ }, "$x<=$y");
+ assertTypeError(() {
+ x > y;
+ }, "$x>$y");
+ assertTypeError(() {
+ x >= y;
+ }, "$x>=$y");
+ }
+
+ static testUnaryOperatorErrors(x) {
+ if (x is! int) {
+ assertTypeError(() {
+ ~x;
+ }, "~$x");
+ }
+ if (x is! num) {
+ assertTypeError(() {
+ -x;
+ }, "-$x");
+ }
+ if (x is! bool) {
+ assertTypeError(() {
+ !x;
+ }, "!$x");
+ }
+ }
+
+ static testRationalMethods() {
+ var x = 10.6;
+ assertEquals(x.abs(), 10.6);
+ assertEquals((-x).abs(), 10.6);
+ assertEquals(x.round(), 11);
+ assertEquals(x.floor(), 10);
+ assertEquals(x.ceil(), 11);
+ }
+
+ // TODO(jimhug): Determine correct behavior for mixing ints and floats.
+ static testIntegerMethods() {
+ var y = 9;
+ assertEquals(y.isEven, false);
+ assertEquals(y.isOdd, true);
+ assertEquals(y.toRadixString(2), '1001');
+ assertEquals(y.toRadixString(3), '100');
+ assertEquals(y.toRadixString(16), '9');
+ assertEquals((0).toRadixString(16), '0');
+ try {
+ y.toRadixString(0);
+ Expect.fail("Illegal radix 0 accepted.");
+ } catch (e) {}
+ try {
+ y.toRadixString(-1);
+ Expect.fail("Illegal radix -1 accepted.");
+ } catch (e) {}
+ }
+
+ static testStringOperators() {
+ dynamic s = "abcdef";
+ assertEquals(s, "abcdef");
+ assertEquals(s.codeUnitAt(0), 97);
+ assertEquals(s[0], 'a');
+ assertEquals(s.length, 6);
+ }
+
+ // TODO(jimhug): Fill out full set of string methods.
+ static testStringMethods() {
+ var s = "abcdef";
+ assertEquals(s.isEmpty, false);
+ assertEquals(s.isNotEmpty, true);
+ assertEquals(s.startsWith("abc"), true);
+ assertEquals(s.endsWith("def"), true);
+ assertEquals(s.startsWith("aa"), false);
+ assertEquals(s.endsWith("ff"), false);
+ assertEquals(s.contains('cd', 0), true);
+ assertEquals(s.contains('cd', 2), true);
+ assertEquals(s.contains('cd', 3), false);
+ assertEquals(s.indexOf('cd', 2), 2);
+ assertEquals(s.indexOf('cd', 3), -1);
+ }
+
+ static testListOperators() {
+ var a = [1, 2, 3, 4];
+ assertEquals(a[0], 1);
+ a[0] = 42;
+ assertEquals(a[0], 42);
+ assertEquals(a.length, 4);
+ }
+
+ // TODO(jimhug): Fill out full set of list methods.
+ static testListMethods() {
+ var a = [1, 2, 3, 4];
+ assertEquals(a.isEmpty, false);
+ assertEquals(a.length, 4);
+ var exception = null;
+ a.clear();
+ assertEquals(a.length, 0);
+ }
+
+ static testMapOperators() {
+ var d = new Map();
+ d['a'] = 1;
+ d['b'] = 2;
+ assertEquals(d['a'], 1);
+ assertEquals(d['b'], 2);
+ assertEquals(d['c'], null);
+ }
+
+ static testMapMethods() {
+ var d = new Map();
+ d['a'] = 1;
+ d['b'] = 2;
+ assertEquals(d.containsValue(2), true);
+ assertEquals(d.containsValue(3), false);
+ assertEquals(d.containsKey('a'), true);
+ assertEquals(d.containsKey('c'), false);
+ assertEquals(d.keys.length, 2);
+ assertEquals(d.values.length, 2);
+
+ assertEquals(d.remove('c'), null);
+ assertEquals(d.remove('b'), 2);
+ assertEquals(d.keys.single, 'a');
+ assertEquals(d.values.single, 1);
+
+ d['c'] = 3;
+ d['f'] = 4;
+ assertEquals(d.keys.length, 3);
+ assertEquals(d.values.length, 3);
+ assertListContains(d.keys.toList(), ['a', 'c', 'f']);
+ assertListContains(d.values.toList(), [1, 3, 4]);
+
+ var count = 0;
+ d.forEach((key, value) {
+ count++;
+ assertEquals(value, d[key]);
+ });
+ assertEquals(count, 3);
+
+ d = {'a': 1, 'b': 2};
+ assertEquals(d.containsValue(2), true);
+ assertEquals(d.containsValue(3), false);
+ assertEquals(d.containsKey('a'), true);
+ assertEquals(d.containsKey('c'), false);
+ assertEquals(d.keys.length, 2);
+ assertEquals(d.values.length, 2);
+
+ d['g'] = null;
+ assertEquals(d.containsKey('g'), true);
+ assertEquals(d['g'], null);
+ }
+
+ static testDateMethods() {
+ var msec = 115201000;
+ var d = new DateTime.fromMillisecondsSinceEpoch(msec, isUtc: true);
+ assertEquals(d.second, 1);
+ assertEquals(d.year, 1970);
+
+ d = new DateTime.now();
+ assertEquals(d.year >= 1970, true);
+ }
+
+ static testLiterals() {
+ true.toString();
+ 1.0.toString();
+ .5.toString();
+ 1.toString();
+ if (false) {
+ // Depends on http://b/4198808.
+ null.toString();
+ }
+ '${null}'.toString();
+ '${true}'.toString();
+ '${false}'.toString();
+ ''.toString();
+ ''.endsWith('');
+ }
+}
+
+main() {
+ CoreRuntimeTypesTest.testMain();
+}
diff --git a/tests/corelib/data_uri_test.dart b/tests/corelib/data_uri_test.dart
new file mode 100644
index 0000000..09ff01b
--- /dev/null
+++ b/tests/corelib/data_uri_test.dart
@@ -0,0 +1,301 @@
+// Copyright (c) 2015, 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.
+
+import "package:expect/expect.dart";
+import "dart:convert";
+import "dart:typed_data";
+
+main() {
+ testMediaType();
+
+ testRoundTrip("");
+ testRoundTrip("a");
+ testRoundTrip("ab");
+ testRoundTrip("abc");
+ testRoundTrip("abcd");
+ testRoundTrip("Content with special%25 characters: # ? = % # ? = %");
+ testRoundTrip("blåbærgrød", utf8);
+ testRoundTrip("blåbærgrød", latin1);
+
+ testUriEquals("data:,abc?d");
+ testUriEquals("DATA:,ABC?D");
+ testUriEquals("data:,a%20bc?d");
+ testUriEquals("DATA:,A%20BC?D");
+ testUriEquals("data:,abc?d%23e"); // # must and will be is escaped.
+
+ // Test that UriData.uri normalizes path and query.
+
+ testUtf8Encoding("\u1000\uffff");
+ testBytes();
+ testInvalidCharacters();
+ testNormalization();
+ testErrors();
+}
+
+void testMediaType() {
+ for (var mimeType in ["", "text/plain", "text/javascript"]) {
+ for (var charset in ["", ";charset=US-ASCII", ";charset=UTF-8"]) {
+ for (var base64 in ["", ";base64"]) {
+ bool isBase64 = base64.isNotEmpty;
+ var text = "data:$mimeType$charset$base64,";
+ var uri = UriData.parse(text);
+
+ String expectedCharset =
+ charset.isEmpty ? "US-ASCII" : charset.substring(9);
+ String expectedMimeType = mimeType.isEmpty ? "text/plain" : mimeType;
+
+ Expect.equals(text, "$uri");
+ Expect.equals(expectedMimeType, uri.mimeType);
+ Expect.equals(expectedCharset, uri.charset);
+ Expect.equals(isBase64, uri.isBase64);
+ }
+ }
+ }
+}
+
+void testRoundTrip(String content, [Encoding? encoding]) {
+ UriData dataUri = new UriData.fromString(content, encoding: encoding);
+ Expect.isFalse(dataUri.isBase64);
+ Uri uri = dataUri.uri;
+ expectUriEquals(new Uri.dataFromString(content, encoding: encoding), uri);
+
+ if (encoding != null) {
+ UriData dataUriParams =
+ new UriData.fromString(content, parameters: {"charset": encoding.name});
+ Expect.equals("$dataUri", "$dataUriParams");
+ }
+
+ Expect.equals(encoding ?? ascii, Encoding.getByName(dataUri.charset));
+ Expect.equals(content, dataUri.contentAsString(encoding: encoding));
+ Expect.equals(content, dataUri.contentAsString());
+ Expect.equals(content, (encoding ?? ascii).decode(dataUri.contentAsBytes()));
+
+ uri = dataUri.uri;
+ Expect.equals(uri.toString(), dataUri.toString());
+ Expect.equals(dataUri.toString(), new UriData.fromUri(uri).toString());
+
+ dataUri = new UriData.fromBytes(content.codeUnits);
+ Expect.listEquals(content.codeUnits, dataUri.contentAsBytes());
+ Expect.equals(content, dataUri.contentAsString(encoding: latin1));
+
+ uri = dataUri.uri;
+ Expect.equals(uri.toString(), dataUri.toString());
+ Expect.equals(dataUri.toString(), new UriData.fromUri(uri).toString());
+ // Check that the URI is properly normalized.
+ expectUriEquals(uri, Uri.parse("$uri"));
+}
+
+void testUtf8Encoding(String content) {
+ UriData uri = new UriData.fromString(content, encoding: utf8);
+ Expect.equals(content, uri.contentAsString(encoding: utf8));
+ Expect.listEquals(utf8.encode(content), uri.contentAsBytes());
+}
+
+void testInvalidCharacters() {
+ // SPACE, CTL and tspecial, plus '%' and '#' (URI gen-delim)
+ // This contains all ASCII character that are not valid in attribute/value
+ // parts.
+ var invalid =
+ '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x7f'
+ ' ()<>@,;:"/[]?=%#\x80\u{1000}\u{10000}';
+ var invalidNoSlash = invalid.replaceAll('/', '');
+ var dataUri = new UriData.fromString(invalid,
+ encoding: utf8,
+ mimeType: "$invalidNoSlash/$invalidNoSlash",
+ parameters: {invalid: invalid});
+
+ Expect.equals(invalid, dataUri.contentAsString());
+ Expect.equals("$invalidNoSlash/$invalidNoSlash", dataUri.mimeType);
+ Expect.equals(invalid, dataUri.parameters[invalid]);
+
+ var uri = dataUri.uri;
+ Expect.equals("$uri", "$dataUri");
+ expectUriEquals(uri, Uri.parse("$uri")); // Check that it's canonicalized.
+ Expect.equals("$dataUri", new UriData.fromUri(uri).toString());
+}
+
+void testBytes() {
+ void testList(List<int> list) {
+ var dataUri = new UriData.fromBytes(list);
+ Expect.equals("application/octet-stream", dataUri.mimeType);
+ Expect.isTrue(dataUri.isBase64);
+ Expect.listEquals(list, dataUri.contentAsBytes());
+
+ dataUri = new UriData.fromBytes(list, percentEncoded: true);
+ Expect.equals("application/octet-stream", dataUri.mimeType);
+ Expect.isFalse(dataUri.isBase64);
+ Expect.listEquals(list, dataUri.contentAsBytes());
+
+ var string = new String.fromCharCodes(list);
+
+ dataUri = new UriData.fromString(string, encoding: latin1);
+ Expect.equals("text/plain", dataUri.mimeType);
+ Expect.isFalse(dataUri.isBase64);
+ Expect.listEquals(list, dataUri.contentAsBytes());
+
+ dataUri = new UriData.fromString(string, encoding: latin1, base64: true);
+ Expect.equals("text/plain", dataUri.mimeType);
+ Expect.isTrue(dataUri.isBase64);
+ Expect.listEquals(list, dataUri.contentAsBytes());
+ }
+
+ void testLists(List<int> list) {
+ testList(list);
+ for (int i = 0; i < 27; i++) {
+ testList(list.sublist(i, i + i)); // All lengths from 0 to 27.
+ }
+ }
+
+ var bytes = new Uint8List(512);
+ for (int i = 0; i < bytes.length; i++) {
+ bytes[i] = i;
+ }
+ testLists(bytes);
+ testLists(new List.from(bytes));
+ testLists(new List.unmodifiable(bytes));
+}
+
+void testNormalization() {
+ // Base-64 normalization.
+
+ // Normalized URI-alphabet characters.
+ Expect.equals(
+ "data:;base64,AA/+", UriData.parse("data:;base64,AA_-").toString());
+ // Normalized escapes.
+ Expect.equals(
+ "data:;base64,AB==", UriData.parse("data:;base64,A%42=%3D").toString());
+ Expect.equals("data:;base64,/+/+",
+ UriData.parse("data:;base64,%5F%2D%2F%2B").toString());
+ // Normalized padded data.
+ Expect.equals(
+ "data:;base64,AA==", UriData.parse("data:;base64,AA%3D%3D").toString());
+ Expect.equals(
+ "data:;base64,AAA=", UriData.parse("data:;base64,AAA%3D").toString());
+ // Normalized unpadded data.
+ Expect.equals(
+ "data:;base64,AA==", UriData.parse("data:;base64,AA").toString());
+ Expect.equals(
+ "data:;base64,AAA=", UriData.parse("data:;base64,AAA").toString());
+
+ // "URI normalization" of non-base64 content.
+ var uri = UriData.parse("data:,\x20\xa0");
+ Expect.equals("data:,%20%C2%A0", uri.toString());
+ uri = UriData.parse("data:,x://x@y:[z]:42/p/./?q=x&y=z#?#\u1234\u{12345}");
+ Expect.equals(
+ "data:,x://x@y:%5Bz%5D:42/p/./?q=x&y=z%23?%23%E1%88%B4%F0%92%8D%85",
+ uri.toString());
+}
+
+void testErrors() {
+ // Invalid constructor parameters.
+ Expect.throwsArgumentError(
+ () => new UriData.fromBytes([], mimeType: "noslash"));
+ Expect.throwsArgumentError(() => new UriData.fromBytes([257]));
+ Expect.throwsArgumentError(() => new UriData.fromBytes([-1]));
+ Expect.throwsArgumentError(() => new UriData.fromBytes([0x10000000]));
+ Expect.throwsArgumentError(
+ () => new UriData.fromString("", mimeType: "noslash"));
+
+ Expect.throwsArgumentError(
+ () => new Uri.dataFromBytes([], mimeType: "noslash"));
+ Expect.throwsArgumentError(() => new Uri.dataFromBytes([257]));
+ Expect.throwsArgumentError(() => new Uri.dataFromBytes([-1]));
+ Expect.throwsArgumentError(() => new Uri.dataFromBytes([0x10000000]));
+ Expect.throwsArgumentError(
+ () => new Uri.dataFromString("", mimeType: "noslash"));
+
+ // Empty parameters allowed, not an error.
+ var uri = new UriData.fromString("", mimeType: "", parameters: {});
+ Expect.equals("data:,", "$uri");
+ // Empty parameter key or value is an error.
+ Expect.throwsArgumentError(
+ () => new UriData.fromString("", parameters: {"": "X"}));
+ Expect.throwsArgumentError(
+ () => new UriData.fromString("", parameters: {"X": ""}));
+
+ // Not recognizing charset is an error.
+ uri = UriData.parse("data:;charset=arglebargle,X");
+ Expect.throws(() {
+ uri.contentAsString();
+ });
+ // Doesn't throw if we specify the encoding.
+ Expect.equals("X", uri.contentAsString(encoding: ascii));
+
+ // Parse format.
+ Expect.throwsFormatException(() => UriData.parse("notdata:,"));
+ Expect.throwsFormatException(() => UriData.parse("text/plain,noscheme"));
+ Expect.throwsFormatException(() => UriData.parse("data:noseparator"));
+ Expect.throwsFormatException(() => UriData.parse("data:noslash,text"));
+ Expect.throwsFormatException(
+ () => UriData.parse("data:type/sub;noequals,text"));
+ Expect.throwsFormatException(() => UriData.parse("data:type/sub;knocomma="));
+ Expect.throwsFormatException(
+ () => UriData.parse("data:type/sub;k=v;nocomma"));
+ Expect.throwsFormatException(() => UriData.parse("data:type/sub;k=nocomma"));
+ Expect.throwsFormatException(() => UriData.parse("data:type/sub;k=v;base64"));
+
+ void formatError(String input) {
+ Expect.throwsFormatException(() => UriData.parse("data:;base64,$input"),
+ input);
+ }
+
+ // Invalid base64 format (detected when parsed).
+ for (var a = 0; a <= 4; a++) {
+ for (var p = 0; p <= 4; p++) {
+ // Base-64 encoding must have length divisible by four and no more
+ // than two padding characters at the end.
+ if (p < 3 && (a + p) % 4 == 0) continue;
+ if (p == 0 && a > 1) continue;
+ formatError("A" * a + "=" * p);
+ formatError("A" * a + "%3D" * p);
+ }
+ }
+ // Invalid base64 encoding: padding not at end.
+ formatError("AA=A");
+ formatError("A=AA");
+ formatError("=AAA");
+ formatError("A==A");
+ formatError("==AA");
+ formatError("===A");
+ formatError("AAA%3D=");
+ formatError("A%3D==");
+
+ // Invalid unpadded data.
+ formatError("A");
+ formatError("AAAAA");
+
+ // Invalid characters.
+ formatError("AAA*");
+ formatError("AAA\x00");
+ formatError("AAA\\");
+ formatError("AAA,");
+
+ // Invalid escapes.
+ formatError("AAA%25");
+ formatError("AAA%7F");
+ formatError("AAA%7F");
+}
+
+/// Checks that two [Uri]s are exactly the same.
+expectUriEquals(Uri expect, Uri actual) {
+ Expect.equals(expect.scheme, actual.scheme, "scheme");
+ Expect.equals(expect.hasAuthority, actual.hasAuthority, "hasAuthority");
+ Expect.equals(expect.userInfo, actual.userInfo, "userInfo");
+ Expect.equals(expect.host, actual.host, "host");
+ Expect.equals(expect.hasPort, actual.hasPort, "hasPort");
+ Expect.equals(expect.port, actual.port, "port");
+ Expect.equals(expect.port, actual.port, "port");
+ Expect.equals(expect.hasQuery, actual.hasQuery, "hasQuery");
+ Expect.equals(expect.query, actual.query, "query");
+ Expect.equals(expect.hasFragment, actual.hasFragment, "hasFragment");
+ Expect.equals(expect.fragment, actual.fragment, "fragment");
+}
+
+void testUriEquals(String uriText) {
+ var data = UriData.parse(uriText);
+ var uri = Uri.parse(uriText);
+ Expect.equals(data.uri, uri);
+ Expect.equals(data.toString(), uri.data.toString());
+ Expect.equals(data.toString(), uri.toString());
+}
diff --git a/tests/corelib/date_time10_test.dart b/tests/corelib/date_time10_test.dart
new file mode 100644
index 0000000..3d7d34e
--- /dev/null
+++ b/tests/corelib/date_time10_test.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Make sure the years in the range of single digits are handled correctly with
+// month roll-over. (This tests an edge condition when delegating to
+// JavaScript's Date constructor.)
+
+void check(String expected, DateTime actual) {
+ Expect.equals(expected, actual.toString());
+}
+
+testUtc() {
+ check("0099-01-01 00:00:00.000Z", new DateTime.utc(99, 1));
+ check("0100-01-01 00:00:00.000Z", new DateTime.utc(99, 1 + 12));
+ check("0000-01-01 00:00:00.000Z", new DateTime.utc(0, 1));
+ check("-0001-01-01 00:00:00.000Z", new DateTime.utc(0, 1 - 12));
+
+ check("0099-03-02 00:00:00.000Z", new DateTime.utc(99, 2, 30));
+ check("0100-03-02 00:00:00.000Z", new DateTime.utc(99, 2 + 12, 30));
+
+ check("0004-03-01 00:00:00.000Z", new DateTime.utc(3, 2 + 12, 30));
+ check("0004-03-01 00:00:00.000Z", new DateTime.utc(4, 2, 30));
+ check("0004-03-01 00:00:00.000Z", new DateTime.utc(5, 2 - 12, 30));
+
+ check("0005-03-02 00:00:00.000Z", new DateTime.utc(4, 2 + 12, 30));
+ check("0005-03-02 00:00:00.000Z", new DateTime.utc(5, 2, 30));
+ check("0005-03-02 00:00:00.000Z", new DateTime.utc(6, 2 - 12, 30));
+}
+
+testLocal() {
+ check("0099-01-01 00:00:00.000", new DateTime(99, 1));
+ check("0100-01-01 00:00:00.000", new DateTime(99, 1 + 12));
+ check("0000-01-01 00:00:00.000", new DateTime(0, 1));
+ check("-0001-01-01 00:00:00.000", new DateTime(0, 1 - 12));
+
+ check("0099-03-02 00:00:00.000", new DateTime(99, 2, 30));
+ check("0100-03-02 00:00:00.000", new DateTime(99, 2 + 12, 30));
+
+ check("0004-03-01 00:00:00.000", new DateTime(3, 2 + 12, 30));
+ check("0004-03-01 00:00:00.000", new DateTime(4, 2, 30));
+ check("0004-03-01 00:00:00.000", new DateTime(5, 2 - 12, 30));
+
+ check("0005-03-02 00:00:00.000", new DateTime(4, 2 + 12, 30));
+ check("0005-03-02 00:00:00.000", new DateTime(5, 2, 30));
+ check("0005-03-02 00:00:00.000", new DateTime(6, 2 - 12, 30));
+}
+
+main() {
+ testUtc();
+ testLocal();
+}
diff --git a/tests/corelib/date_time11_test.dart b/tests/corelib/date_time11_test.dart
new file mode 100644
index 0000000..0a1790c
--- /dev/null
+++ b/tests/corelib/date_time11_test.dart
@@ -0,0 +1,138 @@
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+// Make sure that date-times close to daylight savings work correctly.
+// See http://dartbug.com/30550
+
+/// A list of (decomposed) date-times where daylight saving changes
+/// happen.
+///
+/// This list covers multiple timezones to increase test coverage on
+/// different machines.
+final daylightSavingChanges = [
+ // TZ environment, y, m, d, h, change.
+ ["Europe/Paris", 2017, 03, 26, 02, 60],
+ ["Europe/Paris", 2017, 10, 29, 03, -60],
+ ["Antarctica/Troll", 2017, 03, 19, 01, 120],
+ ["Antarctica/Troll", 2017, 10, 29, 03, -120],
+ ["Australia/Canberra", 2017, 04, 02, 03, -60],
+ ["Australia/Canberra", 2017, 10, 01, 02, 60],
+ ["Australia/Lord_Howe", 2017, 04, 02, 02, -30],
+ ["Australia/Lord_Howe", 2017, 10, 01, 02, 30],
+ ["Atlantic/Bermuda", 2017, 03, 12, 02, 60], // US and Canada.
+ ["Atlantic/Bermuda", 2017, 11, 05, 02, -60],
+ ["America/Campo_Grande", 2017, 02, 19, 00, -60], // Brazil
+ ["America/Campo_Grande", 2017, 10, 15, 00, 60],
+ ["America/Santiago", 2017, 05, 14, 00, -60],
+ ["America/Santiago", 2017, 08, 13, 00, 60],
+ ["Chile/EasterIsland", 2017, 05, 13, 22, -60],
+ ["Chile/EasterIsland", 2017, 08, 12, 22, 60],
+ ["Pacific/Fiji", 2017, 01, 15, 03, -60],
+ ["Pacific/Fiji", 2017, 11, 05, 02, 60],
+ ["America/Scoresbysund", 2017, 03, 26, 00, 60], // Ittoqqortoormiit.
+ ["America/Scoresbysund", 2017, 10, 29, 01, -60],
+ ["Asia/Tehran", 2017, 03, 22, 00, 60],
+ ["Asia/Tehran", 2017, 09, 22, 00, -60],
+ ["Israel", 2017, 03, 24, 02, 60],
+ ["Israel", 2017, 10, 29, 02, -60],
+ ["Asia/Amman", 2017, 03, 31, 00, 60],
+ ["Asia/Amman", 2017, 10, 27, 01, -60],
+ ["Mexico/General", 2017, 04, 02, 02, 60],
+ ["Mexico/General", 2017, 10, 29, 02, -60],
+];
+
+void runTests() {
+ // Makes sure we don't go into the wrong direction during a
+ // daylight-savings change (as happened in #30550).
+ for (var test in daylightSavingChanges) {
+ for (int i = 0; i < 2; i++) {
+ var year = test[1] as int;
+ var month = test[2] as int;
+ var day = test[3] as int;
+ var hour = test[4] as int;
+
+ var minute = i == 0 ? 0 : test[5] as int;
+ // Rather adjust the hours than keeping the minutes.
+ hour += minute ~/ 60;
+ minute = minute.remainder(60) as int;
+ if (hour < 0) {
+ hour += 24;
+ day--;
+ }
+
+ {
+ // Check that microseconds are taken into account.
+ var dtMillisecond = new DateTime(year, month, day, hour, minute, 0, 1);
+ var dtSecond = new DateTime(year, month, day, hour, minute, 1);
+ Expect.equals(const Duration(milliseconds: 999),
+ dtSecond.difference(dtMillisecond));
+
+ dtMillisecond = new DateTime(year, month, day, hour, minute, 0, -1);
+ dtSecond = new DateTime(year, month, day, hour, minute, -1);
+ Expect.equals(const Duration(milliseconds: 999),
+ dtMillisecond.difference(dtSecond));
+ }
+
+ var dt1 = new DateTime(year, month, day, hour);
+ var dt2 = new DateTime(year, month, day, hour, 1);
+
+ // Earlier:
+ int earlierDay = day;
+ int earlierHour = hour - 1;
+ if (earlierHour < 0) {
+ earlierHour = 23;
+ earlierDay--;
+ }
+ var dt3 = new DateTime(year, month, earlierDay, earlierHour, 59);
+
+ var diff1 = dt2.difference(dt1).inMinutes;
+ var diff2 = dt1.difference(dt3).inMinutes;
+
+ if (diff1 == 1 && diff2 == 1 && dt1.hour == hour && dt1.minute == 0) {
+ // Regular date-time.
+ continue;
+ }
+
+ // At most one is at a distance of more than a minute.
+ Expect.isTrue(diff1 == 1 || diff2 == 1);
+
+ if (diff2 < 0) {
+ // This happens, when we ask for invalid times.
+ // Suppose daylight-saving is at 2:00 and switches to 3:00. If we
+ // ask for 2:59, we get 3:59 (59 minutes after 2:00).
+ Expect.isFalse(dt3.day == earlierDay && dt3.hour == earlierHour);
+ // If that's the case, then removing one minute from dt1 should
+ // not yield a date-time with the earlier values, and it should
+ // be far away from dt3.
+ var dt4 = dt1.add(const Duration(minutes: -1));
+ Expect.isFalse(dt4.day == earlierDay && dt4.hour == earlierHour);
+ Expect.isTrue(dt4.isBefore(dt1));
+ Expect.isTrue(dt4.day < earlierDay ||
+ (dt4.day == earlierDay && dt4.hour < earlierHour));
+ continue;
+ }
+
+ // They must be in the right order.
+ Expect.isTrue(dt1.isBefore(dt2));
+ Expect.isTrue(dt3.isBefore(dt1));
+ }
+ }
+}
+
+void main(List<String> args) {
+ // The following code constructs a String with all timezones that are
+ // relevant for this test.
+ // This can be helpful for running tests in multiple timezones.
+ // Typically, one would write something like:
+ // for tz in <contents_of_string>; do TZ=$tz tools/test.py ...; done
+ var result = new StringBuffer();
+ for (int i = 0; i < daylightSavingChanges.length; i += 2) {
+ if (i != 0) result.write(" ");
+ result.write(daylightSavingChanges[i][0]);
+ }
+
+ runTests();
+}
diff --git a/tests/corelib/date_time2_test.dart b/tests/corelib/date_time2_test.dart
new file mode 100644
index 0000000..6a0bb87
--- /dev/null
+++ b/tests/corelib/date_time2_test.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Dart test program for DateTime's hashCode.
+
+main() {
+ var d = DateTime.parse("2000-01-01T00:00:00Z");
+ var d2 = DateTime.parse("2000-01-01T00:00:01Z");
+ // There is no guarantee that the hashcode for these two dates is different,
+ // but in the worst case we will have to fix this test.
+ // The important test here is, that DateTime .
+ Expect.isFalse(d.hashCode == d2.hashCode);
+}
diff --git a/tests/corelib/date_time3_test.dart b/tests/corelib/date_time3_test.dart
new file mode 100644
index 0000000..557eede
--- /dev/null
+++ b/tests/corelib/date_time3_test.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// At some point dart was emitting a bad padding 0 for Dates where the ms were
+// ending with 10.
+
+main() {
+ String s = "2012-01-30 08:30:00.010";
+ DateTime d = DateTime.parse(s);
+ Expect.equals(s, d.toString());
+}
diff --git a/tests/corelib/date_time4_test.dart b/tests/corelib/date_time4_test.dart
new file mode 100644
index 0000000..4342019
--- /dev/null
+++ b/tests/corelib/date_time4_test.dart
@@ -0,0 +1,104 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Test fromString with 6 digits after the decimal point.
+
+bool get supportsMicroseconds =>
+ new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
+
+main() {
+ if (supportsMicroseconds) {
+ testMicrosecondPrecision();
+ } else {
+ testMillisecondPrecision();
+ }
+}
+
+void testMillisecondPrecision() {
+ // We only support milliseconds. If the user supplies more data (the "51"
+ // here), we round.
+ DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519");
+ Expect.equals(1999, dt1.year);
+ Expect.equals(1, dt1.month);
+ Expect.equals(3, dt1.day);
+ Expect.equals(0, dt1.hour);
+ Expect.equals(0, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(0, dt1.millisecond);
+ Expect.equals(false, dt1.isUtc);
+ dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z");
+ Expect.equals(1999, dt1.year);
+ Expect.equals(1, dt1.month);
+ Expect.equals(2, dt1.day);
+ Expect.equals(23, dt1.hour);
+ Expect.equals(59, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(0, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(9, dt1.day);
+ Expect.equals(9, dt1.hour);
+ Expect.equals(9, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+ String svnDate = "2012-03-30T04:28:13.752341Z";
+ dt1 = DateTime.parse(svnDate);
+ Expect.equals(2012, dt1.year);
+ Expect.equals(3, dt1.month);
+ Expect.equals(30, dt1.day);
+ Expect.equals(4, dt1.hour);
+ Expect.equals(28, dt1.minute);
+ Expect.equals(13, dt1.second);
+ Expect.equals(752, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+}
+
+void testMicrosecondPrecision() {
+ DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519");
+ Expect.equals(1999, dt1.year);
+ Expect.equals(1, dt1.month);
+ Expect.equals(2, dt1.day);
+ Expect.equals(23, dt1.hour);
+ Expect.equals(59, dt1.minute);
+ Expect.equals(59, dt1.second);
+ Expect.equals(999, dt1.millisecond);
+ Expect.equals(519, dt1.microsecond);
+ Expect.equals(false, dt1.isUtc);
+ dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z");
+ Expect.equals(1999, dt1.year);
+ Expect.equals(1, dt1.month);
+ Expect.equals(2, dt1.day);
+ Expect.equals(23, dt1.hour);
+ Expect.equals(58, dt1.minute);
+ Expect.equals(59, dt1.second);
+ Expect.equals(999, dt1.millisecond);
+ Expect.equals(519, dt1.microsecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(9, dt1.day);
+ Expect.equals(9, dt1.hour);
+ Expect.equals(9, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(411, dt1.microsecond);
+ Expect.equals(true, dt1.isUtc);
+ String svnDate = "2012-03-30T04:28:13.752341Z";
+ dt1 = DateTime.parse(svnDate);
+ Expect.equals(2012, dt1.year);
+ Expect.equals(3, dt1.month);
+ Expect.equals(30, dt1.day);
+ Expect.equals(4, dt1.hour);
+ Expect.equals(28, dt1.minute);
+ Expect.equals(13, dt1.second);
+ Expect.equals(752, dt1.millisecond);
+ Expect.equals(341, dt1.microsecond);
+ Expect.equals(true, dt1.isUtc);
+}
diff --git a/tests/corelib/date_time5_test.dart b/tests/corelib/date_time5_test.dart
new file mode 100644
index 0000000..abf893d
--- /dev/null
+++ b/tests/corelib/date_time5_test.dart
@@ -0,0 +1,81 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Test DateTime constructor with optional arguments.
+
+main() {
+ var d = new DateTime(2012);
+ Expect.equals(2012, d.year);
+ Expect.equals(1, d.month);
+ Expect.equals(1, d.day);
+ Expect.equals(0, d.hour);
+ Expect.equals(0, d.minute);
+ Expect.equals(0, d.second);
+ Expect.equals(0, d.millisecond);
+
+ d = new DateTime(2012, 1, 28);
+ Expect.equals(2012, d.year);
+ Expect.equals(1, d.month);
+ Expect.equals(28, d.day);
+ Expect.equals(0, d.hour);
+ Expect.equals(0, d.minute);
+ Expect.equals(0, d.second);
+ Expect.equals(0, d.millisecond);
+
+ d = new DateTime(1970, 3);
+ Expect.equals(1970, d.year);
+ Expect.equals(3, d.month);
+ Expect.equals(1, d.day);
+ Expect.equals(0, d.hour);
+ Expect.equals(0, d.minute);
+ Expect.equals(0, d.second);
+ Expect.equals(0, d.millisecond);
+
+ d = new DateTime(1970, 3, 1, 11);
+ Expect.equals(1970, d.year);
+ Expect.equals(3, d.month);
+ Expect.equals(1, d.day);
+ Expect.equals(11, d.hour);
+ Expect.equals(0, d.minute);
+ Expect.equals(0, d.second);
+ Expect.equals(0, d.millisecond);
+
+ d = new DateTime(0, 12, 24, 0, 12);
+ Expect.equals(0, d.year);
+ Expect.equals(12, d.month);
+ Expect.equals(24, d.day);
+ Expect.equals(0, d.hour);
+ Expect.equals(12, d.minute);
+ Expect.equals(0, d.second);
+ Expect.equals(0, d.millisecond);
+
+ d = new DateTime(-1, 2, 2, 3, 0, 0, 4);
+ Expect.equals(-1, d.year);
+ Expect.equals(2, d.month);
+ Expect.equals(2, d.day);
+ Expect.equals(3, d.hour);
+ Expect.equals(0, d.minute);
+ Expect.equals(0, d.second);
+ Expect.equals(4, d.millisecond);
+
+ d = new DateTime(-1, 2, 2, 3, 0, 4);
+ Expect.equals(-1, d.year);
+ Expect.equals(2, d.month);
+ Expect.equals(2, d.day);
+ Expect.equals(3, d.hour);
+ Expect.equals(0, d.minute);
+ Expect.equals(4, d.second);
+ Expect.equals(0, d.millisecond);
+
+ d = new DateTime(2012, 5, 15, 13, 21, 33, 12);
+ Expect.equals(2012, d.year);
+ Expect.equals(5, d.month);
+ Expect.equals(15, d.day);
+ Expect.equals(13, d.hour);
+ Expect.equals(21, d.minute);
+ Expect.equals(33, d.second);
+ Expect.equals(12, d.millisecond);
+}
diff --git a/tests/corelib/date_time6_test.dart b/tests/corelib/date_time6_test.dart
new file mode 100644
index 0000000..c065705
--- /dev/null
+++ b/tests/corelib/date_time6_test.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Test DateTime comparison operators.
+
+main() {
+ var d = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
+ var d2 = new DateTime.fromMillisecondsSinceEpoch(1, isUtc: true);
+ Expect.isTrue(d.isBefore(d2));
+ Expect.isTrue(!d.isAfter(d2));
+ Expect.isTrue(d2.isAfter(d));
+ Expect.isTrue(!d2.isBefore(d));
+ Expect.isFalse(d2.isBefore(d));
+ Expect.isFalse(!d2.isAfter(d));
+ Expect.isFalse(d.isAfter(d2));
+ Expect.isFalse(!d.isBefore(d2));
+
+ d = new DateTime.fromMillisecondsSinceEpoch(-1, isUtc: true);
+ d2 = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
+ Expect.isTrue(d.isBefore(d2));
+ Expect.isTrue(!d.isAfter(d2));
+ Expect.isTrue(d2.isAfter(d));
+ Expect.isTrue(!d2.isBefore(d));
+ Expect.isFalse(d2.isBefore(d));
+ Expect.isFalse(!d2.isAfter(d));
+ Expect.isFalse(d.isAfter(d2));
+ Expect.isFalse(!d.isBefore(d2));
+}
diff --git a/tests/corelib/date_time7_test.dart b/tests/corelib/date_time7_test.dart
new file mode 100644
index 0000000..b14eb7d
--- /dev/null
+++ b/tests/corelib/date_time7_test.dart
@@ -0,0 +1,50 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Test DateTime timeZoneName and timeZoneOffset getters.
+
+testUtc() {
+ var d = DateTime.parse("2012-03-04T03:25:38.123Z");
+ Expect.equals("UTC", d.timeZoneName);
+ Expect.equals(0, d.timeZoneOffset.inSeconds);
+}
+
+testLocal() {
+ checkOffset(String name, Duration offset) {
+ // Timezone abbreviations are not in bijection with their timezones.
+ // For example AST stands for "Arab Standard Time" (UTC+03), as well as
+ // "Arabian Standard Time" (UTC+04), or PST stands for Pacific Standard Time
+ // and Philippine Standard Time.
+ //
+ // Hardcode some common timezones.
+ if (name == "CET") {
+ Expect.equals(1, offset.inHours);
+ } else if (name == "CEST") {
+ Expect.equals(2, offset.inHours);
+ } else if (name == "GMT") {
+ Expect.equals(0, offset.inSeconds);
+ } else if (name == "EST") {
+ Expect.equals(-5, offset.inHours);
+ } else if (name == "EDT") {
+ Expect.equals(-4, offset.inHours);
+ } else if (name == "PDT") {
+ Expect.equals(-7, offset.inHours);
+ }
+ }
+
+ var d = DateTime.parse("2012-01-02T13:45:23");
+ String name = d.timeZoneName;
+ checkOffset(name, d.timeZoneOffset);
+
+ d = DateTime.parse("2012-07-02T13:45:23");
+ name = d.timeZoneName;
+ checkOffset(name, d.timeZoneOffset);
+}
+
+main() {
+ testUtc();
+ testLocal();
+}
diff --git a/tests/corelib/date_time8_test.dart b/tests/corelib/date_time8_test.dart
new file mode 100644
index 0000000..85d573f
--- /dev/null
+++ b/tests/corelib/date_time8_test.dart
@@ -0,0 +1,22 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Make sure the year 0 is correctly printed.
+
+testUtc() {
+ var d = new DateTime.utc(0, 1, 1);
+ Expect.equals("0000-01-01 00:00:00.000Z", d.toString());
+}
+
+testLocal() {
+ var d = new DateTime(0, 1, 1);
+ Expect.equals("0000-01-01 00:00:00.000", d.toString());
+}
+
+main() {
+ testUtc();
+ testLocal();
+}
diff --git a/tests/corelib/date_time9_test.dart b/tests/corelib/date_time9_test.dart
new file mode 100644
index 0000000..9475775
--- /dev/null
+++ b/tests/corelib/date_time9_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ var dt = new DateTime.now();
+ Expect.isTrue(dt is Comparable);
+
+ var dt2 = new DateTime.fromMillisecondsSinceEpoch(100);
+ var dt3 = new DateTime.fromMillisecondsSinceEpoch(200, isUtc: true);
+ var dt3b = new DateTime.fromMillisecondsSinceEpoch(200);
+ var dt4 = new DateTime.fromMillisecondsSinceEpoch(300);
+ var dt5 = new DateTime.fromMillisecondsSinceEpoch(400, isUtc: true);
+ var dt5b = new DateTime.fromMillisecondsSinceEpoch(400);
+
+ Expect.isTrue(dt2.compareTo(dt2) == 0);
+ Expect.isTrue(dt3.compareTo(dt3) == 0);
+ Expect.isTrue(dt3b.compareTo(dt3b) == 0);
+ Expect.isTrue(dt4.compareTo(dt4) == 0);
+ Expect.isTrue(dt5.compareTo(dt5) == 0);
+ Expect.isTrue(dt5b.compareTo(dt5b) == 0);
+
+ // Time zones don't have any effect.
+ Expect.isTrue(dt3.compareTo(dt3b) == 0);
+ Expect.isTrue(dt5.compareTo(dt5b) == 0);
+
+ Expect.isTrue(dt2.compareTo(dt3) < 0);
+ Expect.isTrue(dt3.compareTo(dt4) < 0);
+ Expect.isTrue(dt4.compareTo(dt5) < 0);
+
+ Expect.isTrue(dt2.compareTo(dt3b) < 0);
+ Expect.isTrue(dt4.compareTo(dt5b) < 0);
+
+ Expect.isTrue(dt3.compareTo(dt2) > 0);
+ Expect.isTrue(dt4.compareTo(dt3) > 0);
+ Expect.isTrue(dt5.compareTo(dt4) > 0);
+
+ Expect.isTrue(dt3b.compareTo(dt2) > 0);
+ Expect.isTrue(dt5b.compareTo(dt4) > 0);
+}
diff --git a/tests/corelib/date_time_extremes_test.dart b/tests/corelib/date_time_extremes_test.dart
new file mode 100644
index 0000000..05563d1
--- /dev/null
+++ b/tests/corelib/date_time_extremes_test.dart
@@ -0,0 +1,99 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Dart test program for DateTime, extreme values.
+
+bool get supportsMicroseconds =>
+ new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
+
+// Identical to _maxMillisecondsSinceEpoch in date_time.dart
+const int _MAX_MILLISECONDS = 8640000000000000;
+
+void testExtremes() {
+ var dt =
+ new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS, isUtc: true);
+ Expect.equals(275760, dt.year);
+ Expect.equals(9, dt.month);
+ Expect.equals(13, dt.day);
+ Expect.equals(0, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS, isUtc: true);
+ Expect.equals(-271821, dt.year);
+ Expect.equals(4, dt.month);
+ Expect.equals(20, dt.day);
+ Expect.equals(0, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ // Make sure that we can build the extreme dates in local too.
+ dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS);
+ dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute);
+ Expect.equals(_MAX_MILLISECONDS, dt.millisecondsSinceEpoch);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS);
+ dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute);
+ Expect.equals(-_MAX_MILLISECONDS, dt.millisecondsSinceEpoch);
+ Expect.throws(() => new DateTime.fromMillisecondsSinceEpoch(
+ _MAX_MILLISECONDS + 1,
+ isUtc: true));
+ Expect.throws(() => new DateTime.fromMillisecondsSinceEpoch(
+ -_MAX_MILLISECONDS - 1,
+ isUtc: true));
+ Expect.throws(
+ () => new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS + 1));
+ Expect.throws(
+ () => new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS - 1));
+ dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS);
+ Expect.throws(
+ () => new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 1));
+ dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS, isUtc: true);
+ Expect.throws(() =>
+ new DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 1));
+ dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS);
+ Expect.throws(
+ () => new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, -1));
+ dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS, isUtc: true);
+ Expect.throws(() =>
+ new DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, -1));
+
+ if (!supportsMicroseconds) return;
+
+ dt = new DateTime.fromMicrosecondsSinceEpoch(_MAX_MILLISECONDS * 1000);
+ dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute);
+ Expect.equals(_MAX_MILLISECONDS * 1000, dt.microsecondsSinceEpoch);
+ dt = new DateTime.fromMicrosecondsSinceEpoch(-_MAX_MILLISECONDS * 1000);
+ dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute);
+ Expect.equals(-_MAX_MILLISECONDS * 1000, dt.microsecondsSinceEpoch);
+ Expect.throws(() => new DateTime.fromMicrosecondsSinceEpoch(
+ _MAX_MILLISECONDS * 1000 + 1,
+ isUtc: true));
+ Expect.throws(() => new DateTime.fromMicrosecondsSinceEpoch(
+ -_MAX_MILLISECONDS * 1000 - 1,
+ isUtc: true));
+ Expect.throws(() =>
+ new DateTime.fromMicrosecondsSinceEpoch(_MAX_MILLISECONDS * 1000 + 1));
+ Expect.throws(() =>
+ new DateTime.fromMicrosecondsSinceEpoch(-_MAX_MILLISECONDS * 1000 - 1));
+ dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS);
+ Expect.throws(() =>
+ new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, 1));
+ dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS, isUtc: true);
+ Expect.throws(() =>
+ new DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, 1));
+ dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS);
+ Expect.throws(() =>
+ new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, -1));
+ dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS, isUtc: true);
+ Expect.throws(() => new DateTime.utc(
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, -1));
+}
+
+void main() {
+ testExtremes();
+}
diff --git a/tests/corelib/date_time_far_away_dates_test.dart b/tests/corelib/date_time_far_away_dates_test.dart
new file mode 100644
index 0000000..ba7104f
--- /dev/null
+++ b/tests/corelib/date_time_far_away_dates_test.dart
@@ -0,0 +1,107 @@
+// Copyright (c) 2019, 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.
+
+import "package:expect/expect.dart";
+
+// Dart test program for DateTime, far away dates.
+
+// TODO(37442): Find far-away dates with milliseconds-since-epoch values that
+// are 'web' integers.
+
+bool get supportsMicroseconds =>
+ new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
+
+void testFarAwayDates() {
+ DateTime dt =
+ new DateTime.fromMillisecondsSinceEpoch(1000000000000001, isUtc: true);
+ Expect.equals(33658, dt.year);
+ Expect.equals(9, dt.month);
+ Expect.equals(27, dt.day);
+ Expect.equals(1, dt.hour);
+ Expect.equals(46, dt.minute);
+ Expect.equals(40, dt.second);
+ Expect.equals(1, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-1000000000000001, isUtc: true);
+ Expect.equals(-29719, dt.year);
+ Expect.equals(4, dt.month);
+ Expect.equals(5, dt.day);
+ Expect.equals(22, dt.hour);
+ Expect.equals(13, dt.minute);
+ Expect.equals(19, dt.second);
+ Expect.equals(999, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ // Same with local zone.
+ dt = new DateTime.fromMillisecondsSinceEpoch(1000000000000001);
+ Expect.equals(33658, dt.year);
+ Expect.equals(9, dt.month);
+ Expect.equals(true, dt.day == 27 || dt.day == 26);
+ // Not much we can test for local hour.
+ Expect.equals(true, dt.hour >= 0 && dt.hour < 24);
+ // Timezones can have offsets down to 15 minute.
+ Expect.equals(true, dt.minute % 15 == 46 % 15);
+ Expect.equals(40, dt.second);
+ Expect.equals(1, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-1000000000000001);
+ Expect.equals(-29719, dt.year);
+ Expect.equals(4, dt.month);
+ Expect.equals(true, 5 == dt.day || 6 == dt.day);
+ // Not much we can test for local hour.
+ Expect.equals(true, dt.hour >= 0 && dt.hour < 24);
+ // Timezones can have offsets down to 15 minute.
+ Expect.equals(true, dt.minute % 15 == 13);
+ Expect.equals(19, dt.second);
+ Expect.equals(999, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+
+ if (!supportsMicroseconds) return;
+ dt =
+ new DateTime.fromMicrosecondsSinceEpoch(1000000000000000001, isUtc: true);
+ Expect.equals(33658, dt.year);
+ Expect.equals(9, dt.month);
+ Expect.equals(27, dt.day);
+ Expect.equals(1, dt.hour);
+ Expect.equals(46, dt.minute);
+ Expect.equals(40, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(1, dt.microsecond);
+ dt = new DateTime.fromMicrosecondsSinceEpoch(-1000000000000000001,
+ isUtc: true);
+ Expect.equals(-29719, dt.year);
+ Expect.equals(4, dt.month);
+ Expect.equals(5, dt.day);
+ Expect.equals(22, dt.hour);
+ Expect.equals(13, dt.minute);
+ Expect.equals(19, dt.second);
+ Expect.equals(999, dt.millisecond);
+ Expect.equals(999, dt.microsecond);
+ // Same with local zone.
+ dt = new DateTime.fromMicrosecondsSinceEpoch(1000000000000000001);
+ Expect.equals(33658, dt.year);
+ Expect.equals(9, dt.month);
+ Expect.equals(true, dt.day == 27 || dt.day == 26);
+ // Not much we can test for local hour.
+ Expect.equals(true, dt.hour >= 0 && dt.hour < 24);
+ // Timezones can have offsets down to 15 minute.
+ Expect.equals(true, dt.minute % 15 == 46 % 15);
+ Expect.equals(40, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(1, dt.microsecond);
+ dt = new DateTime.fromMicrosecondsSinceEpoch(-1000000000000000001);
+ Expect.equals(-29719, dt.year);
+ Expect.equals(4, dt.month);
+ Expect.equals(true, 5 == dt.day || 6 == dt.day);
+ // Not much we can test for local hour.
+ Expect.equals(true, dt.hour >= 0 && dt.hour < 24);
+ // Timezones can have offsets down to 15 minute.
+ Expect.equals(true, dt.minute % 15 == 13);
+ Expect.equals(19, dt.second);
+ Expect.equals(999, dt.millisecond);
+ Expect.equals(999, dt.microsecond);
+}
+
+void main() {
+ testFarAwayDates();
+}
diff --git a/tests/corelib/date_time_parse_test.dart b/tests/corelib/date_time_parse_test.dart
new file mode 100644
index 0000000..23b8b02
--- /dev/null
+++ b/tests/corelib/date_time_parse_test.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+check(DateTime expected, String str) {
+ DateTime actual = DateTime.parse(str);
+ Expect.equals(expected, actual); // Only checks if they are at the same time.
+ Expect.equals(expected.isUtc, actual.isUtc);
+}
+
+bool get supportsMicroseconds =>
+ new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
+
+main() {
+ check(new DateTime(2012, 02, 27, 13, 27), "2012-02-27 13:27:00");
+ if (supportsMicroseconds) {
+ check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456),
+ "2012-02-27 13:27:00.1234567891234z");
+ check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456),
+ "2012-02-27 13:27:00,1234567891234z");
+ } else {
+ check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 0),
+ "2012-02-27 13:27:00.1234567891234z");
+ check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 0),
+ "2012-02-27 13:27:00,1234567891234z");
+ }
+ check(new DateTime(2012, 02, 27, 13, 27), "20120227 13:27:00");
+ check(new DateTime(2012, 02, 27, 13, 27), "20120227T132700");
+ check(new DateTime(2012, 02, 27), "20120227");
+ check(new DateTime(2012, 02, 27), "+20120227");
+ check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14Z");
+ check(new DateTime.utc(-12345, 1, 1), "-123450101 00:00:00 Z");
+ check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+00");
+ check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+0000");
+ check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+00:00");
+ check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14 +00:00");
+
+ check(new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00+11");
+ check(new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00:00+11");
+ check(
+ new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00:00+11:00");
+
+ if (supportsMicroseconds) {
+ check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 500, 500),
+ "2015-02-15T00:00:00.500500Z");
+ check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 511, 500),
+ "2015-02-15T00:00:00.511500Z");
+ } else {
+ check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 501),
+ "2015-02-15T00:00:00.501Z");
+ check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 512),
+ "2015-02-15T00:00:00.512Z");
+ }
+}
diff --git a/tests/corelib/date_time_test.dart b/tests/corelib/date_time_test.dart
new file mode 100644
index 0000000..e782ca5
--- /dev/null
+++ b/tests/corelib/date_time_test.dart
@@ -0,0 +1,1206 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Dart test program for DateTime.
+
+bool get supportsMicroseconds =>
+ new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
+
+// Identical to _maxMillisecondsSinceEpoch in date_time.dart
+const int _MAX_MILLISECONDS = 8640000000000000;
+
+// Tests if the time moves eventually forward.
+void testNow() {
+ var t1 = new DateTime.now();
+ bool timeMovedForward = false;
+ const int N = 1000000;
+ outer:
+ while (true) {
+ for (int i = N; i > 0; i--) {
+ var t2 = new DateTime.now();
+ if (t1.millisecondsSinceEpoch < t2.millisecondsSinceEpoch) {
+ break outer;
+ }
+ }
+ print("testNow: No Date.now() progress in $N loops. Time: $t1");
+ }
+ Expect.isFalse(t1.isUtc);
+}
+
+void testMillisecondsSinceEpoch() {
+ var dt1 = new DateTime.now();
+ var millisecondsSinceEpoch = dt1.millisecondsSinceEpoch;
+ var dt2 = new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch);
+ Expect.equals(millisecondsSinceEpoch, dt2.millisecondsSinceEpoch);
+}
+
+void testMicrosecondsSinceEpoch() {
+ var dt1 = new DateTime.fromMillisecondsSinceEpoch(1);
+ var microsecondsSinceEpoch = dt1.microsecondsSinceEpoch;
+ var dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch);
+ Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch);
+
+ dt1 = new DateTime.now();
+ microsecondsSinceEpoch = dt1.microsecondsSinceEpoch;
+ dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch);
+ Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch);
+}
+
+void testEquivalentYears() {
+ // All hardcoded values come from V8. This means that the values are not
+ // necessarily correct (see limitations of DateTime object in
+ // EcmaScript 15.9.1 and in particular 15.9.1.8/9).
+ DateTime dt =
+ new DateTime.fromMillisecondsSinceEpoch(-31485600000, isUtc: true);
+ Expect.equals(1969, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(14, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-63108000000, isUtc: true);
+ Expect.equals(1968, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(14, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-94644000000, isUtc: true);
+ Expect.equals(1967, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(14, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-126180000000, isUtc: true);
+ Expect.equals(1966, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(14, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-157716000000, isUtc: true);
+ Expect.equals(1965, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(14, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-2177402400000, isUtc: true);
+ Expect.equals(1901, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(14, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-5333076000000, isUtc: true);
+ Expect.equals(1801, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(14, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-8520285600000, isUtc: true);
+ Expect.equals(1700, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(14, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-14831719200000, isUtc: true);
+ Expect.equals(1500, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(14, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-59011408800000, isUtc: true);
+ Expect.equals(100, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(14, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-62011408800000, isUtc: true);
+ Expect.equals(4, dt.year);
+ Expect.equals(12, dt.month);
+ Expect.equals(8, dt.day);
+ Expect.equals(8, dt.hour);
+ Expect.equals(40, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-64011408800000, isUtc: true);
+ Expect.equals(-59, dt.year);
+ Expect.equals(7, dt.month);
+ Expect.equals(24, dt.day);
+ Expect.equals(5, dt.hour);
+ Expect.equals(6, dt.minute);
+ Expect.equals(40, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ final int SECONDS_YEAR_2035 = 2051222400;
+ dt = new DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 + 1,
+ isUtc: true);
+ Expect.equals(2035, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(0, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(1, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ dt = new DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 - 1,
+ isUtc: true);
+ Expect.equals(2034, dt.year);
+ Expect.equals(12, dt.month);
+ Expect.equals(31, dt.day);
+ Expect.equals(23, dt.hour);
+ Expect.equals(59, dt.minute);
+ Expect.equals(59, dt.second);
+ Expect.equals(999, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+
+ dt = new DateTime.utc(2035, 1, 1, 0, 0, 0, 1);
+ Expect.equals(SECONDS_YEAR_2035 * 1000 + 1, dt.millisecondsSinceEpoch);
+ dt = new DateTime.utc(2034, 12, 31, 23, 59, 59, 999);
+ Expect.equals(SECONDS_YEAR_2035 * 1000 - 1, dt.millisecondsSinceEpoch);
+ dt = new DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 + 1);
+ Expect.equals(
+ true,
+ (2035 == dt.year && 1 == dt.month && 1 == dt.day) ||
+ (2034 == dt.year && 12 == dt.month && 31 == dt.day));
+ Expect.equals(0, dt.second);
+ Expect.equals(1, dt.millisecond);
+ DateTime dt2 = new DateTime(
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.millisecond);
+ Expect.equals(dt.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch);
+ dt = new DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 - 1);
+ Expect.equals(
+ true,
+ (2035 == dt.year && 1 == dt.month && 1 == dt.day) ||
+ (2034 == dt.year && 12 == dt.month && 31 == dt.day));
+ Expect.equals(59, dt.second);
+ Expect.equals(999, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+
+ dt2 = new DateTime(
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.millisecond);
+ Expect.equals(dt.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch);
+ dt = new DateTime.fromMillisecondsSinceEpoch(2100000000 * 1000, isUtc: true);
+ Expect.equals(2036, dt.year);
+ Expect.equals(7, dt.month);
+ Expect.equals(18, dt.day);
+ Expect.equals(13, dt.hour);
+ Expect.equals(20, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+
+ // Internally this will use the maximum value for the native calls.
+ dt = new DateTime(2036, 7, 18, 13, 20);
+ Expect.equals(2036, dt.year);
+ Expect.equals(7, dt.month);
+ Expect.equals(18, dt.day);
+ Expect.equals(13, dt.hour);
+ Expect.equals(20, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ Expect.equals("2036-07-18 13:20:00.000", dt.toString());
+
+ if (!supportsMicroseconds) return;
+
+ dt = new DateTime.utc(2035, 1, 1, 0, 0, 0, 0, 1);
+ Expect.equals(SECONDS_YEAR_2035 * 1000000 + 1, dt.microsecondsSinceEpoch);
+ dt = new DateTime.utc(2034, 12, 31, 23, 59, 59, 999, 999);
+ Expect.equals(SECONDS_YEAR_2035 * 1000000 - 1, dt.microsecondsSinceEpoch);
+ dt = new DateTime.fromMicrosecondsSinceEpoch(SECONDS_YEAR_2035 * 1000000 + 1);
+ Expect.equals(
+ true,
+ (2035 == dt.year && 1 == dt.month && 1 == dt.day) ||
+ (2034 == dt.year && 12 == dt.month && 31 == dt.day));
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(1, dt.microsecond);
+ dt2 = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
+ dt.millisecond, dt.microsecond);
+ Expect.equals(dt.microsecondsSinceEpoch, dt2.microsecondsSinceEpoch);
+ dt = new DateTime.fromMicrosecondsSinceEpoch(SECONDS_YEAR_2035 * 1000000 - 1);
+ Expect.equals(
+ true,
+ (2035 == dt.year && 1 == dt.month && 1 == dt.day) ||
+ (2034 == dt.year && 12 == dt.month && 31 == dt.day));
+ Expect.equals(59, dt.second);
+ Expect.equals(999, dt.millisecond);
+ Expect.equals(999, dt.microsecond);
+
+ dt2 = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
+ dt.millisecond, dt.microsecond);
+ Expect.equals(dt.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch);
+ dt = new DateTime.fromMicrosecondsSinceEpoch(2100000000 * 1000000,
+ isUtc: true);
+ Expect.equals(2036, dt.year);
+ Expect.equals(7, dt.month);
+ Expect.equals(18, dt.day);
+ Expect.equals(13, dt.hour);
+ Expect.equals(20, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+}
+
+void testUTCGetters() {
+ var dt = new DateTime.fromMillisecondsSinceEpoch(1305140315000, isUtc: true);
+ Expect.equals(2011, dt.year);
+ Expect.equals(5, dt.month);
+ Expect.equals(11, dt.day);
+ Expect.equals(18, dt.hour);
+ Expect.equals(58, dt.minute);
+ Expect.equals(35, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+ Expect.equals(true, dt.isUtc);
+ Expect.equals(1305140315000, dt.millisecondsSinceEpoch);
+ dt = new DateTime.fromMillisecondsSinceEpoch(-9999999, isUtc: true);
+ Expect.equals(1969, dt.year);
+ Expect.equals(12, dt.month);
+ Expect.equals(31, dt.day);
+ Expect.equals(21, dt.hour);
+ Expect.equals(13, dt.minute);
+ Expect.equals(20, dt.second);
+ Expect.equals(1, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+
+ if (!supportsMicroseconds) return;
+
+ dt = new DateTime.fromMicrosecondsSinceEpoch(-9999999999, isUtc: true);
+ Expect.equals(1969, dt.year);
+ Expect.equals(12, dt.month);
+ Expect.equals(31, dt.day);
+ Expect.equals(21, dt.hour);
+ Expect.equals(13, dt.minute);
+ Expect.equals(20, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(1, dt.microsecond);
+}
+
+void testLocalGetters() {
+ var dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000);
+ var dt2 = new DateTime.utc(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute,
+ dt1.second, dt1.millisecond, dt1.microsecond);
+ Duration zoneOffset = dt1.difference(dt2);
+ Expect.equals(true, zoneOffset.inDays == 0);
+ Expect.equals(true, zoneOffset.inHours.abs() <= 12);
+ Expect.equals(dt1.year, dt2.year);
+ Expect.equals(dt1.month, dt2.month);
+ Expect.equals(true, (dt1.day - dt2.day).abs() <= 1);
+ Expect.equals(true, dt1.hour < 24);
+ // There are timezones with 0.5 or 0.25 hour offsets.
+ Expect.equals(
+ true,
+ (dt1.minute == dt2.minute) ||
+ ((dt1.minute - dt2.minute).abs() == 30) ||
+ ((dt1.minute - dt2.minute).abs() == 15));
+ Expect.equals(dt1.second, dt2.second);
+ Expect.equals(dt1.millisecond, dt2.millisecond);
+ Expect.equals(dt1.microsecond, dt2.microsecond);
+}
+
+void testConstructors() {
+ var dt0 = new DateTime.utc(2011, 5, 11, 18, 58, 35, 0, 0);
+ var dt0b = new DateTime.utc(2011, 5, 11, 18, 58, 35, 0, 0).toLocal();
+ Expect.equals(1305140315000, dt0.millisecondsSinceEpoch);
+ var dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000);
+ Expect.equals(dt1.millisecondsSinceEpoch, dt0.millisecondsSinceEpoch);
+ Expect.equals(dt1.microsecondsSinceEpoch, dt0.microsecondsSinceEpoch);
+ Expect.equals(false, dt1 == dt0);
+ Expect.equals(true, dt1 == dt0b);
+ var dt3 = new DateTime(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute,
+ dt1.second, dt1.millisecond, dt1.microsecond);
+ Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch);
+ Expect.equals(dt1.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch);
+ Expect.equals(false, dt3 == dt0);
+ Expect.equals(true, dt1 == dt3);
+ dt3 = new DateTime(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute,
+ dt1.second, dt1.millisecond, dt1.microsecond);
+ Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch);
+ Expect.equals(dt1.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch);
+ Expect.equals(true, dt1 == dt3);
+ var dt2 = dt1.toLocal();
+ dt3 = new DateTime(2011, 5, dt1.day, dt1.hour, dt1.minute, 35, 0, 0);
+ Expect.equals(dt2.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch);
+ Expect.equals(dt2.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch);
+ Expect.equals(true, dt2 == dt3);
+ dt1 = new DateTime.fromMillisecondsSinceEpoch(-9999999, isUtc: true);
+ dt3 = new DateTime.utc(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute,
+ dt1.second, dt1.millisecond);
+ Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch);
+ Expect.equals(dt1.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch);
+ dt3 = new DateTime.utc(99, 1, 2, 10, 11, 12, 0);
+ Expect.equals(99, dt3.year);
+ Expect.equals(1, dt3.month);
+ Expect.equals(2, dt3.day);
+ Expect.equals(10, dt3.hour);
+ Expect.equals(11, dt3.minute);
+ Expect.equals(12, dt3.second);
+ Expect.equals(0, dt3.millisecond);
+ Expect.equals(0, dt3.microsecond);
+ Expect.equals(true, dt3.isUtc);
+ var dt4 = new DateTime(99, 1, 2);
+ Expect.equals(99, dt4.year);
+ Expect.equals(1, dt4.month);
+ Expect.equals(2, dt4.day);
+ Expect.equals(0, dt4.hour);
+ Expect.equals(0, dt4.minute);
+ Expect.equals(0, dt4.second);
+ Expect.equals(0, dt4.millisecond);
+ Expect.equals(0, dt4.microsecond);
+ Expect.isFalse(dt4.isUtc);
+ var dt5 = new DateTime.utc(99, 1, 2);
+ Expect.equals(99, dt5.year);
+ Expect.equals(1, dt5.month);
+ Expect.equals(2, dt5.day);
+ Expect.equals(0, dt5.hour);
+ Expect.equals(0, dt5.minute);
+ Expect.equals(0, dt5.second);
+ Expect.equals(0, dt5.millisecond);
+ Expect.equals(0, dt5.microsecond);
+ Expect.isTrue(dt5.isUtc);
+ var dt6 = new DateTime(2012, 2, 27, 13, 27, 0);
+ Expect.equals(2012, dt6.year);
+ Expect.equals(2, dt6.month);
+ Expect.equals(27, dt6.day);
+ Expect.equals(13, dt6.hour);
+ Expect.equals(27, dt6.minute);
+ Expect.equals(0, dt6.second);
+ Expect.equals(0, dt6.millisecond);
+ Expect.equals(0, dt6.microsecond);
+ Expect.isFalse(dt6.isUtc);
+ var dt7 = new DateTime.utc(2012, 2, 27, 13, 27, 0);
+ Expect.equals(2012, dt7.year);
+ Expect.equals(2, dt7.month);
+ Expect.equals(27, dt7.day);
+ Expect.equals(13, dt7.hour);
+ Expect.equals(27, dt7.minute);
+ Expect.equals(0, dt7.second);
+ Expect.equals(0, dt7.millisecond);
+ Expect.equals(0, dt7.microsecond);
+ Expect.isTrue(dt7.isUtc);
+}
+
+void testChangeTimeZone() {
+ var dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000);
+ var dt2 = dt1.toUtc();
+ Expect.equals(dt1.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch);
+ var dt3 = new DateTime.fromMillisecondsSinceEpoch(1305140315000, isUtc: true);
+ Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch);
+ Expect.equals(dt2.year, dt3.year);
+ Expect.equals(dt2.month, dt3.month);
+ Expect.equals(dt2.day, dt3.day);
+ Expect.equals(dt2.hour, dt3.hour);
+ Expect.equals(dt2.minute, dt3.minute);
+ Expect.equals(dt2.second, dt3.second);
+ Expect.equals(dt2.millisecond, dt3.millisecond);
+ Expect.equals(dt2.microsecond, dt3.microsecond);
+ var dt4 = dt3.toLocal();
+ Expect.equals(dt1.year, dt4.year);
+ Expect.equals(dt1.month, dt4.month);
+ Expect.equals(dt1.day, dt4.day);
+ Expect.equals(dt1.hour, dt4.hour);
+ Expect.equals(dt1.minute, dt4.minute);
+ Expect.equals(dt1.second, dt4.second);
+ Expect.equals(dt1.millisecond, dt4.millisecond);
+ Expect.equals(dt1.microsecond, dt4.microsecond);
+}
+
+void testSubAdd() {
+ var dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000, isUtc: true);
+ var dt2 = dt1
+ .add(new Duration(milliseconds: 3 * Duration.millisecondsPerSecond + 5));
+ Expect.equals(dt1.year, dt2.year);
+ Expect.equals(dt1.month, dt2.month);
+ Expect.equals(dt1.day, dt2.day);
+ Expect.equals(dt1.hour, dt2.hour);
+ Expect.equals(dt1.minute, dt2.minute);
+ Expect.equals(dt1.second + 3, dt2.second);
+ Expect.equals(dt1.millisecond + 5, dt2.millisecond);
+ Expect.equals(dt1.microsecond, dt2.microsecond);
+ var dt3 = dt2.subtract(
+ new Duration(milliseconds: 3 * Duration.millisecondsPerSecond + 5));
+ Expect.equals(true, dt1 == dt3);
+ Expect.equals(false, dt1 == dt2);
+
+ if (!supportsMicroseconds) return;
+
+ dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000, isUtc: true);
+ dt2 = dt1
+ .add(new Duration(microseconds: 3 * Duration.microsecondsPerSecond + 5));
+ Expect.equals(dt1.year, dt2.year);
+ Expect.equals(dt1.month, dt2.month);
+ Expect.equals(dt1.day, dt2.day);
+ Expect.equals(dt1.hour, dt2.hour);
+ Expect.equals(dt1.minute, dt2.minute);
+ Expect.equals(dt1.second + 3, dt2.second);
+ Expect.equals(dt1.millisecond, dt2.millisecond);
+ Expect.equals(dt1.microsecond + 5, dt2.microsecond);
+ dt3 = dt2.subtract(
+ new Duration(microseconds: 3 * Duration.microsecondsPerSecond + 5));
+ Expect.equals(true, dt1 == dt3);
+ Expect.equals(false, dt1 == dt2);
+}
+
+void testUnderflowAndOverflow() {
+ int microsecond = supportsMicroseconds ? 499 : 0;
+ final dtBase = new DateTime(2012, 6, 20, 12, 30, 30, 500, microsecond);
+
+ // Millisecond
+ print(" >>> Millisecond+");
+ var dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour,
+ dtBase.minute, dtBase.second, 1000, dtBase.microsecond);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month, dt.month);
+ Expect.equals(dtBase.day, dt.day);
+ Expect.equals(dtBase.hour, dt.hour);
+ Expect.equals(dtBase.minute, dt.minute);
+ Expect.equals(dtBase.second + 1, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ print(" >>> Millisecond-");
+ dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour,
+ dtBase.minute, dtBase.second, -1000, dtBase.microsecond);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month, dt.month);
+ Expect.equals(dtBase.day, dt.day);
+ Expect.equals(dtBase.hour, dt.hour);
+ Expect.equals(dtBase.minute, dt.minute);
+ Expect.equals(dtBase.second - 1, dt.second);
+ Expect.equals(0, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ // Second
+ print(" >>> Second+");
+ dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour,
+ dtBase.minute, 60, dtBase.millisecond, dtBase.microsecond);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month, dt.month);
+ Expect.equals(dtBase.day, dt.day);
+ Expect.equals(dtBase.hour, dt.hour);
+ Expect.equals(dtBase.minute + 1, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(dtBase.millisecond, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ print(" >>> Second-");
+ dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour,
+ dtBase.minute, -60, dtBase.millisecond, dtBase.microsecond);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month, dt.month);
+ Expect.equals(dtBase.day, dt.day);
+ Expect.equals(dtBase.hour, dt.hour);
+ Expect.equals(dtBase.minute - 1, dt.minute);
+ Expect.equals(0, dt.second);
+ Expect.equals(dtBase.millisecond, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ // Minute
+ print(" >>> Minute+");
+ dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, 60,
+ dtBase.second, dtBase.millisecond, dtBase.microsecond);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month, dt.month);
+ Expect.equals(dtBase.day, dt.day);
+ Expect.equals(dtBase.hour + 1, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(dtBase.second, dt.second);
+ Expect.equals(dtBase.millisecond, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ print(" >>> Minute-");
+ dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, -60,
+ dtBase.second, dtBase.millisecond, dtBase.microsecond);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month, dt.month);
+ Expect.equals(dtBase.day, dt.day);
+ Expect.equals(dtBase.hour - 1, dt.hour);
+ Expect.equals(0, dt.minute);
+ Expect.equals(dtBase.second, dt.second);
+ Expect.equals(dtBase.millisecond, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ // Hour
+ print(" >>> Hour+");
+ dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, 24, dtBase.minute,
+ dtBase.second, dtBase.millisecond, dtBase.microsecond);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month, dt.month);
+ Expect.equals(dtBase.day + 1, dt.day);
+ Expect.equals(0, dt.hour);
+ Expect.equals(dtBase.minute, dt.minute);
+ Expect.equals(dtBase.second, dt.second);
+ Expect.equals(dtBase.millisecond, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ print(" >>> Hour-");
+ dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, -24, dtBase.minute,
+ dtBase.second, dtBase.millisecond, dtBase.microsecond);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month, dt.month);
+ Expect.equals(dtBase.day - 1, dt.day);
+ Expect.equals(0, dt.hour);
+ Expect.equals(dtBase.minute, dt.minute);
+ Expect.equals(dtBase.second, dt.second);
+ Expect.equals(dtBase.millisecond, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ // Day
+ print(" >>> Day+");
+ dt = new DateTime(dtBase.year, dtBase.month, 31, dtBase.hour, dtBase.minute,
+ dtBase.second, dtBase.millisecond, dtBase.microsecond);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month + 1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(dtBase.hour, dt.hour);
+ Expect.equals(dtBase.minute, dt.minute);
+ Expect.equals(dtBase.second, dt.second);
+ Expect.equals(dtBase.millisecond, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ print(" >>> Day-");
+ dt = new DateTime(dtBase.year, dtBase.month, -30, dtBase.hour, dtBase.minute,
+ dtBase.second, dtBase.millisecond, dtBase.microsecond);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month - 1, dt.month);
+ Expect.equals(1, dt.day);
+ Expect.equals(dtBase.hour, dt.hour);
+ Expect.equals(dtBase.minute, dt.minute);
+ Expect.equals(dtBase.second, dt.second);
+ Expect.equals(dtBase.millisecond, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ // Month
+ print(" >>> Month+");
+ dt = new DateTime(dtBase.year, 13, dtBase.day, dtBase.hour, dtBase.minute,
+ dtBase.second, dtBase.millisecond, dtBase.microsecond);
+ Expect.equals(dtBase.year + 1, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(dtBase.day, dt.day);
+ Expect.equals(dtBase.hour, dt.hour);
+ Expect.equals(dtBase.minute, dt.minute);
+ Expect.equals(dtBase.second, dt.second);
+ Expect.equals(dtBase.millisecond, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ print(" >>> Month-");
+ dt = new DateTime(dtBase.year, -11, dtBase.day, dtBase.hour, dtBase.minute,
+ dtBase.second, dtBase.millisecond, dtBase.microsecond);
+ Expect.equals(dtBase.year - 1, dt.year);
+ Expect.equals(1, dt.month);
+ Expect.equals(dtBase.day, dt.day);
+ Expect.equals(dtBase.hour, dt.hour);
+ Expect.equals(dtBase.minute, dt.minute);
+ Expect.equals(dtBase.second, dt.second);
+ Expect.equals(dtBase.millisecond, dt.millisecond);
+ Expect.equals(dtBase.microsecond, dt.microsecond);
+
+ // Flowing all the way up the chain.
+ print(" >>> Flow+");
+ var dtBase1 = new DateTime(2012, 12, 31, 23, 59, 59, 999, 000);
+ var dtTick = new DateTime(
+ dtBase1.year,
+ dtBase1.month,
+ dtBase1.day,
+ dtBase1.hour,
+ dtBase1.minute,
+ dtBase1.second,
+ dtBase1.millisecond + 1,
+ dtBase1.microsecond);
+ Expect.equals(dtBase1.year + 1, dtTick.year);
+ Expect.equals(1, dtTick.month);
+ Expect.equals(1, dtTick.day);
+ Expect.equals(0, dtTick.hour);
+ Expect.equals(0, dtTick.minute);
+ Expect.equals(0, dtTick.second);
+ Expect.equals(0, dtTick.millisecond);
+ Expect.equals(0, dtTick.microsecond);
+
+ print(" >>> Flow-");
+ dtBase1 = new DateTime(2012, 1, 1, 0, 0, 0, 0);
+ dtTick = new DateTime(
+ dtBase1.year,
+ dtBase1.month,
+ dtBase1.day,
+ dtBase1.hour,
+ dtBase1.minute,
+ dtBase1.second,
+ dtBase1.millisecond - 1,
+ dtBase1.microsecond);
+ Expect.equals(dtBase1.year - 1, dtTick.year);
+ Expect.equals(12, dtTick.month);
+ Expect.equals(31, dtTick.day);
+ Expect.equals(23, dtTick.hour);
+ Expect.equals(59, dtTick.minute);
+ Expect.equals(59, dtTick.second);
+ Expect.equals(999, dtTick.millisecond);
+ Expect.equals(0, dtTick.microsecond);
+
+ print(" >>> extra underflow");
+ dtTick = new DateTime(dtBase1.year, dtBase1.month, dtBase1.day, -17520,
+ dtBase1.minute, dtBase1.second, dtBase1.millisecond, dtBase1.microsecond);
+ Expect.equals(dtBase1.year - 2, dtTick.year);
+ Expect.equals(dtBase1.month, dtTick.month);
+ Expect.equals(dtBase1.day, dtTick.day);
+ Expect.equals(dtBase1.hour, dtTick.hour);
+ Expect.equals(dtBase1.minute, dtTick.minute);
+ Expect.equals(dtBase1.second, dtTick.second);
+ Expect.equals(dtBase1.millisecond, dtTick.millisecond);
+ Expect.equals(dtBase1.microsecond, dtTick.microsecond);
+
+ if (!supportsMicroseconds) return;
+
+ // Microsecond
+ print(" >>> Microsecond+");
+ dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour,
+ dtBase.minute, dtBase.second, dtBase.millisecond, 1000);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month, dt.month);
+ Expect.equals(dtBase.day, dt.day);
+ Expect.equals(dtBase.hour, dt.hour);
+ Expect.equals(dtBase.minute, dt.minute);
+ Expect.equals(dtBase.second, dt.second);
+ Expect.equals(dtBase.millisecond + 1, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+
+ print(" >>> Microsecond-");
+ dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour,
+ dtBase.minute, dtBase.second, dtBase.millisecond, -1000);
+ Expect.equals(dtBase.year, dt.year);
+ Expect.equals(dtBase.month, dt.month);
+ Expect.equals(dtBase.day, dt.day);
+ Expect.equals(dtBase.hour, dt.hour);
+ Expect.equals(dtBase.minute, dt.minute);
+ Expect.equals(dtBase.second, dt.second);
+ Expect.equals(dtBase.millisecond - 1, dt.millisecond);
+ Expect.equals(0, dt.microsecond);
+
+ // Flowing all the way up the chain.
+ print(" >>> Flow+ 2");
+ dtBase1 = new DateTime(2012, 12, 31, 23, 59, 59, 999, 999);
+ dtTick = new DateTime(
+ dtBase1.year,
+ dtBase1.month,
+ dtBase1.day,
+ dtBase1.hour,
+ dtBase1.minute,
+ dtBase1.second,
+ dtBase1.millisecond,
+ dtBase1.microsecond + 1);
+ Expect.equals(dtBase1.year + 1, dtTick.year);
+ Expect.equals(1, dtTick.month);
+ Expect.equals(1, dtTick.day);
+ Expect.equals(0, dtTick.hour);
+ Expect.equals(0, dtTick.minute);
+ Expect.equals(0, dtTick.second);
+ Expect.equals(0, dtTick.millisecond);
+ Expect.equals(0, dtTick.microsecond);
+
+ print(" >>> Flow- 2");
+ dtBase1 = new DateTime(2012, 1, 1, 0, 0, 0, 0, 0);
+ dtTick = new DateTime(
+ dtBase1.year,
+ dtBase1.month,
+ dtBase1.day,
+ dtBase1.hour,
+ dtBase1.minute,
+ dtBase1.second,
+ dtBase1.millisecond,
+ dtBase1.microsecond - 1);
+ Expect.equals(dtBase1.year - 1, dtTick.year);
+ Expect.equals(12, dtTick.month);
+ Expect.equals(31, dtTick.day);
+ Expect.equals(23, dtTick.hour);
+ Expect.equals(59, dtTick.minute);
+ Expect.equals(59, dtTick.second);
+ Expect.equals(999, dtTick.millisecond);
+ Expect.equals(999, dtTick.microsecond);
+}
+
+void testDateStrings() {
+ // TODO(floitsch): Clean up the DateTime API that deals with strings.
+ var dt1 = DateTime.parse("2011-05-11 18:58:35Z");
+ Expect.equals(1305140315000, dt1.millisecondsSinceEpoch);
+ Expect.isTrue(dt1.isUtc);
+ dt1 = DateTime.parse("20110511 18:58:35z");
+ Expect.equals(1305140315000, dt1.millisecondsSinceEpoch);
+ Expect.isTrue(dt1.isUtc);
+ dt1 = DateTime.parse("+20110511 18:58:35z");
+ Expect.equals(1305140315000, dt1.millisecondsSinceEpoch);
+ Expect.isTrue(dt1.isUtc);
+ var str = dt1.toString();
+ var dt2 = DateTime.parse(str);
+ Expect.equals(true, dt1 == dt2);
+ var dt3 = dt1.toUtc();
+ str = dt3.toString();
+ Expect.equals("2011-05-11 18:58:35.000Z", str);
+ var dt4 = DateTime.parse("-1234-01-01 00:00:00Z");
+ Expect.equals(-1234, dt4.year);
+ Expect.equals(1, dt4.month);
+ Expect.equals(1, dt4.day);
+ Expect.equals(0, dt4.hour);
+ Expect.equals(0, dt4.minute);
+ Expect.equals(0, dt4.second);
+ Expect.equals(0, dt4.millisecond);
+ Expect.equals(0, dt4.microsecond);
+ Expect.isTrue(dt4.isUtc);
+ var dt5 = DateTime.parse("0099-01-02");
+ Expect.equals(99, dt5.year);
+ Expect.equals(1, dt5.month);
+ Expect.equals(2, dt5.day);
+ Expect.equals(0, dt5.hour);
+ Expect.equals(0, dt5.minute);
+ Expect.equals(0, dt5.second);
+ Expect.equals(0, dt5.millisecond);
+ Expect.equals(0, dt5.microsecond);
+ Expect.isFalse(dt5.isUtc);
+ var dt6 = DateTime.parse("2012-01-01 00:00:10.012");
+ Expect.equals(12, dt6.millisecond);
+ Expect.equals(0, dt6.microsecond);
+ dt6 = DateTime.parse("2012-01-01 00:00:10.003");
+ Expect.equals(3, dt6.millisecond);
+ Expect.equals(0, dt6.microsecond);
+ dt6 = DateTime.parse("2012-01-01 00:00:10.5");
+ Expect.equals(500, dt6.millisecond);
+ Expect.equals(0, dt6.microsecond);
+ dt6 = DateTime.parse("2012-01-01 00:00:10.003Z");
+ Expect.equals(3, dt6.millisecond);
+ Expect.equals(0, dt6.microsecond);
+ dt6 = DateTime.parse("2012-01-01 00:00:10.5z");
+ Expect.equals(500, dt6.millisecond);
+ Expect.equals(0, dt6.microsecond);
+ var dt7 = DateTime.parse("2011-05-11T18:58:35Z");
+ Expect.equals(1305140315000, dt7.millisecondsSinceEpoch);
+ var dt8 = DateTime.parse("-1234-01-01T00:00:00Z");
+ Expect.equals(-1234, dt8.year);
+ Expect.equals(1, dt8.month);
+ Expect.equals(1, dt8.day);
+ Expect.equals(0, dt8.hour);
+ Expect.equals(0, dt8.minute);
+ Expect.equals(0, dt8.second);
+ Expect.equals(0, dt8.millisecond);
+ Expect.equals(0, dt8.microsecond);
+ Expect.isTrue(dt8.isUtc);
+ var dt9 = DateTime.parse("-1234-01-01T00:00:00");
+ Expect.equals(-1234, dt9.year);
+ Expect.equals(1, dt9.month);
+ Expect.equals(1, dt9.day);
+ Expect.equals(0, dt9.hour);
+ Expect.equals(0, dt9.minute);
+ Expect.equals(0, dt9.second);
+ Expect.equals(0, dt9.millisecond);
+ Expect.equals(0, dt9.microsecond);
+ Expect.isFalse(dt9.isUtc);
+ var dt10 = DateTime.parse("-12340101");
+ Expect.equals(-1234, dt10.year);
+ Expect.equals(1, dt10.month);
+ Expect.equals(1, dt10.day);
+ Expect.equals(0, dt10.hour);
+ Expect.equals(0, dt10.minute);
+ Expect.equals(0, dt10.second);
+ Expect.equals(0, dt10.millisecond);
+ Expect.equals(0, dt10.microsecond);
+ Expect.isFalse(dt10.isUtc);
+ dt1 = DateTime.parse("2012-02-27 13:27:00");
+ Expect.equals(2012, dt1.year);
+ Expect.equals(2, dt1.month);
+ Expect.equals(27, dt1.day);
+ Expect.equals(13, dt1.hour);
+ Expect.equals(27, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(0, dt1.millisecond);
+ Expect.equals(0, dt1.microsecond);
+ Expect.equals(false, dt1.isUtc);
+ dt1 = DateTime.parse("2012-02-27 13:27:00.423z");
+ Expect.equals(2012, dt1.year);
+ Expect.equals(2, dt1.month);
+ Expect.equals(27, dt1.day);
+ Expect.equals(13, dt1.hour);
+ Expect.equals(27, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(423, dt1.millisecond);
+ Expect.equals(0, dt1.microsecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("20120227 13:27:00");
+ Expect.equals(2012, dt1.year);
+ Expect.equals(2, dt1.month);
+ Expect.equals(27, dt1.day);
+ Expect.equals(13, dt1.hour);
+ Expect.equals(27, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(0, dt1.millisecond);
+ Expect.equals(0, dt1.microsecond);
+ Expect.equals(false, dt1.isUtc);
+ dt1 = DateTime.parse("20120227T132700");
+ Expect.equals(2012, dt1.year);
+ Expect.equals(2, dt1.month);
+ Expect.equals(27, dt1.day);
+ Expect.equals(13, dt1.hour);
+ Expect.equals(27, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(0, dt1.millisecond);
+ Expect.equals(0, dt1.microsecond);
+ Expect.equals(false, dt1.isUtc);
+ dt1 = DateTime.parse("20120227");
+ Expect.equals(2012, dt1.year);
+ Expect.equals(2, dt1.month);
+ Expect.equals(27, dt1.day);
+ Expect.equals(0, dt1.hour);
+ Expect.equals(0, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(0, dt1.millisecond);
+ Expect.equals(0, dt1.microsecond);
+ Expect.equals(false, dt1.isUtc);
+ dt1 = DateTime.parse("2012-02-27T14Z");
+ Expect.equals(2012, dt1.year);
+ Expect.equals(2, dt1.month);
+ Expect.equals(27, dt1.day);
+ Expect.equals(14, dt1.hour);
+ Expect.equals(0, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(0, dt1.millisecond);
+ Expect.equals(0, dt1.microsecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("-123450101 00:00:00 Z");
+ Expect.equals(-12345, dt1.year);
+ Expect.equals(1, dt1.month);
+ Expect.equals(1, dt1.day);
+ Expect.equals(0, dt1.hour);
+ Expect.equals(0, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(0, dt1.millisecond);
+ Expect.equals(0, dt1.microsecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("1999-01-02 23:59:59.99951");
+ if (supportsMicroseconds) {
+ Expect.equals(1999, dt1.year);
+ Expect.equals(1, dt1.month);
+ Expect.equals(2, dt1.day);
+ Expect.equals(23, dt1.hour);
+ Expect.equals(59, dt1.minute);
+ Expect.equals(59, dt1.second);
+ Expect.equals(999, dt1.millisecond);
+ Expect.equals(510, dt1.microsecond);
+ } else {
+ // We only support millisecond. If the user supplies more data (the "51"
+ // here), we round.
+ Expect.equals(1999, dt1.year);
+ Expect.equals(1, dt1.month);
+ Expect.equals(3, dt1.day);
+ Expect.equals(0, dt1.hour);
+ Expect.equals(0, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(0, dt1.millisecond);
+ Expect.equals(0, dt1.microsecond);
+ }
+ Expect.equals(false, dt1.isUtc);
+ dt1 = DateTime.parse("1999-01-02 23:58:59.99951Z");
+ if (supportsMicroseconds) {
+ Expect.equals(1999, dt1.year);
+ Expect.equals(1, dt1.month);
+ Expect.equals(2, dt1.day);
+ Expect.equals(23, dt1.hour);
+ Expect.equals(58, dt1.minute);
+ Expect.equals(59, dt1.second);
+ Expect.equals(999, dt1.millisecond);
+ Expect.equals(510, dt1.microsecond);
+ } else {
+ Expect.equals(1999, dt1.year);
+ Expect.equals(1, dt1.month);
+ Expect.equals(2, dt1.day);
+ Expect.equals(23, dt1.hour);
+ Expect.equals(59, dt1.minute);
+ Expect.equals(0, dt1.second);
+ Expect.equals(0, dt1.millisecond);
+ Expect.equals(0, dt1.microsecond);
+ }
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009Z");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(9, dt1.day);
+ Expect.equals(9, dt1.hour);
+ Expect.equals(9, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009-00");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(9, dt1.day);
+ Expect.equals(9, dt1.hour);
+ Expect.equals(9, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009-0000");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(9, dt1.day);
+ Expect.equals(9, dt1.hour);
+ Expect.equals(9, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009-02");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(9, dt1.day);
+ Expect.equals(11, dt1.hour);
+ Expect.equals(9, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009+0200");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(9, dt1.day);
+ Expect.equals(7, dt1.hour);
+ Expect.equals(9, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009+1200");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(8, dt1.day);
+ Expect.equals(21, dt1.hour);
+ Expect.equals(9, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009-1200");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(9, dt1.day);
+ Expect.equals(21, dt1.hour);
+ Expect.equals(9, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009-0230");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(9, dt1.day);
+ Expect.equals(11, dt1.hour);
+ Expect.equals(39, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+ dt1 = DateTime.parse("0009-09-09 09:09:09.009-2134");
+ Expect.equals(9, dt1.year);
+ Expect.equals(9, dt1.month);
+ Expect.equals(10, dt1.day);
+ Expect.equals(6, dt1.hour);
+ Expect.equals(43, dt1.minute);
+ Expect.equals(9, dt1.second);
+ Expect.equals(9, dt1.millisecond);
+ Expect.equals(true, dt1.isUtc);
+
+ Expect.throwsFormatException(() => DateTime.parse("bad"));
+ var bad_year =
+ 1970 + (_MAX_MILLISECONDS ~/ (1000 * 60 * 60 * 24 * 365.2425)) + 1;
+ Expect.throwsFormatException(
+ () => DateTime.parse(bad_year.toString() + "-01-01"));
+ // The last valid time; should not throw.
+ dt1 = DateTime.parse("275760-09-13T00:00:00.000Z");
+ Expect.throwsFormatException(
+ () => DateTime.parse("275760-09-14T00:00:00.000Z"));
+ Expect.throwsFormatException(
+ () => DateTime.parse("275760-09-13T00:00:00.001Z"));
+ if (supportsMicroseconds) {
+ Expect.throwsFormatException(
+ () => DateTime.parse("275760-09-13T00:00:00.000001Z"));
+ } else {
+ dt1 = DateTime.parse("275760-09-13T00:00:00.000001Z");
+ }
+
+ // first valid time; should not throw.
+ dt1 = DateTime.parse("-271821-04-20T00:00:00.000Z");
+ Expect.throwsFormatException(
+ () => DateTime.parse("-271821-04-19T23:59:59.999Z"));
+
+ if (supportsMicroseconds) {
+ Expect.throwsFormatException(
+ () => DateTime.parse("-271821-04-19T23:59:59.999999Z"));
+ }
+}
+
+void testWeekday() {
+ // 2011-10-06 is Summertime.
+ var d = new DateTime(2011, 10, 6, 0, 45, 37, 0);
+ Expect.equals(DateTime.thursday, d.weekday);
+ d = new DateTime.utc(2011, 10, 6, 0, 45, 37, 0);
+ Expect.equals(DateTime.thursday, d.weekday);
+ d = new DateTime(2011, 10, 5, 23, 45, 37, 0);
+ Expect.equals(DateTime.wednesday, d.weekday);
+ d = new DateTime.utc(2011, 10, 5, 23, 45, 37, 0);
+ Expect.equals(DateTime.wednesday, d.weekday);
+ // 1970-01-01 is Wintertime.
+ d = new DateTime(1970, 1, 1, 0, 0, 0, 1);
+ Expect.equals(DateTime.thursday, d.weekday);
+ d = new DateTime.utc(1970, 1, 1, 0, 0, 0, 1);
+ Expect.equals(DateTime.thursday, d.weekday);
+ d = new DateTime.utc(1969, 12, 31, 23, 59, 59, 999);
+ Expect.equals(DateTime.wednesday, d.weekday);
+ d = new DateTime(1969, 12, 31, 23, 59, 59, 999);
+ Expect.equals(DateTime.wednesday, d.weekday);
+ d = new DateTime(2011, 10, 4, 23, 45, 37, 0);
+ Expect.equals(DateTime.tuesday, d.weekday);
+ d = new DateTime(2011, 10, 3, 23, 45, 37, 0);
+ Expect.equals(DateTime.monday, d.weekday);
+ d = new DateTime(2011, 10, 2, 23, 45, 37, 0);
+ Expect.equals(DateTime.sunday, d.weekday);
+ d = new DateTime(2011, 10, 1, 23, 45, 37, 0);
+ Expect.equals(DateTime.saturday, d.weekday);
+ d = new DateTime(2011, 9, 30, 23, 45, 37, 0);
+ Expect.equals(DateTime.friday, d.weekday);
+}
+
+void testToStrings() {
+ void test(date, time) {
+ {
+ // UTC time.
+ String source1 = "$date ${time}Z";
+ String source2 = "${date}T${time}Z";
+ var utcTime1 = DateTime.parse(source1);
+ var utcTime2 = DateTime.parse(source2);
+ Expect.isTrue(utcTime1.isUtc);
+ Expect.equals(utcTime1, utcTime2);
+ Expect.equals(source1, utcTime1.toString());
+ Expect.equals(source2, utcTime1.toIso8601String());
+ }
+ {
+ // Local time
+ String source1 = "$date $time";
+ String source2 = "${date}T$time";
+ var utcTime1 = DateTime.parse(source1);
+ var utcTime2 = DateTime.parse(source2);
+ Expect.isFalse(utcTime1.isUtc);
+ Expect.equals(utcTime1, utcTime2);
+ Expect.equals(source1, utcTime1.toString());
+ Expect.equals(source2, utcTime1.toIso8601String());
+ }
+ }
+
+ test("2000-01-01", "12:00:00.000");
+ test("-2000-01-01", "12:00:00.000");
+ test("1970-01-01", "00:00:00.000");
+ test("1969-12-31", "23:59:59.999");
+ test("1969-09-09", "00:09:09.009");
+
+ if (supportsMicroseconds) {
+ test("2000-01-01", "12:00:00.000001");
+ test("-2000-01-01", "12:00:00.000001");
+ test("1970-01-01", "00:00:00.000001");
+ test("1969-12-31", "23:59:59.999999");
+ test("1969-09-09", "00:09:09.009999");
+ }
+}
+
+void testIsoString() {
+ var d = new DateTime(9999, 1, 1, 23, 59, 59, 999);
+ Expect.equals("9999-01-01T23:59:59.999", d.toIso8601String());
+ d = new DateTime(-9999, 1, 1, 23, 59, 59, 999);
+ Expect.equals("-9999-01-01T23:59:59.999", d.toIso8601String());
+ d = new DateTime.utc(9999, 1, 1, 23, 59, 59, 999);
+ Expect.equals("9999-01-01T23:59:59.999Z", d.toIso8601String());
+ d = new DateTime.utc(-9999, 1, 1, 23, 59, 59, 999);
+ Expect.equals("-9999-01-01T23:59:59.999Z", d.toIso8601String());
+
+ d = new DateTime(10000, 1, 1, 23, 59, 59, 999);
+ Expect.equals("+010000-01-01T23:59:59.999", d.toIso8601String());
+ d = new DateTime(-10000, 1, 1, 23, 59, 59, 999);
+ Expect.equals("-010000-01-01T23:59:59.999", d.toIso8601String());
+ d = new DateTime.utc(10000, 1, 1, 23, 59, 59, 999);
+ Expect.equals("+010000-01-01T23:59:59.999Z", d.toIso8601String());
+ d = new DateTime.utc(-10000, 1, 1, 23, 59, 59, 999);
+ Expect.equals("-010000-01-01T23:59:59.999Z", d.toIso8601String());
+
+ if (!supportsMicroseconds) return;
+
+ d = new DateTime(9999, 1, 1, 23, 59, 59, 999, 999);
+ Expect.equals("9999-01-01T23:59:59.999999", d.toIso8601String());
+ d = new DateTime(-9999, 1, 1, 23, 59, 59, 999, 999);
+ Expect.equals("-9999-01-01T23:59:59.999999", d.toIso8601String());
+ d = new DateTime.utc(9999, 1, 1, 23, 59, 59, 999, 999);
+ Expect.equals("9999-01-01T23:59:59.999999Z", d.toIso8601String());
+ d = new DateTime.utc(-9999, 1, 1, 23, 59, 59, 999, 999);
+ Expect.equals("-9999-01-01T23:59:59.999999Z", d.toIso8601String());
+
+ d = new DateTime(10000, 1, 1, 23, 59, 59, 999, 999);
+ Expect.equals("+010000-01-01T23:59:59.999999", d.toIso8601String());
+ d = new DateTime(-10000, 1, 1, 23, 59, 59, 999, 999);
+ Expect.equals("-010000-01-01T23:59:59.999999", d.toIso8601String());
+ d = new DateTime.utc(10000, 1, 1, 23, 59, 59, 999, 999);
+ Expect.equals("+010000-01-01T23:59:59.999999Z", d.toIso8601String());
+ d = new DateTime.utc(-10000, 1, 1, 23, 59, 59, 999, 999);
+ Expect.equals("-010000-01-01T23:59:59.999999Z", d.toIso8601String());
+
+ d = new DateTime(9999, 1, 1, 23, 49, 59, 989, 979);
+ Expect.equals("9999-01-01T23:49:59.989979", d.toIso8601String());
+ d = new DateTime(-9999, 1, 1, 23, 49, 59, 989, 979);
+ Expect.equals("-9999-01-01T23:49:59.989979", d.toIso8601String());
+ d = new DateTime.utc(9999, 1, 1, 23, 49, 59, 989, 979);
+ Expect.equals("9999-01-01T23:49:59.989979Z", d.toIso8601String());
+ d = new DateTime.utc(-9999, 1, 1, 23, 49, 59, 989, 979);
+ Expect.equals("-9999-01-01T23:49:59.989979Z", d.toIso8601String());
+
+ d = new DateTime(10000, 1, 1, 23, 49, 59, 989, 979);
+ Expect.equals("+010000-01-01T23:49:59.989979", d.toIso8601String());
+ d = new DateTime(-10000, 1, 1, 23, 49, 59, 989, 979);
+ Expect.equals("-010000-01-01T23:49:59.989979", d.toIso8601String());
+ d = new DateTime.utc(10000, 1, 1, 23, 49, 59, 989, 979);
+ Expect.equals("+010000-01-01T23:49:59.989979Z", d.toIso8601String());
+ d = new DateTime.utc(-10000, 1, 1, 23, 49, 59, 989, 979);
+ Expect.equals("-010000-01-01T23:49:59.989979Z", d.toIso8601String());
+}
+
+void main() {
+ testNow();
+ testMillisecondsSinceEpoch();
+ testMicrosecondsSinceEpoch();
+ testConstructors();
+ testUTCGetters();
+ testLocalGetters();
+ testChangeTimeZone();
+ testSubAdd();
+ testUnderflowAndOverflow();
+ testDateStrings();
+ testEquivalentYears();
+ testWeekday();
+ testToStrings();
+ testIsoString();
+}
diff --git a/tests/corelib/double_ceil2_test.dart b/tests/corelib/double_ceil2_test.dart
new file mode 100644
index 0000000..630554a
--- /dev/null
+++ b/tests/corelib/double_ceil2_test.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.throwsUnsupportedError(() => double.infinity.ceil());
+ Expect.throwsUnsupportedError(() => double.negativeInfinity.ceil());
+ Expect.throwsUnsupportedError(() => double.nan.ceil());
+}
diff --git a/tests/corelib/double_ceil_test.dart b/tests/corelib/double_ceil_test.dart
new file mode 100644
index 0000000..f461bae
--- /dev/null
+++ b/tests/corelib/double_ceil_test.dart
@@ -0,0 +1,80 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0, 0.0.ceil());
+ Expect.equals(1, double.minPositive.ceil());
+ Expect.equals(1, (2.0 * double.minPositive).ceil());
+ Expect.equals(1, (1.18e-38).ceil());
+ Expect.equals(1, (1.18e-38 * 2).ceil());
+ Expect.equals(1, 0.49999999999999994.ceil());
+ Expect.equals(1, 0.5.ceil());
+ Expect.equals(1, 0.9999999999999999.ceil());
+ Expect.equals(1, 1.0.ceil());
+ Expect.equals(2, 1.000000000000001.ceil());
+ // The following numbers are on the border of 52 bits.
+ // For example: 4503599627370499 + 0.5 => 4503599627370500.
+ Expect.equals(4503599627370496, 4503599627370496.0.ceil());
+ Expect.equals(4503599627370497, 4503599627370497.0.ceil());
+ Expect.equals(4503599627370498, 4503599627370498.0.ceil());
+ Expect.equals(4503599627370499, 4503599627370499.0.ceil());
+
+ Expect.equals(9007199254740991, 9007199254740991.0.ceil());
+ Expect.equals(9007199254740992, 9007199254740992.0.ceil());
+ Expect.equals(9223372036854775807, double.maxFinite.ceil()); // //# int64: ok
+
+ Expect.equals(0, (-double.minPositive).ceil());
+ Expect.equals(0, (2.0 * -double.minPositive).ceil());
+ Expect.equals(0, (-1.18e-38).ceil());
+ Expect.equals(0, (-1.18e-38 * 2).ceil());
+ Expect.equals(0, (-0.49999999999999994).ceil());
+ Expect.equals(0, (-0.5).ceil());
+ Expect.equals(0, (-0.9999999999999999).ceil());
+ Expect.equals(-1, (-1.0).ceil());
+ Expect.equals(-1, (-1.000000000000001).ceil());
+ Expect.equals(-4503599627370496, (-4503599627370496.0).ceil());
+ Expect.equals(-4503599627370497, (-4503599627370497.0).ceil());
+ Expect.equals(-4503599627370498, (-4503599627370498.0).ceil());
+ Expect.equals(-4503599627370499, (-4503599627370499.0).ceil());
+ Expect.equals(-9007199254740991, (-9007199254740991.0).ceil());
+ Expect.equals(-9007199254740992, (-9007199254740992.0).ceil());
+ Expect.equals(-9223372036854775808, (-double.maxFinite).ceil()); // //# int64: ok
+
+ Expect.isTrue(0.0.ceil() is int);
+ Expect.isTrue(double.minPositive.ceil() is int);
+ Expect.isTrue((2.0 * double.minPositive).ceil() is int);
+ Expect.isTrue((1.18e-38).ceil() is int);
+ Expect.isTrue((1.18e-38 * 2).ceil() is int);
+ Expect.isTrue(0.49999999999999994.ceil() is int);
+ Expect.isTrue(0.5.ceil() is int);
+ Expect.isTrue(0.9999999999999999.ceil() is int);
+ Expect.isTrue(1.0.ceil() is int);
+ Expect.isTrue(1.000000000000001.ceil() is int);
+ Expect.isTrue(4503599627370496.0.ceil() is int);
+ Expect.isTrue(4503599627370497.0.ceil() is int);
+ Expect.isTrue(4503599627370498.0.ceil() is int);
+ Expect.isTrue(4503599627370499.0.ceil() is int);
+ Expect.isTrue(9007199254740991.0.ceil() is int);
+ Expect.isTrue(9007199254740992.0.ceil() is int);
+ Expect.isTrue(double.maxFinite.ceil() is int);
+
+ Expect.isTrue((-double.minPositive).ceil() is int);
+ Expect.isTrue((2.0 * -double.minPositive).ceil() is int);
+ Expect.isTrue((-1.18e-38).ceil() is int);
+ Expect.isTrue((-1.18e-38 * 2).ceil() is int);
+ Expect.isTrue((-0.49999999999999994).ceil() is int);
+ Expect.isTrue((-0.5).ceil() is int);
+ Expect.isTrue((-0.9999999999999999).ceil() is int);
+ Expect.isTrue((-1.0).ceil() is int);
+ Expect.isTrue((-1.000000000000001).ceil() is int);
+ Expect.isTrue((-4503599627370496.0).ceil() is int);
+ Expect.isTrue((-4503599627370497.0).ceil() is int);
+ Expect.isTrue((-4503599627370498.0).ceil() is int);
+ Expect.isTrue((-4503599627370499.0).ceil() is int);
+ Expect.isTrue((-9007199254740991.0).ceil() is int);
+ Expect.isTrue((-9007199254740992.0).ceil() is int);
+ Expect.isTrue((-double.maxFinite).ceil() is int);
+}
diff --git a/tests/corelib/double_ceil_to_double_test.dart b/tests/corelib/double_ceil_to_double_test.dart
new file mode 100644
index 0000000..856ead3
--- /dev/null
+++ b/tests/corelib/double_ceil_to_double_test.dart
@@ -0,0 +1,93 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0.0, 0.0.ceilToDouble());
+ Expect.equals(1.0, double.minPositive.ceilToDouble());
+ Expect.equals(1.0, (2.0 * double.minPositive).ceilToDouble());
+ Expect.equals(1.0, (1.18e-38).ceilToDouble());
+ Expect.equals(1.0, (1.18e-38 * 2).ceilToDouble());
+ Expect.equals(1.0, 0.49999999999999994.ceilToDouble());
+ Expect.equals(1.0, 0.5.ceilToDouble());
+ Expect.equals(1.0, 0.9999999999999999.ceilToDouble());
+ Expect.equals(1.0, 1.0.ceilToDouble());
+ Expect.equals(2.0, 1.000000000000001.ceilToDouble());
+ // The following numbers are on the border of 52 bits.
+ // For example: 4503599627370499 + 0.5 => 4503599627370500.
+ Expect.equals(4503599627370496.0, 4503599627370496.0.ceilToDouble());
+ Expect.equals(4503599627370497.0, 4503599627370497.0.ceilToDouble());
+ Expect.equals(4503599627370498.0, 4503599627370498.0.ceilToDouble());
+ Expect.equals(4503599627370499.0, 4503599627370499.0.ceilToDouble());
+
+ Expect.equals(9007199254740991.0, 9007199254740991.0.ceilToDouble());
+ Expect.equals(9007199254740992.0, 9007199254740992.0.ceilToDouble());
+ Expect.equals(double.maxFinite, double.maxFinite.ceilToDouble());
+
+ Expect.equals(0.0, (-double.minPositive).ceilToDouble());
+ Expect.equals(0.0, (2.0 * -double.minPositive).ceilToDouble());
+ Expect.equals(0.0, (-1.18e-38).ceilToDouble());
+ Expect.equals(0.0, (-1.18e-38 * 2).ceilToDouble());
+ Expect.equals(0.0, (-0.49999999999999994).ceilToDouble());
+ Expect.equals(0.0, (-0.5).ceilToDouble());
+ Expect.equals(0.0, (-0.9999999999999999).ceilToDouble());
+ Expect.equals(-1.0, (-1.0).ceilToDouble());
+ Expect.equals(-1.0, (-1.000000000000001).ceilToDouble());
+ Expect.equals(-4503599627370496.0, (-4503599627370496.0).ceilToDouble());
+ Expect.equals(-4503599627370497.0, (-4503599627370497.0).ceilToDouble());
+ Expect.equals(-4503599627370498.0, (-4503599627370498.0).ceilToDouble());
+ Expect.equals(-4503599627370499.0, (-4503599627370499.0).ceilToDouble());
+ Expect.equals(-9007199254740991.0, (-9007199254740991.0).ceilToDouble());
+ Expect.equals(-9007199254740992.0, (-9007199254740992.0).ceilToDouble());
+ Expect.equals(-double.maxFinite, (-double.maxFinite).ceilToDouble());
+
+ Expect.equals(double.infinity, double.infinity.ceilToDouble());
+ Expect.equals(
+ double.negativeInfinity, double.negativeInfinity.ceilToDouble());
+ Expect.isTrue(double.nan.ceilToDouble().isNaN);
+
+ Expect.isTrue(0.0.ceilToDouble() is double);
+ Expect.isTrue(double.minPositive.ceilToDouble() is double);
+ Expect.isTrue((2.0 * double.minPositive).ceilToDouble() is double);
+ Expect.isTrue((1.18e-38).ceilToDouble() is double);
+ Expect.isTrue((1.18e-38 * 2).ceilToDouble() is double);
+ Expect.isTrue(0.49999999999999994.ceilToDouble() is double);
+ Expect.isTrue(0.5.ceilToDouble() is double);
+ Expect.isTrue(0.9999999999999999.ceilToDouble() is double);
+ Expect.isTrue(1.0.ceilToDouble() is double);
+ Expect.isTrue(1.000000000000001.ceilToDouble() is double);
+ Expect.isTrue(4503599627370496.0.ceilToDouble() is double);
+ Expect.isTrue(4503599627370497.0.ceilToDouble() is double);
+ Expect.isTrue(4503599627370498.0.ceilToDouble() is double);
+ Expect.isTrue(4503599627370499.0.ceilToDouble() is double);
+ Expect.isTrue(9007199254740991.0.ceilToDouble() is double);
+ Expect.isTrue(9007199254740992.0.ceilToDouble() is double);
+ Expect.isTrue(double.maxFinite.ceilToDouble() is double);
+
+ Expect.isTrue((-double.minPositive).ceilToDouble().isNegative);
+ Expect.isTrue((2.0 * -double.minPositive).ceilToDouble().isNegative);
+ Expect.isTrue((-1.18e-38).ceilToDouble().isNegative);
+ Expect.isTrue((-1.18e-38 * 2).ceilToDouble().isNegative);
+ Expect.isTrue((-0.49999999999999994).ceilToDouble().isNegative);
+ Expect.isTrue((-0.5).ceilToDouble().isNegative);
+ Expect.isTrue((-0.9999999999999999).ceilToDouble().isNegative);
+
+ Expect.isTrue((-double.minPositive).ceilToDouble() is double);
+ Expect.isTrue((2.0 * -double.minPositive).ceilToDouble() is double);
+ Expect.isTrue((-1.18e-38).ceilToDouble() is double);
+ Expect.isTrue((-1.18e-38 * 2).ceilToDouble() is double);
+ Expect.isTrue((-0.49999999999999994).ceilToDouble() is double);
+ Expect.isTrue((-0.5).ceilToDouble() is double);
+ Expect.isTrue((-0.9999999999999999).ceilToDouble() is double);
+ Expect.isTrue((-1.0).ceilToDouble() is double);
+ Expect.isTrue((-1.000000000000001).ceilToDouble() is double);
+ Expect.isTrue((-4503599627370496.0).ceilToDouble() is double);
+ Expect.isTrue((-4503599627370497.0).ceilToDouble() is double);
+ Expect.isTrue((-4503599627370498.0).ceilToDouble() is double);
+ Expect.isTrue((-4503599627370499.0).ceilToDouble() is double);
+ Expect.isTrue((-9007199254740991.0).ceilToDouble() is double);
+ Expect.isTrue((-9007199254740992.0).ceilToDouble() is double);
+ Expect.isTrue((-double.maxFinite).ceilToDouble() is double);
+}
diff --git a/tests/corelib/double_compare_test.dart b/tests/corelib/double_compare_test.dart
new file mode 100644
index 0000000..0071cf0
--- /dev/null
+++ b/tests/corelib/double_compare_test.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+// Dart test program for testing 'compare' on doubles.
+
+void main() {
+ Expect.equals(0, (0.0).compareTo(0.0));
+ Expect.equals(0, (1.0).compareTo(1.0));
+ Expect.equals(0, (-2.0).compareTo(-2.0));
+ Expect.equals(0, (1e-50).compareTo(1e-50));
+ Expect.equals(0, (-2e50).compareTo(-2e50));
+ Expect.equals(0, double.nan.compareTo(double.nan));
+ Expect.equals(0, double.infinity.compareTo(double.infinity));
+ Expect.equals(0, double.negativeInfinity.compareTo(double.negativeInfinity));
+ Expect.equals(0, (-0.0).compareTo(-0.0));
+ Expect.isTrue((0.0).compareTo(1.0) < 0);
+ Expect.isTrue((1.0).compareTo(0.0) > 0);
+ Expect.isTrue((0.0).compareTo(-1.0) > 0);
+ Expect.isTrue((-1.0).compareTo(0.0) < 0);
+ Expect.isTrue((0.0).compareTo(1234e11) < 0);
+ Expect.isTrue((123e-112).compareTo(0.0) > 0);
+ Expect.isTrue((0.0).compareTo(-123.0e12) > 0);
+ Expect.isTrue((-1.0e8).compareTo(0.0) < 0);
+
+ double maxDouble = 1.7976931348623157e308;
+ Expect.equals(0, maxDouble.compareTo(maxDouble));
+ Expect.isTrue(maxDouble.compareTo(double.infinity) < 0);
+ Expect.isTrue(double.infinity.compareTo(maxDouble) > 0);
+
+ double negMaxDouble = -maxDouble;
+ Expect.equals(0, negMaxDouble.compareTo(negMaxDouble));
+ Expect.isTrue(double.negativeInfinity.compareTo(negMaxDouble) < 0);
+ Expect.isTrue(negMaxDouble.compareTo(double.negativeInfinity) > 0);
+
+ Expect.isTrue((-0.0).compareTo(0.0) < 0);
+ Expect.isTrue((0.0).compareTo(-0.0) > 0);
+ Expect.isTrue(double.nan.compareTo(double.infinity) > 0);
+ Expect.isTrue(double.nan.compareTo(double.negativeInfinity) > 0);
+ Expect.isTrue(double.infinity.compareTo(double.nan) < 0);
+ Expect.isTrue(double.negativeInfinity.compareTo(double.nan) < 0);
+ Expect.isTrue(maxDouble.compareTo(double.nan) < 0);
+ Expect.isTrue(negMaxDouble.compareTo(double.nan) < 0);
+ Expect.isTrue(double.nan.compareTo(maxDouble) > 0);
+ Expect.isTrue(double.nan.compareTo(negMaxDouble) > 0);
+}
diff --git a/tests/corelib/double_floor2_test.dart b/tests/corelib/double_floor2_test.dart
new file mode 100644
index 0000000..95413e5
--- /dev/null
+++ b/tests/corelib/double_floor2_test.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.throwsUnsupportedError(() => double.infinity.floor());
+ Expect.throwsUnsupportedError(() => double.negativeInfinity.floor());
+ Expect.throwsUnsupportedError(() => double.nan.floor());
+}
diff --git a/tests/corelib/double_floor_test.dart b/tests/corelib/double_floor_test.dart
new file mode 100644
index 0000000..ba34daf
--- /dev/null
+++ b/tests/corelib/double_floor_test.dart
@@ -0,0 +1,80 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0, 0.0.floor());
+ Expect.equals(0, double.minPositive.floor());
+ Expect.equals(0, (2.0 * double.minPositive).floor());
+ Expect.equals(0, (1.18e-38).floor());
+ Expect.equals(0, (1.18e-38 * 2).floor());
+ Expect.equals(0, 0.49999999999999994.floor());
+ Expect.equals(0, 0.5.floor());
+ Expect.equals(0, 0.9999999999999999.floor());
+ Expect.equals(1, 1.0.floor());
+ Expect.equals(1, 1.000000000000001.floor());
+ // The following numbers are on the border of 52 bits.
+ // For example: 4503599627370499 + 0.5 => 4503599627370500.
+ Expect.equals(4503599627370496, 4503599627370496.0.floor());
+ Expect.equals(4503599627370497, 4503599627370497.0.floor());
+ Expect.equals(4503599627370498, 4503599627370498.0.floor());
+ Expect.equals(4503599627370499, 4503599627370499.0.floor());
+
+ Expect.equals(9007199254740991, 9007199254740991.0.floor());
+ Expect.equals(9007199254740992, 9007199254740992.0.floor());
+ Expect.equals(9223372036854775807, double.maxFinite.floor()); // //# int64: ok
+
+ Expect.equals(-1, (-double.minPositive).floor());
+ Expect.equals(-1, (2.0 * -double.minPositive).floor());
+ Expect.equals(-1, (-1.18e-38).floor());
+ Expect.equals(-1, (-1.18e-38 * 2).floor());
+ Expect.equals(-1, (-0.49999999999999994).floor());
+ Expect.equals(-1, (-0.5).floor());
+ Expect.equals(-1, (-0.9999999999999999).floor());
+ Expect.equals(-1, (-1.0).floor());
+ Expect.equals(-2, (-1.000000000000001).floor());
+ Expect.equals(-4503599627370496, (-4503599627370496.0).floor());
+ Expect.equals(-4503599627370497, (-4503599627370497.0).floor());
+ Expect.equals(-4503599627370498, (-4503599627370498.0).floor());
+ Expect.equals(-4503599627370499, (-4503599627370499.0).floor());
+ Expect.equals(-9007199254740991, (-9007199254740991.0).floor());
+ Expect.equals(-9007199254740992, (-9007199254740992.0).floor());
+ Expect.equals(-9223372036854775808, (-double.maxFinite).floor()); // //# int64: ok
+
+ Expect.isTrue(0.0.floor() is int);
+ Expect.isTrue(double.minPositive.floor() is int);
+ Expect.isTrue((2.0 * double.minPositive).floor() is int);
+ Expect.isTrue((1.18e-38).floor() is int);
+ Expect.isTrue((1.18e-38 * 2).floor() is int);
+ Expect.isTrue(0.49999999999999994.floor() is int);
+ Expect.isTrue(0.5.floor() is int);
+ Expect.isTrue(0.9999999999999999.floor() is int);
+ Expect.isTrue(1.0.floor() is int);
+ Expect.isTrue(1.000000000000001.floor() is int);
+ Expect.isTrue(4503599627370496.0.floor() is int);
+ Expect.isTrue(4503599627370497.0.floor() is int);
+ Expect.isTrue(4503599627370498.0.floor() is int);
+ Expect.isTrue(4503599627370499.0.floor() is int);
+ Expect.isTrue(9007199254740991.0.floor() is int);
+ Expect.isTrue(9007199254740992.0.floor() is int);
+ Expect.isTrue(double.maxFinite.floor() is int);
+
+ Expect.isTrue((-double.minPositive).floor() is int);
+ Expect.isTrue((2.0 * -double.minPositive).floor() is int);
+ Expect.isTrue((-1.18e-38).floor() is int);
+ Expect.isTrue((-1.18e-38 * 2).floor() is int);
+ Expect.isTrue((-0.49999999999999994).floor() is int);
+ Expect.isTrue((-0.5).floor() is int);
+ Expect.isTrue((-0.9999999999999999).floor() is int);
+ Expect.isTrue((-1.0).floor() is int);
+ Expect.isTrue((-1.000000000000001).floor() is int);
+ Expect.isTrue((-4503599627370496.0).floor() is int);
+ Expect.isTrue((-4503599627370497.0).floor() is int);
+ Expect.isTrue((-4503599627370498.0).floor() is int);
+ Expect.isTrue((-4503599627370499.0).floor() is int);
+ Expect.isTrue((-9007199254740991.0).floor() is int);
+ Expect.isTrue((-9007199254740992.0).floor() is int);
+ Expect.isTrue((-double.maxFinite).floor() is int);
+}
diff --git a/tests/corelib/double_floor_to_double_test.dart b/tests/corelib/double_floor_to_double_test.dart
new file mode 100644
index 0000000..8a42862
--- /dev/null
+++ b/tests/corelib/double_floor_to_double_test.dart
@@ -0,0 +1,85 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0.0, 0.0.floorToDouble());
+ Expect.equals(0.0, double.minPositive.floorToDouble());
+ Expect.equals(0.0, (2.0 * double.minPositive).floorToDouble());
+ Expect.equals(0.0, (1.18e-38).floorToDouble());
+ Expect.equals(0.0, (1.18e-38 * 2).floorToDouble());
+ Expect.equals(0.0, 0.49999999999999994.floorToDouble());
+ Expect.equals(0.0, 0.5.floorToDouble());
+ Expect.equals(0.0, 0.9999999999999999.floorToDouble());
+ Expect.equals(1.0, 1.0.floorToDouble());
+ Expect.equals(1.0, 1.000000000000001.floorToDouble());
+ // The following numbers are on the border of 52 bits.
+ // For example: 4503599627370499 + 0.5 => 4503599627370500.
+ Expect.equals(4503599627370496.0, 4503599627370496.0.floorToDouble());
+ Expect.equals(4503599627370497.0, 4503599627370497.0.floorToDouble());
+ Expect.equals(4503599627370498.0, 4503599627370498.0.floorToDouble());
+ Expect.equals(4503599627370499.0, 4503599627370499.0.floorToDouble());
+
+ Expect.equals(9007199254740991.0, 9007199254740991.0.floorToDouble());
+ Expect.equals(9007199254740992.0, 9007199254740992.0.floorToDouble());
+ Expect.equals(double.maxFinite, double.maxFinite.floorToDouble());
+
+ Expect.equals(-1.0, (-double.minPositive).floorToDouble());
+ Expect.equals(-1.0, (2.0 * -double.minPositive).floorToDouble());
+ Expect.equals(-1.0, (-1.18e-38).floorToDouble());
+ Expect.equals(-1.0, (-1.18e-38 * 2).floorToDouble());
+ Expect.equals(-1.0, (-0.49999999999999994).floorToDouble());
+ Expect.equals(-1.0, (-0.5).floorToDouble());
+ Expect.equals(-1.0, (-0.9999999999999999).floorToDouble());
+ Expect.equals(-1.0, (-1.0).floorToDouble());
+ Expect.equals(-2.0, (-1.000000000000001).floorToDouble());
+ Expect.equals(-4503599627370496.0, (-4503599627370496.0).floorToDouble());
+ Expect.equals(-4503599627370497.0, (-4503599627370497.0).floorToDouble());
+ Expect.equals(-4503599627370498.0, (-4503599627370498.0).floorToDouble());
+ Expect.equals(-4503599627370499.0, (-4503599627370499.0).floorToDouble());
+ Expect.equals(-9007199254740991.0, (-9007199254740991.0).floorToDouble());
+ Expect.equals(-9007199254740992.0, (-9007199254740992.0).floorToDouble());
+ Expect.equals(-double.maxFinite, (-double.maxFinite).floorToDouble());
+
+ Expect.equals(double.infinity, double.infinity.floorToDouble());
+ Expect.equals(
+ double.negativeInfinity, double.negativeInfinity.floorToDouble());
+ Expect.isTrue(double.nan.floorToDouble().isNaN);
+
+ Expect.isTrue(0.0.floorToDouble() is double);
+ Expect.isTrue(double.minPositive.floorToDouble() is double);
+ Expect.isTrue((2.0 * double.minPositive).floorToDouble() is double);
+ Expect.isTrue((1.18e-38).floorToDouble() is double);
+ Expect.isTrue((1.18e-38 * 2).floorToDouble() is double);
+ Expect.isTrue(0.49999999999999994.floorToDouble() is double);
+ Expect.isTrue(0.5.floorToDouble() is double);
+ Expect.isTrue(0.9999999999999999.floorToDouble() is double);
+ Expect.isTrue(1.0.floorToDouble() is double);
+ Expect.isTrue(1.000000000000001.floorToDouble() is double);
+ Expect.isTrue(4503599627370496.0.floorToDouble() is double);
+ Expect.isTrue(4503599627370497.0.floorToDouble() is double);
+ Expect.isTrue(4503599627370498.0.floorToDouble() is double);
+ Expect.isTrue(4503599627370499.0.floorToDouble() is double);
+ Expect.isTrue(9007199254740991.0.floorToDouble() is double);
+ Expect.isTrue(9007199254740992.0.floorToDouble() is double);
+ Expect.isTrue(double.maxFinite.floorToDouble() is double);
+
+ Expect.isTrue((-double.minPositive).floorToDouble() is double);
+ Expect.isTrue((2.0 * -double.minPositive).floorToDouble() is double);
+ Expect.isTrue((-1.18e-38).floorToDouble() is double);
+ Expect.isTrue((-1.18e-38 * 2).floorToDouble() is double);
+ Expect.isTrue((-0.49999999999999994).floorToDouble() is double);
+ Expect.isTrue((-0.5).floorToDouble() is double);
+ Expect.isTrue((-0.9999999999999999).floorToDouble() is double);
+ Expect.isTrue((-1.0).floorToDouble() is double);
+ Expect.isTrue((-1.000000000000001).floorToDouble() is double);
+ Expect.isTrue((-4503599627370496.0).floorToDouble() is double);
+ Expect.isTrue((-4503599627370497.0).floorToDouble() is double);
+ Expect.isTrue((-4503599627370498.0).floorToDouble() is double);
+ Expect.isTrue((-4503599627370499.0).floorToDouble() is double);
+ Expect.isTrue((-9007199254740991.0).floorToDouble() is double);
+ Expect.isTrue((-9007199254740992.0).floorToDouble() is double);
+ Expect.isTrue((-double.maxFinite).floorToDouble() is double);
+}
diff --git a/tests/corelib/double_hash_code_test.dart b/tests/corelib/double_hash_code_test.dart
new file mode 100644
index 0000000..8665e6b
--- /dev/null
+++ b/tests/corelib/double_hash_code_test.dart
@@ -0,0 +1,26 @@
+// Copyright (c) 2017, 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.
+
+// VMOptions=--intrinsify
+// VMOptions=--no_intrinsify
+
+import 'package:expect/expect.dart';
+
+main() {
+ for (int x in [0, 1, 0xffff, 0xffffffff, 0x111111111111, 0xffffffffffff]) {
+ test(x);
+ test(-x);
+ }
+
+ // Test with ints outside the 53-bit range that are known to have an
+ // exact double representation.
+ test(9007199254840856);
+ test(144115188075954880);
+ test(936748722493162112);
+}
+
+test(int x) {
+ Expect.equals(x, x.toDouble().toInt(), "bad test argument ($x)");
+ Expect.equals(x.hashCode, x.toDouble().hashCode);
+}
diff --git a/tests/corelib/double_parse_test.dart b/tests/corelib/double_parse_test.dart
new file mode 100644
index 0000000..7dc70e7
--- /dev/null
+++ b/tests/corelib/double_parse_test.dart
@@ -0,0 +1,1215 @@
+// Copyright (c) 2014 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.
+// VMOptions=--no-use-field-guards
+// VMOptions=
+
+import "dart:math" show pow;
+import "package:expect/expect.dart";
+
+const whiteSpace = const [
+ "",
+ "\x09",
+ "\x0a",
+ "\x0b",
+ "\x0c",
+ "\x0d",
+ // JS implementations disagree on U+0085 being whitespace.
+ // U+0085 does not work well with testParseWhiteSpace, so omit it.
+ "\xa0",
+ "\u1680",
+ "\u2000",
+ "\u2001",
+ "\u2002",
+ "\u2003",
+ "\u2004",
+ "\u2005",
+ "\u2006",
+ "\u2007",
+ "\u2008",
+ "\u2009",
+ "\u200a",
+ "\u2028",
+ "\u2029",
+ "\u202f",
+ "\u205f",
+ "\u3000",
+ "\uFEFF"
+];
+
+void expectNumEquals(double expected, var actual, String message) {
+ if (expected.isNaN) {
+ Expect.isTrue(actual is double && actual.isNaN, "isNaN: $message");
+ } else {
+ Expect.identical(expected, actual, message);
+ }
+}
+
+// Test source surrounded by any combination of whitespace.
+void testParseAllWhitespace(String source, double result) {
+ for (String ws1 in whiteSpace) {
+ for (String ws2 in whiteSpace) {
+ String padded = "$ws1$source$ws2";
+ // Use Expect.identical because it also handles NaN and 0.0/-0.0.
+ // Except on dart2js: http://dartbug.com/11551
+ expectNumEquals(result, double.parse(padded), "parse '$padded'");
+ padded = "$ws1$ws2$source";
+ expectNumEquals(result, double.parse(padded), "parse '$padded'");
+ padded = "$source$ws1$ws2";
+ expectNumEquals(result, double.parse(padded), "parse '$padded'");
+ }
+ }
+}
+
+// Test source and -source surrounded by any combination of whitespace.
+void testParseWhitespace(String source, double result) {
+ assert(result >= 0);
+ testParseAllWhitespace(source, result);
+ testParseAllWhitespace("-$source", -result);
+}
+
+// Test parsing source, optionally preceeded and/or followed by whitespace.
+void testParse(String source, double result, [name = ""]) {
+ expectNumEquals(result, double.parse(source), "parse '$source:$name");
+ expectNumEquals(result, double.parse(" $source"), "parse ' $source':$name");
+ expectNumEquals(result, double.parse("$source "), "parse '$source ':$name");
+ expectNumEquals(result, double.parse(" $source "), "parse ' $source ':$name");
+
+ expectNumEquals(result, double.parse("+$source"), "parse '+$source:$name");
+ expectNumEquals(result, double.parse(" +$source"), "parse ' +$source':$name");
+ expectNumEquals(result, double.parse("+$source "), "parse '+$source ':$name");
+ expectNumEquals(
+ result, double.parse(" +$source "), "parse ' +$source ':$name");
+
+ expectNumEquals(-result, double.parse("-$source"), "parse '-$source:$name");
+ expectNumEquals(
+ -result, double.parse(" -$source"), "parse ' -$source':$name");
+ expectNumEquals(
+ -result, double.parse("-$source "), "parse '-$source ':$name");
+ expectNumEquals(
+ -result, double.parse(" -$source "), "parse ' -$source ':$name");
+}
+
+void testDouble(double value) {
+ testParse("$value", value);
+ if (value.isFinite) {
+ String exp = value.toStringAsExponential();
+ String lcexp = exp.toLowerCase();
+ testParse(lcexp, value);
+ String ucexp = exp.toUpperCase();
+ testParse(ucexp, value);
+ }
+}
+
+void testFail(String source) {
+ var object = new Object();
+ Expect.throws(() {
+ double.parse(source, (s) {
+ Expect.equals(source, s);
+ throw object;
+ });
+ }, (e) => identical(object, e), "Fail: '$source'");
+ Expect.equals(1.5, double.parse(source, (s) => 1.5));
+}
+
+void main() {
+ testDouble(0.0);
+ testDouble(5e-324);
+ testDouble(2.225073858507201e-308);
+ testDouble(2.2250738585072014e-308);
+ testDouble(0.49999999999999994);
+ testDouble(0.5);
+ testDouble(0.50000000000000006);
+ testDouble(0.9999999999999999);
+ testDouble(1.0);
+ testDouble(1.0000000000000002);
+ testDouble(4294967295.0);
+ testDouble(4294967296.0);
+ testDouble(4503599627370495.5);
+ testDouble(4503599627370497.0);
+ testDouble(9007199254740991.0);
+ testDouble(9007199254740992.0);
+ testDouble(1.7976931348623157e+308);
+ testDouble(double.infinity);
+ testDouble(double.nan);
+
+ // Strings that cannot occur from toString of a number.
+ testParse("000000000000", 0.0);
+ testParse("000000000001", 1.0);
+ testParse("000000000000.0000000000000", 0.0);
+ testParse("000000000001.0000000000000", 1.0);
+ testParse("0e0", 0.0);
+ testParse("0e+0", 0.0);
+ testParse("0e-0", 0.0);
+ testParse("1e0", 1.0);
+ testParse("1e+0", 1.0);
+ testParse("1e-0", 1.0);
+ testParse("1.", 1.0);
+ testParse(".1", 0.1);
+ testParse("1.e1", 10.0);
+ testParse(".1e1", 1.0);
+ testParse("Infinity", double.infinity);
+ testParse("NaN", double.nan);
+
+ // Cases where mantissa and 10^exponent are representable as a double.
+ for (int i = -22; i <= 22; i++) {
+ for (double j in [1.0, 9007199254740991.0, 9007199254740992.0]) {
+ var value = (i >= 0) ? j * pow(10.0, i) : j / pow(10.0, -i);
+ testParse("${j}e$i", value, "$i/$j");
+ testParse("${j}E$i", value, "$i/$j");
+ if (i >= 0) {
+ testParse("${j}e+$i", value, "$i/$j");
+ testParse("${j}E+$i", value, "$i/$j");
+ }
+ }
+ }
+ for (int i = 0; i <= 22; i++) {
+ var digits = "9007199254740991";
+ for (int i = 0; i < digits.length; i++) {
+ int dotIndex = digits.length - i;
+ var string = "${digits.substring(0, dotIndex)}."
+ "${digits.substring(dotIndex)}e$i";
+ testParse(string, 9007199254740991.0);
+ }
+ }
+
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000012351641146031163604414219821705534309126495065358119110639"
+ "6420625168876817552187966324959090408998094949141173861429432731"
+ "6641775889849490996936990026954695315751782975778511319614542919"
+ "6224552592217965901424968268076250159685228839124609682811834931"
+ "8292403785007928846349518531559641397792756664639171692046759890"
+ "0776562329863178978731138323263641361002818700324274998854829973"
+ "5227010414083113118928696725368169503983880965288753370088162336"
+ "8004844756702677687292583305671118833393020810798402309572336459"
+ "2015026502876542452438269585569329582311976245631182694093981811"
+ "9686640211945509336174248834117544931694293962814151377997828762"
+ "2277536275946568454181273895934743339974841620248529105142565927"
+ "256981069188614130727188467062660492956638336181640625",
+ 0.0);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000024703282292062327208828439643411068618252990130716238221279"
+ "2841250337753635104375932649918180817996189898282347722858865463"
+ "3283551779698981993873980053909390631503565951557022639229085839"
+ "2449105184435931802849936536152500319370457678249219365623669863"
+ "6584807570015857692699037063119282795585513329278343384093519780"
+ "1553124659726357957462276646527282722005637400648549997709659947"
+ "0454020828166226237857393450736339007967761930577506740176324673"
+ "6009689513405355374585166611342237666786041621596804619144672918"
+ "4030053005753084904876539171138659164623952491262365388187963623"
+ "9373280423891018672348497668235089863388587925628302755995657524"
+ "4555072551893136908362547791869486679949683240497058210285131854"
+ "51396213837722826145437693412532098591327667236328125",
+ 0.0);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000024703282292062327208828439643411068618252990130716238221279"
+ "2841250337753635104375932649918180817996189898282347722858865463"
+ "3283551779698981993873980053909390631503565951557022639229085839"
+ "2449105184435931802849936536152500319370457678249219365623669863"
+ "6584807570015857692699037063119282795585513329278343384093519780"
+ "1553124659726357957462276646527282722005637400648549997709659947"
+ "0454020828166226237857393450736339007967761930577506740176324673"
+ "6009689513405355374585166611342237666786041621596804619144672918"
+ "4030053005753084904876539171138659164623952491262365388187963623"
+ "9373280423891018672348497668235089863388587925628302755995657524"
+ "4555072551893136908362547791869486679949683240497058210285131854"
+ "51396213837722826145437693412532098591327667236328125",
+ 0.0);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000024703282292062327208828439643411068627545332140664243314532"
+ "8041234170109088178685677591650492652607243027730579814636067699"
+ "1112238669661707327453443265068702897439863329200619332642599205"
+ "1806252781222000513169502627641523911022607448403553068808609405"
+ "1727798181294290864842608522062097649849550765341204993205100587"
+ "2127469658709242016690593998242808606978027857019419997429604579"
+ "7572623273334010723772922131119806567715298322567005234345331218"
+ "5169920860031716486480793611343761679481328431956040281530986197"
+ "8304604971452253283193290744072288902141724247846767401941767720"
+ "8561650585989659548591956327689896895290365125294085321852619688"
+ "9863888974446146846024033780172178553364579041996676675092137151"
+ "9705456298034409473812692774776868254618683783877327369245051207"
+ "5931578479504396230612962142122846982018227555473696607567828620"
+ "5497859173707553281928994692862033843994140625",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000037054923438093490813242659465116602918087143186126352238665"
+ "4061891674274999582254154033144959392383231717975289492511095959"
+ "2096640779585747657231506869704773681319051549691937265430115392"
+ "9316510179867828993955338712739726887403536747219495345250565253"
+ "9734220743745353366904984135736109339114232557854653467028698863"
+ "1755341990606652876965097618075398198036065644601954996844545287"
+ "8562428797081554870870561495721040952204106503876761616095480465"
+ "4854302923481671949982122917011832487483775622035971266330696098"
+ "1770527542930458978998057183774359009418156980309146068528141338"
+ "9871550473737887132279287842897827763181104688776671568136524122"
+ "1523792405286695424882335699501538146509629059245968850620692484"
+ "3143597161396297062546730578356156393213233025204703880754948792"
+ "4068421520495603769387037857877153017981772444526303392432171379"
+ "4502140826292446718071005307137966156005859375",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000037054923438093490813242659465116602927379485196074357331918"
+ "9261875506630452656563898974877271226994284847423521584288298194"
+ "9925327669548472990810970080864085947255348927335533958843628758"
+ "8673657776653897704274904804228750479055686517373829048435504795"
+ "4877211355023786539048555594678924193378269993917515076140279670"
+ "2329686989589536936193414969790924083008456100972824996564489920"
+ "5681031242249339356786090176104508511951642895866260110264487010"
+ "4014534270108033061877749917013356500179062432395206928717009377"
+ "6045079508629627357314808756707988746935928736893548082281945435"
+ "9059920635836528008522746502352634795082881888442454133993486286"
+ "6832608827839705362543821687804230019924524860745587315427697781"
+ "770943207565842392181565401187981478869915008544921875",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000037054923438093490813242659465116602936671827206022362425172"
+ "4461859338985905730873643916609583061605337976871753676065500430"
+ "7754014559511198324390433292023398213191646304979130652257142124"
+ "8030805373439966414594470895717774070707836287528162751620444337"
+ "0020201966302219711192127053621739047642307429980376685251860477"
+ "2904031988572420995421732321506449967980846557343694996284434553"
+ "2799633687417123842701618856487976071699179287855758604433493555"
+ "3174765616734394173773376917014880512874349242754442591103322657"
+ "0319631474328795735631560329641618484453700493477950096035749532"
+ "8248290797935168884766205161807441826984659088108236699850448451"
+ "2141425250392715300205307676106921893339420662245205780234703079"
+ "2275266989920550781084577445403473184185067145693733619245051207"
+ "5931578479504396230612962142122846982018227555473696607567828620"
+ "5497859173707553281928994692862033843994140625",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000049406564584124654417656879286822137236505980261432476442558"
+ "5682500675507270208751865299836361635992379796564695445717730926"
+ "6567103559397963987747960107818781263007131903114045278458171678"
+ "4898210368871863605699873072305000638740915356498438731247339727"
+ "3169615140031715385398074126238565591171026658556686768187039560"
+ "3106249319452715914924553293054565444011274801297099995419319894"
+ "0908041656332452475714786901472678015935523861155013480352649347"
+ "2019379026810710749170333222684475333572083243193609238289345836"
+ "8060106011506169809753078342277318329247904982524730776375927247"
+ "8746560847782037344696995336470179726777175851256605511991315048"
+ "9110145103786273816725095583738973359899366480994116420570263709"
+ "0279242767544565229087538682506419718265533447265625",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000049406564584124654417656879286822137255090664281328486629065"
+ "6082468340218176357371355183300985305214486055461159629272135398"
+ "2224477339323414654906886530137405794879726658401238665285198410"
+ "3612505562444001026339005255283047822045214896807106137617218810"
+ "3455596362588581729685217044124195299699101530682409986410201174"
+ "4254939317418484033381187996485617213956055714038839994859209159"
+ "5145246546668021447545844262239613135430596645134010468690662437"
+ "0339841720063432972961587222687523358962656863912080563061972395"
+ "6609209942904506566386581488144577804283448495693534803883535441"
+ "7123301171979319097183912655379793790580730250588170643705239377"
+ "9727777948892293692048067560344357106729158083993353350184274303"
+ "9410912596068818947625385549553736509237367567754654738490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000074109846876186981626485318930233205836174286372252704477330"
+ "8123783348549999164508308066289918784766463435950578985022191918"
+ "4193281559171495314463013739409547362638103099383874530860230785"
+ "8633020359735657987910677425479453774807073494438990690501130507"
+ "9468441487490706733809968271472218678228465115709306934057397726"
+ "3510683981213305753930195236150796396072131289203909993689090575"
+ "7124857594163109741741122991442081904408213007753523232190960930"
+ "9708605846963343899964245834023664974967551244071942532661392196"
+ "3541055085860917957996114367548718018836313960618292137056282677"
+ "9743100947475774264558575685795655526362209377553343136273048244"
+ "3047584810573390849764671399003076293019258118491937701241384968"
+ "6287194322792594125093461156712312786426466050409407761509897584"
+ "8136843040991207538774075715754306035963544889052606784864342758"
+ "900428165258489343614201061427593231201171875",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000074109846876186981626485318930233205854758970392148714663837"
+ "8523751013260905313127797949754542453988569694847043168576596389"
+ "9850655339096945981621940161728171894510697854671067917687257517"
+ "7347315553307795408549809608457500958111373034747658096871009590"
+ "9754422710047573078097111189357848386756539987835030152280559340"
+ "4659373979179073872386829939581848166016912201945649993128979841"
+ "1362062484498678713572180352209017023903285791732520220528974020"
+ "8029068540216066123755499834026713000358124864790413857434018755"
+ "2090159017259254714629617513415977493871857473787096164563890871"
+ "8119841271673056017045493004705269590165763776884908267986972573"
+ "3665217655679410725087643375608460039849049721491174630855395563"
+ "54188641513168478436313080237596295773983001708984375",
+ 1e-323);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000074109846876186981626485318930233205873343654412044724850344"
+ "8923718677971811461747287833219166123210675953743507352131000861"
+ "5508029119022396648780866584046796426383292609958261304514284249"
+ "6061610746879932829188941791435548141415672575056325503240888674"
+ "0040403932604439422384254107243478095284614859960753370503720954"
+ "5808063977144841990843464643012899935961693114687389992568869106"
+ "5599267374834247685403237712975952143398358575711517208866987110"
+ "6349531233468788347546753834029761025748698485508885182206645314"
+ "0639262948657591471263120659283236968907400986955900192071499065"
+ "6496581595870337769532410323614883653969318176216473399700896902"
+ "4282850500785430600410615352213843786678841324490411560469406158"
+ "4550533979841101562169154890806946368370134291387467238490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 1e-323);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360069154511635866620203210960799023116591527666370844360221740"
+ "6959097927141579506255510282033669865517905502576217080776730054"
+ "4280061926888594105653889967660011652398050737212918180359607825"
+ "2347125186710418762540332530832907947436024558998429581982425031"
+ "7954385059152437399890443876874974725790225802525457699928291235"
+ "4093225567689679024960579905428830259962166760571761950743978498"
+ "0479564444580149632075553173315669683173879325651468588102366281"
+ "5890742832175436061414318821022423405703806955738531400844926622"
+ "0550120807237108092835830752700771425423583764509515806613894483"
+ "6485368656166704349449158753391942346304638698898642932982747054"
+ "5684547703068233784351199339157645340492308605462312698364257812"
+ "5",
+ 1.1125369292536007e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360069154511635866620203210960799023116610112350390740370408247"
+ "7359065591852485654875000165498293534740011761472681264331134525"
+ "9937435706814044772812816389978636184270645492500111567186634557"
+ "1061420380282556183179464713810955130740324099307096988352304114"
+ "8240366281709303744177586794760604434318300674651180918151452849"
+ "5241915565655447143417214608859882029906947673313501950183867763"
+ "4716769334915718603906610534082604802668952109630465576440379371"
+ "4211205525428158285205572821025471431094380576457002725617553180"
+ "9099224738635444849469333898568030900459127277678319834121502677"
+ "4862108980363986101936076072301556410108193098230208064696671383"
+ "6302180548174253659674171315763029087322100208461549627978268407"
+ "4131669828524253718537846867047316790971834120489029738490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 1.1125369292536007e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360093857793927928947412039400442434185191195972481664588256512"
+ "9400380600184308462011953048487227014291989141962100620081191046"
+ "1906239926662125432368943599250777752029021933482747432761666932"
+ "6081935177574213144751136884007361083502182696938981541236215812"
+ "4253211406611428748302338022108627812847664259678077865798649401"
+ "4497660229450268863966221848525061212023023248478571949013749179"
+ "6696380382410806898101889263285073571646568472249978339940677865"
+ "3579969652328069212208231432361613047099274956616864695216972981"
+ "6031069881591856241078866777972171115011992742603077167294249913"
+ "7481908755860441269310739102717418145889672225195380557264480249"
+ "9621987409855350817390775154421748273612200242960133979035379072"
+ "1007951555248028896005922474205893068160932603143782761509897584"
+ "8136843040991207538774075715754306035963544889052606784864342758"
+ "900428165258489343614201061427593231201171875",
+ 1.1125369292536007e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360093857793927928947412039400442434185209780656501560598443019"
+ "9800348264895214610631442931951850683514095400858564803635595517"
+ "7563613706587576099527870021569402283901616688769940819588693664"
+ "4796230371146350565390269066985408266806482237247648947606094895"
+ "4539192629168295092589480939994257521375739131803801084021811015"
+ "5646350227416036982422856551956112981967804161220311948453638445"
+ "0933585272746375869932946624052008691141641256228975328278690955"
+ "1900432345580791435999485432364661072489848577335336019989599540"
+ "4580173812990192997712369923839430590047536255771881194801858107"
+ "5858649080057723021797656421627032209693226624526945688978404579"
+ "0239620254961370692713747131027132020441991845959370908649389667"
+ "01396213837722826145437693412532098591327667236328125",
+ 1.1125369292536007e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360093857793927928947412039400442434185228365340521456608629527"
+ "0200315929606120759250932815416474352736201659755028987189999989"
+ "3220987486513026766686796443888026815774211444057134206415720396"
+ "3510525564718487986029401249963455450110781777556316353975973978"
+ "4825173851725161436876623857879887229903814003929524302244972629"
+ "6795040225381805100879491255387164751912585073962051947893527710"
+ "5170790163081944841764003984818943810636714040207972316616704045"
+ "0220895038833513659790739432367709097880422198053807344762226099"
+ "3129277744388529754345873069706690065083079768940685222309466301"
+ "4235389404255004774284573740536646273496781023858510820692328908"
+ "0857253100067390568036719107632515767271783448958607838263400261"
+ "9271291212296536333081616208300526650104600844121842238490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 1.112536929253601e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360118561076219991274620867840085845253828033646632276836664299"
+ "2641598602648849715007375581870031501510285299140912526494460981"
+ "0847165486286558093401850075478792915405182640326963458817779503"
+ "7245335555582282368240205603137908586176939915496868313229764759"
+ "1124000199184152785288518003113540316961252461082144468115330795"
+ "7199474887142394939885133198483395703973441561868861946163298392"
+ "1387606100912602107790340074788347699109403186806482068455015628"
+ "7910121858986146810584652043706898739275890198932140639134272458"
+ "8610226818743277902588909094978089754671488747034246582989821731"
+ "5231929503948741694146154089862122073081814550155248444974062103"
+ "4794692806854507601076294922896618700391675086456429118934521521"
+ "5279242767544565229087538682506419718265533447265625",
+ 1.112536929253601e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360118561076219991274620867840085845253846618330652172846850806"
+ "3041566267359755863626865465334655170732391558037376710048865452"
+ "6504539266212008760560776497797417447277777395614156845644806235"
+ "5959630749154419788879337786115955769481239455805535719599643842"
+ "1409981421741019129575660920999170025489327333207867686338492409"
+ "8348164885108163058341767901914447473918222474610601945603187657"
+ "5624810991248171079621397435555282818604475970785479056793028718"
+ "6230584552238869034375906043709946764666463819650611963906899017"
+ "7159330750141614659222412240845349229707032260203050610497429925"
+ "3608669828146023446633071408771736136885368949486813576687986432"
+ "5412325651960527476399266899502002447221466689455666048548532116"
+ "4410912596068818947625385549553736509237367567754654738490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 1.112536929253601e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360143264358512053601829696279729256322427701952743097064699071"
+ "5082881275691578670763818348323588650284368938526796065798921972"
+ "8473343486060089420116903707069559015036153836596792711219838611"
+ "0980145546446076750451009956312361722243098053437420272483555539"
+ "7422826546643144133700412148347193404018690918234764633985688961"
+ "7603909548902984778890775141579626656034298049775671944433069073"
+ "7604422038743259373816676164757751587582092333404991820293327212"
+ "5599348679138779961378564655046088380671358199810473933506318818"
+ "4091175893098026050831945120249489444259897725127807943670177161"
+ "6228469603642478614007734439187597872666848076451986069255795298"
+ "8732132513641624634115870738160721633511566723954250399605642781"
+ "1287194322792594125093461156712312786426466050409407761509897584"
+ "8136843040991207538774075715754306035963544889052606784864342758"
+ "900428165258489343614201061427593231201171875",
+ 1.112536929253601e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360143264358512053601829696279729256322446286636762993074885578"
+ "5482848940402484819383308231788212319506475197423260249353326444"
+ "4130717265985540087275830129388183546908748591883986098046865342"
+ "9694440740018214171090142139290408905547397593746087678853434622"
+ "7708807769200010477987555066232823112546765790360487852208850575"
+ "8752599546868752897347409845010678425979078962517411943872958339"
+ "1841626929078828345647733525524686707077165117383988808631340302"
+ "3919811372391502185169818655049136406061931820528945258278945377"
+ "2640279824496362807465448266116748919295441238296611971177785355"
+ "4605209927839760366494651758097211936470402475783551200969719627"
+ "9349765358747644509438842714766105380341358326953487329219653376"
+ "04188641513168478436313080237596295773983001708984375",
+ 1.1125369292536017e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360143264358512053601829696279729256322464871320782889085072085"
+ "5882816605113390968002798115252835988728581456319724432907730915"
+ "9788091045910990754434756551706808078781343347171179484873892074"
+ "8408735933590351591729274322268456088851697134054755085223313705"
+ "7994788991756876822274697984118452821074840662486211070432012189"
+ "9901289544834521015804044548441730195923859875259151943312847604"
+ "6078831819414397317478790886291621826572237901362985796969353392"
+ "2240274065644224408961072655052184431452505441247416583051571936"
+ "1189383755894699564098951411984008394330984751465415998685393549"
+ "2981950252037042118981569077006826000273956875115116332683643956"
+ "9967398203853664384761814691371489127171149929952724258833663970"
+ "9550533979841101562169154890806946368370134291387467238490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 1.1125369292536017e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720138309023271733240406421921598046233183055332741688720443481"
+ "3918195854283159012511020564067339731035811005152434161553460108"
+ "8560123853777188211307779935320023304796101474425836360719215650"
+ "4694250373420837525080665061665815894872049117996859163964850063"
+ "5908770118304874799780887753749949451580451605050915399856582470"
+ "8186451135379358049921159810857660519924333521143523901487956996"
+ "0959128889160299264151106346631339366347758651302937176204732563"
+ "1781485664350872122828637642044846811407613911477062801689853244"
+ "1100241614474216185671661505401542850847167529019031613227788967"
+ "2970737312333408698898317506783884692609277397797285865965494109"
+ "1369095406136467568702398678315290680984617210924625396728515625",
+ 2.2250738585072014e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720138309023271733240406421921598046233201640016761584730629988"
+ "4318163518994065161130510447531963400257917264048898345107864580"
+ "4217497633702638878466706357638647836668696229713029747546242382"
+ "3408545566992974945719797244643863078176348658305526570334729146"
+ "6194751340861741144068030671635579160108526477176638618079744084"
+ "9335141133345126168377794514288712289869114433885263900927846261"
+ "5196333779495868235982163707398274485842831435281934164542745653"
+ "0101948357603594346619891642047894836798187532195534126462479802"
+ "9649345545872552942305164651268802325882711042187835640735397161"
+ "1347477636530690451385234825693498756412831797128850997679418438"
+ "1986728251242487444025370654920674427814408813923862326342526219"
+ "9131669828524253718537846867047316790971834120489029738490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 2.2250738585072014e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720163012305563795567615250361241457301782723638852508948478253"
+ "6359478527325887968267463330520896879809894644538317700857921100"
+ "6186301853550719538022833566910789404427072670695665613121274757"
+ "8429060364284631907291469414840269030938207255937411123218640844"
+ "2207596465763866148192781898983602538637890062203535565726940636"
+ "8590885797139947888926801753953891471985190009050333899757727677"
+ "7175944826990956530177442436600743254820447797901446928043044146"
+ "9470712484503505273622550253384036452803081912355396096061899603"
+ "6581190688828964333914697530672942540435576507112592973908144397"
+ "3967277412027145618759897856109360492194310924094023490247227304"
+ "5306535112923584601741974493579393614104508848422446677399636884"
+ "6007951555248028896005922474205893068160932603143782761509897584"
+ "8136843040991207538774075715754306035963544889052606784864342758"
+ "900428165258489343614201061427593231201171875",
+ 2.2250738585072014e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720163012305563795567615250361241457301801308322872404958664760"
+ "6759446192036794116886953213985520549032000903434781884412325572"
+ "1843675633476170205181759989229413936299667425982858999948301489"
+ "7143355557856769327930601597818316214242506796246078529588519927"
+ "2493577688320732492479924816869232247165964934329258783950102250"
+ "9739575795105716007383436457384943241929970921792073899197616943"
+ "1413149717326525502008499797367678374315520581880443916381057236"
+ "7791175177756227497413804253387084478193655533073867420834526162"
+ "5130294620227301090548200676540202015471120020281397001415752591"
+ "2344017736224427371246815175018974555997865323425588621961151633"
+ "5924167958029604477064946470184777360934300451421683607013647479"
+ "51396213837722826145437693412532098591327667236328125",
+ 2.2250738585072014e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720163012305563795567615250361241457301819893006892300968851267"
+ "7159413856747700265506443097450144218254107162331246067966730043"
+ "7501049413401620872340686411548038468172262181270052386775328221"
+ "5857650751428906748569733780796363397546806336554745935958399010"
+ "2779558910877598836767067734754861955694039806454982002173263865"
+ "0888265793071484125840071160815995011874751834533813898637506208"
+ "5650354607662094473839557158134613493810593365859440904719070326"
+ "6111637871008949721205058253390132503584229153792338745607152721"
+ "3679398551625637847181703822407461490506663533450201028923360785"
+ "0720758060421709123733732493928588619801419722757153753675075962"
+ "6541800803135624352387918446790161107764092054420920536627658074"
+ "4271291212296536333081616208300526650104600844121842238490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 2.225073858507202e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720187715587855857894824078800884868370419561313003121196886039"
+ "9600696529790429221262885863903701367028190801717129607271191035"
+ "5127227413175152199055740043138804567803233377539881639177387328"
+ "9592460742292701130780538133970816533612964474495297895212189790"
+ "9078385258336590185178961879988515042751478263607602168043622031"
+ "1292700454832073964845713103912225963935608322440623896907276890"
+ "1867170545492751739865893248104017382283282512457950656557381910"
+ "3800864691161582871998970864729322144979697154670672039979199080"
+ "9160347625980385995424739847678861180095072511543762389603716215"
+ "1717298160115446043595312843254064419386453249053891377956809158"
+ "0479240509922741385427494262054264040883983691918741817298779334"
+ "0279242767544565229087538682506419718265533447265625",
+ 2.225073858507202e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720187715587855857894824078800884868370438145997023017207072547"
+ "0000664194501335369882375747368325036250297060613593790825595507"
+ "0784601193100602866214666465457429099675828132827075026004414060"
+ "8306755935864838551419670316948863716917264014803965301582068873"
+ "9364366480893456529466104797874144751279553135733325386266783645"
+ "2441390452797842083302347807343277733880389235182363896347166155"
+ "6104375435828320711696950608870952501778355296436947644895395000"
+ "2121327384414305095790224864732370170370270775389143364751825639"
+ "7709451557378722752058242993546120655130616024712566417111324409"
+ "0094038484312727796082230162163678483190007648385456509670733487"
+ "1096873355028761260750466238659647787713775294917978746912789928"
+ "9410912596068818947625385549553736509237367567754654738490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 2.225073858507202e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720212418870147920222032907240528279439019229619113941424920812"
+ "2041979202833158177019328630357258515802274441103013146575652027"
+ "2753405412948683525770793674729570667434204573809710891579446436"
+ "3327270733156495512991342487145269669679122612435849854465980571"
+ "5377211605795581533590856025222168129808916720760222333913980197"
+ "1697135116592663803851355047008456915996464810347433895177047571"
+ "8083986483323409005892229338073421270755971659056460408395693494"
+ "1490091511314216022792883476068511786375165155549005334351245440"
+ "4641296700335134143667775872950260869683481489637323750284071645"
+ "2713838259809182963456893192579540218971486775350629002238542353"
+ "4416680216709858418467070077318366974003875329416563097969900593"
+ "6287194322792594125093461156712312786426466050409407761509897584"
+ "8136843040991207538774075715754306035963544889052606784864342758"
+ "900428165258489343614201061427593231201171875",
+ 2.225073858507202e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720212418870147920222032907240528279439037814303133837435107319"
+ "2441946867544064325638818513821882185024380699999477330130056498"
+ "8410779192874134192929720097048195199306799329096904278406473168"
+ "2041565926728632933630474670123316852983422152744517260835859654"
+ "5663192828352447877877998943107797838336991592885945552137141811"
+ "2845825114558431922307989750439508685941245723089173894616936837"
+ "2321191373658977977723286698840356390251044443035457396733706583"
+ "9810554204566938246584137476071559811765738776267476659123871999"
+ "3190400631733470900301279018817520344719025002806127777791679839"
+ "1090578584006464715943810511489154282775041174682194133952466682"
+ "5034313061815878293790042053923750720833666932415800027583911188"
+ "54188641513168478436313080237596295773983001708984375",
+ 2.2250738585072024e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720212418870147920222032907240528279439056398987153733445293826"
+ "2841914532254970474258308397286505854246486958895941513684460970"
+ "4068152972799584860088646519366819731179394084384097665233499900"
+ "0755861120300770354269606853101364036287721693053184667205738737"
+ "5949174050909314222165141860993427546865066465011668770360303425"
+ "3994515112524200040764624453870560455886026635830913894056826102"
+ "6558396263994546949554344059607291509746117227014454385071719673"
+ "8131016897819660470375391476074607837156312396985947983896498558"
+ "1739504563131807656934782164684779819754568515974931805299288032"
+ "9467318908203746468430727830398768346578595574013759265666391011"
+ "5651945906921898169113014030529134467663458535415036957197921783"
+ "4550533979841101562169154890806946368370134291387467238490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 2.2250738585072024e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000100208418000448638899805402"
+ "5675081023947173151201955956352756465219477298834774949553868001"
+ "7172354813827222283890479851867436841402279176933922227531985191"
+ "9016883548022442028316027357265612083085166971723487691494714589"
+ "5578331812936322386545483369746322848628024994920311121080242823"
+ "5714326388663336759990619917681011604908667604621058852897083245"
+ "0816977893343649540492907374306035456728456338904015275857972276"
+ "1526157631250497160973795706924168310120033199859199012414074894"
+ "8202195091387650850548954516920927386376492603899633528627985383"
+ "2932104496700123254769405070337764094630065313795728259355401668"
+ "8207267296623786504114239553488532354086348874488976434804499149"
+ "322509765625",
+ 1.0020841800044864e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000100208418000448638899805402"
+ "5675081023947173151201956040050732492021560444211472901925540702"
+ "1586014286915762763038748010206109436411449756840422987132589595"
+ "3085274649978096343836685185731606312366412920027708756586099963"
+ "7975552653362983131506665648352778744386705639822064232334712197"
+ "7867779247842315182877112028658635902319185766818606103345104073"
+ "9923514010434512590195330770391813338086311968111531328662618487"
+ "3315578521649250253839821623536466419018719481428679013982985346"
+ "1571995354000952600076951720089726239270930511481845755671197870"
+ "4747866889418540057514218596081876158765839665014133210631738825"
+ "4165335079883777074977685931654819161553596657523084699300803458"
+ "3609637179288099118793858900152420545987239088654699259390735847"
+ "0152049332041520812604025151794328168042160636342216519487980314"
+ "421878240614097350935640662328296457417309284210205078125",
+ 1.0020841800044864e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000100208418000448650025174695"
+ "1035150178458809017822159083615579461533985681124447841542417041"
+ "9717793267880261310997721975562434111911014099603638548708110842"
+ "9228554372955381818449259496459629506201971760632184806762937040"
+ "5528236159220080404124633621972774900305368909016987591808198481"
+ "1515258588636795736994571683578362033288375244948969302377353651"
+ "5803667343942465515751063883649087835332767470268261173797304563"
+ "0216301185431893700183322963627539884395226243941187598947530725"
+ "0723137660949785162435276134774551939185861652055952702429699518"
+ "1666462911218814544860422297294423455917874727086839114692958995"
+ "8734568169530500282699951928714187892923739790353511103290941894"
+ "8525105836280134665557340439005224794505069516807613438973521965"
+ "4847950667958479187395974848205671831957839363657783480512019685"
+ "578121759385902649064359337671703542582690715789794921875",
+ 1.0020841800044864e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000100208418000448650025174695"
+ "1035150178458809017822159167313555488336068826501145793914089742"
+ "4131452740968801790145990133901106706920184679510139308308715246"
+ "3296945474911036133969917324925623735483217708936405871854322414"
+ "7925456999646741149085815900579230796064049553918740703062667855"
+ "3668711447815774159881063794555986330698893407146516552825374480"
+ "4910203461033328565453487279734865716690623099475777226601950774"
+ "2005722075830646793049348880239837993293912525510667600516441176"
+ "4092937923563086911963273337943350792080299559638164929472912005"
+ "3482225303937231347605235823038535520053649078305244065969296152"
+ "4692635952790490853563398306880474700390987573387619367787246203"
+ "8909645359318233784351199339157645340492308605462312698364257812"
+ "5",
+ 1.0020841800044864e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000100208418000448650025174695"
+ "1035150178458809017822159251011531515138151971877843746285762442"
+ "8545112214057342269294258292239779301929355259416640067909319649"
+ "7365336576866690449490575153391617964764463657240626936945707789"
+ "0322677840073401894046998179185686691822730198820493814317137229"
+ "5822164306994752582767555905533610628109411569344063803273395309"
+ "4016739578124191615155910675820643598048478728683293279406596985"
+ "3795142966229399885915374796852136102192598807080147602085351627"
+ "7462738186176388661491270541112149644974737467220377156516124492"
+ "5297987696655648150350049348782647584189423429523649017245633309"
+ "0650703736050481424426844685046761507858235356421727632283550512"
+ "9294184882356332903145058239310065886479547694117011957754993659"
+ "5152049332041520812604025151794328168042160636342216519487980314"
+ "421878240614097350935640662328296457417309284210205078125",
+ 1.0020841800044866e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000200416836000897255548872220"
+ "0630023738871074569163505490783914884205771542336808210387292522"
+ "0426513773371285555269939139667533951768747348715410293510510274"
+ "9473643242267695845324274779211200861374232469021139022270213528"
+ "6462413252451807248010301677826829802384000871843763078195635583"
+ "5519882659021798720200352081612073758236883604191202305937584019"
+ "3447504651307941031064654937754410393532579156664506650227987556"
+ "2093186373340695057796485067216997253892307748415460848623417226"
+ "4622904518424429578269271391797007961345371296322204255566117522"
+ "4763967378926030323867148635273985338412963098572424905483014370"
+ "3443797280914164309330161600193180015563420351180667003643504189"
+ "5081099906363532431297601321684709319015382789075374603271484375",
+ 2.0041683600089726e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000200416836000897255548872220"
+ "0630023738871074569163505574481890911007854687713506162758965222"
+ "4840173246459826034418207298006206546777917928621911053111114678"
+ "3542034344223350160844932607677195090655478417325360087361598902"
+ "8859634092878467992971483956433285698142681516745516189450104957"
+ "7673335518200777143086844192589698055647401766388749556385604848"
+ "2554040768398804080767078333840188274890434785872022703032633767"
+ "3882607263739448150662510983829295362790994029984940850192327677"
+ "7992704781037731327797268594965806814239809203904416482609330009"
+ "6579729771644447126611962161018097402548737449790829856759351526"
+ "9401865064174154880193607978359466823030668134214775268139808498"
+ "5465639429401631550091460221837129865002621877730073862662220222"
+ "0152049332041520812604025151794328168042160636342216519487980314"
+ "421878240614097350935640662328296457417309284210205078125",
+ 2.0041683600089726e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000200416836000897266674241512"
+ "5990092893382710435783708618046737880520279924626481102375841562"
+ "2971952227424324582377181263362531222277482271385126614686635925"
+ "9685314067200635635457506918405218284491037257929836137538435979"
+ "6412317598735565265589451930053281854061344785940439548923591241"
+ "1320814858995257697204303847509424186616591244519112755417854425"
+ "8434194101906757006322811447097462772136890288028752548167319843"
+ "0783329927522091597006012323920368828167500792497449435156873056"
+ "7143847087986563890155593009650632514154740344478523429367831657"
+ "3498325793444721613958165862230644699700772511863535760820571697"
+ "3971098153820878087915873975418835554400811267045201672129946935"
+ "0381108086393667096854941760689934113520452305882988042245006340"
+ "4847950667958479187395974848205671831957839363657783480512019685"
+ "578121759385902649064359337671703542582690715789794921875",
+ 2.0041683600089726e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000200416836000897266674241512"
+ "5990092893382710435783708701744713907322363070003179054747514262"
+ "7385611700512865061525449421701203817286652851291627374287240329"
+ "3753705169156289950978164746871212513772283206234057202629821353"
+ "8809538439162226010550634208659737749820025430842192660178060615"
+ "3474267718174236120090795958487048484027109406716660005865875254"
+ "7540730218997620056025234843183240653494745917236268600971966054"
+ "2572750817920844689872038240532666937066187074066929436725783508"
+ "0513647350599865639683590212819431367049178252060735656411044144"
+ "5314088186163138416702979387974756763836546863081940712096908853"
+ "9929165937080868658779320353585122361868059050079309936626251244"
+ "0765647609431766215648800660842354659507691394537687301635742187"
+ "5",
+ 2.004168360008973e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000200416836000897266674241512"
+ "5990092893382710435783708785442689934124446215379877007119186963"
+ "1799271173601405540673717580039876412295823431198128133887844732"
+ "7822096271111944266498822575337206743053529154538278267721206728"
+ "1206759279588886755511816487266193645578706075743945771432529989"
+ "5627720577353214542977288069464672781437627568914207256313896083"
+ "6647266336088483105727658239269018534852601546443784653776612265"
+ "4362171708319597782738064157144965045964873355636409438294693959"
+ "3883447613213167389211587415988230219943616159642947883454256631"
+ "7129850578881555219447792913718868827972321214300345663373246010"
+ "5887233720340859229642766731751409169335306833113418201122555553"
+ "1150187132469865334442659560994775205494930483192386561026478034"
+ "5152049332041520812604025151794328168042160636342216519487980314"
+ "421878240614097350935640662328296457417309284210205078125",
+ 2.004168360008973e-292);
+ testParse("0.99999999999999988897769753748434595763683319091796875",
+ 0.9999999999999999);
+ testParse(
+ "0.99999999999999988897769753748434595763683319091796879176194859"
+ "5190556970945882299241904356487451251641385905655273315006228765"
+ "423911854226535211864757002331316471099853515625",
+ 0.9999999999999999);
+ testParse(
+ "0.99999999999999994448884876874217297881841659545898433323805140"
+ "4809443029054117700758095643512548748358614094344726684993771234"
+ "576088145773464788135242997668683528900146484375",
+ 0.9999999999999999);
+ testParse(
+ "0.999999999999999944488848768742172978818416595458984375",
+ 1.0);
+ testParse(
+ "0.99999999999999994448884876874217297881841659545898441676194859"
+ "5190556970945882299241904356487451251641385905655273315006228765"
+ "423911854226535211864757002331316471099853515625",
+ 1.0);
+ testParse("0.499999999999999944488848768742172978818416595458984375",
+ 0.49999999999999994);
+ testParse(
+ "0.49999999999999994448884876874217297881841659545898439588097429"
+ "7595278485472941149620952178243725625820692952827636657503114382"
+ "7119559271132676059323785011656582355499267578125",
+ 0.49999999999999994);
+ testParse(
+ "0.49999999999999997224442438437108648940920829772949216661902570"
+ "2404721514527058850379047821756274374179307047172363342496885617"
+ "2880440728867323940676214988343417644500732421875",
+ 0.49999999999999994);
+ testParse(
+ "0.4999999999999999722444243843710864894092082977294921875",
+ 0.5);
+ testParse(
+ "0.49999999999999997224442438437108648940920829772949220838097429"
+ "7595278485472941149620952178243725625820692952827636657503114382"
+ "7119559271132676059323785011656582355499267578125",
+ 0.5);
+ testParse("1.9999999999999997779553950749686919152736663818359375",
+ 1.9999999999999998);
+ testParse(
+ "1.99999999999999977795539507496869191527366638183593758352389719"
+ "0381113941891764598483808712974902503282771811310546630012457530"
+ "84782370845307042372951400466263294219970703125",
+ 1.9999999999999998);
+ testParse(
+ "1.99999999999999988897769753748434595763683319091796866647610280"
+ "9618886058108235401516191287025097496717228188689453369987542469"
+ "15217629154692957627048599533736705780029296875",
+ 1.9999999999999998);
+ testParse(
+ "1.99999999999999988897769753748434595763683319091796875",
+ 2.0);
+ testParse(
+ "1.99999999999999988897769753748434595763683319091796883352389719"
+ "0381113941891764598483808712974902503282771811310546630012457530"
+ "84782370845307042372951400466263294219970703125",
+ 2.0);
+ testParse("4503599627370495.5", 4503599627370495.5);
+ testParse(
+ "4503599627370495.50000000000000000000000000000000000018807909613"
+ "1566001274997845955559308450986489083534003441400273004546761512"
+ "75634765625",
+ 4503599627370495.5);
+ testParse(
+ "4503599627370495.74999999999999999999999999999999999981192090386"
+ "8433998725002154044440691549013510916465996558599726995453238487"
+ "24365234375",
+ 4503599627370495.5);
+ testParse("4503599627370495.75", 4503599627370496.0);
+ testParse(
+ "4503599627370495.75000000000000000000000000000000000018807909613"
+ "1566001274997845955559308450986489083534003441400273004546761512"
+ "75634765625",
+ 4503599627370496.0);
+ testParse("4503599627370496", 4503599627370496.0);
+ testParse(
+ "4503599627370496.00000000000000000000000000000000000037615819226"
+ "3132002549995691911118616901972978167068006882800546009093523025"
+ "5126953125",
+ 4503599627370496.0);
+ testParse(
+ "4503599627370496.49999999999999999999999999999999999962384180773"
+ "6867997450004308088881383098027021832931993117199453990906476974"
+ "4873046875",
+ 4503599627370496.0);
+ testParse("4503599627370496.5", 4503599627370496.0);
+ testParse(
+ "4503599627370496.50000000000000000000000000000000000037615819226"
+ "3132002549995691911118616901972978167068006882800546009093523025"
+ "5126953125",
+ 4503599627370497.0);
+ testParse("9007199254740991", 9007199254740991.0);
+ testParse(
+ "9007199254740991.00000000000000000000000000000000000037615819226"
+ "3132002549995691911118616901972978167068006882800546009093523025"
+ "5126953125",
+ 9007199254740991.0);
+ testParse(
+ "9007199254740991.49999999999999999999999999999999999962384180773"
+ "6867997450004308088881383098027021832931993117199453990906476974"
+ "4873046875",
+ 9007199254740991.0);
+ testParse("9007199254740991.5", 9007199254740992.0);
+ testParse(
+ "9007199254740991.50000000000000000000000000000000000037615819226"
+ "3132002549995691911118616901972978167068006882800546009093523025"
+ "5126953125",
+ 9007199254740992.0);
+ testParse(
+ "1797693134862315708145274237317043567980705675258449965989174768"
+ "0315726078002853876058955863276687817154045895351438246423432132"
+ "6889464182768467546703537516986049910576551282076245490090389328"
+ "9440758685084551339423045832369032229481658085593321233482747978"
+ "26204144723168738177180919299881250404026184124858368",
+ 1.7976931348623157e+308);
+ testParse(
+ "1797693134862315708145274237317043567980705675258450041064343056"
+ "0785749075118623426984641994452647172104399563141377322686588394"
+ "6121172130178666127034918365540069095282013901258936156392632590"
+ "7055367751483602939820315058278058002847941584484775356682545657"
+ "44106770877499077221865536419145864291265781790932992",
+ 1.7976931348623157e+308);
+ testParse(
+ "1797693134862315807937289714053034150799341327100378194286569501"
+ "7574473832160705543739215666582761354682674973879349714831499292"
+ "8620232455220458908340124972127889717295245764493583188543574449"
+ "7703035690903649098158444443687202655781915109457910629727393062"
+ "50541739356374003666875082388828428992938306508423168",
+ 1.7976931348623157e+308);
+ testParse(
+ "1797693134862315807937289714053034150799341327100378269361737789"
+ "8044496829276475094664901797758720709633028641669288791094655554"
+ "7851940402630657488671505820681908902000708383676273854845817711"
+ "5317644757302700698555713669596228429148198608349364752927190741"
+ "68444365510704342711559699508093042880177904174497792",
+ double.infinity);
+ testParse(
+ "1797693134862315807937289714053034150799341327100378344436906077"
+ "8514519826392244645590587928934680064583382309459227867357811816"
+ "7083648350040856069002886669235928086706171002858964521148060973"
+ "2932253823701752298952982895505254202514482107240818876126988420"
+ "86346991665034681756244316627357656767417501840572416",
+ double.infinity);
+
+ // Edge cases of algorithm (e+-22/23).
+ testParse("1e22", 1e22);
+ testParse("1e23", 1e23);
+ testParse("1e-22", 1e-22);
+ testParse("1e-23", 1e-23);
+
+ testParseWhitespace("1", 1.0);
+ testParseWhitespace("1.0", 1.0);
+ testParseWhitespace("1e1", 10.0);
+ testParseWhitespace(".1e1", 1.0);
+ testParseWhitespace("1.e1", 10.0);
+ testParseWhitespace("1e+1", 10.0);
+ testParseWhitespace("1e-1", 0.1);
+
+ // Negative tests - things not to allow.
+
+ // Spaces inside the numeral.
+ testFail("- 1");
+ testFail("+ 1");
+ testFail("2 2");
+ testFail("1 .");
+ testFail(". 1");
+ testFail("1e 2");
+ testFail("1 e2");
+ // Invalid characters.
+ testFail("0x0");
+ testFail("0x1H");
+ testFail("12H");
+ testFail("1x2");
+ testFail("00x2");
+ testFail("0x2.2");
+ // Double exponent without value.
+ testFail(".e1");
+ testFail("e1");
+ testFail("e+1");
+ testFail("e-1");
+ testFail("-e1");
+ testFail("-e+1");
+ testFail("-e-1");
+ // Too many signs.
+ testFail("--1");
+ testFail("-+1");
+ testFail("+-1");
+ testFail("++1");
+ // Incorrect ways to write NaN/Infinity.
+ testFail("infinity");
+ testFail("INFINITY");
+ testFail("1.#INF");
+ testFail("inf");
+ testFail("nan");
+ testFail("NAN");
+ testFail("1.#IND");
+ testFail("indef");
+ testFail("qnan");
+ testFail("snan");
+}
diff --git a/tests/corelib/double_round2_test.dart b/tests/corelib/double_round2_test.dart
new file mode 100644
index 0000000..3fd59b1
--- /dev/null
+++ b/tests/corelib/double_round2_test.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.throwsUnsupportedError(() => double.infinity.round());
+ Expect.throwsUnsupportedError(() => double.negativeInfinity.round());
+ Expect.throwsUnsupportedError(() => double.nan.round());
+}
diff --git a/tests/corelib/double_round3_test.dart b/tests/corelib/double_round3_test.dart
new file mode 100644
index 0000000..a1edeeb
--- /dev/null
+++ b/tests/corelib/double_round3_test.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0, 0.49999999999999994.round());
+ Expect.equals(0, (-0.49999999999999994).round());
+ Expect.isTrue(0.49999999999999994.round() is int);
+ Expect.isTrue((-0.49999999999999994).round() is int);
+}
diff --git a/tests/corelib/double_round4_test.dart b/tests/corelib/double_round4_test.dart
new file mode 100644
index 0000000..2b89dcc
--- /dev/null
+++ b/tests/corelib/double_round4_test.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ // The following numbers are on the border of 52 bits.
+ // For example: 4503599627370499 + 0.5 => 4503599627370500.
+ Expect.equals(4503599627370496, 4503599627370496.0.round());
+ Expect.equals(4503599627370497, 4503599627370497.0.round());
+ Expect.equals(4503599627370498, 4503599627370498.0.round());
+ Expect.equals(4503599627370499, 4503599627370499.0.round());
+
+ Expect.equals(9007199254740991, 9007199254740991.0.round());
+ Expect.equals(9007199254740992, 9007199254740992.0.round());
+
+ Expect.equals(-4503599627370496, (-4503599627370496.0).round());
+ Expect.equals(-4503599627370497, (-4503599627370497.0).round());
+ Expect.equals(-4503599627370498, (-4503599627370498.0).round());
+ Expect.equals(-4503599627370499, (-4503599627370499.0).round());
+
+ Expect.equals(-9007199254740991, (-9007199254740991.0).round());
+ Expect.equals(-9007199254740992, (-9007199254740992.0).round());
+
+ Expect.isTrue(4503599627370496.0.round() is int);
+ Expect.isTrue(4503599627370497.0.round() is int);
+ Expect.isTrue(4503599627370498.0.round() is int);
+ Expect.isTrue(4503599627370499.0.round() is int);
+ Expect.isTrue(9007199254740991.0.round() is int);
+ Expect.isTrue(9007199254740992.0.round() is int);
+ Expect.isTrue((-4503599627370496.0).round() is int);
+ Expect.isTrue((-4503599627370497.0).round() is int);
+ Expect.isTrue((-4503599627370498.0).round() is int);
+ Expect.isTrue((-4503599627370499.0).round() is int);
+ Expect.isTrue((-9007199254740991.0).round() is int);
+ Expect.isTrue((-9007199254740992.0).round() is int);
+}
diff --git a/tests/corelib/double_round_test.dart b/tests/corelib/double_round_test.dart
new file mode 100644
index 0000000..f40dcd8
--- /dev/null
+++ b/tests/corelib/double_round_test.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0, 0.0.round());
+ Expect.equals(0, double.minPositive.round());
+ Expect.equals(0, (2.0 * double.minPositive).round());
+ Expect.equals(0, (1.18e-38).round());
+ Expect.equals(0, (1.18e-38 * 2).round());
+ Expect.equals(1, 0.5.round());
+ Expect.equals(1, 0.9999999999999999.round());
+ Expect.equals(1, 1.0.round());
+ Expect.equals(1, 1.000000000000001.round());
+ Expect.equals(9223372036854775807, double.maxFinite.round()); // //# int64: ok
+
+ Expect.equals(0, (-double.minPositive).round());
+ Expect.equals(0, (2.0 * -double.minPositive).round());
+ Expect.equals(0, (-1.18e-38).round());
+ Expect.equals(0, (-1.18e-38 * 2).round());
+ Expect.equals(-1, (-0.5).round());
+ Expect.equals(-1, (-0.9999999999999999).round());
+ Expect.equals(-1, (-1.0).round());
+ Expect.equals(-1, (-1.000000000000001).round());
+ Expect.equals(-9223372036854775808, (-double.maxFinite).round()); // //# int64: ok
+
+ Expect.isTrue(0.0.round() is int);
+ Expect.isTrue(double.minPositive.round() is int);
+ Expect.isTrue((2.0 * double.minPositive).round() is int);
+ Expect.isTrue((1.18e-38).round() is int);
+ Expect.isTrue((1.18e-38 * 2).round() is int);
+ Expect.isTrue(0.5.round() is int);
+ Expect.isTrue(0.9999999999999999.round() is int);
+ Expect.isTrue(1.0.round() is int);
+ Expect.isTrue(1.000000000000001.round() is int);
+ Expect.isTrue(double.maxFinite.round() is int);
+
+ Expect.isTrue((-double.minPositive).round() is int);
+ Expect.isTrue((2.0 * -double.minPositive).round() is int);
+ Expect.isTrue((-1.18e-38).round() is int);
+ Expect.isTrue((-1.18e-38 * 2).round() is int);
+ Expect.isTrue((-0.5).round() is int);
+ Expect.isTrue((-0.9999999999999999).round() is int);
+ Expect.isTrue((-1.0).round() is int);
+ Expect.isTrue((-1.000000000000001).round() is int);
+ Expect.isTrue((-double.maxFinite).round() is int);
+}
diff --git a/tests/corelib/double_round_to_double2_test.dart b/tests/corelib/double_round_to_double2_test.dart
new file mode 100644
index 0000000..ef8024db
--- /dev/null
+++ b/tests/corelib/double_round_to_double2_test.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0.0, 0.49999999999999994.roundToDouble());
+ Expect.equals(0.0, (-0.49999999999999994).roundToDouble());
+ Expect.isTrue(0.49999999999999994.roundToDouble() is double);
+ Expect.isTrue((-0.49999999999999994).roundToDouble().isNegative);
+ Expect.isTrue((-0.49999999999999994).roundToDouble() is double);
+}
diff --git a/tests/corelib/double_round_to_double3_test.dart b/tests/corelib/double_round_to_double3_test.dart
new file mode 100644
index 0000000..c53ac81
--- /dev/null
+++ b/tests/corelib/double_round_to_double3_test.dart
@@ -0,0 +1,34 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ // The following numbers are on the border of 52 bits.
+ // For example: 4503599627370499 + 0.5 => 4503599627370500.
+ Expect.equals(4503599627370496.0, 4503599627370496.0.roundToDouble());
+ Expect.equals(4503599627370497.0, 4503599627370497.0.roundToDouble());
+ Expect.equals(4503599627370498.0, 4503599627370498.0.roundToDouble());
+ Expect.equals(4503599627370499.0, 4503599627370499.0.roundToDouble());
+ Expect.equals(9007199254740991.0, 9007199254740991.0.roundToDouble());
+ Expect.equals(9007199254740992.0, 9007199254740992.0.roundToDouble());
+ Expect.equals(-4503599627370496.0, (-4503599627370496.0).roundToDouble());
+ Expect.equals(-4503599627370497.0, (-4503599627370497.0).roundToDouble());
+ Expect.equals(-4503599627370498.0, (-4503599627370498.0).roundToDouble());
+ Expect.equals(-4503599627370499.0, (-4503599627370499.0).roundToDouble());
+ Expect.equals(-9007199254740991.0, (-9007199254740991.0).roundToDouble());
+ Expect.equals(-9007199254740992.0, (-9007199254740992.0).roundToDouble());
+ Expect.isTrue(4503599627370496.0.roundToDouble() is double);
+ Expect.isTrue(4503599627370497.0.roundToDouble() is double);
+ Expect.isTrue(4503599627370498.0.roundToDouble() is double);
+ Expect.isTrue(4503599627370499.0.roundToDouble() is double);
+ Expect.isTrue(9007199254740991.0.roundToDouble() is double);
+ Expect.isTrue(9007199254740992.0.roundToDouble() is double);
+ Expect.isTrue((-4503599627370496.0).roundToDouble() is double);
+ Expect.isTrue((-4503599627370497.0).roundToDouble() is double);
+ Expect.isTrue((-4503599627370498.0).roundToDouble() is double);
+ Expect.isTrue((-4503599627370499.0).roundToDouble() is double);
+ Expect.isTrue((-9007199254740991.0).roundToDouble() is double);
+ Expect.isTrue((-9007199254740992.0).roundToDouble() is double);
+}
diff --git a/tests/corelib/double_round_to_double_test.dart b/tests/corelib/double_round_to_double_test.dart
new file mode 100644
index 0000000..16c162d
--- /dev/null
+++ b/tests/corelib/double_round_to_double_test.dart
@@ -0,0 +1,62 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0.0, 0.0.roundToDouble());
+ Expect.equals(0.0, double.minPositive.roundToDouble());
+ Expect.equals(0.0, (2.0 * double.minPositive).roundToDouble());
+ Expect.equals(0.0, (1.18e-38).roundToDouble());
+ Expect.equals(0.0, (1.18e-38 * 2).roundToDouble());
+ Expect.equals(1.0, 0.5.roundToDouble());
+ Expect.equals(1.0, 0.9999999999999999.roundToDouble());
+ Expect.equals(1.0, 1.0.roundToDouble());
+ Expect.equals(1.0, 1.000000000000001.roundToDouble());
+ Expect.equals(2.0, 1.5.roundToDouble());
+
+ Expect.equals(double.maxFinite, double.maxFinite.roundToDouble());
+
+ Expect.equals(0.0, (-double.minPositive).roundToDouble());
+ Expect.equals(0.0, (2.0 * -double.minPositive).roundToDouble());
+ Expect.equals(0.0, (-1.18e-38).roundToDouble());
+ Expect.equals(0.0, (-1.18e-38 * 2).roundToDouble());
+ Expect.equals(-1.0, (-0.5).roundToDouble());
+ Expect.equals(-1.0, (-0.9999999999999999).roundToDouble());
+ Expect.equals(-1.0, (-1.0).roundToDouble());
+ Expect.equals(-1.0, (-1.000000000000001).roundToDouble());
+ Expect.equals(-2.0, (-1.5).roundToDouble());
+ Expect.equals(-double.maxFinite, (-double.maxFinite).roundToDouble());
+
+ Expect.equals(double.infinity, double.infinity.roundToDouble());
+ Expect.equals(
+ double.negativeInfinity, double.negativeInfinity.roundToDouble());
+ Expect.isTrue(double.nan.roundToDouble().isNaN);
+
+ Expect.isTrue(0.0.roundToDouble() is double);
+ Expect.isTrue(double.minPositive.roundToDouble() is double);
+ Expect.isTrue((2.0 * double.minPositive).roundToDouble() is double);
+ Expect.isTrue((1.18e-38).roundToDouble() is double);
+ Expect.isTrue((1.18e-38 * 2).roundToDouble() is double);
+ Expect.isTrue(0.5.roundToDouble() is double);
+ Expect.isTrue(0.9999999999999999.roundToDouble() is double);
+ Expect.isTrue(1.0.roundToDouble() is double);
+ Expect.isTrue(1.000000000000001.roundToDouble() is double);
+ Expect.isTrue(double.maxFinite.roundToDouble() is double);
+
+ Expect.isTrue((-double.minPositive).roundToDouble().isNegative);
+ Expect.isTrue((2.0 * -double.minPositive).roundToDouble().isNegative);
+ Expect.isTrue((-1.18e-38).roundToDouble().isNegative);
+ Expect.isTrue((-1.18e-38 * 2).roundToDouble().isNegative);
+
+ Expect.isTrue((-double.minPositive).roundToDouble() is double);
+ Expect.isTrue((2.0 * -double.minPositive).roundToDouble() is double);
+ Expect.isTrue((-1.18e-38).roundToDouble() is double);
+ Expect.isTrue((-1.18e-38 * 2).roundToDouble() is double);
+ Expect.isTrue((-0.5).roundToDouble() is double);
+ Expect.isTrue((-0.9999999999999999).roundToDouble() is double);
+ Expect.isTrue((-1.0).roundToDouble() is double);
+ Expect.isTrue((-1.000000000000001).roundToDouble() is double);
+ Expect.isTrue((-double.maxFinite).roundToDouble() is double);
+}
diff --git a/tests/corelib/double_truncate2_test.dart b/tests/corelib/double_truncate2_test.dart
new file mode 100644
index 0000000..b4b33e8
--- /dev/null
+++ b/tests/corelib/double_truncate2_test.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.throwsUnsupportedError(() => double.infinity.truncate());
+ Expect.throwsUnsupportedError(() => double.negativeInfinity.truncate());
+ Expect.throwsUnsupportedError(() => double.nan.truncate());
+}
diff --git a/tests/corelib/double_truncate_test.dart b/tests/corelib/double_truncate_test.dart
new file mode 100644
index 0000000..4de6a79
--- /dev/null
+++ b/tests/corelib/double_truncate_test.dart
@@ -0,0 +1,88 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0, 0.0.truncate());
+ Expect.equals(0, double.minPositive.truncate());
+ Expect.equals(0, (2.0 * double.minPositive).truncate());
+ Expect.equals(0, (1.18e-38).truncate());
+ Expect.equals(0, (1.18e-38 * 2).truncate());
+ Expect.equals(0, 0.49999999999999994.truncate());
+ Expect.equals(0, 0.5.truncate());
+ Expect.equals(0, 0.9999999999999999.truncate());
+ Expect.equals(1, 1.0.truncate());
+ Expect.equals(1, 1.000000000000001.truncate());
+ // The following numbers are on the border of 52 bits.
+ // For example: 4503599627370499 + 0.5 => 4503599627370500.
+ Expect.equals(4503599627370496, 4503599627370496.0.truncate());
+ Expect.equals(4503599627370497, 4503599627370497.0.truncate());
+ Expect.equals(4503599627370498, 4503599627370498.0.truncate());
+ Expect.equals(4503599627370499, 4503599627370499.0.truncate());
+
+ Expect.equals(9007199254740991, 9007199254740991.0.truncate());
+ Expect.equals(9007199254740992, 9007199254740992.0.truncate());
+ Expect.equals(9223372036854775807, double.maxFinite.truncate()); // //# int64: ok
+
+ Expect.equals(0, (-double.minPositive).truncate());
+ Expect.equals(0, (2.0 * -double.minPositive).truncate());
+ Expect.equals(0, (-1.18e-38).truncate());
+ Expect.equals(0, (-1.18e-38 * 2).truncate());
+ Expect.equals(0, (-0.49999999999999994).truncate());
+ Expect.equals(0, (-0.5).truncate());
+ Expect.equals(0, (-0.9999999999999999).truncate());
+ Expect.equals(-1, (-1.0).truncate());
+ Expect.equals(-1, (-1.000000000000001).truncate());
+ Expect.equals(-4503599627370496, (-4503599627370496.0).truncate());
+ Expect.equals(-4503599627370497, (-4503599627370497.0).truncate());
+ Expect.equals(-4503599627370498, (-4503599627370498.0).truncate());
+ Expect.equals(-4503599627370499, (-4503599627370499.0).truncate());
+ Expect.equals(-9007199254740991, (-9007199254740991.0).truncate());
+ Expect.equals(-9007199254740992, (-9007199254740992.0).truncate());
+ Expect.equals(-9223372036854775808, (-double.maxFinite).truncate()); // //# int64: ok
+
+ Expect.isTrue(0.0.truncate() is int);
+ Expect.isTrue(double.minPositive.truncate() is int);
+ Expect.isTrue((2.0 * double.minPositive).truncate() is int);
+ Expect.isTrue((1.18e-38).truncate() is int);
+ Expect.isTrue((1.18e-38 * 2).truncate() is int);
+ Expect.isTrue(0.49999999999999994.truncate() is int);
+ Expect.isTrue(0.5.truncate() is int);
+ Expect.isTrue(0.9999999999999999.truncate() is int);
+ Expect.isTrue(1.0.truncate() is int);
+ Expect.isTrue(1.000000000000001.truncate() is int);
+ Expect.isTrue(4503599627370496.0.truncate() is int);
+ Expect.isTrue(4503599627370497.0.truncate() is int);
+ Expect.isTrue(4503599627370498.0.truncate() is int);
+ Expect.isTrue(4503599627370499.0.truncate() is int);
+ Expect.isTrue(9007199254740991.0.truncate() is int);
+ Expect.isTrue(9007199254740992.0.truncate() is int);
+ Expect.isTrue(double.maxFinite.truncate() is int);
+
+ Expect.isTrue((-double.minPositive).truncateToDouble().isNegative);
+ Expect.isTrue((2.0 * -double.minPositive).truncateToDouble().isNegative);
+ Expect.isTrue((-1.18e-38).truncateToDouble().isNegative);
+ Expect.isTrue((-1.18e-38 * 2).truncateToDouble().isNegative);
+ Expect.isTrue((-0.49999999999999994).truncateToDouble().isNegative);
+ Expect.isTrue((-0.5).truncateToDouble().isNegative);
+ Expect.isTrue((-0.9999999999999999).truncateToDouble().isNegative);
+
+ Expect.isTrue((-double.minPositive).truncate() is int);
+ Expect.isTrue((2.0 * -double.minPositive).truncate() is int);
+ Expect.isTrue((-1.18e-38).truncate() is int);
+ Expect.isTrue((-1.18e-38 * 2).truncate() is int);
+ Expect.isTrue((-0.49999999999999994).truncate() is int);
+ Expect.isTrue((-0.5).truncate() is int);
+ Expect.isTrue((-0.9999999999999999).truncate() is int);
+ Expect.isTrue((-1.0).truncate() is int);
+ Expect.isTrue((-1.000000000000001).truncate() is int);
+ Expect.isTrue((-4503599627370496.0).truncate() is int);
+ Expect.isTrue((-4503599627370497.0).truncate() is int);
+ Expect.isTrue((-4503599627370498.0).truncate() is int);
+ Expect.isTrue((-4503599627370499.0).truncate() is int);
+ Expect.isTrue((-9007199254740991.0).truncate() is int);
+ Expect.isTrue((-9007199254740992.0).truncate() is int);
+ Expect.isTrue((-double.maxFinite).truncate() is int);
+}
diff --git a/tests/corelib/double_truncate_to_double_test.dart b/tests/corelib/double_truncate_to_double_test.dart
new file mode 100644
index 0000000..1efec34
--- /dev/null
+++ b/tests/corelib/double_truncate_to_double_test.dart
@@ -0,0 +1,85 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ Expect.equals(0.0, 0.0.truncateToDouble());
+ Expect.equals(0.0, double.minPositive.truncateToDouble());
+ Expect.equals(0.0, (2.0 * double.minPositive).truncateToDouble());
+ Expect.equals(0.0, (1.18e-38).truncateToDouble());
+ Expect.equals(0.0, (1.18e-38 * 2).truncateToDouble());
+ Expect.equals(0.0, 0.49999999999999994.truncateToDouble());
+ Expect.equals(0.0, 0.5.truncateToDouble());
+ Expect.equals(0.0, 0.9999999999999999.truncateToDouble());
+ Expect.equals(1.0, 1.0.truncateToDouble());
+ Expect.equals(1.0, 1.000000000000001.truncateToDouble());
+ // The following numbers are on the border of 52 bits.
+ // For example: 4503599627370499 + 0.5 => 4503599627370500.
+ Expect.equals(4503599627370496.0, 4503599627370496.0.truncateToDouble());
+ Expect.equals(4503599627370497.0, 4503599627370497.0.truncateToDouble());
+ Expect.equals(4503599627370498.0, 4503599627370498.0.truncateToDouble());
+ Expect.equals(4503599627370499.0, 4503599627370499.0.truncateToDouble());
+
+ Expect.equals(9007199254740991.0, 9007199254740991.0.truncateToDouble());
+ Expect.equals(9007199254740992.0, 9007199254740992.0.truncateToDouble());
+ Expect.equals(double.maxFinite, double.maxFinite.truncateToDouble());
+
+ Expect.equals(0.0, (-double.minPositive).truncateToDouble());
+ Expect.equals(0.0, (2.0 * -double.minPositive).truncateToDouble());
+ Expect.equals(0.0, (-1.18e-38).truncateToDouble());
+ Expect.equals(0.0, (-1.18e-38 * 2).truncateToDouble());
+ Expect.equals(0.0, (-0.49999999999999994).truncateToDouble());
+ Expect.equals(0.0, (-0.5).truncateToDouble());
+ Expect.equals(0.0, (-0.9999999999999999).truncateToDouble());
+ Expect.equals(-1.0, (-1.0).truncateToDouble());
+ Expect.equals(-1.0, (-1.000000000000001).truncateToDouble());
+ Expect.equals(-4503599627370496.0, (-4503599627370496.0).truncateToDouble());
+ Expect.equals(-4503599627370497.0, (-4503599627370497.0).truncateToDouble());
+ Expect.equals(-4503599627370498.0, (-4503599627370498.0).truncateToDouble());
+ Expect.equals(-4503599627370499.0, (-4503599627370499.0).truncateToDouble());
+ Expect.equals(-9007199254740991.0, (-9007199254740991.0).truncateToDouble());
+ Expect.equals(-9007199254740992.0, (-9007199254740992.0).truncateToDouble());
+ Expect.equals(-double.maxFinite, (-double.maxFinite).truncateToDouble());
+
+ Expect.equals(double.infinity, double.infinity.truncateToDouble());
+ Expect.equals(
+ double.negativeInfinity, double.negativeInfinity.truncateToDouble());
+ Expect.isTrue(double.nan.truncateToDouble().isNaN);
+
+ Expect.isTrue(0.0.truncateToDouble() is double);
+ Expect.isTrue(double.minPositive.truncateToDouble() is double);
+ Expect.isTrue((2.0 * double.minPositive).truncateToDouble() is double);
+ Expect.isTrue((1.18e-38).truncateToDouble() is double);
+ Expect.isTrue((1.18e-38 * 2).truncateToDouble() is double);
+ Expect.isTrue(0.49999999999999994.truncateToDouble() is double);
+ Expect.isTrue(0.5.truncateToDouble() is double);
+ Expect.isTrue(0.9999999999999999.truncateToDouble() is double);
+ Expect.isTrue(1.0.truncateToDouble() is double);
+ Expect.isTrue(1.000000000000001.truncateToDouble() is double);
+ Expect.isTrue(4503599627370496.0.truncateToDouble() is double);
+ Expect.isTrue(4503599627370497.0.truncateToDouble() is double);
+ Expect.isTrue(4503599627370498.0.truncateToDouble() is double);
+ Expect.isTrue(4503599627370499.0.truncateToDouble() is double);
+ Expect.isTrue(9007199254740991.0.truncateToDouble() is double);
+ Expect.isTrue(9007199254740992.0.truncateToDouble() is double);
+ Expect.isTrue(double.maxFinite.truncateToDouble() is double);
+
+ Expect.isTrue((-double.minPositive).truncateToDouble() is double);
+ Expect.isTrue((2.0 * -double.minPositive).truncateToDouble() is double);
+ Expect.isTrue((-1.18e-38).truncateToDouble() is double);
+ Expect.isTrue((-1.18e-38 * 2).truncateToDouble() is double);
+ Expect.isTrue((-0.49999999999999994).truncateToDouble() is double);
+ Expect.isTrue((-0.5).truncateToDouble() is double);
+ Expect.isTrue((-0.9999999999999999).truncateToDouble() is double);
+ Expect.isTrue((-1.0).truncateToDouble() is double);
+ Expect.isTrue((-1.000000000000001).truncateToDouble() is double);
+ Expect.isTrue((-4503599627370496.0).truncateToDouble() is double);
+ Expect.isTrue((-4503599627370497.0).truncateToDouble() is double);
+ Expect.isTrue((-4503599627370498.0).truncateToDouble() is double);
+ Expect.isTrue((-4503599627370499.0).truncateToDouble() is double);
+ Expect.isTrue((-9007199254740991.0).truncateToDouble() is double);
+ Expect.isTrue((-9007199254740992.0).truncateToDouble() is double);
+ Expect.isTrue((-double.maxFinite).truncateToDouble() is double);
+}
diff --git a/tests/corelib/double_try_parse_test.dart b/tests/corelib/double_try_parse_test.dart
new file mode 100644
index 0000000..11dba69
--- /dev/null
+++ b/tests/corelib/double_try_parse_test.dart
@@ -0,0 +1,1209 @@
+// Copyright (c) 2014 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.
+// VMOptions=--no-use-field-guards
+// VMOptions=
+
+import "dart:math" show pow;
+import "package:expect/expect.dart";
+
+// U+0085 has been whitespace, isn't any more in all browsers.
+const whiteSpace = const [
+ "",
+ "\x09",
+ "\x0a",
+ "\x0b",
+ "\x0c",
+ "\x0d",
+ "\xa0",
+ "\u1680",
+ "\u2000",
+ "\u2001",
+ "\u2002",
+ "\u2003",
+ "\u2004",
+ "\u2005",
+ "\u2006",
+ "\u2007",
+ "\u2008",
+ "\u2009",
+ "\u200a",
+ "\u2028",
+ "\u2029",
+ "\u202f",
+ "\u205f",
+ "\u3000",
+ "\uFEFF"
+];
+
+void expectNumEquals(double expected, var actual, String message) {
+ if (expected.isNaN) {
+ Expect.isTrue(actual is double && actual.isNaN, "isNaN: $message");
+ } else {
+ Expect.identical(expected, actual, message);
+ }
+}
+
+// Test source surrounded by any combination of whitespace.
+void testParseAllWhitespace(String source, double result) {
+ for (String ws1 in whiteSpace) {
+ for (String ws2 in whiteSpace) {
+ String padded = "$ws1$source$ws2";
+ // Use Expect.identical because it also handles NaN and 0.0/-0.0.
+ // Except on dart2js: http://dartbug.com/11551
+ expectNumEquals(result, double.tryParse(padded), "parse '$padded'");
+ padded = "$ws1$ws2$source";
+ expectNumEquals(result, double.tryParse(padded), "parse '$padded'");
+ padded = "$source$ws1$ws2";
+ expectNumEquals(result, double.tryParse(padded), "parse '$padded'");
+ }
+ }
+}
+
+// Test source and -source surrounded by any combination of whitespace.
+void testParseWhitespace(String source, double result) {
+ assert(result >= 0);
+ testParseAllWhitespace(source, result);
+ testParseAllWhitespace("-$source", -result);
+}
+
+// Test parsing source, optionally preceeded and/or followed by whitespace.
+void testParse(String source, double result, [name = ""]) {
+ expectNumEquals(result, double.tryParse(source), "parse '$source:$name");
+ expectNumEquals(
+ result, double.tryParse(" $source"), "parse ' $source':$name");
+ expectNumEquals(
+ result, double.tryParse("$source "), "parse '$source ':$name");
+ expectNumEquals(
+ result, double.tryParse(" $source "), "parse ' $source ':$name");
+
+ expectNumEquals(result, double.tryParse("+$source"), "parse '+$source:$name");
+ expectNumEquals(
+ result, double.tryParse(" +$source"), "parse ' +$source':$name");
+ expectNumEquals(
+ result, double.tryParse("+$source "), "parse '+$source ':$name");
+ expectNumEquals(
+ result, double.tryParse(" +$source "), "parse ' +$source ':$name");
+
+ expectNumEquals(
+ -result, double.tryParse("-$source"), "parse '-$source:$name");
+ expectNumEquals(
+ -result, double.tryParse(" -$source"), "parse ' -$source':$name");
+ expectNumEquals(
+ -result, double.tryParse("-$source "), "parse '-$source ':$name");
+ expectNumEquals(
+ -result, double.tryParse(" -$source "), "parse ' -$source ':$name");
+}
+
+void testDouble(double value) {
+ testParse("$value", value);
+ if (value.isFinite) {
+ String exp = value.toStringAsExponential();
+ String lcexp = exp.toLowerCase();
+ testParse(lcexp, value);
+ String ucexp = exp.toUpperCase();
+ testParse(ucexp, value);
+ }
+}
+
+void testFail(String source) {
+ var object = new Object();
+ Expect.isNull(double.tryParse(source), "Fail: '$source'");
+}
+
+void main() {
+ testDouble(0.0);
+ testDouble(5e-324);
+ testDouble(2.225073858507201e-308);
+ testDouble(2.2250738585072014e-308);
+ testDouble(0.49999999999999994);
+ testDouble(0.5);
+ testDouble(0.50000000000000006);
+ testDouble(0.9999999999999999);
+ testDouble(1.0);
+ testDouble(1.0000000000000002);
+ testDouble(4294967295.0);
+ testDouble(4294967296.0);
+ testDouble(4503599627370495.5);
+ testDouble(4503599627370497.0);
+ testDouble(9007199254740991.0);
+ testDouble(9007199254740992.0);
+ testDouble(1.7976931348623157e+308);
+ testDouble(double.infinity);
+ testDouble(double.nan);
+
+ // Strings that cannot occur from toString of a number.
+ testParse("000000000000", 0.0);
+ testParse("000000000001", 1.0);
+ testParse("000000000000.0000000000000", 0.0);
+ testParse("000000000001.0000000000000", 1.0);
+ testParse("0e0", 0.0);
+ testParse("0e+0", 0.0);
+ testParse("0e-0", 0.0);
+ testParse("1e0", 1.0);
+ testParse("1e+0", 1.0);
+ testParse("1e-0", 1.0);
+ testParse("1.", 1.0);
+ testParse(".1", 0.1);
+ testParse("1.e1", 10.0);
+ testParse(".1e1", 1.0);
+ testParse("Infinity", double.infinity);
+ testParse("NaN", double.nan);
+
+ // Cases where mantissa and 10^exponent are representable as a double.
+ for (int i = -22; i <= 22; i++) {
+ for (double j in [1.0, 9007199254740991.0, 9007199254740992.0]) {
+ var value = (i >= 0) ? j * pow(10.0, i) : j / pow(10.0, -i);
+ testParse("${j}e$i", value, "$i/$j");
+ testParse("${j}E$i", value, "$i/$j");
+ if (i >= 0) {
+ testParse("${j}e+$i", value, "$i/$j");
+ testParse("${j}E+$i", value, "$i/$j");
+ }
+ }
+ }
+ for (int i = 0; i <= 22; i++) {
+ var digits = "9007199254740991";
+ for (int i = 0; i < digits.length; i++) {
+ int dotIndex = digits.length - i;
+ var string = "${digits.substring(0, dotIndex)}."
+ "${digits.substring(dotIndex)}e$i";
+ testParse(string, 9007199254740991.0);
+ }
+ }
+
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000012351641146031163604414219821705534309126495065358119110639"
+ "6420625168876817552187966324959090408998094949141173861429432731"
+ "6641775889849490996936990026954695315751782975778511319614542919"
+ "6224552592217965901424968268076250159685228839124609682811834931"
+ "8292403785007928846349518531559641397792756664639171692046759890"
+ "0776562329863178978731138323263641361002818700324274998854829973"
+ "5227010414083113118928696725368169503983880965288753370088162336"
+ "8004844756702677687292583305671118833393020810798402309572336459"
+ "2015026502876542452438269585569329582311976245631182694093981811"
+ "9686640211945509336174248834117544931694293962814151377997828762"
+ "2277536275946568454181273895934743339974841620248529105142565927"
+ "256981069188614130727188467062660492956638336181640625",
+ 0.0);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000024703282292062327208828439643411068618252990130716238221279"
+ "2841250337753635104375932649918180817996189898282347722858865463"
+ "3283551779698981993873980053909390631503565951557022639229085839"
+ "2449105184435931802849936536152500319370457678249219365623669863"
+ "6584807570015857692699037063119282795585513329278343384093519780"
+ "1553124659726357957462276646527282722005637400648549997709659947"
+ "0454020828166226237857393450736339007967761930577506740176324673"
+ "6009689513405355374585166611342237666786041621596804619144672918"
+ "4030053005753084904876539171138659164623952491262365388187963623"
+ "9373280423891018672348497668235089863388587925628302755995657524"
+ "4555072551893136908362547791869486679949683240497058210285131854"
+ "51396213837722826145437693412532098591327667236328125",
+ 0.0);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000024703282292062327208828439643411068618252990130716238221279"
+ "2841250337753635104375932649918180817996189898282347722858865463"
+ "3283551779698981993873980053909390631503565951557022639229085839"
+ "2449105184435931802849936536152500319370457678249219365623669863"
+ "6584807570015857692699037063119282795585513329278343384093519780"
+ "1553124659726357957462276646527282722005637400648549997709659947"
+ "0454020828166226237857393450736339007967761930577506740176324673"
+ "6009689513405355374585166611342237666786041621596804619144672918"
+ "4030053005753084904876539171138659164623952491262365388187963623"
+ "9373280423891018672348497668235089863388587925628302755995657524"
+ "4555072551893136908362547791869486679949683240497058210285131854"
+ "51396213837722826145437693412532098591327667236328125",
+ 0.0);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000024703282292062327208828439643411068627545332140664243314532"
+ "8041234170109088178685677591650492652607243027730579814636067699"
+ "1112238669661707327453443265068702897439863329200619332642599205"
+ "1806252781222000513169502627641523911022607448403553068808609405"
+ "1727798181294290864842608522062097649849550765341204993205100587"
+ "2127469658709242016690593998242808606978027857019419997429604579"
+ "7572623273334010723772922131119806567715298322567005234345331218"
+ "5169920860031716486480793611343761679481328431956040281530986197"
+ "8304604971452253283193290744072288902141724247846767401941767720"
+ "8561650585989659548591956327689896895290365125294085321852619688"
+ "9863888974446146846024033780172178553364579041996676675092137151"
+ "9705456298034409473812692774776868254618683783877327369245051207"
+ "5931578479504396230612962142122846982018227555473696607567828620"
+ "5497859173707553281928994692862033843994140625", //
+ 5e-324); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000037054923438093490813242659465116602918087143186126352238665"
+ "4061891674274999582254154033144959392383231717975289492511095959"
+ "2096640779585747657231506869704773681319051549691937265430115392"
+ "9316510179867828993955338712739726887403536747219495345250565253"
+ "9734220743745353366904984135736109339114232557854653467028698863"
+ "1755341990606652876965097618075398198036065644601954996844545287"
+ "8562428797081554870870561495721040952204106503876761616095480465"
+ "4854302923481671949982122917011832487483775622035971266330696098"
+ "1770527542930458978998057183774359009418156980309146068528141338"
+ "9871550473737887132279287842897827763181104688776671568136524122"
+ "1523792405286695424882335699501538146509629059245968850620692484"
+ "3143597161396297062546730578356156393213233025204703880754948792"
+ "4068421520495603769387037857877153017981772444526303392432171379"
+ "4502140826292446718071005307137966156005859375",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000037054923438093490813242659465116602927379485196074357331918"
+ "9261875506630452656563898974877271226994284847423521584288298194"
+ "9925327669548472990810970080864085947255348927335533958843628758"
+ "8673657776653897704274904804228750479055686517373829048435504795"
+ "4877211355023786539048555594678924193378269993917515076140279670"
+ "2329686989589536936193414969790924083008456100972824996564489920"
+ "5681031242249339356786090176104508511951642895866260110264487010"
+ "4014534270108033061877749917013356500179062432395206928717009377"
+ "6045079508629627357314808756707988746935928736893548082281945435"
+ "9059920635836528008522746502352634795082881888442454133993486286"
+ "6832608827839705362543821687804230019924524860745587315427697781"
+ "770943207565842392181565401187981478869915008544921875",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000037054923438093490813242659465116602936671827206022362425172"
+ "4461859338985905730873643916609583061605337976871753676065500430"
+ "7754014559511198324390433292023398213191646304979130652257142124"
+ "8030805373439966414594470895717774070707836287528162751620444337"
+ "0020201966302219711192127053621739047642307429980376685251860477"
+ "2904031988572420995421732321506449967980846557343694996284434553"
+ "2799633687417123842701618856487976071699179287855758604433493555"
+ "3174765616734394173773376917014880512874349242754442591103322657"
+ "0319631474328795735631560329641618484453700493477950096035749532"
+ "8248290797935168884766205161807441826984659088108236699850448451"
+ "2141425250392715300205307676106921893339420662245205780234703079"
+ "2275266989920550781084577445403473184185067145693733619245051207"
+ "5931578479504396230612962142122846982018227555473696607567828620"
+ "5497859173707553281928994692862033843994140625",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000049406564584124654417656879286822137236505980261432476442558"
+ "5682500675507270208751865299836361635992379796564695445717730926"
+ "6567103559397963987747960107818781263007131903114045278458171678"
+ "4898210368871863605699873072305000638740915356498438731247339727"
+ "3169615140031715385398074126238565591171026658556686768187039560"
+ "3106249319452715914924553293054565444011274801297099995419319894"
+ "0908041656332452475714786901472678015935523861155013480352649347"
+ "2019379026810710749170333222684475333572083243193609238289345836"
+ "8060106011506169809753078342277318329247904982524730776375927247"
+ "8746560847782037344696995336470179726777175851256605511991315048"
+ "9110145103786273816725095583738973359899366480994116420570263709"
+ "0279242767544565229087538682506419718265533447265625",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000049406564584124654417656879286822137255090664281328486629065"
+ "6082468340218176357371355183300985305214486055461159629272135398"
+ "2224477339323414654906886530137405794879726658401238665285198410"
+ "3612505562444001026339005255283047822045214896807106137617218810"
+ "3455596362588581729685217044124195299699101530682409986410201174"
+ "4254939317418484033381187996485617213956055714038839994859209159"
+ "5145246546668021447545844262239613135430596645134010468690662437"
+ "0339841720063432972961587222687523358962656863912080563061972395"
+ "6609209942904506566386581488144577804283448495693534803883535441"
+ "7123301171979319097183912655379793790580730250588170643705239377"
+ "9727777948892293692048067560344357106729158083993353350184274303"
+ "9410912596068818947625385549553736509237367567754654738490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000074109846876186981626485318930233205836174286372252704477330"
+ "8123783348549999164508308066289918784766463435950578985022191918"
+ "4193281559171495314463013739409547362638103099383874530860230785"
+ "8633020359735657987910677425479453774807073494438990690501130507"
+ "9468441487490706733809968271472218678228465115709306934057397726"
+ "3510683981213305753930195236150796396072131289203909993689090575"
+ "7124857594163109741741122991442081904408213007753523232190960930"
+ "9708605846963343899964245834023664974967551244071942532661392196"
+ "3541055085860917957996114367548718018836313960618292137056282677"
+ "9743100947475774264558575685795655526362209377553343136273048244"
+ "3047584810573390849764671399003076293019258118491937701241384968"
+ "6287194322792594125093461156712312786426466050409407761509897584"
+ "8136843040991207538774075715754306035963544889052606784864342758"
+ "900428165258489343614201061427593231201171875",
+ 5e-324);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000074109846876186981626485318930233205854758970392148714663837"
+ "8523751013260905313127797949754542453988569694847043168576596389"
+ "9850655339096945981621940161728171894510697854671067917687257517"
+ "7347315553307795408549809608457500958111373034747658096871009590"
+ "9754422710047573078097111189357848386756539987835030152280559340"
+ "4659373979179073872386829939581848166016912201945649993128979841"
+ "1362062484498678713572180352209017023903285791732520220528974020"
+ "8029068540216066123755499834026713000358124864790413857434018755"
+ "2090159017259254714629617513415977493871857473787096164563890871"
+ "8119841271673056017045493004705269590165763776884908267986972573"
+ "3665217655679410725087643375608460039849049721491174630855395563"
+ "54188641513168478436313080237596295773983001708984375", //
+ 1e-323); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000074109846876186981626485318930233205873343654412044724850344"
+ "8923718677971811461747287833219166123210675953743507352131000861"
+ "5508029119022396648780866584046796426383292609958261304514284249"
+ "6061610746879932829188941791435548141415672575056325503240888674"
+ "0040403932604439422384254107243478095284614859960753370503720954"
+ "5808063977144841990843464643012899935961693114687389992568869106"
+ "5599267374834247685403237712975952143398358575711517208866987110"
+ "6349531233468788347546753834029761025748698485508885182206645314"
+ "0639262948657591471263120659283236968907400986955900192071499065"
+ "6496581595870337769532410323614883653969318176216473399700896902"
+ "4282850500785430600410615352213843786678841324490411560469406158"
+ "4550533979841101562169154890806946368370134291387467238490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125", //
+ 1e-323); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360069154511635866620203210960799023116591527666370844360221740"
+ "6959097927141579506255510282033669865517905502576217080776730054"
+ "4280061926888594105653889967660011652398050737212918180359607825"
+ "2347125186710418762540332530832907947436024558998429581982425031"
+ "7954385059152437399890443876874974725790225802525457699928291235"
+ "4093225567689679024960579905428830259962166760571761950743978498"
+ "0479564444580149632075553173315669683173879325651468588102366281"
+ "5890742832175436061414318821022423405703806955738531400844926622"
+ "0550120807237108092835830752700771425423583764509515806613894483"
+ "6485368656166704349449158753391942346304638698898642932982747054"
+ "5684547703068233784351199339157645340492308605462312698364257812"
+ "5",
+ 1.1125369292536007e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360069154511635866620203210960799023116610112350390740370408247"
+ "7359065591852485654875000165498293534740011761472681264331134525"
+ "9937435706814044772812816389978636184270645492500111567186634557"
+ "1061420380282556183179464713810955130740324099307096988352304114"
+ "8240366281709303744177586794760604434318300674651180918151452849"
+ "5241915565655447143417214608859882029906947673313501950183867763"
+ "4716769334915718603906610534082604802668952109630465576440379371"
+ "4211205525428158285205572821025471431094380576457002725617553180"
+ "9099224738635444849469333898568030900459127277678319834121502677"
+ "4862108980363986101936076072301556410108193098230208064696671383"
+ "6302180548174253659674171315763029087322100208461549627978268407"
+ "4131669828524253718537846867047316790971834120489029738490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 1.1125369292536007e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360093857793927928947412039400442434185191195972481664588256512"
+ "9400380600184308462011953048487227014291989141962100620081191046"
+ "1906239926662125432368943599250777752029021933482747432761666932"
+ "6081935177574213144751136884007361083502182696938981541236215812"
+ "4253211406611428748302338022108627812847664259678077865798649401"
+ "4497660229450268863966221848525061212023023248478571949013749179"
+ "6696380382410806898101889263285073571646568472249978339940677865"
+ "3579969652328069212208231432361613047099274956616864695216972981"
+ "6031069881591856241078866777972171115011992742603077167294249913"
+ "7481908755860441269310739102717418145889672225195380557264480249"
+ "9621987409855350817390775154421748273612200242960133979035379072"
+ "1007951555248028896005922474205893068160932603143782761509897584"
+ "8136843040991207538774075715754306035963544889052606784864342758"
+ "900428165258489343614201061427593231201171875",
+ 1.1125369292536007e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360093857793927928947412039400442434185209780656501560598443019"
+ "9800348264895214610631442931951850683514095400858564803635595517"
+ "7563613706587576099527870021569402283901616688769940819588693664"
+ "4796230371146350565390269066985408266806482237247648947606094895"
+ "4539192629168295092589480939994257521375739131803801084021811015"
+ "5646350227416036982422856551956112981967804161220311948453638445"
+ "0933585272746375869932946624052008691141641256228975328278690955"
+ "1900432345580791435999485432364661072489848577335336019989599540"
+ "4580173812990192997712369923839430590047536255771881194801858107"
+ "5858649080057723021797656421627032209693226624526945688978404579"
+ "0239620254961370692713747131027132020441991845959370908649389667"
+ "01396213837722826145437693412532098591327667236328125",
+ 1.1125369292536007e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360093857793927928947412039400442434185228365340521456608629527"
+ "0200315929606120759250932815416474352736201659755028987189999989"
+ "3220987486513026766686796443888026815774211444057134206415720396"
+ "3510525564718487986029401249963455450110781777556316353975973978"
+ "4825173851725161436876623857879887229903814003929524302244972629"
+ "6795040225381805100879491255387164751912585073962051947893527710"
+ "5170790163081944841764003984818943810636714040207972316616704045"
+ "0220895038833513659790739432367709097880422198053807344762226099"
+ "3129277744388529754345873069706690065083079768940685222309466301"
+ "4235389404255004774284573740536646273496781023858510820692328908"
+ "0857253100067390568036719107632515767271783448958607838263400261"
+ "9271291212296536333081616208300526650104600844121842238490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125", //
+ 1.112536929253601e-308); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360118561076219991274620867840085845253828033646632276836664299"
+ "2641598602648849715007375581870031501510285299140912526494460981"
+ "0847165486286558093401850075478792915405182640326963458817779503"
+ "7245335555582282368240205603137908586176939915496868313229764759"
+ "1124000199184152785288518003113540316961252461082144468115330795"
+ "7199474887142394939885133198483395703973441561868861946163298392"
+ "1387606100912602107790340074788347699109403186806482068455015628"
+ "7910121858986146810584652043706898739275890198932140639134272458"
+ "8610226818743277902588909094978089754671488747034246582989821731"
+ "5231929503948741694146154089862122073081814550155248444974062103"
+ "4794692806854507601076294922896618700391675086456429118934521521"
+ "5279242767544565229087538682506419718265533447265625",
+ 1.112536929253601e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360118561076219991274620867840085845253846618330652172846850806"
+ "3041566267359755863626865465334655170732391558037376710048865452"
+ "6504539266212008760560776497797417447277777395614156845644806235"
+ "5959630749154419788879337786115955769481239455805535719599643842"
+ "1409981421741019129575660920999170025489327333207867686338492409"
+ "8348164885108163058341767901914447473918222474610601945603187657"
+ "5624810991248171079621397435555282818604475970785479056793028718"
+ "6230584552238869034375906043709946764666463819650611963906899017"
+ "7159330750141614659222412240845349229707032260203050610497429925"
+ "3608669828146023446633071408771736136885368949486813576687986432"
+ "5412325651960527476399266899502002447221466689455666048548532116"
+ "4410912596068818947625385549553736509237367567754654738490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 1.112536929253601e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360143264358512053601829696279729256322427701952743097064699071"
+ "5082881275691578670763818348323588650284368938526796065798921972"
+ "8473343486060089420116903707069559015036153836596792711219838611"
+ "0980145546446076750451009956312361722243098053437420272483555539"
+ "7422826546643144133700412148347193404018690918234764633985688961"
+ "7603909548902984778890775141579626656034298049775671944433069073"
+ "7604422038743259373816676164757751587582092333404991820293327212"
+ "5599348679138779961378564655046088380671358199810473933506318818"
+ "4091175893098026050831945120249489444259897725127807943670177161"
+ "6228469603642478614007734439187597872666848076451986069255795298"
+ "8732132513641624634115870738160721633511566723954250399605642781"
+ "1287194322792594125093461156712312786426466050409407761509897584"
+ "8136843040991207538774075715754306035963544889052606784864342758"
+ "900428165258489343614201061427593231201171875",
+ 1.112536929253601e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360143264358512053601829696279729256322446286636762993074885578"
+ "5482848940402484819383308231788212319506475197423260249353326444"
+ "4130717265985540087275830129388183546908748591883986098046865342"
+ "9694440740018214171090142139290408905547397593746087678853434622"
+ "7708807769200010477987555066232823112546765790360487852208850575"
+ "8752599546868752897347409845010678425979078962517411943872958339"
+ "1841626929078828345647733525524686707077165117383988808631340302"
+ "3919811372391502185169818655049136406061931820528945258278945377"
+ "2640279824496362807465448266116748919295441238296611971177785355"
+ "4605209927839760366494651758097211936470402475783551200969719627"
+ "9349765358747644509438842714766105380341358326953487329219653376"
+ "04188641513168478436313080237596295773983001708984375", //
+ 1.1125369292536017e-308); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000011125369292"
+ "5360143264358512053601829696279729256322464871320782889085072085"
+ "5882816605113390968002798115252835988728581456319724432907730915"
+ "9788091045910990754434756551706808078781343347171179484873892074"
+ "8408735933590351591729274322268456088851697134054755085223313705"
+ "7994788991756876822274697984118452821074840662486211070432012189"
+ "9901289544834521015804044548441730195923859875259151943312847604"
+ "6078831819414397317478790886291621826572237901362985796969353392"
+ "2240274065644224408961072655052184431452505441247416583051571936"
+ "1189383755894699564098951411984008394330984751465415998685393549"
+ "2981950252037042118981569077006826000273956875115116332683643956"
+ "9967398203853664384761814691371489127171149929952724258833663970"
+ "9550533979841101562169154890806946368370134291387467238490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125", //
+ 1.1125369292536017e-308); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720138309023271733240406421921598046233183055332741688720443481"
+ "3918195854283159012511020564067339731035811005152434161553460108"
+ "8560123853777188211307779935320023304796101474425836360719215650"
+ "4694250373420837525080665061665815894872049117996859163964850063"
+ "5908770118304874799780887753749949451580451605050915399856582470"
+ "8186451135379358049921159810857660519924333521143523901487956996"
+ "0959128889160299264151106346631339366347758651302937176204732563"
+ "1781485664350872122828637642044846811407613911477062801689853244"
+ "1100241614474216185671661505401542850847167529019031613227788967"
+ "2970737312333408698898317506783884692609277397797285865965494109"
+ "1369095406136467568702398678315290680984617210924625396728515625",
+ 2.2250738585072014e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720138309023271733240406421921598046233201640016761584730629988"
+ "4318163518994065161130510447531963400257917264048898345107864580"
+ "4217497633702638878466706357638647836668696229713029747546242382"
+ "3408545566992974945719797244643863078176348658305526570334729146"
+ "6194751340861741144068030671635579160108526477176638618079744084"
+ "9335141133345126168377794514288712289869114433885263900927846261"
+ "5196333779495868235982163707398274485842831435281934164542745653"
+ "0101948357603594346619891642047894836798187532195534126462479802"
+ "9649345545872552942305164651268802325882711042187835640735397161"
+ "1347477636530690451385234825693498756412831797128850997679418438"
+ "1986728251242487444025370654920674427814408813923862326342526219"
+ "9131669828524253718537846867047316790971834120489029738490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 2.2250738585072014e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720163012305563795567615250361241457301782723638852508948478253"
+ "6359478527325887968267463330520896879809894644538317700857921100"
+ "6186301853550719538022833566910789404427072670695665613121274757"
+ "8429060364284631907291469414840269030938207255937411123218640844"
+ "2207596465763866148192781898983602538637890062203535565726940636"
+ "8590885797139947888926801753953891471985190009050333899757727677"
+ "7175944826990956530177442436600743254820447797901446928043044146"
+ "9470712484503505273622550253384036452803081912355396096061899603"
+ "6581190688828964333914697530672942540435576507112592973908144397"
+ "3967277412027145618759897856109360492194310924094023490247227304"
+ "5306535112923584601741974493579393614104508848422446677399636884"
+ "6007951555248028896005922474205893068160932603143782761509897584"
+ "8136843040991207538774075715754306035963544889052606784864342758"
+ "900428165258489343614201061427593231201171875",
+ 2.2250738585072014e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720163012305563795567615250361241457301801308322872404958664760"
+ "6759446192036794116886953213985520549032000903434781884412325572"
+ "1843675633476170205181759989229413936299667425982858999948301489"
+ "7143355557856769327930601597818316214242506796246078529588519927"
+ "2493577688320732492479924816869232247165964934329258783950102250"
+ "9739575795105716007383436457384943241929970921792073899197616943"
+ "1413149717326525502008499797367678374315520581880443916381057236"
+ "7791175177756227497413804253387084478193655533073867420834526162"
+ "5130294620227301090548200676540202015471120020281397001415752591"
+ "2344017736224427371246815175018974555997865323425588621961151633"
+ "5924167958029604477064946470184777360934300451421683607013647479"
+ "51396213837722826145437693412532098591327667236328125",
+ 2.2250738585072014e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720163012305563795567615250361241457301819893006892300968851267"
+ "7159413856747700265506443097450144218254107162331246067966730043"
+ "7501049413401620872340686411548038468172262181270052386775328221"
+ "5857650751428906748569733780796363397546806336554745935958399010"
+ "2779558910877598836767067734754861955694039806454982002173263865"
+ "0888265793071484125840071160815995011874751834533813898637506208"
+ "5650354607662094473839557158134613493810593365859440904719070326"
+ "6111637871008949721205058253390132503584229153792338745607152721"
+ "3679398551625637847181703822407461490506663533450201028923360785"
+ "0720758060421709123733732493928588619801419722757153753675075962"
+ "6541800803135624352387918446790161107764092054420920536627658074"
+ "4271291212296536333081616208300526650104600844121842238490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125", //
+ 2.225073858507202e-308); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720187715587855857894824078800884868370419561313003121196886039"
+ "9600696529790429221262885863903701367028190801717129607271191035"
+ "5127227413175152199055740043138804567803233377539881639177387328"
+ "9592460742292701130780538133970816533612964474495297895212189790"
+ "9078385258336590185178961879988515042751478263607602168043622031"
+ "1292700454832073964845713103912225963935608322440623896907276890"
+ "1867170545492751739865893248104017382283282512457950656557381910"
+ "3800864691161582871998970864729322144979697154670672039979199080"
+ "9160347625980385995424739847678861180095072511543762389603716215"
+ "1717298160115446043595312843254064419386453249053891377956809158"
+ "0479240509922741385427494262054264040883983691918741817298779334"
+ "0279242767544565229087538682506419718265533447265625",
+ 2.225073858507202e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720187715587855857894824078800884868370438145997023017207072547"
+ "0000664194501335369882375747368325036250297060613593790825595507"
+ "0784601193100602866214666465457429099675828132827075026004414060"
+ "8306755935864838551419670316948863716917264014803965301582068873"
+ "9364366480893456529466104797874144751279553135733325386266783645"
+ "2441390452797842083302347807343277733880389235182363896347166155"
+ "6104375435828320711696950608870952501778355296436947644895395000"
+ "2121327384414305095790224864732370170370270775389143364751825639"
+ "7709451557378722752058242993546120655130616024712566417111324409"
+ "0094038484312727796082230162163678483190007648385456509670733487"
+ "1096873355028761260750466238659647787713775294917978746912789928"
+ "9410912596068818947625385549553736509237367567754654738490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125",
+ 2.225073858507202e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720212418870147920222032907240528279439019229619113941424920812"
+ "2041979202833158177019328630357258515802274441103013146575652027"
+ "2753405412948683525770793674729570667434204573809710891579446436"
+ "3327270733156495512991342487145269669679122612435849854465980571"
+ "5377211605795581533590856025222168129808916720760222333913980197"
+ "1697135116592663803851355047008456915996464810347433895177047571"
+ "8083986483323409005892229338073421270755971659056460408395693494"
+ "1490091511314216022792883476068511786375165155549005334351245440"
+ "4641296700335134143667775872950260869683481489637323750284071645"
+ "2713838259809182963456893192579540218971486775350629002238542353"
+ "4416680216709858418467070077318366974003875329416563097969900593"
+ "6287194322792594125093461156712312786426466050409407761509897584"
+ "8136843040991207538774075715754306035963544889052606784864342758"
+ "900428165258489343614201061427593231201171875",
+ 2.225073858507202e-308);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720212418870147920222032907240528279439037814303133837435107319"
+ "2441946867544064325638818513821882185024380699999477330130056498"
+ "8410779192874134192929720097048195199306799329096904278406473168"
+ "2041565926728632933630474670123316852983422152744517260835859654"
+ "5663192828352447877877998943107797838336991592885945552137141811"
+ "2845825114558431922307989750439508685941245723089173894616936837"
+ "2321191373658977977723286698840356390251044443035457396733706583"
+ "9810554204566938246584137476071559811765738776267476659123871999"
+ "3190400631733470900301279018817520344719025002806127777791679839"
+ "1090578584006464715943810511489154282775041174682194133952466682"
+ "5034313061815878293790042053923750720833666932415800027583911188"
+ "54188641513168478436313080237596295773983001708984375", //
+ 2.2250738585072024e-308); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000022250738585"
+ "0720212418870147920222032907240528279439056398987153733445293826"
+ "2841914532254970474258308397286505854246486958895941513684460970"
+ "4068152972799584860088646519366819731179394084384097665233499900"
+ "0755861120300770354269606853101364036287721693053184667205738737"
+ "5949174050909314222165141860993427546865066465011668770360303425"
+ "3994515112524200040764624453870560455886026635830913894056826102"
+ "6558396263994546949554344059607291509746117227014454385071719673"
+ "8131016897819660470375391476074607837156312396985947983896498558"
+ "1739504563131807656934782164684779819754568515974931805299288032"
+ "9467318908203746468430727830398768346578595574013759265666391011"
+ "5651945906921898169113014030529134467663458535415036957197921783"
+ "4550533979841101562169154890806946368370134291387467238490102415"
+ "1863156959008792461225924284245693964036455110947393215135657241"
+ "099571834741510656385798938572406768798828125", //
+ 2.2250738585072024e-308); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000100208418000448638899805402"
+ "5675081023947173151201955956352756465219477298834774949553868001"
+ "7172354813827222283890479851867436841402279176933922227531985191"
+ "9016883548022442028316027357265612083085166971723487691494714589"
+ "5578331812936322386545483369746322848628024994920311121080242823"
+ "5714326388663336759990619917681011604908667604621058852897083245"
+ "0816977893343649540492907374306035456728456338904015275857972276"
+ "1526157631250497160973795706924168310120033199859199012414074894"
+ "8202195091387650850548954516920927386376492603899633528627985383"
+ "2932104496700123254769405070337764094630065313795728259355401668"
+ "8207267296623786504114239553488532354086348874488976434804499149"
+ "322509765625",
+ 1.0020841800044864e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000100208418000448638899805402"
+ "5675081023947173151201956040050732492021560444211472901925540702"
+ "1586014286915762763038748010206109436411449756840422987132589595"
+ "3085274649978096343836685185731606312366412920027708756586099963"
+ "7975552653362983131506665648352778744386705639822064232334712197"
+ "7867779247842315182877112028658635902319185766818606103345104073"
+ "9923514010434512590195330770391813338086311968111531328662618487"
+ "3315578521649250253839821623536466419018719481428679013982985346"
+ "1571995354000952600076951720089726239270930511481845755671197870"
+ "4747866889418540057514218596081876158765839665014133210631738825"
+ "4165335079883777074977685931654819161553596657523084699300803458"
+ "3609637179288099118793858900152420545987239088654699259390735847"
+ "0152049332041520812604025151794328168042160636342216519487980314"
+ "421878240614097350935640662328296457417309284210205078125",
+ 1.0020841800044864e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000100208418000448650025174695"
+ "1035150178458809017822159083615579461533985681124447841542417041"
+ "9717793267880261310997721975562434111911014099603638548708110842"
+ "9228554372955381818449259496459629506201971760632184806762937040"
+ "5528236159220080404124633621972774900305368909016987591808198481"
+ "1515258588636795736994571683578362033288375244948969302377353651"
+ "5803667343942465515751063883649087835332767470268261173797304563"
+ "0216301185431893700183322963627539884395226243941187598947530725"
+ "0723137660949785162435276134774551939185861652055952702429699518"
+ "1666462911218814544860422297294423455917874727086839114692958995"
+ "8734568169530500282699951928714187892923739790353511103290941894"
+ "8525105836280134665557340439005224794505069516807613438973521965"
+ "4847950667958479187395974848205671831957839363657783480512019685"
+ "578121759385902649064359337671703542582690715789794921875",
+ 1.0020841800044864e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000100208418000448650025174695"
+ "1035150178458809017822159167313555488336068826501145793914089742"
+ "4131452740968801790145990133901106706920184679510139308308715246"
+ "3296945474911036133969917324925623735483217708936405871854322414"
+ "7925456999646741149085815900579230796064049553918740703062667855"
+ "3668711447815774159881063794555986330698893407146516552825374480"
+ "4910203461033328565453487279734865716690623099475777226601950774"
+ "2005722075830646793049348880239837993293912525510667600516441176"
+ "4092937923563086911963273337943350792080299559638164929472912005"
+ "3482225303937231347605235823038535520053649078305244065969296152"
+ "4692635952790490853563398306880474700390987573387619367787246203"
+ "8909645359318233784351199339157645340492308605462312698364257812"
+ "5",
+ 1.0020841800044864e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000100208418000448650025174695"
+ "1035150178458809017822159251011531515138151971877843746285762442"
+ "8545112214057342269294258292239779301929355259416640067909319649"
+ "7365336576866690449490575153391617964764463657240626936945707789"
+ "0322677840073401894046998179185686691822730198820493814317137229"
+ "5822164306994752582767555905533610628109411569344063803273395309"
+ "4016739578124191615155910675820643598048478728683293279406596985"
+ "3795142966229399885915374796852136102192598807080147602085351627"
+ "7462738186176388661491270541112149644974737467220377156516124492"
+ "5297987696655648150350049348782647584189423429523649017245633309"
+ "0650703736050481424426844685046761507858235356421727632283550512"
+ "9294184882356332903145058239310065886479547694117011957754993659"
+ "5152049332041520812604025151794328168042160636342216519487980314"
+ "421878240614097350935640662328296457417309284210205078125", //
+ 1.0020841800044866e-292); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000200416836000897255548872220"
+ "0630023738871074569163505490783914884205771542336808210387292522"
+ "0426513773371285555269939139667533951768747348715410293510510274"
+ "9473643242267695845324274779211200861374232469021139022270213528"
+ "6462413252451807248010301677826829802384000871843763078195635583"
+ "5519882659021798720200352081612073758236883604191202305937584019"
+ "3447504651307941031064654937754410393532579156664506650227987556"
+ "2093186373340695057796485067216997253892307748415460848623417226"
+ "4622904518424429578269271391797007961345371296322204255566117522"
+ "4763967378926030323867148635273985338412963098572424905483014370"
+ "3443797280914164309330161600193180015563420351180667003643504189"
+ "5081099906363532431297601321684709319015382789075374603271484375",
+ 2.0041683600089726e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000200416836000897255548872220"
+ "0630023738871074569163505574481890911007854687713506162758965222"
+ "4840173246459826034418207298006206546777917928621911053111114678"
+ "3542034344223350160844932607677195090655478417325360087361598902"
+ "8859634092878467992971483956433285698142681516745516189450104957"
+ "7673335518200777143086844192589698055647401766388749556385604848"
+ "2554040768398804080767078333840188274890434785872022703032633767"
+ "3882607263739448150662510983829295362790994029984940850192327677"
+ "7992704781037731327797268594965806814239809203904416482609330009"
+ "6579729771644447126611962161018097402548737449790829856759351526"
+ "9401865064174154880193607978359466823030668134214775268139808498"
+ "5465639429401631550091460221837129865002621877730073862662220222"
+ "0152049332041520812604025151794328168042160636342216519487980314"
+ "421878240614097350935640662328296457417309284210205078125",
+ 2.0041683600089726e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000200416836000897266674241512"
+ "5990092893382710435783708618046737880520279924626481102375841562"
+ "2971952227424324582377181263362531222277482271385126614686635925"
+ "9685314067200635635457506918405218284491037257929836137538435979"
+ "6412317598735565265589451930053281854061344785940439548923591241"
+ "1320814858995257697204303847509424186616591244519112755417854425"
+ "8434194101906757006322811447097462772136890288028752548167319843"
+ "0783329927522091597006012323920368828167500792497449435156873056"
+ "7143847087986563890155593009650632514154740344478523429367831657"
+ "3498325793444721613958165862230644699700772511863535760820571697"
+ "3971098153820878087915873975418835554400811267045201672129946935"
+ "0381108086393667096854941760689934113520452305882988042245006340"
+ "4847950667958479187395974848205671831957839363657783480512019685"
+ "578121759385902649064359337671703542582690715789794921875",
+ 2.0041683600089726e-292);
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000200416836000897266674241512"
+ "5990092893382710435783708701744713907322363070003179054747514262"
+ "7385611700512865061525449421701203817286652851291627374287240329"
+ "3753705169156289950978164746871212513772283206234057202629821353"
+ "8809538439162226010550634208659737749820025430842192660178060615"
+ "3474267718174236120090795958487048484027109406716660005865875254"
+ "7540730218997620056025234843183240653494745917236268600971966054"
+ "2572750817920844689872038240532666937066187074066929436725783508"
+ "0513647350599865639683590212819431367049178252060735656411044144"
+ "5314088186163138416702979387974756763836546863081940712096908853"
+ "9929165937080868658779320353585122361868059050079309936626251244"
+ "0765647609431766215648800660842354659507691394537687301635742187"
+ "5", //
+ 2.004168360008973e-292); //
+ testParse(
+ "0.00000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000200416836000897266674241512"
+ "5990092893382710435783708785442689934124446215379877007119186963"
+ "1799271173601405540673717580039876412295823431198128133887844732"
+ "7822096271111944266498822575337206743053529154538278267721206728"
+ "1206759279588886755511816487266193645578706075743945771432529989"
+ "5627720577353214542977288069464672781437627568914207256313896083"
+ "6647266336088483105727658239269018534852601546443784653776612265"
+ "4362171708319597782738064157144965045964873355636409438294693959"
+ "3883447613213167389211587415988230219943616159642947883454256631"
+ "7129850578881555219447792913718868827972321214300345663373246010"
+ "5887233720340859229642766731751409169335306833113418201122555553"
+ "1150187132469865334442659560994775205494930483192386561026478034"
+ "5152049332041520812604025151794328168042160636342216519487980314"
+ "421878240614097350935640662328296457417309284210205078125", //
+ 2.004168360008973e-292); //
+ testParse("0.99999999999999988897769753748434595763683319091796875",
+ 0.9999999999999999);
+ testParse(
+ "0.99999999999999988897769753748434595763683319091796879176194859"
+ "5190556970945882299241904356487451251641385905655273315006228765"
+ "423911854226535211864757002331316471099853515625",
+ 0.9999999999999999);
+ testParse(
+ "0.99999999999999994448884876874217297881841659545898433323805140"
+ "4809443029054117700758095643512548748358614094344726684993771234"
+ "576088145773464788135242997668683528900146484375",
+ 0.9999999999999999);
+ testParse("0.999999999999999944488848768742172978818416595458984375", 1.0); //
+ testParse(
+ "0.99999999999999994448884876874217297881841659545898441676194859"
+ "5190556970945882299241904356487451251641385905655273315006228765"
+ "423911854226535211864757002331316471099853515625", //
+ 1.0); //
+ testParse("0.499999999999999944488848768742172978818416595458984375",
+ 0.49999999999999994);
+ testParse(
+ "0.49999999999999994448884876874217297881841659545898439588097429"
+ "7595278485472941149620952178243725625820692952827636657503114382"
+ "7119559271132676059323785011656582355499267578125",
+ 0.49999999999999994);
+ testParse(
+ "0.49999999999999997224442438437108648940920829772949216661902570"
+ "2404721514527058850379047821756274374179307047172363342496885617"
+ "2880440728867323940676214988343417644500732421875",
+ 0.49999999999999994);
+ testParse(
+ "0.4999999999999999722444243843710864894092082977294921875", 0.5); //
+ testParse(
+ "0.49999999999999997224442438437108648940920829772949220838097429"
+ "7595278485472941149620952178243725625820692952827636657503114382"
+ "7119559271132676059323785011656582355499267578125", //
+ 0.5); //
+ testParse("1.9999999999999997779553950749686919152736663818359375",
+ 1.9999999999999998);
+ testParse(
+ "1.99999999999999977795539507496869191527366638183593758352389719"
+ "0381113941891764598483808712974902503282771811310546630012457530"
+ "84782370845307042372951400466263294219970703125",
+ 1.9999999999999998);
+ testParse(
+ "1.99999999999999988897769753748434595763683319091796866647610280"
+ "9618886058108235401516191287025097496717228188689453369987542469"
+ "15217629154692957627048599533736705780029296875",
+ 1.9999999999999998);
+ testParse("1.99999999999999988897769753748434595763683319091796875", 2.0); //
+ testParse(
+ "1.99999999999999988897769753748434595763683319091796883352389719"
+ "0381113941891764598483808712974902503282771811310546630012457530"
+ "84782370845307042372951400466263294219970703125", //
+ 2.0); //
+ testParse("4503599627370495.5", 4503599627370495.5);
+ testParse(
+ "4503599627370495.50000000000000000000000000000000000018807909613"
+ "1566001274997845955559308450986489083534003441400273004546761512"
+ "75634765625",
+ 4503599627370495.5);
+ testParse(
+ "4503599627370495.74999999999999999999999999999999999981192090386"
+ "8433998725002154044440691549013510916465996558599726995453238487"
+ "24365234375",
+ 4503599627370495.5);
+ testParse("4503599627370495.75", 4503599627370496.0);
+ testParse(
+ "4503599627370495.75000000000000000000000000000000000018807909613"
+ "1566001274997845955559308450986489083534003441400273004546761512"
+ "75634765625",
+ 4503599627370496.0);
+ testParse("4503599627370496", 4503599627370496.0);
+ testParse(
+ "4503599627370496.00000000000000000000000000000000000037615819226"
+ "3132002549995691911118616901972978167068006882800546009093523025"
+ "5126953125",
+ 4503599627370496.0);
+ testParse(
+ "4503599627370496.49999999999999999999999999999999999962384180773"
+ "6867997450004308088881383098027021832931993117199453990906476974"
+ "4873046875",
+ 4503599627370496.0);
+ testParse("4503599627370496.5", 4503599627370496.0);
+ testParse(
+ "4503599627370496.50000000000000000000000000000000000037615819226"
+ "3132002549995691911118616901972978167068006882800546009093523025"
+ "5126953125",
+ 4503599627370497.0);
+ testParse("9007199254740991", 9007199254740991.0);
+ testParse(
+ "9007199254740991.00000000000000000000000000000000000037615819226"
+ "3132002549995691911118616901972978167068006882800546009093523025"
+ "5126953125",
+ 9007199254740991.0);
+ testParse(
+ "9007199254740991.49999999999999999999999999999999999962384180773"
+ "6867997450004308088881383098027021832931993117199453990906476974"
+ "4873046875",
+ 9007199254740991.0);
+ testParse("9007199254740991.5", 9007199254740992.0);
+ testParse(
+ "9007199254740991.50000000000000000000000000000000000037615819226"
+ "3132002549995691911118616901972978167068006882800546009093523025"
+ "5126953125",
+ 9007199254740992.0);
+ testParse(
+ "1797693134862315708145274237317043567980705675258449965989174768"
+ "0315726078002853876058955863276687817154045895351438246423432132"
+ "6889464182768467546703537516986049910576551282076245490090389328"
+ "9440758685084551339423045832369032229481658085593321233482747978"
+ "26204144723168738177180919299881250404026184124858368",
+ 1.7976931348623157e+308);
+ testParse(
+ "1797693134862315708145274237317043567980705675258450041064343056"
+ "0785749075118623426984641994452647172104399563141377322686588394"
+ "6121172130178666127034918365540069095282013901258936156392632590"
+ "7055367751483602939820315058278058002847941584484775356682545657"
+ "44106770877499077221865536419145864291265781790932992",
+ 1.7976931348623157e+308);
+ testParse(
+ "1797693134862315807937289714053034150799341327100378194286569501"
+ "7574473832160705543739215666582761354682674973879349714831499292"
+ "8620232455220458908340124972127889717295245764493583188543574449"
+ "7703035690903649098158444443687202655781915109457910629727393062"
+ "50541739356374003666875082388828428992938306508423168",
+ 1.7976931348623157e+308);
+ testParse(
+ "1797693134862315807937289714053034150799341327100378269361737789"
+ "8044496829276475094664901797758720709633028641669288791094655554"
+ "7851940402630657488671505820681908902000708383676273854845817711"
+ "5317644757302700698555713669596228429148198608349364752927190741"
+ "68444365510704342711559699508093042880177904174497792",
+ double.infinity);
+ testParse(
+ "1797693134862315807937289714053034150799341327100378344436906077"
+ "8514519826392244645590587928934680064583382309459227867357811816"
+ "7083648350040856069002886669235928086706171002858964521148060973"
+ "2932253823701752298952982895505254202514482107240818876126988420"
+ "86346991665034681756244316627357656767417501840572416",
+ double.infinity);
+
+ // Edge cases of algorithm (e+-22/23).
+ testParse("1e22", 1e22);
+ testParse("1e23", 1e23);
+ testParse("1e-22", 1e-22);
+ testParse("1e-23", 1e-23);
+
+ testParseWhitespace("1", 1.0);
+ testParseWhitespace("1.0", 1.0);
+ testParseWhitespace("1e1", 10.0);
+ testParseWhitespace(".1e1", 1.0);
+ testParseWhitespace("1.e1", 10.0);
+ testParseWhitespace("1e+1", 10.0);
+ testParseWhitespace("1e-1", 0.1);
+
+ // Negative tests - things not to allow.
+
+ // Spaces inside the numeral.
+ testFail("- 1");
+ testFail("+ 1");
+ testFail("2 2");
+ testFail("1 .");
+ testFail(". 1");
+ testFail("1e 2");
+ testFail("1 e2");
+ // Invalid characters.
+ testFail("0x0");
+ testFail("0x1H");
+ testFail("12H");
+ testFail("1x2");
+ testFail("00x2");
+ testFail("0x2.2");
+ // Double exponent without value.
+ testFail(".e1");
+ testFail("e1");
+ testFail("e+1");
+ testFail("e-1");
+ testFail("-e1");
+ testFail("-e+1");
+ testFail("-e-1");
+ // Too many signs.
+ testFail("--1");
+ testFail("-+1");
+ testFail("+-1");
+ testFail("++1");
+ // Incorrect ways to write NaN/Infinity.
+ testFail("infinity");
+ testFail("INFINITY");
+ testFail("1.#INF");
+ testFail("inf");
+ testFail("nan");
+ testFail("NAN");
+ testFail("1.#IND");
+ testFail("indef");
+ testFail("qnan");
+ testFail("snan");
+}
diff --git a/tests/corelib/duration_big_num_test.dart b/tests/corelib/duration_big_num_test.dart
new file mode 100644
index 0000000..e2f5fd5
--- /dev/null
+++ b/tests/corelib/duration_big_num_test.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+import 'dart:math';
+
+main() {
+ Duration d, d1;
+
+ d1 = new Duration(microseconds: pow(2, 53) as int);
+ d = d1 * 2;
+ Expect.equals(pow(2, 54), d.inMicroseconds);
+ d = d1 * 1.5;
+ Expect.equals(pow(2, 53).toDouble() * 1.5, d.inMicroseconds);
+ Expect.isTrue(d.inMicroseconds is int);
+
+ // Test that we lose precision when multiplying with a double.
+ d = new Duration(microseconds: (pow(2, 53) as int) + 1) * 1.0;
+ Expect.equals(0, d.inMicroseconds % 2);
+}
diff --git a/tests/corelib/duration_double_multiplication_test.dart b/tests/corelib/duration_double_multiplication_test.dart
new file mode 100644
index 0000000..415067c
--- /dev/null
+++ b/tests/corelib/duration_double_multiplication_test.dart
@@ -0,0 +1,19 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ Duration d, d1;
+
+ d1 = new Duration(milliseconds: 1);
+ d = d1 * 0.005;
+ Expect.equals(1000 * 0.005, d.inMicroseconds);
+ d = d1 * 0.0;
+ Expect.equals(0, d.inMicroseconds);
+ d = d1 * -0.005;
+ Expect.equals(1000 * -0.005, d.inMicroseconds);
+ d = d1 * 0.0015;
+ Expect.equals((1000 * 0.0015).round(), d.inMicroseconds);
+}
diff --git a/tests/corelib/duration_test.dart b/tests/corelib/duration_test.dart
new file mode 100644
index 0000000..842f4b0
--- /dev/null
+++ b/tests/corelib/duration_test.dart
@@ -0,0 +1,293 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ Duration d;
+ d = new Duration(days: 1);
+ Expect.equals(86400000000, d.inMicroseconds);
+ Expect.equals(86400000, d.inMilliseconds);
+ Expect.equals(86400, d.inSeconds);
+ Expect.equals(1440, d.inMinutes);
+ Expect.equals(24, d.inHours);
+ Expect.equals(1, d.inDays);
+ d = const Duration(hours: 1);
+ Expect.equals(3600000000, d.inMicroseconds);
+ Expect.equals(3600000, d.inMilliseconds);
+ Expect.equals(3600, d.inSeconds);
+ Expect.equals(60, d.inMinutes);
+ Expect.equals(1, d.inHours);
+ Expect.equals(0, d.inDays);
+ d = new Duration(minutes: 1);
+ Expect.equals(60000000, d.inMicroseconds);
+ Expect.equals(60000, d.inMilliseconds);
+ Expect.equals(60, d.inSeconds);
+ Expect.equals(1, d.inMinutes);
+ Expect.equals(0, d.inHours);
+ Expect.equals(0, d.inDays);
+ d = const Duration(seconds: 1);
+ Expect.equals(1000000, d.inMicroseconds);
+ Expect.equals(1000, d.inMilliseconds);
+ Expect.equals(1, d.inSeconds);
+ Expect.equals(0, d.inMinutes);
+ Expect.equals(0, d.inHours);
+ Expect.equals(0, d.inDays);
+ d = new Duration(milliseconds: 1);
+ Expect.equals(1000, d.inMicroseconds);
+ Expect.equals(1, d.inMilliseconds);
+ Expect.equals(0, d.inSeconds);
+ Expect.equals(0, d.inMinutes);
+ Expect.equals(0, d.inHours);
+ Expect.equals(0, d.inDays);
+ d = new Duration(microseconds: 1);
+ Expect.equals(1, d.inMicroseconds);
+ Expect.equals(0, d.inMilliseconds);
+ Expect.equals(0, d.inSeconds);
+ Expect.equals(0, d.inMinutes);
+ Expect.equals(0, d.inHours);
+ Expect.equals(0, d.inDays);
+
+ d = const Duration(milliseconds: 1, microseconds: 999);
+ Expect.equals(1999, d.inMicroseconds);
+ Expect.equals(1, d.inMilliseconds);
+ d = const Duration(seconds: 1, milliseconds: 999);
+ Expect.equals(1999, d.inMilliseconds);
+ Expect.equals(1, d.inSeconds);
+ d = new Duration(minutes: 1, seconds: 59);
+ Expect.equals(119, d.inSeconds);
+ Expect.equals(1, d.inMinutes);
+ d = const Duration(hours: 1, minutes: 59);
+ Expect.equals(119, d.inMinutes);
+ Expect.equals(1, d.inHours);
+ d = new Duration(days: 1, hours: 23);
+ Expect.equals(47, d.inHours);
+ Expect.equals(1, d.inDays);
+ d = const Duration(
+ days: 0,
+ hours: 23,
+ minutes: 59,
+ seconds: 59,
+ milliseconds: 999,
+ microseconds: 999);
+ Expect.equals(0, d.inDays);
+
+ d = new Duration(days: -1);
+ Expect.equals(-86400000000, d.inMicroseconds);
+ Expect.equals(-86400000, d.inMilliseconds);
+ Expect.equals(-86400, d.inSeconds);
+ Expect.equals(-1440, d.inMinutes);
+ Expect.equals(-24, d.inHours);
+ Expect.equals(-1, d.inDays);
+ d = const Duration(hours: -1);
+ Expect.equals(-3600000000, d.inMicroseconds);
+ Expect.equals(-3600000, d.inMilliseconds);
+ Expect.equals(-3600, d.inSeconds);
+ Expect.equals(-60, d.inMinutes);
+ Expect.equals(-1, d.inHours);
+ Expect.equals(0, d.inDays);
+ d = new Duration(minutes: -1);
+ Expect.equals(-60000000, d.inMicroseconds);
+ Expect.equals(-60000, d.inMilliseconds);
+ Expect.equals(-60, d.inSeconds);
+ Expect.equals(-1, d.inMinutes);
+ Expect.equals(0, d.inHours);
+ Expect.equals(0, d.inDays);
+ d = const Duration(seconds: -1);
+ Expect.equals(-1000000, d.inMicroseconds);
+ Expect.equals(-1000, d.inMilliseconds);
+ Expect.equals(-1, d.inSeconds);
+ Expect.equals(0, d.inMinutes);
+ Expect.equals(0, d.inHours);
+ Expect.equals(0, d.inDays);
+ d = new Duration(milliseconds: -1);
+ Expect.equals(-1000, d.inMicroseconds);
+ Expect.equals(-1, d.inMilliseconds);
+ Expect.equals(0, d.inSeconds);
+ Expect.equals(0, d.inMinutes);
+ Expect.equals(0, d.inHours);
+ Expect.equals(0, d.inDays);
+ d = new Duration(microseconds: -1);
+ Expect.equals(-1, d.inMicroseconds);
+ Expect.equals(0, d.inMilliseconds);
+ Expect.equals(0, d.inSeconds);
+ Expect.equals(0, d.inMinutes);
+ Expect.equals(0, d.inHours);
+ Expect.equals(0, d.inDays);
+
+ d = const Duration(days: 1, hours: -24);
+ Expect.equals(0, d.inMicroseconds);
+ d = new Duration(hours: 1, minutes: -60);
+ Expect.equals(0, d.inMicroseconds);
+ d = const Duration(minutes: 1, seconds: -60);
+ Expect.equals(0, d.inMicroseconds);
+ d = new Duration(seconds: 1, milliseconds: -1000);
+ Expect.equals(0, d.inMicroseconds);
+ d = new Duration(milliseconds: 1, microseconds: -1000);
+ Expect.equals(0, d.inMicroseconds);
+
+ d = const Duration(hours: 25);
+ Expect.equals(1, d.inDays);
+ Expect.equals(25, d.inHours);
+ Expect.equals(1500, d.inMinutes);
+ Expect.equals(90000, d.inSeconds);
+ Expect.equals(90000000, d.inMilliseconds);
+ Expect.equals(90000000000, d.inMicroseconds);
+ d = new Duration(minutes: 61);
+ Expect.equals(0, d.inDays);
+ Expect.equals(1, d.inHours);
+ Expect.equals(61, d.inMinutes);
+ Expect.equals(3660, d.inSeconds);
+ Expect.equals(3660000, d.inMilliseconds);
+ Expect.equals(3660000000, d.inMicroseconds);
+ d = const Duration(seconds: 61);
+ Expect.equals(0, d.inDays);
+ Expect.equals(0, d.inHours);
+ Expect.equals(1, d.inMinutes);
+ Expect.equals(61, d.inSeconds);
+ Expect.equals(61000, d.inMilliseconds);
+ Expect.equals(61000000, d.inMicroseconds);
+ d = new Duration(milliseconds: 1001);
+ Expect.equals(0, d.inDays);
+ Expect.equals(0, d.inHours);
+ Expect.equals(0, d.inMinutes);
+ Expect.equals(1, d.inSeconds);
+ Expect.equals(1001, d.inMilliseconds);
+ Expect.equals(1001000, d.inMicroseconds);
+ d = new Duration(microseconds: 1001);
+ Expect.equals(0, d.inDays);
+ Expect.equals(0, d.inHours);
+ Expect.equals(0, d.inMinutes);
+ Expect.equals(0, d.inSeconds);
+ Expect.equals(1, d.inMilliseconds);
+ Expect.equals(1001, d.inMicroseconds);
+
+ var d1 = const Duration(milliseconds: 1000);
+ var d2 = const Duration(seconds: 1);
+ Expect.identical(d1, d2);
+
+ d1 = const Duration(microseconds: 1000);
+ d2 = const Duration(milliseconds: 1);
+ Expect.identical(d1, d2);
+
+ d1 = new Duration(hours: 1);
+ d2 = new Duration(hours: -1);
+ d = d1 + d2;
+ Expect.equals(0, d.inMicroseconds);
+ d = d1 - d2;
+ Expect.equals(3600000000 * 2, d.inMicroseconds);
+
+ d2 = new Duration(hours: 1);
+ d = d1 + d2;
+ Expect.equals(3600000000 * 2, d.inMicroseconds);
+ d = d1 - d2;
+ Expect.equals(0, d.inMicroseconds);
+
+ d = d1 * 2;
+ Expect.equals(3600000000 * 2, d.inMicroseconds);
+ d = d1 * -1;
+ Expect.equals(-3600000000, d.inMicroseconds);
+ d = d1 * 0;
+ Expect.equals(0, d.inMicroseconds);
+
+ d = d1 ~/ 2;
+ Expect.equals(1800000000, d.inMicroseconds);
+ d = d1 ~/ 3600000001;
+ Expect.equals(0, d.inMicroseconds);
+ d = d1 ~/ -3600000001;
+ Expect.equals(0, d.inMicroseconds);
+ d = d1 ~/ 3599999999;
+ Expect.equals(1, d.inMicroseconds);
+ d = d1 ~/ -3599999999;
+ Expect.equals(-1, d.inMicroseconds);
+ d = d1 ~/ -1;
+ Expect.equals(-3600000000, d.inMicroseconds);
+ d = d1 * 0;
+ Expect.equals(0, d.inMicroseconds);
+ Expect.throws(() => d1 ~/ 0, (e) => e is IntegerDivisionByZeroException);
+
+ d = new Duration(microseconds: 0);
+ Expect.isTrue(d < new Duration(microseconds: 1));
+ Expect.isTrue(d <= new Duration(microseconds: 1));
+ Expect.isTrue(d <= d);
+ Expect.isTrue(d > new Duration(microseconds: -1));
+ Expect.isTrue(d >= new Duration(microseconds: -1));
+ Expect.isTrue(d >= d);
+
+ d = const Duration(
+ days: 1,
+ hours: 3,
+ minutes: 17,
+ seconds: 42,
+ milliseconds: 823,
+ microseconds: 127);
+ Expect.equals("27:17:42.823127", d.toString());
+
+ d = const Duration(hours: 1999, minutes: 17, seconds: 42);
+ Expect.equals("1999:17:42.000000", d.toString());
+
+ d = const Duration(
+ days: -1,
+ hours: -3,
+ minutes: -17,
+ seconds: -42,
+ milliseconds: -823,
+ microseconds: -127);
+ Expect.equals("-27:17:42.823127", d.toString());
+
+ d = const Duration(hours: -1999, minutes: -17, seconds: -42);
+ Expect.equals("-1999:17:42.000000", d.toString());
+
+ // Edge conditions for toString of microseconds.
+ // Regression test for http://dartbug.com/15678
+
+ d = const Duration(microseconds: 1);
+ Expect.equals("0:00:00.000001", d.toString());
+
+ d = const Duration(microseconds: 9);
+ Expect.equals("0:00:00.000009", d.toString());
+
+ d = const Duration(microseconds: 10);
+ Expect.equals("0:00:00.000010", d.toString());
+
+ d = const Duration(microseconds: 99);
+ Expect.equals("0:00:00.000099", d.toString());
+
+ d = const Duration(microseconds: 100);
+ Expect.equals("0:00:00.000100", d.toString());
+
+ d = const Duration(microseconds: 999);
+ Expect.equals("0:00:00.000999", d.toString());
+
+ d = const Duration(microseconds: 1000);
+ Expect.equals("0:00:00.001000", d.toString());
+
+ d = const Duration(microseconds: 9999);
+ Expect.equals("0:00:00.009999", d.toString());
+
+ d = const Duration(microseconds: 10000);
+ Expect.equals("0:00:00.010000", d.toString());
+
+ d = const Duration(microseconds: 99999);
+ Expect.equals("0:00:00.099999", d.toString());
+
+ d = const Duration(microseconds: 100000);
+ Expect.equals("0:00:00.100000", d.toString());
+
+ d = const Duration(microseconds: 999999);
+ Expect.equals("0:00:00.999999", d.toString());
+
+ d = const Duration(microseconds: 1000000);
+ Expect.equals("0:00:01.000000", d.toString());
+
+ d1 = const Duration(hours: 1);
+ d2 = const Duration(hours: -1);
+ Expect.isFalse(d1.isNegative);
+ Expect.isTrue(d2.isNegative);
+ Expect.equals(d1, d1.abs());
+ Expect.equals(d1, d2.abs());
+
+ Expect.equals(d2, -d1);
+ Expect.equals(d1, -d2);
+}
diff --git a/tests/corelib/dynamic_nosuchmethod_test.dart b/tests/corelib/dynamic_nosuchmethod_test.dart
new file mode 100644
index 0000000..2577b48
--- /dev/null
+++ b/tests/corelib/dynamic_nosuchmethod_test.dart
@@ -0,0 +1,86 @@
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+// Test that noSuchMethod calls behave as expected for dynamic object invocations.
+class BaseClass {
+ final dynamic finalField = "final!";
+
+ baz() => "baz!!";
+ get bla => (() => "bla!!");
+}
+
+class ReturnInvocationName extends BaseClass {
+ var _bar;
+
+ ReturnInvocationName(this._bar);
+
+ noSuchMethod(Invocation invocation) {
+ var name = invocation.memberName.toString();
+ var match = new RegExp(r'Symbol\("([^"]+)"\)').matchAsPrefix(name);
+ return match != null ? match.group(1) : name;
+ }
+
+ bar() {
+ return _bar;
+ }
+}
+
+class Foo {}
+
+main() {
+ dynamic x = new ReturnInvocationName(42);
+ Expect.equals('final!', x.finalField);
+ Expect.equals('foo', x.finalField = "foo", 'should call noSuchMethod');
+ Expect.equals('final!', x.finalField, 'field was not set');
+
+ Expect.equals('_prototype', x._prototype);
+ Expect.equals('_prototype', x._prototype());
+
+ Expect.equals('prototype', x.prototype);
+ Expect.equals('prototype', x.prototype());
+
+ Expect.equals('constructor', x.constructor);
+ Expect.equals('constructor', x.constructor());
+
+ Expect.equals('__proto__', x.__proto__);
+ Expect.equals('__proto__', x.__proto__);
+
+ Expect.equals(42, x.bar());
+ Expect.equals(42, (x.bar)());
+
+ Expect.equals('unary-', -x);
+ Expect.equals('+', x + 42);
+ Expect.equals('[]', x[4]);
+
+ dynamic b = new BaseClass();
+ Expect.equals('final!', b.finalField);
+ Expect.throwsNoSuchMethodError(() => b.finalField = "foo");
+ Expect.equals('final!', b.finalField, 'field was not set');
+
+ // Verify that noSuchMethod errors are triggered even when the JS object
+ // happens to have a matching member name.
+ dynamic f = new Foo();
+ Expect.throwsNoSuchMethodError(() => f.prototype);
+ Expect.throwsNoSuchMethodError(() => f.prototype());
+ Expect.throwsNoSuchMethodError(() => f.prototype = 42);
+
+ Expect.throwsNoSuchMethodError(() => f.constructor);
+ Expect.throwsNoSuchMethodError(() => f.constructor());
+ Expect.throwsNoSuchMethodError(() => f.constructor = 42);
+
+ Expect.throwsNoSuchMethodError(() => f.__proto__);
+
+ // These are valid JS properties but not Dart methods.
+ Expect.throwsNoSuchMethodError(() => f.toLocaleString);
+
+ Expect.throwsNoSuchMethodError(() => f.hasOwnProperty);
+
+ f = (int x) {};
+ // Calls with the wrong number of arguments should be NoSuchMethodErrors.
+ Expect.throwsNoSuchMethodError(() => f());
+ Expect.throwsNoSuchMethodError(() => f('hi', '!'));
+ Expect.throwsNoSuchMethodError(() => f(x: 42));
+}
diff --git a/tests/corelib/error_stack_trace1_test.dart b/tests/corelib/error_stack_trace1_test.dart
new file mode 100644
index 0000000..17adde7
--- /dev/null
+++ b/tests/corelib/error_stack_trace1_test.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ static Aa() => Ab();
+ static Ab() => Ac();
+ static Ac() => throw "abc";
+}
+
+class B {
+ static Ba() => Bb();
+ static Bb() => Bc();
+ static Bc() {
+ try {
+ A.Aa();
+ } catch (e) {
+ // This should produce a NoSuchMethodError.
+ var trace = e.stackTrace;
+ }
+ }
+}
+
+main() {
+ bool hasThrown = false;
+ try {
+ B.Ba();
+ } catch (e, stackTrace) {
+ hasThrown = true;
+ var trace = stackTrace.toString();
+ print(trace);
+ Expect.isTrue(trace.contains("Bc"));
+ Expect.isTrue(trace.contains("Bb"));
+ Expect.isTrue(trace.contains("Ba"));
+ Expect.isTrue(trace.contains("main"));
+ }
+ Expect.isTrue(hasThrown);
+}
diff --git a/tests/corelib/error_stack_trace2_test.dart b/tests/corelib/error_stack_trace2_test.dart
new file mode 100644
index 0000000..7437651
--- /dev/null
+++ b/tests/corelib/error_stack_trace2_test.dart
@@ -0,0 +1,29 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ get foo => cyclicStatic;
+}
+
+var a = new A();
+dynamic cyclicStatic = (() => a.foo + 1)();
+
+cyclicInitialization() {
+ return cyclicStatic;
+}
+
+main() {
+ bool hasThrown = false;
+ try {
+ cyclicStatic + 1;
+ } catch (e2) {
+ var e = e2;
+ hasThrown = true;
+ Expect.isTrue(
+ e.stackTrace is StackTrace, "$e doesn't have a non-null stack trace");
+ }
+ Expect.isTrue(hasThrown);
+}
diff --git a/tests/corelib/error_stack_trace_test.dart b/tests/corelib/error_stack_trace_test.dart
new file mode 100644
index 0000000..347f26f
--- /dev/null
+++ b/tests/corelib/error_stack_trace_test.dart
@@ -0,0 +1,68 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+void argument() {
+ throw new ArgumentError(499);
+}
+
+// Verify that
+void noSuchMethod() {
+ (499 as dynamic).doesNotExist();
+}
+
+void nullThrown() {
+ throw null as dynamic;
+}
+
+void range() {
+ throw new RangeError.range(0, 1, 2);
+}
+
+abstract class A {
+ foo();
+}
+
+void unsupported() {
+ throw new UnsupportedError("unsupported");
+}
+
+void unimplemented() {
+ throw new UnimplementedError("unimplemented");
+}
+
+void state() {
+ [1, 2].single;
+}
+
+void cast() {
+ dynamic d = 1;
+ d as String;
+}
+
+main() {
+ List<Function> errorFunctions = [
+ argument,
+ noSuchMethod,
+ nullThrown, //# nullThrown: ok
+ range,
+ unsupported,
+ unimplemented,
+ state,
+ cast,
+ ];
+
+ for (var f in errorFunctions) {
+ bool hasThrown = false;
+ try {
+ f();
+ } catch (e) {
+ hasThrown = true;
+ Expect.isTrue(
+ e.stackTrace is StackTrace, "$e doesn't have a non-null stack trace");
+ }
+ Expect.isTrue(hasThrown);
+ }
+}
diff --git a/tests/corelib/errors_test.dart b/tests/corelib/errors_test.dart
new file mode 100644
index 0000000..763b486
--- /dev/null
+++ b/tests/corelib/errors_test.dart
@@ -0,0 +1,77 @@
+// Copyright (c) 2015, 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.
+
+import "package:expect/expect.dart";
+
+// Test that error constructors do what they are documented as doing.
+
+main() {
+ Expect.equals("Invalid argument(s)", new ArgumentError().toString());
+ Expect.equals(
+ "Invalid argument(s): message", new ArgumentError("message").toString());
+ Expect.equals(
+ "Invalid argument: null", new ArgumentError.value(null).toString());
+ Expect.equals("Invalid argument: 42", new ArgumentError.value(42).toString());
+ Expect.equals(
+ "Invalid argument: \"bad\"", new ArgumentError.value("bad").toString());
+ Expect.equals("Invalid argument (foo): null",
+ new ArgumentError.value(null, "foo").toString());
+ Expect.equals("Invalid argument (foo): 42",
+ new ArgumentError.value(42, "foo").toString());
+ Expect.equals("Invalid argument (foo): message: 42",
+ new ArgumentError.value(42, "foo", "message").toString());
+ Expect.equals("Invalid argument: message: 42",
+ new ArgumentError.value(42, null, "message").toString());
+ Expect.equals("Invalid argument(s): Must not be null",
+ new ArgumentError.notNull().toString());
+ Expect.equals("Invalid argument(s) (foo): Must not be null",
+ new ArgumentError.notNull("foo").toString());
+
+ Expect.equals("RangeError", new RangeError(null).toString());
+ Expect.equals("RangeError: message", new RangeError("message").toString());
+ Expect.equals("RangeError: Value not in range: 42",
+ new RangeError.value(42).toString());
+ Expect.equals("RangeError (foo): Value not in range: 42",
+ new RangeError.value(42, "foo").toString());
+ Expect.equals("RangeError (foo): message: 42",
+ new RangeError.value(42, "foo", "message").toString());
+ Expect.equals("RangeError: message: 42",
+ new RangeError.value(42, null, "message").toString());
+
+ Expect.equals("RangeError: Invalid value: Not in range 2..9, inclusive: 42",
+ new RangeError.range(42, 2, 9).toString());
+ Expect.equals(
+ "RangeError (foo): Invalid value: Not in range 2..9, "
+ "inclusive: 42",
+ new RangeError.range(42, 2, 9, "foo").toString());
+ Expect.equals("RangeError (foo): message: Not in range 2..9, inclusive: 42",
+ new RangeError.range(42, 2, 9, "foo", "message").toString());
+ Expect.equals("RangeError: message: Not in range 2..9, inclusive: 42",
+ new RangeError.range(42, 2, 9, null, "message").toString());
+
+ Expect.equals(
+ "RangeError: Index out of range: "
+ "index should be less than 3: 42",
+ new RangeError.index(42, [1, 2, 3]).toString());
+ Expect.equals(
+ "RangeError (foo): Index out of range: "
+ "index should be less than 3: 42",
+ new RangeError.index(42, [1, 2, 3], "foo").toString());
+ Expect.equals(
+ "RangeError (foo): message: "
+ "index should be less than 3: 42",
+ new RangeError.index(42, [1, 2, 3], "foo", "message").toString());
+ Expect.equals(
+ "RangeError: message: "
+ "index should be less than 3: 42",
+ new RangeError.index(42, [1, 2, 3], null, "message").toString());
+ Expect.equals(
+ "RangeError (foo): message: "
+ "index should be less than 2: 42",
+ new RangeError.index(42, [1, 2, 3], "foo", "message", 2).toString());
+ Expect.equals(
+ "RangeError: Index out of range: "
+ "index must not be negative: -5",
+ new RangeError.index(-5, [1, 2, 3]).toString());
+}
diff --git a/tests/corelib/exception_implementation_test.dart b/tests/corelib/exception_implementation_test.dart
new file mode 100644
index 0000000..0744f50
--- /dev/null
+++ b/tests/corelib/exception_implementation_test.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2011, 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.
+
+library exception_implementation_test;
+
+import "package:expect/expect.dart";
+
+main() {
+ final msg = 1;
+ try {
+ throw new Exception(msg);
+ Expect.fail("Unreachable");
+ } on Exception catch (e) {
+ Expect.isTrue(e is Exception);
+ Expect.equals("Exception: $msg", e.toString());
+ }
+}
diff --git a/tests/corelib/expando_test.dart b/tests/corelib/expando_test.dart
new file mode 100644
index 0000000..3189c9b
--- /dev/null
+++ b/tests/corelib/expando_test.dart
@@ -0,0 +1,106 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+class ExpandoTest {
+ static Expando<int> visits = Expando('visits');
+
+ static testMain() {
+ var legal = [
+ new Object(),
+ new List(),
+ [1, 2, 3],
+ const [1, 2, 3],
+ new Map(),
+ {'x': 1, 'y': 2},
+ const {'x': 1, 'y': 2},
+ new Expando(),
+ new Expando('horse')
+ ];
+ for (var object in legal) {
+ testNamedExpando(object);
+ testUnnamedExpando(object);
+ }
+ for (var object in legal) {
+ Expect.equals(2, visits[object], "$object");
+ }
+ testIllegal();
+ testIdentity();
+ }
+
+ static visit(object) {
+ int count = visits[object]!;
+ count = (count == null) ? 1 : count + 1;
+ visits[object] = count;
+ }
+
+ static testNamedExpando(object) {
+ Expando<int> expando = new Expando<int>('myexpando');
+ Expect.equals('myexpando', expando.name);
+ Expect.isTrue(expando.toString().startsWith('Expando:myexpando'));
+ testExpando(expando, object);
+ }
+
+ static testUnnamedExpando(object) {
+ Expando<int> expando = new Expando<int>();
+ Expect.isNull(expando.name);
+ Expect.isTrue(expando.toString().startsWith('Expando:'));
+ testExpando(expando, object);
+ }
+
+ static testExpando(Expando<int> expando, object) {
+ visit(object);
+
+ Expect.isNull(expando[object]);
+ expando[object] = 42;
+ Expect.equals(42, expando[object]);
+ expando[object] = null;
+ Expect.isNull(expando[object]);
+
+ Expando<int> alternative = new Expando('myexpando');
+ Expect.isNull(alternative[object]);
+ alternative[object] = 87;
+ Expect.isNull(expando[object]);
+ expando[object] = 99;
+ Expect.equals(99, expando[object]);
+ Expect.equals(87, alternative[object]);
+ }
+
+ static testIllegal() {
+ Expando<int> expando = new Expando<int>();
+ Expect.throwsArgumentError(() => expando['string'], "'string'");
+ Expect.throwsArgumentError(() => expando[42], "42");
+ Expect.throwsArgumentError(() => expando[42.87], "42.87");
+ Expect.throwsArgumentError(() => expando[true], "true");
+ Expect.throwsArgumentError(() => expando[false], "false");
+ }
+
+ static testIdentity() {
+ // Expando only depends on identity of object.
+ Expando<int> expando = new Expando<int>();
+ var m1 = new Mutable(1);
+ var m2 = new Mutable(7);
+ var m3 = new Mutable(13);
+ expando[m1] = 42;
+ Expect.equals(42, expando[m1]);
+ m1.id = 37;
+ Expect.equals(42, expando[m1]);
+ expando[m2] = 37;
+ expando[m3] = 10;
+ m3.id = 1;
+ Expect.equals(42, expando[m1]);
+ Expect.equals(37, expando[m2]);
+ Expect.equals(10, expando[m3]);
+ }
+}
+
+main() => ExpandoTest.testMain();
+
+class Mutable {
+ int id;
+ Mutable(this.id);
+ int get hashCode => id;
+ bool operator ==(other) => other is Mutable && other.id == id;
+}
diff --git a/tests/corelib/expression_test.dart b/tests/corelib/expression_test.dart
new file mode 100644
index 0000000..7cbce5a
--- /dev/null
+++ b/tests/corelib/expression_test.dart
@@ -0,0 +1,117 @@
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+// Tests basic expressions. Does not attempt to validate the details of arithmetic, coercion, and
+// so forth.
+class ExpressionTest {
+ ExpressionTest() {}
+
+ int foo = -1;
+
+ static testMain() {
+ var test = new ExpressionTest();
+ test.testBinary();
+ test.testUnary();
+ test.testShifts();
+ test.testBitwise();
+ test.testIncrement();
+ test.testMangling();
+ }
+
+ testBinary() {
+ int x = 4, y = 2;
+ Expect.equals(6, x + y);
+ Expect.equals(2, x - y);
+ Expect.equals(8, x * y);
+ Expect.equals(2, x / y);
+ Expect.equals(0, x % y);
+ }
+
+ testUnary() {
+ int x = 4, y = 2, z = -5;
+ bool t = true, f = false;
+ Expect.equals(-4, -x);
+ Expect.equals(4, ~z);
+ Expect.equals(f, !t);
+ }
+
+ testShifts() {
+ int x = 4, y = 2;
+ Expect.equals(y, x >> 1);
+ Expect.equals(x, y << 1);
+ }
+
+ testBitwise() {
+ int x = 4, y = 2;
+ Expect.equals(6, (x | y));
+ Expect.equals(0, (x & y));
+ Expect.equals(6, (x ^ y));
+ }
+
+ int operator [](int index) {
+ return foo;
+ }
+
+ operator []=(int index, int value) {
+ foo = value;
+ }
+
+ testIncrement() {
+ int x = 4, a = x++;
+ Expect.equals(4, a);
+ Expect.equals(5, x);
+ Expect.equals(6, ++x);
+ Expect.equals(6, x++);
+ Expect.equals(7, x);
+ Expect.equals(6, --x);
+ Expect.equals(6, x--);
+ Expect.equals(5, x);
+
+ this.foo = 0;
+ Expect.equals(0, this.foo++);
+ Expect.equals(1, this.foo);
+ Expect.equals(2, ++this.foo);
+ Expect.equals(2, this.foo);
+ Expect.equals(2, this.foo--);
+ Expect.equals(1, this.foo);
+ Expect.equals(0, --this.foo);
+ Expect.equals(0, this.foo);
+
+ Expect.equals(0, this[0]++);
+ Expect.equals(1, this[0]);
+ Expect.equals(2, ++this[0]);
+ Expect.equals(2, this[0]);
+ Expect.equals(2, this[0]--);
+ Expect.equals(1, this[0]);
+ Expect.equals(0, --this[0]);
+ Expect.equals(0, this[0]);
+
+ int $0 = 42, $1 = 87, $2 = 117;
+ Expect.equals(42, $0++);
+ Expect.equals(43, $0);
+ Expect.equals(44, ++$0);
+ Expect.equals(88, $0 += $0);
+ Expect.equals(87, $1++);
+ Expect.equals(88, $1);
+ Expect.equals(89, ++$1);
+ Expect.equals(178, ($1 += $1));
+ Expect.equals(117, $2++);
+ Expect.equals(118, $2);
+ Expect.equals(119, ++$2);
+ }
+
+ void testMangling() {
+ int $0 = 42, $1 = 87, $2 = 117;
+ this[0] = 0;
+ Expect.equals(42, (this[0] += $0));
+ Expect.equals(129, (this[0] += $1));
+ Expect.equals(246, (this[0] += $2));
+ }
+}
+
+main() {
+ ExpressionTest.testMain();
+}
diff --git a/tests/corelib/for_in_test.dart b/tests/corelib/for_in_test.dart
new file mode 100644
index 0000000..79c0434
--- /dev/null
+++ b/tests/corelib/for_in_test.dart
@@ -0,0 +1,97 @@
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+class ForInTest {
+ static testMain() {
+ testSimple();
+ testBreak();
+ testContinue();
+ testClosure();
+ }
+
+ static Set<int> getSmallSet() {
+ Set<int> set = new Set<int>();
+ set.add(1);
+ set.add(2);
+ set.add(4);
+ return set;
+ }
+
+ static void testSimple() {
+ Set<int> set = getSmallSet();
+ int count = 0;
+ for (final i in set) {
+ count += i;
+ }
+ Expect.equals(7, count);
+
+ count = 0;
+ for (var i in set) {
+ count += i;
+ }
+ Expect.equals(7, count);
+
+ count = 0;
+ for (int i in set) {
+ count += i;
+ }
+ Expect.equals(7, count);
+
+ count = 0;
+ for (final int i in set) {
+ count += i;
+ }
+ Expect.equals(7, count);
+
+ count = 0;
+ int i = 0;
+ Expect.equals(false, set.contains(i)); // Used to test [i] after loop.
+ for (i in set) {
+ count += i;
+ }
+ Expect.equals(7, count);
+ Expect.equals(true, set.contains(i));
+ // The default implementation of [Set] preserves order.
+ Expect.equals(4, i);
+ }
+
+ static void testBreak() {
+ Set<int> set = getSmallSet();
+ int count = 0;
+ for (final i in set) {
+ if (i == 4) break;
+ count += i;
+ }
+ Expect.equals(true, count < 4);
+ }
+
+ static void testContinue() {
+ Set<int> set = getSmallSet();
+ int count = 0;
+ for (final i in set) {
+ if (i < 4) continue;
+ count += i;
+ }
+ Expect.equals(4, count);
+ }
+
+ static void testClosure() {
+ Set<int> set = getSmallSet();
+ List<Function> closures = [];
+ int index = 0;
+ for (var i in set) {
+ closures.add(() => i);
+ index++;
+ }
+
+ Expect.equals(index, set.length);
+ Expect.equals(7, closures[0]() + closures[1]() + closures[2]());
+ }
+}
+
+main() {
+ ForInTest.testMain();
+}
diff --git a/tests/corelib/format_exception_test.dart b/tests/corelib/format_exception_test.dart
new file mode 100644
index 0000000..dcc9d35
--- /dev/null
+++ b/tests/corelib/format_exception_test.dart
@@ -0,0 +1,106 @@
+// Copyright (c) 2011, 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.
+
+library format_exception_test;
+
+import "package:expect/expect.dart";
+
+test(exn, message, source, offset, toString) {
+ Expect.equals(message, exn.message);
+ Expect.equals(source, exn.source);
+ Expect.equals(offset, exn.offset);
+ Expect.equals(toString, exn.toString());
+}
+
+main() {
+ var e;
+ e = new FormatException();
+ test(e, "", null, null, "FormatException");
+ e = new FormatException("");
+ test(e, "", null, null, "FormatException");
+
+ e = new FormatException("message");
+ test(e, "message", null, null, "FormatException: message");
+
+ e = new FormatException("message", "source");
+ test(e, "message", "source", null, "FormatException: message\nsource");
+
+ e = new FormatException("message", "source" * 25);
+ test(e, "message", "source" * 25, null,
+ "FormatException: message\n" + "source" * 12 + "sou...");
+ e = new FormatException("message", "source" * 25);
+ test(e, "message", "source" * 25, null,
+ "FormatException: message\n" + "source" * 12 + "sou...");
+ e = new FormatException("message", "s1\nsource\ns2");
+ test(e, "message", "s1\nsource\ns2", null,
+ "FormatException: message\n" + "s1\nsource\ns2");
+
+ var o = new Object();
+ e = new FormatException("message", o, 10);
+ test(e, "message", o, 10, "FormatException: message (at offset 10)");
+
+ e = new FormatException("message", "source", 3);
+ test(e, "message", "source", 3,
+ "FormatException: message (at character 4)\nsource\n ^\n");
+
+ e = new FormatException("message", "s1\nsource\ns2", 6);
+ test(e, "message", "s1\nsource\ns2", 6,
+ "FormatException: message (at line 2, character 4)\nsource\n ^\n");
+
+ var longline = "watermelon cantaloupe " * 8 + "watermelon"; // Length > 160.
+ var longsource = (longline + "\n") * 25;
+ var line10 = (longline.length + 1) * 9;
+ e = new FormatException("message", longsource, line10);
+ test(
+ e,
+ "message",
+ longsource,
+ line10,
+ "FormatException: message (at line 10, character 1)\n"
+ "${longline.substring(0, 75)}...\n^\n");
+
+ e = new FormatException("message", longsource, line10 - 1);
+ test(
+ e,
+ "message",
+ longsource,
+ line10 - 1,
+ "FormatException: message (at line 9, "
+ "character ${longline.length + 1})\n"
+ "...${longline.substring(longline.length - 75)}\n"
+ "${' ' * 78}^\n");
+
+ var half = longline.length ~/ 2;
+ e = new FormatException("message", longsource, line10 + half);
+ test(
+ e,
+ "message",
+ longsource,
+ line10 + half,
+ "FormatException: message (at line 10, character ${half + 1})\n"
+ "...${longline.substring(half - 36, half + 36)}...\n"
+ "${' ' * 39}^\n");
+
+ var sourceNL = "\nsource with leading NL";
+ e = new FormatException("message", sourceNL, 2);
+ test(
+ e,
+ "message",
+ sourceNL,
+ 2,
+ "FormatException: message (at line 2, character 2)\n"
+ "source with leading NL\n"
+ " ^\n");
+
+ var sourceNL2 = "\n\nsource with leading NL";
+ e = new FormatException("message", sourceNL2, 2);
+ test(
+ e,
+ "message",
+ sourceNL2,
+ 2,
+ "FormatException: message (at line 3, character 1)\n"
+ "source with leading NL\n"
+ "^\n");
+}
diff --git a/tests/corelib/from_environment_const_type_test.dart b/tests/corelib/from_environment_const_type_test.dart
new file mode 100644
index 0000000..3ed691c
--- /dev/null
+++ b/tests/corelib/from_environment_const_type_test.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2014, 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.
+// SharedOptions=-Da=true -Db=false -Dc=3 -Dd=STRING
+
+import "package:expect/expect.dart";
+
+class Foo {}
+
+const
+ bool // //# 01: ok
+ int // //# 02: compile-time error
+ String // //# 03: compile-time error
+ Foo // //# 04: compile-time error
+ a = const bool.fromEnvironment('a');
+
+const
+ bool // //# 05: ok
+ int // //# 06: compile-time error
+ String // //# 07: compile-time error
+ Foo // //# 08: compile-time error
+ b = const bool.fromEnvironment('b');
+
+const
+ bool // //# 09: compile-time error
+ int // //# 10: ok
+ String // //# 11: compile-time error
+ Foo // //# 12: compile-time error
+ c = const int.fromEnvironment('c');
+
+const
+ bool // //# 13: compile-time error
+ int // //# 14: compile-time error
+ String // //# 15: ok
+ Foo // //# 16: compile-time error
+ d = const String.fromEnvironment('d');
+
+main() {
+ Expect.equals(a, true);
+ Expect.equals(b, false);
+ Expect.equals(c, 3);
+ Expect.equals(d, 'STRING');
+}
diff --git a/tests/corelib/from_environment_const_type_undefined_test.dart b/tests/corelib/from_environment_const_type_undefined_test.dart
new file mode 100644
index 0000000..c555b02
--- /dev/null
+++ b/tests/corelib/from_environment_const_type_undefined_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class Foo {}
+
+const
+ bool // //# 01: ok
+ int // //# 02: compile-time error
+ String //# 03: compile-time error
+ Foo // //# 04: compile-time error
+ a = const bool.fromEnvironment('a');
+
+const
+ bool // //# 05: ok
+ int // //# 06: compile-time error
+ String //# 07: compile-time error
+ Foo // //# 08: compile-time error
+ b = const bool.fromEnvironment('b');
+
+const
+ bool // //# 09: compile-time error
+ int // //# 10: ok
+ String //# 11: compile-time error
+ Foo // //# 12: compile-time error
+ c = const int.fromEnvironment('c');
+
+const
+ bool // //# 13: compile-time error
+ int // //# 14: compile-time error
+ String //# 15: ok
+ Foo // //# 16: compile-time error
+ d = const String.fromEnvironment('d');
+
+main() {
+ Expect.equals(a, false);
+ Expect.equals(b, false);
+ Expect.equals(c, null);
+ Expect.equals(d, null);
+}
diff --git a/tests/corelib/growable_list_test.dart b/tests/corelib/growable_list_test.dart
new file mode 100644
index 0000000..91915bd
--- /dev/null
+++ b/tests/corelib/growable_list_test.dart
@@ -0,0 +1,164 @@
+// Copyright (c) 2011, 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.
+
+// Sanity check on the growing behavior of a growable list.
+
+import "package:expect/expect.dart";
+
+void main() {
+ testConstructor();
+ // Concurrent modification checks are only guaranteed in checked mode.
+ testConcurrentModification();
+}
+
+// Iterable generating numbers in range [0..count).
+// May perform callback at some point underways.
+class TestIterableBase extends Iterable<int> {
+ final int length;
+ final int count;
+ // call [callback] if generating callbackIndex.
+ final int callbackIndex;
+ final Function callback;
+ TestIterableBase(this.length, this.count, this.callbackIndex, this.callback);
+ Iterator<int> get iterator => new CallbackIterator(this);
+}
+
+class TestIterable extends TestIterableBase {
+ TestIterable(count, [callbackIndex = -1, callback])
+ : super(-1, count, callbackIndex, callback);
+ int get length => throw "SHOULD NOT BE CALLED";
+}
+
+// Implement Set for private EfficientLengthIterable interface.
+class EfficientTestIterable extends TestIterableBase implements Set<int> {
+ EfficientTestIterable(length, count, [callbackIndex = -1, callback])
+ : super(length, count, callbackIndex, callback);
+ // Avoid warnings because we don't actually implement Set.
+ noSuchMethod(i) => super.noSuchMethod(i);
+ Set<R> cast<R>() => throw "not used by test";
+}
+
+class CallbackIterator implements Iterator<int> {
+ TestIterableBase _iterable;
+ int? _current = null;
+ int _nextIndex = 0;
+ CallbackIterator(this._iterable);
+ bool moveNext() {
+ if (_nextIndex >= _iterable.count) {
+ _current = null;
+ return false;
+ }
+ _current = _nextIndex;
+ _nextIndex++;
+ if (_current == _iterable.callbackIndex) {
+ _iterable.callback();
+ }
+ return true;
+ }
+
+ int get current => _current ?? (throw StateError("No current element"));
+}
+
+void testConstructor() {
+ // Constructor can make both growable and fixed-length lists.
+ testGrowable(list) {
+ Expect.isTrue(list is List<int>);
+ Expect.isFalse(list is List<String>);
+ int length = list.length;
+ list.add(42);
+ Expect.equals(list.length, length + 1);
+ }
+
+ testFixedLength(list) {
+ Expect.isTrue(list is List<int>);
+ int length = list.length;
+ Expect.throws(() {
+ list.add(42);
+ });
+ Expect.equals(length, list.length);
+ }
+
+ testThrowsOrTypeError(fn, [name]) {
+ Expect.throws(fn, (_) => true, name);
+ }
+
+ testFixedLength(new List<int?>(0));
+ testFixedLength(new List<int?>(5));
+ testFixedLength(new List<int?>.filled(5, null)); // default growable: false.
+ testGrowable(new List<int?>());
+ testGrowable(new List<int?>()..length = 5);
+ testGrowable(new List<int?>.filled(5, null, growable: true));
+ Expect.throwsArgumentError(() => new List<int?>(-1), "-1");
+ // There must be limits. Fix this test if we ever allow 2^63 elements.
+ Expect.throws(() => new List<int?>(0x7ffffffffffff000),
+ (e) => e is OutOfMemoryError || e is ArgumentError, "bignum");
+ Expect.throwsArgumentError(() => new List<int?>(null), "null");
+ testThrowsOrTypeError(
+ () => new List([] as dynamic), // Cast to avoid warning.
+ 'list');
+ testThrowsOrTypeError(() => new List([42] as dynamic), "list2");
+}
+
+void testConcurrentModification() {
+ // Without EfficientLengthIterable interface
+ {
+ // Change length of list after 200 additions.
+ var l = [];
+ var ci = new TestIterable(257, 200, () {
+ l.add("X");
+ });
+ Expect.throws(() {
+ l.addAll(ci);
+ }, (e) => e is ConcurrentModificationError, "cm1");
+ }
+
+ {
+ // Change length of list after 200 additions.
+ var l = [];
+ var ci = new TestIterable(257, 200, () {
+ l.length = 0;
+ });
+ Expect.throws(() {
+ l.addAll(ci);
+ }, (e) => e is ConcurrentModificationError, "cm2");
+ }
+
+ // With EfficientLengthIterable interface (uses length).
+ {
+ // Change length of list after 20 additions.
+ var l = [];
+ var ci = new EfficientTestIterable(257, 257, 20, () {
+ l.add("X");
+ });
+ Expect.throws(() {
+ l.addAll(ci);
+ }, (e) => e is ConcurrentModificationError, "cm3");
+ }
+
+ {
+ var l = [];
+ var ci = new EfficientTestIterable(257, 257, 20, () {
+ l.length = 0;
+ });
+ Expect.throws(() {
+ l.addAll(ci);
+ }, (e) => e is ConcurrentModificationError, "cm4");
+ }
+
+ {
+ // Length 500, only 250 elements.
+ var l = [];
+ var ci = new EfficientTestIterable(500, 250);
+ l.addAll(ci);
+ Expect.listEquals(new List.generate(250, (x) => x), l, "cm5");
+ }
+
+ {
+ // Length 250, but 500 elements.
+ var l = [];
+ var ci = new EfficientTestIterable(250, 500);
+ l.addAll(ci);
+ Expect.listEquals(new List.generate(500, (x) => x), l, "cm6");
+ }
+}
diff --git a/tests/corelib/has_next_iterator_test.dart b/tests/corelib/has_next_iterator_test.dart
new file mode 100644
index 0000000..7930cd6
--- /dev/null
+++ b/tests/corelib/has_next_iterator_test.dart
@@ -0,0 +1,37 @@
+// Copyright (c) 2012, 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.
+
+library hasNextIterator.test;
+
+import "package:expect/expect.dart";
+import 'dart:collection';
+
+main() {
+ var it = new HasNextIterator([].iterator);
+ Expect.isFalse(it.hasNext);
+ Expect.isFalse(it.hasNext);
+ Expect.throwsStateError(() => it.next());
+ Expect.isFalse(it.hasNext);
+
+ it = new HasNextIterator([1].iterator);
+ Expect.isTrue(it.hasNext);
+ Expect.isTrue(it.hasNext);
+ Expect.equals(1, it.next());
+ Expect.isFalse(it.hasNext);
+ Expect.isFalse(it.hasNext);
+ Expect.throwsStateError(() => it.next());
+ Expect.isFalse(it.hasNext);
+
+ it = new HasNextIterator([1, 2].iterator);
+ Expect.isTrue(it.hasNext);
+ Expect.isTrue(it.hasNext);
+ Expect.equals(1, it.next());
+ Expect.isTrue(it.hasNext);
+ Expect.isTrue(it.hasNext);
+ Expect.equals(2, it.next());
+ Expect.isFalse(it.hasNext);
+ Expect.isFalse(it.hasNext);
+ Expect.throwsStateError(() => it.next());
+ Expect.isFalse(it.hasNext);
+}
diff --git a/tests/corelib/hash_map2_test.dart b/tests/corelib/hash_map2_test.dart
new file mode 100644
index 0000000..b8b352f
--- /dev/null
+++ b/tests/corelib/hash_map2_test.dart
@@ -0,0 +1,311 @@
+// Copyright (c) 2013, 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.
+//
+// VMOptions=
+// VMOptions=--use_internal_hash_map
+
+// Tests of hash map behavior, with focus in iteration and concurrent
+// modification errors.
+
+library hash_map2_test;
+
+import "package:expect/expect.dart";
+import 'dart:collection';
+
+testMap(Map newMap(), Map newMapFrom(Map map)) {
+ Map gen(int from, int to) {
+ Map map = new LinkedHashMap();
+ for (int i = from; i < to; i++) map[i] = i;
+ return map;
+ }
+
+ bool odd(dynamic n) => ((n as int) & 1) == 1;
+ bool even(dynamic n) => ((n as int) & 1) == 0;
+ void addAll(Map toMap, Map fromMap) {
+ fromMap.forEach((k, v) {
+ toMap[k] = v;
+ });
+ }
+
+ {
+ // Test growing to largish capacity.
+ Map map = newMap();
+
+ for (int i = 0; i < 256; i++) {
+ map[i] = i;
+ }
+ addAll(map, gen(256, 512));
+ addAll(map, newMapFrom(gen(512, 1000)));
+ Expect.equals(1000, map.length);
+
+ // Remove half.
+ for (int i = 0; i < 1000; i += 2) map.remove(i);
+ Expect.equals(500, map.length);
+ Expect.isFalse(map.keys.any(even));
+ Expect.isTrue(map.keys.every(odd));
+
+ // Re-add all.
+ addAll(map, gen(0, 1000));
+ Expect.equals(1000, map.length);
+ }
+
+ {
+ // Test having many deleted elements.
+ Map map = newMap();
+ map[0] = 0;
+ for (int i = 0; i < 1000; i++) {
+ map[i + 1] = i + 1;
+ map.remove(i);
+ Expect.equals(1, map.length);
+ }
+ }
+
+ {
+ // Test having many elements with same hashCode
+ Map map = newMap();
+ for (int i = 0; i < 1000; i++) {
+ map[new BadHashCode()] = 0;
+ }
+ Expect.equals(1000, map.length);
+ }
+
+ {
+ // Check concurrent modification
+ Map map = newMap()
+ ..[0] = 0
+ ..[1] = 1;
+
+ {
+ // Test adding before a moveNext.
+ Iterator iter = map.keys.iterator;
+ iter.moveNext();
+ map[1] = 9; // Updating existing key isn't a modification.
+ iter.moveNext();
+ map[2] = 2;
+ Expect.throws(iter.moveNext, (e) => e is Error);
+ }
+
+ {
+ // Test adding after last element.
+ Iterator iter = map.keys.iterator;
+ Expect.equals(3, map.length);
+ iter.moveNext();
+ iter.moveNext();
+ iter.moveNext();
+ map[3] = 3;
+ Expect.throws(iter.moveNext, (e) => e is Error);
+ }
+
+ {
+ // Test removing during iteration.
+ Iterator iter = map.keys.iterator;
+ iter.moveNext();
+ map.remove(1000); // Not a modification if it's not there.
+ iter.moveNext();
+ int n = iter.current;
+ map.remove(n);
+ // Removing doesn't change current.
+ Expect.equals(n, iter.current);
+ Expect.throws(iter.moveNext, (e) => e is Error);
+ }
+
+ {
+ // Test removing after last element.
+ Iterator iter = map.keys.iterator;
+ Expect.equals(3, map.length);
+ iter.moveNext();
+ iter.moveNext();
+ iter.moveNext();
+ int n = iter.current;
+ map.remove(n);
+ // Removing doesn't change current.
+ Expect.equals(n, iter.current);
+ Expect.throws(iter.moveNext, (e) => e is Error);
+ }
+
+ {
+ // Test that updating value of existing key doesn't cause concurrent
+ // modification error.
+ Iterator iter = map.keys.iterator;
+ Expect.equals(2, map.length);
+ iter.moveNext();
+ int n = iter.current;
+ map[n] = n * 2;
+ iter.moveNext();
+ Expect.equals(map[iter.current], iter.current);
+ }
+
+ {
+ // Test that modification during putIfAbsent is not an error.
+ map.putIfAbsent(4, () {
+ map[5] = 5;
+ map[4] = -1;
+ return 4;
+ });
+ Expect.equals(4, map[4]);
+ Expect.equals(5, map[5]);
+ }
+
+ {
+ // Check adding many existing keys isn't considered modification.
+ Map map2 = newMap();
+ for (var key in map.keys) {
+ map2[key] = map[key] + 1;
+ }
+ Iterator iter = map.keys.iterator;
+ addAll(map, map2);
+ // Shouldn't throw.
+ iter.moveNext();
+ }
+ }
+
+ {
+ // Regression test for bug in putIfAbsent where adding an element
+ // that make the table grow, can be lost.
+ Map map = newMap();
+ map.putIfAbsent("S", () => 0);
+ map.putIfAbsent("T", () => 0);
+ map.putIfAbsent("U", () => 0);
+ map.putIfAbsent("C", () => 0);
+ map.putIfAbsent("a", () => 0);
+ map.putIfAbsent("b", () => 0);
+ map.putIfAbsent("n", () => 0);
+ Expect.isTrue(map.containsKey("n"));
+ }
+
+ {
+ // Check that putIfAbsent works just as well as put.
+ Map map = newMap();
+ for (int i = 0; i < 128; i++) {
+ map.putIfAbsent(i, () => i);
+ Expect.isTrue(map.containsKey(i));
+ map.putIfAbsent(i >> 1, () => -1); // Never triggers.
+ }
+ for (int i = 0; i < 128; i++) {
+ Expect.equals(i, map[i]);
+ }
+ }
+
+ {
+ // Check that updating existing elements is not a modification.
+ // This must be the case even if the underlying data structure is
+ // nearly full.
+ for (int i = 1; i < 128; i++) {
+ // Create maps of different sizes, some of which should be
+ // at a limit of the underlying data structure.
+ Map map = newMapFrom(gen(0, i));
+
+ // ForEach-iteration.
+ map.forEach((key, v) {
+ Expect.equals(key, map[key]);
+ map[key] = key + 1;
+ map.remove(1000); // Removing something not there.
+ map.putIfAbsent(key, () => Expect.fail("SHOULD NOT BE ABSENT"));
+ // Doesn't cause ConcurrentModificationError.
+ });
+
+ // for-in iteration.
+ for (int key in map.keys) {
+ Expect.equals(key + 1, map[key]);
+ map[key] = map[key] + 1;
+ map.remove(1000); // Removing something not there.
+ map.putIfAbsent(key, () => Expect.fail("SHOULD NOT BE ABSENT"));
+ // Doesn't cause ConcurrentModificationError.
+ }
+
+ // Raw iterator.
+ Iterator iter = map.keys.iterator;
+ for (int key = 0; key < i; key++) {
+ Expect.equals(key + 2, map[key]);
+ map[key] = key + 3;
+ map.remove(1000); // Removing something not there.
+ map.putIfAbsent(key, () => Expect.fail("SHOULD NOT BE ABSENT"));
+ // Doesn't cause ConcurrentModificationError on the moveNext.
+ }
+ iter.moveNext(); // Should not throw.
+
+ // Remove a lot of elements, which can cause a re-tabulation.
+ for (int key = 1; key < i; key++) {
+ Expect.equals(key + 3, map[key]);
+ map.remove(key);
+ }
+ iter = map.keys.iterator;
+ map[0] = 2;
+ iter.moveNext(); // Should not throw.
+ }
+ }
+
+ {
+ // Check that null can be in the map.
+ Map map = newMap();
+ map[null] = 0;
+ Expect.equals(1, map.length);
+ Expect.isTrue(map.containsKey(null));
+ Expect.isNull(map.keys.first);
+ Expect.isNull(map.keys.last);
+ map[null] = 1;
+ Expect.equals(1, map.length);
+ Expect.isTrue(map.containsKey(null));
+ map.remove(null);
+ Expect.isTrue(map.isEmpty);
+ Expect.isFalse(map.containsKey(null));
+
+ // Created using map.from.
+ map = newMapFrom(new Map()..[null] = 0);
+ Expect.equals(1, map.length);
+ Expect.isTrue(map.containsKey(null));
+ Expect.isNull(map.keys.first);
+ Expect.isNull(map.keys.last);
+ map[null] = 1;
+ Expect.equals(1, map.length);
+ Expect.isTrue(map.containsKey(null));
+ map.remove(null);
+ Expect.isTrue(map.isEmpty);
+ Expect.isFalse(map.containsKey(null));
+
+ Map fromMap = new Map();
+ fromMap[1] = 0;
+ fromMap[2] = 0;
+ fromMap[3] = 0;
+ fromMap[null] = 0;
+ fromMap[4] = 0;
+ fromMap[5] = 0;
+ fromMap[6] = 0;
+ Expect.equals(7, fromMap.length);
+
+ // map that grows with null in it.
+ map = newMapFrom(fromMap);
+ Expect.equals(7, map.length);
+ for (int i = 7; i < 128; i++) {
+ map[i] = 0;
+ }
+ Expect.equals(128, map.length);
+ Expect.isTrue(map.containsKey(null));
+ map[null] = 1;
+ Expect.equals(128, map.length);
+ Expect.isTrue(map.containsKey(null));
+ map.remove(null);
+ Expect.equals(127, map.length);
+ Expect.isFalse(map.containsKey(null));
+ }
+}
+
+void main() {
+ Expect.isTrue(new HashMap<int, String>() is Map<int, String>);
+ Expect.isTrue(new LinkedHashMap<int, String>() is Map<int, String>);
+ Expect.isTrue(new HashMap<String, int>.from({}) is Map<String, int>);
+ Expect.isTrue(new LinkedHashMap<String, int>.from({}) is Map<String, int>);
+ Expect.isTrue(<String, int>{} is Map<String, int>);
+ Expect.isTrue(const <String, int>{} is Map<String, int>);
+
+ testMap(() => new HashMap(), (m) => new HashMap.from(m));
+ testMap(() => new LinkedHashMap(), (m) => new LinkedHashMap.from(m));
+}
+
+class BadHashCode {
+ static int idCounter = 0;
+ final int id;
+ BadHashCode() : id = idCounter++;
+ int get hashCode => 42;
+}
diff --git a/tests/corelib/hash_map_test.dart b/tests/corelib/hash_map_test.dart
new file mode 100644
index 0000000..4bd6d62
--- /dev/null
+++ b/tests/corelib/hash_map_test.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+// Test program for the HashMap class.
+
+class HashMapTest {
+ static testMain() {
+ var m = new Map();
+ Expect.equals(0, m.length);
+ Expect.equals(true, m.isEmpty);
+ m["one"] = 1;
+ Expect.equals(1, m.length);
+ Expect.equals(false, m.isEmpty);
+ Expect.equals(1, m["one"]);
+ }
+}
+
+main() {
+ HashMapTest.testMain();
+}
diff --git a/tests/corelib/hash_set_test.dart b/tests/corelib/hash_set_test.dart
new file mode 100644
index 0000000..965ace1
--- /dev/null
+++ b/tests/corelib/hash_set_test.dart
@@ -0,0 +1,363 @@
+// Copyright (c) 2013, 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.
+//
+// VMOptions=
+
+// Tests of hash set behavior, with focus in iteration and concurrent
+// modification errors.
+
+library hash_map2_test;
+
+import "package:expect/expect.dart";
+import 'dart:collection';
+import 'dart:math' as math;
+
+testSet(Set newSet(), Set newSetFrom(Iterable from)) {
+ Set gen(int from, int to) =>
+ new Set.from(new Iterable.generate(to - from, (n) => n + from));
+
+ bool odd(n) => (n & 1) == 1;
+ bool even(n) => (n & 1) == 0;
+
+ {
+ // Test growing to largish capacity.
+ Set set = newSet();
+
+ for (int i = 0; i < 256; i++) {
+ set.add(i);
+ }
+
+ set.addAll(gen(256, 512));
+ set.addAll(newSetFrom(gen(512, 1000)));
+ Expect.equals(1000, set.length);
+
+ // Remove half.
+ for (int i = 0; i < 1000; i += 2) set.remove(i);
+ Expect.equals(500, set.length);
+ Expect.isFalse(set.any(even));
+ Expect.isTrue(set.every(odd));
+
+ // Re-add all.
+ set.addAll(gen(0, 1000));
+ Expect.equals(1000, set.length);
+ }
+
+ {
+ // Test having many deleted elements.
+ Set set = newSet();
+ set.add(0);
+ for (int i = 0; i < 1000; i++) {
+ set.add(i + 1);
+ set.remove(i);
+ Expect.equals(1, set.length);
+ }
+ }
+
+ {
+ // Test having many elements with same hashCode
+ Set set = newSet();
+ for (int i = 0; i < 1000; i++) {
+ set.add(new BadHashCode());
+ }
+ Expect.equals(1000, set.length);
+ }
+
+ {
+ // Check concurrent modification
+ Set set = newSet()..add(0)..add(1);
+
+ {
+ // Test adding before a moveNext.
+ Iterator iter = set.iterator;
+ iter.moveNext();
+ set.add(1); // Updating existing key isn't a modification.
+ iter.moveNext();
+ set.add(2);
+ Expect.throws(iter.moveNext, (e) => e is Error);
+ }
+
+ {
+ // Test adding after last element.
+ Iterator iter = set.iterator;
+ Expect.equals(3, set.length);
+ iter.moveNext();
+ iter.moveNext();
+ iter.moveNext();
+ set.add(3);
+ Expect.throws(iter.moveNext, (e) => e is Error);
+ }
+
+ {
+ // Test removing during iteration.
+ Iterator iter = set.iterator;
+ iter.moveNext();
+ set.remove(1000); // Not a modification if it's not there.
+ iter.moveNext();
+ int n = iter.current;
+ set.remove(n);
+ // Removing doesn't change current.
+ Expect.equals(n, iter.current);
+ Expect.throws(iter.moveNext, (e) => e is Error);
+ }
+
+ {
+ // Test removing after last element.
+ Iterator iter = set.iterator;
+ Expect.equals(3, set.length);
+ iter.moveNext();
+ iter.moveNext();
+ iter.moveNext();
+ int n = iter.current;
+ set.remove(n);
+ // Removing doesn't change current.
+ Expect.equals(n, iter.current);
+ Expect.throws(iter.moveNext, (e) => e is Error);
+ }
+
+ {
+ // Test that updating value doesn't cause error.
+ Iterator iter = set.iterator;
+ Expect.equals(2, set.length);
+ iter.moveNext();
+ int n = iter.current;
+ set.add(n);
+ iter.moveNext();
+ Expect.isTrue(set.contains(iter.current));
+ }
+
+ {
+ // Check adding many existing values isn't considered modification.
+ Set set2 = newSet();
+ for (var value in set) {
+ set2.add(value);
+ }
+ Iterator iter = set.iterator;
+ set.addAll(set2);
+ // Shouldn't throw.
+ iter.moveNext();
+ }
+ }
+
+ {
+ // Check that updating existing elements is not a modification.
+ // This must be the case even if the underlying data structure is
+ // nearly full.
+ for (int i = 1; i < 128; i++) {
+ // Create maps of different sizes, some of which should be
+ // at a limit of the underlying data structure.
+ Set set = newSetFrom(gen(0, i));
+ Iterator iter = set.iterator;
+ for (int j = 0; j < i; j++) {
+ set.add(j);
+ }
+ iter.moveNext(); // Should not throw.
+
+ for (int j = 1; j < i; j++) {
+ set.remove(j);
+ }
+ iter = set.iterator;
+ set.add(0);
+ iter.moveNext(); // Should not throw.
+ }
+ }
+
+ {
+ // Check that null can be in the set.
+ Set set = newSet();
+ set.add(null);
+ Expect.equals(1, set.length);
+ Expect.isTrue(set.contains(null));
+ Expect.isNull(set.first);
+ Expect.isNull(set.last);
+ set.add(null);
+ Expect.equals(1, set.length);
+ Expect.isTrue(set.contains(null));
+ set.remove(null);
+ Expect.isTrue(set.isEmpty);
+ Expect.isFalse(set.contains(null));
+
+ // Created using Set.from.
+ set = newSetFrom([null]);
+ Expect.equals(1, set.length);
+ Expect.isTrue(set.contains(null));
+ Expect.isNull(set.first);
+ Expect.isNull(set.last);
+ set.add(null);
+ Expect.equals(1, set.length);
+ Expect.isTrue(set.contains(null));
+ set.remove(null);
+ Expect.isTrue(set.isEmpty);
+ Expect.isFalse(set.contains(null));
+
+ // Set that grows with null in it.
+ set = newSetFrom([1, 2, 3, null, 4, 5, 6]);
+ Expect.equals(7, set.length);
+ for (int i = 7; i < 128; i++) {
+ set.add(i);
+ }
+ Expect.equals(128, set.length);
+ Expect.isTrue(set.contains(null));
+ set.add(null);
+ Expect.equals(128, set.length);
+ Expect.isTrue(set.contains(null));
+ set.remove(null);
+ Expect.equals(127, set.length);
+ Expect.isFalse(set.contains(null));
+ }
+
+ {
+ // Check that addAll and clear works.
+ Set set = newSet();
+ set.addAll([]);
+ Expect.isTrue(set.isEmpty);
+ set.addAll([1, 3, 2]);
+ Expect.equals(3, set.length);
+ Expect.isTrue(set.contains(1));
+ Expect.isTrue(set.contains(3));
+ Expect.isTrue(set.contains(2));
+ Expect.isFalse(set.contains(4));
+ set.clear();
+ Expect.isTrue(set.isEmpty);
+ }
+
+ {
+ // Check that removeWhere and retainWhere work.
+ Set set = newSetFrom([1, 2, 3]);
+ set.removeWhere((each) => each == 2);
+ Expect.equals(2, set.length);
+ Expect.isTrue(set.contains(1));
+ Expect.isFalse(set.contains(2));
+ Expect.isTrue(set.contains(3));
+ set.retainWhere((each) => each == 3);
+ Expect.equals(1, set.length);
+ Expect.isFalse(set.contains(1));
+ Expect.isFalse(set.contains(2));
+ Expect.isTrue(set.contains(3));
+ }
+
+ {
+ // Test lookup
+ Set set = newSet();
+ var m1a = new Mutable(1);
+ var m1b = new Mutable(1);
+ var m2a = new Mutable(2);
+ var m2b = new Mutable(2);
+ Expect.isNull(set.lookup(m1a));
+ Expect.isNull(set.lookup(m1b));
+ set.add(m1a);
+ Expect.identical(m1a, set.lookup(m1a));
+ Expect.identical(m1a, set.lookup(m1b));
+
+ Expect.isNull(set.lookup(m2a));
+ Expect.isNull(set.lookup(m2b));
+ set.add(m2a);
+ Expect.identical(m2a, set.lookup(m2a));
+ Expect.identical(m2a, set.lookup(m2b));
+
+ set.add(m2b); // Adding doesn't change element.
+ Expect.identical(m2a, set.lookup(m2a));
+ Expect.identical(m2a, set.lookup(m2b));
+
+ set.remove(m1a);
+ set.add(m1b);
+ Expect.identical(m1b, set.lookup(m1a));
+ Expect.identical(m1b, set.lookup(m1b));
+
+ set.add(1);
+ Expect.identical(1, set.lookup(1.0));
+ set.add(-0.0);
+ Expect.identical(-0.0, set.lookup(0.0));
+ }
+
+ {
+ // Test special hash codes
+ Set set = newSet();
+ List keys = [];
+ // Powers of two
+ for (int i = 63; i >= 2; --i) {
+ keys.add(new Mutable(math.pow(2, i) as int));
+ }
+ for (var key in keys) {
+ Expect.isTrue(set.add(key));
+ }
+ for (var key in keys) {
+ Expect.isTrue(set.contains(key));
+ }
+ }
+}
+
+void testIdentitySet(Set create()) {
+ Set set = create();
+ set.add(1);
+ set.add(2);
+ set.add(1); // Integers are identical if equal.
+ Expect.equals(2, set.length);
+ var complex = 4;
+ complex = set.length == 2 ? complex ~/ 4 : 87; // Avoid compile-time constant.
+ Expect.isTrue(set.contains(complex)); // 1 is in set, even if computed.
+ set.clear();
+
+ // All compile time constants are identical to themselves.
+ var constants = [
+ double.infinity,
+ double.nan, -0.0, //# 01: ok
+ 0.0, 42, "", null, false, true, #bif, testIdentitySet
+ ];
+ set.addAll(constants);
+ Expect.equals(constants.length, set.length);
+ for (var c in constants) {
+ Expect.isTrue(set.contains(c), "constant: $c");
+ }
+ Expect.isTrue(set.containsAll(constants), "constants: $set");
+ set.clear();
+
+ var m1 = new Mutable(1);
+ var m2 = new Mutable(2);
+ var m3 = new Mutable(3);
+ var m4 = new Mutable(2); // Equal to m2, but not identical.
+ set.addAll([m1, m2, m3, m4]);
+ Expect.equals(4, set.length);
+ Expect.equals(3, m3.hashCode);
+ m3.id = 1;
+ Expect.equals(1, m3.hashCode);
+ // Changing hashCode doesn't affect lookup.
+ Expect.isTrue(set.contains(m3));
+ Expect.isTrue(set.contains(m1));
+ set.remove(m3);
+ Expect.isFalse(set.contains(m3));
+ Expect.isTrue(set.contains(m1));
+
+ Expect.identical(m1, set.lookup(m1));
+ Expect.identical(null, set.lookup(m3));
+}
+
+void main() {
+ testSet(() => new Set(), (m) => new Set.from(m));
+ testSet(() => new HashSet(), (m) => new HashSet.from(m));
+ testSet(() => new LinkedHashSet(), (m) => new LinkedHashSet.from(m));
+ testIdentitySet(() => new Set.identity());
+ testIdentitySet(() => new HashSet.identity());
+ testIdentitySet(() => new LinkedHashSet.identity());
+ testIdentitySet(() => new HashSet(
+ equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x)));
+ testIdentitySet(() => new LinkedHashSet(
+ equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x)));
+}
+
+class BadHashCode {
+ static int idCounter = 0;
+ final int id;
+ BadHashCode() : id = idCounter++;
+ int get hashCode => 42;
+ // operator == is identity.
+ // Can't make a bad compareTo that isn't invalid.
+ int compareTo(BadHashCode other) => id - other.id;
+}
+
+class Mutable {
+ int id;
+ Mutable(this.id);
+ int get hashCode => id;
+ bool operator ==(other) => other is Mutable && id == other.id;
+}
diff --git a/tests/corelib/hash_set_type_check_test.dart b/tests/corelib/hash_set_type_check_test.dart
new file mode 100644
index 0000000..e51c88d
--- /dev/null
+++ b/tests/corelib/hash_set_type_check_test.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2015, 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.
+
+// Tests of hash set type checking.
+
+library hash_set_type_check_test;
+
+import "package:expect/expect.dart";
+import 'dart:collection';
+
+// TODO: all this test does now is verify that lookup takes a non-T
+// should merge this with `hash_test_test`.
+testSet(Set<String> newSet()) {
+ Set<String> s = newSet();
+ Expect.isNull(s.lookup(1));
+}
+
+void main() {
+ testSet(() => new Set<String>());
+ testSet(() => new HashSet<String>());
+ testSet(() => new LinkedHashSet<String>());
+ testSet(() => new Set<String>.identity());
+ testSet(() => new HashSet<String>.identity());
+ testSet(() => new LinkedHashSet<String>.identity());
+ testSet(() => new HashSet<String>(
+ equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x)));
+ testSet(() => new LinkedHashSet<String>(
+ equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x)));
+}
diff --git a/tests/corelib/hashcode_boxed_test.dart b/tests/corelib/hashcode_boxed_test.dart
new file mode 100644
index 0000000..e23c75a
--- /dev/null
+++ b/tests/corelib/hashcode_boxed_test.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+double fib(double n) {
+ return n <= 1.0 ? 1.0 : fib(n - 1) + fib(n - 2);
+}
+
+main() {
+ // Compute the same value in a way that won't be optimized away so the results
+ // are different objects in memory.
+ var a = fib(5.0) + 1.0;
+ var b = fib(4.0) + 4.0;
+
+ Expect.isTrue(identical(a, b));
+ Expect.equals(identityHashCode(a), identityHashCode(b));
+ Expect.equals(a, b);
+ Expect.equals(a.hashCode, b.hashCode);
+}
diff --git a/tests/corelib/hashcode_test.dart b/tests/corelib/hashcode_test.dart
new file mode 100644
index 0000000..365bb0f
--- /dev/null
+++ b/tests/corelib/hashcode_test.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+class Override {
+ int hash = -1;
+ int get superHash => super.hashCode;
+ int get hashCode => hash;
+
+ int foo() => hash; // Just some function that can be closurized.
+
+ bool operator ==(Object other) => other is Override && other.hash == hash;
+}
+
+int bar() => 42; // Some global function.
+
+main() {
+ var o = new Object();
+ var hash = o.hashCode;
+ // Doesn't change.
+ Expect.equals(hash, o.hashCode);
+ Expect.equals(hash, identityHashCode(o));
+
+ var c = new Override();
+ int identityHash = c.superHash;
+ hash = (identityHash == 42) ? 37 : 42;
+ c.hash = hash;
+ Expect.equals(hash, c.hashCode);
+ Expect.equals(identityHash, identityHashCode(c));
+
+ // These classes don't override hashCode.
+ var samples = [0, 0x10000000, 1.5, -0, null, true, false, const Object()];
+ for (var v in samples) {
+ print(v);
+ Expect.equals(v.hashCode, identityHashCode(v));
+ }
+ // These do, or might do, but we can still use hashCodeOf and get the same
+ // result each time.
+ samples = ["string", "", (x) => 42, c.foo, bar];
+ for (var v in samples) {
+ print(v);
+ Expect.equals(v.hashCode, v.hashCode);
+ Expect.equals(identityHashCode(v), identityHashCode(v));
+ }
+}
diff --git a/tests/corelib/hidden_library2_test.dart b/tests/corelib/hidden_library2_test.dart
new file mode 100644
index 0000000..637cd94
--- /dev/null
+++ b/tests/corelib/hidden_library2_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2013, 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.
+
+// Test that the internal hidden library doesn't make problems with taking
+// stack-traces.
+
+main() {
+ print(['x'].where((_) {
+ // We actually don't really care for the successful case. We just want to
+ // make sure that the test doesn't crash when it is negative.
+ throw 'fisk'; // //# 01: runtime error
+ return true;
+ }).toList());
+}
diff --git a/tests/corelib/int_ceil_test.dart b/tests/corelib/int_ceil_test.dart
new file mode 100644
index 0000000..731e15a
--- /dev/null
+++ b/tests/corelib/int_ceil_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ const int big = 0x123456789AB0000 + 0xCDEF; // Slightly rounded on web.
+
+ Expect.equals(0, 0.ceil());
+ Expect.equals(1, 1.ceil());
+ Expect.equals(0x1234, 0x1234.ceil());
+ Expect.equals(0x12345678, 0x12345678.ceil());
+ Expect.equals(0x123456789AB, 0x123456789AB.ceil());
+ Expect.equals(big, big.ceil());
+ Expect.equals(-1, (-1).ceil());
+ Expect.equals(-0x1234, (-0x1234).ceil());
+ Expect.equals(-0x12345678, (-0x12345678).ceil());
+ Expect.equals(-0x123456789AB, (-0x123456789AB).ceil());
+ Expect.equals(-big, (-big).ceil());
+
+ Expect.isTrue(0.ceil() is int);
+ Expect.isTrue(1.ceil() is int);
+ Expect.isTrue(0x1234.ceil() is int);
+ Expect.isTrue(0x12345678.ceil() is int);
+ Expect.isTrue(0x123456789AB.ceil() is int);
+ Expect.isTrue(big.ceil() is int);
+ Expect.isTrue((-1).ceil() is int);
+ Expect.isTrue((-0x1234).ceil() is int);
+ Expect.isTrue((-0x12345678).ceil() is int);
+ Expect.isTrue((-0x123456789AB).ceil() is int);
+ Expect.isTrue((-big).ceil() is int);
+}
diff --git a/tests/corelib/int_ceil_to_double_test.dart b/tests/corelib/int_ceil_to_double_test.dart
new file mode 100644
index 0000000..0a35acb
--- /dev/null
+++ b/tests/corelib/int_ceil_to_double_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ const int big = 0x123456789AB0000 + 0xCDEF; // Slightly rounded on web.
+
+ Expect.equals(0.0, 0.ceilToDouble());
+ Expect.equals(1.0, 1.ceilToDouble());
+ Expect.equals(0x1234, 0x1234.ceilToDouble());
+ Expect.equals(0x12345678, 0x12345678.ceilToDouble());
+ Expect.equals(0x123456789AB, 0x123456789AB.ceilToDouble());
+ Expect.equals(81985529216486900.0, big.ceilToDouble());
+ Expect.equals(-1.0, (-1).ceilToDouble());
+ Expect.equals(-0x1234, (-0x1234).ceilToDouble());
+ Expect.equals(-0x12345678, (-0x12345678).ceilToDouble());
+ Expect.equals(-0x123456789AB, (-0x123456789AB).ceilToDouble());
+ Expect.equals(-81985529216486900.0, (-big).ceilToDouble());
+
+ Expect.isTrue(0.ceilToDouble() is double);
+ Expect.isTrue(1.ceilToDouble() is double);
+ Expect.isTrue(0x1234.ceilToDouble() is double);
+ Expect.isTrue(0x12345678.ceilToDouble() is double);
+ Expect.isTrue(0x123456789AB.ceilToDouble() is double);
+ Expect.isTrue(big.ceilToDouble() is double);
+ Expect.isTrue((-1).ceilToDouble() is double);
+ Expect.isTrue((-0x1234).ceilToDouble() is double);
+ Expect.isTrue((-0x12345678).ceilToDouble() is double);
+ Expect.isTrue((-0x123456789AB).ceilToDouble() is double);
+ Expect.isTrue((-big).ceilToDouble() is double);
+}
diff --git a/tests/corelib/int_floor_test.dart b/tests/corelib/int_floor_test.dart
new file mode 100644
index 0000000..e85d5df
--- /dev/null
+++ b/tests/corelib/int_floor_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ const int big = 0x123456789AB0000 + 0xCDEF; // Slightly rounded on web.
+
+ Expect.equals(0, 0.floor());
+ Expect.equals(1, 1.floor());
+ Expect.equals(0x1234, 0x1234.floor());
+ Expect.equals(0x12345678, 0x12345678.floor());
+ Expect.equals(0x123456789AB, 0x123456789AB.floor());
+ Expect.equals(big, big.floor());
+ Expect.equals(-1, (-1).floor());
+ Expect.equals(-0x1234, (-0x1234).floor());
+ Expect.equals(-0x12345678, (-0x12345678).floor());
+ Expect.equals(-0x123456789AB, (-0x123456789AB).floor());
+ Expect.equals(-big, (-big).floor());
+
+ Expect.isTrue(0.floor() is int);
+ Expect.isTrue(1.floor() is int);
+ Expect.isTrue(0x1234.floor() is int);
+ Expect.isTrue(0x12345678.floor() is int);
+ Expect.isTrue(0x123456789AB.floor() is int);
+ Expect.isTrue(big.floor() is int);
+ Expect.isTrue((-1).floor() is int);
+ Expect.isTrue((-0x1234).floor() is int);
+ Expect.isTrue((-0x12345678).floor() is int);
+ Expect.isTrue((-0x123456789AB).floor() is int);
+ Expect.isTrue((-big).floor() is int);
+}
diff --git a/tests/corelib/int_floor_to_double_test.dart b/tests/corelib/int_floor_to_double_test.dart
new file mode 100644
index 0000000..659b295
--- /dev/null
+++ b/tests/corelib/int_floor_to_double_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ const int big = 0x123456789AB0000 + 0xCDEF; // Slightly rounded on web.
+
+ Expect.equals(0.0, 0.floorToDouble());
+ Expect.equals(1.0, 1.floorToDouble());
+ Expect.equals(0x1234, 0x1234.floorToDouble());
+ Expect.equals(0x12345678, 0x12345678.floorToDouble());
+ Expect.equals(0x123456789AB, 0x123456789AB.floorToDouble());
+ Expect.equals(81985529216486900.0, big.floorToDouble());
+ Expect.equals(-1.0, (-1).floorToDouble());
+ Expect.equals(-0x1234, (-0x1234).floorToDouble());
+ Expect.equals(-0x12345678, (-0x12345678).floorToDouble());
+ Expect.equals(-0x123456789AB, (-0x123456789AB).floorToDouble());
+ Expect.equals(-81985529216486900.0, (-big).floorToDouble());
+
+ Expect.isTrue(0.floorToDouble() is double);
+ Expect.isTrue(1.floorToDouble() is double);
+ Expect.isTrue(0x1234.floorToDouble() is double);
+ Expect.isTrue(0x12345678.floorToDouble() is double);
+ Expect.isTrue(0x123456789AB.floorToDouble() is double);
+ Expect.isTrue(big.floorToDouble() is double);
+ Expect.isTrue((-1).floorToDouble() is double);
+ Expect.isTrue((-0x1234).floorToDouble() is double);
+ Expect.isTrue((-0x12345678).floorToDouble() is double);
+ Expect.isTrue((-0x123456789AB).floorToDouble() is double);
+ Expect.isTrue((-big).floorToDouble() is double);
+}
diff --git a/tests/corelib/int_from_environment2_test.dart b/tests/corelib/int_from_environment2_test.dart
new file mode 100644
index 0000000..348f0b0
--- /dev/null
+++ b/tests/corelib/int_from_environment2_test.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2013, 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.
+// SharedOptions=-Da=x -Db=- -Dc=0xg -Dd=+ -Dd=
+
+import "package:expect/expect.dart";
+
+main() {
+ Expect.isNull(const int.fromEnvironment('a'));
+ Expect.isNull(const int.fromEnvironment('b'));
+ Expect.isNull(const int.fromEnvironment('c'));
+ Expect.isNull(const int.fromEnvironment('d'));
+ Expect.isNull(const int.fromEnvironment('e'));
+}
diff --git a/tests/corelib/int_from_environment_int64_test.dart b/tests/corelib/int_from_environment_int64_test.dart
new file mode 100644
index 0000000..b734556
--- /dev/null
+++ b/tests/corelib/int_from_environment_int64_test.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2013, 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.
+// SharedOptions=-Df=-9223372036854775808 -Dg=9223372036854775807
+
+import "package:expect/expect.dart";
+
+main() {
+ Expect.equals(-9223372036854775808, const int.fromEnvironment('f'));
+ Expect.equals(9223372036854775807, const int.fromEnvironment('g'));
+}
diff --git a/tests/corelib/int_from_environment_test.dart b/tests/corelib/int_from_environment_test.dart
new file mode 100644
index 0000000..2e6d28e
--- /dev/null
+++ b/tests/corelib/int_from_environment_test.dart
@@ -0,0 +1,19 @@
+// Copyright (c) 2013, 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.
+// SharedOptions=-Da=1 -Db=-12 -Dc=0x123 -Dd=-0x1234 -De=+0x112296 -Df=-9007199254740991 -Dg=9007199254740991 -Dh=-0x8000000000000000 -Di=0x8000000000000000 -Dj=0xDEADBEEFCAFE0000
+
+import "package:expect/expect.dart";
+
+main() {
+ Expect.equals(1, const int.fromEnvironment('a'));
+ Expect.equals(-12, const int.fromEnvironment('b'));
+ Expect.equals(0x123, const int.fromEnvironment('c'));
+ Expect.equals(-0x1234, const int.fromEnvironment('d'));
+ Expect.equals(0x112296, const int.fromEnvironment('e'));
+ Expect.equals(-9007199254740991, const int.fromEnvironment('f'));
+ Expect.equals(9007199254740991, const int.fromEnvironment('g'));
+ Expect.equals(-0x8000000000000000, const int.fromEnvironment('h'));
+ Expect.equals(0x8000000000000000, const int.fromEnvironment('i'));
+ Expect.equals(0xDEADBEEFCAFE0000, const int.fromEnvironment('j'));
+}
diff --git a/tests/corelib/int_modpow_hard_test.dart b/tests/corelib/int_modpow_hard_test.dart
new file mode 100644
index 0000000..0024c9a
--- /dev/null
+++ b/tests/corelib/int_modpow_hard_test.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2019, 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.
+
+// Extreme values from int_modulo_arith_test. Test cases that that have
+// intermediate values that overflow the precision of 'int'.
+
+import "package:expect/expect.dart";
+
+import "dart:math" show pow;
+
+main() {
+ test(x, e, m, expectedResult) {
+ var result = x.modPow(e, m);
+ Expect.equals(expectedResult, result, "$x.modPow($e, $m)");
+ }
+
+ for (int mBase in [
+ 50000000,
+ 94906266, // Smallest integer with square over 2^53.
+ 100000000,
+ 1000000000,
+ 3037000500, // Smallest integer with square over 2^63.
+ 4000000000,
+ 0x7FFFFFFFFFFFF000 + 0xFFC
+ ]) {
+ // On 'web' platforms skip values outside web number safe range.
+ if (mBase == mBase + 1) continue;
+
+ for (int mAdjustment in [0, 1, 2, 3, -1]) {
+ int m = mBase + mAdjustment;
+ for (int e = 1; e < 100; e++) {
+ // Test "M-k ^ N mod M == (-k) ^ N mod M" for some small values of k.
+ test(m - 1, e, m, pow(-1, e) % m);
+ if (e < 53) {
+ test(m - 2, e, m, pow(-2, e) % m);
+ }
+ if (e < 33) {
+ test(m - 3, e, m, pow(-3, e) % m);
+ }
+ if (e < 26) {
+ test(m - 4, e, m, pow(-4, e) % m);
+ }
+ }
+ }
+ }
+}
diff --git a/tests/corelib/int_modulo_arith_test.dart b/tests/corelib/int_modulo_arith_test.dart
new file mode 100644
index 0000000..5e95c3a
--- /dev/null
+++ b/tests/corelib/int_modulo_arith_test.dart
@@ -0,0 +1,172 @@
+// Copyright (c) 2015, 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.
+
+import "package:expect/expect.dart";
+
+import "dart:math" show pow;
+
+var smallNumber = 1234567890; // is 31-bit integer.
+var mediumNumber = 1234567890123456; // is 53-bit integer
+
+testModPow() {
+ test(x, e, m, expectedResult) {
+ // Check that expected result is correct, using an unoptimized version.
+ assert(() {
+ if (1 is double) return true; // Don't have bignums.
+ slowModPow(x, e, m) {
+ var r = 1;
+ while (e > 0) {
+ if (e.isOdd) r = (r * x) % m as int;
+ e >>= 1;
+ x = (x * x) % m;
+ }
+ return r;
+ }
+
+ return slowModPow(x, e, m) == expectedResult;
+ }());
+ var result = x.modPow(e, m);
+ Expect.equals(expectedResult, result, "$x.modPow($e, $m)");
+ }
+
+ test(10, 20, 1, 0);
+ test(1234567890, 1000000001, 19, 11);
+ test(1234567890, 19, 1000000001, 122998977);
+ test(19, 1234567890, 1000000001, 619059596);
+ test(19, 1000000001, 1234567890, 84910879);
+ test(1000000001, 19, 1234567890, 872984351);
+ test(1000000001, 1234567890, 19, 0);
+}
+
+testModInverse() {
+ test(x, m, expectedResult) {
+ //print("$x op $m == $expectedResult");
+ // Check that expectedResult is an inverse.
+ assert(expectedResult < m);
+ // The 1 % m handles the m = 1 special case.
+ // This test may overflow if we don't have bignums, so only run on VM.
+ assert(1 is double || (((x % m) * expectedResult) - 1) % m == 0);
+
+ var result = x.modInverse(m);
+ Expect.equals(expectedResult, result, "$x modinv $m");
+
+ if (x > m) {
+ x = x % m;
+ var result = x.modInverse(m);
+ Expect.equals(expectedResult, result, "$x modinv $m");
+ }
+ }
+
+ testThrows(x, m) {
+ // Throws if not co-prime, which is a symmetric property.
+ Expect.throws(() => x.modInverse(m));
+ Expect.throws(() => m.modInverse(x));
+ }
+
+ test(1, 1, 0);
+
+ testThrows(0, 1000000001);
+ testThrows(2, 4);
+ testThrows(99, 9);
+ testThrows(19, 1000000001);
+
+ // Co-prime numbers
+ test(1234567890, 19, 11);
+ test(1234567890, 1000000001, 189108911);
+ test(19, 1234567890, 519818059);
+ test(1000000001, 1234567890, 1001100101);
+
+ test(12345, 12346, 12345);
+ test(12345, 12346, 12345);
+
+ test(smallNumber, 137, 42);
+ test(137, smallNumber, 856087223);
+ test(mediumNumber, 137, 77);
+ test(137, mediumNumber, 540686667207353);
+}
+
+testGcd() {
+ // Call testFunc with all combinations and orders of plus/minus
+ // value and other.
+ callCombos(value, other, testFunc) {
+ testFunc(value, other);
+ testFunc(value, -other);
+ testFunc(-value, other);
+ testFunc(-value, -other);
+ if (value == other) return;
+ testFunc(other, value);
+ testFunc(other, -value);
+ testFunc(-other, value);
+ testFunc(-other, -value);
+ }
+
+ // Test that gcd of value and other (non-negative) is expectedResult.
+ // Tests all combinations of positive and negative values and order of
+ // operands, so use positive values and order is not important.
+ test(value, other, expectedResult) {
+ // Check for bug in test.
+ assert(expectedResult == 0 || value % expectedResult == 0);
+ assert(expectedResult == 0 || other % expectedResult == 0);
+ callCombos(value, other, (a, b) {
+ var result = a.gcd(b);
+
+ /// Check that the result is a divisor.
+ Expect.equals(0, result == 0 ? a : a % result, "$result | $a");
+ Expect.equals(0, result == 0 ? b : b % result, "$result | $b");
+ // Check for bug in test. If assert fails, the expected value is too low,
+ // and the gcd call has found a greater common divisor.
+ assert(result >= expectedResult);
+ Expect.equals(expectedResult, result, "$a.gcd($b)");
+ });
+ }
+
+ // Test that gcd of value and other (non-negative) throws.
+ testThrows(value, other) {
+ callCombos(value, other, (a, b) {
+ Expect.throws(() => a.gcd(b));
+ });
+ }
+
+ testThrows(2.5, 5); // Not a method on double.
+ testThrows(5, 2.5); // Not accepting non-int arguments.
+
+ // Format:
+ // test(value1, value2, expectedResult);
+ test(1, 1, 1); // both are 1
+ test(1, 2, 1); // one is 1
+ test(3, 5, 1); // coprime.
+ test(37, 37, 37); // Same larger prime.
+
+ test(9999, 7272, 909); // Larger numbers
+
+ test(0, 1000, 1000); // One operand is zero.
+ test(0, 0, 0); // Both operands are zero.
+
+ // Multiplying both operands by a number multiplies result by same number.
+ test(693, 609, 21);
+ test(693 << 5, 609 << 5, 21 << 5);
+ test(693 * 937, 609 * 937, 21 * 937);
+ test(693 * pow(2, 32), 609 * pow(2, 32), 21 * pow(2, 32));
+ test(693 * pow(2, 52), 609 * pow(2, 52), 21 * pow(2, 52));
+ test(693 * pow(2, 53), 609 * pow(2, 53), 21 * pow(2, 53)); // Regression.
+ test(693 * pow(2, 99), 609 * pow(2, 99), 21 * pow(2, 99));
+
+ test(1234567890, 19, 1);
+ test(1234567890, 1000000001, 1);
+ test(19, 1000000001, 19);
+
+ test(0x3FFFFFFF, 0x3FFFFFFF, 0x3FFFFFFF);
+ test(0x3FFFFFFF, 0x40000000, 1);
+
+ test(pow(2, 54), pow(2, 53), pow(2, 53));
+
+ test((pow(2, 52) - 1) * pow(2, 10), (pow(2, 26) - 1) * pow(2, 22),
+ (pow(2, 26) - 1) * pow(2, 10));
+}
+
+main() {
+ testModPow(); // //# modPow: ok
+ testModInverse();
+ testGcd();
+}
diff --git a/tests/corelib/int_parse_radix_bad_handler_test.dart b/tests/corelib/int_parse_radix_bad_handler_test.dart
new file mode 100644
index 0000000..2c3b2be
--- /dev/null
+++ b/tests/corelib/int_parse_radix_bad_handler_test.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+void main() {
+ // These are compile time errors for Dart 2.0.
+ Expect.throws(() => int.parse("9", radix: 8, /*@compile-error=unspecified*/ onError: "not a function"));
+ Expect.throws(() => int.parse("9", radix: 8, /*@compile-error=unspecified*/ onError: () => 42));
+ Expect.throws(() => int.parse("9", radix: 8, /*@compile-error=unspecified*/ onError: (v1, v2) => 42));
+}
diff --git a/tests/corelib/int_parse_radix_int64_test.dart b/tests/corelib/int_parse_radix_int64_test.dart
new file mode 100644
index 0000000..ffe8e84
--- /dev/null
+++ b/tests/corelib/int_parse_radix_int64_test.dart
@@ -0,0 +1,68 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+import "dart:math" show pow, log;
+
+void main() {
+ const String oneByteWhiteSpace = "\x09\x0a\x0b\x0c\x0d\x20"
+ "\x85" //# 01: ok
+ "\xa0";
+ const String whiteSpace = "$oneByteWhiteSpace\u1680"
+ "\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a"
+ "\u2028\u2029\u202f\u205f\u3000\ufeff";
+
+ var digits = "0123456789abcdefghijklmnopqrstuvwxyz";
+ var zeros = "0" * 64;
+
+ void testParse(int result, String radixString, int radix) {
+ var m = "$radixString/$radix->$result";
+ Expect.equals(
+ result, int.parse(radixString.toLowerCase(), radix: radix), m);
+ Expect.equals(
+ result, int.parse(radixString.toUpperCase(), radix: radix), m);
+ Expect.equals(result, int.parse(" $radixString", radix: radix), m);
+ Expect.equals(result, int.parse("$radixString ", radix: radix), m);
+ Expect.equals(result, int.parse(" $radixString ", radix: radix), m);
+ Expect.equals(result, int.parse("+$radixString", radix: radix), m);
+ Expect.equals(result, int.parse(" +$radixString", radix: radix), m);
+ Expect.equals(result, int.parse("+$radixString ", radix: radix), m);
+ Expect.equals(result, int.parse(" +$radixString ", radix: radix), m);
+ Expect.equals(-result, int.parse("-$radixString", radix: radix), m);
+ Expect.equals(-result, int.parse(" -$radixString", radix: radix), m);
+ Expect.equals(-result, int.parse("-$radixString ", radix: radix), m);
+ Expect.equals(-result, int.parse(" -$radixString ", radix: radix), m);
+ Expect.equals(
+ result,
+ int.parse("$oneByteWhiteSpace$radixString$oneByteWhiteSpace",
+ radix: radix),
+ m);
+ Expect.equals(
+ -result,
+ int.parse("$oneByteWhiteSpace-$radixString$oneByteWhiteSpace",
+ radix: radix),
+ m);
+ Expect.equals(result,
+ int.parse("$whiteSpace$radixString$whiteSpace", radix: radix), m);
+ Expect.equals(-result,
+ int.parse("$whiteSpace-$radixString$whiteSpace", radix: radix), m);
+
+ Expect.equals(result, int.parse("$zeros$radixString", radix: radix), m);
+ Expect.equals(result, int.parse("+$zeros$radixString", radix: radix), m);
+ Expect.equals(-result, int.parse("-$zeros$radixString", radix: radix), m);
+ }
+
+ final max = 9223372036854775807;
+ for (int i = 2; i <= 36; i++) { // //# 02: ok
+ // Test with bignums. // //# 02: continued
+ final n = (log(max) / log(i)).truncate(); // //# 02: continued
+ var digit = digits[i - 1]; // //# 02: continued
+ testParse((pow(i, n) as int) - 1, digit * n, i); // //# 02: continued
+ testParse(0, zeros, i); // //# 02: continued
+ } // //# 02: continued
+
+ // Big number.
+ Expect.equals(9223372036854775807, int.parse("9223372036854775807"));
+ Expect.equals(-9223372036854775808, int.parse("-9223372036854775808"));
+}
diff --git a/tests/corelib/int_parse_radix_test.dart b/tests/corelib/int_parse_radix_test.dart
new file mode 100644
index 0000000..215f737
--- /dev/null
+++ b/tests/corelib/int_parse_radix_test.dart
@@ -0,0 +1,140 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+import "dart:math" show pow, log;
+
+void main() {
+ const String oneByteWhiteSpace = "\x09\x0a\x0b\x0c\x0d\x20"
+ "\x85" //# 01: ok
+ "\xa0";
+ const String whiteSpace = "$oneByteWhiteSpace\u1680"
+ "\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a"
+ "\u2028\u2029\u202f\u205f\u3000\ufeff";
+
+ var digits = "0123456789abcdefghijklmnopqrstuvwxyz";
+ var zeros = "0" * 64;
+
+ for (int i = 0; i < whiteSpace.length; i++) {
+ var ws = whiteSpace[i];
+ Expect.equals(0, int.parse("${ws}0${ws}", radix: 2));
+ }
+
+ void testParse(int result, String radixString, int radix) {
+ var m = "$radixString/$radix->$result";
+ Expect.equals(
+ result, int.parse(radixString.toLowerCase(), radix: radix), m);
+ Expect.equals(
+ result, int.parse(radixString.toUpperCase(), radix: radix), m);
+ Expect.equals(result, int.parse(" $radixString", radix: radix), m);
+ Expect.equals(result, int.parse("$radixString ", radix: radix), m);
+ Expect.equals(result, int.parse(" $radixString ", radix: radix), m);
+ Expect.equals(result, int.parse("+$radixString", radix: radix), m);
+ Expect.equals(result, int.parse(" +$radixString", radix: radix), m);
+ Expect.equals(result, int.parse("+$radixString ", radix: radix), m);
+ Expect.equals(result, int.parse(" +$radixString ", radix: radix), m);
+ Expect.equals(-result, int.parse("-$radixString", radix: radix), m);
+ Expect.equals(-result, int.parse(" -$radixString", radix: radix), m);
+ Expect.equals(-result, int.parse("-$radixString ", radix: radix), m);
+ Expect.equals(-result, int.parse(" -$radixString ", radix: radix), m);
+ Expect.equals(
+ result,
+ int.parse("$oneByteWhiteSpace$radixString$oneByteWhiteSpace",
+ radix: radix),
+ m);
+ Expect.equals(
+ -result,
+ int.parse("$oneByteWhiteSpace-$radixString$oneByteWhiteSpace",
+ radix: radix),
+ m);
+ Expect.equals(result,
+ int.parse("$whiteSpace$radixString$whiteSpace", radix: radix), m);
+ Expect.equals(-result,
+ int.parse("$whiteSpace-$radixString$whiteSpace", radix: radix), m);
+
+ Expect.equals(result, int.parse("$zeros$radixString", radix: radix), m);
+ Expect.equals(result, int.parse("+$zeros$radixString", radix: radix), m);
+ Expect.equals(-result, int.parse("-$zeros$radixString", radix: radix), m);
+ }
+
+ for (int r = 2; r <= 36; r++) {
+ for (int i = 0; i <= r * r; i++) {
+ String radixString = i.toRadixString(r);
+ testParse(i, radixString, r);
+ }
+ }
+
+ final max = 0x1FFFFFFFFFFFFF;
+ for (int i = 2; i <= 36; i++) { // //# 02: ok
+ // Test with bignums. // //# 02: continued
+ final n = (log(max) / log(i)).truncate(); // //# 02: continued
+ var digit = digits[i - 1]; // //# 02: continued
+ testParse((pow(i, n) as int) - 1, digit * n, i); // //# 02: continued
+ testParse(0, zeros, i); // //# 02: continued
+ } // //# 02: continued
+
+ // Allow both upper- and lower-case letters.
+ Expect.equals(0xABCD, int.parse("ABCD", radix: 16));
+ Expect.equals(0xABCD, int.parse("abcd", radix: 16));
+ Expect.equals(15628859, int.parse("09azAZ", radix: 36));
+ // Big-ish number. (2^53)
+ Expect.equals(9007199254740991, int.parse("9007199254740991"));
+ Expect.equals(-9007199254740991, int.parse("-9007199254740991"));
+ Expect.equals(-9223372036854775808, int.parse("-9223372036854775808"));
+ // Allow whitespace before and after the number.
+ Expect.equals(1, int.parse(" 1", radix: 2));
+ Expect.equals(1, int.parse("1 ", radix: 2));
+ Expect.equals(1, int.parse(" 1 ", radix: 2));
+ Expect.equals(1, int.parse("\n1", radix: 2));
+ Expect.equals(1, int.parse("1\n", radix: 2));
+ Expect.equals(1, int.parse("\n1\n", radix: 2));
+ Expect.equals(1, int.parse("+1", radix: 2));
+
+ void testFails(String source, int radix) {
+ Expect.throws(() {
+ throw int.parse(source, radix: radix, onError: (s) {
+ throw "FAIL";
+ });
+ }, isFail, "$source/$radix");
+ Expect.equals(-999, int.parse(source, radix: radix, onError: (s) => -999));
+ }
+
+ for (int i = 2; i < 36; i++) {
+ var char = i.toRadixString(36);
+ testFails(char.toLowerCase(), i);
+ testFails(char.toUpperCase(), i);
+ }
+ testFails("", 2);
+ testFails("+ 1", 2); // No space between sign and digits.
+ testFails("- 1", 2); // No space between sign and digits.
+ for (int i = 2; i <= 33; i++) {
+ // No 0x specially allowed.
+ // At radix 34 and above, "x" is a valid digit.
+ testFails("0x10", i);
+ }
+
+ testBadTypes(var source, var radix) {
+ Expect.throwsTypeError(() => int.parse(source, radix: radix, onError: (s) => 0)); //# badTypes: ok
+ }
+
+ testBadTypes(9, 10);
+ testBadTypes(true, 10);
+ testBadTypes("0", true);
+ testBadTypes("0", "10");
+
+ testBadArguments(String source, int radix) {
+ // If the types match, it should be an ArgumentError of some sort.
+ Expect.throwsArgumentError(
+ () => int.parse(source, radix: radix, onError: (s) => 0));
+ }
+
+ testBadArguments("0", -1);
+ testBadArguments("0", 0);
+ testBadArguments("0", 1);
+ testBadArguments("0", 37);
+
+ // See also int_parse_radix_bad_handler_test.dart
+}
+
+bool isFail(e) => e == "FAIL";
diff --git a/tests/corelib/int_parse_with_limited_ints_test.dart b/tests/corelib/int_parse_with_limited_ints_test.dart
new file mode 100644
index 0000000..018bcd2
--- /dev/null
+++ b/tests/corelib/int_parse_with_limited_ints_test.dart
@@ -0,0 +1,75 @@
+// Copyright (c) 2017, 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.
+
+// Test for int.parse with limited 64-bit integers.
+
+import "package:expect/expect.dart";
+
+main() {
+ const int ERROR = 42;
+ int returnError(String s) => ERROR;
+
+ Expect.equals(0, int.parse("0"));
+ Expect.equals(1, int.parse("1"));
+ Expect.equals(-1, int.parse("-1"));
+
+ Expect.equals(0x7ffffffffffffffe, int.parse("0x7ffffffffffffffe"));
+ Expect.equals(0x7fffffffffffffff, int.parse("0x7fffffffffffffff"));
+ Expect.equals(-0x7fffffffffffffff, int.parse("-0x7fffffffffffffff"));
+ Expect.equals(-0x7fffffffffffffff - 1, int.parse("-0x8000000000000000"));
+ Expect.equals(1 << 63, int.parse("0x8000000000000000"));
+
+ Expect.equals(8999999999999999999, int.parse("8999999999999999999"));
+ Expect.equals(-8999999999999999999, int.parse("-8999999999999999999"));
+ Expect.equals(9223372036854775807, int.parse("9223372036854775807"));
+ Expect.equals(-9223372036854775807, int.parse("-9223372036854775807"));
+ Expect.equals(-9223372036854775807 - 1, int.parse("-9223372036854775808"));
+
+ Expect.equals(ERROR, int.parse("-0x8000000000000001", onError: returnError));
+ Expect.equals(ERROR, int.parse("9223372036854775808", onError: returnError));
+ Expect.equals(ERROR, int.parse("9223372036854775809", onError: returnError));
+ Expect.equals(ERROR, int.parse("-9223372036854775809", onError: returnError));
+ Expect.equals(ERROR, int.parse("10000000000000000000", onError: returnError));
+
+ Expect.equals(
+ 0x7fffffffffffffff,
+ int.parse(
+ "111111111111111111111111111111111111111111111111111111111111111",
+ radix: 2));
+ Expect.equals(
+ -0x7fffffffffffffff,
+ int.parse(
+ "-111111111111111111111111111111111111111111111111111111111111111",
+ radix: 2));
+ Expect.equals(
+ -0x7fffffffffffffff - 1,
+ int.parse(
+ "-1000000000000000000000000000000000000000000000000000000000000000",
+ radix: 2));
+
+ Expect.equals(
+ ERROR,
+ int.parse(
+ "1000000000000000000000000000000000000000000000000000000000000000",
+ radix: 2,
+ onError: returnError));
+ Expect.equals(
+ ERROR,
+ int.parse(
+ "1111111111111111111111111111111111111111111111111111111111111110",
+ radix: 2,
+ onError: returnError));
+ Expect.equals(
+ ERROR,
+ int.parse(
+ "1111111111111111111111111111111111111111111111111111111111111111",
+ radix: 2,
+ onError: returnError));
+ Expect.equals(
+ ERROR,
+ int.parse(
+ "-1000000000000000000000000000000000000000000000000000000000000001",
+ radix: 2,
+ onError: returnError));
+}
diff --git a/tests/corelib/int_round_test.dart b/tests/corelib/int_round_test.dart
new file mode 100644
index 0000000..3e9a8ae
--- /dev/null
+++ b/tests/corelib/int_round_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ const int big = 0x123456789AB0000 + 0xCDEF; // truncating arithmetic on web.
+
+ Expect.equals(0, 0.round());
+ Expect.equals(1, 1.round());
+ Expect.equals(0x1234, 0x1234.round());
+ Expect.equals(0x12345678, 0x12345678.round());
+ Expect.equals(0x123456789AB, 0x123456789AB.round());
+ Expect.equals(big, big.round());
+ Expect.equals(-1, (-1).round());
+ Expect.equals(-0x1234, (-0x1234).round());
+ Expect.equals(-0x12345678, (-0x12345678).round());
+ Expect.equals(-0x123456789AB, (-0x123456789AB).round());
+ Expect.equals(-big, (-big).round());
+
+ Expect.isTrue(0.round() is int);
+ Expect.isTrue(1.round() is int);
+ Expect.isTrue(0x1234.round() is int);
+ Expect.isTrue(0x12345678.round() is int);
+ Expect.isTrue(0x123456789AB.round() is int);
+ Expect.isTrue(big.round() is int);
+ Expect.isTrue((-1).round() is int);
+ Expect.isTrue((-0x1234).round() is int);
+ Expect.isTrue((-0x12345678).round() is int);
+ Expect.isTrue((-0x123456789AB).round() is int);
+ Expect.isTrue((-big).round() is int);
+}
diff --git a/tests/corelib/int_round_to_double_test.dart b/tests/corelib/int_round_to_double_test.dart
new file mode 100644
index 0000000..b49cd94
--- /dev/null
+++ b/tests/corelib/int_round_to_double_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ const int big = 0x123456789AB0000 + 0xCDEF; // Slightly rounded on web.
+
+ Expect.equals(0.0, 0.roundToDouble());
+ Expect.equals(1.0, 1.roundToDouble());
+ Expect.equals(0x1234, 0x1234.roundToDouble());
+ Expect.equals(0x12345678, 0x12345678.roundToDouble());
+ Expect.equals(0x123456789AB, 0x123456789AB.roundToDouble());
+ Expect.equals(81985529216486900.0, big.roundToDouble());
+ Expect.equals(-1.0, (-1).roundToDouble());
+ Expect.equals(-0x1234, (-0x1234).roundToDouble());
+ Expect.equals(-0x12345678, (-0x12345678).roundToDouble());
+ Expect.equals(-0x123456789AB, (-0x123456789AB).roundToDouble());
+ Expect.equals(-81985529216486900.0, (-big).roundToDouble());
+
+ Expect.isTrue(0.roundToDouble() is double);
+ Expect.isTrue(1.roundToDouble() is double);
+ Expect.isTrue(0x1234.roundToDouble() is double);
+ Expect.isTrue(0x12345678.roundToDouble() is double);
+ Expect.isTrue(0x123456789AB.roundToDouble() is double);
+ Expect.isTrue(big.roundToDouble() is double);
+ Expect.isTrue((-1).roundToDouble() is double);
+ Expect.isTrue((-0x1234).roundToDouble() is double);
+ Expect.isTrue((-0x12345678).roundToDouble() is double);
+ Expect.isTrue((-0x123456789AB).roundToDouble() is double);
+ Expect.isTrue((-big).roundToDouble() is double);
+}
diff --git a/tests/corelib/int_to_int_test.dart b/tests/corelib/int_to_int_test.dart
new file mode 100644
index 0000000..065d357
--- /dev/null
+++ b/tests/corelib/int_to_int_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ const int big = 0x123456789AB0000 + 0xCDEF; // Slightly rounded on web.
+
+ Expect.equals(0, 0.toInt());
+ Expect.equals(1, 1.toInt());
+ Expect.equals(0x1234, 0x1234.toInt());
+ Expect.equals(0x12345678, 0x12345678.toInt());
+ Expect.equals(0x123456789AB, 0x123456789AB.toInt());
+ Expect.equals(big, big.toInt());
+ Expect.equals(-1, (-1).toInt());
+ Expect.equals(-0x1234, (-0x1234).toInt());
+ Expect.equals(-0x12345678, (-0x12345678).toInt());
+ Expect.equals(-0x123456789AB, (-0x123456789AB).toInt());
+ Expect.equals(-big, (-big).toInt());
+
+ Expect.isTrue(0.toInt() is int);
+ Expect.isTrue(1.toInt() is int);
+ Expect.isTrue(0x1234.toInt() is int);
+ Expect.isTrue(0x12345678.toInt() is int);
+ Expect.isTrue(0x123456789AB.toInt() is int);
+ Expect.isTrue(big.toInt() is int);
+ Expect.isTrue((-1).toInt() is int);
+ Expect.isTrue((-0x1234).toInt() is int);
+ Expect.isTrue((-0x12345678).toInt() is int);
+ Expect.isTrue((-0x123456789AB).toInt() is int);
+ Expect.isTrue((-big).toInt() is int);
+}
diff --git a/tests/corelib/int_truncate_test.dart b/tests/corelib/int_truncate_test.dart
new file mode 100644
index 0000000..f26a856
--- /dev/null
+++ b/tests/corelib/int_truncate_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ const int big = 0x123456789AB0000 + 0xCDEF; // Slightly rounded on web.
+
+ Expect.equals(0, 0.truncate());
+ Expect.equals(1, 1.truncate());
+ Expect.equals(0x1234, 0x1234.truncate());
+ Expect.equals(0x12345678, 0x12345678.truncate());
+ Expect.equals(0x123456789AB, 0x123456789AB.truncate());
+ Expect.equals(big, big.truncate());
+ Expect.equals(-1, (-1).truncate());
+ Expect.equals(-0x1234, (-0x1234).truncate());
+ Expect.equals(-0x12345678, (-0x12345678).truncate());
+ Expect.equals(-0x123456789AB, (-0x123456789AB).truncate());
+ Expect.equals(-big, (-big).truncate());
+
+ Expect.isTrue(0.truncate() is int);
+ Expect.isTrue(1.truncate() is int);
+ Expect.isTrue(0x1234.truncate() is int);
+ Expect.isTrue(0x12345678.truncate() is int);
+ Expect.isTrue(0x123456789AB.truncate() is int);
+ Expect.isTrue(big.truncate() is int);
+ Expect.isTrue((-1).truncate() is int);
+ Expect.isTrue((-0x1234).truncate() is int);
+ Expect.isTrue((-0x12345678).truncate() is int);
+ Expect.isTrue((-0x123456789AB).truncate() is int);
+ Expect.isTrue((-big).truncate() is int);
+}
diff --git a/tests/corelib/int_truncate_to_double_test.dart b/tests/corelib/int_truncate_to_double_test.dart
new file mode 100644
index 0000000..20b27d3
--- /dev/null
+++ b/tests/corelib/int_truncate_to_double_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ const int big = 0x123456789AB0000 + 0xCDEF; // Slightly rounded on web.
+
+ Expect.equals(0.0, 0.truncateToDouble());
+ Expect.equals(1.0, 1.truncateToDouble());
+ Expect.equals(0x1234, 0x1234.truncateToDouble());
+ Expect.equals(0x12345678, 0x12345678.truncateToDouble());
+ Expect.equals(0x123456789AB, 0x123456789AB.truncateToDouble());
+ Expect.equals(81985529216486900.0, big.truncateToDouble());
+ Expect.equals(-1.0, (-1).truncateToDouble());
+ Expect.equals(-0x1234, (-0x1234).truncateToDouble());
+ Expect.equals(-0x12345678, (-0x12345678).truncateToDouble());
+ Expect.equals(-0x123456789AB, (-0x123456789AB).truncateToDouble());
+ Expect.equals(-81985529216486900.0, (-big).truncateToDouble());
+
+ Expect.isTrue(0.truncateToDouble() is double);
+ Expect.isTrue(1.truncateToDouble() is double);
+ Expect.isTrue(0x1234.truncateToDouble() is double);
+ Expect.isTrue(0x12345678.truncateToDouble() is double);
+ Expect.isTrue(0x123456789AB.truncateToDouble() is double);
+ Expect.isTrue(big.truncateToDouble() is double);
+ Expect.isTrue((-1).truncateToDouble() is double);
+ Expect.isTrue((-0x1234).truncateToDouble() is double);
+ Expect.isTrue((-0x12345678).truncateToDouble() is double);
+ Expect.isTrue((-0x123456789AB).truncateToDouble() is double);
+ Expect.isTrue((-big).truncateToDouble() is double);
+}
diff --git a/tests/corelib/int_try_parse_int64_test.dart b/tests/corelib/int_try_parse_int64_test.dart
new file mode 100644
index 0000000..419da75
--- /dev/null
+++ b/tests/corelib/int_try_parse_int64_test.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+import "dart:math" show pow, log;
+
+void main() {
+ // Big numbers (representable as both Int64 and double).
+ Expect.equals(9223372036854774784, int.tryParse("9223372036854774784"));
+ Expect.equals(-9223372036854775808, int.tryParse("-9223372036854775808"));
+}
diff --git a/tests/corelib/int_try_parse_test.dart b/tests/corelib/int_try_parse_test.dart
new file mode 100644
index 0000000..9aa7ae4
--- /dev/null
+++ b/tests/corelib/int_try_parse_test.dart
@@ -0,0 +1,146 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+import "dart:math" show pow, log;
+
+void main() {
+ const String oneByteWhiteSpace = "\x09\x0a\x0b\x0c\x0d\x20\xa0";
+ const String whiteSpace = "$oneByteWhiteSpace\u1680"
+ "\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a"
+ "\u2028\u2029\u202f\u205f\u3000\ufeff";
+
+ var digits = "0123456789abcdefghijklmnopqrstuvwxyz";
+ var zeros = "0" * 64;
+
+ for (int i = 0; i < whiteSpace.length; i++) {
+ var ws = whiteSpace[i];
+ Expect.equals(0, int.parse("${ws}0${ws}", radix: 2));
+ }
+
+ void testParse(int result, String radixString, int radix) {
+ var m = "$radixString/$radix->$result";
+ Expect.equals(
+ result, int.tryParse(radixString.toLowerCase(), radix: radix), m);
+ Expect.equals(
+ result, int.tryParse(radixString.toUpperCase(), radix: radix), m);
+ Expect.equals(result, int.tryParse(" $radixString", radix: radix), m);
+ Expect.equals(result, int.tryParse("$radixString ", radix: radix), m);
+ Expect.equals(result, int.tryParse(" $radixString ", radix: radix), m);
+ Expect.equals(result, int.tryParse("+$radixString", radix: radix), m);
+ Expect.equals(result, int.tryParse(" +$radixString", radix: radix), m);
+ Expect.equals(result, int.tryParse("+$radixString ", radix: radix), m);
+ Expect.equals(result, int.tryParse(" +$radixString ", radix: radix), m);
+ Expect.equals(-result, int.tryParse("-$radixString", radix: radix), m);
+ Expect.equals(-result, int.tryParse(" -$radixString", radix: radix), m);
+ Expect.equals(-result, int.tryParse("-$radixString ", radix: radix), m);
+ Expect.equals(-result, int.tryParse(" -$radixString ", radix: radix), m);
+ Expect.equals(
+ result,
+ int.tryParse("$oneByteWhiteSpace$radixString$oneByteWhiteSpace",
+ radix: radix),
+ m);
+ Expect.equals(
+ -result,
+ int.tryParse("$oneByteWhiteSpace-$radixString$oneByteWhiteSpace",
+ radix: radix),
+ m);
+ Expect.equals(result,
+ int.tryParse("$whiteSpace$radixString$whiteSpace", radix: radix), m);
+ Expect.equals(-result,
+ int.tryParse("$whiteSpace-$radixString$whiteSpace", radix: radix), m);
+
+ Expect.equals(result, int.tryParse("$zeros$radixString", radix: radix), m);
+ Expect.equals(result, int.tryParse("+$zeros$radixString", radix: radix), m);
+ Expect.equals(
+ -result, int.tryParse("-$zeros$radixString", radix: radix), m);
+ }
+
+ for (int r = 2; r <= 36; r++) {
+ for (int i = 0; i <= r * r; i++) {
+ String radixString = i.toRadixString(r);
+ testParse(i, radixString, r);
+ }
+ for (var v in [
+ 0,
+ 0x10000,
+ 0x7FFFFFFF,
+ 0x80000000,
+ 0xFFFFFFFF,
+ 0x100000000,
+ 0x7FFFFFFFFFFFF8,
+ ]) {
+ var string = v.toRadixString(r);
+ Expect.equals(v, int.tryParse(string, radix: r));
+ if (v > 0) {
+ Expect.equals(-v, int.tryParse("-$string", radix: r));
+ if (r == 16) {
+ Expect.equals(v, int.tryParse("0x$string"));
+ Expect.equals(v, int.tryParse("0X$string"));
+ }
+ }
+ }
+ }
+
+ // Allow both upper- and lower-case letters.
+ Expect.equals(0xABCD, int.tryParse("ABCD", radix: 16));
+ Expect.equals(0xABCD, int.tryParse("abcd", radix: 16));
+ Expect.equals(15628859, int.tryParse("09azAZ", radix: 36));
+ // Bigish numbers (representable precisely as both Int64 and double (2^53)).
+ Expect.equals(9007199254740991, int.tryParse("9007199254740991"));
+ Expect.equals(-9007199254740991, int.tryParse("-9007199254740991"));
+ // Allow whitespace before and after the number.
+ Expect.equals(1, int.tryParse(" 1", radix: 2));
+ Expect.equals(1, int.tryParse("1 ", radix: 2));
+ Expect.equals(1, int.tryParse(" 1 ", radix: 2));
+ Expect.equals(1, int.tryParse("\n1", radix: 2));
+ Expect.equals(1, int.tryParse("1\n", radix: 2));
+ Expect.equals(1, int.tryParse("\n1\n", radix: 2));
+ Expect.equals(1, int.tryParse("+1", radix: 2));
+
+ void testFails(String source, int radix, [String? message]) {
+ Expect.isNull(int.tryParse(source, radix: radix), message ?? "");
+ }
+
+ for (int i = 2; i < 36; i++) {
+ var char = i.toRadixString(36);
+ testFails(char.toLowerCase(), i);
+ testFails(char.toUpperCase(), i);
+ }
+ testFails("", 2);
+ testFails("+ 1", 2); // No space between sign and digits.
+ testFails("- 1", 2); // No space between sign and digits.
+ for (int i = 2; i <= 33; i++) {
+ // No 0x specially allowed.
+ // At radix 34 and above, "x" is a valid digit.
+ testFails("0x10", i);
+ }
+
+ int digitX = 33;
+ Expect.equals(((digitX * 34) + 1) * 34, int.tryParse("0x10", radix: 34));
+ Expect.equals(((digitX * 35) + 1) * 35, int.tryParse("0x10", radix: 35));
+
+ // Radix must be in the range 2 .. 36.
+ Expect.throwsArgumentError(() => int.tryParse("0", radix: -1));
+ Expect.throwsArgumentError(() => int.tryParse("0", radix: 0));
+ Expect.throwsArgumentError(() => int.tryParse("0", radix: -1));
+ Expect.throwsArgumentError(() => int.tryParse("0", radix: 37));
+
+ // Regression test for http://dartbug.com/32858
+ Expect.equals(
+ -0x8000000000000000, int.tryParse("-0x8000000000000000"), "-minint");
+
+ // Tests run only with 64-bit integers.
+ if (0x8000000000000000 < 0) {
+ // `int` is 64-bit signed integers.
+ Expect.equals(
+ -0x8000000000000000, int.tryParse("0x8000000000000000"), "0xUnsigned");
+ Expect.equals(-1, int.tryParse("0xFFFFFFFFFFFFFFFF"), "0xUnsigned2");
+
+ Expect.equals(
+ 0x8000000000000000 - 1, int.tryParse("0x7FFFFFFFFFFFFFFF"), "maxint");
+ testFails("8000000000000000", 16, "2^63 radix: 16");
+ testFails("FFFFFFFFFFFFFFFF", 16, "maxuint64 radix: 16");
+ }
+}
diff --git a/tests/corelib/integer_arith_vm_test.dart b/tests/corelib/integer_arith_vm_test.dart
new file mode 100644
index 0000000..fcd3e9e
--- /dev/null
+++ b/tests/corelib/integer_arith_vm_test.dart
@@ -0,0 +1,139 @@
+// Copyright (c) 2011, 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.
+
+// Testing integers with and without intrinsics.
+// VMOptions=
+// VMOptions=--no_intrinsify
+// VMOptions=--optimization_counter_threshold=10 --no-background_compilation
+
+library integer_arithmetic_test;
+
+import "package:expect/expect.dart";
+
+foo() => 1234567890123456789;
+
+testSmiOverflow() {
+ var a = 1073741823;
+ var b = 1073741822;
+ Expect.equals(2147483645, a + b);
+ a = -1000000000;
+ b = 1000000001;
+ Expect.equals(-2000000001, a - b);
+ Expect.equals(-1000000001000000000, a * b);
+}
+
+testModPow() {
+ var x, e, m;
+ x = 1234567890;
+ e = 1000000001;
+ m = 19;
+ Expect.equals(11, x.modPow(e, m));
+ x = 1234567890;
+ e = 19;
+ m = 1000000001;
+ Expect.equals(122998977, x.modPow(e, m));
+ x = 19;
+ e = 1234567890;
+ m = 1000000001;
+ Expect.equals(619059596, x.modPow(e, m));
+ x = 19;
+ e = 1000000001;
+ m = 1234567890;
+ Expect.equals(84910879, x.modPow(e, m));
+ x = 1000000001;
+ e = 19;
+ m = 1234567890;
+ Expect.equals(872984351, x.modPow(e, m));
+ x = 1000000001;
+ e = 1234567890;
+ m = 19;
+ Expect.equals(0, x.modPow(e, m));
+}
+
+testModInverse() {
+ var x, m;
+ x = 1;
+ m = 1;
+ Expect.equals(0, x.modInverse(m));
+ x = 0;
+ m = 1000000001;
+ Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
+ x = 1234567890;
+ m = 19;
+ Expect.equals(11, x.modInverse(m));
+ x = 1234567890;
+ m = 1000000001;
+ Expect.equals(189108911, x.modInverse(m));
+ x = 19;
+ m = 1000000001;
+ Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
+ x = 19;
+ m = 1234567890;
+ Expect.equals(519818059, x.modInverse(m));
+ x = 1000000001;
+ m = 1234567890;
+ Expect.equals(1001100101, x.modInverse(m));
+ x = 1000000001;
+ m = 19;
+ Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime.
+}
+
+testGcd() {
+ var x, m;
+ x = 1;
+ m = 1;
+ Expect.equals(1, x.gcd(m));
+ x = 693;
+ m = 609;
+ Expect.equals(21, x.gcd(m));
+ x = 693 << 40;
+ m = 609 << 40;
+ Expect.equals(21 << 40, x.gcd(m));
+ x = 609 << 40;
+ m = 693 << 40;
+ Expect.equals(21 << 40, x.gcd(m));
+ x = 0;
+ m = 1000000001;
+ Expect.equals(m, x.gcd(m));
+ x = 1000000001;
+ m = 0;
+ Expect.equals(x, x.gcd(m));
+ x = 0;
+ m = -1000000001;
+ Expect.equals(-m, x.gcd(m));
+ x = -1000000001;
+ m = 0;
+ Expect.equals(-x, x.gcd(m));
+ x = 0;
+ m = 0;
+ Expect.equals(0, x.gcd(m));
+ x = 1234567890;
+ m = 19;
+ Expect.equals(1, x.gcd(m));
+ x = 1234567890;
+ m = 1000000001;
+ Expect.equals(1, x.gcd(m));
+ x = 19;
+ m = 1000000001;
+ Expect.equals(19, x.gcd(m));
+ x = 19;
+ m = 1234567890;
+ Expect.equals(1, x.gcd(m));
+ x = 1000000001;
+ m = 1234567890;
+ Expect.equals(1, x.gcd(m));
+ x = 1000000001;
+ m = 19;
+ Expect.equals(19, x.gcd(m));
+}
+
+main() {
+ for (int i = 0; i < 10; i++) {
+ Expect.equals(1234567890123456789, foo());
+ testSmiOverflow();
+ testModPow(); // //# modPow: ok
+ testModInverse();
+ testGcd();
+ }
+}
diff --git a/tests/corelib/integer_parsed_arith_vm_test.dart b/tests/corelib/integer_parsed_arith_vm_test.dart
new file mode 100644
index 0000000..6458722
--- /dev/null
+++ b/tests/corelib/integer_parsed_arith_vm_test.dart
@@ -0,0 +1,471 @@
+// Copyright (c) 2011, 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.
+
+// Testing integers with and without intrinsics.
+// VMOptions=
+// VMOptions=--no_intrinsify
+
+library integer_arithmetic_test;
+
+import "package:expect/expect.dart";
+
+String toHexString(int value) => value >= 0
+ ? "0x${value.toRadixString(16)}"
+ : "-0x${value.toRadixString(16).substring(1)}";
+
+addSubParsed(String a, String b, String sum) {
+ int int_a = int.parse(a);
+ int int_b = int.parse(b);
+ int int_sum = int.parse(sum);
+ int computed_sum = int_a + int_b;
+ Expect.equals(int_sum, computed_sum);
+ String str_sum = toHexString(computed_sum);
+ Expect.equals(sum.toLowerCase(), str_sum);
+ int computed_difference1 = int_sum - int_a;
+ Expect.equals(int_b, computed_difference1);
+ String str_difference1 = toHexString(computed_difference1);
+ Expect.equals(b.toLowerCase(), str_difference1);
+ int computed_difference2 = int_sum - int_b;
+ Expect.equals(int_a, computed_difference2);
+ String str_difference2 = toHexString(computed_difference2);
+ Expect.equals(a.toLowerCase(), str_difference2);
+}
+
+testAddSub() {
+ String zero = "0x0";
+ String one = "0x1";
+ String minus_one = "-0x1";
+
+ addSubParsed(zero, zero, zero);
+ addSubParsed(zero, one, one);
+ addSubParsed(one, zero, one);
+ addSubParsed(one, one, "0x2");
+ addSubParsed(minus_one, minus_one, "-0x2");
+ addSubParsed("0x123", zero, "0x123");
+ addSubParsed(zero, "0x123", "0x123");
+ addSubParsed("0x123", one, "0x124");
+ addSubParsed(one, "0x123", "0x124");
+ addSubParsed(
+ "0xFFFFFFF",
+ one, // 28 bit overflow.
+ "0x10000000");
+ addSubParsed(
+ "0xFFFFFFFF",
+ one, // 32 bit overflow.
+ "0x100000000");
+ addSubParsed(
+ "0xFFFFFFFFFFFFFF",
+ one, // 56 bit overflow.
+ "0x100000000000000");
+ addSubParsed(
+ "0x7FFFFFFFFFFFFFFF",
+ one, // 64 bit overflow.
+ "-0x8000000000000000");
+ addSubParsed(
+ minus_one,
+ one, // 64 bit overflow.
+ zero);
+ addSubParsed(
+ "0x8000000", // 28 bit overflow.
+ "0x8000000",
+ "0x10000000");
+ addSubParsed(
+ "0x80000000", // 32 bit overflow.
+ "0x80000000",
+ "0x100000000");
+ addSubParsed(
+ "0x80000000000000", // 56 bit overflow.
+ "0x80000000000000",
+ "0x100000000000000");
+ addSubParsed(
+ "-0x8000000000000000", // 64 bit overflow.
+ "-0x8000000000000000",
+ zero);
+
+ addSubParsed("-0x123", minus_one, "-0x124");
+ addSubParsed(minus_one, "-0x123", "-0x124");
+ addSubParsed(
+ "-0xFFFFFFF",
+ minus_one, // 28 bit overflow.
+ "-0x10000000");
+ addSubParsed(
+ "-0xFFFFFFFF",
+ minus_one, // 32 bit overflow.
+ "-0x100000000");
+ addSubParsed(
+ "-0xFFFFFFFFFFFFFF",
+ minus_one, // 56 bit overflow.
+ "-0x100000000000000");
+ addSubParsed(
+ "-0x8000000000000000",
+ minus_one, // 64 bit overflow.
+ "0x7FFFFFFFFFFFFFFF");
+ addSubParsed(
+ "-0x8000000", // 28 bit overflow.
+ "-0x8000000",
+ "-0x10000000");
+ addSubParsed(
+ "-0x80000000", // 32 bit overflow.
+ "-0x80000000",
+ "-0x100000000");
+ addSubParsed(
+ "-0x80000000000000", // 56 bit overflow.
+ "-0x80000000000000",
+ "-0x100000000000000");
+ addSubParsed(
+ "-0x8000000000000000", // 64 bit overflow.
+ "-0x8000000000000000",
+ "0x0");
+
+ addSubParsed("0xB", "-0x7", "0x4");
+ addSubParsed("-0xB", "-0x7", "-0x12");
+ addSubParsed("0xB", "0x7", "0x12");
+ addSubParsed("-0xB", "0x7", "-0x4");
+ addSubParsed("-0x7", "0xB", "0x4");
+ addSubParsed("-0x7", "-0xB", "-0x12");
+ addSubParsed("0x7", "0xB", "0x12");
+ addSubParsed("0x7", "-0xB", "-0x4");
+}
+
+shiftLeftParsed(String a, int amount, String result,
+ {String? result_back_shifted}) {
+ result_back_shifted ??= a;
+ int int_a = int.parse(a);
+ int int_result = int.parse(result);
+ int int_result_back_shifted = int.parse(result_back_shifted);
+ int shifted = int_a << amount;
+ Expect.equals(int_result, shifted);
+ String str_shifted = toHexString(shifted);
+ Expect.equals(result.toLowerCase(), str_shifted);
+ int back_shifted = shifted >> amount;
+ Expect.equals(int_result_back_shifted, back_shifted);
+ String str_back_shifted = toHexString(back_shifted);
+ Expect.equals(result_back_shifted.toLowerCase(), str_back_shifted);
+}
+
+testLeftShift() {
+ String zero = "0x0";
+ String one = "0x1";
+ String minus_one = "-0x1";
+
+ shiftLeftParsed(zero, 0, zero);
+ shiftLeftParsed(one, 0, one);
+ shiftLeftParsed("0x1234", 0, "0x1234");
+ shiftLeftParsed(zero, 100000, zero);
+ shiftLeftParsed(one, 1, "0x2");
+ shiftLeftParsed(one, 28, "0x10000000");
+ shiftLeftParsed(one, 32, "0x100000000");
+ shiftLeftParsed(one, 64, zero, result_back_shifted: zero);
+ shiftLeftParsed("0x5", 28, "0x50000000");
+ shiftLeftParsed("0x5", 32, "0x500000000");
+ shiftLeftParsed("0x5", 56, "0x500000000000000");
+ shiftLeftParsed("0x5", 64, zero, result_back_shifted: zero);
+ shiftLeftParsed("0x5", 128, zero, result_back_shifted: zero);
+ shiftLeftParsed("0x5", 27, "0x28000000");
+ shiftLeftParsed("0x5", 31, "0x280000000");
+ shiftLeftParsed("0x5", 55, "0x280000000000000");
+ shiftLeftParsed("0x5", 63, "-0x8000000000000000",
+ result_back_shifted: "-0x1");
+ shiftLeftParsed("0x5", 127, zero, result_back_shifted: zero);
+ shiftLeftParsed("0x8000001", 1, "0x10000002");
+ shiftLeftParsed("0x80000001", 1, "0x100000002");
+ shiftLeftParsed("0x8000000000000001", 1, "0x2", result_back_shifted: "0x1");
+ shiftLeftParsed("0x8000001", 29, "0x100000020000000");
+ shiftLeftParsed("0x80000001", 33, "0x200000000", result_back_shifted: "0x1");
+ shiftLeftParsed("0x8000000000000001", 65, zero, result_back_shifted: zero);
+ shiftLeftParsed("0x7fffffffffffffff", 1, "-0x2", result_back_shifted: "-0x1");
+ shiftLeftParsed("0x7fffffffffffffff", 29, "-0x20000000",
+ result_back_shifted: "-0x1");
+ shiftLeftParsed(minus_one, 0, minus_one);
+ shiftLeftParsed("-0x1234", 0, "-0x1234");
+ shiftLeftParsed(minus_one, 1, "-0x2");
+ shiftLeftParsed(minus_one, 28, "-0x10000000");
+ shiftLeftParsed(minus_one, 32, "-0x100000000");
+ shiftLeftParsed(minus_one, 64, zero, result_back_shifted: zero);
+ shiftLeftParsed("-0x5", 28, "-0x50000000");
+ shiftLeftParsed("-0x5", 32, "-0x500000000");
+ shiftLeftParsed("-0x5", 64, zero, result_back_shifted: zero);
+ shiftLeftParsed("-0x5", 27, "-0x28000000");
+ shiftLeftParsed("-0x5", 31, "-0x280000000");
+ shiftLeftParsed("-0x5", 63, "-0x8000000000000000",
+ result_back_shifted: minus_one);
+ shiftLeftParsed("-0x8000001", 1, "-0x10000002");
+ shiftLeftParsed("-0x80000001", 1, "-0x100000002");
+ shiftLeftParsed("-0x8000001", 29, "-0x100000020000000");
+ shiftLeftParsed("-0x80000001", 33, "-0x200000000",
+ result_back_shifted: "-0x1");
+ shiftLeftParsed("-0x7fffffffffffffff", 1, "0x2", result_back_shifted: "0x1");
+ shiftLeftParsed("-0x7fffffffffffffff", 65, zero, result_back_shifted: zero);
+ shiftLeftParsed("-0x8000000000000000", 1, zero, result_back_shifted: zero);
+ shiftLeftParsed("-0x8000000000000000", 29, zero, result_back_shifted: zero);
+}
+
+shiftRightParsed(String a, int amount, String result) {
+ int int_a = int.parse(a);
+ int int_result = int.parse(result);
+ int shifted = int_a >> amount;
+ Expect.equals(int_result, shifted);
+ String str_shifted = toHexString(shifted);
+ Expect.equals(result.toLowerCase(), str_shifted);
+}
+
+testRightShift() {
+ String zero = "0x0";
+ String one = "0x1";
+ String minus_one = "-0x1";
+
+ shiftRightParsed(one, 1, zero);
+ shiftRightParsed(minus_one, 1, minus_one);
+ shiftRightParsed("-0x2", 1, minus_one);
+ shiftRightParsed("0x12345678", 29, zero);
+ shiftRightParsed("-0x12345678", 29, minus_one);
+ shiftRightParsed("-0x12345678", 100, minus_one);
+ shiftRightParsed("0x5", 1, "0x2");
+ shiftRightParsed("0x5", 2, "0x1");
+ shiftRightParsed("-0x5", 1, "-0x3");
+ shiftRightParsed("-0x5", 2, "-0x2");
+ shiftRightParsed("0x10000001", 28, one);
+ shiftRightParsed("0x100000001", 32, one);
+ shiftRightParsed("0x1000000000000001", 60, one);
+ shiftRightParsed("0x1000000000000001", 64, zero);
+ shiftRightParsed("-0x10000001", 28, "-0x2");
+ shiftRightParsed("-0x100000001", 32, "-0x2");
+ shiftRightParsed("-0x1000000000000001", 64, minus_one);
+ shiftRightParsed("0x30000000", 29, one);
+ shiftRightParsed("0x300000000", 33, one);
+ shiftRightParsed("0x3000000000000000", 61, one);
+ shiftRightParsed("0x3000000000000000", 65, zero);
+ shiftRightParsed("-0x30000000", 29, "-0x2");
+ shiftRightParsed("-0x300000000", 33, "-0x2");
+ shiftRightParsed("-0x3000000000000000", 60, "-0x3");
+ shiftRightParsed("-0x3000000000000000", 65, minus_one);
+}
+
+bitAndParsed(String a, String b, String result) {
+ int int_a = int.parse(a);
+ int int_b = int.parse(b);
+ int int_result = int.parse(result);
+ int anded = int_a & int_b;
+ Expect.equals(int_result, anded);
+ String str_anded = toHexString(anded);
+ Expect.equals(result.toLowerCase(), str_anded);
+ int anded2 = int_b & int_a;
+ Expect.equals(int_result, anded2);
+ String str_anded2 = toHexString(anded2);
+ Expect.equals(result.toLowerCase(), str_anded2);
+}
+
+testBitAnd() {
+ String zero = "0x0";
+ String one = "0x1";
+ String minus_one = "-0x1";
+
+ bitAndParsed(one, zero, zero);
+ bitAndParsed(one, one, one);
+ bitAndParsed(minus_one, zero, zero);
+ bitAndParsed(minus_one, one, one);
+ bitAndParsed(minus_one, minus_one, minus_one);
+ bitAndParsed("0x5", "0x3", one);
+ bitAndParsed("0x5", minus_one, "0x5");
+ bitAndParsed("0x50000000", one, zero);
+ bitAndParsed("0x50000000", minus_one, "0x50000000");
+ bitAndParsed("0x500000000", one, zero);
+ bitAndParsed("0x500000000", minus_one, "0x500000000");
+ bitAndParsed("0x5000000000000000", one, zero);
+ bitAndParsed("0x5000000000000000", minus_one, "0x5000000000000000");
+ bitAndParsed("-0x50000000", "-0x50000000", "-0x50000000");
+ bitAndParsed("-0x500000000", "-0x500000000", "-0x500000000");
+ bitAndParsed("0x12345678", "0xFFFFFFF", "0x2345678");
+ bitAndParsed("0x123456789", "0xFFFFFFFF", "0x23456789");
+ bitAndParsed("-0x10000000", "0xFFFFFFF", "0x0");
+ bitAndParsed("-0x100000000", "0xFFFFFFFF", "0x0");
+ bitAndParsed("-0x10000001", "0xFFFFFFF", "0xFFFFFFF");
+ bitAndParsed("-0x100000001", "0xFFFFFFFF", "0xFFFFFFFF");
+ bitAndParsed("-0x10000001", "0x3FFFFFFF", "0x2FFFFFFF");
+ bitAndParsed("-0x100000001", "0x3FFFFFFFF", "0x2FFFFFFFF");
+ bitAndParsed("-0x100000000000000", "0xFFFFFFFFFFFFFF", "0x0");
+ bitAndParsed(
+ "-0x1000000000000000", "0xFFFFFFFFFFFFFFFF", "-0x1000000000000000");
+ bitAndParsed("-0x300000000000000", "0xFFFFFFFFFFFFFFF", "0xD00000000000000");
+ bitAndParsed(
+ "-0x3000000000000000", "0xFFFFFFFFFFFFFFFF", "-0x3000000000000000");
+ bitAndParsed("-0x10000000", "-0x10000000", "-0x10000000");
+ bitAndParsed("-0x100000000", "-0x100000000", "-0x100000000");
+ bitAndParsed(
+ "-0x100000000000000", "-0x100000000000000", "-0x100000000000000");
+ bitAndParsed(
+ "-0x1000000000000000", "-0x1000000000000000", "-0x1000000000000000");
+ bitAndParsed("-0x3", "-0x2", "-0x4");
+ bitAndParsed("-0x10000000", "-0x10000001", "-0x20000000");
+ bitAndParsed("-0x100000000", "-0x100000001", "-0x200000000");
+ bitAndParsed(
+ "-0x100000000000000", "-0x100000000000001", "-0x200000000000000");
+ bitAndParsed(
+ "-0x1000000000000000", "-0x1000000000000001", "-0x2000000000000000");
+}
+
+bitOrParsed(String a, String b, String result) {
+ int int_a = int.parse(a);
+ int int_b = int.parse(b);
+ int int_result = int.parse(result);
+ int ored = int_a | int_b;
+ Expect.equals(int_result, ored);
+ String str_ored = toHexString(ored);
+ Expect.equals(result.toLowerCase(), str_ored);
+ int ored2 = int_b | int_a;
+ Expect.equals(int_result, ored2);
+ String str_ored2 = toHexString(ored2);
+ Expect.equals(result.toLowerCase(), str_ored2);
+}
+
+testBitOr() {
+ String zero = "0x0";
+ String one = "0x1";
+ String minus_one = "-0x1";
+
+ bitOrParsed(one, zero, one);
+ bitOrParsed(one, one, one);
+ bitOrParsed(minus_one, zero, minus_one);
+ bitOrParsed(minus_one, one, minus_one);
+ bitOrParsed(minus_one, minus_one, minus_one);
+ bitOrParsed("-0x3", one, "-0x3");
+ bitOrParsed("0x5", "0x3", "0x7");
+ bitOrParsed("0x5", minus_one, minus_one);
+ bitOrParsed("0x5", zero, "0x5");
+ bitOrParsed("0x50000000", one, "0x50000001");
+ bitOrParsed("0x50000000", minus_one, minus_one);
+ bitOrParsed("0x500000000", one, "0x500000001");
+ bitOrParsed("0x500000000", minus_one, minus_one);
+ bitOrParsed("0x5000000000000000", one, "0x5000000000000001");
+ bitOrParsed("0x5000000000000000", minus_one, minus_one);
+ bitOrParsed("-0x50000000", "-0x50000000", "-0x50000000");
+ bitOrParsed("-0x500000000", "-0x500000000", "-0x500000000");
+ bitOrParsed("0x12345678", "0xFFFFFFF", "0x1FFFFFFF");
+ bitOrParsed("0x123456789", "0xFFFFFFFF", "0x1FFFFFFFF");
+ bitOrParsed("-0x10000000", "0xFFFFFFF", "-0x1");
+ bitOrParsed("-0x100000000", "0xFFFFFFFF", "-0x1");
+ bitOrParsed("-0x10000001", "0xFFFFFFF", "-0x10000001");
+ bitOrParsed("-0x100000001", "0xFFFFFFFF", "-0x100000001");
+ bitOrParsed("-0x10000001", "0x3FFFFFFF", "-0x1");
+ bitOrParsed("-0x100000001", "0x3FFFFFFFF", "-0x1");
+ bitOrParsed("-0x1000000000000001", "0x3FFFFFFFFFFFFFFF", "-0x1");
+ bitOrParsed("-0x100000000000000", "0xFFFFFFFFFFFFFF", "-0x1");
+ bitOrParsed("-0x1000000000000000", "0xFFFFFFFFFFFFFFF", "-0x1");
+ bitOrParsed("-0x300000000000000", "0xFFFFFFFFFFFFFFF", "-0x1");
+ bitOrParsed("-0x3000000000000000", "0xFFFFFFFFFFFFFFFF", "-0x1");
+ bitOrParsed("-0x10000000", "-0x10000000", "-0x10000000");
+ bitOrParsed("-0x100000000", "-0x100000000", "-0x100000000");
+ bitOrParsed("-0x100000000000000", "-0x100000000000000", "-0x100000000000000");
+ bitOrParsed(
+ "-0x1000000000000000", "-0x1000000000000000", "-0x1000000000000000");
+ bitOrParsed("-0x10000000", "-0x10000001", "-0x1");
+ bitOrParsed("-0x100000000", "-0x100000001", "-0x1");
+ bitOrParsed("-0x100000000000000", "-0x100000000000001", "-0x1");
+ bitOrParsed("-0x1000000000000000", "-0x1000000000000001", "-0x1");
+ bitOrParsed("-0x1000000000000000", "-0x1", "-0x1");
+}
+
+bitXorParsed(String a, String b, String result) {
+ int int_a = int.parse(a);
+ int int_b = int.parse(b);
+ int int_result = int.parse(result);
+ int xored = int_a ^ int_b;
+ Expect.equals(int_result, xored);
+ String str_xored = toHexString(xored);
+ Expect.equals(result.toLowerCase(), str_xored);
+ int xored2 = int_b ^ int_a;
+ Expect.equals(int_result, xored2);
+ String str_xored2 = toHexString(xored2);
+ Expect.equals(result.toLowerCase(), str_xored2);
+ int xored3 = int_a ^ xored2;
+ Expect.equals(int_b, xored3);
+ String str_xored3 = toHexString(xored3);
+ Expect.equals(b.toLowerCase(), str_xored3);
+}
+
+testBitXor() {
+ String zero = "0x0";
+ String one = "0x1";
+ String minus_one = "-0x1";
+
+ bitXorParsed(one, zero, one);
+ bitXorParsed(one, one, zero);
+ bitXorParsed(minus_one, zero, minus_one);
+ bitXorParsed(minus_one, one, "-0x2");
+ bitXorParsed(minus_one, minus_one, zero);
+ bitXorParsed("0x5", "0x3", "0x6");
+ bitXorParsed("0x5", minus_one, "-0x6");
+ bitXorParsed("0x5", zero, "0x5");
+ bitXorParsed(minus_one, "-0x8", "0x7");
+ bitXorParsed("0x50000000", one, "0x50000001");
+ bitXorParsed("0x50000000", minus_one, "-0x50000001");
+ bitXorParsed("0x500000000", one, "0x500000001");
+ bitXorParsed("0x500000000", minus_one, "-0x500000001");
+ bitXorParsed("0x5000000000000000", one, "0x5000000000000001");
+ bitXorParsed("0x5000000000000000", minus_one, "-0x5000000000000001");
+ bitXorParsed("-0x50000000", "-0x50000000", zero);
+ bitXorParsed("-0x500000000", "-0x500000000", zero);
+ bitXorParsed("0x12345678", "0xFFFFFFF", "0x1DCBA987");
+ bitXorParsed("0x123456789", "0xFFFFFFFF", "0x1DCBA9876");
+ bitXorParsed("-0x10000000", "0xFFFFFFF", "-0x1");
+ bitXorParsed("-0x100000000", "0xFFFFFFFF", "-0x1");
+ bitXorParsed("-0x10000001", "0xFFFFFFF", "-0x20000000");
+ bitXorParsed("-0x100000001", "0xFFFFFFFF", "-0x200000000");
+ bitXorParsed("-0x10000001", "0x3FFFFFFF", "-0x30000000");
+ bitXorParsed("-0x100000001", "0x3FFFFFFFF", "-0x300000000");
+ bitXorParsed(
+ "-0x1000000000000001", "0x3FFFFFFFFFFFFFFF", "-0x3000000000000000");
+ bitXorParsed("-0x100000000000000", "0xFFFFFFFFFFFFFF", "-0x1");
+ bitXorParsed("-0x1000000000000000", "0xFFFFFFFFFFFFFFF", "-0x1");
+ bitXorParsed("-0x300000000000000", "0xFFFFFFFFFFFFFFF", "-0xD00000000000001");
+ bitXorParsed("-0x3000000000000000", "-0x1", "0x2FFFFFFFFFFFFFFF");
+ bitXorParsed("-0x10000000", "-0x10000000", zero);
+ bitXorParsed("-0x100000000", "-0x100000000", zero);
+ bitXorParsed("-0x100000000000000", "-0x100000000000000", zero);
+ bitXorParsed("-0x1000000000000000", "-0x1000000000000000", zero);
+ bitXorParsed("-0x10000000", "-0x10000001", "0x1FFFFFFF");
+ bitXorParsed("-0x100000000", "-0x100000001", "0x1FFFFFFFF");
+ bitXorParsed("-0x100000000000000", "-0x100000000000001", "0x1FFFFFFFFFFFFFF");
+ bitXorParsed(
+ "-0x1000000000000000", "-0x1000000000000001", "0x1FFFFFFFFFFFFFFF");
+}
+
+bitNotParsed(String a, String result) {
+ int int_a = int.parse(a);
+ int int_result = int.parse(result);
+ int inverted = ~int_a;
+ Expect.equals(int_result, inverted);
+ String str_inverted = toHexString(inverted);
+ Expect.equals(result.toLowerCase(), str_inverted);
+ int back = ~inverted;
+ Expect.equals(int_a, back);
+ String str_back = toHexString(back);
+ Expect.equals(a.toLowerCase(), str_back);
+}
+
+testBitNot() {
+ String zero = "0x0";
+ String one = "0x1";
+ String minus_one = "-0x1";
+
+ bitNotParsed(zero, minus_one);
+ bitNotParsed(one, "-0x2");
+ bitNotParsed("0x5", "-0x6");
+ bitNotParsed("0x50000000", "-0x50000001");
+ bitNotParsed("0xFFFFFFF", "-0x10000000");
+ bitNotParsed("0xFFFFFFFF", "-0x100000000");
+ bitNotParsed("0xFFFFFFFFFFFFFF", "-0x100000000000000");
+ bitNotParsed("0x7FFFFFFFFFFFFFFF", "-0x8000000000000000");
+ bitNotParsed("-0x1", "0x0");
+}
+
+main() {
+ testAddSub();
+ testLeftShift();
+ testRightShift();
+ testBitAnd();
+ testBitOr();
+ testBitXor();
+ testBitNot();
+}
diff --git a/tests/corelib/integer_parsed_div_rem_vm_test.dart b/tests/corelib/integer_parsed_div_rem_vm_test.dart
new file mode 100644
index 0000000..57eed91
--- /dev/null
+++ b/tests/corelib/integer_parsed_div_rem_vm_test.dart
@@ -0,0 +1,66 @@
+// Copyright (c) 2011, 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.
+
+// Testing integers with and without intrinsics.
+// VMOptions=
+// VMOptions=--no_intrinsify
+
+library integer_arithmetic_test;
+
+import "package:expect/expect.dart";
+
+divRemParsed(String a, String b, String quotient, String remainder) {
+ int int_a = int.parse(a);
+ int int_b = int.parse(b);
+ int int_quotient = int.parse(quotient);
+ int int_remainder = int.parse(remainder);
+ int computed_quotient = int_a ~/ int_b;
+ Expect.equals(int_quotient, computed_quotient);
+ String str_quotient = computed_quotient >= 0
+ ? "0x${computed_quotient.toRadixString(16)}"
+ : "-0x${computed_quotient.toRadixString(16).substring(1)}";
+ Expect.equals(quotient.toLowerCase(), str_quotient);
+ int computed_remainder = int_a.remainder(int_b) as int;
+ Expect.equals(int_remainder, computed_remainder);
+ String str_remainder = computed_remainder >= 0
+ ? "0x${computed_remainder.toRadixString(16)}"
+ : "-0x${computed_remainder.toRadixString(16).substring(1)}";
+ Expect.equals(remainder.toLowerCase(), str_remainder);
+}
+
+testDivideRemainder() {
+ String zero = "0x0";
+ String one = "0x1";
+ String minus_one = "-0x1";
+
+ divRemParsed(one, one, one, zero);
+ divRemParsed(zero, one, zero, zero);
+ divRemParsed(minus_one, one, minus_one, zero);
+ divRemParsed(one, "0x2", zero, one);
+ divRemParsed(minus_one, "0x7", zero, minus_one);
+ divRemParsed("0xB", "0x7", one, "0x4");
+ divRemParsed("0x12345678", "0x7", "0x299C335", "0x5");
+ divRemParsed("-0x12345678", "0x7", "-0x299C335", "-0x5");
+ divRemParsed("0x12345678", "-0x7", "-0x299C335", "0x5");
+ divRemParsed("-0x12345678", "-0x7", "0x299C335", "-0x5");
+ divRemParsed("0x7", "0x12345678", zero, "0x7");
+ divRemParsed("-0x7", "0x12345678", zero, "-0x7");
+ divRemParsed("-0x7", "-0x12345678", zero, "-0x7");
+ divRemParsed("0x7", "-0x12345678", zero, "0x7");
+ divRemParsed("0x12345678", "0x7", "0x299C335", "0x5");
+ divRemParsed("-0x12345678", "0x7", "-0x299C335", "-0x5");
+ divRemParsed("0x12345678", "-0x7", "-0x299C335", "0x5");
+ divRemParsed("-0x12345678", "-0x7", "0x299C335", "-0x5");
+ divRemParsed("9223372036854775807", "0x7", "0x1249249249249249", "0x0");
+ divRemParsed("9223372036854775807", "-0x7", "-0x1249249249249249", "0x0");
+ divRemParsed("-9223372036854775807", "0x7", "-0x1249249249249249", "0x0");
+ divRemParsed("-9223372036854775807", "-0x7", "0x1249249249249249", "0x0");
+ divRemParsed("-9223372036854775808", "-1", "-0x8000000000000000", "0x0"); //# 01: ok
+ divRemParsed("-9223372036854775808", "0x7", "-0x1249249249249249", "-0x1");
+ divRemParsed("-9223372036854775808", "-0x7", "0x1249249249249249", "-0x1");
+}
+
+main() {
+ testDivideRemainder();
+}
diff --git a/tests/corelib/integer_parsed_mul_div_vm_test.dart b/tests/corelib/integer_parsed_mul_div_vm_test.dart
new file mode 100644
index 0000000..607aa7f
--- /dev/null
+++ b/tests/corelib/integer_parsed_mul_div_vm_test.dart
@@ -0,0 +1,81 @@
+// Copyright (c) 2011, 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.
+
+// Testing integers with and without intrinsics.
+// VMOptions=
+// VMOptions=--no_intrinsify
+
+library integer_arithmetic_test;
+
+import "package:expect/expect.dart";
+
+mulDivParsed(String a, String b, String product,
+ {String? expected_quotient1, String? expected_quotient2}) {
+ int int_a = int.parse(a);
+ int int_b = int.parse(b);
+ int int_product = int.parse(product);
+ int computed_product = int_a * int_b;
+ Expect.equals(int_product, computed_product);
+ String str_product = computed_product >= 0
+ ? "0x${computed_product.toRadixString(16)}"
+ : "-0x${(-computed_product).toRadixString(16)}";
+ Expect.equals(product.toLowerCase(), str_product);
+ int computed_product2 = int_b * int_a;
+ Expect.equals(int_product, computed_product2);
+ String str_product2 = computed_product2 >= 0
+ ? "0x${computed_product2.toRadixString(16)}"
+ : "-0x${(-computed_product2).toRadixString(16)}";
+ Expect.equals(product.toLowerCase(), str_product2);
+
+ if (int_a != 0) {
+ expected_quotient1 ??= b;
+ int int_expected_quotient1 = int.parse(expected_quotient1);
+ int computed_quotient1 = int_product ~/ int_a;
+ Expect.equals(int_expected_quotient1, computed_quotient1);
+ String str_quotient1 = computed_quotient1 >= 0
+ ? "0x${computed_quotient1.toRadixString(16)}"
+ : "-0x${(-computed_quotient1).toRadixString(16)}";
+ Expect.equals(expected_quotient1.toLowerCase(), str_quotient1);
+ }
+
+ if (int_b != 0) {
+ expected_quotient2 ??= a;
+ int int_expected_quotient2 = int.parse(expected_quotient2);
+ int computed_quotient2 = int_product ~/ int_b;
+ Expect.equals(int_expected_quotient2, computed_quotient2);
+ String str_quotient2 = computed_quotient2 >= 0
+ ? "0x${computed_quotient2.toRadixString(16)}"
+ : "-0x${(-computed_quotient2).toRadixString(16)}";
+ Expect.equals(expected_quotient2.toLowerCase(), str_quotient2);
+ }
+}
+
+testMultiplyDivide() {
+ String zero = "0x0";
+ String one = "0x1";
+ String minus_one = "-0x1";
+
+ mulDivParsed(zero, zero, zero);
+ mulDivParsed(one, one, one);
+ mulDivParsed(one, zero, zero);
+ mulDivParsed(zero, one, zero);
+ mulDivParsed(one, minus_one, minus_one);
+ mulDivParsed(minus_one, minus_one, one);
+ mulDivParsed("0x42", one, "0x42");
+ mulDivParsed("0x42", "0x2", "0x84");
+ mulDivParsed("0xFFFF", "0x2", "0x1FFFE");
+ mulDivParsed("0x3", "0x5", "0xF");
+ mulDivParsed("0xFFFFF", "0x5", "0x4FFFFB");
+ mulDivParsed("0xFFFFFFF", "0x5", "0x4FFFFFFB");
+ mulDivParsed("0xFFFFFFFF", "0x5", "0x4FFFFFFFB");
+ mulDivParsed("0x7FFFFFFFFFFFFFFF", "0x5", "0x7FFFFFFFFFFFFFFB",
+ expected_quotient1: zero, expected_quotient2: "0x1999999999999998");
+ mulDivParsed("0x7FFFFFFFFFFFFFFF", "0x3039", "0x7FFFFFFFFFFFCFC7",
+ expected_quotient1: zero, expected_quotient2: "0x2A783BE38C73D");
+ mulDivParsed("0x10000001", "0x5", "0x50000005");
+}
+
+main() {
+ testMultiplyDivide();
+}
diff --git a/tests/corelib/integer_to_radix_string_test.dart b/tests/corelib/integer_to_radix_string_test.dart
new file mode 100644
index 0000000..bfe726c
--- /dev/null
+++ b/tests/corelib/integer_to_radix_string_test.dart
@@ -0,0 +1,87 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ // Test that we accept radix 2 to 36 and that we use lower-case
+ // letters.
+ var expected = [
+ '0',
+ '1',
+ '2',
+ '3',
+ '4',
+ '5',
+ '6',
+ '7',
+ '8',
+ '9',
+ 'a',
+ 'b',
+ 'c',
+ 'd',
+ 'e',
+ 'f',
+ 'g',
+ 'h',
+ 'i',
+ 'j',
+ 'k',
+ 'l',
+ 'm',
+ 'n',
+ 'o',
+ 'p',
+ 'q',
+ 'r',
+ 's',
+ 't',
+ 'u',
+ 'v',
+ 'w',
+ 'x',
+ 'y',
+ 'z'
+ ];
+ for (var radix = 2; radix <= 36; radix++) {
+ for (var i = 0; i < radix; i++) {
+ Expect.equals(expected[i], i.toRadixString(radix));
+ }
+ }
+
+ var illegalRadices = [-1, 0, 1, 37];
+ for (var radix in illegalRadices) {
+ try {
+ 42.toRadixString(radix);
+ Expect.fail("Exception expected");
+ } on ArgumentError catch (e) {
+ // Nothing to do.
+ }
+ }
+
+ // Try large numbers (regression test for issue 15316).
+ var bignums = [
+ 0x80000000,
+ 0x100000000,
+ 0x10000000000000,
+ 0x10000000000001, // 53 significant bits.
+ 0x20000000000000,
+ 0x20000000000002,
+ 0x1000000000000000,
+ 0x1000000000000100,
+ 0x2000000000000000,
+ 0x2000000000000200,
+ 0x8000000000000000, //# 01: ok
+ 0x8000000000000800, //# 02: ok
+ ];
+ for (var bignum in bignums) {
+ for (int radix = 2; radix <= 36; radix++) {
+ String digits = bignum.toRadixString(radix);
+ int result = int.parse(digits, radix: radix);
+ Expect.equals(
+ bignum, result, "${bignum.toRadixString(16)} -> $digits/$radix");
+ }
+ }
+}
diff --git a/tests/corelib/integer_to_string_test.dart b/tests/corelib/integer_to_string_test.dart
new file mode 100644
index 0000000..c23e8bb
--- /dev/null
+++ b/tests/corelib/integer_to_string_test.dart
@@ -0,0 +1,84 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ /// Test that converting [value] to a string gives [expect].
+ /// Also test that `-value` gives `"-"+expect`.
+ test(int value, String expect) {
+ Expect.equals(expect, value.toString());
+ Expect.equals(expect, "$value");
+ Expect.equals(expect, (new StringBuffer()..write(value)).toString());
+ if (value <= 0) return;
+ expect = "-$expect";
+ value = -value;
+ Expect.equals(expect, value.toString());
+ Expect.equals(expect, "$value");
+ Expect.equals(expect, (new StringBuffer()..write(value)).toString());
+ }
+
+ // Very simple tests.
+ test(0, "0");
+ test(1, "1");
+ test(2, "2");
+ test(5, "5");
+
+ // Binary special cases.
+
+ // ~2^30.
+ test(0x3fffffff, "1073741823");
+ test(0x40000000, "1073741824");
+ test(0x40000001, "1073741825");
+ // ~2^31.
+ test(0x7fffffff, "2147483647");
+ test(0x80000000, "2147483648");
+ test(0x80000001, "2147483649");
+ // ~2^32.
+ test(0xffffffff, "4294967295");
+ test(0x100000000, "4294967296");
+ test(0x100000001, "4294967297");
+
+ // ~2^51.
+ test(0x7ffffffffffff, "2251799813685247");
+ test(0x8000000000000, "2251799813685248");
+ test(0x8000000000001, "2251799813685249");
+ // ~2^52.
+ test(0xfffffffffffff, "4503599627370495");
+ test(0x10000000000000, "4503599627370496");
+ test(0x10000000000001, "4503599627370497");
+ // ~2^53.
+ test(0x1fffffffffffff, "9007199254740991");
+ test(0x20000000000000, "9007199254740992");
+ test(0x20000000000001, "9007199254740993"); // //# 01: ok
+ // ~2^62.
+ test(0x3fffffffffffffff, "4611686018427387903"); // //# 01: continued
+ test(0x4000000000000000, "4611686018427387904"); // //# 01: continued
+ test(0x4000000000000001, "4611686018427387905"); // //# 01: continued
+ // ~2^63.
+ test(0x7fffffffffffffff, "9223372036854775807"); // //# 01: continued
+ test(0x8000000000000000, "-9223372036854775808"); // //# 01: continued
+ test(0x8000000000000001, "-9223372036854775807"); // //# 01: continued
+ // ~2^64.
+ test(0xffffffffffffffff, "-1"); // //# 01: continued
+
+ // Decimal special cases.
+
+ int number = 10;
+ // Numbers 99..99, 100...00, and 100..01 up to 18 digits.
+ for (int i = 1; i < 15; i++) {
+ // Works in dart2js up to 10^15.
+ test(number - 1, "9" * i);
+ test(number, "1" + "0" * i);
+ test(number + 1, "1" + "0" * (i - 1) + "1");
+ number *= 10;
+ }
+ // Fails to represent exactly in dart2js.
+ for (int i = 15; i < 19; i++) { // //# 01: continued
+ test(number - 1, "9" * i); // //# 01: continued
+ test(number, "1" + "0" * i); // //# 01: continued
+ test(number + 1, "1" + "0" * (i - 1) + "1"); // //# 01: continued
+ number *= 10; // //# 01: continued
+ } // //# 01: continued
+}
diff --git a/tests/corelib/invocation_test.dart b/tests/corelib/invocation_test.dart
new file mode 100644
index 0000000..044eb93
--- /dev/null
+++ b/tests/corelib/invocation_test.dart
@@ -0,0 +1,413 @@
+// Copyright (c) 2018, 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.
+
+import "package:expect/expect.dart";
+
+// Tests the constructors of the Invocation class.
+
+main() {
+ {
+ var name = "getter";
+ var invocation = new Invocation.getter(#name);
+ Expect.isTrue(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isTrue(invocation.isAccessor, "$name:isAccessor");
+ Expect.isFalse(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([], invocation.typeArguments, "$name:types");
+ Expect.listEquals([], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals({}, invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+ }
+ {
+ var name = "setter";
+ var argument = new Object();
+ var invocation = new Invocation.setter(const Symbol("name="), argument);
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isTrue(invocation.isSetter, "$name:isSetter");
+ Expect.isTrue(invocation.isAccessor, "$name:isAccessor");
+ Expect.isFalse(invocation.isMethod, "$name:isMethod");
+ Expect.equals(const Symbol("name="), invocation.memberName, "$name:name");
+ Expect.listEquals([], invocation.typeArguments, "$name:types");
+ Expect.listEquals([argument], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals({}, invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+ }
+ {
+ var name = ".name()";
+ var invocation = new Invocation.method(#name, []);
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([], invocation.typeArguments, "$name:types");
+ Expect.listEquals([], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals({}, invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+
+ expectInvocation("$name:", invocation, new Invocation.method(#name, null));
+ expectInvocation(
+ "$name:", invocation, new Invocation.method(#name, [], null));
+ expectInvocation(
+ "$name:", invocation, new Invocation.method(#name, [], {}));
+
+ expectInvocation(
+ "$name:", invocation, new Invocation.genericMethod(#name, [], []));
+ expectInvocation(
+ "$name:", invocation, new Invocation.genericMethod(#name, [], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [], [], null));
+ expectInvocation(
+ "$name:", invocation, new Invocation.genericMethod(#name, [], [], {}));
+ expectInvocation(
+ "$name:", invocation, new Invocation.genericMethod(#name, null, []));
+ expectInvocation(
+ "$name:", invocation, new Invocation.genericMethod(#name, null, null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, null, [], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, null, [], {}));
+ }
+ {
+ var name = ".name(a)";
+ var argument = new Object();
+ var invocation = new Invocation.method(#name, [argument]);
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([], invocation.typeArguments, "$name:types");
+ Expect.listEquals([argument], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals({}, invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+
+ expectInvocation(
+ "$name:", invocation, new Invocation.method(#name, [argument], null));
+ expectInvocation(
+ "$name:", invocation, new Invocation.method(#name, [argument], {}));
+
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [], [argument], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [], [argument], {}));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, null, [argument], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, null, [argument], {}));
+ }
+ {
+ var name = ".name(a,b)";
+ var argument = new Object();
+ var argument2 = new Object();
+ var invocation = new Invocation.method(#name, [argument, argument2]);
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([], invocation.typeArguments, "$name:types");
+ Expect.listEquals(
+ [argument, argument2], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals({}, invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+
+ expectInvocation("$name:", invocation,
+ new Invocation.method(#name, [argument, argument2], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.method(#name, [argument, argument2], {}));
+
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [], [argument, argument2], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [], [argument, argument2], {}));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, null, [argument, argument2], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, null, [argument, argument2], {}));
+ }
+ {
+ var name = ".name(a,b:)";
+ var argument = new Object();
+ var argument2 = new Object();
+ var invocation =
+ new Invocation.method(#name, [argument], {#arg: argument2});
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([], invocation.typeArguments, "$name:types");
+ Expect.listEquals([argument], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals(
+ {#arg: argument2}, invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+
+ expectInvocation(
+ "$name:",
+ invocation,
+ new Invocation.genericMethod(
+ #name, null, [argument], {#arg: argument2}));
+ }
+ {
+ var name = ".name(a:,b:)";
+ var argument = new Object();
+ var argument2 = new Object();
+ var invocation =
+ new Invocation.method(#name, [], {#arg: argument, #arg2: argument2});
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([], invocation.typeArguments, "$name:types");
+ Expect.listEquals([], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals({#arg: argument, #arg2: argument2},
+ invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+
+ expectInvocation("$name:", invocation,
+ new Invocation.method(#name, null, {#arg: argument, #arg2: argument2}));
+ expectInvocation(
+ "$name:",
+ invocation,
+ new Invocation.genericMethod(
+ #name, null, [], {#arg: argument, #arg2: argument2}));
+ expectInvocation(
+ "$name:",
+ invocation,
+ new Invocation.genericMethod(
+ #name, null, null, {#arg: argument, #arg2: argument2}));
+ }
+ {
+ var name = ".name<i>()";
+ var invocation = new Invocation.genericMethod(#name, [int], []);
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([int], invocation.typeArguments, "$name:types");
+ Expect.listEquals([], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals({}, invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+
+ expectInvocation(
+ "$name:", invocation, new Invocation.genericMethod(#name, [int], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [int], [], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [int], null, null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [int], [], {}));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [int], null, {}));
+ }
+ {
+ var name = ".name<i>(a)";
+ var argument = new Object();
+ var invocation = new Invocation.genericMethod(#name, [int], [argument]);
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([int], invocation.typeArguments, "$name:types");
+ Expect.listEquals([argument], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals({}, invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [int], [argument], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [int], [argument], {}));
+ }
+ {
+ var name = ".name<i>(a,b)";
+ var argument = new Object();
+ var argument2 = new Object();
+ var invocation =
+ new Invocation.genericMethod(#name, [int], [argument, argument2]);
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([int], invocation.typeArguments, "$name:types");
+ Expect.listEquals(
+ [argument, argument2], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals({}, invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+
+ expectInvocation(
+ "$name:",
+ invocation,
+ new Invocation.genericMethod(
+ #name, [int], [argument, argument2], null));
+ expectInvocation("$name:", invocation,
+ new Invocation.genericMethod(#name, [int], [argument, argument2], {}));
+ }
+ {
+ var name = ".name<i>(a,b:)";
+ var argument = new Object();
+ var argument2 = new Object();
+ var invocation = new Invocation.genericMethod(
+ #name, [int], [argument], {#arg: argument2});
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([int], invocation.typeArguments, "$name:types");
+ Expect.listEquals([argument], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals(
+ {#arg: argument2}, invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+ }
+ {
+ var name = ".name<i>(a:,b:)";
+ var argument = new Object();
+ var argument2 = new Object();
+ var invocation = new Invocation.genericMethod(
+ #name, [int], [], {#arg: argument, #arg2: argument2});
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals([int], invocation.typeArguments, "$name:types");
+ Expect.listEquals([], invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals({#arg: argument, #arg2: argument2},
+ invocation.namedArguments, "$name: named");
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+
+ expectInvocation(
+ "$name:",
+ invocation,
+ new Invocation.genericMethod(
+ #name, [int], null, {#arg: argument, #arg2: argument2}));
+ }
+ {
+ // Many arguments.
+ var name = ".name<..>(..,..:)";
+ var argument = new Object();
+ var argument2 = new Object();
+ Type intList = new TypeHelper<List<int>>().type;
+ var invocation = new Invocation.genericMethod(
+ #name,
+ [int, double, intList],
+ [argument, argument2, null, argument],
+ {#arg: argument, #arg2: argument2, #arg3: null, #arg4: argument});
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals(
+ [int, double, intList], invocation.typeArguments, "$name:types");
+ Expect.listEquals([argument, argument2, null, argument],
+ invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals(
+ {#arg: argument, #arg2: argument2, #arg3: null, #arg4: argument},
+ invocation.namedArguments);
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+ }
+ {
+ // Accepts iterables, not just lists.
+ var name = "iterables";
+ var argument = new Object();
+ var argument2 = new Object();
+ Type intList = new TypeHelper<List<int>>().type;
+ var invocation = new Invocation.genericMethod(
+ #name,
+ [int, double, intList].where(kTrue),
+ [argument, argument2, null, argument].where(kTrue),
+ {#arg: argument, #arg2: argument2, #arg3: null, #arg4: argument});
+ Expect.isFalse(invocation.isGetter, "$name:isGetter");
+ Expect.isFalse(invocation.isSetter, "$name:isSetter");
+ Expect.isFalse(invocation.isAccessor, "$name:isAccessor");
+ Expect.isTrue(invocation.isMethod, "$name:isMethod");
+ Expect.equals(#name, invocation.memberName, "$name:name");
+ Expect.listEquals(
+ [int, double, intList], invocation.typeArguments, "$name:types");
+ Expect.listEquals([argument, argument2, null, argument],
+ invocation.positionalArguments, "$name:pos");
+ Expect.mapEquals(
+ {#arg: argument, #arg2: argument2, #arg3: null, #arg4: argument},
+ invocation.namedArguments);
+ checkUnmodifiableList("$name types", invocation.typeArguments);
+ checkUnmodifiableList("$name positional", invocation.positionalArguments);
+ checkUnmodifiableMap("$name named", invocation.namedArguments);
+ }
+}
+
+void checkUnmodifiableList(String name, List<Object?> list) {
+ if (list.isNotEmpty) {
+ Expect.throws(() {
+ list[0] = null;
+ }, (_) => true, "$name: list not unmodifiable");
+ }
+ Expect.throws(() {
+ list.add(null);
+ }, (_) => true, "$name: list not unmodifiable");
+}
+
+void checkUnmodifiableMap(String name, Map<Symbol, Object?> map) {
+ Expect.throws(() {
+ map[#key] = null;
+ }, (_) => true, "$name: map not unmodifiable");
+}
+
+class TypeHelper<T> {
+ Type get type => T;
+}
+
+expectInvocation(String name, Invocation expect, Invocation actual) {
+ Expect.equals(expect.isGetter, actual.isGetter, "$name:isGetter");
+ Expect.equals(expect.isSetter, actual.isSetter, "$name:isSetter");
+ Expect.equals(expect.isAccessor, actual.isAccessor, "$name:isAccessor");
+ Expect.equals(actual.isGetter || actual.isSetter, actual.isAccessor);
+ Expect.equals(expect.isMethod, actual.isMethod, "$name:isMethod");
+ Expect.isTrue(actual.isMethod || actual.isGetter || actual.isSetter);
+ Expect.isFalse(actual.isMethod && actual.isGetter);
+ Expect.isFalse(actual.isMethod && actual.isSetter);
+ Expect.isFalse(actual.isSetter && actual.isGetter);
+ Expect.equals(expect.memberName, actual.memberName, "$name:memberName");
+ Expect.listEquals(expect.typeArguments, actual.typeArguments, "$name:types");
+ Expect.listEquals(
+ expect.positionalArguments, actual.positionalArguments, "$name:pos");
+ Expect.mapEquals(expect.namedArguments, actual.namedArguments, "$name:named");
+ checkUnmodifiableList(name, actual.typeArguments);
+ checkUnmodifiableList(name, actual.positionalArguments);
+ checkUnmodifiableMap(name, actual.namedArguments);
+}
+
+bool kTrue(_) => true;
diff --git a/tests/corelib/is_operator_basic_types_test.dart b/tests/corelib/is_operator_basic_types_test.dart
new file mode 100644
index 0000000..772afb2
--- /dev/null
+++ b/tests/corelib/is_operator_basic_types_test.dart
@@ -0,0 +1,61 @@
+// Copyright (c) 2012, 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.
+// Dart test program for the "is" type test operator.
+
+import "package:expect/expect.dart";
+
+check(args) {
+ var list = args[0];
+ var string = args[1];
+ var nullObject = args[2];
+
+ Expect.isTrue(list is Object);
+ Expect.isTrue(list is List);
+ Expect.isTrue(list is Iterable);
+ Expect.isFalse(list is Comparable);
+ Expect.isFalse(list is Pattern);
+ Expect.isFalse(list is String);
+
+ Expect.isFalse(list is! List);
+ Expect.isFalse(list is! Iterable);
+ Expect.isTrue(list is! Comparable);
+ Expect.isTrue(list is! Pattern);
+ Expect.isTrue(list is! String);
+
+ Expect.isTrue(string is Object);
+ Expect.isFalse(string is List);
+ Expect.isFalse(string is Iterable);
+ Expect.isTrue(string is Comparable);
+ Expect.isTrue(string is Pattern);
+ Expect.isTrue(string is String);
+
+ Expect.isTrue(string is! List);
+ Expect.isTrue(string is! Iterable);
+ Expect.isFalse(string is! Comparable);
+ Expect.isFalse(string is! Pattern);
+ Expect.isFalse(string is! String);
+
+ Expect.isTrue(nullObject is Object);
+ Expect.isFalse(nullObject is List);
+ Expect.isFalse(nullObject is Iterable);
+ Expect.isFalse(nullObject is Comparable);
+ Expect.isFalse(nullObject is Pattern);
+ Expect.isFalse(nullObject is String);
+
+ Expect.isTrue(nullObject is! List);
+ Expect.isTrue(nullObject is! Iterable);
+ Expect.isTrue(nullObject is! Comparable);
+ Expect.isTrue(nullObject is! Pattern);
+ Expect.isTrue(nullObject is! String);
+}
+
+main() {
+ // Try to make it hard for an optimizing compiler to inline the
+ // tests.
+ check([[], 'string', null]);
+
+ // Try to make it even harder.
+ var string = new String.fromCharCodes([new DateTime.now().year % 100 + 1]);
+ check([string.codeUnits, string, null]);
+}
diff --git a/tests/corelib/iterable_contains2_test.dart b/tests/corelib/iterable_contains2_test.dart
new file mode 100644
index 0000000..d4714c7
--- /dev/null
+++ b/tests/corelib/iterable_contains2_test.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Tests for the contains methods on lists.
+
+class A {
+ const A();
+}
+
+class B extends A {
+ const B();
+}
+
+main() {
+ var list = <B>[new B()];
+ var set = new Set<B>();
+ set.add(new B());
+ var iterable1 = list.map((x) => x);
+ var iterable2 = list.take(1);
+ var list2 = const <B>[const B()];
+ var iterable3 = list2.map((x) => x);
+ var iterable4 = list2.take(1);
+ var iterables = [
+ list,
+ set,
+ iterable1,
+ iterable2,
+ list2,
+ iterable3,
+ iterable4
+ ];
+ for (var iterable in iterables) {
+ Expect.isFalse(iterable.contains(new A()));
+ }
+}
diff --git a/tests/corelib/iterable_contains_test.dart b/tests/corelib/iterable_contains_test.dart
new file mode 100644
index 0000000..760a104
--- /dev/null
+++ b/tests/corelib/iterable_contains_test.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Tests for the contains methods on lists.
+
+test(list, notInList) {
+ testList(list) {
+ for (int i = 0; i < list.length; i++) {
+ var elem = list[i];
+ Expect.isTrue(list.contains(list[i]), "$list.contains($elem)");
+ }
+ Expect.isFalse(list.contains(notInList), "!$list.contains($notInList)");
+ }
+
+ List fixedList = new List(list.length);
+ List growList = new List();
+ for (int i = 0; i < list.length; i++) {
+ fixedList[i] = list[i];
+ growList.add(list[i]);
+ }
+ testList(list);
+ testList(fixedList);
+ testList(growList);
+}
+
+class C {
+ const C();
+}
+
+class Niet {
+ bool operator ==(other) => false;
+}
+
+main() {
+ test(const <String?>["a", "b", "c", null], "d");
+ test(const <int?>[1, 2, 3, null], 0);
+ test(const <bool>[true, false], null);
+ test(const <C?>[const C(), const C(), null], new C());
+ test(<C?>[new C(), new C(), new C(), null], new C());
+ test(const <double>[0.0, 1.0, 5e-324, 1e+308, double.infinity], 2.0);
+ Expect.isTrue(const <double>[-0.0].contains(0.0));
+ Expect.isFalse(const <double>[double.nan].contains(double.nan));
+ var niet = new Niet();
+ Expect.isFalse([niet].contains(niet));
+}
diff --git a/tests/corelib/iterable_element_at_test.dart b/tests/corelib/iterable_element_at_test.dart
new file mode 100644
index 0000000..d895686
--- /dev/null
+++ b/tests/corelib/iterable_element_at_test.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 5, 6];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(11)..add(12)..add(13);
+ Set set2 = new Set();
+
+ Expect.equals(1, list1.elementAt(0));
+ Expect.equals(2, list1.elementAt(1));
+ Expect.equals(3, list1.elementAt(2));
+ list1.elementAt("2"); //# static: compile-time error
+ Expect.throwsArgumentError(() => list1.elementAt(-1));
+ Expect.throwsRangeError(() => list1.elementAt(3));
+
+ Expect.equals(4, list2.elementAt(0));
+ Expect.equals(5, list2.elementAt(1));
+ Expect.equals(6, list2.elementAt(2));
+ list2.elementAt("2"); //# static: compile-time error
+ Expect.throwsArgumentError(() => list2.elementAt(-1));
+ Expect.throwsRangeError(() => list2.elementAt(3));
+
+ Expect.isTrue(set1.contains(set1.elementAt(0)));
+ Expect.isTrue(set1.contains(set1.elementAt(1)));
+ Expect.isTrue(set1.contains(set1.elementAt(2)));
+ Expect.throwsArgumentError(() => set1.elementAt(-1));
+ Expect.throwsRangeError(() => set1.elementAt(3));
+
+ set2.elementAt("2"); //# static: compile-time error
+ Expect.throwsArgumentError(() => set2.elementAt(-1));
+ Expect.throwsRangeError(() => set2.elementAt(0));
+ Expect.throwsRangeError(() => set2.elementAt(1));
+}
diff --git a/tests/corelib/iterable_empty_test.dart b/tests/corelib/iterable_empty_test.dart
new file mode 100644
index 0000000..7d26088
--- /dev/null
+++ b/tests/corelib/iterable_empty_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ testEmpty(name, Iterable<int> it, [depth = 2]) {
+ Expect.isTrue(it.isEmpty, name);
+ Expect.isFalse(it.isNotEmpty, name);
+ Expect.equals(0, it.length, name);
+ Expect.isFalse(it.contains(null), name);
+ Expect.isFalse(it.any((x) => true), name);
+ Expect.isTrue(it.every((x) => false), name);
+ Expect.throwsStateError(() => it.first, name);
+ Expect.throwsStateError(() => it.last, name);
+ Expect.throwsStateError(() => it.single, name);
+ Expect.throwsRangeError(() => it.elementAt(0), name);
+ Expect.throwsStateError(() => it.reduce((a, b) => a), name);
+ Expect.throwsStateError(() => it.singleWhere((_) => true), name);
+ Expect.equals(42, it.fold(42, (a, b) => "not 42"), name);
+ Expect.equals(42, it.firstWhere((v) => true, orElse: () => 42), name);
+ Expect.equals(42, it.lastWhere((v) => true, orElse: () => 42), name);
+ Expect.equals("", it.join("separator"), name);
+ Expect.equals("()", it.toString(), name);
+ Expect.listEquals([], it.toList(), name);
+ Expect.listEquals([], it.toList(growable: false), name);
+ Expect.listEquals([], it.toList(growable: true), name);
+ Expect.equals(0, it.toSet().length, name);
+ // Doesn't throw:
+ it.forEach((v) => throw v);
+ for (var v in it) {
+ throw v;
+ }
+ // Check that returned iterables are also empty.
+ if (depth > 0) {
+ testEmpty("$name-map", it.map((x) => x), depth - 1);
+ testEmpty("$name-where", it.where((x) => true), depth - 1);
+ testEmpty("$name-expand", it.expand((x) => [x]), depth - 1);
+ testEmpty("$name-skip", it.skip(1), depth - 1);
+ testEmpty("$name-take", it.take(2), depth - 1);
+ testEmpty("$name-skipWhile", it.skipWhile((v) => false), depth - 1);
+ testEmpty("$name-takeWhile", it.takeWhile((v) => true), depth - 1);
+ }
+ }
+
+ testType(name, it, [depth = 2]) {
+ Expect.isTrue(it is Iterable<int>, name);
+ Expect.isFalse(it is Iterable<String>, name);
+ if (depth > 0) {
+ testType("$name-where", it.where((_) => true), depth - 1);
+ testType("$name-skip", it.skip(1), depth - 1);
+ testType("$name-take", it.take(1), depth - 1);
+ testType("$name-skipWhile", it.skipWhile((_) => false), depth - 1);
+ testType("$name-takeWhile", it.takeWhile((_) => true), depth - 1);
+ testType("$name-toList", it.toList(), depth - 1);
+ testType("$name-toList", it.toList(growable: false), depth - 1);
+ testType("$name-toList", it.toList(growable: true), depth - 1);
+ testType("$name-toSet", it.toSet(), depth - 1);
+ }
+ }
+
+ test(name, it) {
+ testEmpty(name, it);
+ testType(name, it);
+ }
+
+ test("const", const Iterable<int>.empty());
+ test("new", new Iterable<int>.empty());
+}
diff --git a/tests/corelib/iterable_expand_test.dart b/tests/corelib/iterable_expand_test.dart
new file mode 100644
index 0000000..a02787a
--- /dev/null
+++ b/tests/corelib/iterable_expand_test.dart
@@ -0,0 +1,74 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+import 'dart:collection';
+
+class MyList extends ListBase {
+ List list;
+ MyList(this.list);
+
+ get length => list.length;
+ set length(val) {
+ list.length = val;
+ }
+
+ operator [](index) => list[index];
+ operator []=(index, val) => list[index] = val;
+
+ String toString() => "[" + join(", ") + "]";
+}
+
+main() {
+ test(expectation, iterable) {
+ Expect.listEquals(expectation, iterable.toList());
+ }
+
+ // Function not called on empty iterable.
+ test(
+ [],
+ [].expand((x) {
+ throw "not called";
+ }));
+
+ // Creating the iterable doesn't call the function.
+ [1].expand((x) {
+ throw "not called";
+ });
+
+ test([1], [1].expand((x) => [x]));
+ test([1, 2, 3], [1, 2, 3].expand((x) => [x]));
+
+ test([], [1].expand((x) => []));
+ test([], [1, 2, 3].expand((x) => []));
+ test([2], [1, 2, 3].expand((x) => x == 2 ? [2] : []));
+
+ test([1, 1, 2, 2, 3, 3], [1, 2, 3].expand((x) => [x, x]));
+ test([1, 1, 2], [1, 2, 3].expand((x) => [x, x, x].skip(x)));
+
+ test([1], new MyList([1]).expand((x) => [x]));
+ test([1, 2, 3], new MyList([1, 2, 3]).expand((x) => [x]));
+
+ test([], new MyList([1]).expand((x) => []));
+ test([], new MyList([1, 2, 3]).expand((x) => []));
+ test([2], new MyList([1, 2, 3]).expand((x) => x == 2 ? [2] : []));
+
+ test([1, 1, 2, 2, 3, 3], new MyList([1, 2, 3]).expand((x) => [x, x]));
+ test([1, 1, 2], new MyList([1, 2, 3]).expand((x) => [x, x, x].skip(x)));
+
+ // if function throws, iteration is stopped.
+ Iterable iterable = [1, 2, 3].expand((x) {
+ if (x == 2) throw "FAIL";
+ return [x, x];
+ });
+ Iterator it = iterable.iterator;
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.throws(it.moveNext, (e) => e == "FAIL");
+ // After throwing, iteration is ended.
+ Expect.equals(null, it.current);
+ Expect.isFalse(it.moveNext());
+}
diff --git a/tests/corelib/iterable_first_test.dart b/tests/corelib/iterable_first_test.dart
new file mode 100644
index 0000000..40e53c2
--- /dev/null
+++ b/tests/corelib/iterable_first_test.dart
@@ -0,0 +1,22 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 5];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(11)..add(12)..add(13);
+ Set set2 = new Set();
+
+ Expect.equals(1, list1.first);
+ Expect.equals(4, list2.first);
+ Expect.throwsStateError(() => list3.first);
+
+ Expect.isTrue(set1.contains(set1.first));
+
+ Expect.throwsStateError(() => set2.first);
+}
diff --git a/tests/corelib/iterable_first_where_test.dart b/tests/corelib/iterable_first_where_test.dart
new file mode 100644
index 0000000..80e4958
--- /dev/null
+++ b/tests/corelib/iterable_first_where_test.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2012, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ List<int?> list1 = <int?>[1, 2, 3];
+ List<int?> list2 = const <int?>[4, 5];
+ List<String?> list3 = <String?>[];
+ Set<int?> set1 = new Set<int?>();
+ set1..add(11)..add(12)..add(13);
+ Set set2 = new Set();
+
+ Expect.equals(2, list1.firstWhere((x) => x!.isEven));
+ Expect.equals(1, list1.firstWhere((x) => x!.isOdd));
+ Expect.throwsStateError(() => list1.firstWhere((x) => x! > 3));
+ Expect.equals(null, list1.firstWhere((x) => x! > 3, orElse: () => null));
+ Expect.equals(499, list1.firstWhere((x) => x! > 3, orElse: () => 499));
+
+ Expect.equals(4, list2.firstWhere((x) => x!.isEven));
+ Expect.equals(5, list2.firstWhere((x) => x!.isOdd));
+ Expect.throwsStateError(() => list2.firstWhere((x) => x == 0));
+ Expect.equals(null, list2.firstWhere((x) => false, orElse: () => null));
+ Expect.equals(499, list2.firstWhere((x) => false, orElse: () => 499));
+
+ Expect.throwsStateError(() => list3.firstWhere((x) => x == 0));
+ Expect.throwsStateError(() => list3.firstWhere((x) => true));
+ Expect.equals(null, list3.firstWhere((x) => true, orElse: () => null));
+ Expect.equals("str", list3.firstWhere((x) => false, orElse: () => "str"));
+
+ Expect.equals(12, set1.firstWhere((x) => x!.isEven));
+ var odd = set1.firstWhere((x) => x!.isOdd);
+ Expect.isTrue(odd == 11 || odd == 13);
+ Expect.throwsStateError(() => set1.firstWhere((x) => false));
+ Expect.equals(null, set1.firstWhere((x) => false, orElse: () => null));
+ Expect.equals(499, set1.firstWhere((x) => false, orElse: () => 499));
+
+ Expect.throwsStateError(() => set2.firstWhere((x) => false));
+ Expect.throwsStateError(() => set2.firstWhere((x) => true));
+ Expect.equals(null, set2.firstWhere((x) => true, orElse: () => null));
+ Expect.equals(499, set2.firstWhere((x) => false, orElse: () => 499));
+}
diff --git a/tests/corelib/iterable_fold_test.dart b/tests/corelib/iterable_fold_test.dart
new file mode 100644
index 0000000..b531ccc
--- /dev/null
+++ b/tests/corelib/iterable_fold_test.dart
@@ -0,0 +1,206 @@
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+import 'dart:collection';
+import 'dart:typed_data';
+
+class MyList extends ListBase {
+ List list;
+ MyList(this.list);
+
+ get length => list.length;
+ set length(val) {
+ list.length = val;
+ }
+
+ operator [](index) => list[index];
+ operator []=(index, val) => list[index] = val;
+}
+
+Iterable id(Iterable x) => x;
+
+main() {
+ for (dynamic iterable in [
+ const [1, 2, 3],
+ [1, 2, 3],
+ new List(3)
+ ..[0] = 1
+ ..[1] = 2
+ ..[2] = 3,
+ {1: 1, 2: 2, 3: 3}.keys,
+ {1: 1, 2: 2, 3: 3}.values,
+ new Iterable.generate(3, (x) => x + 1),
+ new List.generate(3, (x) => x + 1),
+ [0, 1, 2, 3].where((x) => x > 0),
+ [0, 1, 2].map((x) => x + 1),
+ [
+ [1, 2],
+ [3]
+ ].expand(id),
+ [3, 2, 1].reversed,
+ [0, 1, 2, 3].skip(1),
+ [1, 2, 3, 4].take(3),
+ new Uint8List(3)
+ ..[0] = 1
+ ..[1] = 2
+ ..[2] = 3,
+ (new HashMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3)
+ .keys,
+ (new HashMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3)
+ .values,
+ (new SplayTreeMap()
+ ..[1] = 0
+ ..[2] = 0
+ ..[3] = 0)
+ .keys,
+ (new SplayTreeMap()
+ ..[0] = 1
+ ..[1] = 2
+ ..[2] = 3)
+ .values,
+ new HashSet()..add(1)..add(2)..add(3),
+ new LinkedHashSet()..add(1)..add(2)..add(3),
+ new SplayTreeSet()..add(1)..add(2)..add(3),
+ "\x01\x02\x03".codeUnits,
+ "\x01\x02\x03".runes,
+ new MyList([1, 2, 3]),
+ ]) {
+ int callCount = 0;
+ var result = iterable.fold(0, (x, y) {
+ callCount++;
+ return x + y;
+ });
+ Expect.equals(6, result, "${iterable.runtimeType}");
+ Expect.equals(3, callCount);
+ }
+
+ // Empty iterables are allowed.
+ for (var iterable in [
+ const [],
+ [],
+ new List(0),
+ {}.keys,
+ {}.values,
+ new Iterable.generate(0, (x) => x + 1),
+ new List.generate(0, (x) => x + 1),
+ [0, 1, 2, 3].where((x) => false),
+ [].map((x) => x + 1),
+ [[], []].expand(id),
+ [].reversed,
+ [0, 1, 2, 3].skip(4),
+ [1, 2, 3, 4].take(0),
+ new Uint8List(0),
+ (new HashMap()).keys,
+ (new HashMap()).values,
+ (new SplayTreeMap()).keys,
+ (new SplayTreeMap()).values,
+ new HashSet(),
+ new LinkedHashSet(),
+ new SplayTreeSet(),
+ "".codeUnits,
+ "".runes,
+ new MyList([]),
+ ]) {
+ Expect.equals(42, iterable.fold(42, (x, y) => throw "Unreachable"));
+ }
+
+ // Singleton iterables are calling reduce function.
+ for (dynamic iterable in [
+ const [1],
+ [1],
+ new List(1)..[0] = 1,
+ {1: 1}.keys,
+ {1: 1}.values,
+ new Iterable.generate(1, (x) => x + 1),
+ new List.generate(1, (x) => x + 1),
+ [0, 1, 2, 3].where((x) => x == 1),
+ [0].map((x) => x + 1),
+ [
+ [],
+ [1]
+ ].expand(id),
+ [1].reversed,
+ [0, 1].skip(1),
+ [1, 2, 3, 4].take(1),
+ new Uint8List(1)..[0] = 1,
+ (new HashMap()..[1] = 0).keys,
+ (new HashMap()..[0] = 1).values,
+ (new SplayTreeMap()..[1] = 0).keys,
+ (new SplayTreeMap()..[0] = 1).values,
+ new HashSet()..add(1),
+ new LinkedHashSet()..add(1),
+ new SplayTreeSet()..add(1),
+ "\x01".codeUnits,
+ "\x01".runes,
+ new MyList([1]),
+ ]) {
+ Expect.equals(43, iterable.fold(42, (x, y) => x + y));
+ }
+
+ // Concurrent modifications not allowed.
+ testModification(base, modify, transform) {
+ var iterable = transform(base);
+ Expect.throws(() {
+ iterable.fold(0, (x, y) {
+ modify(base);
+ return x + y;
+ });
+ }, (e) => e is ConcurrentModificationError);
+ }
+
+ void add4(collection) {
+ collection.add(4);
+ }
+
+ void addListOf4(collection) {
+ collection.add([4]);
+ }
+
+ void put4(map) {
+ map[4] = 4;
+ }
+
+ testModification([1, 2, 3], add4, id);
+ testModification(new HashSet()..add(1)..add(2)..add(3), add4, id);
+ testModification(new LinkedHashSet()..add(1)..add(2)..add(3), add4, id);
+ testModification(new SplayTreeSet()..add(1)..add(2)..add(3), add4, id);
+ testModification(new MyList([1, 2, 3]), add4, id);
+
+ testModification([0, 1, 2, 3], add4, (x) => x.where((int x) => x > 0));
+ testModification([0, 1, 2], add4, (x) => x.map((x) => x + 1));
+ testModification([
+ [1, 2],
+ [3]
+ ], addListOf4, (x) => x.expand((List<int> x) => x));
+ testModification([3, 2, 1], add4, (x) => x.reversed);
+ testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.keys);
+ testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.values);
+ var hashMap = new HashMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3;
+ testModification(hashMap, put4, (x) => x.keys);
+ hashMap = new HashMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3;
+ testModification(hashMap, put4, (x) => x.values);
+ var splayMap = new SplayTreeMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3;
+ testModification(splayMap, put4, (x) => x.keys);
+ splayMap = new SplayTreeMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3;
+ testModification(splayMap, put4, (x) => x.values);
+}
diff --git a/tests/corelib/iterable_followed_by_test.dart b/tests/corelib/iterable_followed_by_test.dart
new file mode 100644
index 0000000..33a37c5
--- /dev/null
+++ b/tests/corelib/iterable_followed_by_test.dart
@@ -0,0 +1,102 @@
+// Copyright (c) 2018, 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.
+
+import "dart:collection" show Queue;
+import "dart:typed_data" show Int32List;
+
+import "package:expect/expect.dart";
+
+// Tests behavior of result of an operation on a followedBy iterable.
+test(List expects, Iterable iterable, [String? name]) {
+ try {
+ Expect.isFalse(iterable is List, "$name is! List");
+ Expect.isFalse(iterable is Set, "$name is! Set");
+ Expect.isFalse(iterable is Queue, "$name is! Queue");
+ if (expects.isNotEmpty) {
+ Expect.equals(expects.first, iterable.first, "$name: first");
+ Expect.equals(expects.last, iterable.last, "$name: last");
+ } else {
+ Expect.throwsStateError(() => iterable.first, "$name: first");
+ Expect.throwsStateError(() => iterable.last, "$name: last");
+ }
+ var it = iterable.iterator;
+ for (int index = 0; index < expects.length; index++) {
+ Expect.isTrue(it.moveNext(), "$name: has element $index");
+ var expect = expects[index];
+ Expect.equals(expect, it.current, "$name at $index");
+ Expect.equals(
+ expect, iterable.elementAt(index), "$name: elementAt($index)");
+ Expect.isTrue(iterable.contains(expect), "$name:contains $index");
+ }
+ Expect.isFalse(it.moveNext(),
+ "$name: extra element at ${expects.length}: ${it.current}");
+ } on Error {
+ print("Failed during: $name");
+ rethrow;
+ }
+}
+
+// Tests various operations on the a followedBy iterable.
+tests(List<int> expects, Iterable<int> follow, [String? name]) {
+ int length = expects.length;
+ test(expects, follow, name);
+ for (int i = 0; i <= length; i++) {
+ test(expects.sublist(i), follow.skip(i), "$name.skip($i)");
+ }
+ for (int i = 0; i <= length; i++) {
+ test(expects.sublist(0, i), follow.take(i), "$name.take($i)");
+ }
+ for (int i = 0; i <= length; i++) {
+ for (int j = 0; j <= length - i; j++) {
+ test(expects.sublist(i, i + j), follow.skip(i).take(j),
+ "$name.skiptake($i,${i+j})");
+ test(expects.sublist(i, i + j), follow.take(i + j).skip(i),
+ "$name.takeskip($i,${i+j})");
+ }
+ }
+}
+
+// Tests various different types of iterables as first and second operand.
+types(List<int> expects, List<int> first, List<int> second, String name) {
+ var conversions = <String, Iterable<int> Function(List<int>)>{
+ "const": toConst,
+ "list": toList,
+ "unmod": toUnmodifiable,
+ "set": toSet,
+ "queue": toQueue,
+ "eff-len-iter": toELIter,
+ "non-eff-iter": toNEIter,
+ "typed": toTyped,
+ "keys": toKeys,
+ "values": toValues,
+ };
+ conversions.forEach((n1, c1) {
+ conversions.forEach((n2, c2) {
+ tests(expects, c1(first).followedBy(c2(second)), "$name:$n1/$n2");
+ });
+ });
+}
+
+List<int> toConst(List<int> elements) => elements;
+List<int> toList(List<int> elements) => elements.toList();
+List<int> toUnmodifiable(List<int> elements) =>
+ new List<int>.unmodifiable(elements);
+Set<int> toSet(List<int> elements) => elements.toSet();
+Queue<int> toQueue(List<int> elements) => new Queue<int>.from(elements);
+// Creates an efficient-length iterable.
+Iterable<int> toELIter(List<int> elements) => elements.map<int>((x) => x);
+// Creates a non-efficient-length iterable.
+Iterable<int> toNEIter(List<int> elements) => elements.where((x) => true);
+List<int> toTyped(List<int> elements) => new Int32List.fromList(elements);
+Iterable<int> toKeys(List<int> elements) =>
+ new Map<int, int>.fromIterables(elements, elements).keys;
+Iterable<int> toValues(List<int> elements) =>
+ new Map<int, int>.fromIterables(elements, elements).values;
+
+main() {
+ types(<int>[], const <int>[], const <int>[], "0+0");
+ types(<int>[1, 2, 3, 4], const <int>[], const <int>[1, 2, 3, 4], "0+4");
+ types(<int>[1, 2, 3, 4], const <int>[1, 2], const <int>[3, 4], "2+2");
+ types(<int>[1, 2, 3, 4], const <int>[1, 2, 3, 4], const <int>[], "4+0");
+}
diff --git a/tests/corelib/iterable_generate_test.dart b/tests/corelib/iterable_generate_test.dart
new file mode 100644
index 0000000..201c2e4
--- /dev/null
+++ b/tests/corelib/iterable_generate_test.dart
@@ -0,0 +1,72 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ void test(expectedList, generatedIterable) {
+ Expect.equals(expectedList.length, generatedIterable.length);
+ Expect.listEquals(expectedList, generatedIterable.toList());
+ }
+
+ test([], new Iterable.generate(0));
+ test([0], new Iterable.generate(1));
+ test([0, 1, 2, 3, 4], new Iterable.generate(5));
+ test(["0", "1", "2", "3", "4"], new Iterable.generate(5, (x) => "$x"));
+ test([2, 3, 4, 5, 6], new Iterable.generate(7).skip(2));
+ test([0, 1, 2, 3, 4], new Iterable.generate(7).take(5));
+ test([], new Iterable.generate(5).skip(6));
+ test([], new Iterable.generate(5).take(0));
+ test([], new Iterable.generate(5).take(3).skip(3));
+ test([], new Iterable.generate(5).skip(6).take(0));
+
+ // Test types.
+
+ Iterable<int> it = new Iterable<int>.generate(5);
+ Expect.isTrue(it is Iterable<int>);
+ Expect.isTrue(it.iterator is Iterator<int>);
+ Expect.isTrue(it is! Iterable<String>);
+ Expect.isTrue(it.iterator is! Iterator<String>);
+ test([0, 1, 2, 3, 4], it);
+
+ Iterable<String> st = new Iterable<String>.generate(5, (x) => "$x");
+ Expect.isTrue(st is Iterable<String>);
+ Expect.isTrue(st.iterator is Iterator<String>);
+ Expect.isFalse(st is Iterable<int>);
+ Expect.isFalse(st.iterator is Iterator<int>);
+ test(["0", "1", "2", "3", "4"], st);
+
+ Expect.throws(() => new Iterable<String>.generate(5));
+
+ // Omitted generator function means `(int x) => x`, and the type parameters
+ // must then be compatible with `int`.
+ // Check that we catch invalid type parameters.
+
+ // Valid types:
+ Iterable<int> iter1 = new Iterable<int>.generate(5);
+ Expect.equals(2, iter1.elementAt(2));
+ Iterable<num> iter2 = new Iterable<num>.generate(5);
+ Expect.equals(2, iter2.elementAt(2));
+ Iterable<Object> iter3 = new Iterable<Object>.generate(5);
+ Expect.equals(2, iter3.elementAt(2));
+ Iterable<dynamic> iter4 = new Iterable<dynamic>.generate(5);
+ Expect.equals(2, iter4.elementAt(2));
+
+ // Invalid types:
+ Expect.throws(() => new Iterable<String>.generate(5));
+ Expect.throws(() => new Iterable<Null>.generate(5).elementAt(2)); //# 01: ok
+ Expect.throws(() => new Iterable<bool>.generate(5));
+
+ // Regression: https://github.com/dart-lang/sdk/issues/26358
+ var count = 0;
+ var iter = new Iterable.generate(5, (v) {
+ count++;
+ return v;
+ });
+ Expect.equals(0, count);
+ Expect.equals(2, iter.elementAt(2)); // Doesn't compute the earlier values.
+ Expect.equals(1, count);
+ Expect.equals(2, iter.skip(2).first); // Doesn't compute the skipped values.
+ Expect.equals(2, count);
+}
diff --git a/tests/corelib/iterable_join_test.dart b/tests/corelib/iterable_join_test.dart
new file mode 100644
index 0000000..2a6c67e
--- /dev/null
+++ b/tests/corelib/iterable_join_test.dart
@@ -0,0 +1,148 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+class IC {
+ int count = 0;
+ String toString() => "${count++}";
+}
+
+testJoin(String expect, Iterable iterable, [String? separator]) {
+ if (separator != null) {
+ Expect.equals(expect, iterable.join(separator));
+ } else {
+ Expect.equals(expect, iterable.join());
+ }
+}
+
+testCollections() {
+ testJoin("", [], ",");
+ testJoin("", [], "");
+ testJoin("", []);
+ testJoin("", new Set(), ",");
+ testJoin("", new Set(), "");
+ testJoin("", new Set());
+
+ testJoin("42", [42], ",");
+ testJoin("42", [42], "");
+ testJoin("42", [42]);
+ testJoin("42", new Set()..add(42), ",");
+ testJoin("42", new Set()..add(42), "");
+ testJoin("42", new Set()..add(42));
+
+ testJoin("a,b,c,d", ["a", "b", "c", "d"], ",");
+ testJoin("abcd", ["a", "b", "c", "d"], "");
+ testJoin("abcd", ["a", "b", "c", "d"]);
+ testJoin("null,b,c,d", [null, "b", "c", "d"], ",");
+ testJoin("1,2,3,4", [1, 2, 3, 4], ",");
+ var ic = new IC();
+ testJoin("0,1,2,3", [ic, ic, ic, ic], ",");
+
+ var set = new Set()..add(1)..add(2)..add(3);
+ var perm = new Set()
+ ..add("123")
+ ..add("132")
+ ..add("213")
+ ..add("231")
+ ..add("312")
+ ..add("321");
+ var setString = set.join();
+ Expect.isTrue(perm.contains(setString), "set: $setString");
+
+ void testArray(List<int> array) {
+ testJoin("1,3,5,7,9", array.where((i) => i.isOdd), ",");
+ testJoin("0,2,4,6,8,10,12,14,16,18", array.map((i) => i * 2), ",");
+ testJoin("5,6,7,8,9", array.skip(5), ",");
+ testJoin("5,6,7,8,9", array.skipWhile((i) => i < 5), ",");
+ testJoin("0,1,2,3,4", array.take(5), ",");
+ testJoin("0,1,2,3,4", array.takeWhile((i) => i < 5), ",");
+ }
+
+ testArray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+ var fixedArray = new List<int>.filled(10, -1);
+ for (int i = 0; i < 10; i++) {
+ fixedArray[i] = i;
+ }
+ testArray(fixedArray);
+ testArray(const [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+
+ testJoin("a,b,c,d", ["a", "b", "c", "d"].map((x) => x), ",");
+ testJoin("abcd", ["a", "b", "c", "d"].map((x) => x), "");
+ testJoin("abcd", ["a", "b", "c", "d"].map((x) => x));
+ testJoin("null,b,c,d", [null, "b", "c", "d"].map((x) => x), ",");
+ testJoin("1,2,3,4", [1, 2, 3, 4].map((x) => x), ",");
+ testJoin("4,5,6,7", [ic, ic, ic, ic].map((x) => x), ",");
+}
+
+void testStringVariants() {
+ // ASCII
+ testJoin("axbxcxd", ["a", "b", "c", "d"], "x");
+ testJoin("a\u2000b\u2000c\u2000d", ["a", "b", "c", "d"], "\u2000");
+ testJoin("abcd", ["a", "b", "c", "d"], "");
+ testJoin("abcd", ["a", "b", "c", "d"]);
+ // Non-ASCII
+ testJoin("axbxcx\u2000", ["a", "b", "c", "\u2000"], "x");
+ testJoin("a\u2000b\u2000c\u2000\u2000", ["a", "b", "c", "\u2000"], "\u2000");
+ testJoin("abc\u2000", ["a", "b", "c", "\u2000"], "");
+ testJoin("abc\u2000", ["a", "b", "c", "\u2000"]);
+ // Long-ASCII
+ testJoin("ax" * 255 + "a", new List.generate(256, (_) => "a"), "x");
+ testJoin("a" * 256, new List.generate(256, (_) => "a"));
+ // Long-Non-ASCII
+ testJoin("a\u2000" * 255 + "a", new List.generate(256, (_) => "a"), "\u2000");
+ testJoin("\u2000" * 256, new List.generate(256, (_) => "\u2000"));
+ testJoin(
+ "\u2000x" * 255 + "\u2000", new List.generate(256, (_) => "\u2000"), "x");
+
+ var o1 = new Stringable("x");
+ var o2 = new Stringable("\ufeff");
+ testJoin("xa" * 3 + "x", [o1, o1, o1, o1], "a");
+ testJoin("x" * 4, [o1, o1, o1, o1], "");
+ testJoin("x" * 4, [o1, o1, o1, o1]);
+
+ testJoin("\ufeffx" * 3 + "\ufeff", [o2, o2, o2, o2], "x");
+ testJoin("\ufeff" * 4, [o2, o2, o2, o2], "");
+ testJoin("\ufeff" * 4, [o2, o2, o2, o2]);
+
+ testJoin("a\u2000x\ufeff", ["a", "\u2000", o1, o2]);
+ testJoin("a\u2000\ufeffx", ["a", "\u2000", o2, o1]);
+ testJoin("ax\u2000\ufeff", ["a", o1, "\u2000", o2]);
+ testJoin("ax\ufeff\u2000", ["a", o1, o2, "\u2000"]);
+ testJoin("a\ufeffx\u2000", ["a", o2, o1, "\u2000"]);
+ testJoin("a\ufeff\u2000x", ["a", o2, "\u2000", o1]);
+
+ testJoin("\u2000ax\ufeff", ["\u2000", "a", o1, o2]);
+ testJoin("\u2000a\ufeffx", ["\u2000", "a", o2, o1]);
+ testJoin("xa\u2000\ufeff", [o1, "a", "\u2000", o2]);
+ testJoin("xa\ufeff\u2000", [o1, "a", o2, "\u2000"]);
+ testJoin("\ufeffax\u2000", [o2, "a", o1, "\u2000"]);
+ testJoin("\ufeffa\u2000x", [o2, "a", "\u2000", o1]);
+
+ testJoin("\u2000xa\ufeff", ["\u2000", o1, "a", o2]);
+ testJoin("\u2000\ufeffax", ["\u2000", o2, "a", o1]);
+ testJoin("x\u2000a\ufeff", [o1, "\u2000", "a", o2]);
+ testJoin("x\ufeffa\u2000", [o1, o2, "a", "\u2000"]);
+ testJoin("\ufeffxa\u2000", [o2, o1, "a", "\u2000"]);
+ testJoin("\ufeff\u2000ax", [o2, "\u2000", "a", o1]);
+
+ testJoin("\u2000x\ufeffa", ["\u2000", o1, o2, "a"]);
+ testJoin("\u2000\ufeffxa", ["\u2000", o2, o1, "a"]);
+ testJoin("x\u2000\ufeffa", [o1, "\u2000", o2, "a"]);
+ testJoin("x\ufeff\u2000a", [o1, o2, "\u2000", "a"]);
+ testJoin("\ufeffx\u2000a", [o2, o1, "\u2000", "a"]);
+ testJoin("\ufeff\u2000xa", [o2, "\u2000", o1, "a"]);
+}
+
+class Stringable {
+ final String value;
+ Stringable(this.value);
+ String toString() => value;
+}
+
+main() {
+ testCollections();
+ testStringVariants();
+ // TODO(lrn): test scalar lists.
+}
diff --git a/tests/corelib/iterable_last_test.dart b/tests/corelib/iterable_last_test.dart
new file mode 100644
index 0000000..356d8b6
--- /dev/null
+++ b/tests/corelib/iterable_last_test.dart
@@ -0,0 +1,22 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 5];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(11)..add(12)..add(13);
+ Set set2 = new Set();
+
+ Expect.equals(3, list1.last);
+ Expect.equals(5, list2.last);
+ Expect.throwsStateError(() => list3.last);
+
+ Expect.isTrue(set1.contains(set1.last));
+
+ Expect.throwsStateError(() => set2.last);
+}
diff --git a/tests/corelib/iterable_last_where_test.dart b/tests/corelib/iterable_last_where_test.dart
new file mode 100644
index 0000000..92e1d9d
--- /dev/null
+++ b/tests/corelib/iterable_last_where_test.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2012, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ List<int?> list1 = <int?>[1, 2, 3];
+ List<int?> list2 = const <int?>[4, 5, 6];
+ List<String?> list3 = <String?>[];
+ Set<int?> set1 = new Set<int?>();
+ set1..add(11)..add(12)..add(13);
+ Set set2 = new Set();
+
+ Expect.equals(2, list1.lastWhere((x) => x!.isEven));
+ Expect.equals(3, list1.lastWhere((x) => x!.isOdd));
+ Expect.throwsStateError(() => list1.lastWhere((x) => x! > 3));
+ Expect.equals(null, list1.lastWhere((x) => x! > 3, orElse: () => null));
+ Expect.equals(499, list1.lastWhere((x) => x! > 3, orElse: () => 499));
+
+ Expect.equals(6, list2.lastWhere((x) => x!.isEven));
+ Expect.equals(5, list2.lastWhere((x) => x!.isOdd));
+ Expect.throwsStateError(() => list2.lastWhere((x) => x == 0));
+ Expect.equals(null, list2.lastWhere((x) => false, orElse: () => null));
+ Expect.equals(499, list2.lastWhere((x) => false, orElse: () => 499));
+
+ Expect.throwsStateError(() => list3.lastWhere((x) => x == 0));
+ Expect.throwsStateError(() => list3.lastWhere((x) => true));
+ Expect.equals(null, list3.lastWhere((x) => true, orElse: () => null));
+ Expect.equals("str", list3.lastWhere((x) => false, orElse: () => "str"));
+
+ Expect.equals(12, set1.lastWhere((x) => x!.isEven));
+ var odd = set1.lastWhere((x) => x!.isOdd);
+ Expect.isTrue(odd == 11 || odd == 13);
+ Expect.throwsStateError(() => set1.lastWhere((x) => false));
+ Expect.equals(null, set1.lastWhere((x) => false, orElse: () => null));
+ Expect.equals(499, set1.lastWhere((x) => false, orElse: () => 499));
+
+ Expect.throwsStateError(() => set2.lastWhere((x) => false));
+ Expect.throwsStateError(() => set2.lastWhere((x) => true));
+ Expect.equals(null, set2.lastWhere((x) => true, orElse: () => null));
+ Expect.equals(499, set2.lastWhere((x) => false, orElse: () => 499));
+}
diff --git a/tests/corelib/iterable_length_test.dart b/tests/corelib/iterable_length_test.dart
new file mode 100644
index 0000000..b43775f
--- /dev/null
+++ b/tests/corelib/iterable_length_test.dart
@@ -0,0 +1,44 @@
+// Copyright (c) 2012, 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.
+
+import "dart:collection";
+import "package:expect/expect.dart";
+
+class A extends IterableBase {
+ int count;
+ A(this.count);
+
+ Iterator get iterator {
+ return new AIterator(count);
+ }
+}
+
+class AIterator implements Iterator {
+ int _count;
+ int? _current;
+
+ AIterator(this._count);
+
+ bool moveNext() {
+ if (_count > 0) {
+ _current = _count;
+ _count--;
+ return true;
+ }
+ _current = null;
+ return false;
+ }
+
+ get current => _current;
+}
+
+main() {
+ var a = new A(10);
+ Expect.equals(10, a.length);
+ a = new A(0);
+ Expect.equals(0, a.length);
+ a = new A(5);
+ Expect.equals(5, a.map((e) => e + 1).length);
+ Expect.equals(3, a.where((e) => e >= 3).length);
+}
diff --git a/tests/corelib/iterable_mapping_test.dart b/tests/corelib/iterable_mapping_test.dart
new file mode 100644
index 0000000..4f06c2c
--- /dev/null
+++ b/tests/corelib/iterable_mapping_test.dart
@@ -0,0 +1,50 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 5];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1.addAll([11, 12, 13]);
+ Set set2 = new Set();
+
+ Iterable mapped = list1.map((x) => x + 1);
+ Expect.listEquals([2, 3, 4], mapped.toList());
+
+ mapped = mapped.map((x) => x + 1);
+ Expect.listEquals([3, 4, 5], mapped.toList());
+
+ mapped = list2.map((x) => x + 1);
+ Expect.listEquals([5, 6], mapped.toList());
+
+ mapped = mapped.map((x) => x + 1);
+ Expect.listEquals([6, 7], mapped.toList());
+
+ mapped = list3.map((x) => x + 1); //# 01: compile-time error
+ Expect.listEquals([], mapped.toList()); //# 01: continued
+
+ mapped = mapped.map((x) => x + 1); //# 01: continued
+ Expect.listEquals([], mapped.toList()); //# 01: continued
+
+ var expected = new Set<int>()..addAll([12, 13, 14]);
+ mapped = set1.map((x) => x + 1);
+ Expect.isFalse(mapped is List);
+ Expect.setEquals(expected, mapped.toSet());
+
+ expected = new Set<int>()..addAll([13, 14, 15]);
+ mapped = mapped.map((x) => x + 1);
+ Expect.isFalse(mapped is List);
+ Expect.setEquals(expected, mapped.toSet());
+
+ mapped = set2.map((x) => x + 1);
+ Expect.isFalse(mapped is List);
+ Expect.listEquals([], mapped.toList());
+
+ mapped = mapped.map((x) => x + 1);
+ Expect.isFalse(mapped is List);
+ Expect.listEquals([], mapped.toList());
+}
diff --git a/tests/corelib/iterable_reduce_test.dart b/tests/corelib/iterable_reduce_test.dart
new file mode 100644
index 0000000..6ee66d0
--- /dev/null
+++ b/tests/corelib/iterable_reduce_test.dart
@@ -0,0 +1,210 @@
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+import 'dart:collection';
+import 'dart:typed_data';
+
+class MyList extends ListBase {
+ List list;
+ MyList(this.list);
+
+ get length => list.length;
+ set length(val) {
+ list.length = val;
+ }
+
+ operator [](index) => list[index];
+ operator []=(index, val) => list[index] = val;
+}
+
+Iterable id(Iterable x) => x;
+
+main() {
+ // Test functionality.
+ for (dynamic iterable in [
+ const [1, 2, 3],
+ [1, 2, 3],
+ new List(3)
+ ..[0] = 1
+ ..[1] = 2
+ ..[2] = 3,
+ {1: 1, 2: 2, 3: 3}.keys,
+ {1: 1, 2: 2, 3: 3}.values,
+ new Iterable.generate(3, (x) => x + 1),
+ new List.generate(3, (x) => x + 1),
+ [0, 1, 2, 3].where((x) => x > 0),
+ [0, 1, 2].map((x) => x + 1),
+ [
+ [1, 2],
+ [3]
+ ].expand(id),
+ [3, 2, 1].reversed,
+ [0, 1, 2, 3].skip(1),
+ [1, 2, 3, 4].take(3),
+ new Uint8List(3)
+ ..[0] = 1
+ ..[1] = 2
+ ..[2] = 3,
+ (new HashMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3)
+ .keys,
+ (new HashMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3)
+ .values,
+ (new SplayTreeMap()
+ ..[1] = 0
+ ..[2] = 0
+ ..[3] = 0)
+ .keys,
+ (new SplayTreeMap()
+ ..[0] = 1
+ ..[1] = 2
+ ..[2] = 3)
+ .values,
+ new HashSet()..add(1)..add(2)..add(3),
+ new LinkedHashSet()..add(1)..add(2)..add(3),
+ new SplayTreeSet()..add(1)..add(2)..add(3),
+ "\x01\x02\x03".codeUnits,
+ "\x01\x02\x03".runes,
+ new MyList([1, 2, 3]),
+ ]) {
+ int callCount = 0;
+ var result = iterable.reduce((x, y) {
+ callCount++;
+ // Return type of reduce() callback should match element type.
+ return (x + y) as int;
+ });
+ Expect.equals(6, result, "${iterable.runtimeType}");
+ Expect.equals(2, callCount);
+ }
+
+ // Empty iterables not allowed.
+ for (var iterable in [
+ const [],
+ [],
+ new List(0),
+ {}.keys,
+ {}.values,
+ new Iterable.generate(0, (x) => x + 1),
+ new List.generate(0, (x) => x + 1),
+ [0, 1, 2, 3].where((x) => false),
+ [].map((x) => x + 1),
+ [[], []].expand(id),
+ [].reversed,
+ [0, 1, 2, 3].skip(4),
+ [1, 2, 3, 4].take(0),
+ new Uint8List(0),
+ (new HashMap()).keys,
+ (new HashMap()).values,
+ (new SplayTreeMap()).keys,
+ (new SplayTreeMap()).values,
+ new HashSet(),
+ new LinkedHashSet(),
+ new SplayTreeSet(),
+ "".codeUnits,
+ "".runes,
+ new MyList([]),
+ ]) {
+ Expect
+ .throwsStateError(() => iterable.reduce((x, y) => throw "Unreachable"));
+ }
+
+ // Singleton iterables not calling reduce function.
+ for (dynamic iterable in [
+ const [1],
+ [1],
+ new List(1)..[0] = 1,
+ {1: 1}.keys,
+ {1: 1}.values,
+ new Iterable.generate(1, (x) => x + 1),
+ new List.generate(1, (x) => x + 1),
+ [0, 1, 2, 3].where((x) => x == 1),
+ [0].map((x) => x + 1),
+ [
+ [],
+ [1]
+ ].expand(id),
+ [1].reversed,
+ [0, 1].skip(1),
+ [1, 2, 3, 4].take(1),
+ new Uint8List(1)..[0] = 1,
+ (new HashMap()..[1] = 0).keys,
+ (new HashMap()..[0] = 1).values,
+ (new SplayTreeMap()..[1] = 0).keys,
+ (new SplayTreeMap()..[0] = 1).values,
+ new HashSet()..add(1),
+ new LinkedHashSet()..add(1),
+ new SplayTreeSet()..add(1),
+ "\x01".codeUnits,
+ "\x01".runes,
+ new MyList([1]),
+ ]) {
+ Expect.equals(1, iterable.reduce((x, y) => throw "Unreachable"));
+ }
+
+ // Concurrent modifications not allowed.
+ testModification(base, modify, transform) {
+ var iterable = transform(base);
+ Expect.throws(() {
+ iterable.reduce((x, y) {
+ modify(base);
+ // Return type of reduce() callback should match element type.
+ return (x + y) as int;
+ });
+ }, (e) => e is ConcurrentModificationError);
+ }
+
+ void add4(collection) {
+ collection.add(4);
+ }
+
+ void addListOf4(collection) {
+ collection.add([4]);
+ }
+
+ void put4(map) {
+ map[4] = 4;
+ }
+
+ testModification([1, 2, 3], add4, id);
+ testModification(new HashSet()..add(1)..add(2)..add(3), add4, id);
+ testModification(new LinkedHashSet()..add(1)..add(2)..add(3), add4, id);
+ testModification(new SplayTreeSet()..add(1)..add(2)..add(3), add4, id);
+ testModification(new MyList([1, 2, 3]), add4, id);
+
+ testModification([0, 1, 2, 3], add4, (x) => x.where((int x) => x > 0));
+ testModification([0, 1, 2], add4, (x) => x.map((x) => x + 1));
+ testModification([
+ [1, 2],
+ [3]
+ ], addListOf4, (x) => x.expand((List<int> x) => x));
+ testModification([3, 2, 1], add4, (x) => x.reversed);
+ testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.keys);
+ testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.values);
+ var hashMap = new HashMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3;
+ testModification(hashMap, put4, (x) => x.keys);
+ hashMap = new HashMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3;
+ testModification(hashMap, put4, (x) => x.values);
+ var splayMap = new SplayTreeMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3;
+ testModification(splayMap, put4, (x) => x.keys);
+ splayMap = new SplayTreeMap()
+ ..[1] = 1
+ ..[2] = 2
+ ..[3] = 3;
+ testModification(splayMap, put4, (x) => x.values);
+}
diff --git a/tests/corelib/iterable_return_type_test.dart b/tests/corelib/iterable_return_type_test.dart
new file mode 100644
index 0000000..9be3513
--- /dev/null
+++ b/tests/corelib/iterable_return_type_test.dart
@@ -0,0 +1,90 @@
+// Copyright (c) 2013, 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.
+
+// Regression test for dart2js where [List.addAll] was not typed
+// correctly.
+
+import "package:expect/expect.dart";
+
+import 'dart:collection';
+import 'dart:typed_data';
+
+testIntIterable(iterable) {
+ Expect.isTrue(iterable is Iterable<int>, "${iterable.runtimeType}");
+ Expect.isFalse(iterable is Iterable<String>, "${iterable.runtimeType}");
+}
+
+void testIterable(Iterable<int> iterable, [int depth = 3]) {
+ testIntIterable(iterable);
+ if (depth > 0) {
+ testIterable(iterable.where((x) => true), depth - 1);
+ testIterable(iterable.skip(1), depth - 1);
+ testIterable(iterable.take(1), depth - 1);
+ testIterable(iterable.skipWhile((x) => false), depth - 1);
+ testIterable(iterable.takeWhile((x) => true), depth - 1);
+ testList(iterable.toList(growable: true), depth - 1);
+ testList(iterable.toList(growable: false), depth - 1);
+ testIterable(iterable.toSet(), depth - 1);
+ }
+}
+
+void testList(List<int> list, [int depth = 3]) {
+ testIterable(list, depth);
+ if (depth > 0) {
+ testIterable(list.getRange(0, list.length), depth - 1);
+ testIterable(list.reversed, depth - 1);
+ testMap(list.asMap(), depth - 1);
+ }
+}
+
+void testMap(Map<int, int> map, [int depth = 3]) {
+ Expect.isTrue(map is Map<int, int>);
+ Expect.isFalse(map is Map<int, String>);
+ Expect.isFalse(map is Map<String, int>);
+ if (depth > 0) {
+ testIterable(map.keys, depth - 1);
+ testIterable(map.values, depth - 1);
+ }
+}
+
+main() {
+ // Empty lists.
+ testList(<int>[]);
+ testList(new List<int>.empty());
+ testList(new List<int>());
+ testList(const <int>[]);
+ testList(new List<int>.generate(0, (x) => x + 1));
+ // Singleton lists.
+ testList(<int>[1]);
+ testList(new List<int>.filled(1, 1));
+ testList(new List<int>()..add(1));
+ testList(const <int>[1]);
+ testList(new List<int>.generate(1, (x) => x + 1));
+
+ // Typed lists.
+ testList(new Uint8List(1)..[0] = 1); // //# 01: ok
+ testList(new Int8List(1)..[0] = 1); // //# 01: continued
+ testList(new Uint16List(1)..[0] = 1); // //# 01: continued
+ testList(new Int16List(1)..[0] = 1); // //# 01: continued
+ testList(new Uint32List(1)..[0] = 1); // //# 01: continued
+ testList(new Int32List(1)..[0] = 1); // //# 01: continued
+ testList(new Uint64List(1)..[0] = 1); // //# 02: ok
+ testList(new Int64List(1)..[0] = 1); // //# 02: continued
+
+ testIterable(new Set<int>()..add(1));
+ testIterable(new HashSet<int>()..add(1));
+ testIterable(new LinkedHashSet<int>()..add(1));
+ testIterable(new SplayTreeSet<int>()..add(1));
+
+ testIterable(new Queue<int>()..add(1));
+ testIterable(new DoubleLinkedQueue<int>()..add(1));
+ testIterable(new ListQueue<int>()..add(1));
+
+ testMap(new Map<int, int>()..[1] = 1);
+ testMap(new HashMap<int, int>()..[1] = 1);
+ testMap(new LinkedHashMap<int, int>()..[1] = 1);
+ testMap(new SplayTreeMap<int, int>()..[1] = 1);
+ testMap(<int, int>{1: 1});
+ testMap(const <int, int>{1: 1});
+}
diff --git a/tests/corelib/iterable_single_test.dart b/tests/corelib/iterable_single_test.dart
new file mode 100644
index 0000000..d0f5d3a
--- /dev/null
+++ b/tests/corelib/iterable_single_test.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ List<int> list1a = <int>[1];
+ List<int> list1b = <int>[1, 2, 3];
+ List<int> list1c = <int>[];
+ List<int> list2a = const <int>[5];
+ List<int> list2b = const <int>[4, 5];
+ List<int> list2c = const <int>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(22);
+ Set set2 = new Set();
+ set2..add(11)..add(12)..add(13);
+ Set set3 = new Set();
+
+ Expect.equals(1, list1a.single);
+ Expect.throwsStateError(() => list1b.single);
+ Expect.throwsStateError(() => list1c.single);
+
+ Expect.equals(5, list2a.single);
+ Expect.throwsStateError(() => list2b.single);
+ Expect.throwsStateError(() => list2c.single);
+
+ Expect.equals(22, set1.single);
+ Expect.throwsStateError(() => set2.single);
+ Expect.throwsStateError(() => set3.single);
+}
diff --git a/tests/corelib/iterable_single_where_test.dart b/tests/corelib/iterable_single_where_test.dart
new file mode 100644
index 0000000..9ecbe05
--- /dev/null
+++ b/tests/corelib/iterable_single_where_test.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2012, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 5, 6];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(11)..add(12)..add(13);
+ Set set2 = new Set();
+
+ Expect.equals(2, list1.singleWhere((x) => x.isEven));
+ Expect.equals(3, list1.singleWhere((x) => x == 3));
+ Expect.throwsStateError(() => list1.singleWhere((x) => x.isOdd));
+
+ Expect.equals(6, list2.singleWhere((x) => x == 6));
+ Expect.equals(5, list2.singleWhere((x) => x.isOdd));
+ Expect.throwsStateError(() => list2.singleWhere((x) => x.isEven));
+
+ Expect.throwsStateError(() => list3.singleWhere((x) => x == 0));
+
+ Expect.equals(12, set1.singleWhere((x) => x.isEven));
+ Expect.equals(11, set1.singleWhere((x) => x == 11));
+ Expect.throwsStateError(() => set1.singleWhere((x) => x.isOdd));
+
+ Expect.throwsStateError(() => set2.singleWhere((x) => true));
+}
diff --git a/tests/corelib/iterable_skip_test.dart b/tests/corelib/iterable_skip_test.dart
new file mode 100644
index 0000000..06fb801
--- /dev/null
+++ b/tests/corelib/iterable_skip_test.dart
@@ -0,0 +1,257 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 5];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(11)..add(12)..add(13);
+ Set set2 = new Set();
+
+ Iterable<int> skip0 = list1.skip(0);
+ Expect.isTrue(skip0 is! List);
+ Iterator<int> it = skip0.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skip1 = list1.skip(1);
+ Expect.isTrue(skip1 is! List);
+ Expect.isTrue(skip1.skip(2).skip(1) is! List);
+ it = skip1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skip2 = list1.skip(2);
+ Expect.isTrue(skip2 is! List);
+ Expect.isTrue(skip2.skip(2).skip(1) is! List);
+ it = skip2.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skip3 = list1.skip(3);
+ Expect.isTrue(skip3 is! List);
+ Expect.isTrue(skip3.skip(2).skip(1) is! List);
+ it = skip3.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skip4 = list1.skip(4);
+ Expect.isTrue(skip4 is! List);
+ Expect.isTrue(skip4.skip(2).skip(1) is! List);
+ it = skip4.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip0 = list1.skip(0);
+ skip1 = skip0.skip(1);
+ skip2 = skip1.skip(1);
+ skip3 = skip2.skip(1);
+ skip4 = skip3.skip(1);
+ it = skip0.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = skip1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = skip2.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = skip3.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = skip4.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip0 = list2.skip(0);
+ Expect.isTrue(skip0 is! List);
+ Expect.isTrue(skip0.skip(2).skip(1) is! List);
+ it = skip0.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(4, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(5, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip1 = list2.skip(1);
+ Expect.isTrue(skip1 is! List);
+ Expect.isTrue(skip1.skip(2).skip(1) is! List);
+ it = skip1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(5, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip2 = list2.skip(2);
+ Expect.isTrue(skip2 is! List);
+ Expect.isTrue(skip2.skip(2).skip(1) is! List);
+ it = skip2.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip3 = list2.skip(3);
+ Expect.isTrue(skip3 is! List);
+ Expect.isTrue(skip3.skip(2).skip(1) is! List);
+ it = skip3.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<String> skip02 = list3.skip(0);
+ Expect.isTrue(skip02 is! List);
+ Expect.isTrue(skip02.skip(2).skip(1) is! List);
+ Iterator<String> it2 = skip02.iterator;
+ Expect.isNull(it2.current);
+ Expect.isFalse(it2.moveNext());
+ Expect.isNull(it2.current);
+
+ Iterable<String> skip12 = list3.skip(1);
+ Expect.isTrue(skip12 is! List);
+ Expect.isTrue(skip12.skip(2).skip(1) is! List);
+ it2 = skip12.iterator;
+ Expect.isNull(it2.current);
+ Expect.isFalse(it2.moveNext());
+ Expect.isNull(it2.current);
+
+ skip0 = set1.skip(0);
+ List<int> copied = skip0.toList();
+ Expect.equals(3, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ Expect.isTrue(set1.contains(copied[1]));
+ Expect.isTrue(set1.contains(copied[2]));
+ Expect.isTrue(copied[0] != copied[1]);
+ Expect.isTrue(copied[0] != copied[2]);
+ Expect.isTrue(copied[1] != copied[2]);
+ it = skip0.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip1 = set1.skip(1);
+ copied = skip1.toList();
+ Expect.equals(2, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ Expect.isTrue(set1.contains(copied[1]));
+ Expect.isTrue(copied[0] != copied[1]);
+ it = skip1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip2 = set1.skip(2);
+ copied = skip2.toList();
+ Expect.equals(1, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ it = skip2.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip3 = set1.skip(3);
+ it = skip3.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip4 = set1.skip(4);
+ it = skip4.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ var dynamicSkip0 = set2.skip(0);
+ var dynamicIt = dynamicSkip0.iterator;
+ Expect.isNull(dynamicIt.current);
+ Expect.isFalse(dynamicIt.moveNext());
+ Expect.isNull(dynamicIt.current);
+
+ var dynamicSkip1 = set2.skip(1);
+ dynamicIt = dynamicSkip1.iterator;
+ Expect.isNull(dynamicIt.current);
+ Expect.isFalse(dynamicIt.moveNext());
+ Expect.isNull(dynamicIt.current);
+
+ testSkipTake(Iterable input, int skip, int take) {
+ List expected = [];
+ Iterator iter = input.iterator;
+ for (int i = 0; i < skip; i++) iter.moveNext();
+ for (int i = 0; i < take; i++) {
+ if (!iter.moveNext()) break;
+ expected.add(iter.current);
+ }
+ Expect.listEquals(expected, input.skip(skip).take(take).toList());
+ }
+
+ List longList = [1, 4, 5, 3, 8, 11, 12, 6, 9, 10, 13, 7, 2, 14, 15];
+ Set bigSet = longList.toSet();
+
+ for (Iterable collection in [longList, longList.reversed, bigSet]) {
+ testSkipTake(collection, 0, 0);
+ testSkipTake(collection, 0, 5);
+ testSkipTake(collection, 0, 15);
+ testSkipTake(collection, 0, 25);
+ testSkipTake(collection, 5, 0);
+ testSkipTake(collection, 5, 5);
+ testSkipTake(collection, 5, 10);
+ testSkipTake(collection, 5, 20);
+ testSkipTake(collection, 15, 0);
+ testSkipTake(collection, 15, 5);
+ testSkipTake(collection, 20, 0);
+ testSkipTake(collection, 20, 5);
+ Expect.throwsRangeError(() => longList.skip(-1));
+ }
+}
diff --git a/tests/corelib/iterable_skip_while_test.dart b/tests/corelib/iterable_skip_while_test.dart
new file mode 100644
index 0000000..d372122
--- /dev/null
+++ b/tests/corelib/iterable_skip_while_test.dart
@@ -0,0 +1,146 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 5];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(11)..add(12)..add(13);
+ Set set2 = new Set();
+
+ Iterable<int> skipWhileTrue = list1.skipWhile((x) => true);
+ Iterator<int> it = skipWhileTrue.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skipWhileOdd = list1.skipWhile((x) => x.isOdd);
+ it = skipWhileOdd.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skipWhileLessThan3 = list1.skipWhile((x) => x < 3);
+ it = skipWhileLessThan3.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skipWhileFalse = list1.skipWhile((x) => false);
+ it = skipWhileFalse.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skipWhileEven = list1.skipWhile((x) => x.isEven);
+ it = skipWhileEven.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skipWhileTrue = list2.skipWhile((x) => true);
+ it = skipWhileTrue.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skipWhileEven = list2.skipWhile((x) => x.isEven);
+ it = skipWhileEven.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(5, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skipWhileOdd = list2.skipWhile((x) => x.isOdd);
+ it = skipWhileOdd.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(4, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(5, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skipWhileFalse = list2.skipWhile((x) => false);
+ it = skipWhileFalse.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(4, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(5, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<String> skipWhileFalse2 = list3.skipWhile((x) => false);
+ Iterator<String> it2 = skipWhileFalse2.iterator;
+ Expect.isNull(it2.current);
+ Expect.isFalse(it2.moveNext());
+ Expect.isNull(it2.current);
+
+ Iterable<String> skipWhileTrue2 = list3.skipWhile((x) => true);
+ it2 = skipWhileTrue2.iterator;
+ Expect.isNull(it2.current);
+ Expect.isFalse(it2.moveNext());
+ Expect.isNull(it2.current);
+
+ skipWhileTrue = set1.skipWhile((x) => true);
+ it = skipWhileTrue.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skipWhileFalse = set1.skipWhile((x) => false);
+ List<int> copied = skipWhileFalse.toList();
+ Expect.equals(3, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ Expect.isTrue(set1.contains(copied[1]));
+ Expect.isTrue(set1.contains(copied[1]));
+ Expect.isTrue(copied[0] != copied[1]);
+ Expect.isTrue(copied[0] != copied[2]);
+ Expect.isTrue(copied[1] != copied[2]);
+ it = skipWhileFalse.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isTrue(it.current != null);
+ Expect.isTrue(it.moveNext());
+ Expect.isTrue(it.current != null);
+ Expect.isTrue(it.moveNext());
+ Expect.isTrue(it.current != null);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ var dynamicSkipWhileTrue = set2.skipWhile((x) => true);
+ var dynamicIt = dynamicSkipWhileTrue.iterator;
+ Expect.isNull(dynamicIt.current);
+ Expect.isFalse(dynamicIt.moveNext());
+ Expect.isNull(dynamicIt.current);
+
+ var dynamicSkipWhileFalse = set2.skipWhile((x) => false);
+ dynamicIt = dynamicSkipWhileFalse.iterator;
+ Expect.isNull(dynamicIt.current);
+ Expect.isFalse(dynamicIt.moveNext());
+ Expect.isNull(dynamicIt.current);
+}
diff --git a/tests/corelib/iterable_take_test.dart b/tests/corelib/iterable_take_test.dart
new file mode 100644
index 0000000..fccb5a2
--- /dev/null
+++ b/tests/corelib/iterable_take_test.dart
@@ -0,0 +1,227 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 5];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(11)..add(12)..add(13);
+ Set set2 = new Set();
+
+ Iterable<int> take0 = list1.take(0);
+ Iterator<int> it = take0.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> take1 = list1.take(1);
+ it = take1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> take2 = list1.take(2);
+ it = take2.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> take3 = list1.take(3);
+ it = take3.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> take4 = list1.take(4);
+ it = take4.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ take4 = list1.take(4);
+ take3 = take4.take(3);
+ take2 = take3.take(2);
+ take1 = take2.take(1);
+ take0 = take1.take(0);
+ it = take0.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = take1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = take2.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = take3.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = take4.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ take0 = list2.take(0);
+ it = take0.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ take1 = list2.take(1);
+ it = take1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(4, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ take2 = list2.take(2);
+ it = take2.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(4, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(5, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ take3 = list2.take(3);
+ it = take3.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(4, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(5, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<String> take02 = list3.take(0);
+ Iterator<String> it2 = take02.iterator;
+ Expect.isNull(it2.current);
+ Expect.isFalse(it2.moveNext());
+ Expect.isNull(it2.current);
+
+ Iterable<String> take12 = list3.take(1);
+ it2 = take12.iterator;
+ Expect.isNull(it2.current);
+ Expect.isFalse(it2.moveNext());
+ Expect.isNull(it2.current);
+
+ take0 = set1.take(0);
+ it = take0.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ take1 = set1.take(1);
+ List<int> copied = take1.toList();
+ Expect.equals(1, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ it = take1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ take2 = set1.take(2);
+ copied = take2.toList();
+ Expect.equals(2, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ Expect.isTrue(set1.contains(copied[1]));
+ Expect.isTrue(copied[0] != copied[1]);
+ it = take2.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ take3 = set1.take(3);
+ copied = take3.toList();
+ Expect.equals(3, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ Expect.isTrue(set1.contains(copied[1]));
+ Expect.isTrue(set1.contains(copied[2]));
+ Expect.isTrue(copied[0] != copied[1]);
+ Expect.isTrue(copied[0] != copied[2]);
+ Expect.isTrue(copied[1] != copied[2]);
+ it = take3.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ var dynamicTake0 = set2.take(0);
+ var dynamicIt = dynamicTake0.iterator;
+ Expect.isNull(dynamicIt.current);
+ Expect.isFalse(dynamicIt.moveNext());
+ Expect.isNull(dynamicIt.current);
+
+ var dynamicTake1 = set2.take(1);
+ dynamicIt = dynamicTake1.iterator;
+ Expect.isNull(dynamicIt.current);
+ Expect.isFalse(dynamicIt.moveNext());
+ Expect.isNull(dynamicIt.current);
+
+ Expect.throwsRangeError(() => list1.skip(-1));
+ Expect.throwsRangeError(() => list2.skip(-1));
+ Expect.throwsRangeError(() => list3.skip(-1));
+ Expect.throwsRangeError(() => set1.skip(-1));
+ Expect.throwsRangeError(() => set2.skip(-1));
+ Expect.throwsRangeError(() => list1.map((x) => x).skip(-1));
+ Expect.throwsRangeError(() => list2.map((x) => x).skip(-1));
+ Expect.throwsRangeError(() => list3.map((x) => x).skip(-1));
+ Expect.throwsRangeError(() => set1.map((x) => x).skip(-1));
+ Expect.throwsRangeError(() => set2.map((x) => x).skip(-1));
+}
diff --git a/tests/corelib/iterable_take_while_test.dart b/tests/corelib/iterable_take_while_test.dart
new file mode 100644
index 0000000..1e9b5f9
--- /dev/null
+++ b/tests/corelib/iterable_take_while_test.dart
@@ -0,0 +1,130 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 5];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(11)..add(12)..add(13);
+ Set set2 = new Set();
+
+ Iterable<int> takeWhileFalse = list1.takeWhile((x) => false);
+ Iterator<int> it = takeWhileFalse.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> takeWhileOdd = list1.takeWhile((x) => x.isOdd);
+ it = takeWhileOdd.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> takeWhileLessThan3 = list1.takeWhile((x) => x < 3);
+ it = takeWhileLessThan3.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> takeEverything = list1.takeWhile((x) => true);
+ it = takeEverything.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> takeWhileEven = list1.takeWhile((x) => x.isEven);
+ it = takeWhileFalse.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ takeWhileFalse = list2.takeWhile((x) => false);
+ it = takeWhileFalse.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ takeWhileEven = list2.takeWhile((x) => x.isEven);
+ it = takeWhileEven.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(4, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ takeEverything = list2.takeWhile((x) => true);
+ it = takeEverything.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(4, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(5, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<String> takeWhileFalse2 = list3.takeWhile((x) => false);
+ Iterator<String> it2 = takeWhileFalse2.iterator;
+ Expect.isNull(it2.current);
+ Expect.isFalse(it2.moveNext());
+ Expect.isNull(it2.current);
+
+ Iterable<String> takeEverything2 = list3.takeWhile((x) => true);
+ it2 = takeEverything2.iterator;
+ Expect.isNull(it2.current);
+ Expect.isFalse(it2.moveNext());
+ Expect.isNull(it2.current);
+
+ takeWhileFalse = set1.takeWhile((x) => false);
+ it = takeWhileFalse.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ takeEverything = set1.takeWhile((x) => true);
+ List<int> copied = takeEverything.toList();
+ Expect.equals(3, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ Expect.isTrue(set1.contains(copied[1]));
+ Expect.isTrue(set1.contains(copied[1]));
+ Expect.isTrue(copied[0] != copied[1]);
+ Expect.isTrue(copied[0] != copied[2]);
+ Expect.isTrue(copied[1] != copied[2]);
+ it = takeEverything.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isTrue(it.current != null);
+ Expect.isTrue(it.moveNext());
+ Expect.isTrue(it.current != null);
+ Expect.isTrue(it.moveNext());
+ Expect.isTrue(it.current != null);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ var dynamicTakeWhileFalse = set2.takeWhile((x) => false);
+ var dynamicIt = dynamicTakeWhileFalse.iterator;
+ Expect.isNull(dynamicIt.current);
+ Expect.isFalse(dynamicIt.moveNext());
+ Expect.isNull(dynamicIt.current);
+
+ var dynamicTakeEverything = set2.takeWhile((x) => true);
+ dynamicIt = dynamicTakeEverything.iterator;
+ Expect.isNull(dynamicIt.current);
+ Expect.isFalse(dynamicIt.moveNext());
+ Expect.isNull(dynamicIt.current);
+}
diff --git a/tests/corelib/iterable_test.dart b/tests/corelib/iterable_test.dart
new file mode 100644
index 0000000..e7f6299
--- /dev/null
+++ b/tests/corelib/iterable_test.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2013, 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.
+
+// Regression test for dart2js where [List.addAll] was not typed
+// correctly.
+
+import "package:expect/expect.dart";
+
+import 'dart:collection';
+
+class MyIterable extends IterableBase {
+ get iterator => [].iterator;
+}
+
+main() {
+ Expect.isTrue(([]..addAll(new MyIterable())).isEmpty);
+}
diff --git a/tests/corelib/iterable_to_list_test.dart b/tests/corelib/iterable_to_list_test.dart
new file mode 100644
index 0000000..4ceb6c8
--- /dev/null
+++ b/tests/corelib/iterable_to_list_test.dart
@@ -0,0 +1,73 @@
+// Copyright (c) 2012, 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.
+
+import "dart:collection" show Queue;
+import "dart:typed_data" show Uint8List, Float32List;
+import "package:expect/expect.dart";
+
+main() {
+ // testIterable takes an iterable and a list expected to be equal to
+ // the iterable's toList result, including the type parameter of the list.
+ testIterable(<dynamic>[], <dynamic>[]);
+ testIterable(<int>[], <int>[]);
+ testIterable(<String>[], <String>[]);
+ testIterable([1, 2, 3], [1, 2, 3]);
+ testIterable(<int>[1, 2, 3], <int>[1, 2, 3]);
+ testIterable(const [1, 2], [1, 2]);
+ testIterable(const <int>[1, 2], <int>[1, 2]);
+ testIterable(<dynamic, dynamic>{"x": 1, "y": 1}.keys, <dynamic>["x", "y"]);
+ testIterable(<String, int>{"x": 1, "y": 1}.keys, <String>["x", "y"]);
+ testIterable(<dynamic, dynamic>{"x": 2, "y": 3}.values, <dynamic>[2, 3]);
+ testIterable(<String, int>{"x": 2, "y": 3}.values, <int>[2, 3]);
+ testIterable(new Iterable.generate(3), [0, 1, 2]);
+ testIterable(new Iterable<int>.generate(3), <int>[0, 1, 2]);
+ testIterable(
+ new Iterable<String>.generate(3, (x) => "$x"), <String>["0", "1", "2"]);
+ testIterable(new Set.from([1, 2, 3]), [1, 2, 3]);
+ testIterable(new Set<int>.from([1, 2, 3]), <int>[1, 2, 3]);
+ testIterable(new Queue.from([1, 2, 3]), [1, 2, 3]);
+ testIterable(new Queue<int>.from(<int>[1, 2, 3]), <int>[1, 2, 3]);
+ testIterable(new Uint8List.fromList(<int>[1, 2, 3]), // //# 01: ok
+ <int>[1, 2, 3]); // //# 01: continued
+ testIterable(new Float32List.fromList([1.0, 2.0, 3.0]), // //# 01: continued
+ <double>[1.0, 2.0, 3.0]); // //# 01: continued
+ testIterable("abc".codeUnits, <int>[97, 98, 99]); // //# 01: continued
+ testIterable("abc".runes, <int>[97, 98, 99]);
+}
+
+testIterable(Iterable iterable, List expected, [int depth = 0]) {
+ print(" " * depth + "${iterable.runtimeType} vs ${expected.runtimeType}");
+ test(iterable, expected);
+ test(iterable, expected, growable: true);
+ test(iterable, expected, growable: false);
+ if (depth < 2) {
+ depth++;
+ testIterable(iterable.map((x) => x), new List.from(expected), depth);
+ testIterable(iterable.where((x) => true), expected, depth);
+ testIterable(iterable.expand((x) => [x]), new List.from(expected), depth);
+ testIterable(iterable.map((x) => x), new List.from(expected), depth);
+ testIterable(iterable.skipWhile((x) => false), expected, depth);
+ testIterable(iterable.takeWhile((x) => true), expected, depth);
+ testIterable(iterable.skip(0), expected, depth);
+ testIterable(iterable.take(expected.length * 2), expected, depth);
+ testIterable(iterable.toSet(), expected, depth);
+ }
+}
+
+test(Iterable iterable, List expected, {bool growable: true}) {
+ var list = iterable.toList(growable: growable);
+ Expect.listEquals(expected, list);
+ Expect.equals(expected is List<int>, list is List<int>, "int");
+ Expect.equals(expected is List<double>, list is List<double>, "double");
+ Expect.equals(expected is List<String>, list is List<String>, "str");
+ if (growable) {
+ int length = list.length;
+ list.add(null);
+ Expect.equals(length + 1, list.length);
+ } else {
+ Expect.throws(() {
+ list.add(null);
+ });
+ }
+}
diff --git a/tests/corelib/iterable_to_set_test.dart b/tests/corelib/iterable_to_set_test.dart
new file mode 100644
index 0000000..e04d49b
--- /dev/null
+++ b/tests/corelib/iterable_to_set_test.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 4];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(11)..add(12)..add(13);
+ Set<String> set2 = new Set<String>();
+ set2..add("foo")..add("bar")..add("toto");
+ Set set3 = new Set();
+
+ var setCopy = list1.toSet();
+ Expect.equals(3, setCopy.length);
+ Expect.isTrue(setCopy.contains(1));
+ Expect.isTrue(setCopy.contains(2));
+ Expect.isTrue(setCopy.contains(3));
+ Expect.isTrue(setCopy is Set<int>);
+ Expect.isFalse(setCopy is Set<String>);
+
+ setCopy = list2.toSet();
+ Expect.equals(1, setCopy.length);
+ Expect.isTrue(setCopy.contains(4));
+ Expect.isTrue(setCopy is Set<int>);
+ Expect.isFalse(setCopy is Set<String>);
+
+ var setStrCopy = list3.toSet();
+ Expect.isTrue(setStrCopy.isEmpty);
+ Expect.isTrue(setStrCopy is Set<String>);
+ Expect.isFalse(setStrCopy is Set<int>);
+
+ setCopy = set1.toSet();
+ Expect.setEquals(set1, setCopy);
+ Expect.isTrue(setCopy is Set<int>);
+ Expect.isFalse(setCopy is Set<String>);
+ Expect.isFalse(identical(setCopy, set1));
+
+ setStrCopy = set2.toSet();
+ Expect.setEquals(set2, setStrCopy);
+ Expect.isTrue(setStrCopy is Set<String>);
+ Expect.isFalse(setStrCopy is Set<int>);
+ Expect.isFalse(identical(setStrCopy, set2));
+
+ var set3Copy = set3.toSet();
+ Expect.setEquals(set3, set3Copy);
+ Expect.isTrue(set3Copy is Set);
+ Expect.isFalse(set3Copy is Set<String>);
+ Expect.isFalse(set3Copy is Set<int>);
+ Expect.isFalse(identical(set3Copy, set3));
+}
diff --git a/tests/corelib/iterable_tostring_test.dart b/tests/corelib/iterable_tostring_test.dart
new file mode 100644
index 0000000..bb22097
--- /dev/null
+++ b/tests/corelib/iterable_tostring_test.dart
@@ -0,0 +1,106 @@
+// Copyright (c) 2013, 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.
+
+// Test the IterableBase/IterableMixin toString method.
+
+import "package:expect/expect.dart";
+import "dart:collection";
+
+String mkIt(int len, [func]) {
+ var list;
+ if (func == null) {
+ list = new List.generate(len, (x) => x);
+ } else {
+ list = new List.generate(len, func);
+ }
+ return new MyIterable(list).toString();
+}
+
+class MyIterable extends IterableBase {
+ final Iterable _base;
+ MyIterable(this._base);
+ Iterator get iterator => _base.iterator;
+}
+
+void main() {
+ Expect.equals("()", mkIt(0));
+ Expect.equals("(0)", mkIt(1));
+ Expect.equals("(0, 1)", mkIt(2));
+ Expect.equals("(0, 1, 2, 3, 4, 5, 6, 7, 8)", mkIt(9));
+
+ // Builds string up to 60 characters, then finishes with last two
+ // elements.
+ Expect.equals(
+ //0123456789012345678901234567890123456789 - 40 characters
+ "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1"
+ "2, 13, 14, 15, 16, 17, 18, ..., 98, 99)",
+ mkIt(100));
+
+ Expect.equals(
+ //0123456789012345678901234567890123456789
+ "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1"
+ "2, 13, 14, 15, 16, 17, 18)",
+ mkIt(19));
+
+ Expect.equals(
+ //0123456789012345678901234567890123456789
+ "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1"
+ "2, 13, 14, 15, 16, 17, 18, 19)",
+ mkIt(20));
+
+ Expect.equals(
+ //0123456789012345678901234567890123456789
+ "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1"
+ "2, 13, 14, 15, 16, 17, 18, 19, 20)",
+ mkIt(21));
+
+ // Don't show last two elements if more than 100 elements total
+ // (can't be 100 elements in 80 characters including commas).
+ Expect.equals(
+ //0123456789012345678901234567890123456789
+ "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1"
+ "2, 13, 14, 15, 16, 17, 18, 19, 20, ...)",
+ mkIt(101));
+
+ // If last two elements bring total over 80 characters, drop some of
+ // the previous ones as well.
+
+ Expect.equals(
+ //0123456789012345678901234567890123456789
+ "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1"
+ "2, 13, ..., 18, xxxxxxxxxxxxxxxxxxxx)",
+ mkIt(20, (x) => x == 19 ? "xxxxxxxxxxxxxxxxxxxx" : "$x"));
+
+ // Never drop the first three or the last two.
+ Expect.equals(
+ //0123456789012345678901234567890123456789
+ "(xxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxx, x"
+ "xxxxxxxxxxxxxxxx, ..., 18, xxxxxxxxxxxxx"
+ "xxxx)",
+ mkIt(20, (x) => (x < 3 || x == 19) ? "xxxxxxxxxxxxxxxxx" : "$x"));
+
+ // Never drop the first three or the last two.
+ Expect.equals(
+ //0123456789012345678901234567890123456789
+ "(xxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxx, x"
+ "xxxxxxxxxxxxxxxx, ..., xxxxxxxxxxxxxxxxx"
+ ", 19)",
+ mkIt(20, (x) => (x < 3 || x == 18) ? "xxxxxxxxxxxxxxxxx" : "$x"));
+
+ // If the first three are very long, always include them anyway.
+ Expect.equals(
+ //0123456789012345678901234567890123456789
+ "(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,"
+ " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,"
+ " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,"
+ " ..., 98, 99)",
+ mkIt(100,
+ (x) => (x < 3) ? "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" : "$x"));
+
+ Expect.equals(
+ //0123456789012345678901234567890123456789
+ "(, , , , , , , , , , , , , , , , , , , ,"
+ " , , , , , , , , , , , , , , , ..., , )",
+ mkIt(100, (_) => ""));
+}
diff --git a/tests/corelib/iterable_where_type_test.dart b/tests/corelib/iterable_where_type_test.dart
new file mode 100644
index 0000000..1c00633
--- /dev/null
+++ b/tests/corelib/iterable_where_type_test.dart
@@ -0,0 +1,105 @@
+// Copyright (c) 2018, 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.
+
+import "dart:collection" show Queue;
+import "dart:typed_data" show Int32List;
+
+import "package:expect/expect.dart";
+
+// Tests behavior of result of an operation on a followedBy iterable.
+test(List expects, Iterable iterable, [String? name]) {
+ try {
+ Expect.isFalse(iterable is List, "$name is! List");
+ Expect.isFalse(iterable is Set, "$name is! Set");
+ Expect.isFalse(iterable is Queue, "$name is! Queue");
+ if (expects.isNotEmpty) {
+ Expect.equals(expects.first, iterable.first, "$name: first");
+ Expect.equals(expects.last, iterable.last, "$name: last");
+ } else {
+ Expect.throwsStateError(() => iterable.first, "$name: first");
+ Expect.throwsStateError(() => iterable.last, "$name: last");
+ }
+ var it = iterable.iterator;
+ for (int index = 0; index < expects.length; index++) {
+ Expect.isTrue(it.moveNext(), "$name: has element $index");
+ var expect = expects[index];
+ Expect.equals(expect, it.current, "$name at $index");
+ Expect.equals(
+ expect, iterable.elementAt(index), "$name: elementAt($index)");
+ Expect.isTrue(iterable.contains(expect), "$name:contains $index");
+ }
+ Expect.isFalse(it.moveNext(),
+ "$name: extra element at ${expects.length}: ${it.current}");
+ } on Error {
+ print("Failed during: $name");
+ rethrow;
+ }
+}
+
+main() {
+ var conversions = <String, Iterable<int> Function(List<int>)>{
+ "const": toConst,
+ "list": toList,
+ "unmod": toUnmodifiable,
+ "set": toSet,
+ "queue": toQueue,
+ "eff-len-iter": toELIter,
+ "non-eff-iter": toNEIter,
+ "typed": toTyped,
+ "keys": toKeys,
+ "values": toValues,
+ };
+ for (var data in [
+ const <int>[],
+ const <int>[1],
+ const <int>[1, 2, 3]
+ ]) {
+ conversions.forEach((name, c) {
+ test(data, c(data).whereType<int>(), "$name#${data.length}.wt<int>");
+ test(data, c(data).whereType<num>(), "$name#${data.length}.wt<num>");
+ test([], c(data).whereType<Null>(), "$name#${data.length}.wt<Null>");
+ });
+ }
+
+ test([1, 0.1], ["a", 1, new Object(), 0.1, null].whereType<num>(), "mixed");
+
+ var o = new Object();
+ var a = new A();
+ var b = new B();
+ var c = new C();
+ var d = new D();
+ var n = null;
+ test([o, a, b, c, d, n], [o, a, b, c, d, n].whereType<Object>(), "Object");
+ test([a, b, c, d], [o, a, b, c, d, n].whereType<A>(), "A");
+ test([b, d], [o, a, b, c, d, n].whereType<B>(), "B");
+ test([c, d], [o, a, b, c, d, n].whereType<C>(), "C");
+ test([d], [o, a, b, c, d, n].whereType<D>(), "D");
+ test([n], [o, a, b, c, d, n].whereType<Null>(), "Null");
+
+ test([d], <B>[d].whereType<C>(), "Unrelated");
+}
+
+class A {}
+
+class B implements A {}
+
+class C implements A {}
+
+class D implements B, C {}
+
+List<int> toConst(List<int> elements) => elements; // Argument is const.
+List<int> toList(List<int> elements) => elements.toList();
+List<int> toUnmodifiable(List<int> elements) =>
+ new List<int>.unmodifiable(elements);
+Set<int> toSet(List<int> elements) => elements.toSet();
+Queue<int> toQueue(List<int> elements) => new Queue<int>.from(elements);
+// Creates an efficient-length iterable.
+Iterable<int> toELIter(List<int> elements) => elements.map<int>((x) => x);
+// Creates a non-efficient-length iterable.
+Iterable<int> toNEIter(List<int> elements) => elements.where((x) => true);
+List<int> toTyped(List<int> elements) => new Int32List.fromList(elements);
+Iterable<int> toKeys(List<int> elements) =>
+ new Map<int, int>.fromIterables(elements, elements).keys;
+Iterable<int> toValues(List<int> elements) =>
+ new Map<int, int>.fromIterables(elements, elements).values;
diff --git a/tests/ffi/aliasing_test.dart b/tests/ffi/aliasing_test.dart
index 9ae36e8..6c2f698 100644
--- a/tests/ffi/aliasing_test.dart
+++ b/tests/ffi/aliasing_test.dart
@@ -8,8 +8,6 @@
// SharedObjects=ffi_test_functions
// VMOptions=--deterministic --optimization-counter-threshold=50
-library FfiTest;
-
import 'dart:ffi';
import "package:ffi/ffi.dart";
diff --git a/tests/ffi/data_not_asan_test.dart b/tests/ffi/data_not_asan_test.dart
index aa9cf24..e95658f 100644
--- a/tests/ffi/data_not_asan_test.dart
+++ b/tests/ffi/data_not_asan_test.dart
@@ -7,8 +7,6 @@
// These mallocs trigger an asan alarm, so these tests are in a separate file
// which is excluded in asan mode.
-library FfiTest;
-
import 'dart:ffi';
import "package:ffi/ffi.dart";
diff --git a/tests/ffi/data_test.dart b/tests/ffi/data_test.dart
index 3df6451..0dc4d19 100644
--- a/tests/ffi/data_test.dart
+++ b/tests/ffi/data_test.dart
@@ -6,8 +6,6 @@
//
// SharedObjects=ffi_test_functions
-library FfiTest;
-
import 'dart:ffi';
import "package:expect/expect.dart";
diff --git a/tests/ffi/dynamic_library_test.dart b/tests/ffi/dynamic_library_test.dart
deleted file mode 100644
index f3d53c8..0000000
--- a/tests/ffi/dynamic_library_test.dart
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2019, 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.
-//
-// Dart test program for testing dart:ffi dynamic library loading.
-//
-// SharedObjects=ffi_test_dynamic_library ffi_test_functions
-
-library FfiTest;
-
-import 'dart:io';
-import 'dart:ffi';
-
-import 'package:expect/expect.dart';
-
-import 'dylib_utils.dart';
-
-void main() {
- testOpen();
- testOpenError();
- testLookup();
- testLookupError();
- testToString();
- testEquality();
- testHandle();
-}
-
-void testOpen() {
- DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
- Expect.notEquals(null, l);
-}
-
-void testOpenError() {
- Expect.throws(
- () => dlopenPlatformSpecific("doesnotexistforsurelibrary123409876"));
-}
-
-typedef NativeDoubleUnOp = Double Function(Double);
-
-typedef DoubleUnOp = double Function(double);
-
-void testLookup() {
- DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
- var timesFour = l.lookupFunction<NativeDoubleUnOp, DoubleUnOp>("timesFour");
- Expect.approxEquals(12.0, timesFour(3));
-
- if (Platform.isMacOS ||
- Platform.isIOS ||
- Platform.isAndroid ||
- Platform.isLinux) {
- // Lookup a symbol from 'libc' since it's loaded with global visibility.
- DynamicLibrary p = DynamicLibrary.process();
- Expect.isTrue(p.lookup<Void>("strcmp") != nullptr);
- } else {
- Expect.throws<UnsupportedError>(() => DynamicLibrary.process());
- }
-
- DynamicLibrary e = DynamicLibrary.executable();
- Expect.isTrue(e.lookup("Dart_Invoke") != nullptr);
-}
-
-void testLookupError() {
- DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
- Expect.throws(() => l.lookupFunction<NativeDoubleUnOp, DoubleUnOp>(
- "functionnamethatdoesnotexistforsure749237593845"));
-}
-
-void testToString() {
- DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
- Expect.stringEquals(
- "DynamicLibrary: handle=0x", l.toString().substring(0, 25));
-}
-
-void testEquality() {
- DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
- DynamicLibrary l2 = dlopenPlatformSpecific("ffi_test_dynamic_library");
- Expect.equals(l, l2);
- Expect.equals(l.hashCode, l2.hashCode);
- Expect.notEquals(l, null);
- Expect.notEquals(null, l);
- DynamicLibrary l3 = dlopenPlatformSpecific("ffi_test_functions");
- Expect.notEquals(l, l3);
-}
-
-void testHandle() {
- DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
- DynamicLibrary l2 = dlopenPlatformSpecific("ffi_test_dynamic_library");
- Pointer<Void> h = l.handle;
- Pointer<Void> h2 = l2.handle;
- Expect.equals(h, h2);
- DynamicLibrary l3 = dlopenPlatformSpecific("ffi_test_functions");
- Pointer<Void> h3 = l3.handle;
- Expect.notEquals(h, h3);
-}
diff --git a/tests/ffi/ffi.status b/tests/ffi/ffi.status
index 4e5b3d1..0b1e494 100644
--- a/tests/ffi/ffi.status
+++ b/tests/ffi/ffi.status
@@ -17,7 +17,7 @@
*: Skip # "hardfp" calling convention is not yet supported (iOS is also supported but not tested): dartbug.com/36309
[ $compiler == dart2analyzer ]
-enable_ffi_test: SkipByDesign # This is a check for VM only.
+vmspecific_enable_ffi_test: SkipByDesign # This is a check for VM only.
[ $runtime != dart_precompiled && $runtime != vm && $compiler != dart2analyzer ]
*: SkipByDesign # FFI is a VM-only feature. (This test suite is part of the default set.)
diff --git a/tests/ffi/function_callbacks_test.dart b/tests/ffi/function_callbacks_test.dart
index 77f6def..35a63bd 100644
--- a/tests/ffi/function_callbacks_test.dart
+++ b/tests/ffi/function_callbacks_test.dart
@@ -1,7 +1,7 @@
// Copyright (c) 2019, 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.
-//
+
// Dart test program for testing dart:ffi function pointers with callbacks.
//
// VMOptions=--enable-testing-pragmas
@@ -14,11 +14,8 @@
// VMOptions=--use-slow-path --enable-testing-pragmas --write-protect-code --no-dual-map-code --stacktrace-every=100
// SharedObjects=ffi_test_functions
-library FfiTest;
-
import 'dart:io';
import 'dart:ffi';
-import 'dart:isolate';
import 'dylib_utils.dart';
import "package:expect/expect.dart";
@@ -175,19 +172,6 @@
throw "Exception.";
}
-void testGC() {
- triggerGc();
-}
-
-typedef WaitForHelperNative = Void Function(Pointer<Void>);
-typedef WaitForHelper = void Function(Pointer<Void>);
-
-void waitForHelper(Pointer<Void> helper) {
- print("helper: $helper");
- testLibrary
- .lookupFunction<WaitForHelperNative, WaitForHelper>("WaitForHelper")(helper);
-}
-
final List<Test> testcases = [
Test("SimpleAddition",
Pointer.fromFunction<SimpleAdditionType>(simpleAddition, 0)),
@@ -212,65 +196,10 @@
Pointer.fromFunction<ThrowExceptionPointer>(throwExceptionPointer)),
Test("ThrowException",
Pointer.fromFunction<ThrowExceptionInt>(throwExceptionInt, 42)),
- Test("GC", Pointer.fromFunction<ReturnVoid>(testGC)),
- Test("UnprotectCode", Pointer.fromFunction<WaitForHelperNative>(waitForHelper)),
];
-testCallbackWrongThread() =>
- Test("CallbackWrongThread", Pointer.fromFunction<ReturnVoid>(returnVoid))
- .run();
-
-testCallbackOutsideIsolate() =>
- Test("CallbackOutsideIsolate", Pointer.fromFunction<ReturnVoid>(returnVoid))
- .run();
-
-isolateHelper(int callbackPointer) {
- final Pointer<Void> ptr = Pointer.fromAddress(callbackPointer);
- final NativeCallbackTestFn tester =
- testLibrary.lookupFunction<NativeCallbackTest, NativeCallbackTestFn>(
- "TestCallbackWrongIsolate");
- Expect.equals(0, tester(ptr));
-}
-
-testCallbackWrongIsolate() async {
- final int callbackPointer =
- Pointer.fromFunction<ReturnVoid>(returnVoid).address;
- final ReceivePort exitPort = ReceivePort();
- await Isolate.spawn(isolateHelper, callbackPointer,
- errorsAreFatal: true, onExit: exitPort.sendPort);
- await exitPort.first;
-}
-
-const double zeroPointZero = 0.0;
-
-// Correct type of exceptionalReturn argument to Pointer.fromFunction.
-double testExceptionalReturn() {
- Pointer.fromFunction<Double Function()>(testExceptionalReturn, 0.0);
- Pointer.fromFunction<Double Function()>(testExceptionalReturn, zeroPointZero);
-
- Pointer.fromFunction<Double Function()>(returnVoid, null); //# 59: compile-time error
- Pointer.fromFunction<Void Function()>(returnVoid, 0); //# 60: compile-time error
- Pointer.fromFunction<Double Function()>(testExceptionalReturn, "abc"); //# 61: compile-time error
- Pointer.fromFunction<Double Function()>(testExceptionalReturn, 0); //# 62: compile-time error
- Pointer.fromFunction<Double Function()>(testExceptionalReturn); //# 63: compile-time error
-
- return 0.0; // not used
-}
-
void main() async {
testcases.forEach((t) => t.run()); //# 00: ok
- testExceptionalReturn(); //# 00: ok
-
- // These tests terminate the process after successful completion, so we have
- // to run them separately.
- //
- // Since they use signal handlers they only run on Linux.
- if (Platform.isLinux && !const bool.fromEnvironment("dart.vm.product")) {
- testCallbackWrongThread(); //# 01: ok
- testCallbackOutsideIsolate(); //# 02: ok
- await testCallbackWrongIsolate(); //# 03: ok
- }
-
testManyCallbacks(); //# 04: ok
}
diff --git a/tests/ffi/function_structs_test.dart b/tests/ffi/function_structs_test.dart
index ee71a4b..3738876 100644
--- a/tests/ffi/function_structs_test.dart
+++ b/tests/ffi/function_structs_test.dart
@@ -7,8 +7,6 @@
//
// SharedObjects=ffi_test_functions
-library FfiTest;
-
import 'dart:ffi';
import 'dylib_utils.dart';
diff --git a/tests/ffi/function_test.dart b/tests/ffi/function_test.dart
index 38c36a9..5ed233d 100644
--- a/tests/ffi/function_test.dart
+++ b/tests/ffi/function_test.dart
@@ -42,11 +42,10 @@
testVoidReturn();
testNoArgs();
testException();
- testLookupFunctionPointerNativeType();
}
}
-DynamicLibrary ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
+final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
typedef NativeBinaryOp = Int32 Function(Int32, Int32);
typedef UnaryOp = int Function(int);
@@ -404,24 +403,12 @@
Expect.approxEquals(1337.0, result);
}
-typedef NativeTypeNFT = Pointer<NativeType> Function(
- Pointer<Pointer<NativeType>>, Int8);
-typedef NativeTypeFT = Pointer<NativeType> Function(
- Pointer<Pointer<NativeType>>, int);
-
-void testLookupFunctionPointerNativeType() {
- // The function signature does not match up, but that does not matter since
- // this test does not use the trampoline.
- ffiTestFunctions.lookupFunction<NativeTypeNFT, NativeTypeFT>("LargePointer");
-}
-
// Throw an exception from within the trampoline and collect a stacktrace
// include its frame.
void testException() {
try {
sumPlus42(null, null);
} catch (e, s) {
- print("$e, $s");
return;
}
throw "Didn't throw!";
diff --git a/tests/ffi/object_gc_test.dart b/tests/ffi/object_gc_test.dart
deleted file mode 100644
index de7d3f7..0000000
--- a/tests/ffi/object_gc_test.dart
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2019, 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.
-//
-// Tests GC of Pointer objects.
-//
-// SharedObjects=ffi_test_functions
-
-library FfiTest;
-
-import 'dart:ffi';
-
-import "package:expect/expect.dart";
-
-import 'dylib_utils.dart';
-
-DynamicLibrary ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
-
-final triggerGc = ffiTestFunctions
- .lookupFunction<Void Function(), void Function()>("TriggerGC");
-
-void main() async {
- testSizeOf();
- testGC();
-}
-
-dynamic bar;
-
-Future<void> testGC() async {
- bar = Pointer<Int8>.fromAddress(11);
- // Verify that the objects manufactured by 'fromAddress' can be scanned by the
- // GC.
- triggerGc();
-}
-
-void testSizeOf() {
- Expect.equals(true, 4 == sizeOf<Pointer>() || 8 == sizeOf<Pointer>());
-}
diff --git a/tests/ffi/prepare_flutter_bundle.dart b/tests/ffi/prepare_flutter_bundle.dart
new file mode 100644
index 0000000..83a4a42
--- /dev/null
+++ b/tests/ffi/prepare_flutter_bundle.dart
@@ -0,0 +1,204 @@
+// Copyright (c) 2019, 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.
+
+import 'dart:async';
+import 'dart:io';
+
+import 'package:path/path.dart' as path;
+import 'package:args/args.dart';
+
+main(List<String> args) async {
+ if (args.length != 1) {
+ print('Usage ${Platform.executable} ${Platform.script} <output-dir>');
+ exit(1);
+ }
+
+ final sdkRoot =
+ path.canonicalize(path.join(Platform.script.path, '../../..'));
+ final flutterTestsDir = args.single;
+
+ print('Using SDK root: $sdkRoot');
+ final testFiles = <String>[];
+ final failedOrTimedOut = <String>[];
+ final filteredTests = <String>[];
+ await for (final testFile in listTestFiles(sdkRoot, filteredTests)) {
+ final duration = await run(sdkRoot, testFile);
+ if (duration != null && duration.inSeconds < 5) {
+ testFiles.add(testFile);
+ } else {
+ failedOrTimedOut.add(testFile);
+ }
+ }
+ testFiles.sort();
+ failedOrTimedOut.sort();
+ filteredTests.sort();
+
+ dumpTestList(testFiles, 'The following tests will be included:');
+ dumpTestList(failedOrTimedOut,
+ 'The following tests will be excluded due to timeout or test failure:');
+ dumpTestList(
+ filteredTests,
+ 'The following tests were filtered due to using '
+ 'dart_api.h/async/DynamicLibrary.{process,executable}/...');
+
+ final allFiles = <String>{};
+ allFiles.add(path.join(sdkRoot, 'pkg/expect/lib/expect.dart'));
+ for (final testFile in testFiles) {
+ allFiles.add(testFile);
+ await addImportedFilesTo(allFiles, testFile);
+ }
+
+ await generateCleanDir(flutterTestsDir);
+
+ final dartTestsDir = path.join(flutterTestsDir, 'lib/src/generated');
+ await generateDartTests(dartTestsDir, allFiles, testFiles);
+
+ final ccDir = path.join(flutterTestsDir, 'ios/Classes');
+ await generateCLibs(sdkRoot, ccDir, allFiles, testFiles);
+
+ print('');
+ print('Please copy generated files into FFI flutter test application');
+ print(' * $dartTestsDir');
+ print(' * $ccDir');
+}
+
+void dumpTestList(List<String> testFiles, String message) {
+ if (testFiles.isEmpty) return;
+
+ print(message);
+ for (final testFile in testFiles) {
+ print(' ${path.basename(testFile)}');
+ }
+}
+
+final importRegExp = RegExp(r'''^import.*['"](.+)['"].*;''');
+
+Future addImportedFilesTo(Set<String> allFiles, String testFile) async {
+ final content = await File(testFile).readAsString();
+ for (final line in content.split('\n')) {
+ final match = importRegExp.matchAsPrefix(line);
+ if (match != null) {
+ final filename = match.group(1);
+ if (!filename.contains('dart:') &&
+ !filename.contains('package:expect') &&
+ !filename.contains('package:ffi')) {
+ final importedFile = Uri.file(testFile).resolve(filename).toFilePath();
+ if (allFiles.add(importedFile)) {
+ addImportedFilesTo(allFiles, importedFile);
+ }
+ }
+ }
+ }
+}
+
+Future generateCLibs(String sdkRoot, String destDir, Set<String> allFiles,
+ List<String> testFiles) async {
+ final dir = await generateCleanDir(destDir);
+
+ String destinationFile;
+
+ final lib1 =
+ path.join(sdkRoot, 'runtime/bin/ffi_test/ffi_test_dynamic_library.cc');
+ destinationFile =
+ path.join(dir.path, path.basename(lib1)).replaceAll('.cc', '.cpp');
+ File(destinationFile).writeAsStringSync(File(lib1).readAsStringSync());
+
+ final lib2 = path.join(sdkRoot, 'runtime/bin/ffi_test/ffi_test_functions.cc');
+ destinationFile =
+ path.join(dir.path, path.basename(lib2)).replaceAll('.cc', '.cpp');
+ File(destinationFile).writeAsStringSync(File(lib2).readAsStringSync());
+}
+
+String cleanDart(String content) {
+ return content.replaceAll('package:expect/expect.dart', 'expect.dart');
+}
+
+Future generateDartTests(
+ String destDir, Set<String> allFiles, List<String> testFiles) async {
+ final dir = await generateCleanDir(destDir);
+
+ final sink = File(path.join(dir.path, 'all.dart')).openWrite();
+ sink.writeln('import "dart:async";');
+ sink.writeln('');
+ for (int i = 0; i < testFiles.length; ++i) {
+ sink.writeln('import "${path.basename(testFiles[i])}" as main$i;');
+ }
+ sink.writeln('');
+ sink.writeln('Future invoke(dynamic fun) async {');
+ sink.writeln(' if (fun is void Function() || fun is Future Function()) {');
+ sink.writeln(' return await fun();');
+ sink.writeln(' } else {');
+ sink.writeln(' return await fun(<String>[]);');
+ sink.writeln(' }');
+ sink.writeln('}');
+ sink.writeln('');
+ sink.writeln('dynamic main() async {');
+ for (int i = 0; i < testFiles.length; ++i) {
+ sink.writeln(' await invoke(main$i.main);');
+ }
+ sink.writeln('}');
+ await sink.close();
+
+ for (final file in allFiles) {
+ File(path.join(dir.path, path.basename(file)))
+ .writeAsStringSync(cleanDart(File(file).readAsStringSync()));
+ }
+
+ File(path.join(dir.path, 'dylib_utils.dart')).writeAsStringSync('''
+import 'dart:ffi' as ffi;
+import 'dart:io' show Platform;
+
+ffi.DynamicLibrary dlopenPlatformSpecific(String name, {String path}) {
+ return Platform.isAndroid
+ ? ffi.DynamicLibrary.open('libffi_tests.so')
+ : ffi.DynamicLibrary.process();
+}
+''');
+}
+
+Stream<String> listTestFiles(
+ String sdkRoot, List<String> filteredTests) async* {
+ await for (final file in Directory(path.join(sdkRoot, 'tests/ffi')).list()) {
+ if (file is File && file.path.endsWith('_test.dart')) {
+ // These tests are VM specific and cannot necessarily be run on Flutter.
+ if (path.basename(file.path).startsWith('vmspecific_')) {
+ filteredTests.add(file.path);
+ continue;
+ }
+ // These tests use special features which are hard to test on Flutter.
+ final contents = file.readAsStringSync();
+ if (contents.contains(RegExp('//# .* compile-time error')) ||
+ contents.contains('DynamicLibrary.process') ||
+ contents.contains('DynamicLibrary.executable')) {
+ filteredTests.add(file.path);
+ continue;
+ }
+ yield file.path;
+ }
+ }
+}
+
+Future<Duration> run(String sdkRoot, String testFile) async {
+ final env = Map<String, String>.from(Platform.environment);
+ env['LD_LIBRARY_PATH'] = path.join(sdkRoot, 'out/ReleaseX64');
+ final sw = Stopwatch()..start();
+ final Process process = await Process.start(
+ Platform.executable, <String>[testFile],
+ environment: env);
+ final timer = Timer(const Duration(seconds: 3), () => process.kill());
+ process.stdout.listen((_) {});
+ process.stderr.listen((_) {});
+ if (await process.exitCode != 0) return null;
+ timer.cancel();
+ return sw.elapsed;
+}
+
+Future<Directory> generateCleanDir(String dirname) async {
+ final directory = Directory(dirname);
+ if (await directory.exists()) {
+ await directory.delete(recursive: true);
+ }
+ await directory.create(recursive: true);
+ return directory;
+}
diff --git a/tests/ffi/regress_37254_test.dart b/tests/ffi/regress_37254_test.dart
index 27ab955..dcd42b9 100644
--- a/tests/ffi/regress_37254_test.dart
+++ b/tests/ffi/regress_37254_test.dart
@@ -240,7 +240,6 @@
void main() {
// Trigger both the runtime entry and the IL in bytecode.
for (int i = 0; i < 100; i++) {
- print(i);
store1();
store2();
store3();
diff --git a/tests/ffi/regress_37511_callbacks_test.dart b/tests/ffi/regress_37511_callbacks_test.dart
deleted file mode 100644
index 37407ee..0000000
--- a/tests/ffi/regress_37511_callbacks_test.dart
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2019, 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.
-//
-// Dart test program for testing dart:ffi struct pointers.
-//
-// VMOptions=--deterministic --enable-testing-pragmas
-//
-// SharedObjects=ffi_test_functions
-//
-// TODO(37295): Merge this file with regress_37511_test.dart when callback
-// support lands.
-
-library FfiTest;
-
-import 'dart:ffi';
-
-import 'ffi_test_helpers.dart';
-
-/// Estimate of how many allocations functions in `functionsToTest` do at most.
-const gcAfterNAllocationsMax = 10;
-
-void main() {
- for (Function() f in functionsToTest) {
- f(); // Ensure code is compiled.
-
- for (int n = 1; n <= gcAfterNAllocationsMax; n++) {
- collectOnNthAllocation(n);
- f();
- }
- }
-}
-
-final List<Function()> functionsToTest = [
- // Callback trampolines.
- doFromFunction,
- () => callbackSmallDouble(dartFunctionPointer),
-];
-
-// Callback trampoline helpers.
-typedef NativeCallbackTest = Int32 Function(Pointer);
-typedef NativeCallbackTestFn = int Function(Pointer);
-
-final callbackSmallDouble =
- ffiTestFunctions.lookupFunction<NativeCallbackTest, NativeCallbackTestFn>(
- "TestSimpleMultiply");
-
-typedef SimpleMultiplyType = Double Function(Double);
-double simpleMultiply(double x) => x * 1.337;
-
-final doFromFunction =
- () => Pointer.fromFunction<SimpleMultiplyType>(simpleMultiply, 0.0);
-
-final dartFunctionPointer = doFromFunction();
diff --git a/tests/ffi/regress_37511_test.dart b/tests/ffi/regress_37511_test.dart
deleted file mode 100644
index e2a2e70..0000000
--- a/tests/ffi/regress_37511_test.dart
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2019, 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.
-//
-// Dart test program for testing dart:ffi struct pointers.
-//
-// VMOptions=--deterministic --enable-testing-pragmas
-//
-// SharedObjects=ffi_test_functions
-
-library FfiTest;
-
-import 'dart:ffi';
-
-import 'dylib_utils.dart';
-import 'ffi_test_helpers.dart';
-
-/// Estimate of how many allocations functions in `functionsToTest` do at most.
-const gcAfterNAllocationsMax = 10;
-
-void main() {
- for (Function() f in functionsToTest) {
- f(); // Ensure code is compiled.
-
- for (int n = 1; n <= gcAfterNAllocationsMax; n++) {
- collectOnNthAllocation(n);
- f();
- }
- }
-}
-
-final List<Function()> functionsToTest = [
- // Pointer operations.
- () => highAddressPointer.cast<Double>(),
- () => Pointer.fromAddress(highAddressPointer.address),
- () => highAddressPointer.address,
- () => highAddressPointer.elementAt(1),
- () => highAddressPointer.offsetBy(1),
- () => highAddressPointer.asTypedList(1),
-
- // DynamicLibrary operations.
- doDlopen,
- doDlsym, // Includes `asFunction`.
- () => ffiTestFunctions.handle,
-
- // Trampolines.
- () => sumManyIntsOdd(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, mint64bit),
- () => sumManyDoubles(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0),
- minInt64,
- minInt32,
- smallDouble,
- largePointer,
-
- // Callback trampolines.
- //
- // In regress_37511_callbacks_test.dart because callbacks are not supported
- // in AOT yet.
-];
-
-// Pointer operation helpers.
-const mint32bit = 0xFFFFFFF0;
-const mint64bit = 0x7FFFFFFFFFFFFFF0;
-
-final int highAddress = sizeOf<IntPtr>() == 4 ? mint32bit : mint64bit;
-
-final Pointer<Int64> highAddressPointer = Pointer.fromAddress(highAddress);
-
-// Dynamic library operation helpers.
-final doDlopen = () => dlopenPlatformSpecific("ffi_test_functions");
-
-final doDlsym = () => ffiTestFunctions
- .lookupFunction<NativeNullaryOp, NullaryOpVoid>("TriggerGC");
-
-// Trampoline helpers.
-typedef NativeUndenaryOp = IntPtr Function(IntPtr, IntPtr, IntPtr, IntPtr,
- IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr);
-typedef UndenaryOp = int Function(
- int, int, int, int, int, int, int, int, int, int, int);
-
-final UndenaryOp sumManyIntsOdd = ffiTestFunctions
- .lookupFunction<NativeUndenaryOp, UndenaryOp>("SumManyIntsOdd");
-
-typedef NativeDoubleDecenaryOp = Double Function(Double, Double, Double, Double,
- Double, Double, Double, Double, Double, Double);
-typedef DoubleDecenaryOp = double Function(double, double, double, double,
- double, double, double, double, double, double);
-
-final DoubleDecenaryOp sumManyDoubles = ffiTestFunctions
- .lookupFunction<NativeDoubleDecenaryOp, DoubleDecenaryOp>("SumManyDoubles");
-
-typedef NativeNullaryOp64 = Int64 Function();
-typedef NativeNullaryOp32 = Int32 Function();
-typedef NativeNullaryOpDouble = Double Function();
-typedef NullaryOpPtr = Pointer<Void> Function();
-typedef NullaryOp = int Function();
-typedef NullaryOpDbl = double Function();
-
-final minInt64 =
- ffiTestFunctions.lookupFunction<NativeNullaryOp64, NullaryOp>("MinInt64");
-
-final minInt32 =
- ffiTestFunctions.lookupFunction<NativeNullaryOp32, NullaryOp>("MinInt32");
-
-final smallDouble = ffiTestFunctions
- .lookupFunction<NativeNullaryOpDouble, NullaryOpDbl>("SmallDouble");
-
-final largePointer =
- ffiTestFunctions.lookupFunction<NullaryOpPtr, NullaryOpPtr>("LargePointer");
diff --git a/tests/ffi/regress_39068_test.dart b/tests/ffi/regress_39068_test.dart
index fbfca38..6709a53 100644
--- a/tests/ffi/regress_39068_test.dart
+++ b/tests/ffi/regress_39068_test.dart
@@ -60,10 +60,12 @@
final sumManyNumbers = ffiTestFunctions
.lookupFunction<NativeVigesimalOp, VigesimalOp>("SumManyNumbers");
+ bool gotException = false;
try {
sumManyNumbers(1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9, 10.0, 11, 12.0, 13, 14.0,
15, 16.0, 17, 18.0, null, 20.0);
} on Error {
- print('Expected exception on passing null for int');
+ gotException = true;
}
+ Expect.isTrue(gotException);
}
diff --git a/tests/ffi/sizeof_test.dart b/tests/ffi/sizeof_test.dart
new file mode 100644
index 0000000..fd02efc
--- /dev/null
+++ b/tests/ffi/sizeof_test.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2019, 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.
+//
+// SharedObjects=ffi_test_functions
+
+import 'dart:ffi';
+
+import "package:expect/expect.dart";
+
+void main() async {
+ Expect.equals(true, 4 == sizeOf<Pointer>() || 8 == sizeOf<Pointer>());
+}
diff --git a/tests/ffi/snapshot_test.dart b/tests/ffi/snapshot_test.dart
index a935a0d..b27b88b 100644
--- a/tests/ffi/snapshot_test.dart
+++ b/tests/ffi/snapshot_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2019, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// Checks that the VM throws an appropriate exception when FFI objects are
// passed between isolates.
diff --git a/tests/ffi/static_checks_test.dart b/tests/ffi/static_checks_test.dart
deleted file mode 100644
index 3c60703..0000000
--- a/tests/ffi/static_checks_test.dart
+++ /dev/null
@@ -1,453 +0,0 @@
-// Copyright (c) 2019, 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.
-//
-// Dart test program for testing dart:ffi extra checks
-//
-// SharedObjects=ffi_test_dynamic_library
-
-library FfiTest;
-
-import 'dart:ffi';
-
-import "package:ffi/ffi.dart";
-
-import 'dylib_utils.dart';
-
-void main() {
- testGetGeneric();
- testGetGeneric2();
- testGetVoid();
- testGetNativeFunction();
- testGetNativeType();
- testGetTypeMismatch();
- testSetGeneric();
- testSetGeneric2();
- testSetVoid();
- testSetNativeFunction();
- testSetNativeType();
- testSetTypeMismatch();
- testAsFunctionGeneric();
- testAsFunctionGeneric2();
- testAsFunctionWrongNativeFunctionSignature();
- testAsFunctionTypeMismatch();
- testFromFunctionGeneric();
- testFromFunctionGeneric2();
- testFromFunctionWrongNativeFunctionSignature();
- testFromFunctionTypeMismatch();
- testFromFunctionClosure();
- testFromFunctionTearOff();
- testFromFunctionAbstract();
- testLookupFunctionGeneric();
- testLookupFunctionGeneric2();
- testLookupFunctionWrongNativeFunctionSignature();
- testLookupFunctionTypeMismatch();
- testNativeFunctionSignatureInvalidReturn();
- testNativeFunctionSignatureInvalidParam();
- testNativeFunctionSignatureInvalidOptionalNamed();
- testNativeFunctionSignatureInvalidOptionalPositional();
-}
-
-typedef Int8UnOp = Int8 Function(Int8);
-typedef IntUnOp = int Function(int);
-
-void testGetGeneric() {
- int generic(Pointer p) {
- int result;
- result = p.value; //# 20: compile-time error
- return result;
- }
-
- Pointer<Int8> p = allocate();
- p.value = 123;
- Pointer loseType = p;
- generic(loseType);
- free(p);
-}
-
-void testGetGeneric2() {
- T generic<T extends Object>() {
- Pointer<Int8> p = allocate();
- p.value = 123;
- T result;
- result = p.value; //# 21: compile-time error
- free(p);
- return result;
- }
-
- generic<int>();
-}
-
-void testGetVoid() {
- Pointer<IntPtr> p1 = allocate();
- Pointer<Void> p2 = p1.cast();
-
- p2.value; //# 22: compile-time error
-
- free(p1);
-}
-
-void testGetNativeFunction() {
- Pointer<NativeFunction<Int8UnOp>> p = Pointer.fromAddress(1337);
- IntUnOp f = p.value; //# 23: compile-time error
-}
-
-void testGetNativeType() {
- // Is it possible to obtain a Pointer<NativeType> at all?
-}
-
-void testGetTypeMismatch() {
- Pointer<Pointer<Int16>> p = allocate();
- Pointer<Int16> typedNull = nullptr;
- p.value = typedNull;
-
- // this fails to compile due to type mismatch
- Pointer<Int8> p2 = p.value; //# 25: compile-time error
-
- free(p);
-}
-
-void testSetGeneric() {
- void generic(Pointer p) {
- p.value = 123; //# 26: compile-time error
- }
-
- Pointer<Int8> p = allocate();
- p.value = 123;
- Pointer loseType = p;
- generic(loseType);
- free(p);
-}
-
-void testSetGeneric2() {
- void generic<T extends Object>(T arg) {
- Pointer<Int8> p = allocate();
- p.value = arg; //# 27: compile-time error
- free(p);
- }
-
- generic<int>(123);
-}
-
-void testSetVoid() {
- Pointer<IntPtr> p1 = allocate();
- Pointer<Void> p2 = p1.cast();
-
- p2.value = 1234; //# 28: compile-time error
-
- free(p1);
-}
-
-void testSetNativeFunction() {
- Pointer<NativeFunction<Int8UnOp>> p = Pointer.fromAddress(1337);
- IntUnOp f = (a) => a + 1;
- p.value = f; //# 29: compile-time error
-}
-
-void testSetNativeType() {
- // Is it possible to obtain a Pointer<NativeType> at all?
-}
-
-void testSetTypeMismatch() {
- // the pointer to pointer types must match up
- Pointer<Int8> pHelper = allocate();
- pHelper.value = 123;
-
- Pointer<Pointer<Int16>> p = allocate();
-
- // this fails to compile due to type mismatch
- p.value = pHelper; //# 40: compile-time error
-
- free(pHelper);
- free(p);
-}
-
-void testAsFunctionGeneric() {
- T generic<T extends Function>() {
- Pointer<NativeFunction<Int8UnOp>> p = Pointer.fromAddress(1337);
- Function f;
- f = p.asFunction<T>(); //# 11: compile-time error
- return f;
- }
-
- generic<IntUnOp>();
-}
-
-void testAsFunctionGeneric2() {
- generic(Pointer<NativeFunction> p) {
- Function f;
- f = p.asFunction<IntUnOp>(); //# 12: compile-time error
- return f;
- }
-
- Pointer<NativeFunction<Int8UnOp>> p = Pointer.fromAddress(1337);
- generic(p);
-}
-
-void testAsFunctionWrongNativeFunctionSignature() {
- Pointer<NativeFunction<IntUnOp>> p;
- Function f = p.asFunction<IntUnOp>(); //# 13: compile-time error
-}
-
-typedef IntBinOp = int Function(int, int);
-
-void testAsFunctionTypeMismatch() {
- Pointer<NativeFunction<Int8UnOp>> p = Pointer.fromAddress(1337);
- IntBinOp f = p.asFunction(); //# 14: compile-time error
-}
-
-typedef NativeDoubleUnOp = Double Function(Double);
-typedef DoubleUnOp = double Function(double);
-
-double myTimesThree(double d) => d * 3;
-
-int myTimesFour(int i) => i * 4;
-
-void testFromFunctionGeneric() {
- Pointer<NativeFunction> generic<T extends Function>(T f) {
- Pointer<NativeFunction<NativeDoubleUnOp>> result;
- result = Pointer.fromFunction(f); //# 70: compile-time error
- return result;
- }
-
- generic(myTimesThree);
-}
-
-void testFromFunctionGeneric2() {
- Pointer<NativeFunction<T>> generic<T extends Function>() {
- Pointer<NativeFunction<T>> result;
- result = Pointer.fromFunction(myTimesThree); //# 71: compile-time error
- return result;
- }
-
- generic<NativeDoubleUnOp>();
-}
-
-void testFromFunctionWrongNativeFunctionSignature() {
- Pointer.fromFunction<IntUnOp>(myTimesFour); //# 72: compile-time error
-}
-
-void testFromFunctionTypeMismatch() {
- Pointer<NativeFunction<NativeDoubleUnOp>> p;
- p = Pointer.fromFunction(myTimesFour); //# 73: compile-time error
-}
-
-void testFromFunctionClosure() {
- DoubleUnOp someClosure = (double z) => z / 27.0;
- Pointer<NativeFunction<NativeDoubleUnOp>> p;
- p = Pointer.fromFunction(someClosure); //# 74: compile-time error
-}
-
-class X {
- double tearoff(double d) => d / 27.0;
-}
-
-DoubleUnOp fld = null;
-
-void testFromFunctionTearOff() {
- fld = X().tearoff;
- Pointer<NativeFunction<NativeDoubleUnOp>> p;
- p = Pointer.fromFunction(fld); //# 75: compile-time error
-}
-
-void testFromFunctionAbstract() {
- Pointer.fromFunction<Function>(//# 76: compile-time error
- testFromFunctionAbstract); //# 76: compile-time error
-}
-
-void testLookupFunctionGeneric() {
- Function generic<T extends Function>() {
- DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
- Function result;
- result = l.lookupFunction<T, DoubleUnOp>("cos"); //# 15: compile-time error
- return result;
- }
-
- generic<NativeDoubleUnOp>();
-}
-
-void testLookupFunctionGeneric2() {
- Function generic<T extends Function>() {
- DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
- Function result;
- result = //# 16: compile-time error
- l.lookupFunction<NativeDoubleUnOp, T>("cos"); //# 16: compile-time error
- return result;
- }
-
- generic<DoubleUnOp>();
-}
-
-void testLookupFunctionWrongNativeFunctionSignature() {
- DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
- l.lookupFunction<IntUnOp, IntUnOp>("cos"); //# 17: compile-time error
-}
-
-void testLookupFunctionTypeMismatch() {
- DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
- l.lookupFunction<NativeDoubleUnOp, IntUnOp>("cos"); //# 18: compile-time error
-}
-
-// TODO(dacoharkes): make the next 4 test compile errors
-typedef Invalid1 = int Function(Int8);
-typedef Invalid2 = Int8 Function(int);
-typedef Invalid3 = Int8 Function({Int8 named});
-typedef Invalid4 = Int8 Function([Int8 positional]);
-
-void testNativeFunctionSignatureInvalidReturn() {
- // Pointer<NativeFunction<Invalid1>> p = fromAddress(999);
-}
-
-void testNativeFunctionSignatureInvalidParam() {
- // Pointer<NativeFunction<Invalid2>> p = fromAddress(999);
-}
-
-void testNativeFunctionSignatureInvalidOptionalNamed() {
- // Pointer<NativeFunction<Invalid3>> p = fromAddress(999);
-}
-
-void testNativeFunctionSignatureInvalidOptionalPositional() {
- // Pointer<NativeFunction<Invalid4>> p = fromAddress(999);
-}
-
-// error on missing field annotation
-class TestStruct extends Struct {
- @Double()
- double x;
-
- double y; //# 50: compile-time error
-}
-
-// Cannot extend structs.
-class TestStruct3 extends TestStruct {} //# 52: compile-time error
-
-// error on double annotation
-class TestStruct4 extends Struct {
- @Double()
- @Double() //# 53: compile-time error
- double z;
-}
-
-// error on annotation not matching up
-class TestStruct5 extends Struct {
- @Int64() //# 54: compile-time error
- double z; //# 54: compile-time error
-}
-
-// error on annotation not matching up
-class TestStruct6 extends Struct {
- @Void() //# 55: compile-time error
- double z; //# 55: compile-time error
-}
-
-// error on annotation not matching up
-class TestStruct7 extends Struct {
- @NativeType() //# 56: compile-time error
- double z; //# 56: compile-time error
-}
-
-// error on field initializer on field
-class TestStruct8 extends Struct {
- @Double() //# 57: compile-time error
- double z = 10.0; //# 57: compile-time error
-}
-
-// error on field initializer in constructor
-class TestStruct9 extends Struct {
- @Double()
- double z;
-
- TestStruct9() : z = 0.0 {} //# 58: compile-time error
-}
-
-// Struct classes may not be generic.
-class TestStruct11<T> extends //# 60: compile-time error
- Struct<TestStruct11<dynamic>> {} //# 60: compile-time error
-
-// Structs may not appear inside structs (currently, there is no suitable
-// annotation).
-class TestStruct12 extends Struct {
- @Pointer //# 61: compile-time error
- TestStruct9 struct; //# 61: compile-time error
-}
-
-class DummyAnnotation {
- const DummyAnnotation();
-}
-
-// Structs fields may have other annotations.
-class TestStruct13 extends Struct {
- @DummyAnnotation()
- @Double()
- double z;
-}
-
-// Cannot extend native types.
-
-class ENativeType extends NativeType {} //# 90: compile-time error
-
-class EInt8 extends Int8 {} //# 91: compile-time error
-
-class EInt16 extends Int16 {} //# 92: compile-time error
-
-class EInt32 extends Int32 {} //# 93: compile-time error
-
-class EInt64 extends Int64 {} //# 94: compile-time error
-
-class EUint8 extends Uint8 {} //# 95: compile-time error
-
-class EUint16 extends Uint16 {} //# 96: compile-time error
-
-class EUint32 extends Uint32 {} //# 97: compile-time error
-
-class EUint64 extends Uint64 {} //# 98: compile-time error
-
-class EIntPtr extends IntPtr {} //# 99: compile-time error
-
-class EFloat extends Float {} //# 910: compile-time error
-
-class EDouble extends Double {} //# 911: compile-time error
-
-class EVoid extends Void {} //# 912: compile-time error
-
-class ENativeFunction extends NativeFunction {} //# 913: compile-time error
-
-class EPointer extends Pointer {} //# 914: compile-time error
-
-// Cannot implement native natives or Struct.
-
-// Cannot extend native types.
-
-class INativeType implements NativeType {} //# 80: compile-time error
-
-class IInt8 implements Int8 {} //# 81: compile-time error
-
-class IInt16 implements Int16 {} //# 82: compile-time error
-
-class IInt32 implements Int32 {} //# 83: compile-time error
-
-class IInt64 implements Int64 {} //# 84: compile-time error
-
-class IUint8 implements Uint8 {} //# 85: compile-time error
-
-class IUint16 implements Uint16 {} //# 86: compile-time error
-
-class IUint32 implements Uint32 {} //# 87: compile-time error
-
-class IUint64 implements Uint64 {} //# 88: compile-time error
-
-class IIntPtr implements IntPtr {} //# 88: compile-time error
-
-class IFloat implements Float {} //# 810: compile-time error
-
-class IDouble implements Double {} //# 811: compile-time error
-
-class IVoid implements Void {} //# 812: compile-time error
-
-class INativeFunction //# 813: compile-time error
- implements //# 813: compile-time error
- NativeFunction {} //# 813: compile-time error
-
-class IPointer implements Pointer {} //# 814: compile-time error
-
-class IStruct implements Struct {} //# 815: compile-time error
diff --git a/tests/ffi/structs_test.dart b/tests/ffi/structs_test.dart
index 669e837..263d562 100644
--- a/tests/ffi/structs_test.dart
+++ b/tests/ffi/structs_test.dart
@@ -6,8 +6,6 @@
//
// VMOptions=--deterministic --optimization-counter-threshold=50 --enable-inlining-annotations
-library FfiTest;
-
import 'dart:ffi';
import "package:expect/expect.dart";
diff --git a/tests/ffi/vmspecific_dynamic_library_test.dart b/tests/ffi/vmspecific_dynamic_library_test.dart
new file mode 100644
index 0000000..5c65c5c
--- /dev/null
+++ b/tests/ffi/vmspecific_dynamic_library_test.dart
@@ -0,0 +1,92 @@
+// Copyright (c) 2019, 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.
+//
+// Dart test program for testing dart:ffi dynamic library loading.
+//
+// SharedObjects=ffi_test_dynamic_library ffi_test_functions
+
+import 'dart:io';
+import 'dart:ffi';
+
+import 'package:expect/expect.dart';
+
+import 'dylib_utils.dart';
+
+void main() {
+ testOpen();
+ testOpenError();
+ testLookup();
+ testLookupError();
+ testToString();
+ testEquality();
+ testHandle();
+}
+
+void testOpen() {
+ DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ Expect.notEquals(null, l);
+}
+
+void testOpenError() {
+ Expect.throws(
+ () => dlopenPlatformSpecific("doesnotexistforsurelibrary123409876"));
+}
+
+typedef NativeDoubleUnOp = Double Function(Double);
+
+typedef DoubleUnOp = double Function(double);
+
+void testLookup() {
+ DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ var timesFour = l.lookupFunction<NativeDoubleUnOp, DoubleUnOp>("timesFour");
+ Expect.approxEquals(12.0, timesFour(3));
+
+ if (Platform.isMacOS ||
+ Platform.isIOS ||
+ Platform.isAndroid ||
+ Platform.isLinux) {
+ // Lookup a symbol from 'libc' since it's loaded with global visibility.
+ DynamicLibrary p = DynamicLibrary.process();
+ Expect.isTrue(p.lookup<Void>("strcmp") != nullptr);
+ } else {
+ Expect.throws<UnsupportedError>(() => DynamicLibrary.process());
+ }
+
+ DynamicLibrary e = DynamicLibrary.executable();
+ Expect.isTrue(e.lookup("Dart_Invoke") != nullptr);
+}
+
+void testLookupError() {
+ DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ Expect.throws(() => l.lookupFunction<NativeDoubleUnOp, DoubleUnOp>(
+ "functionnamethatdoesnotexistforsure749237593845"));
+}
+
+void testToString() {
+ DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ Expect.stringEquals(
+ "DynamicLibrary: handle=0x", l.toString().substring(0, 25));
+}
+
+void testEquality() {
+ DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ DynamicLibrary l2 = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ Expect.equals(l, l2);
+ Expect.equals(l.hashCode, l2.hashCode);
+ Expect.notEquals(l, null);
+ Expect.notEquals(null, l);
+ DynamicLibrary l3 = dlopenPlatformSpecific("ffi_test_functions");
+ Expect.notEquals(l, l3);
+}
+
+void testHandle() {
+ DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ DynamicLibrary l2 = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ Pointer<Void> h = l.handle;
+ Pointer<Void> h2 = l2.handle;
+ Expect.equals(h, h2);
+ DynamicLibrary l3 = dlopenPlatformSpecific("ffi_test_functions");
+ Pointer<Void> h3 = l3.handle;
+ Expect.notEquals(h, h3);
+}
diff --git a/tests/ffi/enable_ffi_test.dart b/tests/ffi/vmspecific_enable_ffi_test.dart
similarity index 100%
rename from tests/ffi/enable_ffi_test.dart
rename to tests/ffi/vmspecific_enable_ffi_test.dart
diff --git a/tests/ffi/vmspecific_function_callbacks_test.dart b/tests/ffi/vmspecific_function_callbacks_test.dart
new file mode 100644
index 0000000..6d4ab93
--- /dev/null
+++ b/tests/ffi/vmspecific_function_callbacks_test.dart
@@ -0,0 +1,103 @@
+// Copyright (c) 2019, 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.
+
+// VMOptions=--enable-testing-pragmas --enable-isolate-groups
+// VMOptions=--enable-testing-pragmas --no-enable-isolate-groups
+//
+// Dart test program for testing dart:ffi function pointers with callbacks.
+//
+// VMOptions=--enable-testing-pragmas
+// VMOptions=--enable-testing-pragmas --stacktrace-every=100
+// VMOptions=--enable-testing-pragmas --write-protect-code --no-dual-map-code
+// VMOptions=--enable-testing-pragmas --write-protect-code --no-dual-map-code --stacktrace-every=100
+// VMOptions=--use-slow-path --enable-testing-pragmas
+// VMOptions=--use-slow-path --enable-testing-pragmas --stacktrace-every=100
+// VMOptions=--use-slow-path --enable-testing-pragmas --write-protect-code --no-dual-map-code
+// VMOptions=--use-slow-path --enable-testing-pragmas --write-protect-code --no-dual-map-code --stacktrace-every=100
+// SharedObjects=ffi_test_functions
+
+import 'dart:io';
+import 'dart:ffi';
+import 'dart:isolate';
+import 'dylib_utils.dart';
+
+import "package:expect/expect.dart";
+
+import 'ffi_test_helpers.dart';
+import 'function_callbacks_test.dart' show Test, testLibrary,
+ NativeCallbackTest, NativeCallbackTestFn, ReturnVoid, returnVoid;
+
+void testGC() {
+ triggerGc();
+}
+
+typedef WaitForHelperNative = Void Function(Pointer<Void>);
+typedef WaitForHelper = void Function(Pointer<Void>);
+
+void waitForHelper(Pointer<Void> helper) {
+ print("helper: $helper");
+ testLibrary
+ .lookupFunction<WaitForHelperNative, WaitForHelper>("WaitForHelper")(helper);
+}
+
+final List<Test> testcases = [
+ Test("GC", Pointer.fromFunction<ReturnVoid>(testGC)),
+ Test("UnprotectCode", Pointer.fromFunction<WaitForHelperNative>(waitForHelper)),
+];
+
+testCallbackWrongThread() =>
+ Test("CallbackWrongThread", Pointer.fromFunction<ReturnVoid>(returnVoid))
+ .run();
+
+testCallbackOutsideIsolate() =>
+ Test("CallbackOutsideIsolate", Pointer.fromFunction<ReturnVoid>(returnVoid))
+ .run();
+
+isolateHelper(int callbackPointer) {
+ final Pointer<Void> ptr = Pointer.fromAddress(callbackPointer);
+ final NativeCallbackTestFn tester =
+ testLibrary.lookupFunction<NativeCallbackTest, NativeCallbackTestFn>(
+ "TestCallbackWrongIsolate");
+ Expect.equals(0, tester(ptr));
+}
+
+testCallbackWrongIsolate() async {
+ final int callbackPointer =
+ Pointer.fromFunction<ReturnVoid>(returnVoid).address;
+ final ReceivePort exitPort = ReceivePort();
+ await Isolate.spawn(isolateHelper, callbackPointer,
+ errorsAreFatal: true, onExit: exitPort.sendPort);
+ await exitPort.first;
+}
+
+const double zeroPointZero = 0.0;
+
+// Correct type of exceptionalReturn argument to Pointer.fromFunction.
+double testExceptionalReturn() {
+ Pointer.fromFunction<Double Function()>(testExceptionalReturn, 0.0);
+ Pointer.fromFunction<Double Function()>(testExceptionalReturn, zeroPointZero);
+
+ Pointer.fromFunction<Double Function()>(returnVoid, null); //# 59: compile-time error
+ Pointer.fromFunction<Void Function()>(returnVoid, 0); //# 60: compile-time error
+ Pointer.fromFunction<Double Function()>(testExceptionalReturn, "abc"); //# 61: compile-time error
+ Pointer.fromFunction<Double Function()>(testExceptionalReturn, 0); //# 62: compile-time error
+ Pointer.fromFunction<Double Function()>(testExceptionalReturn); //# 63: compile-time error
+
+ return 0.0; // not used
+}
+
+void main() async {
+ testcases.forEach((t) => t.run()); //# 00: ok
+ testExceptionalReturn(); //# 00: ok
+
+ // These tests terminate the process after successful completion, so we have
+ // to run them separately.
+ //
+ // Since they use signal handlers they only run on Linux.
+ if (Platform.isLinux && !const bool.fromEnvironment("dart.vm.product")) {
+ testCallbackWrongThread(); //# 01: ok
+ testCallbackOutsideIsolate(); //# 02: ok
+ await testCallbackWrongIsolate(); //# 03: ok
+ }
+}
diff --git a/tests/ffi/function_gc_test.dart b/tests/ffi/vmspecific_function_gc_test.dart
similarity index 100%
rename from tests/ffi/function_gc_test.dart
rename to tests/ffi/vmspecific_function_gc_test.dart
diff --git a/tests/ffi/vmspecific_function_test.dart b/tests/ffi/vmspecific_function_test.dart
new file mode 100644
index 0000000..00ea922
--- /dev/null
+++ b/tests/ffi/vmspecific_function_test.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2019, 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.
+//
+// Dart test program for testing dart:ffi function pointers.
+//
+// VMOptions=
+// VMOptions=--deterministic --optimization-counter-threshold=10
+// VMOptions=--use-slow-path
+// VMOptions=--use-slow-path --stacktrace-every=100
+// VMOptions=--write-protect-code --no-dual-map-code
+// VMOptions=--write-protect-code --no-dual-map-code --use-slow-path
+// VMOptions=--write-protect-code --no-dual-map-code --stacktrace-every=100
+// SharedObjects=ffi_test_functions
+
+import 'dart:ffi';
+
+import 'dylib_utils.dart';
+
+import "package:ffi/ffi.dart";
+import "package:expect/expect.dart";
+
+void main() {
+ for (int i = 0; i < 100; ++i) {
+ testLookupFunctionPointerNativeType();
+ }
+}
+
+final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
+
+typedef NativeTypeNFT = Pointer<NativeType> Function(
+ Pointer<Pointer<NativeType>>, Int8);
+typedef NativeTypeFT = Pointer<NativeType> Function(
+ Pointer<Pointer<NativeType>>, int);
+
+void testLookupFunctionPointerNativeType() {
+ // The function signature does not match up, but that does not matter since
+ // this test does not use the trampoline.
+ ffiTestFunctions.lookupFunction<NativeTypeNFT, NativeTypeFT>("LargePointer");
+}
diff --git a/tests/ffi/highmem_32bit_test.dart b/tests/ffi/vmspecific_highmem_32bit_test.dart
similarity index 100%
rename from tests/ffi/highmem_32bit_test.dart
rename to tests/ffi/vmspecific_highmem_32bit_test.dart
diff --git a/tests/ffi/vmspecific_object_gc_test.dart b/tests/ffi/vmspecific_object_gc_test.dart
new file mode 100644
index 0000000..c1d9f9c
--- /dev/null
+++ b/tests/ffi/vmspecific_object_gc_test.dart
@@ -0,0 +1,34 @@
+// Copyright (c) 2019, 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.
+//
+// Tests GC of Pointer objects.
+//
+// SharedObjects=ffi_test_functions
+
+import 'dart:ffi';
+
+import "package:expect/expect.dart";
+
+import 'dylib_utils.dart';
+
+DynamicLibrary ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
+
+final triggerGc = ffiTestFunctions
+ .lookupFunction<Void Function(), void Function()>("TriggerGC");
+
+void main() async {
+ testGC();
+}
+
+dynamic bar;
+
+Future<void> testGC() async {
+ bar = Pointer<Int8>.fromAddress(11);
+
+ // Verify that the objects manufactured by 'fromAddress' can be scanned by the
+ // GC.
+ triggerGc();
+
+ Expect.equals(11, bar.address);
+}
diff --git a/tests/ffi/regress_37100_test.dart b/tests/ffi/vmspecific_regress_37100_test.dart
similarity index 100%
rename from tests/ffi/regress_37100_test.dart
rename to tests/ffi/vmspecific_regress_37100_test.dart
diff --git a/tests/ffi/vmspecific_regress_37511_callbacks_test.dart b/tests/ffi/vmspecific_regress_37511_callbacks_test.dart
new file mode 100644
index 0000000..0153560
--- /dev/null
+++ b/tests/ffi/vmspecific_regress_37511_callbacks_test.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2019, 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.
+//
+// Dart test program for testing dart:ffi struct pointers.
+//
+// VMOptions=--deterministic --enable-testing-pragmas
+//
+// SharedObjects=ffi_test_functions
+//
+// TODO(37295): Merge this file with regress_37511_test.dart when callback
+// support lands.
+
+import 'dart:ffi';
+
+import 'ffi_test_helpers.dart';
+
+/// Estimate of how many allocations functions in `functionsToTest` do at most.
+const gcAfterNAllocationsMax = 10;
+
+void main() {
+ for (Function() f in functionsToTest) {
+ f(); // Ensure code is compiled.
+
+ for (int n = 1; n <= gcAfterNAllocationsMax; n++) {
+ collectOnNthAllocation(n);
+ f();
+ }
+ }
+}
+
+final List<Function()> functionsToTest = [
+ // Callback trampolines.
+ doFromFunction,
+ () => callbackSmallDouble(dartFunctionPointer),
+];
+
+// Callback trampoline helpers.
+typedef NativeCallbackTest = Int32 Function(Pointer);
+typedef NativeCallbackTestFn = int Function(Pointer);
+
+final callbackSmallDouble =
+ ffiTestFunctions.lookupFunction<NativeCallbackTest, NativeCallbackTestFn>(
+ "TestSimpleMultiply");
+
+typedef SimpleMultiplyType = Double Function(Double);
+double simpleMultiply(double x) => x * 1.337;
+
+final doFromFunction =
+ () => Pointer.fromFunction<SimpleMultiplyType>(simpleMultiply, 0.0);
+
+final dartFunctionPointer = doFromFunction();
diff --git a/tests/ffi/vmspecific_regress_37511_test.dart b/tests/ffi/vmspecific_regress_37511_test.dart
new file mode 100644
index 0000000..6d857e5
--- /dev/null
+++ b/tests/ffi/vmspecific_regress_37511_test.dart
@@ -0,0 +1,106 @@
+// Copyright (c) 2019, 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.
+//
+// Dart test program for testing dart:ffi struct pointers.
+//
+// VMOptions=--deterministic --enable-testing-pragmas
+//
+// SharedObjects=ffi_test_functions
+
+import 'dart:ffi';
+
+import 'dylib_utils.dart';
+import 'ffi_test_helpers.dart';
+
+/// Estimate of how many allocations functions in `functionsToTest` do at most.
+const gcAfterNAllocationsMax = 10;
+
+void main() {
+ for (Function() f in functionsToTest) {
+ f(); // Ensure code is compiled.
+
+ for (int n = 1; n <= gcAfterNAllocationsMax; n++) {
+ collectOnNthAllocation(n);
+ f();
+ }
+ }
+}
+
+final List<Function()> functionsToTest = [
+ // Pointer operations.
+ () => highAddressPointer.cast<Double>(),
+ () => Pointer.fromAddress(highAddressPointer.address),
+ () => highAddressPointer.address,
+ () => highAddressPointer.elementAt(1),
+ () => highAddressPointer.offsetBy(1),
+ () => highAddressPointer.asTypedList(1),
+
+ // DynamicLibrary operations.
+ doDlopen,
+ doDlsym, // Includes `asFunction`.
+ () => ffiTestFunctions.handle,
+
+ // Trampolines.
+ () => sumManyIntsOdd(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, mint64bit),
+ () => sumManyDoubles(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0),
+ minInt64,
+ minInt32,
+ smallDouble,
+ largePointer,
+
+ // Callback trampolines.
+ //
+ // In regress_37511_callbacks_test.dart because callbacks are not supported
+ // in AOT yet.
+];
+
+// Pointer operation helpers.
+const mint32bit = 0xFFFFFFF0;
+const mint64bit = 0x7FFFFFFFFFFFFFF0;
+
+final int highAddress = sizeOf<IntPtr>() == 4 ? mint32bit : mint64bit;
+
+final Pointer<Int64> highAddressPointer = Pointer.fromAddress(highAddress);
+
+// Dynamic library operation helpers.
+final doDlopen = () => dlopenPlatformSpecific("ffi_test_functions");
+
+final doDlsym = () => ffiTestFunctions
+ .lookupFunction<NativeNullaryOp, NullaryOpVoid>("TriggerGC");
+
+// Trampoline helpers.
+typedef NativeUndenaryOp = IntPtr Function(IntPtr, IntPtr, IntPtr, IntPtr,
+ IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr);
+typedef UndenaryOp = int Function(
+ int, int, int, int, int, int, int, int, int, int, int);
+
+final UndenaryOp sumManyIntsOdd = ffiTestFunctions
+ .lookupFunction<NativeUndenaryOp, UndenaryOp>("SumManyIntsOdd");
+
+typedef NativeDoubleDecenaryOp = Double Function(Double, Double, Double, Double,
+ Double, Double, Double, Double, Double, Double);
+typedef DoubleDecenaryOp = double Function(double, double, double, double,
+ double, double, double, double, double, double);
+
+final DoubleDecenaryOp sumManyDoubles = ffiTestFunctions
+ .lookupFunction<NativeDoubleDecenaryOp, DoubleDecenaryOp>("SumManyDoubles");
+
+typedef NativeNullaryOp64 = Int64 Function();
+typedef NativeNullaryOp32 = Int32 Function();
+typedef NativeNullaryOpDouble = Double Function();
+typedef NullaryOpPtr = Pointer<Void> Function();
+typedef NullaryOp = int Function();
+typedef NullaryOpDbl = double Function();
+
+final minInt64 =
+ ffiTestFunctions.lookupFunction<NativeNullaryOp64, NullaryOp>("MinInt64");
+
+final minInt32 =
+ ffiTestFunctions.lookupFunction<NativeNullaryOp32, NullaryOp>("MinInt32");
+
+final smallDouble = ffiTestFunctions
+ .lookupFunction<NativeNullaryOpDouble, NullaryOpDbl>("SmallDouble");
+
+final largePointer =
+ ffiTestFunctions.lookupFunction<NullaryOpPtr, NullaryOpPtr>("LargePointer");
diff --git a/tests/ffi/regress_37780_test.dart b/tests/ffi/vmspecific_regress_37780_test.dart
similarity index 100%
rename from tests/ffi/regress_37780_test.dart
rename to tests/ffi/vmspecific_regress_37780_test.dart
diff --git a/tests/ffi/regress_38993_test.dart b/tests/ffi/vmspecific_regress_38993_test.dart
similarity index 100%
rename from tests/ffi/regress_38993_test.dart
rename to tests/ffi/vmspecific_regress_38993_test.dart
diff --git a/tests/ffi/send_port_id_test.dart b/tests/ffi/vmspecific_send_port_id_test.dart
similarity index 100%
rename from tests/ffi/send_port_id_test.dart
rename to tests/ffi/vmspecific_send_port_id_test.dart
diff --git a/tests/ffi/vmspecific_static_checks_test.dart b/tests/ffi/vmspecific_static_checks_test.dart
new file mode 100644
index 0000000..3a54970
--- /dev/null
+++ b/tests/ffi/vmspecific_static_checks_test.dart
@@ -0,0 +1,451 @@
+// Copyright (c) 2019, 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.
+//
+// Dart test program for testing dart:ffi extra checks
+//
+// SharedObjects=ffi_test_dynamic_library
+
+import 'dart:ffi';
+
+import "package:ffi/ffi.dart";
+
+import 'dylib_utils.dart';
+
+void main() {
+ testGetGeneric();
+ testGetGeneric2();
+ testGetVoid();
+ testGetNativeFunction();
+ testGetNativeType();
+ testGetTypeMismatch();
+ testSetGeneric();
+ testSetGeneric2();
+ testSetVoid();
+ testSetNativeFunction();
+ testSetNativeType();
+ testSetTypeMismatch();
+ testAsFunctionGeneric();
+ testAsFunctionGeneric2();
+ testAsFunctionWrongNativeFunctionSignature();
+ testAsFunctionTypeMismatch();
+ testFromFunctionGeneric();
+ testFromFunctionGeneric2();
+ testFromFunctionWrongNativeFunctionSignature();
+ testFromFunctionTypeMismatch();
+ testFromFunctionClosure();
+ testFromFunctionTearOff();
+ testFromFunctionAbstract();
+ testLookupFunctionGeneric();
+ testLookupFunctionGeneric2();
+ testLookupFunctionWrongNativeFunctionSignature();
+ testLookupFunctionTypeMismatch();
+ testNativeFunctionSignatureInvalidReturn();
+ testNativeFunctionSignatureInvalidParam();
+ testNativeFunctionSignatureInvalidOptionalNamed();
+ testNativeFunctionSignatureInvalidOptionalPositional();
+}
+
+typedef Int8UnOp = Int8 Function(Int8);
+typedef IntUnOp = int Function(int);
+
+void testGetGeneric() {
+ int generic(Pointer p) {
+ int result;
+ result = p.value; //# 20: compile-time error
+ return result;
+ }
+
+ Pointer<Int8> p = allocate();
+ p.value = 123;
+ Pointer loseType = p;
+ generic(loseType);
+ free(p);
+}
+
+void testGetGeneric2() {
+ T generic<T extends Object>() {
+ Pointer<Int8> p = allocate();
+ p.value = 123;
+ T result;
+ result = p.value; //# 21: compile-time error
+ free(p);
+ return result;
+ }
+
+ generic<int>();
+}
+
+void testGetVoid() {
+ Pointer<IntPtr> p1 = allocate();
+ Pointer<Void> p2 = p1.cast();
+
+ p2.value; //# 22: compile-time error
+
+ free(p1);
+}
+
+void testGetNativeFunction() {
+ Pointer<NativeFunction<Int8UnOp>> p = Pointer.fromAddress(1337);
+ IntUnOp f = p.value; //# 23: compile-time error
+}
+
+void testGetNativeType() {
+ // Is it possible to obtain a Pointer<NativeType> at all?
+}
+
+void testGetTypeMismatch() {
+ Pointer<Pointer<Int16>> p = allocate();
+ Pointer<Int16> typedNull = nullptr;
+ p.value = typedNull;
+
+ // this fails to compile due to type mismatch
+ Pointer<Int8> p2 = p.value; //# 25: compile-time error
+
+ free(p);
+}
+
+void testSetGeneric() {
+ void generic(Pointer p) {
+ p.value = 123; //# 26: compile-time error
+ }
+
+ Pointer<Int8> p = allocate();
+ p.value = 123;
+ Pointer loseType = p;
+ generic(loseType);
+ free(p);
+}
+
+void testSetGeneric2() {
+ void generic<T extends Object>(T arg) {
+ Pointer<Int8> p = allocate();
+ p.value = arg; //# 27: compile-time error
+ free(p);
+ }
+
+ generic<int>(123);
+}
+
+void testSetVoid() {
+ Pointer<IntPtr> p1 = allocate();
+ Pointer<Void> p2 = p1.cast();
+
+ p2.value = 1234; //# 28: compile-time error
+
+ free(p1);
+}
+
+void testSetNativeFunction() {
+ Pointer<NativeFunction<Int8UnOp>> p = Pointer.fromAddress(1337);
+ IntUnOp f = (a) => a + 1;
+ p.value = f; //# 29: compile-time error
+}
+
+void testSetNativeType() {
+ // Is it possible to obtain a Pointer<NativeType> at all?
+}
+
+void testSetTypeMismatch() {
+ // the pointer to pointer types must match up
+ Pointer<Int8> pHelper = allocate();
+ pHelper.value = 123;
+
+ Pointer<Pointer<Int16>> p = allocate();
+
+ // this fails to compile due to type mismatch
+ p.value = pHelper; //# 40: compile-time error
+
+ free(pHelper);
+ free(p);
+}
+
+void testAsFunctionGeneric() {
+ T generic<T extends Function>() {
+ Pointer<NativeFunction<Int8UnOp>> p = Pointer.fromAddress(1337);
+ Function f;
+ f = p.asFunction<T>(); //# 11: compile-time error
+ return f;
+ }
+
+ generic<IntUnOp>();
+}
+
+void testAsFunctionGeneric2() {
+ generic(Pointer<NativeFunction> p) {
+ Function f;
+ f = p.asFunction<IntUnOp>(); //# 12: compile-time error
+ return f;
+ }
+
+ Pointer<NativeFunction<Int8UnOp>> p = Pointer.fromAddress(1337);
+ generic(p);
+}
+
+void testAsFunctionWrongNativeFunctionSignature() {
+ Pointer<NativeFunction<IntUnOp>> p;
+ Function f = p.asFunction<IntUnOp>(); //# 13: compile-time error
+}
+
+typedef IntBinOp = int Function(int, int);
+
+void testAsFunctionTypeMismatch() {
+ Pointer<NativeFunction<Int8UnOp>> p = Pointer.fromAddress(1337);
+ IntBinOp f = p.asFunction(); //# 14: compile-time error
+}
+
+typedef NativeDoubleUnOp = Double Function(Double);
+typedef DoubleUnOp = double Function(double);
+
+double myTimesThree(double d) => d * 3;
+
+int myTimesFour(int i) => i * 4;
+
+void testFromFunctionGeneric() {
+ Pointer<NativeFunction> generic<T extends Function>(T f) {
+ Pointer<NativeFunction<NativeDoubleUnOp>> result;
+ result = Pointer.fromFunction(f); //# 70: compile-time error
+ return result;
+ }
+
+ generic(myTimesThree);
+}
+
+void testFromFunctionGeneric2() {
+ Pointer<NativeFunction<T>> generic<T extends Function>() {
+ Pointer<NativeFunction<T>> result;
+ result = Pointer.fromFunction(myTimesThree); //# 71: compile-time error
+ return result;
+ }
+
+ generic<NativeDoubleUnOp>();
+}
+
+void testFromFunctionWrongNativeFunctionSignature() {
+ Pointer.fromFunction<IntUnOp>(myTimesFour); //# 72: compile-time error
+}
+
+void testFromFunctionTypeMismatch() {
+ Pointer<NativeFunction<NativeDoubleUnOp>> p;
+ p = Pointer.fromFunction(myTimesFour); //# 73: compile-time error
+}
+
+void testFromFunctionClosure() {
+ DoubleUnOp someClosure = (double z) => z / 27.0;
+ Pointer<NativeFunction<NativeDoubleUnOp>> p;
+ p = Pointer.fromFunction(someClosure); //# 74: compile-time error
+}
+
+class X {
+ double tearoff(double d) => d / 27.0;
+}
+
+DoubleUnOp fld = null;
+
+void testFromFunctionTearOff() {
+ fld = X().tearoff;
+ Pointer<NativeFunction<NativeDoubleUnOp>> p;
+ p = Pointer.fromFunction(fld); //# 75: compile-time error
+}
+
+void testFromFunctionAbstract() {
+ Pointer.fromFunction<Function>(//# 76: compile-time error
+ testFromFunctionAbstract); //# 76: compile-time error
+}
+
+void testLookupFunctionGeneric() {
+ Function generic<T extends Function>() {
+ DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ Function result;
+ result = l.lookupFunction<T, DoubleUnOp>("cos"); //# 15: compile-time error
+ return result;
+ }
+
+ generic<NativeDoubleUnOp>();
+}
+
+void testLookupFunctionGeneric2() {
+ Function generic<T extends Function>() {
+ DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ Function result;
+ result = //# 16: compile-time error
+ l.lookupFunction<NativeDoubleUnOp, T>("cos"); //# 16: compile-time error
+ return result;
+ }
+
+ generic<DoubleUnOp>();
+}
+
+void testLookupFunctionWrongNativeFunctionSignature() {
+ DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ l.lookupFunction<IntUnOp, IntUnOp>("cos"); //# 17: compile-time error
+}
+
+void testLookupFunctionTypeMismatch() {
+ DynamicLibrary l = dlopenPlatformSpecific("ffi_test_dynamic_library");
+ l.lookupFunction<NativeDoubleUnOp, IntUnOp>("cos"); //# 18: compile-time error
+}
+
+// TODO(dacoharkes): make the next 4 test compile errors
+typedef Invalid1 = int Function(Int8);
+typedef Invalid2 = Int8 Function(int);
+typedef Invalid3 = Int8 Function({Int8 named});
+typedef Invalid4 = Int8 Function([Int8 positional]);
+
+void testNativeFunctionSignatureInvalidReturn() {
+ // Pointer<NativeFunction<Invalid1>> p = fromAddress(999);
+}
+
+void testNativeFunctionSignatureInvalidParam() {
+ // Pointer<NativeFunction<Invalid2>> p = fromAddress(999);
+}
+
+void testNativeFunctionSignatureInvalidOptionalNamed() {
+ // Pointer<NativeFunction<Invalid3>> p = fromAddress(999);
+}
+
+void testNativeFunctionSignatureInvalidOptionalPositional() {
+ // Pointer<NativeFunction<Invalid4>> p = fromAddress(999);
+}
+
+// error on missing field annotation
+class TestStruct extends Struct {
+ @Double()
+ double x;
+
+ double y; //# 50: compile-time error
+}
+
+// Cannot extend structs.
+class TestStruct3 extends TestStruct {} //# 52: compile-time error
+
+// error on double annotation
+class TestStruct4 extends Struct {
+ @Double()
+ @Double() //# 53: compile-time error
+ double z;
+}
+
+// error on annotation not matching up
+class TestStruct5 extends Struct {
+ @Int64() //# 54: compile-time error
+ double z; //# 54: compile-time error
+}
+
+// error on annotation not matching up
+class TestStruct6 extends Struct {
+ @Void() //# 55: compile-time error
+ double z; //# 55: compile-time error
+}
+
+// error on annotation not matching up
+class TestStruct7 extends Struct {
+ @NativeType() //# 56: compile-time error
+ double z; //# 56: compile-time error
+}
+
+// error on field initializer on field
+class TestStruct8 extends Struct {
+ @Double() //# 57: compile-time error
+ double z = 10.0; //# 57: compile-time error
+}
+
+// error on field initializer in constructor
+class TestStruct9 extends Struct {
+ @Double()
+ double z;
+
+ TestStruct9() : z = 0.0 {} //# 58: compile-time error
+}
+
+// Struct classes may not be generic.
+class TestStruct11<T> extends //# 60: compile-time error
+ Struct<TestStruct11<dynamic>> {} //# 60: compile-time error
+
+// Structs may not appear inside structs (currently, there is no suitable
+// annotation).
+class TestStruct12 extends Struct {
+ @Pointer //# 61: compile-time error
+ TestStruct9 struct; //# 61: compile-time error
+}
+
+class DummyAnnotation {
+ const DummyAnnotation();
+}
+
+// Structs fields may have other annotations.
+class TestStruct13 extends Struct {
+ @DummyAnnotation()
+ @Double()
+ double z;
+}
+
+// Cannot extend native types.
+
+class ENativeType extends NativeType {} //# 90: compile-time error
+
+class EInt8 extends Int8 {} //# 91: compile-time error
+
+class EInt16 extends Int16 {} //# 92: compile-time error
+
+class EInt32 extends Int32 {} //# 93: compile-time error
+
+class EInt64 extends Int64 {} //# 94: compile-time error
+
+class EUint8 extends Uint8 {} //# 95: compile-time error
+
+class EUint16 extends Uint16 {} //# 96: compile-time error
+
+class EUint32 extends Uint32 {} //# 97: compile-time error
+
+class EUint64 extends Uint64 {} //# 98: compile-time error
+
+class EIntPtr extends IntPtr {} //# 99: compile-time error
+
+class EFloat extends Float {} //# 910: compile-time error
+
+class EDouble extends Double {} //# 911: compile-time error
+
+class EVoid extends Void {} //# 912: compile-time error
+
+class ENativeFunction extends NativeFunction {} //# 913: compile-time error
+
+class EPointer extends Pointer {} //# 914: compile-time error
+
+// Cannot implement native natives or Struct.
+
+// Cannot extend native types.
+
+class INativeType implements NativeType {} //# 80: compile-time error
+
+class IInt8 implements Int8 {} //# 81: compile-time error
+
+class IInt16 implements Int16 {} //# 82: compile-time error
+
+class IInt32 implements Int32 {} //# 83: compile-time error
+
+class IInt64 implements Int64 {} //# 84: compile-time error
+
+class IUint8 implements Uint8 {} //# 85: compile-time error
+
+class IUint16 implements Uint16 {} //# 86: compile-time error
+
+class IUint32 implements Uint32 {} //# 87: compile-time error
+
+class IUint64 implements Uint64 {} //# 88: compile-time error
+
+class IIntPtr implements IntPtr {} //# 88: compile-time error
+
+class IFloat implements Float {} //# 810: compile-time error
+
+class IDouble implements Double {} //# 811: compile-time error
+
+class IVoid implements Void {} //# 812: compile-time error
+
+class INativeFunction //# 813: compile-time error
+ implements //# 813: compile-time error
+ NativeFunction {} //# 813: compile-time error
+
+class IPointer implements Pointer {} //# 814: compile-time error
+
+class IStruct implements Struct {} //# 815: compile-time error
diff --git a/tests/ffi/variance_function_checks_test.dart b/tests/ffi/vmspecific_variance_function_checks_test.dart
similarity index 100%
rename from tests/ffi/variance_function_checks_test.dart
rename to tests/ffi/vmspecific_variance_function_checks_test.dart
diff --git a/tests/language_2/abstract_exact_selector_runtime_test.dart b/tests/language_2/abstract_exact_selector_runtime_test.dart
new file mode 100644
index 0000000..d13fbfe
--- /dev/null
+++ b/tests/language_2/abstract_exact_selector_runtime_test.dart
@@ -0,0 +1,41 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Regression test for dart2js that used to duplicate some `Object`
+// methods to handle `noSuchMethod`.
+
+import "package:expect/expect.dart";
+import "compiler_annotations.dart";
+
+
+ class Foo {
+ noSuchMethod(im) => 42;
+}
+
+@DontInline()
+returnFoo() {
+ (() => 42)();
+ return new Foo();
+}
+
+class Bar {
+ operator ==(other) => false;
+}
+
+var a = [false, true, new Object(), new Bar()];
+
+main() {
+ if (a[0]) {
+ // This `==` call will make the compiler create a selector with an
+ // exact `TypeMask` of `Foo`. Since `Foo` is abstract, such a call
+ // cannot happen, but we still used to generate a `==` method on
+ // the `Object` class to handle `noSuchMethod`.
+ print(returnFoo() == 42);
+ } else {
+ Expect.isFalse(a[2] == 42);
+ }
+}
diff --git a/tests/language_2/abstract_exact_selector_test.dart b/tests/language_2/abstract_exact_selector_test.dart
index 0b481aa..6aa06d8 100644
--- a/tests/language_2/abstract_exact_selector_test.dart
+++ b/tests/language_2/abstract_exact_selector_test.dart
@@ -8,7 +8,7 @@
import "package:expect/expect.dart";
import "compiler_annotations.dart";
-abstract //# 01: compile-time error
+abstract
class Foo {
noSuchMethod(im) => 42;
}
@@ -17,6 +17,9 @@
returnFoo() {
(() => 42)();
return new Foo();
+ // ^^^
+ // [analyzer] STATIC_WARNING.INSTANTIATE_ABSTRACT_CLASS
+ // [cfe] The class 'Foo' is abstract and can't be instantiated.
}
class Bar {
diff --git a/tests/language_2/abstract_factory_constructor_runtime_test.dart b/tests/language_2/abstract_factory_constructor_runtime_test.dart
new file mode 100644
index 0000000..8743c6d
--- /dev/null
+++ b/tests/language_2/abstract_factory_constructor_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Dart test program for constructors and initializers.
+
+// Exercises issue 2282, factory constructors in abstract classes should
+// not emit a static type warning
+
+class B extends A1 {
+ B() {}
+ method() {}
+}
+
+abstract class A1 {
+ A1() {}
+ method(); // Abstract.
+ factory A1.make() {
+ return new B();
+ }
+}
+
+class A2 {
+ // Intentionally abstract method.
+
+ A2.make() {}
+}
+
+main() {
+ new A1.make();
+
+}
diff --git a/tests/language_2/abstract_factory_constructor_test.dart b/tests/language_2/abstract_factory_constructor_test.dart
index 90713ca..bda6a23 100644
--- a/tests/language_2/abstract_factory_constructor_test.dart
+++ b/tests/language_2/abstract_factory_constructor_test.dart
@@ -20,12 +20,17 @@
}
class A2 {
+// ^
+// [cfe] The non-abstract class 'A2' is missing implementations for these members:
+
// Intentionally abstract method.
- method(); //# 00: compile-time error
+ method();
+//^^^^^^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
A2.make() {}
}
main() {
new A1.make();
- new A2.make(); //# 00: continued
+ new A2.make();
}
diff --git a/tests/language_2/abstract_getter_test.dart b/tests/language_2/abstract_getter_test.dart
index 73d43a3..fe5acdf 100644
--- a/tests/language_2/abstract_getter_test.dart
+++ b/tests/language_2/abstract_getter_test.dart
@@ -7,16 +7,21 @@
// Test to ensure that an abstract getter is not mistaken for a field.
class Foo {
+// ^
+// [cfe] The non-abstract class 'Foo' is missing implementations for these members:
+
// Intentionally abstract:
- get i; //# 01: compile-time error
+ get i;
+//^^^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
}
class Bar {}
checkIt(f) {
- Expect.throwsNoSuchMethodError(() => f.i = 'hi'); // //# 01: continued
- Expect.throwsNoSuchMethodError(() => print(f.i)); // //# 01: continued
- Expect.throwsNoSuchMethodError(() => print(f.i())); // //# 01: continued
+ Expect.throwsNoSuchMethodError(() => f.i = 'hi');
+ Expect.throwsNoSuchMethodError(() => print(f.i));
+ Expect.throwsNoSuchMethodError(() => print(f.i()));
}
main() {
diff --git a/tests/language_2/abstract_syntax_runtime_test.dart b/tests/language_2/abstract_syntax_runtime_test.dart
new file mode 100644
index 0000000..8646921
--- /dev/null
+++ b/tests/language_2/abstract_syntax_runtime_test.dart
@@ -0,0 +1,23 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ var b = new B();
+ Expect.equals(42, b.foo());
+}
+
+class A {
+
+
+}
+
+class B extends A {
+ foo() => 42;
+ bar() => 87;
+}
diff --git a/tests/language_2/abstract_syntax_test.dart b/tests/language_2/abstract_syntax_test.dart
index fba3725..1b617fd 100644
--- a/tests/language_2/abstract_syntax_test.dart
+++ b/tests/language_2/abstract_syntax_test.dart
@@ -10,8 +10,15 @@
}
class A {
- foo(); // //# 00: compile-time error
- static bar(); // //# 01: syntax error
+// ^
+// [cfe] The non-abstract class 'A' is missing implementations for these members:
+ foo();
+//^^^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
+ static bar();
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+ // [cfe] Expected a function body or '=>'.
}
class B extends A {
diff --git a/tests/language_2/argument_assignability_function_typed_runtime_1_test.dart b/tests/language_2/argument_assignability_function_typed_runtime_1_test.dart
new file mode 100644
index 0000000..4b6ea49
--- /dev/null
+++ b/tests/language_2/argument_assignability_function_typed_runtime_1_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+void f(num callback(num x)) {}
+
+Object intToObject(int x) => null;
+Object numToObject(num x) => null;
+Object objectToObject(Object x) => null;
+int intToInt(int x) => null;
+int numToInt(num x) => null;
+int objectToInt(Object x) => null;
+num intToNum(int x) => null;
+num numToNum(num x) => null;
+num objectToNum(Object x) => null;
+
+main() {
+ // Unrelated types (not assignable)
+
+
+
+ // Assignable but fails at runtime.
+ var intToObject2 = intToObject;
+ Expect.throwsTypeError(() => f(intToObject2));
+ var intToNum2 = intToNum;
+
+ var numToObject2 = numToObject;
+
+
+ // Ok
+
+
+
+
+}
diff --git a/tests/language_2/argument_assignability_function_typed_runtime_2_test.dart b/tests/language_2/argument_assignability_function_typed_runtime_2_test.dart
new file mode 100644
index 0000000..420f70a
--- /dev/null
+++ b/tests/language_2/argument_assignability_function_typed_runtime_2_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+void f(num callback(num x)) {}
+
+Object intToObject(int x) => null;
+Object numToObject(num x) => null;
+Object objectToObject(Object x) => null;
+int intToInt(int x) => null;
+int numToInt(num x) => null;
+int objectToInt(Object x) => null;
+num intToNum(int x) => null;
+num numToNum(num x) => null;
+num objectToNum(Object x) => null;
+
+main() {
+ // Unrelated types (not assignable)
+
+
+
+ // Assignable but fails at runtime.
+ var intToObject2 = intToObject;
+
+ var intToNum2 = intToNum;
+ Expect.throwsTypeError(() => f(intToNum2));
+ var numToObject2 = numToObject;
+
+
+ // Ok
+
+
+
+
+}
diff --git a/tests/language_2/argument_assignability_function_typed_runtime_3_test.dart b/tests/language_2/argument_assignability_function_typed_runtime_3_test.dart
new file mode 100644
index 0000000..0afae71
--- /dev/null
+++ b/tests/language_2/argument_assignability_function_typed_runtime_3_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+void f(num callback(num x)) {}
+
+Object intToObject(int x) => null;
+Object numToObject(num x) => null;
+Object objectToObject(Object x) => null;
+int intToInt(int x) => null;
+int numToInt(num x) => null;
+int objectToInt(Object x) => null;
+num intToNum(int x) => null;
+num numToNum(num x) => null;
+num objectToNum(Object x) => null;
+
+main() {
+ // Unrelated types (not assignable)
+
+
+
+ // Assignable but fails at runtime.
+ var intToObject2 = intToObject;
+
+ var intToNum2 = intToNum;
+
+ var numToObject2 = numToObject;
+ Expect.throwsTypeError(() => f(numToObject2));
+
+ // Ok
+
+
+
+
+}
diff --git a/tests/language_2/argument_assignability_function_typed_runtime_4_test.dart b/tests/language_2/argument_assignability_function_typed_runtime_4_test.dart
new file mode 100644
index 0000000..b33fb97
--- /dev/null
+++ b/tests/language_2/argument_assignability_function_typed_runtime_4_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+void f(num callback(num x)) {}
+
+Object intToObject(int x) => null;
+Object numToObject(num x) => null;
+Object objectToObject(Object x) => null;
+int intToInt(int x) => null;
+int numToInt(num x) => null;
+int objectToInt(Object x) => null;
+num intToNum(int x) => null;
+num numToNum(num x) => null;
+num objectToNum(Object x) => null;
+
+main() {
+ // Unrelated types (not assignable)
+
+
+
+ // Assignable but fails at runtime.
+ var intToObject2 = intToObject;
+
+ var intToNum2 = intToNum;
+
+ var numToObject2 = numToObject;
+
+
+ // Ok
+ f(numToNum);
+
+
+
+}
diff --git a/tests/language_2/argument_assignability_function_typed_runtime_5_test.dart b/tests/language_2/argument_assignability_function_typed_runtime_5_test.dart
new file mode 100644
index 0000000..df2ebb3
--- /dev/null
+++ b/tests/language_2/argument_assignability_function_typed_runtime_5_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+void f(num callback(num x)) {}
+
+Object intToObject(int x) => null;
+Object numToObject(num x) => null;
+Object objectToObject(Object x) => null;
+int intToInt(int x) => null;
+int numToInt(num x) => null;
+int objectToInt(Object x) => null;
+num intToNum(int x) => null;
+num numToNum(num x) => null;
+num objectToNum(Object x) => null;
+
+main() {
+ // Unrelated types (not assignable)
+
+
+
+ // Assignable but fails at runtime.
+ var intToObject2 = intToObject;
+
+ var intToNum2 = intToNum;
+
+ var numToObject2 = numToObject;
+
+
+ // Ok
+
+ f(numToInt);
+
+
+}
diff --git a/tests/language_2/argument_assignability_function_typed_runtime_6_test.dart b/tests/language_2/argument_assignability_function_typed_runtime_6_test.dart
new file mode 100644
index 0000000..f3cbfb8
--- /dev/null
+++ b/tests/language_2/argument_assignability_function_typed_runtime_6_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+void f(num callback(num x)) {}
+
+Object intToObject(int x) => null;
+Object numToObject(num x) => null;
+Object objectToObject(Object x) => null;
+int intToInt(int x) => null;
+int numToInt(num x) => null;
+int objectToInt(Object x) => null;
+num intToNum(int x) => null;
+num numToNum(num x) => null;
+num objectToNum(Object x) => null;
+
+main() {
+ // Unrelated types (not assignable)
+
+
+
+ // Assignable but fails at runtime.
+ var intToObject2 = intToObject;
+
+ var intToNum2 = intToNum;
+
+ var numToObject2 = numToObject;
+
+
+ // Ok
+
+
+ f(objectToNum);
+
+}
diff --git a/tests/language_2/argument_assignability_function_typed_runtime_7_test.dart b/tests/language_2/argument_assignability_function_typed_runtime_7_test.dart
new file mode 100644
index 0000000..2b7ba59
--- /dev/null
+++ b/tests/language_2/argument_assignability_function_typed_runtime_7_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+void f(num callback(num x)) {}
+
+Object intToObject(int x) => null;
+Object numToObject(num x) => null;
+Object objectToObject(Object x) => null;
+int intToInt(int x) => null;
+int numToInt(num x) => null;
+int objectToInt(Object x) => null;
+num intToNum(int x) => null;
+num numToNum(num x) => null;
+num objectToNum(Object x) => null;
+
+main() {
+ // Unrelated types (not assignable)
+
+
+
+ // Assignable but fails at runtime.
+ var intToObject2 = intToObject;
+
+ var intToNum2 = intToNum;
+
+ var numToObject2 = numToObject;
+
+
+ // Ok
+
+
+
+ f(objectToInt);
+}
diff --git a/tests/language_2/argument_assignability_function_typed_runtime_test.dart b/tests/language_2/argument_assignability_function_typed_runtime_test.dart
new file mode 100644
index 0000000..1b8c09e
--- /dev/null
+++ b/tests/language_2/argument_assignability_function_typed_runtime_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+void f(num callback(num x)) {}
+
+Object intToObject(int x) => null;
+Object numToObject(num x) => null;
+Object objectToObject(Object x) => null;
+int intToInt(int x) => null;
+int numToInt(num x) => null;
+int objectToInt(Object x) => null;
+num intToNum(int x) => null;
+num numToNum(num x) => null;
+num objectToNum(Object x) => null;
+
+main() {
+ // Unrelated types (not assignable)
+
+
+
+ // Assignable but fails at runtime.
+ var intToObject2 = intToObject;
+
+ var intToNum2 = intToNum;
+
+ var numToObject2 = numToObject;
+
+
+ // Ok
+
+
+
+
+}
diff --git a/tests/language_2/argument_assignability_function_typed_test.dart b/tests/language_2/argument_assignability_function_typed_test.dart
index 6d096a8..7e17271 100644
--- a/tests/language_2/argument_assignability_function_typed_test.dart
+++ b/tests/language_2/argument_assignability_function_typed_test.dart
@@ -18,20 +18,26 @@
main() {
// Unrelated types (not assignable)
- f(intToInt); //# 01: compile-time error
- f(objectToObject); //# 02: compile-time error
+ f(intToInt);
+ //^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'int Function(int)' can't be assigned to the parameter type 'num Function(num)'.
+ f(objectToObject);
+ //^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'Object Function(Object)' can't be assigned to the parameter type 'num Function(num)'.
// Assignable but fails at runtime.
var intToObject2 = intToObject;
- Expect.throwsTypeError(() => f(intToObject2)); //# 03: ok
+ Expect.throwsTypeError(() => f(intToObject2));
var intToNum2 = intToNum;
- Expect.throwsTypeError(() => f(intToNum2)); //# 04: ok
+ Expect.throwsTypeError(() => f(intToNum2));
var numToObject2 = numToObject;
- Expect.throwsTypeError(() => f(numToObject2)); //# 05: ok
+ Expect.throwsTypeError(() => f(numToObject2));
// Ok
- f(numToNum); //# 06: ok
- f(numToInt); //# 07: ok
- f(objectToNum); //# 08: ok
- f(objectToInt); //# 09: ok
+ f(numToNum);
+ f(numToInt);
+ f(objectToNum);
+ f(objectToInt);
}
diff --git a/tests/language_2/assert_trailing_comma_runtime_test.dart b/tests/language_2/assert_trailing_comma_runtime_test.dart
new file mode 100644
index 0000000..066c5f7
--- /dev/null
+++ b/tests/language_2/assert_trailing_comma_runtime_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+main() {
+ assert(true);
+ assert(true,);
+ assert(true,"message");
+ assert(true,"message",);
+
+
+}
diff --git a/tests/language_2/assert_trailing_comma_test.dart b/tests/language_2/assert_trailing_comma_test.dart
index e99c2af..7b90068 100644
--- a/tests/language_2/assert_trailing_comma_test.dart
+++ b/tests/language_2/assert_trailing_comma_test.dart
@@ -7,6 +7,12 @@
assert(true,);
assert(true,"message");
assert(true,"message",);
- assert(true,"message",extra); //# 01: syntax error
- assert(true,"message",,); //# 02: syntax error
+ assert(true,"message",extra);
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN
+ // [cfe] Unexpected token 'extra'.
+ assert(true,"message",,);
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN
+ // [cfe] Unexpected token ','.
}
diff --git a/tests/language_2/assertion_initializer_const_error2_runtime_test.dart b/tests/language_2/assertion_initializer_const_error2_runtime_test.dart
new file mode 100644
index 0000000..2ce838b
--- /dev/null
+++ b/tests/language_2/assertion_initializer_const_error2_runtime_test.dart
@@ -0,0 +1,87 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+// VMOptions=--enable-asserts
+// dart2jsOptions=--enable-asserts
+//
+// Test of asserts in initializer lists.
+
+import "package:expect/expect.dart";
+
+class C {
+ final int x;
+ // Const constructors.
+ const C.cc01(this.x, y) : assert(x < y);
+ const C.cc02(x, y)
+ : x = x,
+ assert(x < y);
+ const C.cc03(x, y)
+ : assert(x < y),
+ x = x;
+ const C.cc04(this.x, y)
+ : assert(x < y),
+ super();
+ const C.cc05(x, y)
+ : x = x,
+ assert(x < y),
+ super();
+ const C.cc06(x, y)
+ : assert(x < y),
+ x = x,
+ super();
+ const C.cc07(x, y)
+ : assert(x < y),
+ x = x,
+ assert(y > x),
+ super();
+ const C.cc08(this.x, y) : assert(x < y, "$x < $y");
+ const C.cc09(this.x, y) : assert(x < y,);
+ const C.cc10(this.x, y) : assert(x < y, "$x < $y",);
+}
+
+main() {
+ const x = 3;
+ {
+
+ const C.cc01(2, x);
+ }
+ {
+
+ const C.cc02(2, x);
+ }
+ {
+
+ const C.cc03(2, x);
+ }
+ {
+
+ const C.cc04(2, x);
+ }
+ {
+
+ const C.cc05(2, x);
+ }
+ {
+
+ const C.cc06(2, x);
+ }
+ {
+
+ const C.cc07(2, x);
+ }
+ {
+
+ const C.cc08(2, x);
+ }
+ {
+
+ const C.cc09(2, x);
+ }
+ {
+
+ const C.cc10(2, x);
+ }
+}
diff --git a/tests/language_2/assertion_initializer_const_error2_test.dart b/tests/language_2/assertion_initializer_const_error2_test.dart
index 02372d5..f5fa386 100644
--- a/tests/language_2/assertion_initializer_const_error2_test.dart
+++ b/tests/language_2/assertion_initializer_const_error2_test.dart
@@ -42,43 +42,83 @@
main() {
const x = 3;
{
- const x = 1; //# cc01: compile-time error
+ const x = 1;
const C.cc01(2, x);
+// ^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
}
{
- const x = 1; //# cc02: compile-time error
+ const x = 1;
const C.cc02(2, x);
+// ^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
}
{
- const x = 1; //# cc03: compile-time error
+ const x = 1;
const C.cc03(2, x);
+// ^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
}
{
- const x = 1; //# cc04: compile-time error
+ const x = 1;
const C.cc04(2, x);
+// ^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
}
{
- const x = 1; //# cc05: compile-time error
+ const x = 1;
const C.cc05(2, x);
+// ^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
}
{
- const x = 1; //# cc06: compile-time error
+ const x = 1;
const C.cc06(2, x);
+// ^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
}
{
- const x = 1; //# cc07: compile-time error
+ const x = 1;
const C.cc07(2, x);
+// ^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
}
{
- const x = 1; //# cc08: compile-time error
+ const x = 1;
const C.cc08(2, x);
+// ^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
}
{
- const x = 1; //# cc09: compile-time error
+ const x = 1;
const C.cc09(2, x);
+// ^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
}
{
- const x = 1; //# cc10: compile-time error
+ const x = 1;
const C.cc10(2, x);
+// ^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
}
}
diff --git a/tests/language_2/assertion_initializer_const_error_runtime_test.dart b/tests/language_2/assertion_initializer_const_error_runtime_test.dart
new file mode 100644
index 0000000..682d563
--- /dev/null
+++ b/tests/language_2/assertion_initializer_const_error_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+class C {
+ static bool check(x, y) => x < y;
+ final int x;
+ const C(this.x);
+ // The expression is not a potentially constant expression.
+ // This is a compile-time error even in production mode.
+ const C.bc03(this.x, y)
+
+ ;
+}
+
+main() {
+ var c = new C.bc03(1, 2);
+ if (c.x != 1) throw "non-trivial use of c";
+}
diff --git a/tests/language_2/assertion_initializer_const_error_test.dart b/tests/language_2/assertion_initializer_const_error_test.dart
index b01e736..d7ec1fb 100644
--- a/tests/language_2/assertion_initializer_const_error_test.dart
+++ b/tests/language_2/assertion_initializer_const_error_test.dart
@@ -9,7 +9,10 @@
// The expression is not a potentially constant expression.
// This is a compile-time error even in production mode.
const C.bc03(this.x, y)
- : assert(check(x, y)) //# 01: compile-time error
+ : assert(check(x, y))
+ // ^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Method invocation is not a constant expression.
;
}
diff --git a/tests/language_2/assertion_initializer_const_function_runtime_test.dart b/tests/language_2/assertion_initializer_const_function_runtime_test.dart
new file mode 100644
index 0000000..ff43fc1
--- /dev/null
+++ b/tests/language_2/assertion_initializer_const_function_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+class C {
+ static bool staticTrue() => true;
+ final int x;
+
+ // Functions as parameters to assert are no longer supported in Dart 2.0, so
+ // this is now a static type error.
+ const C.bc01(this.x, y)
+
+ ;
+}
+
+main() {
+ new C.bc01(1, 2);
+}
diff --git a/tests/language_2/assertion_initializer_const_function_test.dart b/tests/language_2/assertion_initializer_const_function_test.dart
index 5ed1d26..27b99bd 100644
--- a/tests/language_2/assertion_initializer_const_function_test.dart
+++ b/tests/language_2/assertion_initializer_const_function_test.dart
@@ -9,7 +9,10 @@
// Functions as parameters to assert are no longer supported in Dart 2.0, so
// this is now a static type error.
const C.bc01(this.x, y)
- : assert(staticTrue) //# 01: compile-time error
+ : assert(staticTrue)
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_BOOL_EXPRESSION
+ // [cfe] A value of type 'bool Function()' can't be assigned to a variable of type 'bool'.
;
}
diff --git a/tests/language_2/assign_static_type_runtime_test.dart b/tests/language_2/assign_static_type_runtime_test.dart
new file mode 100644
index 0000000..2b0c4a4
--- /dev/null
+++ b/tests/language_2/assign_static_type_runtime_test.dart
@@ -0,0 +1,28 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// This test insures that statically initialized variables, fields, and
+// parameters report compile-time errors.
+
+
+
+class A {
+
+
+
+ A() {
+
+ }
+ method(
+ [
+
+ g = "String"]) {
+ return g;
+ }
+}
+
+main() {}
diff --git a/tests/language_2/assign_static_type_test.dart b/tests/language_2/assign_static_type_test.dart
index a479264..d184bf4 100644
--- a/tests/language_2/assign_static_type_test.dart
+++ b/tests/language_2/assign_static_type_test.dart
@@ -5,19 +5,39 @@
// This test insures that statically initialized variables, fields, and
// parameters report compile-time errors.
-int a = "String"; //# 01: compile-time error
+int a = "String";
+// ^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
class A {
- static const int c = "String"; //# 02: compile-time error
- final int d = "String"; //# 03: compile-time error
- int e = "String"; //# 04: compile-time error
+ static const int c = "String";
+ // ^^^^^^^^
+ // [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.VARIABLE_TYPE_MISMATCH
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ final int d = "String";
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+ int e = "String";
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
A() {
- int f = "String"; //# 05: compile-time error
+ int f = "String";
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
}
method(
[
- int //# 06: compile-time error
+ int
g = "String"]) {
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
return g;
}
}
diff --git a/tests/language_2/assign_to_type_runtime_test.dart b/tests/language_2/assign_to_type_runtime_test.dart
new file mode 100644
index 0000000..ecb363e
--- /dev/null
+++ b/tests/language_2/assign_to_type_runtime_test.dart
@@ -0,0 +1,28 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify that an attempt to assign to a class, enum, typedef, or type
+// parameter produces a compile error.
+
+class C<T> {
+ f() {
+
+ }
+}
+
+class D {}
+
+enum E { e0 }
+
+typedef void F();
+
+main() {
+ new C<D>().f();
+
+
+
+}
diff --git a/tests/language_2/assign_to_type_test.dart b/tests/language_2/assign_to_type_test.dart
index c8e4932..3b09b48 100644
--- a/tests/language_2/assign_to_type_test.dart
+++ b/tests/language_2/assign_to_type_test.dart
@@ -7,7 +7,10 @@
class C<T> {
f() {
- T = null; //# 01: compile-time error
+ T = null;
+// ^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_TYPE
+// [cfe] Setter not found: 'T'.
}
}
@@ -19,7 +22,16 @@
main() {
new C<D>().f();
- D = null; //# 02: compile-time error
- E = null; //# 03: compile-time error
- F = null; //# 04: compile-time error
+ D = null;
+//^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_TYPE
+// [cfe] Setter not found: 'D'.
+ E = null;
+//^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_TYPE
+// [cfe] Setter not found: 'E'.
+ F = null;
+//^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_TYPE
+// [cfe] Setter not found: 'F'.
}
diff --git a/tests/language_2/assignable_expression_runtime_test.dart b/tests/language_2/assignable_expression_runtime_test.dart
new file mode 100644
index 0000000..942cb23
--- /dev/null
+++ b/tests/language_2/assignable_expression_runtime_test.dart
@@ -0,0 +1,47 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test to detect syntactically illegal left-hand-side (assignable)
+// expressions.
+
+class C {
+ static dynamic field = 0;
+}
+
+dynamic variable = 0;
+
+main() {
+ variable = 0;
+
+
+
+
+ C.field = 0;
+
+
+
+
+ variable = [1, 2, 3];
+ variable[0] = 0;
+ (variable)[0] = 0;
+
+
+
+
+ C.field = [1, 2, 3];
+
+
+
+
+ var a = 0;
+
+
+
+
+ // Neat palindrome expression. x is assignable, ((x)) is not.
+
+}
diff --git a/tests/language_2/assignable_expression_test.dart b/tests/language_2/assignable_expression_test.dart
index de041696..5bd904c 100644
--- a/tests/language_2/assignable_expression_test.dart
+++ b/tests/language_2/assignable_expression_test.dart
@@ -13,32 +13,101 @@
main() {
variable = 0;
- (variable) = 0; // //# 01: syntax error
- (variable)++; // //# 02: syntax error
- ++(variable); // //# 03: syntax error
+ (variable) = 0;
+//^^^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+//^^^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+// ^
+// [cfe] Can't assign to a parenthesized expression.
+ (variable)++;
+ // ^
+ // [cfe] Can't assign to a parenthesized expression.
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+ ++(variable);
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+ // [cfe] Can't assign to a parenthesized expression.
C.field = 0;
- (C.field) = 0; // //# 11: syntax error
- (C.field)++; // //# 12: syntax error
- ++(C.field); // //# 13: syntax error
+ (C.field) = 0;
+//^^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+//^^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+// ^
+// [cfe] Can't assign to a parenthesized expression.
+ (C.field)++;
+ // ^
+ // [cfe] Can't assign to a parenthesized expression.
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+ ++(C.field);
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+ // [cfe] Can't assign to a parenthesized expression.
variable = [1, 2, 3];
variable[0] = 0;
(variable)[0] = 0;
- (variable[0]) = 0; // //# 21: syntax error
- (variable[0])++; // //# 22: syntax error
- ++(variable[0]); // //# 23: syntax error
+ (variable[0]) = 0;
+//^^^^^^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+//^^^^^^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+// ^
+// [cfe] Can't assign to a parenthesized expression.
+ (variable[0])++;
+ // ^
+ // [cfe] Can't assign to a parenthesized expression.
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+ ++(variable[0]);
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+ // [cfe] Can't assign to a parenthesized expression.
C.field = [1, 2, 3];
- (C.field[0]) = 0; // //# 31: syntax error
- (C.field[0])++; // //# 32: syntax error
- ++(C.field[0]); // //# 33: syntax error
+ (C.field[0]) = 0;
+//^^^^^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+//^^^^^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+// ^
+// [cfe] Can't assign to a parenthesized expression.
+ (C.field[0])++;
+ // ^
+ // [cfe] Can't assign to a parenthesized expression.
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+ ++(C.field[0]);
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+ // [cfe] Can't assign to a parenthesized expression.
var a = 0;
- (a) = 0; // //# 41: syntax error
- (a)++; // //# 42: syntax error
- ++(a); // //# 43: syntax error
+ (a) = 0;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+//^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+// ^
+// [cfe] Can't assign to a parenthesized expression.
+ (a)++;
+ //^
+ // [cfe] Can't assign to a parenthesized expression.
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+ ++(a);
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+ // [cfe] Can't assign to a parenthesized expression.
// Neat palindrome expression. x is assignable, ((x)) is not.
- var funcnuf = (x) => ((x))=((x)) <= (x); // //# 50: syntax error
+ var funcnuf = (x) => ((x))=((x)) <= (x);
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+ // ^
+ // [cfe] Can't assign to a parenthesized expression.
}
diff --git a/tests/language_2/async_congruence_local_runtime_test.dart b/tests/language_2/async_congruence_local_runtime_test.dart
new file mode 100644
index 0000000..4c8e013
--- /dev/null
+++ b/tests/language_2/async_congruence_local_runtime_test.dart
@@ -0,0 +1,123 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// This test verifies that for a local async function, the following three
+// types are all appropriately matched:
+// - The static return type
+// - The return type of reified runtime type of a tearoff of the function or
+// method
+// - The reified type of the future returned by the function or method
+//
+// Specific attention is paid to the following conditions:
+// - The static return type is determined by type inference
+// - The static return type is `dynamic`
+// - The function or method immediately returns a value or future with a
+// different type (possibly using `=>` syntax)
+
+import 'dart:async';
+
+import 'package:expect/expect.dart';
+
+class A {}
+
+class B extends A {}
+
+class B2 extends A {}
+
+Future quick() async {}
+
+Future<B> futureB() => new Future<B>.value(new B());
+
+void checkDynamic(dynamic tearoff) {
+ Expect.isTrue(tearoff is dynamic Function());
+ Expect.isFalse(tearoff is Future<dynamic> Function());
+ dynamic f = tearoff();
+ Expect.isTrue(f is Future<dynamic>);
+ Expect.isFalse(f is Future<A>);
+}
+
+void checkFutureDynamic(dynamic tearoff) {
+ Expect.isTrue(tearoff is Future<dynamic> Function());
+ Expect.isFalse(tearoff is Future<A> Function());
+ dynamic f = tearoff();
+ Expect.isTrue(f is Future<dynamic>);
+ Expect.isFalse(f is Future<A>);
+}
+
+void checkFutureA(dynamic tearoff) {
+ Expect.isTrue(tearoff is Future<A> Function());
+ Expect.isFalse(tearoff is Future<B> Function());
+ dynamic f = tearoff();
+ Expect.isTrue(f is Future<A>);
+ Expect.isFalse(f is Future<B>);
+}
+
+main() {
+ f_inferred_futureDynamic() async {
+ await quick();
+ if (false) {
+ return 0;
+ } else {
+ return new A();
+ }
+ }
+
+ f_inferred_A() async {
+ await quick();
+ if (false) {
+ return new A();
+ } else {
+ return new B();
+ }
+ }
+
+ dynamic f_dynamic() async {
+ await quick();
+ return new B();
+ }
+
+ Future<A> f_A() async {
+ await quick();
+ return new B();
+ }
+
+ Future<A> f_immediateReturn_B() async {
+ return new B();
+ }
+
+ Future<A> f_immediateReturn_FutureB() async {
+ return futureB();
+ }
+
+ Future<A> f_expressionSyntax_B() async => new B();
+
+ Future<A> f_expressionSyntax_FutureB() async => futureB();
+
+ // Not executed
+ void checkStaticTypes() {
+ // Check that f_inferred_futureDynamic's static return type is
+ // `Future<dynamic>`, by verifying that its return value can be assigned to
+ // `Future<int>` but not `int`.
+ Future<int> v1 = f_inferred_futureDynamic();
+
+
+ // Check that f_inferred_A's static return type is `Future<A>`, by verifying
+ // that its return value can be assigned to `Future<B2>` but not
+ // `Future<int>`.
+ Future<B2> v3 = f_inferred_A();
+
+ }
+
+ checkFutureDynamic(f_inferred_futureDynamic);
+ checkFutureA(f_inferred_A);
+ checkDynamic(f_dynamic);
+ checkFutureA(f_A);
+ checkFutureA(f_immediateReturn_B);
+ checkFutureA(f_immediateReturn_FutureB);
+ checkFutureA(f_expressionSyntax_B);
+ checkFutureA(f_expressionSyntax_FutureB);
+}
diff --git a/tests/language_2/async_congruence_local_test.dart b/tests/language_2/async_congruence_local_test.dart
index 3e89b7c..e51ba25 100644
--- a/tests/language_2/async_congruence_local_test.dart
+++ b/tests/language_2/async_congruence_local_test.dart
@@ -100,13 +100,21 @@
// `Future<dynamic>`, by verifying that its return value can be assigned to
// `Future<int>` but not `int`.
Future<int> v1 = f_inferred_futureDynamic();
- int v2 = f_inferred_futureDynamic(); //# 01: compile-time error
+ int v2 = f_inferred_futureDynamic();
+ // ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'Future<Object>' can't be assigned to a variable of type 'int'.
// Check that f_inferred_A's static return type is `Future<A>`, by verifying
// that its return value can be assigned to `Future<B2>` but not
// `Future<int>`.
Future<B2> v3 = f_inferred_A();
- Future<int> v4 = f_inferred_A(); //# 02: compile-time error
+ Future<int> v4 = f_inferred_A();
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'Future<A>' can't be assigned to a variable of type 'Future<int>'.
}
checkFutureDynamic(f_inferred_futureDynamic);
diff --git a/tests/language_2/async_congruence_method_runtime_test.dart b/tests/language_2/async_congruence_method_runtime_test.dart
new file mode 100644
index 0000000..485941a
--- /dev/null
+++ b/tests/language_2/async_congruence_method_runtime_test.dart
@@ -0,0 +1,116 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// This test verifies that for an async method, the following three
+// types are all appropriately matched:
+// - The static return type
+// - The return type of reified runtime type of a tearoff of the function or
+// method
+// - The reified type of the future returned by the function or method
+//
+// Specific attention is paid to the following conditions:
+// - The static return type is determined by type inference
+// - The static return type is `dynamic`
+// - The function or method immediately returns a value or future with a
+// different type (possibly using `=>` syntax)
+
+import 'dart:async';
+
+import 'package:expect/expect.dart';
+
+class A {}
+
+class B extends A {}
+
+class B2 extends A {}
+
+Future quick() async {}
+
+Future<B> futureB() => new Future<B>.value(new B());
+
+abstract class I {
+ dynamic f_inferred_dynamic();
+ Future<A> f_inferred_A();
+}
+
+class C implements I {
+ f_inferred_dynamic() async {
+ await quick();
+ return new B();
+ }
+
+ f_inferred_A() async {
+ await quick();
+ return new B();
+ }
+
+ dynamic f_dynamic() async {
+ await quick();
+ return new B();
+ }
+
+ Future<A> f_A() async {
+ await quick();
+ return new B();
+ }
+
+ Future<A> f_immediateReturn_B() async {
+ return new B();
+ }
+
+ Future<A> f_immediateReturn_FutureB() async {
+ return futureB();
+ }
+
+ Future<A> f_expressionSyntax_B() async => new B();
+
+ Future<A> f_expressionSyntax_FutureB() async => futureB();
+}
+
+// Not executed
+void checkStaticTypes(C c) {
+ // Check that f_inferred_dynamic's static return type is `dynamic`, by
+ // verifying that no error occurs if we try to call `foo` on its return value.
+ c.f_inferred_dynamic().foo();
+
+ // Check that f_inferred_A's static return type is `Future<A>`, by verifying
+ // that its return value can be assigned to `Future<B2>` but not
+ // `Future<int>`.
+ Future<B2> v1 = c.f_inferred_A();
+
+}
+
+void checkDynamic(dynamic tearoff) {
+ Expect.isTrue(tearoff is dynamic Function());
+ Expect.isFalse(tearoff is Future<dynamic> Function());
+ dynamic f = tearoff();
+ Expect.isTrue(f is Future<dynamic>);
+ Expect.isFalse(f is Future<A>);
+}
+
+void checkFutureA(dynamic tearoff) {
+ Expect.isTrue(tearoff is Future<A> Function());
+ Expect.isFalse(tearoff is Future<B> Function());
+ dynamic f = tearoff();
+ Expect.isTrue(f is Future<A>);
+ Expect.isFalse(f is Future<B>);
+}
+
+void test(C c) {
+ checkDynamic(c.f_inferred_dynamic);
+ checkFutureA(c.f_inferred_A);
+ checkDynamic(c.f_dynamic);
+ checkFutureA(c.f_A);
+ checkFutureA(c.f_immediateReturn_B);
+ checkFutureA(c.f_immediateReturn_FutureB);
+ checkFutureA(c.f_expressionSyntax_B);
+ checkFutureA(c.f_expressionSyntax_FutureB);
+}
+
+main() {
+ test(new C());
+}
diff --git a/tests/language_2/async_congruence_method_test.dart b/tests/language_2/async_congruence_method_test.dart
index a463b25..69f63d7 100644
--- a/tests/language_2/async_congruence_method_test.dart
+++ b/tests/language_2/async_congruence_method_test.dart
@@ -78,7 +78,11 @@
// that its return value can be assigned to `Future<B2>` but not
// `Future<int>`.
Future<B2> v1 = c.f_inferred_A();
- Future<int> v2 = c.f_inferred_A(); //# 01: compile-time error
+ Future<int> v2 = c.f_inferred_A();
+ // ^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'Future<A>' can't be assigned to a variable of type 'Future<int>'.
}
void checkDynamic(dynamic tearoff) {
diff --git a/tests/language_2/async_congruence_unnamed_runtime_test.dart b/tests/language_2/async_congruence_unnamed_runtime_test.dart
new file mode 100644
index 0000000..66961b2
--- /dev/null
+++ b/tests/language_2/async_congruence_unnamed_runtime_test.dart
@@ -0,0 +1,135 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// This test verifies that for an unnamed async closure, the following three
+// types are all appropriately matched:
+// - The static return type
+// - The return type of reified runtime type of a tearoff of the function or
+// method
+// - The reified type of the future returned by the function or method
+//
+// Specific attention is paid to the following conditions:
+// - The static return type is determined by type inference
+// - The static return type is `dynamic`
+// - The function or method immediately returns a value or future with a
+// different type (possibly using `=>` syntax)
+
+import 'dart:async';
+
+import 'package:expect/expect.dart';
+
+class A {}
+
+class B extends A {}
+
+class B2 extends A {}
+
+Future quick() async {}
+
+Future<A> futureA() => new Future<A>.value(new A());
+
+Future<B> futureB() => new Future<B>.value(new B());
+
+void checkFutureDynamic(dynamic tearoff) {
+ Expect.isTrue(tearoff is Future<dynamic> Function());
+ Expect.isFalse(tearoff is Future<A> Function());
+ dynamic f = tearoff();
+ Expect.isTrue(f is Future<dynamic>);
+ Expect.isFalse(f is Future<A>);
+}
+
+void checkFutureA(dynamic tearoff) {
+ Expect.isTrue(tearoff is Future<A> Function());
+ Expect.isFalse(tearoff is Future<B> Function());
+ dynamic f = tearoff();
+ Expect.isTrue(f is Future<A>);
+ Expect.isFalse(f is Future<B>);
+}
+
+main() {
+ var f_inferred_futureDynamic = () async {
+ await quick();
+ if (false) {
+ return 0;
+ } else {
+ return new A();
+ }
+ };
+
+ var f_inferred_A = () async {
+ await quick();
+ if (false) {
+ return new A();
+ } else {
+ return new B();
+ }
+ };
+
+ Future<dynamic> Function() f_futureDynamic = () async {
+ await quick();
+ if (false) {
+ return 0;
+ } else {
+ return new B();
+ }
+ };
+
+ Future<A> Function() f_A = () async {
+ await quick();
+ if (false) {
+ return new A();
+ } else {
+ return new B();
+ }
+ };
+
+ Future<A> Function() f_immediateReturn_B = () async {
+ if (false) {
+ return new A();
+ } else {
+ return new B();
+ }
+ };
+
+ Future<A> Function() f_immediateReturn_FutureB = () async {
+ if (false) {
+ return new A();
+ } else {
+ return futureB();
+ }
+ };
+
+ Future<A> Function() f_expressionSyntax_B =
+ () async => false ? new A() : new B();
+
+ Future<A> Function() f_expressionSyntax_FutureB =
+ () async => false ? futureA() : futureB();
+
+ // Not executed
+ void checkStaticTypes() {
+ // Check that f_inferred_futureDynamic's static return type is
+ // `Future<dynamic>`, by verifying that its return value can be assigned to
+ // `Future<int>` but not `int`.
+ Future<int> v1 = f_inferred_futureDynamic();
+
+
+ // Check that f_inferred_A's static return type is `Future<A>`, by verifying
+ // that its return value can be assigned to `Future<B2>` but not
+ // `Future<int>`.
+ Future<B2> v3 = f_inferred_A();
+
+ }
+
+ checkFutureDynamic(f_inferred_futureDynamic);
+ checkFutureA(f_inferred_A);
+ checkFutureDynamic(f_futureDynamic);
+ checkFutureA(f_A);
+ checkFutureA(f_immediateReturn_B);
+ checkFutureA(f_immediateReturn_FutureB);
+ checkFutureA(f_expressionSyntax_B);
+ checkFutureA(f_expressionSyntax_FutureB);
+}
diff --git a/tests/language_2/async_congruence_unnamed_test.dart b/tests/language_2/async_congruence_unnamed_test.dart
index 237e471..7bb0228 100644
--- a/tests/language_2/async_congruence_unnamed_test.dart
+++ b/tests/language_2/async_congruence_unnamed_test.dart
@@ -112,13 +112,21 @@
// `Future<dynamic>`, by verifying that its return value can be assigned to
// `Future<int>` but not `int`.
Future<int> v1 = f_inferred_futureDynamic();
- int v2 = f_inferred_futureDynamic(); //# 01: compile-time error
+ int v2 = f_inferred_futureDynamic();
+ // ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'Future<Object>' can't be assigned to a variable of type 'int'.
// Check that f_inferred_A's static return type is `Future<A>`, by verifying
// that its return value can be assigned to `Future<B2>` but not
// `Future<int>`.
Future<B2> v3 = f_inferred_A();
- Future<int> v4 = f_inferred_A(); //# 02: compile-time error
+ Future<int> v4 = f_inferred_A();
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'Future<A>' can't be assigned to a variable of type 'Future<int>'.
}
checkFutureDynamic(f_inferred_futureDynamic);
diff --git a/tests/language_2/async_or_generator_return_type_stacktrace_runtime_test.dart b/tests/language_2/async_or_generator_return_type_stacktrace_runtime_test.dart
new file mode 100644
index 0000000..e41973a
--- /dev/null
+++ b/tests/language_2/async_or_generator_return_type_stacktrace_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import "package:expect/expect.dart";
+
+
+
+
+
+void main() {}
diff --git a/tests/language_2/async_or_generator_return_type_stacktrace_test.dart b/tests/language_2/async_or_generator_return_type_stacktrace_test.dart
index f5bd334..39fdb56 100644
--- a/tests/language_2/async_or_generator_return_type_stacktrace_test.dart
+++ b/tests/language_2/async_or_generator_return_type_stacktrace_test.dart
@@ -4,8 +4,20 @@
import "package:expect/expect.dart";
-int badReturnTypeAsync() async {} // //# 01: compile-time error
-int badReturnTypeAsyncStar() async* {} // //# 02: compile-time error
-int badReturnTypeSyncStar() sync* {} // //# 03: compile-time error
+int badReturnTypeAsync() async {}
+// [error line 7, column 1, length 3]
+// [analyzer] STATIC_TYPE_WARNING.ILLEGAL_ASYNC_RETURN_TYPE
+// ^
+// [cfe] Functions marked 'async' must have a return type assignable to 'Future'.
+int badReturnTypeAsyncStar() async* {}
+// [error line 12, column 1, length 3]
+// [analyzer] STATIC_TYPE_WARNING.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE
+// ^
+// [cfe] Functions marked 'async*' must have a return type assignable to 'Stream'.
+int badReturnTypeSyncStar() sync* {}
+// [error line 17, column 1, length 3]
+// [analyzer] STATIC_TYPE_WARNING.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
+// ^
+// [cfe] Functions marked 'sync*' must have a return type assignable to 'Iterable'.
void main() {}
diff --git a/tests/language_2/async_return_types_runtime_test.dart b/tests/language_2/async_return_types_runtime_test.dart
new file mode 100644
index 0000000..b8c1de6
--- /dev/null
+++ b/tests/language_2/async_return_types_runtime_test.dart
@@ -0,0 +1,75 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import "dart:async";
+import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
+
+Future foo1() async {
+ return 3;
+}
+
+Future<int> foo2() async {
+ return 3;
+}
+
+
+foo3() async {
+ return "String";
+}
+
+
+foo4() async {
+ return "String";
+}
+
+
+foo5() async {
+ return 3;
+}
+
+Future<int> foo6() async {
+ // This is fine, the future is flattened
+ return new Future<int>.value(3);
+}
+
+
+foo7() async {
+ return new Future<int>.value(3);
+}
+
+Iterable<int> foo8() sync* {
+ yield 1;
+ // Can only have valueless return in sync* functions.
+ return
+
+ ;
+}
+
+Stream<int> foo9() async* {
+ yield 1;
+ // Can only have valueless return in async* functions.
+ return
+
+ ;
+}
+
+test() async {
+ Expect.equals(3, await foo1());
+ Expect.equals(3, await foo2());
+ Expect.equals("String", await foo3());
+ Expect.equals("String", await foo4());
+ Expect.equals(3, await foo5());
+ Expect.equals(3, await await foo6());
+ Expect.equals(3, await await foo7());
+ Expect.listEquals([1], foo8().toList());
+ Expect.listEquals([1], await foo9().toList());
+}
+
+main() {
+ asyncTest(test);
+}
diff --git a/tests/language_2/async_return_types_test.dart b/tests/language_2/async_return_types_test.dart
index eae381b..473150f 100644
--- a/tests/language_2/async_return_types_test.dart
+++ b/tests/language_2/async_return_types_test.dart
@@ -14,19 +14,35 @@
return 3;
}
-Future<int> //# wrongTypeParameter: compile-time error
+Future<int>
foo3() async {
return "String";
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.RETURN_OF_INVALID_TYPE
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'FutureOr<int>'.
}
-Future<int, String> //# tooManyTypeParameters: compile-time error
+Future<int, String>
+// [error line 25, column 1, length 19]
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 1 type arguments.
foo4() async {
+// [error line 29, column 1]
+// [cfe] Functions marked 'async' must have a return type assignable to 'Future'.
return "String";
+ // ^
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'FutureOr<invalid-type>'.
}
-int //# wrongReturnType: compile-time error
+int
+// [error line 37, column 1, length 3]
+// [analyzer] STATIC_TYPE_WARNING.ILLEGAL_ASYNC_RETURN_TYPE
foo5() async {
+// [error line 40, column 1]
+// [cfe] Functions marked 'async' must have a return type assignable to 'Future'.
return 3;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.RETURN_OF_INVALID_TYPE
}
Future<int> foo6() async {
@@ -34,25 +50,33 @@
return new Future<int>.value(3);
}
-Future<Future<int>> //# nestedFuture: compile-time error
+Future<Future<int>>
foo7() async {
return new Future<int>.value(3);
+ // ^^^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.RETURN_OF_INVALID_TYPE
}
Iterable<int> foo8() sync* {
yield 1;
// Can only have valueless return in sync* functions.
- return
- 8 //# return_value_sync_star: compile-time error
- ;
+ return 8;
+//^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATOR
+// [cfe] 'sync*' and 'async*' can't return a value.
+//^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATOR
}
Stream<int> foo9() async* {
yield 1;
// Can only have valueless return in async* functions.
- return
- 8 //# return_value_sync_star: compile-time error
- ;
+ return 8;
+//^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATOR
+// [cfe] 'sync*' and 'async*' can't return a value.
+//^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATOR
}
test() async {
diff --git a/tests/language_2/await_backwards_compatibility_runtime_test.dart b/tests/language_2/await_backwards_compatibility_runtime_test.dart
new file mode 100644
index 0000000..e257558
--- /dev/null
+++ b/tests/language_2/await_backwards_compatibility_runtime_test.dart
@@ -0,0 +1,49 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import 'dart:async';
+
+import 'package:expect/expect.dart';
+
+get await => 4;
+
+// For functions that are declared with the async modifier we treat await as
+// keyword.
+
+test0() async {
+ var x = await 7;
+ Expect.equals(7, x);
+
+}
+
+test1() async {
+ var x = await 9;
+ Expect.equals(9, x);
+
+}
+
+// For functions that are not declared with the async modifier we allow await to
+// be used as an identifier.
+
+test2() {
+ var y = await;
+ Expect.equals(4, y);
+
+}
+
+test3() {
+ var await = 3;
+ Expect.equals(3, await);
+
+}
+
+main() {
+ test0();
+ test1();
+ test2();
+ test3();
+}
diff --git a/tests/language_2/await_backwards_compatibility_test.dart b/tests/language_2/await_backwards_compatibility_test.dart
index 0d9b248..ea6084c 100644
--- a/tests/language_2/await_backwards_compatibility_test.dart
+++ b/tests/language_2/await_backwards_compatibility_test.dart
@@ -14,13 +14,19 @@
test0() async {
var x = await 7;
Expect.equals(7, x);
- var await = 1; // //# await1: syntax error
+ var await = 1;
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
+ // [cfe] 'await' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
}
test1() async {
var x = await 9;
Expect.equals(9, x);
- var y = await; // //# await2: syntax error
+ var y = await;
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected an identifier, but got ';'.
}
// For functions that are not declared with the async modifier we allow await to
@@ -29,13 +35,19 @@
test2() {
var y = await;
Expect.equals(4, y);
- var x = await 1; // //# await3: compile-time error
+ var x = await 1;
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected ';' after this.
}
test3() {
var await = 3;
Expect.equals(3, await);
- var x = await 1; // //# await4: compile-time error
+ var x = await 1;
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected ';' after this.
}
main() {
diff --git a/tests/language_2/bad_constructor_runtime_1_test.dart b/tests/language_2/bad_constructor_runtime_1_test.dart
new file mode 100644
index 0000000..4269607
--- /dev/null
+++ b/tests/language_2/bad_constructor_runtime_1_test.dart
@@ -0,0 +1,37 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// A constructor can't be static.
+class A {
+
+ A();
+}
+
+// A factory constructor can't be static.
+class B {
+
+ factory B() { return null; }
+}
+
+// A named constructor can have the same name as a setter.
+class E {
+ set setter(value) {}
+ E.setter();
+}
+
+// A constructor can't be static.
+class F {
+
+ F(){}
+}
+
+main() {
+ new A();
+ new B();
+ new E.setter();
+ new F();
+}
diff --git a/tests/language_2/bad_constructor_runtime_test.dart b/tests/language_2/bad_constructor_runtime_test.dart
new file mode 100644
index 0000000..40d8378
--- /dev/null
+++ b/tests/language_2/bad_constructor_runtime_test.dart
@@ -0,0 +1,37 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// A constructor can't be static.
+class A {
+
+ A();
+}
+
+// A factory constructor can't be static.
+class B {
+
+ factory B() { return null; }
+}
+
+// A named constructor can have the same name as a setter.
+class E {
+
+ E.setter();
+}
+
+// A constructor can't be static.
+class F {
+
+ F(){}
+}
+
+main() {
+ new A();
+ new B();
+ new E.setter();
+ new F();
+}
diff --git a/tests/language_2/bad_constructor_test.dart b/tests/language_2/bad_constructor_test.dart
index 10b9f42..5a12ca5 100644
--- a/tests/language_2/bad_constructor_test.dart
+++ b/tests/language_2/bad_constructor_test.dart
@@ -4,25 +4,37 @@
// A constructor can't be static.
class A {
- static //# 00: syntax error
+ static
+//^^^^^^
+// [analyzer] SYNTACTIC_ERROR.STATIC_CONSTRUCTOR
+// [cfe] Constructors can't be static.
A();
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+ // [cfe] Expected a function body or '=>'.
}
// A factory constructor can't be static.
class B {
- static //# 01: syntax error
+ static
+//^^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'static' here.
factory B() { return null; }
}
// A named constructor can have the same name as a setter.
class E {
- set setter(value) {} //# 05: ok
+ set setter(value) {}
E.setter();
}
// A constructor can't be static.
class F {
- static //# 07: compile-time error
+ static
+//^^^^^^
+// [analyzer] SYNTACTIC_ERROR.STATIC_CONSTRUCTOR
+// [cfe] Constructors can't be static.
F(){}
}
diff --git a/tests/language_2/bad_initializer1_runtime_test.dart b/tests/language_2/bad_initializer1_runtime_test.dart
new file mode 100644
index 0000000..e97f36b
--- /dev/null
+++ b/tests/language_2/bad_initializer1_runtime_test.dart
@@ -0,0 +1,23 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// Variable initializer must not reference the initialized variable.
+
+main() {
+ const elems = const [
+ const [
+ 1,
+ 2.0,
+ true,
+ false,
+ 0xffffffffff,
+
+ ],
+ "a",
+ "b"
+ ];
+}
diff --git a/tests/language_2/bad_initializer1_test.dart b/tests/language_2/bad_initializer1_test.dart
index 21edfa4..0070cd8 100644
--- a/tests/language_2/bad_initializer1_test.dart
+++ b/tests/language_2/bad_initializer1_test.dart
@@ -6,13 +6,19 @@
main() {
const elems = const [
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_COMPILE_TIME_CONSTANT
+ // [cfe] Can't declare 'elems' because it was already used in this scope.
const [
1,
2.0,
true,
false,
0xffffffffff,
- elems //# 01: compile-time error
+ elems
+// ^^^^^
+// [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
+// [cfe] Getter not found: 'elems'.
],
"a",
"b"
diff --git a/tests/language_2/bad_initializer2_runtime_test.dart b/tests/language_2/bad_initializer2_runtime_test.dart
new file mode 100644
index 0000000..5163cf0
--- /dev/null
+++ b/tests/language_2/bad_initializer2_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Variable initializer must not reference the initialized variable.
+import "package:expect/expect.dart";
+
+main() {
+ var foo = (int n) {
+ if (n == 0) {
+ return 0;
+ } else {
+ return 1
+
+ ;
+ }
+ };
+ foo(1);
+}
diff --git a/tests/language_2/bad_initializer2_test.dart b/tests/language_2/bad_initializer2_test.dart
index 7fb5475..384511a 100644
--- a/tests/language_2/bad_initializer2_test.dart
+++ b/tests/language_2/bad_initializer2_test.dart
@@ -7,13 +7,20 @@
main() {
var foo = (int n) {
+ // ^
+ // [cfe] Can't declare 'foo' because it was already used in this scope.
if (n == 0) {
return 0;
} else {
return 1
- + foo(n - 1) //# 01: compile-time error
+ + foo(n - 1)
+ //^^^
+ // [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
+ // [cfe] Method not found: 'foo'.
;
}
};
foo(1);
+//^
+// [cfe] Method not found: 'foo'.
}
diff --git a/tests/language_2/bad_named_constructor_runtime_test.dart b/tests/language_2/bad_named_constructor_runtime_test.dart
new file mode 100644
index 0000000..c84de90
--- /dev/null
+++ b/tests/language_2/bad_named_constructor_runtime_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+class A {
+ A() {}
+
+}
+
+main() {
+ new A();
+}
diff --git a/tests/language_2/bad_named_constructor_test.dart b/tests/language_2/bad_named_constructor_test.dart
index f00187f..b7fc8f2 100644
--- a/tests/language_2/bad_named_constructor_test.dart
+++ b/tests/language_2/bad_named_constructor_test.dart
@@ -4,7 +4,10 @@
class A {
A() {}
- WrongName.foo() {} //# 01: compile-time error
+ WrongName.foo() {}
+//^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTRUCTOR_NAME
+// [cfe] The name of a constructor must match the name of the enclosing class.
}
main() {
diff --git a/tests/language_2/bad_named_parameters2_runtime_test.dart b/tests/language_2/bad_named_parameters2_runtime_test.dart
new file mode 100644
index 0000000..5e30826
--- /dev/null
+++ b/tests/language_2/bad_named_parameters2_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Dart test program for testing bad named parameters.
+
+class BadNamedParameters2Test {
+ int foo(int a) {
+ // Although no optional named parameters are declared, we must check that
+ // no named arguments are passed in, either here or in the resolving stub.
+ return a;
+ }
+}
+
+main() {
+ BadNamedParameters2Test np = new BadNamedParameters2Test();
+
+ // No formal parameter named b.
+
+}
diff --git a/tests/language_2/bad_named_parameters2_test.dart b/tests/language_2/bad_named_parameters2_test.dart
index b64af40..131909b 100644
--- a/tests/language_2/bad_named_parameters2_test.dart
+++ b/tests/language_2/bad_named_parameters2_test.dart
@@ -15,5 +15,10 @@
BadNamedParameters2Test np = new BadNamedParameters2Test();
// No formal parameter named b.
- np.foo(b: 25); //# 01: compile-time error
+ np.foo(b: 25);
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
}
diff --git a/tests/language_2/bad_named_parameters_runtime_test.dart b/tests/language_2/bad_named_parameters_runtime_test.dart
new file mode 100644
index 0000000..66e75ee
--- /dev/null
+++ b/tests/language_2/bad_named_parameters_runtime_test.dart
@@ -0,0 +1,38 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Dart test program for testing bad named parameters.
+
+import "package:expect/expect.dart";
+
+class BadNamedParametersTest {
+ int f42(int a, {int b: 20, int c: 30}) {
+ return 100 * (100 * a + b) + c;
+ }
+
+ int f52(int a, {int b: 20, int c, int d: 40}) {
+ return 100 * (100 * (100 * a + b) + (c == null ? 0 : c)) + d;
+ }
+}
+
+main() {
+ BadNamedParametersTest np = new BadNamedParametersTest();
+
+ // Parameter b passed twice.
+
+
+ // Parameter x does not exist.
+
+
+ // Parameter b1 does not exist.
+
+
+ // Too many parameters.
+
+
+ // Too few parameters.
+
+}
diff --git a/tests/language_2/bad_named_parameters_test.dart b/tests/language_2/bad_named_parameters_test.dart
index 5e03fd0..173e340 100644
--- a/tests/language_2/bad_named_parameters_test.dart
+++ b/tests/language_2/bad_named_parameters_test.dart
@@ -19,17 +19,34 @@
BadNamedParametersTest np = new BadNamedParametersTest();
// Parameter b passed twice.
- np.f42(10, 25, b: 25); //# 01: compile-time error
+ np.f42(10, 25, b: 25);
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
// Parameter x does not exist.
- np.f42(10, 25, x: 99); //# 02: compile-time error
+ np.f42(10, 25, x: 99);
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
// Parameter b1 does not exist.
- np.f52(10, b: 25, b1: 99, c: 35); //# 03: compile-time error
+ np.f52(10, b: 25, b1: 99, c: 35);
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'b1'.
// Too many parameters.
- np.f42(10, 20, 30, 40); //# 04: compile-time error
+ np.f42(10, 20, 30, 40);
+ // ^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 1 allowed, but 4 found.
// Too few parameters.
- np.f42(b: 25); //# 05: compile-time error
+ np.f42(b: 25);
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
}
diff --git a/tests/language_2/bad_override_runtime_test.dart b/tests/language_2/bad_override_runtime_test.dart
new file mode 100644
index 0000000..1e2abe5
--- /dev/null
+++ b/tests/language_2/bad_override_runtime_test.dart
@@ -0,0 +1,33 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+class Fisk {
+ get fisk => null;
+
+ set fisk(x) {}
+
+
+ get hest => null;
+ set hest(x) {}
+
+ foo() {}
+ var field;
+ method() {}
+ nullary() {}
+}
+
+class Hest extends Fisk {
+
+
+
+
+}
+
+main() {
+ new Fisk();
+ new Hest();
+}
diff --git a/tests/language_2/bad_override_test.dart b/tests/language_2/bad_override_test.dart
index 02cb97f..07400d2 100644
--- a/tests/language_2/bad_override_test.dart
+++ b/tests/language_2/bad_override_test.dart
@@ -4,11 +4,17 @@
class Fisk {
get fisk => null;
- static // //# 01: compile-time error
+ static
set fisk(x) {}
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] This static member conflicts with an instance member.
- static // //# 02: compile-time error
+ static
get hest => null;
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] This static member conflicts with an instance member.
set hest(x) {}
foo() {}
@@ -18,10 +24,22 @@
}
class Hest extends Fisk {
- static foo() {} // //# 03: compile-time error
- field() {} // //# 04: compile-time error
- var method; // //# 05: compile-time error
- nullary(x) {} // //# 06: compile-time error
+ static foo() {}
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
+ field() {}
+//^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_METHOD_AND_FIELD
+// [cfe] Can't declare a member that conflicts with an inherited one.
+ var method;
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_FIELD_AND_METHOD
+ // [cfe] Can't declare a member that conflicts with an inherited one.
+ nullary(x) {}
+//^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+// [cfe] The method 'Hest.nullary' has more required arguments than those of overridden method 'Fisk.nullary'.
}
main() {
diff --git a/tests/language_2/bad_raw_string_runtime_test.dart b/tests/language_2/bad_raw_string_runtime_test.dart
new file mode 100644
index 0000000..4046aa5
--- /dev/null
+++ b/tests/language_2/bad_raw_string_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2016, 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.
+
+main() {
+ // Raw String may not contain newline (may not be multi-line).
+ String x = ''
+
+
+
+
+ // Test that a raw string containing just one character, a \n char, fails.
+ // Enclose the test string in a bigger multiline string, except in case 03:
+
+ """
+
+ r'
+'
+
+ """
+
+ ;
+}
diff --git a/tests/language_2/bad_raw_string_test.dart b/tests/language_2/bad_raw_string_test.dart
index e40d8e2..7091ebae 100644
--- a/tests/language_2/bad_raw_string_test.dart
+++ b/tests/language_2/bad_raw_string_test.dart
@@ -5,19 +5,41 @@
main() {
// Raw String may not contain newline (may not be multi-line).
String x = ''
- r' // //# 01: syntax error
-' // //# 01: continued
- r" // //# 02: syntax error
-" // //# 02: continued
+ r'
+// ^
+// [cfe] String starting with r' must end with '.
+// ^
+// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
+'
+// [error line 13, column 1, length 1]
+// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
+// [cfe] String starting with ' must end with '.
+ r"
+// ^
+// [cfe] String starting with r" must end with ".
+// ^
+// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
+"
+// [error line 22, column 1, length 1]
+// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
+// [cfe] String starting with " must end with ".
+
// Test that a raw string containing just one character, a \n char, fails.
// Enclose the test string in a bigger multiline string, except in case 03:
- ''' // //# 03: syntax error
+ '''
"""
- ''' // //# 03: continued
+ '''
r'
+// ^
+// [cfe] String starting with r' must end with '.
+// ^
+// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
'
- ''' // //# 03: continued
+// [error line 37, column 1, length 1]
+// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
+// [cfe] String starting with ' must end with '.
+ '''
"""
- ''' // //# 03: continued
+ '''
;
}
diff --git a/tests/language_2/bad_typedef_runtime_test.dart b/tests/language_2/bad_typedef_runtime_test.dart
new file mode 100644
index 0000000..274f7e7
--- /dev/null
+++ b/tests/language_2/bad_typedef_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2016, 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.
+// Dart test for a function type test that cannot be eliminated at compile time.
+
+import "package:expect/expect.dart";
+
+typedef int H(
+ Function
+
+ x);
+
+main() {
+ bool b = true;
+ Expect.isFalse(b is H);
+}
diff --git a/tests/language_2/bad_typedef_test.dart b/tests/language_2/bad_typedef_test.dart
index 14974ff..c49eea8 100644
--- a/tests/language_2/bad_typedef_test.dart
+++ b/tests/language_2/bad_typedef_test.dart
@@ -7,8 +7,11 @@
typedef int H(
Function
- Function //# 00: syntax error
+ Function
x);
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ')' before this.
main() {
bool b = true;
diff --git a/tests/language_2/bodyless_constructor_wrong_arg_runtime_test.dart b/tests/language_2/bodyless_constructor_wrong_arg_runtime_test.dart
new file mode 100644
index 0000000..6a6c07e
--- /dev/null
+++ b/tests/language_2/bodyless_constructor_wrong_arg_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+class Base {
+ final String name;
+ const Base(this.name);
+}
+
+class C extends Base {
+ const C(String s)
+ : super(
+ // Call super constructor with wrong argument count.
+
+ s
+
+ );
+}
+
+main() {
+ const C("str");
+}
diff --git a/tests/language_2/bodyless_constructor_wrong_arg_test.dart b/tests/language_2/bodyless_constructor_wrong_arg_test.dart
index b136ed3..4e669d0 100644
--- a/tests/language_2/bodyless_constructor_wrong_arg_test.dart
+++ b/tests/language_2/bodyless_constructor_wrong_arg_test.dart
@@ -9,12 +9,11 @@
class C extends Base {
const C(String s)
- : super(
- // Call super constructor with wrong argument count.
- /* //# 01: compile-time error
- s
- */ //# 01: continued
- );
+ // Call super constructor with wrong argument count.
+ : super();
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
}
main() {
diff --git a/tests/language_2/break_outside_loop_runtime_test.dart b/tests/language_2/break_outside_loop_runtime_test.dart
new file mode 100644
index 0000000..b4879cf
--- /dev/null
+++ b/tests/language_2/break_outside_loop_runtime_test.dart
@@ -0,0 +1,13 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+// Dart test program to test check that we catch label errors.
+
+main() {
+ if (true) {
+
+ }
+}
diff --git a/tests/language_2/break_outside_loop_test.dart b/tests/language_2/break_outside_loop_test.dart
index 5fab9e1..6cfbbbd 100644
--- a/tests/language_2/break_outside_loop_test.dart
+++ b/tests/language_2/break_outside_loop_test.dart
@@ -5,6 +5,9 @@
main() {
if (true) {
- break; //# 01: compile-time error
+ break;
+// ^^^^^
+// [analyzer] SYNTACTIC_ERROR.BREAK_OUTSIDE_OF_LOOP
+// [cfe] A break statement can't be used outside of a loop or switch statement.
}
}
diff --git a/tests/language_2/bug34235_runtime_test.dart b/tests/language_2/bug34235_runtime_test.dart
new file mode 100644
index 0000000..9cedc8e
--- /dev/null
+++ b/tests/language_2/bug34235_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Base {
+ void foo() {}
+}
+
+class M1 {
+ void foo(
+ // Prevent formatter from joining the line below to the one above
+
+ ) {}
+}
+
+class BaseWithM1 = Base with M1;
+
+class M2 {
+ void foo() {}
+}
+
+class Derived extends BaseWithM1 with M2 {}
+
+main() {
+ new Derived().foo();
+}
diff --git a/tests/language_2/bug34235_test.dart b/tests/language_2/bug34235_test.dart
index 69011ff..d8bf539 100644
--- a/tests/language_2/bug34235_test.dart
+++ b/tests/language_2/bug34235_test.dart
@@ -9,7 +9,7 @@
class M1 {
void foo(
// Prevent formatter from joining the line below to the one above
- {x} //# 01: compile-time error
+ {x}
) {}
}
@@ -20,6 +20,11 @@
}
class Derived extends BaseWithM1 with M2 {}
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+// [cfe] Applying the mixin 'M2' to 'BaseWithM1' introduces an erroneous override of 'foo'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
main() {
new Derived().foo();
diff --git a/tests/language_2/built_in_identifier_illegal_runtime_test.dart b/tests/language_2/built_in_identifier_illegal_runtime_test.dart
new file mode 100644
index 0000000..ab96118
--- /dev/null
+++ b/tests/language_2/built_in_identifier_illegal_runtime_test.dart
@@ -0,0 +1,28 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Check that we cannot use a pseudo keyword at the class level code.
+
+// Pseudo keywords are not allowed to be used as class names.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+main() {}
diff --git a/tests/language_2/built_in_identifier_illegal_test.dart b/tests/language_2/built_in_identifier_illegal_test.dart
index 030aa76..13c9235 100644
--- a/tests/language_2/built_in_identifier_illegal_test.dart
+++ b/tests/language_2/built_in_identifier_illegal_test.dart
@@ -4,22 +4,179 @@
// Check that we cannot use a pseudo keyword at the class level code.
// Pseudo keywords are not allowed to be used as class names.
-class abstract { } // //# abstract: syntax error
-class as { } // //# as: syntax error
-class dynamic { } // //# dynamic: compile-time error
-class export { } // //# export: syntax error
-class external { } // //# external: syntax error
-class factory { } // //# factory: syntax error
-class get { } // //# get: syntax error
-class interface { } // //# interface: syntax error
-class implements { } // //# implements: syntax error
-class import { } // //# import: syntax error
-class mixin { } // //# mixin: syntax error
-class library { } // //# library: syntax error
-class operator { } // //# operator: syntax error
-class part { } // //# part: syntax error
-class set { } // //# set: syntax error
-class static { } // //# static: syntax error
-class typedef { } // //# typedef: syntax error
+class abstract { }
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
+// [cfe] Can't use 'abstract' as a name here.
+class as { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
+// [cfe] Can't use 'as' as a name here.
+class dynamic { }
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
+// [cfe] Can't use 'dynamic' as a name here.
+class export { }
+// ^^^^^^
+// [analyzer] SYNTACTIC_ERROR.DIRECTIVE_AFTER_DECLARATION
+// [cfe] A class declaration must have a body, even if it is empty.
+// ^^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+// [cfe] Directives must appear before any declarations.
+// ^^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got 'export'.
+// [error line 19, column 14, length 0]
+// [analyzer] COMPILE_TIME_ERROR.INVALID_URI
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
+// [cfe] Expected a String, but got '{'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_STRING_LITERAL
+// [cfe] Expected a declaration, but got '{'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+class external { }
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
+// [cfe] Can't use 'external' as a name here.
+class factory { }
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
+// [cfe] Can't use 'factory' as a name here.
+class get { }
+// ^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+// [cfe] A class declaration must have a body, even if it is empty.
+// ^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_PARAMETERS
+// [cfe] A function declaration needs an explicit list of parameters.
+// ^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got 'get'.
+class interface { }
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
+// [cfe] Can't use 'interface' as a name here.
+class implements { }
+// ^^^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got 'implements'.
+// [error line 62, column 18, length 0]
+// [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
+// [cfe] Expected a type, but got '{'.
+// [error line 62, column 18, length 0]
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TYPE_NAME
+class import { }
+// ^^^^^^
+// [analyzer] SYNTACTIC_ERROR.DIRECTIVE_AFTER_DECLARATION
+// [cfe] A class declaration must have a body, even if it is empty.
+// ^^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+// [cfe] Directives must appear before any declarations.
+// ^^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got 'import'.
+// [error line 73, column 14, length 0]
+// [analyzer] COMPILE_TIME_ERROR.INVALID_URI
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
+// [cfe] Expected a String, but got '{'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_STRING_LITERAL
+// [cfe] Expected a declaration, but got '{'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+class mixin { }
+// ^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+// [cfe] A class declaration must have a body, even if it is empty.
+// ^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got 'mixin'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got '{'.
+class library { }
+// ^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+// [cfe] A class declaration must have a body, even if it is empty.
+// ^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.LIBRARY_DIRECTIVE_NOT_FIRST
+// [cfe] Expected an identifier, but got 'library'.
+// ^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] The library directive must appear before all other directives.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got '{'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected a declaration, but got '}'.
+class operator { }
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
+// [cfe] Can't use 'operator' as a name here.
+class part { }
+// ^^^^
+// [analyzer] SYNTACTIC_ERROR.DIRECTIVE_AFTER_DECLARATION
+// [cfe] A class declaration must have a body, even if it is empty.
+// ^^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+// [cfe] Directives must appear before any declarations.
+// ^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got 'part'.
+// [error line 127, column 12, length 0]
+// [analyzer] COMPILE_TIME_ERROR.INVALID_URI
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
+// [cfe] Expected a String, but got '{'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_STRING_LITERAL
+// [cfe] Expected a declaration, but got '{'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+class set { }
+// ^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+// [cfe] A class declaration must have a body, even if it is empty.
+// ^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_PARAMETERS
+// [cfe] A function declaration needs an explicit list of parameters.
+// ^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got 'set'.
+class static { }
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.BUILT_IN_IDENTIFIER_AS_TYPE_NAME
+// [cfe] Can't use 'static' as a name here.
+class typedef { }
+// ^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+// [cfe] A class declaration must have a body, even if it is empty.
+// ^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got 'typedef'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got '{'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
+// [cfe] A typedef needs an explicit list of parameters.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_TYPEDEF_PARAMETERS
+// [cfe] Expected a declaration, but got '}'.
main() {}
diff --git a/tests/language_2/call_constructor_on_unresolvable_class_runtime_test.dart b/tests/language_2/call_constructor_on_unresolvable_class_runtime_test.dart
new file mode 100644
index 0000000..0c30e8b
--- /dev/null
+++ b/tests/language_2/call_constructor_on_unresolvable_class_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// Check that calling a constructor of a class that cannot be resolved causes
+// compile error.
+
+import "package:expect/expect.dart";
+import 'dart:math';
+
+main() {
+
+
+
+}
diff --git a/tests/language_2/call_constructor_on_unresolvable_class_test.dart b/tests/language_2/call_constructor_on_unresolvable_class_test.dart
index 86a4091..d068b53 100644
--- a/tests/language_2/call_constructor_on_unresolvable_class_test.dart
+++ b/tests/language_2/call_constructor_on_unresolvable_class_test.dart
@@ -9,7 +9,16 @@
import 'dart:math';
main() {
- new A(); // //# 01: compile-time error
- new A.foo(); // //# 02: compile-time error
- new lib.A(); // //# 03: compile-time error
+ new A();
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // [cfe] Method not found: 'A'.
+ new A.foo();
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // [cfe] Method not found: 'A.foo'.
+ new lib.A();
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // [cfe] Method not found: 'lib.A'.
}
diff --git a/tests/language_2/call_method_implicit_invoke_local_runtime_1_test.dart b/tests/language_2/call_method_implicit_invoke_local_runtime_1_test.dart
new file mode 100644
index 0000000..5df9be0
--- /dev/null
+++ b/tests/language_2/call_method_implicit_invoke_local_runtime_1_test.dart
@@ -0,0 +1,35 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+// Dart test program to test arithmetic operations.
+
+import "package:expect/expect.dart";
+
+class C1 {
+ int call(int i) => 2 * i;
+}
+
+class C2 implements Function {
+ int call(int i) => 2 * i;
+}
+
+main() {
+ C1 c1 = new C1();
+ // Implicitly invokes c1.call(1)
+ Expect.equals(c1(1), 2);
+ dynamic d1 = c1;
+ // Implicitly invokes d1.call(1)
+
+ C2 c2 = new C2();
+ // Implicitly invokes c2.call(1)
+
+ dynamic d2 = c2;
+ // Implicitly invokes d2.call(1)
+
+ // Cannot invoke with the wrong signature.
+
+
+}
diff --git a/tests/language_2/call_method_implicit_invoke_local_runtime_2_test.dart b/tests/language_2/call_method_implicit_invoke_local_runtime_2_test.dart
new file mode 100644
index 0000000..b4b00f4
--- /dev/null
+++ b/tests/language_2/call_method_implicit_invoke_local_runtime_2_test.dart
@@ -0,0 +1,35 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+// Dart test program to test arithmetic operations.
+
+import "package:expect/expect.dart";
+
+class C1 {
+ int call(int i) => 2 * i;
+}
+
+class C2 implements Function {
+ int call(int i) => 2 * i;
+}
+
+main() {
+ C1 c1 = new C1();
+ // Implicitly invokes c1.call(1)
+
+ dynamic d1 = c1;
+ // Implicitly invokes d1.call(1)
+ Expect.equals(d1(1), 2);
+ C2 c2 = new C2();
+ // Implicitly invokes c2.call(1)
+
+ dynamic d2 = c2;
+ // Implicitly invokes d2.call(1)
+
+ // Cannot invoke with the wrong signature.
+
+
+}
diff --git a/tests/language_2/call_method_implicit_invoke_local_runtime_3_test.dart b/tests/language_2/call_method_implicit_invoke_local_runtime_3_test.dart
new file mode 100644
index 0000000..215d998
--- /dev/null
+++ b/tests/language_2/call_method_implicit_invoke_local_runtime_3_test.dart
@@ -0,0 +1,35 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+// Dart test program to test arithmetic operations.
+
+import "package:expect/expect.dart";
+
+class C1 {
+ int call(int i) => 2 * i;
+}
+
+class C2 implements Function {
+ int call(int i) => 2 * i;
+}
+
+main() {
+ C1 c1 = new C1();
+ // Implicitly invokes c1.call(1)
+
+ dynamic d1 = c1;
+ // Implicitly invokes d1.call(1)
+
+ C2 c2 = new C2();
+ // Implicitly invokes c2.call(1)
+ Expect.equals(c2(1), 2);
+ dynamic d2 = c2;
+ // Implicitly invokes d2.call(1)
+
+ // Cannot invoke with the wrong signature.
+
+
+}
diff --git a/tests/language_2/call_method_implicit_invoke_local_runtime_4_test.dart b/tests/language_2/call_method_implicit_invoke_local_runtime_4_test.dart
new file mode 100644
index 0000000..01a364c
--- /dev/null
+++ b/tests/language_2/call_method_implicit_invoke_local_runtime_4_test.dart
@@ -0,0 +1,35 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+// Dart test program to test arithmetic operations.
+
+import "package:expect/expect.dart";
+
+class C1 {
+ int call(int i) => 2 * i;
+}
+
+class C2 implements Function {
+ int call(int i) => 2 * i;
+}
+
+main() {
+ C1 c1 = new C1();
+ // Implicitly invokes c1.call(1)
+
+ dynamic d1 = c1;
+ // Implicitly invokes d1.call(1)
+
+ C2 c2 = new C2();
+ // Implicitly invokes c2.call(1)
+
+ dynamic d2 = c2;
+ // Implicitly invokes d2.call(1)
+ Expect.equals(d2(1), 2);
+ // Cannot invoke with the wrong signature.
+
+
+}
diff --git a/tests/language_2/call_method_implicit_invoke_local_runtime_test.dart b/tests/language_2/call_method_implicit_invoke_local_runtime_test.dart
new file mode 100644
index 0000000..f06206f
--- /dev/null
+++ b/tests/language_2/call_method_implicit_invoke_local_runtime_test.dart
@@ -0,0 +1,35 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+// Dart test program to test arithmetic operations.
+
+import "package:expect/expect.dart";
+
+class C1 {
+ int call(int i) => 2 * i;
+}
+
+class C2 implements Function {
+ int call(int i) => 2 * i;
+}
+
+main() {
+ C1 c1 = new C1();
+ // Implicitly invokes c1.call(1)
+
+ dynamic d1 = c1;
+ // Implicitly invokes d1.call(1)
+
+ C2 c2 = new C2();
+ // Implicitly invokes c2.call(1)
+
+ dynamic d2 = c2;
+ // Implicitly invokes d2.call(1)
+
+ // Cannot invoke with the wrong signature.
+
+
+}
diff --git a/tests/language_2/call_method_implicit_invoke_local_test.dart b/tests/language_2/call_method_implicit_invoke_local_test.dart
index 5528311..1e58c47 100644
--- a/tests/language_2/call_method_implicit_invoke_local_test.dart
+++ b/tests/language_2/call_method_implicit_invoke_local_test.dart
@@ -16,17 +16,23 @@
main() {
C1 c1 = new C1();
// Implicitly invokes c1.call(1)
- Expect.equals(c1(1), 2); //# 01: ok
+ Expect.equals(c1(1), 2);
dynamic d1 = c1;
// Implicitly invokes d1.call(1)
- Expect.equals(d1(1), 2); //# 02: ok
+ Expect.equals(d1(1), 2);
C2 c2 = new C2();
// Implicitly invokes c2.call(1)
- Expect.equals(c2(1), 2); //# 03: ok
+ Expect.equals(c2(1), 2);
dynamic d2 = c2;
// Implicitly invokes d2.call(1)
- Expect.equals(d2(1), 2); //# 04: ok
+ Expect.equals(d2(1), 2);
// Cannot invoke with the wrong signature.
- c2(); //# 05: compile-time error
- c2(3, 4); //# 05: compile-time error
+ c2();
+ //^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
+ c2(3, 4);
+ //^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
}
diff --git a/tests/language_2/call_method_override_runtime_test.dart b/tests/language_2/call_method_override_runtime_test.dart
new file mode 100644
index 0000000..26e0dd4
--- /dev/null
+++ b/tests/language_2/call_method_override_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+// Dart test program to test arithmetic operations.
+
+class B {}
+
+class C {
+ B call(B b) => b;
+}
+
+typedef B BToB(B x);
+
+class D {
+ BToB f() => null;
+ void g(C x) {}
+}
+
+class E extends D {
+ // This override is illegal because C is not a subtype of BToB.
+
+
+ // This override is illegal because BToB is not a supertype of C.
+
+}
+
+main() {
+ new E();
+}
diff --git a/tests/language_2/call_method_override_test.dart b/tests/language_2/call_method_override_test.dart
index 265ad91..8e402a4 100644
--- a/tests/language_2/call_method_override_test.dart
+++ b/tests/language_2/call_method_override_test.dart
@@ -18,10 +18,17 @@
class E extends D {
// This override is illegal because C is not a subtype of BToB.
- C f() => null; //# 01: compile-time error
+ C f() => null;
+ //^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+ // [cfe] The return type of the method 'E.f' is 'C', which does not match the return type, 'B Function(B)', of the overridden method, 'D.f'.
// This override is illegal because BToB is not a supertype of C.
- void g(BToB x) {} //# 02: compile-time error
+ void g(BToB x) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+ // ^
+ // [cfe] The parameter 'x' of the method 'E.g' has type 'B Function(B)', which does not match the corresponding type, 'C', in the overridden method, 'D.g'.
}
main() {
diff --git a/tests/language_2/call_non_method_field_runtime_test.dart b/tests/language_2/call_non_method_field_runtime_test.dart
new file mode 100644
index 0000000..d9d98a8
--- /dev/null
+++ b/tests/language_2/call_non_method_field_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// Tests calling an object's field which is not a method.
+
+class Fisk {
+ int i;
+}
+
+class Hest extends Fisk {}
+
+main() {
+ Fisk x1 = new Fisk();
+
+
+ Hest x2 = new Hest();
+
+}
diff --git a/tests/language_2/call_non_method_field_test.dart b/tests/language_2/call_non_method_field_test.dart
index e69dbf5..7bd4490 100644
--- a/tests/language_2/call_non_method_field_test.dart
+++ b/tests/language_2/call_non_method_field_test.dart
@@ -12,8 +12,16 @@
main() {
Fisk x1 = new Fisk();
- x1.i(); //# 01: compile-time error
+ x1.i();
+//^^^^
+// [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION
+// ^
+// [cfe] 'i' isn't a function or method and can't be invoked.
Hest x2 = new Hest();
- x2.i(); //# 02: compile-time error
+ x2.i();
+//^^^^
+// [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION
+// ^
+// [cfe] 'i' isn't a function or method and can't be invoked.
}
diff --git a/tests/language_2/call_nonexistent_constructor_runtime_test.dart b/tests/language_2/call_nonexistent_constructor_runtime_test.dart
new file mode 100644
index 0000000..92e4b19
--- /dev/null
+++ b/tests/language_2/call_nonexistent_constructor_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// When attempting to call a nonexistent constructor, check that a
+// compile error is reported.
+
+foo() {
+ throw 'hest';
+}
+
+class A {
+ A.foo(var x) {}
+}
+
+main() {
+ new A.foo(42);
+
+
+}
diff --git a/tests/language_2/call_nonexistent_constructor_test.dart b/tests/language_2/call_nonexistent_constructor_test.dart
index 6b534fe..4649f37 100644
--- a/tests/language_2/call_nonexistent_constructor_test.dart
+++ b/tests/language_2/call_nonexistent_constructor_test.dart
@@ -17,6 +17,12 @@
main() {
new A.foo(42);
- new A.bar(foo()); //# 01: compile-time error
- new A(); //# 02: compile-time error
+ new A.bar(foo());
+ // ^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_UNDEFINED_CONSTRUCTOR
+ // [cfe] Method not found: 'A.bar'.
+ new A();
+ // ^
+ // [analyzer] STATIC_WARNING.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT
+ // [cfe] Method not found: 'A'.
}
diff --git a/tests/language_2/call_through_getter_runtime_test.dart b/tests/language_2/call_through_getter_runtime_test.dart
new file mode 100644
index 0000000..4737aa6
--- /dev/null
+++ b/tests/language_2/call_through_getter_runtime_test.dart
@@ -0,0 +1,179 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+// Tests that we can call functions through getters.
+
+const TOP_LEVEL_CONST = 1;
+const TOP_LEVEL_CONST_REF = TOP_LEVEL_CONST;
+const TOP_LEVEL_NULL = null;
+
+var topLevel;
+
+class CallThroughGetterTest {
+ static void testMain() {
+ testTopLevel();
+ testField();
+ testGetter();
+ testMethod();
+ testEvaluationOrder();
+ }
+
+ static void testTopLevel() {
+ topLevel = () {
+ return 2;
+ };
+ Expect.equals(1, TOP_LEVEL_CONST);
+ Expect.equals(1, TOP_LEVEL_CONST_REF);
+ Expect.equals(2, topLevel());
+
+
+
+ }
+
+ static void testField() {
+ A a = new A();
+ a.field = () => 42;
+ Expect.equals(42, a.field());
+ Expect.equals(42, (a.field)());
+
+ a.field = () => 87;
+ Expect.equals(87, a.field());
+ Expect.equals(87, (a.field)());
+
+ a.field = 99;
+ Expect.throwsNoSuchMethodError(() => a.field());
+ Expect.throwsNoSuchMethodError(() => (a.field)());
+ }
+
+ static void testGetter() {
+ A a = new A();
+ a.field = () => 42;
+ Expect.equals(42, a.getter());
+ Expect.equals(42, (a.getter)());
+
+ a.field = () => 87;
+ Expect.equals(87, a.getter());
+ Expect.equals(87, (a.getter)());
+
+ a.field = 99;
+ Expect.throwsNoSuchMethodError(() => a.getter());
+ Expect.throwsNoSuchMethodError(() => (a.getter)());
+ }
+
+ static void testMethod() {
+ A a = new A();
+ a.field = () => 42;
+ Expect.equals(true, a.method() is Function);
+ Expect.equals(42, a.method()());
+
+ a.field = () => 87;
+ Expect.equals(true, a.method() is Function);
+ Expect.equals(87, a.method()());
+
+ a.field = null;
+ Expect.equals(null, a.method());
+ }
+
+ static void testEvaluationOrder() {
+ B b = new B();
+ Expect.equals("gf", b.g0());
+ b = new B();
+ Expect.equals("gf", (b.g0)());
+
+ b = new B();
+ Expect.equals("xgf", b.g1(b.x));
+ b = new B();
+ Expect.equals("gxf", (b.g1)(b.x));
+
+ b = new B();
+ Expect.equals("xygf", b.g2(b.x, b.y));
+ b = new B();
+ Expect.equals("gxyf", (b.g2)(b.x, b.y));
+
+ b = new B();
+ Expect.equals("xyzgf", b.g3(b.x, b.y, b.z));
+ b = new B();
+ Expect.equals("gxyzf", (b.g3)(b.x, b.y, b.z));
+
+ b = new B();
+ Expect.equals("yzxgf", b.g3(b.y, b.z, b.x));
+ b = new B();
+ Expect.equals("gyzxf", (b.g3)(b.y, b.z, b.x));
+ }
+}
+
+class A {
+ A() {}
+ var field;
+ get getter {
+ return field;
+ }
+
+ method() {
+ return field;
+ }
+}
+
+class B {
+ B() : _order = new StringBuffer("") {}
+
+ get g0 {
+ _mark('g');
+ return () {
+ return _mark('f');
+ };
+ }
+
+ get g1 {
+ _mark('g');
+ return (x) {
+ return _mark('f');
+ };
+ }
+
+ get g2 {
+ _mark('g');
+ return (x, y) {
+ return _mark('f');
+ };
+ }
+
+ get g3 {
+ _mark('g');
+ return (x, y, z) {
+ return _mark('f');
+ };
+ }
+
+ get x {
+ _mark('x');
+ return 0;
+ }
+
+ get y {
+ _mark('y');
+ return 1;
+ }
+
+ get z {
+ _mark('z');
+ return 2;
+ }
+
+ _mark(m) {
+ _order.write(m);
+ return _order.toString();
+ }
+
+ StringBuffer _order;
+}
+
+main() {
+ CallThroughGetterTest.testMain();
+}
diff --git a/tests/language_2/call_through_getter_test.dart b/tests/language_2/call_through_getter_test.dart
index 83cd73d..2169e8c6 100644
--- a/tests/language_2/call_through_getter_test.dart
+++ b/tests/language_2/call_through_getter_test.dart
@@ -29,8 +29,16 @@
Expect.equals(1, TOP_LEVEL_CONST_REF);
Expect.equals(2, topLevel());
- TOP_LEVEL_CONST(); //# 01: compile-time error
- (TOP_LEVEL_CONST)(); //# 02: compile-time error
+ TOP_LEVEL_CONST();
+// ^^^^^^^^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION
+// ^
+// [cfe] The method 'call' isn't defined for the class 'int'.
+ (TOP_LEVEL_CONST)();
+// ^^^^^^^^^^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION
+// ^
+// [cfe] The method 'call' isn't defined for the class 'int'.
}
static void testField() {
diff --git a/tests/language_2/callable_runtime_test.dart b/tests/language_2/callable_runtime_test.dart
new file mode 100644
index 0000000..05fad49
--- /dev/null
+++ b/tests/language_2/callable_runtime_test.dart
@@ -0,0 +1,70 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import 'package:expect/expect.dart';
+
+class X {
+ call() => 42;
+}
+
+class XX extends X {
+ XX.named();
+}
+
+class Y {
+ call(int x) => 87 + x;
+
+ static int staticMethod(int x) => x + 1;
+}
+
+class Z<T> {
+ final T value;
+ Z(this.value);
+ T call() => value;
+
+ static int staticMethod(int x) => x + 1;
+}
+
+typedef F(int x);
+typedef G(String y);
+typedef H();
+typedef T I<T>();
+
+main() {
+ X x = new X();
+ Function f = x; // Should pass checked mode test
+ Y y = new Y();
+ Function g = y; // Should pass checked mode test
+ F f0 = y; // Should pass checked mode test
+
+
+
+
+ Expect.equals(f(), 42);
+ Expect.equals(g(100), 187);
+
+ var z = new Z<int>(123);
+ Expect.equals(z(), 123);
+ Expect.equals((z as dynamic)(), 123);
+
+ Expect.equals(Y.staticMethod(6), 7);
+ Expect.equals(Z.staticMethod(6), 7);
+
+ var xx = new XX.named();
+ Expect.equals(xx(), 42);
+
+ H xx2 = new XX.named();
+ Expect.equals(xx2(), 42);
+
+ Expect.throwsTypeError(() {
+ F f2 = x as dynamic;
+ });
+
+ Expect.throwsTypeError(() {
+ G g1 = y as dynamic;
+ });
+}
diff --git a/tests/language_2/callable_test.dart b/tests/language_2/callable_test.dart
index fb8ee79..75ff4c2 100644
--- a/tests/language_2/callable_test.dart
+++ b/tests/language_2/callable_test.dart
@@ -38,8 +38,16 @@
Function g = y; // Should pass checked mode test
F f0 = y; // Should pass checked mode test
- F f1 = x; //# 00: compile-time error
- G g0 = y; //# 01: compile-time error
+ F f1 = x;
+ //^
+ // [cfe] A value of type 'dynamic Function()' can't be assigned to a variable of type 'dynamic Function(int)'.
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ G g0 = y;
+ //^
+ // [cfe] A value of type 'dynamic Function(int)' can't be assigned to a variable of type 'dynamic Function(String)'.
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
Expect.equals(f(), 42);
Expect.equals(g(100), 187);
diff --git a/tests/language_2/cascade_runtime_test.dart b/tests/language_2/cascade_runtime_test.dart
new file mode 100644
index 0000000..9357093
--- /dev/null
+++ b/tests/language_2/cascade_runtime_test.dart
@@ -0,0 +1,91 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Test cascades.
+
+class A {
+ int x;
+ int y;
+
+ A(this.x, this.y);
+
+ A setX(int x) {
+ this.x = x;
+ return this;
+ }
+
+ void setY(int y) {
+ this.y = y;
+ }
+
+ Function swap() {
+ int tmp = x;
+ x = y;
+ y = tmp;
+ return this.swap;
+ }
+
+ void check(int x, int y) {
+ Expect.equals(x, this.x);
+ Expect.equals(y, this.y);
+ }
+
+ operator [](var i) {
+ if (i == 0) return x;
+ if (i == 1) return y;
+ if (i == "swap") return this.swap;
+ return null;
+ }
+
+ operator []=(int i, int value) {
+ if (i == 0) {
+ x = value;
+ } else if (i == 1) {
+ y = value;
+ }
+ }
+
+ /**
+ * A pseudo-keyword.
+ */
+ import() {
+ x++;
+ }
+}
+
+main() {
+ A a = new A(1, 2);
+ a
+ ..check(1, 2)
+ ..swap()
+ ..check(2, 1)
+ ..x = 4
+ ..y = 9
+ ..check(4, 9)
+ ..setX(10)
+ ..check(10, 9)
+ ..y = 5
+ ..check(10, 5)
+ ..swap()()()
+ ..check(5, 10)
+ ..[0] = 2
+ ..check(2, 10)
+ ..setX(10).setY(3)
+ ..check(10, 3)
+ ..setX(7)["swap"]()
+ ..check(3, 7)
+ ..import()
+ ..check(4, 7)
+ ..["swap"]()()()
+ ..check(7, 4);
+ a.check(7, 4);
+
+
+
+}
diff --git a/tests/language_2/cascade_test.dart b/tests/language_2/cascade_test.dart
index 7208093..274b23bf 100644
--- a/tests/language_2/cascade_test.dart
+++ b/tests/language_2/cascade_test.dart
@@ -82,7 +82,22 @@
..["swap"]()()()
..check(7, 4);
a.check(7, 4);
- a..(42); // //# 01: syntax error
- a..37; // //# 02: syntax error
- a.."foo"; // //# 03: syntax error
+ a..(42);
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected an identifier, but got ''.
+ // ^
+ // [cfe] Expected an identifier, but got '('.
+ a..37;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected an identifier, but got '37'.
+ // [error line 91, column 8, length 0]
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ a.."foo";
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected an identifier, but got '"foo"'.
+ // [error line 97, column 11, length 0]
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
}
diff --git a/tests/language_2/case_expression_with_assignment_runtime_test.dart b/tests/language_2/case_expression_with_assignment_runtime_test.dart
new file mode 100644
index 0000000..8b534c6
--- /dev/null
+++ b/tests/language_2/case_expression_with_assignment_runtime_test.dart
@@ -0,0 +1,31 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// Regression test for crash in VM parser (issue 29370).
+
+import "package:expect/expect.dart";
+
+const ERROR_A = 0;
+const ERROR_B = 1;
+
+errorToString(error) {
+ switch (error) {
+ case ERROR_A:
+ return "ERROR_A";
+
+ case ERROR_B:
+ return "ERROR_B";
+ default:
+ return "Unknown error";
+ }
+}
+
+main() {
+ Expect.equals(errorToString(ERROR_A), "ERROR_A");
+ Expect.equals(errorToString(ERROR_B), "ERROR_B");
+ Expect.equals(errorToString(55), "Unknown error");
+}
diff --git a/tests/language_2/case_expression_with_assignment_test.dart b/tests/language_2/case_expression_with_assignment_test.dart
index aa78629..115cb94 100644
--- a/tests/language_2/case_expression_with_assignment_test.dart
+++ b/tests/language_2/case_expression_with_assignment_test.dart
@@ -13,8 +13,14 @@
switch (error) {
case ERROR_A:
return "ERROR_A";
- case ERROR_B = 1: //# 01: compile-time error
- case ERROR_B: //# none: ok
+ case ERROR_B = 1:
+ // ^^^^^^^
+ // [analyzer] STATIC_WARNING.ASSIGNMENT_TO_CONST
+ // ^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_CASE_EXPRESSION
+ // ^
+ // [cfe] Not a constant expression.
+ case ERROR_B:
return "ERROR_B";
default:
return "Unknown error";
diff --git a/tests/language_2/check_member_static_runtime_1_test.dart b/tests/language_2/check_member_static_runtime_1_test.dart
new file mode 100644
index 0000000..b9b4391
--- /dev/null
+++ b/tests/language_2/check_member_static_runtime_1_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+class A {
+ static var a;
+ var b;
+}
+
+class B extends A {}
+
+class C extends B {
+ var a;
+
+}
+
+void main() {
+ new C();
+}
diff --git a/tests/language_2/check_member_static_runtime_test.dart b/tests/language_2/check_member_static_runtime_test.dart
new file mode 100644
index 0000000..db884e0
--- /dev/null
+++ b/tests/language_2/check_member_static_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+class A {
+ static var a;
+ var b;
+}
+
+class B extends A {}
+
+class C extends B {
+
+
+}
+
+void main() {
+ new C();
+}
diff --git a/tests/language_2/check_member_static_test.dart b/tests/language_2/check_member_static_test.dart
index 90aba31..2987cb8 100644
--- a/tests/language_2/check_member_static_test.dart
+++ b/tests/language_2/check_member_static_test.dart
@@ -10,8 +10,11 @@
class B extends A {}
class C extends B {
- var a; //# 01: ok
- static var b; //# 02: compile-time error
+ var a;
+ static var b;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
void main() {
diff --git a/tests/language_2/check_method_override_runtime_test.dart b/tests/language_2/check_method_override_runtime_test.dart
new file mode 100644
index 0000000..e538a33
--- /dev/null
+++ b/tests/language_2/check_method_override_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+class A {
+ f([var x]) {}
+ foo(var a, [x, y]) {}
+}
+
+class C extends A {
+
+
+}
+
+main() {
+ new A().foo(2);
+ new C().foo(1);
+}
diff --git a/tests/language_2/check_method_override_test.dart b/tests/language_2/check_method_override_test.dart
index f535a55..a23af64 100644
--- a/tests/language_2/check_method_override_test.dart
+++ b/tests/language_2/check_method_override_test.dart
@@ -8,8 +8,14 @@
}
class C extends A {
- f() {} //# 01: compile-time error
- foo(var a, [x]) {} //# 02: compile-time error
+ f() {}
+//^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+// [cfe] The method 'C.f' has fewer positional arguments than those of overridden method 'A.f'.
+ foo(var a, [x]) {}
+//^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+// [cfe] The method 'C.foo' has fewer positional arguments than those of overridden method 'A.foo'.
}
main() {
diff --git a/tests/language_2/checked_null_runtime_test.dart b/tests/language_2/checked_null_runtime_test.dart
new file mode 100644
index 0000000..bc644d9
--- /dev/null
+++ b/tests/language_2/checked_null_runtime_test.dart
@@ -0,0 +1,30 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ Map a;
+ Comparator b;
+ // This code exhibited a bug in dart2js, where the type of [a] was inferred to
+ // be [Comparator] or null;
+ A()
+ : b = null,
+ a = null;
+}
+
+main() {
+
+}
+
+bar() {
+ // We would create a typed selector for the call to foo, where the
+ // receiver type is a typedef. Some code in the dart2js backend were
+ // not dealing correctly with typedefs and lead the compiler to
+ // crash.
+
+}
diff --git a/tests/language_2/checked_null_test.dart b/tests/language_2/checked_null_test.dart
index e69cdd9..f6187cc 100644
--- a/tests/language_2/checked_null_test.dart
+++ b/tests/language_2/checked_null_test.dart
@@ -15,7 +15,7 @@
}
main() {
- Expect.throws(bar); //# 01: continued
+ Expect.throws(bar);
}
bar() {
@@ -23,5 +23,8 @@
// receiver type is a typedef. Some code in the dart2js backend were
// not dealing correctly with typedefs and lead the compiler to
// crash.
- new A().a.foo(); //# 01: compile-time error
+ new A().a.foo();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'foo' isn't defined for the class 'Map<dynamic, dynamic>'.
}
diff --git a/tests/language_2/class_keyword_runtime_test.dart b/tests/language_2/class_keyword_runtime_test.dart
new file mode 100644
index 0000000..3b6e2bd
--- /dev/null
+++ b/tests/language_2/class_keyword_runtime_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Test that "class" cannot be used as identifier.
+
+class foo {}
+
+void main() {
+
+
+}
diff --git a/tests/language_2/class_keyword_test.dart b/tests/language_2/class_keyword_test.dart
index 9d42e82..891c4a7 100644
--- a/tests/language_2/class_keyword_test.dart
+++ b/tests/language_2/class_keyword_test.dart
@@ -7,6 +7,21 @@
class foo {}
void main() {
- int class = 10; //# 01: syntax error
- print("$class"); //# 02: compile-time error
+ int class = 10;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ';' after this.
+// ^^^^^
+// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+// [cfe] Expected an identifier, but got 'class'.
+// ^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Setter not found: 'class'.
+ print("$class");
+ // ^^^^^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] Expected an identifier, but got 'class'.
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Getter not found: 'class'.
}
diff --git a/tests/language_2/closure_internals_runtime_test.dart b/tests/language_2/closure_internals_runtime_test.dart
new file mode 100644
index 0000000..1b52d32
--- /dev/null
+++ b/tests/language_2/closure_internals_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+class C {
+ foo() => 123;
+}
+
+main() {
+ var f = new C().foo;
+
+
+
+}
diff --git a/tests/language_2/closure_internals_test.dart b/tests/language_2/closure_internals_test.dart
index 61e5b2b..78f04ab 100644
--- a/tests/language_2/closure_internals_test.dart
+++ b/tests/language_2/closure_internals_test.dart
@@ -10,7 +10,16 @@
main() {
var f = new C().foo;
- var target = f.target; //# 01: compile-time error
- var self = f.self; //# 02: compile-time error
- var receiver = f.receiver; //# 03: compile-time error
+ var target = f.target;
+ // ^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'target' isn't defined for the class 'dynamic Function()'.
+ var self = f.self;
+ // ^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'self' isn't defined for the class 'dynamic Function()'.
+ var receiver = f.receiver;
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'receiver' isn't defined for the class 'dynamic Function()'.
}
diff --git a/tests/language_2/compile_time_constant_arguments_runtime_test.dart b/tests/language_2/compile_time_constant_arguments_runtime_test.dart
new file mode 100644
index 0000000..9718f01
--- /dev/null
+++ b/tests/language_2/compile_time_constant_arguments_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+class A {
+ const A(a);
+ const A.named({a: 42});
+ const A.optional([a]);
+}
+
+main() {
+ const A(1);
+
+
+ const A.named();
+
+
+
+ const A.optional();
+ const A.optional(42);
+
+}
diff --git a/tests/language_2/compile_time_constant_arguments_test.dart b/tests/language_2/compile_time_constant_arguments_test.dart
index d572b62..70d7fd3b 100644
--- a/tests/language_2/compile_time_constant_arguments_test.dart
+++ b/tests/language_2/compile_time_constant_arguments_test.dart
@@ -10,13 +10,31 @@
main() {
const A(1);
- const A(); //# 01: compile-time error
- const A(1, 2); //# 02: compile-time error
+ const A();
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
+ const A(1, 2);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
const A.named();
- const A.named(b: 1); //# 03: compile-time error
- const A.named(a: 1, a: 2); //# 04: compile-time error
- const A.named(a: 1, b: 2); //# 05: compile-time error
+ const A.named(b: 1);
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'b'.
+ const A.named(a: 1, a: 2);
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_NAMED_ARGUMENT
+ // [cfe] Duplicated named argument 'a'.
+ const A.named(a: 1, b: 2);
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'b'.
const A.optional();
const A.optional(42);
- const A.optional(42, 54); //# 06: compile-time error
+ const A.optional(42, 54);
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
}
diff --git a/tests/language_2/compile_time_constant_c_runtime_1_test.dart b/tests/language_2/compile_time_constant_c_runtime_1_test.dart
new file mode 100644
index 0000000..0dfa265
--- /dev/null
+++ b/tests/language_2/compile_time_constant_c_runtime_1_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+const m0 = const {499: 400 + 99};
+const m1 = const {
+ "foo" + "bar": 42
+};
+const m2 = const {
+
+};
+const m3 = const {
+
+};
+
+use(x) => x;
+
+main() {
+ use(m0);
+ use(m1);
+ use(m2);
+ use(m3);
+}
diff --git a/tests/language_2/compile_time_constant_c_runtime_test.dart b/tests/language_2/compile_time_constant_c_runtime_test.dart
new file mode 100644
index 0000000..8355fea
--- /dev/null
+++ b/tests/language_2/compile_time_constant_c_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+const m0 = const {499: 400 + 99};
+const m1 = const {
+
+};
+const m2 = const {
+
+};
+const m3 = const {
+
+};
+
+use(x) => x;
+
+main() {
+ use(m0);
+ use(m1);
+ use(m2);
+ use(m3);
+}
diff --git a/tests/language_2/compile_time_constant_c_test.dart b/tests/language_2/compile_time_constant_c_test.dart
index 3ebc2e7..308f562 100644
--- a/tests/language_2/compile_time_constant_c_test.dart
+++ b/tests/language_2/compile_time_constant_c_test.dart
@@ -4,13 +4,23 @@
const m0 = const {499: 400 + 99};
const m1 = const {
- "foo" + "bar": 42 // //# 01: ok
+ "foo" + "bar": 42
};
const m2 = const {
- "foo" * 4: 42 // //# 02: compile-time error
+// ^
+// [cfe] Constant evaluation error:
+ "foo" * 4: 42
+//^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_NUM
};
const m3 = const {
- "foo".codeUnitAt(0): 42 // //# 03: compile-time error
+ "foo".codeUnitAt(0): 42
+//^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+//^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_MAP_KEY
+// ^
+// [cfe] Method invocation is not a constant expression.
};
use(x) => x;
diff --git a/tests/language_2/compile_time_constant_k_runtime_test.dart b/tests/language_2/compile_time_constant_k_runtime_test.dart
new file mode 100644
index 0000000..ba5a2a0
--- /dev/null
+++ b/tests/language_2/compile_time_constant_k_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+const x = const {
+
+ 'a': 4
+};
+const y = const {
+
+
+};
+
+const z = const {
+
+
+
+ '__proto__': 499
+};
+
+const x2 = const {'a': 4};
+const y2 = const {'a': 14, 'b': 13};
+const z2 = const {'__proto__': 499};
+
+main() {
+ Expect.identical(x2, x);
+
+ Expect.identical(z2, z);
+}
diff --git a/tests/language_2/compile_time_constant_k_test.dart b/tests/language_2/compile_time_constant_k_test.dart
index 8f58552..0fc7128 100644
--- a/tests/language_2/compile_time_constant_k_test.dart
+++ b/tests/language_2/compile_time_constant_k_test.dart
@@ -5,19 +5,39 @@
import "package:expect/expect.dart";
const x = const {
- 'a': 3, // //# 01: compile-time error
+// ^
+// [cfe] Constant evaluation error:
+ 'a': 3,
'a': 4
+//^^^
+// [analyzer] COMPILE_TIME_ERROR.EQUAL_KEYS_IN_CONST_MAP
};
const y = const {
- 'a': 10, 'b': 11, 'a': 12, // //# 02: compile-time error
- 'b': 13, 'a': 14 // //# 02: continued
+// ^
+// [cfe] Constant evaluation error:
+ 'a': 10, 'b': 11, 'a': 12,
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.EQUAL_KEYS_IN_CONST_MAP
+ 'b': 13, 'a': 14
+//^^^
+// [analyzer] COMPILE_TIME_ERROR.EQUAL_KEYS_IN_CONST_MAP
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.EQUAL_KEYS_IN_CONST_MAP
};
const z = const {
- '__proto__': 496, // //# 03: compile-time error
- '__proto__': 497, // //# 03: continued
- '__proto__': 498, // //# 03: continued
+// ^
+// [cfe] Constant evaluation error:
+ '__proto__': 496,
+ '__proto__': 497,
+//^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.EQUAL_KEYS_IN_CONST_MAP
+ '__proto__': 498,
+//^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.EQUAL_KEYS_IN_CONST_MAP
'__proto__': 499
+//^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.EQUAL_KEYS_IN_CONST_MAP
};
const x2 = const {'a': 4};
@@ -26,6 +46,6 @@
main() {
Expect.identical(x2, x);
- Expect.identical(y2, y); // //# 02: continued
+ Expect.identical(y2, y);
Expect.identical(z2, z);
}
diff --git a/tests/language_2/compile_time_constant_o_runtime_test.dart b/tests/language_2/compile_time_constant_o_runtime_test.dart
new file mode 100644
index 0000000..d808e9e
--- /dev/null
+++ b/tests/language_2/compile_time_constant_o_runtime_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Test compile-time constants with string-interpolation.
+
+import "package:expect/expect.dart";
+
+const str = "foo";
+const m1 = const {"foo": 499};
+const m2 = const {"$str": 499};
+const m3 = const {
+ // Causes in a duplicate key error.
+
+ "foo": 499
+};
+const m4 = const {
+ // Causes in a duplicate key error.
+
+ "$str": 499
+};
+const m5 = const {"f" "o" "o": 499};
+
+const mm1 = const {"afoo#foo": 499};
+const mm2 = const {"a$str#$str": 499};
+const mm3 = const {"a" "$str" "#" "foo": 499};
+const mm4 = const {"a$str" "#$str": 499};
+
+main() {
+ Expect.equals(1, m1.length);
+ Expect.equals(499, m1["foo"]);
+ Expect.identical(m1, m2);
+ Expect.identical(m1, m3);
+ Expect.identical(m1, m4);
+ Expect.identical(m1, m5);
+
+ Expect.equals(1, mm1.length);
+ Expect.equals(499, mm1["afoo#foo"]);
+ Expect.identical(mm1, mm2);
+ Expect.identical(mm1, mm3);
+ Expect.identical(mm1, mm4);
+}
diff --git a/tests/language_2/compile_time_constant_o_test.dart b/tests/language_2/compile_time_constant_o_test.dart
index 358285b..f9419b7 100644
--- a/tests/language_2/compile_time_constant_o_test.dart
+++ b/tests/language_2/compile_time_constant_o_test.dart
@@ -9,14 +9,24 @@
const m1 = const {"foo": 499};
const m2 = const {"$str": 499};
const m3 = const {
+// ^
+// [cfe] Constant evaluation error:
+
// Causes in a duplicate key error.
- "$str": 42, //# 01: compile-time error
+ "$str": 42,
"foo": 499
+//^^^^^
+// [analyzer] COMPILE_TIME_ERROR.EQUAL_KEYS_IN_CONST_MAP
};
const m4 = const {
+// ^
+// [cfe] Constant evaluation error:
+
// Causes in a duplicate key error.
- "foo": 42, //# 02: compile-time error
+ "foo": 42,
"$str": 499
+//^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.EQUAL_KEYS_IN_CONST_MAP
};
const m5 = const {"f" "o" "o": 499};
diff --git a/tests/language_2/compile_time_constant_p_runtime_test.dart b/tests/language_2/compile_time_constant_p_runtime_test.dart
new file mode 100644
index 0000000..283ecec
--- /dev/null
+++ b/tests/language_2/compile_time_constant_p_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ const A(
+
+ );
+ final x = null;
+}
+
+class B extends A {
+ const B();
+}
+
+var b = const B();
+
+main() {
+ Expect.equals(null, b.x);
+}
diff --git a/tests/language_2/compile_time_constant_p_test.dart b/tests/language_2/compile_time_constant_p_test.dart
index 6b1c7f4..5c41a46 100644
--- a/tests/language_2/compile_time_constant_p_test.dart
+++ b/tests/language_2/compile_time_constant_p_test.dart
@@ -6,16 +6,26 @@
class A {
const A(
- this.x //# 01: compile-time error
+ this.x
+ // ^
+ // [analyzer] STATIC_WARNING.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR
+ // [cfe] 'x' is a final instance variable that has already been initialized.
+ // ^
+ // [cfe] Cannot invoke a non-'const' constructor where a const expression is expected.
);
final x = null;
}
class B extends A {
const B();
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+ // [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
}
var b = const B();
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
main() {
Expect.equals(null, b.x);
diff --git a/tests/language_2/compile_time_constant_r_runtime_test.dart b/tests/language_2/compile_time_constant_r_runtime_test.dart
new file mode 100644
index 0000000..2e8c359
--- /dev/null
+++ b/tests/language_2/compile_time_constant_r_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+const x =
+
+ "x";
+
+const y = const {
+ 0:
+
+ "y"
+};
+
+main() {
+ print(x);
+ print(y);
+ const z =
+
+ 1 + 1 + 1;
+ print(z);
+}
diff --git a/tests/language_2/compile_time_constant_r_test.dart b/tests/language_2/compile_time_constant_r_test.dart
index 98d057b..8713d18 100644
--- a/tests/language_2/compile_time_constant_r_test.dart
+++ b/tests/language_2/compile_time_constant_r_test.dart
@@ -3,20 +3,31 @@
// BSD-style license that can be found in the LICENSE file.
const x =
- throw //# 01: compile-time error
- "x";
+ throw "x";
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Throw is not a constant expression.
const y = const {
0:
- throw //# 02: compile-time error
- "y"
+ throw "y";
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Throw is not a constant expression.
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_MAP_VALUE
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected '}' before this.
};
main() {
print(x);
print(y);
const z =
- throw //# 03: compile-time error
- 1 + 1 + 1;
+ throw 1 + 1 + 1;
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Throw is not a constant expression.
print(z);
}
diff --git a/tests/language_2/compile_time_constant_runtime_test.dart b/tests/language_2/compile_time_constant_runtime_test.dart
new file mode 100644
index 0000000..9fc8d8f
--- /dev/null
+++ b/tests/language_2/compile_time_constant_runtime_test.dart
@@ -0,0 +1,23 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+class Bad {
+ int foo;
+ final int bar =
+
+ -1;
+ static const int toto =
+
+ -3;
+}
+
+void use(x) {}
+
+main() {
+ use(new Bad().bar);
+ use(Bad.toto);
+}
diff --git a/tests/language_2/compile_time_constant_static2_runtime_test.dart b/tests/language_2/compile_time_constant_static2_runtime_test.dart
new file mode 100644
index 0000000..d5b8939
--- /dev/null
+++ b/tests/language_2/compile_time_constant_static2_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+class A {
+ final int x;
+
+ const A.a2(this.x);
+
+
+
+ const A.a6(int x) : this.x = x;
+}
+
+
+
+
+
+
+
+
+main() {
+
+
+
+
+
+
+}
diff --git a/tests/language_2/compile_time_constant_static2_test.dart b/tests/language_2/compile_time_constant_static2_test.dart
index 3d2ebfe..2155448 100644
--- a/tests/language_2/compile_time_constant_static2_test.dart
+++ b/tests/language_2/compile_time_constant_static2_test.dart
@@ -4,26 +4,65 @@
class A {
final int x;
- const A.a1() : x = 'foo'; //# 01: continued
+ const A.a1() : x = 'foo';
+ // ^^^^^
+ // [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+ // ^^^^^
+ // [analyzer] STATIC_WARNING.FIELD_INITIALIZER_NOT_ASSIGNABLE
const A.a2(this.x);
- const A.a3([this.x = 'foo']); //# 03: continued
- const A.a4(String this.x); //# 04: continued
- const A.a5(String x) : this.x = x; //# 05: continued
+ const A.a3([this.x = 'foo']);
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+ const A.a4(String this.x);
+ // ^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_PARAMETER_DECLARATION
+ // ^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE
+ // ^
+ // [cfe] The type of parameter 'x', 'String' is not a subtype of the corresponding field's type, 'int'.
+ const A.a5(String x) : this.x = x;
+ // ^
+ // [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+ // ^
+ // [analyzer] STATIC_WARNING.FIELD_INITIALIZER_NOT_ASSIGNABLE
const A.a6(int x) : this.x = x;
}
-const a1 = const A.a1(); //# 01: compile-time error
-const a2 = const A.a2('foo'); //# 02: compile-time error
-const a3 = const A.a3(); //# 03: compile-time error
-const a4 = const A.a4('foo'); //# 04: compile-time error
-const a5 = const A.a5('foo'); //# 05: compile-time error
-const a6 = const A.a6('foo'); //# 06: compile-time error
+const a1 = const A.a1();
+// ^^^^^^^^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+const a2 = const A.a2('foo');
+// ^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+// [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
+// ^^^^^
+// [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+const a3 = const A.a3();
+// ^^^^^^^^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+const a4 = const A.a4('foo');
+// ^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+const a5 = const A.a5('foo');
+// ^^^^^^^^^^^^^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+const a6 = const A.a6('foo');
+// ^^^^^^^^^^^^^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+// ^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+// [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
+// ^^^^^
+// [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
main() {
- print(a1); //# 01: continued
- print(a2); //# 02: continued
- print(a3); //# 03: continued
- print(a4); //# 04: continued
- print(a5); //# 05: continued
- print(a6); //# 06: continued
+ print(a1);
+ print(a2);
+ print(a3);
+ print(a4);
+ print(a5);
+ print(a6);
}
diff --git a/tests/language_2/compile_time_constant_static3_runtime_test.dart b/tests/language_2/compile_time_constant_static3_runtime_test.dart
new file mode 100644
index 0000000..d5b8939
--- /dev/null
+++ b/tests/language_2/compile_time_constant_static3_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+class A {
+ final int x;
+
+ const A.a2(this.x);
+
+
+
+ const A.a6(int x) : this.x = x;
+}
+
+
+
+
+
+
+
+
+main() {
+
+
+
+
+
+
+}
diff --git a/tests/language_2/compile_time_constant_static3_test.dart b/tests/language_2/compile_time_constant_static3_test.dart
index 40da992..3deabbb 100644
--- a/tests/language_2/compile_time_constant_static3_test.dart
+++ b/tests/language_2/compile_time_constant_static3_test.dart
@@ -4,26 +4,65 @@
class A {
final int x;
- const A.a1() : x = 'foo'; //# 01: continued
+ const A.a1() : x = 'foo';
+ // ^^^^^
+ // [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+ // ^^^^^
+ // [analyzer] STATIC_WARNING.FIELD_INITIALIZER_NOT_ASSIGNABLE
const A.a2(this.x);
- const A.a3([this.x = 'foo']); //# 03: continued
- const A.a4(String this.x); //# 04: continued
- const A.a5(String x) : this.x = x; //# 05: continued
+ const A.a3([this.x = 'foo']);
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+ const A.a4(String this.x);
+ // ^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_PARAMETER_DECLARATION
+ // ^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE
+ // ^
+ // [cfe] The type of parameter 'x', 'String' is not a subtype of the corresponding field's type, 'int'.
+ const A.a5(String x) : this.x = x;
+ // ^
+ // [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+ // ^
+ // [analyzer] STATIC_WARNING.FIELD_INITIALIZER_NOT_ASSIGNABLE
const A.a6(int x) : this.x = x;
}
-var a1 = const A.a1(); //# 01: compile-time error
-var a2 = const A.a2('foo'); //# 02: compile-time error
-var a3 = const A.a3(); //# 03: compile-time error
-var a4 = const A.a4('foo'); //# 04: compile-time error
-var a5 = const A.a5('foo'); //# 05: compile-time error
-var a6 = const A.a6('foo'); //# 06: compile-time error
+var a1 = const A.a1();
+// ^^^^^^^^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+var a2 = const A.a2('foo');
+// ^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+// [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
+// ^^^^^
+// [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+var a3 = const A.a3();
+// ^^^^^^^^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+var a4 = const A.a4('foo');
+// ^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+var a5 = const A.a5('foo');
+// ^^^^^^^^^^^^^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+var a6 = const A.a6('foo');
+// ^^^^^^^^^^^^^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+// ^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+// [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
+// ^^^^^
+// [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
main() {
- print(a1); //# 01: continued
- print(a2); //# 02: continued
- print(a3); //# 03: continued
- print(a4); //# 04: continued
- print(a5); //# 05: continued
- print(a6); //# 06: continued
+ print(a1);
+ print(a2);
+ print(a3);
+ print(a4);
+ print(a5);
+ print(a6);
}
diff --git a/tests/language_2/compile_time_constant_static_runtime_test.dart b/tests/language_2/compile_time_constant_static_runtime_test.dart
new file mode 100644
index 0000000..9e4712f
--- /dev/null
+++ b/tests/language_2/compile_time_constant_static_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+
+
+
+
+main() {
+
+
+
+}
diff --git a/tests/language_2/compile_time_constant_static_test.dart b/tests/language_2/compile_time_constant_static_test.dart
index 75d0565..288ffef 100644
--- a/tests/language_2/compile_time_constant_static_test.dart
+++ b/tests/language_2/compile_time_constant_static_test.dart
@@ -2,12 +2,23 @@
// 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.
-final int x = 'foo'; //# 01: compile-time error
-const int y = 'foo'; //# 02: compile-time error
-int z = 'foo'; //# 03: compile-time error
+final int x = 'foo';
+// ^^^^^
+// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+const int y = 'foo';
+// ^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.VARIABLE_TYPE_MISMATCH
+// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+// ^^^^^
+// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+int z = 'foo';
+// ^^^^^
+// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
main() {
- print(x); //# 01: continued
- print(y); //# 02: continued
- print(z); //# 03: continued
+ print(x);
+ print(y);
+ print(z);
}
diff --git a/tests/language_2/compile_time_constant_test.dart b/tests/language_2/compile_time_constant_test.dart
index 8c641bd..caf6d82 100644
--- a/tests/language_2/compile_time_constant_test.dart
+++ b/tests/language_2/compile_time_constant_test.dart
@@ -5,10 +5,19 @@
class Bad {
int foo;
final int bar =
- foo //# 01: compile-time error
+ foo
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER
+// [cfe] Can't access 'this' in a field initializer to read 'foo'.
-1;
static const int toto =
- bar //# 02: compile-time error
+ bar
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Can't access 'this' in a field initializer to read 'bar'.
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER
+// [cfe] Getter not found: 'bar'.
-3;
}
diff --git a/tests/language_2/conditional_method_invocation_runtime_1_test.dart b/tests/language_2/conditional_method_invocation_runtime_1_test.dart
new file mode 100644
index 0000000..9722db0
--- /dev/null
+++ b/tests/language_2/conditional_method_invocation_runtime_1_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it is used to invoke a method.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ f(callback()) => callback();
+ int g(int callback()) => callback();
+ static staticF(callback()) => callback();
+ static int staticG(int callback()) => callback();
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if method invocation using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.f(null);
+
+ // o?.m(...) is equivalent to ((x) => x == null ? null : x.m(...))(o).
+ Expect.equals(null, nullC()?.f(bad()));
+
+
+ // C?.m(...) is equivalent to C.m(...).
+
+
+
+ // The static type of o?.m(...) is the same as the static type of
+ // o.m(...).
+
+
+
+
+
+
+
+
+
+ // Let T be the static type of o and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.m(...) are also
+ // generated in the case of o?.m(...).
+
+
+
+ // '?.' can't be used to access toplevel functions in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the toString method on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_method_invocation_runtime_2_test.dart b/tests/language_2/conditional_method_invocation_runtime_2_test.dart
new file mode 100644
index 0000000..b450284
--- /dev/null
+++ b/tests/language_2/conditional_method_invocation_runtime_2_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it is used to invoke a method.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ f(callback()) => callback();
+ int g(int callback()) => callback();
+ static staticF(callback()) => callback();
+ static int staticG(int callback()) => callback();
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if method invocation using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.f(null);
+
+ // o?.m(...) is equivalent to ((x) => x == null ? null : x.m(...))(o).
+
+ Expect.equals(1, new C()?.f(() => 1));
+
+ // C?.m(...) is equivalent to C.m(...).
+
+
+
+ // The static type of o?.m(...) is the same as the static type of
+ // o.m(...).
+
+
+
+
+
+
+
+
+
+ // Let T be the static type of o and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.m(...) are also
+ // generated in the case of o?.m(...).
+
+
+
+ // '?.' can't be used to access toplevel functions in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the toString method on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_method_invocation_runtime_3_test.dart b/tests/language_2/conditional_method_invocation_runtime_3_test.dart
new file mode 100644
index 0000000..0c96523
--- /dev/null
+++ b/tests/language_2/conditional_method_invocation_runtime_3_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it is used to invoke a method.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ f(callback()) => callback();
+ int g(int callback()) => callback();
+ static staticF(callback()) => callback();
+ static int staticG(int callback()) => callback();
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if method invocation using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.f(null);
+
+ // o?.m(...) is equivalent to ((x) => x == null ? null : x.m(...))(o).
+
+
+
+ // C?.m(...) is equivalent to C.m(...).
+ Expect.equals(1, C?.staticF(() => 1));
+
+
+ // The static type of o?.m(...) is the same as the static type of
+ // o.m(...).
+
+
+
+
+
+
+
+
+
+ // Let T be the static type of o and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.m(...) are also
+ // generated in the case of o?.m(...).
+
+
+
+ // '?.' can't be used to access toplevel functions in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the toString method on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_method_invocation_runtime_4_test.dart b/tests/language_2/conditional_method_invocation_runtime_4_test.dart
new file mode 100644
index 0000000..c830c78
--- /dev/null
+++ b/tests/language_2/conditional_method_invocation_runtime_4_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it is used to invoke a method.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ f(callback()) => callback();
+ int g(int callback()) => callback();
+ static staticF(callback()) => callback();
+ static int staticG(int callback()) => callback();
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if method invocation using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.f(null);
+
+ // o?.m(...) is equivalent to ((x) => x == null ? null : x.m(...))(o).
+
+
+
+ // C?.m(...) is equivalent to C.m(...).
+
+ Expect.equals(1, h.C?.staticF(() => 1));
+
+ // The static type of o?.m(...) is the same as the static type of
+ // o.m(...).
+
+
+
+
+
+
+
+
+
+ // Let T be the static type of o and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.m(...) are also
+ // generated in the case of o?.m(...).
+
+
+
+ // '?.' can't be used to access toplevel functions in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the toString method on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_method_invocation_runtime_5_test.dart b/tests/language_2/conditional_method_invocation_runtime_5_test.dart
new file mode 100644
index 0000000..ee15500
--- /dev/null
+++ b/tests/language_2/conditional_method_invocation_runtime_5_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it is used to invoke a method.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ f(callback()) => callback();
+ int g(int callback()) => callback();
+ static staticF(callback()) => callback();
+ static int staticG(int callback()) => callback();
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if method invocation using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.f(null);
+
+ // o?.m(...) is equivalent to ((x) => x == null ? null : x.m(...))(o).
+
+
+
+ // C?.m(...) is equivalent to C.m(...).
+
+
+
+ // The static type of o?.m(...) is the same as the static type of
+ // o.m(...).
+ { int i = nullC()?.g(bad()); Expect.equals(null, i); }
+
+
+
+
+
+
+
+
+ // Let T be the static type of o and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.m(...) are also
+ // generated in the case of o?.m(...).
+
+
+
+ // '?.' can't be used to access toplevel functions in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the toString method on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_method_invocation_runtime_6_test.dart b/tests/language_2/conditional_method_invocation_runtime_6_test.dart
new file mode 100644
index 0000000..6242c72
--- /dev/null
+++ b/tests/language_2/conditional_method_invocation_runtime_6_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it is used to invoke a method.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ f(callback()) => callback();
+ int g(int callback()) => callback();
+ static staticF(callback()) => callback();
+ static int staticG(int callback()) => callback();
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if method invocation using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.f(null);
+
+ // o?.m(...) is equivalent to ((x) => x == null ? null : x.m(...))(o).
+
+
+
+ // C?.m(...) is equivalent to C.m(...).
+
+
+
+ // The static type of o?.m(...) is the same as the static type of
+ // o.m(...).
+
+ { int i = new C()?.g(() => 1); Expect.equals(1, i); }
+
+
+
+
+
+
+
+ // Let T be the static type of o and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.m(...) are also
+ // generated in the case of o?.m(...).
+
+
+
+ // '?.' can't be used to access toplevel functions in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the toString method on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_method_invocation_runtime_7_test.dart b/tests/language_2/conditional_method_invocation_runtime_7_test.dart
new file mode 100644
index 0000000..4ea694d
--- /dev/null
+++ b/tests/language_2/conditional_method_invocation_runtime_7_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it is used to invoke a method.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ f(callback()) => callback();
+ int g(int callback()) => callback();
+ static staticF(callback()) => callback();
+ static int staticG(int callback()) => callback();
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if method invocation using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.f(null);
+
+ // o?.m(...) is equivalent to ((x) => x == null ? null : x.m(...))(o).
+
+
+
+ // C?.m(...) is equivalent to C.m(...).
+
+
+
+ // The static type of o?.m(...) is the same as the static type of
+ // o.m(...).
+
+
+
+
+ { int i = C?.staticG(() => 1); Expect.equals(1, i); }
+
+
+
+
+ // Let T be the static type of o and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.m(...) are also
+ // generated in the case of o?.m(...).
+
+
+
+ // '?.' can't be used to access toplevel functions in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the toString method on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_method_invocation_runtime_8_test.dart b/tests/language_2/conditional_method_invocation_runtime_8_test.dart
new file mode 100644
index 0000000..4d37e3c
--- /dev/null
+++ b/tests/language_2/conditional_method_invocation_runtime_8_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it is used to invoke a method.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ f(callback()) => callback();
+ int g(int callback()) => callback();
+ static staticF(callback()) => callback();
+ static int staticG(int callback()) => callback();
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if method invocation using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.f(null);
+
+ // o?.m(...) is equivalent to ((x) => x == null ? null : x.m(...))(o).
+
+
+
+ // C?.m(...) is equivalent to C.m(...).
+
+
+
+ // The static type of o?.m(...) is the same as the static type of
+ // o.m(...).
+
+
+
+
+
+ { int i = h.C?.staticG(() => 1); Expect.equals(1, i); }
+
+
+
+ // Let T be the static type of o and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.m(...) are also
+ // generated in the case of o?.m(...).
+
+
+
+ // '?.' can't be used to access toplevel functions in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the toString method on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_method_invocation_runtime_test.dart b/tests/language_2/conditional_method_invocation_runtime_test.dart
new file mode 100644
index 0000000..b4c8217
--- /dev/null
+++ b/tests/language_2/conditional_method_invocation_runtime_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it is used to invoke a method.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ f(callback()) => callback();
+ int g(int callback()) => callback();
+ static staticF(callback()) => callback();
+ static int staticG(int callback()) => callback();
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if method invocation using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.f(null);
+
+ // o?.m(...) is equivalent to ((x) => x == null ? null : x.m(...))(o).
+
+
+
+ // C?.m(...) is equivalent to C.m(...).
+
+
+
+ // The static type of o?.m(...) is the same as the static type of
+ // o.m(...).
+
+
+
+
+
+
+
+
+
+ // Let T be the static type of o and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.m(...) are also
+ // generated in the case of o?.m(...).
+
+
+
+ // '?.' can't be used to access toplevel functions in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the toString method on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_method_invocation_test.dart b/tests/language_2/conditional_method_invocation_test.dart
index 4d1ddb2..1d729d7 100644
--- a/tests/language_2/conditional_method_invocation_test.dart
+++ b/tests/language_2/conditional_method_invocation_test.dart
@@ -28,35 +28,65 @@
nullC()?.f(null);
// o?.m(...) is equivalent to ((x) => x == null ? null : x.m(...))(o).
- Expect.equals(null, nullC()?.f(bad())); //# 01: ok
- Expect.equals(1, new C()?.f(() => 1)); //# 02: ok
+ Expect.equals(null, nullC()?.f(bad()));
+ Expect.equals(1, new C()?.f(() => 1));
// C?.m(...) is equivalent to C.m(...).
- Expect.equals(1, C?.staticF(() => 1)); //# 14: ok
- Expect.equals(1, h.C?.staticF(() => 1)); //# 15: ok
+ Expect.equals(1, C?.staticF(() => 1));
+ Expect.equals(1, h.C?.staticF(() => 1));
// The static type of o?.m(...) is the same as the static type of
// o.m(...).
- { int i = nullC()?.g(bad()); Expect.equals(null, i); } //# 03: ok
- { int i = new C()?.g(() => 1); Expect.equals(1, i); } //# 04: ok
- { String s = nullC()?.g(bad()); Expect.equals(null, s); } //# 05: compile-time error
- { String s = new C()?.g(() => null); Expect.equals(null, s); } //# 06: compile-time error
- { int i = C?.staticG(() => 1); Expect.equals(1, i); } //# 16: ok
- { int i = h.C?.staticG(() => 1); Expect.equals(1, i); } //# 17: ok
- { String s = C?.staticG(() => null); Expect.equals(null, s); } //# 18: compile-time error
- { String s = h.C?.staticG(() => null); Expect.equals(null, s); } //# 19: compile-time error
+ { int i = nullC()?.g(bad()); Expect.equals(null, i); }
+ { int i = new C()?.g(() => 1); Expect.equals(1, i); }
+ { String s = nullC()?.g(bad()); Expect.equals(null, s); }
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'String'.
+ { String s = new C()?.g(() => null); Expect.equals(null, s); }
+ // ^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'String'.
+ { int i = C?.staticG(() => 1); Expect.equals(1, i); }
+ { int i = h.C?.staticG(() => 1); Expect.equals(1, i); }
+ { String s = C?.staticG(() => null); Expect.equals(null, s); }
+ // ^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'String'.
+ { String s = h.C?.staticG(() => null); Expect.equals(null, s); }
+ // ^^^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'String'.
// Let T be the static type of o and let y be a fresh variable of type T.
// Exactly the same static warnings that would be caused by y.m(...) are also
// generated in the case of o?.m(...).
- { B b = new C(); Expect.equals(1, b?.f(() => 1)); } //# 07: compile-time error
- { int i = 1; Expect.equals(null, nullC()?.f(i)); } //# 08: compile-time error
+ { B b = new C(); Expect.equals(1, b?.f(() => 1)); }
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'f' isn't defined for the class 'B'.
+ { int i = 1; Expect.equals(null, nullC()?.f(i)); }
+ // ^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'int' can't be assigned to the parameter type 'dynamic Function()'.
// '?.' can't be used to access toplevel functions in libraries imported via
// prefix.
- h?.topLevelFunction(); //# 11: compile-time error
+ h?.topLevelFunction();
+//^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used with null-aware operators.
// Nor can it be used to access the toString method on the class Type.
- Expect.throwsNoSuchMethodError(() => C?.toString()); //# 12: compile-time error
- Expect.throwsNoSuchMethodError(() => h.C?.toString()); //# 13: compile-time error
+ Expect.throwsNoSuchMethodError(() => C?.toString());
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] Method not found: 'C.toString'.
+ Expect.throwsNoSuchMethodError(() => h.C?.toString());
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] Method not found: 'C.toString'.
}
diff --git a/tests/language_2/conditional_property_access_runtime_1_test.dart b/tests/language_2/conditional_property_access_runtime_1_test.dart
new file mode 100644
index 0000000..a779325
--- /dev/null
+++ b/tests/language_2/conditional_property_access_runtime_1_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it does not appear on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if property access using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.v;
+
+ // e1?.id is equivalent to ((x) => x == null ? null : x.id)(e1).
+ Expect.equals(null, nullC()?.v);
+
+
+ // C?.id is equivalent to C.id.
+
+
+
+ // The static type of e1?.d is the static type of e1.id.
+
+
+
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.id are also
+ // generated in the case of e1?.id.
+
+
+
+ // '?.' cannot be used to access toplevel properties in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the hashCode getter on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_property_access_runtime_2_test.dart b/tests/language_2/conditional_property_access_runtime_2_test.dart
new file mode 100644
index 0000000..eb812b6
--- /dev/null
+++ b/tests/language_2/conditional_property_access_runtime_2_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it does not appear on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if property access using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.v;
+
+ // e1?.id is equivalent to ((x) => x == null ? null : x.id)(e1).
+
+ Expect.equals(1, new C(1)?.v);
+
+ // C?.id is equivalent to C.id.
+
+
+
+ // The static type of e1?.d is the static type of e1.id.
+
+
+
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.id are also
+ // generated in the case of e1?.id.
+
+
+
+ // '?.' cannot be used to access toplevel properties in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the hashCode getter on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_property_access_runtime_3_test.dart b/tests/language_2/conditional_property_access_runtime_3_test.dart
new file mode 100644
index 0000000..7be7987
--- /dev/null
+++ b/tests/language_2/conditional_property_access_runtime_3_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it does not appear on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if property access using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.v;
+
+ // e1?.id is equivalent to ((x) => x == null ? null : x.id)(e1).
+
+
+
+ // C?.id is equivalent to C.id.
+ { C.staticInt = 1; Expect.equals(1, C?.staticInt); }
+
+
+ // The static type of e1?.d is the static type of e1.id.
+
+
+
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.id are also
+ // generated in the case of e1?.id.
+
+
+
+ // '?.' cannot be used to access toplevel properties in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the hashCode getter on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_property_access_runtime_4_test.dart b/tests/language_2/conditional_property_access_runtime_4_test.dart
new file mode 100644
index 0000000..a10d171
--- /dev/null
+++ b/tests/language_2/conditional_property_access_runtime_4_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it does not appear on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if property access using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.v;
+
+ // e1?.id is equivalent to ((x) => x == null ? null : x.id)(e1).
+
+
+
+ // C?.id is equivalent to C.id.
+
+ { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt); }
+
+ // The static type of e1?.d is the static type of e1.id.
+
+
+
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.id are also
+ // generated in the case of e1?.id.
+
+
+
+ // '?.' cannot be used to access toplevel properties in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the hashCode getter on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_property_access_runtime_5_test.dart b/tests/language_2/conditional_property_access_runtime_5_test.dart
new file mode 100644
index 0000000..73df91b
--- /dev/null
+++ b/tests/language_2/conditional_property_access_runtime_5_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it does not appear on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if property access using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.v;
+
+ // e1?.id is equivalent to ((x) => x == null ? null : x.id)(e1).
+
+
+
+ // C?.id is equivalent to C.id.
+
+
+
+ // The static type of e1?.d is the static type of e1.id.
+ { int i = new C(1)?.v; Expect.equals(1, i); }
+
+
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.id are also
+ // generated in the case of e1?.id.
+
+
+
+ // '?.' cannot be used to access toplevel properties in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the hashCode getter on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_property_access_runtime_6_test.dart b/tests/language_2/conditional_property_access_runtime_6_test.dart
new file mode 100644
index 0000000..39e966a
--- /dev/null
+++ b/tests/language_2/conditional_property_access_runtime_6_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it does not appear on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if property access using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.v;
+
+ // e1?.id is equivalent to ((x) => x == null ? null : x.id)(e1).
+
+
+
+ // C?.id is equivalent to C.id.
+
+
+
+ // The static type of e1?.d is the static type of e1.id.
+
+
+ { C.staticInt = 1; int i = C?.staticInt; Expect.equals(1, i); }
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.id are also
+ // generated in the case of e1?.id.
+
+
+
+ // '?.' cannot be used to access toplevel properties in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the hashCode getter on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_property_access_runtime_7_test.dart b/tests/language_2/conditional_property_access_runtime_7_test.dart
new file mode 100644
index 0000000..2cd7a6a
--- /dev/null
+++ b/tests/language_2/conditional_property_access_runtime_7_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it does not appear on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if property access using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.v;
+
+ // e1?.id is equivalent to ((x) => x == null ? null : x.id)(e1).
+
+
+
+ // C?.id is equivalent to C.id.
+
+
+
+ // The static type of e1?.d is the static type of e1.id.
+
+
+
+ { h.C.staticInt = 1; int i = h.C?.staticInt; Expect.equals(1, i); }
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.id are also
+ // generated in the case of e1?.id.
+
+
+
+ // '?.' cannot be used to access toplevel properties in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the hashCode getter on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_property_access_runtime_test.dart b/tests/language_2/conditional_property_access_runtime_test.dart
new file mode 100644
index 0000000..1455389
--- /dev/null
+++ b/tests/language_2/conditional_property_access_runtime_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it does not appear on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if property access using "?." is not
+ // implemented. This makes status files easier to maintain.
+ nullC()?.v;
+
+ // e1?.id is equivalent to ((x) => x == null ? null : x.id)(e1).
+
+
+
+ // C?.id is equivalent to C.id.
+
+
+
+ // The static type of e1?.d is the static type of e1.id.
+
+
+
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same static warnings that would be caused by y.id are also
+ // generated in the case of e1?.id.
+
+
+
+ // '?.' cannot be used to access toplevel properties in libraries imported via
+ // prefix.
+
+
+ // Nor can it be used to access the hashCode getter on the class Type.
+
+
+}
diff --git a/tests/language_2/conditional_property_access_test.dart b/tests/language_2/conditional_property_access_test.dart
index 6e5e2ae..4965ccb 100644
--- a/tests/language_2/conditional_property_access_test.dart
+++ b/tests/language_2/conditional_property_access_test.dart
@@ -24,32 +24,59 @@
nullC()?.v;
// e1?.id is equivalent to ((x) => x == null ? null : x.id)(e1).
- Expect.equals(null, nullC()?.v); //# 01: ok
- Expect.equals(1, new C(1)?.v); //# 02: ok
+ Expect.equals(null, nullC()?.v);
+ Expect.equals(1, new C(1)?.v);
// C?.id is equivalent to C.id.
- { C.staticInt = 1; Expect.equals(1, C?.staticInt); } //# 12: ok
- { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt); } //# 13: ok
+ { C.staticInt = 1; Expect.equals(1, C?.staticInt); }
+ { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt); }
// The static type of e1?.d is the static type of e1.id.
- { int i = new C(1)?.v; Expect.equals(1, i); } //# 03: ok
- { String s = new C(null)?.v; Expect.equals(null, s); } //# 04: compile-time error
- { C.staticInt = 1; int i = C?.staticInt; Expect.equals(1, i); } //# 14: ok
- { h.C.staticInt = 1; int i = h.C?.staticInt; Expect.equals(1, i); } //# 15: ok
- { C.staticInt = null; String s = C?.staticInt; Expect.equals(null, s); } //# 16: compile-time error
- { h.C.staticInt = null; String s = h.C?.staticInt; Expect.equals(null, s); } //# 17: compile-time error
+ { int i = new C(1)?.v; Expect.equals(1, i); }
+ { String s = new C(null)?.v; Expect.equals(null, s); }
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'String'.
+ { C.staticInt = 1; int i = C?.staticInt; Expect.equals(1, i); }
+ { h.C.staticInt = 1; int i = h.C?.staticInt; Expect.equals(1, i); }
+ { C.staticInt = null; String s = C?.staticInt; Expect.equals(null, s); }
+ // ^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'String'.
+ { h.C.staticInt = null; String s = h.C?.staticInt; Expect.equals(null, s); }
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'String'.
// Let T be the static type of e1 and let y be a fresh variable of type T.
// Exactly the same static warnings that would be caused by y.id are also
// generated in the case of e1?.id.
- Expect.equals(null, nullC()?.bad); //# 05: compile-time error
- { B b = new C(1); Expect.equals(1, b?.v); } //# 06: compile-time error
+ Expect.equals(null, nullC()?.bad);
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'bad' isn't defined for the class 'C'.
+ { B b = new C(1); Expect.equals(1, b?.v); }
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'v' isn't defined for the class 'B'.
// '?.' cannot be used to access toplevel properties in libraries imported via
// prefix.
- var x = h?.topLevelVar; //# 09: compile-time error
+ var x = h?.topLevelVar;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+ // [cfe] A prefix can't be used with null-aware operators.
// Nor can it be used to access the hashCode getter on the class Type.
- Expect.throwsNoSuchMethodError(() => C?.hashCode); //# 10: compile-time error
- Expect.throwsNoSuchMethodError(() => h.C?.hashCode); //# 11: compile-time error
+ Expect.throwsNoSuchMethodError(() => C?.hashCode);
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] Getter not found: 'hashCode'.
+ Expect.throwsNoSuchMethodError(() => h.C?.hashCode);
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] Getter not found: 'hashCode'.
}
diff --git a/tests/language_2/conditional_property_assignment_runtime_10_test.dart b/tests/language_2/conditional_property_assignment_runtime_10_test.dart
new file mode 100644
index 0000000..ee7de0a
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_10_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+ { C.staticInt = 1; Expect.equals(3, C?.staticInt += 2); Expect.equals(3, C?.staticInt); }
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_11_test.dart b/tests/language_2/conditional_property_assignment_runtime_11_test.dart
new file mode 100644
index 0000000..75b0820
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_11_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+ { D d = new D(new E()); F f = (d?.v += 1); Expect.identical(d.v, f); }
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_12_test.dart b/tests/language_2/conditional_property_assignment_runtime_12_test.dart
new file mode 100644
index 0000000..e22b2c3
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_12_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+ { D.staticE = new E(); F f = (D?.staticE += 1); Expect.identical(D.staticE, f); }
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_13_test.dart b/tests/language_2/conditional_property_assignment_runtime_13_test.dart
new file mode 100644
index 0000000..78c5fe0
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_13_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+ { h.D.staticE = new h.E(); h.F f = (h.D?.staticE += 1); Expect.identical(h.D.staticE, f); }
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_1_test.dart b/tests/language_2/conditional_property_assignment_runtime_1_test.dart
new file mode 100644
index 0000000..fb9ee93
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_1_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+ Expect.equals(null, nullC()?.v = bad());
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_2_test.dart b/tests/language_2/conditional_property_assignment_runtime_2_test.dart
new file mode 100644
index 0000000..6a69208
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_2_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+ { C c = new C(1); Expect.equals(2, c?.v = 2); Expect.equals(2, c.v); }
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_3_test.dart b/tests/language_2/conditional_property_assignment_runtime_3_test.dart
new file mode 100644
index 0000000..62edd74
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_3_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+ { C.staticInt = 1; Expect.equals(2, C?.staticInt = 2); Expect.equals(2, C.staticInt); }
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_4_test.dart b/tests/language_2/conditional_property_assignment_runtime_4_test.dart
new file mode 100644
index 0000000..c9dc84e
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_4_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+ { h.C.staticInt = 1; Expect.equals(2, h.C?.staticInt = 2); Expect.equals(2, h.C.staticInt); }
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_5_test.dart b/tests/language_2/conditional_property_assignment_runtime_5_test.dart
new file mode 100644
index 0000000..6f03af5
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_5_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+ { D d = new D(new E()); G g = new G(); F f = (d?.v = g); Expect.identical(f, g); }
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_6_test.dart b/tests/language_2/conditional_property_assignment_runtime_6_test.dart
new file mode 100644
index 0000000..8cf0a47
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_6_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+ { D.staticE = new E(); G g = new G(); F f = (D?.staticE = g); Expect.identical(f, g); }
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_7_test.dart b/tests/language_2/conditional_property_assignment_runtime_7_test.dart
new file mode 100644
index 0000000..09baf2d
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_7_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+ { h.D.staticE = new h.E(); h.G g = new h.G(); h.F f = (h.D?.staticE = g); Expect.identical(f, g); }
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_8_test.dart b/tests/language_2/conditional_property_assignment_runtime_8_test.dart
new file mode 100644
index 0000000..4725be7
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_8_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+ Expect.equals(null, nullC()?.v += bad());
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_9_test.dart b/tests/language_2/conditional_property_assignment_runtime_9_test.dart
new file mode 100644
index 0000000..0bc41ff
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_9_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+ { C c = new C(1); Expect.equals(3, c?.v += 2); Expect.equals(3, c.v); }
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_runtime_test.dart b/tests/language_2/conditional_property_assignment_runtime_test.dart
new file mode 100644
index 0000000..0cbd597
--- /dev/null
+++ b/tests/language_2/conditional_property_assignment_runtime_test.dart
@@ -0,0 +1,101 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears on the LHS of an
+// assignment.
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+class B {}
+
+class C extends B {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
+
+
+
+ // C?.v = e2 is equivalent to C.v = e2.
+
+
+
+ // The static type of e1?.v = e2 is the static type of e2.
+
+
+
+
+
+
+
+ // Exactly the same errors that would be caused by e1.v = e2 are
+ // also generated in the case of e1?.v = e2.
+
+
+
+ // e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
+
+
+
+ // C?.v op= e2 is equivalent to C.v op= e2.
+
+
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2.
+
+
+
+
+ // Let T be the static type of e1 and let y be a fresh variable of type T.
+ // Exactly the same errors that would be caused by y.v op e2 are
+ // also generated in the case of e1?.v op= e2.
+
+
+
+
+
+
+
+
+
+ // '?.' cannot be used to assign to toplevel properties in libraries imported
+ // via prefix.
+
+
+
+}
diff --git a/tests/language_2/conditional_property_assignment_test.dart b/tests/language_2/conditional_property_assignment_test.dart
index 7c3dc18..adbe290 100644
--- a/tests/language_2/conditional_property_assignment_test.dart
+++ b/tests/language_2/conditional_property_assignment_test.dart
@@ -46,53 +46,116 @@
nullC()?.v = 1;
// e1?.v = e2 is equivalent to ((x) => x == null ? null : x.v = e2)(e1).
- Expect.equals(null, nullC()?.v = bad()); //# 01: ok
- { C c = new C(1); Expect.equals(2, c?.v = 2); Expect.equals(2, c.v); } //# 02: ok
+ Expect.equals(null, nullC()?.v = bad());
+ { C c = new C(1); Expect.equals(2, c?.v = 2); Expect.equals(2, c.v); }
// C?.v = e2 is equivalent to C.v = e2.
- { C.staticInt = 1; Expect.equals(2, C?.staticInt = 2); Expect.equals(2, C.staticInt); } //# 23: ok
- { h.C.staticInt = 1; Expect.equals(2, h.C?.staticInt = 2); Expect.equals(2, h.C.staticInt); } //# 24: ok
+ { C.staticInt = 1; Expect.equals(2, C?.staticInt = 2); Expect.equals(2, C.staticInt); }
+ { h.C.staticInt = 1; Expect.equals(2, h.C?.staticInt = 2); Expect.equals(2, h.C.staticInt); }
// The static type of e1?.v = e2 is the static type of e2.
- { D d = new D(new E()); G g = new G(); F f = (d?.v = g); Expect.identical(f, g); } //# 03: ok
- { D d = new D(new E()); E e = new G(); F f = (d?.v = e); } //# 04: compile-time error
- { D.staticE = new E(); G g = new G(); F f = (D?.staticE = g); Expect.identical(f, g); } //# 25: ok
- { h.D.staticE = new h.E(); h.G g = new h.G(); h.F f = (h.D?.staticE = g); Expect.identical(f, g); } //# 26: ok
- { D.staticE = new E(); E e = new G(); F f = (D?.staticE = e); } //# 27: compile-time error
- { h.D.staticE = new h.E(); h.E e = new h.G(); h.F f = (h.D?.staticE = e); } //# 28: compile-time error
+ { D d = new D(new E()); G g = new G(); F f = (d?.v = g); Expect.identical(f, g); }
+ { D d = new D(new E()); E e = new G(); F f = (d?.v = e); }
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E' can't be assigned to a variable of type 'F'.
+ { D.staticE = new E(); G g = new G(); F f = (D?.staticE = g); Expect.identical(f, g); }
+ { h.D.staticE = new h.E(); h.G g = new h.G(); h.F f = (h.D?.staticE = g); Expect.identical(f, g); }
+ { D.staticE = new E(); E e = new G(); F f = (D?.staticE = e); }
+ // ^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E' can't be assigned to a variable of type 'F'.
+ { h.D.staticE = new h.E(); h.E e = new h.G(); h.F f = (h.D?.staticE = e); }
+ // ^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E' can't be assigned to a variable of type 'F'.
// Exactly the same errors that would be caused by e1.v = e2 are
// also generated in the case of e1?.v = e2.
- Expect.equals(null, nullC()?.bad = bad()); //# 05: compile-time error
- { B b = new C(1); Expect.equals(2, b?.v = 2); } //# 06: compile-time error
+ Expect.equals(null, nullC()?.bad = bad());
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] The setter 'bad' isn't defined for the class 'C'.
+ { B b = new C(1); Expect.equals(2, b?.v = 2); }
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] The setter 'v' isn't defined for the class 'B'.
// e1?.v op= e2 is equivalent to ((x) => x?.v = x.v op e2)(e1).
- Expect.equals(null, nullC()?.v += bad()); //# 07: ok
- { C c = new C(1); Expect.equals(3, c?.v += 2); Expect.equals(3, c.v); } //# 08: ok
+ Expect.equals(null, nullC()?.v += bad());
+ { C c = new C(1); Expect.equals(3, c?.v += 2); Expect.equals(3, c.v); }
// C?.v op= e2 is equivalent to C.v op= e2.
- { C.staticInt = 1; Expect.equals(3, C?.staticInt += 2); Expect.equals(3, C?.staticInt); } //# 29: ok
+ { C.staticInt = 1; Expect.equals(3, C?.staticInt += 2); Expect.equals(3, C?.staticInt); }
// The static type of e1?.v op= e2 is the static type of e1.v op e2.
- { D d = new D(new E()); F f = (d?.v += 1); Expect.identical(d.v, f); } //# 09: ok
- { D.staticE = new E(); F f = (D?.staticE += 1); Expect.identical(D.staticE, f); } //# 30: ok
- { h.D.staticE = new h.E(); h.F f = (h.D?.staticE += 1); Expect.identical(h.D.staticE, f); } //# 31: ok
+ { D d = new D(new E()); F f = (d?.v += 1); Expect.identical(d.v, f); }
+ { D.staticE = new E(); F f = (D?.staticE += 1); Expect.identical(D.staticE, f); }
+ { h.D.staticE = new h.E(); h.F f = (h.D?.staticE += 1); Expect.identical(h.D.staticE, f); }
// Let T be the static type of e1 and let y be a fresh variable of type T.
// Exactly the same errors that would be caused by y.v op e2 are
// also generated in the case of e1?.v op= e2.
- nullC()?.bad = bad(); //# 10: compile-time error
- { B b = new C(1); b?.v += 2; } //# 11: compile-time error
- { D d = new D(new E()); F f = (d?.v += nullC()); } //# 12: compile-time error
- { D d = new D(new E()); H h = (d?.v += 1); } //# 13: compile-time error
- { D.staticE = new E(); F f = (D?.staticE += nullC()); } //# 32: compile-time error
- { h.D.staticE = new h.E(); h.F f = (h.D?.staticE += h.nullC()); } //# 33: compile-time error
- { D.staticE = new E(); H h = (D?.staticE += 1); } //# 34: compile-time error
- { h.D.staticE = new h.E(); h.H hh = (h.D?.staticE += 1); } //# 35: compile-time error
+ nullC()?.bad = bad();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] The setter 'bad' isn't defined for the class 'C'.
+ { B b = new C(1); b?.v += 2; }
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'v' isn't defined for the class 'B'.
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] The setter 'v' isn't defined for the class 'B'.
+ { D d = new D(new E()); F f = (d?.v += nullC()); }
+ // ^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] A value of type 'C' can't be assigned to a variable of type 'int'.
+ { D d = new D(new E()); H h = (d?.v += 1); }
+ // ^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'G' can't be assigned to a variable of type 'H'.
+ { D.staticE = new E(); F f = (D?.staticE += nullC()); }
+ // ^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] A value of type 'C' can't be assigned to a variable of type 'int'.
+ { h.D.staticE = new h.E(); h.F f = (h.D?.staticE += h.nullC()); }
+ // ^^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] A value of type 'C' can't be assigned to a variable of type 'int'.
+ { D.staticE = new E(); H h = (D?.staticE += 1); }
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'G' can't be assigned to a variable of type 'H'.
+ { h.D.staticE = new h.E(); h.H hh = (h.D?.staticE += 1); }
+ // ^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'G' can't be assigned to a variable of type 'H'.
// '?.' cannot be used to assign to toplevel properties in libraries imported
// via prefix.
- h?.topLevelVar = null; //# 20: compile-time error
- h?.topLevelVar += null; //# 21: compile-time error
- h?.topLevelVar ??= null; //# 22: compile-time error
+ h?.topLevelVar = null;
+//^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used with null-aware operators.
+// ^
+// [cfe] Can't assign to this.
+ h?.topLevelVar += null;
+//^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used with null-aware operators.
+// ^
+// [cfe] Can't assign to this.
+ h?.topLevelVar ??= null;
+//^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used with null-aware operators.
+// ^
+// [cfe] Can't assign to this.
}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_10_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_10_test.dart
new file mode 100644
index 0000000..8be2ec6
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_10_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+ { C.staticInt = 1; Expect.equals(1, C?.staticInt--); Expect.equals(0, C.staticInt); }
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_11_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_11_test.dart
new file mode 100644
index 0000000..1047e8b
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_11_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+ { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt--); Expect.equals(0, h.C.staticInt); }
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_12_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_12_test.dart
new file mode 100644
index 0000000..bb84f75
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_12_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+ { E e1 = new E(); D d = new D(e1); E e2 = d?.v--; Expect.identical(e1, e2); }
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_13_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_13_test.dart
new file mode 100644
index 0000000..7b4118f4
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_13_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+ { E e1 = new E(); D.staticE = e1; E e2 = D?.staticE--; Expect.identical(e1, e2); }
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_14_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_14_test.dart
new file mode 100644
index 0000000..f712892
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_14_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+ { h.E e1 = new h.E(); h.D.staticE = e1; h.E e2 = h.D?.staticE--; Expect.identical(e1, e2); }
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_15_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_15_test.dart
new file mode 100644
index 0000000..864e758
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_15_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+ Expect.equals(null, ++nullC()?.v);
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_16_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_16_test.dart
new file mode 100644
index 0000000..2ab109c
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_16_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+ { C c = new C(1); Expect.equals(2, ++c?.v); Expect.equals(2, c.v); }
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_17_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_17_test.dart
new file mode 100644
index 0000000..f56c3aa
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_17_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+ { C.staticInt = 1; Expect.equals(2, ++C?.staticInt); Expect.equals(2, C.staticInt); }
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_18_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_18_test.dart
new file mode 100644
index 0000000..c11e88d
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_18_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+ { h.C.staticInt = 1; Expect.equals(2, ++h.C?.staticInt); Expect.equals(2, h.C.staticInt); }
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_19_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_19_test.dart
new file mode 100644
index 0000000..8d796b8
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_19_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+ { D d = new D(new E()); F f = ++d?.v; Expect.identical(d.v, f); }
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_1_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_1_test.dart
new file mode 100644
index 0000000..3b825fb
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_1_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+ Expect.equals(null, nullC()?.v++);
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_20_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_20_test.dart
new file mode 100644
index 0000000..da8284e
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_20_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+ { D.staticE = new E(); F f = ++D?.staticE; Expect.identical(D.staticE, f); }
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_21_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_21_test.dart
new file mode 100644
index 0000000..109dc57
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_21_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+ { h.D.staticE = new h.E(); h.F f = ++h.D?.staticE; Expect.identical(h.D.staticE, f); }
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_22_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_22_test.dart
new file mode 100644
index 0000000..154228a
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_22_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+ Expect.equals(null, --nullC()?.v);
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_23_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_23_test.dart
new file mode 100644
index 0000000..8cad501
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_23_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+ { C c = new C(1); Expect.equals(0, --c?.v); Expect.equals(0, c.v); }
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_24_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_24_test.dart
new file mode 100644
index 0000000..a76bd15
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_24_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+ { C.staticInt = 1; Expect.equals(0, --C?.staticInt); Expect.equals(0, C.staticInt); }
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_25_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_25_test.dart
new file mode 100644
index 0000000..0ae8ae2
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_25_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+ { h.C.staticInt = 1; Expect.equals(0, --h.C?.staticInt); Expect.equals(0, h.C.staticInt); }
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_26_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_26_test.dart
new file mode 100644
index 0000000..47bbd46
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_26_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+ { D d = new D(new E()); F f = --d?.v; Expect.identical(d.v, f); }
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_27_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_27_test.dart
new file mode 100644
index 0000000..1bf4b88
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_27_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+ { D.staticE = new E(); F f = --D?.staticE; Expect.identical(D.staticE, f); }
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_28_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_28_test.dart
new file mode 100644
index 0000000..b62e19c
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_28_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+ { h.D.staticE = new h.E(); h.F f = --h.D?.staticE; Expect.identical(h.D.staticE, f); }
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_2_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_2_test.dart
new file mode 100644
index 0000000..eb07c4f
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_2_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+ { C c = new C(1); Expect.equals(1, c?.v++); Expect.equals(2, c.v); }
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_3_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_3_test.dart
new file mode 100644
index 0000000..ce732e7
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_3_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+ { C.staticInt = 1; Expect.equals(1, C?.staticInt++); Expect.equals(2, C.staticInt); }
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_4_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_4_test.dart
new file mode 100644
index 0000000..c6d3562
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_4_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+ { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt++); Expect.equals(2, h.C.staticInt); }
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_5_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_5_test.dart
new file mode 100644
index 0000000..6b24ecc
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_5_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+ { E e1 = new E(); D d = new D(e1); E e2 = d?.v++; Expect.identical(e1, e2); }
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_6_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_6_test.dart
new file mode 100644
index 0000000..3bf81f4
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_6_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+ { E e1 = new E(); D.staticE = e1; E e2 = D?.staticE++; Expect.identical(e1, e2); }
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_7_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_7_test.dart
new file mode 100644
index 0000000..c567658
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_7_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+ { h.E e1 = new h.E(); h.D.staticE = e1; h.E e2 = h.D?.staticE++; Expect.identical(e1, e2); }
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_8_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_8_test.dart
new file mode 100644
index 0000000..b9a6a1d
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_8_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+ Expect.equals(null, nullC()?.v--);
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_9_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_9_test.dart
new file mode 100644
index 0000000..af41766
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_9_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+ { C c = new C(1); Expect.equals(1, c?.v--); Expect.equals(0, c.v); }
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_runtime_test.dart b/tests/language_2/conditional_property_increment_decrement_runtime_test.dart
new file mode 100644
index 0000000..e1ef629
--- /dev/null
+++ b/tests/language_2/conditional_property_increment_decrement_runtime_test.dart
@@ -0,0 +1,109 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ?. operator when it appears in a postincrement or
+// preincrement expression (or a postdecrement or predecrement expression).
+
+import "package:expect/expect.dart";
+import "conditional_access_helper.dart" as h;
+
+class C {
+ int v;
+ C(this.v);
+ static int staticInt;
+}
+
+class D {
+ E v;
+ D(this.v);
+ static E staticE;
+}
+
+class E {
+ G operator +(int i) => new I();
+ G operator -(int i) => new I();
+}
+
+class F {}
+
+class G extends E implements F {}
+
+class H {}
+
+class I extends G implements H {}
+
+C nullC() => null;
+
+main() {
+ // Make sure the "none" test fails if assignment to "?." is not implemented.
+ // This makes status files easier to maintain.
+ nullC()?.v = 1;
+
+ // e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
+
+
+
+ // C?.v++ is equivalent to C.v++.
+
+
+
+ // The static type of e1?.v++ is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
+
+
+
+ // C?.v-- is equivalent to C.v--.
+
+
+
+ // The static type of e1?.v-- is the same as the static type of e1.v.
+
+
+
+
+
+
+
+ // ++e1?.v is equivalent to e1?.v += 1.
+
+
+
+ // ++C?.v is equivalent to C?.v += 1.
+
+
+
+ // The static type of ++e1?.v is the same as the static type of e1.v + 1.
+
+
+
+
+
+
+
+ // --e1?.v is equivalent to e1?.v -= 1.
+
+
+
+ // --C?.v is equivalent to C?.v -= 1.
+
+
+
+ // The static type of --e1?.v is the same as the static type of e1.v - 1.
+
+
+
+
+
+
+}
diff --git a/tests/language_2/conditional_property_increment_decrement_test.dart b/tests/language_2/conditional_property_increment_decrement_test.dart
index ec3b880..2341f98 100644
--- a/tests/language_2/conditional_property_increment_decrement_test.dart
+++ b/tests/language_2/conditional_property_increment_decrement_test.dart
@@ -41,66 +41,112 @@
nullC()?.v = 1;
// e1?.v++ is equivalent to ((x) => x == null ? null : x.v++)(e1).
- Expect.equals(null, nullC()?.v++); //# 01: ok
- { C c = new C(1); Expect.equals(1, c?.v++); Expect.equals(2, c.v); } //# 02: ok
+ Expect.equals(null, nullC()?.v++);
+ { C c = new C(1); Expect.equals(1, c?.v++); Expect.equals(2, c.v); }
// C?.v++ is equivalent to C.v++.
- { C.staticInt = 1; Expect.equals(1, C?.staticInt++); Expect.equals(2, C.staticInt); } //# 17: ok
- { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt++); Expect.equals(2, h.C.staticInt); } //# 18: ok
+ { C.staticInt = 1; Expect.equals(1, C?.staticInt++); Expect.equals(2, C.staticInt); }
+ { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt++); Expect.equals(2, h.C.staticInt); }
// The static type of e1?.v++ is the same as the static type of e1.v.
- { E e1 = new E(); D d = new D(e1); E e2 = d?.v++; Expect.identical(e1, e2); } //# 03: ok
- { G g = new G(); D d = new D(g); F f = d?.v++; Expect.identical(f, g); } //# 04: compile-time error
- { E e1 = new E(); D.staticE = e1; E e2 = D?.staticE++; Expect.identical(e1, e2); } //# 19: ok
- { h.E e1 = new h.E(); h.D.staticE = e1; h.E e2 = h.D?.staticE++; Expect.identical(e1, e2); } //# 20: ok
- { G g = new G(); D.staticE = g; F f = D?.staticE++; Expect.identical(f, g); } //# 21: compile-time error
- { h.G g = new h.G(); h.D.staticE = g; h.F f = h.D?.staticE++; Expect.identical(f, g); } //# 22: compile-time error
+ { E e1 = new E(); D d = new D(e1); E e2 = d?.v++; Expect.identical(e1, e2); }
+ { G g = new G(); D d = new D(g); F f = d?.v++; Expect.identical(f, g); }
+ // ^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'E' can't be assigned to a variable of type 'F'.
+ { E e1 = new E(); D.staticE = e1; E e2 = D?.staticE++; Expect.identical(e1, e2); }
+ { h.E e1 = new h.E(); h.D.staticE = e1; h.E e2 = h.D?.staticE++; Expect.identical(e1, e2); }
+ { G g = new G(); D.staticE = g; F f = D?.staticE++; Expect.identical(f, g); }
+ // ^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E' can't be assigned to a variable of type 'F'.
+ { h.G g = new h.G(); h.D.staticE = g; h.F f = h.D?.staticE++; Expect.identical(f, g); }
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E' can't be assigned to a variable of type 'F'.
// e1?.v-- is equivalent to ((x) => x == null ? null : x.v--)(e1).
- Expect.equals(null, nullC()?.v--); //# 05: ok
- { C c = new C(1); Expect.equals(1, c?.v--); Expect.equals(0, c.v); } //# 06: ok
+ Expect.equals(null, nullC()?.v--);
+ { C c = new C(1); Expect.equals(1, c?.v--); Expect.equals(0, c.v); }
// C?.v-- is equivalent to C.v--.
- { C.staticInt = 1; Expect.equals(1, C?.staticInt--); Expect.equals(0, C.staticInt); } //# 23: ok
- { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt--); Expect.equals(0, h.C.staticInt); } //# 24: ok
+ { C.staticInt = 1; Expect.equals(1, C?.staticInt--); Expect.equals(0, C.staticInt); }
+ { h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt--); Expect.equals(0, h.C.staticInt); }
// The static type of e1?.v-- is the same as the static type of e1.v.
- { E e1 = new E(); D d = new D(e1); E e2 = d?.v--; Expect.identical(e1, e2); } //# 07: ok
- { G g = new G(); D d = new D(g); F f = d?.v--; Expect.identical(f, g); } //# 08: compile-time error
- { E e1 = new E(); D.staticE = e1; E e2 = D?.staticE--; Expect.identical(e1, e2); } //# 25: ok
- { h.E e1 = new h.E(); h.D.staticE = e1; h.E e2 = h.D?.staticE--; Expect.identical(e1, e2); } //# 26: ok
- { G g = new G(); D.staticE = g; F f = D?.staticE--; Expect.identical(f, g); } //# 27: compile-time error
- { h.G g = new h.G(); h.D.staticE = g; h.F f = h.D?.staticE--; Expect.identical(f, g); } //# 28: compile-time error
+ { E e1 = new E(); D d = new D(e1); E e2 = d?.v--; Expect.identical(e1, e2); }
+ { G g = new G(); D d = new D(g); F f = d?.v--; Expect.identical(f, g); }
+ // ^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'E' can't be assigned to a variable of type 'F'.
+ { E e1 = new E(); D.staticE = e1; E e2 = D?.staticE--; Expect.identical(e1, e2); }
+ { h.E e1 = new h.E(); h.D.staticE = e1; h.E e2 = h.D?.staticE--; Expect.identical(e1, e2); }
+ { G g = new G(); D.staticE = g; F f = D?.staticE--; Expect.identical(f, g); }
+ // ^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E' can't be assigned to a variable of type 'F'.
+ { h.G g = new h.G(); h.D.staticE = g; h.F f = h.D?.staticE--; Expect.identical(f, g); }
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E' can't be assigned to a variable of type 'F'.
// ++e1?.v is equivalent to e1?.v += 1.
- Expect.equals(null, ++nullC()?.v); //# 09: ok
- { C c = new C(1); Expect.equals(2, ++c?.v); Expect.equals(2, c.v); } //# 10: ok
+ Expect.equals(null, ++nullC()?.v);
+ { C c = new C(1); Expect.equals(2, ++c?.v); Expect.equals(2, c.v); }
// ++C?.v is equivalent to C?.v += 1.
- { C.staticInt = 1; Expect.equals(2, ++C?.staticInt); Expect.equals(2, C.staticInt); } //# 29: ok
- { h.C.staticInt = 1; Expect.equals(2, ++h.C?.staticInt); Expect.equals(2, h.C.staticInt); } //# 30: ok
+ { C.staticInt = 1; Expect.equals(2, ++C?.staticInt); Expect.equals(2, C.staticInt); }
+ { h.C.staticInt = 1; Expect.equals(2, ++h.C?.staticInt); Expect.equals(2, h.C.staticInt); }
// The static type of ++e1?.v is the same as the static type of e1.v + 1.
- { D d = new D(new E()); F f = ++d?.v; Expect.identical(d.v, f); } //# 11: ok
- { D d = new D(new E()); H h = ++d?.v; Expect.identical(d.v, h); } //# 12: compile-time error
- { D.staticE = new E(); F f = ++D?.staticE; Expect.identical(D.staticE, f); } //# 31: ok
- { h.D.staticE = new h.E(); h.F f = ++h.D?.staticE; Expect.identical(h.D.staticE, f); } //# 32: ok
- { D.staticE = new E(); H h = ++D?.staticE; Expect.identical(D.staticE, h); } //# 33: compile-time error
- { h.D.staticE = new h.E(); h.H hh = ++h.D?.staticE; Expect.identical(h.D.staticE, hh); } //# 34: compile-time error
+ { D d = new D(new E()); F f = ++d?.v; Expect.identical(d.v, f); }
+ { D d = new D(new E()); H h = ++d?.v; Expect.identical(d.v, h); }
+ // ^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'G' can't be assigned to a variable of type 'H'.
+ { D.staticE = new E(); F f = ++D?.staticE; Expect.identical(D.staticE, f); }
+ { h.D.staticE = new h.E(); h.F f = ++h.D?.staticE; Expect.identical(h.D.staticE, f); }
+ { D.staticE = new E(); H h = ++D?.staticE; Expect.identical(D.staticE, h); }
+ // ^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'G' can't be assigned to a variable of type 'H'.
+ { h.D.staticE = new h.E(); h.H hh = ++h.D?.staticE; Expect.identical(h.D.staticE, hh); }
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'G' can't be assigned to a variable of type 'H'.
// --e1?.v is equivalent to e1?.v -= 1.
- Expect.equals(null, --nullC()?.v); //# 13: ok
- { C c = new C(1); Expect.equals(0, --c?.v); Expect.equals(0, c.v); } //# 14: ok
+ Expect.equals(null, --nullC()?.v);
+ { C c = new C(1); Expect.equals(0, --c?.v); Expect.equals(0, c.v); }
// --C?.v is equivalent to C?.v -= 1.
- { C.staticInt = 1; Expect.equals(0, --C?.staticInt); Expect.equals(0, C.staticInt); } //# 35: ok
- { h.C.staticInt = 1; Expect.equals(0, --h.C?.staticInt); Expect.equals(0, h.C.staticInt); } //# 36: ok
+ { C.staticInt = 1; Expect.equals(0, --C?.staticInt); Expect.equals(0, C.staticInt); }
+ { h.C.staticInt = 1; Expect.equals(0, --h.C?.staticInt); Expect.equals(0, h.C.staticInt); }
// The static type of --e1?.v is the same as the static type of e1.v - 1.
- { D d = new D(new E()); F f = --d?.v; Expect.identical(d.v, f); } //# 15: ok
- { D d = new D(new E()); H h = --d?.v; Expect.identical(d.v, h); } //# 16: compile-time error
- { D.staticE = new E(); F f = --D?.staticE; Expect.identical(D.staticE, f); } //# 37: ok
- { h.D.staticE = new h.E(); h.F f = --h.D?.staticE; Expect.identical(h.D.staticE, f); } //# 38: ok
- { D.staticE = new E(); H h = --D?.staticE; Expect.identical(D.staticE, h); } //# 39: compile-time error
- { h.D.staticE = new h.E(); h.H hh = --h.D?.staticE; Expect.identical(h.D.staticE, hh); } //# 40: compile-time error
+ { D d = new D(new E()); F f = --d?.v; Expect.identical(d.v, f); }
+ { D d = new D(new E()); H h = --d?.v; Expect.identical(d.v, h); }
+ // ^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'G' can't be assigned to a variable of type 'H'.
+ { D.staticE = new E(); F f = --D?.staticE; Expect.identical(D.staticE, f); }
+ { h.D.staticE = new h.E(); h.F f = --h.D?.staticE; Expect.identical(h.D.staticE, f); }
+ { D.staticE = new E(); H h = --D?.staticE; Expect.identical(D.staticE, h); }
+ // ^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'G' can't be assigned to a variable of type 'H'.
+ { h.D.staticE = new h.E(); h.H hh = --h.D?.staticE; Expect.identical(h.D.staticE, hh); }
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'G' can't be assigned to a variable of type 'H'.
}
diff --git a/tests/language_2/const_conditional_runtime_test.dart b/tests/language_2/const_conditional_runtime_test.dart
new file mode 100644
index 0000000..5b9d8c8
--- /dev/null
+++ b/tests/language_2/const_conditional_runtime_test.dart
@@ -0,0 +1,59 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test for conditionals as compile-time constants.
+
+import 'package:expect/expect.dart';
+
+class Marker {
+ final field;
+ const Marker(this.field);
+}
+
+var var0 = const Marker(0);
+var var1 = const Marker(1);
+const const0 = const Marker(0);
+const const1 = const Marker(1);
+
+const trueConst = true;
+const falseConst = false;
+var nonConst = true;
+const zeroConst = 0;
+
+const cond1 = trueConst ? const0 : const1;
+
+
+
+const cond2 = falseConst ? const0 : const1;
+
+
+
+
+
+
+
+
+
+
+
+void main() {
+ Expect.identical(var0, cond1);
+
+
+
+ Expect.identical(var1, cond2);
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/const_conditional_test.dart b/tests/language_2/const_conditional_test.dart
index b214af9..33aec86 100644
--- a/tests/language_2/const_conditional_test.dart
+++ b/tests/language_2/const_conditional_test.dart
@@ -22,35 +22,89 @@
const zeroConst = 0;
const cond1 = trueConst ? const0 : const1;
-const cond1a = trueConst ? nonConst : const1; //# 01: compile-time error
-const cond1b = trueConst ? const0 : nonConst; //# 02: compile-time error
+const cond1a = trueConst ? nonConst : const1;
+// ^
+// [cfe] Constant evaluation error:
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Not a constant expression.
+const cond1b = trueConst ? const0 : nonConst;
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Not a constant expression.
const cond2 = falseConst ? const0 : const1;
-const cond2a = falseConst ? nonConst : const1; //# 03: compile-time error
-const cond2b = falseConst ? const0 : nonConst; //# 04: compile-time error
+const cond2a = falseConst ? nonConst : const1;
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Not a constant expression.
+const cond2b = falseConst ? const0 : nonConst;
+// ^
+// [cfe] Constant evaluation error:
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Not a constant expression.
-const cond3 = nonConst ? const0 : const1; //# 05: compile-time error
-const cond3a = nonConst ? nonConst : const1; //# 06: compile-time error
-const cond3b = nonConst ? const0 : nonConst; //# 07: compile-time error
+const cond3 = nonConst ? const0 : const1;
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Not a constant expression.
+// ^
+// [cfe] Constant evaluation error:
+const cond3a = nonConst ? nonConst : const1;
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Not a constant expression.
+// ^
+// [cfe] Constant evaluation error:
+// ^
+// [cfe] Not a constant expression.
+const cond3b = nonConst ? const0 : nonConst;
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Not a constant expression.
+// ^
+// [cfe] Constant evaluation error:
+// ^
+// [cfe] Not a constant expression.
-const cond4 = zeroConst ? const0 : const1; //# 08: compile-time error
-const cond4a = zeroConst ? nonConst : const1; //# 09: compile-time error
-const cond4b = zeroConst ? const0 : nonConst; //# 10: compile-time error
+const cond4 = zeroConst ? const0 : const1;
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
+// [cfe] A value of type 'int' can't be assigned to a variable of type 'bool'.
+// ^^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_BOOL_CONDITION
+const cond4a = zeroConst ? nonConst : const1;
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
+// [cfe] A value of type 'int' can't be assigned to a variable of type 'bool'.
+// ^^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_BOOL_CONDITION
+// ^
+// [cfe] Not a constant expression.
+const cond4b = zeroConst ? const0 : nonConst;
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
+// [cfe] A value of type 'int' can't be assigned to a variable of type 'bool'.
+// ^^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_BOOL_CONDITION
+// ^
+// [cfe] Not a constant expression.
void main() {
Expect.identical(var0, cond1);
- Expect.identical(nonConst, cond1a); //# 01: continued
- Expect.identical(var0, cond1b); //# 02: continued
+ Expect.identical(nonConst, cond1a);
+ Expect.identical(var0, cond1b);
Expect.identical(var1, cond2);
- Expect.identical(var1, cond2a); //# 03: continued
- Expect.identical(nonConst, cond2b); //# 04: continued
+ Expect.identical(var1, cond2a);
+ Expect.identical(nonConst, cond2b);
- Expect.identical(var0, cond3); // //# 05: continued
- Expect.identical(nonConst, cond3a); //# 06: continued
- Expect.identical(var0, cond3b); //# 07: continued
+ Expect.identical(var0, cond3);
+ Expect.identical(nonConst, cond3a);
+ Expect.identical(var0, cond3b);
- Expect.identical(var1, cond4); // //# 08: continued
- Expect.identical(var1, cond4a); //# 09: continued
- Expect.identical(nonConst, cond4b); //# 10: continued
+ Expect.identical(var1, cond4);
+ Expect.identical(var1, cond4a);
+ Expect.identical(nonConst, cond4b);
}
diff --git a/tests/language_2/const_constructor3_runtime_1_test.dart b/tests/language_2/const_constructor3_runtime_1_test.dart
new file mode 100644
index 0000000..2a970db
--- /dev/null
+++ b/tests/language_2/const_constructor3_runtime_1_test.dart
@@ -0,0 +1,28 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+class C {
+ final double d;
+ const C(this.d);
+}
+
+class D extends C {
+ const D(var d) : super(d);
+}
+
+const intValue = 0;
+const c = const C(0.0);
+
+
+
+
+main() {
+ print(c);
+
+
+
+}
diff --git a/tests/language_2/const_constructor3_runtime_2_test.dart b/tests/language_2/const_constructor3_runtime_2_test.dart
new file mode 100644
index 0000000..799f5d7
--- /dev/null
+++ b/tests/language_2/const_constructor3_runtime_2_test.dart
@@ -0,0 +1,28 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+class C {
+ final double d;
+ const C(this.d);
+}
+
+class D extends C {
+ const D(var d) : super(d);
+}
+
+const intValue = 0;
+
+
+const e = const D(0.0);
+
+
+main() {
+
+
+ print(e);
+
+}
diff --git a/tests/language_2/const_constructor3_runtime_test.dart b/tests/language_2/const_constructor3_runtime_test.dart
new file mode 100644
index 0000000..5c2e771
--- /dev/null
+++ b/tests/language_2/const_constructor3_runtime_test.dart
@@ -0,0 +1,28 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+class C {
+ final double d;
+ const C(this.d);
+}
+
+class D extends C {
+ const D(var d) : super(d);
+}
+
+const intValue = 0;
+
+
+
+
+
+main() {
+
+
+
+
+}
diff --git a/tests/language_2/const_constructor3_test.dart b/tests/language_2/const_constructor3_test.dart
index e12c4b7..54191d1 100644
--- a/tests/language_2/const_constructor3_test.dart
+++ b/tests/language_2/const_constructor3_test.dart
@@ -12,14 +12,23 @@
}
const intValue = 0;
-const c = const C(0.0); //# 01: ok
-const d = const C(intValue); //# 02: compile-time error
-const e = const D(0.0); //# 03: ok
-const f = const D(intValue); //# 04: compile-time error
+const c = const C(0.0);
+const d = const C(intValue);
+// ^^^^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
+// ^^^^^^^^
+// [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+const e = const D(0.0);
+const f = const D(intValue);
+// ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
+// ^
+// [cfe] Constant evaluation error:
main() {
- print(c); //# 01: continued
- print(d); //# 02: continued
- print(e); //# 03: continued
- print(f); //# 04: continued
+ print(c);
+ print(d);
+ print(e);
+ print(f);
}
diff --git a/tests/language_2/const_constructor_mixin2_runtime_test.dart b/tests/language_2/const_constructor_mixin2_runtime_test.dart
new file mode 100644
index 0000000..5ca87e9
--- /dev/null
+++ b/tests/language_2/const_constructor_mixin2_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class Mixin {
+ var nonFinalField;
+}
+
+class A {
+ const A(foo);
+}
+
+class B extends A
+
+{
+ const B(foo) : super(foo);
+}
+
+main() {
+ var a = const B(42);
+
+}
diff --git a/tests/language_2/const_constructor_mixin2_test.dart b/tests/language_2/const_constructor_mixin2_test.dart
index 2030c45..d1a854c 100644
--- a/tests/language_2/const_constructor_mixin2_test.dart
+++ b/tests/language_2/const_constructor_mixin2_test.dart
@@ -11,12 +11,18 @@
}
class B extends A
- with Mixin //# 01: compile-time error
+ with Mixin
{
const B(foo) : super(foo);
+//^^^^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELD
+// ^
+// [cfe] A constant constructor can't call a non-constant super constructor.
}
main() {
var a = const B(42);
- a.nonFinalField = 54; //# 01: continued
+ a.nonFinalField = 54;
}
diff --git a/tests/language_2/const_constructor_nonconst_field_runtime_test.dart b/tests/language_2/const_constructor_nonconst_field_runtime_test.dart
new file mode 100644
index 0000000..a08abbe
--- /dev/null
+++ b/tests/language_2/const_constructor_nonconst_field_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+
+ final int j = 1;
+ const A();
+}
+
+int f() {
+ return 3;
+}
+
+main() {
+ const A().j;
+}
diff --git a/tests/language_2/const_constructor_nonconst_field_test.dart b/tests/language_2/const_constructor_nonconst_field_test.dart
index e644e81..d2e7030 100644
--- a/tests/language_2/const_constructor_nonconst_field_test.dart
+++ b/tests/language_2/const_constructor_nonconst_field_test.dart
@@ -5,9 +5,13 @@
import "package:expect/expect.dart";
class A {
- final int i = f(); //# 01: compile-time error
+ final int i = f();
+ // ^
+ // [cfe] Method invocation is not a constant expression.
final int j = 1;
const A();
+//^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST
}
int f() {
diff --git a/tests/language_2/const_constructor_nonconst_param_runtime_test.dart b/tests/language_2/const_constructor_nonconst_param_runtime_test.dart
new file mode 100644
index 0000000..5ba2bf7
--- /dev/null
+++ b/tests/language_2/const_constructor_nonconst_param_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class A {
+ const A(int a);
+}
+
+class B {
+
+ const B(dynamic v) //
+
+ ;
+}
+
+void main() {
+ const B("");
+}
diff --git a/tests/language_2/const_constructor_nonconst_param_test.dart b/tests/language_2/const_constructor_nonconst_param_test.dart
index aae46a6..bca1b3e 100644
--- a/tests/language_2/const_constructor_nonconst_param_test.dart
+++ b/tests/language_2/const_constructor_nonconst_param_test.dart
@@ -7,12 +7,19 @@
}
class B {
- final a; // //# 01: compile-time error
+ final a;
const B(dynamic v) //
- : a = A(v) //# 01: continued
+ : a = A(v)
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] Constant evaluation error:
+ // ^
+ // [cfe] Constant expression expected.
;
}
void main() {
const B("");
+//^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
}
diff --git a/tests/language_2/const_constructor_runtime_test.dart b/tests/language_2/const_constructor_runtime_test.dart
new file mode 100644
index 0000000..c643e1c
--- /dev/null
+++ b/tests/language_2/const_constructor_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+class A<T> {
+ final int x;
+ const A.named() : x = 42;
+ A() : x = null;
+}
+
+main() {
+ Expect.equals(42, (const A<int>.named()).x);
+ Expect.equals(42, (new A<int>.named()).x);
+
+}
diff --git a/tests/language_2/const_constructor_super_runtime_test.dart b/tests/language_2/const_constructor_super_runtime_test.dart
new file mode 100644
index 0000000..aa555a62
--- /dev/null
+++ b/tests/language_2/const_constructor_super_runtime_test.dart
@@ -0,0 +1,36 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ final a;
+ A(this.a); // Not const.
+ const A.five() : a = 5;
+}
+
+class B extends A {
+ final b;
+ B(x)
+ : b = x + 1,
+ super(x);
+
+ // Const constructor cannot call non-const super constructor.
+
+}
+
+class C extends A {
+ C() : super(0);
+ // Implicit call to non-const constructor A(x).
+
+}
+
+main() {
+
+ var b1 = new B(0);
+
+}
diff --git a/tests/language_2/const_constructor_super_test.dart b/tests/language_2/const_constructor_super_test.dart
index 5a884d2..f710d15 100644
--- a/tests/language_2/const_constructor_super_test.dart
+++ b/tests/language_2/const_constructor_super_test.dart
@@ -17,17 +17,25 @@
super(x);
// Const constructor cannot call non-const super constructor.
- const B.zerofive() : b = 0, super(5); //# 01: compile-time error
+ const B.zerofive() : b = 0, super(5);
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER
+ // [cfe] A constant constructor can't call a non-constant super constructor.
}
class C extends A {
C() : super(0);
// Implicit call to non-const constructor A(x).
- const C.named(x); //# 02: compile-time error
+ const C.named(x);
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER
+ // [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
}
main() {
- var b = new B.zerofive(); //# 01: continued
+ var b = new B.zerofive();
var b1 = new B(0);
- var c = new C.named(""); //# 02: continued
+ var c = new C.named("");
}
diff --git a/tests/language_2/const_constructor_syntax_runtime_test.dart b/tests/language_2/const_constructor_syntax_runtime_test.dart
new file mode 100644
index 0000000..bccb4a8
--- /dev/null
+++ b/tests/language_2/const_constructor_syntax_runtime_test.dart
@@ -0,0 +1,38 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+main() {
+
+
+ var c1 = const C1();
+
+ var c3 = const C3();
+}
+
+abstract class I0 {
+ factory I0() = C0;
+}
+
+class C0 implements I0 {
+ C0();
+}
+
+class C1 {
+ const C1();
+
+}
+
+class C2 {
+ C2();
+}
+
+class C3 {
+ const C3()
+
+ ;
+ final field = null;
+}
diff --git a/tests/language_2/const_constructor_syntax_test.dart b/tests/language_2/const_constructor_syntax_test.dart
index f4ae9aa..645c0f1 100644
--- a/tests/language_2/const_constructor_syntax_test.dart
+++ b/tests/language_2/const_constructor_syntax_test.dart
@@ -3,11 +3,25 @@
// BSD-style license that can be found in the LICENSE file.
main() {
- var c0 = const C0(); //# 01: compile-time error
- var i0 = const I0(); //# 02: compile-time error
+ var c0 = const C0();
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_WITH_NON_CONST
+ // ^
+ // [cfe] Cannot invoke a non-'const' constructor where a const expression is expected.
+ var i0 = const I0();
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_WITH_NON_CONST
+ // ^
+ // [cfe] Cannot invoke a non-'const' factory where a const expression is expected.
var c1 = const C1();
- var c2 = const C2(); //# 03: compile-time error
+ var c2 = const C2();
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_WITH_NON_CONST
+ // ^
+ // [cfe] Cannot invoke a non-'const' constructor where a const expression is expected.
var c3 = const C3();
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
}
abstract class I0 {
@@ -20,7 +34,11 @@
class C1 {
const C1();
- var modifiable; //# 04: compile-time error
+//^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD
+// ^
+// [cfe] Constructor is marked 'const' so all fields must be final.
+ var modifiable;
}
class C2 {
@@ -29,7 +47,16 @@
class C3 {
const C3()
- : field = new C0() //# 05: compile-time error
+ : field = new C0()
+ //^^^^^
+ // [analyzer] STATIC_WARNING.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION
+ // ^
+ // [cfe] 'field' is a final instance variable that has already been initialized.
+ // ^
+ // [cfe] Cannot invoke a non-'const' constructor where a const expression is expected.
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // [cfe] New expression is not a constant expression.
;
final field = null;
}
diff --git a/tests/language_2/const_constructor_test.dart b/tests/language_2/const_constructor_test.dart
index ae84d73..d571d92 100644
--- a/tests/language_2/const_constructor_test.dart
+++ b/tests/language_2/const_constructor_test.dart
@@ -13,5 +13,9 @@
main() {
Expect.equals(42, (const A<int>.named()).x);
Expect.equals(42, (new A<int>.named()).x);
- const A<int>(); //# 01: compile-time error
+ const A<int>();
+//^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_WITH_NON_CONST
+// ^
+// [cfe] Cannot invoke a non-'const' constructor where a const expression is expected.
}
diff --git a/tests/language_2/const_counter_runtime_test.dart b/tests/language_2/const_counter_runtime_test.dart
new file mode 100644
index 0000000..dd8251f
--- /dev/null
+++ b/tests/language_2/const_counter_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// Bug: 4254106 Constant constructors must have (implicit) const parameters.
+
+class ConstCounter {
+ const ConstCounter(int i)
+ : nextValue_ = (
+ // Incorrect assignment of a non-const function to a final field.
+
+ i + 1);
+
+ final nextValue_;
+}
+
+main() {
+ const ConstCounter(3);
+}
diff --git a/tests/language_2/const_counter_test.dart b/tests/language_2/const_counter_test.dart
index 32ac968..0ca474f 100644
--- a/tests/language_2/const_counter_test.dart
+++ b/tests/language_2/const_counter_test.dart
@@ -7,13 +7,21 @@
class ConstCounter {
const ConstCounter(int i)
: nextValue_ = (
- // Incorrect assignment of a non-const function to a final field.
- () => //# 01: compile-time error
- i + 1);
+ // ^
+ // [cfe] Can't find ')' to match '('.
+ // Incorrect assignment of a non-const function to a final field.
+ () => i + 1;
+// ^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+// [cfe] Not a constant expression.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
final nextValue_;
}
main() {
const ConstCounter(3);
+//^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
}
diff --git a/tests/language_2/const_dynamic_type_literal_runtime_1_test.dart b/tests/language_2/const_dynamic_type_literal_runtime_1_test.dart
new file mode 100644
index 0000000..8f56bb6
--- /dev/null
+++ b/tests/language_2/const_dynamic_type_literal_runtime_1_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Test that 'dynamic' can be used in const expressions and has the expected
+// behavior.
+
+import "package:expect/expect.dart";
+
+const d = dynamic;
+const i = int;
+
+void main() {
+ Expect.isTrue(identical(d, dynamic));
+ // Duplicate key error.
+
+
+}
diff --git a/tests/language_2/const_dynamic_type_literal_runtime_2_test.dart b/tests/language_2/const_dynamic_type_literal_runtime_2_test.dart
new file mode 100644
index 0000000..478a9ed
--- /dev/null
+++ b/tests/language_2/const_dynamic_type_literal_runtime_2_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Test that 'dynamic' can be used in const expressions and has the expected
+// behavior.
+
+import "package:expect/expect.dart";
+
+const d = dynamic;
+const i = int;
+
+void main() {
+
+ // Duplicate key error.
+
+ Expect.equals(2, const { d: 1, i: 2 }.length);
+}
diff --git a/tests/language_2/const_dynamic_type_literal_runtime_test.dart b/tests/language_2/const_dynamic_type_literal_runtime_test.dart
new file mode 100644
index 0000000..05cb59a
--- /dev/null
+++ b/tests/language_2/const_dynamic_type_literal_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Test that 'dynamic' can be used in const expressions and has the expected
+// behavior.
+
+import "package:expect/expect.dart";
+
+const d = dynamic;
+const i = int;
+
+void main() {
+
+ // Duplicate key error.
+
+
+}
diff --git a/tests/language_2/const_dynamic_type_literal_test.dart b/tests/language_2/const_dynamic_type_literal_test.dart
index 3b34b30..e69bb8f 100644
--- a/tests/language_2/const_dynamic_type_literal_test.dart
+++ b/tests/language_2/const_dynamic_type_literal_test.dart
@@ -11,8 +11,12 @@
const i = int;
void main() {
- Expect.isTrue(identical(d, dynamic)); //# 01: ok
+ Expect.isTrue(identical(d, dynamic));
// Duplicate key error.
- Expect.equals(1, const { d: 1, d: 2 }.length); //# 02: compile-time error
- Expect.equals(2, const { d: 1, i: 2 }.length); //# 03: ok
+ Expect.equals(1, const { d: 1, d: 2 }.length);
+ // ^
+ // [cfe] Constant evaluation error:
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.EQUAL_KEYS_IN_CONST_MAP
+ Expect.equals(2, const { d: 1, i: 2 }.length);
}
diff --git a/tests/language_2/const_factory_with_body_runtime_test.dart b/tests/language_2/const_factory_with_body_runtime_test.dart
new file mode 100644
index 0000000..559defc
--- /dev/null
+++ b/tests/language_2/const_factory_with_body_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+//
+// Tests that a "const factory" with body produces a compile-time error.
+
+class ConstFactoryWithBody {
+
+}
+
+main() {
+
+}
diff --git a/tests/language_2/const_factory_with_body_test.dart b/tests/language_2/const_factory_with_body_test.dart
index eb6cdbf..acabe6c 100644
--- a/tests/language_2/const_factory_with_body_test.dart
+++ b/tests/language_2/const_factory_with_body_test.dart
@@ -5,9 +5,12 @@
// Tests that a "const factory" with body produces a compile-time error.
class ConstFactoryWithBody {
- const factory ConstFactoryWithBody.one() { } //# 01: compile-time error
+ const factory ConstFactoryWithBody.one() { }
+//^^^^^
+// [analyzer] SYNTACTIC_ERROR.CONST_FACTORY
+// [cfe] Only redirecting factory constructors can be declared to be 'const'.
}
main() {
- const ConstFactoryWithBody.one(); //# 01: continued
+ const ConstFactoryWithBody.one();
}
diff --git a/tests/language_2/const_getter_runtime_test.dart b/tests/language_2/const_getter_runtime_test.dart
new file mode 100644
index 0000000..4d32485
--- /dev/null
+++ b/tests/language_2/const_getter_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Check that const getters are not allowed.
+
+import 'package:expect/expect.dart';
+
+class C {
+ const C();
+
+
+ get x => 1;
+}
+
+
+get y => 2;
+
+main() {
+ const C().x;
+ y;
+}
diff --git a/tests/language_2/const_getter_test.dart b/tests/language_2/const_getter_test.dart
index 5ca0211..c843529 100644
--- a/tests/language_2/const_getter_test.dart
+++ b/tests/language_2/const_getter_test.dart
@@ -9,11 +9,17 @@
class C {
const C();
- const //# 01: syntax error
+ const
+//^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'const' here.
get x => 1;
}
-const //# 02: syntax error
+const
+// [error line 19, column 1, length 5]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'const' here.
get y => 2;
main() {
diff --git a/tests/language_2/const_init2_runtime_1_test.dart b/tests/language_2/const_init2_runtime_1_test.dart
new file mode 100644
index 0000000..7338f45
--- /dev/null
+++ b/tests/language_2/const_init2_runtime_1_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+const intValue = 0;
+const double c = 0.0;
+
+
+main() {
+ print(c);
+
+}
diff --git a/tests/language_2/const_init2_runtime_test.dart b/tests/language_2/const_init2_runtime_test.dart
new file mode 100644
index 0000000..5970f29
--- /dev/null
+++ b/tests/language_2/const_init2_runtime_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+const intValue = 0;
+
+
+
+main() {
+
+
+}
diff --git a/tests/language_2/const_init2_test.dart b/tests/language_2/const_init2_test.dart
index fcc6f6f..7f5e1a3 100644
--- a/tests/language_2/const_init2_test.dart
+++ b/tests/language_2/const_init2_test.dart
@@ -3,10 +3,15 @@
// BSD-style license that can be found in the LICENSE file.
const intValue = 0;
-const double c = 0.0; //# 01: ok
-const double d = intValue; //# 02: compile-time error
+const double c = 0.0;
+const double d = intValue;
+// ^^^^^^^^
+// [analyzer] CHECKED_MODE_COMPILE_TIME_ERROR.VARIABLE_TYPE_MISMATCH
+// [cfe] A value of type 'int' can't be assigned to a variable of type 'double'.
+// ^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
main() {
- print(c); //# 01: continued
- print(d); //# 02: continued
+ print(c);
+ print(d);
}
diff --git a/tests/language_2/const_instance_field_runtime_test.dart b/tests/language_2/const_instance_field_runtime_test.dart
new file mode 100644
index 0000000..697b231
--- /dev/null
+++ b/tests/language_2/const_instance_field_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// Test that const instance fields are compile-time errors.
+
+class C {
+
+}
+
+void main() {
+ new C();
+}
diff --git a/tests/language_2/const_instance_field_test.dart b/tests/language_2/const_instance_field_test.dart
index 1584887..f80551a 100644
--- a/tests/language_2/const_instance_field_test.dart
+++ b/tests/language_2/const_instance_field_test.dart
@@ -5,7 +5,10 @@
// Test that const instance fields are compile-time errors.
class C {
- const field = 0; //# 01: syntax error
+ const field = 0;
+//^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INSTANCE_FIELD
+// [cfe] Only static fields can be declared as const.
}
void main() {
diff --git a/tests/language_2/const_map2_runtime_test.dart b/tests/language_2/const_map2_runtime_test.dart
new file mode 100644
index 0000000..9e1fe97
--- /dev/null
+++ b/tests/language_2/const_map2_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ const factory A() = B;
+}
+
+class B implements A {
+ const B();
+
+
+}
+
+confuse(x) {
+ if (new DateTime.now() == 42) return confuse(2);
+ return x;
+}
+
+main() {
+ // It is a compile-time error if the key type overrides operator ==.
+ dynamic m = const {const A(): 42};
+ Expect.equals(42, m[confuse(const B())]);
+
+ m = const {"foo": 99, const A(): 499};
+ Expect.equals(499, m[confuse(const B())]);
+}
diff --git a/tests/language_2/const_map2_test.dart b/tests/language_2/const_map2_test.dart
index 043afd6..a5f3798 100644
--- a/tests/language_2/const_map2_test.dart
+++ b/tests/language_2/const_map2_test.dart
@@ -11,7 +11,7 @@
class B implements A {
const B();
- operator ==(o) => true; //# 00: compile-time error
+ operator ==(o) => true;
}
confuse(x) {
@@ -22,8 +22,16 @@
main() {
// It is a compile-time error if the key type overrides operator ==.
dynamic m = const {const A(): 42};
+ // ^
+ // [cfe] Constant evaluation error:
+ // ^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
Expect.equals(42, m[confuse(const B())]);
m = const {"foo": 99, const A(): 499};
+ // ^
+ // [cfe] Constant evaluation error:
+ // ^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
Expect.equals(499, m[confuse(const B())]);
}
diff --git a/tests/language_2/const_map3_runtime_test.dart b/tests/language_2/const_map3_runtime_test.dart
new file mode 100644
index 0000000..4416774
--- /dev/null
+++ b/tests/language_2/const_map3_runtime_test.dart
@@ -0,0 +1,27 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ static const b = const B();
+}
+
+class B implements A {
+ const B();
+
+
+}
+
+main() {
+ // It is a compile-time error if the key type overrides operator ==.
+ dynamic m = const {A.b: 42};
+ Expect.equals(42, m[const B()]);
+
+ m = const {"foo": 99, A.b: 499};
+ Expect.equals(499, m[const B()]);
+}
diff --git a/tests/language_2/const_map3_test.dart b/tests/language_2/const_map3_test.dart
index 9ba8005..b7ee989 100644
--- a/tests/language_2/const_map3_test.dart
+++ b/tests/language_2/const_map3_test.dart
@@ -11,14 +11,22 @@
class B implements A {
const B();
- operator ==(o) => true; //# 00: compile-time error
+ operator ==(o) => true;
}
main() {
// It is a compile-time error if the key type overrides operator ==.
dynamic m = const {A.b: 42};
+ // ^
+ // [cfe] Constant evaluation error:
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
Expect.equals(42, m[const B()]);
m = const {"foo": 99, A.b: 499};
+ // ^
+ // [cfe] Constant evaluation error:
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
Expect.equals(499, m[const B()]);
}
diff --git a/tests/language_2/const_optional_args_runtime_test.dart b/tests/language_2/const_optional_args_runtime_test.dart
new file mode 100644
index 0000000..46d23f9
--- /dev/null
+++ b/tests/language_2/const_optional_args_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// Check that const objects (including literals) are immutable.
+
+// Must be 'const {}' to be valid.
+invalid(
+ [var p =
+
+ const
+
+ {}]) {}
+
+main() {
+ invalid();
+}
diff --git a/tests/language_2/const_optional_args_test.dart b/tests/language_2/const_optional_args_test.dart
index 0f98b1a..3d7c779 100644
--- a/tests/language_2/const_optional_args_test.dart
+++ b/tests/language_2/const_optional_args_test.dart
@@ -7,10 +7,13 @@
// Must be 'const {}' to be valid.
invalid(
[var p =
- /* //# 01: compile-time error
+ /*
const
- */ //# 01: continued
+ */
{}]) {}
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_DEFAULT_VALUE
+// [cfe] Constant expression expected.
main() {
invalid();
diff --git a/tests/language_2/const_switch2_runtime_test.dart b/tests/language_2/const_switch2_runtime_test.dart
new file mode 100644
index 0000000..65d37de
--- /dev/null
+++ b/tests/language_2/const_switch2_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import 'package:expect/expect.dart';
+
+int main() {
+ var a = [1, 2, 3][2];
+ switch (a) {
+
+
+
+ case 1:
+ print("OK");
+ }
+}
diff --git a/tests/language_2/const_switch2_test.dart b/tests/language_2/const_switch2_test.dart
index 185bd5c..ce1dea9 100644
--- a/tests/language_2/const_switch2_test.dart
+++ b/tests/language_2/const_switch2_test.dart
@@ -7,10 +7,16 @@
int main() {
var a = [1, 2, 3][2];
switch (a) {
- case 0.0: // //# 01: compile-time error
- print("illegal"); // //# 01: continued
- break; // //# 01: continued
+ // ^
+ // [analyzer] STATIC_WARNING.SWITCH_EXPRESSION_NOT_ASSIGNABLE
+ case 0.0:
+ // ^
+ // [cfe] Type 'int' of the switch expression isn't assignable to the type 'double' of this case expression.
+ print("illegal");
+ break;
case 1:
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_CASE_EXPRESSION_TYPES
print("OK");
}
}
diff --git a/tests/language_2/const_syntax_runtime_test.dart b/tests/language_2/const_syntax_runtime_test.dart
new file mode 100644
index 0000000..93d1f48
--- /dev/null
+++ b/tests/language_2/const_syntax_runtime_test.dart
@@ -0,0 +1,92 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ const f0 = 42;
+
+ const int f2 = 87;
+
+ Expect.equals(42, f0);
+ Expect.equals(87, f2);
+
+ Expect.equals(42, F0);
+
+ Expect.equals(87, F2);
+
+
+ Expect.isTrue(P0 is Point);
+
+
+
+
+ Expect.isTrue(A0 is int);
+ Expect.isTrue(A1 is int);
+
+
+
+ Expect.isTrue(C0.X is C1);
+
+
+ Expect.equals("Hello 42", B2);
+
+
+ const cf1 = identical(const Point(1, 2), const Point(1, 2));
+
+
+
+
+ var f5 = B5;
+}
+
+const F0 = 42;
+
+const int F2 = 87;
+
+
+class Point {
+ final x, y;
+ const Point(this.x, this.y);
+ operator +(int other) => x;
+}
+
+// Check that compile time expressions can include invocations of
+// user-defined const constructors.
+const P0 = const Point(0, 0);
+
+
+
+
+// Check that we cannot have cyclic references in compile time
+// expressions.
+const A0 = 42;
+const A1 = A0 + 1;
+
+
+
+class C0 {
+ static const X = const C1();
+}
+
+class C1 {
+ const C1()
+
+ ;
+ final x = null;
+}
+
+// Check that sub-expressions of binary + are numeric.
+const B0 = 42;
+const B1 = "Hello";
+const B2 = "$B1 $B0";
+
+
+// Check identical.
+
+
+const B5 = identical(1, const Point(1, 2));
diff --git a/tests/language_2/const_syntax_test.dart b/tests/language_2/const_syntax_test.dart
index 63486db..358440d 100644
--- a/tests/language_2/const_syntax_test.dart
+++ b/tests/language_2/const_syntax_test.dart
@@ -6,45 +6,62 @@
main() {
const f0 = 42;
- const f1; //# 01: compile-time error
+ const f1;
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_NOT_INITIALIZED
+ // ^
+ // [cfe] The const variable ';' must be initialized.
const int f2 = 87;
- const int f3; //# 02: compile-time error
+ const int f3;
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_NOT_INITIALIZED
+ // ^
+ // [cfe] The const variable ';' must be initialized.
Expect.equals(42, f0);
Expect.equals(87, f2);
Expect.equals(42, F0);
- Expect.equals(null, F1); //# 03: continued
+ Expect.equals(null, F1);
Expect.equals(87, F2);
- Expect.equals(null, F3); //# 04: continued
+ Expect.equals(null, F3);
Expect.isTrue(P0 is Point);
- Expect.isTrue(P1 is int); //# 05: compile-time error
- Expect.isTrue(P2 is Point); //# 06: compile-time error
- Expect.isTrue(P3 is int); //# 07: compile-time error
+ Expect.isTrue(P1 is int);
+ Expect.isTrue(P2 is Point);
+ Expect.isTrue(P3 is int);
Expect.isTrue(A0 is int);
Expect.isTrue(A1 is int);
- Expect.isTrue(A2 is int); //# 08: compile-time error
- Expect.isTrue(A3 is int); //# 08: continued
+ Expect.isTrue(A2 is int);
+ Expect.isTrue(A3 is int);
Expect.isTrue(C0.X is C1);
- Expect.isTrue(C0.X.x is C1); //# 09: compile-time error
+ Expect.isTrue(C0.X.x is C1);
Expect.equals("Hello 42", B2);
- Expect.equals("42Hello", B3); //# 10: compile-time error
+ Expect.equals("42Hello", B3);
const cf1 = identical(const Point(1, 2), const Point(1, 2));
- const cf2 = identical(const Point(1, 2), new Point(1, 2)); //# 11: compile-time error
+ const cf2 = identical(const Point(1, 2), new Point(1, 2));
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ // [cfe] New expression is not a constant expression.
- var f4 = B4; //# 12: compile-time error
+ var f4 = B4;
var f5 = B5;
}
const F0 = 42;
-const F1; //# 03: syntax error
+const F1;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_NOT_INITIALIZED
+// [cfe] The const variable 'F1' must be initialized.
const int F2 = 87;
-const int F3; //# 04: syntax error
+const int F3;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_NOT_INITIALIZED
+// [cfe] The const variable 'F3' must be initialized.
class Point {
final x, y;
@@ -55,24 +72,55 @@
// Check that compile time expressions can include invocations of
// user-defined const constructors.
const P0 = const Point(0, 0);
-const P1 = const Point(0, 0) + 1; //# 05: continued
-const P2 = new Point(0, 0); //# 06: continued
-const P3 = new Point(0, 0) + 1; //# 07: continued
+const P1 = const Point(0, 0) + 1;
+// ^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_NUM
+// ^
+// [cfe] Constant evaluation error:
+const P2 = new Point(0, 0);
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] New expression is not a constant expression.
+const P3 = new Point(0, 0) + 1;
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] New expression is not a constant expression.
+// ^
+// [cfe] Constant evaluation error:
// Check that we cannot have cyclic references in compile time
// expressions.
const A0 = 42;
const A1 = A0 + 1;
-const A2 = A3 + 1; //# 08: continued
-const A3 = A2 + 1; //# 08: continued
+const A2 = A3 + 1;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_COMPILE_TIME_CONSTANT
+// [cfe] Can't infer the type of 'A2': circularity found during type inference.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.TOP_LEVEL_CYCLE
+// ^
+// [cfe] Constant evaluation error:
+const A3 = A2 + 1;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_COMPILE_TIME_CONSTANT
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.TOP_LEVEL_CYCLE
class C0 {
static const X = const C1();
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_COMPILE_TIME_CONSTANT
}
class C1 {
const C1()
- : x = C0.X //# 09: continued
+ : x = C0.X
+ //^
+ // [analyzer] STATIC_WARNING.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION
+ // ^
+ // [cfe] 'x' is a final instance variable that has already been initialized.
+ // ^
+ // [cfe] Cannot invoke a non-'const' constructor where a const expression is expected.
;
final x = null;
}
@@ -81,9 +129,17 @@
const B0 = 42;
const B1 = "Hello";
const B2 = "$B1 $B0";
-const B3 = B0 + B1; //# 10: continued
+const B3 = B0 + B1;
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_NUM
+// ^^
+// [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+// [cfe] A value of type 'String' can't be assigned to a variable of type 'num'.
// Check identical.
-const B4 = identical(1, new Point(1, 2)); //# 12: compile-time error
+const B4 = identical(1, new Point(1, 2));
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] New expression is not a constant expression.
const B5 = identical(1, const Point(1, 2));
diff --git a/tests/language_2/constant_locals_runtime_test.dart b/tests/language_2/constant_locals_runtime_test.dart
new file mode 100644
index 0000000..efabff5
--- /dev/null
+++ b/tests/language_2/constant_locals_runtime_test.dart
@@ -0,0 +1,33 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test that constant local variables have constant initializers.
+
+import "package:expect/expect.dart";
+
+void main() {
+
+ const c2 = 0;
+
+
+ const c5 = constField;
+
+
+ const c8 = const Class();
+}
+
+var field = 0;
+
+final finalField = 0;
+
+const constField = 0;
+
+method() => 0;
+
+class Class {
+ const Class();
+}
diff --git a/tests/language_2/constant_locals_test.dart b/tests/language_2/constant_locals_test.dart
index f5aa080..9f937df 100644
--- a/tests/language_2/constant_locals_test.dart
+++ b/tests/language_2/constant_locals_test.dart
@@ -7,13 +7,33 @@
import "package:expect/expect.dart";
void main() {
- const c1; //# 01: compile-time error
+ const c1;
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_NOT_INITIALIZED
+ // ^
+ // [cfe] The const variable ';' must be initialized.
const c2 = 0;
- const c3 = field; //# 02: compile-time error
- const c4 = finalField; //# 03: compile-time error
+ const c3 = field;
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ // [cfe] Constant evaluation error:
+ // ^
+ // [cfe] Not a constant expression.
+ const c4 = finalField;
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ // [cfe] Constant evaluation error:
+ // ^
+ // [cfe] Not a constant expression.
const c5 = constField;
- const c6 = method(); //# 04: compile-time error
- const c7 = new Class(); //# 05: compile-time error
+ const c6 = method();
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ // [cfe] Method invocation is not a constant expression.
+ const c7 = new Class();
+ // ^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ // [cfe] New expression is not a constant expression.
const c8 = const Class();
}
diff --git a/tests/language_2/constant_type_literal_runtime_test.dart b/tests/language_2/constant_type_literal_runtime_test.dart
new file mode 100644
index 0000000..30fdd50
--- /dev/null
+++ b/tests/language_2/constant_type_literal_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test for type literals as compile-time constants.
+
+class C<T> {
+ void m() {
+ const List lst = const [
+
+ ];
+ }
+}
+
+main() {
+ new C().m();
+}
diff --git a/tests/language_2/constant_type_literal_test.dart b/tests/language_2/constant_type_literal_test.dart
index f3b910b..91e07f4 100644
--- a/tests/language_2/constant_type_literal_test.dart
+++ b/tests/language_2/constant_type_literal_test.dart
@@ -7,7 +7,12 @@
class C<T> {
void m() {
const List lst = const [
- T //# 01: compile-time error
+ T
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+// [cfe] Type variables can't be used as constants.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_LIST_ELEMENT
];
}
}
diff --git a/tests/language_2/constants_runtime_test.dart b/tests/language_2/constants_runtime_test.dart
new file mode 100644
index 0000000..bb84f01
--- /dev/null
+++ b/tests/language_2/constants_runtime_test.dart
@@ -0,0 +1,24 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+class C {
+ factory C() => null;
+}
+
+
+t() => null;
+
+
+get v => null;
+
+main() {
+
+ dynamic x = t();
+
+
+ dynamic z = v;
+}
diff --git a/tests/language_2/constants_test.dart b/tests/language_2/constants_test.dart
index 98442d8..db84c5b 100644
--- a/tests/language_2/constants_test.dart
+++ b/tests/language_2/constants_test.dart
@@ -6,16 +6,34 @@
factory C() => null;
}
-const //# 01: syntax error
+const
+// [error line 9, column 1, length 5]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'const' here.
t() => null;
-const //# 02: syntax error
+const
+// [error line 15, column 1, length 5]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'const' here.
get v => null;
main() {
- const //# 03: compile-time error
+ const
dynamic x = t();
- const y = const C(); //# 04: compile-time error
- const //# 05: compile-time error
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ // [cfe] Method invocation is not a constant expression.
+ const y = const C();
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_WITH_NON_CONST
+ // ^
+ // [cfe] Cannot invoke a non-'const' factory where a const expression is expected.
+ const
dynamic z = v;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ // [cfe] Constant evaluation error:
}
diff --git a/tests/language_2/constructor10_runtime_test.dart b/tests/language_2/constructor10_runtime_test.dart
new file mode 100644
index 0000000..554c0e1
--- /dev/null
+++ b/tests/language_2/constructor10_runtime_test.dart
@@ -0,0 +1,47 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// Check that the implicit super call for synthetic constructors are checked.
+
+class A {
+ final x;
+ A(this.x);
+}
+
+class B extends A {
+
+ B() : super(null);
+
+}
+
+// ==========
+
+class Y extends A {
+
+ Y() : super(null);
+
+}
+
+class Z extends Y {
+ Z() : super();
+}
+
+// ==============
+
+class G extends A {
+
+ G() : super(null);
+
+}
+
+class H extends G {}
+
+main() {
+ new B().x;
+ new Z().x;
+ new H().x;
+}
diff --git a/tests/language_2/constructor10_test.dart b/tests/language_2/constructor10_test.dart
index 87d28d7..06426fb 100644
--- a/tests/language_2/constructor10_test.dart
+++ b/tests/language_2/constructor10_test.dart
@@ -10,17 +10,23 @@
}
class B extends A {
- /* // //# 00: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+// [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
+ /*
B() : super(null);
- */ // //# 00: continued
+ */
}
// ==========
class Y extends A {
- /* // //# 01: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+// [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
+ /*
Y() : super(null);
- */ // //# 01: continued
+ */
}
class Z extends Y {
@@ -30,9 +36,12 @@
// ==============
class G extends A {
- /* // //# 02: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+// [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
+ /*
G() : super(null);
- */ // //# 02: continued
+ */
}
class H extends G {}
diff --git a/tests/language_2/constructor13_runtime_test.dart b/tests/language_2/constructor13_runtime_test.dart
new file mode 100644
index 0000000..e2ff3b6
--- /dev/null
+++ b/tests/language_2/constructor13_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// Check that there's no crash when constructor called with wrong
+// number of args.
+
+class Klass {
+ Klass(v) {}
+}
+
+main() {
+
+ new Klass(1);
+
+}
diff --git a/tests/language_2/constructor13_test.dart b/tests/language_2/constructor13_test.dart
index 0e4c52d..f6790ec 100644
--- a/tests/language_2/constructor13_test.dart
+++ b/tests/language_2/constructor13_test.dart
@@ -10,7 +10,13 @@
}
main() {
- new Klass(); //# 01: compile-time error
+ new Klass();
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
new Klass(1);
- new Klass(1, 2); //# 02: compile-time error
+ new Klass(1, 2);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
}
diff --git a/tests/language_2/constructor9_runtime_test.dart b/tests/language_2/constructor9_runtime_test.dart
new file mode 100644
index 0000000..fcdbf5a
--- /dev/null
+++ b/tests/language_2/constructor9_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Check that all final instance fields of a class are initialized by
+// constructors.
+
+class Klass {
+ Klass(var v) : field_ = v {}
+
+ var field_;
+}
+
+main() {
+ new Klass(5);
+}
diff --git a/tests/language_2/constructor9_test.dart b/tests/language_2/constructor9_test.dart
index 3194d1d..4c7b35d 100644
--- a/tests/language_2/constructor9_test.dart
+++ b/tests/language_2/constructor9_test.dart
@@ -7,7 +7,15 @@
class Klass {
Klass(var v) : field_ = v {}
- final uninitializedFinalField_; // //# 01: compile-time error
+//^^^^^
+// [analyzer] STATIC_WARNING.FINAL_NOT_INITIALIZED_CONSTRUCTOR
+ final uninitializedFinalField_;
+ // ^
+ // [cfe] Final field 'uninitializedFinalField_' is not initialized.
+ final uninitializedFinalField_;
+ // ^^^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+ // [cfe] 'uninitializedFinalField_' is already declared in this scope.
var field_;
}
diff --git a/tests/language_2/constructor_call_wrong_argument_count_runtime_test.dart b/tests/language_2/constructor_call_wrong_argument_count_runtime_test.dart
new file mode 100644
index 0000000..adb20bd
--- /dev/null
+++ b/tests/language_2/constructor_call_wrong_argument_count_runtime_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+class Stockhorn {
+ Stockhorn(int a);
+}
+
+main() {
+ new Stockhorn(1);
+
+}
diff --git a/tests/language_2/constructor_call_wrong_argument_count_test.dart b/tests/language_2/constructor_call_wrong_argument_count_test.dart
index 8855749..4830bcd 100644
--- a/tests/language_2/constructor_call_wrong_argument_count_test.dart
+++ b/tests/language_2/constructor_call_wrong_argument_count_test.dart
@@ -8,5 +8,8 @@
main() {
new Stockhorn(1);
- new Stockhorn(); //# 01: compile-time error
+ new Stockhorn();
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
}
diff --git a/tests/language_2/constructor_duplicate_initializers_runtime_test.dart b/tests/language_2/constructor_duplicate_initializers_runtime_test.dart
new file mode 100644
index 0000000..94a3466
--- /dev/null
+++ b/tests/language_2/constructor_duplicate_initializers_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Check that initializers are not duplicated
+
+ class Class {
+ Class(var v) : field_ = v
+ // Test against duplicate final field initialization in initializing list.
+
+ ;
+ Class.field(this.field_)
+ // Test against duplicate final field initialization between initializing
+ // formals and initializer list.
+
+ ;
+ // Test against duplicate final field initialization in initializing formals.
+ Class.two_fields(this.field_
+
+ );
+ final field_;
+ }
+
+ main() {
+ new Class(42);
+ new Class.field(42);
+ new Class.two_fields(42
+
+ );
+ }
diff --git a/tests/language_2/constructor_duplicate_initializers_test.dart b/tests/language_2/constructor_duplicate_initializers_test.dart
index d5c99d5..86532ce 100644
--- a/tests/language_2/constructor_duplicate_initializers_test.dart
+++ b/tests/language_2/constructor_duplicate_initializers_test.dart
@@ -6,16 +6,30 @@
class Class {
Class(var v) : field_ = v
// Test against duplicate final field initialization in initializing list.
- , field_ = 2 // //# 01: compile-time error
+ , field_ = 2
+ //^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS
+ // ^
+ // [cfe] 'field_' is a final instance variable that has already been initialized.
;
Class.field(this.field_)
// Test against duplicate final field initialization between initializing
// formals and initializer list.
- : field_ = 2 // //# 02: compile-time error
+ : field_ = 2
+ //^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER
+ // ^
+ // [cfe] 'field_' is a final instance variable that has already been initialized.
;
// Test against duplicate final field initialization in initializing formals.
Class.two_fields(this.field_
- , this.field_ //# 03: compile-time error
+ , this.field_
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+ // [cfe] 'field_' is a final instance variable that has already been initialized.
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FINAL_INITIALIZED_MULTIPLE_TIMES
+ // [cfe] Duplicated parameter name 'field_'.
);
final field_;
}
@@ -24,6 +38,6 @@
new Class(42);
new Class.field(42);
new Class.two_fields(42
- , 42 // //# 03: continued
+ , 42
);
}
diff --git a/tests/language_2/constructor_redirect2_runtime_test.dart b/tests/language_2/constructor_redirect2_runtime_test.dart
new file mode 100644
index 0000000..f5216f6
--- /dev/null
+++ b/tests/language_2/constructor_redirect2_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Redirection constructors must not have a function body.
+
+class A {
+ var x;
+ A(this.x) {}
+
+ // Redirecting constructor must not have a function body.
+
+
+ // Redirecting constructor must not initialize any fields.
+
+
+ // Redirecting constructor must not have initializing formal parameters.
+
+
+ // Redirection constructors must not call super constructor.
+
+}
+
+main() {
+ new A(3);
+
+
+
+
+}
diff --git a/tests/language_2/constructor_redirect2_test.dart b/tests/language_2/constructor_redirect2_test.dart
index adfb25f..0999747 100644
--- a/tests/language_2/constructor_redirect2_test.dart
+++ b/tests/language_2/constructor_redirect2_test.dart
@@ -8,22 +8,39 @@
A(this.x) {}
// Redirecting constructor must not have a function body.
- A.illegalBody(x) : this(3) {} // //# 01: syntax error
+ A.illegalBody(x) : this(3) {}
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.REDIRECTING_CONSTRUCTOR_WITH_BODY
+ // [cfe] Redirecting constructors can't have a body.
// Redirecting constructor must not initialize any fields.
- A.illegalInit() : this(3), x = 5; // //# 02: syntax error
+ A.illegalInit() : this(3), x = 5;
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
+ // ^
+ // [cfe] Can't have other initializers together with 'this'.
// Redirecting constructor must not have initializing formal parameters.
- A.illegalFormal(this.x) : this(3); // //# 03: compile-time error
+ A.illegalFormal(this.x) : this(3);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
+ // ^
+ // [cfe] Can't have other initializers together with 'this'.
// Redirection constructors must not call super constructor.
- A.illegalSuper() : this(3), super(3); // //# 04: syntax error
+ A.illegalSuper() : this(3), super(3);
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.SUPER_IN_REDIRECTING_CONSTRUCTOR
+ // [cfe] Can't have other initializers together with 'this'.
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 0 allowed, but 1 found.
}
main() {
new A(3);
- new A.illegalBody(10); // //# 01: continued
- new A.illegalInit(); // //# 02: continued
- new A.illegalFormal(10); // //# 03: continued
- new A.illegalSuper(); // //# 04: continued
+ new A.illegalBody(10);
+ new A.illegalInit();
+ new A.illegalFormal(10);
+ new A.illegalSuper();
}
diff --git a/tests/language_2/constructor_redirect_cycle_runtime_test.dart b/tests/language_2/constructor_redirect_cycle_runtime_test.dart
new file mode 100644
index 0000000..4a05857
--- /dev/null
+++ b/tests/language_2/constructor_redirect_cycle_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Redirection constructors must not be cyclic.
+
+class A {
+ var x;
+ A(x)
+
+ ;
+}
+
+main() {
+ new A(10);
+}
diff --git a/tests/language_2/constructor_redirect_cycle_test.dart b/tests/language_2/constructor_redirect_cycle_test.dart
index a8e6353..6730e06 100644
--- a/tests/language_2/constructor_redirect_cycle_test.dart
+++ b/tests/language_2/constructor_redirect_cycle_test.dart
@@ -6,7 +6,10 @@
class A {
var x;
A(x)
- : this(0) //# 01: compile-time error
+ : this(0)
+ //^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_CONSTRUCTOR_REDIRECT
+ // [cfe] Redirecting constructors can't be cyclic.
;
}
diff --git a/tests/language_2/constructor_redirect_indirect_cycle_runtime_test.dart b/tests/language_2/constructor_redirect_indirect_cycle_runtime_test.dart
new file mode 100644
index 0000000..94159a5
--- /dev/null
+++ b/tests/language_2/constructor_redirect_indirect_cycle_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+class A {
+ var x;
+ A(x) : this.named(x, 0);
+ A.named(x, int y)
+ // Redirecting constructors must not be cyclic.
+
+ ;
+}
+
+main() {
+ new A(10);
+}
diff --git a/tests/language_2/constructor_redirect_indirect_cycle_test.dart b/tests/language_2/constructor_redirect_indirect_cycle_test.dart
index 50c6d64..aa2bb69 100644
--- a/tests/language_2/constructor_redirect_indirect_cycle_test.dart
+++ b/tests/language_2/constructor_redirect_indirect_cycle_test.dart
@@ -5,9 +5,14 @@
class A {
var x;
A(x) : this.named(x, 0);
+ // ^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_CONSTRUCTOR_REDIRECT
A.named(x, int y)
// Redirecting constructors must not be cyclic.
- : this(x + y) //# 01: compile-time error
+ : this(x + y)
+ //^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_CONSTRUCTOR_REDIRECT
+ // [cfe] Redirecting constructors can't be cyclic.
;
}
diff --git a/tests/language_2/constructor_redirect_runtime_test.dart b/tests/language_2/constructor_redirect_runtime_test.dart
new file mode 100644
index 0000000..f6084b8
--- /dev/null
+++ b/tests/language_2/constructor_redirect_runtime_test.dart
@@ -0,0 +1,75 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Dart test program for redirection constructors.
+
+import "package:expect/expect.dart";
+
+class A {
+ var x;
+ A(this.x) {}
+ A.named(x, int y) : this(x + y);
+ A.named2(int x, int y, z) : this.named(staticFun(x, y), z);
+
+ // The following is a bit tricky. It is a compile-time error to
+ // refer to this (implicitly or explicitly) from an initializer.
+ // When we remove the line with moreStaticFun, staticFun is really a
+ // static function and it is legal to call it. This is what will
+ // happen in the /none version of this test. However, in /01,
+ // staticFun isn't really a static function and should cause a
+ // compile-time error.
+ static
+
+ int staticFun(int v1, int v2) {
+ return v1 * v2;
+ }
+}
+
+class B extends A {
+ B(y) : super(y + 1) {}
+ B.named(y) : super.named(y, y + 1) {}
+}
+
+class C {
+ final x;
+ const C(this.x);
+ const C.named(x, int y) : this(x + y);
+}
+
+class D extends C {
+ const D(y) : super(y + 1);
+ const D.named(y) : super.named(y, y + 1);
+}
+
+class ConstructorRedirectTest {
+ static testMain() {
+ var a = new A(499);
+ Expect.equals(499, a.x);
+ a = new A.named(349, 499);
+ Expect.equals(349 + 499, a.x);
+ a = new A.named2(11, 42, 99);
+ Expect.equals(11 * 42 + 99, a.x);
+
+ var b = new B(498);
+ Expect.equals(499, b.x);
+ b = new B.named(249);
+ Expect.equals(499, b.x);
+
+ C c = const C(499);
+ Expect.equals(499, c.x);
+ c = const C.named(249, 250);
+ Expect.equals(499, c.x);
+
+ D d = const D(498);
+ Expect.equals(499, d.x);
+ d = const D.named(249);
+ Expect.equals(499, d.x);
+ }
+}
+
+main() {
+ ConstructorRedirectTest.testMain();
+}
diff --git a/tests/language_2/constructor_redirect_test.dart b/tests/language_2/constructor_redirect_test.dart
index 64616c9..0f1ee3a 100644
--- a/tests/language_2/constructor_redirect_test.dart
+++ b/tests/language_2/constructor_redirect_test.dart
@@ -10,6 +10,9 @@
A(this.x) {}
A.named(x, int y) : this(x + y);
A.named2(int x, int y, z) : this.named(staticFun(x, y), z);
+ // ^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER
+ // [cfe] Can't access 'this' in a field initializer to read 'staticFun'.
// The following is a bit tricky. It is a compile-time error to
// refer to this (implicitly or explicitly) from an initializer.
@@ -19,7 +22,7 @@
// staticFun isn't really a static function and should cause a
// compile-time error.
static
- moreStaticFun() {} //# 01: compile-time error
+ moreStaticFun() {}
int staticFun(int v1, int v2) {
return v1 * v2;
}
diff --git a/tests/language_2/constructor_reference_runtime_10_test.dart b/tests/language_2/constructor_reference_runtime_10_test.dart
new file mode 100644
index 0000000..b96d8f9
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_10_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Foo.bar();
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_11_test.dart b/tests/language_2/constructor_reference_runtime_11_test.dart
new file mode 100644
index 0000000..cea554d
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_11_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Foo<int>();
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_12_test.dart b/tests/language_2/constructor_reference_runtime_12_test.dart
new file mode 100644
index 0000000..5b58eae
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_12_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Foo<int>.bar();
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_1_test.dart b/tests/language_2/constructor_reference_runtime_1_test.dart
new file mode 100644
index 0000000..450bc7f
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_1_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+ new Foo();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_2_test.dart b/tests/language_2/constructor_reference_runtime_2_test.dart
new file mode 100644
index 0000000..cab730f
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_2_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+ new Foo.bar();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_3_test.dart b/tests/language_2/constructor_reference_runtime_3_test.dart
new file mode 100644
index 0000000..20ac3d2
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_3_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+ new Foo<int>();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_4_test.dart b/tests/language_2/constructor_reference_runtime_4_test.dart
new file mode 100644
index 0000000..e69fe77
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_4_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+ new Foo<int>.bar();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_5_test.dart b/tests/language_2/constructor_reference_runtime_5_test.dart
new file mode 100644
index 0000000..4dda061
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_5_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+ const Foo();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_6_test.dart b/tests/language_2/constructor_reference_runtime_6_test.dart
new file mode 100644
index 0000000..75859e0
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_6_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+ const Foo.bar();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_7_test.dart b/tests/language_2/constructor_reference_runtime_7_test.dart
new file mode 100644
index 0000000..b18721e
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_7_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+ const Foo<int>();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_8_test.dart b/tests/language_2/constructor_reference_runtime_8_test.dart
new file mode 100644
index 0000000..1493e34
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_8_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ const Foo<int>.bar();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_9_test.dart b/tests/language_2/constructor_reference_runtime_9_test.dart
new file mode 100644
index 0000000..cad70b0
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_9_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Foo();
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_runtime_test.dart b/tests/language_2/constructor_reference_runtime_test.dart
new file mode 100644
index 0000000..12b5314
--- /dev/null
+++ b/tests/language_2/constructor_reference_runtime_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/constructor_reference_test.dart b/tests/language_2/constructor_reference_test.dart
index 173320c..52e1235 100644
--- a/tests/language_2/constructor_reference_test.dart
+++ b/tests/language_2/constructor_reference_test.dart
@@ -9,33 +9,109 @@
}
main() {
- new Foo(); //# 01: ok
- new Foo.bar(); //# 02: ok
- new Foo.bar.baz(); //# 03: compile-time error
- new Foo<int>(); //# 04: ok
- new Foo<int>.bar(); //# 05: ok
- new Foo<int>.bar.baz(); //# 06: syntax error
- new Foo.bar<int>(); //# 07: compile-time error
- new Foo.bar<int>.baz(); //# 08: compile-time error
- new Foo.bar.baz<int>(); //# 09: syntax error
+ new Foo();
+ new Foo.bar();
+ new Foo.bar.baz();
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+ new Foo<int>();
+ new Foo<int>.bar();
+ new Foo<int>.bar.baz();
+ // ^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'baz' isn't defined for the class 'Foo<int>'.
+ new Foo.bar<int>();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ new Foo.bar<int>.baz();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+ new Foo.bar.baz<int>();
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
- const Foo(); //# 11: ok
- const Foo.bar(); //# 12: ok
- const Foo.bar.baz(); //# 13: compile-time error
- const Foo<int>(); //# 14: ok
- const Foo<int>.bar(); //# 15: ok
- const Foo<int>.bar.baz(); //# 16: syntax error
- const Foo.bar<int>(); //# 17: compile-time error
- const Foo.bar<int>.baz(); //# 18: compile-time error
- const Foo.bar.baz<int>(); //# 19: syntax error
+ const Foo();
+ const Foo.bar();
+ const Foo.bar.baz();
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+ const Foo<int>();
+ const Foo<int>.bar();
+ const Foo<int>.bar.baz();
+ // ^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'baz' isn't defined for the class 'Foo<int>'.
+ const Foo.bar<int>();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ const Foo.bar<int>.baz();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+ const Foo.bar.baz<int>();
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
- Foo(); //# 21: ok
- Foo.bar(); //# 22: ok
- Foo.bar.baz(); //# 23: compile-time error
- Foo<int>(); //# 24: ok
- Foo<int>.bar(); //# 25: ok
- Foo<int>.bar.baz(); //# 26: syntax error
- Foo.bar<int>(); //# 27: compile-time error
- Foo.bar<int>.baz(); //# 28: compile-time error
- Foo.bar.baz<int>(); //# 29: compile-time error
+ Foo();
+ Foo.bar();
+ Foo.bar.baz();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] Getter not found: 'bar'.
+ Foo<int>();
+ Foo<int>.bar();
+ Foo<int>.bar.baz();
+ // ^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'baz' isn't defined for the class 'Foo<int>'.
+ Foo.bar<int>();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ Foo.bar<int>.baz();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+ Foo.bar.baz<int>();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] Getter not found: 'bar'.
}
diff --git a/tests/language_2/constructor_return_runtime_test.dart b/tests/language_2/constructor_return_runtime_test.dart
new file mode 100644
index 0000000..5b83303
--- /dev/null
+++ b/tests/language_2/constructor_return_runtime_test.dart
@@ -0,0 +1,47 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+// Dart spec 0.03, section 11.10 - generative constructors can only have return
+// statements in the form 'return;'.
+class A {
+ int x;
+ A(this.x) {
+ return;
+ }
+ A.test1(this.x) {
+
+ }
+ A.test2(this.x) {
+
+ }
+ int foo(int y) => x + y;
+}
+
+class B {
+
+}
+
+class C {
+ int value;
+
+}
+
+class D {
+ int value;
+
+}
+
+main() {
+ Expect.equals((new A(1)).foo(10), 11);
+ Expect.equals((new A.test1(1)).foo(10), 11);
+ Expect.equals((new A.test2(1)).foo(10), 11);
+ new B();
+ new C();
+ new D();
+}
diff --git a/tests/language_2/constructor_return_test.dart b/tests/language_2/constructor_return_test.dart
index 2f03e58..d82dd04 100644
--- a/tests/language_2/constructor_return_test.dart
+++ b/tests/language_2/constructor_return_test.dart
@@ -12,26 +12,46 @@
return;
}
A.test1(this.x) {
- return this; // //# 01: compile-time error
+ return this;
+// ^
+// [cfe] Constructors can't have a return type.
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATIVE_CONSTRUCTOR
}
A.test2(this.x) {
- return null; // //# 02: compile-time error
+ return null;
+// ^
+// [cfe] Constructors can't have a return type.
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATIVE_CONSTRUCTOR
}
int foo(int y) => x + y;
}
class B {
- B() => null; // //# 03: compile-time error
+ B() => null;
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATIVE_CONSTRUCTOR
+ // ^
+ // [cfe] Constructors can't have a return type.
}
class C {
int value;
- C() : value = 1 { return null; } // //# 04: compile-time error
+ C() : value = 1 { return null; }
+ // ^
+ // [cfe] Constructors can't have a return type.
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATIVE_CONSTRUCTOR
}
class D {
int value;
- D(): value = 1 => null; // //# 05: compile-time error
+ D(): value = 1 => null;
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATIVE_CONSTRUCTOR
+ // ^
+ // [cfe] Constructors can't have a return type.
}
main() {
diff --git a/tests/language_2/constructor_type_parameter_runtime_test.dart b/tests/language_2/constructor_type_parameter_runtime_test.dart
new file mode 100644
index 0000000..6cb2a75
--- /dev/null
+++ b/tests/language_2/constructor_type_parameter_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Foo {
+
+}
+
+main() {
+ new Foo();
+}
diff --git a/tests/language_2/constructor_type_parameter_test.dart b/tests/language_2/constructor_type_parameter_test.dart
index d038361..3712c26 100644
--- a/tests/language_2/constructor_type_parameter_test.dart
+++ b/tests/language_2/constructor_type_parameter_test.dart
@@ -3,7 +3,10 @@
// BSD-style license that can be found in the LICENSE file.
class Foo {
- Foo<A>() {} // //# 00: compile-time error
+ Foo<A>() {}
+ // ^^^
+ // [analyzer] SYNTACTIC_ERROR.TYPE_PARAMETER_ON_CONSTRUCTOR
+ // [cfe] Constructors can't have type parameters.
}
main() {
diff --git a/tests/language_2/crash_6725_runtime_test.dart b/tests/language_2/crash_6725_runtime_test.dart
new file mode 100644
index 0000000..6b07ac0
--- /dev/null
+++ b/tests/language_2/crash_6725_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Regression test for a crash in dart2js.
+
+library crash_6725;
+
+
+
+main() {
+
+}
diff --git a/tests/language_2/create_unresolved_type_runtime_test.dart b/tests/language_2/create_unresolved_type_runtime_test.dart
new file mode 100644
index 0000000..13d07d8
--- /dev/null
+++ b/tests/language_2/create_unresolved_type_runtime_test.dart
@@ -0,0 +1,10 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+main() {
+
+}
diff --git a/tests/language_2/create_unresolved_type_test.dart b/tests/language_2/create_unresolved_type_test.dart
index cc422a9..296859c 100644
--- a/tests/language_2/create_unresolved_type_test.dart
+++ b/tests/language_2/create_unresolved_type_test.dart
@@ -3,5 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
main() {
- new F<int>(); //# 01: compile-time error
+ new F<int>();
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // [cfe] Method not found: 'F'.
}
diff --git a/tests/language_2/cyclic_class_member_runtime_test.dart b/tests/language_2/cyclic_class_member_runtime_test.dart
new file mode 100644
index 0000000..17cea8d
--- /dev/null
+++ b/tests/language_2/cyclic_class_member_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test that class with a cyclic hierarchy doesn't cause a loop in dart2js.
+
+class A
+
+{
+ // When checking that foo isn't overriding an instance method in the
+ // superclass, dart2js might loop.
+ static foo() {}
+}
+
+main() {
+ new A();
+}
diff --git a/tests/language_2/cyclic_class_member_test.dart b/tests/language_2/cyclic_class_member_test.dart
index d33d896..516943f 100644
--- a/tests/language_2/cyclic_class_member_test.dart
+++ b/tests/language_2/cyclic_class_member_test.dart
@@ -5,7 +5,10 @@
// Test that class with a cyclic hierarchy doesn't cause a loop in dart2js.
class A
- extends A //# 01: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE_EXTENDS
+// [cfe] 'A' is a supertype of itself.
+ extends A
{
// When checking that foo isn't overriding an instance method in the
// superclass, dart2js might loop.
diff --git a/tests/language_2/cyclic_constructor_runtime_test.dart b/tests/language_2/cyclic_constructor_runtime_test.dart
new file mode 100644
index 0000000..b0cf8aff
--- /dev/null
+++ b/tests/language_2/cyclic_constructor_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+class A {
+ A.a() : this.b();
+ A.b()
+
+ ;
+ A.c() : this.b();
+}
+
+main() {
+ new A.a();
+ new A.b();
+ new A.c();
+}
diff --git a/tests/language_2/cyclic_constructor_test.dart b/tests/language_2/cyclic_constructor_test.dart
index 5a83edd..1b2533f 100644
--- a/tests/language_2/cyclic_constructor_test.dart
+++ b/tests/language_2/cyclic_constructor_test.dart
@@ -4,8 +4,14 @@
class A {
A.a() : this.b();
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_CONSTRUCTOR_REDIRECT
A.b()
- : this.a() // //# 01: compile-time error
+ : this.a()
+ //^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_CONSTRUCTOR_REDIRECT
+ // ^
+ // [cfe] Redirecting constructors can't be cyclic.
;
A.c() : this.b();
}
diff --git a/tests/language_2/default_factory2_runtime_test.dart b/tests/language_2/default_factory2_runtime_test.dart
new file mode 100644
index 0000000..63399e3
--- /dev/null
+++ b/tests/language_2/default_factory2_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// Check type bounds when invoking a redirecting factory method
+
+abstract class Foo {}
+
+abstract class IA<T> {
+
+}
+
+class A<T extends Foo> implements IA<T> {
+ factory A() {}
+}
+
+main() {
+
+}
diff --git a/tests/language_2/default_factory2_test.dart b/tests/language_2/default_factory2_test.dart
index a493285..49f11ce 100644
--- a/tests/language_2/default_factory2_test.dart
+++ b/tests/language_2/default_factory2_test.dart
@@ -7,7 +7,11 @@
abstract class Foo {}
abstract class IA<T> {
- factory IA() = A<T>; //# 01: compile-time error
+ factory IA() = A<T>;
+ // ^
+ // [cfe] The type 'T' doesn't extend 'Foo'.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
class A<T extends Foo> implements IA<T> {
@@ -15,5 +19,7 @@
}
main() {
- var result = new IA<String>(); //# 01: continued
+ var result = new IA<String>();
+ // ^
+ // [cfe] Type argument 'String' doesn't conform to the bound 'Foo' of the type variable 'T' on 'A'.
}
diff --git a/tests/language_2/default_factory_runtime_test.dart b/tests/language_2/default_factory_runtime_test.dart
new file mode 100644
index 0000000..a12c7e5
--- /dev/null
+++ b/tests/language_2/default_factory_runtime_test.dart
@@ -0,0 +1,38 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Dart test program for testing default factories.
+
+abstract class Vehicle {
+
+}
+
+class Bike implements Vehicle, GoogleOne {
+ Bike.redOne() {}
+}
+
+abstract class SpaceShip {
+ factory SpaceShip() = GoogleOne;
+}
+
+class GoogleOne implements SpaceShip {
+ GoogleOne.internal_() {}
+ factory GoogleOne() {
+ return new GoogleOne.internal_();
+ }
+ factory GoogleOne.Vehicle() {
+ return new Bike.redOne();
+ }
+}
+
+main() {
+ Expect.equals(true, (new Bike.redOne()) is Bike);
+ Expect.equals(true, (new SpaceShip()) is GoogleOne);
+
+}
diff --git a/tests/language_2/default_factory_test.dart b/tests/language_2/default_factory_test.dart
index 663e8f4..43a93e8 100644
--- a/tests/language_2/default_factory_test.dart
+++ b/tests/language_2/default_factory_test.dart
@@ -7,7 +7,10 @@
// Dart test program for testing default factories.
abstract class Vehicle {
- factory Vehicle() = GoogleOne.Vehicle; //# 01: compile-time error
+ factory Vehicle() = GoogleOne.Vehicle;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.REDIRECT_TO_INVALID_RETURN_TYPE
+ // [cfe] The constructor function type 'GoogleOne Function()' isn't a subtype of 'Vehicle Function()'.
}
class Bike implements Vehicle, GoogleOne {
@@ -31,5 +34,5 @@
main() {
Expect.equals(true, (new Bike.redOne()) is Bike);
Expect.equals(true, (new SpaceShip()) is GoogleOne);
- var ensureItsCalled = new Vehicle(); //# 01: continued
+ var ensureItsCalled = new Vehicle();
}
diff --git a/tests/language_2/deferred_duplicate_prefix1_runtime_test.dart b/tests/language_2/deferred_duplicate_prefix1_runtime_test.dart
new file mode 100644
index 0000000..5466486
--- /dev/null
+++ b/tests/language_2/deferred_duplicate_prefix1_runtime_test.dart
@@ -0,0 +1,11 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "deferred_prefix_constraints_lib2.dart" as lib;
+
+
+void main() {}
diff --git a/tests/language_2/deferred_duplicate_prefix1_test.dart b/tests/language_2/deferred_duplicate_prefix1_test.dart
index 1807e92..b208717 100644
--- a/tests/language_2/deferred_duplicate_prefix1_test.dart
+++ b/tests/language_2/deferred_duplicate_prefix1_test.dart
@@ -3,6 +3,10 @@
// BSD-style license that can be found in the LICENSE file.
import "deferred_prefix_constraints_lib2.dart" as lib;
-import "deferred_prefix_constraints_lib.dart" deferred as lib; //# 01: compile-time error
+import "deferred_prefix_constraints_lib.dart" deferred as lib;
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.SHARED_DEFERRED_PREFIX
+// ^
+// [cfe] Can't use the name 'lib' for a deferred library, as the name is used elsewhere.
void main() {}
diff --git a/tests/language_2/deferred_duplicate_prefix2_runtime_test.dart b/tests/language_2/deferred_duplicate_prefix2_runtime_test.dart
new file mode 100644
index 0000000..8717c6e
--- /dev/null
+++ b/tests/language_2/deferred_duplicate_prefix2_runtime_test.dart
@@ -0,0 +1,11 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+
+import "deferred_prefix_constraints_lib2.dart" as lib;
+
+void main() {}
diff --git a/tests/language_2/deferred_duplicate_prefix2_test.dart b/tests/language_2/deferred_duplicate_prefix2_test.dart
index 1edfeca..2c505ca 100644
--- a/tests/language_2/deferred_duplicate_prefix2_test.dart
+++ b/tests/language_2/deferred_duplicate_prefix2_test.dart
@@ -2,7 +2,11 @@
// 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.
-import "deferred_prefix_constraints_lib.dart" deferred as lib; // //# 01: compile-time error
+import "deferred_prefix_constraints_lib.dart" deferred as lib;
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.SHARED_DEFERRED_PREFIX
+// ^
+// [cfe] Can't use the name 'lib' for a deferred library, as the name is used elsewhere.
import "deferred_prefix_constraints_lib2.dart" as lib;
void main() {}
diff --git a/tests/language_2/deferred_duplicate_prefix3_runtime_test.dart b/tests/language_2/deferred_duplicate_prefix3_runtime_test.dart
new file mode 100644
index 0000000..3f409b6
--- /dev/null
+++ b/tests/language_2/deferred_duplicate_prefix3_runtime_test.dart
@@ -0,0 +1,11 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+
+
+
+void main() {}
diff --git a/tests/language_2/deferred_duplicate_prefix3_test.dart b/tests/language_2/deferred_duplicate_prefix3_test.dart
index 08d8bd1..3b3b3e8 100644
--- a/tests/language_2/deferred_duplicate_prefix3_test.dart
+++ b/tests/language_2/deferred_duplicate_prefix3_test.dart
@@ -2,7 +2,13 @@
// 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.
-import "deferred_prefix_constraints_lib.dart" deferred as lib; //# 01: compile-time error
-import "deferred_prefix_constraints_lib2.dart" deferred as lib; //# 01: continued
+import "deferred_prefix_constraints_lib.dart" deferred as lib;
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.SHARED_DEFERRED_PREFIX
+import "deferred_prefix_constraints_lib2.dart" deferred as lib;
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.SHARED_DEFERRED_PREFIX
+// ^
+// [cfe] Can't use the name 'lib' for a deferred library, as the name is used elsewhere.
void main() {}
diff --git a/tests/language_2/deferred_inheritance_constraints_runtime_test.dart b/tests/language_2/deferred_inheritance_constraints_runtime_test.dart
new file mode 100644
index 0000000..2be0495
--- /dev/null
+++ b/tests/language_2/deferred_inheritance_constraints_runtime_test.dart
@@ -0,0 +1,43 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+import "deferred_inheritance_constraints_lib.dart" deferred as lib;
+
+class Foo {}
+
+class Foo2 extends D {}
+
+class A extends
+
+ Foo {}
+
+class B
+ implements
+
+ Foo {}
+
+class C1 {}
+
+class C = C1
+ with
+
+ Foo;
+
+class D {
+ D();
+ factory D.factory() =
+
+ Foo2;
+}
+
+void main() {
+ new A();
+ new B();
+ new C();
+ new D.factory();
+}
diff --git a/tests/language_2/deferred_inheritance_constraints_test.dart b/tests/language_2/deferred_inheritance_constraints_test.dart
index 01c8db4..392335e 100644
--- a/tests/language_2/deferred_inheritance_constraints_test.dart
+++ b/tests/language_2/deferred_inheritance_constraints_test.dart
@@ -9,27 +9,26 @@
class Foo2 extends D {}
-class A extends
- lib. //# extends: compile-time error
- Foo {}
+class A extends lib.Foo {}
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.EXTENDS_DEFERRED_CLASS
-class B
- implements
- lib. //# implements: compile-time error
- Foo {}
+class B implements lib.Foo {}
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_DEFERRED_CLASS
class C1 {}
-class C = C1
- with
- lib. //# mixin: compile-time error
- Foo;
+class C = C1 with lib.Foo;
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_DEFERRED_CLASS
class D {
D();
- factory D.factory() =
- lib. //# redirecting_constructor: compile-time error
- Foo2;
+ factory D.factory() = lib.Foo2;
+// ^^^^^^^^
+// [analyzer] STATIC_WARNING.REDIRECT_TO_INVALID_RETURN_TYPE
+// [cfe] The constructor function type 'Foo2 Function()' isn't a subtype of 'D Function()'.
}
void main() {
diff --git a/tests/language_2/deferred_load_constants_runtime_test.dart b/tests/language_2/deferred_load_constants_runtime_test.dart
new file mode 100644
index 0000000..d4a1b18
--- /dev/null
+++ b/tests/language_2/deferred_load_constants_runtime_test.dart
@@ -0,0 +1,38 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+// Dart version of two-argument Ackermann-Peter function.
+
+library deferred_load_constants;
+
+import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
+import "deferred_load_constants.dart" deferred as foo;
+import "deferred_load_constants.dart";
+
+main() {
+ asyncStart();
+ Expect.throws(() => foo.c);
+ Expect.throws(() => foo.C);
+ Expect.throws(() => foo.funtype);
+ Expect.throws(() => foo.toplevel);
+ foo.loadLibrary().whenComplete(() {
+ // Reading constant declarations through deferred prefix works.
+ Expect.identical(c, foo.c);
+ Expect.identical(C, foo.C);
+ Expect.identical(funtype, foo.funtype);
+ Expect.identical(toplevel, foo.toplevel);
+ Expect.identical(C.staticfun, foo.C.staticfun);
+ // Access through deferred prefix is not a constant expression.
+
+
+
+
+
+
+ asyncEnd();
+ });
+}
diff --git a/tests/language_2/deferred_load_constants_test.dart b/tests/language_2/deferred_load_constants_test.dart
index f56414c..7728c7e 100644
--- a/tests/language_2/deferred_load_constants_test.dart
+++ b/tests/language_2/deferred_load_constants_test.dart
@@ -24,11 +24,36 @@
Expect.identical(toplevel, foo.toplevel);
Expect.identical(C.staticfun, foo.C.staticfun);
// Access through deferred prefix is not a constant expression.
- Expect.throws(() => const [foo.c]); // //# 01: compile-time error
- Expect.throws(() => const [foo.C]); // //# 02: compile-time error
- Expect.throws(() => const [foo.funtype]); // //# 03: compile-time error
- Expect.throws(() => const [foo.toplevel]); // //# 04: compile-time error
- Expect.throws(() => const [foo.C.staticfun]); // //# 05: compile-time error
+ Expect.throws(() => const [foo.c]);
+ // ^
+ // [cfe] Constant evaluation error:
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY
+ // [cfe] 'foo' can't be used in a constant expression because it's marked as 'deferred' which means it isn't available until loaded.
+ Expect.throws(() => const [foo.C]);
+ // ^
+ // [cfe] Constant evaluation error:
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY
+ // [cfe] 'foo' can't be used in a constant expression because it's marked as 'deferred' which means it isn't available until loaded.
+ Expect.throws(() => const [foo.funtype]);
+ // ^
+ // [cfe] Constant evaluation error:
+ // ^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY
+ // [cfe] 'foo' can't be used in a constant expression because it's marked as 'deferred' which means it isn't available until loaded.
+ Expect.throws(() => const [foo.toplevel]);
+ // ^
+ // [cfe] Constant evaluation error:
+ // ^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY
+ // [cfe] 'foo' can't be used in a constant expression because it's marked as 'deferred' which means it isn't available until loaded.
+ Expect.throws(() => const [foo.C.staticfun]);
+ // ^
+ // [cfe] Constant evaluation error:
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY
+ // [cfe] 'foo' can't be used in a constant expression because it's marked as 'deferred' which means it isn't available until loaded.
asyncEnd();
});
diff --git a/tests/language_2/deferred_no_prefix_runtime_test.dart b/tests/language_2/deferred_no_prefix_runtime_test.dart
new file mode 100644
index 0000000..c53588e
--- /dev/null
+++ b/tests/language_2/deferred_no_prefix_runtime_test.dart
@@ -0,0 +1,13 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// Loading a deferred library without prefix is not allowed.
+import "deferred_constraints_lib2.dart"
+
+ ;
+
+void main() {}
diff --git a/tests/language_2/deferred_no_prefix_test.dart b/tests/language_2/deferred_no_prefix_test.dart
index b54356c..2af5e86 100644
--- a/tests/language_2/deferred_no_prefix_test.dart
+++ b/tests/language_2/deferred_no_prefix_test.dart
@@ -4,7 +4,10 @@
// Loading a deferred library without prefix is not allowed.
import "deferred_constraints_lib2.dart"
- deferred //# 01: syntax error
+ deferred
+//^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_PREFIX_IN_DEFERRED_IMPORT
+// [cfe] Deferred imports should have a prefix.
;
void main() {}
diff --git a/tests/language_2/deferred_super_dependency_runtime_test.dart b/tests/language_2/deferred_super_dependency_runtime_test.dart
new file mode 100644
index 0000000..c09a7f8
--- /dev/null
+++ b/tests/language_2/deferred_super_dependency_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Regression test.
+// lib.C.foo has code that references `super.foo=` that does not exist. This
+// used to cause a crash.
+
+import "package:expect/expect.dart";
+
+
+main() async {
+
+
+}
diff --git a/tests/language_2/deferred_super_dependency_test.dart b/tests/language_2/deferred_super_dependency_test.dart
index 6c19389..75527cbe 100644
--- a/tests/language_2/deferred_super_dependency_test.dart
+++ b/tests/language_2/deferred_super_dependency_test.dart
@@ -7,9 +7,12 @@
// used to cause a crash.
import "package:expect/expect.dart";
-import "deferred_super_dependency_lib.dart" deferred as lib; //# 01: compile-time error
+// ^^^
+// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SUPER_SETTER
+// [cfe] Superclass has no setter named 'foo'.
+import "deferred_super_dependency_lib.dart" deferred as lib;
main() async {
- await lib.loadLibrary(); //# 01: continued
- Expect.throwsNoSuchMethodError(() => new lib.C().foo()); //# 01: continued
+ await lib.loadLibrary();
+ Expect.throwsNoSuchMethodError(() => new lib.C().foo());
}
diff --git a/tests/language_2/double_invalid_runtime_test.dart b/tests/language_2/double_invalid_runtime_test.dart
new file mode 100644
index 0000000..a47bfc7
--- /dev/null
+++ b/tests/language_2/double_invalid_runtime_test.dart
@@ -0,0 +1,13 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// Test an invalid double format
+
+main() {
+
+ ;
+}
diff --git a/tests/language_2/double_invalid_test.dart b/tests/language_2/double_invalid_test.dart
index 469de2e..dcfe3f4 100644
--- a/tests/language_2/double_invalid_test.dart
+++ b/tests/language_2/double_invalid_test.dart
@@ -5,7 +5,10 @@
// Test an invalid double format
main() {
- 3457e //# 01: compile-time error
+ 3457e
+//^
+// [cfe] Numbers in exponential notation should always contain an exponent (an integer number with an optional sign).
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_DIGIT
;
}
-
diff --git a/tests/language_2/double_to_string_as_exponential2_runtime_test.dart b/tests/language_2/double_to_string_as_exponential2_runtime_test.dart
new file mode 100644
index 0000000..1c0a498
--- /dev/null
+++ b/tests/language_2/double_to_string_as_exponential2_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+ var v = 1.0;
+ Expect.throwsRangeError(() => v.toStringAsExponential(-1));
+ Expect.throwsRangeError(() => v.toStringAsExponential(21));
+
+
+
+}
diff --git a/tests/language_2/double_to_string_as_exponential2_test.dart b/tests/language_2/double_to_string_as_exponential2_test.dart
index d5618bc..13e461b 100644
--- a/tests/language_2/double_to_string_as_exponential2_test.dart
+++ b/tests/language_2/double_to_string_as_exponential2_test.dart
@@ -9,7 +9,16 @@
var v = 1.0;
Expect.throwsRangeError(() => v.toStringAsExponential(-1));
Expect.throwsRangeError(() => v.toStringAsExponential(21));
- v.toStringAsExponential(1.5); //# 01: compile-time error
- v.toStringAsExponential("string"); //# 02: compile-time error
- v.toStringAsExponential("3"); //# 03: compile-time error
+ v.toStringAsExponential(1.5);
+ // ^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'double' can't be assigned to the parameter type 'int'.
+ v.toStringAsExponential("string");
+ // ^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
+ v.toStringAsExponential("3");
+ // ^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
}
diff --git a/tests/language_2/double_to_string_as_fixed2_runtime_test.dart b/tests/language_2/double_to_string_as_fixed2_runtime_test.dart
new file mode 100644
index 0000000..e711f2d
--- /dev/null
+++ b/tests/language_2/double_to_string_as_fixed2_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+ var v = 0.0;
+ Expect.throwsRangeError(() => v.toStringAsFixed(-1));
+ Expect.throwsRangeError(() => v.toStringAsFixed(21));
+ Expect.throwsArgumentError(() => v.toStringAsFixed(null));
+
+
+
+}
diff --git a/tests/language_2/double_to_string_as_fixed2_test.dart b/tests/language_2/double_to_string_as_fixed2_test.dart
index 6f43596..bc76e63 100644
--- a/tests/language_2/double_to_string_as_fixed2_test.dart
+++ b/tests/language_2/double_to_string_as_fixed2_test.dart
@@ -10,7 +10,16 @@
Expect.throwsRangeError(() => v.toStringAsFixed(-1));
Expect.throwsRangeError(() => v.toStringAsFixed(21));
Expect.throwsArgumentError(() => v.toStringAsFixed(null));
- v.toStringAsFixed(1.5);//# 01: compile-time error
- v.toStringAsFixed("string");//# 02: compile-time error
- v.toStringAsFixed("3");//# 03: compile-time error
+ v.toStringAsFixed(1.5);
+ // ^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'double' can't be assigned to the parameter type 'int'.
+ v.toStringAsFixed("string");
+ // ^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
+ v.toStringAsFixed("3");
+ // ^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
}
diff --git a/tests/language_2/double_to_string_as_precision2_runtime_test.dart b/tests/language_2/double_to_string_as_precision2_runtime_test.dart
new file mode 100644
index 0000000..42214dc
--- /dev/null
+++ b/tests/language_2/double_to_string_as_precision2_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+ var v = 0.0;
+ Expect.throwsRangeError(() => v.toStringAsPrecision(0));
+ Expect.throwsRangeError(() => v.toStringAsPrecision(22));
+ Expect.throwsArgumentError(() => v.toStringAsPrecision(null));
+
+
+
+}
diff --git a/tests/language_2/double_to_string_as_precision2_test.dart b/tests/language_2/double_to_string_as_precision2_test.dart
index ea003dc..e69d0c9 100644
--- a/tests/language_2/double_to_string_as_precision2_test.dart
+++ b/tests/language_2/double_to_string_as_precision2_test.dart
@@ -10,7 +10,16 @@
Expect.throwsRangeError(() => v.toStringAsPrecision(0));
Expect.throwsRangeError(() => v.toStringAsPrecision(22));
Expect.throwsArgumentError(() => v.toStringAsPrecision(null));
- v.toStringAsPrecision(1.5); //# 01: compile-time error
- v.toStringAsPrecision("string"); //# 02: compile-time error
- v.toStringAsPrecision("3"); //# 03: compile-time error
+ v.toStringAsPrecision(1.5);
+ // ^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'double' can't be assigned to the parameter type 'int'.
+ v.toStringAsPrecision("string");
+ // ^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
+ v.toStringAsPrecision("3");
+ // ^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
}
diff --git a/tests/language_2/duplicate_constructor_runtime_test.dart b/tests/language_2/duplicate_constructor_runtime_test.dart
new file mode 100644
index 0000000..c65bc41
--- /dev/null
+++ b/tests/language_2/duplicate_constructor_runtime_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+class Foo {
+ Foo();
+
+}
+
+main() {
+ new Foo();
+}
diff --git a/tests/language_2/duplicate_constructor_test.dart b/tests/language_2/duplicate_constructor_test.dart
index 45b344a..0d36d5c 100644
--- a/tests/language_2/duplicate_constructor_test.dart
+++ b/tests/language_2/duplicate_constructor_test.dart
@@ -4,9 +4,14 @@
class Foo {
Foo();
- Foo(); //# 01: compile-time error
+ Foo();
+//^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_CONSTRUCTOR_DEFAULT
+// [cfe] 'Foo' is already declared in this scope.
}
main() {
new Foo();
+ // ^
+ // [cfe] Can't use 'Foo' because it is declared more than once.
}
diff --git a/tests/language_2/duplicate_field_with_initializer_runtime_test.dart b/tests/language_2/duplicate_field_with_initializer_runtime_test.dart
new file mode 100644
index 0000000..7764d43
--- /dev/null
+++ b/tests/language_2/duplicate_field_with_initializer_runtime_test.dart
@@ -0,0 +1,13 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Repeated {
+ var a, b = 'Something';
+
+}
+
+main() {}
diff --git a/tests/language_2/duplicate_field_with_initializer_test.dart b/tests/language_2/duplicate_field_with_initializer_test.dart
index f697a1f..9a65936 100644
--- a/tests/language_2/duplicate_field_with_initializer_test.dart
+++ b/tests/language_2/duplicate_field_with_initializer_test.dart
@@ -4,7 +4,10 @@
class Repeated {
var a, b = 'Something';
- var b; //# 01: compile-time error
+ var b;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+ // [cfe] 'b' is already declared in this scope.
}
main() {}
diff --git a/tests/language_2/duplicate_interface_implements_runtime_test.dart b/tests/language_2/duplicate_interface_implements_runtime_test.dart
new file mode 100644
index 0000000..aced31d
--- /dev/null
+++ b/tests/language_2/duplicate_interface_implements_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import "duplicate_interface_lib.dart" as alib;
+import "duplicate_interface_lib.dart" show InterfA;
+
+// Expect error since InterfA and alib.InterfA refer to the same interface.
+class Foo implements InterfA
+
+{}
+
+main() {
+ new Foo();
+}
diff --git a/tests/language_2/duplicate_interface_implements_test.dart b/tests/language_2/duplicate_interface_implements_test.dart
index e674f1e..4564aad 100644
--- a/tests/language_2/duplicate_interface_implements_test.dart
+++ b/tests/language_2/duplicate_interface_implements_test.dart
@@ -7,7 +7,9 @@
// Expect error since InterfA and alib.InterfA refer to the same interface.
class Foo implements InterfA
- , alib.InterfA //# 01: compile-time error
+ , alib.InterfA
+ //^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_REPEATED
{}
main() {
diff --git a/tests/language_2/dynamic2_runtime_test.dart b/tests/language_2/dynamic2_runtime_test.dart
new file mode 100644
index 0000000..d7159b8
--- /dev/null
+++ b/tests/language_2/dynamic2_runtime_test.dart
@@ -0,0 +1,17 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+//
+// Test the prohibited use of 'dynamic' in extending and implementing classes.
+
+class A
+
+
+{}
+
+main() {
+ new A();
+}
diff --git a/tests/language_2/dynamic2_test.dart b/tests/language_2/dynamic2_test.dart
index fdefa40..6871f9f 100644
--- a/tests/language_2/dynamic2_test.dart
+++ b/tests/language_2/dynamic2_test.dart
@@ -5,8 +5,14 @@
// Test the prohibited use of 'dynamic' in extending and implementing classes.
class A
- extends dynamic // //# 00: compile-time error
- implements dynamic // //# 01: compile-time error
+// ^
+// [cfe] The type 'dynamic' can't be used as supertype.
+ extends dynamic
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTENDS_NON_CLASS
+ implements dynamic
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
{}
main() {
diff --git a/tests/language_2/dynamic_field_runtime_test.dart b/tests/language_2/dynamic_field_runtime_test.dart
new file mode 100644
index 0000000..aebfbf6
--- /dev/null
+++ b/tests/language_2/dynamic_field_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+//
+// Test that ensures that fields can be accessed dynamically.
+
+import "package:expect/expect.dart";
+
+class A extends C {
+ var a;
+ var b;
+}
+
+class C {
+ foo() {
+
+
+ }
+ bar() {
+
+
+ }
+}
+
+main() {
+ var a = new A();
+ a.a = 1;
+ a.b = a;
+
+
+}
diff --git a/tests/language_2/dynamic_field_test.dart b/tests/language_2/dynamic_field_test.dart
index e6facc3..ebe094e 100644
--- a/tests/language_2/dynamic_field_test.dart
+++ b/tests/language_2/dynamic_field_test.dart
@@ -13,12 +13,24 @@
class C {
foo() {
- print(a); //# 01: compile-time error
- return a; //# 01: continued
+ print(a);
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'a' isn't defined for the class 'C'.
+ return a;
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'a' isn't defined for the class 'C'.
}
bar() {
- print(b.a); //# 02: compile-time error
- return b.a; //# 02: continued
+ print(b.a);
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'b' isn't defined for the class 'C'.
+ return b.a;
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'b' isn't defined for the class 'C'.
}
}
@@ -26,6 +38,6 @@
var a = new A();
a.a = 1;
a.b = a;
- Expect.equals(1, a.foo()); //# 01: continued
- Expect.equals(1, a.bar()); //# 02: continued
+ Expect.equals(1, a.foo());
+ Expect.equals(1, a.bar());
}
diff --git a/tests/language_2/enum_is_keyword_runtime_test.dart b/tests/language_2/enum_is_keyword_runtime_test.dart
new file mode 100644
index 0000000..2e9a471
--- /dev/null
+++ b/tests/language_2/enum_is_keyword_runtime_test.dart
@@ -0,0 +1,13 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Test that `enum` is considered a keyword and therefore invalid as the name of
+// declarations.
+
+main() {
+
+}
diff --git a/tests/language_2/enum_is_keyword_test.dart b/tests/language_2/enum_is_keyword_test.dart
index 09db3d9..5e7d0b5 100644
--- a/tests/language_2/enum_is_keyword_test.dart
+++ b/tests/language_2/enum_is_keyword_test.dart
@@ -6,5 +6,8 @@
// declarations.
main() {
- var enum; //# 01: syntax error
+ var enum;
+ // ^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected an identifier, but got 'enum'.
}
diff --git a/tests/language_2/enum_private_runtime_1_test.dart b/tests/language_2/enum_private_runtime_1_test.dart
new file mode 100644
index 0000000..6208940
--- /dev/null
+++ b/tests/language_2/enum_private_runtime_1_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Test privacy issue for enums.
+
+library enum_private_test;
+
+import 'package:expect/expect.dart';
+
+import 'enum_private_lib.dart';
+
+enum Enum1 {
+ _A,
+ _B,
+}
+
+main() {
+ Expect.equals('Enum1._A,Enum1._B', Enum1.values.join(','));
+ Expect.equals('Enum2._A,Enum2._B', Enum2.values.join(','));
+
+}
diff --git a/tests/language_2/enum_private_runtime_test.dart b/tests/language_2/enum_private_runtime_test.dart
new file mode 100644
index 0000000..5442171
--- /dev/null
+++ b/tests/language_2/enum_private_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Test privacy issue for enums.
+
+library enum_private_test;
+
+import 'package:expect/expect.dart';
+
+import 'enum_private_lib.dart';
+
+enum Enum1 {
+ _A,
+ _B,
+}
+
+main() {
+ Expect.equals('Enum1._A,Enum1._B', Enum1.values.join(','));
+
+
+}
diff --git a/tests/language_2/enum_private_test.dart b/tests/language_2/enum_private_test.dart
index 896acb0..d2661cfc 100644
--- a/tests/language_2/enum_private_test.dart
+++ b/tests/language_2/enum_private_test.dart
@@ -17,6 +17,9 @@
main() {
Expect.equals('Enum1._A,Enum1._B', Enum1.values.join(','));
- Expect.equals('Enum2._A,Enum2._B', Enum2.values.join(',')); //# 01: ok
- Expect.throwsNoSuchMethodError(() => Enum2._A); //# 02: compile-time error
+ Expect.equals('Enum2._A,Enum2._B', Enum2.values.join(','));
+ Expect.throwsNoSuchMethodError(() => Enum2._A);
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] Getter not found: '_A'.
}
diff --git a/tests/language_2/error_stacktrace_runtime_test.dart b/tests/language_2/error_stacktrace_runtime_test.dart
new file mode 100644
index 0000000..4f6b152
--- /dev/null
+++ b/tests/language_2/error_stacktrace_runtime_test.dart
@@ -0,0 +1,126 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+// Dart test program for testing throw statement
+
+import "package:expect/expect.dart";
+
+class MyException {
+ const MyException(String message) : message_ = message;
+ final String message_;
+}
+
+class Helper1 {
+ static int func1() {
+ return func2();
+ }
+
+ static int func2() {
+ return func3();
+ }
+
+ static int func3() {
+ return func4();
+ }
+
+ static int func4() {
+ var i = 0;
+ try {
+ i = 10;
+ func5();
+ } on ArgumentError catch (e) {
+ i = 100;
+ Expect.isNotNull(e.stackTrace, "Errors need a stackTrace on throw");
+ }
+ return i;
+ }
+
+ static void func5() {
+ // Throw an Error.
+ throw new ArgumentError("ArgumentError in func5");
+ }
+}
+
+class Helper2 {
+ static int func1() {
+ return func2();
+ }
+
+ static int func2() {
+ return func3();
+ }
+
+ static int func3() {
+ return func4();
+ }
+
+ static int func4() {
+ var i = 0;
+ try {
+ i = 10;
+ func5();
+ } on ArgumentError catch (e, s) {
+ i = 200;
+ Expect.isNotNull(e.stackTrace, "Errors need a stackTrace on throw");
+ Expect.equals(e.stackTrace.toString(), s.toString());
+ }
+ return i;
+ }
+
+ static List func5() {
+ // Throw an Error.
+ throw new ArgumentError("ArgumentError in func5");
+ }
+}
+
+class Helper3 {
+ static int func1() {
+ return func2();
+ }
+
+ static int func2() {
+ return func3();
+ }
+
+ static int func3() {
+ return func4();
+ }
+
+ static int func4() {
+ var i = 0;
+ try {
+ i = 10;
+ func5();
+ } on MyException catch (e) {
+ i = 300;
+
+ // There should be no stackTrace in this normal exception object.
+ // We should get a NoSuchMethodError.
+
+
+
+
+ }
+ return i;
+ }
+
+ static List func5() {
+ // Throw an Exception (any random object).
+ throw new MyException("MyException in func5");
+ }
+}
+
+class ErrorStackTraceTest {
+ static testMain() {
+ Expect.equals(100, Helper1.func1());
+ Expect.equals(200, Helper2.func1());
+ Expect.equals(300, Helper3.func1());
+ }
+}
+
+main() {
+ ErrorStackTraceTest.testMain();
+}
diff --git a/tests/language_2/error_stacktrace_test.dart b/tests/language_2/error_stacktrace_test.dart
index 098dbb6..56707da 100644
--- a/tests/language_2/error_stacktrace_test.dart
+++ b/tests/language_2/error_stacktrace_test.dart
@@ -93,13 +93,16 @@
func5();
} on MyException catch (e) {
i = 300;
- try {// //# 00: continued
+ try {
// There should be no stackTrace in this normal exception object.
// We should get a NoSuchMethodError.
- var trace = e.stackTrace; // //# 00: compile-time error
- } on NoSuchMethodError catch (e) {// //# 00: continued
- Expect.isNotNull(e.stackTrace, "Error needs a stackTrace on throw");// //# 00: continued
- }// //# 00: continued
+ var trace = e.stackTrace;
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'stackTrace' isn't defined for the class 'MyException'.
+ } on NoSuchMethodError catch (e) {
+ Expect.isNotNull(e.stackTrace, "Error needs a stackTrace on throw");
+ }
}
return i;
}
diff --git a/tests/language_2/expect_test.dart b/tests/language_2/expect_test.dart
index c2d871e..5cd8c8a3 100644
--- a/tests/language_2/expect_test.dart
+++ b/tests/language_2/expect_test.dart
@@ -40,7 +40,7 @@
}
static testIdentical(a) {
- var ab = "${a}B";
+ var ab = a + "B";
try {
Expect.identical("AB", ab);
} on ExpectException catch (msg) {
diff --git a/tests/language_2/export_private_runtime_test.dart b/tests/language_2/export_private_runtime_test.dart
new file mode 100644
index 0000000..e78b2b1
--- /dev/null
+++ b/tests/language_2/export_private_runtime_test.dart
@@ -0,0 +1,13 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+// Check that private dart:_ libraries cannot be imported.
+
+
+
+main() {
+ print("Done.");
+}
diff --git a/tests/language_2/export_private_test.dart b/tests/language_2/export_private_test.dart
index 2828f45..d152f32 100644
--- a/tests/language_2/export_private_test.dart
+++ b/tests/language_2/export_private_test.dart
@@ -3,7 +3,10 @@
// BSD-style license that can be found in the LICENSE file.
// Check that private dart:_ libraries cannot be imported.
-export "dart:_internal"; // //# 01: compile-time error
+export "dart:_internal";
+// [error line 6, column 1, length 24]
+// [analyzer] COMPILE_TIME_ERROR.EXPORT_INTERNAL_LIBRARY
+// [cfe] Can't access platform private library.
main() {
print("Done.");
diff --git a/tests/language_2/external_runtime_test.dart b/tests/language_2/external_runtime_test.dart
new file mode 100644
index 0000000..e51282c
--- /dev/null
+++ b/tests/language_2/external_runtime_test.dart
@@ -0,0 +1,54 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+class Bar {
+ Bar(val);
+}
+
+class Foo {
+ var x;
+ f() {}
+
+ Foo() : x = 0;
+
+ // fields can't be declared external
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+
+
+
+main() {
+ // Ensure Foo class is compiled.
+ var foo = new Foo();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/external_test.dart b/tests/language_2/external_test.dart
index c021505..2e83649 100644
--- a/tests/language_2/external_test.dart
+++ b/tests/language_2/external_test.dart
@@ -7,45 +7,97 @@
}
class Foo {
+// ^
+// [cfe] The non-abstract class 'Foo' is missing implementations for these members:
var x;
f() {}
Foo() : x = 0;
// fields can't be declared external
- external var x01; // //# 01: syntax error
- external int x02; // //# 02: syntax error
+ external var x01;
+//^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXTERNAL_FIELD
+// [cfe] Fields can't be declared to be 'external'.
+ external int x02;
+//^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXTERNAL_FIELD
+// [cfe] Fields can't be declared to be 'external'.
- external f11() { } // //# 11: syntax error
- external f12() => 1; // //# 12: syntax error
- static external f14(); // //# 14: syntax error
- int external f16(); // //# 16: syntax error
+ external f11() { }
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.EXTERNAL_METHOD_WITH_BODY
+ // [cfe] An external or native method can't have a body.
+ external f12() => 1;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.EXTERNAL_METHOD_WITH_BODY
+ // [cfe] An external or native method can't have a body.
+ // ^
+ // [cfe] An external or native method can't have a body.
+ static external f14();
+ // ^^^^^^^^
+ // [analyzer] SYNTACTIC_ERROR.MODIFIER_OUT_OF_ORDER
+ // [cfe] The modifier 'external' should be before the modifier 'static'.
+ int external f16();
+ // ^^^^^^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected ';' after this.
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
- external Foo.n21(val) : x = 1; // //# 21: syntax error
- external Foo.n22(val) { x = 1; } // //# 22: syntax error
- external factory Foo.n23(val) => new Foo(); // //# 23: syntax error
- external Foo.n24(this.x); // //# 24: compile-time error
- external factory Foo.n25(val) = Bar; // //# 25: syntax error
+ external Foo.n21(val) : x = 1;
+ // ^
+ // [cfe] Only constructors can have initializers, and 'n21' is not a constructor.
+ external Foo.n22(val) { x = 1; }
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.EXTERNAL_METHOD_WITH_BODY
+ // [cfe] An external or native method can't have a body.
+ external factory Foo.n23(val) => new Foo();
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.EXTERNAL_FACTORY_WITH_BODY
+ // [cfe] External factories can't have a body.
+ // ^
+ // [cfe] An external or native method can't have a body.
+ external Foo.n24(this.x);
+ // ^
+ // [cfe] An external constructor can't initialize fields.
+ external factory Foo.n25(val) = Bar;
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.EXTERNAL_FACTORY_REDIRECTION
+ // [cfe] A redirecting factory can't be external.
+ // ^^^
+ // [analyzer] STATIC_WARNING.REDIRECT_TO_INVALID_RETURN_TYPE
+ // [cfe] The constructor function type 'Bar Function(dynamic)' isn't a subtype of 'Foo Function(dynamic)'.
}
-external int t06(int i) { } // //# 30: syntax error
-external int t07(int i) => i + 1; // //# 31: syntax error
+external int t06(int i) { }
+// [error line 73, column 1, length 8]
+// [analyzer] SYNTACTIC_ERROR.EXTERNAL_METHOD_WITH_BODY
+// [cfe] An external or native method can't have a body.
+// ^
+// [cfe] An external or native method can't have a body.
+external int t07(int i) => i + 1;
+// [error line 79, column 1, length 8]
+// [analyzer] SYNTACTIC_ERROR.EXTERNAL_METHOD_WITH_BODY
+// [cfe] An external or native method can't have a body.
+// ^
+// [cfe] An external or native method can't have a body.
main() {
// Ensure Foo class is compiled.
var foo = new Foo();
- new Foo().f11(); // //# 11: continued
- new Foo().f12(); // //# 12: continued
- Foo.f14(); // //# 14: continued
- new Foo().f16(); // //# 16: continued
+ new Foo().f11();
+ new Foo().f12();
+ Foo.f14();
+ new Foo().f16();
- new Foo.n21(1); // //# 21: continued
- new Foo.n22(1); // //# 22: continued
- new Foo.n23(1); // //# 23: continued
- new Foo.n24(1); // //# 24: continued
- new Foo.n25(1); // //# 25: continued
+ new Foo.n21(1);
+ new Foo.n22(1);
+ new Foo.n23(1);
+ new Foo.n24(1);
+ new Foo.n25(1);
- t06(1); // //# 30: continued
- t07(1); // //# 31: continued
+ t06(1);
+ t07(1);
}
diff --git a/tests/language_2/f_bounded_quantification_runtime_test.dart b/tests/language_2/f_bounded_quantification_runtime_test.dart
new file mode 100644
index 0000000..77a3466
--- /dev/null
+++ b/tests/language_2/f_bounded_quantification_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Test for F-Bounded Quantification.
+
+class FBound<F extends FBound<F>> {}
+
+class Bar extends FBound<Bar> {}
+
+class SubBar extends Bar {}
+
+class Baz<T> extends FBound<Baz<T>> {}
+
+class SubBaz<T> extends Baz<T> {}
+
+main() {
+ FBound<Bar> fb = new FBound<Bar>();
+
+
+ FBound<Baz<Bar>> fbb = new FBound<Baz<Bar>>();
+
+}
diff --git a/tests/language_2/f_bounded_quantification_test.dart b/tests/language_2/f_bounded_quantification_test.dart
index 433df64..4247e7d 100644
--- a/tests/language_2/f_bounded_quantification_test.dart
+++ b/tests/language_2/f_bounded_quantification_test.dart
@@ -16,8 +16,24 @@
main() {
FBound<Bar> fb = new FBound<Bar>();
- FBound<SubBar> fsb = new FBound<SubBar>(); // //# 01: compile-time error
+ FBound<SubBar> fsb = new FBound<SubBar>();
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
+ // ^
+ // [cfe] Type argument 'SubBar' doesn't conform to the bound 'FBound<F>' of the type variable 'F' on 'FBound'.
+ // ^
+ // [cfe] Type argument 'SubBar' doesn't conform to the bound 'FBound<F>' of the type variable 'F' on 'FBound'.
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
FBound<Baz<Bar>> fbb = new FBound<Baz<Bar>>();
- FBound<SubBaz<Bar>> fsbb = new FBound<SubBaz<Bar>>(); // //# 02: compile-time error
+ FBound<SubBaz<Bar>> fsbb = new FBound<SubBaz<Bar>>();
+ // ^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
+ // ^
+ // [cfe] Type argument 'SubBaz<Bar>' doesn't conform to the bound 'FBound<F>' of the type variable 'F' on 'FBound'.
+ // ^
+ // [cfe] Type argument 'SubBaz<Bar>' doesn't conform to the bound 'FBound<F>' of the type variable 'F' on 'FBound'.
+ // ^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
diff --git a/tests/language_2/factory4_runtime_test.dart b/tests/language_2/factory4_runtime_test.dart
new file mode 100644
index 0000000..1d6ed5e7
--- /dev/null
+++ b/tests/language_2/factory4_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+abstract class Link<T> {
+
+}
+
+class A<T> {}
+
+class LinkFactory<T> extends A<T> {
+ factory LinkFactory.create() {
+ return null;
+ }
+}
+
+main() {
+
+}
diff --git a/tests/language_2/factory4_test.dart b/tests/language_2/factory4_test.dart
index e553917..660b103 100644
--- a/tests/language_2/factory4_test.dart
+++ b/tests/language_2/factory4_test.dart
@@ -3,7 +3,10 @@
// BSD-style license that can be found in the LICENSE file.
abstract class Link<T> {
- factory Link.create() = LinkFactory.create; //# 00: compile-time error
+ factory Link.create() = LinkFactory.create;
+ // ^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.REDIRECT_TO_INVALID_RETURN_TYPE
+ // [cfe] The constructor function type 'LinkFactory<dynamic> Function()' isn't a subtype of 'Link<T> Function()'.
}
class A<T> {}
@@ -15,5 +18,5 @@
}
main() {
- new Link<int>.create(); //# 00: continued
+ new Link<int>.create();
}
diff --git a/tests/language_2/factory5_runtime_test.dart b/tests/language_2/factory5_runtime_test.dart
new file mode 100644
index 0000000..28b34b0
--- /dev/null
+++ b/tests/language_2/factory5_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+abstract class Link<T> {
+
+}
+
+class LinkFactory<T> {
+ factory LinkFactory.create() {
+ return null;
+ }
+
+}
+
+main() {
+
+}
diff --git a/tests/language_2/factory5_test.dart b/tests/language_2/factory5_test.dart
index 3502a08..c1b5028 100644
--- a/tests/language_2/factory5_test.dart
+++ b/tests/language_2/factory5_test.dart
@@ -3,16 +3,24 @@
// BSD-style license that can be found in the LICENSE file.
abstract class Link<T> {
- factory Link.create() = LinkFactory<T>.create; //# 00: compile-time error
+ factory Link.create() = LinkFactory<T>.create;
+ // ^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.REDIRECT_TO_INVALID_RETURN_TYPE
+ // [cfe] The constructor function type 'LinkFactory<T> Function()' isn't a subtype of 'Link<T> Function()'.
}
class LinkFactory<T> {
factory LinkFactory.create() {
return null;
}
- factory LinkFactory.Foo() = Foo<T>; //# 00: compile-time error
+ factory LinkFactory.Foo() = Foo<T>;
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_NON_CLASS
+ // [cfe] Couldn't find constructor 'Foo'.
+ // ^
+ // [cfe] Redirection constructor target not found: 'Foo'
}
main() {
- new Link<int>.create(); //# 00: continued
+ new Link<int>.create();
}
diff --git a/tests/language_2/factory6_runtime_test.dart b/tests/language_2/factory6_runtime_test.dart
new file mode 100644
index 0000000..8452028
--- /dev/null
+++ b/tests/language_2/factory6_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2016, 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.
+
+import 'package:expect/expect.dart';
+
+abstract class Link<T> {
+
+}
+
+class LinkFactory<T> {
+
+}
+
+main() {
+
+}
diff --git a/tests/language_2/factory6_test.dart b/tests/language_2/factory6_test.dart
index 2d3dc52..7e36cb9 100644
--- a/tests/language_2/factory6_test.dart
+++ b/tests/language_2/factory6_test.dart
@@ -5,13 +5,21 @@
import 'package:expect/expect.dart';
abstract class Link<T> {
- factory Link.Foo() = LinkFactory<T>.Foo; // //# 00: compile-time error
+ factory Link.Foo() = LinkFactory<T>.Foo;
+ // ^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.REDIRECT_TO_INVALID_RETURN_TYPE
+ // [cfe] The constructor function type 'LinkFactory<T> Function()' isn't a subtype of 'Link<T> Function()'.
}
class LinkFactory<T> {
- factory LinkFactory.Foo() = Foo<T>; // //# 00: continued
+ factory LinkFactory.Foo() = Foo<T>;
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_NON_CLASS
+ // [cfe] Couldn't find constructor 'Foo'.
+ // ^
+ // [cfe] Redirection constructor target not found: 'Foo'
}
main() {
- Expect.throws(() => new Link<int>.Foo()); //# 00: continued
+ Expect.throws(() => new Link<int>.Foo());
}
diff --git a/tests/language_2/factory_and_instance_variable_runtime_test.dart b/tests/language_2/factory_and_instance_variable_runtime_test.dart
new file mode 100644
index 0000000..f250fb8
--- /dev/null
+++ b/tests/language_2/factory_and_instance_variable_runtime_test.dart
@@ -0,0 +1,41 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.md file.
+
+abstract class A {
+ var bar;
+ factory A.bar() = B.bar;
+
+ get foo => bar;
+
+}
+
+class B implements A {
+ var bar;
+ factory B.bar() => new C.bar();
+
+ get foo => bar;
+
+
+ B() {}
+}
+
+class C extends B {
+ C.bar() {
+ bar = "foo";
+ }
+
+
+}
+
+main() {
+ assert(new A.bar().foo == "foo");
+ assert(new B.bar().foo == "foo");
+ assert(new C.bar().foo == "foo");
+ assert(new A.bar().bar == "foo");
+ assert(new B.bar().bar == "foo");
+ assert(new C.bar().bar == "foo");
+}
diff --git a/tests/language_2/factory_and_instance_variable_test.dart b/tests/language_2/factory_and_instance_variable_test.dart
index 97f92f9..b35c290 100644
--- a/tests/language_2/factory_and_instance_variable_test.dart
+++ b/tests/language_2/factory_and_instance_variable_test.dart
@@ -7,7 +7,10 @@
factory A.bar() = B.bar;
get foo => bar;
- static get baz => bar; //# 01: compile-time error
+ static get baz => bar;
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.INSTANCE_MEMBER_ACCESS_FROM_STATIC
+ // [cfe] Getter not found: 'bar'.
}
class B implements A {
@@ -15,7 +18,10 @@
factory B.bar() => new C.bar();
get foo => bar;
- static get baz => bar; //# 02: compile-time error
+ static get baz => bar;
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.INSTANCE_MEMBER_ACCESS_FROM_STATIC
+ // [cfe] Getter not found: 'bar'.
B() {}
}
@@ -25,7 +31,10 @@
bar = "foo";
}
- static get baz => bar; //# 03: compile-time error
+ static get baz => bar;
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.INSTANCE_MEMBER_ACCESS_FROM_STATIC
+ // [cfe] Getter not found: 'bar'.
}
main() {
diff --git a/tests/language_2/factory_redirection2_runtime_test.dart b/tests/language_2/factory_redirection2_runtime_test.dart
new file mode 100644
index 0000000..b00089c
--- /dev/null
+++ b/tests/language_2/factory_redirection2_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Test that it is a compile-time error to have a redirection in a
+// non-factory constructor.
+
+class Foo {
+ Foo()
+
+ ;
+}
+
+class Bar extends Foo {
+ factory Bar() => null;
+}
+
+main() {
+ Expect.isTrue(new Foo() is Foo);
+ Expect.isFalse(new Foo() is Bar);
+}
diff --git a/tests/language_2/factory_redirection2_test.dart b/tests/language_2/factory_redirection2_test.dart
index 39a1abb..f2edbc9 100644
--- a/tests/language_2/factory_redirection2_test.dart
+++ b/tests/language_2/factory_redirection2_test.dart
@@ -9,7 +9,14 @@
class Foo {
Foo()
- = Bar //# 01: syntax error
+ = Bar
+//^
+// [analyzer] SYNTACTIC_ERROR.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR
+// [cfe] Expected a function body or '=>'.
+//^
+// [cfe] Only factory constructor can specify '=' redirection.
+// ^
+// [cfe] Constructors can't have a return type.
;
}
diff --git a/tests/language_2/factory_redirection3_cyclic_runtime_test.dart b/tests/language_2/factory_redirection3_cyclic_runtime_test.dart
new file mode 100644
index 0000000..ecbccc2
--- /dev/null
+++ b/tests/language_2/factory_redirection3_cyclic_runtime_test.dart
@@ -0,0 +1,28 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test that a cycle in redirecting factories leads to a compile-time error.
+
+class A {
+ factory A.foo() = B;
+}
+
+class B implements A {
+ factory B() = C.bar;
+}
+
+class C implements B {
+ factory C.bar() = C.foo;
+ factory C.foo() = C
+
+ ;
+ C();
+}
+
+main() {
+ new A.foo();
+}
diff --git a/tests/language_2/factory_redirection3_cyclic_test.dart b/tests/language_2/factory_redirection3_cyclic_test.dart
index 0407262..ed352be 100644
--- a/tests/language_2/factory_redirection3_cyclic_test.dart
+++ b/tests/language_2/factory_redirection3_cyclic_test.dart
@@ -6,6 +6,8 @@
class A {
factory A.foo() = B;
+ // ^
+ // [cfe] Cyclic definition of factory 'A.foo'.
}
class B implements A {
@@ -14,9 +16,19 @@
class C implements B {
factory C.bar() = C.foo;
- factory C.foo() = C
- .bar //# 01: compile-time error
- ;
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_FACTORY_REDIRECT
+ factory C.foo() = C.bar();
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_FACTORY_REDIRECT
+ // ^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected ';' after this.
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected an identifier, but got '('.
+ // ^^^
+ // [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
C();
}
diff --git a/tests/language_2/factory_return_type_checked_runtime_test.dart b/tests/language_2/factory_return_type_checked_runtime_test.dart
new file mode 100644
index 0000000..3bef4c2
--- /dev/null
+++ b/tests/language_2/factory_return_type_checked_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+
+}
+
+main() {
+
+}
diff --git a/tests/language_2/factory_return_type_checked_test.dart b/tests/language_2/factory_return_type_checked_test.dart
index bee1405..bff29b4 100644
--- a/tests/language_2/factory_return_type_checked_test.dart
+++ b/tests/language_2/factory_return_type_checked_test.dart
@@ -5,9 +5,12 @@
import "package:expect/expect.dart";
class A {
- factory A() => 42; //# 00: compile-time error
+ factory A() => 42;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.RETURN_OF_INVALID_TYPE_FROM_CLOSURE
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'A'.
}
main() {
- Expect.throws(() => new A()); //# 00: continued
+ Expect.throws(() => new A());
}
diff --git a/tests/language_2/factory_runtime_test.dart b/tests/language_2/factory_runtime_test.dart
new file mode 100644
index 0000000..bac5c66
--- /dev/null
+++ b/tests/language_2/factory_runtime_test.dart
@@ -0,0 +1,54 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Dart test program for testing factories.
+
+import "package:expect/expect.dart";
+
+class A {
+ factory A(n) {
+ return new A.internal(n);
+ }
+ A.internal(n) : n_ = n {}
+ var n_;
+}
+
+class B {
+ factory B.my() {
+ return new B(3);
+ }
+ B(n) : n_ = n {}
+ var n_;
+}
+
+class FactoryTest {
+ static testMain() {
+ new B.my();
+ var b = new B.my();
+ Expect.equals(3, b.n_);
+ var a = new A(5);
+ Expect.equals(5, a.n_);
+ }
+}
+
+// Test compile time error for factories with parameterized types.
+
+
+
+
+
+
+ // Compile time error: should be LinkFactory<T> to match abstract class above
+
+
+
+
+
+
+main() {
+ FactoryTest.testMain();
+
+}
diff --git a/tests/language_2/factory_test.dart b/tests/language_2/factory_test.dart
index 81fa004..9d4301c 100644
--- a/tests/language_2/factory_test.dart
+++ b/tests/language_2/factory_test.dart
@@ -33,19 +33,29 @@
// Test compile time error for factories with parameterized types.
-abstract class Link<T> {// //# 00: continued
- factory Link.create() = LinkFactory<T>.create; // //# 00: compile-time error
-}// //# 00: continued
+abstract class Link<T> {
+ factory Link.create() = LinkFactory<T>.create;
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+ // [cfe] Expected 0 type arguments.
+ // ^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.REDIRECT_TO_INVALID_RETURN_TYPE
+}
-class LinkFactory {// //# 00: continued
+class LinkFactory {
// Compile time error: should be LinkFactory<T> to match abstract class above
- factory Link.create() { //# 00: compile-time error
- return null;// //# 00: continued
- }// //# 00: continued
-}// //# 00: continued
+ factory Link.create() {
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_FACTORY_NAME_NOT_A_CLASS
+ // [cfe] The name of a constructor must match the name of the enclosing class.
+ return null;
+ }
+}
main() {
FactoryTest.testMain();
- var a = new Link<int>.create(); //# 00: continued
+ var a = new Link<int>.create();
+ // ^
+ // [cfe] Expected 0 type arguments.
}
diff --git a/tests/language_2/fauxverride_runtime_test.dart b/tests/language_2/fauxverride_runtime_test.dart
new file mode 100644
index 0000000..d5ae11a
--- /dev/null
+++ b/tests/language_2/fauxverride_runtime_test.dart
@@ -0,0 +1,102 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+// Test the semantics of static members mixed with instance members.
+
+// Following are relevant quotes from Dart Programming Language
+// Specification, Draft Version 0.10, June 7, 2012.
+
+// 7 Classes:
+
+// "It is a compile-time error if a class has an instance method and a
+// static member method with the same name."
+
+// 7.1 Instance Methods:
+
+// "Instance methods are functions (6) whose declarations are
+// immediately contained within a class declaration and that are not
+// declared static. The instance methods of a class C are those
+// instance methods declared by C and the instance methods inherited
+// by C from its superclass."
+
+// 7.6 Static Methods
+
+// "Static methods are functions whose declarations are immediately
+// contained within a class declaration and that are declared
+// static. The static methods of a class C are those static methods
+// declared by C."
+
+// 7.7 Static Variables
+
+// "Static variables are variables whose declarations are immediately
+// contained within a class declaration and that are declared
+// static. The static variables of a class C are those static
+// variables declared by C."
+
+// "A static variable declaration of one of the forms static T v;,
+// static T v = e; , static const T v = e; or static final T v = e;
+// always induces an implicit static getter function (7.2) with
+// signature static T get v whose invocation evaluates as described
+// below (7.7.1)."
+
+m() => 'top level';
+
+class Super {
+ // No error from hiding.
+ static m() => 'super';
+
+ static var i = 'super';
+
+ static var i2 = 'super';
+
+ instanceMethod() => m();
+
+ instanceMethod2() => m();
+}
+
+class Sub extends Super {
+ // According to 7.6, static methods are not inherited.
+ static m() => 'sub';
+
+ // According to 7.7, static variables are not inherited.
+ static var i = 'sub';
+
+ // According to 7.1, instance methods include those of the
+ // superclass, and according to 7, it is a compile-time to have an
+ // instance method and static method with the same name.
+
+ instanceMethod() => m();
+
+ // According to 7.7, static variables are not inherited.
+ static i2() => m();
+
+ // According to 7.1, instance methods include those of the
+ // superclass, and according to 7, it is a compile-time to have an
+ // instance method and static method with the same
+ // name. Furthermore, according to 7.7 a static variable induces an
+ // implicit getter function (a static method).
+
+
+ foo() => 'foo';
+}
+
+main() {
+ Expect.equals('foo', new Sub().foo());
+ Expect.equals('top level', m());
+ Expect.equals('super', Super.m());
+ Expect.equals('sub', Sub.m());
+ Expect.equals('super', Super.i);
+ Expect.equals('sub', Sub.i);
+ Expect.equals('super', Super.i2);
+ Expect.equals('sub', Sub.i2());
+ Expect.equals('super', new Super().instanceMethod());
+ Expect.equals('sub', new Sub().instanceMethod());
+ Expect.equals('super', new Super().instanceMethod2());
+ Expect.equals('super', new Sub().instanceMethod2());
+}
diff --git a/tests/language_2/fauxverride_test.dart b/tests/language_2/fauxverride_test.dart
index fa2ee5b..d5fc6b1 100644
--- a/tests/language_2/fauxverride_test.dart
+++ b/tests/language_2/fauxverride_test.dart
@@ -67,8 +67,11 @@
// According to 7.1, instance methods include those of the
// superclass, and according to 7, it is a compile-time to have an
// instance method and static method with the same name.
- static //# 03: compile-time error
+ static
instanceMethod() => m();
+//^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+// [cfe] Can't declare a member that conflicts with an inherited one.
// According to 7.7, static variables are not inherited.
static i2() => m();
@@ -78,7 +81,10 @@
// instance method and static method with the same
// name. Furthermore, according to 7.7 a static variable induces an
// implicit getter function (a static method).
- static var instanceMethod2; //# 05: compile-time error
+ static var instanceMethod2;
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
foo() => 'foo';
}
@@ -94,6 +100,10 @@
Expect.equals('sub', Sub.i2());
Expect.equals('super', new Super().instanceMethod());
Expect.equals('sub', new Sub().instanceMethod());
+ // ^
+ // [cfe] The method 'instanceMethod' isn't defined for the class 'Sub'.
Expect.equals('super', new Super().instanceMethod2());
Expect.equals('super', new Sub().instanceMethod2());
+ // ^
+ // [cfe] The method 'instanceMethod2' isn't defined for the class 'Sub'.
}
diff --git a/tests/language_2/field_decl_missing_var_type_runtime_test.dart b/tests/language_2/field_decl_missing_var_type_runtime_test.dart
new file mode 100644
index 0000000..3d31ad0
--- /dev/null
+++ b/tests/language_2/field_decl_missing_var_type_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Dart test program for constructors and initializers.
+
+// Exercises issue 2997, missing var or type on field declarations should
+// generate a compile-time error.
+
+class A {
+
+
+}
+
+main() {
+
+}
diff --git a/tests/language_2/field_decl_missing_var_type_test.dart b/tests/language_2/field_decl_missing_var_type_test.dart
index 19cdd55..6435dfb 100644
--- a/tests/language_2/field_decl_missing_var_type_test.dart
+++ b/tests/language_2/field_decl_missing_var_type_test.dart
@@ -7,10 +7,13 @@
// generate a compile-time error.
class A {
- _this; // //# 01: syntax error
- A(x) : this._this = x; // //# 01: continued
+ _this;
+//^^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
+// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
+ A(x) : this._this = x;
}
main() {
- new A(0); // //# 01: continued
+ new A(0);
}
diff --git a/tests/language_2/field_type_check_runtime_test.dart b/tests/language_2/field_type_check_runtime_test.dart
new file mode 100644
index 0000000..53fccb5
--- /dev/null
+++ b/tests/language_2/field_type_check_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+class A {
+ int e;
+}
+
+int main() {
+
+}
diff --git a/tests/language_2/field_type_check_test.dart b/tests/language_2/field_type_check_test.dart
index 485408f..51f03fc 100644
--- a/tests/language_2/field_type_check_test.dart
+++ b/tests/language_2/field_type_check_test.dart
@@ -7,5 +7,8 @@
}
int main() {
- new A().e = "String"; //# 01: compile-time error
+ new A().e = "String";
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
}
diff --git a/tests/language_2/final_attempt_reinitialization_runtime_test.dart b/tests/language_2/final_attempt_reinitialization_runtime_test.dart
new file mode 100644
index 0000000..b16a2c7
--- /dev/null
+++ b/tests/language_2/final_attempt_reinitialization_runtime_test.dart
@@ -0,0 +1,23 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+class Foo {
+
+
+}
+
+class CoffeeShop {
+
+
+
+}
+
+void main() {
+
+
+
+}
diff --git a/tests/language_2/final_attempt_reinitialization_test.dart b/tests/language_2/final_attempt_reinitialization_test.dart
index a5a8be2..009998b 100644
--- a/tests/language_2/final_attempt_reinitialization_test.dart
+++ b/tests/language_2/final_attempt_reinitialization_test.dart
@@ -3,18 +3,25 @@
// BSD-style license that can be found in the LICENSE file.
class Foo {
- Foo(this.x); //# 01: compile-time error
- final int x = 42; //# 01: compile-time error
+ Foo(this.x);
+ // ^
+ // [analyzer] STATIC_WARNING.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR
+ // [cfe] 'x' is a final instance variable that has already been initialized.
+ final int x = 42;
}
class CoffeeShop {
- final String shopName = "Coffee Lab"; //# 02: compile-time error
- CoffeeShop.name(String shopName) //# 02: compile-time error
- : this.shopName = shopName; //# 02: compile-time error
+ final String shopName = "Coffee Lab";
+ CoffeeShop.name(String shopName)
+ : this.shopName = shopName;
+ // ^^^^^^^^
+ // [analyzer] STATIC_WARNING.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION
+ // ^
+ // [cfe] 'shopName' is a final instance variable that has already been initialized.
}
void main() {
- Foo f = new Foo(10); //# 01: compile-time error
- CoffeeShop presidentialCoffee = //# 02: compile-time error
- new CoffeeShop.name("Covfefe Lab"); //# 02: compile-time error
+ Foo f = new Foo(10);
+ CoffeeShop presidentialCoffee =
+ new CoffeeShop.name("Covfefe Lab");
}
diff --git a/tests/language_2/final_variable_assignment_runtime_test.dart b/tests/language_2/final_variable_assignment_runtime_test.dart
new file mode 100644
index 0000000..1fabb8b
--- /dev/null
+++ b/tests/language_2/final_variable_assignment_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// Test to make sure we catch assignments to final local variables.
+
+main() {
+ final x = 30;
+
+
+
+
+}
diff --git a/tests/language_2/final_variable_assignment_test.dart b/tests/language_2/final_variable_assignment_test.dart
index 6f12699..d56db9332 100644
--- a/tests/language_2/final_variable_assignment_test.dart
+++ b/tests/language_2/final_variable_assignment_test.dart
@@ -6,8 +6,20 @@
main() {
final x = 30;
- x = 0; // //# 01: compile-time error
- x += 1; // //# 02: compile-time error
- ++x; // //# 03: compile-time error
- x++; // //# 04: compile-time error
+ x = 0;
+//^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_LOCAL
+// [cfe] Setter not found: 'x'.
+ x += 1;
+//^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_LOCAL
+// [cfe] Setter not found: 'x'.
+ ++x;
+ //^
+ // [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_LOCAL
+ // [cfe] Setter not found: 'x'.
+ x++;
+//^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_LOCAL
+// [cfe] Setter not found: 'x'.
}
diff --git a/tests/language_2/first_class_types_literals_runtime_1_test.dart b/tests/language_2/first_class_types_literals_runtime_1_test.dart
new file mode 100644
index 0000000..b415e99
--- /dev/null
+++ b/tests/language_2/first_class_types_literals_runtime_1_test.dart
@@ -0,0 +1,67 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+class C<T, U, V> {}
+
+class D {}
+
+typedef int Foo(bool b);
+
+sameType(a, b) {
+ Expect.equals(a.runtimeType, b.runtimeType);
+}
+
+main() {
+ void foo(a) {}
+
+ // Test that literals can be used in different contexts.
+ [int];
+ ([int]);
+ foo([int]);
+ [int].length;
+ ({1: int});
+ foo({1: int});
+ ({1: int}).keys;
+
+ // Test type literals.
+ Expect.equals(int, int);
+ Expect.notEquals(int, num);
+ Expect.equals(Foo, Foo);
+ Expect.equals(dynamic, dynamic);
+
+ // Test that class literals return instances of Type.
+ Expect.isTrue((D).runtimeType is Type);
+ Expect.isTrue((dynamic).runtimeType is Type);
+
+ // Test that types from runtimeType and literals agree.
+ Expect.equals(int, 1.runtimeType);
+ Expect.equals(String, 'hest'.runtimeType);
+ Expect.equals(double, (0.5).runtimeType);
+ Expect.equals(bool, true.runtimeType);
+ Expect.equals(Object, Object().runtimeType);
+ Expect.equals(C, new C().runtimeType);
+
+
+ // runtimeType on type is idempotent.
+ Expect.equals((D).runtimeType, (D).runtimeType.runtimeType);
+
+ // Test that operator calls on class literals go to Type.
+
+
+
+
+
+
+
+
+
+
+
+ Expect.equals((dynamic).toString(), 'dynamic');
+}
diff --git a/tests/language_2/first_class_types_literals_runtime_2_test.dart b/tests/language_2/first_class_types_literals_runtime_2_test.dart
new file mode 100644
index 0000000..e5c8442
--- /dev/null
+++ b/tests/language_2/first_class_types_literals_runtime_2_test.dart
@@ -0,0 +1,67 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+class C<T, U, V> {}
+
+class D {}
+
+typedef int Foo(bool b);
+
+sameType(a, b) {
+ Expect.equals(a.runtimeType, b.runtimeType);
+}
+
+main() {
+ void foo(a) {}
+
+ // Test that literals can be used in different contexts.
+ [int];
+ ([int]);
+ foo([int]);
+ [int].length;
+ ({1: int});
+ foo({1: int});
+ ({1: int}).keys;
+
+ // Test type literals.
+ Expect.equals(int, int);
+ Expect.notEquals(int, num);
+ Expect.equals(Foo, Foo);
+ Expect.equals(dynamic, dynamic);
+
+ // Test that class literals return instances of Type.
+ Expect.isTrue((D).runtimeType is Type);
+ Expect.isTrue((dynamic).runtimeType is Type);
+
+ // Test that types from runtimeType and literals agree.
+ Expect.equals(int, 1.runtimeType);
+ Expect.equals(String, 'hest'.runtimeType);
+ Expect.equals(double, (0.5).runtimeType);
+ Expect.equals(bool, true.runtimeType);
+ Expect.equals(Object, Object().runtimeType);
+
+ Expect.equals(D, new D().runtimeType);
+
+ // runtimeType on type is idempotent.
+ Expect.equals((D).runtimeType, (D).runtimeType.runtimeType);
+
+ // Test that operator calls on class literals go to Type.
+
+
+
+
+
+
+
+
+
+
+
+ Expect.equals((dynamic).toString(), 'dynamic');
+}
diff --git a/tests/language_2/first_class_types_literals_runtime_test.dart b/tests/language_2/first_class_types_literals_runtime_test.dart
new file mode 100644
index 0000000..3df083a
--- /dev/null
+++ b/tests/language_2/first_class_types_literals_runtime_test.dart
@@ -0,0 +1,67 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+class C<T, U, V> {}
+
+class D {}
+
+typedef int Foo(bool b);
+
+sameType(a, b) {
+ Expect.equals(a.runtimeType, b.runtimeType);
+}
+
+main() {
+ void foo(a) {}
+
+ // Test that literals can be used in different contexts.
+ [int];
+ ([int]);
+ foo([int]);
+ [int].length;
+ ({1: int});
+ foo({1: int});
+ ({1: int}).keys;
+
+ // Test type literals.
+ Expect.equals(int, int);
+ Expect.notEquals(int, num);
+ Expect.equals(Foo, Foo);
+ Expect.equals(dynamic, dynamic);
+
+ // Test that class literals return instances of Type.
+ Expect.isTrue((D).runtimeType is Type);
+ Expect.isTrue((dynamic).runtimeType is Type);
+
+ // Test that types from runtimeType and literals agree.
+ Expect.equals(int, 1.runtimeType);
+ Expect.equals(String, 'hest'.runtimeType);
+ Expect.equals(double, (0.5).runtimeType);
+ Expect.equals(bool, true.runtimeType);
+ Expect.equals(Object, Object().runtimeType);
+
+
+
+ // runtimeType on type is idempotent.
+ Expect.equals((D).runtimeType, (D).runtimeType.runtimeType);
+
+ // Test that operator calls on class literals go to Type.
+
+
+
+
+
+
+
+
+
+
+
+ Expect.equals((dynamic).toString(), 'dynamic');
+}
diff --git a/tests/language_2/first_class_types_literals_test.dart b/tests/language_2/first_class_types_literals_test.dart
index ced302f..e256332 100644
--- a/tests/language_2/first_class_types_literals_test.dart
+++ b/tests/language_2/first_class_types_literals_test.dart
@@ -42,23 +42,59 @@
Expect.equals(double, (0.5).runtimeType);
Expect.equals(bool, true.runtimeType);
Expect.equals(Object, Object().runtimeType);
- Expect.equals(C, new C().runtimeType); // //# 01: ok
- Expect.equals(D, new D().runtimeType); // //# 02: ok
+ Expect.equals(C, new C().runtimeType);
+ Expect.equals(D, new D().runtimeType);
// runtimeType on type is idempotent.
Expect.equals((D).runtimeType, (D).runtimeType.runtimeType);
// Test that operator calls on class literals go to Type.
- Expect.throwsNoSuchMethodError(() => C = 1); //# 03: compile-time error
- Expect.throwsNoSuchMethodError(() => C++); //# 04: compile-time error
- Expect.throwsNoSuchMethodError(() => C + 1); //# 05: compile-time error
- Expect.throwsNoSuchMethodError(() => C[2]); //# 06: compile-time error
- Expect.throwsNoSuchMethodError(() => C[2] = 'hest'); //# 07: compile-time error
- Expect.throwsNoSuchMethodError(() => dynamic = 1); //# 08: compile-time error
- Expect.throwsNoSuchMethodError(() => dynamic++); //# 09: compile-time error
- Expect.throwsNoSuchMethodError(() => dynamic + 1); //# 10: compile-time error
- Expect.throwsNoSuchMethodError(() => dynamic[2]); //# 11: compile-time error
- Expect.throwsNoSuchMethodError(() => dynamic[2] = 'hest'); //# 12: compile-time error
+ Expect.throwsNoSuchMethodError(() => C = 1);
+ // ^
+ // [analyzer] STATIC_WARNING.ASSIGNMENT_TO_TYPE
+ // [cfe] Setter not found: 'C'.
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ Expect.throwsNoSuchMethodError(() => C++);
+ // ^
+ // [analyzer] STATIC_WARNING.ASSIGNMENT_TO_TYPE
+ // [cfe] Setter not found: 'C'.
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ Expect.throwsNoSuchMethodError(() => C + 1);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '+' isn't defined for the class 'Type'.
+ Expect.throwsNoSuchMethodError(() => C[2]);
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '[]' isn't defined for the class 'Type'.
+ Expect.throwsNoSuchMethodError(() => C[2] = 'hest');
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '[]=' isn't defined for the class 'Type'.
+ Expect.throwsNoSuchMethodError(() => dynamic = 1);
+ // ^
+ // [cfe] Setter not found: 'dynamic'.
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ Expect.throwsNoSuchMethodError(() => dynamic++);
+ // ^
+ // [cfe] Setter not found: 'dynamic'.
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ Expect.throwsNoSuchMethodError(() => dynamic + 1);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '+' isn't defined for the class 'Type'.
+ Expect.throwsNoSuchMethodError(() => dynamic[2]);
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '[]' isn't defined for the class 'Type'.
+ Expect.throwsNoSuchMethodError(() => dynamic[2] = 'hest');
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '[]=' isn't defined for the class 'Type'.
Expect.equals((dynamic).toString(), 'dynamic');
}
diff --git a/tests/language_2/for_runtime_test.dart b/tests/language_2/for_runtime_test.dart
new file mode 100644
index 0000000..9de889f
--- /dev/null
+++ b/tests/language_2/for_runtime_test.dart
@@ -0,0 +1,93 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Dart test program for testing for statement.
+
+import "package:expect/expect.dart";
+
+class Helper {
+ static int f1() {
+ for (;;) return 1;
+ }
+
+ static int f2(var n) {
+ int i = 0;
+ for (; i < n; i++);
+ return i;
+ }
+
+ static int f3(int n) {
+ int i = 0;
+ for (int j = 0; j < n; j++) i = i + j + 1;
+ return i;
+ }
+
+ static int f4(n) {
+ int i = 0;
+ for (bool stop = false; (i < n) && !stop; i++) {
+ if (i >= 5) {
+ stop = true;
+ }
+ }
+ return i;
+ }
+
+ static var status;
+ static void f5() {
+ status = 0;
+ for (var stop = false;;) {
+ if (stop) {
+ break;
+ } else {
+ stop = true;
+ continue;
+ }
+ }
+ status = 1;
+ }
+
+ static int f6() {
+ // Verify that side effects in the condition are visible after the loop.
+ int i = 0;
+ for (; ++i < 3;) {}
+ return i;
+ }
+}
+
+class ForTest {
+ static testMain() {
+ Expect.equals(1, Helper.f1());
+ Expect.equals(0, Helper.f2(-1));
+ Expect.equals(0, Helper.f2(0));
+ Expect.equals(10, Helper.f2(10));
+ Expect.equals(0, Helper.f3(-1));
+ Expect.equals(0, Helper.f3(0));
+ Expect.equals(1, Helper.f3(1));
+ Expect.equals(3, Helper.f3(2));
+ Expect.equals(6, Helper.f3(3));
+ Expect.equals(10, Helper.f3(4));
+ Expect.equals(0, Helper.f4(-1));
+ Expect.equals(0, Helper.f4(0));
+ Expect.equals(1, Helper.f4(1));
+ Expect.equals(6, Helper.f4(6));
+ Expect.equals(6, Helper.f4(10));
+
+ Helper.f5();
+ Expect.equals(1, Helper.status);
+
+ Expect.equals(3, Helper.f6());
+ }
+}
+
+main() {
+ ForTest.testMain();
+ testShadowLocal();
+}
+
+void testShadowLocal() {
+ List<int> x = [1, 2, 3];
+
+}
diff --git a/tests/language_2/for_test.dart b/tests/language_2/for_test.dart
index 0feac17..375fa78 100644
--- a/tests/language_2/for_test.dart
+++ b/tests/language_2/for_test.dart
@@ -86,5 +86,7 @@
void testShadowLocal() {
List<int> x = [1, 2, 3];
- for (var x = x;;) break; //# 01: compile-time error
+ for (var x = x;;) break;
+ // ^
+ // [cfe] Can't declare 'x' because it was already used in this scope.
}
diff --git a/tests/language_2/function_malformed_result_type_runtime_test.dart b/tests/language_2/function_malformed_result_type_runtime_test.dart
new file mode 100644
index 0000000..02b26b4
--- /dev/null
+++ b/tests/language_2/function_malformed_result_type_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// Dart test for a function with a malformed result type.
+
+import "package:expect/expect.dart";
+
+class C<T, U> {}
+
+main() {
+
+}
diff --git a/tests/language_2/function_malformed_result_type_test.dart b/tests/language_2/function_malformed_result_type_test.dart
index 7cb2315..3b0257b 100644
--- a/tests/language_2/function_malformed_result_type_test.dart
+++ b/tests/language_2/function_malformed_result_type_test.dart
@@ -9,5 +9,8 @@
class C<T, U> {}
main() {
- C<int> f() => null; //# 00: compile-time error
+ C<int> f() => null;
+//^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 2 type arguments.
}
diff --git a/tests/language_2/function_type_alias6_runtime_test.dart b/tests/language_2/function_type_alias6_runtime_test.dart
new file mode 100644
index 0000000..7b54ee4
--- /dev/null
+++ b/tests/language_2/function_type_alias6_runtime_test.dart
@@ -0,0 +1,31 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Dart test for legally self referencing function type alias.
+
+import "package:expect/expect.dart";
+
+typedef F(
+ List
+
+ x);
+
+typedef D C();
+
+class D {
+ C foo() {}
+ D bar() {}
+}
+
+main() {
+ var f = (List x) {};
+ Expect.isTrue(f is F);
+ var g = (List<F> x) {};
+ Expect.isFalse(g is F);
+ var d = new D();
+ Expect.isTrue(d.foo is! C);
+ Expect.isTrue(d.bar is C);
+}
diff --git a/tests/language_2/function_type_alias6_test.dart b/tests/language_2/function_type_alias6_test.dart
index 4c5a5a6..8a27555 100644
--- a/tests/language_2/function_type_alias6_test.dart
+++ b/tests/language_2/function_type_alias6_test.dart
@@ -5,10 +5,11 @@
import "package:expect/expect.dart";
-typedef F(
- List
- <F> //# 00: compile-time error
- x);
+typedef F(List<F> x);
+// [error line 8, column 1, length 21]
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
+// ^
+// [cfe] The typedef 'F' has a reference to itself.
typedef D C();
diff --git a/tests/language_2/function_type_alias9_runtime_test.dart b/tests/language_2/function_type_alias9_runtime_test.dart
new file mode 100644
index 0000000..366a477
--- /dev/null
+++ b/tests/language_2/function_type_alias9_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Dart test for legally self referencing function type alias.
+
+typedef void F(
+ List
+
+ l);
+typedef void G(List<F> l);
+
+main() {
+ F foo(G g) => g;
+ foo(null);
+}
diff --git a/tests/language_2/function_type_alias9_test.dart b/tests/language_2/function_type_alias9_test.dart
index 6178ab1..d7e4c1f 100644
--- a/tests/language_2/function_type_alias9_test.dart
+++ b/tests/language_2/function_type_alias9_test.dart
@@ -3,13 +3,18 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for legally self referencing function type alias.
-typedef void F(
- List
- <G> //# 00: compile-time error
- l);
+typedef void F(List<G> l);
+// [error line 6, column 1, length 26]
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
+// ^
+// [cfe] The typedef 'F' has a reference to itself.
typedef void G(List<F> l);
+// [error line 11, column 1, length 26]
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
main() {
F foo(G g) => g;
+ // ^
+ // [cfe] A value of type 'void Function(List<invalid-type>)' can't be assigned to a variable of type 'void Function(List<void Function(List<invalid-type>)>)'.
foo(null);
}
diff --git a/tests/language_2/function_type_call_getter2_runtime_test.dart b/tests/language_2/function_type_call_getter2_runtime_test.dart
new file mode 100644
index 0000000..689328b
--- /dev/null
+++ b/tests/language_2/function_type_call_getter2_runtime_test.dart
@@ -0,0 +1,76 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ final call = null;
+}
+
+class B {
+ get call => null;
+}
+
+class C {
+ set call(x) {}
+}
+
+typedef int F(String str);
+
+main() {
+ A a = new A();
+ B b = new B();
+ C c = new C();
+
+ final
+
+ a2 = a;
+
+ final
+
+ a3 = a;
+
+ final
+
+ b2 = b;
+
+ final
+
+ b3 = b;
+
+ final
+
+ c2 = c;
+
+ final
+
+ c3 = c;
+
+ Expect.throwsTypeError(() {
+ Function a4 = a as dynamic;
+ });
+
+ Expect.throwsTypeError(() {
+ F a5 = a as dynamic;
+ });
+
+ Expect.throwsTypeError(() {
+ Function b4 = b as dynamic;
+ });
+
+ Expect.throwsTypeError(() {
+ F b5 = b as dynamic;
+ });
+
+ Expect.throwsTypeError(() {
+ Function c4 = c as dynamic;
+ });
+
+ Expect.throwsTypeError(() {
+ F c5 = c as dynamic;
+ });
+}
diff --git a/tests/language_2/function_type_call_getter2_test.dart b/tests/language_2/function_type_call_getter2_test.dart
index 5be3366..c52cb9e 100644
--- a/tests/language_2/function_type_call_getter2_test.dart
+++ b/tests/language_2/function_type_call_getter2_test.dart
@@ -24,28 +24,46 @@
C c = new C();
final
- Function //# 00: compile-time error
+ Function
a2 = a;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'A' can't be assigned to a variable of type 'Function'.
final
- F //# 01: compile-time error
+ F
a3 = a;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'A' can't be assigned to a variable of type 'int Function(String)'.
final
- Function //# 02: compile-time error
+ Function
b2 = b;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'B' can't be assigned to a variable of type 'Function'.
final
- F //# 03: compile-time error
+ F
b3 = b;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'B' can't be assigned to a variable of type 'int Function(String)'.
final
- Function //# 04: compile-time error
+ Function
c2 = c;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'C' can't be assigned to a variable of type 'Function'.
final
- F //# 05: compile-time error
+ F
c3 = c;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'C' can't be assigned to a variable of type 'int Function(String)'.
Expect.throwsTypeError(() {
Function a4 = a as dynamic;
diff --git a/tests/language_2/generic_constructor_mixin2_runtime_test.dart b/tests/language_2/generic_constructor_mixin2_runtime_test.dart
new file mode 100644
index 0000000..d85d5d0
--- /dev/null
+++ b/tests/language_2/generic_constructor_mixin2_runtime_test.dart
@@ -0,0 +1,27 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// Test that parameter types types are checked correctly in the face of
+// mixin application upon a generic constructor.
+
+import 'dynamic_type_helper.dart';
+
+class A<X> {
+ A(X x);
+}
+
+class B {}
+
+class C {}
+
+class D<Y> = A<Y> with B, C;
+
+void main() {
+ var v = 0;
+ checkNoDynamicTypeError(() => new D<int>(v));
+
+}
diff --git a/tests/language_2/generic_constructor_mixin2_test.dart b/tests/language_2/generic_constructor_mixin2_test.dart
index 7a7095b..13b2eed 100644
--- a/tests/language_2/generic_constructor_mixin2_test.dart
+++ b/tests/language_2/generic_constructor_mixin2_test.dart
@@ -20,5 +20,8 @@
void main() {
var v = 0;
checkNoDynamicTypeError(() => new D<int>(v));
- checkDynamicTypeError(() => new D<String>(v)); //# 01: compile-time error
+ checkDynamicTypeError(() => new D<String>(v));
+ // ^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'int' can't be assigned to the parameter type 'String'.
}
diff --git a/tests/language_2/generic_constructor_mixin3_runtime_test.dart b/tests/language_2/generic_constructor_mixin3_runtime_test.dart
new file mode 100644
index 0000000..7fd1c1a
--- /dev/null
+++ b/tests/language_2/generic_constructor_mixin3_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// Test that parameter types types are checked correctly in the face of
+// mixin application upon a generic constructor.
+
+import 'dynamic_type_helper.dart';
+
+class A<X> {
+ A(X x);
+}
+
+class B {}
+
+class C1 = A<int> with B;
+class C2 = A<String> with B;
+
+void main() {
+ var v = 0;
+ checkNoDynamicTypeError(() => new C1(v));
+
+}
diff --git a/tests/language_2/generic_constructor_mixin3_test.dart b/tests/language_2/generic_constructor_mixin3_test.dart
index b0bb536..5e1a90d 100644
--- a/tests/language_2/generic_constructor_mixin3_test.dart
+++ b/tests/language_2/generic_constructor_mixin3_test.dart
@@ -19,5 +19,8 @@
void main() {
var v = 0;
checkNoDynamicTypeError(() => new C1(v));
- checkDynamicTypeError(() => new C2(v)); //# 01: compile-time error
+ checkDynamicTypeError(() => new C2(v));
+ // ^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'int' can't be assigned to the parameter type 'String'.
}
diff --git a/tests/language_2/generic_constructor_mixin_runtime_test.dart b/tests/language_2/generic_constructor_mixin_runtime_test.dart
new file mode 100644
index 0000000..11eae83
--- /dev/null
+++ b/tests/language_2/generic_constructor_mixin_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// Test that parameter types types are checked correctly in the face of
+// mixin application upon a generic constructor.
+
+import 'dynamic_type_helper.dart';
+
+class A<X> {
+ A(X x);
+}
+
+class B {}
+
+class C<Y> = A<Y> with B;
+
+void main() {
+ var v = 0;
+ checkNoDynamicTypeError(() => new C<int>(v));
+
+}
diff --git a/tests/language_2/generic_constructor_mixin_test.dart b/tests/language_2/generic_constructor_mixin_test.dart
index 99ff5ac..4812f12 100644
--- a/tests/language_2/generic_constructor_mixin_test.dart
+++ b/tests/language_2/generic_constructor_mixin_test.dart
@@ -18,5 +18,8 @@
void main() {
var v = 0;
checkNoDynamicTypeError(() => new C<int>(v));
- checkDynamicTypeError(() => new C<String>(v)); //# 01: compile-time error
-}
\ No newline at end of file
+ checkDynamicTypeError(() => new C<String>(v));
+ // ^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'int' can't be assigned to the parameter type 'String'.
+}
diff --git a/tests/language_2/generic_field_mixin6_runtime_test.dart b/tests/language_2/generic_field_mixin6_runtime_test.dart
new file mode 100644
index 0000000..7fa746b
--- /dev/null
+++ b/tests/language_2/generic_field_mixin6_runtime_test.dart
@@ -0,0 +1,31 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// Test that generic types in mixins are handled.
+
+import 'package:expect/expect.dart';
+
+class M<T> {
+
+ T field2 = 0 as dynamic;
+}
+
+class A<U> {}
+
+class C1<V> = Object with M<V>;
+class C2 = Object with M<int>;
+class C3 = Object with M<String>;
+
+main() {
+ // no error: 0 is an int
+ new C1<int>();
+ new C2();
+
+ // type error: 0 is not a string
+ Expect.throwsTypeError(() => new C1<String>());
+ Expect.throws(() => new C3());
+}
diff --git a/tests/language_2/generic_field_mixin6_test.dart b/tests/language_2/generic_field_mixin6_test.dart
index e69242d..47a3678 100644
--- a/tests/language_2/generic_field_mixin6_test.dart
+++ b/tests/language_2/generic_field_mixin6_test.dart
@@ -7,7 +7,10 @@
import 'package:expect/expect.dart';
class M<T> {
- T field1 = 0; //# 01: compile-time error
+ T field1 = 0;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'T'.
T field2 = 0 as dynamic;
}
diff --git a/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_1_test.dart b/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_1_test.dart
new file mode 100644
index 0000000..568b6c7
--- /dev/null
+++ b/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_1_test.dart
@@ -0,0 +1,33 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test of the subtype relationship that includes parametrized typedefs and
+// invariant occurrences of types.
+
+typedef H<X> = void Function<Y extends X>();
+
+class A {}
+
+class B extends A {}
+
+class C extends B {}
+
+void foo(H<A> ha, H<B> hb, H<C> hc) {
+ H<A> haa = ha;
+
+
+
+
+
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_2_test.dart b/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_2_test.dart
new file mode 100644
index 0000000..c3226fb
--- /dev/null
+++ b/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_2_test.dart
@@ -0,0 +1,33 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test of the subtype relationship that includes parametrized typedefs and
+// invariant occurrences of types.
+
+typedef H<X> = void Function<Y extends X>();
+
+class A {}
+
+class B extends A {}
+
+class C extends B {}
+
+void foo(H<A> ha, H<B> hb, H<C> hc) {
+
+
+
+
+
+ H<B> hbb = hb;
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_3_test.dart b/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_3_test.dart
new file mode 100644
index 0000000..fbdd29a
--- /dev/null
+++ b/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_3_test.dart
@@ -0,0 +1,33 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test of the subtype relationship that includes parametrized typedefs and
+// invariant occurrences of types.
+
+typedef H<X> = void Function<Y extends X>();
+
+class A {}
+
+class B extends A {}
+
+class C extends B {}
+
+void foo(H<A> ha, H<B> hb, H<C> hc) {
+
+
+
+
+
+
+
+
+
+
+ H<C> hcc = hc;
+}
+
+main() {}
diff --git a/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_test.dart b/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_test.dart
new file mode 100644
index 0000000..9749428
--- /dev/null
+++ b/tests/language_2/generic_function_subtype_parametrized_typedef_runtime_test.dart
@@ -0,0 +1,33 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test of the subtype relationship that includes parametrized typedefs and
+// invariant occurrences of types.
+
+typedef H<X> = void Function<Y extends X>();
+
+class A {}
+
+class B extends A {}
+
+class C extends B {}
+
+void foo(H<A> ha, H<B> hb, H<C> hc) {
+
+
+
+
+
+
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/generic_function_subtype_parametrized_typedef_test.dart b/tests/language_2/generic_function_subtype_parametrized_typedef_test.dart
index a1dbfb8..a1dd791 100644
--- a/tests/language_2/generic_function_subtype_parametrized_typedef_test.dart
+++ b/tests/language_2/generic_function_subtype_parametrized_typedef_test.dart
@@ -14,17 +14,35 @@
class C extends B {}
void foo(H<A> ha, H<B> hb, H<C> hc) {
- H<A> haa = ha; //# 01: ok
- H<A> hab = hb; //# 02: compile-time error
- H<A> hac = hc; //# 03: compile-time error
+ H<A> haa = ha;
+ H<A> hab = hb;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'void Function<Y extends B>()' can't be assigned to a variable of type 'void Function<Y extends A>()'.
+ H<A> hac = hc;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'void Function<Y extends C>()' can't be assigned to a variable of type 'void Function<Y extends A>()'.
- H<B> hba = ha; //# 04: compile-time error
- H<B> hbb = hb; //# 05: ok
- H<B> hbc = hc; //# 06: compile-time error
+ H<B> hba = ha;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'void Function<Y extends A>()' can't be assigned to a variable of type 'void Function<Y extends B>()'.
+ H<B> hbb = hb;
+ H<B> hbc = hc;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'void Function<Y extends C>()' can't be assigned to a variable of type 'void Function<Y extends B>()'.
- H<C> hca = ha; //# 07: compile-time error
- H<C> hcb = hb; //# 08: compile-time error
- H<C> hcc = hc; //# 09: ok
+ H<C> hca = ha;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'void Function<Y extends A>()' can't be assigned to a variable of type 'void Function<Y extends C>()'.
+ H<C> hcb = hb;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'void Function<Y extends B>()' can't be assigned to a variable of type 'void Function<Y extends C>()'.
+ H<C> hcc = hc;
}
main() {}
diff --git a/tests/language_2/generic_function_subtype_runtime_1_test.dart b/tests/language_2/generic_function_subtype_runtime_1_test.dart
new file mode 100644
index 0000000..1153373
--- /dev/null
+++ b/tests/language_2/generic_function_subtype_runtime_1_test.dart
@@ -0,0 +1,24 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Simple test of the subtype relationship on generic function types.
+
+typedef F1 = void Function<X1 extends num>();
+typedef F2 = void Function<X2 extends String>();
+
+void f1<Y1 extends num>() {}
+void f2<Y2 extends String>() {}
+
+void foo() {
+ F1 f11 = f1;
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/generic_function_subtype_runtime_2_test.dart b/tests/language_2/generic_function_subtype_runtime_2_test.dart
new file mode 100644
index 0000000..44aeb53
--- /dev/null
+++ b/tests/language_2/generic_function_subtype_runtime_2_test.dart
@@ -0,0 +1,24 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Simple test of the subtype relationship on generic function types.
+
+typedef F1 = void Function<X1 extends num>();
+typedef F2 = void Function<X2 extends String>();
+
+void f1<Y1 extends num>() {}
+void f2<Y2 extends String>() {}
+
+void foo() {
+
+
+
+
+ F2 f22 = f2;
+}
+
+main() {}
diff --git a/tests/language_2/generic_function_subtype_runtime_test.dart b/tests/language_2/generic_function_subtype_runtime_test.dart
new file mode 100644
index 0000000..eb7163a
--- /dev/null
+++ b/tests/language_2/generic_function_subtype_runtime_test.dart
@@ -0,0 +1,24 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Simple test of the subtype relationship on generic function types.
+
+typedef F1 = void Function<X1 extends num>();
+typedef F2 = void Function<X2 extends String>();
+
+void f1<Y1 extends num>() {}
+void f2<Y2 extends String>() {}
+
+void foo() {
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/generic_function_subtype_test.dart b/tests/language_2/generic_function_subtype_test.dart
index de3717d..28cb90a 100644
--- a/tests/language_2/generic_function_subtype_test.dart
+++ b/tests/language_2/generic_function_subtype_test.dart
@@ -11,11 +11,17 @@
void f2<Y2 extends String>() {}
void foo() {
- F1 f11 = f1; //# 01: ok
- F1 f12 = f2; //# 02: compile-time error
+ F1 f11 = f1;
+ F1 f12 = f2;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'void Function<Y2 extends String>()' can't be assigned to a variable of type 'void Function<X1 extends num>()'.
- F2 f21 = f1; //# 03: compile-time error
- F2 f22 = f2; //# 04: ok
+ F2 f21 = f1;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'void Function<Y1 extends num>()' can't be assigned to a variable of type 'void Function<X2 extends String>()'.
+ F2 f22 = f2;
}
main() {}
diff --git a/tests/language_2/generic_function_type_as_type_argument_runtime_1_test.dart b/tests/language_2/generic_function_type_as_type_argument_runtime_1_test.dart
new file mode 100644
index 0000000..e0074f5
--- /dev/null
+++ b/tests/language_2/generic_function_type_as_type_argument_runtime_1_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+//
+// VMOptions=--reify-generic-functions
+
+import "package:expect/expect.dart";
+
+T foo<T>(T i) => i;
+
+void main() {
+ Expect.equals(42, foo<int>(42));
+
+ var bar = foo;
+ Expect.equals(42, bar<int>(42));
+
+ // Generic function types are not allowed as type arguments.
+
+
+ // Type inference must also give an error.
+
+
+ // No error if illegal type cannot be inferred.
+ var dynamicList = <dynamic>[foo];
+ Expect.equals(42, (dynamicList[0] as T Function<T>(T))<int>(42));
+}
diff --git a/tests/language_2/generic_function_type_as_type_argument_runtime_test.dart b/tests/language_2/generic_function_type_as_type_argument_runtime_test.dart
new file mode 100644
index 0000000..0ad5dad
--- /dev/null
+++ b/tests/language_2/generic_function_type_as_type_argument_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+//
+// VMOptions=--reify-generic-functions
+
+import "package:expect/expect.dart";
+
+T foo<T>(T i) => i;
+
+void main() {
+ Expect.equals(42, foo<int>(42));
+
+ var bar = foo;
+ Expect.equals(42, bar<int>(42));
+
+ // Generic function types are not allowed as type arguments.
+
+
+ // Type inference must also give an error.
+
+
+ // No error if illegal type cannot be inferred.
+
+
+}
diff --git a/tests/language_2/generic_function_type_as_type_argument_test.dart b/tests/language_2/generic_function_type_as_type_argument_test.dart
index 23bc534..c59dce7 100644
--- a/tests/language_2/generic_function_type_as_type_argument_test.dart
+++ b/tests/language_2/generic_function_type_as_type_argument_test.dart
@@ -15,12 +15,20 @@
Expect.equals(42, bar<int>(42));
// Generic function types are not allowed as type arguments.
- List<T Function<T>(T)> typedList = <T Function<T>(T)>[foo]; //# 01: compile-time error
+ List<T Function<T>(T)> typedList = <T Function<T>(T)>[foo];
+ // ^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.GENERIC_FUNCTION_TYPE_CANNOT_BE_TYPE_ARGUMENT
+ // ^
+ // [cfe] A generic function type can't be used as a type argument.
// Type inference must also give an error.
- var inferredList = [foo]; //# 02: compile-time error
+ var inferredList = [foo];
+ // ^
+ // [cfe] Generic function type 'T Function<T>(T)' inferred as a type argument.
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
// No error if illegal type cannot be inferred.
- var dynamicList = <dynamic>[foo]; //# 03: ok
- Expect.equals(42, (dynamicList[0] as T Function<T>(T))<int>(42)); //# 03: continued
+ var dynamicList = <dynamic>[foo];
+ Expect.equals(42, (dynamicList[0] as T Function<T>(T))<int>(42));
}
diff --git a/tests/language_2/generic_function_typedef2_runtime_test.dart b/tests/language_2/generic_function_typedef2_runtime_test.dart
new file mode 100644
index 0000000..195bc41
--- /dev/null
+++ b/tests/language_2/generic_function_typedef2_runtime_test.dart
@@ -0,0 +1,43 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+// Dart test for a function type test that cannot be eliminated at compile time.
+
+import "package:expect/expect.dart";
+
+class A {}
+
+typedef int F();
+
+
+
+
+
+typedef K = Function(
+ Function<A>(A
+
+ ));
+typedef L = Function(
+ {
+
+ bool
+
+ x});
+
+typedef M = Function(
+ {
+
+ bool
+
+ int});
+
+foo({bool int}) {}
+main() {
+ bool b = true;
+ Expect.isFalse(b is L);
+ Expect.isFalse(b is M);
+ Expect.isTrue(foo is M);
+}
diff --git a/tests/language_2/generic_function_typedef2_test.dart b/tests/language_2/generic_function_typedef2_test.dart
index 438dfaf..5a3207f 100644
--- a/tests/language_2/generic_function_typedef2_test.dart
+++ b/tests/language_2/generic_function_typedef2_test.dart
@@ -9,27 +9,38 @@
typedef int F();
-typedef G = F; //# 00: syntax error
-typedef H = int; //# 01: syntax error
-typedef I = A; //# 02: syntax error
-typedef J = List<int>; //# 03: syntax error
-typedef K = Function(
- Function<A>(A
- <int> // //# 04: compile-time error
- ));
-typedef L = Function(
- {
- /* // //# 05: syntax error
- bool
- */ // //# 05: continued
- x});
+typedef G = F;
+// ^
+// [analyzer] SYNTACTIC_ERROR.INVALID_GENERIC_FUNCTION_TYPE
+// [cfe] Can't create typedef from non-function type.
+typedef H = int;
+// ^
+// [analyzer] SYNTACTIC_ERROR.INVALID_GENERIC_FUNCTION_TYPE
+// [cfe] Can't create typedef from non-function type.
+typedef I = A;
+// ^
+// [analyzer] SYNTACTIC_ERROR.INVALID_GENERIC_FUNCTION_TYPE
+// [cfe] Can't create typedef from non-function type.
+typedef J = List<int>;
+// ^
+// [analyzer] SYNTACTIC_ERROR.INVALID_GENERIC_FUNCTION_TYPE
+// [cfe] Can't create typedef from non-function type.
+typedef K = Function(Function<A>(A<int>));
+// ^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Can't use type arguments with type variable 'A'.
+typedef L = Function({x});
+// ^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+// [cfe] Type 'x' not found.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got '}'.
-typedef M = Function(
- {
- /* // //# 06: syntax error
- bool
- */ // //# 06: continued
- int});
+typedef M = Function({int});
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected an identifier, but got '}'.
foo({bool int}) {}
main() {
diff --git a/tests/language_2/generic_metadata_runtime_1_test.dart b/tests/language_2/generic_metadata_runtime_1_test.dart
new file mode 100644
index 0000000..f411bd2
--- /dev/null
+++ b/tests/language_2/generic_metadata_runtime_1_test.dart
@@ -0,0 +1,17 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2016, 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.
+
+// Check that annotations cannot use type arguments, but can be raw.
+
+class C<T> {
+ const C();
+}
+
+@C()
+
+
+main() {}
diff --git a/tests/language_2/generic_metadata_runtime_test.dart b/tests/language_2/generic_metadata_runtime_test.dart
new file mode 100644
index 0000000..bee4c44
--- /dev/null
+++ b/tests/language_2/generic_metadata_runtime_test.dart
@@ -0,0 +1,17 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2016, 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.
+
+// Check that annotations cannot use type arguments, but can be raw.
+
+class C<T> {
+ const C();
+}
+
+
+
+
+main() {}
diff --git a/tests/language_2/generic_metadata_test.dart b/tests/language_2/generic_metadata_test.dart
index 7109ab8..99c8fbc 100644
--- a/tests/language_2/generic_metadata_test.dart
+++ b/tests/language_2/generic_metadata_test.dart
@@ -8,7 +8,13 @@
const C();
}
-@C() //# 01: ok
-@C<dynamic>() //# 02: compile-time error
-@C<int>() //# 03: compile-time error
+@C()
+@C<dynamic>()
+//^
+// [analyzer] SYNTACTIC_ERROR.ANNOTATION_WITH_TYPE_ARGUMENTS
+// [cfe] An annotation (metadata) can't use type arguments.
+@C<int>()
+//^
+// [analyzer] SYNTACTIC_ERROR.ANNOTATION_WITH_TYPE_ARGUMENTS
+// [cfe] An annotation (metadata) can't use type arguments.
main() {}
diff --git a/tests/language_2/generic_methods_generic_function_result_runtime_test.dart b/tests/language_2/generic_methods_generic_function_result_runtime_test.dart
new file mode 100644
index 0000000..e382965
--- /dev/null
+++ b/tests/language_2/generic_methods_generic_function_result_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// Verify that function type parameter S can be resolved in bar's result type.
+// Verify that generic function types are not allowed as type arguments.
+
+import "package:expect/expect.dart";
+
+int foo
+
+ (int i, int j) => i + j;
+
+List<int Function
+
+ (S, int)> bar<S extends int>() {
+ return <int Function
+
+ (S, int)>[foo, foo];
+}
+
+void main() {
+ var list = bar<int>();
+ print(list[0].runtimeType);
+ Expect.equals(123, list[1](100, 23));
+}
diff --git a/tests/language_2/generic_methods_generic_function_result_test.dart b/tests/language_2/generic_methods_generic_function_result_test.dart
index 3a391ec..41d4742 100644
--- a/tests/language_2/generic_methods_generic_function_result_test.dart
+++ b/tests/language_2/generic_methods_generic_function_result_test.dart
@@ -8,19 +8,21 @@
import "package:expect/expect.dart";
int foo
- <T> //# 01: continued
+ <T>
(int i, int j) => i + j;
-List<int Function
- <T> //# 01: compile-time error
- (S, int)> bar<S extends int>() {
- return <int Function
- <T> //# 01: continued
- (S, int)>[foo, foo];
+List<int Function<T>(S, int)> bar<S extends int>() {
+// ^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.GENERIC_FUNCTION_TYPE_CANNOT_BE_TYPE_ARGUMENT
+// ^
+// [cfe] A generic function type can't be used as a type argument.
+ return <int Function<T>(S, int)>[foo, foo];
}
void main() {
var list = bar<int>();
+ // ^
+ // [cfe] Generic function type 'int Function<T>(int, int)' inferred as a type argument.
print(list[0].runtimeType);
Expect.equals(123, list[1](100, 23));
}
diff --git a/tests/language_2/get_set_syntax_runtime_1_test.dart b/tests/language_2/get_set_syntax_runtime_1_test.dart
new file mode 100644
index 0000000..c64ac20
--- /dev/null
+++ b/tests/language_2/get_set_syntax_runtime_1_test.dart
@@ -0,0 +1,50 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+var get;
+
+
+
+var set;
+
+
+
+class C0 {
+ var get;
+
+
+
+ var set;
+
+
+}
+
+class C1 {
+ List get;
+ List get a => null;
+
+
+ List set;
+
+
+}
+
+class C2 {
+ List<int> get;
+ List<int> get a => null;
+
+
+ List<int> set;
+
+
+}
+
+main() {
+ new C0();
+ new C1();
+ new C2();
+}
diff --git a/tests/language_2/get_set_syntax_runtime_test.dart b/tests/language_2/get_set_syntax_runtime_test.dart
new file mode 100644
index 0000000..baf1437
--- /dev/null
+++ b/tests/language_2/get_set_syntax_runtime_test.dart
@@ -0,0 +1,50 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+
+
+
+
+
+
+
+
+class C0 {
+
+
+
+
+
+
+
+}
+
+class C1 {
+
+
+
+
+
+
+
+}
+
+class C2 {
+
+
+
+
+
+
+
+}
+
+main() {
+ new C0();
+ new C1();
+ new C2();
+}
diff --git a/tests/language_2/get_set_syntax_test.dart b/tests/language_2/get_set_syntax_test.dart
index b94aac82..e9789c6 100644
--- a/tests/language_2/get_set_syntax_test.dart
+++ b/tests/language_2/get_set_syntax_test.dart
@@ -2,42 +2,222 @@
// 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.
-var get; // //# ok: ok
-var get a; // //# 00: syntax error
-var get b, c; // //# 01: syntax error
+var get;
+var get a;
+// [error line 6, column 1, length 3]
+// [analyzer] SYNTACTIC_ERROR.VAR_RETURN_TYPE
+// [cfe] The return type can't be 'var'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+// [cfe] Expected a function body or '=>'.
+var get b, c;
+// [error line 13, column 1, length 3]
+// [analyzer] SYNTACTIC_ERROR.VAR_RETURN_TYPE
+// [cfe] The return type can't be 'var'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
+// [cfe] Expected '{' before this.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+// [cfe] Expected a declaration, but got ','.
+// ^
+// [cfe] Expected a function body, but got ','.
+// ^
+// [cfe] Expected a function body, but got '{'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
+// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
-var set; // //# ok: continued
-var set d; // //# 02: syntax error
-var set e, f; // //# 03: syntax error
+var set;
+var set d;
+// [error line 32, column 1, length 3]
+// [analyzer] SYNTACTIC_ERROR.VAR_RETURN_TYPE
+// [cfe] The return type can't be 'var'.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
+// [cfe] A function declaration needs an explicit list of parameters.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_PARAMETERS
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+// [cfe] A setter should have exactly one formal parameter.
+// ^
+// [cfe] Expected a function body or '=>'.
+var set e, f;
+// [error line 46, column 1, length 3]
+// [analyzer] SYNTACTIC_ERROR.VAR_RETURN_TYPE
+// [cfe] The return type can't be 'var'.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
+// [cfe] A function declaration needs an explicit list of parameters.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_PARAMETERS
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
+// [cfe] A setter should have exactly one formal parameter.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+// [cfe] Expected '{' before this.
+// ^
+// [cfe] Expected a declaration, but got ','.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
+// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
class C0 {
- var get; // //# ok: continued
- var get a; // //# 04: syntax error
- var get b, c; // //# 05: syntax error
+// ^
+// [cfe] The non-abstract class 'C0' is missing implementations for these members:
+ var get;
+ var get a;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.VAR_RETURN_TYPE
+// [cfe] The return type can't be 'var'.
+// ^^^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
+ var get b, c;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.VAR_RETURN_TYPE
+// [cfe] The return type can't be 'var'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_CLASS_MEMBER
+// [cfe] Expected '{' before this.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+// [cfe] Expected a class member, but got ','.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
+// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
- var set; // //# ok: continued
- var set d; // //# 06: syntax error
- var set e, f; // //# 07: syntax error
+ var set;
+ var set d;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.VAR_RETURN_TYPE
+// [cfe] The return type can't be 'var'.
+// ^^^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
+// ^
+// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
+// [cfe] A method declaration needs an explicit list of parameters.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_METHOD_PARAMETERS
+// ^
+// [cfe] A setter should have exactly one formal parameter.
+ var set e, f;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.VAR_RETURN_TYPE
+// [cfe] The return type can't be 'var'.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
+// [cfe] A method declaration needs an explicit list of parameters.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_METHOD_PARAMETERS
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_CLASS_MEMBER
+// [cfe] A setter should have exactly one formal parameter.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+// [cfe] Expected '{' before this.
+// ^
+// [cfe] Expected a class member, but got ','.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
+// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
}
class C1 {
- List get; // //# ok: continued
- List get a => null; // //# ok: continued
- List get b, c; // //# 09: syntax error
+ List get;
+ List get a => null;
+ List get b, c;
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_CLASS_MEMBER
+ // [cfe] Expected '{' before this.
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+ // [cfe] Expected a class member, but got ','.
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
+ // [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
- List set; // //# ok: continued
- List set d; // //# 10: syntax error
- List set e, f; // //# 11: syntax error
+ List set;
+ List set d;
+//^^^^
+// [analyzer] STATIC_WARNING.NON_VOID_RETURN_FOR_SETTER
+//^^^^^^^^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
+// ^
+// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
+// [cfe] A method declaration needs an explicit list of parameters.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_METHOD_PARAMETERS
+// ^
+// [cfe] A setter should have exactly one formal parameter.
+ List set e, f;
+//^^^^
+// [analyzer] STATIC_WARNING.NON_VOID_RETURN_FOR_SETTER
+// ^
+// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
+// [cfe] A method declaration needs an explicit list of parameters.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_METHOD_PARAMETERS
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_CLASS_MEMBER
+// [cfe] A setter should have exactly one formal parameter.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+// [cfe] Expected '{' before this.
+// ^
+// [cfe] Expected a class member, but got ','.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
+// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
}
class C2 {
- List<int> get; // //# ok: continued
- List<int> get a => null; //# ok: continued
- List<int> get b, c; // //# 13: syntax error
+ List<int> get;
+ List<int> get a => null;
+ List<int> get b, c;
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_CLASS_MEMBER
+ // [cfe] Expected '{' before this.
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+ // [cfe] Expected a class member, but got ','.
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
+ // [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
- List<int> set; // //# ok: continued
- List<int> set d; // //# 14: syntax error
- List<int> set e, f; // //# 15: syntax error
+ List<int> set;
+ List<int> set d;
+//^^^^^^^^^
+// [analyzer] STATIC_WARNING.NON_VOID_RETURN_FOR_SETTER
+//^^^^^^^^^^^^^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
+// ^
+// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
+// [cfe] A method declaration needs an explicit list of parameters.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_METHOD_PARAMETERS
+// ^
+// [cfe] A setter should have exactly one formal parameter.
+ List<int> set e, f;
+//^^^^^^^^^
+// [analyzer] STATIC_WARNING.NON_VOID_RETURN_FOR_SETTER
+// ^
+// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER
+// [cfe] A method declaration needs an explicit list of parameters.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_METHOD_PARAMETERS
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_CLASS_MEMBER
+// [cfe] A setter should have exactly one formal parameter.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+// [cfe] Expected '{' before this.
+// ^
+// [cfe] Expected a class member, but got ','.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
+// [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
}
main() {
diff --git a/tests/language_2/getter_no_setter2_runtime_test.dart b/tests/language_2/getter_no_setter2_runtime_test.dart
new file mode 100644
index 0000000..3e7567b
--- /dev/null
+++ b/tests/language_2/getter_no_setter2_runtime_test.dart
@@ -0,0 +1,38 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Verifies behavior with a static getter, but no field and no setter.
+
+import "package:expect/expect.dart";
+
+class Example {
+ static int _var = 1;
+ static int get nextVar => _var++;
+ Example() {
+
+
+ }
+ static test() {
+
+
+ }
+}
+
+class Example1 {
+ Example1(int i) {}
+}
+
+class Example2 extends Example1 {
+ static int _var = 1;
+ static int get nextVar => _var++;
+ Example2() : super(nextVar) {} // No 'this' in scope.
+}
+
+void main() {
+ Example x = new Example();
+ Example.test();
+ Example2 x2 = new Example2();
+}
diff --git a/tests/language_2/getter_no_setter2_test.dart b/tests/language_2/getter_no_setter2_test.dart
index b974031..778ce8f 100644
--- a/tests/language_2/getter_no_setter2_test.dart
+++ b/tests/language_2/getter_no_setter2_test.dart
@@ -9,12 +9,31 @@
static int _var = 1;
static int get nextVar => _var++;
Example() {
- nextVar++; //# 03: compile-time error
- this.nextVar++; //# 00: compile-time error
+ nextVar++;
+// ^^^^^^^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_NO_SETTER
+// [cfe] Setter not found: 'nextVar'.
+ this.nextVar++;
+ // ^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INSTANCE_ACCESS_TO_STATIC_MEMBER
+ // [cfe] The getter 'nextVar' isn't defined for the class 'Example'.
+ // ^^^^^^^
+ // [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_NO_SETTER
+ // [cfe] The setter 'nextVar' isn't defined for the class 'Example'.
}
static test() {
- nextVar++; // //# 01: compile-time error
- this.nextVar++; // //# 02: compile-time error
+ nextVar++;
+// ^^^^^^^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_NO_SETTER
+// [cfe] Setter not found: 'nextVar'.
+ this.nextVar++;
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_REFERENCE_TO_THIS
+// [cfe] Expected identifier, but got 'this'.
+// ^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.INSTANCE_ACCESS_TO_STATIC_MEMBER
+// ^^^^^^^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_NO_SETTER
}
}
diff --git a/tests/language_2/getter_no_setter_runtime_test.dart b/tests/language_2/getter_no_setter_runtime_test.dart
new file mode 100644
index 0000000..3e7567b
--- /dev/null
+++ b/tests/language_2/getter_no_setter_runtime_test.dart
@@ -0,0 +1,38 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Verifies behavior with a static getter, but no field and no setter.
+
+import "package:expect/expect.dart";
+
+class Example {
+ static int _var = 1;
+ static int get nextVar => _var++;
+ Example() {
+
+
+ }
+ static test() {
+
+
+ }
+}
+
+class Example1 {
+ Example1(int i) {}
+}
+
+class Example2 extends Example1 {
+ static int _var = 1;
+ static int get nextVar => _var++;
+ Example2() : super(nextVar) {} // No 'this' in scope.
+}
+
+void main() {
+ Example x = new Example();
+ Example.test();
+ Example2 x2 = new Example2();
+}
diff --git a/tests/language_2/getter_no_setter_test.dart b/tests/language_2/getter_no_setter_test.dart
index a641589..8d84129 100644
--- a/tests/language_2/getter_no_setter_test.dart
+++ b/tests/language_2/getter_no_setter_test.dart
@@ -9,12 +9,30 @@
static int _var = 1;
static int get nextVar => _var++;
Example() {
- nextVar = 1; //# 03: compile-time error
- this.nextVar = 1; //# 00: compile-time error
+ nextVar = 1;
+// ^^^^^^^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_NO_SETTER
+// [cfe] Setter not found: 'nextVar'.
+ this.nextVar = 1;
+ // ^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INSTANCE_ACCESS_TO_STATIC_MEMBER
+ // [cfe] The setter 'nextVar' isn't defined for the class 'Example'.
+ // ^^^^^^^
+ // [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_NO_SETTER
}
static test() {
- nextVar = 0; //# 01: compile-time error
- this.nextVar = 0; //# 02: compile-time error
+ nextVar = 0;
+// ^^^^^^^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_NO_SETTER
+// [cfe] Setter not found: 'nextVar'.
+ this.nextVar = 0;
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_REFERENCE_TO_THIS
+// [cfe] Expected identifier, but got 'this'.
+// ^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.INSTANCE_ACCESS_TO_STATIC_MEMBER
+// ^^^^^^^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_NO_SETTER
}
}
diff --git a/tests/language_2/getter_parameters_runtime_test.dart b/tests/language_2/getter_parameters_runtime_test.dart
new file mode 100644
index 0000000..f61f2fc
--- /dev/null
+++ b/tests/language_2/getter_parameters_runtime_test.dart
@@ -0,0 +1,30 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+//
+// Test that a getter has no parameters.
+
+get f1 => null;
+get f2
+
+ => null;
+get f3
+
+ => null;
+get f4
+
+ => null;
+get f5
+
+ => null;
+
+main() {
+ f1;
+ f2;
+ f3;
+ f4;
+ f5;
+}
diff --git a/tests/language_2/getter_parameters_test.dart b/tests/language_2/getter_parameters_test.dart
index de45b02..0ff6eac 100644
--- a/tests/language_2/getter_parameters_test.dart
+++ b/tests/language_2/getter_parameters_test.dart
@@ -6,16 +6,28 @@
get f1 => null;
get f2
-() //# 01: syntax error
+()
+// [error line 9, column 1, length 1]
+// [analyzer] SYNTACTIC_ERROR.GETTER_WITH_PARAMETERS
+// [cfe] A getter can't have formal parameters.
=> null;
get f3
-(arg) //# 02: syntax error
+(arg)
+// [error line 15, column 1, length 1]
+// [analyzer] SYNTACTIC_ERROR.GETTER_WITH_PARAMETERS
+// [cfe] A getter can't have formal parameters.
=> null;
get f4
-([arg]) //# 03: syntax error
+([arg])
+// [error line 21, column 1, length 1]
+// [analyzer] SYNTACTIC_ERROR.GETTER_WITH_PARAMETERS
+// [cfe] A getter can't have formal parameters.
=> null;
get f5
-({arg}) //# 04: syntax error
+({arg})
+// [error line 27, column 1, length 1]
+// [analyzer] SYNTACTIC_ERROR.GETTER_WITH_PARAMETERS
+// [cfe] A getter can't have formal parameters.
=> null;
main() {
diff --git a/tests/language_2/getters_setters2_runtime_test.dart b/tests/language_2/getters_setters2_runtime_test.dart
new file mode 100644
index 0000000..c4e5b8b
--- /dev/null
+++ b/tests/language_2/getters_setters2_runtime_test.dart
@@ -0,0 +1,83 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Tests classes with getters and setters that do not have the same type.
+
+class A {
+ int a() {
+ return 37;
+ }
+}
+
+class B extends A {
+ int b() {
+ return 38;
+ }
+}
+
+class C {}
+
+class T1 {
+ A getterField;
+ A get field {
+ return getterField;
+ }
+
+ // OK, B is assignable to A
+ void set field(B arg) {
+ getterField = arg;
+ }
+}
+
+class T2 {
+ A getterField;
+ C setterField;
+ A get field {
+ return getterField;
+ }
+
+ // Type C is not assignable to A
+
+}
+
+class T3 {
+ B getterField;
+ B get field {
+ return getterField;
+ }
+
+ // OK, A is assignable to B
+ void set field(A arg) {
+ getterField = arg;
+ }
+}
+
+main() {
+ T1 instance1 = new T1();
+
+ T3 instance3 = new T3();
+
+ instance1.field = new B();
+ A resultA = instance1.field;
+ Expect.throwsTypeError(() => instance1.field = new A() as dynamic);
+ B resultB = instance1.field;
+
+ int result;
+ result = instance1.field.a();
+ Expect.equals(37, result);
+
+ // Type 'A' has no method named 'b'
+
+
+ instance3.field = new B();
+ result = instance3.field.a();
+ Expect.equals(37, result);
+ result = instance3.field.b();
+ Expect.equals(38, result);
+}
diff --git a/tests/language_2/getters_setters2_test.dart b/tests/language_2/getters_setters2_test.dart
index 8249f62..cdc268b 100644
--- a/tests/language_2/getters_setters2_test.dart
+++ b/tests/language_2/getters_setters2_test.dart
@@ -36,11 +36,13 @@
A getterField;
C setterField;
A get field {
+ // ^^^^^
+ // [analyzer] STATIC_WARNING.MISMATCHED_GETTER_AND_SETTER_TYPES
return getterField;
}
// Type C is not assignable to A
- void set field(C arg) { setterField = arg; } //# 01: static type warning
+ void set field(C arg) { setterField = arg; }
}
class T3 {
@@ -57,7 +59,7 @@
main() {
T1 instance1 = new T1();
- T2 instance2 = new T2(); //# 01: continued
+ T2 instance2 = new T2();
T3 instance3 = new T3();
instance1.field = new B();
@@ -70,7 +72,10 @@
Expect.equals(37, result);
// Type 'A' has no method named 'b'
- instance1.field.b(); //# 02: compile-time error
+ instance1.field.b();
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'b' isn't defined for the class 'A'.
instance3.field = new B();
result = instance3.field.a();
diff --git a/tests/language_2/getters_setters_type_runtime_test.dart b/tests/language_2/getters_setters_type_runtime_test.dart
new file mode 100644
index 0000000..150f1737
--- /dev/null
+++ b/tests/language_2/getters_setters_type_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Getters and setters can have different types, but it is a warning if the
+// two types are not assignable.
+
+import "package:expect/expect.dart";
+
+int bar = 499;
+
+
+get foo => bar;
+
+void set foo(
+
+ str) {
+ bar = str.length;
+}
+
+main() {
+ int x = foo;
+ Expect.equals(499, x);
+ foo = "1234";
+ int y = foo;
+ Expect.equals(4, y);
+}
diff --git a/tests/language_2/getters_setters_type_test.dart b/tests/language_2/getters_setters_type_test.dart
index da9a0b7..63db11a 100644
--- a/tests/language_2/getters_setters_type_test.dart
+++ b/tests/language_2/getters_setters_type_test.dart
@@ -8,12 +8,11 @@
int bar = 499;
-int //# 01: static type warning
-get foo => bar;
+int get foo => bar;
+// [error line 11, column 1, length 19]
+// [analyzer] STATIC_WARNING.MISMATCHED_GETTER_AND_SETTER_TYPES
-void set foo(
- String // //# 01: continued
- str) {
+void set foo(String str) {
bar = str.length;
}
diff --git a/tests/language_2/hidden_import_runtime_test.dart b/tests/language_2/hidden_import_runtime_test.dart
new file mode 100644
index 0000000..aac0b67
--- /dev/null
+++ b/tests/language_2/hidden_import_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Tests that dart: imports are implicitly hidden and cause warning on use.
+
+library hidden_import;
+
+import 'hidden_import_lib.dart';
+import 'hidden_import_lib.dart' as prefix;
+import 'dart:async';
+import 'dart:async' as prefix;
+
+main() {
+
+
+}
diff --git a/tests/language_2/hidden_import_test.dart b/tests/language_2/hidden_import_test.dart
index f3398e0..ada103a 100644
--- a/tests/language_2/hidden_import_test.dart
+++ b/tests/language_2/hidden_import_test.dart
@@ -12,6 +12,6 @@
import 'dart:async' as prefix;
main() {
- new Future(); //# 01: static type warning
- new prefix.Future(); //# 02: static type warning
+ new Future();
+ new prefix.Future();
}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_10_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_10_test.dart
new file mode 100644
index 0000000..73277de
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_10_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+ { var l; yGetValue = 1; check(1, () => l ??= y, ['y']); Expect.equals(1, l); }
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_13_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_13_test.dart
new file mode 100644
index 0000000..2a29ecb
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_13_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+ C.xGetValue = 1; check(1, () => C.x ??= bad(), ['C.x']);
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_14_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_14_test.dart
new file mode 100644
index 0000000..fcd0d7b
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_14_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+ yGetValue = 1; check(1, () => C.x ??= y, ['C.x', 'y', 'C.x=1']);
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_15_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_15_test.dart
new file mode 100644
index 0000000..857d10b
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_15_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+ h.C.xGetValue = 1; check(1, () => h.C.x ??= bad(), ['h.C.x']);
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_16_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_16_test.dart
new file mode 100644
index 0000000..89813b4
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_16_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+ yGetValue = 1; check(1, () => h.C.x ??= y, ['h.C.x', 'y', 'h.C.x=1']);
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_17_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_17_test.dart
new file mode 100644
index 0000000..058b00a
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_17_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+ xGetValue = new C('x'); xGetValue.vGetValue = 1;
+ check(1, () => x.v ??= bad(), ['x', 'x.v']);
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_18_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_18_test.dart
new file mode 100644
index 0000000..2c2d1aa
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_18_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+ xGetValue = new C('x'); yGetValue = 1;
+ check(1, () => x.v ??= y, ['x', 'x.v', 'y', 'x.v=1']);
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_19_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_19_test.dart
new file mode 100644
index 0000000..8d38436
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_19_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+ fValue = new C('f()'); fValue.vGetValue = 1;
+ check(1, () => f().v ??= bad(), ['f()', 'f().v']);
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_1_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_1_test.dart
new file mode 100644
index 0000000..cfe118f
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_1_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+ vGetValue = 1; check(1, () => v ??= bad(), ['$s.v']);
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_20_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_20_test.dart
new file mode 100644
index 0000000..07a9253
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_20_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+ fValue = new C('f()'); yGetValue = 1;
+ check(1, () => f().v ??= y, ['f()', 'f().v', 'y', 'f().v=1']);
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_21_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_21_test.dart
new file mode 100644
index 0000000..83e0863
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_21_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+ xGetValue = new C('x'); yGetValue = 1; xGetValue.indexGetValue = 2;
+ check(2, () => x[y] ??= bad(), ['x', 'y', 'x[1]']);
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_22_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_22_test.dart
new file mode 100644
index 0000000..c58faef
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_22_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+ xGetValue = new C('x'); yGetValue = 1; zGetValue = 2;
+ check(2, () => x[y] ??= z, ['x', 'y', 'x[1]', 'z', 'x[1]=2']);
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_23_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_23_test.dart
new file mode 100644
index 0000000..5f470eb
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_23_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+ check(null, () => x?.v ??= bad(), ['x']);
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_24_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_24_test.dart
new file mode 100644
index 0000000..b74ceb9
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_24_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+ xGetValue = new C('x'); xGetValue.vGetValue = 1;
+ check(1, () => x?.v ??= bad(), ['x', 'x.v']);
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_25_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_25_test.dart
new file mode 100644
index 0000000..467ea0b
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_25_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+ xGetValue = new C('x'); yGetValue = 1;
+ check(1, () => x?.v ??= y, ['x', 'x.v', 'y', 'x.v=1']);
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_26_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_26_test.dart
new file mode 100644
index 0000000..6a9b710
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_26_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+ yGetValue = 1;
+ check(1, () => C?.x ??= y, ['C.x', 'y', 'C.x=1']);
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_27_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_27_test.dart
new file mode 100644
index 0000000..1e213d6
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_27_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+ yGetValue = 1;
+ check(1, () => h.C?.x ??= y, ['h.C.x', 'y', 'h.C.x=1']);
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_2_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_2_test.dart
new file mode 100644
index 0000000..82a8bb1
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_2_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+ yGetValue = 1; check(1, () => v ??= y, ['$s.v', 'y', '$s.v=1']);
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_3_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_3_test.dart
new file mode 100644
index 0000000..49eaa80
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_3_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+ vGetValue = 1; check(1, () => super.v ??= bad(), ['$s.v']);
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_4_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_4_test.dart
new file mode 100644
index 0000000..d6346f8
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_4_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+ yGetValue = 1; check(1, () => super.v ??= y, ['$s.v', 'y', '$s.v=1']);
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_5_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_5_test.dart
new file mode 100644
index 0000000..184aa20
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_5_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+ xGetValue = 1; check(1, () => x ??= bad(), ['x']);
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_6_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_6_test.dart
new file mode 100644
index 0000000..b0381c2
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_6_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+ yGetValue = 1; check(1, () => x ??= y, ['x', 'y', 'x=1']);
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_7_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_7_test.dart
new file mode 100644
index 0000000..4a709bd
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_7_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+ h.xGetValue = 1; check(1, () => h.x ??= bad(), ['h.x']);
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_8_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_8_test.dart
new file mode 100644
index 0000000..0a176ac
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_8_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1; check(1, () => h.x ??= y, ['h.x', 'y', 'h.x=1']);
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_9_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_9_test.dart
new file mode 100644
index 0000000..4ced6da
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_9_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+ { var l = 1; check(1, () => l ??= bad(), []); }
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_runtime_test.dart b/tests/language_2/if_null_assignment_behavior_runtime_test.dart
new file mode 100644
index 0000000..dc0ce1f
--- /dev/null
+++ b/tests/language_2/if_null_assignment_behavior_runtime_test.dart
@@ -0,0 +1,209 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify semantics of the ??= operator, including order of operations, by
+// keeping track of the operations performed.
+
+import "package:expect/expect.dart";
+import "if_null_assignment_helper.dart" as h;
+
+bad() {
+ Expect.fail('Should not be executed');
+}
+
+var xGetValue = null;
+
+get x {
+ h.operations.add('x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+}
+
+void set x(value) {
+ h.operations.add('x=$value');
+}
+
+var yGetValue = null;
+
+get y {
+ h.operations.add('y');
+ var tmp = yGetValue;
+ yGetValue = null;
+ return tmp;
+}
+
+void set y(value) {
+ h.operations.add('y=$value');
+}
+
+var zGetValue = null;
+
+get z {
+ h.operations.add('z');
+ var tmp = zGetValue;
+ zGetValue = null;
+ return tmp;
+}
+
+void set z(value) {
+ h.operations.add('z=$value');
+}
+
+var fValue = null;
+
+f() {
+ h.operations.add('f()');
+ var tmp = fValue;
+ fValue = null;
+ return tmp;
+}
+
+void check(expectedValue, f(), expectedOperations) {
+ Expect.equals(expectedValue, f());
+ Expect.listEquals(expectedOperations, h.operations);
+ h.operations = [];
+}
+
+class C {
+ final String s;
+
+ C(this.s);
+
+ @override
+ String toString() => s;
+
+ static var xGetValue = null;
+
+ static get x {
+ h.operations.add('C.x');
+ var tmp = xGetValue;
+ xGetValue = null;
+ return tmp;
+ }
+
+ static void set x(value) {
+ h.operations.add('C.x=$value');
+ }
+
+ var vGetValue = null;
+
+ get v {
+ h.operations.add('$s.v');
+ var tmp = vGetValue;
+ vGetValue = null;
+ return tmp;
+ }
+
+ void set v(value) {
+ h.operations.add('$s.v=$value');
+ }
+
+ var indexGetValue = null;
+
+ operator [](index) {
+ h.operations.add('$s[$index]');
+ var tmp = indexGetValue;
+ indexGetValue = null;
+ return tmp;
+ }
+
+ void operator []=(index, value) {
+ h.operations.add('$s[$index]=$value');
+ }
+
+ final finalOne = 1;
+ final finalNull = null;
+
+ void instanceTest() {
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+ yGetValue = 1;
+ }
+}
+
+class D extends C {
+ D(String s) : super(s);
+
+ get v => bad();
+
+ void set v(value) {
+ bad();
+ }
+
+ void derivedInstanceTest() {
+ // super.v ??= e is equivalent to
+ // ((x) => x == null ? super.v = e : x)(super.v)
+
+
+ }
+}
+
+main() {
+ // Make sure the "none" test fails if "??=" is not implemented. This makes
+ // status files easier to maintain.
+ var _;
+ _ ??= null;
+
+ new C('c').instanceTest();
+ new D('d').derivedInstanceTest();
+
+ // v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
+
+
+
+
+
+
+
+
+
+
+
+ // C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
+
+
+
+
+
+ // e1.v ??= e2 is equivalent to
+ // ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
+
+
+
+
+
+
+
+
+
+ // e1[e2] ??= e3 is equivalent to
+ // ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
+
+
+
+
+
+ // e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
+
+
+
+
+
+
+ // C?.v ??= e2 is equivalent to C.v ??= e2.
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/if_null_assignment_behavior_test.dart b/tests/language_2/if_null_assignment_behavior_test.dart
index bfaf56e..6fee756 100644
--- a/tests/language_2/if_null_assignment_behavior_test.dart
+++ b/tests/language_2/if_null_assignment_behavior_test.dart
@@ -118,9 +118,12 @@
void instanceTest() {
// v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
- vGetValue = 1; check(1, () => v ??= bad(), ['$s.v']); //# 01: ok
- yGetValue = 1; check(1, () => v ??= y, ['$s.v', 'y', '$s.v=1']); //# 02: ok
- finalOne ??= null; //# 03: compile-time error
+ vGetValue = 1; check(1, () => v ??= bad(), ['$s.v']);
+ yGetValue = 1; check(1, () => v ??= y, ['$s.v', 'y', '$s.v=1']);
+ finalOne ??= null;
+// ^^^^^^^^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL
+// [cfe] The setter 'finalOne' isn't defined for the class 'C'.
yGetValue = 1;
}
}
@@ -137,8 +140,8 @@
void derivedInstanceTest() {
// super.v ??= e is equivalent to
// ((x) => x == null ? super.v = e : x)(super.v)
- vGetValue = 1; check(1, () => super.v ??= bad(), ['$s.v']); //# 05: ok
- yGetValue = 1; check(1, () => super.v ??= y, ['$s.v', 'y', '$s.v=1']); //# 06: ok
+ vGetValue = 1; check(1, () => super.v ??= bad(), ['$s.v']);
+ yGetValue = 1; check(1, () => super.v ??= y, ['$s.v', 'y', '$s.v=1']);
}
}
@@ -152,55 +155,73 @@
new D('d').derivedInstanceTest();
// v ??= e is equivalent to ((x) => x == null ? v = e : x)(v)
- xGetValue = 1; check(1, () => x ??= bad(), ['x']); //# 07: ok
- yGetValue = 1; check(1, () => x ??= y, ['x', 'y', 'x=1']); //# 08: ok
- h.xGetValue = 1; check(1, () => h.x ??= bad(), ['h.x']); //# 09: ok
- yGetValue = 1; check(1, () => h.x ??= y, ['h.x', 'y', 'h.x=1']); //# 10: ok
- { var l = 1; check(1, () => l ??= bad(), []); } //# 11: ok
- { var l; yGetValue = 1; check(1, () => l ??= y, ['y']); Expect.equals(1, l); } //# 12: ok
- { final l = 1; l ??= null; } //# 13: compile-time error
- C ??= null; //# 15: compile-time error
- h ??= null; //# 29: compile-time error
- h[0] ??= null; //# 30: compile-time error
+ xGetValue = 1; check(1, () => x ??= bad(), ['x']);
+ yGetValue = 1; check(1, () => x ??= y, ['x', 'y', 'x=1']);
+ h.xGetValue = 1; check(1, () => h.x ??= bad(), ['h.x']);
+ yGetValue = 1; check(1, () => h.x ??= y, ['h.x', 'y', 'h.x=1']);
+ { var l = 1; check(1, () => l ??= bad(), []); }
+ { var l; yGetValue = 1; check(1, () => l ??= y, ['y']); Expect.equals(1, l); }
+ { final l = 1; l ??= null; }
+ // ^
+ // [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_LOCAL
+ // [cfe] Setter not found: 'l'.
+ C ??= null;
+//^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_TYPE
+// [cfe] Setter not found: 'C'.
+ h ??= null;
+//^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used as an expression.
+ h[0] ??= null;
+//^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used as an expression.
// C.v ??= e is equivalent to ((x) => x == null ? C.v = e : x)(C.v)
- C.xGetValue = 1; check(1, () => C.x ??= bad(), ['C.x']); //# 16: ok
- yGetValue = 1; check(1, () => C.x ??= y, ['C.x', 'y', 'C.x=1']); //# 17: ok
- h.C.xGetValue = 1; check(1, () => h.C.x ??= bad(), ['h.C.x']); //# 18: ok
- yGetValue = 1; check(1, () => h.C.x ??= y, ['h.C.x', 'y', 'h.C.x=1']); //# 19: ok
+ C.xGetValue = 1; check(1, () => C.x ??= bad(), ['C.x']);
+ yGetValue = 1; check(1, () => C.x ??= y, ['C.x', 'y', 'C.x=1']);
+ h.C.xGetValue = 1; check(1, () => h.C.x ??= bad(), ['h.C.x']);
+ yGetValue = 1; check(1, () => h.C.x ??= y, ['h.C.x', 'y', 'h.C.x=1']);
// e1.v ??= e2 is equivalent to
// ((x) => ((y) => y == null ? x.v = e2 : y)(x.v))(e1)
- xGetValue = new C('x'); xGetValue.vGetValue = 1; //# 20: ok
- check(1, () => x.v ??= bad(), ['x', 'x.v']); // //# 20: continued
- xGetValue = new C('x'); yGetValue = 1; // //# 21: ok
- check(1, () => x.v ??= y, ['x', 'x.v', 'y', 'x.v=1']); //# 21: continued
- fValue = new C('f()'); fValue.vGetValue = 1; // //# 22: ok
- check(1, () => f().v ??= bad(), ['f()', 'f().v']); //# 22: continued
- fValue = new C('f()'); yGetValue = 1; // //# 23: ok
- check(1, () => f().v ??= y, ['f()', 'f().v', 'y', 'f().v=1']); //# 23: continued
+ xGetValue = new C('x'); xGetValue.vGetValue = 1;
+ check(1, () => x.v ??= bad(), ['x', 'x.v']);
+ xGetValue = new C('x'); yGetValue = 1;
+ check(1, () => x.v ??= y, ['x', 'x.v', 'y', 'x.v=1']);
+ fValue = new C('f()'); fValue.vGetValue = 1;
+ check(1, () => f().v ??= bad(), ['f()', 'f().v']);
+ fValue = new C('f()'); yGetValue = 1;
+ check(1, () => f().v ??= y, ['f()', 'f().v', 'y', 'f().v=1']);
// e1[e2] ??= e3 is equivalent to
// ((a, i) => ((x) => x == null ? a[i] = e3 : x)(a[i]))(e1, e2)
- xGetValue = new C('x'); yGetValue = 1; xGetValue.indexGetValue = 2; //# 24: ok
- check(2, () => x[y] ??= bad(), ['x', 'y', 'x[1]']); // //# 24: continued
- xGetValue = new C('x'); yGetValue = 1; zGetValue = 2; // //# 25: ok
- check(2, () => x[y] ??= z, ['x', 'y', 'x[1]', 'z', 'x[1]=2']); //# 25: continued
+ xGetValue = new C('x'); yGetValue = 1; xGetValue.indexGetValue = 2;
+ check(2, () => x[y] ??= bad(), ['x', 'y', 'x[1]']);
+ xGetValue = new C('x'); yGetValue = 1; zGetValue = 2;
+ check(2, () => x[y] ??= z, ['x', 'y', 'x[1]', 'z', 'x[1]=2']);
// e1?.v ??= e2 is equivalent to ((x) => x == null ? null : x.v ??= e2)(e1).
- check(null, () => x?.v ??= bad(), ['x']); //# 26: ok
- xGetValue = new C('x'); xGetValue.vGetValue = 1; //# 27: ok
- check(1, () => x?.v ??= bad(), ['x', 'x.v']); // //# 27: continued
- xGetValue = new C('x'); yGetValue = 1; // //# 28: ok
- check(1, () => x?.v ??= y, ['x', 'x.v', 'y', 'x.v=1']); //# 28: continued
+ check(null, () => x?.v ??= bad(), ['x']);
+ xGetValue = new C('x'); xGetValue.vGetValue = 1;
+ check(1, () => x?.v ??= bad(), ['x', 'x.v']);
+ xGetValue = new C('x'); yGetValue = 1;
+ check(1, () => x?.v ??= y, ['x', 'x.v', 'y', 'x.v=1']);
// C?.v ??= e2 is equivalent to C.v ??= e2.
- C.xGetValue = 1; // //# 29: ok
- check(1, () => C?.x ??= bad(), ['C.x']); //# 29: continued
- h.C.xgetValue = 1; // //# 30: ok
- check(1, () => h.c?.x ??= bad(), ['h.C.x']); //# 30: continued
- yGetValue = 1; // //# 31: ok
- check(1, () => C?.x ??= y, ['C.x', 'y', 'C.x=1']); //# 31: continued
- yGetValue = 1; // //# 32: ok
- check(1, () => h.C?.x ??= y, ['h.C.x', 'y', 'h.C.x=1']); //# 32: continued
+ C.xGetValue = 1;
+ check(1, () => C?.x ??= bad(), ['C.x']);
+ h.C.xgetValue = 1;
+ // ^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] Setter not found: 'xgetValue'.
+ check(1, () => h.c?.x ??= bad(), ['h.C.x']);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_PREFIXED_NAME
+ // [cfe] Getter not found: 'c'.
+ yGetValue = 1;
+ check(1, () => C?.x ??= y, ['C.x', 'y', 'C.x=1']);
+ yGetValue = 1;
+ check(1, () => h.C?.x ??= y, ['h.C.x', 'y', 'h.C.x=1']);
}
diff --git a/tests/language_2/if_null_precedence_runtime_test.dart b/tests/language_2/if_null_precedence_runtime_test.dart
new file mode 100644
index 0000000..27f4d85
--- /dev/null
+++ b/tests/language_2/if_null_precedence_runtime_test.dart
@@ -0,0 +1,43 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify that '??' binds tighter than '?:' and less tightly than '||'.
+
+import "package:expect/expect.dart";
+
+main() {
+ // Make sure the "none" test fails if "??" is not implemented. This makes
+ // status files easier to maintain.
+ var _ = null ?? null;
+
+ // "a ?? b ?? c" should be legal, and should evaluate to the first non-null
+ // value (or null if there are no non-null values).
+ Expect.equals(1, 1 ?? 2 ?? 3);
+ Expect.equals(2, null ?? 2 ?? 3);
+ Expect.equals(3, null ?? null ?? 3);
+ Expect.equals(null, null ?? null ?? null);
+
+ // "a ?? b ? c : d" should parse as "(a ?? b) ? c : d", therefore provided
+ // that a is true, b need not be a bool. An incorrect parse of
+ // "a ?? (b ? c : d)" would require b to be a bool to avoid a static type
+ // warning.
+ Expect.equals(2, true ?? 1 ? 2 : 3);
+
+ // "a ?? b || c" should parse as "a ?? (b || c)", therefore it's a static
+ // type warning if b doesn't have type bool. An incorrect parse of
+ // "(a ?? b) || c" would allow b to have any type provided that a is bool.
+
+
+ // "a || b ?? c" should parse as "(a || b) ?? c", therefore it is a static
+ // type warning if b doesn't have type bool. An incorrect parse of
+ // "a || (b ?? c)" would allow b to have any type provided that c is bool.
+
+
+ // An incorrect parse of "a || (b ?? c)" would result in no checked-mode
+ // error.
+ Expect.throwsAssertionError(() => false || null ?? true);
+}
diff --git a/tests/language_2/if_null_precedence_test.dart b/tests/language_2/if_null_precedence_test.dart
index e404d49..cb419fc 100644
--- a/tests/language_2/if_null_precedence_test.dart
+++ b/tests/language_2/if_null_precedence_test.dart
@@ -27,12 +27,18 @@
// "a ?? b || c" should parse as "a ?? (b || c)", therefore it's a static
// type warning if b doesn't have type bool. An incorrect parse of
// "(a ?? b) || c" would allow b to have any type provided that a is bool.
- false ?? 1 || true; //# 06: compile-time error
+ false ?? 1 || true;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.NON_BOOL_OPERAND
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'bool'.
// "a || b ?? c" should parse as "(a || b) ?? c", therefore it is a static
// type warning if b doesn't have type bool. An incorrect parse of
// "a || (b ?? c)" would allow b to have any type provided that c is bool.
- false || 1 ?? true; //# 07: compile-time error
+ false || 1 ?? true;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.NON_BOOL_OPERAND
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'bool'.
// An incorrect parse of "a || (b ?? c)" would result in no checked-mode
// error.
diff --git a/tests/language_2/illegal_initializer_runtime_test.dart b/tests/language_2/illegal_initializer_runtime_test.dart
new file mode 100644
index 0000000..fecbeba
--- /dev/null
+++ b/tests/language_2/illegal_initializer_runtime_test.dart
@@ -0,0 +1,50 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class A {
+ A();
+ A.foo();
+}
+
+class B extends A {
+ B.c1()
+ : super.foo
+
+ ()
+
+ ;
+
+ B.foo();
+ B.c2()
+ : this.foo
+
+ ()
+
+ ;
+
+ B.c3()
+ : super
+
+ ()
+
+ ;
+
+ B();
+ B.c4()
+ : this
+
+ ()
+
+ ;
+}
+
+main() {
+ new B.c1();
+ new B.c2();
+ new B.c3();
+ new B.c4();
+}
diff --git a/tests/language_2/illegal_initializer_test.dart b/tests/language_2/illegal_initializer_test.dart
index f56d005..1b99406 100644
--- a/tests/language_2/illegal_initializer_test.dart
+++ b/tests/language_2/illegal_initializer_test.dart
@@ -8,35 +8,48 @@
}
class B extends A {
- B.c1()
- : super.foo
- /* //# 01: syntax error
- ()
- */ //# 01: continued
- ;
+ B.c1() : super.foo;
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected '(' after this.
B.foo();
- B.c2()
- : this.foo
- /* //# 02: syntax error
- ()
- */ //# 02: continued
- ;
+ B.c2() : this.foo;
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_REFERENCE_TO_THIS
+ // [cfe] Can't access 'this' in a field initializer.
+ // ^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNMENT_IN_INITIALIZER
+ // [cfe] Expected an assignment after the field name.
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INITIALIZER_FOR_NON_EXISTENT_FIELD
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
- B.c3()
- : super
- /* //# 03: syntax error
- ()
- */ //# 03: continued
+ B.c3() : super;
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
;
+//^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_CLASS_MEMBER
+// [cfe] Expected a class member, but got ';'.
B();
- B.c4()
- : this
- /* //# 04: syntax error
- ()
- */ //# 04: continued
- ;
+ B.c4() : this;
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INITIALIZER_FOR_NON_EXISTENT_FIELD
+ // [cfe] Expected an assignment after the field name.
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_REFERENCE_TO_THIS
+ // ^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNMENT_IN_INITIALIZER
+ // [error line 39, column 16, length 0]
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] Expected '.' before this.
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected an identifier, but got ''.
}
main() {
diff --git a/tests/language_2/illegal_invocation_runtime_test.dart b/tests/language_2/illegal_invocation_runtime_test.dart
new file mode 100644
index 0000000..41f46b0
--- /dev/null
+++ b/tests/language_2/illegal_invocation_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Dart test program for constructors and initializers.
+//
+// Test for issue 1393. Invoking a library prefix name caused an internal error
+// in dartc.
+
+
+
+main() {
+ // probably what the user meant was foo.foo(), but the qualifier refers
+ // to the library prefix, not the method defined within the library.
+
+}
diff --git a/tests/language_2/illegal_invocation_test.dart b/tests/language_2/illegal_invocation_test.dart
index 48ad70a..7af9479 100644
--- a/tests/language_2/illegal_invocation_test.dart
+++ b/tests/language_2/illegal_invocation_test.dart
@@ -6,10 +6,13 @@
// Test for issue 1393. Invoking a library prefix name caused an internal error
// in dartc.
-import "illegal_invocation_lib.dart" as foo; //# 01: compile-time error
+import "illegal_invocation_lib.dart" as foo;
main() {
// probably what the user meant was foo.foo(), but the qualifier refers
// to the library prefix, not the method defined within the library.
- foo(); //# 01: continued
+ foo();
+//^^^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used as an expression.
}
diff --git a/tests/language_2/implements_futureor_runtime_test.dart b/tests/language_2/implements_futureor_runtime_test.dart
new file mode 100644
index 0000000..257056b
--- /dev/null
+++ b/tests/language_2/implements_futureor_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'dart:async';
+
+class A<T>
+
+{}
+
+void main() {
+ A a = new A();
+}
diff --git a/tests/language_2/implements_futureor_test.dart b/tests/language_2/implements_futureor_test.dart
index 4e878ff..ec47e42 100644
--- a/tests/language_2/implements_futureor_test.dart
+++ b/tests/language_2/implements_futureor_test.dart
@@ -5,7 +5,9 @@
import 'dart:async';
class A<T>
- implements FutureOr<T> //# 01: compile-time error
+ implements FutureOr<T>
+ // ^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_DISALLOWED_CLASS
{}
void main() {
diff --git a/tests/language_2/implicit_this_runtime_test.dart b/tests/language_2/implicit_this_runtime_test.dart
new file mode 100644
index 0000000..34022fd
--- /dev/null
+++ b/tests/language_2/implicit_this_runtime_test.dart
@@ -0,0 +1,46 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+abstract class Interface {
+ final x;
+ Interface(this.x);
+}
+
+abstract class Abstract implements Interface {
+ String toString() => x.toString();
+}
+
+// This class does not implement "x" either, but it is not marked
+// abstract.
+
+
+// This class does not implement "x", but is itself abstract, so that's OK.
+abstract class SubAbstract2 extends Abstract {
+ get x; // Abstract.
+}
+
+// This class does not implement "x" either, but it is not marked
+// abstract.
+
+
+class Concrete extends Abstract {
+ get x => 7;
+}
+
+class SubConcrete extends Concrete {
+ final x;
+ SubConcrete(this.x);
+}
+
+void main() {
+
+ Expect.equals('7', new Concrete().toString());
+ Expect.equals('42', new SubConcrete(42).toString());
+ Expect.equals('7', new SubConcrete(new Concrete()).toString());
+}
diff --git a/tests/language_2/implicit_this_test.dart b/tests/language_2/implicit_this_test.dart
index 9342f9e..3500c9a 100644
--- a/tests/language_2/implicit_this_test.dart
+++ b/tests/language_2/implicit_this_test.dart
@@ -15,7 +15,10 @@
// This class does not implement "x" either, but it is not marked
// abstract.
-class SubAbstract1 extends Abstract {} //# 01: compile-time error
+class SubAbstract1 extends Abstract {}
+// ^^^^^^^^^^^^
+// [analyzer] STATIC_WARNING.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER
+// [cfe] The non-abstract class 'SubAbstract1' is missing implementations for these members:
// This class does not implement "x", but is itself abstract, so that's OK.
abstract class SubAbstract2 extends Abstract {
@@ -24,7 +27,10 @@
// This class does not implement "x" either, but it is not marked
// abstract.
-class SubSubAbstract2 extends SubAbstract2 {} //# 04: compile-time error
+class SubSubAbstract2 extends SubAbstract2 {}
+// ^^^^^^^^^^^^^^^
+// [analyzer] STATIC_WARNING.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER
+// [cfe] The non-abstract class 'SubSubAbstract2' is missing implementations for these members:
class Concrete extends Abstract {
get x => 7;
@@ -36,7 +42,10 @@
}
void main() {
- new Abstract(); //# 02: compile-time error
+ new Abstract();
+ // ^^^^^^^^
+ // [analyzer] STATIC_WARNING.INSTANTIATE_ABSTRACT_CLASS
+ // [cfe] The class 'Abstract' is abstract and can't be instantiated.
Expect.equals('7', new Concrete().toString());
Expect.equals('42', new SubConcrete(42).toString());
Expect.equals('7', new SubConcrete(new Concrete()).toString());
diff --git a/tests/language_2/import_combinators2_runtime_test.dart b/tests/language_2/import_combinators2_runtime_test.dart
new file mode 100644
index 0000000..ec0051d
--- /dev/null
+++ b/tests/language_2/import_combinators2_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// Dart test program importing with show/hide combinators.
+
+// Show "hide" and "show", hide "ugly".
+import "import1_lib.dart" show hide, show hide ugly;
+
+main() {
+ print(hide);
+ print(show);
+
+ // Ugly is hidden.
+
+}
diff --git a/tests/language_2/import_combinators2_test.dart b/tests/language_2/import_combinators2_test.dart
index ba3922e..47a2db0 100644
--- a/tests/language_2/import_combinators2_test.dart
+++ b/tests/language_2/import_combinators2_test.dart
@@ -12,5 +12,8 @@
print(show);
// Ugly is hidden.
- print(ugly); //# 00: compile-time error
+ print(ugly);
+ // ^^^^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] Getter not found: 'ugly'.
}
diff --git a/tests/language_2/import_nonexisting_dart_uri_runtime_test.dart b/tests/language_2/import_nonexisting_dart_uri_runtime_test.dart
new file mode 100644
index 0000000..f31c56d
--- /dev/null
+++ b/tests/language_2/import_nonexisting_dart_uri_runtime_test.dart
@@ -0,0 +1,10 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+
+
+main() {}
diff --git a/tests/language_2/import_nonexisting_dart_uri_test.dart b/tests/language_2/import_nonexisting_dart_uri_test.dart
index 1a4fd42..cb25b61 100644
--- a/tests/language_2/import_nonexisting_dart_uri_test.dart
+++ b/tests/language_2/import_nonexisting_dart_uri_test.dart
@@ -2,6 +2,9 @@
// 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.
-import "dart:nonexisting/nonexisting.dart"; //# 01: compile-time error
+import "dart:nonexisting/nonexisting.dart";
+// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.URI_DOES_NOT_EXIST
+// [cfe] Not found: 'dart:nonexisting/nonexisting.dart'
main() {}
diff --git a/tests/language_2/import_private_runtime_test.dart b/tests/language_2/import_private_runtime_test.dart
new file mode 100644
index 0000000..81914a9
--- /dev/null
+++ b/tests/language_2/import_private_runtime_test.dart
@@ -0,0 +1,13 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+// Check that private dart:_ libraries cannot be imported.
+
+
+
+main() {
+ print("Done.");
+}
diff --git a/tests/language_2/import_private_test.dart b/tests/language_2/import_private_test.dart
index 9fc82bf..deb2f1e 100644
--- a/tests/language_2/import_private_test.dart
+++ b/tests/language_2/import_private_test.dart
@@ -3,7 +3,10 @@
// BSD-style license that can be found in the LICENSE file.
// Check that private dart:_ libraries cannot be imported.
-import "dart:_internal"; //# 01: compile-time error
+import "dart:_internal";
+// ^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.IMPORT_INTERNAL_LIBRARY
+// [cfe] Can't access platform private library.
main() {
print("Done.");
diff --git a/tests/language_2/import_self_runtime_test.dart b/tests/language_2/import_self_runtime_test.dart
new file mode 100644
index 0000000..47dac6e
--- /dev/null
+++ b/tests/language_2/import_self_runtime_test.dart
@@ -0,0 +1,23 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+//
+// Check that private names cannot be imported even if the library imports
+// itself.
+
+library import_self;
+
+import "package:expect/expect.dart";
+
+// Eliminate the import of the unmodified file or else the analyzer
+// will generate the static error in the import_self_test_none case.
+
+
+var _x = "The quick brown fox jumps over the dazy log";
+
+main() {
+
+}
diff --git a/tests/language_2/import_self_test.dart b/tests/language_2/import_self_test.dart
index b6502d3..98c9fc0 100644
--- a/tests/language_2/import_self_test.dart
+++ b/tests/language_2/import_self_test.dart
@@ -11,10 +11,13 @@
// Eliminate the import of the unmodified file or else the analyzer
// will generate the static error in the import_self_test_none case.
-import "import_self_test.dart" as p; //# 01: continued
+import "import_self_test.dart" as p;
var _x = "The quick brown fox jumps over the dazy log";
main() {
- p._x; //# 01: compile-time error
+ p._x;
+ //^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_PREFIXED_NAME
+ // [cfe] Getter not found: '_x'.
}
diff --git a/tests/language_2/inferrer_constructor5_runtime_test.dart b/tests/language_2/inferrer_constructor5_runtime_test.dart
new file mode 100644
index 0000000..eec6a13
--- /dev/null
+++ b/tests/language_2/inferrer_constructor5_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ A() {
+
+ }
+}
+
+class B extends A {
+ var field;
+ B() {
+ field = 42;
+ }
+}
+
+main() {
+
+}
diff --git a/tests/language_2/inferrer_constructor5_test.dart b/tests/language_2/inferrer_constructor5_test.dart
index 582fb67..7221fea 100644
--- a/tests/language_2/inferrer_constructor5_test.dart
+++ b/tests/language_2/inferrer_constructor5_test.dart
@@ -6,7 +6,10 @@
class A {
A() {
- print(field + 42); //# 01: compile-time error
+ print(field + 42);
+ // ^^^^^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'field' isn't defined for the class 'A'.
}
}
@@ -18,5 +21,5 @@
}
main() {
- Expect.throwsNoSuchMethodError(() => new B()); //# 01: continued
+ Expect.throwsNoSuchMethodError(() => new B());
}
diff --git a/tests/language_2/initializer_super_last_runtime_test.dart b/tests/language_2/initializer_super_last_runtime_test.dart
new file mode 100644
index 0000000..dc2caeb
--- /dev/null
+++ b/tests/language_2/initializer_super_last_runtime_test.dart
@@ -0,0 +1,170 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 201, 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.
+// VMOptions=--enable-asserts
+//
+// Dart test program testing assert statements.
+
+import "package:expect/expect.dart";
+
+class S {
+ const S();
+ const S.named();
+}
+
+class C extends S {
+ final int x;
+ C.cc01(int x)
+ : x = x,
+ super();
+ C.cc02(int x)
+ : x = x,
+ super.named();
+ C.cc03(this.x) : super();
+ C.cc04(this.x) : super.named();
+ C.cc05(int x)
+ : x = x,
+ assert(x == x),
+ super();
+ C.cc06(int x)
+ : x = x,
+ assert(x == x),
+ super.named();
+ C.cc07(this.x)
+ : assert(x == x),
+ super();
+ C.cc08(this.x)
+ : assert(x == x),
+ super.named();
+ C.cc09(int x)
+ : //
+
+ x = x;
+ C.cc10(int x)
+ : //
+
+ x = x;
+ C.cc11(this.x)
+ : //
+
+ assert(x == x);
+ C.cc12(this.x)
+ : //
+
+ assert(x == x);
+ C.cc13(int x)
+ : //
+
+ x = x,
+ assert(x == x);
+ C.cc14(int x)
+ : //
+
+ x = x,
+ assert(x == x);
+ C.cc15(int x)
+ : x = x,
+
+ assert(x == x);
+ C.cc16(int x)
+ : x = x,
+
+ assert(x == x);
+
+ const C.cc17(int x)
+ : x = x,
+ super();
+ const C.cc18(int x)
+ : x = x,
+ super.named();
+ const C.cc19(this.x) : super();
+ const C.cc20(this.x) : super.named();
+ const C.cc21(int x)
+ : x = x,
+ assert(x == x),
+ super();
+ const C.cc22(int x)
+ : x = x,
+ assert(x == x),
+ super.named();
+ const C.cc23(this.x)
+ : assert(x == x),
+ super();
+ const C.cc24(this.x)
+ : assert(x == x),
+ super.named();
+ const C.cc25(int x)
+ : //
+
+ x = x;
+ const C.cc26(int x)
+ : //
+
+ x = x;
+ const C.cc27(this.x)
+ : //
+
+ assert(x == x);
+ const C.cc28(this.x)
+ : //
+
+ assert(x == x);
+ const C.cc29(int x)
+ : //
+
+ x = x,
+ assert(x == x);
+ const C.cc30(int x)
+ : //
+
+ x = x,
+ assert(x == x);
+ const C.cc31(int x)
+ : x = x,
+
+ assert(x == x);
+ const C.cc32(int x)
+ : x = x,
+
+ assert(x == x);
+}
+
+main() {
+ // Ensure that erroneous constructors are actually needed.
+ new C.cc01(42);
+ new C.cc02(42);
+ new C.cc03(42);
+ new C.cc04(42);
+ new C.cc05(42);
+ new C.cc06(42);
+ new C.cc07(42);
+ new C.cc08(42);
+ new C.cc09(42);
+ new C.cc10(42);
+ new C.cc11(42);
+ new C.cc12(42);
+ new C.cc13(42);
+ new C.cc14(42);
+ new C.cc15(42);
+ new C.cc16(42);
+
+ const C.cc17(42);
+ const C.cc18(42);
+ const C.cc19(42);
+ const C.cc20(42);
+ const C.cc21(42);
+ const C.cc22(42);
+ const C.cc23(42);
+ const C.cc24(42);
+ const C.cc25(42);
+ const C.cc26(42);
+ const C.cc27(42);
+ const C.cc28(42);
+ const C.cc29(42);
+ const C.cc30(42);
+ const C.cc31(42);
+ const C.cc32(42);
+}
diff --git a/tests/language_2/initializer_super_last_test.dart b/tests/language_2/initializer_super_last_test.dart
index 19ad3fa..916f223 100644
--- a/tests/language_2/initializer_super_last_test.dart
+++ b/tests/language_2/initializer_super_last_test.dart
@@ -37,38 +37,74 @@
: assert(x == x),
super.named();
C.cc09(int x)
+//^
+// [cfe] Final field 'x' is not initialized by this constructor.
: //
- super(), //# cc09: compile-time error
+ super(),
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// [cfe] Can't have initializers after 'super'.
x = x;
C.cc10(int x)
+//^
+// [cfe] Final field 'x' is not initialized by this constructor.
: //
- super.named(), //# cc10: compile-time error
+ super.named(),
+// ^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// ^
+// [cfe] Can't have initializers after 'super'.
x = x;
C.cc11(this.x)
: //
- super(), //# cc11: compile-time error
+ super(),
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// [cfe] Can't have initializers after 'super'.
assert(x == x);
C.cc12(this.x)
: //
- super.named(), //# cc12: compile-time error
+ super.named(),
+// ^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// ^
+// [cfe] Can't have initializers after 'super'.
assert(x == x);
C.cc13(int x)
+//^
+// [cfe] Final field 'x' is not initialized by this constructor.
: //
- super(), //# cc13: compile-time error
+ super(),
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// [cfe] Can't have initializers after 'super'.
x = x,
assert(x == x);
C.cc14(int x)
+//^
+// [cfe] Final field 'x' is not initialized by this constructor.
: //
- super.named(), //# cc14: compile-time error
+ super.named(),
+// ^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// ^
+// [cfe] Can't have initializers after 'super'.
x = x,
assert(x == x);
C.cc15(int x)
: x = x,
- super(), //# cc15: compile-time error
+ super(),
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// [cfe] Can't have initializers after 'super'.
assert(x == x);
C.cc16(int x)
: x = x,
- super.named(), //# cc16: compile-time error
+ super.named(),
+// ^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// ^
+// [cfe] Can't have initializers after 'super'.
assert(x == x);
const C.cc17(int x)
@@ -94,38 +130,74 @@
: assert(x == x),
super.named();
const C.cc25(int x)
+ // ^
+ // [cfe] Final field 'x' is not initialized by this constructor.
: //
- super(), //# cc25: compile-time error
+ super(),
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// [cfe] Can't have initializers after 'super'.
x = x;
const C.cc26(int x)
+ // ^
+ // [cfe] Final field 'x' is not initialized by this constructor.
: //
- super.named(), //# cc26: compile-time error
+ super.named(),
+// ^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// ^
+// [cfe] Can't have initializers after 'super'.
x = x;
const C.cc27(this.x)
: //
- super(), //# cc27: compile-time error
+ super(),
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// [cfe] Can't have initializers after 'super'.
assert(x == x);
const C.cc28(this.x)
: //
- super.named(), //# cc28: compile-time error
+ super.named(),
+// ^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// ^
+// [cfe] Can't have initializers after 'super'.
assert(x == x);
const C.cc29(int x)
+ // ^
+ // [cfe] Final field 'x' is not initialized by this constructor.
: //
- super(), //# cc29: compile-time error
+ super(),
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// [cfe] Can't have initializers after 'super'.
x = x,
assert(x == x);
const C.cc30(int x)
+ // ^
+ // [cfe] Final field 'x' is not initialized by this constructor.
: //
- super.named(), //# cc30: compile-time error
+ super.named(),
+// ^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// ^
+// [cfe] Can't have initializers after 'super'.
x = x,
assert(x == x);
const C.cc31(int x)
: x = x,
- super(), //# cc31: compile-time error
+ super(),
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// [cfe] Can't have initializers after 'super'.
assert(x == x);
const C.cc32(int x)
: x = x,
- super.named(), //# cc32: compile-time error
+ super.named(),
+// ^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_SUPER_INVOCATION
+// ^
+// [cfe] Can't have initializers after 'super'.
assert(x == x);
}
diff --git a/tests/language_2/initializing_formal_type_annotation_runtime_test.dart b/tests/language_2/initializing_formal_type_annotation_runtime_test.dart
new file mode 100644
index 0000000..c09a0ff
--- /dev/null
+++ b/tests/language_2/initializing_formal_type_annotation_runtime_test.dart
@@ -0,0 +1,23 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// Testing the static checks for type annotations on initializing formals.
+
+class C {
+ num a;
+ C.sameType(num this.a);
+ C.subType(int this.a);
+
+
+}
+
+main() {
+ new C.sameType(3.14);
+ new C.subType(42);
+
+
+}
diff --git a/tests/language_2/initializing_formal_type_annotation_test.dart b/tests/language_2/initializing_formal_type_annotation_test.dart
index 5a0a457..b15ad9a 100644
--- a/tests/language_2/initializing_formal_type_annotation_test.dart
+++ b/tests/language_2/initializing_formal_type_annotation_test.dart
@@ -8,13 +8,23 @@
num a;
C.sameType(num this.a);
C.subType(int this.a);
- C.superType(dynamic this.a); //# 01: compile-time error
- C.unrelatedType(String this.a); //# 02: compile-time error
+ C.superType(dynamic this.a);
+ // ^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_PARAMETER_DECLARATION
+ // ^
+ // [cfe] The type of parameter 'a', 'dynamic' is not a subtype of the corresponding field's type, 'num'.
+ C.unrelatedType(String this.a);
+ // ^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_PARAMETER_DECLARATION
+ // ^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE
+ // ^
+ // [cfe] The type of parameter 'a', 'String' is not a subtype of the corresponding field's type, 'num'.
}
main() {
new C.sameType(3.14);
new C.subType(42);
- new C.superType([]); //# 01: continued
- new C.unrelatedType('String'); //# 02: continued
+ new C.superType([]);
+ new C.unrelatedType('String');
}
diff --git a/tests/language_2/instantiate_type_variable_runtime_test.dart b/tests/language_2/instantiate_type_variable_runtime_test.dart
new file mode 100644
index 0000000..973da61
--- /dev/null
+++ b/tests/language_2/instantiate_type_variable_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Test that you cannot instantiate a type variable.
+
+class Foo<T> {
+ Foo() {}
+ T make() {
+
+ }
+}
+
+main() {
+ new Foo<Object>().make();
+}
diff --git a/tests/language_2/instantiate_type_variable_test.dart b/tests/language_2/instantiate_type_variable_test.dart
index 5bf7f76..72fc68c 100644
--- a/tests/language_2/instantiate_type_variable_test.dart
+++ b/tests/language_2/instantiate_type_variable_test.dart
@@ -7,7 +7,12 @@
class Foo<T> {
Foo() {}
T make() {
- return new T(); //# 01: compile-time error
+ return new T();
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_NEW_EXPR
+ // ^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'T'.
}
}
diff --git a/tests/language_2/int64_literal_runtime_10_test.dart b/tests/language_2/int64_literal_runtime_10_test.dart
new file mode 100644
index 0000000..6391a0f
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_10_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+
+
+
+
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+
+
+
+
+
+ maxInt64Value = -0x8000000000000000 - 1;
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_11_test.dart b/tests/language_2/int64_literal_runtime_11_test.dart
new file mode 100644
index 0000000..02ae918
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_11_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+
+
+
+
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+
+
+
+
+
+
+
+ maxInt64Value = -(0x8000000000000001);
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_1_test.dart b/tests/language_2/int64_literal_runtime_1_test.dart
new file mode 100644
index 0000000..3b23e7f
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_1_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+ minInt64Value = -9223372036854775807 - 1;
+
+
+
+
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+
+
+
+
+
+
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_2_test.dart b/tests/language_2/int64_literal_runtime_2_test.dart
new file mode 100644
index 0000000..6664a7d
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_2_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+ minInt64Value = -9223372036854775808;
+
+
+
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+
+
+
+
+
+
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_3_test.dart b/tests/language_2/int64_literal_runtime_3_test.dart
new file mode 100644
index 0000000..6a474c9
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_3_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+
+
+ minInt64Value = -(0x8000000000000000);
+
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+
+
+
+
+
+
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_4_test.dart b/tests/language_2/int64_literal_runtime_4_test.dart
new file mode 100644
index 0000000..e40dd6b
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_4_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+
+
+
+ minInt64Value = 0x8000000000000000;
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+
+
+
+
+
+
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_5_test.dart b/tests/language_2/int64_literal_runtime_5_test.dart
new file mode 100644
index 0000000..d9f1aac
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_5_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+
+
+
+
+ minInt64Value = -0x8000000000000000;
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+
+
+
+
+
+
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_6_test.dart b/tests/language_2/int64_literal_runtime_6_test.dart
new file mode 100644
index 0000000..fefa1f3
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_6_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+
+
+
+
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+ maxInt64Value = 9223372036854775807;
+
+
+
+
+
+
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_7_test.dart b/tests/language_2/int64_literal_runtime_7_test.dart
new file mode 100644
index 0000000..227ea41
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_7_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+
+
+
+
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+ maxInt64Value = 9223372036854775807;
+
+
+
+
+
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_8_test.dart b/tests/language_2/int64_literal_runtime_8_test.dart
new file mode 100644
index 0000000..07ba174
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_8_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+
+
+
+
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+
+
+ maxInt64Value = -9223372036854775808 - 1;
+
+
+
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_9_test.dart b/tests/language_2/int64_literal_runtime_9_test.dart
new file mode 100644
index 0000000..7aabfc2
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_9_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+
+
+
+
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+
+
+
+
+ maxInt64Value = 0x8000000000000000 - 1;
+
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_runtime_test.dart b/tests/language_2/int64_literal_runtime_test.dart
new file mode 100644
index 0000000..d135bb1
--- /dev/null
+++ b/tests/language_2/int64_literal_runtime_test.dart
@@ -0,0 +1,40 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+const String realMaxInt64Value = '9223372036854775807';
+const String realMinInt64Value = '-9223372036854775808';
+
+const int i21 = 2097152;
+
+main() {
+ int minInt64Value = -1 * i21 * i21 * i21;
+
+
+
+
+
+
+
+ Expect.equals('$minInt64Value', realMinInt64Value);
+ Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
+
+ int maxInt64Value = 1 * i21 * i21 * i21 - 1;
+
+
+
+
+
+
+
+
+
+
+ Expect.equals('$maxInt64Value', realMaxInt64Value);
+ Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
+}
diff --git a/tests/language_2/int64_literal_test.dart b/tests/language_2/int64_literal_test.dart
index e111807..edce72e 100644
--- a/tests/language_2/int64_literal_test.dart
+++ b/tests/language_2/int64_literal_test.dart
@@ -11,26 +11,38 @@
main() {
int minInt64Value = -1 * i21 * i21 * i21;
- minInt64Value = -9223372036854775807 - 1; //# 01: ok
- minInt64Value = -9223372036854775808; //# 02: ok
- minInt64Value = -(9223372036854775808); //# 03: compile-time error
- minInt64Value = -(0x8000000000000000); //# 04: ok
- minInt64Value = 0x8000000000000000; //# 05: ok
- minInt64Value = -0x8000000000000000; //# 06: ok
+ minInt64Value = -9223372036854775807 - 1;
+ minInt64Value = -9223372036854775808;
+ minInt64Value = -(9223372036854775808);
+ // ^^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INTEGER_LITERAL_OUT_OF_RANGE
+ // [cfe] The integer literal 9223372036854775808 can't be represented in 64 bits.
+ minInt64Value = -(0x8000000000000000);
+ minInt64Value = 0x8000000000000000;
+ minInt64Value = -0x8000000000000000;
Expect.equals('$minInt64Value', realMinInt64Value);
Expect.equals('${minInt64Value - 1}', realMaxInt64Value);
int maxInt64Value = 1 * i21 * i21 * i21 - 1;
- maxInt64Value = 9223372036854775807; //# 11: ok
- maxInt64Value = 9223372036854775807; //# 12: ok
- maxInt64Value = 9223372036854775808 - 1; //# 13: compile-time error
- maxInt64Value = -9223372036854775808 - 1; //# 14: ok
- maxInt64Value = -9223372036854775809; //# 15: compile-time error
- maxInt64Value = 0x8000000000000000 - 1; //# 16: ok
- maxInt64Value = -0x8000000000000000 - 1; //# 17: ok
- maxInt64Value = -0x8000000000000001; //# 18: compile-time error
- maxInt64Value = -(0x8000000000000001); //# 19: ok
+ maxInt64Value = 9223372036854775807;
+ maxInt64Value = 9223372036854775807;
+ maxInt64Value = 9223372036854775808 - 1;
+ // ^^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INTEGER_LITERAL_OUT_OF_RANGE
+ // [cfe] The integer literal 9223372036854775808 can't be represented in 64 bits.
+ maxInt64Value = -9223372036854775808 - 1;
+ maxInt64Value = -9223372036854775809;
+ // ^^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INTEGER_LITERAL_OUT_OF_RANGE
+ // [cfe] The integer literal 9223372036854775809 can't be represented in 64 bits.
+ maxInt64Value = 0x8000000000000000 - 1;
+ maxInt64Value = -0x8000000000000000 - 1;
+ maxInt64Value = -0x8000000000000001;
+ // ^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INTEGER_LITERAL_OUT_OF_RANGE
+ // [cfe] The integer literal 0x8000000000000001 can't be represented in 64 bits.
+ maxInt64Value = -(0x8000000000000001);
Expect.equals('$maxInt64Value', realMaxInt64Value);
Expect.equals('${maxInt64Value + 1}', realMinInt64Value);
diff --git a/tests/language_2/interface_injection1_runtime_test.dart b/tests/language_2/interface_injection1_runtime_test.dart
new file mode 100644
index 0000000..ab438b4
--- /dev/null
+++ b/tests/language_2/interface_injection1_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// The removed language feature "interface injection" is now a syntax error.
+
+import "package:expect/expect.dart";
+
+abstract class S { }
+abstract class I { }
+
+
+class C implements I { }
+
+main() {
+ Expect.isFalse(new C() is S);
+}
diff --git a/tests/language_2/interface_injection1_test.dart b/tests/language_2/interface_injection1_test.dart
index 235903b..9a3faf4 100644
--- a/tests/language_2/interface_injection1_test.dart
+++ b/tests/language_2/interface_injection1_test.dart
@@ -8,9 +8,20 @@
abstract class S { }
abstract class I { }
-abstract class I implements S; //# 1: syntax error
+abstract class I implements S;
+// ^
+// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+// [cfe] 'I' is already declared in this scope.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+// [cfe] A class declaration must have a body, even if it is empty.
+// ^
+// [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN
+// [cfe] Unexpected token ';'.
class C implements I { }
+// ^
+// [cfe] 'I' isn't a type.
main() {
Expect.isFalse(new C() is S);
diff --git a/tests/language_2/interface_injection2_runtime_test.dart b/tests/language_2/interface_injection2_runtime_test.dart
new file mode 100644
index 0000000..a8a6788
--- /dev/null
+++ b/tests/language_2/interface_injection2_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// The removed language feature "interface injection" is now a syntax error.
+
+import "package:expect/expect.dart";
+
+abstract class S { }
+class C { }
+
+
+main() {
+ Expect.isFalse(new C() is S);
+}
diff --git a/tests/language_2/interface_injection2_test.dart b/tests/language_2/interface_injection2_test.dart
index ef7937e..e49d5bd 100644
--- a/tests/language_2/interface_injection2_test.dart
+++ b/tests/language_2/interface_injection2_test.dart
@@ -8,8 +8,19 @@
abstract class S { }
class C { }
-class C implements S; //# 1: syntax error
+class C implements S;
+// ^
+// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+// [cfe] 'C' is already declared in this scope.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+// [cfe] A class declaration must have a body, even if it is empty.
+// ^
+// [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN
+// [cfe] Unexpected token ';'.
main() {
Expect.isFalse(new C() is S);
+ // ^
+ // [cfe] Method not found: 'C'.
}
diff --git a/tests/language_2/interface_runtime_test.dart b/tests/language_2/interface_runtime_test.dart
new file mode 100644
index 0000000..b789fe7
--- /dev/null
+++ b/tests/language_2/interface_runtime_test.dart
@@ -0,0 +1,45 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Dart test program for testing Interfaces.
+
+abstract class Ai {
+ int foo();
+}
+
+abstract class Bi implements Ai {
+
+}
+
+abstract class Simple implements Ai {}
+
+abstract class Aai {}
+
+abstract class Abi {}
+
+abstract class Bar {}
+
+abstract class Foo implements Bar {}
+
+abstract class Baz implements Bar, Foo {}
+
+abstract class InterfaceTest implements Ai, Aai, Abi, Baz, Bi {
+ var f;
+
+ InterfaceTest() {}
+ int foo() {
+ return 1;
+ }
+
+ // intentionally unimplemented methods
+ beta(); // Abstract.
+ String beta1(); // Abstract.
+ String beta2(double d); // Abstract.
+}
+
+main() {
+
+}
diff --git a/tests/language_2/interface_static_method_test.dart b/tests/language_2/interface_static_method_test.dart
index 9170aac..b07e7b9 100644
--- a/tests/language_2/interface_static_method_test.dart
+++ b/tests/language_2/interface_static_method_test.dart
@@ -12,6 +12,6 @@
main() {
A();
//^
-// [analyzer] STATIC_WARNING.NEW_WITH_ABSTRACT_CLASS
+// [analyzer] STATIC_WARNING.INSTANTIATE_ABSTRACT_CLASS
// [cfe] The class 'A' is abstract and can't be instantiated.
}
diff --git a/tests/language_2/interface_test.dart b/tests/language_2/interface_test.dart
index 925f000..5ffd3d4 100644
--- a/tests/language_2/interface_test.dart
+++ b/tests/language_2/interface_test.dart
@@ -8,7 +8,9 @@
}
abstract class Bi implements Ai {
- factory Bi() = InterfaceTest; //# 00: compile-time error
+ factory Bi() = InterfaceTest;
+ // ^
+ // [cfe] Factory redirects to class 'InterfaceTest', which is abstract and can't be instantiated.
}
abstract class Simple implements Ai {}
@@ -38,5 +40,5 @@
}
main() {
- new Bi(); //# 00: continued
+ new Bi();
}
diff --git a/tests/language_2/internal_library_runtime_test.dart b/tests/language_2/internal_library_runtime_test.dart
new file mode 100644
index 0000000..a0e4c23
--- /dev/null
+++ b/tests/language_2/internal_library_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test that a private library cannot be accessed from outside the platform.
+
+library internal_library_test;
+
+import 'dart:core'; // This loads 'dart:_foreign_helper' and 'patch:core'.
+
+
+
+
+void main() {
+
+
+}
diff --git a/tests/language_2/internal_library_test.dart b/tests/language_2/internal_library_test.dart
index dd399cb..4983fd9 100644
--- a/tests/language_2/internal_library_test.dart
+++ b/tests/language_2/internal_library_test.dart
@@ -7,11 +7,27 @@
library internal_library_test;
import 'dart:core'; // This loads 'dart:_foreign_helper' and 'patch:core'.
-import 'dart:_foreign_helper'; //# 01: compile-time error
+import 'dart:_foreign_helper';
+// ^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.IMPORT_INTERNAL_LIBRARY
+// [cfe] Can't access platform private library.
+// ^
+// [cfe] Not found: 'dart:_foreign_helper'
-part 'dart:_foreign_helper'; //# 02: compile-time error
+part 'dart:_foreign_helper';
+// ^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.PART_OF_NON_PART
+// [cfe] Can't access platform private library.
+// ^
+// [cfe] Can't use 'org-dartlang-untranslatable-uri:dart%3A_foreign_helper' as a part, because it has no 'part of' declaration.
+// ^
+// [cfe] Not found: 'dart:_foreign_helper'
void main() {
- JS('int', '0'); //# 01: continued
- JS('int', '0'); //# 02: continued
+ JS('int', '0');
+//^
+// [cfe] Method not found: 'JS'.
+ JS('int', '0');
+//^
+// [cfe] Method not found: 'JS'.
}
diff --git a/tests/language_2/inv_cse_licm.dart b/tests/language_2/inv_cse_licm.dart
deleted file mode 100644
index 43624cb..0000000
--- a/tests/language_2/inv_cse_licm.dart
+++ /dev/null
@@ -1,499 +0,0 @@
-// Copyright (c) 2019, 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.
-
-// VMOptions=--deterministic--optimization_counter_threshold=10
-
-import 'dart:typed_data';
-import "package:expect/expect.dart";
-
-// Tests a few situations in which invariant instructions
-// can be subject to CSE and LICM.
-
-@pragma('vm:never-inline')
-int cse1(Int32List a, int n) {
- int x = a[0];
- for (int i = 0; i < n; i++) {
- // The a[0] null check, bounds check, and the actual load can be
- // CSEed with the instructions above even if loop is not taken.
- x += a[0] * a[i];
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int cse2(Int32List a, int n) {
- int x = a[0];
- for (int i = 0; i < n; i++) {
- // The a[0] null check, bounds check, but not the actual load can be
- // CSEed with the instructions above, since the value of the load
- // changes in the loop.
- a[i] = a[0] + 1;
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm1(Int32List a, int n) {
- int x = 0;
- for (int i = 0; i < n; i++) {
- // The a[0] null check, bounds check, and the actual load cannot
- // be LICMed, since the loop may be non-taken.
- x += a[0] * a[i];
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm2(Int32List a) {
- int x = 0;
- for (int i = 0; i < 16; i++) {
- // The a[0] null check, bounds check, and the actual load can be
- // LICMed, since the loop is always-taken.
- x += a[0] * a[i];
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm3(Int32List a, bool cond) {
- int x = 0;
- for (int i = 0; i < 16; i++) {
- // The a[0] null check, bounds check, and the actual load cannot
- // be LICMed, since the condition may be non-taken (and we don't
- // hoist invariant conditions).
- if (cond) x += a[0] * a[i];
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm3_brk(Int32List a, bool cond) {
- int x = 0;
- for (int i = 0; i < 16; i++) {
- // The a[0] null check, bounds check, and the actual load cannot
- // be LICMed, since the condition may be taken (and we don't
- // hoist invariant conditions).
- if (cond) break;
- x += a[0] * a[i];
- }
- return x;
-}
-
-int global;
-
-@pragma('vm:never-inline')
-int licm4(Int32List a) {
- int x = 0;
- for (int i = 0; i < 16; i++) {
- // The a[0] null check, bounds check, and the actual load cannot
- // be LICMed, since something visible happens before an exception
- // may be thrown.
- global++;
- x += a[0] * a[i];
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm5(Int32List a) {
- int x = 0;
- // Anything in the loop header can be LICMed.
- for (int i = 0; i < a[1]; i++) {
- x++;
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm6(Int32List a, int n) {
- int x = 0;
- int i = 0;
- do {
- // The a[0] null check, bounds check, and the actual load can be
- // LICMed, since this "header" is always-taken.
- x += a[0] * a[i++];
- } while (i < n);
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm7(Int32List a, int n) {
- int x = 0;
- int i = 0;
- while (true) {
- // The a[0] null check, bounds check, and the actual load can be
- // LICMed, since this "header" is always-taken.
- x += a[0] * a[i++];
- if (i >= n) break;
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm8(Int32List a, int n) {
- int x = 0;
- int i = 0;
- while (true) {
- if (i >= n) break;
- // No LICM at this point, loop body may not be taken.
- x += a[0] * a[i++];
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm9(Int32List a) {
- int x = 0;
- int i = 0;
- while (true) {
- if (i >= 16) break;
- // The a[0] null check, bounds check, and the actual load can be
- // LICMed, since the loop is always-taken.
- x += a[0] * a[i++];
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm10(Int32List a, bool cond) {
- int x = 0;
- int i = 0;
- while (true) {
- if (i >= 16) break;
- // The a[0] null check, bounds check, and the actual load cannot
- // be LICMed, since the condition may be non-taken (and we don't
- // hoist invariant conditions).
- if (cond) x += a[0] * a[i];
- i++;
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm10_brk(Int32List a, bool cond) {
- int x = 0;
- int i = 0;
- while (true) {
- if (i >= 16) break;
- // The a[0] null check, bounds check, and the actual load cannot
- // be LICMed, since the condition may be taken (and we don't
- // hoist invariant conditions).
- if (cond) break;
- x += a[0] * a[i++];
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int licm11(Int32List a) {
- int x = 0;
- while (true) {
- // Anything in the loop header can be LICMed.
- if (x > a[1]) break;
- x++;
- }
- return x;
-}
-
-@pragma('vm:never-inline')
-int foo() {
- return global--;
-}
-
-@pragma('vm:never-inline')
-int licm12(Int32List a) {
- int x = 0;
- int i = 0;
- // Side-effect loop bound.
- for (int i = 0; i < foo(); i++) {
- x += a[0] * a[i++];
- }
- return x;
-}
-
-doTests() {
- var x = new Int32List(0);
- var a = new Int32List(16);
- for (int i = 0; i < 16; i++) {
- a[i] = i + 1;
- }
-
- Expect.throws(() {
- cse1(null, 0);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- cse1(null, 1);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- cse1(x, 0);
- }, (e) {
- return e is RangeError;
- });
- Expect.throws(() {
- cse1(x, 1);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(1, cse1(a, 0));
- Expect.equals(137, cse1(a, 16));
-
- Expect.throws(() {
- cse2(null, 0);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- cse2(null, 1);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- cse2(x, 0);
- }, (e) {
- return e is RangeError;
- });
- Expect.throws(() {
- cse2(x, 1);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(1, cse2(a, 0));
- Expect.equals(1, cse2(a, 16));
- Expect.equals(2, a[0]);
- for (int i = 1; i < 16; i++) {
- Expect.equals(3, a[i]);
- }
-
- Expect.equals(0, licm1(null, 0));
- Expect.throws(() {
- licm1(null, 1);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.equals(0, licm1(x, 0));
- Expect.throws(() {
- licm1(x, 1);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(0, licm1(a, 0));
- Expect.equals(94, licm1(a, 16));
-
- Expect.throws(() {
- licm2(null);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- licm2(x);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(94, licm2(a));
-
- Expect.equals(0, licm3(null, false));
- Expect.throws(() {
- licm3(null, true);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.equals(0, licm3(x, false));
- Expect.throws(() {
- licm3(x, true);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(0, licm3(a, false));
- Expect.equals(94, licm3(a, true));
-
- Expect.equals(0, licm3_brk(null, true));
- Expect.throws(() {
- licm3_brk(null, false);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.equals(0, licm3_brk(x, true));
- Expect.throws(() {
- licm3_brk(x, false);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(0, licm3_brk(a, true));
- Expect.equals(94, licm3_brk(a, false));
-
- global = 0;
- Expect.throws(() {
- licm4(null);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.equals(1, global);
- Expect.throws(() {
- licm4(x);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(2, global);
- Expect.equals(94, licm4(a));
- Expect.equals(18, global);
-
- Expect.throws(() {
- licm5(null);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- licm5(x);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(3, licm5(a));
-
- Expect.throws(() {
- licm6(null, 0);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- licm6(null, 1);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- licm6(x, 0);
- }, (e) {
- return e is RangeError;
- });
- Expect.throws(() {
- licm6(x, 1);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(4, licm6(a, 0));
- Expect.equals(94, licm6(a, 16));
-
- Expect.throws(() {
- licm7(null, 0);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- licm7(null, 1);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- licm7(x, 0);
- }, (e) {
- return e is RangeError;
- });
- Expect.throws(() {
- licm7(x, 1);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(4, licm7(a, 0));
- Expect.equals(94, licm7(a, 16));
-
- Expect.equals(0, licm8(null, 0));
- Expect.throws(() {
- licm8(null, 1);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.equals(0, licm8(x, 0));
- Expect.throws(() {
- licm8(x, 1);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(0, licm8(a, 0));
- Expect.equals(94, licm8(a, 16));
-
- Expect.throws(() {
- licm9(null);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- licm9(x);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(94, licm9(a));
-
- Expect.equals(0, licm10(null, false));
- Expect.throws(() {
- licm10(null, true);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.equals(0, licm10(x, false));
- Expect.throws(() {
- licm10(x, true);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(0, licm10(a, false));
- Expect.equals(94, licm10(a, true));
-
- Expect.equals(0, licm10_brk(null, true));
- Expect.throws(() {
- licm10_brk(null, false);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.equals(0, licm10_brk(x, true));
- Expect.throws(() {
- licm10_brk(x, false);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(0, licm10_brk(a, true));
- Expect.equals(94, licm10_brk(a, false));
-
- Expect.throws(() {
- licm11(null);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.throws(() {
- licm11(x);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(4, licm11(a));
-
- global = 0;
- Expect.equals(0, licm12(null));
- Expect.equals(-1, global);
- Expect.equals(0, licm12(x));
- Expect.equals(-2, global);
- global = 16;
- Expect.throws(() {
- licm12(null);
- }, (e) {
- return e is NoSuchMethodError;
- });
- Expect.equals(15, global);
- Expect.throws(() {
- licm12(x);
- }, (e) {
- return e is RangeError;
- });
- Expect.equals(14, global);
- Expect.equals(28, licm12(a));
- Expect.equals(8, global);
-}
-
-main() {
- // Repeat to enter JIT (when applicable).
- for (int i = 0; i < 20; i++) {
- doTests();
- }
-}
diff --git a/tests/language_2/inv_cse_licm_test.dart b/tests/language_2/inv_cse_licm_test.dart
new file mode 100644
index 0000000..267e757
--- /dev/null
+++ b/tests/language_2/inv_cse_licm_test.dart
@@ -0,0 +1,499 @@
+// Copyright (c) 2019, 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.
+
+// VMOptions=--deterministic --optimization_counter_threshold=10
+
+import 'dart:typed_data';
+import "package:expect/expect.dart";
+
+// Tests a few situations in which invariant instructions
+// can be subject to CSE and LICM.
+
+@pragma('vm:never-inline')
+int cse1(Int32List a, int n) {
+ int x = a[0];
+ for (int i = 0; i < n; i++) {
+ // The a[0] null check, bounds check, and the actual load can be
+ // CSEed with the instructions above even if loop is not taken.
+ x += a[0] * a[i];
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int cse2(Int32List a, int n) {
+ int x = a[0];
+ for (int i = 0; i < n; i++) {
+ // The a[0] null check, bounds check, but not the actual load can be
+ // CSEed with the instructions above, since the value of the load
+ // changes in the loop.
+ a[i] = a[0] + 1;
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm1(Int32List a, int n) {
+ int x = 0;
+ for (int i = 0; i < n; i++) {
+ // The a[0] null check, bounds check, and the actual load cannot
+ // be LICMed, since the loop may be non-taken.
+ x += a[0] * a[i];
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm2(Int32List a) {
+ int x = 0;
+ for (int i = 0; i < 16; i++) {
+ // The a[0] null check, bounds check, and the actual load can be
+ // LICMed, since the loop is always-taken.
+ x += a[0] * a[i];
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm3(Int32List a, bool cond) {
+ int x = 0;
+ for (int i = 0; i < 16; i++) {
+ // The a[0] null check, bounds check, and the actual load cannot
+ // be LICMed, since the condition may be non-taken (and we don't
+ // hoist invariant conditions).
+ if (cond) x += a[0] * a[i];
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm3_brk(Int32List a, bool cond) {
+ int x = 0;
+ for (int i = 0; i < 16; i++) {
+ // The a[0] null check, bounds check, and the actual load cannot
+ // be LICMed, since the condition may be taken (and we don't
+ // hoist invariant conditions).
+ if (cond) break;
+ x += a[0] * a[i];
+ }
+ return x;
+}
+
+int global;
+
+@pragma('vm:never-inline')
+int licm4(Int32List a) {
+ int x = 0;
+ for (int i = 0; i < 16; i++) {
+ // The a[0] null check, bounds check, and the actual load cannot
+ // be LICMed, since something visible happens before an exception
+ // may be thrown.
+ global++;
+ x += a[0] * a[i];
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm5(Int32List a) {
+ int x = 0;
+ // Anything in the loop header can be LICMed.
+ for (int i = 0; i < a[1]; i++) {
+ x++;
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm6(Int32List a, int n) {
+ int x = 0;
+ int i = 0;
+ do {
+ // The a[0] null check, bounds check, and the actual load can be
+ // LICMed, since this "header" is always-taken.
+ x += a[0] * a[i++];
+ } while (i < n);
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm7(Int32List a, int n) {
+ int x = 0;
+ int i = 0;
+ while (true) {
+ // The a[0] null check, bounds check, and the actual load can be
+ // LICMed, since this "header" is always-taken.
+ x += a[0] * a[i++];
+ if (i >= n) break;
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm8(Int32List a, int n) {
+ int x = 0;
+ int i = 0;
+ while (true) {
+ if (i >= n) break;
+ // No LICM at this point, loop body may not be taken.
+ x += a[0] * a[i++];
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm9(Int32List a) {
+ int x = 0;
+ int i = 0;
+ while (true) {
+ if (i >= 16) break;
+ // The a[0] null check, bounds check, and the actual load can be
+ // LICMed, since the loop is always-taken.
+ x += a[0] * a[i++];
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm10(Int32List a, bool cond) {
+ int x = 0;
+ int i = 0;
+ while (true) {
+ if (i >= 16) break;
+ // The a[0] null check, bounds check, and the actual load cannot
+ // be LICMed, since the condition may be non-taken (and we don't
+ // hoist invariant conditions).
+ if (cond) x += a[0] * a[i];
+ i++;
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm10_brk(Int32List a, bool cond) {
+ int x = 0;
+ int i = 0;
+ while (true) {
+ if (i >= 16) break;
+ // The a[0] null check, bounds check, and the actual load cannot
+ // be LICMed, since the condition may be taken (and we don't
+ // hoist invariant conditions).
+ if (cond) break;
+ x += a[0] * a[i++];
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int licm11(Int32List a) {
+ int x = 0;
+ while (true) {
+ // Anything in the loop header can be LICMed.
+ if (x > a[1]) break;
+ x++;
+ }
+ return x;
+}
+
+@pragma('vm:never-inline')
+int foo() {
+ return global--;
+}
+
+@pragma('vm:never-inline')
+int licm12(Int32List a) {
+ int x = 0;
+ int i = 0;
+ // Side-effect loop bound.
+ for (int i = 0; i < foo(); i++) {
+ x += a[0] * a[i++];
+ }
+ return x;
+}
+
+doTests() {
+ var x = new Int32List(0);
+ var a = new Int32List(16);
+ for (int i = 0; i < 16; i++) {
+ a[i] = i + 1;
+ }
+
+ Expect.throws(() {
+ cse1(null, 0);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ cse1(null, 1);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ cse1(x, 0);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.throws(() {
+ cse1(x, 1);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(1, cse1(a, 0));
+ Expect.equals(137, cse1(a, 16));
+
+ Expect.throws(() {
+ cse2(null, 0);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ cse2(null, 1);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ cse2(x, 0);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.throws(() {
+ cse2(x, 1);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(1, cse2(a, 0));
+ Expect.equals(1, cse2(a, 16));
+ Expect.equals(2, a[0]);
+ for (int i = 1; i < 16; i++) {
+ Expect.equals(3, a[i]);
+ }
+
+ Expect.equals(0, licm1(null, 0));
+ Expect.throws(() {
+ licm1(null, 1);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.equals(0, licm1(x, 0));
+ Expect.throws(() {
+ licm1(x, 1);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(0, licm1(a, 0));
+ Expect.equals(94, licm1(a, 16));
+
+ Expect.throws(() {
+ licm2(null);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ licm2(x);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(94, licm2(a));
+
+ Expect.equals(0, licm3(null, false));
+ Expect.throws(() {
+ licm3(null, true);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.equals(0, licm3(x, false));
+ Expect.throws(() {
+ licm3(x, true);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(0, licm3(a, false));
+ Expect.equals(94, licm3(a, true));
+
+ Expect.equals(0, licm3_brk(null, true));
+ Expect.throws(() {
+ licm3_brk(null, false);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.equals(0, licm3_brk(x, true));
+ Expect.throws(() {
+ licm3_brk(x, false);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(0, licm3_brk(a, true));
+ Expect.equals(94, licm3_brk(a, false));
+
+ global = 0;
+ Expect.throws(() {
+ licm4(null);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.equals(1, global);
+ Expect.throws(() {
+ licm4(x);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(2, global);
+ Expect.equals(94, licm4(a));
+ Expect.equals(18, global);
+
+ Expect.throws(() {
+ licm5(null);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ licm5(x);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(3, licm5(a));
+
+ Expect.throws(() {
+ licm6(null, 0);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ licm6(null, 1);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ licm6(x, 0);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.throws(() {
+ licm6(x, 1);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(4, licm6(a, 0));
+ Expect.equals(94, licm6(a, 16));
+
+ Expect.throws(() {
+ licm7(null, 0);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ licm7(null, 1);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ licm7(x, 0);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.throws(() {
+ licm7(x, 1);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(4, licm7(a, 0));
+ Expect.equals(94, licm7(a, 16));
+
+ Expect.equals(0, licm8(null, 0));
+ Expect.throws(() {
+ licm8(null, 1);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.equals(0, licm8(x, 0));
+ Expect.throws(() {
+ licm8(x, 1);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(0, licm8(a, 0));
+ Expect.equals(94, licm8(a, 16));
+
+ Expect.throws(() {
+ licm9(null);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ licm9(x);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(94, licm9(a));
+
+ Expect.equals(0, licm10(null, false));
+ Expect.throws(() {
+ licm10(null, true);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.equals(0, licm10(x, false));
+ Expect.throws(() {
+ licm10(x, true);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(0, licm10(a, false));
+ Expect.equals(94, licm10(a, true));
+
+ Expect.equals(0, licm10_brk(null, true));
+ Expect.throws(() {
+ licm10_brk(null, false);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.equals(0, licm10_brk(x, true));
+ Expect.throws(() {
+ licm10_brk(x, false);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(0, licm10_brk(a, true));
+ Expect.equals(94, licm10_brk(a, false));
+
+ Expect.throws(() {
+ licm11(null);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.throws(() {
+ licm11(x);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(4, licm11(a));
+
+ global = 0;
+ Expect.equals(0, licm12(null));
+ Expect.equals(-1, global);
+ Expect.equals(0, licm12(x));
+ Expect.equals(-2, global);
+ global = 16;
+ Expect.throws(() {
+ licm12(null);
+ }, (e) {
+ return e is NoSuchMethodError;
+ });
+ Expect.equals(15, global);
+ Expect.throws(() {
+ licm12(x);
+ }, (e) {
+ return e is RangeError;
+ });
+ Expect.equals(14, global);
+ Expect.equals(28, licm12(a));
+ Expect.equals(8, global);
+}
+
+main() {
+ // Repeat to enter JIT (when applicable).
+ for (int i = 0; i < 20; i++) {
+ doTests();
+ }
+}
diff --git a/tests/language_2/invalid_assignment_to_postfix_increment_runtime_test.dart b/tests/language_2/invalid_assignment_to_postfix_increment_runtime_test.dart
new file mode 100644
index 0000000..6998367
--- /dev/null
+++ b/tests/language_2/invalid_assignment_to_postfix_increment_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+void f(int x, int y) {
+
+
+
+}
+
+main() {
+ f(1, 2);
+}
diff --git a/tests/language_2/invalid_assignment_to_postfix_increment_test.dart b/tests/language_2/invalid_assignment_to_postfix_increment_test.dart
index eda617b..fcae91f 100644
--- a/tests/language_2/invalid_assignment_to_postfix_increment_test.dart
+++ b/tests/language_2/invalid_assignment_to_postfix_increment_test.dart
@@ -3,9 +3,27 @@
// BSD-style license that can be found in the LICENSE file.
void f(int x, int y) {
- x++ = y; //# 01: syntax error
- x++ += y; //# 02: syntax error
- x++ ??= y; //# 03: syntax error
+ x++ = y;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+//^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+// ^
+// [cfe] Illegal assignment to non-assignable expression.
+ x++ += y;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+//^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+// ^
+// [cfe] Illegal assignment to non-assignable expression.
+ x++ ??= y;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE
+//^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+// ^
+// [cfe] Illegal assignment to non-assignable expression.
}
main() {
diff --git a/tests/language_2/invalid_cast_runtime_1_test.dart b/tests/language_2/invalid_cast_runtime_1_test.dart
new file mode 100644
index 0000000..52d4ced
--- /dev/null
+++ b/tests/language_2/invalid_cast_runtime_1_test.dart
@@ -0,0 +1,36 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+class C {
+ C();
+ factory C.fact() => null;
+ factory C.fact2() = D;
+ C.nonFact();
+ C.nonFact2() : this.nonFact();
+ static void staticFunction(int i) {}
+}
+
+class D extends C {}
+
+void topLevelFunction(int i) {}
+
+test() {
+ void localFunction(int i) {}
+
+
+
+
+ D e = new C.fact();
+
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/invalid_cast_runtime_2_test.dart b/tests/language_2/invalid_cast_runtime_2_test.dart
new file mode 100644
index 0000000..7e97e48
--- /dev/null
+++ b/tests/language_2/invalid_cast_runtime_2_test.dart
@@ -0,0 +1,36 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+class C {
+ C();
+ factory C.fact() => null;
+ factory C.fact2() = D;
+ C.nonFact();
+ C.nonFact2() : this.nonFact();
+ static void staticFunction(int i) {}
+}
+
+class D extends C {}
+
+void topLevelFunction(int i) {}
+
+test() {
+ void localFunction(int i) {}
+
+
+
+
+
+ D f = new C.fact2();
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/invalid_cast_runtime_test.dart b/tests/language_2/invalid_cast_runtime_test.dart
new file mode 100644
index 0000000..60403e0
--- /dev/null
+++ b/tests/language_2/invalid_cast_runtime_test.dart
@@ -0,0 +1,36 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+class C {
+ C();
+ factory C.fact() => null;
+ factory C.fact2() = D;
+ C.nonFact();
+ C.nonFact2() : this.nonFact();
+ static void staticFunction(int i) {}
+}
+
+class D extends C {}
+
+void topLevelFunction(int i) {}
+
+test() {
+ void localFunction(int i) {}
+
+
+
+
+
+
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/invalid_cast_test.dart b/tests/language_2/invalid_cast_test.dart
index 72fc76a..e00a1d6 100644
--- a/tests/language_2/invalid_cast_test.dart
+++ b/tests/language_2/invalid_cast_test.dart
@@ -17,17 +17,50 @@
test() {
void localFunction(int i) {}
- List<int> a = <Object>[]; //# 01: compile-time error
- Map<int, String> b = <Object, String>{}; //# 02: compile-time error
- Map<int, String> c = <int, Object>{}; //# 03: compile-time error
- int Function(Object) d = (int i) => i; //# 04: compile-time error
- D e = new C.fact(); //# 05: ok
- D f = new C.fact2(); //# 06: ok
- D g = new C.nonFact(); //# 07: compile-time error
- D h = new C.nonFact2(); //# 08: compile-time error
- void Function(Object) i = C.staticFunction; //# 09: compile-time error
- void Function(Object) j = topLevelFunction; //# 10: compile-time error
- void Function(Object) k = localFunction; //# 11: compile-time error
+ List<int> a = <Object>[];
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_LITERAL_LIST
+ // ^
+ // [cfe] The list literal type 'List<Object>' isn't of expected type 'List<int>'.
+ Map<int, String> b = <Object, String>{};
+ // ^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_LITERAL_MAP
+ // ^
+ // [cfe] The map literal type 'Map<Object, String>' isn't of expected type 'Map<int, String>'.
+ Map<int, String> c = <int, Object>{};
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_LITERAL_MAP
+ // ^
+ // [cfe] The map literal type 'Map<int, Object>' isn't of expected type 'Map<int, String>'.
+ int Function(Object) d = (int i) => i;
+ // ^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_FUNCTION_EXPR
+ // [cfe] The function expression type 'int Function(int)' isn't of expected type 'int Function(Object)'.
+ D e = new C.fact();
+ D f = new C.fact2();
+ D g = new C.nonFact();
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_NEW_EXPR
+ // ^
+ // [cfe] The constructor returns type 'C' that isn't of expected type 'D'.
+ D h = new C.nonFact2();
+ // ^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_NEW_EXPR
+ // ^
+ // [cfe] The constructor returns type 'C' that isn't of expected type 'D'.
+ void Function(Object) i = C.staticFunction;
+ // ^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_METHOD
+ // ^
+ // [cfe] The static method has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
+ void Function(Object) j = topLevelFunction;
+ // ^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_FUNCTION
+ // [cfe] The top level function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
+ void Function(Object) k = localFunction;
+ // ^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_FUNCTION
+ // [cfe] The local function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
}
main() {}
diff --git a/tests/language_2/invalid_override_in_mixin_runtime_test.dart b/tests/language_2/invalid_override_in_mixin_runtime_test.dart
new file mode 100644
index 0000000..7584e4a
--- /dev/null
+++ b/tests/language_2/invalid_override_in_mixin_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import 'package:expect/expect.dart';
+
+class A {
+
+}
+
+class C extends Object with A {
+ test() {
+ print("Hello from test");
+ }
+}
+
+main() {
+ C c = new C();
+ c.test();
+ dynamic cc = c;
+ Expect.throwsNoSuchMethodError(() => cc.doesntExist());
+}
diff --git a/tests/language_2/invalid_override_in_mixin_test.dart b/tests/language_2/invalid_override_in_mixin_test.dart
index 426dac0..b8edfea 100644
--- a/tests/language_2/invalid_override_in_mixin_test.dart
+++ b/tests/language_2/invalid_override_in_mixin_test.dart
@@ -5,10 +5,20 @@
import 'package:expect/expect.dart';
class A {
- noSuchMethod() {} // //# 01: compile-time error
+ noSuchMethod() {}
+//^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+// [cfe] The method 'A.noSuchMethod' has fewer positional arguments than those of overridden method 'Object.noSuchMethod'.
}
class C extends Object with A {
+// ^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Applying the mixin 'A' to 'Object' introduces an erroneous override of 'noSuchMethod'.
+// ^
+// [cfe] Class 'Object with A' inherits multiple members named 'noSuchMethod' with incompatible signatures.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
test() {
print("Hello from test");
}
diff --git a/tests/language_2/invalid_type_argument_count_runtime_test.dart b/tests/language_2/invalid_type_argument_count_runtime_test.dart
new file mode 100644
index 0000000..a0959a8
--- /dev/null
+++ b/tests/language_2/invalid_type_argument_count_runtime_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test top level field.
+dynamic // Formatter shouldn't join this line.
+
+ x1 = 42;
+
+class Foo {
+ // Test class member.
+ dynamic // Formatter shouldn't join this line.
+
+ x2 = 42;
+
+ Foo() {
+ print(x2);
+ }
+}
+
+main() {
+ print(x1);
+
+ new Foo();
+
+ // Test local variable.
+ dynamic // Formatter shouldn't join this line.
+
+ x3 = 42;
+ print(x3);
+
+ foo(42);
+}
+
+// Test parameter.
+void foo(
+ dynamic // Formatter shouldn't join this line.
+
+ x4) {
+ print(x4);
+}
diff --git a/tests/language_2/invalid_type_argument_count_test.dart b/tests/language_2/invalid_type_argument_count_test.dart
index 7e9c351..3a93da2 100644
--- a/tests/language_2/invalid_type_argument_count_test.dart
+++ b/tests/language_2/invalid_type_argument_count_test.dart
@@ -3,15 +3,17 @@
// BSD-style license that can be found in the LICENSE file.
// Test top level field.
-dynamic // Formatter shouldn't join this line.
- <int> // //# 01: compile-time error
- x1 = 42;
+dynamic<int> x1 = 42;
+// [error line 6, column 1, length 12]
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 0 type arguments.
class Foo {
// Test class member.
- dynamic // Formatter shouldn't join this line.
- <int> // //# 02: compile-time error
- x2 = 42;
+ dynamic<int> x2 = 42;
+// [error line 13, column 3, length 12]
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 0 type arguments.
Foo() {
print(x2);
@@ -24,18 +26,19 @@
new Foo();
// Test local variable.
- dynamic // Formatter shouldn't join this line.
- <int> // //# 03: compile-time error
- x3 = 42;
+ dynamic<int> x3 = 42;
+// [error line 29, column 3, length 12]
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 0 type arguments.
print(x3);
foo(42);
}
// Test parameter.
-void foo(
- dynamic // Formatter shouldn't join this line.
- <int> // //# 04: compile-time error
- x4) {
+void foo(dynamic<int> x4) {
+// [error line 39, column 10, length 12]
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 0 type arguments.
print(x4);
}
diff --git a/tests/language_2/is_malformed_type_runtime_test.dart b/tests/language_2/is_malformed_type_runtime_test.dart
new file mode 100644
index 0000000..1389f62
--- /dev/null
+++ b/tests/language_2/is_malformed_type_runtime_test.dart
@@ -0,0 +1,60 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+// Dart test program for the "is" and "as" operator with malformed type.
+
+import "package:expect/expect.dart";
+
+testEval(x) {
+ return x;
+}
+
+test99(e) {
+ // Test that a runtime error is thrown when the 'is' operator checks for a
+ // malformed type.
+
+}
+
+test98(e) {
+ // Test that a runtime error is thrown when the 'as' operator checks for a
+ // malformed type.
+
+}
+
+test97(e) {
+ // Check that the remaining expression after the type test
+ // with malformed type is parsed, but not executed at runtime.
+ // Regression test for issue 16985.
+
+}
+
+test96(e) {
+ // Check that the remaining expression after the type test
+ // with malformed type is parsed, but not executed at runtime.
+ // Regression test for issue 16985.
+
+}
+
+test95(e) {
+ // Check that the type-tested expression is evaluated before the
+ // runtime error is thrown.
+
+}
+
+test94(e) {
+ // Check that the type-tested expression is evaluated before the
+ // runtime error is thrown.
+
+}
+
+main() {
+
+
+
+
+
+
+}
diff --git a/tests/language_2/is_malformed_type_test.dart b/tests/language_2/is_malformed_type_test.dart
index e1c5d5d..d54d4de 100644
--- a/tests/language_2/is_malformed_type_test.dart
+++ b/tests/language_2/is_malformed_type_test.dart
@@ -12,46 +12,64 @@
test99(e) {
// Test that a runtime error is thrown when the 'is' operator checks for a
// malformed type.
- if (e is Undefined) Expect.fail("unreachable"); // //# 99: continued
+ if (e is Undefined) Expect.fail("unreachable");
+ // ^^^^^^^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_UNDEFINED_NAME
+ // [cfe] 'Undefined' isn't a type.
}
test98(e) {
// Test that a runtime error is thrown when the 'as' operator checks for a
// malformed type.
- if (e as Undefined) Expect.fail("unreachable"); // //# 98: continued
+ if (e as Undefined) Expect.fail("unreachable");
+ // ^^^^^^^^^
+ // [analyzer] STATIC_WARNING.CAST_TO_NON_TYPE
+ // [cfe] 'Undefined' isn't a type.
}
test97(e) {
// Check that the remaining expression after the type test
// with malformed type is parsed, but not executed at runtime.
// Regression test for issue 16985.
- if (e is Undefined && testEval(e)) Expect.fail("unreachable"); // //# 97: continued
+ if (e is Undefined && testEval(e)) Expect.fail("unreachable");
+ // ^^^^^^^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_UNDEFINED_NAME
+ // [cfe] 'Undefined' isn't a type.
}
test96(e) {
// Check that the remaining expression after the type test
// with malformed type is parsed, but not executed at runtime.
// Regression test for issue 16985.
- if (e as Undefined && testEval(e)) Expect.fail("unreachable"); // //# 96: continued
+ if (e as Undefined && testEval(e)) Expect.fail("unreachable");
+ // ^^^^^^^^^
+ // [analyzer] STATIC_WARNING.CAST_TO_NON_TYPE
+ // [cfe] 'Undefined' isn't a type.
}
test95(e) {
// Check that the type-tested expression is evaluated before the
// runtime error is thrown.
- if (testEval(e) is Undefined) Expect.fail("unreachable"); // //# 95: continued
+ if (testEval(e) is Undefined) Expect.fail("unreachable");
+ // ^^^^^^^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_UNDEFINED_NAME
+ // [cfe] 'Undefined' isn't a type.
}
test94(e) {
// Check that the type-tested expression is evaluated before the
// runtime error is thrown.
- if (testEval(e) as Undefined) Expect.fail("unreachable"); // //# 94: continued
+ if (testEval(e) as Undefined) Expect.fail("unreachable");
+ // ^^^^^^^^^
+ // [analyzer] STATIC_WARNING.CAST_TO_NON_TYPE
+ // [cfe] 'Undefined' isn't a type.
}
main() {
- test99("99 bottles"); //# 99: compile-time error
- test98("98 bottles"); //# 98: compile-time error
- test97("97 bottles"); //# 97: compile-time error
- test96("96 bottles"); //# 96: compile-time error
- test95("95 bottles"); //# 95: compile-time error
- test94("94 bottles"); //# 94: compile-time error
+ test99("99 bottles");
+ test98("98 bottles");
+ test97("97 bottles");
+ test96("96 bottles");
+ test95("95 bottles");
+ test94("94 bottles");
}
diff --git a/tests/language_2/is_not_class2_runtime_test.dart b/tests/language_2/is_not_class2_runtime_test.dart
new file mode 100644
index 0000000..088e489
--- /dev/null
+++ b/tests/language_2/is_not_class2_runtime_test.dart
@@ -0,0 +1,31 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Dart test program for catch that we expect a class after an 'is'. 'aa' is a
+// malformed type and a type error should be thrown upon test.
+
+import 'package:expect/expect.dart';
+
+class A {
+ const A();
+}
+
+class IsNotClass2NegativeTest {
+ static testMain() {
+ var a = new A();
+ var aa = new A();
+
+
+
+
+ return 0;
+ }
+}
+
+main() {
+ IsNotClass2NegativeTest.testMain();
+}
diff --git a/tests/language_2/is_not_class2_test.dart b/tests/language_2/is_not_class2_test.dart
index 4ee00ebb..9073117 100644
--- a/tests/language_2/is_not_class2_test.dart
+++ b/tests/language_2/is_not_class2_test.dart
@@ -16,9 +16,12 @@
var a = new A();
var aa = new A();
- if (a is aa) { //# 01: compile-time error
- return 0; //# 01: continued
- } //# 01: continued
+ if (a is aa) {
+ // ^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_NON_TYPE
+ // [cfe] 'aa' isn't a type.
+ return 0;
+ }
return 0;
}
}
diff --git a/tests/language_2/isnot_malformed_type_runtime_test.dart b/tests/language_2/isnot_malformed_type_runtime_test.dart
new file mode 100644
index 0000000..c815992
--- /dev/null
+++ b/tests/language_2/isnot_malformed_type_runtime_test.dart
@@ -0,0 +1,17 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import 'package:expect/expect.dart';
+
+f(obj) {
+ // 'Baz' is not loaded, throws a type error on test.
+
+}
+
+main() {
+
+}
diff --git a/tests/language_2/isnot_malformed_type_test.dart b/tests/language_2/isnot_malformed_type_test.dart
index 794b02e..11715e2 100644
--- a/tests/language_2/isnot_malformed_type_test.dart
+++ b/tests/language_2/isnot_malformed_type_test.dart
@@ -6,9 +6,12 @@
f(obj) {
// 'Baz' is not loaded, throws a type error on test.
- return (obj is! Baz); //# 01: compile-time error
+ return (obj is! Baz);
+ // ^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_UNDEFINED_NAME
+ // [cfe] 'Baz' isn't a type.
}
main() {
- f(null); //# 01: continued
+ f(null);
}
diff --git a/tests/language_2/issue11724_runtime_test.dart b/tests/language_2/issue11724_runtime_test.dart
new file mode 100644
index 0000000..6cf180d
--- /dev/null
+++ b/tests/language_2/issue11724_runtime_test.dart
@@ -0,0 +1,12 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+void main() {
+
+}
diff --git a/tests/language_2/issue11724_test.dart b/tests/language_2/issue11724_test.dart
index 3303071..ddf3925 100644
--- a/tests/language_2/issue11724_test.dart
+++ b/tests/language_2/issue11724_test.dart
@@ -5,5 +5,8 @@
import "package:expect/expect.dart";
void main() {
- method(<int>[]); //# 01: compile-time error
+ method(<int>[]);
+//^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_FUNCTION
+// [cfe] Method not found: 'method'.
}
diff --git a/tests/language_2/issue1363_runtime_test.dart b/tests/language_2/issue1363_runtime_test.dart
new file mode 100644
index 0000000..8635ed6
--- /dev/null
+++ b/tests/language_2/issue1363_runtime_test.dart
@@ -0,0 +1,30 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// VMOptions=--enable_type_checks
+
+library Issue1363Test.dart;
+
+import 'issue1363_lib.dart' as lib;
+
+main() {
+ new C().test();
+}
+
+class C {
+ lib.Cup<lib.C> libCup;
+ lib.Cup<C> myCup;
+
+ C();
+
+ test() {
+ myCup = new lib.Cup<C>(new C());
+ libCup = new lib.Cup<lib.C>(new lib.C());
+
+ C contents = myCup.getContents(); // expect no warning or error
+
+ }
+}
diff --git a/tests/language_2/issue1363_test.dart b/tests/language_2/issue1363_test.dart
index d76a9b1..969d932 100644
--- a/tests/language_2/issue1363_test.dart
+++ b/tests/language_2/issue1363_test.dart
@@ -22,6 +22,10 @@
libCup = new lib.Cup<lib.C>(new lib.C());
C contents = myCup.getContents(); // expect no warning or error
- contents = libCup.getContents(); //# 01: compile-time error
+ contents = libCup.getContents();
+ // ^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'C/*1*/' can't be assigned to a variable of type 'C/*2*/'.
}
}
diff --git a/tests/language_2/issue15606_runtime_test.dart b/tests/language_2/issue15606_runtime_test.dart
new file mode 100644
index 0000000..539a0d7
--- /dev/null
+++ b/tests/language_2/issue15606_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class Foo<T> {}
+
+var a = [new Object(), 42];
+
+bar(x, y) {}
+
+main() {
+ while (false) {
+ // Comply to inlining heuristics.
+ // Use an unresolved prefix.
+ var foo =
+
+ bar(
+ // Make dart2js generate a call to setRuntimeTypeInfo.
+ new Foo<int>(),
+ // Use a one-shot interceptor.
+ a[0].toString());
+
+ // Do an is test on `Foo` to require setRuntimeTypeInfo.
+ print(foo is Foo<int>);
+ }
+}
diff --git a/tests/language_2/issue15606_test.dart b/tests/language_2/issue15606_test.dart
index a1ec9f9..3891202 100644
--- a/tests/language_2/issue15606_test.dart
+++ b/tests/language_2/issue15606_test.dart
@@ -13,7 +13,10 @@
// Comply to inlining heuristics.
// Use an unresolved prefix.
var foo =
- Unresolved. //# 01: compile-time error
+ Unresolved.
+// ^^^^^^^^^^
+// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+// [cfe] Getter not found: 'Unresolved'.
bar(
// Make dart2js generate a call to setRuntimeTypeInfo.
new Foo<int>(),
diff --git a/tests/language_2/issue18628_1_runtime_test.dart b/tests/language_2/issue18628_1_runtime_test.dart
new file mode 100644
index 0000000..56d7377
--- /dev/null
+++ b/tests/language_2/issue18628_1_runtime_test.dart
@@ -0,0 +1,23 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// This test checks for a regression found in Dart Editor: the
+// analyzer was treating [Type] as more specific than any type
+// variable (generic parameter).
+//
+// https://code.google.com/p/dart/issues/detail?id=18628
+
+class C<T> {
+ // This line is supposed to cause the warning; the other commented
+ // line just doesn't make sense without this line.
+
+}
+
+main() {
+ C<Type> c = new C<Type>();
+
+}
diff --git a/tests/language_2/issue18628_1_test.dart b/tests/language_2/issue18628_1_test.dart
index a32fad1..3f2bef3 100644
--- a/tests/language_2/issue18628_1_test.dart
+++ b/tests/language_2/issue18628_1_test.dart
@@ -11,10 +11,13 @@
class C<T> {
// This line is supposed to cause the warning; the other commented
// line just doesn't make sense without this line.
- T t = int; //# 01: compile-time error
+ T t = int;
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'Type' can't be assigned to a variable of type 'T'.
}
main() {
C<Type> c = new C<Type>();
- print(c.t); //# 01: compile-time error
+ print(c.t);
}
diff --git a/tests/language_2/issue18628_2_runtime_test.dart b/tests/language_2/issue18628_2_runtime_test.dart
new file mode 100644
index 0000000..d604adb
--- /dev/null
+++ b/tests/language_2/issue18628_2_runtime_test.dart
@@ -0,0 +1,23 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// This test checks for a regression found in Dart Editor: the
+// analyzer was treating [Type] as more specific than any type
+// variable (generic parameter).
+//
+// https://code.google.com/p/dart/issues/detail?id=18628
+
+class X<T extends Type> {}
+
+// This line is supposed to cause the warning; the other lines are
+// marked because they don't make sense when [Y] is not defined.
+
+
+main() {
+
+
+}
diff --git a/tests/language_2/issue18628_2_test.dart b/tests/language_2/issue18628_2_test.dart
index e129c2a..622b724 100644
--- a/tests/language_2/issue18628_2_test.dart
+++ b/tests/language_2/issue18628_2_test.dart
@@ -12,9 +12,13 @@
// This line is supposed to cause the warning; the other lines are
// marked because they don't make sense when [Y] is not defined.
-class Y<U> extends X<U> {} //# 01: compile-time error
+class Y<U> extends X<U> {}
+// ^
+// [cfe] Type argument 'U' doesn't conform to the bound 'Type' of the type variable 'T' on 'X' in the supertype 'X' of class 'Y'.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
main() {
- X<Type> x = new X<Type>(); //# 01: compile-time error
- Y<Type> y = new Y<Type>(); //# 01: compile-time error
+ X<Type> x = new X<Type>();
+ Y<Type> y = new Y<Type>();
}
diff --git a/tests/language_2/issue23244_test.dart b/tests/language_2/issue23244_test.dart
index 24a1d9b..6a25b57 100644
--- a/tests/language_2/issue23244_test.dart
+++ b/tests/language_2/issue23244_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Regression test case for http://dartbug.com/23244
import 'dart:async';
import 'dart:isolate';
diff --git a/tests/language_2/issue31596_runtime_test.dart b/tests/language_2/issue31596_runtime_test.dart
new file mode 100644
index 0000000..c4dd7f0
--- /dev/null
+++ b/tests/language_2/issue31596_runtime_test.dart
@@ -0,0 +1,53 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+import "package:expect/expect.dart";
+
+class A {}
+
+class B extends A {}
+
+class B2 extends A {}
+
+class C {
+ void f(B x, B y) {}
+}
+
+abstract class I<X> {
+ void f(X x, B y);
+}
+
+// This class contains a forwarding stub for f to allow it to satisfy the
+// interface I<B>, while still ensuring that the x argument is type checked
+// before C.f is executed.
+//
+// For purposes of static type checking, the interface of the class D is
+// considered to contain a method f with signature (B, B) -> void. For purposes
+// of runtime behavior, a tearoff of D.f is considered to have the reified
+// runtime type (Object, B) -> void.
+class D extends C implements I<B> {}
+
+main() {
+ var d = new D();
+ I<A> i = d;
+ A a = new A();
+ B b = new B();
+ B2 b2 = null;
+
+ i.f(b2, b); // Ok since B2 assignable to A
+ // TODO: Downcast will be a compile-time error with NNBD. Consider using
+ // `d.f as dynamic`.
+ void Function(Object, B) g = d.f; // Ok; D.f reified as (Object, B) -> void
+ Expect.throwsTypeError(() {
+ // TODO: Downcast will be a compile-time error with NNBD.
+ d.f(a, b);
+ });
+ Expect.throwsTypeError(() {
+ // TODO: Downcast will be a compile-time error with NNBD.
+ i.f(a, b);
+ });
+}
diff --git a/tests/language_2/issue31596_super_runtime_1_test.dart b/tests/language_2/issue31596_super_runtime_1_test.dart
new file mode 100644
index 0000000..b3cc5e1
--- /dev/null
+++ b/tests/language_2/issue31596_super_runtime_1_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import "package:expect/expect.dart";
+
+class I0 {}
+
+class A {}
+
+class B extends A implements I0 {}
+
+class B2 extends A {}
+
+class C {
+ void f(B x) {}
+}
+
+abstract class I<X> {
+ void f(X x);
+}
+
+// This class contains a forwarding stub for f to allow it to satisfy the
+// interface I<B>, while still ensuring that the x argument is type checked
+// before C.f is executed.
+//
+// Super calls in a derived class resolve directly to C.f, and are type checked
+// accordingly at compile time.
+class D extends C implements I<B> {}
+
+class E extends D {
+ void test() {
+ I0 i0 = null;
+ B2 b2 = null;
+
+ // ok since I0 is assignable to B
+ // TODO: Downcast from I0 to B will be a compile-time error with NNBD.
+ super.f(i0);
+
+ // not ok since B2 is not assignable to B
+
+
+ var superF = super.f; // Inferred static type: void Function(B)
+
+ // ok since I0 is assignable to B
+ // TODO: Downcast from I0 to B will be a compile-time error with NNBD.
+
+
+ // not ok since B2 is not assignable to B
+
+
+ // Should pass since superF's runtime type is void Function(Object)
+
+
+
+
+ }
+}
+
+main() {
+ new E().test();
+}
diff --git a/tests/language_2/issue31596_super_runtime_2_test.dart b/tests/language_2/issue31596_super_runtime_2_test.dart
new file mode 100644
index 0000000..ba37a8c
--- /dev/null
+++ b/tests/language_2/issue31596_super_runtime_2_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import "package:expect/expect.dart";
+
+class I0 {}
+
+class A {}
+
+class B extends A implements I0 {}
+
+class B2 extends A {}
+
+class C {
+ void f(B x) {}
+}
+
+abstract class I<X> {
+ void f(X x);
+}
+
+// This class contains a forwarding stub for f to allow it to satisfy the
+// interface I<B>, while still ensuring that the x argument is type checked
+// before C.f is executed.
+//
+// Super calls in a derived class resolve directly to C.f, and are type checked
+// accordingly at compile time.
+class D extends C implements I<B> {}
+
+class E extends D {
+ void test() {
+ I0 i0 = null;
+ B2 b2 = null;
+
+ // ok since I0 is assignable to B
+ // TODO: Downcast from I0 to B will be a compile-time error with NNBD.
+
+
+ // not ok since B2 is not assignable to B
+
+
+ var superF = super.f; // Inferred static type: void Function(B)
+
+ // ok since I0 is assignable to B
+ // TODO: Downcast from I0 to B will be a compile-time error with NNBD.
+ superF(i0);
+
+ // not ok since B2 is not assignable to B
+
+
+ // Should pass since superF's runtime type is void Function(Object)
+
+
+
+
+ }
+}
+
+main() {
+ new E().test();
+}
diff --git a/tests/language_2/issue31596_super_runtime_3_test.dart b/tests/language_2/issue31596_super_runtime_3_test.dart
new file mode 100644
index 0000000..98e9f6e
--- /dev/null
+++ b/tests/language_2/issue31596_super_runtime_3_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import "package:expect/expect.dart";
+
+class I0 {}
+
+class A {}
+
+class B extends A implements I0 {}
+
+class B2 extends A {}
+
+class C {
+ void f(B x) {}
+}
+
+abstract class I<X> {
+ void f(X x);
+}
+
+// This class contains a forwarding stub for f to allow it to satisfy the
+// interface I<B>, while still ensuring that the x argument is type checked
+// before C.f is executed.
+//
+// Super calls in a derived class resolve directly to C.f, and are type checked
+// accordingly at compile time.
+class D extends C implements I<B> {}
+
+class E extends D {
+ void test() {
+ I0 i0 = null;
+ B2 b2 = null;
+
+ // ok since I0 is assignable to B
+ // TODO: Downcast from I0 to B will be a compile-time error with NNBD.
+
+
+ // not ok since B2 is not assignable to B
+
+
+ var superF = super.f; // Inferred static type: void Function(B)
+
+ // ok since I0 is assignable to B
+ // TODO: Downcast from I0 to B will be a compile-time error with NNBD.
+
+
+ // not ok since B2 is not assignable to B
+
+
+ // Should pass since superF's runtime type is void Function(Object)
+ Expect.isTrue(superF is void Function(B));
+ Expect.isTrue(superF is void Function(I0));
+ Expect.isTrue(superF is void Function(A));
+ Expect.isTrue(superF is void Function(Object));
+ }
+}
+
+main() {
+ new E().test();
+}
diff --git a/tests/language_2/issue31596_super_runtime_test.dart b/tests/language_2/issue31596_super_runtime_test.dart
new file mode 100644
index 0000000..d65653a
--- /dev/null
+++ b/tests/language_2/issue31596_super_runtime_test.dart
@@ -0,0 +1,65 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import "package:expect/expect.dart";
+
+class I0 {}
+
+class A {}
+
+class B extends A implements I0 {}
+
+class B2 extends A {}
+
+class C {
+ void f(B x) {}
+}
+
+abstract class I<X> {
+ void f(X x);
+}
+
+// This class contains a forwarding stub for f to allow it to satisfy the
+// interface I<B>, while still ensuring that the x argument is type checked
+// before C.f is executed.
+//
+// Super calls in a derived class resolve directly to C.f, and are type checked
+// accordingly at compile time.
+class D extends C implements I<B> {}
+
+class E extends D {
+ void test() {
+ I0 i0 = null;
+ B2 b2 = null;
+
+ // ok since I0 is assignable to B
+ // TODO: Downcast from I0 to B will be a compile-time error with NNBD.
+
+
+ // not ok since B2 is not assignable to B
+
+
+ var superF = super.f; // Inferred static type: void Function(B)
+
+ // ok since I0 is assignable to B
+ // TODO: Downcast from I0 to B will be a compile-time error with NNBD.
+
+
+ // not ok since B2 is not assignable to B
+
+
+ // Should pass since superF's runtime type is void Function(Object)
+
+
+
+
+ }
+}
+
+main() {
+ new E().test();
+}
diff --git a/tests/language_2/issue31596_super_test.dart b/tests/language_2/issue31596_super_test.dart
index 86b7807..657bace 100644
--- a/tests/language_2/issue31596_super_test.dart
+++ b/tests/language_2/issue31596_super_test.dart
@@ -35,25 +35,31 @@
// ok since I0 is assignable to B
// TODO: Downcast from I0 to B will be a compile-time error with NNBD.
- super.f(i0); //# 01: ok
+ super.f(i0);
// not ok since B2 is not assignable to B
- super.f(b2); //# 02: compile-time error
+ super.f(b2);
+ // ^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'B2' can't be assigned to the parameter type 'B'.
var superF = super.f; // Inferred static type: void Function(B)
// ok since I0 is assignable to B
// TODO: Downcast from I0 to B will be a compile-time error with NNBD.
- superF(i0); //# 03: ok
+ superF(i0);
// not ok since B2 is not assignable to B
- superF(b2); //# 04: compile-time error
+ superF(b2);
+ // ^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'B2' can't be assigned to the parameter type 'B'.
// Should pass since superF's runtime type is void Function(Object)
- Expect.isTrue(superF is void Function(B)); //# 05: ok
- Expect.isTrue(superF is void Function(I0)); //# 05: continued
- Expect.isTrue(superF is void Function(A)); //# 05: continued
- Expect.isTrue(superF is void Function(Object)); //# 05: continued
+ Expect.isTrue(superF is void Function(B));
+ Expect.isTrue(superF is void Function(I0));
+ Expect.isTrue(superF is void Function(A));
+ Expect.isTrue(superF is void Function(Object));
}
}
diff --git a/tests/language_2/issue31596_test.dart b/tests/language_2/issue31596_test.dart
index 4edb2ce..d65dee2 100644
--- a/tests/language_2/issue31596_test.dart
+++ b/tests/language_2/issue31596_test.dart
@@ -34,7 +34,10 @@
A a = new A();
B b = new B();
B2 b2 = null;
- d.f(b2, b); //# 01: compile-time error
+ d.f(b2, b);
+ // ^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'B2' can't be assigned to the parameter type 'B'.
i.f(b2, b); // Ok since B2 assignable to A
// TODO: Downcast will be a compile-time error with NNBD. Consider using
// `d.f as dynamic`.
diff --git a/tests/language_2/issue34488_runtime_test.dart b/tests/language_2/issue34488_runtime_test.dart
new file mode 100644
index 0000000..3c3d51c
--- /dev/null
+++ b/tests/language_2/issue34488_runtime_test.dart
@@ -0,0 +1,35 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+abstract class Base {
+ void f(int i);
+ void g([int i]);
+ void h({int i});
+}
+
+abstract class Mixin implements Base {}
+
+class Derived extends Object with Mixin {
+ // Type `(int) -> void` should be inherited from `Base`
+ f(i) {}
+
+ // Type `([int]) -> void` should be inherited from `Base`
+ g([i]) {}
+
+ // Type `({h: int}) -> void` should be inherited from `Base`
+ h({i}) {}
+}
+
+main() {
+ var d = new Derived();
+
+
+
+
+
+
+}
diff --git a/tests/language_2/issue34488_test.dart b/tests/language_2/issue34488_test.dart
index 4954abe..3375997 100644
--- a/tests/language_2/issue34488_test.dart
+++ b/tests/language_2/issue34488_test.dart
@@ -23,10 +23,29 @@
main() {
var d = new Derived();
- d.f('bad'); //# 01: compile-time error
- d.g('bad'); //# 02: compile-time error
- d.h(i: 'bad'); //# 03: compile-time error
- Object x = d.f(1); //# 04: compile-time error
- Object y = d.g(1); //# 05: compile-time error
- Object z = d.h(i: 1); //# 06: compile-time error
+ d.f('bad');
+ // ^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
+ d.g('bad');
+ // ^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
+ d.h(i: 'bad');
+ // ^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // ^
+ // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
+ Object x = d.f(1);
+ // ^
+ // [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
+ // [cfe] This expression has type 'void' and can't be used.
+ Object y = d.g(1);
+ // ^
+ // [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
+ // [cfe] This expression has type 'void' and can't be used.
+ Object z = d.h(i: 1);
+ // ^
+ // [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
+ // [cfe] This expression has type 'void' and can't be used.
}
diff --git a/tests/language_2/issue34489_runtime_test.dart b/tests/language_2/issue34489_runtime_test.dart
new file mode 100644
index 0000000..8cadeed
--- /dev/null
+++ b/tests/language_2/issue34489_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class C<T> {
+ var field = T;
+}
+
+main() {
+
+}
diff --git a/tests/language_2/issue34489_test.dart b/tests/language_2/issue34489_test.dart
index 59553a3..a29cab8 100644
--- a/tests/language_2/issue34489_test.dart
+++ b/tests/language_2/issue34489_test.dart
@@ -7,5 +7,8 @@
}
main() {
- new C().field = 'bad'; //# 01: compile-time error
+ new C().field = 'bad';
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'Type'.
}
diff --git a/tests/language_2/issue34495_runtime_test.dart b/tests/language_2/issue34495_runtime_test.dart
new file mode 100644
index 0000000..f31c56d
--- /dev/null
+++ b/tests/language_2/issue34495_runtime_test.dart
@@ -0,0 +1,10 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+
+
+main() {}
diff --git a/tests/language_2/issue34495_test.dart b/tests/language_2/issue34495_test.dart
index e599403..dee281c 100644
--- a/tests/language_2/issue34495_test.dart
+++ b/tests/language_2/issue34495_test.dart
@@ -2,6 +2,12 @@
// 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.
-final foo = A<B>.foo(); //# 01: compile-time error
+final foo = A<B>.foo();
+// ^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+// [cfe] Method not found: 'A'.
+// ^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'B' isn't a type.
main() {}
diff --git a/tests/language_2/issue35043_runtime_test.dart b/tests/language_2/issue35043_runtime_test.dart
new file mode 100644
index 0000000..f31c56d
--- /dev/null
+++ b/tests/language_2/issue35043_runtime_test.dart
@@ -0,0 +1,10 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+
+
+main() {}
diff --git a/tests/language_2/issue35043_test.dart b/tests/language_2/issue35043_test.dart
index 95c5f13..3655ac0 100644
--- a/tests/language_2/issue35043_test.dart
+++ b/tests/language_2/issue35043_test.dart
@@ -2,6 +2,9 @@
// 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.
-final foo = Map<int>(); //# 01: compile-time error
+final foo = Map<int>();
+// ^^^^^^^^
+// [analyzer] STATIC_WARNING.NEW_WITH_INVALID_TYPE_PARAMETERS
+// [cfe] Expected 2 type arguments.
main() {}
diff --git a/tests/language_2/known_identifier_prefix_error_runtime_test.dart b/tests/language_2/known_identifier_prefix_error_runtime_test.dart
new file mode 100644
index 0000000..b11ea63
--- /dev/null
+++ b/tests/language_2/known_identifier_prefix_error_runtime_test.dart
@@ -0,0 +1,81 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// Test that identifiers which are used explicitly in the grammar but are
+// not built-in identifiers can be used as library prefixes.
+
+// The identifiers listed below are mentioned in the grammar, but none of
+// them is a reserved word or a built-in identifier. Such an identifier can
+// be used as a library prefix; this test puts such prefixes in wrong
+// locations to verify that this is being handled. Here are the 'known'
+// identifiers: `async`, `await`, `hide`, `of`, `on`, `show`, `sync`, `yield`.
+
+import "package:expect/expect.dart";
+import 'built_in_identifier_prefix_library_async.dart' as async;
+import 'built_in_identifier_prefix_library_await.dart' as await;
+import 'built_in_identifier_prefix_library_hide.dart' as hide;
+import 'built_in_identifier_prefix_library_of.dart' as of;
+import 'built_in_identifier_prefix_library_on.dart' as on;
+import 'built_in_identifier_prefix_library_show.dart' as show;
+import 'built_in_identifier_prefix_library_sync.dart' as sync;
+import 'built_in_identifier_prefix_library_yield.dart' as yield;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/known_identifier_prefix_error_test.dart b/tests/language_2/known_identifier_prefix_error_test.dart
index 7882965..983b57b 100644
--- a/tests/language_2/known_identifier_prefix_error_test.dart
+++ b/tests/language_2/known_identifier_prefix_error_test.dart
@@ -21,58 +21,162 @@
import 'built_in_identifier_prefix_library_sync.dart' as sync;
import 'built_in_identifier_prefix_library_yield.dart' as yield;
-async<dynamic> _async = new async.A(); //# 01: compile-time error
-await<dynamic> _await = new await.A(); //# 02: compile-time error
-hide<dynamic> _hide = new hide.A(); //# 03: compile-time error
-of<dynamic> _of = new of.A(); //# 04: compile-time error
-on<dynamic> _on = new on.A(); //# 05: compile-time error
-show<dynamic> _show = new show.A(); //# 06: compile-time error
-sync<dynamic> _sync = new sync.A(); //# 07: compile-time error
-yield<dynamic> _yield = new yield.A(); //# 08: compile-time error
+async<dynamic> _async = new async.A();
+// [error line 24, column 1, length 5]
+// [analyzer] STATIC_WARNING.NOT_A_TYPE
+// [cfe] 'async' isn't a type.
+// [error line 24, column 1]
+// [cfe] Expected 0 type arguments.
+await<dynamic> _await = new await.A();
+// [error line 30, column 1, length 5]
+// [analyzer] STATIC_WARNING.NOT_A_TYPE
+// [cfe] 'await' isn't a type.
+// [error line 30, column 1]
+// [cfe] Expected 0 type arguments.
+hide<dynamic> _hide = new hide.A();
+// [error line 36, column 1, length 4]
+// [analyzer] STATIC_WARNING.NOT_A_TYPE
+// [cfe] 'hide' isn't a type.
+// [error line 36, column 1]
+// [cfe] Expected 0 type arguments.
+of<dynamic> _of = new of.A();
+// [error line 42, column 1, length 2]
+// [analyzer] STATIC_WARNING.NOT_A_TYPE
+// [cfe] 'of' isn't a type.
+// [error line 42, column 1]
+// [cfe] Expected 0 type arguments.
+on<dynamic> _on = new on.A();
+// [error line 48, column 1, length 2]
+// [analyzer] STATIC_WARNING.NOT_A_TYPE
+// [cfe] 'on' isn't a type.
+// [error line 48, column 1]
+// [cfe] Expected 0 type arguments.
+show<dynamic> _show = new show.A();
+// [error line 54, column 1, length 4]
+// [analyzer] STATIC_WARNING.NOT_A_TYPE
+// [cfe] 'show' isn't a type.
+// [error line 54, column 1]
+// [cfe] Expected 0 type arguments.
+sync<dynamic> _sync = new sync.A();
+// [error line 60, column 1, length 4]
+// [analyzer] STATIC_WARNING.NOT_A_TYPE
+// [cfe] 'sync' isn't a type.
+// [error line 60, column 1]
+// [cfe] Expected 0 type arguments.
+yield<dynamic> _yield = new yield.A();
+// [error line 66, column 1, length 5]
+// [analyzer] STATIC_WARNING.NOT_A_TYPE
+// [cfe] 'yield' isn't a type.
+// [error line 66, column 1]
+// [cfe] Expected 0 type arguments.
-async.B<async> _B_async = new async.B(); //# 09: compile-time error
-await.B<await> _B_await = new await.B(); //# 10: compile-time error
-hide.B<hide> _B_hide = new hide.B(); //# 11: compile-time error
-of.B<of> _B_of = new of.B(); //# 12: compile-time error
-on.B<on> _B_on = new on.B(); //# 13: compile-time error
-show.B<show> _B_show = new show.B(); //# 14: compile-time error
-sync.B<sync> _B_sync = new sync.B(); //# 15: compile-time error
-yield.B<yield> _B_yield = new yield.B(); //# 16: compile-time error
+async.B<async> _B_async = new async.B();
+// ^^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'async' isn't a type.
+await.B<await> _B_await = new await.B();
+// ^^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'await' isn't a type.
+hide.B<hide> _B_hide = new hide.B();
+// ^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'hide' isn't a type.
+of.B<of> _B_of = new of.B();
+// ^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'of' isn't a type.
+on.B<on> _B_on = new on.B();
+// ^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'on' isn't a type.
+show.B<show> _B_show = new show.B();
+// ^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'show' isn't a type.
+sync.B<sync> _B_sync = new sync.B();
+// ^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'sync' isn't a type.
+yield.B<yield> _B_yield = new yield.B();
+// ^^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'yield' isn't a type.
-async.B<async<dynamic>> _B2_async = new async.B(); //# 17: compile-time error
-await.B<await<dynamic>> _B2_await = new await.B(); //# 18: compile-time error
-hide.B<hide<dynamic>> _B2_hide = new hide.B(); //# 19: compile-time error
-of.B<of<dynamic>> _B2_of = new of.B(); //# 20: compile-time error
-on.B<on<dynamic>> _B2_on = new on.B(); //# 21: compile-time error
-show.B<show<dynamic>> _B2_show = new show.B(); //# 22: compile-time error
-sync.B<sync<dynamic>> _B2_sync = new sync.B(); //# 23: compile-time error
-yield.B<yield<dynamic>> _B2_yield = new yield.B(); //# 24: compile-time error
+async.B<async<dynamic>> _B2_async = new async.B();
+// ^^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'async' isn't a type.
+// ^
+// [cfe] Expected 0 type arguments.
+await.B<await<dynamic>> _B2_await = new await.B();
+// ^^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'await' isn't a type.
+// ^
+// [cfe] Expected 0 type arguments.
+hide.B<hide<dynamic>> _B2_hide = new hide.B();
+// ^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'hide' isn't a type.
+// ^
+// [cfe] Expected 0 type arguments.
+of.B<of<dynamic>> _B2_of = new of.B();
+// ^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'of' isn't a type.
+// ^
+// [cfe] Expected 0 type arguments.
+on.B<on<dynamic>> _B2_on = new on.B();
+// ^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'on' isn't a type.
+// ^
+// [cfe] Expected 0 type arguments.
+show.B<show<dynamic>> _B2_show = new show.B();
+// ^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'show' isn't a type.
+// ^
+// [cfe] Expected 0 type arguments.
+sync.B<sync<dynamic>> _B2_sync = new sync.B();
+// ^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'sync' isn't a type.
+// ^
+// [cfe] Expected 0 type arguments.
+yield.B<yield<dynamic>> _B2_yield = new yield.B();
+// ^^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+// [cfe] 'yield' isn't a type.
+// ^
+// [cfe] Expected 0 type arguments.
main() {
- Expect.isTrue(_async is async.A); //# 01: continued
- Expect.isTrue(_await is await.A); //# 02: continued
- Expect.isTrue(_hide is hide.A); //# 03: continued
- Expect.isTrue(_of is of.A); //# 04: continued
- Expect.isTrue(_on is on.A); //# 05: continued
- Expect.isTrue(_show is show.A); //# 06: continued
- Expect.isTrue(_sync is sync.A); //# 07: continued
- Expect.isTrue(_yield is yield.A); //# 08: continued
+ Expect.isTrue(_async is async.A);
+ Expect.isTrue(_await is await.A);
+ Expect.isTrue(_hide is hide.A);
+ Expect.isTrue(_of is of.A);
+ Expect.isTrue(_on is on.A);
+ Expect.isTrue(_show is show.A);
+ Expect.isTrue(_sync is sync.A);
+ Expect.isTrue(_yield is yield.A);
- Expect.isTrue(_B_async is async.B); //# 09: continued
- Expect.isTrue(_B_await is await.B); //# 10: continued
- Expect.isTrue(_B_hide is hide.B); //# 11: continued
- Expect.isTrue(_B_of is of.B); //# 12: continued
- Expect.isTrue(_B_on is on.B); //# 13: continued
- Expect.isTrue(_B_show is show.B); //# 14: continued
- Expect.isTrue(_B_sync is sync.B); //# 15: continued
- Expect.isTrue(_B_yield is yield.B); //# 16: continued
+ Expect.isTrue(_B_async is async.B);
+ Expect.isTrue(_B_await is await.B);
+ Expect.isTrue(_B_hide is hide.B);
+ Expect.isTrue(_B_of is of.B);
+ Expect.isTrue(_B_on is on.B);
+ Expect.isTrue(_B_show is show.B);
+ Expect.isTrue(_B_sync is sync.B);
+ Expect.isTrue(_B_yield is yield.B);
- Expect.isTrue(_B2_async is async.B); //# 17: continued
- Expect.isTrue(_B2_await is await.B); //# 18: continued
- Expect.isTrue(_B2_hide is hide.B); //# 19: continued
- Expect.isTrue(_B2_of is of.B); //# 20: continued
- Expect.isTrue(_B2_on is on.B); //# 21: continued
- Expect.isTrue(_B2_show is show.B); //# 22: continued
- Expect.isTrue(_B2_sync is sync.B); //# 23: continued
- Expect.isTrue(_B2_yield is yield.B); //# 24: continued
+ Expect.isTrue(_B2_async is async.B);
+ Expect.isTrue(_B2_await is await.B);
+ Expect.isTrue(_B2_hide is hide.B);
+ Expect.isTrue(_B2_of is of.B);
+ Expect.isTrue(_B2_on is on.B);
+ Expect.isTrue(_B2_show is show.B);
+ Expect.isTrue(_B2_sync is sync.B);
+ Expect.isTrue(_B2_yield is yield.B);
}
diff --git a/tests/language_2/known_identifier_usage_error_runtime_test.dart b/tests/language_2/known_identifier_usage_error_runtime_test.dart
new file mode 100644
index 0000000..de3844b
--- /dev/null
+++ b/tests/language_2/known_identifier_usage_error_runtime_test.dart
@@ -0,0 +1,76 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// The identifiers listed below are mentioned in the grammar, but none of
+// them is a reserved word or a built-in identifier. Such an identifier can
+// be used just like all other identifiers, with the exceptions mentioned
+// below. Here are said 'known' identifiers:
+//
+// `async`, `await`, `hide`, `of`, `on`, `show`, `sync`, `yield`
+//
+// The following exceptions apply:
+//
+// It is a compile-time error to use `async`, `await`, or `yield` as an
+// identifier in the body of a function marked `async`, `async*`, or
+// `sync*`.
+//
+// It is a compile-time error if an asynchronous for-in appears inside a
+// synchronous function.
+
+import 'dart:async';
+
+Future<int> f1() async {
+ int async = 1;
+
+
+
+ Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
+ await for (int i in s) {
+ return i + 1;
+ }
+}
+
+Stream<int> f2() async* {
+ int async = 1;
+
+
+
+ Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
+ await for (var i in s) {
+ yield i + 1;
+ }
+}
+
+Iterable<int> f3() sync* {
+ int async = 1;
+
+
+
+ Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
+
+
+
+}
+
+int f4() {
+ int async = 1;
+ int await = 1;
+ int yield = 1;
+
+ Stream s = new Stream<int>.fromFuture(new Future<int>.value(1));
+
+
+
+
+}
+
+main() {
+ Future<int> f = f1();
+ Stream s = f2();
+ Iterable<int> i = f3();
+ int x = f4();
+}
diff --git a/tests/language_2/known_identifier_usage_error_test.dart b/tests/language_2/known_identifier_usage_error_test.dart
index 0d56f26..c4e36f3 100644
--- a/tests/language_2/known_identifier_usage_error_test.dart
+++ b/tests/language_2/known_identifier_usage_error_test.dart
@@ -22,8 +22,14 @@
Future<int> f1() async {
int async = 1;
- int await = 1; //# 02: syntax error
- int yield = 1; //# 03: syntax error
+ int await = 1;
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
+ // [cfe] 'await' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
+ int yield = 1;
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
+ // [cfe] 'yield' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
await for (int i in s) {
@@ -33,8 +39,14 @@
Stream<int> f2() async* {
int async = 1;
- int await = 1; //# 05: syntax error
- int yield = 1; //# 06: syntax error
+ int await = 1;
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
+ // [cfe] 'await' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
+ int yield = 1;
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
+ // [cfe] 'yield' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
await for (var i in s) {
@@ -44,13 +56,22 @@
Iterable<int> f3() sync* {
int async = 1;
- int await = 1; //# 08: syntax error
- int yield = 1; //# 09: syntax error
+ int await = 1;
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
+ // [cfe] 'await' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
+ int yield = 1;
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.ASYNC_KEYWORD_USED_AS_IDENTIFIER
+ // [cfe] 'yield' can't be used as an identifier in 'async', 'async*', or 'sync*' methods.
Stream<int> s = new Stream<int>.fromFuture(new Future<int>.value(1));
- await for (int i in s) { //# 10: compile-time error
- yield i + 1; //# 10: continued
- } //# 10: continued
+ await for (int i in s) {
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.ASYNC_FOR_IN_WRONG_CONTEXT
+ // [cfe] The asynchronous for-in can only be used in functions marked with 'async' or 'async*'.
+ yield i + 1;
+ }
}
int f4() {
@@ -59,9 +80,12 @@
int yield = 1;
Stream s = new Stream<int>.fromFuture(new Future<int>.value(1));
- await for (int i in s) { //# 11: compile-time error
- return i + 1; //# 11: continued
- } //# 11: continued
+ await for (int i in s) {
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.ASYNC_FOR_IN_WRONG_CONTEXT
+ // [cfe] The asynchronous for-in can only be used in functions marked with 'async' or 'async*'.
+ return i + 1;
+ }
}
diff --git a/tests/language_2/label3_runtime_1_test.dart b/tests/language_2/label3_runtime_1_test.dart
new file mode 100644
index 0000000..76da501
--- /dev/null
+++ b/tests/language_2/label3_runtime_1_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+main() {
+ L: while (false) {
+ if (true) break L;
+ }
+ // Illegal: L is out of scope.
+
+}
diff --git a/tests/language_2/label3_runtime_test.dart b/tests/language_2/label3_runtime_test.dart
new file mode 100644
index 0000000..afcaad7
--- /dev/null
+++ b/tests/language_2/label3_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+main() {
+ L: while (false) {
+
+ }
+ // Illegal: L is out of scope.
+
+}
diff --git a/tests/language_2/label3_test.dart b/tests/language_2/label3_test.dart
index 5685aab..cdea8e4 100644
--- a/tests/language_2/label3_test.dart
+++ b/tests/language_2/label3_test.dart
@@ -4,8 +4,14 @@
main() {
L: while (false) {
- if (true) break L; //# 01: ok
+ if (true) break L;
}
// Illegal: L is out of scope.
- continue L; //# 02: compile-time error
+ continue L;
+//^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.CONTINUE_OUTSIDE_OF_LOOP
+// [cfe] A continue statement can't be used outside of a loop or switch statement.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.LABEL_UNDEFINED
+// [cfe] Can't find label 'L'.
}
diff --git a/tests/language_2/label5_runtime_test.dart b/tests/language_2/label5_runtime_test.dart
new file mode 100644
index 0000000..fd934f0
--- /dev/null
+++ b/tests/language_2/label5_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+main() {
+ var L = 33;
+ while (false) {
+ // Illegal: L is not a label.
+
+ }
+}
diff --git a/tests/language_2/label5_test.dart b/tests/language_2/label5_test.dart
index 2007cf4..9856809 100644
--- a/tests/language_2/label5_test.dart
+++ b/tests/language_2/label5_test.dart
@@ -6,6 +6,9 @@
var L = 33;
while (false) {
// Illegal: L is not a label.
- if (true) break L; //# 01: compile-time error
+ if (true) break L;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.LABEL_UNDEFINED
+ // [cfe] Can't break to 'L'.
}
}
diff --git a/tests/language_2/label6_runtime_1_test.dart b/tests/language_2/label6_runtime_1_test.dart
new file mode 100644
index 0000000..effe712
--- /dev/null
+++ b/tests/language_2/label6_runtime_1_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+main() {
+ L:
+ while (false) {
+ break;
+
+ void innerfunc() {
+ // Illegal: jump target is outside of function
+
+ }
+
+ innerfunc();
+ }
+}
diff --git a/tests/language_2/label6_runtime_2_test.dart b/tests/language_2/label6_runtime_2_test.dart
new file mode 100644
index 0000000..732c430
--- /dev/null
+++ b/tests/language_2/label6_runtime_2_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+main() {
+ L:
+ while (false) {
+
+ break L;
+ void innerfunc() {
+ // Illegal: jump target is outside of function
+
+ }
+
+ innerfunc();
+ }
+}
diff --git a/tests/language_2/label6_runtime_test.dart b/tests/language_2/label6_runtime_test.dart
new file mode 100644
index 0000000..e240a78
--- /dev/null
+++ b/tests/language_2/label6_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+main() {
+ L:
+ while (false) {
+
+
+ void innerfunc() {
+ // Illegal: jump target is outside of function
+
+ }
+
+ innerfunc();
+ }
+}
diff --git a/tests/language_2/label6_test.dart b/tests/language_2/label6_test.dart
index d46ca9b..5219b01 100644
--- a/tests/language_2/label6_test.dart
+++ b/tests/language_2/label6_test.dart
@@ -5,11 +5,15 @@
main() {
L:
while (false) {
- break; //# 01: ok
- break L; //# 02: ok
+ break;
+ break L;
void innerfunc() {
// Illegal: jump target is outside of function
- if (true) break L; //# 03: compile-time error
+ if (true) break L;
+ // ^
+ // [cfe] Can't break to 'L' in a different function.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.LABEL_IN_OUTER_SCOPE
}
innerfunc();
diff --git a/tests/language_2/label8_runtime_test.dart b/tests/language_2/label8_runtime_test.dart
new file mode 100644
index 0000000..313ce69
--- /dev/null
+++ b/tests/language_2/label8_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+main() {
+ int i;
+ // Grammar doesn't allow label on block for switch statement.
+ switch(i)
+
+ {
+ case 111:
+ while (false) {
+
+ }
+ i++;
+ }
+}
diff --git a/tests/language_2/label8_test.dart b/tests/language_2/label8_test.dart
index 866fcc7..df4f1b8 100644
--- a/tests/language_2/label8_test.dart
+++ b/tests/language_2/label8_test.dart
@@ -6,11 +6,37 @@
int i;
// Grammar doesn't allow label on block for switch statement.
switch(i)
- L: //# 01: syntax error
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_BODY
+ // [cfe] A switch statement must have a body, even if it is empty.
+ L:
{
case 111:
+// ^^^^
+// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+// [cfe] Expected ';' after this.
+// ^^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected an identifier, but got 'case'.
+// ^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Getter not found: 'case'.
+// ^^^^
+// [analyzer] SYNTACTIC_ERROR.MISSING_STATEMENT
+// ^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+// [cfe] Expected an identifier, but got ':'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN
+// [cfe] Unexpected token ':'.
while (false) {
- break L; //# 01: continued
+ break L;
}
i++;
}
diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status
index 64bc2b8..275c483 100644
--- a/tests/language_2/language_2_dart2js.status
+++ b/tests/language_2/language_2_dart2js.status
@@ -4,6 +4,7 @@
# Sections in this file should contain "$compiler == dart2js".
[ $compiler == dart2js ]
+int64_literal_runtime*_test: Skip # This is testing Dart 2.0 int64 semantics
mixin_method_override_test/G5: Skip # Issue 34354
vm/*: SkipByDesign # Tests for the VM.
diff --git a/tests/language_2/language_2_dartdevc.status b/tests/language_2/language_2_dartdevc.status
index 1aed49b..35e3516 100644
--- a/tests/language_2/language_2_dartdevc.status
+++ b/tests/language_2/language_2_dartdevc.status
@@ -18,6 +18,6 @@
[ $compiler == dartdevc || $compiler == dartdevk ]
asyncstar_throw_in_catch_test: Skip # Times out. Issue 29920
-int64_literal_test/*: Skip # This is testing Dart 2.0 int64 semantics.
+int64_literal_runtime*_test: Skip # This is testing Dart 2.0 int64 semantics.
superinterface_variance/*: Skip # Issue dart-lang/language#113
vm/*: SkipByDesign # VM only tests.; VM only tests.
diff --git a/tests/language_2/least_upper_bound_expansive_runtime_test.dart b/tests/language_2/least_upper_bound_expansive_runtime_test.dart
new file mode 100644
index 0000000..5d2e542
--- /dev/null
+++ b/tests/language_2/least_upper_bound_expansive_runtime_test.dart
@@ -0,0 +1,104 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class N<T> {
+ T get n => null;
+}
+
+class C1<T> extends N<N<C1<T>>> {
+ T get c1 => null;
+}
+
+class C2<T> extends N<N<C2<N<C2<T>>>>> {
+ T get c2 => null;
+}
+
+/**
+ * Test that we don't try to find the least upper bound by applying the
+ * algorithm for finding the most specific common declaration recursively on
+ * type arguments.
+ *
+ * For C1<int> and N<C1<String>> this would result in this infinite chain of
+ * computations:
+ *
+ * lub(C1<int>, N<C1<String>>) = lub(N<N<C1<int>>>, N<C1<String>>)
+ * =>
+ * lub(N<C1<int>>, C1<String>) = lub(N<C1<int>>, N<N<C1<String>>>)
+ * =>
+ * lub(C1<int>, N<C1<String>>) = lub(N<N<C1<int>>>, N<C1<String>>>)
+ * => ...
+ */
+void testC1(bool z, C1<int> a, N<C1<String>> b) {
+ if (z) {
+ // The least upper bound of C1<int> and N<C1<String>> is Object since the
+ // supertypes are
+ // {C1<int>, N<N<C1<int>>>, Object} for C1<int> and
+ // {N<C1<String>>, Object} for N<C1<String>> and
+ // Object is the most specific type in the intersection of the supertypes.
+
+ // Is least upper bound dynamic?
+
+ // Is least upper bound N<...> ?
+
+ // Is least upper bound C1<...> ?
+
+ // Is least upper bound N<dynamic> ?
+
+ // Is least upper bound N<N<...>> ?
+
+ // Is least upper bound N<C1<...>> ?
+
+ }
+}
+
+/**
+ * Test that we don't try to find the least upper bound by applying the
+ * algorithm for finding the most specific common declaration recursively on
+ * type arguments.
+ *
+ * For C1<int> and N<C1<String>> this would result in this infinite and
+ * expanding chain of computations:
+ *
+ * lub(C2<int>, N<C2<String>>) = lub(N<N<C2<N<C2<int>>>>>, N<C2<String>>)
+ * =>
+ * lub(N<C2<N<C2<int>>>>, C2<String>) =
+ * lub(N<C2<N<C2<int>>>>, N<N<C2<N<C2<String>>>>>)
+ * =>
+ * lub(C2<N<C2<int>>>, N<C2<N<C2<String>>>>) =
+ * lub(N<N<C2<N<C2<int>>>>>, N<C2<N<C2<String>>>>>)
+ * => ...
+ */
+
+void testC2(bool z, C2<int> a, N<C2<String>> b) {
+ if (z) {
+ // The least upper bound of C2<int> and N<C2<String>> is Object since the
+ // supertypes are
+ // {C2<int>, N<N<C2<N<C2<int>>>>>, Object} for C1<int> and
+ // {N<C2<String>>, Object} for N<C1<String>> and
+ // Object is the most specific type in the intersection of the supertypes.
+
+ // Is least upper bound dynamic?
+
+ // Is least upper bound N<...> ?
+
+ // Is least upper bound C2<...> ?
+
+ // Is least upper bound N<dynamic> ?
+
+ // Is least upper bound N<N<...>> ?
+
+ // Is least upper bound N<C2<...>> ?
+
+ }
+}
+
+void main() {
+ testC1(false, null, null);
+ testC2(false, null, null);
+}
diff --git a/tests/language_2/least_upper_bound_expansive_test.dart b/tests/language_2/least_upper_bound_expansive_test.dart
index 2beb61a..d798b15 100644
--- a/tests/language_2/least_upper_bound_expansive_test.dart
+++ b/tests/language_2/least_upper_bound_expansive_test.dart
@@ -40,17 +40,40 @@
// Object is the most specific type in the intersection of the supertypes.
// Is least upper bound dynamic?
- (z ? a : b).z; //# 01: compile-time error
+ (z ? a : b).z;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'z' isn't defined for the class 'Object'.
+
// Is least upper bound N<...> ?
- (z ? a : b).n; //# 02: compile-time error
+ (z ? a : b).n;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'n' isn't defined for the class 'Object'.
+
// Is least upper bound C1<...> ?
- (z ? a : b).c1; //# 03: compile-time error
+ (z ? a : b).c1;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c1' isn't defined for the class 'Object'.
+
// Is least upper bound N<dynamic> ?
- (z ? a : b).n.z; //# 04: compile-time error
+ (z ? a : b).n.z;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'n' isn't defined for the class 'Object'.
+
// Is least upper bound N<N<...>> ?
- (z ? a : b).n.n; //# 05: compile-time error
+ (z ? a : b).n.n;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'n' isn't defined for the class 'Object'.
+
// Is least upper bound N<C1<...>> ?
- (z ? a : b).n.c1; //# 06: compile-time error
+ (z ? a : b).n.c1;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'n' isn't defined for the class 'Object'.
}
}
@@ -81,17 +104,40 @@
// Object is the most specific type in the intersection of the supertypes.
// Is least upper bound dynamic?
- (z ? a : b).z; //# 07: compile-time error
+ (z ? a : b).z;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'z' isn't defined for the class 'Object'.
+
// Is least upper bound N<...> ?
- (z ? a : b).n; //# 08: compile-time error
+ (z ? a : b).n;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'n' isn't defined for the class 'Object'.
+
// Is least upper bound C2<...> ?
- (z ? a : b).c2; //# 09: compile-time error
+ (z ? a : b).c2;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c2' isn't defined for the class 'Object'.
+
// Is least upper bound N<dynamic> ?
- (z ? a : b).n.z; //# 10: compile-time error
+ (z ? a : b).n.z;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'n' isn't defined for the class 'Object'.
+
// Is least upper bound N<N<...>> ?
- (z ? a : b).n.n; //# 11: compile-time error
+ (z ? a : b).n.n;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'n' isn't defined for the class 'Object'.
+
// Is least upper bound N<C2<...>> ?
- (z ? a : b).n.c2; //# 12: compile-time error
+ (z ? a : b).n.c2;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'n' isn't defined for the class 'Object'.
}
}
diff --git a/tests/language_2/least_upper_bound_runtime_10_test.dart b/tests/language_2/least_upper_bound_runtime_10_test.dart
new file mode 100644
index 0000000..417d1ce
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_10_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+ (true ? c : a).b = 0;
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_11_test.dart b/tests/language_2/least_upper_bound_runtime_11_test.dart
new file mode 100644
index 0000000..e699c6b
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_11_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+ (false ? a : c).c = 0;
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_12_test.dart b/tests/language_2/least_upper_bound_runtime_12_test.dart
new file mode 100644
index 0000000..08c0855
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_12_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+ C r1 = true ? c : d;
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_13_test.dart b/tests/language_2/least_upper_bound_runtime_13_test.dart
new file mode 100644
index 0000000..493a68a
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_13_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+ D r2 = false ? c : d;
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_14_test.dart b/tests/language_2/least_upper_bound_runtime_14_test.dart
new file mode 100644
index 0000000..25210f9
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_14_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+ (true ? c : d).b = 0;
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_15_test.dart b/tests/language_2/least_upper_bound_runtime_15_test.dart
new file mode 100644
index 0000000..f637466
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_15_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+ (false ? c : d).b = 0;
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_16_test.dart b/tests/language_2/least_upper_bound_runtime_16_test.dart
new file mode 100644
index 0000000..22ad6d3
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_16_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+ E<B> r1 = true ? e : f;
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_17_test.dart b/tests/language_2/least_upper_bound_runtime_17_test.dart
new file mode 100644
index 0000000..3d88356
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_17_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+ F<C> r2 = false ? e : f;
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_18_test.dart b/tests/language_2/least_upper_bound_runtime_18_test.dart
new file mode 100644
index 0000000..67cf93d
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_18_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+ (true ? e : f).e = null;
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_19_test.dart b/tests/language_2/least_upper_bound_runtime_19_test.dart
new file mode 100644
index 0000000..9fc6257
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_19_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+ (false ? e : f).e = null;
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_1_test.dart b/tests/language_2/least_upper_bound_runtime_1_test.dart
new file mode 100644
index 0000000..22311fe
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_1_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+ A r1 = true ? a : b;
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_20_test.dart b/tests/language_2/least_upper_bound_runtime_20_test.dart
new file mode 100644
index 0000000..4d41fa2
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_20_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+ E<B> r1 = true ? e : f;
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_21_test.dart b/tests/language_2/least_upper_bound_runtime_21_test.dart
new file mode 100644
index 0000000..c302432
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_21_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+ F<C> r2 = false ? e : f;
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_22_test.dart b/tests/language_2/least_upper_bound_runtime_22_test.dart
new file mode 100644
index 0000000..659af08
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_22_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+ r5 = (true ? e : f).e;
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_2_test.dart b/tests/language_2/least_upper_bound_runtime_2_test.dart
new file mode 100644
index 0000000..8ccd6df
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_2_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+ B r2 = false ? a : b;
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_3_test.dart b/tests/language_2/least_upper_bound_runtime_3_test.dart
new file mode 100644
index 0000000..98b8016
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_3_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+ (true ? a as dynamic : c).a = 0;
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_4_test.dart b/tests/language_2/least_upper_bound_runtime_4_test.dart
new file mode 100644
index 0000000..260ca6e
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_4_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+ (false ? c : b).b = 0;
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_5_test.dart b/tests/language_2/least_upper_bound_runtime_5_test.dart
new file mode 100644
index 0000000..af9eb20
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_5_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+ B r1 = true ? b : c;
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_6_test.dart b/tests/language_2/least_upper_bound_runtime_6_test.dart
new file mode 100644
index 0000000..0d580d7
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_6_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+ C r2 = false ? b : c;
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_7_test.dart b/tests/language_2/least_upper_bound_runtime_7_test.dart
new file mode 100644
index 0000000..5e2405b
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_7_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+ (true ? b : c).b = 0;
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_8_test.dart b/tests/language_2/least_upper_bound_runtime_8_test.dart
new file mode 100644
index 0000000..5bc86d3
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_8_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+ (true ? b : a).b = 0;
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_9_test.dart b/tests/language_2/least_upper_bound_runtime_9_test.dart
new file mode 100644
index 0000000..fe6d5c0
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_9_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+ (false ? a : b).c = 0;
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_runtime_test.dart b/tests/language_2/least_upper_bound_runtime_test.dart
new file mode 100644
index 0000000..781a3a7
--- /dev/null
+++ b/tests/language_2/least_upper_bound_runtime_test.dart
@@ -0,0 +1,98 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test least upper bound through type checking of conditionals.
+
+class A {
+ var a;
+}
+
+class B {
+ var b;
+}
+
+class C extends B {
+ var c;
+}
+
+class D extends B {
+ var d;
+}
+
+class E<T> {
+ T e;
+
+ E(this.e);
+}
+
+class F<T> extends E<T> {
+ T f;
+
+ F(T f)
+ : this.f = f,
+ super(f);
+}
+
+void main() {
+ testAB(new A(), new B());
+ testBC(new C(), new C());
+ testCD(new C(), new D());
+ testEE(new F<C>(new C()), new F<C>(new C()));
+ testEF(new F<C>(new C()), new F<C>(new C()));
+}
+
+void testAB(A a, B b) {
+
+
+
+
+ var c = new C();
+
+
+}
+
+void testBC(B b, C c) {
+
+
+
+
+ var a = null;
+
+
+
+
+}
+
+void testCD(C c, D d) {
+
+
+
+
+
+
+}
+
+void testEE(E<B> e, E<C> f) {
+ // The least upper bound of E<B> and E<C> is E<B>.
+
+
+
+
+
+
+}
+
+void testEF(E<B> e, F<C> f) {
+ // The least upper bound of E<B> and F<C> is E<B>.
+
+
+
+
+ var r5;
+
+
+}
diff --git a/tests/language_2/least_upper_bound_test.dart b/tests/language_2/least_upper_bound_test.dart
index 0eced14..4815316 100644
--- a/tests/language_2/least_upper_bound_test.dart
+++ b/tests/language_2/least_upper_bound_test.dart
@@ -43,53 +43,87 @@
}
void testAB(A a, B b) {
- A r1 = true ? a : b; //# 01: ok
- B r2 = false ? a : b; //# 02: ok
- (true ? a : b).a = 0; //# 03: compile-time error
- (false ? a : b).b = 0; //# 04: compile-time error
+ A r1 = true ? a : b;
+ B r2 = false ? a : b;
+ (true ? a : b).a = 0;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] The setter 'a' isn't defined for the class 'Object'.
+ (false ? a : b).b = 0;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] The setter 'b' isn't defined for the class 'Object'.
var c = new C();
- (true ? a as dynamic : c).a = 0; //# 05: ok
- (false ? c : b).b = 0; //# 06: ok
+ (true ? a as dynamic : c).a = 0;
+ (false ? c : b).b = 0;
}
void testBC(B b, C c) {
- B r1 = true ? b : c; //# 07: ok
- C r2 = false ? b : c; //# 08: ok
- (true ? b : c).b = 0; //# 09: ok
- (false ? b : c).c = 0; //# 10: compile-time error
+ B r1 = true ? b : c;
+ C r2 = false ? b : c;
+ (true ? b : c).b = 0;
+ (false ? b : c).c = 0;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] The setter 'c' isn't defined for the class 'B'.
var a = null;
- (true ? b : a).b = 0; //# 11: ok
- (false ? a : b).c = 0; //# 12: ok
- (true ? c : a).b = 0; //# 13: ok
- (false ? a : c).c = 0; //# 14: ok
+ (true ? b : a).b = 0;
+ (false ? a : b).c = 0;
+ (true ? c : a).b = 0;
+ (false ? a : c).c = 0;
}
void testCD(C c, D d) {
- C r1 = true ? c : d; //# 15: ok
- D r2 = false ? c : d; //# 16: ok
- (true ? c : d).b = 0; //# 17: ok
- (false ? c : d).b = 0; //# 18: ok
- (true ? c : d).c = 0; //# 19: compile-time error
- (false ? c : d).d = 0; //# 20: compile-time error
+ C r1 = true ? c : d;
+ D r2 = false ? c : d;
+ (true ? c : d).b = 0;
+ (false ? c : d).b = 0;
+ (true ? c : d).c = 0;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] The setter 'c' isn't defined for the class 'B'.
+ (false ? c : d).d = 0;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] The setter 'd' isn't defined for the class 'B'.
}
void testEE(E<B> e, E<C> f) {
// The least upper bound of E<B> and E<C> is E<B>.
- E<B> r1 = true ? e : f; //# 21: ok
- F<C> r2 = false ? e : f; //# 22: ok
- A r3 = true ? e : f; //# 23: compile-time error
- B r4 = false ? e : f; //# 24: compile-time error
- (true ? e : f).e = null; //# 25: ok
- (false ? e : f).e = null; //# 26: ok
+ E<B> r1 = true ? e : f;
+ F<C> r2 = false ? e : f;
+ A r3 = true ? e : f;
+ // ^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E<B>' can't be assigned to a variable of type 'A'.
+ B r4 = false ? e : f;
+ // ^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E<B>' can't be assigned to a variable of type 'B'.
+ (true ? e : f).e = null;
+ (false ? e : f).e = null;
}
void testEF(E<B> e, F<C> f) {
// The least upper bound of E<B> and F<C> is E<B>.
- E<B> r1 = true ? e : f; //# 27: ok
- F<C> r2 = false ? e : f; //# 28: ok
- A r3 = true ? e : f; //# 29: compile-time error
- B r4 = false ? e : f; //# 30: compile-time error
+ E<B> r1 = true ? e : f;
+ F<C> r2 = false ? e : f;
+ A r3 = true ? e : f;
+ // ^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E<B>' can't be assigned to a variable of type 'A'.
+ B r4 = false ? e : f;
+ // ^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'E<B>' can't be assigned to a variable of type 'B'.
var r5;
- r5 = (true ? e : f).e; //# 31: ok
- r5 = (false ? e : f).f; //# 32: compile-time error
+ r5 = (true ? e : f).e;
+ r5 = (false ? e : f).f;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'f' isn't defined for the class 'E<B>'.
}
diff --git a/tests/language_2/list_literal1_runtime_test.dart b/tests/language_2/list_literal1_runtime_test.dart
new file mode 100644
index 0000000..542d7ed
--- /dev/null
+++ b/tests/language_2/list_literal1_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+//
+// A type mismatch in a list literal is a compile-time error
+
+main() {
+ var m = const
+
+ [0, 1];
+}
diff --git a/tests/language_2/list_literal1_test.dart b/tests/language_2/list_literal1_test.dart
index 7ba8b18..f8db7b2 100644
--- a/tests/language_2/list_literal1_test.dart
+++ b/tests/language_2/list_literal1_test.dart
@@ -6,6 +6,12 @@
main() {
var m = const
- <String> //# 01: compile-time error
+ <String>
[0, 1];
+// ^
+// [analyzer] STATIC_WARNING.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE
+// [cfe] A value of type 'int' can't be assigned to a variable of type 'String'.
+// ^
+// [analyzer] STATIC_WARNING.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE
+// [cfe] A value of type 'int' can't be assigned to a variable of type 'String'.
}
diff --git a/tests/language_2/malbounded_instantiation_runtime_test.dart b/tests/language_2/malbounded_instantiation_runtime_test.dart
new file mode 100644
index 0000000..31f8703
--- /dev/null
+++ b/tests/language_2/malbounded_instantiation_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class Super<T extends num> {}
+
+
+
+main() {
+
+
+
+}
diff --git a/tests/language_2/malbounded_instantiation_test.dart b/tests/language_2/malbounded_instantiation_test.dart
index 6755de6..2f397b2 100644
--- a/tests/language_2/malbounded_instantiation_test.dart
+++ b/tests/language_2/malbounded_instantiation_test.dart
@@ -3,11 +3,23 @@
// BSD-style license that can be found in the LICENSE file.
class Super<T extends num> {}
-class Malbounded1 implements Super<String> {} // //# 01: compile-time error
-class Malbounded2 extends Super<String> {} // //# 02: compile-time error
+class Malbounded1 implements Super<String> {}
+// ^
+// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Super' in the supertype 'Super' of class 'Malbounded1'.
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
+class Malbounded2 extends Super<String> {}
+// ^
+// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Super' in the supertype 'Super' of class 'Malbounded2'.
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
main() {
- new Malbounded1(); // //# 01: continued
- new Malbounded2(); // //# 02: continued
- new Super<String>(); // //# 03: compile-time error
+ new Malbounded1();
+ new Malbounded2();
+ new Super<String>();
+ // ^
+ // [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Super'.
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
diff --git a/tests/language_2/malbounded_type_cast_runtime_test.dart b/tests/language_2/malbounded_type_cast_runtime_test.dart
new file mode 100644
index 0000000..31e8b55
--- /dev/null
+++ b/tests/language_2/malbounded_type_cast_runtime_test.dart
@@ -0,0 +1,27 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+class Super<T extends num> {}
+class Malbounded1 implements Super
+
+ {}
+class Malbounded2 extends Super
+
+ {}
+
+main() {
+ var m = new Malbounded1();
+ Expect.throwsCastError(() => m as Super<int>);
+ var s = new Super<int>();
+ Expect.throwsCastError(() => s as Malbounded1);
+ Expect.throwsCastError(() => s as Malbounded2);
+ s as Super
+
+ ;
+}
diff --git a/tests/language_2/malbounded_type_cast_test.dart b/tests/language_2/malbounded_type_cast_test.dart
index 07175ef..4ebe0c7 100644
--- a/tests/language_2/malbounded_type_cast_test.dart
+++ b/tests/language_2/malbounded_type_cast_test.dart
@@ -6,10 +6,18 @@
class Super<T extends num> {}
class Malbounded1 implements Super
- <String> //# 00: compile-time error
+// ^
+// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Super' in the supertype 'Super' of class 'Malbounded1'.
+ <String>
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
{}
class Malbounded2 extends Super
- <String> //# 01: compile-time error
+// ^
+// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Super' in the supertype 'Super' of class 'Malbounded2'.
+ <String>
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
{}
main() {
@@ -19,6 +27,10 @@
Expect.throwsCastError(() => s as Malbounded1);
Expect.throwsCastError(() => s as Malbounded2);
s as Super
- <String> //# 02: compile-time error
+ //^
+ // [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Super'.
+ <String>
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
;
}
diff --git a/tests/language_2/malbounded_type_literal_runtime_test.dart b/tests/language_2/malbounded_type_literal_runtime_test.dart
new file mode 100644
index 0000000..adeefbf
--- /dev/null
+++ b/tests/language_2/malbounded_type_literal_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+class Super<T extends num> {}
+
+class Malbounded extends Super
+
+ {}
+
+main() {
+ Type t = Malbounded;
+ Expect.isNotNull(t);
+ Expect.isTrue(t is Type);
+}
diff --git a/tests/language_2/malbounded_type_literal_test.dart b/tests/language_2/malbounded_type_literal_test.dart
index 4ab5907..2369b69 100644
--- a/tests/language_2/malbounded_type_literal_test.dart
+++ b/tests/language_2/malbounded_type_literal_test.dart
@@ -7,7 +7,11 @@
class Super<T extends num> {}
class Malbounded extends Super
- <String> //# 00: compile-time error
+// ^
+// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Super' in the supertype 'Super' of class 'Malbounded'.
+ <String>
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
{}
main() {
diff --git a/tests/language_2/malbounded_type_test2_runtime_test.dart b/tests/language_2/malbounded_type_test2_runtime_test.dart
new file mode 100644
index 0000000..1edb15f
--- /dev/null
+++ b/tests/language_2/malbounded_type_test2_runtime_test.dart
@@ -0,0 +1,23 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class A<T extends num> {}
+
+class B<T> {
+ test() {
+ new A() is A
+
+ ;
+ }
+}
+
+main() {
+ var b = new B<String>();
+ b.test();
+}
diff --git a/tests/language_2/malbounded_type_test2_test.dart b/tests/language_2/malbounded_type_test2_test.dart
index 80b313e..8eec3aa 100644
--- a/tests/language_2/malbounded_type_test2_test.dart
+++ b/tests/language_2/malbounded_type_test2_test.dart
@@ -9,7 +9,11 @@
class B<T> {
test() {
new A() is A
- <T> //# 00: compile-time error
+ // ^
+ // [cfe] Type argument 'T' doesn't conform to the bound 'num' of the type variable 'T' on 'A'.
+ <T>
+// ^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
;
}
}
diff --git a/tests/language_2/malbounded_type_test_runtime_test.dart b/tests/language_2/malbounded_type_test_runtime_test.dart
new file mode 100644
index 0000000..e62f180
--- /dev/null
+++ b/tests/language_2/malbounded_type_test_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+class Super<T extends num> {}
+
+class Malbounded1 implements Super
+
+ {}
+
+class Malbounded2 extends Super
+
+ {}
+
+main() {
+ var m = new Malbounded1();
+ Expect.isFalse(m is Super<int>);
+ var s = new Super<int>();
+ Expect.isFalse(s is Malbounded1);
+ Expect.isFalse(s is Malbounded2);
+ Expect.isTrue(s is Super
+
+ );
+}
diff --git a/tests/language_2/malbounded_type_test_test.dart b/tests/language_2/malbounded_type_test_test.dart
index 405d221..70fc939 100644
--- a/tests/language_2/malbounded_type_test_test.dart
+++ b/tests/language_2/malbounded_type_test_test.dart
@@ -7,11 +7,19 @@
class Super<T extends num> {}
class Malbounded1 implements Super
- <String> //# 00: compile-time error
+// ^
+// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Super' in the supertype 'Super' of class 'Malbounded1'.
+ <String>
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
{}
class Malbounded2 extends Super
- <String> //# 01: compile-time error
+// ^
+// [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Super' in the supertype 'Super' of class 'Malbounded2'.
+ <String>
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
{}
main() {
@@ -21,6 +29,10 @@
Expect.isFalse(s is Malbounded1);
Expect.isFalse(s is Malbounded2);
Expect.isTrue(s is Super
- <String> //# 02: compile-time error
+ // ^
+ // [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Super'.
+ <String>
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
);
}
diff --git a/tests/language_2/malformed_inheritance_runtime_test.dart b/tests/language_2/malformed_inheritance_runtime_test.dart
new file mode 100644
index 0000000..8c88a62
--- /dev/null
+++ b/tests/language_2/malformed_inheritance_runtime_test.dart
@@ -0,0 +1,86 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Tests that malformed types used in extends, implements, and with clauses
+// cause compile-time errors.
+
+class A<T> {}
+
+class C
+
+ {
+}
+
+class C1
+
+ {
+}
+
+class C2
+
+ {
+}
+
+class C3
+
+ {
+}
+
+class C4
+
+ {
+}
+
+class C5
+
+ {
+}
+
+class C6<A>
+
+ {
+}
+
+class C7<A>
+
+ {
+}
+
+class C8<A>
+
+ {
+}
+
+class C9<A>
+
+ {
+}
+
+class C10<A>
+
+ {
+}
+
+class C11<A>
+
+ {
+}
+
+void main() {
+ new C();
+ new C1();
+ new C2();
+ new C3();
+ new C4();
+ new C5();
+ new C6<Object>();
+ new C7<Object>();
+ new C8<Object>();
+ new C9<Object>();
+ new C10<Object>();
+ new C11<Object>();
+}
diff --git a/tests/language_2/malformed_inheritance_test.dart b/tests/language_2/malformed_inheritance_test.dart
index 7baed22..e82cc7a 100644
--- a/tests/language_2/malformed_inheritance_test.dart
+++ b/tests/language_2/malformed_inheritance_test.dart
@@ -8,62 +8,131 @@
class A<T> {}
class C
- extends Unresolved //# 00: compile-time error
+ extends Unresolved
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTENDS_NON_CLASS
+ // [cfe] Type 'Unresolved' not found.
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
{
}
class C1
- extends A<Unresolved> //# 01: compile-time error
+ extends A<Unresolved>
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // [cfe] Type 'Unresolved' not found.
{
}
class C2
- extends Object with Unresolved //# 02: compile-time error
+// ^
+// [cfe] The type 'Unresolved' can't be mixed in.
+ extends Object with Unresolved
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
+ // [cfe] Type 'Unresolved' not found.
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
{
}
class C3
- extends Object with A<Unresolved> //# 03: compile-time error
+ extends Object with A<Unresolved>
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // [cfe] Type 'Unresolved' not found.
{
}
class C4
- implements Unresolved //# 04: compile-time error
+ implements Unresolved
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
+ // [cfe] Type 'Unresolved' not found.
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
{
}
class C5
- implements A<Unresolved> //# 05: compile-time error
+ implements A<Unresolved>
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // [cfe] Type 'Unresolved' not found.
{
}
class C6<A>
- extends A<int> //# 06: compile-time error
+ extends A<int>
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.EXTENDS_NON_CLASS
+ // [cfe] Can't use type arguments with type variable 'A'.
+ // ^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
{
}
class C7<A>
- extends A<Unresolved> //# 07: compile-time error
+ extends A<Unresolved>
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.EXTENDS_NON_CLASS
+ // [cfe] Can't use type arguments with type variable 'A'.
+ // ^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // [cfe] Type 'Unresolved' not found.
{
}
class C8<A>
- extends Object with A<int> //# 08: compile-time error
+// ^
+// [cfe] The type 'A<int>' can't be mixed in.
+ extends Object with A<int>
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
+ // [cfe] Can't use type arguments with type variable 'A'.
+ // ^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
{
}
class C9<A>
- extends Object with A<Unresolved> //# 09: compile-time error
+// ^
+// [cfe] The type 'A<Unresolved>' can't be mixed in.
+ extends Object with A<Unresolved>
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
+ // [cfe] Can't use type arguments with type variable 'A'.
+ // ^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // [cfe] Type 'Unresolved' not found.
{
}
class C10<A>
- implements A<int> //# 10: compile-time error
+ implements A<int>
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
+ // [cfe] Can't use type arguments with type variable 'A'.
+ // ^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
{
}
class C11<A>
- implements A<Unresolved> //# 11: compile-time error
+ implements A<Unresolved>
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
+ // [cfe] Can't use type arguments with type variable 'A'.
+ // ^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // [cfe] Type 'Unresolved' not found.
{
}
diff --git a/tests/language_2/malformed_runtime_test.dart b/tests/language_2/malformed_runtime_test.dart
new file mode 100644
index 0000000..e08772f
--- /dev/null
+++ b/tests/language_2/malformed_runtime_test.dart
@@ -0,0 +1,84 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+import 'package:expect/expect.dart' as prefix; // Define 'prefix'.
+
+checkIsUnresolved(var v) {
+
+
+
+
+}
+
+checkIsListUnresolved(var v) {
+
+
+
+
+
+}
+
+checkAsUnresolved(var v) {
+
+
+
+
+}
+
+checkAsListUnresolved(var v) {
+
+
+
+
+
+}
+
+void main() {
+ checkIsUnresolved('');
+ checkAsUnresolved('');
+ checkIsListUnresolved(new List());
+ checkAsListUnresolved(new List());
+
+
+
+
+ try {
+ throw 'foo';
+ }
+
+ catch (e) {
+ }
+
+ try {
+ throw 'foo';
+ }
+
+ catch (e) {
+ }
+
+ try {
+ throw 'foo';
+ }
+
+ catch (e) {
+ }
+
+ try {
+ throw 'foo';
+ }
+
+ catch (e) {
+ }
+
+ try {
+ throw 'foo';
+ }
+
+ catch (e) {
+ }
+}
diff --git a/tests/language_2/malformed_test.dart b/tests/language_2/malformed_test.dart
index b032bc0..2a11ce8 100644
--- a/tests/language_2/malformed_test.dart
+++ b/tests/language_2/malformed_test.dart
@@ -6,33 +6,95 @@
import 'package:expect/expect.dart' as prefix; // Define 'prefix'.
checkIsUnresolved(var v) {
- v is Unresolved; //# 00: compile-time error
- v is Unresolved<int>; //# 01: compile-time error
- v is prefix.Unresolved; //# 02: compile-time error
- v is prefix.Unresolved<int>; //# 03: compile-time error
+ v is Unresolved;
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_UNDEFINED_NAME
+ // [cfe] 'Unresolved' isn't a type.
+ v is Unresolved<int>;
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_UNDEFINED_NAME
+ // [cfe] 'Unresolved' isn't a type.
+ v is prefix.Unresolved;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_UNDEFINED_NAME
+ // ^
+ // [cfe] 'Unresolved' isn't a type.
+ v is prefix.Unresolved<int>;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_UNDEFINED_NAME
+ // ^
+ // [cfe] 'Unresolved' isn't a type.
}
checkIsListUnresolved(var v) {
- v is List<Unresolved>; //# 04: compile-time error
- v is List<Unresolved<int>>; //# 05: compile-time error
- v is List<prefix.Unresolved>; //# 06: compile-time error
- v is List<prefix.Unresolved<int>>; //# 07: compile-time error
- v is List<int, String>; //# 08: compile-time error
+ v is List<Unresolved>;
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // [cfe] 'Unresolved' isn't a type.
+ v is List<Unresolved<int>>;
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // [cfe] 'Unresolved' isn't a type.
+ v is List<prefix.Unresolved>;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // ^
+ // [cfe] 'Unresolved' isn't a type.
+ v is List<prefix.Unresolved<int>>;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // ^
+ // [cfe] 'Unresolved' isn't a type.
+ v is List<int, String>;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+ // [cfe] Expected 1 type arguments.
}
checkAsUnresolved(var v) {
- v as Unresolved; //# 09: compile-time error
- v as Unresolved<int>; //# 10: compile-time error
- v as prefix.Unresolved; //# 11: compile-time error
- v as prefix.Unresolved<int>; //# 12: compile-time error
+ v as Unresolved;
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.CAST_TO_NON_TYPE
+ // [cfe] 'Unresolved' isn't a type.
+ v as Unresolved<int>;
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.CAST_TO_NON_TYPE
+ // [cfe] 'Unresolved' isn't a type.
+ v as prefix.Unresolved;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.CAST_TO_NON_TYPE
+ // ^
+ // [cfe] 'Unresolved' isn't a type.
+ v as prefix.Unresolved<int>;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.CAST_TO_NON_TYPE
+ // ^
+ // [cfe] 'Unresolved' isn't a type.
}
checkAsListUnresolved(var v) {
- v as List<Unresolved>; //# 13: compile-time error
- v as List<Unresolved<int>>; //# 14: compile-time error
- v as List<prefix.Unresolved>; //# 15: compile-time error
- v as List<prefix.Unresolved<int>>; //# 16: compile-time error
- v as List<int, String>; //# 17: compile-time error
+ v as List<Unresolved>;
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // [cfe] 'Unresolved' isn't a type.
+ v as List<Unresolved<int>>;
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // [cfe] 'Unresolved' isn't a type.
+ v as List<prefix.Unresolved>;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // ^
+ // [cfe] 'Unresolved' isn't a type.
+ v as List<prefix.Unresolved<int>>;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.NON_TYPE_AS_TYPE_ARGUMENT
+ // ^
+ // [cfe] 'Unresolved' isn't a type.
+ v as List<int, String>;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+ // [cfe] Expected 1 type arguments.
}
void main() {
@@ -41,41 +103,64 @@
checkIsListUnresolved(new List());
checkAsListUnresolved(new List());
- new undeclared_prefix.Unresolved(); //# 18: compile-time error
- new undeclared_prefix.Unresolved<int>(); //# 19: compile-time error
+ new undeclared_prefix.Unresolved();
+ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // [cfe] Method not found: 'undeclared_prefix.Unresolved'.
+ new undeclared_prefix.Unresolved<int>();
+ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // [cfe] Method not found: 'undeclared_prefix.Unresolved'.
try {
throw 'foo';
}
- on Unresolved //# 20: compile-time error
+ on Unresolved
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NON_TYPE_IN_CATCH_CLAUSE
+ // [cfe] 'Unresolved' isn't a type.
catch (e) {
}
try {
throw 'foo';
}
- on Unresolved<int> //# 21: compile-time error
+ on Unresolved<int>
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NON_TYPE_IN_CATCH_CLAUSE
+ // [cfe] 'Unresolved' isn't a type.
catch (e) {
}
try {
throw 'foo';
}
- on prefix.Unresolved //# 22: compile-time error
+ on prefix.Unresolved
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NON_TYPE_IN_CATCH_CLAUSE
+ // ^
+ // [cfe] 'Unresolved' isn't a type.
catch (e) {
}
try {
throw 'foo';
}
- on prefix.Unresolved<int> //# 23: compile-time error
+ on prefix.Unresolved<int>
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NON_TYPE_IN_CATCH_CLAUSE
+ // ^
+ // [cfe] 'Unresolved' isn't a type.
catch (e) {
}
try {
throw 'foo';
}
- on undeclared_prefix.Unresolved<int> // //# 24: compile-time error
+ on undeclared_prefix.Unresolved<int>
+ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NON_TYPE_IN_CATCH_CLAUSE
+ // [cfe] 'undeclared_prefix.Unresolved' can't be used as a type because 'undeclared_prefix' isn't defined.
catch (e) {
}
}
diff --git a/tests/language_2/map_literal1_runtime_test.dart b/tests/language_2/map_literal1_runtime_test.dart
new file mode 100644
index 0000000..093f893
--- /dev/null
+++ b/tests/language_2/map_literal1_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+//
+// A type mismatch in a constant map literal is a compile-time error.
+
+main() {
+ var m = const
+
+ {"a": 0};
+}
diff --git a/tests/language_2/map_literal1_test.dart b/tests/language_2/map_literal1_test.dart
index 431f4bf..71c4e8e 100644
--- a/tests/language_2/map_literal1_test.dart
+++ b/tests/language_2/map_literal1_test.dart
@@ -6,6 +6,9 @@
main() {
var m = const
- <String, String> // //# 01: compile-time error
+ <String, String>
{"a": 0};
+ // ^
+ // [analyzer] STATIC_WARNING.MAP_VALUE_TYPE_NOT_ASSIGNABLE
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'String'.
}
diff --git a/tests/language_2/method_not_found_runtime_test.dart b/tests/language_2/method_not_found_runtime_test.dart
new file mode 100644
index 0000000..49dc434
--- /dev/null
+++ b/tests/language_2/method_not_found_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class A {
+
+ static const field = const B();
+}
+
+class B {
+ const B();
+}
+
+main() {
+ print(A.field);
+}
diff --git a/tests/language_2/method_not_found_test.dart b/tests/language_2/method_not_found_test.dart
index 803f251..08423fb 100644
--- a/tests/language_2/method_not_found_test.dart
+++ b/tests/language_2/method_not_found_test.dart
@@ -3,8 +3,17 @@
// BSD-style license that can be found in the LICENSE file.
class A {
- B(); //# 01: compile-time error
+// ^
+// [cfe] The non-abstract class 'A' is missing implementations for these members:
+ B();
+//^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
static const field = const B();
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_WITH_NON_TYPE
+ // [cfe] Can't access 'this' in a field initializer to read 'B'.
+ // ^
+ // [cfe] Method not found: 'B'.
}
class B {
diff --git a/tests/language_2/method_override3_runtime_test.dart b/tests/language_2/method_override3_runtime_test.dart
new file mode 100644
index 0000000..e391830
--- /dev/null
+++ b/tests/language_2/method_override3_runtime_test.dart
@@ -0,0 +1,55 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import 'package:expect/expect.dart';
+
+class A {
+ foo(required1, {named1: 499}) => -(required1 + named1 * 3);
+ bar(required1, required2, {named1: 13, named2: 17}) =>
+ -(required1 + required2 * 3 + named1 * 5 + named2 * 7);
+ gee({named1: 31}) => -named1;
+}
+
+class B extends A {
+ foo(
+ required1
+
+ ,
+ {named1: 499}
+
+ ) {
+ return required1;
+ }
+
+ bar(required1, required2,
+ {named1: 13
+
+ ,
+ named2: 17
+
+ }) {
+ return required1 + required2 * 3 + named1 * 5;
+ }
+
+ gee(
+ {named2: 11
+
+ ,
+ named1: 31
+
+ }) {
+ return named2 * 99;
+ }
+}
+
+main() {
+ // Ensure that compile-time errors are reached.
+ var b = new B();
+ b.foo(499);
+ b.bar(1, 3, named1: 5);
+ b.gee(named2: 3);
+}
diff --git a/tests/language_2/method_override3_test.dart b/tests/language_2/method_override3_test.dart
index 2b28739..b131ff0 100644
--- a/tests/language_2/method_override3_test.dart
+++ b/tests/language_2/method_override3_test.dart
@@ -13,31 +13,40 @@
class B extends A {
foo(
+//^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+// [cfe] The method 'B.foo' has fewer named arguments than those of overridden method 'A.foo'.
required1
- /* // //# 00: compile-time error
+ /*
,
{named1: 499}
- */ // //# 00: compile-time error
+ */
) {
return required1;
}
bar(required1, required2,
+//^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+// [cfe] The method 'B.bar' has fewer named arguments than those of overridden method 'A.bar'.
{named1: 13
- /* // //# 01: compile-time error
+ /*
,
named2: 17
- */ // //# 01: compile-time error
+ */
}) {
return required1 + required2 * 3 + named1 * 5;
}
gee(
+//^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+// [cfe] The method 'B.gee' doesn't have the named parameter 'named1' of overridden method 'A.gee'.
{named2: 11
- /* // //# 02: compile-time error
+ /*
,
named1: 31
- */ // //# 02: compile-time error
+ */
}) {
return named2 * 99;
}
diff --git a/tests/language_2/mixin_cyclic_runtime_test.dart b/tests/language_2/mixin_cyclic_runtime_test.dart
new file mode 100644
index 0000000..2217ac1
--- /dev/null
+++ b/tests/language_2/mixin_cyclic_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test for cyclicity check on named mixin applications.
+
+class A<T> {}
+
+class S {}
+
+class M<T> {}
+
+class C1 = S with M;
+
+class C3 = S with M implements A;
+
+
+void main() {
+ new C1();
+
+ new C3();
+
+}
diff --git a/tests/language_2/mixin_cyclic_test.dart b/tests/language_2/mixin_cyclic_test.dart
index 9a37d5f..4e129a6 100644
--- a/tests/language_2/mixin_cyclic_test.dart
+++ b/tests/language_2/mixin_cyclic_test.dart
@@ -11,13 +11,21 @@
class M<T> {}
class C1 = S with M;
-class C2 = S with C2; //# 01: compile-time error
+class C2 = S with C2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE_WITH
+// [cfe] 'C2' is a supertype of itself.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class C3 = S with M implements A;
-class C4 = S with M implements C4; //# 02: compile-time error
+class C4 = S with M implements C4;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE_IMPLEMENTS
+// [cfe] 'C4' is a supertype of itself.
void main() {
new C1();
- new C2(); //# 01: continued
+ new C2();
new C3();
- new C4(); //# 02: continued
+ new C4();
}
diff --git a/tests/language_2/mixin_illegal_constructor_runtime_test.dart b/tests/language_2/mixin_illegal_constructor_runtime_test.dart
new file mode 100644
index 0000000..da8e2680
--- /dev/null
+++ b/tests/language_2/mixin_illegal_constructor_runtime_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class M0 {
+ factory M0(a, b, c) => null;
+ factory M0.named() => null;
+}
+
+class M1 {
+ M1();
+}
+
+class M2 {
+ M2.named();
+}
+
+class C0 = Object with M0;
+
+
+
+
+
+
+
+class D0 extends Object with M0 {}
+
+
+
+
+
+
+
+main() {
+ new C0();
+
+
+
+
+
+
+
+ new D0();
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/mixin_illegal_constructor_test.dart b/tests/language_2/mixin_illegal_constructor_test.dart
index 0185189..b6df547 100644
--- a/tests/language_2/mixin_illegal_constructor_test.dart
+++ b/tests/language_2/mixin_illegal_constructor_test.dart
@@ -16,40 +16,100 @@
}
class C0 = Object with M0;
-class C1 = Object with M1; // //# 01: compile-time error
-class C2 = Object with M2; // //# 02: compile-time error
-class C3 = Object with M0, M1; // //# 03: compile-time error
-class C4 = Object with M1, M0; // //# 04: compile-time error
-class C5 = Object with M0, M2; // //# 05: compile-time error
-class C6 = Object with M2, M0; // //# 06: compile-time error
+class C1 = Object with M1;
+// ^
+// [cfe] Can't use 'M1' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
+class C2 = Object with M2;
+// ^
+// [cfe] Can't use 'M2' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
+class C3 = Object with M0, M1;
+// ^
+// [cfe] Can't use 'M1' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
+class C4 = Object with M1, M0;
+// ^
+// [cfe] Can't use 'M1' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
+class C5 = Object with M0, M2;
+// ^
+// [cfe] Can't use 'M2' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
+class C6 = Object with M2, M0;
+// ^
+// [cfe] Can't use 'M2' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
class D0 extends Object with M0 {}
-class D1 extends Object with M1 { } // //# 07: compile-time error
-class D2 extends Object with M2 { } // //# 08: compile-time error
-class D3 extends Object with M0, M1 { } // //# 09: compile-time error
-class D4 extends Object with M1, M0 { } // //# 10: compile-time error
-class D5 extends Object with M0, M2 { } // //# 11: compile-time error
-class D6 extends Object with M2, M0 { } // //# 12: compile-time error
+class D1 extends Object with M1 { }
+// ^
+// [cfe] Can't use 'M1' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
+class D2 extends Object with M2 { }
+// ^
+// [cfe] Can't use 'M2' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
+class D3 extends Object with M0, M1 { }
+// ^
+// [cfe] Can't use 'M1' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
+class D4 extends Object with M1, M0 { }
+// ^
+// [cfe] Can't use 'M1' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
+class D5 extends Object with M0, M2 { }
+// ^
+// [cfe] Can't use 'M2' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
+class D6 extends Object with M2, M0 { }
+// ^
+// [cfe] Can't use 'M2' as a mixin because it has constructors.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
main() {
new C0();
- new C1(); // //# 01: continued
- new C2(); // //# 02: continued
- new C3(); // //# 03: continued
- new C4(); // //# 04: continued
- new C5(); // //# 05: continued
- new C6(); // //# 06: continued
+ new C1();
+ new C2();
+ new C3();
+ new C4();
+ new C5();
+ new C6();
new D0();
- new D1(); // //# 07: continued
- new D2(); // //# 08: continued
- new D3(); // //# 09: continued
- new D4(); // //# 10: continued
- new D5(); // //# 11: continued
- new D6(); // //# 12: continued
+ new D1();
+ new D2();
+ new D3();
+ new D4();
+ new D5();
+ new D6();
- new C0(1,2,3); // //# 13: compile-time error
- new C0.named(); // //# 14: compile-time error
- new D0(1,2,3); // //# 15: compile-time error
- new D0.named(); // //# 16: compile-time error
+ new C0(1,2,3);
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 0 allowed, but 3 found.
+ new C0.named();
+ // ^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_UNDEFINED_CONSTRUCTOR
+ // [cfe] Method not found: 'C0.named'.
+ new D0(1,2,3);
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 0 allowed, but 3 found.
+ new D0.named();
+ // ^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_UNDEFINED_CONSTRUCTOR
+ // [cfe] Method not found: 'D0.named'.
}
diff --git a/tests/language_2/mixin_illegal_cycles_runtime_test.dart b/tests/language_2/mixin_illegal_cycles_runtime_test.dart
new file mode 100644
index 0000000..cd5bbfe
--- /dev/null
+++ b/tests/language_2/mixin_illegal_cycles_runtime_test.dart
@@ -0,0 +1,42 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class M {}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/mixin_illegal_cycles_test.dart b/tests/language_2/mixin_illegal_cycles_test.dart
index 06c907f..3db5716 100644
--- a/tests/language_2/mixin_illegal_cycles_test.dart
+++ b/tests/language_2/mixin_illegal_cycles_test.dart
@@ -3,37 +3,84 @@
// BSD-style license that can be found in the LICENSE file.
class M {}
-class M0 extends Object with M0 { } // //# 01: compile-time error
-class M1 = Object with M1; // //# 02: compile-time error
+class M0 extends Object with M0 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE_WITH
+// [cfe] 'M0' is a supertype of itself.
+// ^
+// [cfe] 'Object with M0' is a supertype of itself.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class M1 = Object with M1;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE_WITH
+// [cfe] 'M1' is a supertype of itself.
-class M2 = Object with M3; // //# 03: compile-time error
-class M3 = Object with M2; // //# 03: continued
+class M2 = Object with M3;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE
+// [cfe] 'M2' is a supertype of itself.
+class M3 = Object with M2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE
+// [cfe] 'M3' is a supertype of itself.
-class M4 = Object with M5; // //# 04: compile-time error
-class M5 = Object with M6; // //# 04: continued
-class M6 = Object with M4; // //# 04: continued
+class M4 = Object with M5;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE
+// [cfe] 'M4' is a supertype of itself.
+class M5 = Object with M6;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE
+// [cfe] 'M5' is a supertype of itself.
+class M6 = Object with M4;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE
+// [cfe] 'M6' is a supertype of itself.
-class M7 extends Object with M8 { } // //# 05: compile-time error
-class M8 extends Object with M7 { } // //# 05: continued
+class M7 extends Object with M8 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE
+// [cfe] 'M7' is a supertype of itself.
+// ^
+// [cfe] 'Object with M8' is a supertype of itself.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class M8 extends Object with M7 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE
+// [cfe] 'M8' is a supertype of itself.
+// ^
+// [cfe] 'Object with M7' is a supertype of itself.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
-class M9 = Object with M91; // //# 06: compile-time error
-class M91 = Object with M92; // //# 06: continued
-class M92 = Object with M91; // //# 06: continued
+class M9 = Object with M91;
+// ^
+// [cfe] 'M9' is a supertype of itself.
+class M91 = Object with M92;
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE
+// [cfe] 'M91' is a supertype of itself.
+class M92 = Object with M91;
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_INTERFACE_INHERITANCE
+// [cfe] 'M92' is a supertype of itself.
main() {
- new M0(); // //# 01: continued
+ new M0();
- new M1(); // //# 02: continued
+ new M1();
- new M2(); // //# 03: continued
- new M3(); // //# 03: continued
+ new M2();
+ new M3();
- new M4(); // //# 04: continued
- new M5(); // //# 04: continued
- new M6(); // //# 04: continued
+ new M4();
+ new M5();
+ new M6();
- new M7(); // //# 05: continued
- new M8(); // //# 05: continued
+ new M7();
+ new M8();
- new M9(); // //# 06: continued
+ new M9();
}
diff --git a/tests/language_2/mixin_illegal_object_runtime_test.dart b/tests/language_2/mixin_illegal_object_runtime_test.dart
new file mode 100644
index 0000000..9f8bf27
--- /dev/null
+++ b/tests/language_2/mixin_illegal_object_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Object has a non-trivial constructor and hence cannot be used as mixin.
+
+class S {}
+
+class C0 extends S
+
+{}
+
+
+
+main() {
+ new C0();
+
+}
diff --git a/tests/language_2/mixin_illegal_object_test.dart b/tests/language_2/mixin_illegal_object_test.dart
index dac0341..ddd27f2 100644
--- a/tests/language_2/mixin_illegal_object_test.dart
+++ b/tests/language_2/mixin_illegal_object_test.dart
@@ -7,12 +7,20 @@
class S {}
class C0 extends S
-with Object // //# 01: compile-time error
+// ^
+// [cfe] Can't use 'Object' as a mixin because it has constructors.
+with Object
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
{}
-class C1 = S with Object; // //# 02: compile-time error
+class C1 = S with Object;
+// ^
+// [cfe] Can't use 'Object' as a mixin because it has constructors.
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_CLASS_DECLARES_CONSTRUCTOR
main() {
new C0();
- new C1(); // //# 02: continued
+ new C1();
}
diff --git a/tests/language_2/mixin_illegal_static_access_runtime_test.dart b/tests/language_2/mixin_illegal_static_access_runtime_test.dart
new file mode 100644
index 0000000..edf6b9a
--- /dev/null
+++ b/tests/language_2/mixin_illegal_static_access_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+class S {
+ static foo() => 42;
+}
+
+class M {
+ static bar() => 87;
+}
+
+class C = S with M;
+
+main() {
+ Expect.equals(42, S.foo());
+ Expect.equals(87, M.bar());
+
+
+
+}
diff --git a/tests/language_2/mixin_illegal_static_access_test.dart b/tests/language_2/mixin_illegal_static_access_test.dart
index cfda0fe..21e2348 100644
--- a/tests/language_2/mixin_illegal_static_access_test.dart
+++ b/tests/language_2/mixin_illegal_static_access_test.dart
@@ -18,6 +18,12 @@
Expect.equals(42, S.foo());
Expect.equals(87, M.bar());
- Expect.throwsNoSuchMethodError(() => C.foo()); //# 01: compile-time error
- Expect.throwsNoSuchMethodError(() => C.bar()); //# 02: compile-time error
+ Expect.throwsNoSuchMethodError(() => C.foo());
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] Method not found: 'C.foo'.
+ Expect.throwsNoSuchMethodError(() => C.bar());
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] Method not found: 'C.bar'.
}
diff --git a/tests/language_2/mixin_illegal_super_use_runtime_test.dart b/tests/language_2/mixin_illegal_super_use_runtime_test.dart
new file mode 100644
index 0000000..86ecb63
--- /dev/null
+++ b/tests/language_2/mixin_illegal_super_use_runtime_test.dart
@@ -0,0 +1,73 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+class M {}
+
+class P0 {
+ foo() {
+
+
+
+
+ void inner() {
+
+
+
+ }
+ inner();
+
+ (() {
+
+
+
+ })();
+
+ return 42;
+ }
+}
+
+class P1 {
+ bar() {
+
+ return 87;
+ }
+
+ // The test method is strategically placed here to try to force the
+ // P1 class and its bar method to be resolved before resolving the
+ // mixin applications.
+ test() {
+ new C();
+ var d = new D();
+ var e = new E();
+ var f = new F();
+ Expect.equals(42, d.foo());
+ Expect.equals(87, e.bar());
+ Expect.equals(99, f.baz());
+ }
+}
+
+class P2 {
+ baz() {
+
+ return 99;
+ }
+}
+
+class C = Object with M;
+class D = Object with P0;
+class E = Object with M, P1;
+class F = Object with P2, M;
+
+main() {
+ var p1 = new P1();
+ var p2 = new P2();
+ Expect.equals(87, p1.bar());
+ p1.test();
+ Expect.equals(99, p2.baz());
+}
diff --git a/tests/language_2/mixin_illegal_super_use_test.dart b/tests/language_2/mixin_illegal_super_use_test.dart
index 151236e..4796185 100644
--- a/tests/language_2/mixin_illegal_super_use_test.dart
+++ b/tests/language_2/mixin_illegal_super_use_test.dart
@@ -8,21 +8,39 @@
class P0 {
foo() {
- super.toString(); // //# 01: compile-time error
- super.foo(); // //# 02: compile-time error
- super.bar = 100; // //# 03: compile-time error
+ super.toString();
+ super.foo();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SUPER_METHOD
+ // [cfe] Superclass has no method named 'foo'.
+ super.bar = 100;
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SUPER_SETTER
+ // [cfe] Superclass has no setter named 'bar'.
void inner() {
- super.toString(); // //# 04: compile-time error
- super.foo(); // //# 05: compile-time error
- super.bar = 100; // //# 06: compile-time error
+ super.toString();
+ super.foo();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SUPER_METHOD
+ // [cfe] Superclass has no method named 'foo'.
+ super.bar = 100;
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SUPER_SETTER
+ // [cfe] Superclass has no setter named 'bar'.
}
inner();
(() {
- super.toString(); // //# 07: compile-time error
- super.foo(); // //# 08: compile-time error
- super.bar = 100; // //# 09: compile-time error
+ super.toString();
+ super.foo();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SUPER_METHOD
+ // [cfe] Superclass has no method named 'foo'.
+ super.bar = 100;
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SUPER_SETTER
+ // [cfe] Superclass has no setter named 'bar'.
})();
return 42;
@@ -31,7 +49,7 @@
class P1 {
bar() {
- super.toString(); // //# 10: compile-time error
+ super.toString();
return 87;
}
@@ -51,15 +69,21 @@
class P2 {
baz() {
- super.toString(); // //# 11: compile-time error
+ super.toString();
return 99;
}
}
class C = Object with M;
class D = Object with P0;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_REFERENCES_SUPER
class E = Object with M, P1;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_REFERENCES_SUPER
class F = Object with P2, M;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_REFERENCES_SUPER
main() {
var p1 = new P1();
diff --git a/tests/language_2/mixin_illegal_superclass_runtime_test.dart b/tests/language_2/mixin_illegal_superclass_runtime_test.dart
new file mode 100644
index 0000000..303ca9b
--- /dev/null
+++ b/tests/language_2/mixin_illegal_superclass_runtime_test.dart
@@ -0,0 +1,134 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class S0 {}
+
+class S1 extends Object {}
+
+class S2 extends S0 {}
+
+class M0 {}
+
+class M1 extends Object {}
+
+class M2 extends M0 {}
+
+class C00 = S0 with M0;
+class C01 = S0 with M1;
+
+class C03 = S0 with M0, M1;
+
+
+
+
+
+class C10 = S1 with M0;
+class C11 = S1 with M1;
+
+class C13 = S1 with M0, M1;
+
+
+
+
+
+class C20 = S2 with M0;
+class C21 = S2 with M1;
+
+class C23 = S2 with M0, M1;
+
+
+
+
+
+class D00 extends S0 with M0 {}
+
+class D01 extends S0 with M1 {}
+
+
+class D03 extends S0 with M0, M1 {}
+
+
+
+
+
+class D10 extends S1 with M0 {}
+
+class D11 extends S1 with M1 {}
+
+
+class D13 extends S1 with M0, M1 {}
+
+
+
+
+
+class D20 extends S2 with M0 {}
+
+class D21 extends S2 with M1 {}
+
+
+class D23 extends S2 with M0, M1 {}
+
+
+
+
+
+main() {
+ new C00();
+ new C01();
+
+ new C03();
+
+
+
+
+
+ new C10();
+ new C11();
+
+ new C13();
+
+
+
+
+
+ new C20();
+ new C21();
+
+ new C23();
+
+
+
+
+
+ new D00();
+ new D01();
+
+ new D03();
+
+
+
+
+
+ new D10();
+ new D11();
+
+ new D13();
+
+
+
+
+
+ new D20();
+ new D21();
+
+ new D23();
+
+
+
+
+}
diff --git a/tests/language_2/mixin_illegal_superclass_test.dart b/tests/language_2/mixin_illegal_superclass_test.dart
index 2ca1539..c1e1e0c 100644
--- a/tests/language_2/mixin_illegal_superclass_test.dart
+++ b/tests/language_2/mixin_illegal_superclass_test.dart
@@ -16,116 +16,176 @@
class C00 = S0 with M0;
class C01 = S0 with M1;
-class C02 = S0 with M2; // //# 01: compile-time error
+class C02 = S0 with M2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class C03 = S0 with M0, M1;
-class C04 = S0 with M0, M2; // //# 02: compile-time error
-class C05 = S0 with M2, M0; // //# 03: compile-time error
-class C06 = S0 with M1, M2; // //# 04: compile-time error
-class C07 = S0 with M2, M1; // //# 05: compile-time error
+class C04 = S0 with M0, M2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class C05 = S0 with M2, M0;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class C06 = S0 with M1, M2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class C07 = S0 with M2, M1;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class C10 = S1 with M0;
class C11 = S1 with M1;
-class C12 = S1 with M2; // //# 06: compile-time error
+class C12 = S1 with M2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class C13 = S1 with M0, M1;
-class C14 = S1 with M0, M2; // //# 07: compile-time error
-class C15 = S1 with M2, M0; // //# 08: compile-time error
-class C16 = S1 with M1, M2; // //# 09: compile-time error
-class C17 = S1 with M2, M1; // //# 10: compile-time error
+class C14 = S1 with M0, M2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class C15 = S1 with M2, M0;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class C16 = S1 with M1, M2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class C17 = S1 with M2, M1;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class C20 = S2 with M0;
class C21 = S2 with M1;
-class C22 = S2 with M2; // //# 11: compile-time error
+class C22 = S2 with M2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class C23 = S2 with M0, M1;
-class C24 = S2 with M0, M2; // //# 12: compile-time error
-class C25 = S2 with M2, M0; // //# 13: compile-time error
-class C26 = S2 with M1, M2; // //# 14: compile-time error
-class C27 = S2 with M2, M1; // //# 15: compile-time error
+class C24 = S2 with M0, M2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class C25 = S2 with M2, M0;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class C26 = S2 with M1, M2;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class C27 = S2 with M2, M1;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class D00 extends S0 with M0 {}
class D01 extends S0 with M1 {}
-class D02 extends S0 with M2 { } // //# 16: compile-time error
+class D02 extends S0 with M2 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class D03 extends S0 with M0, M1 {}
-class D04 extends S0 with M0, M2 { } // //# 17: compile-time error
-class D05 extends S0 with M2, M0 { } // //# 18: compile-time error
-class D06 extends S0 with M1, M2 { } // //# 19: compile-time error
-class D07 extends S0 with M2, M1 { } // //# 20: compile-time error
+class D04 extends S0 with M0, M2 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class D05 extends S0 with M2, M0 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class D06 extends S0 with M1, M2 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class D07 extends S0 with M2, M1 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class D10 extends S1 with M0 {}
class D11 extends S1 with M1 {}
-class D12 extends S1 with M2 { } // //# 21: compile-time error
+class D12 extends S1 with M2 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class D13 extends S1 with M0, M1 {}
-class D14 extends S1 with M0, M2 { } // //# 22: compile-time error
-class D15 extends S1 with M2, M0 { } // //# 23: compile-time error
-class D16 extends S1 with M1, M2 { } // //# 24: compile-time error
-class D17 extends S1 with M2, M1 { } // //# 25: compile-time error
+class D14 extends S1 with M0, M2 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class D15 extends S1 with M2, M0 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class D16 extends S1 with M1, M2 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class D17 extends S1 with M2, M1 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class D20 extends S2 with M0 {}
class D21 extends S2 with M1 {}
-class D22 extends S2 with M2 { } // //# 26: compile-time error
+class D22 extends S2 with M2 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
class D23 extends S2 with M0, M1 {}
-class D24 extends S2 with M0, M2 { } // //# 27: compile-time error
-class D25 extends S2 with M2, M0 { } // //# 28: compile-time error
-class D26 extends S2 with M1, M2 { } // //# 29: compile-time error
-class D27 extends S2 with M2, M1 { } // //# 30: compile-time error
+class D24 extends S2 with M0, M2 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class D25 extends S2 with M2, M0 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class D26 extends S2 with M1, M2 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
+class D27 extends S2 with M2, M1 { }
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_INHERITS_FROM_NOT_OBJECT
main() {
new C00();
new C01();
- new C02(); // //# 01: continued
+ new C02();
new C03();
- new C04(); // //# 02: continued
- new C05(); // //# 03: continued
- new C06(); // //# 04: continued
- new C07(); // //# 05: continued
+ new C04();
+ new C05();
+ new C06();
+ new C07();
new C10();
new C11();
- new C12(); // //# 06: continued
+ new C12();
new C13();
- new C14(); // //# 07: continued
- new C15(); // //# 08: continued
- new C16(); // //# 09: continued
- new C17(); // //# 10: continued
+ new C14();
+ new C15();
+ new C16();
+ new C17();
new C20();
new C21();
- new C22(); // //# 11: continued
+ new C22();
new C23();
- new C24(); // //# 12: continued
- new C25(); // //# 13: continued
- new C26(); // //# 14: continued
- new C27(); // //# 15: continued
+ new C24();
+ new C25();
+ new C26();
+ new C27();
new D00();
new D01();
- new D02(); // //# 16: continued
+ new D02();
new D03();
- new D04(); // //# 17: continued
- new D05(); // //# 18: continued
- new D06(); // //# 19: continued
- new D07(); // //# 20: continued
+ new D04();
+ new D05();
+ new D06();
+ new D07();
new D10();
new D11();
- new D12(); // //# 21: continued
+ new D12();
new D13();
- new D14(); // //# 22: continued
- new D15(); // //# 23: continued
- new D16(); // //# 24: continued
- new D17(); // //# 25: continued
+ new D14();
+ new D15();
+ new D16();
+ new D17();
new D20();
new D21();
- new D22(); // //# 26: continued
+ new D22();
new D23();
- new D24(); // //# 27: continued
- new D25(); // //# 28: continued
- new D26(); // //# 29: continued
- new D27(); // //# 30: continued
+ new D24();
+ new D25();
+ new D26();
+ new D27();
}
diff --git a/tests/language_2/mixin_interface_check_runtime_test.dart b/tests/language_2/mixin_interface_check_runtime_test.dart
new file mode 100644
index 0000000..6a652ab
--- /dev/null
+++ b/tests/language_2/mixin_interface_check_runtime_test.dart
@@ -0,0 +1,33 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Thing {}
+
+class SubThing extends Thing {
+ void sub() {}
+}
+
+class A {
+ Thing get thing => new Thing();
+}
+
+abstract class B implements A {
+ @override
+ SubThing get thing;
+}
+
+class C extends A //
+
+
+{}
+
+main() {
+ new C()
+ .thing //
+
+ ;
+}
diff --git a/tests/language_2/mixin_interface_check_test.dart b/tests/language_2/mixin_interface_check_test.dart
index b174f5e..db0aaf3 100644
--- a/tests/language_2/mixin_interface_check_test.dart
+++ b/tests/language_2/mixin_interface_check_test.dart
@@ -18,13 +18,16 @@
}
class C extends A //
- with //# mixin: compile-time error
- B //# mixin: continued
+// ^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+// [cfe] The implementation of 'thing' in the non-abstract class 'C' does not conform to its interface.
+ with
+ B
{}
main() {
new C()
.thing //
- .sub() //# mixin: continued
+ .sub()
;
}
diff --git a/tests/language_2/mixin_method_override_runtime_test.dart b/tests/language_2/mixin_method_override_runtime_test.dart
new file mode 100644
index 0000000..d6f2d76
--- /dev/null
+++ b/tests/language_2/mixin_method_override_runtime_test.dart
@@ -0,0 +1,162 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Signature conformance test.
+abstract class CII {
+ int id(int x);
+}
+
+class CSI {
+ String id(int x) => "$x";
+}
+
+class CIS {
+ int id(String x) => 0;
+}
+
+class CTT<T> {
+ T id(T x) => x;
+}
+
+// Wrong return type.
+
+
+// Wrong argument type.
+
+
+
+// Similar as the above but using an instantiated class instead.
+abstract class C5 = CII with CTT<int>;
+abstract class C6 extends CII with CTT<int> {}
+
+
+
+// Named parameters
+abstract class NIIx {
+ int id({int x}) => x;
+}
+
+class NIIxy {
+ int id({int x, int y}) => y;
+}
+
+class NIIy {
+ int id({int y}) => y;
+}
+
+class NII {
+ int id(int x) => x;
+}
+
+// It's OK to introduce more named parameters.
+abstract class N1 = NIIx with NIIxy;
+abstract class N2 extends NIIx with NIIxy {}
+// It's NOT OK to rename named parameters.
+
+
+// It's NOT OK to drop named parameters.
+
+
+
+class NBABxy<A, B> {
+ B id ({A x, B y}) => y;
+}
+
+class NTTy<T> {
+ T id({T y}) => y;
+}
+
+class NTTx<T> {
+ T id(T x) => x;
+}
+
+// Same as above but with generic classes.
+abstract class N7 = NIIx with NBABxy<int, int>;
+abstract class N8 extends NIIx with NBABxy<int, int> {}
+
+
+
+
+
+
+
+// Optional positional parameters
+abstract class OII {
+ int id([int x]) => x;
+}
+
+class OIII {
+ int id([int x, int y]) => y;
+}
+
+class OIIy {
+ int id([int y]) => y;
+}
+
+class PII {
+ int id(int x) => x;
+}
+
+// It's OK to introduce more optional parameters.
+abstract class O1 = OII with OIII;
+abstract class O2 extends OII with OIII {}
+// It's OK to rename optional parameters.
+abstract class O3 = OII with OIIy;
+abstract class O4 extends OII with OIIy {}
+// It's NOT OK to drop optional parameters.
+
+
+
+class OBAB<A, B> {
+ B id ([A x, B y]) => y;
+}
+
+class OTTy<T> {
+ T id([T y]) => y;
+}
+
+class PTT<T> {
+ T id(T x) => x;
+}
+
+// Same as above but with generic classes.
+abstract class O7 = OII with OBAB<int, int>;
+abstract class O8 extends OII with OBAB<int, int> {}
+
+
+abstract class O11 = OII with OTTy<int>;
+abstract class O12 extends OII with OTTy<int> {}
+
+
+
+// More tests with generic classes.
+abstract class GTTnum {
+ T id<T extends num>(x);
+}
+
+class MTTnum {
+ T id<T extends num>(x) => x;
+}
+
+class MTTint {
+ T id<T extends int>(x) => x;
+}
+
+class MTT {
+ T id<T>(x) => x;
+}
+
+class MTTnumR {
+ T id<T extends num, R>(x) => x;
+}
+class G1 = GTTnum with MTTnum;
+
+
+
+
+
+void main() {}
diff --git a/tests/language_2/mixin_method_override_test.dart b/tests/language_2/mixin_method_override_test.dart
index 2ea1905..3b8e104 100644
--- a/tests/language_2/mixin_method_override_test.dart
+++ b/tests/language_2/mixin_method_override_test.dart
@@ -20,17 +20,61 @@
}
// Wrong return type.
-abstract class C1 = CII with CIS; //# C1: compile-time error
-abstract class C2 extends CII with CIS {} //# C2: compile-time error
+abstract class C1 = CII with CIS;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'C1' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'C1' introduces an erroneous override of 'id'.
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class C2 extends CII with CIS {}
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Applying the mixin 'CIS' to 'CII' introduces an erroneous override of 'id'.
+// ^
+// [cfe] Class 'CII with CIS' inherits multiple members named 'id' with incompatible signatures.
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+
+
// Wrong argument type.
-abstract class C3 = CII with CSI; //# C3: compile-time error
-abstract class C4 extends CII with CSI {} //# C4: compile-time error
+abstract class C3 = CII with CSI;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'C3' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'C3' introduces an erroneous override of 'id'.
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class C4 extends CII with CSI {}
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Applying the mixin 'CSI' to 'CII' introduces an erroneous override of 'id'.
+// ^
+// [cfe] Class 'CII with CSI' inherits multiple members named 'id' with incompatible signatures.
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
// Similar as the above but using an instantiated class instead.
abstract class C5 = CII with CTT<int>;
abstract class C6 extends CII with CTT<int> {}
-abstract class C7 = CII with CTT<String>; //# C7: compile-time error
-abstract class C8 extends CII with CTT<String> {} //# C8: compile-time error
+abstract class C7 = CII with CTT<String>;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'C7' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'C7' introduces an erroneous override of 'id'.
+// ^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class C8 extends CII with CTT<String> {}
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Applying the mixin 'CTT' to 'CII' introduces an erroneous override of 'id'.
+// ^
+// [cfe] Class 'CII with CTT<String>' inherits multiple members named 'id' with incompatible signatures.
+// ^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
// Named parameters
abstract class NIIx {
@@ -53,11 +97,41 @@
abstract class N1 = NIIx with NIIxy;
abstract class N2 extends NIIx with NIIxy {}
// It's NOT OK to rename named parameters.
-abstract class N3 = NIIx with NIIy; //# N3: compile-time error
-abstract class N4 extends NIIx with NIIy {} //# N4: compile-time error
+abstract class N3 = NIIx with NIIy;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'N3' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'N3' introduces an erroneous override of 'id'.
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class N4 extends NIIx with NIIy {}
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Applying the mixin 'NIIy' to 'NIIx' introduces an erroneous override of 'id'.
+// ^
+// [cfe] Class 'NIIx with NIIy' inherits multiple members named 'id' with incompatible signatures.
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+
+
// It's NOT OK to drop named parameters.
-abstract class N5 = NIIx with NII; //# N5: compile-time error
-abstract class N6 extends NIIx with NII {} //# N6: compile-time error
+abstract class N5 = NIIx with NII;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'N5' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'N5' introduces an erroneous override of 'id'.
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class N6 extends NIIx with NII {}
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Applying the mixin 'NII' to 'NIIx' introduces an erroneous override of 'id'.
+// ^
+// [cfe] Class 'NIIx with NII' inherits multiple members named 'id' with incompatible signatures.
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
class NBABxy<A, B> {
B id ({A x, B y}) => y;
@@ -74,12 +148,54 @@
// Same as above but with generic classes.
abstract class N7 = NIIx with NBABxy<int, int>;
abstract class N8 extends NIIx with NBABxy<int, int> {}
-abstract class N9 = NIIx with NBABxy<String, int>; //# N9: compile-time error
-abstract class N10 extends NIIx with NBABxy<String, int> {} //# N10: compile-time error
-abstract class N11 = NIIx with NTTy<int>; //# N11: compile-time error
-abstract class N12 extends NIIx with NTTy<int> {} //# N12: compile-time error
-abstract class N13 = NIIx with NTTx<int>; //# N13: compile-time error
-abstract class N14 extends NIIx with NTTx<int> {} //# N14: compile-time error
+abstract class N9 = NIIx with NBABxy<String, int>;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'N9' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'N9' introduces an erroneous override of 'id'.
+// ^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class N10 extends NIIx with NBABxy<String, int> {}
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Applying the mixin 'NBABxy' to 'NIIx' introduces an erroneous override of 'id'.
+// ^
+// [cfe] Class 'NIIx with NBABxy<String, int>' inherits multiple members named 'id' with incompatible signatures.
+// ^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class N11 = NIIx with NTTy<int>;
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'N11' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'N11' introduces an erroneous override of 'id'.
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class N12 extends NIIx with NTTy<int> {}
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Applying the mixin 'NTTy' to 'NIIx' introduces an erroneous override of 'id'.
+// ^
+// [cfe] Class 'NIIx with NTTy<int>' inherits multiple members named 'id' with incompatible signatures.
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class N13 = NIIx with NTTx<int>;
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'N13' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'N13' introduces an erroneous override of 'id'.
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class N14 extends NIIx with NTTx<int> {}
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Applying the mixin 'NTTx' to 'NIIx' introduces an erroneous override of 'id'.
+// ^
+// [cfe] Class 'NIIx with NTTx<int>' inherits multiple members named 'id' with incompatible signatures.
+// ^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
// Optional positional parameters
abstract class OII {
@@ -105,8 +221,16 @@
abstract class O3 = OII with OIIy;
abstract class O4 extends OII with OIIy {}
// It's NOT OK to drop optional parameters.
-abstract class O5 = OII with PII; //# O5: compile-time error
-abstract class O6 extends OII with PII {} //# O6: compile-time error
+abstract class O5 = OII with PII;
+// ^
+// [cfe] The mixin application class 'O5' introduces an erroneous override of 'id'.
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class O6 extends OII with PII {}
+// ^
+// [cfe] Applying the mixin 'PII' to 'OII' introduces an erroneous override of 'id'.
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
class OBAB<A, B> {
B id ([A x, B y]) => y;
@@ -123,12 +247,34 @@
// Same as above but with generic classes.
abstract class O7 = OII with OBAB<int, int>;
abstract class O8 extends OII with OBAB<int, int> {}
-abstract class O9 = OII with OBAB<String, int>; //# O9: compile-time error
-abstract class O10 extends OII with OBAB<String, int> {} //# O10: compile-time error
+abstract class O9 = OII with OBAB<String, int>;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'O9' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'O9' introduces an erroneous override of 'id'.
+// ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class O10 extends OII with OBAB<String, int> {}
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Applying the mixin 'OBAB' to 'OII' introduces an erroneous override of 'id'.
+// ^
+// [cfe] Class 'OII with OBAB<String, int>' inherits multiple members named 'id' with incompatible signatures.
+// ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
abstract class O11 = OII with OTTy<int>;
abstract class O12 extends OII with OTTy<int> {}
-abstract class O13 = OII with PTT<int>; //# O13: compile-time error
-abstract class O14 extends OII with PTT<int> {} //# O14: compile-time error
+abstract class O13 = OII with PTT<int>;
+// ^
+// [cfe] The mixin application class 'O13' introduces an erroneous override of 'id'.
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+abstract class O14 extends OII with PTT<int> {}
+// ^
+// [cfe] Applying the mixin 'PTT' to 'OII' introduces an erroneous override of 'id'.
+// ^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
// More tests with generic classes.
abstract class GTTnum {
@@ -151,9 +297,37 @@
T id<T extends num, R>(x) => x;
}
class G1 = GTTnum with MTTnum;
-class G2 = GTTnum with MTTint; //# G2: compile-time error
-class G3 = GTTnum with MTT; //# G3: compile-time error
-class G4 = GTTnum with MTTnumR; //# G4: compile-time error
-class G5 = GTTnum with CII; //# G5: compile-time error
+class G2 = GTTnum with MTTint;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'G2' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'G2' introduces an erroneous override of 'id'.
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+class G3 = GTTnum with MTT;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'G3' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'G3' introduces an erroneous override of 'id'.
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+class G4 = GTTnum with MTTnumR;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] Class 'G4' inherits multiple members named 'id' with incompatible signatures.
+// ^
+// [cfe] The mixin application class 'G4' introduces an erroneous override of 'id'.
+// ^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
+class G5 = GTTnum with CII;
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_INHERITANCE
+// [cfe] The mixin application class 'G5' introduces an erroneous override of 'id'.
+// ^
+// [cfe] The non-abstract class 'G5' is missing implementations for these members:
+// ^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_OVERRIDE
void main() {}
diff --git a/tests/language_2/mixin_super_bound_runtime_test.dart b/tests/language_2/mixin_super_bound_runtime_test.dart
new file mode 100644
index 0000000..6214978
--- /dev/null
+++ b/tests/language_2/mixin_super_bound_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+class M<U extends V, V> {}
+
+class N<U, V extends U> {}
+
+class S<T> {}
+
+class MNA<U, V extends U, W> extends S<List<U>>
+ with M<V, U>, N<List<W>, List<W>> {}
+
+class MNA2<U, V extends U, W> = S<List<U>> with M<V, U>, N<List<W>, List<W>>;
+
+main() {
+ new MNA<num, int, bool>();
+ new MNA2<num, int, bool>();
+
+ // Type parameter U of M must extend type parameter V, but
+ // type argument num is not a subtype of int.
+
+ // Type parameter U of M must extend type parameter V, but
+ // type argument num is not a subtype of int.
+
+}
diff --git a/tests/language_2/mixin_super_bound_test.dart b/tests/language_2/mixin_super_bound_test.dart
index 588c05b..634c838 100644
--- a/tests/language_2/mixin_super_bound_test.dart
+++ b/tests/language_2/mixin_super_bound_test.dart
@@ -19,8 +19,17 @@
// Type parameter U of M must extend type parameter V, but
// type argument num is not a subtype of int.
- new MNA<int, num, bool>(); //# 01: compile-time error
+ new MNA<int, num, bool>();
+ // ^
+ // [cfe] Type argument 'num' doesn't conform to the bound 'U' of the type variable 'V' on 'MNA'.
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
+
// Type parameter U of M must extend type parameter V, but
// type argument num is not a subtype of int.
- new MNA2<int, num, bool>(); //# 02: compile-time error
+ new MNA2<int, num, bool>();
+ // ^
+ // [cfe] Type argument 'num' doesn't conform to the bound 'U' of the type variable 'V' on 'MNA2'.
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
diff --git a/tests/language_2/mixin_superclass_runtime_test.dart b/tests/language_2/mixin_superclass_runtime_test.dart
new file mode 100644
index 0000000..eeb1b9c
--- /dev/null
+++ b/tests/language_2/mixin_superclass_runtime_test.dart
@@ -0,0 +1,125 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class S0 {}
+
+class S1 extends Object {}
+
+class S2 extends S0 {}
+
+class M0 {}
+
+class M1 extends Object {}
+
+mixin M2 on M0 {}
+
+class C00 = S0 with M0;
+class C01 = S0 with M1;
+
+class C03 = S0 with M0, M1;
+class C04 = S0 with M0, M2;
+
+
+
+
+class C10 = S1 with M0;
+class C11 = S1 with M1;
+
+class C13 = S1 with M0, M1;
+class C14 = S1 with M0, M2;
+
+
+
+
+class C20 = S2 with M0;
+class C21 = S2 with M1;
+
+class C23 = S2 with M0, M1;
+class C24 = S2 with M0, M2;
+
+
+
+
+class D00 extends S0 with M0 {}
+
+class D01 extends S0 with M1 {}
+
+
+
+class D03 extends S0 with M0, M1 {}
+
+class D04 extends S0 with M0, M2 {}
+
+
+
+
+
+
+
+class D10 extends S1 with M0 {}
+
+class D11 extends S1 with M1 {}
+
+
+
+class D13 extends S1 with M0, M1 {}
+
+class D14 extends S1 with M0, M2 {}
+
+
+
+
+
+
+
+class D20 extends S2 with M0 {}
+
+class D21 extends S2 with M1 {}
+
+
+
+class D23 extends S2 with M0, M1 {}
+
+class D24 extends S2 with M0, M2 {}
+
+
+
+
+
+
+
+main() {
+ new C00();
+ new C01();
+ new C03();
+ new C04();
+
+ new C10();
+ new C11();
+ new C13();
+ new C14();
+
+ new C20();
+ new C21();
+ new C23();
+ new C24();
+
+ new D00();
+ new D01();
+ new D03();
+ new D04();
+
+ new D10();
+ new D11();
+ new D13();
+ new D14();
+
+ new D20();
+ new D21();
+ new D23();
+ new D24();
+}
diff --git a/tests/language_2/mixin_superclass_test.dart b/tests/language_2/mixin_superclass_test.dart
index 7e2c6d1..5b9a8ee 100644
--- a/tests/language_2/mixin_superclass_test.dart
+++ b/tests/language_2/mixin_superclass_test.dart
@@ -16,78 +16,174 @@
class C00 = S0 with M0;
class C01 = S0 with M1;
-class C02 = S0 with M2; //# C02: compile-time error
+class C02 = S0 with M2;
+// ^
+// [cfe] 'S0' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class C03 = S0 with M0, M1;
class C04 = S0 with M0, M2;
-class C05 = S0 with M2, M0; //# C05: compile-time error
-class C06 = S0 with M1, M2; //# C06: compile-time error
-class C07 = S0 with M2, M1; //# C07: compile-time error
+class C05 = S0 with M2, M0;
+// ^
+// [cfe] 'S0' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
+class C06 = S0 with M1, M2;
+// ^
+// [cfe] '_C06&S0&M1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
+class C07 = S0 with M2, M1;
+// ^
+// [cfe] 'S0' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class C10 = S1 with M0;
class C11 = S1 with M1;
-class C12 = S1 with M2; //# C12: compile-time error
+class C12 = S1 with M2;
+// ^
+// [cfe] 'S1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class C13 = S1 with M0, M1;
class C14 = S1 with M0, M2;
-class C15 = S1 with M2, M0; //# C15: compile-time error
-class C16 = S1 with M1, M2; //# C16: compile-time error
-class C17 = S1 with M2, M1; //# C17: compile-time error
+class C15 = S1 with M2, M0;
+// ^
+// [cfe] 'S1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
+class C16 = S1 with M1, M2;
+// ^
+// [cfe] '_C16&S1&M1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
+class C17 = S1 with M2, M1;
+// ^
+// [cfe] 'S1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class C20 = S2 with M0;
class C21 = S2 with M1;
-class C22 = S2 with M2; //# C22: compile-time error
+class C22 = S2 with M2;
+// ^
+// [cfe] 'S2' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class C23 = S2 with M0, M1;
class C24 = S2 with M0, M2;
-class C25 = S2 with M2, M0; //# C25: compile-time error
-class C26 = S2 with M1, M2; //# C26: compile-time error
-class C27 = S2 with M2, M1; //# C27: compile-time error
+class C25 = S2 with M2, M0;
+// ^
+// [cfe] 'S2' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
+class C26 = S2 with M1, M2;
+// ^
+// [cfe] '_C26&S2&M1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
+class C27 = S2 with M2, M1;
+// ^
+// [cfe] 'S2' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class D00 extends S0 with M0 {}
class D01 extends S0 with M1 {}
-class D02 extends S0 with M2 {} //# D02: compile-time error
+class D02 extends S0 with M2 {}
+// ^
+// [cfe] 'S0' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class D03 extends S0 with M0, M1 {}
class D04 extends S0 with M0, M2 {}
-class D05 extends S0 with M2, M0 {} //# D05: compile-time error
+class D05 extends S0 with M2, M0 {}
+// ^
+// [cfe] 'S0' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
-class D06 extends S0 with M1, M2 {} //# D06: compile-time error
+class D06 extends S0 with M1, M2 {}
+// ^
+// [cfe] '_D06&S0&M1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
-class D07 extends S0 with M2, M1 {} //# D07: compile-time error
+class D07 extends S0 with M2, M1 {}
+// ^
+// [cfe] 'S0' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class D10 extends S1 with M0 {}
class D11 extends S1 with M1 {}
-class D12 extends S1 with M2 {} //# D12: compile-time error
+class D12 extends S1 with M2 {}
+// ^
+// [cfe] 'S1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class D13 extends S1 with M0, M1 {}
class D14 extends S1 with M0, M2 {}
-class D15 extends S1 with M2, M0 {} //# D15: compile-time error
+class D15 extends S1 with M2, M0 {}
+// ^
+// [cfe] 'S1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
-class D16 extends S1 with M1, M2 {} //# D16: compile-time error
+class D16 extends S1 with M1, M2 {}
+// ^
+// [cfe] '_D16&S1&M1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
-class D17 extends S1 with M2, M1 {} //# D17: compile-time error
+class D17 extends S1 with M2, M1 {}
+// ^
+// [cfe] 'S1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class D20 extends S2 with M0 {}
class D21 extends S2 with M1 {}
-class D22 extends S2 with M2 {} //# D22: compile-time error
+class D22 extends S2 with M2 {}
+// ^
+// [cfe] 'S2' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
class D23 extends S2 with M0, M1 {}
class D24 extends S2 with M0, M2 {}
-class D25 extends S2 with M2, M0 {} //# D25: compile-time error
+class D25 extends S2 with M2, M0 {}
+// ^
+// [cfe] 'S2' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
-class D26 extends S2 with M1, M2 {} //# D26: compile-time error
+class D26 extends S2 with M1, M2 {}
+// ^
+// [cfe] '_D26&S2&M1' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
-class D27 extends S2 with M2, M1 {} //# D27: compile-time error
+class D27 extends S2 with M2, M1 {}
+// ^
+// [cfe] 'S2' doesn't implement 'M0' so it can't be used with 'M2'.
+// ^^
+// [analyzer] COMPILE_TIME_ERROR.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE
main() {
new C00();
diff --git a/tests/language_2/mixin_type_parameters_errors_runtime_test.dart b/tests/language_2/mixin_type_parameters_errors_runtime_test.dart
new file mode 100644
index 0000000..ee3b7ca
--- /dev/null
+++ b/tests/language_2/mixin_type_parameters_errors_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class S<T> {}
+
+class M<U> {}
+
+class A<X> extends S<int> with M<double> {}
+
+
+
+class F<X> = S<X> with M<X>;
+
+
+main() {
+ var a;
+ a = new A();
+ a = new A<int>();
+
+ a = new F<int>();
+
+}
diff --git a/tests/language_2/mixin_type_parameters_errors_test.dart b/tests/language_2/mixin_type_parameters_errors_test.dart
index 7501cdc..d978db7 100644
--- a/tests/language_2/mixin_type_parameters_errors_test.dart
+++ b/tests/language_2/mixin_type_parameters_errors_test.dart
@@ -7,17 +7,36 @@
class M<U> {}
class A<X> extends S<int> with M<double> {}
-class B<U, V> extends S with M<U, V> { } // //# 01: compile-time error
-class C<A, B> extends S<A, int> with M { } // //# 02: compile-time error
+class B<U, V> extends S with M<U, V> { }
+// ^
+// [cfe] The type 'M<U, V>' can't be mixed in.
+// ^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 1 type arguments.
+class C<A, B> extends S<A, int> with M { }
+// ^^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 1 type arguments.
class F<X> = S<X> with M<X>;
-class G = S<int> with M<double, double>; // //# 05: compile-time error
+class G = S<int> with M<double, double>;
+// ^
+// [cfe] The type 'M<double, double>' can't be mixed in.
+// ^^^^^^^^^^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 1 type arguments.
main() {
var a;
a = new A();
a = new A<int>();
- a = new A<String, String>(); // //# 03: compile-time error
+ a = new A<String, String>();
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_INVALID_TYPE_PARAMETERS
+ // [cfe] Expected 1 type arguments.
a = new F<int>();
- a = new F<int, String>(); // //# 04: compile-time error
+ a = new F<int, String>();
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_INVALID_TYPE_PARAMETERS
+ // [cfe] Expected 1 type arguments.
}
diff --git a/tests/language_2/multiline_newline_runtime_1_test.dart b/tests/language_2/multiline_newline_runtime_1_test.dart
new file mode 100644
index 0000000..65c906d
--- /dev/null
+++ b/tests/language_2/multiline_newline_runtime_1_test.dart
@@ -0,0 +1,128 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+import 'multiline_newline_cr.dart' as cr;
+import 'multiline_newline_crlf.dart' as crlf;
+import 'multiline_newline_lf.dart' as lf;
+
+main() {
+ Expect.equals(4, cr.constantMultilineString.length);
+ Expect.equals(4, crlf.constantMultilineString.length);
+ Expect.equals(4, lf.constantMultilineString.length);
+
+ Expect.equals(6, cr.constantRawMultilineString.length);
+ Expect.equals(6, crlf.constantRawMultilineString.length);
+ Expect.equals(6, lf.constantRawMultilineString.length);
+
+ Expect.equals(cr.constantMultilineString, crlf.constantMultilineString);
+ Expect.equals(crlf.constantMultilineString, lf.constantMultilineString);
+ Expect.equals(lf.constantMultilineString, cr.constantMultilineString);
+
+ Expect.equals(cr.constantRawMultilineString, crlf.constantRawMultilineString);
+ Expect.equals(crlf.constantRawMultilineString, lf.constantRawMultilineString);
+ Expect.equals(lf.constantRawMultilineString, cr.constantRawMultilineString);
+
+ Expect.equals(4, cr.nonConstantMultilineString.length);
+ Expect.equals(4, crlf.nonConstantMultilineString.length);
+ Expect.equals(4, lf.nonConstantMultilineString.length);
+
+ Expect.equals(6, cr.nonConstantRawMultilineString.length);
+ Expect.equals(6, crlf.nonConstantRawMultilineString.length);
+ Expect.equals(6, lf.nonConstantRawMultilineString.length);
+
+ Expect.equals(cr.nonConstantMultilineString, crlf.nonConstantMultilineString);
+ Expect.equals(crlf.nonConstantMultilineString, lf.nonConstantMultilineString);
+ Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
+
+ Expect.equals(
+ cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
+ Expect.equals(
+ crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
+ Expect.equals(
+ lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
+
+ const c1 =
+ cr.constantMultilineString == crlf.constantMultilineString ? true : null;
+ const c2 =
+ crlf.constantMultilineString == lf.constantMultilineString ? true : null;
+ const c3 =
+ lf.constantMultilineString == cr.constantMultilineString ? true : null;
+ Expect.isTrue(c1);
+ Expect.isTrue(c2);
+ Expect.isTrue(c3);
+
+ const c1r = cr.constantRawMultilineString == crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c2r = crlf.constantRawMultilineString == lf.constantRawMultilineString
+ ? true
+ : null;
+ const c3r = lf.constantRawMultilineString == cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isTrue(c1r);
+ Expect.isTrue(c2r);
+ Expect.isTrue(c3r);
+
+ const c4 = c1 ? 1 : 2;
+ Expect.equals(1, c4);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ const c7 =
+ cr.constantMultilineString != crlf.constantMultilineString ? true : null;
+ const c8 =
+ crlf.constantMultilineString != lf.constantMultilineString ? true : null;
+ const c9 =
+ lf.constantMultilineString != cr.constantMultilineString ? true : null;
+ Expect.isNull(c7);
+ Expect.isNull(c8);
+ Expect.isNull(c9);
+
+ const c7r = cr.constantRawMultilineString != crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c8r = crlf.constantRawMultilineString != lf.constantRawMultilineString
+ ? true
+ : null;
+ const c9r = lf.constantRawMultilineString != cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isNull(c7r);
+ Expect.isNull(c8r);
+ Expect.isNull(c9r);
+
+ // What's the deal with the compile-time errors below? This is to validate
+ // that constants are evaluated correctly at compile-time (or analysis
+ // time). For example, only if [c7] is evaluated correctly does it become
+ // null which leads to a compile-time error (as it isn't a boolean). For
+ // tools like dart2js, this ensures that the compile-time evaluation of
+ // constants is similar to the runtime evaluation tested above. For tools
+ // like the analyzer, this ensures that evaluation is tested (there's no
+ // runtime evaluation).
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/multiline_newline_runtime_2_test.dart b/tests/language_2/multiline_newline_runtime_2_test.dart
new file mode 100644
index 0000000..1c39d93
--- /dev/null
+++ b/tests/language_2/multiline_newline_runtime_2_test.dart
@@ -0,0 +1,128 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+import 'multiline_newline_cr.dart' as cr;
+import 'multiline_newline_crlf.dart' as crlf;
+import 'multiline_newline_lf.dart' as lf;
+
+main() {
+ Expect.equals(4, cr.constantMultilineString.length);
+ Expect.equals(4, crlf.constantMultilineString.length);
+ Expect.equals(4, lf.constantMultilineString.length);
+
+ Expect.equals(6, cr.constantRawMultilineString.length);
+ Expect.equals(6, crlf.constantRawMultilineString.length);
+ Expect.equals(6, lf.constantRawMultilineString.length);
+
+ Expect.equals(cr.constantMultilineString, crlf.constantMultilineString);
+ Expect.equals(crlf.constantMultilineString, lf.constantMultilineString);
+ Expect.equals(lf.constantMultilineString, cr.constantMultilineString);
+
+ Expect.equals(cr.constantRawMultilineString, crlf.constantRawMultilineString);
+ Expect.equals(crlf.constantRawMultilineString, lf.constantRawMultilineString);
+ Expect.equals(lf.constantRawMultilineString, cr.constantRawMultilineString);
+
+ Expect.equals(4, cr.nonConstantMultilineString.length);
+ Expect.equals(4, crlf.nonConstantMultilineString.length);
+ Expect.equals(4, lf.nonConstantMultilineString.length);
+
+ Expect.equals(6, cr.nonConstantRawMultilineString.length);
+ Expect.equals(6, crlf.nonConstantRawMultilineString.length);
+ Expect.equals(6, lf.nonConstantRawMultilineString.length);
+
+ Expect.equals(cr.nonConstantMultilineString, crlf.nonConstantMultilineString);
+ Expect.equals(crlf.nonConstantMultilineString, lf.nonConstantMultilineString);
+ Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
+
+ Expect.equals(
+ cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
+ Expect.equals(
+ crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
+ Expect.equals(
+ lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
+
+ const c1 =
+ cr.constantMultilineString == crlf.constantMultilineString ? true : null;
+ const c2 =
+ crlf.constantMultilineString == lf.constantMultilineString ? true : null;
+ const c3 =
+ lf.constantMultilineString == cr.constantMultilineString ? true : null;
+ Expect.isTrue(c1);
+ Expect.isTrue(c2);
+ Expect.isTrue(c3);
+
+ const c1r = cr.constantRawMultilineString == crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c2r = crlf.constantRawMultilineString == lf.constantRawMultilineString
+ ? true
+ : null;
+ const c3r = lf.constantRawMultilineString == cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isTrue(c1r);
+ Expect.isTrue(c2r);
+ Expect.isTrue(c3r);
+
+
+
+
+ const c5 = c2 ? 2 : 3;
+ Expect.equals(2, c5);
+
+
+
+
+
+
+
+
+
+
+
+
+
+ const c7 =
+ cr.constantMultilineString != crlf.constantMultilineString ? true : null;
+ const c8 =
+ crlf.constantMultilineString != lf.constantMultilineString ? true : null;
+ const c9 =
+ lf.constantMultilineString != cr.constantMultilineString ? true : null;
+ Expect.isNull(c7);
+ Expect.isNull(c8);
+ Expect.isNull(c9);
+
+ const c7r = cr.constantRawMultilineString != crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c8r = crlf.constantRawMultilineString != lf.constantRawMultilineString
+ ? true
+ : null;
+ const c9r = lf.constantRawMultilineString != cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isNull(c7r);
+ Expect.isNull(c8r);
+ Expect.isNull(c9r);
+
+ // What's the deal with the compile-time errors below? This is to validate
+ // that constants are evaluated correctly at compile-time (or analysis
+ // time). For example, only if [c7] is evaluated correctly does it become
+ // null which leads to a compile-time error (as it isn't a boolean). For
+ // tools like dart2js, this ensures that the compile-time evaluation of
+ // constants is similar to the runtime evaluation tested above. For tools
+ // like the analyzer, this ensures that evaluation is tested (there's no
+ // runtime evaluation).
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/multiline_newline_runtime_3_test.dart b/tests/language_2/multiline_newline_runtime_3_test.dart
new file mode 100644
index 0000000..df02923
--- /dev/null
+++ b/tests/language_2/multiline_newline_runtime_3_test.dart
@@ -0,0 +1,128 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+import 'multiline_newline_cr.dart' as cr;
+import 'multiline_newline_crlf.dart' as crlf;
+import 'multiline_newline_lf.dart' as lf;
+
+main() {
+ Expect.equals(4, cr.constantMultilineString.length);
+ Expect.equals(4, crlf.constantMultilineString.length);
+ Expect.equals(4, lf.constantMultilineString.length);
+
+ Expect.equals(6, cr.constantRawMultilineString.length);
+ Expect.equals(6, crlf.constantRawMultilineString.length);
+ Expect.equals(6, lf.constantRawMultilineString.length);
+
+ Expect.equals(cr.constantMultilineString, crlf.constantMultilineString);
+ Expect.equals(crlf.constantMultilineString, lf.constantMultilineString);
+ Expect.equals(lf.constantMultilineString, cr.constantMultilineString);
+
+ Expect.equals(cr.constantRawMultilineString, crlf.constantRawMultilineString);
+ Expect.equals(crlf.constantRawMultilineString, lf.constantRawMultilineString);
+ Expect.equals(lf.constantRawMultilineString, cr.constantRawMultilineString);
+
+ Expect.equals(4, cr.nonConstantMultilineString.length);
+ Expect.equals(4, crlf.nonConstantMultilineString.length);
+ Expect.equals(4, lf.nonConstantMultilineString.length);
+
+ Expect.equals(6, cr.nonConstantRawMultilineString.length);
+ Expect.equals(6, crlf.nonConstantRawMultilineString.length);
+ Expect.equals(6, lf.nonConstantRawMultilineString.length);
+
+ Expect.equals(cr.nonConstantMultilineString, crlf.nonConstantMultilineString);
+ Expect.equals(crlf.nonConstantMultilineString, lf.nonConstantMultilineString);
+ Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
+
+ Expect.equals(
+ cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
+ Expect.equals(
+ crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
+ Expect.equals(
+ lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
+
+ const c1 =
+ cr.constantMultilineString == crlf.constantMultilineString ? true : null;
+ const c2 =
+ crlf.constantMultilineString == lf.constantMultilineString ? true : null;
+ const c3 =
+ lf.constantMultilineString == cr.constantMultilineString ? true : null;
+ Expect.isTrue(c1);
+ Expect.isTrue(c2);
+ Expect.isTrue(c3);
+
+ const c1r = cr.constantRawMultilineString == crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c2r = crlf.constantRawMultilineString == lf.constantRawMultilineString
+ ? true
+ : null;
+ const c3r = lf.constantRawMultilineString == cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isTrue(c1r);
+ Expect.isTrue(c2r);
+ Expect.isTrue(c3r);
+
+
+
+
+
+
+
+ const c6 = c3 ? 3 : 4;
+ Expect.equals(3, c6);
+
+
+
+
+
+
+
+
+
+
+ const c7 =
+ cr.constantMultilineString != crlf.constantMultilineString ? true : null;
+ const c8 =
+ crlf.constantMultilineString != lf.constantMultilineString ? true : null;
+ const c9 =
+ lf.constantMultilineString != cr.constantMultilineString ? true : null;
+ Expect.isNull(c7);
+ Expect.isNull(c8);
+ Expect.isNull(c9);
+
+ const c7r = cr.constantRawMultilineString != crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c8r = crlf.constantRawMultilineString != lf.constantRawMultilineString
+ ? true
+ : null;
+ const c9r = lf.constantRawMultilineString != cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isNull(c7r);
+ Expect.isNull(c8r);
+ Expect.isNull(c9r);
+
+ // What's the deal with the compile-time errors below? This is to validate
+ // that constants are evaluated correctly at compile-time (or analysis
+ // time). For example, only if [c7] is evaluated correctly does it become
+ // null which leads to a compile-time error (as it isn't a boolean). For
+ // tools like dart2js, this ensures that the compile-time evaluation of
+ // constants is similar to the runtime evaluation tested above. For tools
+ // like the analyzer, this ensures that evaluation is tested (there's no
+ // runtime evaluation).
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/multiline_newline_runtime_4_test.dart b/tests/language_2/multiline_newline_runtime_4_test.dart
new file mode 100644
index 0000000..89503e4
--- /dev/null
+++ b/tests/language_2/multiline_newline_runtime_4_test.dart
@@ -0,0 +1,128 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+import 'multiline_newline_cr.dart' as cr;
+import 'multiline_newline_crlf.dart' as crlf;
+import 'multiline_newline_lf.dart' as lf;
+
+main() {
+ Expect.equals(4, cr.constantMultilineString.length);
+ Expect.equals(4, crlf.constantMultilineString.length);
+ Expect.equals(4, lf.constantMultilineString.length);
+
+ Expect.equals(6, cr.constantRawMultilineString.length);
+ Expect.equals(6, crlf.constantRawMultilineString.length);
+ Expect.equals(6, lf.constantRawMultilineString.length);
+
+ Expect.equals(cr.constantMultilineString, crlf.constantMultilineString);
+ Expect.equals(crlf.constantMultilineString, lf.constantMultilineString);
+ Expect.equals(lf.constantMultilineString, cr.constantMultilineString);
+
+ Expect.equals(cr.constantRawMultilineString, crlf.constantRawMultilineString);
+ Expect.equals(crlf.constantRawMultilineString, lf.constantRawMultilineString);
+ Expect.equals(lf.constantRawMultilineString, cr.constantRawMultilineString);
+
+ Expect.equals(4, cr.nonConstantMultilineString.length);
+ Expect.equals(4, crlf.nonConstantMultilineString.length);
+ Expect.equals(4, lf.nonConstantMultilineString.length);
+
+ Expect.equals(6, cr.nonConstantRawMultilineString.length);
+ Expect.equals(6, crlf.nonConstantRawMultilineString.length);
+ Expect.equals(6, lf.nonConstantRawMultilineString.length);
+
+ Expect.equals(cr.nonConstantMultilineString, crlf.nonConstantMultilineString);
+ Expect.equals(crlf.nonConstantMultilineString, lf.nonConstantMultilineString);
+ Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
+
+ Expect.equals(
+ cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
+ Expect.equals(
+ crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
+ Expect.equals(
+ lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
+
+ const c1 =
+ cr.constantMultilineString == crlf.constantMultilineString ? true : null;
+ const c2 =
+ crlf.constantMultilineString == lf.constantMultilineString ? true : null;
+ const c3 =
+ lf.constantMultilineString == cr.constantMultilineString ? true : null;
+ Expect.isTrue(c1);
+ Expect.isTrue(c2);
+ Expect.isTrue(c3);
+
+ const c1r = cr.constantRawMultilineString == crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c2r = crlf.constantRawMultilineString == lf.constantRawMultilineString
+ ? true
+ : null;
+ const c3r = lf.constantRawMultilineString == cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isTrue(c1r);
+ Expect.isTrue(c2r);
+ Expect.isTrue(c3r);
+
+
+
+
+
+
+
+
+
+
+ const c4r = c1r ? 1 : 2;
+ Expect.equals(1, c4r);
+
+
+
+
+
+
+
+ const c7 =
+ cr.constantMultilineString != crlf.constantMultilineString ? true : null;
+ const c8 =
+ crlf.constantMultilineString != lf.constantMultilineString ? true : null;
+ const c9 =
+ lf.constantMultilineString != cr.constantMultilineString ? true : null;
+ Expect.isNull(c7);
+ Expect.isNull(c8);
+ Expect.isNull(c9);
+
+ const c7r = cr.constantRawMultilineString != crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c8r = crlf.constantRawMultilineString != lf.constantRawMultilineString
+ ? true
+ : null;
+ const c9r = lf.constantRawMultilineString != cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isNull(c7r);
+ Expect.isNull(c8r);
+ Expect.isNull(c9r);
+
+ // What's the deal with the compile-time errors below? This is to validate
+ // that constants are evaluated correctly at compile-time (or analysis
+ // time). For example, only if [c7] is evaluated correctly does it become
+ // null which leads to a compile-time error (as it isn't a boolean). For
+ // tools like dart2js, this ensures that the compile-time evaluation of
+ // constants is similar to the runtime evaluation tested above. For tools
+ // like the analyzer, this ensures that evaluation is tested (there's no
+ // runtime evaluation).
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/multiline_newline_runtime_5_test.dart b/tests/language_2/multiline_newline_runtime_5_test.dart
new file mode 100644
index 0000000..450e6b3
--- /dev/null
+++ b/tests/language_2/multiline_newline_runtime_5_test.dart
@@ -0,0 +1,128 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+import 'multiline_newline_cr.dart' as cr;
+import 'multiline_newline_crlf.dart' as crlf;
+import 'multiline_newline_lf.dart' as lf;
+
+main() {
+ Expect.equals(4, cr.constantMultilineString.length);
+ Expect.equals(4, crlf.constantMultilineString.length);
+ Expect.equals(4, lf.constantMultilineString.length);
+
+ Expect.equals(6, cr.constantRawMultilineString.length);
+ Expect.equals(6, crlf.constantRawMultilineString.length);
+ Expect.equals(6, lf.constantRawMultilineString.length);
+
+ Expect.equals(cr.constantMultilineString, crlf.constantMultilineString);
+ Expect.equals(crlf.constantMultilineString, lf.constantMultilineString);
+ Expect.equals(lf.constantMultilineString, cr.constantMultilineString);
+
+ Expect.equals(cr.constantRawMultilineString, crlf.constantRawMultilineString);
+ Expect.equals(crlf.constantRawMultilineString, lf.constantRawMultilineString);
+ Expect.equals(lf.constantRawMultilineString, cr.constantRawMultilineString);
+
+ Expect.equals(4, cr.nonConstantMultilineString.length);
+ Expect.equals(4, crlf.nonConstantMultilineString.length);
+ Expect.equals(4, lf.nonConstantMultilineString.length);
+
+ Expect.equals(6, cr.nonConstantRawMultilineString.length);
+ Expect.equals(6, crlf.nonConstantRawMultilineString.length);
+ Expect.equals(6, lf.nonConstantRawMultilineString.length);
+
+ Expect.equals(cr.nonConstantMultilineString, crlf.nonConstantMultilineString);
+ Expect.equals(crlf.nonConstantMultilineString, lf.nonConstantMultilineString);
+ Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
+
+ Expect.equals(
+ cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
+ Expect.equals(
+ crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
+ Expect.equals(
+ lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
+
+ const c1 =
+ cr.constantMultilineString == crlf.constantMultilineString ? true : null;
+ const c2 =
+ crlf.constantMultilineString == lf.constantMultilineString ? true : null;
+ const c3 =
+ lf.constantMultilineString == cr.constantMultilineString ? true : null;
+ Expect.isTrue(c1);
+ Expect.isTrue(c2);
+ Expect.isTrue(c3);
+
+ const c1r = cr.constantRawMultilineString == crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c2r = crlf.constantRawMultilineString == lf.constantRawMultilineString
+ ? true
+ : null;
+ const c3r = lf.constantRawMultilineString == cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isTrue(c1r);
+ Expect.isTrue(c2r);
+ Expect.isTrue(c3r);
+
+
+
+
+
+
+
+
+
+
+
+
+
+ const c5r = c2r ? 2 : 3;
+ Expect.equals(2, c5r);
+
+
+
+
+ const c7 =
+ cr.constantMultilineString != crlf.constantMultilineString ? true : null;
+ const c8 =
+ crlf.constantMultilineString != lf.constantMultilineString ? true : null;
+ const c9 =
+ lf.constantMultilineString != cr.constantMultilineString ? true : null;
+ Expect.isNull(c7);
+ Expect.isNull(c8);
+ Expect.isNull(c9);
+
+ const c7r = cr.constantRawMultilineString != crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c8r = crlf.constantRawMultilineString != lf.constantRawMultilineString
+ ? true
+ : null;
+ const c9r = lf.constantRawMultilineString != cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isNull(c7r);
+ Expect.isNull(c8r);
+ Expect.isNull(c9r);
+
+ // What's the deal with the compile-time errors below? This is to validate
+ // that constants are evaluated correctly at compile-time (or analysis
+ // time). For example, only if [c7] is evaluated correctly does it become
+ // null which leads to a compile-time error (as it isn't a boolean). For
+ // tools like dart2js, this ensures that the compile-time evaluation of
+ // constants is similar to the runtime evaluation tested above. For tools
+ // like the analyzer, this ensures that evaluation is tested (there's no
+ // runtime evaluation).
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/multiline_newline_runtime_6_test.dart b/tests/language_2/multiline_newline_runtime_6_test.dart
new file mode 100644
index 0000000..4dbe7bd
--- /dev/null
+++ b/tests/language_2/multiline_newline_runtime_6_test.dart
@@ -0,0 +1,128 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+import 'multiline_newline_cr.dart' as cr;
+import 'multiline_newline_crlf.dart' as crlf;
+import 'multiline_newline_lf.dart' as lf;
+
+main() {
+ Expect.equals(4, cr.constantMultilineString.length);
+ Expect.equals(4, crlf.constantMultilineString.length);
+ Expect.equals(4, lf.constantMultilineString.length);
+
+ Expect.equals(6, cr.constantRawMultilineString.length);
+ Expect.equals(6, crlf.constantRawMultilineString.length);
+ Expect.equals(6, lf.constantRawMultilineString.length);
+
+ Expect.equals(cr.constantMultilineString, crlf.constantMultilineString);
+ Expect.equals(crlf.constantMultilineString, lf.constantMultilineString);
+ Expect.equals(lf.constantMultilineString, cr.constantMultilineString);
+
+ Expect.equals(cr.constantRawMultilineString, crlf.constantRawMultilineString);
+ Expect.equals(crlf.constantRawMultilineString, lf.constantRawMultilineString);
+ Expect.equals(lf.constantRawMultilineString, cr.constantRawMultilineString);
+
+ Expect.equals(4, cr.nonConstantMultilineString.length);
+ Expect.equals(4, crlf.nonConstantMultilineString.length);
+ Expect.equals(4, lf.nonConstantMultilineString.length);
+
+ Expect.equals(6, cr.nonConstantRawMultilineString.length);
+ Expect.equals(6, crlf.nonConstantRawMultilineString.length);
+ Expect.equals(6, lf.nonConstantRawMultilineString.length);
+
+ Expect.equals(cr.nonConstantMultilineString, crlf.nonConstantMultilineString);
+ Expect.equals(crlf.nonConstantMultilineString, lf.nonConstantMultilineString);
+ Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
+
+ Expect.equals(
+ cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
+ Expect.equals(
+ crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
+ Expect.equals(
+ lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
+
+ const c1 =
+ cr.constantMultilineString == crlf.constantMultilineString ? true : null;
+ const c2 =
+ crlf.constantMultilineString == lf.constantMultilineString ? true : null;
+ const c3 =
+ lf.constantMultilineString == cr.constantMultilineString ? true : null;
+ Expect.isTrue(c1);
+ Expect.isTrue(c2);
+ Expect.isTrue(c3);
+
+ const c1r = cr.constantRawMultilineString == crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c2r = crlf.constantRawMultilineString == lf.constantRawMultilineString
+ ? true
+ : null;
+ const c3r = lf.constantRawMultilineString == cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isTrue(c1r);
+ Expect.isTrue(c2r);
+ Expect.isTrue(c3r);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ const c6r = c3r ? 3 : 4;
+ Expect.equals(3, c6r);
+
+ const c7 =
+ cr.constantMultilineString != crlf.constantMultilineString ? true : null;
+ const c8 =
+ crlf.constantMultilineString != lf.constantMultilineString ? true : null;
+ const c9 =
+ lf.constantMultilineString != cr.constantMultilineString ? true : null;
+ Expect.isNull(c7);
+ Expect.isNull(c8);
+ Expect.isNull(c9);
+
+ const c7r = cr.constantRawMultilineString != crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c8r = crlf.constantRawMultilineString != lf.constantRawMultilineString
+ ? true
+ : null;
+ const c9r = lf.constantRawMultilineString != cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isNull(c7r);
+ Expect.isNull(c8r);
+ Expect.isNull(c9r);
+
+ // What's the deal with the compile-time errors below? This is to validate
+ // that constants are evaluated correctly at compile-time (or analysis
+ // time). For example, only if [c7] is evaluated correctly does it become
+ // null which leads to a compile-time error (as it isn't a boolean). For
+ // tools like dart2js, this ensures that the compile-time evaluation of
+ // constants is similar to the runtime evaluation tested above. For tools
+ // like the analyzer, this ensures that evaluation is tested (there's no
+ // runtime evaluation).
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/multiline_newline_runtime_test.dart b/tests/language_2/multiline_newline_runtime_test.dart
new file mode 100644
index 0000000..7fa95ca
--- /dev/null
+++ b/tests/language_2/multiline_newline_runtime_test.dart
@@ -0,0 +1,128 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+import 'multiline_newline_cr.dart' as cr;
+import 'multiline_newline_crlf.dart' as crlf;
+import 'multiline_newline_lf.dart' as lf;
+
+main() {
+ Expect.equals(4, cr.constantMultilineString.length);
+ Expect.equals(4, crlf.constantMultilineString.length);
+ Expect.equals(4, lf.constantMultilineString.length);
+
+ Expect.equals(6, cr.constantRawMultilineString.length);
+ Expect.equals(6, crlf.constantRawMultilineString.length);
+ Expect.equals(6, lf.constantRawMultilineString.length);
+
+ Expect.equals(cr.constantMultilineString, crlf.constantMultilineString);
+ Expect.equals(crlf.constantMultilineString, lf.constantMultilineString);
+ Expect.equals(lf.constantMultilineString, cr.constantMultilineString);
+
+ Expect.equals(cr.constantRawMultilineString, crlf.constantRawMultilineString);
+ Expect.equals(crlf.constantRawMultilineString, lf.constantRawMultilineString);
+ Expect.equals(lf.constantRawMultilineString, cr.constantRawMultilineString);
+
+ Expect.equals(4, cr.nonConstantMultilineString.length);
+ Expect.equals(4, crlf.nonConstantMultilineString.length);
+ Expect.equals(4, lf.nonConstantMultilineString.length);
+
+ Expect.equals(6, cr.nonConstantRawMultilineString.length);
+ Expect.equals(6, crlf.nonConstantRawMultilineString.length);
+ Expect.equals(6, lf.nonConstantRawMultilineString.length);
+
+ Expect.equals(cr.nonConstantMultilineString, crlf.nonConstantMultilineString);
+ Expect.equals(crlf.nonConstantMultilineString, lf.nonConstantMultilineString);
+ Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
+
+ Expect.equals(
+ cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
+ Expect.equals(
+ crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
+ Expect.equals(
+ lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
+
+ const c1 =
+ cr.constantMultilineString == crlf.constantMultilineString ? true : null;
+ const c2 =
+ crlf.constantMultilineString == lf.constantMultilineString ? true : null;
+ const c3 =
+ lf.constantMultilineString == cr.constantMultilineString ? true : null;
+ Expect.isTrue(c1);
+ Expect.isTrue(c2);
+ Expect.isTrue(c3);
+
+ const c1r = cr.constantRawMultilineString == crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c2r = crlf.constantRawMultilineString == lf.constantRawMultilineString
+ ? true
+ : null;
+ const c3r = lf.constantRawMultilineString == cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isTrue(c1r);
+ Expect.isTrue(c2r);
+ Expect.isTrue(c3r);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ const c7 =
+ cr.constantMultilineString != crlf.constantMultilineString ? true : null;
+ const c8 =
+ crlf.constantMultilineString != lf.constantMultilineString ? true : null;
+ const c9 =
+ lf.constantMultilineString != cr.constantMultilineString ? true : null;
+ Expect.isNull(c7);
+ Expect.isNull(c8);
+ Expect.isNull(c9);
+
+ const c7r = cr.constantRawMultilineString != crlf.constantRawMultilineString
+ ? true
+ : null;
+ const c8r = crlf.constantRawMultilineString != lf.constantRawMultilineString
+ ? true
+ : null;
+ const c9r = lf.constantRawMultilineString != cr.constantRawMultilineString
+ ? true
+ : null;
+ Expect.isNull(c7r);
+ Expect.isNull(c8r);
+ Expect.isNull(c9r);
+
+ // What's the deal with the compile-time errors below? This is to validate
+ // that constants are evaluated correctly at compile-time (or analysis
+ // time). For example, only if [c7] is evaluated correctly does it become
+ // null which leads to a compile-time error (as it isn't a boolean). For
+ // tools like dart2js, this ensures that the compile-time evaluation of
+ // constants is similar to the runtime evaluation tested above. For tools
+ // like the analyzer, this ensures that evaluation is tested (there's no
+ // runtime evaluation).
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/multiline_newline_test.dart b/tests/language_2/multiline_newline_test.dart
index 995c28e..0498d0b 100644
--- a/tests/language_2/multiline_newline_test.dart
+++ b/tests/language_2/multiline_newline_test.dart
@@ -66,23 +66,23 @@
Expect.isTrue(c2r);
Expect.isTrue(c3r);
- const c4 = c1 ? 1 : 2; //# 01: ok
- Expect.equals(1, c4); //# 01: continued
+ const c4 = c1 ? 1 : 2;
+ Expect.equals(1, c4);
- const c5 = c2 ? 2 : 3; //# 02: ok
- Expect.equals(2, c5); //# 02: continued
+ const c5 = c2 ? 2 : 3;
+ Expect.equals(2, c5);
- const c6 = c3 ? 3 : 4; //# 03: ok
- Expect.equals(3, c6); //# 03: continued
+ const c6 = c3 ? 3 : 4;
+ Expect.equals(3, c6);
- const c4r = c1r ? 1 : 2; //# 01r: ok
- Expect.equals(1, c4r); //# 01r: continued
+ const c4r = c1r ? 1 : 2;
+ Expect.equals(1, c4r);
- const c5r = c2r ? 2 : 3; //# 02r: ok
- Expect.equals(2, c5r); //# 02r: continued
+ const c5r = c2r ? 2 : 3;
+ Expect.equals(2, c5r);
- const c6r = c3r ? 3 : 4; //# 03r: ok
- Expect.equals(3, c6r); //# 03r: continued
+ const c6r = c3r ? 3 : 4;
+ Expect.equals(3, c6r);
const c7 =
cr.constantMultilineString != crlf.constantMultilineString ? true : null;
@@ -115,11 +115,35 @@
// constants is similar to the runtime evaluation tested above. For tools
// like the analyzer, this ensures that evaluation is tested (there's no
// runtime evaluation).
- const c10 = c7 ? 1 : 2; //# 04: compile-time error
- const c11 = c8 ? 2 : 3; //# 05: compile-time error
- const c12 = c9 ? 3 : 4; //# 06: compile-time error
+ const c10 = c7 ? 1 : 2;
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
+ // ^
+ // [cfe] Constant evaluation error:
+ const c11 = c8 ? 2 : 3;
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
+ // ^
+ // [cfe] Constant evaluation error:
+ const c12 = c9 ? 3 : 4;
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
+ // ^
+ // [cfe] Constant evaluation error:
- const c10r = c7r ? 1 : 2; //# 04r: compile-time error
- const c11r = c8r ? 2 : 3; //# 05r: compile-time error
- const c12r = c9r ? 3 : 4; //# 06r: compile-time error
+ const c10r = c7r ? 1 : 2;
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
+ // ^
+ // [cfe] Constant evaluation error:
+ const c11r = c8r ? 2 : 3;
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
+ // ^
+ // [cfe] Constant evaluation error:
+ const c12r = c9r ? 3 : 4;
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
+ // ^
+ // [cfe] Constant evaluation error:
}
diff --git a/tests/language_2/named_constructor_runtime_test.dart b/tests/language_2/named_constructor_runtime_test.dart
new file mode 100644
index 0000000..ad25d4c
--- /dev/null
+++ b/tests/language_2/named_constructor_runtime_test.dart
@@ -0,0 +1,52 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+library named_constructor_test;
+
+import 'package:expect/expect.dart';
+import 'named_constructor_lib.dart' as prefix;
+
+class Class<T> {
+ final int value;
+ Class() : value = 0;
+ Class.named() : value = 1;
+}
+
+void main() {
+ Expect.equals(0, new Class().value);
+ Expect.equals(0, new Class<int>().value);
+
+ Expect.equals(1, new Class.named().value);
+ Expect.equals(1, new Class<int>.named().value);
+ // 'Class.named' is not a type:
+
+ // 'Class<int>.named<int>' doesn't fit the grammar syntax T.id:
+
+
+ new prefix.Class().value;
+ // 'prefix' is not a type:
+
+ new prefix.Class<int>().value;
+ // 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id:
+
+
+ new prefix.Class.named().value;
+ // 'prefix<int>.Class.named' doesn't fit the grammar syntax T.id:
+
+ // 'prefix.Class<int>.named' doesn't fit the grammar syntax T.id:
+ new prefix.Class<int>.named().value;
+ // 'prefix.Class.named<int>' doesn't fit the grammar syntax T.id:
+
+ // 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id:
+
+ // 'prefix<int>.Class.named<int>' doesn't fit the grammar syntax T.id:
+
+ // 'prefix.Class<int>.named<int>' doesn't fit the grammar syntax T.id:
+
+ // 'prefix<int>.Class<int>.named<int>' doesn't fit the grammar syntax T.id:
+
+}
diff --git a/tests/language_2/named_constructor_test.dart b/tests/language_2/named_constructor_test.dart
index 0faf69b..92f91e4 100644
--- a/tests/language_2/named_constructor_test.dart
+++ b/tests/language_2/named_constructor_test.dart
@@ -20,30 +20,85 @@
Expect.equals(1, new Class.named().value);
Expect.equals(1, new Class<int>.named().value);
// 'Class.named' is not a type:
- new Class.named<int>().value; //# 01: compile-time error
+ new Class.named<int>().value;
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+
// 'Class<int>.named<int>' doesn't fit the grammar syntax T.id:
- new Class<int>.named<int>().value; //# 02: syntax error
+ new Class<int>.named<int>().value;
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
new prefix.Class().value;
// 'prefix' is not a type:
- new prefix<int>.Class().value; //# 03: compile-time error
+ new prefix<int>.Class().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
new prefix.Class<int>().value;
// 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id:
- new prefix<int>.Class<int>().value; //# 04: syntax error
+ new prefix<int>.Class<int>().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
new prefix.Class.named().value;
// 'prefix<int>.Class.named' doesn't fit the grammar syntax T.id:
- new prefix<int>.Class.named().value; //# 05: syntax error
+ new prefix<int>.Class.named().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
+
+
// 'prefix.Class<int>.named' doesn't fit the grammar syntax T.id:
new prefix.Class<int>.named().value;
// 'prefix.Class.named<int>' doesn't fit the grammar syntax T.id:
- new prefix.Class.named<int>().value; //# 06: syntax error
+ new prefix.Class.named<int>().value;
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+
// 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id:
- new prefix<int>.Class<int>.named().value; //# 07: syntax error
+ new prefix<int>.Class<int>.named().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+
+
// 'prefix<int>.Class.named<int>' doesn't fit the grammar syntax T.id:
- new prefix<int>.Class.named<int>().value; //# 08: syntax error
+ new prefix<int>.Class.named<int>().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
+
+
// 'prefix.Class<int>.named<int>' doesn't fit the grammar syntax T.id:
- new prefix.Class<int>.named<int>().value; //# 09: syntax error
+ new prefix.Class<int>.named<int>().value;
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+
// 'prefix<int>.Class<int>.named<int>' doesn't fit the grammar syntax T.id:
- new prefix<int>.Class<int>.named<int>().value; //# 10: syntax error
+ new prefix<int>.Class<int>.named<int>().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
}
diff --git a/tests/language_2/named_parameters_aggregated_runtime_test.dart b/tests/language_2/named_parameters_aggregated_runtime_test.dart
new file mode 100644
index 0000000..eaf37fb
--- /dev/null
+++ b/tests/language_2/named_parameters_aggregated_runtime_test.dart
@@ -0,0 +1,57 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Dart test program for testing named parameters.
+
+class TypeTester<T> {}
+
+// Expect compile-time error as no default values are allowed
+// in closure type definitions.
+typedef void Callback([String msg
+
+]);
+
+class NamedParametersAggregatedTests {
+ static int F31(int a, {int b: 20, int c: 30}) {
+ return 100 * (100 * a + b) + c;
+ }
+
+ static int f_missing_comma(a
+
+ ) =>
+ a;
+
+ var _handler = null;
+
+ // Expect compile-time error as no default values
+ // are allowed in closure type.
+ void InstallCallback(
+ void cb({String msg
+
+ })) {
+ _handler = cb;
+ }
+}
+
+main() {
+ // Expect compile-time error due to missing comma in function definition.
+ NamedParametersAggregatedTests.f_missing_comma(10
+
+ );
+
+ // Expect compile-time error due to duplicate named argument.
+ NamedParametersAggregatedTests.F31(10, b: 25
+
+
+ );
+
+ // Expect compile-time error due to missing positional argument.
+
+
+ new TypeTester<Callback>();
+
+ (new NamedParametersAggregatedTests()).InstallCallback(null);
+}
diff --git a/tests/language_2/named_parameters_aggregated_test.dart b/tests/language_2/named_parameters_aggregated_test.dart
index a4a5aa0..0d6d754 100644
--- a/tests/language_2/named_parameters_aggregated_test.dart
+++ b/tests/language_2/named_parameters_aggregated_test.dart
@@ -7,46 +7,55 @@
// Expect compile-time error as no default values are allowed
// in closure type definitions.
-typedef void Callback([String msg
-= "" //# 01: compile-time error
-]);
+typedef void Callback([String msg = ""]);
+// [error line 10, column 1, length 41]
+// [analyzer] COMPILE_TIME_ERROR.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS
+// ^
+// [analyzer] SYNTACTIC_ERROR.DEFAULT_VALUE_IN_FUNCTION_TYPE
+// [cfe] Can't have a default value in a function type.
class NamedParametersAggregatedTests {
static int F31(int a, {int b: 20, int c: 30}) {
return 100 * (100 * a + b) + c;
}
- static int f_missing_comma(a
- [b = 42] //# 02: syntax error
- ) =>
- a;
+ static int f_missing_comma(a [b = 42]) => a;
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected ')' before this.
var _handler = null;
// Expect compile-time error as no default values
// are allowed in closure type.
- void InstallCallback(
- void cb({String msg
- : null //# 03: compile-time error
- })) {
+ void InstallCallback(void cb({String msg : null})) {
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.DEFAULT_VALUE_IN_FUNCTION_TYPE
+ // [cfe] Can't have a default value in a function type.
_handler = cb;
}
}
main() {
// Expect compile-time error due to missing comma in function definition.
- NamedParametersAggregatedTests.f_missing_comma(10
- , 25 //# 02: continued
- );
+ NamedParametersAggregatedTests.f_missing_comma(10, 25);
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
// Expect compile-time error due to duplicate named argument.
- NamedParametersAggregatedTests.F31(10, b: 25
- , b:35 //# 04: compile-time error
- , b:35, b:45 //# 06: compile-time error
- );
+ NamedParametersAggregatedTests.F31(10, b: 25, b:35);
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_NAMED_ARGUMENT
+ // [cfe] Duplicated named argument 'b'.
// Expect compile-time error due to missing positional argument.
- NamedParametersAggregatedTests.F31(b:25, c:35); //# 05: compile-time error
+ NamedParametersAggregatedTests.F31(b: 25, c: 35);
+ // ^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
new TypeTester<Callback>();
diff --git a/tests/language_2/named_parameters_default_eq_runtime_test.dart b/tests/language_2/named_parameters_default_eq_runtime_test.dart
new file mode 100644
index 0000000..66bf165
--- /dev/null
+++ b/tests/language_2/named_parameters_default_eq_runtime_test.dart
@@ -0,0 +1,104 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2016, 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.
+
+// Check that both `=` and `:` are allowed for named parameters.
+
+import "package:expect/expect.dart";
+
+// Default values are not allowed on typedefs.
+
+
+typedef functype({x, y, z});
+
+int topF({x = 3, y: 5, z}) => x * y * (z ?? 2);
+
+class A {
+ int x;
+ int y;
+ int z;
+ A({this.x = 3, this.y: 5, z}) : z = z ?? 2;
+ A.redirect({int x = 3, int y: 5, int z}) : this(x: x, y: y, z: z);
+ factory A.factory({int x = 3, int y: 5, int z}) =>
+ new A(x: x, y: y, z: z ?? 2);
+ factory A.redirectFactory({int x, int y, int z}) = A;
+
+ // Default values are not allowed on redirecting factory constructors.
+
+
+
+ int get value => x * y * z;
+
+ static int staticF({x = 3, y: 5, z}) => x * y * (z ?? 2);
+ int instanceF({x = 3, y: 5, z}) => x * y * (z ?? 2);
+}
+
+main() {
+ // Reference the type, or dart2js won't see that the declaration is invalid
+
+
+ var a = new A();
+
+ int local({x = 3, y: 5, z}) => x * y * (z ?? 2);
+ var expr = ({x = 3, y: 5, z}) => x * y * (z ?? 2);
+ var tearOff = a.instanceF;
+
+ test(function) {
+ Expect.equals(30, function());
+ Expect.equals(70, function(x: 7));
+ Expect.equals(42, function(y: 7));
+ Expect.equals(28, function(x: 7, y: 2));
+ Expect.equals(15, function(z: 1));
+ Expect.equals(21, function(y: 7, z: 1));
+ Expect.equals(35, function(x: 7, z: 1));
+ Expect.equals(14, function(x: 7, y: 2, z: 1));
+ Expect.isTrue(function is functype);
+ }
+
+ test(topF);
+ test(A.staticF);
+ test(a.instanceF);
+ test(local);
+ test(expr);
+ test(tearOff);
+
+ // Can't tear off constructors.
+ Expect.equals(30, new A().value);
+ Expect.equals(70, new A(x: 7).value);
+ Expect.equals(42, new A(y: 7).value);
+ Expect.equals(28, new A(x: 7, y: 2).value);
+ Expect.equals(15, new A(z: 1).value);
+ Expect.equals(21, new A(y: 7, z: 1).value);
+ Expect.equals(35, new A(x: 7, z: 1).value);
+ Expect.equals(14, new A(x: 7, y: 2, z: 1).value);
+
+ Expect.equals(30, new A.redirect().value);
+ Expect.equals(70, new A.redirect(x: 7).value);
+ Expect.equals(42, new A.redirect(y: 7).value);
+ Expect.equals(28, new A.redirect(x: 7, y: 2).value);
+ Expect.equals(15, new A.redirect(z: 1).value);
+ Expect.equals(21, new A.redirect(y: 7, z: 1).value);
+ Expect.equals(35, new A.redirect(x: 7, z: 1).value);
+ Expect.equals(14, new A.redirect(x: 7, y: 2, z: 1).value);
+
+ Expect.equals(30, new A.factory().value);
+ Expect.equals(70, new A.factory(x: 7).value);
+ Expect.equals(42, new A.factory(y: 7).value);
+ Expect.equals(28, new A.factory(x: 7, y: 2).value);
+ Expect.equals(15, new A.factory(z: 1).value);
+ Expect.equals(21, new A.factory(y: 7, z: 1).value);
+ Expect.equals(35, new A.factory(x: 7, z: 1).value);
+ Expect.equals(14, new A.factory(x: 7, y: 2, z: 1).value);
+
+ Expect.equals(30, new A.redirectFactory().value);
+ Expect.equals(70, new A.redirectFactory(x: 7).value);
+ Expect.equals(42, new A.redirectFactory(y: 7).value);
+ Expect.equals(28, new A.redirectFactory(x: 7, y: 2).value);
+ Expect.equals(15, new A.redirectFactory(z: 1).value);
+ Expect.equals(21, new A.redirectFactory(y: 7, z: 1).value);
+ Expect.equals(35, new A.redirectFactory(x: 7, z: 1).value);
+ Expect.equals(14, new A.redirectFactory(x: 7, y: 2, z: 1).value);
+}
diff --git a/tests/language_2/named_parameters_default_eq_test.dart b/tests/language_2/named_parameters_default_eq_test.dart
index 17ee092..562a270 100644
--- a/tests/language_2/named_parameters_default_eq_test.dart
+++ b/tests/language_2/named_parameters_default_eq_test.dart
@@ -7,7 +7,12 @@
import "package:expect/expect.dart";
// Default values are not allowed on typedefs.
-typedef F1({x = 3, y}); //# 01: compile-time error
+typedef F1({x = 3, y});
+// [error line 10, column 1, length 23]
+// [analyzer] COMPILE_TIME_ERROR.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS
+// ^
+// [analyzer] SYNTACTIC_ERROR.DEFAULT_VALUE_IN_FUNCTION_TYPE
+// [cfe] Can't have a default value in a function type.
typedef functype({x, y, z});
@@ -24,8 +29,12 @@
factory A.redirectFactory({int x, int y, int z}) = A;
// Default values are not allowed on redirecting factory constructors.
- factory A.badRedirectFactory({int x = 3, int y}) = //# 02: compile-time error
- A; //# 02: compile-time error
+ factory A.badRedirectFactory({int x = 3, int y}) =
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR
+ // ^
+ // [cfe] Can't have a default value here because any default values of 'A' would be used instead.
+ A;
int get value => x * y * z;
@@ -35,7 +44,7 @@
main() {
// Reference the type, or dart2js won't see that the declaration is invalid
- F1 _ = null; //# 01: continued
+ F1 _ = null;
var a = new A();
diff --git a/tests/language_2/named_parameters_runtime_test.dart b/tests/language_2/named_parameters_runtime_test.dart
new file mode 100644
index 0000000..ace45ef
--- /dev/null
+++ b/tests/language_2/named_parameters_runtime_test.dart
@@ -0,0 +1,118 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Dart test program for testing named parameters.
+
+import "package:expect/expect.dart";
+
+class NamedParametersTest {
+ static int F00() {
+ return 0;
+ }
+
+ int f11() {
+ return 0;
+ }
+
+ static int F11(int a) {
+ return a;
+ }
+
+ int f22(int a) {
+ return a;
+ }
+
+ static int F10([int b = 20]) {
+ return b;
+ }
+
+ int f21([int b = 20]) {
+ return b;
+ }
+
+ static int F21(int a, [int b = 20]) {
+ return 100 * a + b;
+ }
+
+ int f32(int a, [int b = 20]) {
+ return 100 * a + b;
+ }
+
+ static int F31(int a, [int b = 20, int c = 30]) {
+ return 100 * (100 * a + b) + c;
+ }
+
+ int f42(int a, [int b = 20, int c = 30]) {
+ return 100 * (100 * a + b) + c;
+ }
+
+ static int F41(int a, [int b = 20, int c, int d = 40]) {
+ return 100 * (100 * (100 * a + b) + (c == null ? 0 : c)) + d;
+ }
+
+ int f52(int a, [int b = 20, int c, int d = 40]) {
+ return 100 * (100 * (100 * a + b) + (c == null ? 0 : c)) + d;
+ }
+
+ static testMain() {
+ NamedParametersTest np = new NamedParametersTest();
+ Expect.equals(0, F00());
+ Expect.equals(0, np.f11());
+ Expect.equals(10, F11(10));
+ Expect.equals(10, np.f22(10));
+ Expect.equals(20, F10());
+ Expect.equals(20, np.f21());
+ Expect.equals(20, F10(20));
+ Expect.equals(20, np.f21(20));
+
+
+ Expect.equals(1020, F21(10));
+ Expect.equals(1020, np.f32(10));
+ Expect.equals(1025, F21(10, 25));
+ Expect.equals(1025, np.f32(10, 25));
+
+
+ Expect.equals(102030, F31(10));
+ Expect.equals(102030, np.f42(10));
+ Expect.equals(102530, F31(10, 25));
+ Expect.equals(102530, np.f42(10, 25));
+
+
+ Expect.equals(102535, F31(10, 25, 35));
+ Expect.equals(102535, np.f42(10, 25, 35));
+
+
+ Expect.equals(10200040, F41(10));
+ Expect.equals(10200040, np.f52(10));
+
+
+ }
+}
+
+abstract class I {
+ factory I() = C;
+ int mul(int a, [int factor]);
+}
+
+class C implements I {
+ int mul(int a, [int factor = 10]) {
+ return a * factor;
+ }
+}
+
+hello(msg, to, {from}) => '${from} sent ${msg} to ${to}';
+message() => hello("gladiolas", "possums", from: "Edna");
+
+main() {
+ NamedParametersTest.testMain();
+ var i = new I();
+ Expect.equals(100, i.mul(10));
+ Expect.equals(1000, i.mul(10, 100));
+ var c = new C();
+ Expect.equals(100, c.mul(10));
+ Expect.equals(1000, c.mul(10, 100));
+ Expect.equals("Edna sent gladiolas to possums", message());
+}
diff --git a/tests/language_2/named_parameters_test.dart b/tests/language_2/named_parameters_test.dart
index e90996a..3f1ee9c 100644
--- a/tests/language_2/named_parameters_test.dart
+++ b/tests/language_2/named_parameters_test.dart
@@ -64,28 +64,58 @@
Expect.equals(20, np.f21());
Expect.equals(20, F10(20));
Expect.equals(20, np.f21(20));
- Expect.equals(20, F10(b:20)); // //# 01: compile-time error
- Expect.equals(20, np.f21(b:20)); // //# 02: compile-time error
+ Expect.equals(20, F10(b:20));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'b'.
+ Expect.equals(20, np.f21(b:20));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'b'.
Expect.equals(1020, F21(10));
Expect.equals(1020, np.f32(10));
Expect.equals(1025, F21(10, 25));
Expect.equals(1025, np.f32(10, 25));
- Expect.equals(1025, F21(10, b:25)); // //# 03: compile-time error
- Expect.equals(1025, np.f32(10, b:25)); // //# 04: compile-time error
+ Expect.equals(1025, F21(10, b:25));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'b'.
+ Expect.equals(1025, np.f32(10, b:25));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'b'.
Expect.equals(102030, F31(10));
Expect.equals(102030, np.f42(10));
Expect.equals(102530, F31(10, 25));
Expect.equals(102530, np.f42(10, 25));
- Expect.equals(102035, F31(10, c:35)); // //# 05: compile-time error
- Expect.equals(102035, np.f42(10, c:35)); // //# 06: compile-time error
+ Expect.equals(102035, F31(10, c:35));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'c'.
+ Expect.equals(102035, np.f42(10, c:35));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'c'.
Expect.equals(102535, F31(10, 25, 35));
Expect.equals(102535, np.f42(10, 25, 35));
- Expect.equals(102535, F31(10, 25, c:35)); // //# 07: compile-time error
- Expect.equals(102535, np.f42(10, 25, c:35)); // //# 08: compile-time error
+ Expect.equals(102535, F31(10, 25, c:35));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'c'.
+ Expect.equals(102535, np.f42(10, 25, c:35));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'c'.
Expect.equals(10200040, F41(10));
Expect.equals(10200040, np.f52(10));
- Expect.equals(10203540, F41(10, c:35)); // //# 09: compile-time error
- Expect.equals(10203540, np.f52(10, c:35)); // //# 10: compile-time error
+ Expect.equals(10203540, F41(10, c:35));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'c'.
+ Expect.equals(10203540, np.f52(10, c:35));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ // [cfe] No named parameter with the name 'c'.
}
}
diff --git a/tests/language_2/named_parameters_type_runtime_test.dart b/tests/language_2/named_parameters_type_runtime_test.dart
new file mode 100644
index 0000000..a3a8ff1
--- /dev/null
+++ b/tests/language_2/named_parameters_type_runtime_test.dart
@@ -0,0 +1,30 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+//
+// Dart test program for testing optional named parameters in type tests.
+
+main() {
+ Function anyFunction;
+ void acceptFunNumOptBool(void funNumOptBool(num n, {bool b})) {}
+ ;
+ void funNum(num n) {}
+ ;
+ void funNumBool(num n, bool b) {}
+ ;
+ void funNumOptBool(num n, {bool b: true}) {}
+ ;
+ void funNumOptBoolX(num n, {bool x: true}) {}
+ ;
+ anyFunction = funNum;
+ anyFunction = funNumBool;
+ anyFunction = funNumOptBool;
+ anyFunction = funNumOptBoolX;
+ acceptFunNumOptBool(funNumOptBool);
+
+
+
+}
diff --git a/tests/language_2/named_parameters_type_test.dart b/tests/language_2/named_parameters_type_test.dart
index 01f1331..0f82274 100644
--- a/tests/language_2/named_parameters_type_test.dart
+++ b/tests/language_2/named_parameters_type_test.dart
@@ -21,7 +21,16 @@
anyFunction = funNumOptBool;
anyFunction = funNumOptBoolX;
acceptFunNumOptBool(funNumOptBool);
- acceptFunNumOptBool(funNum); // //# 01: compile-time error
- acceptFunNumOptBool(funNumBool); // //# 02: compile-time error
- acceptFunNumOptBool(funNumOptBoolX); // //# 03: compile-time error
+ acceptFunNumOptBool(funNum);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_FUNCTION
+ // [cfe] The local function has type 'void Function(num)' that isn't of expected type 'void Function(num, {bool b})'.
+ acceptFunNumOptBool(funNumBool);
+ // ^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'void Function(num, bool)' can't be assigned to the parameter type 'void Function(num, {bool b})'.
+ acceptFunNumOptBool(funNumOptBoolX);
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'void Function(num, {bool x})' can't be assigned to the parameter type 'void Function(num, {bool b})'.
}
diff --git a/tests/language_2/new_expression_type_args_runtime_test.dart b/tests/language_2/new_expression_type_args_runtime_test.dart
new file mode 100644
index 0000000..96f8c18
--- /dev/null
+++ b/tests/language_2/new_expression_type_args_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// Tests showing errors using type-arguments in new expressions:
+class A<T> {
+ // Can't instantiate type parameter (within static or instance method).
+
+
+
+ // OK when used within instance method, but not in static method.
+ m3() => new A<T>();
+
+}
+
+main() {
+ A a = new A();
+
+
+ a.m3();
+
+}
diff --git a/tests/language_2/new_expression_type_args_test.dart b/tests/language_2/new_expression_type_args_test.dart
index d264c5b..91ec581 100644
--- a/tests/language_2/new_expression_type_args_test.dart
+++ b/tests/language_2/new_expression_type_args_test.dart
@@ -5,18 +5,27 @@
// Tests showing errors using type-arguments in new expressions:
class A<T> {
// Can't instantiate type parameter (within static or instance method).
- m1() => new T(); // //# 00: compile-time error
- static m2() => new T(); // //# 01: compile-time error
+ m1() => new T();
+ // ^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'T'.
+ static m2() => new T();
+ // ^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'T'.
// OK when used within instance method, but not in static method.
m3() => new A<T>();
- static m4() => new A<T>(); //# 02: compile-time error
+ static m4() => new A<T>();
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
+ // [cfe] Type variables can't be used in static members.
}
main() {
A a = new A();
- a.m1(); //# 00: continued
- A.m2(); //# 01: continued
+ a.m1();
+ A.m2();
a.m3();
- A.m4(); //# 02: continued
+ A.m4();
}
diff --git a/tests/language_2/new_prefix_runtime_test.dart b/tests/language_2/new_prefix_runtime_test.dart
new file mode 100644
index 0000000..1a7288b
--- /dev/null
+++ b/tests/language_2/new_prefix_runtime_test.dart
@@ -0,0 +1,12 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+import 'dart:core' as prefix;
+
+main() {
+
+}
diff --git a/tests/language_2/new_prefix_test.dart b/tests/language_2/new_prefix_test.dart
index 002d48a..72794c8 100644
--- a/tests/language_2/new_prefix_test.dart
+++ b/tests/language_2/new_prefix_test.dart
@@ -5,5 +5,8 @@
import 'dart:core' as prefix;
main() {
- return new prefix(); //# 01: compile-time error
+ return new prefix();
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix'.
}
diff --git a/tests/language_2/nnbd/static_errors/await_in_late_local_variable_initializer_test.dart b/tests/language_2/nnbd/static_errors/await_in_late_local_variable_initializer_test.dart
new file mode 100644
index 0000000..6f5c2c0
--- /dev/null
+++ b/tests/language_2/nnbd/static_errors/await_in_late_local_variable_initializer_test.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=non-nullable
+
+// Test that it is a compile time error for a `late` variable initializer
+// to use the `await` expression.
+import 'package:expect/expect.dart';
+import 'dart:core';
+
+main() async {
+ late a = 0; //# 01: ok
+ late b = await 0; //# 02: compile-time error
+ late c = () async => await 42; //# 03: ok
+ late d = () async { await 42; }; //# 04: ok
+ var e = () async { late e2 = await 42; }; //# 05: compile-time error
+}
diff --git a/tests/language_2/nnbd/static_errors/late_final_field_with_const_constructor_test.dart b/tests/language_2/nnbd/static_errors/late_final_field_with_const_constructor_test.dart
new file mode 100644
index 0000000..30a931e
--- /dev/null
+++ b/tests/language_2/nnbd/static_errors/late_final_field_with_const_constructor_test.dart
@@ -0,0 +1,26 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=non-nullable
+
+// Test that it is not a compile time error for a `final` variable to not have
+// an initializer if that variable is declared as `late`.
+import 'package:expect/expect.dart';
+import 'dart:core';
+
+class C1 {
+ static late final a = 0; //# 01: ok
+ final a = 0; //# 02: ok
+ late final a = 0; //# 03: compile-time error
+ const C1();
+}
+
+class C2 {
+ static late final a = 0; //# 04: ok
+ final a = 0; //# 05: ok
+ late final a = 0; //# 06: ok
+ C2();
+}
+
+main() {}
diff --git a/tests/language_2/nnbd/static_errors/missing_default_value_for_parameter_test.dart b/tests/language_2/nnbd/static_errors/missing_default_value_for_parameter_test.dart
index 0f72ece..43dd5d5 100644
--- a/tests/language_2/nnbd/static_errors/missing_default_value_for_parameter_test.dart
+++ b/tests/language_2/nnbd/static_errors/missing_default_value_for_parameter_test.dart
@@ -25,20 +25,20 @@
void f12(int? a) {}
class A {
- final f;
- A(void this.f({String s})) {}
+ var f;
+ A(void this.f({String s})) {} //# 03: compile-time error
}
-typedef void f13({String});
-void printToLog(void f({String})) {}
-void Function({String s})? f14;
+typedef void f13({String s}); //# 04: compile-time error
+void printToLog(void f({String s})) {} //# 05: compile-time error
+void Function({String s})? f14; //# 06: compile-time error
class B<T extends Object?> {
// Potentially non-nullable types
- void f15({T a = null}) {} //# 03: compile-time error
- void f16({T a}) {} //# 04: compile-time error
+ void f15({T a = null}) {} //# 07: compile-time error
+ void f16({T a}) {} //# 08: compile-time error
void f17({required T a}) {}
- void f18([T a = null]) {} //# 05: compile-time error
- void f19([T a]) {} //# 06: compile-time error
+ void f18([T a = null]) {} //# 09: compile-time error
+ void f19([T a]) {} //# 10: compile-time error
void f20(T a) {}
// Nullable types
@@ -52,11 +52,11 @@
class C<T extends Object> {
// Non-nullable types
- void f27({T a = null}) {} //# 07: compile-time error
- void f28({T a}) {} //# 08: compile-time error
+ void f27({T a = null}) {} //# 11: compile-time error
+ void f28({T a}) {} //# 12: compile-time error
void f29({required T a}) {}
- void f30([T a = null]) {} //# 09: compile-time error
- void f31([T a]) {} //# 10: compile-time error
+ void f30([T a = null]) {} //# 13: compile-time error
+ void f31([T a]) {} //# 14: compile-time error
void f32(T a) {}
// Nullable types
diff --git a/tests/language_2/nnbd/syntax/late_modifier_bug_39658.dart b/tests/language_2/nnbd/syntax/late_modifier_bug_39658.dart
new file mode 100644
index 0000000..67ca1c2
--- /dev/null
+++ b/tests/language_2/nnbd/syntax/late_modifier_bug_39658.dart
@@ -0,0 +1,64 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=non-nullable
+import 'package:expect/expect.dart';
+
+int initCalls = 0;
+double init() {
+ ++initCalls;
+ return 1.23;
+}
+
+class A {
+ late double? fieldWithInit = init();
+ late double fieldWithTrivialInit = 1.23;
+ late double? fieldWithNullInit = null;
+ late double fieldWithNoInit;
+}
+
+main() {
+ // Late, non-final, with init.
+ var a = A();
+ Expect.equals(0, initCalls);
+ Expect.equals(1.23, a.fieldWithInit);
+ Expect.equals(1.23, a.fieldWithTrivialInit);
+ Expect.equals(null, a.fieldWithNullInit);
+ Expect.throws(
+ () => a.fieldWithNoInit, (error) => error is LateInitializationError);
+ Expect.equals(1, initCalls);
+ Expect.equals(1.23, a.fieldWithInit);
+ Expect.equals(1.23, a.fieldWithTrivialInit);
+ Expect.equals(null, a.fieldWithNullInit);
+ Expect.throws(
+ () => a.fieldWithNoInit, (error) => error is LateInitializationError);
+ Expect.equals(1, initCalls);
+ a.fieldWithInit = 4.56;
+ a.fieldWithTrivialInit = 4.56;
+ a.fieldWithNullInit = 4.56;
+ a.fieldWithNoInit = 4.56;
+ Expect.equals(1, initCalls);
+ Expect.equals(4.56, a.fieldWithInit);
+ Expect.equals(4.56, a.fieldWithTrivialInit);
+ Expect.equals(4.56, a.fieldWithNullInit);
+ Expect.equals(4.56, a.fieldWithNoInit);
+ Expect.equals(1, initCalls);
+ initCalls = 0;
+
+ // Late, non-final, with init that's pre-empted by setter.
+ var b = A();
+ Expect.equals(0, initCalls);
+ b.fieldWithInit = 4.56;
+ Expect.equals(0, initCalls);
+ Expect.equals(4.56, b.fieldWithInit);
+ Expect.equals(0, initCalls);
+
+ // Late, non-final, with init that's pre-empted by null setter.
+ var c = A();
+ Expect.equals(0, initCalls);
+ c.fieldWithInit = null;
+ Expect.equals(0, initCalls);
+ Expect.equals(null, c.fieldWithInit);
+ Expect.equals(0, initCalls);
+}
diff --git a/tests/language_2/nnbd/syntax/late_modifier_edge_cases_test.dart b/tests/language_2/nnbd/syntax/late_modifier_edge_cases_test.dart
index 45a0dcd..fddd83c 100644
--- a/tests/language_2/nnbd/syntax/late_modifier_edge_cases_test.dart
+++ b/tests/language_2/nnbd/syntax/late_modifier_edge_cases_test.dart
@@ -42,13 +42,105 @@
lateFieldWithInitThatWritesIntermediateValue() {
A a = A();
Expect.equals(123, a.lateField);
- Expect.throws(() => print(a.lateFinalField));
+ Expect.throws(() => a.lateFinalField);
Expect.equals(5, a.lateFinalField);
Expect.equals(123, A.staticLateField);
- Expect.throws(() => print(A.staticLateFinalField));
+ Expect.throws(() => A.staticLateFinalField);
Expect.equals(5, A.staticLateFinalField);
}
+lateFieldWithComplicatedInitializers() {
+ late int count = 0;
+ int closure() {
+ ++count;
+ return 5;
+ }
+
+ late int nestedLateVar = closure();
+ late var lateVar = [for (int i = 0; i < nestedLateVar; ++i) i * i];
+ Expect.equals(0, count);
+ Expect.listEquals([0, 1, 4, 9, 16], lateVar);
+ Expect.equals(1, count);
+ Expect.listEquals([0, 1, 4, 9, 16], lateVar);
+ Expect.equals(1, count);
+ count = 0;
+
+ late var lateVarInIf = [++count, for (int i = 0; i < 3; ++i) i * i];
+ Expect.equals(0, count);
+ if (true) Expect.listEquals([1, 0, 1, 4], lateVarInIf);
+ Expect.equals(1, count);
+ Expect.listEquals([1, 0, 1, 4], lateVarInIf);
+ Expect.equals(1, count);
+ count = 0;
+
+ late var lateVarInFor = [++count, for (int i = 0; i < 3; ++i) i * i];
+ Expect.equals(0, count);
+ for (int i = 0; i < 3; ++i) Expect.listEquals([1, 0, 1, 4], lateVarInFor);
+ Expect.equals(1, count);
+ count = 0;
+
+ late var lateVarInClosure = [++count, for (int i = 0; i < 3; ++i) i * i];
+ void anotherClosure() {
+ Expect.listEquals([1, 0, 1, 4], lateVarInClosure);
+ }
+
+ Expect.equals(0, count);
+ anotherClosure();
+ anotherClosure();
+ anotherClosure();
+ Expect.equals(1, count);
+ count = 0;
+
+ late int lateVarClosureOuter = () {
+ Expect.equals(0, count);
+ ++count;
+ late int lateVarClosureInner = closure();
+ Expect.equals(1, count);
+ Expect.equals(5, lateVarClosureInner);
+ Expect.equals(2, count);
+ return lateVarClosureInner;
+ }();
+ Expect.equals(0, count);
+ Expect.equals(5, lateVarClosureOuter);
+ Expect.equals(2, count);
+}
+
+class B {
+ late int throwBeforeWrite = initThrowBeforeWrite();
+ int initThrowBeforeWrite() {
+ throw AssertionError();
+ return 123;
+ }
+
+ late int throwAfterWrite = initThrowAfterWrite();
+ int initThrowAfterWrite() {
+ throwAfterWrite = 456;
+ throw AssertionError();
+ return 123;
+ }
+}
+
+lateFieldWithThrowingInitializers() {
+ late int throwBeforeWrite = () {
+ throw AssertionError();
+ return 123;
+ }();
+ Expect.throwsAssertionError(() => throwBeforeWrite);
+ Expect.throwsAssertionError(() => throwBeforeWrite);
+ Expect.throwsAssertionError(() => throwBeforeWrite);
+
+ B b = B();
+ Expect.throwsAssertionError(() => b.throwBeforeWrite);
+ Expect.throwsAssertionError(() => b.throwBeforeWrite);
+ Expect.throwsAssertionError(() => b.throwBeforeWrite);
+
+ Expect.throwsAssertionError(() => b.throwAfterWrite);
+ Expect.equals(456, b.throwAfterWrite);
+ Expect.equals(456, b.throwAfterWrite);
+}
+
main() {
lateFieldWithInitThatWritesIntermediateValue();
+ lateFieldWithComplicatedInitializers();
+ lateFieldWithThrowingInitializers();
}
diff --git a/tests/language_2/nnbd/syntax/null_assertion_ambiguous_test.dart b/tests/language_2/nnbd/syntax/null_assertion_ambiguous_test.dart
index 68c6037..b4b357e 100644
--- a/tests/language_2/nnbd/syntax/null_assertion_ambiguous_test.dart
+++ b/tests/language_2/nnbd/syntax/null_assertion_ambiguous_test.dart
@@ -4,6 +4,7 @@
// SharedOptions=--enable-experiment=non-nullable
import 'package:expect/expect.dart';
+import 'dart:async';
class C {
C operator*(int? other) => this;
@@ -74,14 +75,16 @@
// the runtime behavior by using an object whose operator- returns null.
int? x8 = 2;
-x8!;
- var x9 = new C();
- -x9!;
+ C? x9 = new C();
+ var x10 = -x9!;
+ Expect.isNull(x10);
// `await x!` means `await (x!)`, not `(await x)!`. We check the compile-time
// behavior by checking that the inferred type of the expression is nullable.
// We check the runtime behavior by ensuring that the future completes to a
// null value, and this does not produce an exception.
- var x10 = new Future<Object?>.value(null);
- var x11 = await x10!;
- x11 = null;
+ FutureOr<Object?> x11 = new Future<Object?>.value(null);
+ var x12 = await x11!;
+ Expect.isNull(x12);
+ x12 = null;
}
diff --git a/tests/language_2/no_such_constructor_runtime_test.dart b/tests/language_2/no_such_constructor_runtime_test.dart
new file mode 100644
index 0000000..17ee996
--- /dev/null
+++ b/tests/language_2/no_such_constructor_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class A {
+ A();
+}
+
+main() {
+
+}
diff --git a/tests/language_2/no_such_constructor_test.dart b/tests/language_2/no_such_constructor_test.dart
index 388df92..b106273 100644
--- a/tests/language_2/no_such_constructor_test.dart
+++ b/tests/language_2/no_such_constructor_test.dart
@@ -7,5 +7,8 @@
}
main() {
- new A(42); //# 01: compile-time error
+ new A(42);
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 0 allowed, but 1 found.
}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_class_error_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_class_error_test.dart
new file mode 100644
index 0000000..1501dad
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_class_error_test.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+class A<X> {
+ A();
+ A.named();
+ static void staticMethod<Y>() {}
+}
+
+typedef T<X> = A<X>;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_class_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_class_test.dart
new file mode 100644
index 0000000..1501dad
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_class_test.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+class A<X> {
+ A();
+ A.named();
+ static void staticMethod<Y>() {}
+}
+
+typedef T<X> = A<X>;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_dynamic_error_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_dynamic_error_test.dart
new file mode 100644
index 0000000..66c0903
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_dynamic_error_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = dynamic;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_dynamic_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_dynamic_test.dart
new file mode 100644
index 0000000..66c0903
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_dynamic_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = dynamic;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_function_error_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_function_error_test.dart
new file mode 100644
index 0000000..d167da5
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_function_error_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = Function;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_function_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_function_test.dart
new file mode 100644
index 0000000..d167da5
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_function_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = Function;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_futureor_error_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_futureor_error_test.dart
new file mode 100644
index 0000000..123547f
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_futureor_error_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = FutureOr<X>;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_futureor_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_futureor_test.dart
new file mode 100644
index 0000000..123547f
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_futureor_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = FutureOr<X>;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_null_error_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_null_error_test.dart
new file mode 100644
index 0000000..ad52fe3
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_null_error_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = Null;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_null_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_null_test.dart
new file mode 100644
index 0000000..ad52fe3
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_null_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = Null;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_object_error_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_object_error_test.dart
new file mode 100644
index 0000000..1947781
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_object_error_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = Object;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_object_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_object_test.dart
new file mode 100644
index 0000000..1947781
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_object_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = Object;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_type_variable_error_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_type_variable_error_test.dart
new file mode 100644
index 0000000..139cad3
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_type_variable_error_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = X;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_type_variable_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_type_variable_test.dart
new file mode 100644
index 0000000..139cad3
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_type_variable_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = X;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_void_error_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_void_error_test.dart
new file mode 100644
index 0000000..ddcdcf7
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_void_error_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = void;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/generic_usage_void_test.dart b/tests/language_2/nonfunction_type_aliases/generic_usage_void_test.dart
new file mode 100644
index 0000000..ddcdcf7
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/generic_usage_void_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Test that a non-function type alias can be used as the denoted type in
+// many situations.
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T<X> = void;
+
+// Use the aliased type.
+
+T<int> v1;
+List<T<void>> v2 = [];
+final T<String> v3 = throw "Anything";
+const List<T<C>> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T<C> v1;
+ static List<T<T>> v2 = [];
+ static final T<Null> v3 = throw "Anything";
+ static const List<T<List>> v4 = [];
+
+ T<C> v5;
+ List<T<T>> v6 = [];
+ final T<Null> v7;
+
+ C(): v7 = T();
+ C.name1(this.v5, this.v7);
+ factory C.name2(T<C> arg1, T<Null> arg2) = C.name1;
+
+ T<double> operator +(T<double> other);
+ T<FutureOr<FutureOr<void>>> get g;
+ set g(T<FutureOr<FutureOr<void>>> value);
+ Map<T<C>, T<C>> m1(covariant T<C> arg1, [Set<Set<T<C>>> arg2]);
+ void m2({T arg1, Map<T, T> arg2(T Function(T) arg21, T arg22)});
+}
+
+class D1<X> extends T<X> {}
+abstract class D2 extends C with T<int> {}
+abstract class D3<X, Y> implements T<T> {}
+abstract class D4 = C with T<void>;
+
+extension E on T<dynamic> {
+ T<dynamic> foo(T<dynamic> t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T<Type> Function(T<Type>) id;
+
+main() {
+ var v8 = <T<C>>[];
+ var v9 = <Set<T<T>>, Set<T<T>>>{{}: {}};
+ var v10 = {v8};
+ v9[{}] = {T<T>()};
+ Set<List<T<C>>> v11 = v10;
+ v10 = v11;
+ T<Null>();
+ T<Null>.named();
+ T<Object> v12 = foo<T<bool>>(T<bool>());
+ id(v12);
+ T<List<List<List<List>>>>.staticMethod<T<int>>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_class_error_test.dart b/tests/language_2/nonfunction_type_aliases/usage_class_error_test.dart
new file mode 100644
index 0000000..329aa5b
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_class_error_test.dart
@@ -0,0 +1,71 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+class A {
+ A();
+ A.named();
+ static void staticMethod<X>() {}
+}
+
+typedef T = A;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_class_test.dart b/tests/language_2/nonfunction_type_aliases/usage_class_test.dart
new file mode 100644
index 0000000..329aa5b
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_class_test.dart
@@ -0,0 +1,71 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+class A {
+ A();
+ A.named();
+ static void staticMethod<X>() {}
+}
+
+typedef T = A;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_dynamic_error_test.dart b/tests/language_2/nonfunction_type_aliases/usage_dynamic_error_test.dart
new file mode 100644
index 0000000..8e7f75d
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_dynamic_error_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T = dynamic;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_dynamic_test.dart b/tests/language_2/nonfunction_type_aliases/usage_dynamic_test.dart
new file mode 100644
index 0000000..8e7f75d
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_dynamic_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T = dynamic;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_function_error_test.dart b/tests/language_2/nonfunction_type_aliases/usage_function_error_test.dart
new file mode 100644
index 0000000..91f5209
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_function_error_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T = Function;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_function_test.dart b/tests/language_2/nonfunction_type_aliases/usage_function_test.dart
new file mode 100644
index 0000000..91f5209
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_function_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T = Function;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_futureor_error_test.dart b/tests/language_2/nonfunction_type_aliases/usage_futureor_error_test.dart
new file mode 100644
index 0000000..246fe38
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_futureor_error_test.dart
@@ -0,0 +1,67 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T = FutureOr<int>;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_futureor_test.dart b/tests/language_2/nonfunction_type_aliases/usage_futureor_test.dart
new file mode 100644
index 0000000..246fe38
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_futureor_test.dart
@@ -0,0 +1,67 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+import 'dart:async';
+
+// Introduce an aliased type.
+
+typedef T = FutureOr<int>;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_null_error_test.dart b/tests/language_2/nonfunction_type_aliases/usage_null_error_test.dart
new file mode 100644
index 0000000..14fe1d1
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_null_error_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T = Null;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_null_test.dart b/tests/language_2/nonfunction_type_aliases/usage_null_test.dart
new file mode 100644
index 0000000..14fe1d1
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_null_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T = Null;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_object_error_test.dart b/tests/language_2/nonfunction_type_aliases/usage_object_error_test.dart
new file mode 100644
index 0000000..9ea528d
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_object_error_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T = Object;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_object_test.dart b/tests/language_2/nonfunction_type_aliases/usage_object_test.dart
new file mode 100644
index 0000000..9ea528d
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_object_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T = Object;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_type_variable_error_test.dart b/tests/language_2/nonfunction_type_aliases/usage_type_variable_error_test.dart
new file mode 100644
index 0000000..f1329c6
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_type_variable_error_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T<X extends num> = X;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_type_variable_test.dart b/tests/language_2/nonfunction_type_aliases/usage_type_variable_test.dart
new file mode 100644
index 0000000..f1329c6
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_type_variable_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T<X extends num> = X;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_void_error_test.dart b/tests/language_2/nonfunction_type_aliases/usage_void_error_test.dart
new file mode 100644
index 0000000..12a230a
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_void_error_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T = void;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/nonfunction_type_aliases/usage_void_test.dart b/tests/language_2/nonfunction_type_aliases/usage_void_test.dart
new file mode 100644
index 0000000..12a230a
--- /dev/null
+++ b/tests/language_2/nonfunction_type_aliases/usage_void_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2019, 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.
+
+// SharedOptions=--enable-experiment=nonfunction-type-aliases
+
+// Introduce an aliased type.
+
+typedef T = void;
+
+// Use the aliased type.
+
+T v1;
+List<T> v2 = [];
+final T v3 = throw "Anything";
+const List<T> v4 = [];
+const v5 = <Type, Type>{T: T};
+
+abstract class C {
+ static T v6;
+ static List<T> v7 = [];
+ static final T v8 = throw "Anything";
+ static const List<T> v9 = [];
+
+ T v10;
+ List<T> v11 = [];
+ final T v12;
+
+ C(): v12 = T();
+ C.name1(this.v10, this.v12);
+ factory C.name2(T arg1, T arg2) = C.name1;
+
+ T operator +(T other);
+ T get g;
+ set g(T value);
+ Map<T, T> m1(covariant T arg1, [Set<Set<T>> arg2]);
+ void m2({T arg1, T arg2(T arg21, T arg22)});
+}
+
+class D1 extends T {}
+abstract class D2 extends C with T {}
+abstract class D3 implements T {}
+abstract class D4 = C with T;
+
+extension E on T {
+ T foo(T t) => t;
+}
+
+X foo<X>(X x) => x;
+
+T Function(T) id = (x) => x;
+
+main() {
+ var v13 = <T>[];
+ var v14 = <Set<T>, Set<T>>{{}: {}};
+ v14[{}] = {T()};
+ var v15 = {v13};
+ Set<List<T>> v16 = v15;
+ v15 = v16;
+ T();
+ T.named();
+ T v17 = foo<T>(T());
+ id(v17);
+ T.staticMethod<T>();
+}
diff --git a/tests/language_2/not_enough_positional_arguments_runtime_test.dart b/tests/language_2/not_enough_positional_arguments_runtime_test.dart
new file mode 100644
index 0000000..4ad8424
--- /dev/null
+++ b/tests/language_2/not_enough_positional_arguments_runtime_test.dart
@@ -0,0 +1,48 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+foo(a, [b]) {}
+
+bar(a, {b}) {}
+
+class A {
+ A();
+ A.test(a, [b]);
+}
+
+class B {
+ B()
+
+ ;
+}
+
+class C extends A {
+ C()
+
+ ;
+}
+
+class D {
+ D();
+ D.test(a, {b});
+}
+
+class E extends D {
+ E()
+
+ ;
+}
+
+main() {
+
+ new B();
+ new C();
+
+ new E();
+
+
+}
diff --git a/tests/language_2/not_enough_positional_arguments_test.dart b/tests/language_2/not_enough_positional_arguments_test.dart
index 825e31a..9ebd09f 100644
--- a/tests/language_2/not_enough_positional_arguments_test.dart
+++ b/tests/language_2/not_enough_positional_arguments_test.dart
@@ -13,13 +13,21 @@
class B {
B()
- : super.test(b: 1) // //# 01: compile-time error
+ : super.test(b: 1)
+ //^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
+ // [cfe] Superclass has no constructor named 'Object.test'.
;
}
class C extends A {
C()
- : super.test(b: 1) // //# 02: compile-time error
+ : super.test(b: 1)
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
;
}
@@ -30,16 +38,35 @@
class E extends D {
E()
- : super.test(b: 1) // //# 05: compile-time error
+ : super.test(b: 1)
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
;
}
main() {
- new A.test(b: 1); // //# 00: compile-time error
+ new A.test(b: 1);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
new B();
new C();
- new D.test(b: 1); // //# 03: compile-time error
+ new D.test(b: 1);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
new E();
- foo(b: 1); // //# 06: compile-time error
- bar(b: 1); // //# 07: compile-time error
+ foo(b: 1);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_NAMED_PARAMETER
+ bar(b: 1);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
}
diff --git a/tests/language_2/number_identifier_runtime_test.dart b/tests/language_2/number_identifier_runtime_test.dart
new file mode 100644
index 0000000..3450bd1
--- /dev/null
+++ b/tests/language_2/number_identifier_runtime_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ // Integer literals.
+ Expect.isTrue(2 is int);
+ Expect.equals(2, 2 as int);
+ Expect.isTrue(-2 is int);
+ Expect.equals(-2, -2 as int);
+ Expect.isTrue(0x10 is int);
+ Expect.isTrue(-0x10 is int);
+ // "a" will be part of hex literal, the following "s" is an error.
+
+
+
+ // Double literals.
+ Expect.isTrue(2.0 is double);
+ Expect.equals(2.0, 2.0 as double);
+ Expect.isTrue(-2.0 is double);
+ Expect.equals(-2.0, -2.0 as double);
+ Expect.isTrue(.2 is double);
+ Expect.equals(0.2, .2 as double);
+ Expect.isTrue(1e2 is double);
+ Expect.equals(1e2, 1e2 as double);
+ Expect.isTrue(1e-2 is double);
+ Expect.equals(1e-2, 1e-2 as double);
+ Expect.isTrue(1e+2 is double);
+ Expect.equals(1e+2, 1e+2 as double);
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/number_identifier_test.dart b/tests/language_2/number_identifier_test.dart
index 80321e8..f31575e 100644
--- a/tests/language_2/number_identifier_test.dart
+++ b/tests/language_2/number_identifier_test.dart
@@ -7,14 +7,38 @@
main() {
// Integer literals.
Expect.isTrue(2 is int);
+ // ^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_NON_TYPE
Expect.equals(2, 2 as int);
+ // ^^^
+ // [analyzer] STATIC_WARNING.CAST_TO_NON_TYPE
Expect.isTrue(-2 is int);
+ // ^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_NON_TYPE
Expect.equals(-2, -2 as int);
+ // ^^^
+ // [analyzer] STATIC_WARNING.CAST_TO_NON_TYPE
Expect.isTrue(0x10 is int);
+ // ^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_NON_TYPE
Expect.isTrue(-0x10 is int);
+ // ^^^
+ // [analyzer] STATIC_WARNING.TYPE_TEST_WITH_NON_TYPE
// "a" will be part of hex literal, the following "s" is an error.
- 0x10as int; //# 01: syntax error
- 0x; //# 04: syntax error
+ 0x10as int;
+//^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+// [cfe] 's' isn't a type.
+// ^
+// [cfe] Can't declare 'int' because it was already used in this scope.
+ 0x;
+//^
+// [cfe] A hex digit (0-9 or A-F) must follow '0x'.
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_HEX_DIGIT
// Double literals.
Expect.isTrue(2.0 is double);
@@ -29,13 +53,56 @@
Expect.equals(1e-2, 1e-2 as double);
Expect.isTrue(1e+2 is double);
Expect.equals(1e+2, 1e+2 as double);
- Expect.throwsNoSuchMethodError(() => 1.e+2); //# 05: compile-time error
- 1d; //# 06: syntax error
- 1D; //# 07: syntax error
- Expect.throwsNoSuchMethodError(() => 1.d+2); //# 08: compile-time error
- Expect.throwsNoSuchMethodError(() => 1.D+2); //# 09: compile-time error
- 1.1d; //# 10: syntax error
- 1.1D; //# 11: syntax error
- 1e; //# 02: syntax error
- 1x; //# 03: syntax error
+ Expect.throwsNoSuchMethodError(() => 1.e+2);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'e' isn't defined for the class 'int'.
+ 1d;
+//^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+// [cfe] Getter not found: 'd'.
+ 1D;
+//^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+// [cfe] Getter not found: 'D'.
+ Expect.throwsNoSuchMethodError(() => 1.d+2);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'int'.
+ Expect.throwsNoSuchMethodError(() => 1.D+2);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'D' isn't defined for the class 'int'.
+ 1.1d;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+// [cfe] Getter not found: 'd'.
+ 1.1D;
+//^^^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+// [cfe] Getter not found: 'D'.
+ 1e;
+//^
+// [cfe] Numbers in exponential notation should always contain an exponent (an integer number with an optional sign).
+// ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_DIGIT
+ 1x;
+//^
+// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+// [cfe] Expected ';' after this.
+// ^
+// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+// [cfe] Getter not found: 'x'.
}
diff --git a/tests/language_2/object_has_no_call_method_runtime_1_test.dart b/tests/language_2/object_has_no_call_method_runtime_1_test.dart
new file mode 100644
index 0000000..3bb0108
--- /dev/null
+++ b/tests/language_2/object_has_no_call_method_runtime_1_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+void test(dynamic d, Object o, Function f) {
+ d();
+
+
+
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/object_has_no_call_method_runtime_2_test.dart b/tests/language_2/object_has_no_call_method_runtime_2_test.dart
new file mode 100644
index 0000000..8c209c5
--- /dev/null
+++ b/tests/language_2/object_has_no_call_method_runtime_2_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+void test(dynamic d, Object o, Function f) {
+
+
+ f();
+
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/object_has_no_call_method_runtime_3_test.dart b/tests/language_2/object_has_no_call_method_runtime_3_test.dart
new file mode 100644
index 0000000..6507f06
--- /dev/null
+++ b/tests/language_2/object_has_no_call_method_runtime_3_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+void test(dynamic d, Object o, Function f) {
+
+
+
+ d.call;
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/object_has_no_call_method_runtime_4_test.dart b/tests/language_2/object_has_no_call_method_runtime_4_test.dart
new file mode 100644
index 0000000..a64f242
--- /dev/null
+++ b/tests/language_2/object_has_no_call_method_runtime_4_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+void test(dynamic d, Object o, Function f) {
+
+
+
+
+
+ f.call;
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/object_has_no_call_method_runtime_5_test.dart b/tests/language_2/object_has_no_call_method_runtime_5_test.dart
new file mode 100644
index 0000000..ef58c84
--- /dev/null
+++ b/tests/language_2/object_has_no_call_method_runtime_5_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+void test(dynamic d, Object o, Function f) {
+
+
+
+
+
+
+ d.call();
+
+
+}
+
+main() {}
diff --git a/tests/language_2/object_has_no_call_method_runtime_6_test.dart b/tests/language_2/object_has_no_call_method_runtime_6_test.dart
new file mode 100644
index 0000000..2dcd453
--- /dev/null
+++ b/tests/language_2/object_has_no_call_method_runtime_6_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+void test(dynamic d, Object o, Function f) {
+
+
+
+
+
+
+
+
+ f.call();
+}
+
+main() {}
diff --git a/tests/language_2/object_has_no_call_method_runtime_test.dart b/tests/language_2/object_has_no_call_method_runtime_test.dart
new file mode 100644
index 0000000..c0ec957
--- /dev/null
+++ b/tests/language_2/object_has_no_call_method_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+void test(dynamic d, Object o, Function f) {
+
+
+
+
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/object_has_no_call_method_test.dart b/tests/language_2/object_has_no_call_method_test.dart
index cf334e8..dcb2a5c 100644
--- a/tests/language_2/object_has_no_call_method_test.dart
+++ b/tests/language_2/object_has_no_call_method_test.dart
@@ -3,15 +3,25 @@
// BSD-style license that can be found in the LICENSE file.
void test(dynamic d, Object o, Function f) {
- d(); //# 01: ok
- o(); //# 02: compile-time error
- f(); //# 03: ok
- d.call; //# 04: ok
- o.call; //# 05: compile-time error
- f.call; //# 06: ok
- d.call(); //# 07: ok
- o.call(); //# 08: compile-time error
- f.call(); //# 09: ok
+ d();
+ o();
+//^
+// [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION
+// ^
+// [cfe] The method 'call' isn't defined for the class 'Object'.
+ f();
+ d.call;
+ o.call;
+ //^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'call' isn't defined for the class 'Object'.
+ f.call;
+ d.call();
+ o.call();
+ //^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'call' isn't defined for the class 'Object'.
+ f.call();
}
main() {}
diff --git a/tests/language_2/optional_named_parameters_runtime_test.dart b/tests/language_2/optional_named_parameters_runtime_test.dart
new file mode 100644
index 0000000..f02243a
--- /dev/null
+++ b/tests/language_2/optional_named_parameters_runtime_test.dart
@@ -0,0 +1,106 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Dart test program for testing optional named parameters.
+
+import "package:expect/expect.dart";
+
+class OptionalNamedParametersTest {
+ static int F00() {
+ return 0;
+ }
+
+ int f11() {
+ return 0;
+ }
+
+ static int F11(int a) {
+ return a;
+ }
+
+ int f22(int a) {
+ return a;
+ }
+
+ static int F10({int b: 20}) {
+ return b;
+ }
+
+ int f21({int b: 20}) {
+ return b;
+ }
+
+ static int F21(int a, {int b: 20}) {
+ return 100 * a + b;
+ }
+
+ int f32(int a, {int b: 20}) {
+ return 100 * a + b;
+ }
+
+ static int F31(int a, {int b: 20, int c: 30}) {
+ return 100 * (100 * a + b) + c;
+ }
+
+ int f42(int a, {int b: 20, int c: 30}) {
+ return 100 * (100 * a + b) + c;
+ }
+
+ static int F41(int a, {int b: 20, int c, int d: 40}) {
+ return 100 * (100 * (100 * a + b) + ((c != null) ? c : 0)) + d;
+ }
+
+ int f52(int a, {int b: 20, int c, int d: 40}) {
+ return 100 * (100 * (100 * a + b) + ((c != null) ? c : 0)) + d;
+ }
+
+ static void test() {
+ OptionalNamedParametersTest np = new OptionalNamedParametersTest();
+ Expect.equals(0, F00());
+ Expect.equals(0, np.f11());
+ Expect.equals(10, F11(10));
+ Expect.equals(10, np.f22(10));
+ Expect.equals(20, F10());
+ Expect.equals(20, np.f21());
+
+
+ Expect.equals(20, F10(b: 20));
+ Expect.equals(20, np.f21(b: 20));
+ Expect.equals(1020, F21(10));
+ Expect.equals(1020, np.f32(10));
+
+
+ Expect.equals(1025, F21(10, b: 25));
+ Expect.equals(1025, np.f32(10, b: 25));
+ Expect.equals(102030, F31(10));
+ Expect.equals(102030, np.f42(10));
+
+
+ Expect.equals(102530, F31(10, b: 25));
+ Expect.equals(102530, np.f42(10, b: 25));
+ Expect.equals(102035, F31(10, c: 35));
+ Expect.equals(102035, np.f42(10, c: 35));
+ Expect.equals(102535, F31(10, b: 25, c: 35));
+ Expect.equals(102535, np.f42(10, b: 25, c: 35));
+
+
+ Expect.equals(102535, F31(10, c: 35, b: 25));
+ Expect.equals(102535, np.f42(10, c: 35, b: 25));
+ Expect.equals(10200040, F41(10));
+ Expect.equals(10200040, np.f52(10));
+ Expect.equals(10203540, F41(10, c: 35));
+ Expect.equals(10203540, np.f52(10, c: 35));
+ Expect.equals(10250045, F41(10, d: 45, b: 25));
+
+ Expect.equals(10250045, np.f52(10, d: 45, b: 25));
+ Expect.equals(10253545, F41(10, d: 45, c: 35, b: 25));
+ Expect.equals(10253545, np.f52(10, d: 45, c: 35, b: 25));
+ }
+}
+
+main() {
+ OptionalNamedParametersTest.test();
+}
diff --git a/tests/language_2/optional_named_parameters_test.dart b/tests/language_2/optional_named_parameters_test.dart
index b16517f25..d08f3d9 100644
--- a/tests/language_2/optional_named_parameters_test.dart
+++ b/tests/language_2/optional_named_parameters_test.dart
@@ -62,28 +62,52 @@
Expect.equals(10, np.f22(10));
Expect.equals(20, F10());
Expect.equals(20, np.f21());
- Expect.equals(20, F10(20)); // //# 01: compile-time error
- Expect.equals(20, np.f21(20)); // //# 02: compile-time error
+ Expect.equals(20, F10(20));
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 0 allowed, but 1 found.
+ Expect.equals(20, np.f21(20));
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 0 allowed, but 1 found.
Expect.equals(20, F10(b: 20));
Expect.equals(20, np.f21(b: 20));
Expect.equals(1020, F21(10));
Expect.equals(1020, np.f32(10));
- Expect.equals(1025, F21(10, 25)); // //# 03: compile-time error
- Expect.equals(1025, np.f32(10, 25)); // //# 04: compile-time error
+ Expect.equals(1025, F21(10, 25));
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
+ Expect.equals(1025, np.f32(10, 25));
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
Expect.equals(1025, F21(10, b: 25));
Expect.equals(1025, np.f32(10, b: 25));
Expect.equals(102030, F31(10));
Expect.equals(102030, np.f42(10));
- Expect.equals(102530, F31(10, 25)); // //# 05: compile-time error
- Expect.equals(102530, np.f42(10, 25)); // //# 06: compile-time error
+ Expect.equals(102530, F31(10, 25));
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
+ Expect.equals(102530, np.f42(10, 25));
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
Expect.equals(102530, F31(10, b: 25));
Expect.equals(102530, np.f42(10, b: 25));
Expect.equals(102035, F31(10, c: 35));
Expect.equals(102035, np.f42(10, c: 35));
Expect.equals(102535, F31(10, b: 25, c: 35));
Expect.equals(102535, np.f42(10, b: 25, c: 35));
- Expect.equals(102535, F31(10, 25, c:35)); // //# 07: compile-time error
- Expect.equals(102535, np.f42(10, 25, c:35)); // //# 08: compile-time error
+ Expect.equals(102535, F31(10, 25, c:35));
+ // ^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
+ Expect.equals(102535, np.f42(10, 25, c:35));
+ // ^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
Expect.equals(102535, F31(10, c: 35, b: 25));
Expect.equals(102535, np.f42(10, c: 35, b: 25));
Expect.equals(10200040, F41(10));
@@ -91,7 +115,10 @@
Expect.equals(10203540, F41(10, c: 35));
Expect.equals(10203540, np.f52(10, c: 35));
Expect.equals(10250045, F41(10, d: 45, b: 25));
- Expect.equals(10250045, F41(10, 25, d:45)); // //# 09: compile-time error
+ Expect.equals(10250045, F41(10, 25, d:45));
+ // ^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
Expect.equals(10250045, np.f52(10, d: 45, b: 25));
Expect.equals(10253545, F41(10, d: 45, c: 35, b: 25));
Expect.equals(10253545, np.f52(10, d: 45, c: 35, b: 25));
diff --git a/tests/language_2/override_inheritance_abstract_runtime_1_test.dart b/tests/language_2/override_inheritance_abstract_runtime_1_test.dart
new file mode 100644
index 0000000..97b0057
--- /dev/null
+++ b/tests/language_2/override_inheritance_abstract_runtime_1_test.dart
@@ -0,0 +1,69 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+abstract class A {
+ method1();
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class I {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class J {
+
+
+
+}
+
+class Class extends A implements I, J {
+ method1() {}
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+main() {
+ new Class();
+}
diff --git a/tests/language_2/override_inheritance_abstract_runtime_2_test.dart b/tests/language_2/override_inheritance_abstract_runtime_2_test.dart
new file mode 100644
index 0000000..2b15235
--- /dev/null
+++ b/tests/language_2/override_inheritance_abstract_runtime_2_test.dart
@@ -0,0 +1,69 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+abstract class A {
+
+ method5();
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class I {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class J {
+
+
+
+}
+
+class Class extends A implements I, J {
+
+
+
+
+ method5() {}
+
+
+
+
+
+
+
+
+
+}
+
+main() {
+ new Class();
+}
diff --git a/tests/language_2/override_inheritance_abstract_runtime_3_test.dart b/tests/language_2/override_inheritance_abstract_runtime_3_test.dart
new file mode 100644
index 0000000..c54794a
--- /dev/null
+++ b/tests/language_2/override_inheritance_abstract_runtime_3_test.dart
@@ -0,0 +1,69 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+abstract class A {
+
+
+ method6();
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class I {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class J {
+
+
+
+}
+
+class Class extends A implements I, J {
+
+
+
+
+
+ method6([a]) {}
+
+
+
+
+
+
+
+
+}
+
+main() {
+ new Class();
+}
diff --git a/tests/language_2/override_inheritance_abstract_runtime_4_test.dart b/tests/language_2/override_inheritance_abstract_runtime_4_test.dart
new file mode 100644
index 0000000..ddfba63
--- /dev/null
+++ b/tests/language_2/override_inheritance_abstract_runtime_4_test.dart
@@ -0,0 +1,69 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+abstract class A {
+
+
+
+
+
+
+
+
+
+
+
+ method18() {}
+
+}
+
+abstract class I {
+
+
+
+
+
+
+
+
+ method18() {}
+
+
+
+
+
+
+
+
+}
+
+abstract class J {
+
+
+
+}
+
+class Class extends A implements I, J {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+main() {
+ new Class();
+}
diff --git a/tests/language_2/override_inheritance_abstract_runtime_5_test.dart b/tests/language_2/override_inheritance_abstract_runtime_5_test.dart
new file mode 100644
index 0000000..48a350d
--- /dev/null
+++ b/tests/language_2/override_inheritance_abstract_runtime_5_test.dart
@@ -0,0 +1,69 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+abstract class A {
+
+
+
+
+
+
+
+
+
+
+
+
+ method27() {}
+}
+
+abstract class I {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class J {
+
+
+
+}
+
+class Class extends A implements I, J {
+
+
+
+
+
+
+
+
+
+
+
+
+
+ method27();
+}
+
+main() {
+ new Class();
+}
diff --git a/tests/language_2/override_inheritance_abstract_runtime_6_test.dart b/tests/language_2/override_inheritance_abstract_runtime_6_test.dart
new file mode 100644
index 0000000..e8b1123
--- /dev/null
+++ b/tests/language_2/override_inheritance_abstract_runtime_6_test.dart
@@ -0,0 +1,69 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+abstract class A {
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class I {
+
+
+
+
+
+ method15() {}
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class J {
+
+
+
+}
+
+class Class extends A implements I, J {
+
+
+
+
+
+
+
+
+ method15() {}
+
+
+
+
+
+}
+
+main() {
+ new Class();
+}
diff --git a/tests/language_2/override_inheritance_abstract_runtime_7_test.dart b/tests/language_2/override_inheritance_abstract_runtime_7_test.dart
new file mode 100644
index 0000000..e1d3cab
--- /dev/null
+++ b/tests/language_2/override_inheritance_abstract_runtime_7_test.dart
@@ -0,0 +1,69 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+abstract class A {
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class I {
+
+
+
+
+
+
+ method16() {}
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class J {
+
+
+
+}
+
+class Class extends A implements I, J {
+
+
+
+
+
+
+
+
+
+ method16([a]) {}
+
+
+
+
+}
+
+main() {
+ new Class();
+}
diff --git a/tests/language_2/override_inheritance_abstract_runtime_test.dart b/tests/language_2/override_inheritance_abstract_runtime_test.dart
new file mode 100644
index 0000000..40685ca
--- /dev/null
+++ b/tests/language_2/override_inheritance_abstract_runtime_test.dart
@@ -0,0 +1,69 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+abstract class A {
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class I {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+abstract class J {
+
+
+
+}
+
+class Class extends A implements I, J {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+main() {
+ new Class();
+}
diff --git a/tests/language_2/override_inheritance_abstract_test.dart b/tests/language_2/override_inheritance_abstract_test.dart
index 026fcf3..9218fab 100644
--- a/tests/language_2/override_inheritance_abstract_test.dart
+++ b/tests/language_2/override_inheritance_abstract_test.dart
@@ -3,62 +3,71 @@
// BSD-style license that can be found in the LICENSE file.
abstract class A {
- method1(); //# 01: ok
- method5(); //# 05: ok
- method6(); //# 06: ok
- method7(); //# 07: compile-time error
- get getter8; //# 08: compile-time error
- set setter9(_); //# 09: compile-time error
- method10(); //# 10: compile-time error
- get getter11; //# 11: compile-time error
- set setter12(_); //# 12: compile-time error
- get field13; //# 13: compile-time error
- set field14(_); //# 14: compile-time error
- method18() {} //# 18: ok
- method27() {} //# 27: ok
+ method1();
+ method5();
+ method6();
+ method7();
+ get getter8;
+ set setter9(_);
+ method10();
+ get getter11;
+ set setter12(_);
+ get field13;
+ set field14(_);
+ method18() {}
+ method27() {}
}
abstract class I {
- method10() {} //# 10: continued
- get getter11 => 0; //# 11: continued
- set setter12(_) {} //# 12: continued
- var field13; //# 13: continued
- var field14; //# 14: continued
- method15() {} //# 15: ok
- method16() {} //# 16: ok
- method17() {} //# 17: compile-time error
- method18() {} //# 18: continued
- var member19; //# 19: compile-time error
- var member20; //# 20: compile-time error
- var member21; //# 21: compile-time error
- get member22 => 0; //# 22: compile-time error
- set member23(_) {} //# 23: compile-time error
- var member24; //# 24: compile-time error
- var field25; //# 25: compile-time error
- var member26; //# 26: compile-time error
+ method10() {}
+ get getter11 => 0;
+ set setter12(_) {}
+ var field13;
+ var field14;
+ method15() {}
+ method16() {}
+ method17() {}
+ method18() {}
+ var member19;
+ var member20;
+ var member21;
+ get member22 => 0;
+ set member23(_) {}
+ var member24;
+ var field25;
+ var member26;
}
abstract class J {
- get member20 => null; //# 20: continued
- set member20(_) {} //# 20: continued
- var member21; //# 21: continued
+ get member20 => null;
+ set member20(_) {}
+ var member21;
}
class Class extends A implements I, J {
- method1() {} //# 01: continued
- method2(); //# 02: compile-time error
- get getter3; //# 03: compile-time error
- set setter4(_); //# 04: compile-time error
- method5() {} //# 05: continued
- method6([a]) {} //# 06: continued
- set field13(_) {} //# 13: continued
- get field14 => 0; //# 14: continued
- method15() {} //# 15: continued
- method16([a]) {} //# 16: continued
- get member24 => 0; //# 24: continued
- final field25 = 0; //# 25: continued
- set member26(_) {} //# 26: continued
- method27(); //# 27: continued
+// ^^^^^
+// [analyzer] STATIC_WARNING.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER
+// [cfe] The non-abstract class 'Class' is missing implementations for these members:
+ method1() {}
+ method2();
+//^^^^^^^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
+ get getter3;
+//^^^^^^^^^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
+ set setter4(_);
+//^^^^^^^^^^^^^^^
+// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
+ method5() {}
+ method6([a]) {}
+ set field13(_) {}
+ get field14 => 0;
+ method15() {}
+ method16([a]) {}
+ get member24 => 0;
+ final field25 = 0;
+ set member26(_) {}
+ method27();
}
main() {
diff --git a/tests/language_2/override_method_with_field_runtime_test.dart b/tests/language_2/override_method_with_field_runtime_test.dart
new file mode 100644
index 0000000..c18d588
--- /dev/null
+++ b/tests/language_2/override_method_with_field_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Test overriding a method with a field.
+
+class Super {
+ Super() : super();
+
+ instanceMethod() => 42;
+}
+
+class Sub extends Super {
+ Sub() : super();
+
+
+
+ superInstanceMethod() => super.instanceMethod();
+}
+
+main() {
+ var s = new Sub();
+ Super sup = s;
+ Sub sub = s;
+ print(s.instanceMethod);
+ Expect.equals(42, s.superInstanceMethod());
+
+ Expect.equals(42, sub.superInstanceMethod());
+}
diff --git a/tests/language_2/override_method_with_field_test.dart b/tests/language_2/override_method_with_field_test.dart
index fe97a77..edd17fd 100644
--- a/tests/language_2/override_method_with_field_test.dart
+++ b/tests/language_2/override_method_with_field_test.dart
@@ -15,7 +15,10 @@
class Sub extends Super {
Sub() : super();
- var instanceMethod = 87; // //# 01: compile-time error
+ var instanceMethod = 87;
+ // ^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_FIELD_AND_METHOD
+ // [cfe] Can't declare a member that conflicts with an inherited one.
superInstanceMethod() => super.instanceMethod();
}
@@ -26,6 +29,9 @@
Sub sub = s;
print(s.instanceMethod);
Expect.equals(42, s.superInstanceMethod());
- Expect.equals(42, sup.superInstanceMethod()); //# 02: compile-time error
+ Expect.equals(42, sup.superInstanceMethod());
+ // ^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'superInstanceMethod' isn't defined for the class 'Super'.
Expect.equals(42, sub.superInstanceMethod());
}
diff --git a/tests/language_2/part_of_multiple_libs_runtime_test.dart b/tests/language_2/part_of_multiple_libs_runtime_test.dart
new file mode 100644
index 0000000..15f0e08
--- /dev/null
+++ b/tests/language_2/part_of_multiple_libs_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+library ambiguous_lib;
+
+
+
+part "part_of_multiple_libs_part.dart";
+
+main() {
+ foo();
+}
diff --git a/tests/language_2/part_of_multiple_libs_test.dart b/tests/language_2/part_of_multiple_libs_test.dart
index 73fd235..69bf2c7 100644
--- a/tests/language_2/part_of_multiple_libs_test.dart
+++ b/tests/language_2/part_of_multiple_libs_test.dart
@@ -4,10 +4,12 @@
library ambiguous_lib;
-import 'part_of_multiple_libs_lib.dart'; //# 01: compile-time error
+import 'part_of_multiple_libs_lib.dart';
part "part_of_multiple_libs_part.dart";
+//^
+// [cfe] Method not found: 'foo'.
main() {
foo();
}
diff --git a/tests/language_2/part_refers_to_core_library_runtime_test.dart b/tests/language_2/part_refers_to_core_library_runtime_test.dart
new file mode 100644
index 0000000..e9abfec
--- /dev/null
+++ b/tests/language_2/part_refers_to_core_library_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// This test reproduces https://github.com/dart-lang/sdk/issues/29709.
+
+library dart.async;
+
+
+
+main() {}
diff --git a/tests/language_2/part_refers_to_core_library_test.dart b/tests/language_2/part_refers_to_core_library_test.dart
index af61075..4eb8dc7 100644
--- a/tests/language_2/part_refers_to_core_library_test.dart
+++ b/tests/language_2/part_refers_to_core_library_test.dart
@@ -6,6 +6,10 @@
library dart.async;
-part 'dart:async/future.dart'; //# 01: compile-time error
+part 'dart:async/future.dart';
+// ^
+// [cfe] Can't use 'org-dartlang-untranslatable-uri:dart%3Aasync%2Ffuture.dart' as a part, because it has no 'part of' declaration.
+// ^
+// [cfe] Not found: 'dart:async/future.dart'
main() {}
diff --git a/tests/language_2/partial_instantiation_static_bounds_check_runtime_test.dart b/tests/language_2/partial_instantiation_static_bounds_check_runtime_test.dart
new file mode 100644
index 0000000..4596750
--- /dev/null
+++ b/tests/language_2/partial_instantiation_static_bounds_check_runtime_test.dart
@@ -0,0 +1,31 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+topFn<T extends num>(T x) {
+ print(T);
+}
+
+class C<T> {
+ instanceFn<S extends T>(S x) {
+ print(S);
+ }
+}
+
+class D<T> extends C<T> {
+ void foo() {
+
+ }
+}
+
+void main() {
+ localFn<T extends num>(T x) {
+ print(T);
+ }
+
+
+
+}
diff --git a/tests/language_2/partial_instantiation_static_bounds_check_test.dart b/tests/language_2/partial_instantiation_static_bounds_check_test.dart
index 2bfa732..38192ba 100644
--- a/tests/language_2/partial_instantiation_static_bounds_check_test.dart
+++ b/tests/language_2/partial_instantiation_static_bounds_check_test.dart
@@ -14,7 +14,9 @@
class D<T> extends C<T> {
void foo() {
- void Function(int) k = instanceFn; //# 03: compile-time error
+ void Function(int) k = instanceFn;
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
}
}
@@ -23,6 +25,10 @@
print(T);
}
- void Function(String) k0 = localFn; //# 01: compile-time error
- void Function(String) k1 = topFn; //# 02: compile-time error
+ void Function(String) k0 = localFn;
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
+ void Function(String) k1 = topFn;
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
}
diff --git a/tests/language_2/positional_parameters_type_runtime_test.dart b/tests/language_2/positional_parameters_type_runtime_test.dart
new file mode 100644
index 0000000..87d1516
--- /dev/null
+++ b/tests/language_2/positional_parameters_type_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+//
+// Dart test program for testing optional positional parameters in type tests.
+
+main() {
+ Function anyFunction;
+ void acceptFunNumOptBool(void funNumOptBool(num n, [bool b])) {}
+ void funNum(num n) {}
+ void funNumBool(num n, bool b) {}
+ void funNumOptBool(num n, [bool b = true]) {}
+ void funNumOptBoolX(num n, [bool x = true]) {}
+
+ anyFunction = funNum;
+ anyFunction = funNumBool;
+ anyFunction = funNumOptBool;
+ anyFunction = funNumOptBoolX;
+ acceptFunNumOptBool(funNumOptBool);
+ acceptFunNumOptBool(funNumOptBoolX);
+
+
+}
diff --git a/tests/language_2/positional_parameters_type_test.dart b/tests/language_2/positional_parameters_type_test.dart
index c3d1633..4bb4aa1 100644
--- a/tests/language_2/positional_parameters_type_test.dart
+++ b/tests/language_2/positional_parameters_type_test.dart
@@ -18,6 +18,12 @@
anyFunction = funNumOptBoolX;
acceptFunNumOptBool(funNumOptBool);
acceptFunNumOptBool(funNumOptBoolX);
- acceptFunNumOptBool(funNum); //# 01: compile-time error
- acceptFunNumOptBool(funNumBool); //# 02: compile-time error
+ acceptFunNumOptBool(funNum);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_FUNCTION
+ // [cfe] The local function has type 'void Function(num)' that isn't of expected type 'void Function(num, [bool])'.
+ acceptFunNumOptBool(funNumBool);
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_FUNCTION
+ // [cfe] The local function has type 'void Function(num, bool)' that isn't of expected type 'void Function(num, [bool])'.
}
diff --git a/tests/language_2/prefix16_runtime_test.dart b/tests/language_2/prefix16_runtime_test.dart
new file mode 100644
index 0000000..d2e0b91
--- /dev/null
+++ b/tests/language_2/prefix16_runtime_test.dart
@@ -0,0 +1,30 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+//
+// Unresolved imported symbols are errors.
+// In this test, the function myFunc contains malformed types because
+// lib12.Library13 is not resolved.
+
+import "package:expect/expect.dart";
+import "library12.dart" as lib12;
+
+typedef
+
+ myFunc(
+
+ param);
+typedef
+
+ myFunc2(
+
+ param, int i);
+
+main() {
+ Expect.isTrue(((Object x) => x) is myFunc);
+ Expect.isTrue(((Object x, int y) => x) is myFunc2);
+ Expect.isFalse(((Object x, String y) => x) is myFunc2);
+}
diff --git a/tests/language_2/prefix16_test.dart b/tests/language_2/prefix16_test.dart
index 33de502..97999c7 100644
--- a/tests/language_2/prefix16_test.dart
+++ b/tests/language_2/prefix16_test.dart
@@ -10,14 +10,26 @@
import "library12.dart" as lib12;
typedef
- lib12.Library13 //# 00: compile-time error
+ lib12.Library13
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+// [cfe] Type 'lib12.Library13' not found.
myFunc(
- lib12.Library13 //# 00: continued
+ lib12.Library13
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+// [cfe] Type 'lib12.Library13' not found.
param);
typedef
- lib12.Library13 //# 01: compile-time error
+ lib12.Library13
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+// [cfe] Type 'lib12.Library13' not found.
myFunc2(
- lib12.Library13 //# 01: continued
+ lib12.Library13
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+// [cfe] Type 'lib12.Library13' not found.
param, int i);
main() {
diff --git a/tests/language_2/prefix22_runtime_test.dart b/tests/language_2/prefix22_runtime_test.dart
new file mode 100644
index 0000000..792dcfb
--- /dev/null
+++ b/tests/language_2/prefix22_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+//
+// Unresolved symbols should be reported as static type warnings.
+// This should not prevent execution.
+
+library Prefix21NegativeTest.dart;
+import "library12.dart" as lib12;
+
+class myClass {
+ myClass(
+
+ p) { }
+}
+
+main() {
+ new myClass(null); // no dynamic type error when assigning null
+}
diff --git a/tests/language_2/prefix22_test.dart b/tests/language_2/prefix22_test.dart
index 97dddb1..43c5157 100644
--- a/tests/language_2/prefix22_test.dart
+++ b/tests/language_2/prefix22_test.dart
@@ -10,7 +10,12 @@
class myClass {
myClass(
- lib12.Library13 //# 00: compile-time error
+ lib12.Library13
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+// [cfe] Type 'lib12.Library13' not found.
+// ^
+// [cfe] 'Library13' isn't a type.
p) { }
}
diff --git a/tests/language_2/prefix23_runtime_test.dart b/tests/language_2/prefix23_runtime_test.dart
new file mode 100644
index 0000000..7c438dc
--- /dev/null
+++ b/tests/language_2/prefix23_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+//
+// Unresolved symbols should be reported as an static type warnings.
+// This should not prevent execution.
+
+library Prefix23Test.dart;
+
+import "library12.dart" as lib12;
+
+class myClass {
+ final
+
+ fld = null;
+}
+
+main() {}
diff --git a/tests/language_2/prefix23_test.dart b/tests/language_2/prefix23_test.dart
index 5957757..03bc842 100644
--- a/tests/language_2/prefix23_test.dart
+++ b/tests/language_2/prefix23_test.dart
@@ -11,7 +11,12 @@
class myClass {
final
- lib12.Library13 //# 00: compile-time error
+ lib12.Library13
+// ^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+// [cfe] Type 'lib12.Library13' not found.
+// ^
+// [cfe] 'Library13' isn't a type.
fld = null;
}
diff --git a/tests/language_2/prefix_assignment_runtime_test.dart b/tests/language_2/prefix_assignment_runtime_test.dart
new file mode 100644
index 0000000..c33c8f5
--- /dev/null
+++ b/tests/language_2/prefix_assignment_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Validate that assignment to a prefix is handled consistently with the
+// following spec text from section 16.19 (Assignment):
+// Evaluation of an assignment a of the form v = e proceeds as follows:
+// Let d be the innermost declaration whose name is v or v=, if it exists.
+// It is a compile-time error if d denotes a prefix object.
+
+import "empty_library.dart" as p;
+
+class Base {
+ var p;
+}
+
+class Derived extends Base {
+ void f() {
+
+ }
+}
+
+main() {
+ new Derived().f();
+
+}
diff --git a/tests/language_2/prefix_assignment_test.dart b/tests/language_2/prefix_assignment_test.dart
index 14e6f51..5a32011 100644
--- a/tests/language_2/prefix_assignment_test.dart
+++ b/tests/language_2/prefix_assignment_test.dart
@@ -16,11 +16,17 @@
class Derived extends Base {
void f() {
- p = 1; //# 01: compile-time error
+ p = 1;
+// ^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used as an expression.
}
}
main() {
new Derived().f();
- p = 1; //# 02: compile-time error
+ p = 1;
+//^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used as an expression.
}
diff --git a/tests/language_2/prefix_import_collision_runtime_test.dart b/tests/language_2/prefix_import_collision_runtime_test.dart
new file mode 100644
index 0000000..ee14f61
--- /dev/null
+++ b/tests/language_2/prefix_import_collision_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Using the same prefix name while importing two different libraries is
+// not an error but both library1.dart and library2.dart define 'foo' which
+// results in a duplicate definition error.
+import "library1.dart" as lib2; // defines 'foo'.
+import "library2.dart" as lib2; // also defines 'foo'.
+
+main() {
+
+}
diff --git a/tests/language_2/prefix_import_collision_test.dart b/tests/language_2/prefix_import_collision_test.dart
index 5540dde..d7bd0f7 100644
--- a/tests/language_2/prefix_import_collision_test.dart
+++ b/tests/language_2/prefix_import_collision_test.dart
@@ -9,5 +9,8 @@
import "library2.dart" as lib2; // also defines 'foo'.
main() {
- lib2.foo = 1; //# 01: compile-time error
+ lib2.foo = 1;
+ // ^^^
+ // [analyzer] STATIC_WARNING.AMBIGUOUS_IMPORT
+ // [cfe] Setter not found: 'foo'.
}
diff --git a/tests/language_2/prefix_invalid_name_runtime_test.dart b/tests/language_2/prefix_invalid_name_runtime_test.dart
new file mode 100644
index 0000000..586b87e
--- /dev/null
+++ b/tests/language_2/prefix_invalid_name_runtime_test.dart
@@ -0,0 +1,13 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Prefix must be a valid identifier.
+import "library1.dart"
+
+ ;
+
+main() {}
diff --git a/tests/language_2/prefix_invalid_name_test.dart b/tests/language_2/prefix_invalid_name_test.dart
index 4d9b406..c96b904 100644
--- a/tests/language_2/prefix_invalid_name_test.dart
+++ b/tests/language_2/prefix_invalid_name_test.dart
@@ -4,7 +4,16 @@
// Prefix must be a valid identifier.
import "library1.dart"
- as lib1.invalid //# 01: syntax error
+ as lib1.invalid
+ // ^^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected ';' after this.
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_EXECUTABLE
+ // [cfe] Expected a declaration, but got '.'.
+ // ^^^^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_CONST_FINAL_VAR_OR_TYPE
+ // [cfe] Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
;
main() {}
diff --git a/tests/language_2/prefix_shadow_runtime_test.dart b/tests/language_2/prefix_shadow_runtime_test.dart
new file mode 100644
index 0000000..8ee27f0
--- /dev/null
+++ b/tests/language_2/prefix_shadow_runtime_test.dart
@@ -0,0 +1,36 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Type parameters can shadow a library prefix.
+
+import "package:expect/expect.dart";
+import "library10.dart" as T;
+import "library10.dart" as lib10;
+
+class P<T> {
+ test() {
+
+ }
+}
+
+main() {
+ new P<int>().test();
+
+ {
+ // Variables in the local scope hide the library prefix.
+
+ var result = 0;
+ result = lib10.Library10.static_fld;
+ Expect.equals(4, result);
+ }
+
+ {
+ // Shadowing is not an error.
+ var lib10 = 1;
+ Expect.equals(2, lib10 + 1);
+ }
+}
diff --git a/tests/language_2/prefix_shadow_test.dart b/tests/language_2/prefix_shadow_test.dart
index e385baf..ca33755 100644
--- a/tests/language_2/prefix_shadow_test.dart
+++ b/tests/language_2/prefix_shadow_test.dart
@@ -10,7 +10,9 @@
class P<T> {
test() {
- new T.Library10(10); //# 01: compile-time error
+ new T.Library10(10);
+ // ^
+ // [cfe] Method not found: 'T.Library10'.
}
}
@@ -19,9 +21,12 @@
{
// Variables in the local scope hide the library prefix.
- var lib10 = 0; //# 02: compile-time error
+ var lib10 = 0;
var result = 0;
result = lib10.Library10.static_fld;
+ // ^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'Library10' isn't defined for the class 'int'.
Expect.equals(4, result);
}
diff --git a/tests/language_2/prefix_transitive_import_prefix_runtime_test.dart b/tests/language_2/prefix_transitive_import_prefix_runtime_test.dart
new file mode 100644
index 0000000..d441887
--- /dev/null
+++ b/tests/language_2/prefix_transitive_import_prefix_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+import "library10.dart";
+
+main() {
+ // Library prefixes in the imported libraries should not be visible here.
+
+
+
+}
diff --git a/tests/language_2/prefix_transitive_import_prefix_test.dart b/tests/language_2/prefix_transitive_import_prefix_test.dart
index ec1767a..778de16 100644
--- a/tests/language_2/prefix_transitive_import_prefix_test.dart
+++ b/tests/language_2/prefix_transitive_import_prefix_test.dart
@@ -5,7 +5,16 @@
main() {
// Library prefixes in the imported libraries should not be visible here.
- new lib11.Library11(1); //# 01: compile-time error
- lib11.Library11.static_func(); //# 02: compile-time error
- lib11.Library11.static_fld; //# 03: compile-time error
+ new lib11.Library11(1);
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // [cfe] Method not found: 'lib11.Library11'.
+ lib11.Library11.static_func();
+//^^^^^
+// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+// [cfe] Getter not found: 'lib11'.
+ lib11.Library11.static_fld;
+//^^^^^
+// [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+// [cfe] Getter not found: 'lib11'.
}
diff --git a/tests/language_2/prefix_transitive_import_runtime_test.dart b/tests/language_2/prefix_transitive_import_runtime_test.dart
new file mode 100644
index 0000000..6b92926
--- /dev/null
+++ b/tests/language_2/prefix_transitive_import_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Symbols in libraries imported by the prefixed library should not be visible.
+
+import "library12.dart" as lib12;
+
+main() {
+ // Class should not be visible.
+
+
+ // Variable should not be visible.
+
+}
diff --git a/tests/language_2/prefix_transitive_import_test.dart b/tests/language_2/prefix_transitive_import_test.dart
index d71654d..ec248e7 100644
--- a/tests/language_2/prefix_transitive_import_test.dart
+++ b/tests/language_2/prefix_transitive_import_test.dart
@@ -8,8 +8,14 @@
main() {
// Class should not be visible.
- new lib12.Library11(1); //# 01: compile-time error
+ new lib12.Library11(1);
+ // ^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'Library11'.
// Variable should not be visible.
- lib12.top_level11; //# 02: compile-time error
+ lib12.top_level11;
+ // ^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_PREFIXED_NAME
+ // [cfe] Getter not found: 'top_level11'.
}
diff --git a/tests/language_2/prefix_unqualified_invocation_runtime_test.dart b/tests/language_2/prefix_unqualified_invocation_runtime_test.dart
new file mode 100644
index 0000000..0841ed0
--- /dev/null
+++ b/tests/language_2/prefix_unqualified_invocation_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Validate the following spec text from section 16.14.3 (Unqualified
+// invocation):
+// An unqualifiedfunction invocation i has the form
+// id(a1, ..., an, xn+1 : an+1, ..., xn+k : an+k),
+// where id is an identifier.
+// If there exists a lexically visible declaration named id, let fid be the
+// innermost such declaration. Then:
+// - If fid is a prefix object, a compile-time error occurs.
+
+import "empty_library.dart" as p;
+
+class Base {
+ void p() {}
+}
+
+class Derived extends Base {
+ void f() {
+
+ }
+}
+
+main() {
+ new Derived().f();
+
+}
diff --git a/tests/language_2/prefix_unqualified_invocation_test.dart b/tests/language_2/prefix_unqualified_invocation_test.dart
index d4a174c..decb209 100644
--- a/tests/language_2/prefix_unqualified_invocation_test.dart
+++ b/tests/language_2/prefix_unqualified_invocation_test.dart
@@ -19,11 +19,17 @@
class Derived extends Base {
void f() {
- p(); //# 01: compile-time error
+ p();
+// ^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used as an expression.
}
}
main() {
new Derived().f();
- p(); //# 02: compile-time error
+ p();
+//^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT
+// [cfe] A prefix can't be used as an expression.
}
diff --git a/tests/language_2/prefix_unresolved_class_runtime_test.dart b/tests/language_2/prefix_unresolved_class_runtime_test.dart
new file mode 100644
index 0000000..055baa5
--- /dev/null
+++ b/tests/language_2/prefix_unresolved_class_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Unresolved symbols should be reported as an error.
+import "library12.dart" as lib12;
+
+class Subclass
+
+{}
+
+class Implementer
+
+{}
+
+main() {
+ new Subclass();
+ new Implementer();
+}
diff --git a/tests/language_2/prefix_unresolved_class_test.dart b/tests/language_2/prefix_unresolved_class_test.dart
index 38f3914..bd32c35 100644
--- a/tests/language_2/prefix_unresolved_class_test.dart
+++ b/tests/language_2/prefix_unresolved_class_test.dart
@@ -6,11 +6,21 @@
import "library12.dart" as lib12;
class Subclass
- extends lib12.Library13 //# 01: compile-time error
+ extends lib12.Library13
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTENDS_NON_CLASS
+ // [cfe] Type 'lib12.Library13' not found.
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
{}
class Implementer
- implements lib12.Library13 //# 02: compile-time error
+ implements lib12.Library13
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
+ // [cfe] Type 'lib12.Library13' not found.
+ // ^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
{}
main() {
diff --git a/tests/language_2/prefix_variable_collision_runtime_test.dart b/tests/language_2/prefix_variable_collision_runtime_test.dart
new file mode 100644
index 0000000..c0f7af3
--- /dev/null
+++ b/tests/language_2/prefix_variable_collision_runtime_test.dart
@@ -0,0 +1,12 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+import "library10.dart" as lib10;
+
+// Top level variables cannot shadow library prefixes, they should collide.
+
+
+main() {}
diff --git a/tests/language_2/prefix_variable_collision_test.dart b/tests/language_2/prefix_variable_collision_test.dart
index 9333fd0..d4d2540 100644
--- a/tests/language_2/prefix_variable_collision_test.dart
+++ b/tests/language_2/prefix_variable_collision_test.dart
@@ -2,8 +2,12 @@
// 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.
import "library10.dart" as lib10;
+// ^
+// [cfe] 'lib10' is already declared in this scope.
// Top level variables cannot shadow library prefixes, they should collide.
-var lib10; //# 01: compile-time error
+var lib10;
+// ^^^^^
+// [analyzer] COMPILE_TIME_ERROR.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER
main() {}
diff --git a/tests/language_2/private_access_runtime_test.dart b/tests/language_2/private_access_runtime_test.dart
new file mode 100644
index 0000000..ae72983
--- /dev/null
+++ b/tests/language_2/private_access_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+
+import 'private_access_lib.dart';
+import 'private_access_lib.dart' as private;
+
+main() {
+
+
+
+
+
+
+}
diff --git a/tests/language_2/private_access_test.dart b/tests/language_2/private_access_test.dart
index b6eeb98d1..e13267e 100644
--- a/tests/language_2/private_access_test.dart
+++ b/tests/language_2/private_access_test.dart
@@ -8,10 +8,30 @@
import 'private_access_lib.dart' as private;
main() {
- _function(); //# 01: compile-time error
- private._function(); //# 02: compile-time error
- new _Class(); //# 03: compile-time error
- private._Class(); //# 04: compile-time error
- new Class._constructor(); //# 05: compile-time error
- new private.Class._constructor(); //# 06: compile-time error
+ _function();
+//^^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_FUNCTION
+// [cfe] Method not found: '_function'.
+ private._function();
+//^
+// [cfe] Method not found: '_function'.
+// ^^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_FUNCTION
+ new _Class();
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // [cfe] Method not found: '_Class'.
+ private._Class();
+//^
+// [cfe] Method not found: '_Class'.
+// ^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_FUNCTION
+ new Class._constructor();
+ // ^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_UNDEFINED_CONSTRUCTOR
+ // [cfe] Method not found: 'Class._constructor'.
+ new private.Class._constructor();
+ // ^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_UNDEFINED_CONSTRUCTOR
+ // [cfe] Method not found: 'Class._constructor'.
}
diff --git a/tests/language_2/private_super_constructor_runtime_test.dart b/tests/language_2/private_super_constructor_runtime_test.dart
new file mode 100644
index 0000000..e906b7a
--- /dev/null
+++ b/tests/language_2/private_super_constructor_runtime_test.dart
@@ -0,0 +1,16 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+library private_super_constructor_test;
+
+import 'private_super_constructor_lib.dart';
+
+class C extends B {
+
+}
+
+main() => new C();
diff --git a/tests/language_2/private_super_constructor_test.dart b/tests/language_2/private_super_constructor_test.dart
index 7db8cdd..fb5edd1 100644
--- a/tests/language_2/private_super_constructor_test.dart
+++ b/tests/language_2/private_super_constructor_test.dart
@@ -7,7 +7,10 @@
import 'private_super_constructor_lib.dart';
class C extends B {
- C() : super._foo(); //# 01: compile-time error
+ C() : super._foo();
+ // ^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
+ // [cfe] Superclass has no constructor named 'B._foo'.
}
main() => new C();
diff --git a/tests/language_2/redirecting_factory_default_values_runtime_test.dart b/tests/language_2/redirecting_factory_default_values_runtime_test.dart
new file mode 100644
index 0000000..a17a7d6
--- /dev/null
+++ b/tests/language_2/redirecting_factory_default_values_runtime_test.dart
@@ -0,0 +1,28 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test that parameter default values are disallowed in a redirecting factory.
+
+import "package:expect/expect.dart";
+
+class A {
+ A(this.a, [this.b = 0]);
+ factory A.f(int a) = A;
+
+
+
+ int a;
+ int b;
+}
+
+main() {
+ var x = new A.f(42);
+ Expect.equals(x.a, 42);
+ Expect.equals(x.b, 0);
+
+
+}
diff --git a/tests/language_2/redirecting_factory_default_values_test.dart b/tests/language_2/redirecting_factory_default_values_test.dart
index e384252..0b24876 100644
--- a/tests/language_2/redirecting_factory_default_values_test.dart
+++ b/tests/language_2/redirecting_factory_default_values_test.dart
@@ -9,8 +9,19 @@
class A {
A(this.a, [this.b = 0]);
factory A.f(int a) = A;
- factory A.g(int a, [int b = 0]) = A; // //# 01: compile-time error
- factory A.h(int a, {int b: 0}) = A; // //# 02: compile-time error
+ factory A.g(int a, [int b = 0]) = A;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR
+ // ^
+ // [cfe] Can't have a default value here because any default values of 'A' would be used instead.
+ factory A.h(int a, {int b: 0}) = A;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR
+ // ^
+ // [cfe] Can't have a default value here because any default values of 'A' would be used instead.
+ // ^
+ // [analyzer] STATIC_WARNING.REDIRECT_TO_INVALID_FUNCTION_TYPE
+ // [cfe] The constructor function type 'A Function(int, [int])' isn't a subtype of 'A Function(int, {int b})'.
int a;
int b;
@@ -21,5 +32,8 @@
Expect.equals(x.a, 42);
Expect.equals(x.b, 0);
- var y = new A.f(42, 43); //# 03: compile-time error
+ var y = new A.f(42, 43);
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
}
diff --git a/tests/language_2/redirecting_factory_incompatible_signature_runtime_test.dart b/tests/language_2/redirecting_factory_incompatible_signature_runtime_test.dart
new file mode 100644
index 0000000..b565714
--- /dev/null
+++ b/tests/language_2/redirecting_factory_incompatible_signature_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test that incompatible signatures in a forwarding factory
+// constructor leads to a compile-time error.
+
+import "package:expect/expect.dart";
+
+class A {
+ A(a, b);
+
+}
+
+main() {
+
+}
diff --git a/tests/language_2/redirecting_factory_incompatible_signature_test.dart b/tests/language_2/redirecting_factory_incompatible_signature_test.dart
index d1cd6c3..7a77f18 100644
--- a/tests/language_2/redirecting_factory_incompatible_signature_test.dart
+++ b/tests/language_2/redirecting_factory_incompatible_signature_test.dart
@@ -9,9 +9,12 @@
class A {
A(a, b);
- factory A.f() = A; //# 01: compile-time error
+ factory A.f() = A;
+ // ^
+ // [analyzer] STATIC_WARNING.REDIRECT_TO_INVALID_FUNCTION_TYPE
+ // [cfe] The constructor function type 'A Function(dynamic, dynamic)' isn't a subtype of 'A Function()'.
}
main() {
- new A.f(); //# 01: continued
+ new A.f();
}
diff --git a/tests/language_2/redirecting_factory_malbounded_runtime_test.dart b/tests/language_2/redirecting_factory_malbounded_runtime_test.dart
new file mode 100644
index 0000000..8cfc36b
--- /dev/null
+++ b/tests/language_2/redirecting_factory_malbounded_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+class Foo<T> {
+ factory Foo() = Bar<T>;
+ Foo.create() {}
+}
+
+class Bar<
+ T
+
+ > extends Foo<T> {
+ factory Bar() {
+ return new Bar<T>.create();
+ }
+
+ Bar.create() : super.create() {}
+}
+
+main() {
+ new Foo<String>();
+}
diff --git a/tests/language_2/redirecting_factory_malbounded_test.dart b/tests/language_2/redirecting_factory_malbounded_test.dart
index be88726..29dd27875 100644
--- a/tests/language_2/redirecting_factory_malbounded_test.dart
+++ b/tests/language_2/redirecting_factory_malbounded_test.dart
@@ -4,12 +4,16 @@
class Foo<T> {
factory Foo() = Bar<T>;
+ // ^
+ // [cfe] The type 'T' doesn't extend 'num'.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
Foo.create() {}
}
class Bar<
T
- extends num //# 01: compile-time error
+ extends num
> extends Foo<T> {
factory Bar() {
return new Bar<T>.create();
@@ -20,4 +24,6 @@
main() {
new Foo<String>();
+ // ^
+ // [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'Bar'.
}
diff --git a/tests/language_2/ref_before_declaration_runtime_test.dart b/tests/language_2/ref_before_declaration_runtime_test.dart
new file mode 100644
index 0000000..84949d0
--- /dev/null
+++ b/tests/language_2/ref_before_declaration_runtime_test.dart
@@ -0,0 +1,100 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test compile-time errors for illegal variable declarations if the name
+// has been referenced before the variable is declared.
+
+import 'dart:math' as math;
+
+use(value) => value;
+
+var x = 0;
+final y = 0;
+
+class C {
+ var f;
+ C() : f = 'How do you spell PTSD?';
+
+ void test1() {
+ use(f); // Refers to instance field f.
+
+ }
+
+ void test2() {
+ void localFunc() {
+ use(f); // Refers to instance field f.
+ }
+
+
+ if (true) {
+ var f = 1; // ok, shadows outer f and instance field f.
+ }
+ }
+
+ void test3() {
+ if (true) {
+ use(x); // Refers to top-level x.
+ use(y); // Refers to top-level y.
+ }
+
+
+ }
+
+ void test4() {
+ void Q() {
+
+ }
+
+
+
+
+
+ }
+
+ test() {
+ test1();
+ test2();
+ test3();
+ test4();
+ }
+}
+
+void testTypeRef() {
+ String s = 'Can vegetarians eat animal crackers?';
+
+}
+
+void testLibPrefix() {
+ var pie = math.pi;
+
+}
+
+void noErrorsExpected() {
+ use(x);
+ for (var x = 0; x < 10; x++) use(x);
+ for (var i = 0; i < 10; i++) var x = 0;
+ if (true) var x = 0;
+ while (false) var x = 0;
+ try {
+ throw "ball";
+ } catch (x) {
+ use(x);
+ }
+ switch (x) {
+ case 0:
+ var x = 'Does fuzzy logic tickle?';
+ }
+ var int = 007;
+}
+
+void main() {
+ var c = new C();
+ c.test();
+ testTypeRef();
+ testLibPrefix();
+ noErrorsExpected();
+}
diff --git a/tests/language_2/ref_before_declaration_test.dart b/tests/language_2/ref_before_declaration_test.dart
index 65f58ac..53f42bc 100644
--- a/tests/language_2/ref_before_declaration_test.dart
+++ b/tests/language_2/ref_before_declaration_test.dart
@@ -18,15 +18,23 @@
void test1() {
use(f); // Refers to instance field f.
- var f = 'A shut mouth gathers no foot.'; // //# 00: compile-time error
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
+ var f = 'A shut mouth gathers no foot.';
+ // ^
+ // [cfe] Can't declare 'f' because it was already used in this scope.
}
void test2() {
void localFunc() {
use(f); // Refers to instance field f.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
}
- var f = 'When chemists die, they barium.'; // //# 01: compile-time error
+ var f = 'When chemists die, they barium.';
+ // ^
+ // [cfe] Can't declare 'f' because it was already used in this scope.
if (true) {
var f = 1; // ok, shadows outer f and instance field f.
}
@@ -35,21 +43,40 @@
void test3() {
if (true) {
use(x); // Refers to top-level x.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
use(y); // Refers to top-level y.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
}
- final x = "I have not yet begun to procrastinate."; // //# 02: compile-time error
- const y = "Honk if you like peace and quiet!"; // //# 03: compile-time error
+ final x = "I have not yet begun to procrastinate.";
+ // ^
+ // [cfe] Can't declare 'x' because it was already used in this scope.
+ const y = "Honk if you like peace and quiet!";
+ // ^
+ // [cfe] Can't declare 'y' because it was already used in this scope.
}
void test4() {
void Q() {
- P(); // Refers to non-existing top-level function P // //# 06: compile-time error
+ P(); // Refers to non-existing top-level function P
+// ^
+// [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
+// [cfe] The method 'P' isn't defined for the class 'C'.
}
- void P() { // //# 06: continued
- Q(); // //# 06: continued
- } // //# 06: continued
+ void P() {
+ // ^
+ // [cfe] Can't declare 'P' because it was already used in this scope.
+ Q();
+ }
- Function f = () {x = f;}; // //# 07: compile-time error
+ Function f = () {x = f;};
+ // ^
+ // [cfe] Can't declare 'f' because it was already used in this scope.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
}
test() {
@@ -62,12 +89,20 @@
void testTypeRef() {
String s = 'Can vegetarians eat animal crackers?';
- var String = "I distinctly remember forgetting that."; // //# 04: compile-time error
+//^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
+ var String = "I distinctly remember forgetting that.";
+ // ^
+ // [cfe] Can't declare 'String' because it was already used in this scope.
}
void testLibPrefix() {
var pie = math.pi;
- final math = 0; // //# 05: compile-time error
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
+ final math = 0;
+ // ^
+ // [cfe] Can't declare 'math' because it was already used in this scope.
}
void noErrorsExpected() {
diff --git a/tests/language_2/regress_20394_runtime_test.dart b/tests/language_2/regress_20394_runtime_test.dart
new file mode 100644
index 0000000..6547d3b
--- /dev/null
+++ b/tests/language_2/regress_20394_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+import 'regress_20394_lib.dart';
+
+class M {}
+
+class C extends Super with M {
+
+}
+
+main() {
+ new C();
+}
diff --git a/tests/language_2/regress_20394_test.dart b/tests/language_2/regress_20394_test.dart
index 1cf77fa..1e88571 100644
--- a/tests/language_2/regress_20394_test.dart
+++ b/tests/language_2/regress_20394_test.dart
@@ -3,7 +3,10 @@
class M {}
class C extends Super with M {
- C() : super._private(42); // //# 01: compile-time error
+ C() : super._private(42);
+ // ^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
+ // [cfe] Superclass has no constructor named 'Super._private'.
}
main() {
diff --git a/tests/language_2/regress_21793_runtime_test.dart b/tests/language_2/regress_21793_runtime_test.dart
new file mode 100644
index 0000000..4bdd03b
--- /dev/null
+++ b/tests/language_2/regress_21793_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// Regression test for issue 21793.
+
+import 'package:expect/expect.dart';
+
+
+class A {
+ call(x) => x;
+}
+
+
+main() {
+ print(new A()(499));
+}
diff --git a/tests/language_2/regress_21793_test.dart b/tests/language_2/regress_21793_test.dart
index 2b823c6..6b8e87e 100644
--- a/tests/language_2/regress_21793_test.dart
+++ b/tests/language_2/regress_21793_test.dart
@@ -6,12 +6,15 @@
import 'package:expect/expect.dart';
-/* // //# 01: compile-time error
+/*
class A {
call(x) => x;
}
-*/ // //# 01: continued
+*/
main() {
print(new A()(499));
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // [cfe] Method not found: 'A'.
}
diff --git a/tests/language_2/regress_21912_runtime_test.dart b/tests/language_2/regress_21912_runtime_test.dart
new file mode 100644
index 0000000..e44b17f
--- /dev/null
+++ b/tests/language_2/regress_21912_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Regression test for issue 21912.
+
+class A {}
+
+class B extends A {}
+
+typedef T Function2<S, T>(S z);
+typedef B AToB(A x);
+typedef A BToA(B x);
+
+void main() {
+ {
+ Function2<Function2<A, B>, Function2<B, A>> t1;
+ Function2<AToB, BToA> t2;
+ Function2<Function2<int, double>, Function2<int, double>> left;
+
+
+ }
+}
diff --git a/tests/language_2/regress_21912_test.dart b/tests/language_2/regress_21912_test.dart
index 39d27e6..46e6e58 100644
--- a/tests/language_2/regress_21912_test.dart
+++ b/tests/language_2/regress_21912_test.dart
@@ -17,7 +17,13 @@
Function2<Function2<A, B>, Function2<B, A>> t1;
Function2<AToB, BToA> t2;
Function2<Function2<int, double>, Function2<int, double>> left;
- left = t1; //# 01: compile-time error
- left = t2; //# 02: compile-time error
+ left = t1;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'A Function(B) Function(B Function(A))' can't be assigned to a variable of type 'double Function(int) Function(double Function(int))'.
+ left = t2;
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // [cfe] A value of type 'A Function(B) Function(B Function(A))' can't be assigned to a variable of type 'double Function(int) Function(double Function(int))'.
}
}
diff --git a/tests/language_2/regress_23038_runtime_test.dart b/tests/language_2/regress_23038_runtime_test.dart
new file mode 100644
index 0000000..fb22db1
--- /dev/null
+++ b/tests/language_2/regress_23038_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+class C<T> {
+ const
+
+ C()
+
+ ;
+}
+
+main() {
+ const C<int>();
+}
diff --git a/tests/language_2/regress_23038_test.dart b/tests/language_2/regress_23038_test.dart
index 9fbe0cb..bf5cbd0 100644
--- a/tests/language_2/regress_23038_test.dart
+++ b/tests/language_2/regress_23038_test.dart
@@ -4,9 +4,14 @@
class C<T> {
const
- factory //# 01: compile-time error
+ factory
C()
- = C<C<T>> //# 01: continued
+//^
+// [cfe] Cyclic definition of factory 'C'.
+ = C<C<T>>
+ //^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_FACTORY_REDIRECT
+ // [cfe] The constructor function type 'C<C<T>> Function()' isn't a subtype of 'C<T> Function()'.
;
}
diff --git a/tests/language_2/regress_26855_runtime_test.dart b/tests/language_2/regress_26855_runtime_test.dart
new file mode 100644
index 0000000..a5cc175
--- /dev/null
+++ b/tests/language_2/regress_26855_runtime_test.dart
@@ -0,0 +1,28 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2016, 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.
+
+
+
+
+
+
+
+class C {
+ C();
+ var x;
+
+
+}
+
+main() {
+
+
+
+ C c = new C();
+
+
+}
diff --git a/tests/language_2/regress_26855_test.dart b/tests/language_2/regress_26855_test.dart
index 0377fa3..889d1ee 100644
--- a/tests/language_2/regress_26855_test.dart
+++ b/tests/language_2/regress_26855_test.dart
@@ -2,24 +2,40 @@
// 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.
-void f0(this.x) {} // //# 0: compile-time error
+void f0(this.x) {}
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
+// [cfe] Field formal parameters can only be used in a constructor.
-void f1(int g(this.x)) {} // //# 1: compile-time error
+void f1(int g(this.x)) {}
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
+// [cfe] Field formal parameters can only be used in a constructor.
-void f2(int g(int this.x)) {} // //# 2: compile-time error
+void f2(int g(int this.x)) {}
+// ^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
+// ^
+// [cfe] Field formal parameters can only be used in a constructor.
class C {
C();
var x;
- void f3(int g(this.x)) {} // //# 3: compile-time error
- C.f4(int g(this.x)); // //# 4: compile-time error
+ void f3(int g(this.x)) {}
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
+ // [cfe] Field formal parameters can only be used in a constructor.
+ C.f4(int g(this.x));
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
+ // [cfe] Field formal parameters can only be used in a constructor.
}
main() {
- f0(null); // //# 0: continued
- f1(null); // //# 1: continued
- f2(null); // //# 2: continued
+ f0(null);
+ f1(null);
+ f2(null);
C c = new C();
- c.f3(null); // //# 3: continued
- new C.f4(null); // //# 4: continued
+ c.f3(null);
+ new C.f4(null);
}
diff --git a/tests/language_2/regress_27617_runtime_test.dart b/tests/language_2/regress_27617_runtime_test.dart
new file mode 100644
index 0000000..e75bc21
--- /dev/null
+++ b/tests/language_2/regress_27617_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2016, 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.
+
+class Foo {
+ final String greeting;
+ Foo._(this.greeting) {}
+
+ // Const constructor must not redirect to non-const constructor.
+
+}
+
+main() {
+
+}
diff --git a/tests/language_2/regress_27617_test.dart b/tests/language_2/regress_27617_test.dart
index 960d987..fbd06e4 100644
--- a/tests/language_2/regress_27617_test.dart
+++ b/tests/language_2/regress_27617_test.dart
@@ -7,9 +7,12 @@
Foo._(this.greeting) {}
// Const constructor must not redirect to non-const constructor.
- const Foo.hi() : this._('hi'); // //# 1: compile-time error
+ const Foo.hi() : this._('hi');
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_NON_CONST_CONSTRUCTOR
+ // [cfe] A constant constructor can't call a non-constant constructor.
}
main() {
- const h = const Foo.hi(); // //# 1: continued
+ const h = const Foo.hi();
}
diff --git a/tests/language_2/regress_29784_runtime_test.dart b/tests/language_2/regress_29784_runtime_test.dart
new file mode 100644
index 0000000..f145ed4
--- /dev/null
+++ b/tests/language_2/regress_29784_runtime_test.dart
@@ -0,0 +1,24 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// VMOptions=--enable_asserts
+
+// Verify that only static members can be accessed in initializers, and this
+// applies to asserts in initializers.
+
+import 'package:expect/expect.dart';
+
+class A {
+
+
+ var a, b;
+}
+
+main() {
+
+
+}
diff --git a/tests/language_2/regress_29784_test.dart b/tests/language_2/regress_29784_test.dart
index eead4c6..0df166f 100644
--- a/tests/language_2/regress_29784_test.dart
+++ b/tests/language_2/regress_29784_test.dart
@@ -10,12 +10,17 @@
import 'package:expect/expect.dart';
class A {
- A.ok() : b = a; //# 01: compile-time error
- A.ko() : assert(a == null); //# 02: compile-time error
+ A.ok() : b = a;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER
+ // [cfe] Can't access 'this' in a field initializer to read 'a'.
+ A.ko() : assert(a == null);
+ // ^
+ // [cfe] Can't access 'this' in a field initializer to read 'a'.
var a, b;
}
main() {
- new A.ok(); //# 01: continued
- new A.ko(); //# 02: continued
+ new A.ok();
+ new A.ko();
}
diff --git a/tests/language_2/regress_33235_01_runtime_test.dart b/tests/language_2/regress_33235_01_runtime_test.dart
new file mode 100644
index 0000000..7ca47d7
--- /dev/null
+++ b/tests/language_2/regress_33235_01_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class C {
+
+
+ static int get n {
+ return 42;
+ }
+}
+
+main() {
+ print(C);
+}
diff --git a/tests/language_2/regress_33235_01_test.dart b/tests/language_2/regress_33235_01_test.dart
index e4b252d..2936782 100644
--- a/tests/language_2/regress_33235_01_test.dart
+++ b/tests/language_2/regress_33235_01_test.dart
@@ -7,9 +7,15 @@
// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
class C {
- C.n() {} // //# 01: compile-time error
+ C.n() {}
+//^
+// [cfe] Conflicts with member 'n'.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_CONSTRUCTOR_AND_STATIC_FIELD
static int get n {
+ // ^
+ // [cfe] Conflicts with constructor 'C.n'.
return 42;
}
}
diff --git a/tests/language_2/regress_33235_02_runtime_test.dart b/tests/language_2/regress_33235_02_runtime_test.dart
new file mode 100644
index 0000000..8694344
--- /dev/null
+++ b/tests/language_2/regress_33235_02_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class C {
+
+
+ static int n() {
+ return 42;
+ }
+}
+
+main() {
+ print(C);
+}
diff --git a/tests/language_2/regress_33235_02_test.dart b/tests/language_2/regress_33235_02_test.dart
index 6cc51d2..5d9156b 100644
--- a/tests/language_2/regress_33235_02_test.dart
+++ b/tests/language_2/regress_33235_02_test.dart
@@ -7,9 +7,15 @@
// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
class C {
- C.n() {} // //# 01: compile-time error
+ C.n() {}
+//^
+// [cfe] Conflicts with member 'n'.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_CONSTRUCTOR_AND_STATIC_METHOD
static int n() {
+ // ^
+ // [cfe] Conflicts with constructor 'C.n'.
return 42;
}
}
diff --git a/tests/language_2/regress_33235_03_runtime_test.dart b/tests/language_2/regress_33235_03_runtime_test.dart
new file mode 100644
index 0000000..01801f6
--- /dev/null
+++ b/tests/language_2/regress_33235_03_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class C {
+
+
+ static set n(int x) {}
+}
+
+main() {
+ print(C);
+}
diff --git a/tests/language_2/regress_33235_03_test.dart b/tests/language_2/regress_33235_03_test.dart
index f1e762b..c47118d 100644
--- a/tests/language_2/regress_33235_03_test.dart
+++ b/tests/language_2/regress_33235_03_test.dart
@@ -7,9 +7,15 @@
// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
class C {
- C.n() {} // //# 01: compile-time error
+ C.n() {}
+//^
+// [cfe] Conflicts with setter 'n'.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_CONSTRUCTOR_AND_STATIC_FIELD
static set n(int x) {}
+ // ^
+ // [cfe] Conflicts with constructor 'n'.
}
main() {
diff --git a/tests/language_2/regress_33235_04_runtime_test.dart b/tests/language_2/regress_33235_04_runtime_test.dart
new file mode 100644
index 0000000..56e2636
--- /dev/null
+++ b/tests/language_2/regress_33235_04_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class C {
+
+
+ static int n() => 42;
+}
+
+main() {
+ print(C);
+}
diff --git a/tests/language_2/regress_33235_04_test.dart b/tests/language_2/regress_33235_04_test.dart
index db46401..2214c0a 100644
--- a/tests/language_2/regress_33235_04_test.dart
+++ b/tests/language_2/regress_33235_04_test.dart
@@ -7,9 +7,12 @@
// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
class C {
- static int get n => 42; // //# 01: compile-time error
+ static int get n => 42;
static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+ // [cfe] 'n' is already declared in this scope.
}
main() {
diff --git a/tests/language_2/regress_33235_05_runtime_test.dart b/tests/language_2/regress_33235_05_runtime_test.dart
new file mode 100644
index 0000000..d2d1f9d
--- /dev/null
+++ b/tests/language_2/regress_33235_05_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class A {
+ int get n => 43;
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ int get n => 43;
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_05_test.dart b/tests/language_2/regress_33235_05_test.dart
index 179a4f3..fa22f82 100644
--- a/tests/language_2/regress_33235_05_test.dart
+++ b/tests/language_2/regress_33235_05_test.dart
@@ -11,17 +11,27 @@
}
class B extends A {
- static int get n => 42; // //# 02: compile-time error
+ static int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- static int get n => 42; // //# 03: compile-time error
+ static int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- static int get n => 42; // //# 01: compile-time error
+ static int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
int get n => 43;
+ // ^
+ // [cfe] 'n' is already declared in this scope.
}
main() {
diff --git a/tests/language_2/regress_33235_06_runtime_test.dart b/tests/language_2/regress_33235_06_runtime_test.dart
new file mode 100644
index 0000000..4d9123d
--- /dev/null
+++ b/tests/language_2/regress_33235_06_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class A {
+ int n() => 43;
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ int n() => 43;
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_06_test.dart b/tests/language_2/regress_33235_06_test.dart
index bd9bcc2..3e36251 100644
--- a/tests/language_2/regress_33235_06_test.dart
+++ b/tests/language_2/regress_33235_06_test.dart
@@ -11,17 +11,27 @@
}
class B extends A {
- static int get n => 42; // //# 02: compile-time error
+ static int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- static int get n => 42; // //# 03: compile-time error
+ static int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- static int get n => 42; // //# 01: compile-time error
+ static int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
int n() => 43;
+ // ^
+ // [cfe] 'n' is already declared in this scope.
}
main() {
diff --git a/tests/language_2/regress_33235_07_runtime_test.dart b/tests/language_2/regress_33235_07_runtime_test.dart
new file mode 100644
index 0000000..1100c43
--- /dev/null
+++ b/tests/language_2/regress_33235_07_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class A {
+ void set n(int i) {}
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ void set n(int i) {}
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_07_test.dart b/tests/language_2/regress_33235_07_test.dart
index da33ad7..9912e7c 100644
--- a/tests/language_2/regress_33235_07_test.dart
+++ b/tests/language_2/regress_33235_07_test.dart
@@ -11,15 +11,24 @@
}
class B extends A {
- static int get n => 42; // //# 02: compile-time error
+ static int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- static int get n => 42; // //# 03: compile-time error
+ static int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- static int get n => 42; // //# 01: compile-time error
+ static int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] This static member conflicts with an instance member.
void set n(int i) {}
}
diff --git a/tests/language_2/regress_33235_08_runtime_test.dart b/tests/language_2/regress_33235_08_runtime_test.dart
new file mode 100644
index 0000000..d2d1f9d
--- /dev/null
+++ b/tests/language_2/regress_33235_08_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class A {
+ int get n => 43;
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ int get n => 43;
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_08_test.dart b/tests/language_2/regress_33235_08_test.dart
index 82369f5..26aa457 100644
--- a/tests/language_2/regress_33235_08_test.dart
+++ b/tests/language_2/regress_33235_08_test.dart
@@ -11,17 +11,27 @@
}
class B extends A {
- static int n() => 42; // //# 02: compile-time error
+ static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- static int n() => 42; // //# 03: compile-time error
+ static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- static int n() => 42; // //# 01: compile-time error
+ static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
int get n => 43;
+ // ^
+ // [cfe] 'n' is already declared in this scope.
}
main() {
diff --git a/tests/language_2/regress_33235_09_runtime_test.dart b/tests/language_2/regress_33235_09_runtime_test.dart
new file mode 100644
index 0000000..4d9123d
--- /dev/null
+++ b/tests/language_2/regress_33235_09_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class A {
+ int n() => 43;
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ int n() => 43;
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_09_test.dart b/tests/language_2/regress_33235_09_test.dart
index b9cff42..4e17aa0 100644
--- a/tests/language_2/regress_33235_09_test.dart
+++ b/tests/language_2/regress_33235_09_test.dart
@@ -11,17 +11,27 @@
}
class B extends A {
- static int n() => 42; // //# 02: compile-time error
+ static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- static int n() => 42; // //# 03: compile-time error
+ static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- static int n() => 42; // //# 01: compile-time error
+ static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
int n() => 43;
+ // ^
+ // [cfe] 'n' is already declared in this scope.
}
main() {
diff --git a/tests/language_2/regress_33235_10_runtime_test.dart b/tests/language_2/regress_33235_10_runtime_test.dart
new file mode 100644
index 0000000..1100c43
--- /dev/null
+++ b/tests/language_2/regress_33235_10_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class A {
+ void set n(int i) {}
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ void set n(int i) {}
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_10_test.dart b/tests/language_2/regress_33235_10_test.dart
index 0aa1514..cdb84e5 100644
--- a/tests/language_2/regress_33235_10_test.dart
+++ b/tests/language_2/regress_33235_10_test.dart
@@ -11,15 +11,24 @@
}
class B extends A {
- static int n() => 42; // //# 02: compile-time error
+ static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- static int n() => 42; // //# 03: compile-time error
+ static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- static int n() => 42; // //# 01: compile-time error
+ static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] This static member conflicts with an instance member.
void set n(int i) {}
}
diff --git a/tests/language_2/regress_33235_11_runtime_test.dart b/tests/language_2/regress_33235_11_runtime_test.dart
new file mode 100644
index 0000000..56e2636
--- /dev/null
+++ b/tests/language_2/regress_33235_11_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class C {
+
+
+ static int n() => 42;
+}
+
+main() {
+ print(C);
+}
diff --git a/tests/language_2/regress_33235_11_test.dart b/tests/language_2/regress_33235_11_test.dart
index 08d4e49..74710f4 100644
--- a/tests/language_2/regress_33235_11_test.dart
+++ b/tests/language_2/regress_33235_11_test.dart
@@ -7,9 +7,14 @@
// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
class C {
- static void set n(int i) {} // //# 01: compile-time error
+ static void set n(int i) {}
+ // ^
+ // [cfe] Conflicts with member 'n'.
static int n() => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+ // [cfe] Conflicts with setter 'n'.
}
main() {
diff --git a/tests/language_2/regress_33235_12_runtime_test.dart b/tests/language_2/regress_33235_12_runtime_test.dart
new file mode 100644
index 0000000..777a912
--- /dev/null
+++ b/tests/language_2/regress_33235_12_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class A {
+ int get n => 42;
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ int get n => 42;
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_12_test.dart b/tests/language_2/regress_33235_12_test.dart
index b8e2ec3..c867285 100644
--- a/tests/language_2/regress_33235_12_test.dart
+++ b/tests/language_2/regress_33235_12_test.dart
@@ -11,15 +11,24 @@
}
class B extends A {
- static void set n(int i) {} // //# 02: compile-time error
+ static void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- static void set n(int i) {} // //# 03: compile-time error
+ static void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- static void set n(int i) {} // //# 01: compile-time error
+ static void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] This static member conflicts with an instance member.
int get n => 42;
}
diff --git a/tests/language_2/regress_33235_13_runtime_test.dart b/tests/language_2/regress_33235_13_runtime_test.dart
new file mode 100644
index 0000000..d5bd071
--- /dev/null
+++ b/tests/language_2/regress_33235_13_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class A {
+ int n() => 42;
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ int n() => 42;
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_13_test.dart b/tests/language_2/regress_33235_13_test.dart
index 13a0c35..9369c01 100644
--- a/tests/language_2/regress_33235_13_test.dart
+++ b/tests/language_2/regress_33235_13_test.dart
@@ -11,15 +11,24 @@
}
class B extends A {
- static void set n(int i) {} // //# 02: compile-time error
+ static void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- static void set n(int i) {} // //# 03: compile-time error
+ static void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- static void set n(int i) {} // //# 01: compile-time error
+ static void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] This static member conflicts with an instance member.
int n() => 42;
}
diff --git a/tests/language_2/regress_33235_14_runtime_test.dart b/tests/language_2/regress_33235_14_runtime_test.dart
new file mode 100644
index 0000000..587dece
--- /dev/null
+++ b/tests/language_2/regress_33235_14_runtime_test.dart
@@ -0,0 +1,33 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+class A {
+ void set n(int x) {}
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ void set n(int x) {}
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_14_test.dart b/tests/language_2/regress_33235_14_test.dart
index 0ba2cba..0e9595e 100644
--- a/tests/language_2/regress_33235_14_test.dart
+++ b/tests/language_2/regress_33235_14_test.dart
@@ -10,17 +10,27 @@
}
class B extends A {
- static void set n(int i) {} // //# 02: compile-time error
+ static void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- static void set n(int i) {} // //# 03: compile-time error
+ static void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- static void set n(int i) {} // //# 01: compile-time error
+ static void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
void set n(int x) {}
+ // ^
+ // [cfe] 'n' is already declared in this scope.
}
main() {
diff --git a/tests/language_2/regress_33235_15_runtime_test.dart b/tests/language_2/regress_33235_15_runtime_test.dart
new file mode 100644
index 0000000..4d9123d
--- /dev/null
+++ b/tests/language_2/regress_33235_15_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class A {
+ int n() => 43;
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ int n() => 43;
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_15_test.dart b/tests/language_2/regress_33235_15_test.dart
index 6264201..0e4eb85 100644
--- a/tests/language_2/regress_33235_15_test.dart
+++ b/tests/language_2/regress_33235_15_test.dart
@@ -11,17 +11,26 @@
}
class B extends A {
- int get n => 42; // //# 02: compile-time error
+ int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_FIELD_AND_METHOD
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- int get n => 42; // //# 03: compile-time error
+ int get n => 42;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_FIELD_AND_METHOD
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- int get n => 42; // //# 01: compile-time error
+ int get n => 42;
int n() => 43;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+ // [cfe] 'n' is already declared in this scope.
}
main() {
diff --git a/tests/language_2/regress_33235_16_runtime_test.dart b/tests/language_2/regress_33235_16_runtime_test.dart
new file mode 100644
index 0000000..4d9123d
--- /dev/null
+++ b/tests/language_2/regress_33235_16_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+// Test for complience with tables at
+// https://github.com/dart-lang/sdk/issues/33235#issue-326617285
+// Files 01 to 16 should be compile time errors, files 17 to 21 should not.
+
+class A {
+ int n() => 43;
+}
+
+class B extends A {
+
+}
+
+abstract class B2 implements A {
+
+}
+
+class C {
+
+
+ int n() => 43;
+}
+
+main() {
+ print(C);
+ print(B);
+ print(B2);
+}
diff --git a/tests/language_2/regress_33235_16_test.dart b/tests/language_2/regress_33235_16_test.dart
index d3d5c05..cd51ee4 100644
--- a/tests/language_2/regress_33235_16_test.dart
+++ b/tests/language_2/regress_33235_16_test.dart
@@ -11,17 +11,26 @@
}
class B extends A {
- void set n(int i) {} // //# 02: compile-time error
+ void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_FIELD_AND_METHOD
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
abstract class B2 implements A {
- void set n(int i) {} // //# 03: compile-time error
+ void set n(int i) {}
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONFLICTING_FIELD_AND_METHOD
+ // [cfe] Can't declare a member that conflicts with an inherited one.
}
class C {
- void set n(int i) {} // //# 01: compile-time error
+ void set n(int i) {}
int n() => 43;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+ // [cfe] 'n' is already declared in this scope.
}
main() {
diff --git a/tests/language_2/regress_33479_runtime_test.dart b/tests/language_2/regress_33479_runtime_test.dart
new file mode 100644
index 0000000..c6f47a2
--- /dev/null
+++ b/tests/language_2/regress_33479_runtime_test.dart
@@ -0,0 +1,12 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+class Hest<TypeX extends Fisk> {}
+
+typedef Fisk = void Function // don't merge lines
+
+ ();
+
+main() {
+ Hest hest = new Hest();
+}
diff --git a/tests/language_2/regress_33479_test.dart b/tests/language_2/regress_33479_test.dart
index 80515ff3..b1225c3 100644
--- a/tests/language_2/regress_33479_test.dart
+++ b/tests/language_2/regress_33479_test.dart
@@ -1,9 +1,28 @@
class Hest<TypeX extends Fisk> {}
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.GENERIC_FUNCTION_TYPE_CANNOT_BE_BOUND
typedef Fisk = void Function // don't merge lines
- <TypeY extends Hest> //# 01: compile-time error
+// [error line 5, column 1, length 462]
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
+// ^
+// [cfe] Generic type 'Fisk' can't be used without type arguments in the bounds of its own type variables. It is referenced indirectly through 'Hest'.
+ <TypeY extends Hest>
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.GENERIC_FUNCTION_TYPE_CANNOT_BE_TYPE_ARGUMENT
();
main() {
Hest hest = new Hest();
+//^^^^
+// [analyzer] COMPILE_TIME_ERROR.GENERIC_FUNCTION_TYPE_CANNOT_BE_TYPE_ARGUMENT
+// ^
+// [cfe] A generic function type can't be used as a type argument.
+// ^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_NEW_EXPR
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
+// [cfe] Generic function type 'void Function<TypeY>()' inferred as a type argument.
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
diff --git a/tests/language_2/regress_35258_runtime_test.dart b/tests/language_2/regress_35258_runtime_test.dart
new file mode 100644
index 0000000..480fd21
--- /dev/null
+++ b/tests/language_2/regress_35258_runtime_test.dart
@@ -0,0 +1,17 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+main() {
+ new C(42);
+}
+
+class C {
+ final d;
+
+
+ C(this.d) {}
+}
diff --git a/tests/language_2/regress_35258_test.dart b/tests/language_2/regress_35258_test.dart
index d875985..e9a014f 100644
--- a/tests/language_2/regress_35258_test.dart
+++ b/tests/language_2/regress_35258_test.dart
@@ -4,11 +4,22 @@
main() {
new C(42);
+ // ^
+ // [cfe] Can't use 'C' because it is declared more than once.
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
}
class C {
final d;
+ // ^
+ // [cfe] Final field 'd' is not initialized.
- C() {} //# 01: compile-time error
+ C() {}
+//^
+// [analyzer] STATIC_WARNING.FINAL_NOT_INITIALIZED_CONSTRUCTOR
C(this.d) {}
+//^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_CONSTRUCTOR_DEFAULT
+// [cfe] 'C' is already declared in this scope.
}
diff --git a/tests/language_2/regress_35259_runtime_test.dart b/tests/language_2/regress_35259_runtime_test.dart
new file mode 100644
index 0000000..cabe50a
--- /dev/null
+++ b/tests/language_2/regress_35259_runtime_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Supertype {
+
+
+}
+
+main() {
+ print(new Supertype());
+}
diff --git a/tests/language_2/regress_35259_test.dart b/tests/language_2/regress_35259_test.dart
index 145a28e..cfc3121 100644
--- a/tests/language_2/regress_35259_test.dart
+++ b/tests/language_2/regress_35259_test.dart
@@ -3,10 +3,26 @@
// BSD-style license that can be found in the LICENSE file.
class Supertype {
- factory Supertype() = Unresolved; //# 01: compile-time error
- factory Supertype() = Unresolved; //# 01: compile-time error
+ factory Supertype() = Unresolved;
+ // ^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_NON_CLASS
+ // [cfe] Couldn't find constructor 'Unresolved'.
+ // ^
+ // [cfe] Redirection constructor target not found: 'Unresolved'
+ factory Supertype() = Unresolved;
+//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_CONSTRUCTOR_DEFAULT
+// ^
+// [cfe] 'Supertype' is already declared in this scope.
+// ^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_NON_CLASS
+// [cfe] Couldn't find constructor 'Unresolved'.
+// ^
+// [cfe] Redirection constructor target not found: 'Unresolved'
}
main() {
print(new Supertype());
+ // ^
+ // [cfe] Can't use 'Supertype' because it is declared more than once.
}
diff --git a/tests/language_2/regress_35260_runtime_test.dart b/tests/language_2/regress_35260_runtime_test.dart
new file mode 100644
index 0000000..c15938c
--- /dev/null
+++ b/tests/language_2/regress_35260_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class Supertype {
+ factory Supertype() = X;
+
+}
+
+class X implements Supertype {
+ X();
+}
+
+main() {
+ X x = new Supertype();
+}
diff --git a/tests/language_2/regress_35260_test.dart b/tests/language_2/regress_35260_test.dart
index a5853ef..113bb7b 100644
--- a/tests/language_2/regress_35260_test.dart
+++ b/tests/language_2/regress_35260_test.dart
@@ -4,7 +4,11 @@
class Supertype {
factory Supertype() = X;
- factory Supertype() = X; //# 01: compile-time error
+ factory Supertype() = X;
+//^^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_CONSTRUCTOR_DEFAULT
+// ^
+// [cfe] 'Supertype' is already declared in this scope.
}
class X implements Supertype {
@@ -13,4 +17,6 @@
main() {
X x = new Supertype();
+ // ^
+ // [cfe] Can't use 'Supertype' because it is declared more than once.
}
diff --git a/tests/language_2/regress_35266_runtime_test.dart b/tests/language_2/regress_35266_runtime_test.dart
new file mode 100644
index 0000000..00ff9ca
--- /dev/null
+++ b/tests/language_2/regress_35266_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+class B<T> extends C<T> {
+ B();
+ factory B.foo() = B<T>;
+
+}
+
+class C<K> {
+ C();
+ factory C.bar() = B<K>.foo;
+}
+
+main() {
+ new C.bar();
+}
diff --git a/tests/language_2/regress_35266_test.dart b/tests/language_2/regress_35266_test.dart
index 3d82833..7c6a312 100644
--- a/tests/language_2/regress_35266_test.dart
+++ b/tests/language_2/regress_35266_test.dart
@@ -5,12 +5,18 @@
class B<T> extends C<T> {
B();
factory B.foo() = B<T>;
- factory B.foo() = B<T>; //# 01: compile-time error
+ factory B.foo() = B<T>;
+//^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_CONSTRUCTOR_NAME
+// ^
+// [cfe] 'B.foo' is already declared in this scope.
}
class C<K> {
C();
factory C.bar() = B<K>.foo;
+ // ^
+ // [cfe] Can't use 'B.foo' because it is declared more than once.
}
main() {
diff --git a/tests/language_2/reify_typevar_static_runtime_1_test.dart b/tests/language_2/reify_typevar_static_runtime_1_test.dart
new file mode 100644
index 0000000..d2f11b2
--- /dev/null
+++ b/tests/language_2/reify_typevar_static_runtime_1_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class C<T> {
+ final x;
+ C([this.x]);
+
+ static staticFunction(bool b) =>
+
+ null;
+ factory C.factoryConstructor(bool b) => new C(
+ b ? T :
+ null);
+ C.redirectingConstructor(bool b) : this(
+
+ null);
+ C.ordinaryConstructor(bool b)
+ : x =
+
+ null;
+}
+
+main() {
+ Expect.equals(null, C.staticFunction(false));
+ Expect.equals(null, new C.factoryConstructor(false).x);
+ Expect.equals(null, new C.redirectingConstructor(false).x);
+ Expect.equals(null, new C.ordinaryConstructor(false).x);
+}
diff --git a/tests/language_2/reify_typevar_static_runtime_2_test.dart b/tests/language_2/reify_typevar_static_runtime_2_test.dart
new file mode 100644
index 0000000..568cc93
--- /dev/null
+++ b/tests/language_2/reify_typevar_static_runtime_2_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class C<T> {
+ final x;
+ C([this.x]);
+
+ static staticFunction(bool b) =>
+
+ null;
+ factory C.factoryConstructor(bool b) => new C(
+
+ null);
+ C.redirectingConstructor(bool b) : this(
+ b ? T :
+ null);
+ C.ordinaryConstructor(bool b)
+ : x =
+
+ null;
+}
+
+main() {
+ Expect.equals(null, C.staticFunction(false));
+ Expect.equals(null, new C.factoryConstructor(false).x);
+ Expect.equals(null, new C.redirectingConstructor(false).x);
+ Expect.equals(null, new C.ordinaryConstructor(false).x);
+}
diff --git a/tests/language_2/reify_typevar_static_runtime_3_test.dart b/tests/language_2/reify_typevar_static_runtime_3_test.dart
new file mode 100644
index 0000000..712db2ef
--- /dev/null
+++ b/tests/language_2/reify_typevar_static_runtime_3_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class C<T> {
+ final x;
+ C([this.x]);
+
+ static staticFunction(bool b) =>
+
+ null;
+ factory C.factoryConstructor(bool b) => new C(
+
+ null);
+ C.redirectingConstructor(bool b) : this(
+
+ null);
+ C.ordinaryConstructor(bool b)
+ : x =
+ b ? T :
+ null;
+}
+
+main() {
+ Expect.equals(null, C.staticFunction(false));
+ Expect.equals(null, new C.factoryConstructor(false).x);
+ Expect.equals(null, new C.redirectingConstructor(false).x);
+ Expect.equals(null, new C.ordinaryConstructor(false).x);
+}
diff --git a/tests/language_2/reify_typevar_static_runtime_test.dart b/tests/language_2/reify_typevar_static_runtime_test.dart
new file mode 100644
index 0000000..02131f0
--- /dev/null
+++ b/tests/language_2/reify_typevar_static_runtime_test.dart
@@ -0,0 +1,34 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class C<T> {
+ final x;
+ C([this.x]);
+
+ static staticFunction(bool b) =>
+
+ null;
+ factory C.factoryConstructor(bool b) => new C(
+
+ null);
+ C.redirectingConstructor(bool b) : this(
+
+ null);
+ C.ordinaryConstructor(bool b)
+ : x =
+
+ null;
+}
+
+main() {
+ Expect.equals(null, C.staticFunction(false));
+ Expect.equals(null, new C.factoryConstructor(false).x);
+ Expect.equals(null, new C.redirectingConstructor(false).x);
+ Expect.equals(null, new C.ordinaryConstructor(false).x);
+}
diff --git a/tests/language_2/reify_typevar_static_test.dart b/tests/language_2/reify_typevar_static_test.dart
index 9fe3680..b3c502b 100644
--- a/tests/language_2/reify_typevar_static_test.dart
+++ b/tests/language_2/reify_typevar_static_test.dart
@@ -9,17 +9,20 @@
C([this.x]);
static staticFunction(bool b) =>
- b ? T : // //# 00: compile-time error
+ b ? T :
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
+ // [cfe] Type variables can't be used in static members.
null;
factory C.factoryConstructor(bool b) => new C(
- b ? T : // //# 01: ok
+ b ? T :
null);
C.redirectingConstructor(bool b) : this(
- b ? T : // //# 02: ok
+ b ? T :
null);
C.ordinaryConstructor(bool b)
: x =
- b ? T : // //# 03: ok
+ b ? T :
null;
}
diff --git a/tests/language_2/rewrite_implicit_this_runtime_test.dart b/tests/language_2/rewrite_implicit_this_runtime_test.dart
new file mode 100644
index 0000000..7fd2b78
--- /dev/null
+++ b/tests/language_2/rewrite_implicit_this_runtime_test.dart
@@ -0,0 +1,111 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+String toplevel = 'A';
+
+class Foo {
+ String x = 'x';
+
+ easy(z) {
+
+ }
+
+ // Shadow the 'y' field in various ways
+ shadow_y_parameter(y) {
+
+ }
+
+ shadow_y_local(z) {
+ var y = z;
+
+ }
+
+ shadow_y_capturedLocal(z) {
+ var y = z;
+ foo() {
+
+ }
+ return foo();
+ }
+
+ shadow_y_closureParam(z) {
+ foo(y) {
+
+ }
+ return foo(z);
+ }
+
+ shadow_y_localInsideClosure(z) {
+ foo() {
+ var y = z;
+
+ }
+
+ return foo();
+ }
+
+ // Shadow the 'x' field in various ways
+ shadow_x_parameter(x) {
+
+ }
+
+ shadow_x_local(z) {
+ var x = z;
+
+ }
+
+ shadow_x_capturedLocal(z) {
+ var x = z;
+ foo() {
+
+ }
+ return foo();
+ }
+
+ shadow_x_closureParam(z) {
+ foo(x) {
+
+ }
+ return foo(z);
+ }
+
+ shadow_x_localInsideClosure(z) {
+ foo() {
+ var x = z;
+
+ }
+
+ return foo();
+ }
+
+ shadow_x_toplevel() {
+
+ }
+}
+
+class Sub extends Foo {
+ String y = 'y';
+ String toplevel = 'B';
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/rewrite_implicit_this_test.dart b/tests/language_2/rewrite_implicit_this_test.dart
index 90600b2..e0e4c41 100644
--- a/tests/language_2/rewrite_implicit_this_test.dart
+++ b/tests/language_2/rewrite_implicit_this_test.dart
@@ -10,30 +10,45 @@
String x = 'x';
easy(z) {
- return x + y + z; //# 01: compile-time error
+ return x + y + z;
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
// Shadow the 'y' field in various ways
shadow_y_parameter(y) {
- return x + this.y + y; //# 01: continued
+ return x + this.y + y;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
shadow_y_local(z) {
var y = z;
- return x + this.y + y; //# 01: continued
+ return x + this.y + y;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
shadow_y_capturedLocal(z) {
var y = z;
foo() {
- return x + this.y + y; //# 01: continued
+ return x + this.y + y;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
return foo();
}
shadow_y_closureParam(z) {
foo(y) {
- return x + this.y + y; //# 01: continued
+ return x + this.y + y;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
return foo(z);
}
@@ -41,7 +56,10 @@
shadow_y_localInsideClosure(z) {
foo() {
var y = z;
- return x + this.y + y; //# 01: continued
+ return x + this.y + y;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
return foo();
@@ -49,25 +67,37 @@
// Shadow the 'x' field in various ways
shadow_x_parameter(x) {
- return this.x + y + x; //# 01: continued
+ return this.x + y + x;
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
shadow_x_local(z) {
var x = z;
- return this.x + y + x; //# 01: continued
+ return this.x + y + x;
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
shadow_x_capturedLocal(z) {
var x = z;
foo() {
- return this.x + y + x; //# 01: continued
+ return this.x + y + x;
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
return foo();
}
shadow_x_closureParam(z) {
foo(x) {
- return this.x + y + x; //# 01: continued
+ return this.x + y + x;
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
return foo(z);
}
@@ -75,14 +105,23 @@
shadow_x_localInsideClosure(z) {
foo() {
var x = z;
- return this.x + y + x; //# 01: continued
+ return this.x + y + x;
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
}
return foo();
}
shadow_x_toplevel() {
- return x + this.y + toplevel + this.toplevel; //# 01: continued
+ return x + this.y + toplevel + this.toplevel;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'y' isn't defined for the class 'Foo'.
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'toplevel' isn't defined for the class 'Foo'.
}
}
@@ -92,17 +131,17 @@
}
main() {
- Expect.equals('xyz', new Sub().easy('z')); //# 01: continued
- Expect.equals('xyz', new Sub().shadow_y_parameter('z')); //# 01: continued
- Expect.equals('xyz', new Sub().shadow_y_local('z')); //# 01: continued
- Expect.equals('xyz', new Sub().shadow_y_capturedLocal('z')); //# 01: continued
- Expect.equals('xyz', new Sub().shadow_y_closureParam('z')); //# 01: continued
- Expect.equals('xyz', new Sub().shadow_y_localInsideClosure('z')); //# 01: continued
- Expect.equals('xyz', new Sub().shadow_x_parameter('z')); //# 01: continued
- Expect.equals('xyz', new Sub().shadow_x_local('z')); //# 01: continued
- Expect.equals('xyz', new Sub().shadow_x_capturedLocal('z')); //# 01: continued
- Expect.equals('xyz', new Sub().shadow_x_closureParam('z')); //# 01: continued
- Expect.equals('xyz', new Sub().shadow_x_localInsideClosure('z')); //# 01: continued
+ Expect.equals('xyz', new Sub().easy('z'));
+ Expect.equals('xyz', new Sub().shadow_y_parameter('z'));
+ Expect.equals('xyz', new Sub().shadow_y_local('z'));
+ Expect.equals('xyz', new Sub().shadow_y_capturedLocal('z'));
+ Expect.equals('xyz', new Sub().shadow_y_closureParam('z'));
+ Expect.equals('xyz', new Sub().shadow_y_localInsideClosure('z'));
+ Expect.equals('xyz', new Sub().shadow_x_parameter('z'));
+ Expect.equals('xyz', new Sub().shadow_x_local('z'));
+ Expect.equals('xyz', new Sub().shadow_x_capturedLocal('z'));
+ Expect.equals('xyz', new Sub().shadow_x_closureParam('z'));
+ Expect.equals('xyz', new Sub().shadow_x_localInsideClosure('z'));
- Expect.equals('xyAB', new Sub().shadow_x_toplevel()); //# 01: continued
+ Expect.equals('xyAB', new Sub().shadow_x_toplevel());
}
diff --git a/tests/language_2/scope_variable_runtime_test.dart b/tests/language_2/scope_variable_runtime_test.dart
new file mode 100644
index 0000000..75a5c31
--- /dev/null
+++ b/tests/language_2/scope_variable_runtime_test.dart
@@ -0,0 +1,50 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+void testSimpleScope() {
+ {
+ var a = "Test";
+ int b = 1;
+ }
+ {
+ var c;
+ int d;
+ Expect.isNull(c);
+ Expect.isNull(d);
+ }
+}
+
+void testShadowingScope() {
+ var a = "Test";
+ {
+ var a;
+ Expect.isNull(a);
+ a = "a";
+ Expect.equals(a, "a");
+ }
+ Expect.equals(a, "Test");
+}
+
+int testShadowingAfterUse() {
+ var a = 1;
+ {
+ var b = 2;
+ var c = a; // Use of 'a' prior to its shadow declaration below.
+ var d = b + c;
+ // Shadow declaration of 'a'.
+
+ return d + a;
+ }
+}
+
+main() {
+ testSimpleScope();
+ testShadowingScope();
+ testShadowingAfterUse();
+}
diff --git a/tests/language_2/scope_variable_test.dart b/tests/language_2/scope_variable_test.dart
index 52c4b8d..14576a6 100644
--- a/tests/language_2/scope_variable_test.dart
+++ b/tests/language_2/scope_variable_test.dart
@@ -33,9 +33,13 @@
{
var b = 2;
var c = a; // Use of 'a' prior to its shadow declaration below.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.REFERENCED_BEFORE_DECLARATION
var d = b + c;
// Shadow declaration of 'a'.
- var a = 5; //# 01: compile-time error
+ var a = 5;
+ // ^
+ // [cfe] Can't declare 'a' because it was already used in this scope.
return d + a;
}
}
diff --git a/tests/language_2/setter3_runtime_test.dart b/tests/language_2/setter3_runtime_test.dart
new file mode 100644
index 0000000..42d3d74
--- /dev/null
+++ b/tests/language_2/setter3_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// Test that setters cannot have defined, non-void return types.
+// Note: The language specification specifies the absence of a type means
+// it is dynamic, however you cannot specify dynamic.
+
+class A {
+ set foo(x) {}
+ void set bar(x) {}
+
+
+}
+
+main() {
+ new A();
+}
diff --git a/tests/language_2/setter3_test.dart b/tests/language_2/setter3_test.dart
index 9033421..916a807 100644
--- a/tests/language_2/setter3_test.dart
+++ b/tests/language_2/setter3_test.dart
@@ -9,8 +9,12 @@
class A {
set foo(x) {}
void set bar(x) {}
- dynamic set baz(x) {} //# 01: static type warning
- bool set bob(x) {} //# 02: static type warning
+ dynamic set baz(x) {}
+//^^^^^^^
+// [analyzer] STATIC_WARNING.NON_VOID_RETURN_FOR_SETTER
+ bool set bob(x) {}
+//^^^^
+// [analyzer] STATIC_WARNING.NON_VOID_RETURN_FOR_SETTER
}
main() {
diff --git a/tests/language_2/setter_no_getter_call_runtime_test.dart b/tests/language_2/setter_no_getter_call_runtime_test.dart
new file mode 100644
index 0000000..d243de3
--- /dev/null
+++ b/tests/language_2/setter_no_getter_call_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+var topLevelClosure;
+
+
+get topLevel => topLevelClosure;
+
+set topLevel(var value) {}
+
+initialize() {
+ print("initializing");
+ topLevelClosure = (x) => x * 2;
+}
+
+main() {
+ initialize();
+ var x = topLevelClosure(2);
+ Expect.equals(4, x);
+
+ x = topLevel(3);
+ Expect.equals(6, x);
+}
diff --git a/tests/language_2/setter_no_getter_call_test.dart b/tests/language_2/setter_no_getter_call_test.dart
index 81adc5d..77b06dc 100644
--- a/tests/language_2/setter_no_getter_call_test.dart
+++ b/tests/language_2/setter_no_getter_call_test.dart
@@ -6,9 +6,9 @@
var topLevelClosure;
-/* //# 01: compile-time error
+/*
get topLevel => topLevelClosure;
-*/ //# 01: continued
+*/
set topLevel(var value) {}
initialize() {
@@ -22,5 +22,8 @@
Expect.equals(4, x);
x = topLevel(3);
+ // ^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_FUNCTION
+ // [cfe] Getter not found: 'topLevel'.
Expect.equals(6, x);
}
diff --git a/tests/language_2/static_field1_runtime_test.dart b/tests/language_2/static_field1_runtime_test.dart
new file mode 100644
index 0000000..6db193e
--- /dev/null
+++ b/tests/language_2/static_field1_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Test that a static field cannot be read as an instance field.
+
+class Foo {
+ Foo() {}
+ static var x;
+}
+
+class StaticField1Test {
+ static testMain() {
+ if (false) {
+ var foo = new Foo();
+
+ }
+ }
+}
+
+main() {
+ StaticField1Test.testMain();
+}
diff --git a/tests/language_2/static_field1_test.dart b/tests/language_2/static_field1_test.dart
index 1a971ee..e4e1472 100644
--- a/tests/language_2/static_field1_test.dart
+++ b/tests/language_2/static_field1_test.dart
@@ -12,7 +12,10 @@
static testMain() {
if (false) {
var foo = new Foo();
- var x = foo.x; //# 01: compile-time error
+ var x = foo.x;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INSTANCE_ACCESS_TO_STATIC_MEMBER
+ // [cfe] The getter 'x' isn't defined for the class 'Foo'.
}
}
}
diff --git a/tests/language_2/static_field1a_runtime_test.dart b/tests/language_2/static_field1a_runtime_test.dart
new file mode 100644
index 0000000..1f6b798
--- /dev/null
+++ b/tests/language_2/static_field1a_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Test that a static method cannot be read as an instance field.
+
+class Foo {
+ Foo() {}
+ static void m() {}
+}
+
+class StaticField1aTest {
+ static testMain() {
+ if (false) {
+ var foo = new Foo();
+
+ }
+ }
+}
+
+main() {
+ StaticField1aTest.testMain();
+}
diff --git a/tests/language_2/static_field1a_test.dart b/tests/language_2/static_field1a_test.dart
index fb6bf6f..9d7f2f2 100644
--- a/tests/language_2/static_field1a_test.dart
+++ b/tests/language_2/static_field1a_test.dart
@@ -12,7 +12,10 @@
static testMain() {
if (false) {
var foo = new Foo();
- var m = foo.m; //# 01: compile-time error
+ var m = foo.m;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INSTANCE_ACCESS_TO_STATIC_MEMBER
+ // [cfe] The getter 'm' isn't defined for the class 'Foo'.
}
}
}
diff --git a/tests/language_2/static_field3_runtime_test.dart b/tests/language_2/static_field3_runtime_test.dart
new file mode 100644
index 0000000..d2c9f3a
--- /dev/null
+++ b/tests/language_2/static_field3_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Test that an instance field cannot be read as a static field.
+
+class Foo {
+ Foo() {}
+ var x;
+ void m() {}
+}
+
+main() {
+ if (false) {
+
+
+
+
+ }
+}
diff --git a/tests/language_2/static_field3_test.dart b/tests/language_2/static_field3_test.dart
index b8832dc..7436df1 100644
--- a/tests/language_2/static_field3_test.dart
+++ b/tests/language_2/static_field3_test.dart
@@ -11,9 +11,21 @@
main() {
if (false) {
- var x = Foo.x; // //# 01: compile-time error
- var m = Foo.m; // //# 02: compile-time error
- Foo.m = 1; // //# 03: compile-time error
- Foo.x = 1; // //# 04: compile-time error
+ var x = Foo.x;
+ // ^
+ // [analyzer] STATIC_WARNING.STATIC_ACCESS_TO_INSTANCE_MEMBER
+ // [cfe] Getter not found: 'x'.
+ var m = Foo.m;
+ // ^
+ // [analyzer] STATIC_WARNING.STATIC_ACCESS_TO_INSTANCE_MEMBER
+ // [cfe] Getter not found: 'm'.
+ Foo.m = 1;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_SETTER
+ // [cfe] Setter not found: 'm'.
+ Foo.x = 1;
+ // ^
+ // [analyzer] STATIC_WARNING.STATIC_ACCESS_TO_INSTANCE_MEMBER
+ // [cfe] Setter not found: 'x'.
}
}
diff --git a/tests/language_2/static_final_field2_runtime_test.dart b/tests/language_2/static_final_field2_runtime_test.dart
new file mode 100644
index 0000000..b69448d
--- /dev/null
+++ b/tests/language_2/static_final_field2_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Disallow re-assignment of a final static variable.
+
+class A {
+ static const x = 1;
+}
+
+class B {
+ const B() : n = 5;
+ final n;
+
+ static const b = 3 + 5;
+}
+
+main() {
+
+ new B();
+ print(B.b);
+
+}
diff --git a/tests/language_2/static_final_field2_test.dart b/tests/language_2/static_final_field2_test.dart
index 533dbc9..76f5174 100644
--- a/tests/language_2/static_final_field2_test.dart
+++ b/tests/language_2/static_final_field2_test.dart
@@ -9,14 +9,23 @@
class B {
const B() : n = 5;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_NOT_INITIALIZED
final n;
- static const a; // //# 02: syntax error
+ static const a;
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_NOT_INITIALIZED
+ // [cfe] The const variable 'a' must be initialized.
static const b = 3 + 5;
}
main() {
- A.x = 2; // //# 01: compile-time error
+ A.x = 2;
+//^^^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_CONST
+// ^
+// [cfe] Setter not found: 'x'.
new B();
print(B.b);
- print(B.a); // //# 02: continued
+ print(B.a);
}
diff --git a/tests/language_2/static_getter_no_setter1_runtime_test.dart b/tests/language_2/static_getter_no_setter1_runtime_test.dart
new file mode 100644
index 0000000..13567db
--- /dev/null
+++ b/tests/language_2/static_getter_no_setter1_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+
+class Class {
+ static int get getter => 0;
+
+ method() {
+
+ }
+}
+
+main() {
+ new Class().method();
+}
diff --git a/tests/language_2/static_getter_no_setter1_test.dart b/tests/language_2/static_getter_no_setter1_test.dart
index 8b2a420..a173b2f 100644
--- a/tests/language_2/static_getter_no_setter1_test.dart
+++ b/tests/language_2/static_getter_no_setter1_test.dart
@@ -8,10 +8,13 @@
static int get getter => 0;
method() {
- getter++; //# 01: compile-time error
+ getter++;
+// ^^^^^^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_NO_SETTER
+// [cfe] Setter not found: 'getter'.
}
}
main() {
new Class().method();
-}
\ No newline at end of file
+}
diff --git a/tests/language_2/static_getter_no_setter2_runtime_test.dart b/tests/language_2/static_getter_no_setter2_runtime_test.dart
new file mode 100644
index 0000000..82663cb
--- /dev/null
+++ b/tests/language_2/static_getter_no_setter2_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+
+class Class {
+ static int get getter => 0;
+
+ method() {
+
+ }
+
+ noSuchMethod(i) => 42;
+}
+
+main() {
+ new Class().method();
+}
diff --git a/tests/language_2/static_getter_no_setter2_test.dart b/tests/language_2/static_getter_no_setter2_test.dart
index 3cb58cf..d10cedb 100644
--- a/tests/language_2/static_getter_no_setter2_test.dart
+++ b/tests/language_2/static_getter_no_setter2_test.dart
@@ -8,7 +8,10 @@
static int get getter => 0;
method() {
- getter++; //# 01: compile-time error
+ getter++;
+// ^^^^^^
+// [analyzer] STATIC_WARNING.ASSIGNMENT_TO_FINAL_NO_SETTER
+// [cfe] Setter not found: 'getter'.
}
noSuchMethod(i) => 42;
@@ -16,4 +19,4 @@
main() {
new Class().method();
-}
\ No newline at end of file
+}
diff --git a/tests/language_2/static_setter_get_runtime_test.dart b/tests/language_2/static_setter_get_runtime_test.dart
new file mode 100644
index 0000000..b04380c
--- /dev/null
+++ b/tests/language_2/static_setter_get_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+
+class Class {
+ static set o(_) {}
+
+ noSuchMethod(_) => 42;
+}
+
+main() {
+
+}
diff --git a/tests/language_2/static_setter_get_test.dart b/tests/language_2/static_setter_get_test.dart
index 9c187e6..44796cc 100644
--- a/tests/language_2/static_setter_get_test.dart
+++ b/tests/language_2/static_setter_get_test.dart
@@ -6,10 +6,13 @@
class Class {
static set o(_) {}
- m() => o; //# 01: compile-time error
+ m() => o;
+ // ^
+ // [analyzer] STATIC_WARNING.UNDEFINED_IDENTIFIER
+ // [cfe] Getter not found: 'o'.
noSuchMethod(_) => 42;
}
main() {
- Expect.throws(() => new Class().m()); //# 01: continued
+ Expect.throws(() => new Class().m());
}
diff --git a/tests/language_2/static_top_level_runtime_test.dart b/tests/language_2/static_top_level_runtime_test.dart
new file mode 100644
index 0000000..0c0b8ce
--- /dev/null
+++ b/tests/language_2/static_top_level_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+
+
+
+
+
+
+
+
+
+
+void main() {}
diff --git a/tests/language_2/static_top_level_test.dart b/tests/language_2/static_top_level_test.dart
index dee2199..c2f45b3 100644
--- a/tests/language_2/static_top_level_test.dart
+++ b/tests/language_2/static_top_level_test.dart
@@ -2,14 +2,38 @@
// 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.
-static method() { } // //# 00: syntax error
-static var field; // //# 01: syntax error
-static const finalField = 42; // //# 02: syntax error
-static const constant = 123; // //# 03: syntax error
+static method() { }
+// [error line 5, column 1, length 6]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'static' here.
+static var field;
+// [error line 9, column 1, length 6]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'static' here.
+static const finalField = 42;
+// [error line 13, column 1, length 6]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'static' here.
+static const constant = 123;
+// [error line 17, column 1, length 6]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'static' here.
-static int typedMethod() => 87; // //# 04: syntax error
-static int typedField; // //# 05: syntax error
-static const int typedFinalField = 99; //# 06: syntax error
-static const int typedConstant = 1; // //# 07: syntax error
+static int typedMethod() => 87;
+// [error line 22, column 1, length 6]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'static' here.
+static int typedField;
+// [error line 26, column 1, length 6]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'static' here.
+static const int typedFinalField = 99;
+// [error line 30, column 1, length 6]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'static' here.
+static const int typedConstant = 1;
+// [error line 34, column 1, length 6]
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'static' here.
void main() {}
diff --git a/tests/language_2/string_interpolation1_runtime_test.dart b/tests/language_2/string_interpolation1_runtime_test.dart
new file mode 100644
index 0000000..3ede1d8
--- /dev/null
+++ b/tests/language_2/string_interpolation1_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// A dollar must be followed by a "{" or an identifier.
+
+class A {
+ final String str;
+ const A(this.str);
+}
+
+class StringInterpolation1NegativeTest {
+ // Dollar not followed by "{" or identifier.
+
+ static testMain() {
+
+ }
+}
+
+main() {
+ StringInterpolation1NegativeTest.testMain();
+}
diff --git a/tests/language_2/string_interpolation1_test.dart b/tests/language_2/string_interpolation1_test.dart
index 821e7bc..7f43236 100644
--- a/tests/language_2/string_interpolation1_test.dart
+++ b/tests/language_2/string_interpolation1_test.dart
@@ -11,9 +11,16 @@
class StringInterpolation1NegativeTest {
// Dollar not followed by "{" or identifier.
- static const DOLLAR = const A("$"); //# 01: syntax error
+ static const DOLLAR = const A("$");
+ // [error line 14, column 35, length 0]
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ // [error line 14, column 35, length 0]
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
static testMain() {
- print(DOLLAR); //# 01: continued
+ print(DOLLAR);
}
}
diff --git a/tests/language_2/string_interpolation2_runtime_test.dart b/tests/language_2/string_interpolation2_runtime_test.dart
new file mode 100644
index 0000000..0b0a89f
--- /dev/null
+++ b/tests/language_2/string_interpolation2_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// A dollar must be followed by a "{" or an identifier.
+
+class StringInterpolation2NegativeTest {
+ static testMain() {
+ // Dollar followed by "/".
+
+ }
+}
+
+main() {
+ StringInterpolation2NegativeTest.testMain();
+}
diff --git a/tests/language_2/string_interpolation2_test.dart b/tests/language_2/string_interpolation2_test.dart
index a1e048c..076fcc1 100644
--- a/tests/language_2/string_interpolation2_test.dart
+++ b/tests/language_2/string_interpolation2_test.dart
@@ -7,7 +7,10 @@
class StringInterpolation2NegativeTest {
static testMain() {
// Dollar followed by "/".
- print('C;Y1;X4;K"$/Month"'); //# 01: syntax error
+ print('C;Y1;X4;K"$/Month"');
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
}
}
diff --git a/tests/language_2/string_interpolation3_runtime_test.dart b/tests/language_2/string_interpolation3_runtime_test.dart
new file mode 100644
index 0000000..96b92fb
--- /dev/null
+++ b/tests/language_2/string_interpolation3_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// A dollar must be followed by a "{" or an identifier.
+
+class StringInterpolation3NegativeTest {
+ static testMain() {
+ // Dollar followed by a number.
+
+ }
+}
+
+main() {
+ StringInterpolation3NegativeTest.testMain();
+}
diff --git a/tests/language_2/string_interpolation3_test.dart b/tests/language_2/string_interpolation3_test.dart
index c58ad6a..0760fd9 100644
--- a/tests/language_2/string_interpolation3_test.dart
+++ b/tests/language_2/string_interpolation3_test.dart
@@ -7,7 +7,10 @@
class StringInterpolation3NegativeTest {
static testMain() {
// Dollar followed by a number.
- print('F;P4;F$2R'); //# 01: syntax error
+ print('F;P4;F$2R');
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
}
}
diff --git a/tests/language_2/string_interpolation4_runtime_test.dart b/tests/language_2/string_interpolation4_runtime_test.dart
new file mode 100644
index 0000000..e89625c
--- /dev/null
+++ b/tests/language_2/string_interpolation4_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// A dollar must be followed by a "{" or an identifier.
+
+class StringInterpolation4NegativeTest {
+ static testMain() {
+ // Dollar not followed by "{" or identifier.
+
+ }
+}
+
+main() {
+ StringInterpolation4NegativeTest.testMain();
+}
diff --git a/tests/language_2/string_interpolation4_test.dart b/tests/language_2/string_interpolation4_test.dart
index ab4b2e7..740dc9a 100644
--- a/tests/language_2/string_interpolation4_test.dart
+++ b/tests/language_2/string_interpolation4_test.dart
@@ -7,7 +7,10 @@
class StringInterpolation4NegativeTest {
static testMain() {
// Dollar not followed by "{" or identifier.
- print("-" + "$" + "foo"); //# 01: syntax error
+ print("-" + "$" + "foo");
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
}
}
diff --git a/tests/language_2/string_interpolation5_runtime_test.dart b/tests/language_2/string_interpolation5_runtime_test.dart
new file mode 100644
index 0000000..acbec21
--- /dev/null
+++ b/tests/language_2/string_interpolation5_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// A dollar must be followed by a "{" or an identifier.
+
+class StringInterpolation5NegativeTest {
+ static testMain() {
+ // Dollar followed by a number.
+
+ }
+}
+
+main() {
+ StringInterpolation5NegativeTest.testMain();
+}
diff --git a/tests/language_2/string_interpolation5_test.dart b/tests/language_2/string_interpolation5_test.dart
index e545012..cd04ed3 100644
--- a/tests/language_2/string_interpolation5_test.dart
+++ b/tests/language_2/string_interpolation5_test.dart
@@ -7,7 +7,10 @@
class StringInterpolation5NegativeTest {
static testMain() {
// Dollar followed by a number.
- print("$1,000"); //# 01: syntax error
+ print("$1,000");
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
}
}
diff --git a/tests/language_2/string_interpolation6_runtime_test.dart b/tests/language_2/string_interpolation6_runtime_test.dart
new file mode 100644
index 0000000..4d4d546
--- /dev/null
+++ b/tests/language_2/string_interpolation6_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+// A dollar must be followed by a "{" or an identifier.
+
+class StringInterpolation6NegativeTest {
+ static testMain() {
+ // Dollar not followed by "{" or identifier.
+ String regexp;
+
+ print(regexp);
+ }
+}
+
+main() {
+ StringInterpolation6NegativeTest.testMain();
+}
diff --git a/tests/language_2/string_interpolation6_test.dart b/tests/language_2/string_interpolation6_test.dart
index c6912c8..74cfbbe 100644
--- a/tests/language_2/string_interpolation6_test.dart
+++ b/tests/language_2/string_interpolation6_test.dart
@@ -8,7 +8,10 @@
static testMain() {
// Dollar not followed by "{" or identifier.
String regexp;
- regexp = "^(\\d\\d?)[-/](\\d\\d?)$"; //# 01: syntax error
+ regexp = "^(\\d\\d?)[-/](\\d\\d?)$";
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
print(regexp);
}
}
diff --git a/tests/language_2/string_interpolation9_runtime_test.dart b/tests/language_2/string_interpolation9_runtime_test.dart
new file mode 100644
index 0000000..3cf2bd1
--- /dev/null
+++ b/tests/language_2/string_interpolation9_runtime_test.dart
@@ -0,0 +1,38 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+//
+// Almost valid string interpolation syntax.
+
+main() {
+ var x;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ return x;
+}
diff --git a/tests/language_2/string_interpolation9_test.dart b/tests/language_2/string_interpolation9_test.dart
index 624414e..b3166b7 100644
--- a/tests/language_2/string_interpolation9_test.dart
+++ b/tests/language_2/string_interpolation9_test.dart
@@ -7,29 +7,89 @@
main() {
var x;
- x = "$"; // //# 1: syntax error
- x = "x$"; // //# 2: syntax error
- x = "$x$"; // //# 3: syntax error
- x = "$$x"; // //# 4: syntax error
- x = "$ "; // //# 5: syntax error
+ x = "$";
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = "x$";
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = "$x$";
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = "$$x";
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = "$ ";
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
- x = '$'; // //# 6: syntax error
- x = 'x$'; // //# 7: syntax error
- x = '$x$'; // //# 8: syntax error
- x = '$$x'; // //# 9: syntax error
- x = '$ '; // //# 10: syntax error
+ x = '$';
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = 'x$';
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = '$x$';
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = '$$x';
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = '$ ';
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
- x = """$"""; // //# 11: syntax error
- x = """x$"""; // //# 12: syntax error
- x = """$x$"""; // //# 13: syntax error
- x = """$$x"""; // //# 14: syntax error
- x = """$ """; // //# 15: syntax error
+ x = """$""";
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = """x$""";
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = """$x$""";
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = """$$x""";
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = """$ """;
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
- x = '''$'''; // //# 16: syntax error
- x = '''x$'''; // //# 17: syntax error
- x = '''$x$'''; // //# 18: syntax error
- x = '''$$x'''; // //# 19: syntax error
- x = '''$ '''; // //# 20: syntax error
+ x = '''$''';
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = '''x$''';
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = '''$x$''';
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = '''$$x''';
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
+ x = '''$ ''';
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] A '$' has special meaning inside a string, and must be followed by an identifier or an expression in curly braces ({}).
return x;
}
diff --git a/tests/language_2/string_interpolation_runtime_test.dart b/tests/language_2/string_interpolation_runtime_test.dart
new file mode 100644
index 0000000..81f4b45
--- /dev/null
+++ b/tests/language_2/string_interpolation_runtime_test.dart
@@ -0,0 +1,85 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+
+import "package:expect/expect.dart";
+
+// Tests for string interpolation
+class StringInterpolationTest {
+ StringInterpolationTest() {}
+
+ static void m() {}
+
+ static const int i = 1;
+ static const String a = "<hi>";
+
+ int j;
+ int k;
+
+ static testMain(bool alwaysFalse) {
+ var test = new StringInterpolationTest();
+ test.j = 3;
+ test.k = 5;
+
+ // simple string
+ Expect.equals(" hi ", " hi ");
+
+ var c1 = '1';
+ var c2 = '2';
+ var c3 = '3';
+ var c4 = '4';
+ // no chars before/after/between embedded expressions
+ Expect.equals(" 1", " ${c1}");
+ Expect.equals("1 ", "${c1} ");
+ Expect.equals("1", "${c1}");
+ Expect.equals("12", "${c1}${c2}");
+ Expect.equals("12 34", "${c1}${c2} ${c3}${c4}");
+
+ // embedding static fields
+ Expect.equals(" hi 1 ", " hi ${i} ");
+ Expect.equals(" hi <hi> ", " hi ${a} ");
+
+ // embedding method parameters
+ Expect.equals("param = 9", test.embedParams(9));
+
+ // embedding a class field
+ Expect.equals("j = 3", test.embedSingleField());
+
+ // embedding more than one (non-constant) expression
+ Expect.equals(" hi 1 <hi>", " hi ${i} ${a}");
+ Expect.equals("j = 3; k = 5", test.embedMultipleFields());
+
+ // escaping $ - doesn't start the embedded expression
+ Expect.equals("\$", "escaped \${3+2}"[12]);
+ Expect.equals("{", "escaped \${3+2}"[13]);
+ Expect.equals("3", "escaped \${3+2}"[14]);
+ Expect.equals("+", "escaped \${3+2}"[15]);
+ Expect.equals("2", "escaped \${3+2}"[16]);
+ Expect.equals("}", "escaped \${3+2}"[17]);
+
+ if (alwaysFalse) {
+
+ }
+
+ Expect.equals("${m}", "$m");
+ }
+
+ String embedParams(int z) {
+ return "param = ${z}";
+ }
+
+ String embedSingleField() {
+ return "j = ${j}";
+ }
+
+ String embedMultipleFields() {
+ return "j = ${j}; k = ${k}";
+ }
+}
+
+main() {
+ StringInterpolationTest.testMain(false);
+}
diff --git a/tests/language_2/string_interpolation_test.dart b/tests/language_2/string_interpolation_test.dart
index af3a28a..8fd6fac 100644
--- a/tests/language_2/string_interpolation_test.dart
+++ b/tests/language_2/string_interpolation_test.dart
@@ -58,7 +58,10 @@
Expect.equals("}", "escaped \${3+2}"[17]);
if (alwaysFalse) {
- "${i.toHorse()}"; //# 01: compile-time error
+ "${i.toHorse()}";
+ // ^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'toHorse' isn't defined for the class 'int'.
}
Expect.equals("${m}", "$m");
diff --git a/tests/language_2/string_no_operator_runtime_test.dart b/tests/language_2/string_no_operator_runtime_test.dart
new file mode 100644
index 0000000..ebf1dc7
--- /dev/null
+++ b/tests/language_2/string_no_operator_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+import 'package:expect/expect.dart';
+
+main() {
+ var x = "x";
+ var y = "y";
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/string_no_operator_test.dart b/tests/language_2/string_no_operator_test.dart
index 85ffe16..e6bf231 100644
--- a/tests/language_2/string_no_operator_test.dart
+++ b/tests/language_2/string_no_operator_test.dart
@@ -7,20 +7,68 @@
main() {
var x = "x";
var y = "y";
- Expect.throws(() => x < y); //# 01: compile-time error
- Expect.throws(() => x <= y); //# 02: compile-time error
- Expect.throws(() => x > y); //# 03: compile-time error
- Expect.throws(() => x >= y); //# 04: compile-time error
- Expect.throws(() => x - y); //# 05: compile-time error
- Expect.throws(() => x * y); //# 06: compile-time error
- Expect.throws(() => x / y); //# 07: compile-time error
- Expect.throws(() => x ~/ y); //# 08: compile-time error
- Expect.throws(() => x % y); //# 09: compile-time error
- Expect.throws(() => x >> y); //# 10: compile-time error
- Expect.throws(() => x << y); //# 11: compile-time error
- Expect.throws(() => x & y); //# 12: compile-time error
- Expect.throws(() => x | y); //# 13: compile-time error
- Expect.throws(() => x ^ y); //# 14: compile-time error
- Expect.throws(() => -x); //# 15: compile-time error
- Expect.throws(() => ~x); //# 16: compile-time error
+ Expect.throws(() => x < y);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '<' isn't defined for the class 'String'.
+ Expect.throws(() => x <= y);
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '<=' isn't defined for the class 'String'.
+ Expect.throws(() => x > y);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '>' isn't defined for the class 'String'.
+ Expect.throws(() => x >= y);
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '>=' isn't defined for the class 'String'.
+ Expect.throws(() => x - y);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '-' isn't defined for the class 'String'.
+ Expect.throws(() => x * y);
+ // ^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
+ Expect.throws(() => x / y);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '/' isn't defined for the class 'String'.
+ Expect.throws(() => x ~/ y);
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '~/' isn't defined for the class 'String'.
+ Expect.throws(() => x % y);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '%' isn't defined for the class 'String'.
+ Expect.throws(() => x >> y);
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '>>' isn't defined for the class 'String'.
+ Expect.throws(() => x << y);
+ // ^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '<<' isn't defined for the class 'String'.
+ Expect.throws(() => x & y);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '&' isn't defined for the class 'String'.
+ Expect.throws(() => x | y);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '|' isn't defined for the class 'String'.
+ Expect.throws(() => x ^ y);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '^' isn't defined for the class 'String'.
+ Expect.throws(() => -x);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method 'unary-' isn't defined for the class 'String'.
+ Expect.throws(() => ~x);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '~' isn't defined for the class 'String'.
}
diff --git a/tests/language_2/string_runtime_test.dart b/tests/language_2/string_runtime_test.dart
new file mode 100644
index 0000000..612251c
--- /dev/null
+++ b/tests/language_2/string_runtime_test.dart
@@ -0,0 +1,49 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Replace with shared test once interface issues clarified.
+
+import "package:expect/expect.dart";
+
+class StringTest {
+ static testMain() {
+ testCodePoints();
+ testNoSuchMethod();
+ testStringsJoin();
+ testCharCodes();
+ }
+
+ static testCodePoints() {
+ String str = "string";
+ for (int i = 0; i < str.length; i++) {
+ Expect.equals(true, str[i] is String);
+ Expect.equals(true, str.codeUnitAt(i) is int);
+ }
+ }
+
+ static testStringsJoin() {
+ List<String> a = new List<String>(2);
+ a[0] = "Hello";
+ a[1] = "World";
+ String s = a.join("*^*");
+ Expect.equals("Hello*^*World", s);
+ }
+
+ static testNoSuchMethod() {
+ String a = "Hello";
+
+ }
+
+ static testCharCodes() {
+ String s = new String.fromCharCodes(const [0x41, 0xC1, 0x424]);
+ Expect.equals("A", s[0]);
+ Expect.equals(0x424, s.codeUnitAt(2));
+ }
+}
+
+main() {
+ StringTest.testMain();
+}
diff --git a/tests/language_2/string_test.dart b/tests/language_2/string_test.dart
index eb7cbc1..275d888 100644
--- a/tests/language_2/string_test.dart
+++ b/tests/language_2/string_test.dart
@@ -31,7 +31,10 @@
static testNoSuchMethod() {
String a = "Hello";
- a[1] = 12; //# 01: compile-time error
+ a[1] = 12;
+// ^^^
+// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+// [cfe] The method '[]=' isn't defined for the class 'String'.
}
static testCharCodes() {
diff --git a/tests/language_2/substring_runtime_test.dart b/tests/language_2/substring_runtime_test.dart
new file mode 100644
index 0000000..38007ad
--- /dev/null
+++ b/tests/language_2/substring_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Dart version of two-argument Ackermann-Peter function.
+
+import "package:expect/expect.dart";
+
+main() {
+ try {
+
+
+ } on TypeError catch (e) {
+ // OK.
+ } on ArgumentError catch (e) {
+ // OK.
+ }
+}
diff --git a/tests/language_2/substring_test.dart b/tests/language_2/substring_test.dart
index 71c810e..bf2ce99 100644
--- a/tests/language_2/substring_test.dart
+++ b/tests/language_2/substring_test.dart
@@ -7,8 +7,14 @@
main() {
try {
- print("abcdef".substring(1.5, 3.5)); // //# 01: compile-time error
- Expect.fail("Should have thrown an exception"); // //# 01: continued
+ print("abcdef".substring(1.5, 3.5));
+ // ^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'double' can't be assigned to the parameter type 'int'.
+ // ^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'double' can't be assigned to the parameter type 'int'.
+ Expect.fail("Should have thrown an exception");
} on TypeError catch (e) {
// OK.
} on ArgumentError catch (e) {
diff --git a/tests/language_2/super_assign_runtime_test.dart b/tests/language_2/super_assign_runtime_test.dart
new file mode 100644
index 0000000..19e4fa4
--- /dev/null
+++ b/tests/language_2/super_assign_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+class A {
+ int x;
+}
+
+class C extends A {
+ void setX(int value) {
+ super.x = value;
+ }
+}
+
+main() {
+ A a = new C();
+ a.x = 37;
+
+}
diff --git a/tests/language_2/super_assign_test.dart b/tests/language_2/super_assign_test.dart
index 23a352a..d3c1b90 100644
--- a/tests/language_2/super_assign_test.dart
+++ b/tests/language_2/super_assign_test.dart
@@ -15,5 +15,8 @@
main() {
A a = new C();
a.x = 37;
- a.setX(42); //# 01: compile-time error
+ a.setX(42);
+ //^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'setX' isn't defined for the class 'A'.
}
diff --git a/tests/language_2/super_call3_runtime_test.dart b/tests/language_2/super_call3_runtime_test.dart
new file mode 100644
index 0000000..1df0b3c
--- /dev/null
+++ b/tests/language_2/super_call3_runtime_test.dart
@@ -0,0 +1,49 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Dart test for testing implicit super calls with bad arguments or no default
+// constructor in super class.
+
+import "package:expect/expect.dart";
+
+class A {
+ A(
+
+ );
+ final foo = 499;
+}
+
+class B extends A {}
+
+class B2 extends A {
+ B2();
+ B2.named() : this.x = 499;
+ var x;
+}
+
+class C {
+ C
+
+ ();
+ final foo = 499;
+}
+
+class D extends C {}
+
+class D2 extends C {
+ D2();
+ D2.named() : this.x = 499;
+ var x;
+}
+
+main() {
+ Expect.equals(499, new B().foo);
+ Expect.equals(499, new B2().foo);
+ Expect.equals(499, new B2.named().foo);
+ Expect.equals(499, new D().foo);
+ Expect.equals(499, new D2().foo);
+ Expect.equals(499, new D2.named().foo);
+}
diff --git a/tests/language_2/super_call3_test.dart b/tests/language_2/super_call3_test.dart
index 4213c52..333f81d 100644
--- a/tests/language_2/super_call3_test.dart
+++ b/tests/language_2/super_call3_test.dart
@@ -8,31 +8,53 @@
class A {
A(
- this.x // //# 01: compile-time error
+ this.x
+// ^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD
+// ^
+// [cfe] 'x' isn't an instance field of this class.
);
final foo = 499;
}
class B extends A {}
+// ^
+// [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+// [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
class B2 extends A {
B2();
+//^^
+// [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+// [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
B2.named() : this.x = 499;
+//^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+// [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
var x;
}
class C {
C
- .named // //# 02: compile-time error
+ .named
();
final foo = 499;
}
class D extends C {}
+// ^
+// [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+// [cfe] The superclass, 'C', has no unnamed constructor that takes no arguments.
class D2 extends C {
D2();
+//^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT
+// [cfe] The superclass, 'C', has no unnamed constructor that takes no arguments.
D2.named() : this.x = 499;
+//^^
+// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT
+// [cfe] The superclass, 'C', has no unnamed constructor that takes no arguments.
var x;
}
diff --git a/tests/language_2/super_conditional_operator_runtime_test.dart b/tests/language_2/super_conditional_operator_runtime_test.dart
new file mode 100644
index 0000000..2529639
--- /dev/null
+++ b/tests/language_2/super_conditional_operator_runtime_test.dart
@@ -0,0 +1,45 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify that the ?. operator cannot be used with "super".
+
+class B {
+ B();
+ B.namedConstructor();
+ var field = 1;
+ method() => 1;
+}
+
+class C extends B {
+ C()
+
+ ;
+
+ test() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+}
+
+main() {
+ new C().test();
+}
diff --git a/tests/language_2/super_conditional_operator_test.dart b/tests/language_2/super_conditional_operator_test.dart
index 1c78d4a..cd2d498 100644
--- a/tests/language_2/super_conditional_operator_test.dart
+++ b/tests/language_2/super_conditional_operator_test.dart
@@ -13,27 +13,95 @@
class C extends B {
C()
- : super?.namedConstructor() //# 01: syntax error
+ : super?.namedConstructor()
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] Cannot use '?.' here.
+ // ^
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
;
test() {
- super?.field = 1; //# 02: syntax error
- super?.field += 1; //# 03: syntax error
- super?.field ??= 1; //# 04: syntax error
- super?.field; //# 05: syntax error
- 1 * super?.field; //# 06: syntax error
- -super?.field; //# 07: syntax error
- ~super?.field; //# 08: syntax error
- !super?.field; //# 09: syntax error
- --super?.field; //# 10: syntax error
- ++super?.field; //# 11: syntax error
- super?.method(); //# 12: syntax error
- 1 * super?.method(); //# 13: syntax error
- -super?.method(); //# 14: syntax error
- ~super?.method(); //# 15: syntax error
- !super?.method(); //# 16: syntax error
- --super?.method(); //# 17: syntax error
- ++super?.method(); //# 18: syntax error
+ super?.field = 1;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ super?.field += 1;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ super?.field ??= 1;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ super?.field;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ 1 * super?.field;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ -super?.field;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ ~super?.field;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ !super?.field;
+// ^^^^^^^^^^^^
+// [analyzer] STATIC_TYPE_WARNING.NON_BOOL_NEGATION_EXPRESSION
+// ^^
+// [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+// [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+// ^
+// [cfe] A value of type 'int' can't be assigned to a variable of type 'bool'.
+ --super?.field;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ ++super?.field;
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ super?.method();
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ 1 * super?.method();
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ -super?.method();
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ ~super?.method();
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ !super?.method();
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ --super?.method();
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ // ^
+ // [cfe] Can't assign to this.
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
+ ++super?.method();
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER
+ // [cfe] The operator '?.' cannot be used with 'super' because 'super' cannot be null.
+ // ^
+ // [cfe] Can't assign to this.
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNABLE_SELECTOR
}
}
diff --git a/tests/language_2/super_no_such_method4_runtime_test.dart b/tests/language_2/super_no_such_method4_runtime_test.dart
new file mode 100644
index 0000000..f8d4880
--- /dev/null
+++ b/tests/language_2/super_no_such_method4_runtime_test.dart
@@ -0,0 +1,24 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2016, 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.
+
+import 'package:expect/expect.dart';
+
+class A {
+ int foo();
+
+ noSuchMethod(im) => 42;
+}
+
+class B extends Object with A {
+ noSuchMethod(im) => 87;
+
+
+}
+
+main() {
+ Expect.equals(87, new B().foo());
+}
diff --git a/tests/language_2/super_no_such_method4_test.dart b/tests/language_2/super_no_such_method4_test.dart
index e63f790..9e83146 100644
--- a/tests/language_2/super_no_such_method4_test.dart
+++ b/tests/language_2/super_no_such_method4_test.dart
@@ -13,7 +13,10 @@
class B extends Object with A {
noSuchMethod(im) => 87;
- foo() => super.foo(); //# 01: compile-time error
+ foo() => super.foo();
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.ABSTRACT_SUPER_MEMBER_REFERENCE
+ // [cfe] Superclass has no method named 'foo'.
}
main() {
diff --git a/tests/language_2/super_no_such_method5_runtime_test.dart b/tests/language_2/super_no_such_method5_runtime_test.dart
new file mode 100644
index 0000000..94adb24
--- /dev/null
+++ b/tests/language_2/super_no_such_method5_runtime_test.dart
@@ -0,0 +1,22 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2016, 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.
+
+import 'package:expect/expect.dart';
+
+class A {
+ int foo();
+
+ noSuchMethod(im) => 42;
+}
+
+class B extends Object with A {
+
+}
+
+main() {
+ Expect.equals(42, new B().foo());
+}
diff --git a/tests/language_2/super_no_such_method5_test.dart b/tests/language_2/super_no_such_method5_test.dart
index 07a6e46..eb923c1 100644
--- a/tests/language_2/super_no_such_method5_test.dart
+++ b/tests/language_2/super_no_such_method5_test.dart
@@ -11,7 +11,10 @@
}
class B extends Object with A {
- foo() => super.foo(); //# 01: compile-time error
+ foo() => super.foo();
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.ABSTRACT_SUPER_MEMBER_REFERENCE
+ // [cfe] Superclass has no method named 'foo'.
}
main() {
diff --git a/tests/language_2/switch_bad_case_runtime_test.dart b/tests/language_2/switch_bad_case_runtime_test.dart
new file mode 100644
index 0000000..0119fa5
--- /dev/null
+++ b/tests/language_2/switch_bad_case_runtime_test.dart
@@ -0,0 +1,39 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test reporting a compile-time error if case expressions do not all have
+// the same type or are of type double.
+
+import "package:expect/expect.dart";
+
+void main() {
+ Expect.equals("IV", caesarSays(4));
+ Expect.equals(null, caesarSays(2));
+ Expect.equals(null, archimedesSays(3.14));
+}
+
+caesarSays(n) {
+ switch (n) {
+ case 1:
+ return "I";
+ case 4:
+ return "IV";
+
+
+ }
+ return null;
+}
+
+archimedesSays(n) {
+
+
+
+
+
+
+ return null;
+}
diff --git a/tests/language_2/switch_bad_case_test.dart b/tests/language_2/switch_bad_case_test.dart
index 29c2843..03746b1 100644
--- a/tests/language_2/switch_bad_case_test.dart
+++ b/tests/language_2/switch_bad_case_test.dart
@@ -19,18 +19,22 @@
return "I";
case 4:
return "IV";
- case "M": // //# 01: compile-time error
- return 1000; // //# 01: continued
+ case "M":
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_CASE_EXPRESSION_TYPES
+ return 1000;
}
return null;
}
archimedesSays(n) {
- switch (n) { // //# 02: continued
- case 3.14: // //# 02: compile-time error
- return "Pi"; // //# 02: continued
- case 2.71828: // //# 02: continued
- return "Huh?"; // //# 02: continued
- } // //# 02: continued
+ switch (n) {
+//^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
+ case 3.14:
+ return "Pi";
+ case 2.71828:
+ return "Huh?";
+ }
return null;
}
diff --git a/tests/language_2/switch_case_runtime_test.dart b/tests/language_2/switch_case_runtime_test.dart
new file mode 100644
index 0000000..b5a83cd
--- /dev/null
+++ b/tests/language_2/switch_case_runtime_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ const A();
+ const factory A.B() = B;
+ const factory A.C() = C;
+ const factory A.C2() = D;
+}
+
+class B implements A {
+ const B();
+
+
+}
+
+class C implements D {
+ final int x;
+ const C() : x = 0;
+ const C.fromD() : x = 1;
+}
+
+class D implements A {
+ int get x => 0;
+ const factory D() = C.fromD;
+}
+
+main() {
+ switch (new B()) {
+
+ }
+
+ switch (new C()) {
+ case const C():
+ Expect.fail("bad switch");
+ break;
+ case const A.C():
+ Expect.fail("bad switch");
+ break;
+ case const A.C2():
+ Expect.fail("bad switch");
+ break;
+
+ }
+
+ switch (new A()) {
+ case const A():
+ Expect.fail("bad switch");
+ break;
+
+ }
+}
diff --git a/tests/language_2/switch_case_test.dart b/tests/language_2/switch_case_test.dart
index 736ec30..105299d 100644
--- a/tests/language_2/switch_case_test.dart
+++ b/tests/language_2/switch_case_test.dart
@@ -14,7 +14,7 @@
class B implements A {
const B();
- operator ==(o) => true; // //# 00: compile-time error
+ operator ==(o) => true;
}
class C implements D {
@@ -30,7 +30,9 @@
main() {
switch (new B()) {
- case const A.B(): Expect.fail("bad switch"); break; // //# 00: continued
+//^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
+ case const A.B(): Expect.fail("bad switch"); break;
}
switch (new C()) {
@@ -43,13 +45,17 @@
case const A.C2():
Expect.fail("bad switch");
break;
- case const A(): Expect.fail("bad switch"); break; // //# 01: compile-time error
+ case const A(): Expect.fail("bad switch"); break;
+ // ^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_CASE_EXPRESSION_TYPES
}
switch (new A()) {
case const A():
Expect.fail("bad switch");
break;
- case const A.B(): Expect.fail("bad switch"); break; // //# 02: compile-time error
+ case const A.B(): Expect.fail("bad switch"); break;
+ // ^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_CASE_EXPRESSION_TYPES
}
}
diff --git a/tests/language_2/switch_fallthru_runtime_test.dart b/tests/language_2/switch_fallthru_runtime_test.dart
new file mode 100644
index 0000000..b1dd57d
--- /dev/null
+++ b/tests/language_2/switch_fallthru_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// Check that FallThroughError is thrown if switch clause does not terminate.
+
+import "package:expect/expect.dart";
+
+String test(int n) {
+ String result = "foo";
+ switch (n) {
+ case 0:
+ result = "zero";
+ break;
+ case 1:
+
+ // fall-through, error if case is non-empty
+ case 9:
+ result = "nine";
+ // No implicit FallThroughError at end of switch statement.
+ }
+ return result;
+}
+
+main() {
+ Expect.equals("zero", test(0));
+ Expect.equals("nine", test(1));
+ Expect.equals("nine", test(9));
+ Expect.equals("foo", test(99));
+}
diff --git a/tests/language_2/switch_fallthru_test.dart b/tests/language_2/switch_fallthru_test.dart
index 1a9b5bc..aabb2ca 100644
--- a/tests/language_2/switch_fallthru_test.dart
+++ b/tests/language_2/switch_fallthru_test.dart
@@ -12,7 +12,10 @@
result = "zero";
break;
case 1:
- result = "one"; //# 01: compile-time error
+// ^^^^
+// [analyzer] STATIC_WARNING.CASE_BLOCK_NOT_TERMINATED
+// [cfe] Switch case may fall through to the next case.
+ result = "one";
// fall-through, error if case is non-empty
case 9:
result = "nine";
diff --git a/tests/language_2/symbol_literal_runtime_1_test.dart b/tests/language_2/symbol_literal_runtime_1_test.dart
new file mode 100644
index 0000000..e574d8c
--- /dev/null
+++ b/tests/language_2/symbol_literal_runtime_1_test.dart
@@ -0,0 +1,51 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test symbol literals.
+
+library symbol_literal_test;
+
+import 'package:expect/expect.dart';
+
+foo(a, b) => Expect.isTrue(identical(a, b));
+
+var check = foo; // Indirection used to avoid inlining.
+
+testSwitch(Symbol s) {
+ switch (s) {
+ case #abc:
+ return 1;
+ case const Symbol("def"):
+ return 2;
+ default:
+ return 0;
+ }
+}
+
+main() {
+ bool doChecks = false;
+ doChecks = true;
+ if (doChecks) {
+ check(const Symbol("a"), #a);
+ check(const Symbol("a"), #a);
+ check(const Symbol("ab"), #ab);
+ check(const Symbol("ab"), #ab);
+ check(const Symbol("a.b"), #a.b);
+ check(const Symbol("a.b"), #a.b);
+ check(const Symbol("=="), #==);
+ check(const Symbol("=="), #==);
+ check(const Symbol("a.toString"), #a.toString);
+ }
+
+ Expect.equals(1, testSwitch(#abc));
+
+ const m = const <Symbol, int>{#A: 0, #B: 1};
+ Expect.equals(1, m[#B]);
+
+ // Tries to call the symbol literal #a.toString
+
+}
diff --git a/tests/language_2/symbol_literal_runtime_test.dart b/tests/language_2/symbol_literal_runtime_test.dart
new file mode 100644
index 0000000..5bc7eed
--- /dev/null
+++ b/tests/language_2/symbol_literal_runtime_test.dart
@@ -0,0 +1,51 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test symbol literals.
+
+library symbol_literal_test;
+
+import 'package:expect/expect.dart';
+
+foo(a, b) => Expect.isTrue(identical(a, b));
+
+var check = foo; // Indirection used to avoid inlining.
+
+testSwitch(Symbol s) {
+ switch (s) {
+ case #abc:
+ return 1;
+ case const Symbol("def"):
+ return 2;
+ default:
+ return 0;
+ }
+}
+
+main() {
+ bool doChecks = false;
+
+ if (doChecks) {
+ check(const Symbol("a"), #a);
+ check(const Symbol("a"), #a);
+ check(const Symbol("ab"), #ab);
+ check(const Symbol("ab"), #ab);
+ check(const Symbol("a.b"), #a.b);
+ check(const Symbol("a.b"), #a.b);
+ check(const Symbol("=="), #==);
+ check(const Symbol("=="), #==);
+ check(const Symbol("a.toString"), #a.toString);
+ }
+
+ Expect.equals(1, testSwitch(#abc));
+
+ const m = const <Symbol, int>{#A: 0, #B: 1};
+ Expect.equals(1, m[#B]);
+
+ // Tries to call the symbol literal #a.toString
+
+}
diff --git a/tests/language_2/symbol_literal_test.dart b/tests/language_2/symbol_literal_test.dart
index aa89fef..268b610 100644
--- a/tests/language_2/symbol_literal_test.dart
+++ b/tests/language_2/symbol_literal_test.dart
@@ -25,7 +25,7 @@
main() {
bool doChecks = false;
- doChecks = true; //# 02: ok
+ doChecks = true;
if (doChecks) {
check(const Symbol("a"), #a);
check(const Symbol("a"), #a);
@@ -44,5 +44,9 @@
Expect.equals(1, m[#B]);
// Tries to call the symbol literal #a.toString
- Expect.throwsNoSuchMethodError(() => #a.toString()); //# 01: compile-time error
+ Expect.throwsNoSuchMethodError(() => #a.toString());
+ // ^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION
+ // ^
+ // [cfe] The method 'call' isn't defined for the class 'Symbol'.
}
diff --git a/tests/language_2/sync_generator1_runtime_test.dart b/tests/language_2/sync_generator1_runtime_test.dart
new file mode 100644
index 0000000..728a800
--- /dev/null
+++ b/tests/language_2/sync_generator1_runtime_test.dart
@@ -0,0 +1,90 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Simple test program for sync* generator functions.
+
+// VMOptions=--optimization_counter_threshold=10
+
+import "package:expect/expect.dart";
+
+sum10() sync* {
+ var s = 0;
+ for (var k = 1; k <= 10; k++) {
+ s += k;
+ yield s;
+ }
+}
+
+class Range {
+ int start, end;
+ Range(this.start, this.end);
+ elements() sync* {
+ var e = start;
+ while (e <= end) yield e++;
+ }
+
+ get yield sync* {
+ // yield is a legal member name here.
+ var e = start;
+ while (e <= end) yield e++;
+ }
+}
+
+get sync sync* {
+ // sync is a legal identifier.
+ yield "sync";
+}
+
+einsZwei() sync* {
+ yield 1;
+ yield* [2, 3];
+ yield* [];
+ yield 5;
+ yield [6];
+}
+
+dreiVier() sync* {
+ // Throws type error: yielded object is not an iterable.
+
+}
+
+main() {
+ for (int i = 0; i < 10; i++) {
+ var sums = sum10();
+ print(sums);
+ Expect.isTrue(sums is Iterable);
+ Expect.equals(10, sums.length);
+ Expect.equals(1, sums.first);
+ Expect.equals(55, sums.last);
+ var q = "";
+ for (var n in sums.take(3)) {
+ q += "$n ";
+ }
+ Expect.equals("1 3 6 ", q);
+
+ var r = new Range(10, 12);
+ var elems1 = r.elements();
+ print(elems1);
+ var elems2 = r.yield;
+ print(elems2);
+ // Walk the elements of each iterable and compare them.
+ var i = elems1.iterator;
+ Expect.isTrue(i is Iterator);
+ elems2.forEach((e) {
+ Expect.isTrue(i.moveNext());
+ Expect.equals(e, i.current);
+ });
+
+ print(sync);
+ Expect.equals("sync", sync.single);
+
+ print(einsZwei());
+ Expect.equals("(1, 2, 3, 5, [6])", einsZwei().toString());
+
+
+ }
+}
diff --git a/tests/language_2/sync_generator1_test.dart b/tests/language_2/sync_generator1_test.dart
index d91ff70..79b294d 100644
--- a/tests/language_2/sync_generator1_test.dart
+++ b/tests/language_2/sync_generator1_test.dart
@@ -46,7 +46,10 @@
dreiVier() sync* {
// Throws type error: yielded object is not an iterable.
- yield* 3; //# 01: compile-time error
+ yield* 3;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.YIELD_OF_INVALID_TYPE
+ // [cfe] A value of type 'int' can't be assigned to a variable of type 'Iterable<dynamic>'.
}
main() {
@@ -82,6 +85,6 @@
print(einsZwei());
Expect.equals("(1, 2, 3, 5, [6])", einsZwei().toString());
- Expect.throws(() => dreiVier().toString()); //# 01: continued
+ Expect.throws(() => dreiVier().toString());
}
}
diff --git a/tests/language_2/this_conditional_operator_runtime_test.dart b/tests/language_2/this_conditional_operator_runtime_test.dart
new file mode 100644
index 0000000..eb56244
--- /dev/null
+++ b/tests/language_2/this_conditional_operator_runtime_test.dart
@@ -0,0 +1,31 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2015, 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.
+
+// Verify that the ?. operator cannot be used for forwarding "this"
+// constructors.
+
+class B {
+ B();
+ B.namedConstructor();
+ var field = 1;
+ method() => 1;
+
+ B.forward()
+
+ ;
+
+ test() {
+ this?.field = 1;
+ this?.field += 1;
+ this?.field;
+ this?.method();
+ }
+}
+
+main() {
+ new B.forward().test();
+}
diff --git a/tests/language_2/this_conditional_operator_test.dart b/tests/language_2/this_conditional_operator_test.dart
index 87ab734..75f711c 100644
--- a/tests/language_2/this_conditional_operator_test.dart
+++ b/tests/language_2/this_conditional_operator_test.dart
@@ -12,7 +12,20 @@
method() => 1;
B.forward()
- : this?.namedConstructor() //# 01: syntax error
+ : this?.namedConstructor()
+ //^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INVALID_REFERENCE_TO_THIS
+ // [cfe] Expected an assignment after the field name.
+ //^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_ASSIGNMENT_IN_INITIALIZER
+ //^^^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INITIALIZER_FOR_NON_EXISTENT_FIELD
+ // [error line 15, column 11, length 0]
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] Expected '.' before this.
+ // ^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected an identifier, but got ''.
;
test() {
diff --git a/tests/language_2/this_runtime_test.dart b/tests/language_2/this_runtime_test.dart
new file mode 100644
index 0000000..c81a1b2
--- /dev/null
+++ b/tests/language_2/this_runtime_test.dart
@@ -0,0 +1,26 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+class Foo {
+ var x;
+ f() {}
+
+ testMe() {
+
+
+
+
+
+
+
+
+ }
+}
+
+main() {
+ new Foo().testMe();
+}
diff --git a/tests/language_2/this_test.dart b/tests/language_2/this_test.dart
index 8395fff..8d29f8a 100644
--- a/tests/language_2/this_test.dart
+++ b/tests/language_2/this_test.dart
@@ -7,14 +7,38 @@
f() {}
testMe() {
- x.this; //# 01: syntax error
- x.this(); //# 02: syntax error
- x.this.x; //# 03: syntax error
- x.this().x; //# 04: syntax error
- f().this; //# 05: syntax error
- f().this(); //# 06: syntax error
- f().this.f(); //# 07: syntax error
- f().this().f(); //# 08: syntax error
+ x.this;
+ //^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected identifier, but got 'this'.
+ x.this();
+ //^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected identifier, but got 'this'.
+ x.this.x;
+ //^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected identifier, but got 'this'.
+ x.this().x;
+ //^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected identifier, but got 'this'.
+ f().this;
+ // ^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected identifier, but got 'this'.
+ f().this();
+ // ^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected identifier, but got 'this'.
+ f().this.f();
+ // ^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected identifier, but got 'this'.
+ f().this().f();
+ // ^^^^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_IDENTIFIER
+ // [cfe] Expected identifier, but got 'this'.
}
}
diff --git a/tests/language_2/try_catch_runtime_test.dart b/tests/language_2/try_catch_runtime_test.dart
new file mode 100644
index 0000000..872f9d7
--- /dev/null
+++ b/tests/language_2/try_catch_runtime_test.dart
@@ -0,0 +1,199 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+// VMOptions=--optimization-counter-threshold=10
+
+import "package:expect/expect.dart";
+
+class MyException {}
+
+class MyException1 extends MyException {}
+
+class MyException2 extends MyException {}
+
+class TryCatchTest {
+ static void test1() {
+ var foo = 0;
+ try {
+ throw new MyException1();
+ } on MyException2 catch (e) {
+ foo = 1;
+ } on MyException1 catch (e) {
+ foo = 2;
+ } on MyException catch (e) {
+ foo = 3;
+ }
+ Expect.equals(2, foo);
+ }
+
+ static void test2() {
+ var foo = 0;
+ try {
+ throw new MyException1();
+ } on MyException2 catch (e) {
+ foo = 1;
+ } on MyException catch (e) {
+ foo = 2;
+ } on MyException1 catch (e) {
+ foo = 3;
+ }
+ Expect.equals(2, foo);
+ }
+
+ static void test3() {
+ var foo = 0;
+ try {
+ throw new MyException();
+ } on MyException2 catch (e) {
+ foo = 1;
+ } on MyException1 catch (e) {
+ foo = 2;
+ } on MyException catch (e) {
+ foo = 3;
+ }
+ Expect.equals(3, foo);
+ }
+
+ static void test4() {
+ var foo = 0;
+ try {
+ try {
+ throw new MyException();
+ } on MyException2 catch (e) {
+ foo = 1;
+ } on MyException1 catch (e) {
+ foo = 2;
+ }
+ } on MyException catch (e) {
+ Expect.equals(0, foo);
+ foo = 3;
+ }
+ Expect.equals(3, foo);
+ }
+
+ static void test5() {
+ var foo = 0;
+ try {
+ throw new MyException1();
+ } on MyException2 catch (e) {
+ foo = 1;
+ } catch (e) {
+ foo = 2;
+ }
+ Expect.equals(2, foo);
+ }
+
+ static void test6() {
+ var foo = 0;
+ try {
+ throw new MyException();
+ } on MyException2 catch (e) {
+ foo = 1;
+ } on MyException1 catch (e) {
+ foo = 2;
+ } catch (e) {
+ foo = 3;
+ }
+ Expect.equals(3, foo);
+ }
+
+ static void test7() {
+ var foo = 0;
+ try {
+ try {
+ throw new MyException();
+ } on MyException2 catch (e) {
+ foo = 1;
+ } on MyException1 catch (e) {
+ foo = 2;
+ }
+ } catch (e) {
+ Expect.equals(0, foo);
+ foo = 3;
+ }
+ Expect.equals(3, foo);
+ }
+
+ static void test8() {
+ var e = 3;
+ var caught = false;
+ try {
+ throw new MyException();
+ } catch (exc) {
+ caught = true;
+ }
+ Expect.equals(true, caught);
+ Expect.equals(3, e);
+ }
+
+ static void test9() {
+ dynamic e = 6;
+ try {
+ throw "up";
+ } on String {
+ e = "s";
+ } on int {
+ e = "i";
+ }
+ Expect.equals("s", e);
+ }
+
+ static void test10() {
+ try {
+ throw "up";
+ } on String catch (e) {
+ var e = 1; // ok, shadows exception variable.
+ Expect.equals(1, e);
+ }
+ }
+
+ static void test11() {
+ var e0 = 11;
+ try {
+ throw "up";
+ } on int catch (e0) {
+ Expect.fail("unreachable");
+ } on String catch (e1) {
+ // e0 from the other catch clause is not in scope.
+ Expect.equals(11, e0);
+ }
+ }
+
+ static void test12() {
+ const x = const [];
+ try {
+ throw "up";
+ } catch (e) {
+ Expect.equals("up", e);
+ } on String catch (e) {
+ // Compile-time constants in unreachable catch blocks are still
+ // compiled.
+
+ Expect.fail("unreachable");
+ }
+ }
+
+ static void testMain() {
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ test7();
+ test8();
+ test9();
+ test10();
+ test11();
+ test12();
+ }
+}
+
+main() {
+ for (var i = 0; i < 20; i++) {
+ TryCatchTest.testMain();
+ }
+}
diff --git a/tests/language_2/try_catch_test.dart b/tests/language_2/try_catch_test.dart
index 59e6486..2b8fee2 100644
--- a/tests/language_2/try_catch_test.dart
+++ b/tests/language_2/try_catch_test.dart
@@ -168,7 +168,11 @@
} on String catch (e) {
// Compile-time constants in unreachable catch blocks are still
// compiled.
- const y = x[0]; // //# 01: compile-time error
+ const y = x[0];
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
+ // ^
+ // [cfe] Constant evaluation error:
Expect.fail("unreachable");
}
}
diff --git a/tests/language_2/type_checks_in_factory_method_runtime_test.dart b/tests/language_2/type_checks_in_factory_method_runtime_test.dart
new file mode 100644
index 0000000..58f0c89
--- /dev/null
+++ b/tests/language_2/type_checks_in_factory_method_runtime_test.dart
@@ -0,0 +1,43 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+// Tests the type checking when passing code into closure from inside a factory method
+
+import "package:expect/expect.dart";
+
+abstract class Foo<T> {
+ factory Foo.from() = Bar<T>.from;
+}
+
+class Bar<T> implements Foo<T> {
+ Bar() {}
+
+ factory Bar.from() {
+ var func = (T arg) {
+ T foo = arg;
+ bool isString = foo is String;
+ print(arg);
+ print(" String=$isString");
+ };
+
+
+ return new Bar<T>();
+ }
+}
+
+main() {
+ Foo<String> value1;
+ value1 = new Foo<String>.from();
+
+ bool gotError = false;
+
+ try {
+ Foo<int> value2 = new Foo<int>.from();
+ } on TypeError catch (e) {
+ gotError = true;
+ }
+ Expect.equals(false, gotError);
+}
diff --git a/tests/language_2/type_checks_in_factory_method_test.dart b/tests/language_2/type_checks_in_factory_method_test.dart
index f0d116d..cae8f04 100644
--- a/tests/language_2/type_checks_in_factory_method_test.dart
+++ b/tests/language_2/type_checks_in_factory_method_test.dart
@@ -20,7 +20,10 @@
print(" String=$isString");
};
- func("Hello World!"); //# 01: compile-time error
+ func("Hello World!");
+ // ^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // [cfe] The argument type 'String' can't be assigned to the parameter type 'T'.
return new Bar<T>();
}
}
diff --git a/tests/language_2/type_inference_accessor_ref_runtime_1_test.dart b/tests/language_2/type_inference_accessor_ref_runtime_1_test.dart
new file mode 100644
index 0000000..4cb3b54
--- /dev/null
+++ b/tests/language_2/type_inference_accessor_ref_runtime_1_test.dart
@@ -0,0 +1,45 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+class A {
+ B b;
+}
+
+class B {
+ C get c => null;
+ void set c(C value) {}
+}
+
+class C {}
+
+class D extends C {}
+
+class E extends C {}
+
+// Inferred type: A
+var a = new A();
+
+// Inferred type: C
+var x = a.b.c;
+
+// Inferred type: C
+var y = a.b.c ??= new D();
+
+test() {
+ // Verify the types of x and y by trying to assign to them.
+ x = new C();
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/type_inference_accessor_ref_runtime_2_test.dart b/tests/language_2/type_inference_accessor_ref_runtime_2_test.dart
new file mode 100644
index 0000000..ed57805
--- /dev/null
+++ b/tests/language_2/type_inference_accessor_ref_runtime_2_test.dart
@@ -0,0 +1,45 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+class A {
+ B b;
+}
+
+class B {
+ C get c => null;
+ void set c(C value) {}
+}
+
+class C {}
+
+class D extends C {}
+
+class E extends C {}
+
+// Inferred type: A
+var a = new A();
+
+// Inferred type: C
+var x = a.b.c;
+
+// Inferred type: C
+var y = a.b.c ??= new D();
+
+test() {
+ // Verify the types of x and y by trying to assign to them.
+
+ x = new E();
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/type_inference_accessor_ref_runtime_3_test.dart b/tests/language_2/type_inference_accessor_ref_runtime_3_test.dart
new file mode 100644
index 0000000..39b4069
--- /dev/null
+++ b/tests/language_2/type_inference_accessor_ref_runtime_3_test.dart
@@ -0,0 +1,45 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+class A {
+ B b;
+}
+
+class B {
+ C get c => null;
+ void set c(C value) {}
+}
+
+class C {}
+
+class D extends C {}
+
+class E extends C {}
+
+// Inferred type: A
+var a = new A();
+
+// Inferred type: C
+var x = a.b.c;
+
+// Inferred type: C
+var y = a.b.c ??= new D();
+
+test() {
+ // Verify the types of x and y by trying to assign to them.
+
+
+
+ y = new C();
+
+
+}
+
+main() {}
diff --git a/tests/language_2/type_inference_accessor_ref_runtime_4_test.dart b/tests/language_2/type_inference_accessor_ref_runtime_4_test.dart
new file mode 100644
index 0000000..900b1d2a
--- /dev/null
+++ b/tests/language_2/type_inference_accessor_ref_runtime_4_test.dart
@@ -0,0 +1,45 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+class A {
+ B b;
+}
+
+class B {
+ C get c => null;
+ void set c(C value) {}
+}
+
+class C {}
+
+class D extends C {}
+
+class E extends C {}
+
+// Inferred type: A
+var a = new A();
+
+// Inferred type: C
+var x = a.b.c;
+
+// Inferred type: C
+var y = a.b.c ??= new D();
+
+test() {
+ // Verify the types of x and y by trying to assign to them.
+
+
+
+
+ y = new E();
+
+}
+
+main() {}
diff --git a/tests/language_2/type_inference_accessor_ref_runtime_test.dart b/tests/language_2/type_inference_accessor_ref_runtime_test.dart
new file mode 100644
index 0000000..4b301be
--- /dev/null
+++ b/tests/language_2/type_inference_accessor_ref_runtime_test.dart
@@ -0,0 +1,45 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+class A {
+ B b;
+}
+
+class B {
+ C get c => null;
+ void set c(C value) {}
+}
+
+class C {}
+
+class D extends C {}
+
+class E extends C {}
+
+// Inferred type: A
+var a = new A();
+
+// Inferred type: C
+var x = a.b.c;
+
+// Inferred type: C
+var y = a.b.c ??= new D();
+
+test() {
+ // Verify the types of x and y by trying to assign to them.
+
+
+
+
+
+
+}
+
+main() {}
diff --git a/tests/language_2/type_inference_accessor_ref_test.dart b/tests/language_2/type_inference_accessor_ref_test.dart
index cb72da6..8f16f8b 100644
--- a/tests/language_2/type_inference_accessor_ref_test.dart
+++ b/tests/language_2/type_inference_accessor_ref_test.dart
@@ -31,12 +31,20 @@
test() {
// Verify the types of x and y by trying to assign to them.
- x = new C(); //# 01: ok
- x = new E(); //# 02: ok
- x = new B(); //# 03: compile-time error
- y = new C(); //# 04: ok
- y = new E(); //# 05: ok
- y = new B(); //# 06: compile-time error
+ x = new C();
+ x = new E();
+ x = new B();
+ // ^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'B' can't be assigned to a variable of type 'C'.
+ y = new C();
+ y = new E();
+ y = new B();
+ // ^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'B' can't be assigned to a variable of type 'C'.
}
main() {}
diff --git a/tests/language_2/type_promotion_assign_runtime_test.dart b/tests/language_2/type_promotion_assign_runtime_test.dart
new file mode 100644
index 0000000..477712c
--- /dev/null
+++ b/tests/language_2/type_promotion_assign_runtime_test.dart
@@ -0,0 +1,54 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test type promotion of assigned locals.
+
+class A {
+ var a = "a";
+}
+
+class B extends A {
+ var b = "b";
+}
+
+class C extends B {
+ var c = "c";
+}
+
+class D extends A {
+ var d = "d";
+}
+
+class E implements C, D {
+ var a = "";
+ var b = "";
+ var c = "";
+ var d = "";
+}
+
+void main() {
+ A a = new E();
+ if (a is B) {
+ print(a.a);
+
+ a = null;
+ }
+ if (a is B) {
+ a = null;
+ print(a.a);
+
+ }
+ if (a is B) {
+ print(a.a);
+
+ {
+ a = null;
+ }
+ print(a.a);
+
+ }
+}
diff --git a/tests/language_2/type_promotion_assign_test.dart b/tests/language_2/type_promotion_assign_test.dart
index d569df5..38f8f55 100644
--- a/tests/language_2/type_promotion_assign_test.dart
+++ b/tests/language_2/type_promotion_assign_test.dart
@@ -31,21 +31,33 @@
A a = new E();
if (a is B) {
print(a.a);
- print(a.b); //# 01: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
a = null;
}
if (a is B) {
a = null;
print(a.a);
- print(a.b); //# 02: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
if (a is B) {
print(a.a);
- print(a.b); //# 03: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
{
a = null;
}
print(a.a);
- print(a.b); //# 04: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
}
diff --git a/tests/language_2/type_promotion_closure_runtime_1_test.dart b/tests/language_2/type_promotion_closure_runtime_1_test.dart
new file mode 100644
index 0000000..d863c91
--- /dev/null
+++ b/tests/language_2/type_promotion_closure_runtime_1_test.dart
@@ -0,0 +1,203 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test type promotion of locals potentially mutated in closures.
+
+import "package:meta/meta.dart" show virtual;
+
+class A {
+ var a = "a";
+ A operator +(int i) => this;
+}
+
+class B extends A {
+ var b = "b";
+}
+
+class C extends B {
+ var c = "c";
+}
+
+class D extends A {
+ var d = "d";
+}
+
+class E extends D implements C {
+ var a = "";
+ var b = "";
+ var c = "";
+ var d = "";
+}
+
+func(x) => true;
+
+void main() {
+ test1();
+ test2();
+ test3();
+ test3a();
+ test4();
+ test5();
+ test6();
+ test6a();
+ test7();
+ test8();
+ test9();
+ test10();
+ test11();
+ test12();
+}
+
+void test1() {
+ A a = new E();
+ if (a is B) {
+ print(a.a);
+
+ }
+ void foo() {
+ a = new D();
+ }
+}
+
+void test2() {
+ A a = new E();
+ void foo() {
+ a = new D();
+ }
+
+ if (a is B) {
+ print(a.a);
+
+ }
+}
+
+void test3() {
+ A a = new E();
+ void foo() {
+ a = new D();
+ }
+
+ if (a is B) {
+ print(a.a);
+
+ void foo() {
+ a = new D();
+ }
+
+ print(a.a);
+
+ }
+}
+
+void test3a() {
+ A a = new E();
+ void foo() {
+ a = new D();
+ }
+
+ if ((((a)) is B)) {
+ print(a.a);
+
+ void foo() {
+ a = new D();
+ }
+
+ print(a.a);
+
+ }
+}
+
+void test4() {
+ A a = new E();
+ if (a is B) {
+ func(() => a.b);
+ print(a.a);
+ print(a.b);
+ }
+}
+
+void test5() {
+ A a = new E();
+ if (a is B) {
+
+ print(a.a);
+ }
+ a = null;
+}
+
+void test6() {
+ A a = new E();
+ if (a is B) {
+ func(() => a);
+ print(a.a);
+
+ }
+ a = null;
+}
+
+void test6a() {
+ A a = new E();
+ if (((a) is B)) {
+ func(() => a);
+ print(a.a);
+
+ }
+ a = null;
+}
+
+void test7() {
+ A a = new E();
+ if (a is B && func(() => a)) {
+ print(a.a);
+
+ }
+ a = null;
+}
+
+void test8() {
+ A a = new E();
+ if (a is B
+
+ ) {
+ print(a.a);
+ }
+ a = null;
+}
+
+void test9() {
+ A a = new E();
+
+ a = null;
+}
+
+void test10() {
+ List<A> a = <E>[new E()];
+ if (a is List<B>) {
+ func(() => a[0]);
+
+ }
+ a = null;
+}
+
+void test11() {
+ List<A> a = <E>[new E()];
+ if (a is List<B>) {
+ func(() => a[0] = null);
+
+ }
+ a = null;
+}
+
+void test12() {
+ A a = new E();
+ if (a is B) {
+ func(() => a++);
+ print(a.a);
+
+ }
+ a = null;
+}
diff --git a/tests/language_2/type_promotion_closure_runtime_2_test.dart b/tests/language_2/type_promotion_closure_runtime_2_test.dart
new file mode 100644
index 0000000..0e397d5
--- /dev/null
+++ b/tests/language_2/type_promotion_closure_runtime_2_test.dart
@@ -0,0 +1,203 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test type promotion of locals potentially mutated in closures.
+
+import "package:meta/meta.dart" show virtual;
+
+class A {
+ var a = "a";
+ A operator +(int i) => this;
+}
+
+class B extends A {
+ var b = "b";
+}
+
+class C extends B {
+ var c = "c";
+}
+
+class D extends A {
+ var d = "d";
+}
+
+class E extends D implements C {
+ var a = "";
+ var b = "";
+ var c = "";
+ var d = "";
+}
+
+func(x) => true;
+
+void main() {
+ test1();
+ test2();
+ test3();
+ test3a();
+ test4();
+ test5();
+ test6();
+ test6a();
+ test7();
+ test8();
+ test9();
+ test10();
+ test11();
+ test12();
+}
+
+void test1() {
+ A a = new E();
+ if (a is B) {
+ print(a.a);
+
+ }
+ void foo() {
+ a = new D();
+ }
+}
+
+void test2() {
+ A a = new E();
+ void foo() {
+ a = new D();
+ }
+
+ if (a is B) {
+ print(a.a);
+
+ }
+}
+
+void test3() {
+ A a = new E();
+ void foo() {
+ a = new D();
+ }
+
+ if (a is B) {
+ print(a.a);
+
+ void foo() {
+ a = new D();
+ }
+
+ print(a.a);
+
+ }
+}
+
+void test3a() {
+ A a = new E();
+ void foo() {
+ a = new D();
+ }
+
+ if ((((a)) is B)) {
+ print(a.a);
+
+ void foo() {
+ a = new D();
+ }
+
+ print(a.a);
+
+ }
+}
+
+void test4() {
+ A a = new E();
+ if (a is B) {
+
+ print(a.a);
+ print(a.b);
+ }
+}
+
+void test5() {
+ A a = new E();
+ if (a is B) {
+
+ print(a.a);
+ }
+ a = null;
+}
+
+void test6() {
+ A a = new E();
+ if (a is B) {
+ func(() => a);
+ print(a.a);
+
+ }
+ a = null;
+}
+
+void test6a() {
+ A a = new E();
+ if (((a) is B)) {
+ func(() => a);
+ print(a.a);
+
+ }
+ a = null;
+}
+
+void test7() {
+ A a = new E();
+ if (a is B && func(() => a)) {
+ print(a.a);
+ print(a.b);
+ }
+ a = null;
+}
+
+void test8() {
+ A a = new E();
+ if (a is B
+
+ ) {
+ print(a.a);
+ }
+ a = null;
+}
+
+void test9() {
+ A a = new E();
+
+ a = null;
+}
+
+void test10() {
+ List<A> a = <E>[new E()];
+ if (a is List<B>) {
+ func(() => a[0]);
+
+ }
+ a = null;
+}
+
+void test11() {
+ List<A> a = <E>[new E()];
+ if (a is List<B>) {
+ func(() => a[0] = null);
+
+ }
+ a = null;
+}
+
+void test12() {
+ A a = new E();
+ if (a is B) {
+ func(() => a++);
+ print(a.a);
+
+ }
+ a = null;
+}
diff --git a/tests/language_2/type_promotion_closure_runtime_test.dart b/tests/language_2/type_promotion_closure_runtime_test.dart
new file mode 100644
index 0000000..b760366
--- /dev/null
+++ b/tests/language_2/type_promotion_closure_runtime_test.dart
@@ -0,0 +1,203 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test type promotion of locals potentially mutated in closures.
+
+import "package:meta/meta.dart" show virtual;
+
+class A {
+ var a = "a";
+ A operator +(int i) => this;
+}
+
+class B extends A {
+ var b = "b";
+}
+
+class C extends B {
+ var c = "c";
+}
+
+class D extends A {
+ var d = "d";
+}
+
+class E extends D implements C {
+ var a = "";
+ var b = "";
+ var c = "";
+ var d = "";
+}
+
+func(x) => true;
+
+void main() {
+ test1();
+ test2();
+ test3();
+ test3a();
+ test4();
+ test5();
+ test6();
+ test6a();
+ test7();
+ test8();
+ test9();
+ test10();
+ test11();
+ test12();
+}
+
+void test1() {
+ A a = new E();
+ if (a is B) {
+ print(a.a);
+
+ }
+ void foo() {
+ a = new D();
+ }
+}
+
+void test2() {
+ A a = new E();
+ void foo() {
+ a = new D();
+ }
+
+ if (a is B) {
+ print(a.a);
+
+ }
+}
+
+void test3() {
+ A a = new E();
+ void foo() {
+ a = new D();
+ }
+
+ if (a is B) {
+ print(a.a);
+
+ void foo() {
+ a = new D();
+ }
+
+ print(a.a);
+
+ }
+}
+
+void test3a() {
+ A a = new E();
+ void foo() {
+ a = new D();
+ }
+
+ if ((((a)) is B)) {
+ print(a.a);
+
+ void foo() {
+ a = new D();
+ }
+
+ print(a.a);
+
+ }
+}
+
+void test4() {
+ A a = new E();
+ if (a is B) {
+
+ print(a.a);
+ print(a.b);
+ }
+}
+
+void test5() {
+ A a = new E();
+ if (a is B) {
+
+ print(a.a);
+ }
+ a = null;
+}
+
+void test6() {
+ A a = new E();
+ if (a is B) {
+ func(() => a);
+ print(a.a);
+
+ }
+ a = null;
+}
+
+void test6a() {
+ A a = new E();
+ if (((a) is B)) {
+ func(() => a);
+ print(a.a);
+
+ }
+ a = null;
+}
+
+void test7() {
+ A a = new E();
+ if (a is B && func(() => a)) {
+ print(a.a);
+
+ }
+ a = null;
+}
+
+void test8() {
+ A a = new E();
+ if (a is B
+
+ ) {
+ print(a.a);
+ }
+ a = null;
+}
+
+void test9() {
+ A a = new E();
+
+ a = null;
+}
+
+void test10() {
+ List<A> a = <E>[new E()];
+ if (a is List<B>) {
+ func(() => a[0]);
+
+ }
+ a = null;
+}
+
+void test11() {
+ List<A> a = <E>[new E()];
+ if (a is List<B>) {
+ func(() => a[0] = null);
+
+ }
+ a = null;
+}
+
+void test12() {
+ A a = new E();
+ if (a is B) {
+ func(() => a++);
+ print(a.a);
+
+ }
+ a = null;
+}
diff --git a/tests/language_2/type_promotion_closure_test.dart b/tests/language_2/type_promotion_closure_test.dart
index 006d50e..9fb7568 100644
--- a/tests/language_2/type_promotion_closure_test.dart
+++ b/tests/language_2/type_promotion_closure_test.dart
@@ -53,7 +53,10 @@
A a = new E();
if (a is B) {
print(a.a);
- print(a.b); //# 01: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
void foo() {
a = new D();
@@ -68,7 +71,10 @@
if (a is B) {
print(a.a);
- print(a.b); //# 02: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
}
@@ -80,13 +86,19 @@
if (a is B) {
print(a.a);
- print(a.b); //# 03: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
void foo() {
a = new D();
}
print(a.a);
- print(a.b); //# 04: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
}
@@ -98,20 +110,26 @@
if ((((a)) is B)) {
print(a.a);
- print(a.b); //# 15: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
void foo() {
a = new D();
}
print(a.a);
- print(a.b); //# 16: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
}
void test4() {
A a = new E();
if (a is B) {
- func(() => a.b); //# 05: ok
+ func(() => a.b);
print(a.a);
print(a.b);
}
@@ -120,7 +138,10 @@
void test5() {
A a = new E();
if (a is B) {
- func(() => a.b); //# 06: compile-time error
+ func(() => a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
print(a.a);
}
a = null;
@@ -131,7 +152,10 @@
if (a is B) {
func(() => a);
print(a.a);
- print(a.b); //# 07: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
a = null;
}
@@ -141,7 +165,10 @@
if (((a) is B)) {
func(() => a);
print(a.a);
- print(a.b); //# 14: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
a = null;
}
@@ -150,7 +177,7 @@
A a = new E();
if (a is B && func(() => a)) {
print(a.a);
- print(a.b); //# 08: ok
+ print(a.b);
}
a = null;
}
@@ -158,7 +185,10 @@
void test8() {
A a = new E();
if (a is B
- && func(() => a.b) //# 09: compile-time error
+ && func(() => a.b)
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
) {
print(a.a);
}
@@ -167,7 +197,10 @@
void test9() {
A a = new E();
- var b = a is B ? func(() => a.b) : false; //# 10: compile-time error
+ var b = a is B ? func(() => a.b) : false;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
a = null;
}
@@ -175,7 +208,10 @@
List<A> a = <E>[new E()];
if (a is List<B>) {
func(() => a[0]);
- print(a[0].b); //# 11: compile-time error
+ print(a[0].b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
a = null;
}
@@ -184,7 +220,10 @@
List<A> a = <E>[new E()];
if (a is List<B>) {
func(() => a[0] = null);
- print(a[0].b); //# 12: compile-time error
+ print(a[0].b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
a = null;
}
@@ -194,7 +233,10 @@
if (a is B) {
func(() => a++);
print(a.a);
- print(a.b); //# 13: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
a = null;
}
diff --git a/tests/language_2/type_promotion_functions_runtime_test.dart b/tests/language_2/type_promotion_functions_runtime_test.dart
new file mode 100644
index 0000000..e421814
--- /dev/null
+++ b/tests/language_2/type_promotion_functions_runtime_test.dart
@@ -0,0 +1,127 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test type promotion of functions.
+
+class A {}
+
+class B extends A {}
+
+class C {}
+
+// Subtype relations:
+//
+// FuncDynToA == A Function(dynamic) <:
+// FuncDynToDyn == dynamic Function(dynamic) <:> // "void == dynamic"
+// FuncDynToVoid == void Function(dynamic) <:
+// FuncAtoDyn == dynamic Function(A).
+//
+// Declarations ordered by "super before sub", as is common for classes:
+
+typedef FuncAtoDyn(A a);
+typedef void FuncDynToVoid(x);
+typedef FuncDynToDyn(x);
+typedef A FuncDynToA(x);
+
+A func(x) => null;
+
+A a;
+B b;
+C c;
+
+main() {
+ testFuncAtoDyn();
+ testFuncDynToDyn();
+ testFuncDynToVoid();
+ testFuncDynToA();
+}
+
+testFuncAtoDyn() {
+ FuncAtoDyn funcAtoDyn = func;
+ a = funcAtoDyn(new A());
+ b = funcAtoDyn(new B());
+
+
+ if (funcAtoDyn is FuncDynToDyn) {
+ // Promotion: FuncDynToDyn <: FuncAtoDyn.
+ a = funcAtoDyn(new A());
+ b = funcAtoDyn(new B());
+ c = funcAtoDyn(new C());
+ }
+}
+
+testFuncDynToDyn() {
+ FuncDynToDyn funcDynToDyn = func;
+ a = funcDynToDyn(new A());
+ b = funcDynToDyn(new B());
+ c = funcDynToDyn(new C());
+
+ if (funcDynToDyn is FuncAtoDyn) {
+ // No promotion: FuncAtoDyn <\: FuncDynToDyn.
+ a = funcDynToDyn(new A());
+ b = funcDynToDyn(new B());
+ c = funcDynToDyn(new C());
+ }
+
+ if (funcDynToDyn is FuncDynToVoid) {
+ // Promotion: FuncDynToVoid <: FuncDynToDyn.
+ funcDynToDyn(new A());
+ funcDynToDyn(new B());
+ funcDynToDyn(new C());
+ // Returned value has type `void`, usage is restricted.
+
+ }
+
+ if (funcDynToDyn is FuncDynToA) {
+ // Promotion: FuncDynToA <: FuncDynToDyn.
+ a = funcDynToDyn(new A());
+ b = funcDynToDyn(new B());
+
+ }
+}
+
+testFuncDynToVoid() {
+ FuncDynToVoid funcDynToVoid = func;
+
+
+
+
+ if (funcDynToVoid is FuncDynToDyn) {
+ // Promotion: FuncDynToDyn <:> FuncDynToVoid.
+ a = funcDynToVoid(new A());
+ b = funcDynToVoid(new B());
+ c = funcDynToVoid(new C());
+ }
+
+ if (funcDynToVoid is FuncDynToA) {
+ // Promotion: FuncDynToA <: FuncDynToVoid.
+ a = funcDynToVoid(new A());
+ b = funcDynToVoid(new B());
+
+ }
+}
+
+testFuncDynToA() {
+ FuncDynToA funcDynToA = func;
+ a = funcDynToA(new A());
+ b = funcDynToA(new B());
+
+
+ if (funcDynToA is FuncDynToDyn) {
+ // No promotion: FuncDynToDyn <\: FuncDynToA.
+ a = funcDynToA(new A());
+ b = funcDynToA(new B());
+
+ }
+
+ if (funcDynToA is FuncDynToVoid) {
+ // No promotion: FuncDynToVoid <\: FuncDynToA.
+ a = funcDynToA(new A());
+ b = funcDynToA(new B());
+
+ }
+}
diff --git a/tests/language_2/type_promotion_functions_test.dart b/tests/language_2/type_promotion_functions_test.dart
index 841d119..ab78d11 100644
--- a/tests/language_2/type_promotion_functions_test.dart
+++ b/tests/language_2/type_promotion_functions_test.dart
@@ -41,7 +41,11 @@
FuncAtoDyn funcAtoDyn = func;
a = funcAtoDyn(new A());
b = funcAtoDyn(new B());
- c = funcAtoDyn(new C()); //# 01: compile-time error
+ c = funcAtoDyn(new C());
+ // ^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+ // ^
+ // [cfe] The argument type 'C' can't be assigned to the parameter type 'A'.
if (funcAtoDyn is FuncDynToDyn) {
// Promotion: FuncDynToDyn <: FuncAtoDyn.
@@ -70,22 +74,42 @@
funcDynToDyn(new B());
funcDynToDyn(new C());
// Returned value has type `void`, usage is restricted.
- Object o = funcDynToDyn(null); //# 12: compile-time error
+ Object o = funcDynToDyn(null);
+ // ^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
+ // ^
+ // [cfe] This expression has type 'void' and can't be used.
}
if (funcDynToDyn is FuncDynToA) {
// Promotion: FuncDynToA <: FuncDynToDyn.
a = funcDynToDyn(new A());
b = funcDynToDyn(new B());
- c = funcDynToDyn(new C()); //# 10: compile-time error
+ c = funcDynToDyn(new C());
+ // ^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'A' can't be assigned to a variable of type 'C'.
}
}
testFuncDynToVoid() {
FuncDynToVoid funcDynToVoid = func;
- a = funcDynToVoid(new A()); //# 02: compile-time error
- b = funcDynToVoid(new B()); //# 03: compile-time error
- c = funcDynToVoid(new C()); //# 04: compile-time error
+ a = funcDynToVoid(new A());
+ // ^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
+ // ^
+ // [cfe] This expression has type 'void' and can't be used.
+ b = funcDynToVoid(new B());
+ // ^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
+ // ^
+ // [cfe] This expression has type 'void' and can't be used.
+ c = funcDynToVoid(new C());
+ // ^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
+ // ^
+ // [cfe] This expression has type 'void' and can't be used.
if (funcDynToVoid is FuncDynToDyn) {
// Promotion: FuncDynToDyn <:> FuncDynToVoid.
@@ -98,7 +122,11 @@
// Promotion: FuncDynToA <: FuncDynToVoid.
a = funcDynToVoid(new A());
b = funcDynToVoid(new B());
- c = funcDynToVoid(new C()); //# 05: compile-time error
+ c = funcDynToVoid(new C());
+ // ^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'A' can't be assigned to a variable of type 'C'.
}
}
@@ -106,19 +134,31 @@
FuncDynToA funcDynToA = func;
a = funcDynToA(new A());
b = funcDynToA(new B());
- c = funcDynToA(new C()); //# 06: compile-time error
+ c = funcDynToA(new C());
+ // ^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'A' can't be assigned to a variable of type 'C'.
if (funcDynToA is FuncDynToDyn) {
// No promotion: FuncDynToDyn <\: FuncDynToA.
a = funcDynToA(new A());
b = funcDynToA(new B());
- c = funcDynToA(new C()); //# 08: compile-time error
+ c = funcDynToA(new C());
+ // ^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'A' can't be assigned to a variable of type 'C'.
}
if (funcDynToA is FuncDynToVoid) {
// No promotion: FuncDynToVoid <\: FuncDynToA.
a = funcDynToA(new A());
b = funcDynToA(new B());
- c = funcDynToA(new C()); //# 07: compile-time error
+ c = funcDynToA(new C());
+ // ^^^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'A' can't be assigned to a variable of type 'C'.
}
}
diff --git a/tests/language_2/type_promotion_local_runtime_test.dart b/tests/language_2/type_promotion_local_runtime_test.dart
new file mode 100644
index 0000000..b010208
--- /dev/null
+++ b/tests/language_2/type_promotion_local_runtime_test.dart
@@ -0,0 +1,163 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test type promotion of locals.
+
+class A {
+ var a = "a";
+}
+
+class B extends A {
+ var b = "b";
+}
+
+class C extends B {
+ var c = "c";
+}
+
+class D extends A {
+ var d = "d";
+}
+
+class E implements C, D {
+ var a = "";
+ var b = "";
+ var c = "";
+ var d = "";
+}
+
+void main() {
+ A a = new E();
+ print(a.a);
+
+
+
+
+ if (a is B) {
+ print(a.a);
+ print(a.b);
+
+
+
+ if (a is C) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+
+ print(a.a);
+ print(a.b);
+
+
+ }
+ if (a is C) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+
+ if (a is B) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+ if (a is D) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+
+ print(a.a);
+
+
+
+
+ if (a is D) {
+ print(a.a);
+
+
+ print(a.d);
+ }
+
+ print(a.a);
+
+
+
+
+ var o1 = a is B
+ ? '${a.a}'
+ '${a.b}'
+
+
+ : '${a.a}'
+
+
+
+ ;
+
+ var o2 = a is C
+ ? '${a.a}'
+ '${a.b}'
+ '${a.c}'
+
+ : '${a.a}'
+
+
+
+ ;
+
+ var o3 = a is D
+ ? '${a.a}'
+
+
+ '${a.d}'
+ : '${a.a}'
+
+
+
+ ;
+
+ if (a is B && a is B) {
+ print(a.a);
+ print(a.b);
+
+
+ }
+ if (a is B && a is C) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+ if (a is C && a is B) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+ if (a is C && a is D) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+ if (a is D && a is C) {
+ print(a.a);
+
+
+ print(a.d);
+ }
+}
diff --git a/tests/language_2/type_promotion_local_test.dart b/tests/language_2/type_promotion_local_test.dart
index 974c0dc..c0fe87d 100644
--- a/tests/language_2/type_promotion_local_test.dart
+++ b/tests/language_2/type_promotion_local_test.dart
@@ -30,131 +30,254 @@
void main() {
A a = new E();
print(a.a);
- print(a.b); //# 01: compile-time error
- print(a.c); //# 02: compile-time error
- print(a.d); //# 03: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
if (a is B) {
print(a.a);
print(a.b);
- print(a.c); //# 04: compile-time error
- print(a.d); //# 05: compile-time error
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
if (a is C) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 06: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
print(a.a);
print(a.b);
- print(a.c); //# 07: compile-time error
- print(a.d); //# 08: compile-time error
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
}
if (a is C) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 09: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
if (a is B) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 10: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
if (a is D) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 11: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 12: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
print(a.a);
- print(a.b); //# 13: compile-time error
- print(a.c); //# 14: compile-time error
- print(a.d); //# 15: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
if (a is D) {
print(a.a);
- print(a.b); //# 16: compile-time error
- print(a.c); //# 17: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'D'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'D'.
print(a.d);
}
print(a.a);
- print(a.b); //# 18: compile-time error
- print(a.c); //# 19: compile-time error
- print(a.d); //# 20: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
var o1 = a is B
? '${a.a}'
'${a.b}'
- '${a.c}' //# 21: compile-time error
- '${a.d}' //# 22: compile-time error
+ '${a.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ '${a.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
: '${a.a}'
- '${a.b}' //# 23: compile-time error
- '${a.c}' //# 24: compile-time error
- '${a.d}' //# 25: compile-time error
+ '${a.b}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ '${a.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ '${a.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
;
var o2 = a is C
? '${a.a}'
'${a.b}'
'${a.c}'
- '${a.d}' //# 26: compile-time error
+ '${a.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
: '${a.a}'
- '${a.b}' //# 27: compile-time error
- '${a.c}' //# 28: compile-time error
- '${a.d}' //# 29: compile-time error
+ '${a.b}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ '${a.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ '${a.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
;
var o3 = a is D
? '${a.a}'
- '${a.b}' //# 30: compile-time error
- '${a.c}' //# 31: compile-time error
+ '${a.b}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'D'.
+ '${a.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'D'.
'${a.d}'
: '${a.a}'
- '${a.b}' //# 32: compile-time error
- '${a.c}' //# 33: compile-time error
- '${a.d}' //# 34: compile-time error
+ '${a.b}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ '${a.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ '${a.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
;
if (a is B && a is B) {
print(a.a);
print(a.b);
- print(a.c); //# 35: compile-time error
- print(a.d); //# 36: compile-time error
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
}
if (a is B && a is C) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 37: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
if (a is C && a is B) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 38: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
if (a is C && a is D) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 39: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
if (a is D && a is C) {
print(a.a);
- print(a.b); //# 40: compile-time error
- print(a.c); //# 41: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'D'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'D'.
print(a.d);
}
}
diff --git a/tests/language_2/type_promotion_logical_and_runtime_test.dart b/tests/language_2/type_promotion_logical_and_runtime_test.dart
new file mode 100644
index 0000000..700d020
--- /dev/null
+++ b/tests/language_2/type_promotion_logical_and_runtime_test.dart
@@ -0,0 +1,52 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test type promotion of locals potentially mutated.
+
+class A {
+ var a = true;
+}
+
+class B extends A {
+ var b = true;
+}
+
+class C extends B {
+ var c = true;
+}
+
+class D extends A {
+ var d = true;
+}
+
+class E implements C, D {
+ var a = true;
+ var b = true;
+ var c = true;
+ var d = true;
+}
+
+void main() {
+ A a = new E();
+ var b;
+ if (a is D && ((a = new D()) != null)) {
+
+ }
+ if (a is D && (b = a.d)) {
+
+ a = null;
+ }
+ if ((((a) is D) && (b = (a).d))) {
+
+ a = null;
+ }
+ if (f(a = null) && a is D) {
+ b = a.d;
+ }
+}
+
+bool f(x) => true;
diff --git a/tests/language_2/type_promotion_logical_and_test.dart b/tests/language_2/type_promotion_logical_and_test.dart
index e60d85c..7dc5b2b 100644
--- a/tests/language_2/type_promotion_logical_and_test.dart
+++ b/tests/language_2/type_promotion_logical_and_test.dart
@@ -31,14 +31,22 @@
A a = new E();
var b;
if (a is D && ((a = new D()) != null)) {
- b = a.d; //# 01: compile-time error
+ b = a.d;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
}
if (a is D && (b = a.d)) {
- b = a.d; //# 02: compile-time error
+ b = a.d;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
a = null;
}
if ((((a) is D) && (b = (a).d))) {
- b = a.d; //# 03: compile-time error
+ b = a.d;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
a = null;
}
if (f(a = null) && a is D) {
diff --git a/tests/language_2/type_promotion_more_specific_runtime_1_test.dart b/tests/language_2/type_promotion_more_specific_runtime_1_test.dart
new file mode 100644
index 0000000..a71d634
--- /dev/null
+++ b/tests/language_2/type_promotion_more_specific_runtime_1_test.dart
@@ -0,0 +1,93 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test use of more specific in type promotion of interface types.
+
+class A {
+ var a;
+}
+
+class B extends A {
+ var b;
+}
+
+class C {
+ var c;
+}
+
+class D<T> {
+ T d;
+
+ D(this.d);
+}
+
+class E<T> extends D<T> {
+ T e;
+
+ E(e)
+ : this.e = e,
+ super(e);
+}
+
+void main() {
+ testInterface();
+ testGeneric();
+}
+
+void testInterface() {
+ var x;
+ var y;
+
+ A a = new B();
+ if (a is B) {
+ // Promotion B << A.
+ x = a.b;
+ }
+ if (a is C) {
+ // No promotion C !<< A.
+
+ }
+ B b = new B();
+ if (b is A) {
+ // No promotion B !<< A.
+
+ }
+ if (x is A) {
+ // Promotion A << dynamic.
+
+ }
+}
+
+testGeneric() {
+ var x;
+ var y;
+
+ D d1 = new E<B>(null);
+ if (d1 is E) {
+ // Promotion: E << D.
+
+ }
+ if (d1 is E<A>) {
+ // Promotion: E<A> << D.
+
+
+
+ }
+
+ D<A> d2 = new E<B>(null);
+ if (d2 is E) {
+ // No promotion: E !<< D<A>
+
+ }
+
+ D<A> d3 = new E<B>(new B());
+ if (d3 is E<B>) {
+ // Promotion: E<B> << D<A>
+
+
+ }
+}
diff --git a/tests/language_2/type_promotion_more_specific_runtime_2_test.dart b/tests/language_2/type_promotion_more_specific_runtime_2_test.dart
new file mode 100644
index 0000000..1f9fd5c
--- /dev/null
+++ b/tests/language_2/type_promotion_more_specific_runtime_2_test.dart
@@ -0,0 +1,93 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test use of more specific in type promotion of interface types.
+
+class A {
+ var a;
+}
+
+class B extends A {
+ var b;
+}
+
+class C {
+ var c;
+}
+
+class D<T> {
+ T d;
+
+ D(this.d);
+}
+
+class E<T> extends D<T> {
+ T e;
+
+ E(e)
+ : this.e = e,
+ super(e);
+}
+
+void main() {
+ testInterface();
+ testGeneric();
+}
+
+void testInterface() {
+ var x;
+ var y;
+
+ A a = new B();
+ if (a is B) {
+ // Promotion B << A.
+
+ }
+ if (a is C) {
+ // No promotion C !<< A.
+
+ }
+ B b = new B();
+ if (b is A) {
+ // No promotion B !<< A.
+ x = b.b;
+ }
+ if (x is A) {
+ // Promotion A << dynamic.
+
+ }
+}
+
+testGeneric() {
+ var x;
+ var y;
+
+ D d1 = new E<B>(null);
+ if (d1 is E) {
+ // Promotion: E << D.
+
+ }
+ if (d1 is E<A>) {
+ // Promotion: E<A> << D.
+
+
+
+ }
+
+ D<A> d2 = new E<B>(null);
+ if (d2 is E) {
+ // No promotion: E !<< D<A>
+
+ }
+
+ D<A> d3 = new E<B>(new B());
+ if (d3 is E<B>) {
+ // Promotion: E<B> << D<A>
+
+
+ }
+}
diff --git a/tests/language_2/type_promotion_more_specific_runtime_3_test.dart b/tests/language_2/type_promotion_more_specific_runtime_3_test.dart
new file mode 100644
index 0000000..93fe239
--- /dev/null
+++ b/tests/language_2/type_promotion_more_specific_runtime_3_test.dart
@@ -0,0 +1,93 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test use of more specific in type promotion of interface types.
+
+class A {
+ var a;
+}
+
+class B extends A {
+ var b;
+}
+
+class C {
+ var c;
+}
+
+class D<T> {
+ T d;
+
+ D(this.d);
+}
+
+class E<T> extends D<T> {
+ T e;
+
+ E(e)
+ : this.e = e,
+ super(e);
+}
+
+void main() {
+ testInterface();
+ testGeneric();
+}
+
+void testInterface() {
+ var x;
+ var y;
+
+ A a = new B();
+ if (a is B) {
+ // Promotion B << A.
+
+ }
+ if (a is C) {
+ // No promotion C !<< A.
+
+ }
+ B b = new B();
+ if (b is A) {
+ // No promotion B !<< A.
+
+ }
+ if (x is A) {
+ // Promotion A << dynamic.
+
+ }
+}
+
+testGeneric() {
+ var x;
+ var y;
+
+ D d1 = new E<B>(null);
+ if (d1 is E) {
+ // Promotion: E << D.
+ x = d1.e;
+ }
+ if (d1 is E<A>) {
+ // Promotion: E<A> << D.
+
+
+
+ }
+
+ D<A> d2 = new E<B>(null);
+ if (d2 is E) {
+ // No promotion: E !<< D<A>
+
+ }
+
+ D<A> d3 = new E<B>(new B());
+ if (d3 is E<B>) {
+ // Promotion: E<B> << D<A>
+
+
+ }
+}
diff --git a/tests/language_2/type_promotion_more_specific_runtime_4_test.dart b/tests/language_2/type_promotion_more_specific_runtime_4_test.dart
new file mode 100644
index 0000000..339a93c
--- /dev/null
+++ b/tests/language_2/type_promotion_more_specific_runtime_4_test.dart
@@ -0,0 +1,93 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test use of more specific in type promotion of interface types.
+
+class A {
+ var a;
+}
+
+class B extends A {
+ var b;
+}
+
+class C {
+ var c;
+}
+
+class D<T> {
+ T d;
+
+ D(this.d);
+}
+
+class E<T> extends D<T> {
+ T e;
+
+ E(e)
+ : this.e = e,
+ super(e);
+}
+
+void main() {
+ testInterface();
+ testGeneric();
+}
+
+void testInterface() {
+ var x;
+ var y;
+
+ A a = new B();
+ if (a is B) {
+ // Promotion B << A.
+
+ }
+ if (a is C) {
+ // No promotion C !<< A.
+
+ }
+ B b = new B();
+ if (b is A) {
+ // No promotion B !<< A.
+
+ }
+ if (x is A) {
+ // Promotion A << dynamic.
+
+ }
+}
+
+testGeneric() {
+ var x;
+ var y;
+
+ D d1 = new E<B>(null);
+ if (d1 is E) {
+ // Promotion: E << D.
+
+ }
+ if (d1 is E<A>) {
+ // Promotion: E<A> << D.
+
+
+ x = d1.e;
+ }
+
+ D<A> d2 = new E<B>(null);
+ if (d2 is E) {
+ // No promotion: E !<< D<A>
+
+ }
+
+ D<A> d3 = new E<B>(new B());
+ if (d3 is E<B>) {
+ // Promotion: E<B> << D<A>
+
+
+ }
+}
diff --git a/tests/language_2/type_promotion_more_specific_runtime_5_test.dart b/tests/language_2/type_promotion_more_specific_runtime_5_test.dart
new file mode 100644
index 0000000..4a8b450
--- /dev/null
+++ b/tests/language_2/type_promotion_more_specific_runtime_5_test.dart
@@ -0,0 +1,93 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test use of more specific in type promotion of interface types.
+
+class A {
+ var a;
+}
+
+class B extends A {
+ var b;
+}
+
+class C {
+ var c;
+}
+
+class D<T> {
+ T d;
+
+ D(this.d);
+}
+
+class E<T> extends D<T> {
+ T e;
+
+ E(e)
+ : this.e = e,
+ super(e);
+}
+
+void main() {
+ testInterface();
+ testGeneric();
+}
+
+void testInterface() {
+ var x;
+ var y;
+
+ A a = new B();
+ if (a is B) {
+ // Promotion B << A.
+
+ }
+ if (a is C) {
+ // No promotion C !<< A.
+
+ }
+ B b = new B();
+ if (b is A) {
+ // No promotion B !<< A.
+
+ }
+ if (x is A) {
+ // Promotion A << dynamic.
+
+ }
+}
+
+testGeneric() {
+ var x;
+ var y;
+
+ D d1 = new E<B>(null);
+ if (d1 is E) {
+ // Promotion: E << D.
+
+ }
+ if (d1 is E<A>) {
+ // Promotion: E<A> << D.
+
+
+
+ }
+
+ D<A> d2 = new E<B>(null);
+ if (d2 is E) {
+ // No promotion: E !<< D<A>
+
+ }
+
+ D<A> d3 = new E<B>(new B());
+ if (d3 is E<B>) {
+ // Promotion: E<B> << D<A>
+ x = d3.d.b;
+
+ }
+}
diff --git a/tests/language_2/type_promotion_more_specific_runtime_6_test.dart b/tests/language_2/type_promotion_more_specific_runtime_6_test.dart
new file mode 100644
index 0000000..ade8839
--- /dev/null
+++ b/tests/language_2/type_promotion_more_specific_runtime_6_test.dart
@@ -0,0 +1,93 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test use of more specific in type promotion of interface types.
+
+class A {
+ var a;
+}
+
+class B extends A {
+ var b;
+}
+
+class C {
+ var c;
+}
+
+class D<T> {
+ T d;
+
+ D(this.d);
+}
+
+class E<T> extends D<T> {
+ T e;
+
+ E(e)
+ : this.e = e,
+ super(e);
+}
+
+void main() {
+ testInterface();
+ testGeneric();
+}
+
+void testInterface() {
+ var x;
+ var y;
+
+ A a = new B();
+ if (a is B) {
+ // Promotion B << A.
+
+ }
+ if (a is C) {
+ // No promotion C !<< A.
+
+ }
+ B b = new B();
+ if (b is A) {
+ // No promotion B !<< A.
+
+ }
+ if (x is A) {
+ // Promotion A << dynamic.
+
+ }
+}
+
+testGeneric() {
+ var x;
+ var y;
+
+ D d1 = new E<B>(null);
+ if (d1 is E) {
+ // Promotion: E << D.
+
+ }
+ if (d1 is E<A>) {
+ // Promotion: E<A> << D.
+
+
+
+ }
+
+ D<A> d2 = new E<B>(null);
+ if (d2 is E) {
+ // No promotion: E !<< D<A>
+
+ }
+
+ D<A> d3 = new E<B>(new B());
+ if (d3 is E<B>) {
+ // Promotion: E<B> << D<A>
+
+ x = d3.e.b;
+ }
+}
diff --git a/tests/language_2/type_promotion_more_specific_runtime_test.dart b/tests/language_2/type_promotion_more_specific_runtime_test.dart
new file mode 100644
index 0000000..3876f67
--- /dev/null
+++ b/tests/language_2/type_promotion_more_specific_runtime_test.dart
@@ -0,0 +1,93 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test use of more specific in type promotion of interface types.
+
+class A {
+ var a;
+}
+
+class B extends A {
+ var b;
+}
+
+class C {
+ var c;
+}
+
+class D<T> {
+ T d;
+
+ D(this.d);
+}
+
+class E<T> extends D<T> {
+ T e;
+
+ E(e)
+ : this.e = e,
+ super(e);
+}
+
+void main() {
+ testInterface();
+ testGeneric();
+}
+
+void testInterface() {
+ var x;
+ var y;
+
+ A a = new B();
+ if (a is B) {
+ // Promotion B << A.
+
+ }
+ if (a is C) {
+ // No promotion C !<< A.
+
+ }
+ B b = new B();
+ if (b is A) {
+ // No promotion B !<< A.
+
+ }
+ if (x is A) {
+ // Promotion A << dynamic.
+
+ }
+}
+
+testGeneric() {
+ var x;
+ var y;
+
+ D d1 = new E<B>(null);
+ if (d1 is E) {
+ // Promotion: E << D.
+
+ }
+ if (d1 is E<A>) {
+ // Promotion: E<A> << D.
+
+
+
+ }
+
+ D<A> d2 = new E<B>(null);
+ if (d2 is E) {
+ // No promotion: E !<< D<A>
+
+ }
+
+ D<A> d3 = new E<B>(new B());
+ if (d3 is E<B>) {
+ // Promotion: E<B> << D<A>
+
+
+ }
+}
diff --git a/tests/language_2/type_promotion_more_specific_test.dart b/tests/language_2/type_promotion_more_specific_test.dart
index 03f40a7..ec19e52 100644
--- a/tests/language_2/type_promotion_more_specific_test.dart
+++ b/tests/language_2/type_promotion_more_specific_test.dart
@@ -42,20 +42,26 @@
A a = new B();
if (a is B) {
// Promotion B << A.
- x = a.b; //# 01: ok
+ x = a.b;
}
if (a is C) {
// No promotion C !<< A.
- x = a.c; //# 02: compile-time error
+ x = a.c;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
}
B b = new B();
if (b is A) {
// No promotion B !<< A.
- x = b.b; //# 03: ok
+ x = b.b;
}
if (x is A) {
// Promotion A << dynamic.
- y = x.b; //# 04: compile-time error
+ y = x.b;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
}
}
@@ -66,25 +72,36 @@
D d1 = new E<B>(null);
if (d1 is E) {
// Promotion: E << D.
- x = d1.e; //# 05: ok
+ x = d1.e;
}
if (d1 is E<A>) {
// Promotion: E<A> << D.
- int a = d1.d; //# 06: compile-time error
- String b = d1.d; //# 07: compile-time error
- x = d1.e; //# 08: ok
+ int a = d1.d;
+ // ^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'A' can't be assigned to a variable of type 'int'.
+ String b = d1.d;
+ // ^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'A' can't be assigned to a variable of type 'String'.
+ x = d1.e;
}
D<A> d2 = new E<B>(null);
if (d2 is E) {
// No promotion: E !<< D<A>
- x = d2.e; //# 09: compile-time error
+ x = d2.e;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'e' isn't defined for the class 'D<A>'.
}
D<A> d3 = new E<B>(new B());
if (d3 is E<B>) {
// Promotion: E<B> << D<A>
- x = d3.d.b; //# 12: ok
- x = d3.e.b; //# 13: ok
+ x = d3.d.b;
+ x = d3.e.b;
}
}
diff --git a/tests/language_2/type_promotion_multiple_runtime_test.dart b/tests/language_2/type_promotion_multiple_runtime_test.dart
new file mode 100644
index 0000000..b465d9b
--- /dev/null
+++ b/tests/language_2/type_promotion_multiple_runtime_test.dart
@@ -0,0 +1,103 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test type promotion of locals.
+
+class A {
+ var a = "a";
+}
+
+class B extends A {
+ var b = "b";
+}
+
+class C extends B {
+ var c = "c";
+}
+
+class D extends A {
+ var d = "d";
+}
+
+class E implements C, D {
+ var a = "";
+ var b = "";
+ var c = "";
+ var d = "";
+}
+
+void main() {
+ test(new E());
+}
+
+void test(A a1) {
+ A a2 = new E();
+ print(a1.a);
+
+
+
+
+ print(a2.a);
+
+
+
+
+ if (a1 is B && a2 is C) {
+ print(a1.a);
+ print(a1.b);
+
+
+
+ print(a2.a);
+ print(a2.b);
+ print(a2.c);
+
+
+ if (a1 is C && a2 is D) {
+ print(a1.a);
+ print(a1.b);
+ print(a1.c);
+
+
+ print(a2.a);
+ print(a2.b);
+ print(a2.c);
+
+ }
+ }
+
+ var o1 = a1 is B && a2 is C
+ ? '${a1.a}'
+ '${a1.b}'
+
+
+ '${a2.a}'
+ '${a2.b}'
+ '${a2.c}'
+
+ : '${a1.a}'
+
+
+
+ '${a2.a}'
+
+
+
+ ;
+
+ if (a2 is C && a1 is B && a1 is C && a2 is B && a2 is D) {
+ print(a1.a);
+ print(a1.b);
+ print(a1.c);
+
+
+ print(a2.a);
+ print(a2.b);
+ print(a2.c);
+
+ }
+}
diff --git a/tests/language_2/type_promotion_multiple_test.dart b/tests/language_2/type_promotion_multiple_test.dart
index b6a7130..8410597 100644
--- a/tests/language_2/type_promotion_multiple_test.dart
+++ b/tests/language_2/type_promotion_multiple_test.dart
@@ -34,67 +34,133 @@
void test(A a1) {
A a2 = new E();
print(a1.a);
- print(a1.b); //# 01: compile-time error
- print(a1.c); //# 02: compile-time error
- print(a1.d); //# 03: compile-time error
+ print(a1.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ print(a1.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ print(a1.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
print(a2.a);
- print(a2.b); //# 04: compile-time error
- print(a2.c); //# 05: compile-time error
- print(a2.d); //# 06: compile-time error
+ print(a2.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ print(a2.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ print(a2.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
if (a1 is B && a2 is C) {
print(a1.a);
print(a1.b);
- print(a1.c); //# 07: compile-time error
- print(a1.d); //# 08: compile-time error
+ print(a1.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ print(a1.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
print(a2.a);
print(a2.b);
print(a2.c);
- print(a2.d); //# 09: compile-time error
+ print(a2.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
if (a1 is C && a2 is D) {
print(a1.a);
print(a1.b);
print(a1.c);
- print(a1.d); //# 10: compile-time error
+ print(a1.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
print(a2.a);
print(a2.b);
print(a2.c);
- print(a2.d); //# 11: compile-time error
+ print(a2.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
}
var o1 = a1 is B && a2 is C
? '${a1.a}'
'${a1.b}'
- '${a1.c}' //# 12: compile-time error
- '${a1.d}' //# 13: compile-time error
+ '${a1.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ '${a1.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
'${a2.a}'
'${a2.b}'
'${a2.c}'
- '${a2.d}' //# 14: compile-time error
+ '${a2.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
: '${a1.a}'
- '${a1.b}' //# 15: compile-time error
- '${a1.c}' //# 16: compile-time error
- '${a1.d}' //# 17: compile-time error
+ '${a1.b}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ '${a1.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ '${a1.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
'${a2.a}'
- '${a2.b}' //# 18: compile-time error
- '${a2.c}' //# 19: compile-time error
- '${a2.d}' //# 20: compile-time error
+ '${a2.b}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ '${a2.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ '${a2.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
;
if (a2 is C && a1 is B && a1 is C && a2 is B && a2 is D) {
print(a1.a);
print(a1.b);
print(a1.c);
- print(a1.d); //# 21: compile-time error
+ print(a1.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
print(a2.a);
print(a2.b);
print(a2.c);
- print(a2.d); //# 22: compile-time error
+ print(a2.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
}
diff --git a/tests/language_2/type_promotion_parameter_runtime_test.dart b/tests/language_2/type_promotion_parameter_runtime_test.dart
new file mode 100644
index 0000000..935dd06
--- /dev/null
+++ b/tests/language_2/type_promotion_parameter_runtime_test.dart
@@ -0,0 +1,211 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test type promotion of parameters.
+
+class A {
+ var a = "a";
+}
+
+class B extends A {
+ var b = "b";
+}
+
+class C extends B {
+ var c = "c";
+}
+
+class D extends A {
+ var d = "d";
+}
+
+class E implements C, D {
+ var a = "";
+ var b = "";
+ var c = "";
+ var d = "";
+}
+
+void main() {
+ test(new E());
+}
+
+void test(A a) {
+ print(a.a);
+
+
+
+
+ if (a is B) {
+ print(a.a);
+ print(a.b);
+
+
+
+ if (a is C) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+
+ print(a.a);
+ print(a.b);
+
+
+ }
+ if (a is C) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+
+ if (a is B) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+ if (a is D) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+
+ print(a.a);
+
+
+
+
+ if (a is D) {
+ print(a.a);
+
+
+ print(a.d);
+ }
+
+ print(a.a);
+
+
+
+
+ var o1 = a is B
+ ? '${a.a}'
+ '${a.b}'
+
+
+ : '${a.a}'
+
+
+
+ ;
+
+ var o2 = a is C
+ ? '${a.a}'
+ '${a.b}'
+ '${a.c}'
+
+ : '${a.a}'
+
+
+
+ ;
+
+ var o3 = a is D
+ ? '${a.a}'
+
+
+ '${a.d}'
+ : '${a.a}'
+
+
+
+ ;
+
+ if (a is B && a is B) {
+ print(a.a);
+ print(a.b);
+
+
+ }
+ if (a is B && a is C) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+ if (a is C && a is B) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+ if (a is C && a is D) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+ if (a is D && a is C) {
+ print(a.a);
+
+
+ print(a.d);
+ }
+ if (a is D &&
+ a.a == ""
+
+
+ &&
+ a.d == "") {
+ print(a.a);
+
+
+ print(a.d);
+ }
+ if (a.a == ""
+
+
+
+ &&
+ a is B &&
+ a.a == "" &&
+ a.b == ""
+
+
+ &&
+ a is C &&
+ a.a == "" &&
+ a.b == "" &&
+ a.c == ""
+
+ ) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+ if ((a is B)) {
+ print(a.a);
+ print(a.b);
+
+
+ }
+ if ((a is B && (a) is C) && a is B) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+
+ }
+}
diff --git a/tests/language_2/type_promotion_parameter_test.dart b/tests/language_2/type_promotion_parameter_test.dart
index ae718d3..b93d764 100644
--- a/tests/language_2/type_promotion_parameter_test.dart
+++ b/tests/language_2/type_promotion_parameter_test.dart
@@ -33,176 +33,341 @@
void test(A a) {
print(a.a);
- print(a.b); //# 01: compile-time error
- print(a.c); //# 02: compile-time error
- print(a.d); //# 03: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
if (a is B) {
print(a.a);
print(a.b);
- print(a.c); //# 04: compile-time error
- print(a.d); //# 05: compile-time error
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
if (a is C) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 06: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
print(a.a);
print(a.b);
- print(a.c); //# 07: compile-time error
- print(a.d); //# 08: compile-time error
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
}
if (a is C) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 09: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
if (a is B) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 10: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
if (a is D) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 11: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 12: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
print(a.a);
- print(a.b); //# 13: compile-time error
- print(a.c); //# 14: compile-time error
- print(a.d); //# 15: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
if (a is D) {
print(a.a);
- print(a.b); //# 16: compile-time error
- print(a.c); //# 17: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'D'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'D'.
print(a.d);
}
print(a.a);
- print(a.b); //# 18: compile-time error
- print(a.c); //# 19: compile-time error
- print(a.d); //# 20: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
var o1 = a is B
? '${a.a}'
'${a.b}'
- '${a.c}' //# 21: compile-time error
- '${a.d}' //# 22: compile-time error
+ '${a.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ '${a.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
: '${a.a}'
- '${a.b}' //# 23: compile-time error
- '${a.c}' //# 24: compile-time error
- '${a.d}' //# 25: compile-time error
+ '${a.b}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ '${a.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ '${a.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
;
var o2 = a is C
? '${a.a}'
'${a.b}'
'${a.c}'
- '${a.d}' //# 26: compile-time error
+ '${a.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
: '${a.a}'
- '${a.b}' //# 27: compile-time error
- '${a.c}' //# 28: compile-time error
- '${a.d}' //# 29: compile-time error
+ '${a.b}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ '${a.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ '${a.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
;
var o3 = a is D
? '${a.a}'
- '${a.b}' //# 30: compile-time error
- '${a.c}' //# 31: compile-time error
+ '${a.b}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'D'.
+ '${a.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'D'.
'${a.d}'
: '${a.a}'
- '${a.b}' //# 32: compile-time error
- '${a.c}' //# 33: compile-time error
- '${a.d}' //# 34: compile-time error
+ '${a.b}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ '${a.c}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ '${a.d}'
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
;
if (a is B && a is B) {
print(a.a);
print(a.b);
- print(a.c); //# 35: compile-time error
- print(a.d); //# 36: compile-time error
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
}
if (a is B && a is C) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 37: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
if (a is C && a is B) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 38: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
if (a is C && a is D) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 39: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
if (a is D && a is C) {
print(a.a);
- print(a.b); //# 40: compile-time error
- print(a.c); //# 41: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'D'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'D'.
print(a.d);
}
if (a is D &&
a.a == ""
- && a.b == "" // //# 42: compile-time error
- && a.c == "" // //# 43: compile-time error
+ && a.b == ""
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'D'.
+ && a.c == ""
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'D'.
&&
a.d == "") {
print(a.a);
- print(a.b); //# 44: compile-time error
- print(a.c); //# 45: compile-time error
+ print(a.b);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'D'.
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'D'.
print(a.d);
}
if (a.a == ""
- && a.b == "" //# 46: compile-time error
- && a.c == "" //# 47: compile-time error
- && a.d == "" //# 48: compile-time error
+ && a.b == ""
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'b' isn't defined for the class 'A'.
+ && a.c == ""
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'A'.
+ && a.d == ""
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'A'.
&&
a is B &&
a.a == "" &&
a.b == ""
- && a.c == "" //# 49: compile-time error
- && a.d == "" //# 50: compile-time error
+ && a.c == ""
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ && a.d == ""
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
&&
a is C &&
a.a == "" &&
a.b == "" &&
a.c == ""
- && a.d == "" //# 51: compile-time error
+ && a.d == ""
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 52: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
if ((a is B)) {
print(a.a);
print(a.b);
- print(a.c); //# 54: compile-time error
- print(a.d); //# 55: compile-time error
+ print(a.c);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'c' isn't defined for the class 'B'.
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'B'.
}
if ((a is B && (a) is C) && a is B) {
print(a.a);
print(a.b);
print(a.c);
- print(a.d); //# 56: compile-time error
+ print(a.d);
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'd' isn't defined for the class 'C'.
}
}
diff --git a/tests/language_2/type_variable_bound_access_runtime_test.dart b/tests/language_2/type_variable_bound_access_runtime_test.dart
new file mode 100644
index 0000000..0c7a123
--- /dev/null
+++ b/tests/language_2/type_variable_bound_access_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2019, 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.
+
+class DynamicClass<T extends dynamic, S extends T> {
+ T field1;
+ T field2;
+
+ DynamicClass(this.field1, this.field2);
+
+ method() => field1 * field2;
+}
+
+class NumClass<T extends num, S extends T> {
+ T field1;
+ S field2;
+
+ NumClass(this.field1, this.field2);
+
+ num method1() => field1 * field2;
+
+
+}
+
+main() {
+ new DynamicClass<num, int>(0.5, 2).method();
+ new NumClass<num, double>(2, 0.5).method1();
+
+}
diff --git a/tests/language_2/type_variable_bound_access_test.dart b/tests/language_2/type_variable_bound_access_test.dart
index 019a75f..77f8594 100644
--- a/tests/language_2/type_variable_bound_access_test.dart
+++ b/tests/language_2/type_variable_bound_access_test.dart
@@ -19,11 +19,14 @@
num method1() => field1 * field2;
- num method2() => field1 + field2.length; //# 01: compile-time error
+ num method2() => field1 + field2.length;
+ // ^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'length' isn't defined for the class 'num'.
}
main() {
new DynamicClass<num, int>(0.5, 2).method();
new NumClass<num, double>(2, 0.5).method1();
- new NumClass<num, double>(2, 0.5).method2(); //# 01: continued
+ new NumClass<num, double>(2, 0.5).method2();
}
diff --git a/tests/language_2/type_variable_bounds3_runtime_test.dart b/tests/language_2/type_variable_bounds3_runtime_test.dart
new file mode 100644
index 0000000..4dd5843
--- /dev/null
+++ b/tests/language_2/type_variable_bounds3_runtime_test.dart
@@ -0,0 +1,21 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test of parameterized types with invalid bounds.
+
+class A<K extends int> {}
+
+class B<X, Y> {
+ foo(x) {
+
+ }
+}
+
+main() {
+ var b = new B<double, double>();
+ b.foo(new A());
+}
diff --git a/tests/language_2/type_variable_bounds3_test.dart b/tests/language_2/type_variable_bounds3_test.dart
index 500d09e..471112b 100644
--- a/tests/language_2/type_variable_bounds3_test.dart
+++ b/tests/language_2/type_variable_bounds3_test.dart
@@ -8,7 +8,11 @@
class B<X, Y> {
foo(x) {
- return x is A<X>; // //# 00: compile-time error
+ return x is A<X>;
+ // ^
+ // [cfe] Type argument 'X' doesn't conform to the bound 'int' of the type variable 'K' on 'A'.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
}
diff --git a/tests/language_2/type_variable_bounds4_runtime_test.dart b/tests/language_2/type_variable_bounds4_runtime_test.dart
new file mode 100644
index 0000000..eef3b1d
--- /dev/null
+++ b/tests/language_2/type_variable_bounds4_runtime_test.dart
@@ -0,0 +1,58 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test instantiation of object with malbounded types.
+
+class A<
+ T
+
+ > {}
+
+class B<T> implements A<T> {}
+
+class C<
+ T
+
+ > implements B<T> {}
+
+class Class<T> {
+ newA() {
+ new A<T>();
+ }
+ newB() {
+ new B<T>();
+ }
+ newC() {
+ new C<T>();
+ }
+}
+
+void test(f()) {
+ var v = f();
+}
+
+void main() {
+ test(() => new A<int>());
+ // TODO(eernst): Should it be a compile-time error to create an instance
+ // of this class in #01?
+ test(() => new B<int>());
+ test(() => new C<int>());
+
+ test(() => new A<String>());
+ test(() => new B<String>());
+ test(() => new C<String>());
+
+ dynamic c = new Class<int>();
+ test(() => c.newA());
+ test(() => c.newB());
+ test(() => c.newC());
+
+ c = new Class<String>();
+ test(() => c.newA());
+ test(() => c.newB());
+ test(() => c.newC());
+}
diff --git a/tests/language_2/type_variable_bounds4_test.dart b/tests/language_2/type_variable_bounds4_test.dart
index d828f77..9908b9c 100644
--- a/tests/language_2/type_variable_bounds4_test.dart
+++ b/tests/language_2/type_variable_bounds4_test.dart
@@ -6,25 +6,37 @@
class A<
T
- extends num //# 01: compile-time error
+ extends num
> {}
class B<T> implements A<T> {}
+// ^
+// [cfe] Type argument 'T' doesn't conform to the bound 'num' of the type variable 'T' on 'A' in the supertype 'A' of class 'B'.
+// ^
+// [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
class C<
T
- extends num //# 01: continued
+ extends num
> implements B<T> {}
class Class<T> {
newA() {
new A<T>();
+ // ^
+ // [cfe] Type argument 'T' doesn't conform to the bound 'num' of the type variable 'T' on 'A'.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
newB() {
new B<T>();
}
newC() {
new C<T>();
+ // ^
+ // [cfe] Type argument 'T' doesn't conform to the bound 'num' of the type variable 'T' on 'C'.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
}
}
@@ -40,8 +52,16 @@
test(() => new C<int>());
test(() => new A<String>());
+ // ^
+ // [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'A'.
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
test(() => new B<String>());
test(() => new C<String>());
+ // ^
+ // [cfe] Type argument 'String' doesn't conform to the bound 'num' of the type variable 'T' on 'C'.
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
dynamic c = new Class<int>();
test(() => c.newA());
diff --git a/tests/language_2/type_variable_conflict2_runtime_test.dart b/tests/language_2/type_variable_conflict2_runtime_test.dart
new file mode 100644
index 0000000..275f8dc
--- /dev/null
+++ b/tests/language_2/type_variable_conflict2_runtime_test.dart
@@ -0,0 +1,59 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// Regression test for issue 13134. Invocation of a type parameter.
+
+import "package:expect/expect.dart";
+
+class C<T> {
+ noSuchMethod(Invocation im) {
+ throw "noSuchMethod shouldn't be called in this test.";
+ }
+
+ // This is equivalent to (T).call(). See issue 19725
+
+
+ // T is in scope, even in static context. Compile-time error to call this.T().
+
+
+ // X is not in scope. NoSuchMethodError.
+
+
+ // Class 'C' has no static method 'T': NoSuchMethodError.
+
+
+ // Class '_Type' has no instance method 'call': NoSuchMethodError.
+
+
+ // Runtime type T not accessible from static context. Compile-time error.
+
+
+ // Class '_Type' has no [] operator: NoSuchMethodError.
+
+
+ // Runtime type T not accessible from static context. Compile-time error.
+
+
+ // Class '_Type' has no member m: NoSuchMethodError.
+
+
+ // Runtime type T not accessible from static context. Compile-time error.
+
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language_2/type_variable_conflict2_test.dart b/tests/language_2/type_variable_conflict2_test.dart
index 9080aa7..c164e5d 100644
--- a/tests/language_2/type_variable_conflict2_test.dart
+++ b/tests/language_2/type_variable_conflict2_test.dart
@@ -12,45 +12,88 @@
}
// This is equivalent to (T).call(). See issue 19725
- foo() => T(); //# 01: compile-time error
+ foo() => T();
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION
+ // [cfe] Method not found: 'T'.
// T is in scope, even in static context. Compile-time error to call this.T().
- static bar() => T(); //# 02: compile-time error
+ static bar() => T();
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION
+ // [cfe] Method not found: 'T'.
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
// X is not in scope. NoSuchMethodError.
- static baz() => X(); //# 03: compile-time error
+ static baz() => X();
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] Method not found: 'X'.
// Class 'C' has no static method 'T': NoSuchMethodError.
- static qux() => C.T(); //# 04: compile-time error
+ static qux() => C.T();
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] Method not found: 'C.T'.
// Class '_Type' has no instance method 'call': NoSuchMethodError.
- quux() => (T)(); //# 05: compile-time error
+ quux() => (T)();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION
+ // ^
+ // [cfe] The method 'call' isn't defined for the class 'Type'.
// Runtime type T not accessible from static context. Compile-time error.
- static corge() => (T)(); //# 06: compile-time error
+ static corge() => (T)();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
+ // [cfe] Type variables can't be used in static members.
+ // ^
+ // [cfe] The method 'call' isn't defined for the class 'Type'.
// Class '_Type' has no [] operator: NoSuchMethodError.
- grault() => T[0]; //# 07: compile-time error
+ grault() => T[0];
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '[]' isn't defined for the class 'Type'.
// Runtime type T not accessible from static context. Compile-time error.
- static garply() => T[0]; //# 08: compile-time error
+ static garply() => T[0];
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
+ // [cfe] Type variables can't be used in static members.
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_OPERATOR
+ // [cfe] The method '[]' isn't defined for the class 'Type'.
// Class '_Type' has no member m: NoSuchMethodError.
- waldo() => T.m; //# 09: compile-time error
+ waldo() => T.m;
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'm' isn't defined for the class 'Type'.
// Runtime type T not accessible from static context. Compile-time error.
- static fred() => T.m; //# 10: compile-time error
+ static fred() => T.m;
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
+ // [cfe] Type variables can't be used in static members.
+ // ^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] The getter 'm' isn't defined for the class 'Type'.
}
main() {
- Expect.throwsNoSuchMethodError(() => new C().foo()); //# 01: continued
- C.bar(); //# 02: continued
- Expect.throwsNoSuchMethodError(() => C.baz()); //# 03: continued
- Expect.throwsNoSuchMethodError(() => C.qux()); //# 04: continued
- Expect.throwsNoSuchMethodError(() => new C().quux()); //# 05: continued
- C.corge(); //# 06: continued
- Expect.throwsNoSuchMethodError(() => new C().grault()); //# 07: continued
- C.garply(); //# 08: continued
- Expect.throwsNoSuchMethodError(() => new C().waldo()); //# 09: continued
- C.fred(); //# 10: continued
+ Expect.throwsNoSuchMethodError(() => new C().foo());
+ C.bar();
+ Expect.throwsNoSuchMethodError(() => C.baz());
+ Expect.throwsNoSuchMethodError(() => C.qux());
+ Expect.throwsNoSuchMethodError(() => new C().quux());
+ C.corge();
+ Expect.throwsNoSuchMethodError(() => new C().grault());
+ C.garply();
+ Expect.throwsNoSuchMethodError(() => new C().waldo());
+ C.fred();
}
diff --git a/tests/language_2/type_variable_conflict_runtime_test.dart b/tests/language_2/type_variable_conflict_runtime_test.dart
new file mode 100644
index 0000000..04623cb
--- /dev/null
+++ b/tests/language_2/type_variable_conflict_runtime_test.dart
@@ -0,0 +1,54 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test that we report a compile-time error when a type parameter conflicts
+// with an instance or static member with the same name.
+
+import "package:expect/expect.dart";
+
+class G1<T> {
+
+}
+
+class G2<T> {
+
+}
+
+class G3<T> {
+
+}
+
+class G4<T> {
+
+}
+
+class G5<T> {
+
+}
+
+class G6<T> {
+
+}
+
+class G7<T> {
+
+}
+
+class G8<T> {
+
+}
+
+main() {
+ new G1<int>();
+ new G2<int>();
+ new G3<int>();
+ new G4<int>();
+ new G5<int>();
+ new G6<int>();
+ new G7<int>();
+ new G8<int>();
+}
diff --git a/tests/language_2/type_variable_conflict_test.dart b/tests/language_2/type_variable_conflict_test.dart
index 5242b0d..cc8e4da 100644
--- a/tests/language_2/type_variable_conflict_test.dart
+++ b/tests/language_2/type_variable_conflict_test.dart
@@ -8,35 +8,67 @@
import "package:expect/expect.dart";
class G1<T> {
- var T; // //# 01: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_TYPE_VARIABLE_AND_MEMBER
+ var T;
+ // ^
+ // [cfe] Conflicts with type variable 'T'.
}
class G2<T> {
- get T {} // //# 02: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_TYPE_VARIABLE_AND_MEMBER
+ get T {}
+ // ^
+ // [cfe] Conflicts with type variable 'T'.
}
class G3<T> {
- T() {} // //# 03: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_TYPE_VARIABLE_AND_MEMBER
+ T() {}
+//^
+// [cfe] Conflicts with type variable 'T'.
}
class G4<T> {
- static var T; // //# 04: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_TYPE_VARIABLE_AND_MEMBER
+ static var T;
+ // ^
+ // [cfe] Conflicts with type variable 'T'.
}
class G5<T> {
- static get T {} // //# 05: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_TYPE_VARIABLE_AND_MEMBER
+ static get T {}
+ // ^
+ // [cfe] Conflicts with type variable 'T'.
}
class G6<T> {
- static T() {} // //# 06: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_TYPE_VARIABLE_AND_MEMBER
+ static T() {}
+ // ^
+ // [cfe] Conflicts with type variable 'T'.
}
class G7<T> {
- set T(_) {} // //# 07: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_TYPE_VARIABLE_AND_MEMBER
+ set T(_) {}
+ // ^
+ // [cfe] Conflicts with type variable 'T'.
}
class G8<T> {
- static set T(x) {} // //# 08: compile-time error
+// ^
+// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_TYPE_VARIABLE_AND_MEMBER
+ static set T(x) {}
+ // ^
+ // [cfe] Conflicts with type variable 'T'.
}
main() {
diff --git a/tests/language_2/type_variable_scope3_runtime_test.dart b/tests/language_2/type_variable_scope3_runtime_test.dart
new file mode 100644
index 0000000..e75b4a0
--- /dev/null
+++ b/tests/language_2/type_variable_scope3_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// Test that a type parameter cannot be repeated.
+
+class Foo<
+ T
+
+ > {}
+
+main() {
+ new Foo<
+ String
+
+ >();
+}
diff --git a/tests/language_2/type_variable_scope3_test.dart b/tests/language_2/type_variable_scope3_test.dart
index cea3ee5..9a38200 100644
--- a/tests/language_2/type_variable_scope3_test.dart
+++ b/tests/language_2/type_variable_scope3_test.dart
@@ -6,12 +6,15 @@
class Foo<
T
- , T // //# 00: compile-time error
+ , T
+ //^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+ // [cfe] A type variable can't have the same name as another.
> {}
main() {
new Foo<
String
- , String // //# 00: continued
+ , String
>();
}
diff --git a/tests/language_2/type_variable_scope_runtime_test.dart b/tests/language_2/type_variable_scope_runtime_test.dart
new file mode 100644
index 0000000..12e327d
--- /dev/null
+++ b/tests/language_2/type_variable_scope_runtime_test.dart
@@ -0,0 +1,51 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+// Test that type variables referenced from within static members are malformed.
+
+class Foo<T> implements I<T> {
+ Foo() {}
+
+ static
+
+ m(
+
+ f) {
+
+ return new Foo<String>();
+ }
+
+ // T is in scope for a factory method.
+ factory Foo.I(Foo<T> f) {
+ Foo<T> x = f;
+ }
+
+ // T is not in scope for a static field.
+
+
+ static
+
+ get f {
+ return new Foo<String>();
+ }
+
+ static void set f(
+
+ value) {}
+}
+
+abstract class I<T> {
+ factory I(Foo<T> f) = Foo<T>.I;
+}
+
+main() {
+ Foo.m(new Foo<String>());
+ new I(new Foo<String>());
+
+ var x = Foo.f;
+ Foo.f = x;
+}
diff --git a/tests/language_2/type_variable_scope_test.dart b/tests/language_2/type_variable_scope_test.dart
index fc53e58..f4c04ca 100644
--- a/tests/language_2/type_variable_scope_test.dart
+++ b/tests/language_2/type_variable_scope_test.dart
@@ -8,12 +8,28 @@
Foo() {}
static
- Foo<T> //# 00: compile-time error
+ Foo<T>
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
m(
- Foo<T> //# 01: compile-time error
+// ^
+// [cfe] Can only use type variables in instance methods.
+ Foo<T>
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
+ // [cfe] Type variables can't be used in static members.
f) {
- Foo<T> x = new Foo<String>(); //# 02: compile-time error
+ Foo<T> x = new Foo<String>();
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
+ // [cfe] Type variables can't be used in static members.
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'Foo<String>' can't be assigned to a variable of type 'Foo<invalid-type>'.
return new Foo<String>();
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.RETURN_OF_INVALID_TYPE
}
// T is in scope for a factory method.
@@ -22,16 +38,32 @@
}
// T is not in scope for a static field.
- static Foo<T> f1; //# 03: compile-time error
+ static Foo<T> f1;
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
+ // [cfe] Type variables can't be used in static members.
+ // ^
+ // [cfe] Verification of the generated program failed:
static
- Foo<T> //# 04: compile-time error
+ Foo<T>
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
get f {
+ // ^
+ // [cfe] Can only use type variables in instance methods.
return new Foo<String>();
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.RETURN_OF_INVALID_TYPE
}
static void set f(
- Foo<T> //# 05: compile-time error
+ // ^
+ // [cfe] Can only use type variables in instance methods.
+ Foo<T>
+ // ^
+ // [analyzer] STATIC_WARNING.TYPE_PARAMETER_REFERENCED_BY_STATIC
+ // [cfe] Type variables can't be used in static members.
value) {}
}
@@ -41,8 +73,14 @@
main() {
Foo.m(new Foo<String>());
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
new I(new Foo<String>());
- Foo.f1 = new Foo<String>(); //# 03: continued
+ Foo.f1 = new Foo<String>();
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
+ // ^
+ // [cfe] A value of type 'Foo<String>' can't be assigned to a variable of type 'Foo<T>'.
var x = Foo.f;
Foo.f = x;
}
diff --git a/tests/language_2/unresolved_default_constructor_runtime_test.dart b/tests/language_2/unresolved_default_constructor_runtime_test.dart
new file mode 100644
index 0000000..dd83067
--- /dev/null
+++ b/tests/language_2/unresolved_default_constructor_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, 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.
+
+// Test unresolved default constructor calls cause compilation errors.
+
+import 'package:expect/expect.dart';
+
+class A {
+ A.named();
+ static method() {}
+}
+
+main() {
+ A.method();
+
+}
diff --git a/tests/language_2/unresolved_default_constructor_test.dart b/tests/language_2/unresolved_default_constructor_test.dart
index 7d9301b..07fdc72 100644
--- a/tests/language_2/unresolved_default_constructor_test.dart
+++ b/tests/language_2/unresolved_default_constructor_test.dart
@@ -13,5 +13,8 @@
main() {
A.method();
- Expect.throws(() => new A()); //# 01: compile-time error
+ Expect.throws(() => new A());
+ // ^
+ // [analyzer] STATIC_WARNING.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT
+ // [cfe] Method not found: 'A'.
}
diff --git a/tests/language_2/unsupported_operators_runtime_test.dart b/tests/language_2/unsupported_operators_runtime_test.dart
new file mode 100644
index 0000000..57eb8b8
--- /dev/null
+++ b/tests/language_2/unsupported_operators_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, 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.
+
+// Test handling of unsupported operators.
+
+library unsupported_operators;
+
+class C {
+ m() {
+ print(
+
+ null);
+ print(
+
+ null);
+ }
+}
+
+void main() {
+ new C().m();
+ new C().m();
+ print(
+
+ null);
+ print(
+
+ null);
+}
diff --git a/tests/language_2/unsupported_operators_test.dart b/tests/language_2/unsupported_operators_test.dart
index 1eb4636..5649260 100644
--- a/tests/language_2/unsupported_operators_test.dart
+++ b/tests/language_2/unsupported_operators_test.dart
@@ -9,10 +9,20 @@
class C {
m() {
print(
- super === //# 01: syntax error
+ super ===
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.UNSUPPORTED_OPERATOR
+ // [cfe] The '===' operator is not supported.
+ // ^
+ // [cfe] The string '===' isn't a user-definable operator.
null);
print(
- super !== //# 02: syntax error
+ super !==
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.UNSUPPORTED_OPERATOR
+ // [cfe] The '!==' operator is not supported.
+ // ^
+ // [cfe] The string '!==' isn't a user-definable operator.
null);
}
}
@@ -21,9 +31,19 @@
new C().m();
new C().m();
print(
- "foo" === //# 03: syntax error
+ "foo" ===
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.UNSUPPORTED_OPERATOR
+ // [cfe] The '===' operator is not supported.
+ // ^
+ // [cfe] The string '===' isn't a user-definable operator.
null);
print(
- "foo" !== //# 04: syntax error
+ "foo" !==
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.UNSUPPORTED_OPERATOR
+ // [cfe] The '!==' operator is not supported.
+ // ^
+ // [cfe] The string '!==' isn't a user-definable operator.
null);
}
diff --git a/tests/language_2/variable_shadow_class_runtime_test.dart b/tests/language_2/variable_shadow_class_runtime_test.dart
new file mode 100644
index 0000000..0c7d951
--- /dev/null
+++ b/tests/language_2/variable_shadow_class_runtime_test.dart
@@ -0,0 +1,29 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, 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.
+import "package:expect/expect.dart";
+
+// Local variables can shadow class names.
+
+class Test {
+ final int field;
+ Test.named(this.field);
+}
+
+main() {
+ {
+
+ // Now this refers to the variable.
+ var i = new Test.named(10);
+ Expect.equals(10, i.field);
+ }
+
+ {
+ // Shadowing is allowed.
+ var Test = 1;
+ Expect.equals(2, Test + 1);
+ }
+}
diff --git a/tests/language_2/variable_shadow_class_test.dart b/tests/language_2/variable_shadow_class_test.dart
index 628819b..d82fef7 100644
--- a/tests/language_2/variable_shadow_class_test.dart
+++ b/tests/language_2/variable_shadow_class_test.dart
@@ -12,9 +12,12 @@
main() {
{
- var Test; //# 01: compile-time error
+ var Test;
// Now this refers to the variable.
var i = new Test.named(10);
+ // ^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'Test.named'.
Expect.equals(10, i.field);
}
diff --git a/tests/language_2/vm/optimized_guarded_field_isolates_test.dart b/tests/language_2/vm/optimized_guarded_field_isolates_test.dart
index 8e68120..2f5ac9a 100644
--- a/tests/language_2/vm/optimized_guarded_field_isolates_test.dart
+++ b/tests/language_2/vm/optimized_guarded_field_isolates_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
// VMOptions=--optimization_counter_threshold=100 --no-background_compilation
// Test field type tracking and field list-length tracking in the presence of
diff --git a/tests/language_2/web_int_literals_runtime_test.dart b/tests/language_2/web_int_literals_runtime_test.dart
new file mode 100644
index 0000000..dfbcf56
--- /dev/null
+++ b/tests/language_2/web_int_literals_runtime_test.dart
@@ -0,0 +1,69 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, 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.
+
+import "package:expect/expect.dart";
+
+main() {
+ check(0x8000000000000000);
+
+ check(0x7FFF00001111F000);
+ check(0x7FFF00001111FC00);
+
+
+
+
+ check(0xFFFF00001111F000);
+ check(0xFFFF00001111F800);
+
+
+
+
+
+ // Test all runs of 53 and 54 bits.
+ check(0x000FFFFFFFFFFFFF);
+ check(0x001FFFFFFFFFFFFF);
+
+ check(0x003FFFFFFFFFFFFE);
+
+ check(0x007FFFFFFFFFFFFC);
+
+ check(0x00FFFFFFFFFFFFF8);
+
+ check(0x01FFFFFFFFFFFFF0);
+
+ check(0x03FFFFFFFFFFFFE0);
+
+ check(0x07FFFFFFFFFFFFC0);
+
+ check(0x0FFFFFFFFFFFFF80);
+
+ check(0x1FFFFFFFFFFFFF00);
+
+ check(0x3FFFFFFFFFFFFE00);
+
+ check(0x7FFFFFFFFFFFFC00);
+
+ check(0xFFFFFFFFFFFFF800);
+
+ // Too big, even on VM.
+
+
+
+ // 9223372036854775808 - 512 is rounded.
+
+ // 9223372036854775808 - 1024 is exact.
+ check(9223372036854774784);
+
+ check(-9223372036854775808);
+
+
+ check(-9223372036854774784);
+
+
+}
+
+check(int n) {}
diff --git a/tests/language_2/web_int_literals_test.dart b/tests/language_2/web_int_literals_test.dart
index a85c49a..094b739 100644
--- a/tests/language_2/web_int_literals_test.dart
+++ b/tests/language_2/web_int_literals_test.dart
@@ -9,58 +9,61 @@
check(0x7FFF00001111F000);
check(0x7FFF00001111FC00);
- check(0x7FFF00001111FE00); // //# 01: compile-time error
- check(0x7FFF00001111FF00); // //# 02: compile-time error
- check(0x7FFF00001111FFFF); // //# 03: compile-time error
+ check(0x7FFF00001111FE00);
+ check(0x7FFF00001111FF00);
+ check(0x7FFF00001111FFFF);
check(0xFFFF00001111F000);
check(0xFFFF00001111F800);
- check(0xFFFF00001111FC00); // //# 10: compile-time error
- check(0xFFFF00001111FE00); // //# 11: compile-time error
- check(0xFFFF00001111FF00); // //# 12: compile-time error
- check(0xFFFF00001111FFFF); // //# 13: compile-time error
+ check(0xFFFF00001111FC00);
+ check(0xFFFF00001111FE00);
+ check(0xFFFF00001111FF00);
+ check(0xFFFF00001111FFFF);
// Test all runs of 53 and 54 bits.
check(0x000FFFFFFFFFFFFF);
check(0x001FFFFFFFFFFFFF);
- check(0x003FFFFFFFFFFFFF); // //# 20: compile-time error
+ check(0x003FFFFFFFFFFFFF);
check(0x003FFFFFFFFFFFFE);
- check(0x007FFFFFFFFFFFFE); // //# 21: compile-time error
+ check(0x007FFFFFFFFFFFFE);
check(0x007FFFFFFFFFFFFC);
- check(0x00FFFFFFFFFFFFFC); // //# 22: compile-time error
+ check(0x00FFFFFFFFFFFFFC);
check(0x00FFFFFFFFFFFFF8);
- check(0x01FFFFFFFFFFFFF8); // //# 23: compile-time error
+ check(0x01FFFFFFFFFFFFF8);
check(0x01FFFFFFFFFFFFF0);
- check(0x03FFFFFFFFFFFFF0); // //# 22: compile-time error
+ check(0x03FFFFFFFFFFFFF0);
check(0x03FFFFFFFFFFFFE0);
- check(0x07FFFFFFFFFFFFE0); // //# 24: compile-time error
+ check(0x07FFFFFFFFFFFFE0);
check(0x07FFFFFFFFFFFFC0);
- check(0x0FFFFFFFFFFFFFC0); // //# 25: compile-time error
+ check(0x0FFFFFFFFFFFFFC0);
check(0x0FFFFFFFFFFFFF80);
- check(0x1FFFFFFFFFFFFF80); // //# 26: compile-time error
+ check(0x1FFFFFFFFFFFFF80);
check(0x1FFFFFFFFFFFFF00);
- check(0x3FFFFFFFFFFFFF00); // //# 27: compile-time error
+ check(0x3FFFFFFFFFFFFF00);
check(0x3FFFFFFFFFFFFE00);
- check(0x7FFFFFFFFFFFFE00); // //# 28: compile-time error
+ check(0x7FFFFFFFFFFFFE00);
check(0x7FFFFFFFFFFFFC00);
- check(0xFFFFFFFFFFFFFC00); // //# 29: compile-time error
+ check(0xFFFFFFFFFFFFFC00);
check(0xFFFFFFFFFFFFF800);
// Too big, even on VM.
- check(9223372036854775808); // //# 60: compile-time error
- check(9223372036854775807); // //# 61: compile-time error
- check(9223372036854775806); // //# 62: compile-time error
+ check(9223372036854775808);
+ // ^^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.INTEGER_LITERAL_OUT_OF_RANGE
+ // [cfe] The integer literal 9223372036854775808 can't be represented in 64 bits.
+ check(9223372036854775807);
+ check(9223372036854775806);
// 9223372036854775808 - 512 is rounded.
- check(9223372036854775296); // //# 63: compile-time error
+ check(9223372036854775296);
// 9223372036854775808 - 1024 is exact.
check(9223372036854774784);
check(-9223372036854775808);
- check(-9223372036854775807); // //# 64: compile-time error
- check(-9223372036854775296); // //# 65: compile-time error
+ check(-9223372036854775807);
+ check(-9223372036854775296);
check(-9223372036854774784);
- check(1000000000000000001); // //# 70: compile-time error
+ check(1000000000000000001);
}
check(int n) {}
diff --git a/tests/language_2/wrong_number_type_arguments_runtime_test.dart b/tests/language_2/wrong_number_type_arguments_runtime_test.dart
new file mode 100644
index 0000000..3a8f42c
--- /dev/null
+++ b/tests/language_2/wrong_number_type_arguments_runtime_test.dart
@@ -0,0 +1,24 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, 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.
+
+import "package:expect/expect.dart";
+
+// Map takes 2 type arguments.
+Map
+
+foo;
+Map
+
+baz;
+
+main() {
+
+ var bar = new Map
+
+ ();
+
+}
diff --git a/tests/language_2/wrong_number_type_arguments_test.dart b/tests/language_2/wrong_number_type_arguments_test.dart
index fad0a11..136a89f 100644
--- a/tests/language_2/wrong_number_type_arguments_test.dart
+++ b/tests/language_2/wrong_number_type_arguments_test.dart
@@ -2,20 +2,21 @@
// 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.
-import "package:expect/expect.dart";
-
// Map takes 2 type arguments.
-Map
- <String> //# 00: compile-time error
-foo;
-Map
- <String> //# 02: compile-time error
-baz;
+Map<String> foo;
+// [error line 6, column 1, length 11]
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 2 type arguments.
+Map<String> baz;
+// [error line 10, column 1, length 11]
+// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS
+// [cfe] Expected 2 type arguments.
main() {
- foo = null; //# 00: continued
- var bar = new Map
- <String> //# 01: compile-time error
- ();
- baz = new Map(); //# 02: continued
+ foo = null;
+ var bar = new Map<String>();
+ // ^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_INVALID_TYPE_PARAMETERS
+ // [cfe] Expected 2 type arguments.
+ baz = new Map();
}
diff --git a/tests/lib_2/html/localstorage_test.dart b/tests/lib_2/html/localstorage_test.dart
index 58cf609..57db920 100644
--- a/tests/lib_2/html/localstorage_test.dart
+++ b/tests/lib_2/html/localstorage_test.dart
@@ -74,7 +74,7 @@
});
test('forEach', () {
- Map<String, String> results = {};
+ var results = <String, String>{};
window.localStorage.forEach((k, v) {
results[k] = v;
});
@@ -91,6 +91,14 @@
unorderedEquals(['val1', 'val2', 'val3']));
});
+ test('getEntries', () {
+ var results = <String, String>{};
+ window.localStorage.entries.forEach((e) {
+ results[e.key] = e.value;
+ });
+ expect(results, equals({'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}));
+ });
+
test('length', () {
expect(window.localStorage.length, 3);
window.localStorage.clear();
diff --git a/tests/lib_2/isolate/bool_from_environment_default_value_test.dart b/tests/lib_2/isolate/bool_from_environment_default_value_test.dart
index 1095e0e..42582fa 100644
--- a/tests/lib_2/isolate/bool_from_environment_default_value_test.dart
+++ b/tests/lib_2/isolate/bool_from_environment_default_value_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/capability_test.dart b/tests/lib_2/isolate/capability_test.dart
index 589c5c6..fd6c4d3 100644
--- a/tests/lib_2/isolate/capability_test.dart
+++ b/tests/lib_2/isolate/capability_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "package:expect/expect.dart";
import "package:async_helper/async_helper.dart";
diff --git a/tests/lib_2/isolate/compile_time_error_test.dart b/tests/lib_2/isolate/compile_time_error_test.dart
index c81fb5e..578bb8c 100644
--- a/tests/lib_2/isolate/compile_time_error_test.dart
+++ b/tests/lib_2/isolate/compile_time_error_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Dart test program for testing that errors thrown from isolates are
// processed correctly and don't result in crashes.
diff --git a/tests/lib_2/isolate/count_test.dart b/tests/lib_2/isolate/count_test.dart
index 740631c..95e2e33 100644
--- a/tests/lib_2/isolate/count_test.dart
+++ b/tests/lib_2/isolate/count_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library CountTest;
import 'dart:isolate';
diff --git a/tests/lib_2/isolate/cross_isolate_message_test.dart b/tests/lib_2/isolate/cross_isolate_message_test.dart
index 683ecb3..7bcdd8d 100644
--- a/tests/lib_2/isolate/cross_isolate_message_test.dart
+++ b/tests/lib_2/isolate/cross_isolate_message_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Dart test program for testing that isolates can communicate to isolates
// other than the main isolate.
diff --git a/tests/lib_2/isolate/deferred_in_isolate2_test.dart b/tests/lib_2/isolate/deferred_in_isolate2_test.dart
index 47d401a..52e5428 100644
--- a/tests/lib_2/isolate/deferred_in_isolate2_test.dart
+++ b/tests/lib_2/isolate/deferred_in_isolate2_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library deferred_in_isolate2_test;
import 'dart:isolate';
diff --git a/tests/lib_2/isolate/deferred_in_isolate_test.dart b/tests/lib_2/isolate/deferred_in_isolate_test.dart
index 496b064..d44f075 100644
--- a/tests/lib_2/isolate/deferred_in_isolate_test.dart
+++ b/tests/lib_2/isolate/deferred_in_isolate_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Test that deferred libraries are supported from isolates other than the root
// isolate.
diff --git a/tests/lib_2/isolate/enum_const_test.dart b/tests/lib_2/isolate/enum_const_test.dart
index 292ba89..0a57f13 100644
--- a/tests/lib_2/isolate/enum_const_test.dart
+++ b/tests/lib_2/isolate/enum_const_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/error_at_spawn_test.dart b/tests/lib_2/isolate/error_at_spawn_test.dart
index 4f5b373..c22f41e 100644
--- a/tests/lib_2/isolate/error_at_spawn_test.dart
+++ b/tests/lib_2/isolate/error_at_spawn_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library error_at_spawn;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/error_at_spawnuri_test.dart b/tests/lib_2/isolate/error_at_spawnuri_test.dart
index 5c428b9..6d0e073 100644
--- a/tests/lib_2/isolate/error_at_spawnuri_test.dart
+++ b/tests/lib_2/isolate/error_at_spawnuri_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library error_at_spawnuri;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/error_exit_at_spawn_test.dart b/tests/lib_2/isolate/error_exit_at_spawn_test.dart
index 603bcb6..9543025 100644
--- a/tests/lib_2/isolate/error_exit_at_spawn_test.dart
+++ b/tests/lib_2/isolate/error_exit_at_spawn_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library error_exit_at_spawn;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/error_exit_at_spawnuri_test.dart b/tests/lib_2/isolate/error_exit_at_spawnuri_test.dart
index 6e9a5a8..cf32b98 100644
--- a/tests/lib_2/isolate/error_exit_at_spawnuri_test.dart
+++ b/tests/lib_2/isolate/error_exit_at_spawnuri_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library error_exit_at_spawnuri;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/exit_at_spawn_test.dart b/tests/lib_2/isolate/exit_at_spawn_test.dart
index 119ca7e..4a2574e 100644
--- a/tests/lib_2/isolate/exit_at_spawn_test.dart
+++ b/tests/lib_2/isolate/exit_at_spawn_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library exit_at_spawn;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/exit_at_spawnuri_test.dart b/tests/lib_2/isolate/exit_at_spawnuri_test.dart
index f415c66..5bb9ed8 100644
--- a/tests/lib_2/isolate/exit_at_spawnuri_test.dart
+++ b/tests/lib_2/isolate/exit_at_spawnuri_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library exit_at_spawn;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/function_send1_test.dart b/tests/lib_2/isolate/function_send1_test.dart
index d766656..9b97739 100644
--- a/tests/lib_2/isolate/function_send1_test.dart
+++ b/tests/lib_2/isolate/function_send1_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "dart:async";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/function_send_test.dart b/tests/lib_2/isolate/function_send_test.dart
index 25eb149..001d857 100644
--- a/tests/lib_2/isolate/function_send_test.dart
+++ b/tests/lib_2/isolate/function_send_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "dart:async";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/handle_error2_test.dart b/tests/lib_2/isolate/handle_error2_test.dart
index 452b46a..435a3ae 100644
--- a/tests/lib_2/isolate/handle_error2_test.dart
+++ b/tests/lib_2/isolate/handle_error2_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library handle_error_test;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/handle_error3_test.dart b/tests/lib_2/isolate/handle_error3_test.dart
index e725822..15b40ce 100644
--- a/tests/lib_2/isolate/handle_error3_test.dart
+++ b/tests/lib_2/isolate/handle_error3_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library handle_error_test;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/handle_error_test.dart b/tests/lib_2/isolate/handle_error_test.dart
index d7e27dc1..365f122 100644
--- a/tests/lib_2/isolate/handle_error_test.dart
+++ b/tests/lib_2/isolate/handle_error_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library handle_error_test;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/illegal_msg_function_test.dart b/tests/lib_2/isolate/illegal_msg_function_test.dart
index 89baaf2..5b5aa45 100644
--- a/tests/lib_2/isolate/illegal_msg_function_test.dart
+++ b/tests/lib_2/isolate/illegal_msg_function_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library illegal_msg_function_test;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/illegal_msg_mirror_test.dart b/tests/lib_2/isolate/illegal_msg_mirror_test.dart
index af5773b..856e4e8 100644
--- a/tests/lib_2/isolate/illegal_msg_mirror_test.dart
+++ b/tests/lib_2/isolate/illegal_msg_mirror_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library illegal_msg_mirror_test;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/int32_length_overflow_test.dart b/tests/lib_2/isolate/int32_length_overflow_test.dart
index 3502ce9..85e2bd7 100644
--- a/tests/lib_2/isolate/int32_length_overflow_test.dart
+++ b/tests/lib_2/isolate/int32_length_overflow_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:async";
import "dart:isolate";
import "dart:typed_data";
diff --git a/tests/lib_2/isolate/int_from_environment_default_value_test.dart b/tests/lib_2/isolate/int_from_environment_default_value_test.dart
index 56ee62e..852d646 100644
--- a/tests/lib_2/isolate/int_from_environment_default_value_test.dart
+++ b/tests/lib_2/isolate/int_from_environment_default_value_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "package:async_helper/async_helper.dart";
diff --git a/tests/lib_2/isolate/isolate_complex_messages_test.dart b/tests/lib_2/isolate/isolate_complex_messages_test.dart
index dd93245..64992dc 100644
--- a/tests/lib_2/isolate/isolate_complex_messages_test.dart
+++ b/tests/lib_2/isolate/isolate_complex_messages_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Dart test program for testing isolate communication with
// complex messages.
diff --git a/tests/lib_2/isolate/isolate_current_test.dart b/tests/lib_2/isolate/isolate_current_test.dart
index bdd62ea..908c42d 100644
--- a/tests/lib_2/isolate/isolate_current_test.dart
+++ b/tests/lib_2/isolate/isolate_current_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library isolate_current_test;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/isolate_import_test.dart b/tests/lib_2/isolate/isolate_import_test.dart
index fc16788..211cced 100644
--- a/tests/lib_2/isolate/isolate_import_test.dart
+++ b/tests/lib_2/isolate/isolate_import_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library IsolateImportNegativeTest;
// Omitting the following import is an error:
diff --git a/tests/lib_2/isolate/isolate_stress_test.dart b/tests/lib_2/isolate/isolate_stress_test.dart
index 8a76b02..449d259 100644
--- a/tests/lib_2/isolate/isolate_stress_test.dart
+++ b/tests/lib_2/isolate/isolate_stress_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// This test creates a lot of isolates. This is meant to exhaust
// resources if the isolates aren't closed correctly (which happened
// in dart2js).
diff --git a/tests/lib_2/isolate/issue_21398_parent_isolate1_test.dart b/tests/lib_2/isolate/issue_21398_parent_isolate1_test.dart
index 74b6cc6..dcb5019 100644
--- a/tests/lib_2/isolate/issue_21398_parent_isolate1_test.dart
+++ b/tests/lib_2/isolate/issue_21398_parent_isolate1_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:isolate';
import "package:expect/expect.dart";
import 'package:async_helper/async_helper.dart';
diff --git a/tests/lib_2/isolate/issue_21398_parent_isolate2_test.dart b/tests/lib_2/isolate/issue_21398_parent_isolate2_test.dart
index 0fe1043..feee51b 100644
--- a/tests/lib_2/isolate/issue_21398_parent_isolate2_test.dart
+++ b/tests/lib_2/isolate/issue_21398_parent_isolate2_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:isolate';
import "package:expect/expect.dart";
import 'package:async_helper/async_helper.dart';
diff --git a/tests/lib_2/isolate/issue_21398_parent_isolate_test.dart b/tests/lib_2/isolate/issue_21398_parent_isolate_test.dart
index ab413e9..851bbf3 100644
--- a/tests/lib_2/isolate/issue_21398_parent_isolate_test.dart
+++ b/tests/lib_2/isolate/issue_21398_parent_isolate_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:isolate';
import "package:expect/expect.dart";
import 'package:async_helper/async_helper.dart';
diff --git a/tests/lib_2/isolate/issue_22778_test.dart b/tests/lib_2/isolate/issue_22778_test.dart
index 51f5a19..28107cc 100644
--- a/tests/lib_2/isolate/issue_22778_test.dart
+++ b/tests/lib_2/isolate/issue_22778_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/issue_24243_parent_isolate_test.dart b/tests/lib_2/isolate/issue_24243_parent_isolate_test.dart
index 2c1dc54..d92815f 100644
--- a/tests/lib_2/isolate/issue_24243_parent_isolate_test.dart
+++ b/tests/lib_2/isolate/issue_24243_parent_isolate_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:collection';
import 'dart:isolate';
diff --git a/tests/lib_2/isolate/issue_35626_test.dart b/tests/lib_2/isolate/issue_35626_test.dart
index 2873d83..1563a8392 100644
--- a/tests/lib_2/isolate/issue_35626_test.dart
+++ b/tests/lib_2/isolate/issue_35626_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Tests that sets of enums can be set through ports.
// https://github.com/dart-lang/sdk/issues/35626
diff --git a/tests/lib_2/isolate/issue_6610_test.dart b/tests/lib_2/isolate/issue_6610_test.dart
index 96cc5e8f..962955e 100644
--- a/tests/lib_2/isolate/issue_6610_test.dart
+++ b/tests/lib_2/isolate/issue_6610_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Testing that Isolate.spawn copies the source code of the parent isolate,
// rather than rereading the parent's source URI.
// https://github.com/dart-lang/sdk/issues/6610
diff --git a/tests/lib_2/isolate/kill2_test.dart b/tests/lib_2/isolate/kill2_test.dart
index 737ee70..f2da76b 100644
--- a/tests/lib_2/isolate/kill2_test.dart
+++ b/tests/lib_2/isolate/kill2_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "dart:async";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/kill_self_synchronously_test.dart b/tests/lib_2/isolate/kill_self_synchronously_test.dart
index 1a40a01..bdb61e8 100644
--- a/tests/lib_2/isolate/kill_self_synchronously_test.dart
+++ b/tests/lib_2/isolate/kill_self_synchronously_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "dart:io";
diff --git a/tests/lib_2/isolate/kill_self_test.dart b/tests/lib_2/isolate/kill_self_test.dart
index 3ab53f4..99131f4 100644
--- a/tests/lib_2/isolate/kill_self_test.dart
+++ b/tests/lib_2/isolate/kill_self_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "dart:async";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/kill_test.dart b/tests/lib_2/isolate/kill_test.dart
index 62a4dd1..4d1e77d 100644
--- a/tests/lib_2/isolate/kill_test.dart
+++ b/tests/lib_2/isolate/kill_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "dart:async";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/large_byte_data_leak_test.dart b/tests/lib_2/isolate/large_byte_data_leak_test.dart
index b55172e..1313519 100644
--- a/tests/lib_2/isolate/large_byte_data_leak_test.dart
+++ b/tests/lib_2/isolate/large_byte_data_leak_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:async";
import "dart:developer" show UserTag;
import "dart:isolate" show Isolate, ReceivePort;
diff --git a/tests/lib_2/isolate/large_byte_data_test.dart b/tests/lib_2/isolate/large_byte_data_test.dart
index d9e3d24..8a78238 100644
--- a/tests/lib_2/isolate/large_byte_data_test.dart
+++ b/tests/lib_2/isolate/large_byte_data_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:async";
import "dart:isolate";
import "dart:typed_data";
diff --git a/tests/lib_2/isolate/mandel_isolate_test.dart b/tests/lib_2/isolate/mandel_isolate_test.dart
index ee21f1e..84f7d14 100644
--- a/tests/lib_2/isolate/mandel_isolate_test.dart
+++ b/tests/lib_2/isolate/mandel_isolate_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library MandelIsolateTest;
import 'dart:async';
diff --git a/tests/lib_2/isolate/message2_test.dart b/tests/lib_2/isolate/message2_test.dart
index 6bf10be..cb625a4 100644
--- a/tests/lib_2/isolate/message2_test.dart
+++ b/tests/lib_2/isolate/message2_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Dart test program for testing serialization of messages.
// VMOptions=--enable_type_checks --enable_asserts
diff --git a/tests/lib_2/isolate/message3_test.dart b/tests/lib_2/isolate/message3_test.dart
index eab9635..aa3166c 100644
--- a/tests/lib_2/isolate/message3_test.dart
+++ b/tests/lib_2/isolate/message3_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Dart test program for testing serialization of messages.
// VMOptions=--enable_type_checks --enable_asserts
diff --git a/tests/lib_2/isolate/message4_test.dart b/tests/lib_2/isolate/message4_test.dart
index 7b2edc2..ecdf986 100644
--- a/tests/lib_2/isolate/message4_test.dart
+++ b/tests/lib_2/isolate/message4_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Dart test program for testing serialization of messages with static
// native functions.
diff --git a/tests/lib_2/isolate/message_const_type_arguments_1_test.dart b/tests/lib_2/isolate/message_const_type_arguments_1_test.dart
index 48d2af1..e5133aa 100644
--- a/tests/lib_2/isolate/message_const_type_arguments_1_test.dart
+++ b/tests/lib_2/isolate/message_const_type_arguments_1_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// https://github.com/dart-lang/sdk/issues/35778
import "dart:async";
diff --git a/tests/lib_2/isolate/message_const_type_arguments_2_test.dart b/tests/lib_2/isolate/message_const_type_arguments_2_test.dart
index 681b1c7..002aa6e 100644
--- a/tests/lib_2/isolate/message_const_type_arguments_2_test.dart
+++ b/tests/lib_2/isolate/message_const_type_arguments_2_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// https://github.com/dart-lang/sdk/issues/35778
import "dart:async";
diff --git a/tests/lib_2/isolate/message_enum_test.dart b/tests/lib_2/isolate/message_enum_test.dart
index 5cf11a1..801afd4d 100644
--- a/tests/lib_2/isolate/message_enum_test.dart
+++ b/tests/lib_2/isolate/message_enum_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'package:expect/expect.dart';
import 'package:async_helper/async_helper.dart';
import "dart:isolate";
diff --git a/tests/lib_2/isolate/message_test.dart b/tests/lib_2/isolate/message_test.dart
index 70eafff..73db18a 100644
--- a/tests/lib_2/isolate/message_test.dart
+++ b/tests/lib_2/isolate/message_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Dart test program for testing serialization of messages.
// VMOptions=--enable_type_checks --enable_asserts
diff --git a/tests/lib_2/isolate/mint_maker_test.dart b/tests/lib_2/isolate/mint_maker_test.dart
index 198e3cc..fb6eb87 100644
--- a/tests/lib_2/isolate/mint_maker_test.dart
+++ b/tests/lib_2/isolate/mint_maker_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library MintMakerTest;
import 'dart:async';
diff --git a/tests/lib_2/isolate/native_wrapper_message_test.dart b/tests/lib_2/isolate/native_wrapper_message_test.dart
index 09dcb40..2b663d5 100644
--- a/tests/lib_2/isolate/native_wrapper_message_test.dart
+++ b/tests/lib_2/isolate/native_wrapper_message_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:isolate';
import 'dart:nativewrappers';
import 'package:expect/expect.dart';
diff --git a/tests/lib_2/isolate/nested_spawn2_test.dart b/tests/lib_2/isolate/nested_spawn2_test.dart
index 0500d7b..1a9fa6a 100644
--- a/tests/lib_2/isolate/nested_spawn2_test.dart
+++ b/tests/lib_2/isolate/nested_spawn2_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Dart test program for testing that isolates can spawn other isolates and
// that the nested isolates can communicate with the main once the spawner has
// disappeared.
diff --git a/tests/lib_2/isolate/nested_spawn_test.dart b/tests/lib_2/isolate/nested_spawn_test.dart
index f72493b..a1d6538 100644
--- a/tests/lib_2/isolate/nested_spawn_test.dart
+++ b/tests/lib_2/isolate/nested_spawn_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Dart test program for testing that isolates can spawn other isolates.
library NestedSpawnTest;
diff --git a/tests/lib_2/isolate/non_fatal_exception_in_timer_callback_test.dart b/tests/lib_2/isolate/non_fatal_exception_in_timer_callback_test.dart
index 4568afe..b361171 100644
--- a/tests/lib_2/isolate/non_fatal_exception_in_timer_callback_test.dart
+++ b/tests/lib_2/isolate/non_fatal_exception_in_timer_callback_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:async';
import 'dart:isolate';
import 'dart:io';
diff --git a/tests/lib_2/isolate/object_leak_test.dart b/tests/lib_2/isolate/object_leak_test.dart
index 8bbd8f4..b8b94b4 100644
--- a/tests/lib_2/isolate/object_leak_test.dart
+++ b/tests/lib_2/isolate/object_leak_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Regression test for http://dartbug.com/18942
library LeakTest;
diff --git a/tests/lib_2/isolate/ondone_test.dart b/tests/lib_2/isolate/ondone_test.dart
index 6b247c7..9445f94 100644
--- a/tests/lib_2/isolate/ondone_test.dart
+++ b/tests/lib_2/isolate/ondone_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source is governed by a
// BSD-style license that can be found in the LICENSE file.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "dart:async";
import "package:async_helper/async_helper.dart";
diff --git a/tests/lib_2/isolate/package_config_test.dart b/tests/lib_2/isolate/package_config_test.dart
index 2b2c9cb..3039f3e 100644
--- a/tests/lib_2/isolate/package_config_test.dart
+++ b/tests/lib_2/isolate/package_config_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2015, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
// VMOptions=--trace_shutdown
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/lib_2/isolate/package_resolve_test.dart b/tests/lib_2/isolate/package_resolve_test.dart
index 89b22ea..4379b4c 100644
--- a/tests/lib_2/isolate/package_resolve_test.dart
+++ b/tests/lib_2/isolate/package_resolve_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/lib_2/isolate/package_root_test.dart b/tests/lib_2/isolate/package_root_test.dart
index 7d6e7b6..390df69 100644
--- a/tests/lib_2/isolate/package_root_test.dart
+++ b/tests/lib_2/isolate/package_root_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/lib_2/isolate/pause_test.dart b/tests/lib_2/isolate/pause_test.dart
index 23a0526..f2bfaac 100644
--- a/tests/lib_2/isolate/pause_test.dart
+++ b/tests/lib_2/isolate/pause_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "dart:async";
import "package:async_helper/async_helper.dart";
diff --git a/tests/lib_2/isolate/ping_pause_test.dart b/tests/lib_2/isolate/ping_pause_test.dart
index c29e594..48ad135 100644
--- a/tests/lib_2/isolate/ping_pause_test.dart
+++ b/tests/lib_2/isolate/ping_pause_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "dart:async";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/ping_test.dart b/tests/lib_2/isolate/ping_test.dart
index fe92a57..4371a4c0 100644
--- a/tests/lib_2/isolate/ping_test.dart
+++ b/tests/lib_2/isolate/ping_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "dart:async";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/port_test.dart b/tests/lib_2/isolate/port_test.dart
index cff9027..5d70832 100644
--- a/tests/lib_2/isolate/port_test.dart
+++ b/tests/lib_2/isolate/port_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Test properties of ports.
// Note: unittest.dart depends on ports, in particular on the behaviour tested
// here. To keep things simple, we don't use the unittest library here.
diff --git a/tests/lib_2/isolate/raw_port_test.dart b/tests/lib_2/isolate/raw_port_test.dart
index 5b946cb..8b3463a 100644
--- a/tests/lib_2/isolate/raw_port_test.dart
+++ b/tests/lib_2/isolate/raw_port_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Test RawReceivePort.
library raw_port_test;
diff --git a/tests/lib_2/isolate/regress_34752_test.dart b/tests/lib_2/isolate/regress_34752_test.dart
index 3292cb6..dafff29 100644
--- a/tests/lib_2/isolate/regress_34752_test.dart
+++ b/tests/lib_2/isolate/regress_34752_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Verifies that large BigInt can be passed through a message port and
// simple arithmetic operations still work after that.
// This is a regression test for https://github.com/dart-lang/sdk/issues/34752.
diff --git a/tests/lib_2/isolate/regress_flutter_22796_test.dart b/tests/lib_2/isolate/regress_flutter_22796_test.dart
index 1e6fc13..1cab5f1 100644
--- a/tests/lib_2/isolate/regress_flutter_22796_test.dart
+++ b/tests/lib_2/isolate/regress_flutter_22796_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Verifies that large typed data can be passed in a field through message port.
// This is a regression test for
// https://github.com/flutter/flutter/issues/22796.
diff --git a/tests/lib_2/isolate/request_reply_test.dart b/tests/lib_2/isolate/request_reply_test.dart
index caeba64..3c8aed0 100644
--- a/tests/lib_2/isolate/request_reply_test.dart
+++ b/tests/lib_2/isolate/request_reply_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library RequestReplyTest;
import 'dart:isolate';
diff --git a/tests/lib_2/isolate/resolve_package_uri_test.dart b/tests/lib_2/isolate/resolve_package_uri_test.dart
index 7aa387a..e55415a 100644
--- a/tests/lib_2/isolate/resolve_package_uri_test.dart
+++ b/tests/lib_2/isolate/resolve_package_uri_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Regression test for faulty encoding of `Isolate.resolvePackageUri` by
// dart2js.
diff --git a/tests/lib_2/isolate/send_private_test.dart b/tests/lib_2/isolate/send_private_test.dart
index 57df312..8ed717f 100644
--- a/tests/lib_2/isolate/send_private_test.dart
+++ b/tests/lib_2/isolate/send_private_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/simple_message_test.dart b/tests/lib_2/isolate/simple_message_test.dart
index 2ca65cb..f0310af 100644
--- a/tests/lib_2/isolate/simple_message_test.dart
+++ b/tests/lib_2/isolate/simple_message_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Dart test program for testing that isolates are spawned.
library IsolateNegativeTest;
diff --git a/tests/lib_2/isolate/spawn_function_custom_class_test.dart b/tests/lib_2/isolate/spawn_function_custom_class_test.dart
index d3ccfc1..8ef17c4 100644
--- a/tests/lib_2/isolate/spawn_function_custom_class_test.dart
+++ b/tests/lib_2/isolate/spawn_function_custom_class_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Create a user-defined class in a new isolate.
//
// Regression test for vm bug 2235: We were forgetting to finalize
diff --git a/tests/lib_2/isolate/spawn_function_test.dart b/tests/lib_2/isolate/spawn_function_test.dart
index e93b4d6..31cb54c 100644
--- a/tests/lib_2/isolate/spawn_function_test.dart
+++ b/tests/lib_2/isolate/spawn_function_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Example of spawning an isolate from a function.
library spawn_tests;
diff --git a/tests/lib_2/isolate/spawn_generic_test.dart b/tests/lib_2/isolate/spawn_generic_test.dart
index 203f855..7763ffa 100644
--- a/tests/lib_2/isolate/spawn_generic_test.dart
+++ b/tests/lib_2/isolate/spawn_generic_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Check that Isolate.spawn is generic.
library spawn_generic;
diff --git a/tests/lib_2/isolate/spawn_uri_exported_main_test.dart b/tests/lib_2/isolate/spawn_uri_exported_main_test.dart
index cf0df43..b8a5501 100644
--- a/tests/lib_2/isolate/spawn_uri_exported_main_test.dart
+++ b/tests/lib_2/isolate/spawn_uri_exported_main_test.dart
@@ -1,3 +1,10 @@
+// Copyright (c) 2013, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:async";
import "dart:isolate";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/spawn_uri_fail_test.dart b/tests/lib_2/isolate/spawn_uri_fail_test.dart
index 8d46548..6c9dc98 100644
--- a/tests/lib_2/isolate/spawn_uri_fail_test.dart
+++ b/tests/lib_2/isolate/spawn_uri_fail_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:io";
import "dart:isolate";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/spawn_uri_missing_from_isolate_test.dart b/tests/lib_2/isolate/spawn_uri_missing_from_isolate_test.dart
index 445edc1..02521b6 100644
--- a/tests/lib_2/isolate/spawn_uri_missing_from_isolate_test.dart
+++ b/tests/lib_2/isolate/spawn_uri_missing_from_isolate_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
/// Tests that Isolate.spawnUri completes with an error when the given URI
/// doesn't resolve to an existing resource.
///
diff --git a/tests/lib_2/isolate/spawn_uri_missing_test.dart b/tests/lib_2/isolate/spawn_uri_missing_test.dart
index 2bb5078..79540b1 100644
--- a/tests/lib_2/isolate/spawn_uri_missing_test.dart
+++ b/tests/lib_2/isolate/spawn_uri_missing_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
/// Tests that Isolate.spanUri completes with an error when the given URI
/// doesn't resolve to an existing resource.
library test.isolate.spawn_uri_missing_test;
diff --git a/tests/lib_2/isolate/spawn_uri_multi_test.dart b/tests/lib_2/isolate/spawn_uri_multi_test.dart
index 2984fca..d5fdc46 100644
--- a/tests/lib_2/isolate/spawn_uri_multi_test.dart
+++ b/tests/lib_2/isolate/spawn_uri_multi_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Negative test to make sure that we are reaching all assertions.
library spawn_tests;
diff --git a/tests/lib_2/isolate/spawn_uri_nested_vm_test.dart b/tests/lib_2/isolate/spawn_uri_nested_vm_test.dart
index f558df5..087b5fc 100644
--- a/tests/lib_2/isolate/spawn_uri_nested_vm_test.dart
+++ b/tests/lib_2/isolate/spawn_uri_nested_vm_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Example of nested spawning of isolates from a URI
library NestedSpawnUriLibrary;
diff --git a/tests/lib_2/isolate/spawn_uri_test.dart b/tests/lib_2/isolate/spawn_uri_test.dart
index 51ea02b..dbd4e6a 100644
--- a/tests/lib_2/isolate/spawn_uri_test.dart
+++ b/tests/lib_2/isolate/spawn_uri_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Example of spawning an isolate from a URI
library spawn_tests;
diff --git a/tests/lib_2/isolate/spawn_uri_vm_test.dart b/tests/lib_2/isolate/spawn_uri_vm_test.dart
index a3b8f61..3832b42 100644
--- a/tests/lib_2/isolate/spawn_uri_vm_test.dart
+++ b/tests/lib_2/isolate/spawn_uri_vm_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Example of spawning an isolate from a URI
library spawn_tests;
diff --git a/tests/lib_2/isolate/start_paused_test.dart b/tests/lib_2/isolate/start_paused_test.dart
index 843e7b1..12ccf6e 100644
--- a/tests/lib_2/isolate/start_paused_test.dart
+++ b/tests/lib_2/isolate/start_paused_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library start_paused_test;
import "dart:isolate";
diff --git a/tests/lib_2/isolate/static_function_test.dart b/tests/lib_2/isolate/static_function_test.dart
index 297fb85..b1e115e 100644
--- a/tests/lib_2/isolate/static_function_test.dart
+++ b/tests/lib_2/isolate/static_function_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// Test starting isolate with static functions (and toplevel ones, for sanity).
library static_function_test;
diff --git a/tests/lib_2/isolate/string_from_environment_default_value_test.dart b/tests/lib_2/isolate/string_from_environment_default_value_test.dart
index 2a34459..d26e759 100644
--- a/tests/lib_2/isolate/string_from_environment_default_value_test.dart
+++ b/tests/lib_2/isolate/string_from_environment_default_value_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:isolate";
import "package:expect/expect.dart";
diff --git a/tests/lib_2/isolate/timer_isolate_test.dart b/tests/lib_2/isolate/timer_isolate_test.dart
index a34005a..58e93c5 100644
--- a/tests/lib_2/isolate/timer_isolate_test.dart
+++ b/tests/lib_2/isolate/timer_isolate_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library multiple_timer_test;
import 'dart:isolate';
diff --git a/tests/lib_2/isolate/timer_multiple_isolates_test.dart b/tests/lib_2/isolate/timer_multiple_isolates_test.dart
index 68a5006..8fb9c3d 100644
--- a/tests/lib_2/isolate/timer_multiple_isolates_test.dart
+++ b/tests/lib_2/isolate/timer_multiple_isolates_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library timer_multiple_isolates_test;
import 'dart:isolate';
diff --git a/tests/lib_2/isolate/transferable_failed_to_send_test.dart b/tests/lib_2/isolate/transferable_failed_to_send_test.dart
index 1bca938..ac6f80e 100644
--- a/tests/lib_2/isolate/transferable_failed_to_send_test.dart
+++ b/tests/lib_2/isolate/transferable_failed_to_send_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:io" show ServerSocket;
import "dart:isolate";
import "dart:typed_data" show ByteData;
diff --git a/tests/lib_2/isolate/transferable_test.dart b/tests/lib_2/isolate/transferable_test.dart
index df28bab..8680828 100644
--- a/tests/lib_2/isolate/transferable_test.dart
+++ b/tests/lib_2/isolate/transferable_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:async";
import "dart:collection";
import "dart:isolate";
diff --git a/tests/lib_2/isolate/typed_message_test.dart b/tests/lib_2/isolate/typed_message_test.dart
index 1b2f8a9..38e24d0 100644
--- a/tests/lib_2/isolate/typed_message_test.dart
+++ b/tests/lib_2/isolate/typed_message_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2012, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
// Dart test program for testing isolate communication with
// typed objects.
diff --git a/tests/lib_2/isolate/unresolved_ports_test.dart b/tests/lib_2/isolate/unresolved_ports_test.dart
index 4634cd0..78bef1a 100644
--- a/tests/lib_2/isolate/unresolved_ports_test.dart
+++ b/tests/lib_2/isolate/unresolved_ports_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
// spawns multiple isolates and sends unresolved ports between them.
library unresolved_ports;
diff --git a/tests/lib_2/isolate/vm_rehash_test.dart b/tests/lib_2/isolate/vm_rehash_test.dart
index 7b1b6c4..f5a0a73 100644
--- a/tests/lib_2/isolate/vm_rehash_test.dart
+++ b/tests/lib_2/isolate/vm_rehash_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:async';
import 'dart:isolate';
diff --git a/tests/standalone_2/dwarf_stack_trace_test.dart b/tests/standalone_2/dwarf_stack_trace_test.dart
index 410360f..d32008a 100644
--- a/tests/standalone_2/dwarf_stack_trace_test.dart
+++ b/tests/standalone_2/dwarf_stack_trace_test.dart
@@ -4,104 +4,235 @@
/// VMOptions=--dwarf-stack-traces
-import 'package:unittest/unittest.dart';
+import 'dart:convert';
import 'dart:io';
+import 'package:unittest/unittest.dart';
+import 'package:vm/elf/convert.dart';
+import 'package:vm/elf/dwarf.dart';
+import 'package:vm/elf/elf.dart';
+import 'package:path/path.dart' as path;
+
+@pragma("vm:prefer-inline")
bar() {
// Keep the 'throw' and its argument on separate lines.
throw // force linebreak with dartfmt
"Hello, Dwarf!";
}
+@pragma("vm:never-inline")
foo() {
bar();
}
-main() {
+Future<void> main() async {
String rawStack;
try {
foo();
} catch (e, st) {
rawStack = st.toString();
}
+
+ // Check that our expected information is consistent.
+ checkConsistency(expectedExternalCallInfo, expectedAllCallsInfo);
+
+ print("");
+ print("Raw stack trace:");
print(rawStack);
- if (Platform.isAndroid) {
- // Attempts to execute 'file' etc fail with security exceptions on
- // Android.
- print("Skipping test on Android");
- return;
- }
-
- if (Platform.isMacOS) {
- // addr2line is not part of the XCode command line tools.
- print("Skipping test on MacOS");
- return;
- }
-
if (Platform.isWindows) {
- // Lacks 'file' and 'addr2line'.
- print("Skipping test on Windows");
+ // TODO(dartbug.com/39490): Remove this when we can retrieve or calculate
+ // virtual addresses from DWARF stack traces on Windows.
+ print("Skipping test because we are running on Windows.");
return;
}
- ProcessResult result = Process.runSync("file", ["--version"]);
- if (result.exitCode != 0) {
- print(result.stdout);
- print(result.stderr);
- throw "'file' is not present";
- }
-
- result = Process.runSync("addr2line", ["--version"]);
- if (result.exitCode != 0) {
- print(result.stdout);
- print(result.stderr);
- throw "'addr2line' is not present";
- }
-
- result = Process.runSync("file", [Platform.script.toFilePath()]);
- if (result.exitCode != 0) {
- print(result.stdout);
- print(result.stderr);
- throw "'file' failed";
- return;
- }
- if (!result.stdout.contains("ELF") && !result.stdout.contains("Mach-O")) {
- print("Skipping test because we are not running from a dylib or ELF.");
+ if (!Elf.startsWithMagicNumber(Platform.script.toFilePath())) {
+ print("Skipping test because we are not running from ELF.");
return;
}
- var frameRegex = new RegExp("pc ([0-9a-z]+) ([0-9a-zA-Z/\._-]+)");
- var symbolizedStack = new StringBuffer();
- for (var frameMatch in frameRegex.allMatches(rawStack)) {
- var framePC = frameMatch[1];
- var frameDSO = frameMatch[2];
- print(framePC);
- print(frameDSO);
- result = Process.runSync(
- "addr2line", ["--exe", frameDSO, "--functions", "--inlines", framePC]);
- if (result.exitCode != 0) {
- print(result.stdout);
- print(result.stderr);
- throw "'addr2line' failed";
- }
- print(result.stdout);
- symbolizedStack.write(result.stdout);
+ final dwarf = Dwarf.fromFile(Platform.script.toFilePath());
+
+ var rawLines =
+ await Stream.value(rawStack).transform(const LineSplitter()).toList();
+
+ final pcAddresses = collectPCAddresses(rawLines).toList();
+
+ // We should have at least enough PC addresses to cover the frames we'll be
+ // checking.
+ expect(pcAddresses.length, greaterThanOrEqualTo(expectedAllCallsInfo.length));
+
+ final externalFramesInfo =
+ pcAddresses.map((i) => dwarf.callInfo(i)?.toList()).toList();
+
+ final allFramesInfo = pcAddresses
+ .map((i) => dwarf.callInfo(i, includeInternalFrames: true)?.toList())
+ .toList();
+
+ print("");
+ print("Call information for PC addresses:");
+ for (var i = 0; i < pcAddresses.length; i++) {
+ print("For PC 0x${pcAddresses[i].toRadixString(16)}:");
+ print(" Calls corresponding to user or library code:");
+ externalFramesInfo[i]?.forEach((frame) => print(" ${frame}"));
+ print(" All calls:");
+ allFramesInfo[i]?.forEach((frame) => print(" ${frame}"));
}
- print(symbolizedStack);
- var symbolizedLines = symbolizedStack.toString().split("\n");
- expect(symbolizedLines.length, greaterThan(8));
+ // Check that our results are also consistent.
+ checkConsistency(externalFramesInfo, allFramesInfo);
+
+ checkFrames(externalFramesInfo, expectedExternalCallInfo);
+ checkFrames(allFramesInfo, expectedAllCallsInfo);
+
+ final externalSymbolizedLines = await Stream.fromIterable(rawLines)
+ .transform(DwarfStackTraceDecoder(dwarf))
+ .toList();
+
+ final externalSymbolizedCalls =
+ externalSymbolizedLines.where((s) => s.startsWith('#')).toList();
+
+ print("");
+ print("Symbolized external-only stack trace:");
+ externalSymbolizedLines.forEach(print);
+ print("");
+ print("Extracted calls:");
+ externalSymbolizedCalls.forEach(print);
+
+ final allSymbolizedLines = await Stream.fromIterable(rawLines)
+ .transform(DwarfStackTraceDecoder(dwarf, includeInternalFrames: true))
+ .toList();
+
+ final allSymbolizedCalls =
+ allSymbolizedLines.where((s) => s.startsWith('#')).toList();
+
+ print("");
+ print("Symbolized full stack trace:");
+ allSymbolizedLines.forEach(print);
+ print("");
+ print("Extracted calls:");
+ allSymbolizedCalls.forEach(print);
+
+ final expectedExternalStrings = extractCallStrings(expectedExternalCallInfo);
+ // There are two strings in the list for each line in the output.
+ final expectedExternalCallCount = expectedExternalStrings.length ~/ 2;
+ final expectedStrings = extractCallStrings(expectedAllCallsInfo);
+ final expectedCallCount = expectedStrings.length ~/ 2;
+
+ expect(externalSymbolizedCalls.length,
+ greaterThanOrEqualTo(expectedExternalCallCount));
+ expect(allSymbolizedCalls.length, greaterThanOrEqualTo(expectedCallCount));
+
+ // Strip off any unexpected lines, so we can also make sure we didn't get
+ // unexpected calls prior to those calls we expect.
+ final externalCallsTrace =
+ externalSymbolizedCalls.sublist(0, expectedExternalCallCount).join('\n');
+ final allCallsTrace =
+ allSymbolizedCalls.sublist(0, expectedCallCount).join('\n');
+
+ expect(externalCallsTrace, stringContainsInOrder(expectedExternalStrings));
+ expect(allCallsTrace, stringContainsInOrder(expectedStrings));
+}
+
+final expectedExternalCallInfo = <List<CallInfo>>[
+ // The first frame should correspond to the throw in bar, which was inlined
+ // into foo (so we'll get information for two calls for that PC address).
+ [
+ CallInfo(
+ function: "bar",
+ filename: "dwarf_stack_trace_test.dart",
+ line: 19,
+ inlined: true),
+ // The second frame corresponds to call to foo in main.
+ CallInfo(
+ function: "foo",
+ filename: "dwarf_stack_trace_test.dart",
+ line: 25,
+ inlined: false)
+ ],
+ [
+ CallInfo(
+ function: "main",
+ filename: "dwarf_stack_trace_test.dart",
+ line: 31,
+ inlined: false)
+ ],
+ // No call information for the main tearoff.
+ [],
+];
+
+// Replace the call information for the main tearoff frame.
+final expectedAllCallsInfo = expectedExternalCallInfo.sublist(0, 2) +
+ <List<CallInfo>>[
+ // Internal frames have non-positive line numbers in the call information.
+ [
+ CallInfo(
+ function: "main",
+ filename: "dwarf_stack_trace_test.dart",
+ line: 0,
+ inlined: false),
+ ]
+ ];
+
+void checkConsistency(
+ List<List<CallInfo>> externalFrames, List<List<CallInfo>> allFrames) {
+ // We should have the same number of frames for both external-only
+ // and combined call information.
+ expect(externalFrames.length, equals(allFrames.length));
+ // There should be no frames in either version where we failed to look up
+ // call information.
+ expect(externalFrames, everyElement(isNotNull));
+ expect(allFrames, everyElement(isNotNull));
+ // All frames in the internal-including version should have at least one
+ // piece of call information.
+ expect(allFrames, everyElement(isNotEmpty));
+ // External-only call information should only include call information with
+ // positive line numbers.
expect(
- symbolizedStack.toString(),
- stringContainsInOrder([
- "bar",
- "dwarf_stack_trace_test.dart:12",
- "foo",
- "dwarf_stack_trace_test.dart:17",
- "main",
- "dwarf_stack_trace_test.dart:23",
- "main", // dispatcher
- "dwarf_stack_trace_test.dart:?"
- ]));
+ externalFrames, everyElement(everyElement(predicate((c) => c.line > 0))));
+ // The information in the external-only and combined call information should
+ // be consistent for external frames.
+ for (var i = 0; i < allFrames.length; i++) {
+ expect(externalFrames[i], anyOf(isEmpty, equals(allFrames[i])));
+ }
+}
+
+void checkFrames(
+ List<List<CallInfo>> framesInfo, List<List<CallInfo>> expectedInfo) {
+ // There may be frames below those we check.
+ expect(framesInfo.length, greaterThanOrEqualTo(expectedInfo.length));
+
+ // We can't just use deep equality, since we only have the filenames in the
+ // expected version, not the whole path, and we don't really care if
+ // non-positive line numbers match, as long as they're both non-positive.
+ for (var i = 0; i < expectedInfo.length; i++) {
+ for (var j = 0; j < expectedInfo[i].length; j++) {
+ final got = framesInfo[i][j];
+ final expected = expectedInfo[i][j];
+ expect(got.function, equals(expected.function));
+ expect(got.inlined, equals(expected.inlined));
+ expect(path.basename(got.filename), equals(expected.filename));
+ if (expected.line > 0) {
+ expect(got.line, equals(expected.line));
+ } else {
+ expect(got.line, lessThanOrEqualTo(0));
+ }
+ }
+ }
+}
+
+List<String> extractCallStrings(List<List<CallInfo>> expectedCalls) {
+ var ret = <String>[];
+ for (final frame in expectedCalls) {
+ for (final call in frame) {
+ ret.add(call.function);
+ if (call.line > 0) {
+ ret.add("${call.filename}:${call.line}");
+ } else {
+ ret.add("${call.filename}:??");
+ }
+ }
+ }
+ return ret;
}
diff --git a/tests/standalone_2/io/echo_server_stream_test.dart b/tests/standalone_2/io/echo_server_stream_test.dart
index 5a44164..a24b01e 100644
--- a/tests/standalone_2/io/echo_server_stream_test.dart
+++ b/tests/standalone_2/io/echo_server_stream_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// Echo server test program to test socket streams.
//
diff --git a/tests/standalone_2/io/file_system_watcher_test.dart b/tests/standalone_2/io/file_system_watcher_test.dart
index c7c3644..ebb08de 100644
--- a/tests/standalone_2/io/file_system_watcher_test.dart
+++ b/tests/standalone_2/io/file_system_watcher_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone_2/io/http_advanced_test.dart b/tests/standalone_2/io/http_advanced_test.dart
index de25c16..4a90161 100644
--- a/tests/standalone_2/io/http_advanced_test.dart
+++ b/tests/standalone_2/io/http_advanced_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// VMOptions=
// VMOptions=--short_socket_read
diff --git a/tests/standalone_2/io/http_basic_test.dart b/tests/standalone_2/io/http_basic_test.dart
index 4f389ce..98e552b 100644
--- a/tests/standalone_2/io/http_basic_test.dart
+++ b/tests/standalone_2/io/http_basic_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// VMOptions=--trace_shutdown
// VMOptions=--trace_shutdown --short_socket_read
diff --git a/tests/standalone_2/io/http_read_test.dart b/tests/standalone_2/io/http_read_test.dart
index 5d32b15c..cddb439 100644
--- a/tests/standalone_2/io/http_read_test.dart
+++ b/tests/standalone_2/io/http_read_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// VMOptions=
// VMOptions=--short_socket_read
diff --git a/tests/standalone_2/io/pipe_server_test.dart b/tests/standalone_2/io/pipe_server_test.dart
index b559452..7841651 100644
--- a/tests/standalone_2/io/pipe_server_test.dart
+++ b/tests/standalone_2/io/pipe_server_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// OtherResources=readline_test1.dat
//
diff --git a/tests/standalone_2/io/platform_test.dart b/tests/standalone_2/io/platform_test.dart
index a1a1a94..16733d0 100644
--- a/tests/standalone_2/io/platform_test.dart
+++ b/tests/standalone_2/io/platform_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone_2/io/raw_synchronous_socket_test.dart b/tests/standalone_2/io/raw_synchronous_socket_test.dart
index ba89758..dfdc492 100644
--- a/tests/standalone_2/io/raw_synchronous_socket_test.dart
+++ b/tests/standalone_2/io/raw_synchronous_socket_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone_2/io/shared_socket_test.dart b/tests/standalone_2/io/shared_socket_test.dart
index 939695d..5f933bb 100644
--- a/tests/standalone_2/io/shared_socket_test.dart
+++ b/tests/standalone_2/io/shared_socket_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/standalone_2/io/socket_close_test.dart b/tests/standalone_2/io/socket_close_test.dart
index ef85bdf..c59a05f 100644
--- a/tests/standalone_2/io/socket_close_test.dart
+++ b/tests/standalone_2/io/socket_close_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// VMOptions=
// VMOptions=--short_socket_read
diff --git a/tests/standalone_2/io/socket_finalizer_test.dart b/tests/standalone_2/io/socket_finalizer_test.dart
index 97f0d65..84ade9e 100644
--- a/tests/standalone_2/io/socket_finalizer_test.dart
+++ b/tests/standalone_2/io/socket_finalizer_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2017, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// This test checks that sockets belonging to an isolate are properly cleaned up
// when the isolate shuts down abnormally. If the socket is not properly cleaned
diff --git a/tests/standalone_2/io/socket_many_connections_test.dart b/tests/standalone_2/io/socket_many_connections_test.dart
index 9166168..93353dd 100644
--- a/tests/standalone_2/io/socket_many_connections_test.dart
+++ b/tests/standalone_2/io/socket_many_connections_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2012, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// Test creating a large number of socket connections.
library ServerTest;
diff --git a/tests/standalone_2/io/stdio_socket_finalizer_test.dart b/tests/standalone_2/io/stdio_socket_finalizer_test.dart
index aa5e24f..c8be0e3 100644
--- a/tests/standalone_2/io/stdio_socket_finalizer_test.dart
+++ b/tests/standalone_2/io/stdio_socket_finalizer_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2017, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// This test checks that stdin is *not* closed when an Isolate leaks it.
diff --git a/tests/standalone_2/io/test_extension_tester.dart b/tests/standalone_2/io/test_extension_tester.dart
index 66380a7..7a3308c 100644
--- a/tests/standalone_2/io/test_extension_tester.dart
+++ b/tests/standalone_2/io/test_extension_tester.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library test_extension_test;
import 'dart:isolate';
diff --git a/tests/standalone_2/io/wait_for_event_isolate_test.dart b/tests/standalone_2/io/wait_for_event_isolate_test.dart
index e051adc..ce624e2 100644
--- a/tests/standalone_2/io/wait_for_event_isolate_test.dart
+++ b/tests/standalone_2/io/wait_for_event_isolate_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:async';
import 'dart:isolate';
import 'dart:cli';
diff --git a/tests/standalone_2/packages_file_test.dart b/tests/standalone_2/packages_file_test.dart
index cc48568..99c2ab5 100644
--- a/tests/standalone_2/packages_file_test.dart
+++ b/tests/standalone_2/packages_file_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import "dart:async";
import "dart:io";
import "dart:convert" show json;
diff --git a/tests/standalone_2/regress_26031_test.dart b/tests/standalone_2/regress_26031_test.dart
index 4ff66d7..7cc1058 100644
--- a/tests/standalone_2/regress_26031_test.dart
+++ b/tests/standalone_2/regress_26031_test.dart
@@ -2,6 +2,9 @@
// 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.
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/standalone_2/regress_28854_1_test.dart b/tests/standalone_2/regress_28854_1_test.dart
index 6bfc9a8..5b45c40 100644
--- a/tests/standalone_2/regress_28854_1_test.dart
+++ b/tests/standalone_2/regress_28854_1_test.dart
@@ -1,7 +1,10 @@
// Copyright (c) 2017, 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.
-//
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library regress;
import 'dart:isolate';
diff --git a/tests/standalone_2/regress_28854_2_test.dart b/tests/standalone_2/regress_28854_2_test.dart
index 980fa76..59a2c45 100644
--- a/tests/standalone_2/regress_28854_2_test.dart
+++ b/tests/standalone_2/regress_28854_2_test.dart
@@ -1,7 +1,10 @@
// Copyright (c) 2017, 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.
-//
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
+
library regress;
import 'dart:isolate';
diff --git a/tests/standalone_2/typed_array_int64_uint64_test.dart b/tests/standalone_2/typed_array_int64_uint64_test.dart
index 141f18d..7b57986 100644
--- a/tests/standalone_2/typed_array_int64_uint64_test.dart
+++ b/tests/standalone_2/typed_array_int64_uint64_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// Dart test program for testing native typed arrays, int64 and uint64 only.
diff --git a/tests/standalone_2/typed_array_test.dart b/tests/standalone_2/typed_array_test.dart
index b72468b..6e4c6c3 100644
--- a/tests/standalone_2/typed_array_test.dart
+++ b/tests/standalone_2/typed_array_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2012, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// Dart test program for testing native float and int arrays. 64-bit int arrays
// are in a separate test.
diff --git a/tests/standalone_2/typed_data_isolate_test.dart b/tests/standalone_2/typed_data_isolate_test.dart
index 6af4773..ab20d49 100644
--- a/tests/standalone_2/typed_data_isolate_test.dart
+++ b/tests/standalone_2/typed_data_isolate_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2013, 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.
+
+// VMOptions=--enable-isolate-groups
+// VMOptions=--no-enable-isolate-groups
//
// Dart test program for testing typed data.
diff --git a/tools/VERSION b/tools/VERSION
index 3e2749c..498d594 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -31,9 +31,9 @@
#
CHANNEL dev
MAJOR 2
-MINOR 7
+MINOR 8
PATCH 0
-PRERELEASE 2
-PRERELEASE_PATCH 1
+PRERELEASE 0
+PRERELEASE_PATCH 0
ABI_VERSION 24
OLDEST_SUPPORTED_ABI_VERSION 23
diff --git a/tools/bots/post_results_to_pubsub.dart b/tools/bots/post_results_to_pubsub.dart
index a019b32..4aac97a 100644
--- a/tools/bots/post_results_to_pubsub.dart
+++ b/tools/bots/post_results_to_pubsub.dart
@@ -24,7 +24,9 @@
// Pubsub messages must be < 10MB long. Because the JSON we send is
// Base64 encoded, and we add a final record after checking the size,
// the limit must be less than 3/4 of 10MB.
-const messageLengthLimit = 7000000;
+// Because we have some Firestore scalability issues when thousands of new
+// tests are added, we currently use less than half of the maximum size.
+const messageLengthLimit = 3000000;
const postUrl =
'https://pubsub.googleapis.com/v1/projects/dart-ci/topics/results:publish';
@@ -42,14 +44,15 @@
usage(parser);
}
- var client = http.Client();
+ final client = http.Client();
- var lines = await File(options['result_file']).readAsLines();
- var token = await File(options['auth_token']).readAsString();
+ final lines = await File(options['result_file']).readAsLines();
+ final token = await File(options['auth_token']).readAsString();
// Construct pubsub messages.
var line = 0;
+ var numMessages = 0;
while (line < lines.length) {
- var message = StringBuffer();
+ final message = StringBuffer();
message.write('[');
message.write(lines[line++]);
var messageLines = 1;
@@ -59,9 +62,17 @@
messageLines++;
}
message.write(']');
+ numMessages++;
+ final attributes = {
+ if (line == lines.length) 'num_messages': numMessages.toString()
+ };
var base64data = base64Encode(utf8.encode(message.toString()));
- var jsonMessage =
- '{"messages": [{"attributes": {}, "data": "$base64data"}]}';
+ var messageObject = {
+ 'messages': [
+ {'attributes': attributes, 'data': base64data}
+ ]
+ };
+ var jsonMessage = jsonEncode(messageObject);
var headers = {'Authorization': 'Bearer $token'};
var response =
await client.post(postUrl, headers: headers, body: jsonMessage);
@@ -69,5 +80,6 @@
print('Status ${response.statusCode}');
print('Response: ${response.body}');
}
+ print('Number of Pub/Sub messages sent: $numMessages');
client.close();
}
diff --git a/tools/bots/try_benchmarks.sh b/tools/bots/try_benchmarks.sh
index 24b87ae..34fac02 100755
--- a/tools/bots/try_benchmarks.sh
+++ b/tools/bots/try_benchmarks.sh
@@ -81,35 +81,6 @@
./tools/build.py --mode=release --arch=ia32 create_sdk
./tools/build.py --mode=release --arch=ia32 runtime
elif [ "$command" = linux-ia32-archive ]; then
- tar -czf linux-ia32_profile.tar.gz \
- --exclude .git \
- --exclude .gitignore \
- --exclude pkg/analysis_server/language_model \
- --exclude out/ReleaseIA32/dart-sdk/model \
- -- \
- third_party/d8/linux/ia32/natives_blob.bin \
- third_party/d8/linux/ia32/snapshot_blob.bin \
- out/ReleaseIA32/dart2js_platform.dill \
- out/ReleaseIA32/vm_outline_strong.dill \
- out/ReleaseIA32/vm_platform_strong.dill \
- out/ReleaseIA32/gen/kernel_service.dill \
- third_party/firefox_jsshell/linux/ \
- out/ReleaseIA32/dart-sdk \
- tools/dart2js/angular2_testing_deps \
- out/ReleaseIA32/dart \
- out/ReleaseIA32/gen_snapshot \
- out/ReleaseIA32/gen_kernel_bytecode.dill \
- out/ReleaseIA32/run_vm_tests \
- third_party/d8/linux/ia32/d8 \
- sdk samples-dev/swarm \
- third_party/pkg \
- third_party/pkg_tested \
- .packages \
- pkg \
- runtime/bin \
- runtime/lib \
- benchmarks \
- || (rm -f linux-ia32_profile.tar.gz; exit 1)
strip -w \
-K 'kDartVmSnapshotData' \
-K 'kDartVmSnapshotInstructions' \
@@ -171,10 +142,9 @@
--exclude .git \
--exclude .gitignore \
--exclude pkg/analysis_server/language_model \
- --exclude out/ReleaseIA32/dart-sdk/model \
+ --exclude out/ReleaseIA32/dart-sdk/bin/model \
+ --exclude pkg/front_end/testcases \
-- \
- third_party/d8/linux/ia32/natives_blob.bin \
- third_party/d8/linux/ia32/snapshot_blob.bin \
out/ReleaseIA32/dart2js_platform.dill \
out/ReleaseIA32/vm_outline_strong.dill \
out/ReleaseIA32/vm_platform_strong.dill \
@@ -186,7 +156,7 @@
out/ReleaseIA32/gen_snapshot \
out/ReleaseIA32/gen_kernel_bytecode.dill \
out/ReleaseIA32/run_vm_tests \
- third_party/d8/linux/ia32/d8 \
+ third_party/d8/linux/ia32 \
sdk \
samples-dev/swarm \
third_party/pkg \
@@ -248,35 +218,6 @@
./tools/build.py --mode=release --arch=x64 dart_precompiled_runtime
elif [ "$command" = linux-x64-archive ] ||
[ "$command" = linux-x64-bytecode-archive ]; then
- tar -czf linux-x64_profile.tar.gz \
- --exclude .git \
- --exclude .gitignore \
- --exclude pkg/analysis_server/language_model \
- --exclude out/ReleaseX64/dart-sdk/model \
- -- \
- third_party/d8/linux/x64/natives_blob.bin \
- third_party/d8/linux/x64/snapshot_blob.bin \
- out/ReleaseX64/dart2js_platform.dill \
- out/ReleaseX64/vm_outline_strong.dill \
- out/ReleaseX64/vm_platform_strong.dill \
- out/ReleaseX64/gen/kernel_service.dill \
- out/ReleaseX64/dart-sdk \
- out/ReleaseX64/dart \
- out/ReleaseX64/gen_snapshot \
- out/ReleaseX64/gen_kernel_bytecode.dill \
- out/ReleaseX64/run_vm_tests \
- third_party/d8/linux/x64/d8 \
- out/ReleaseX64/dart_precompiled_runtime \
- sdk \
- samples-dev/swarm \
- third_party/pkg \
- third_party/pkg_tested \
- .packages \
- pkg \
- runtime/bin \
- runtime/lib \
- benchmarks \
- || (rm -f linux-x64_profile.tar.gz; exit 1)
strip -w \
-K 'kDartVmSnapshotData' \
-K 'kDartVmSnapshotInstructions' \
@@ -357,10 +298,9 @@
--exclude .git \
--exclude .gitignore \
--exclude pkg/analysis_server/language_model \
- --exclude out/ReleaseX64/dart-sdk/model \
+ --exclude out/ReleaseX64/dart-sdk/bin/model \
+ --exclude pkg/front_end/testcases \
-- \
- third_party/d8/linux/x64/natives_blob.bin \
- third_party/d8/linux/x64/snapshot_blob.bin \
out/ReleaseX64/dart2js_platform.dill \
out/ReleaseX64/vm_outline_strong.dill \
out/ReleaseX64/vm_platform_strong.dill \
@@ -370,7 +310,7 @@
out/ReleaseX64/gen_snapshot \
out/ReleaseX64/gen_kernel_bytecode.dill \
out/ReleaseX64/run_vm_tests \
- third_party/d8/linux/x64/d8 \
+ third_party/d8/linux/x64 \
out/ReleaseX64/dart_precompiled_runtime \
sdk \
samples-dev/swarm \
diff --git a/tools/test.dart b/tools/test.dart
index f4cbd7b..1f9e3ef 100755
--- a/tools/test.dart
+++ b/tools/test.dart
@@ -555,10 +555,6 @@
}
}
}
- // Deflake results of the tests if required.
- if (options["deflake"]) {
- await deflake(outDirectory, configurationsToRun, options.rest);
- }
// Write out the merged results for the builders.
if (needsMerge || needsConfigurationOverride) {
await new File("${outDirectory.path}/previous.json").writeAsString(
@@ -569,6 +565,10 @@
await new File("${outDirectory.path}/flaky.json").writeAsString(
mergedFlaky.values.map((data) => jsonEncode(data) + "\n").join(""));
}
+ // Deflake results of the tests if required.
+ if (options["deflake"]) {
+ await deflake(outDirectory, configurationsToRun, options.rest);
+ }
// Write out the final comparison.
print("".padLeft(80, "="));
print("Test Results");
diff --git a/tools/utils.py b/tools/utils.py
index 1002e37..e122635 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -749,6 +749,7 @@
raise Exception(message)
else:
print(message)
+ return True # TODO(39662): Remove once the core_pattern is fixed
return False
return True
@@ -804,7 +805,8 @@
resource.setrlimit(resource.RLIMIT_CORE, (-1, -1))
def __exit__(self, *_):
- resource.setrlimit(resource.RLIMIT_CORE, self._old_limits)
+ if self._old_limits != None:
+ resource.setrlimit(resource.RLIMIT_CORE, self._old_limits)
class LinuxCoreDumpEnabler(PosixCoreDumpEnabler):
diff --git a/utils/dartdevc/BUILD.gn b/utils/dartdevc/BUILD.gn
index c861280..4a8fb03 100644
--- a/utils/dartdevc/BUILD.gn
+++ b/utils/dartdevc/BUILD.gn
@@ -132,8 +132,6 @@
# Apply dev_compiler's patch files to create the Dart version of the dartdevc
# SDK.
prebuilt_dart_action("dartdevc_patch_sdk") {
- # TODO(rnystrom): Unfork DDC's patch_sdk.dart script with the
- # tools/patch_sdk.dart and then change this to use generate_patch_sdk().
deps = [
":dartdevc_files_stamp",
":dartdevc_sdk_patch_stamp",
@@ -145,17 +143,8 @@
script = "../../pkg/dev_compiler/tool/patch_sdk.dart"
- # The main SDK library sources.
inputs = sdk_lib_files
- # dev_compiler's additional sources and patch files.
- inputs += exec_script("../../tools/list_dart_files.py",
- [
- "absolute",
- rebase_path("$sdk_root/lib/_internal/js_dev_runtime"),
- ],
- "list lines")
-
# Arbitrarily use the version file as a token file to check against to see if
# the sources have changed.
# TODO(rnystrom): List the outputs more precisely?
@@ -164,14 +153,17 @@
]
args = [
- rebase_path("../../"),
- rebase_path("$sdk_root/lib/_internal/js_dev_runtime"),
- rebase_path(patched_sdk_dir),
+ "--libraries",
+ rebase_path("$sdk_root/lib/libraries.json"),
+ "--target",
+ "dartdevc",
+ "--out",
+ rebase_path("$patched_sdk_dir/"),
]
# TODO(#38701) Cleanup after merging the forked SDK into mainline.
if (use_nnbd) {
- args += [ "sdk_nnbd" ]
+ args += [ "--nnbd" ]
}
}