Version 2.14.0-357.0.dev Merge commit '4c21e24b9cdf54b1f46d1f4cea1f8e0f35de26ef' into 'dev'
diff --git a/pkg/kernel/test/regression_37753_test.dart b/pkg/front_end/testcases/general/issue37753.dart similarity index 100% rename from pkg/kernel/test/regression_37753_test.dart rename to pkg/front_end/testcases/general/issue37753.dart
diff --git a/pkg/front_end/testcases/general/issue37753.dart.textual_outline.expect b/pkg/front_end/testcases/general/issue37753.dart.textual_outline.expect new file mode 100644 index 0000000..771fd22 --- /dev/null +++ b/pkg/front_end/testcases/general/issue37753.dart.textual_outline.expect
@@ -0,0 +1,3 @@ +// @dart = 2.9 +Iterable<int> getElements() sync* {} +main() => print(getElements());
diff --git a/pkg/front_end/testcases/general/issue37753.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/issue37753.dart.textual_outline_modelled.expect new file mode 100644 index 0000000..771fd22 --- /dev/null +++ b/pkg/front_end/testcases/general/issue37753.dart.textual_outline_modelled.expect
@@ -0,0 +1,3 @@ +// @dart = 2.9 +Iterable<int> getElements() sync* {} +main() => print(getElements());
diff --git a/pkg/front_end/testcases/general/issue37753.dart.weak.expect b/pkg/front_end/testcases/general/issue37753.dart.weak.expect new file mode 100644 index 0000000..8ce1e9b --- /dev/null +++ b/pkg/front_end/testcases/general/issue37753.dart.weak.expect
@@ -0,0 +1,13 @@ +library; +import self as self; +import "dart:core" as core; + +static method getElements() → core::Iterable<core::int*>* sync* { + core::Iterable<core::int*>* elements; + elements = (() → core::Iterable<core::int*>* sync* { + yield 7; + })(){() →* core::Iterable<core::int*>*}; + yield* elements; +} +static method main() → dynamic + return core::print(self::getElements());
diff --git a/pkg/front_end/testcases/general/issue37753.dart.weak.outline.expect b/pkg/front_end/testcases/general/issue37753.dart.weak.outline.expect new file mode 100644 index 0000000..2032eab --- /dev/null +++ b/pkg/front_end/testcases/general/issue37753.dart.weak.outline.expect
@@ -0,0 +1,8 @@ +library; +import self as self; +import "dart:core" as core; + +static method getElements() → core::Iterable<core::int*>* sync* + ; +static method main() → dynamic + ;
diff --git a/pkg/front_end/testcases/general/issue37753.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue37753.dart.weak.transformed.expect new file mode 100644 index 0000000..7321092 --- /dev/null +++ b/pkg/front_end/testcases/general/issue37753.dart.weak.transformed.expect
@@ -0,0 +1,41 @@ +library; +import self as self; +import "dart:core" as core; + +static method getElements() → core::Iterable<core::int*>* /* originally sync* */ { + function :sync_op_gen() → (core::_SyncIterator<dynamic>*, dynamic, dynamic) →* core::bool* { + core::int* :await_jump_var = 0; + dynamic :await_ctx_var; + function :sync_op(core::_SyncIterator<dynamic>* :iterator, dynamic :exception, dynamic :stack_trace) → core::bool* yielding { + { + core::Iterable<core::int*>* elements; + elements = (() → core::Iterable<core::int*>* /* originally sync* */ { + function :sync_op_gen() → (core::_SyncIterator<dynamic>*, dynamic, dynamic) →* core::bool* { + core::int* :await_jump_var = 0; + dynamic :await_ctx_var; + function :sync_op(core::_SyncIterator<dynamic>* :iterator, dynamic :exception, dynamic :stack_trace) → core::bool* yielding { + { + { + :iterator.{core::_SyncIterator::_current} = 7; + [yield] true; + } + } + return false; + } + return :sync_op; + } + return new core::_SyncIterable::•<core::int*>(:sync_op_gen); + })(){() →* core::Iterable<core::int*>*}; + { + :iterator.{core::_SyncIterator::_yieldEachIterable} = elements; + [yield] true; + } + } + return false; + } + return :sync_op; + } + return new core::_SyncIterable::•<core::int*>(:sync_op_gen); +} +static method main() → dynamic + return core::print(self::getElements());
diff --git a/pkg/front_end/testcases/general/issue40662.dart b/pkg/front_end/testcases/general/issue40662.dart index 611fc81..fba166b 100644 --- a/pkg/front_end/testcases/general/issue40662.dart +++ b/pkg/front_end/testcases/general/issue40662.dart
@@ -3,7 +3,9 @@ // BSD-style license that can be found in the LICENSE file. // // Regression test for https://github.com/dart-lang/sdk/issues/40662. + // @dart=2.9 + bar(int a, List<int> b) { expect(-1, a); expect(-1, (b[0] - 2));
diff --git a/pkg/front_end/testcases/general/issue40662.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue40662.dart.weak.transformed.expect index 79b6c00..90be483 100644 --- a/pkg/front_end/testcases/general/issue40662.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/general/issue40662.dart.weak.transformed.expect
@@ -86,6 +86,6 @@ Extra constant evaluation status: -Evaluated: InstanceInvocation @ org-dartlang-testcase:///issue40662.dart:8:10 -> IntConstant(-1) -Evaluated: InstanceInvocation @ org-dartlang-testcase:///issue40662.dart:9:10 -> IntConstant(-1) +Evaluated: InstanceInvocation @ org-dartlang-testcase:///issue40662.dart:10:10 -> IntConstant(-1) +Evaluated: InstanceInvocation @ org-dartlang-testcase:///issue40662.dart:11:10 -> IntConstant(-1) Extra constant evaluation: evaluated: 94, effectively constant: 2
diff --git a/pkg/front_end/tool/_fasta/abcompile.dart b/pkg/front_end/tool/_fasta/abcompile.dart index 26f815a..a9e3125 100644 --- a/pkg/front_end/tool/_fasta/abcompile.dart +++ b/pkg/front_end/tool/_fasta/abcompile.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.9 - import 'dart:async'; import 'dart:convert'; import 'dart:math'; @@ -11,7 +9,7 @@ import 'standard_deviation.dart'; -const String bRootPath = +const String? bRootPath = bool.hasEnvironment("bRoot") ? String.fromEnvironment("bRoot") : null; const int abIterations = int.fromEnvironment("abIterations", defaultValue: 15); const int iterations = int.fromEnvironment("iterations", defaultValue: 15); @@ -31,7 +29,7 @@ Uri aRoot = Platform.script.resolve('../../../..'); // The root of the other Dart SDK repo "B" - Uri bRoot = new Uri.directory(bRootPath); + Uri bRoot = new Uri.directory(bRootPath!); // Sanity check String relPath = 'pkg/front_end/tool/_fasta/compile.dart'; @@ -183,15 +181,15 @@ workingDirectory: workingDirPath); // ignore: unawaited_futures stderr.addStream(process.stderr); - StreamSubscription<String> stdOutSubscription; + StreamSubscription<String>? stdOutSubscription; stdOutSubscription = process.stdout .transform(utf8.decoder) .transform(new LineSplitter()) .listen(processLine, onDone: () { - stdOutSubscription.cancel(); + stdOutSubscription!.cancel(); }, onError: (e) { print('Error: $e'); - stdOutSubscription.cancel(); + stdOutSubscription!.cancel(); }); int code = await process.exitCode; if (code != 0) {
diff --git a/pkg/front_end/tool/_fasta/bench_maker.dart b/pkg/front_end/tool/_fasta/bench_maker.dart index 22732a7..4e95837 100644 --- a/pkg/front_end/tool/_fasta/bench_maker.dart +++ b/pkg/front_end/tool/_fasta/bench_maker.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.9 - library fasta.tool.entry_points; import "dart:convert" show JsonEncoder; @@ -49,8 +47,10 @@ final List<TypeParameter> usedTypeParameters = <TypeParameter>[]; String serializeTypeChecks(List<Object> typeChecks) { - for (List<Object> list in typeChecks) { - writeTypeCheck(list[0], list[1], list[2]); + for (Object list in typeChecks) { + List<Object> typeCheck = list as List<Object>; + writeTypeCheck(typeCheck[0] as DartType, typeCheck[1] as DartType, + typeCheck[2] as bool); } writeClasses(); return jsonEncode(this); @@ -133,11 +133,11 @@ } } - void writeClass(Class cls, Set<Class> writtenClasses) { + void writeClass(Class? cls, Set<Class> writtenClasses) { if (cls == null || !writtenClasses.add(cls)) return; - Supertype supertype = cls.supertype; + Supertype? supertype = cls.supertype; writeClass(supertype?.classNode, writtenClasses); - Supertype mixedInType = cls.mixedInType; + Supertype? mixedInType = cls.mixedInType; writeClass(mixedInType?.classNode, writtenClasses); for (Supertype implementedType in cls.implementedTypes) { writeClass(implementedType.classNode, writtenClasses); @@ -164,7 +164,7 @@ implementedType.asInterfaceType.accept1(this, sb); first = false; } - Procedure callOperator; + Procedure? callOperator; for (Procedure procedure in cls.procedures) { if (procedure.name.text == "call") { callOperator = procedure; @@ -183,11 +183,11 @@ } String computeName(TreeNode node) { - String name = nodeNames[node]; + String? name = nodeNames[node]; if (name != null) return name; if (node is Class) { Library library = node.enclosingLibrary; - String uriString = "${library?.importUri}"; + String uriString = "${library.importUri}"; if (uriString == "dart:core" || uriString == "dart:async") { if (!usedNames.add(node.name)) { throw "Class name conflict for $node"; @@ -336,7 +336,7 @@ sb.write(name); if (node.promotedBound != null) { sb.write(" & "); - node.promotedBound.accept1(this, sb); + node.promotedBound!.accept1(this, sb); } }
diff --git a/pkg/front_end/tool/_fasta/command_line.dart b/pkg/front_end/tool/_fasta/command_line.dart index d4b5b05..6ab0e47 100644 --- a/pkg/front_end/tool/_fasta/command_line.dart +++ b/pkg/front_end/tool/_fasta/command_line.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.9 - library fasta.tool.command_line; import 'dart:io' show exit; @@ -110,7 +108,7 @@ /// All other options require an option value, either on the form `--option /// value` or `--option=value`. static ParsedArguments parse( - List<String> arguments, Map<String, ValueSpecification> specification) { + List<String> arguments, Map<String, ValueSpecification>? specification) { specification ??= const <String, ValueSpecification>{}; ParsedArguments result = new ParsedArguments(); int index = arguments.indexOf("--"); @@ -123,7 +121,7 @@ while (iterator.moveNext()) { String argument = iterator.current; if (argument.startsWith("-") || argument == "/?" || argument == "/h") { - String value; + String? value; if (argument.startsWith("-D")) { value = argument.substring("-D".length); argument = "-D"; @@ -134,14 +132,14 @@ argument = argument.substring(0, index); } } - ValueSpecification valueSpecification = specification[argument]; + ValueSpecification? valueSpecification = specification[argument]; if (valueSpecification == null) { throw new CommandLineProblem.deprecated( "Unknown option '$argument'."); } String canonicalArgument = argument; if (valueSpecification.alias != null) { - canonicalArgument = valueSpecification.alias; + canonicalArgument = valueSpecification.alias as String; valueSpecification = specification[valueSpecification.alias]; } if (valueSpecification == null) { @@ -268,7 +266,7 @@ enableNullSafety: isExperimentEnabled(ExperimentalFlag.nonNullable, explicitExperimentalFlags: explicitExperimentalFlags)); - final Target target = getTarget(targetName, flags); + final Target? target = getTarget(targetName, flags); if (target == null) { return throw new CommandLineProblem.deprecated( "Target '${targetName}' not recognized. " @@ -302,7 +300,7 @@ final bool compileSdk = options.containsKey(Flags.compileSdk); - final String singleRootScheme = options[Flags.singleRootScheme]; + final String? singleRootScheme = options[Flags.singleRootScheme]; final Uri singleRootBase = options[Flags.singleRootBase]; final bool nnbdStrongMode = options[Flags.nnbdStrongMode]; @@ -418,7 +416,7 @@ throwCommandLineProblem( "Target '${target.name}' requires an explicit " "'${Flags.platform}' option."); - }))); + })!)); compilerOptions ..sdkRoot = sdk ..sdkSummary = platform @@ -439,9 +437,9 @@ List<String> arguments, bool areRestArgumentsInputs, Future<T> f(CompilerContext context, List<String> restArguments)) { - ParsedArguments parsedArguments; + ParsedArguments? parsedArguments; ProcessedOptions options; - CommandLineProblem problem; + CommandLineProblem? problem; try { parsedArguments = ParsedArguments.parse(arguments, optionSpecification); options = analyzeCommandLine( @@ -466,13 +464,13 @@ exit(1); } - return f(c, parsedArguments.arguments); + return f(c, parsedArguments!.arguments); }, errorOnMissingInput: problem == null); } Message computeUsage(String programName, bool verbose) { String basicUsage = "Usage: $programName [options] dartfile\n"; - String summary; + String? summary; String options = (verbose ? messageFastaUsageLong.message : messageFastaUsageShort.message) .trim(); @@ -508,7 +506,7 @@ } Future<T> runProtectedFromAbort<T>(Future<T> Function() action, - [T failingValue]) async { + [T? failingValue]) async { if (CompilerContext.isActive) { throw "runProtectedFromAbort should be called from 'main'," " that is, outside a compiler context."; @@ -527,14 +525,14 @@ abstract class ValueSpecification { const ValueSpecification(); - String get alias => null; + String? get alias => null; dynamic get defaultValue => null; bool get requiresValue => true; void processValue(ParsedArguments result, String canonicalArgument, - String argument, String value); + String argument, String? value); } class AliasValue extends ValueSpecification { @@ -546,7 +544,7 @@ throw new UnsupportedError("AliasValue.requiresValue"); void processValue(ParsedArguments result, String canonicalArgument, - String argument, String value) { + String argument, String? value) { throw new UnsupportedError("AliasValue.processValue"); } } @@ -555,7 +553,7 @@ const UriValue(); void processValue(ParsedArguments result, String canonicalArgument, - String argument, String value) { + String argument, String? value) { if (result.options.containsKey(canonicalArgument)) { throw new CommandLineProblem.deprecated( "Multiple values for '$argument': " @@ -563,7 +561,7 @@ } // TODO(ahe): resolve Uris lazily, so that schemes provided by // other flags can be used for parsed command-line arguments too. - result.options[canonicalArgument] = resolveInputUri(value); + result.options[canonicalArgument] = resolveInputUri(value!); } } @@ -571,13 +569,13 @@ const StringValue(); void processValue(ParsedArguments result, String canonicalArgument, - String argument, String value) { + String argument, String? value) { if (result.options.containsKey(canonicalArgument)) { throw new CommandLineProblem.deprecated( "Multiple values for '$argument': " "'${result.options[canonicalArgument]}' and '$value'."); } - result.options[canonicalArgument] = value; + result.options[canonicalArgument] = value!; } } @@ -589,7 +587,7 @@ bool get requiresValue => false; void processValue(ParsedArguments result, String canonicalArgument, - String argument, String value) { + String argument, String? value) { if (result.options.containsKey(canonicalArgument)) { throw new CommandLineProblem.deprecated( "Multiple values for '$argument': " @@ -613,13 +611,13 @@ const IntValue(); void processValue(ParsedArguments result, String canonicalArgument, - String argument, String value) { + String argument, String? value) { if (result.options.containsKey(canonicalArgument)) { throw new CommandLineProblem.deprecated( "Multiple values for '$argument': " "'${result.options[canonicalArgument]}' and '$value'."); } - int parsedValue = int.tryParse(value); + int? parsedValue = int.tryParse(value!); if (parsedValue == null) { throw new CommandLineProblem.deprecated( "Value for '$argument', '$value', isn't an int."); @@ -632,8 +630,8 @@ const DefineValue(); void processValue(ParsedArguments result, String canonicalArgument, - String argument, String value) { - int index = value.indexOf('='); + String argument, String? value) { + int index = value!.indexOf('='); String name; String expression; if (index != -1) { @@ -651,10 +649,10 @@ const StringListValue(); void processValue(ParsedArguments result, String canonicalArgument, - String argument, String value) { + String argument, String? value) { result.options .putIfAbsent(canonicalArgument, () => <String>[]) - .addAll(value.split(",")); + .addAll(value!.split(",")); } } @@ -662,9 +660,9 @@ const UriListValue(); void processValue(ParsedArguments result, String canonicalArgument, - String argument, String value) { + String argument, String? value) { result.options .putIfAbsent(canonicalArgument, () => <Uri>[]) - .addAll(value.split(",").map(resolveInputUri)); + .addAll(value!.split(",").map(resolveInputUri)); } }
diff --git a/pkg/front_end/tool/_fasta/compile_platform_legacy_test.dart b/pkg/front_end/tool/_fasta/compile_platform_legacy_test.dart index 1f624d3..985026c 100644 --- a/pkg/front_end/tool/_fasta/compile_platform_legacy_test.dart +++ b/pkg/front_end/tool/_fasta/compile_platform_legacy_test.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.md file. -// @dart=2.9 - library fasta.test.compile_platform_test; import 'dart:io';
diff --git a/pkg/front_end/tool/_fasta/compile_platform_test.dart b/pkg/front_end/tool/_fasta/compile_platform_test.dart index 1f624d3..985026c 100644 --- a/pkg/front_end/tool/_fasta/compile_platform_test.dart +++ b/pkg/front_end/tool/_fasta/compile_platform_test.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.md file. -// @dart=2.9 - library fasta.test.compile_platform_test; import 'dart:io';
diff --git a/pkg/front_end/tool/_fasta/generate_experimental_flags.dart b/pkg/front_end/tool/_fasta/generate_experimental_flags.dart index f52aee6..a452b9f 100644 --- a/pkg/front_end/tool/_fasta/generate_experimental_flags.dart +++ b/pkg/front_end/tool/_fasta/generate_experimental_flags.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.9 - import 'dart:io' show File; import 'package:_fe_analyzer_shared/src/scanner/characters.dart' @@ -50,7 +48,7 @@ int currentVersionMajor; int currentVersionMinor; { - String currentVersion = getAsVersionNumberString(yaml['current-version']); + String currentVersion = getAsVersionNumberString(yaml['current-version'])!; List<String> split = currentVersion.split("."); currentVersionMajor = int.parse(split[0]); currentVersionMinor = int.parse(split[1]); @@ -84,7 +82,7 @@ int currentVersionMajor; int currentVersionMinor; { - String currentVersion = getAsVersionNumberString(yaml['current-version']); + String currentVersion = getAsVersionNumberString(yaml['current-version'])!; List<String> split = currentVersion.split("."); currentVersionMajor = int.parse(split[0]); currentVersionMinor = int.parse(split[1]); @@ -135,7 +133,7 @@ for (String key in keys) { int major; int minor; - String enabledIn = + String? enabledIn = getAsVersionNumberString((features[key] as YamlMap)['enabledIn']); if (enabledIn == null) { major = currentVersionMajor; @@ -192,7 +190,7 @@ for (String key in keys) { int major; int minor; - String enabledIn = + String? enabledIn = getAsVersionNumberString((features[key] as YamlMap)['enabledIn']); if (enabledIn != null) { List<String> split = enabledIn.split("."); @@ -213,9 +211,9 @@ for (String key in keys) { int major; int minor; - String enabledIn = + String? enabledIn = getAsVersionNumberString((features[key] as YamlMap)['enabledIn']); - String experimentalReleaseVersion = getAsVersionNumberString( + String? experimentalReleaseVersion = getAsVersionNumberString( (features[key] as YamlMap)['experimentalReleaseVersion']); if (experimentalReleaseVersion != null) { List<String> split = experimentalReleaseVersion.split("."); @@ -296,7 +294,7 @@ return identifier.toString(); } -String getAsVersionNumberString(dynamic value) { +String? getAsVersionNumberString(dynamic value) { if (value == null) return null; if (value is String) return value; if (value is double) return "$value";
diff --git a/pkg/front_end/tool/_fasta/generate_messages.dart b/pkg/front_end/tool/_fasta/generate_messages.dart index 8ddafe5..3a971c3 100644 --- a/pkg/front_end/tool/_fasta/generate_messages.dart +++ b/pkg/front_end/tool/_fasta/generate_messages.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.9 - import 'dart:io' show File, exitCode; import "package:_fe_analyzer_shared/src/messages/severity.dart" @@ -96,7 +94,7 @@ while (description is String) { description = yaml[description]; } - Map<dynamic, dynamic> map = description; + Map<dynamic, dynamic>? map = description; if (map == null) { throw "No 'template:' in key $name."; } @@ -109,7 +107,7 @@ index = -1; // Continue looking for other problems. } else { - String otherName = indexNameMap[index]; + String? otherName = indexNameMap[index]; if (otherName != null) { print('Error: The "index:" field must be unique, ' 'but is the same for $otherName and $name'); @@ -166,8 +164,8 @@ Template(this.text, {this.isShared}) : assert(isShared != null); } -Template compileTemplate(String name, int index, String template, String tip, - Object analyzerCode, String severity) { +Template compileTemplate(String name, int? index, String? template, String? tip, + Object? analyzerCode, String? severity) { if (template == null) { print('Error: missing template for message: $name'); exitCode = 1; @@ -194,9 +192,9 @@ for (Match match in placeholderPattern.allMatches("$template\n${tip ?? ''}")) { - String name = match[1]; - String padding = match[2]; - String fractionDigits = match[3]; + String name = match[1]!; + String? padding = match[2]; + String? fractionDigits = match[3]; String format(String name) { String conversion; @@ -205,7 +203,7 @@ } else { conversion = "$name.toStringAsFixed($fractionDigits)"; } - if (padding.isNotEmpty) { + if (padding!.isNotEmpty) { if (padding.startsWith("0")) { conversion += ".padLeft(${int.parse(padding)}, '0')"; } else { @@ -416,13 +414,13 @@ if (analyzerCode is String) { analyzerCode = <String>[analyzerCode]; } - List<Object> codes = analyzerCode; + List<Object> codes = analyzerCode as List<Object>; // If "index:" is defined, then "analyzerCode:" should not be generated // in the front end. See comment in messages.yaml codeArguments.add('analyzerCodes: <String>["${codes.join('", "')}"]'); } if (severity != null) { - String severityEnumName = severityEnumNames[severity]; + String? severityEnumName = severityEnumNames[severity]; if (severityEnumName == null) { throw "Unknown severity '$severity'"; } @@ -430,6 +428,7 @@ } if (parameters.isEmpty && conversions.isEmpty && arguments.isEmpty) { + // ignore: unnecessary_null_comparison if (template != null) { codeArguments.add('message: r"""$template"""'); } @@ -448,6 +447,7 @@ } List<String> templateArguments = <String>[]; + // ignore: unnecessary_null_comparison if (template != null) { templateArguments.add('messageTemplate: r"""$template"""'); }
diff --git a/pkg/front_end/tool/_fasta/log_collector.dart b/pkg/front_end/tool/_fasta/log_collector.dart index 95dc56f..01fac75 100644 --- a/pkg/front_end/tool/_fasta/log_collector.dart +++ b/pkg/front_end/tool/_fasta/log_collector.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.9 - import 'dart:convert' show jsonDecode, utf8; import 'dart:isolate' show RawReceivePort; @@ -55,7 +53,7 @@ String month = "${time.month}".padLeft(2, "0"); String day = "${time.day}".padLeft(2, "0"); String us = "${time.microsecondsSinceEpoch}".padLeft(19, '0'); - Uri uri = Uri.base + Uri? uri = Uri.base .resolve("crash_logs/${data['client']}/$year-$month-$day/$us.log"); File file = new File.fromUri(uri); await file.parent.create(recursive: true); @@ -63,12 +61,12 @@ print("Wrote ${uri.toFilePath()}"); String type = data["type"]; - String text = data["uri"]; + String? text = data["uri"]; uri = text == null ? null : Uri.parse(text); int charOffset = data["offset"]; var error = data["error"]; text = data["trace"]; - StackTrace trace = text == null ? null : new StackTrace.fromString(text); + StackTrace? trace = text == null ? null : new StackTrace.fromString(text); String client = data["client"]; print(""" date: ${time}
diff --git a/pkg/kernel/lib/class_hierarchy.dart b/pkg/kernel/lib/class_hierarchy.dart index 7a61ee2..f66182a 100644 --- a/pkg/kernel/lib/class_hierarchy.dart +++ b/pkg/kernel/lib/class_hierarchy.dart
@@ -1722,8 +1722,6 @@ /// are removed first; in the case of ties, classes with lower topological sort /// index are removed first. class _LubHeap extends Heap<_ClassInfo> { - _LubHeap() : super(_dummyClassInfo); - @override bool sortsBefore(_ClassInfo a, _ClassInfo b) => sortsBeforeStatic(a, b); @@ -1733,5 +1731,3 @@ return a.topologicalIndex < b.topologicalIndex; } } - -final _ClassInfo _dummyClassInfo = new _ClassInfo(dummyClass);
diff --git a/pkg/kernel/lib/src/heap.dart b/pkg/kernel/lib/src/heap.dart index f70098b..5cbeeab 100644 --- a/pkg/kernel/lib/src/heap.dart +++ b/pkg/kernel/lib/src/heap.dart
@@ -5,9 +5,6 @@ /// Basic implementation of a heap, with O(log n) insertion and removal. abstract class Heap<T> { final _items = <T>[]; - final T _dummyValue; - - Heap(this._dummyValue); bool get isEmpty => _items.isEmpty; @@ -15,7 +12,7 @@ void add(T item) { int index = _items.length; - _items.add(_dummyValue); + _items.add(item); while (index > 0) { T parent = _items[_parentIndex(index)]; if (sortsBefore(parent, item)) break;
diff --git a/pkg/kernel/lib/text/serializer_combinators.dart b/pkg/kernel/lib/text/serializer_combinators.dart index 7af498e..aae9ea2 100644 --- a/pkg/kernel/lib/text/serializer_combinators.dart +++ b/pkg/kernel/lib/text/serializer_combinators.dart
@@ -714,7 +714,7 @@ /// Serializes an object and uses it as a binder for the name that is retrieved /// from the object using [nameGetter] and (temporarily) modified using /// [nameSetter]. The binder is added to the enclosing environment. -class Binder<T extends Node> extends TextSerializer<Tuple2<String, T>> { +class Binder<T extends Node> extends TextSerializer<Tuple2<String?, T>> { final Tuple2Serializer<String, T> namedContents; Binder(TextSerializer<T> contents) @@ -733,13 +733,13 @@ return new Tuple2(name, object); } - void writeTo(StringBuffer buffer, Tuple2<String, T> namedObject, + void writeTo(StringBuffer buffer, Tuple2<String?, T> namedObject, SerializationState? state) { if (state == null) { throw StateError( "No serialization state provided for ${runtimeType}.writeTo."); } - String nameClue = namedObject.first; + String? nameClue = namedObject.first; T object = namedObject.second; String distinctName = state.environment.addBinder(object, nameClue: nameClue);
diff --git a/pkg/kernel/lib/text/text_serializer.dart b/pkg/kernel/lib/text/text_serializer.dart index 374cfc4..2c80120 100644 --- a/pkg/kernel/lib/text/text_serializer.dart +++ b/pkg/kernel/lib/text/text_serializer.dart
@@ -1706,7 +1706,7 @@ (ls) => Tuple2(ls, ls.body), (t) => t.first..body = t.second, Bind( - Wrapped<Tuple2<String, LabeledStatement>, LabeledStatement>( + Wrapped<Tuple2<String?, LabeledStatement>, LabeledStatement>( (ls) => Tuple2("L", ls), (t) => t.second, Binder(Wrapped( @@ -1775,7 +1775,7 @@ } TextSerializer<SwitchCase> switchCaseCaseSerializer = - Wrapped<Tuple2<String, SwitchCase>, SwitchCase>( + Wrapped<Tuple2<String?, SwitchCase>, SwitchCase>( (w) => Tuple2("L", w), (u) => u.second, Binder(Wrapped<List<Expression>, SwitchCase>( @@ -1784,7 +1784,7 @@ ListSerializer(expressionSerializer)))); TextSerializer<SwitchCase> switchCaseDefaultSerializer = Wrapped< - Tuple2<String, SwitchCase>, SwitchCase>( + Tuple2<String?, SwitchCase>, SwitchCase>( (w) => Tuple2("L", w), (u) => u.second, Binder(
diff --git a/pkg/kernel/test/ast_membench.dart b/pkg/kernel/test/ast_membench.dart index baf8245..bd448d0 100644 --- a/pkg/kernel/test/ast_membench.dart +++ b/pkg/kernel/test/ast_membench.dart
@@ -3,8 +3,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.9 - import 'package:kernel/kernel.dart'; import 'dart:io';
diff --git a/pkg/kernel/test/binary/can_read_platform_test.dart b/pkg/kernel/test/binary/can_read_platform_test.dart index 2c8d827..2b447bc 100644 --- a/pkg/kernel/test/binary/can_read_platform_test.dart +++ b/pkg/kernel/test/binary/can_read_platform_test.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.9 - import 'dart:io'; import 'package:kernel/binary/ast_from_binary.dart';
diff --git a/pkg/kernel/test/binary/component_mode_test.dart b/pkg/kernel/test/binary/component_mode_test.dart index 2358e2f..c036b67 100644 --- a/pkg/kernel/test/binary/component_mode_test.dart +++ b/pkg/kernel/test/binary/component_mode_test.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.9 - import 'package:kernel/binary/ast_from_binary.dart'; import 'utils.dart';
diff --git a/pkg/kernel/test/binary/invalid_index_size.dart b/pkg/kernel/test/binary/invalid_index_size.dart index 2722ee4..893c14b 100644 --- a/pkg/kernel/test/binary/invalid_index_size.dart +++ b/pkg/kernel/test/binary/invalid_index_size.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.9 - import 'package:kernel/binary/ast_from_binary.dart' show ParseError; import 'utils.dart';
diff --git a/pkg/kernel/test/binary/lazy_reading_test.dart b/pkg/kernel/test/binary/lazy_reading_test.dart index 9d8d45c..f8bec83 100644 --- a/pkg/kernel/test/binary/lazy_reading_test.dart +++ b/pkg/kernel/test/binary/lazy_reading_test.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.9 - import 'package:kernel/binary/ast_from_binary.dart'; import 'package:kernel/src/tool/find_referenced_libraries.dart'; import 'utils.dart'; @@ -47,9 +45,9 @@ final Library loadedLib = loadedComponent.libraries.single; final Class loadedClassA = loadedLib.classes.first; final ExpressionStatement loadedConstructorA = - loadedClassA.constructors.single.function.body; + loadedClassA.constructors.single.function.body as ExpressionStatement; final ConstructorInvocation loadedConstructorInvocation = - loadedConstructorA.expression; + loadedConstructorA.expression as ConstructorInvocation; final Class pointedToClass = loadedConstructorInvocation.target.enclosingClass; final Library pointedToLib = @@ -81,9 +79,9 @@ final Library loadedLib = loadedComponent2.libraries.single; final Class loadedClassA = loadedLib.classes.first; final ExpressionStatement loadedConstructorA = - loadedClassA.constructors.single.function.body; + loadedClassA.constructors.single.function.body as ExpressionStatement; final ConstructorInvocation loadedConstructorInvocation = - loadedConstructorA.expression; + loadedConstructorA.expression as ConstructorInvocation; final Class pointedToClass = loadedConstructorInvocation.target.enclosingClass; final Library pointedToLib =
diff --git a/pkg/kernel/test/binary/library_flags_test.dart b/pkg/kernel/test/binary/library_flags_test.dart index c930c3c..d8776d6 100644 --- a/pkg/kernel/test/binary/library_flags_test.dart +++ b/pkg/kernel/test/binary/library_flags_test.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.9 - import 'utils.dart'; /// Test that library flags are serialized and read correctly.
diff --git a/pkg/kernel/test/binary/utils.dart b/pkg/kernel/test/binary/utils.dart index 4253db8..1005909 100644 --- a/pkg/kernel/test/binary/utils.dart +++ b/pkg/kernel/test/binary/utils.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.9 - import 'dart:io' show BytesBuilder; import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
diff --git a/pkg/kernel/test/binary_bench.dart b/pkg/kernel/test/binary_bench.dart index 75834e6..3c63ecd 100644 --- a/pkg/kernel/test/binary_bench.dart +++ b/pkg/kernel/test/binary_bench.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.9 - // This files contains methods for benchmarking Kernel binary serialization // and deserialization routines. @@ -35,8 +33,8 @@ }, }; -Benchmark benchmark; -File sourceDill; +Benchmark? benchmark; +late File sourceDill; bool forGolem = false; bool forRaw = false; @@ -47,7 +45,7 @@ } final bytes = sourceDill.readAsBytesSync(); - benchmark(bytes); + benchmark!(bytes); } const warmupIterations = 100; @@ -64,7 +62,8 @@ } final warmupUs = sw.elapsedMicroseconds / warmupIterations; - final runsUs = new List<int>.filled(benchmarkIterations, null); + final runsUs = + new List<int>.filled(benchmarkIterations, /* dummy value = */ 0); for (var i = 0; i < benchmarkIterations; i++) { sw.reset(); _fromBinary(bytes, eager: eager); @@ -88,7 +87,8 @@ } final warmupUs = sw.elapsedMicroseconds / warmupIterations; - final runsUs = new List<int>.filled(benchmarkIterations, null); + final runsUs = + new List<int>.filled(benchmarkIterations, /* dummy value = */ 0); for (var i = 0; i < benchmarkIterations; i++) { sw.reset(); _toBinary(p); @@ -106,7 +106,7 @@ BenchmarkResult(this.name, this.coldRunUs, this.warmupUs, this.runsUs); - static T add<T extends num>(T x, T y) => x + y; + static T add<T extends num>(T x, T y) => x + y as T; void report() { runsUs.sort();
diff --git a/pkg/kernel/test/class_hierarchy_basic.dart b/pkg/kernel/test/class_hierarchy_basic.dart index 1a9b34e..78ca0c5 100644 --- a/pkg/kernel/test/class_hierarchy_basic.dart +++ b/pkg/kernel/test/class_hierarchy_basic.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.9 - library kernel.class_hierarchy_basic; import 'package:kernel/class_hierarchy.dart'; @@ -97,19 +95,19 @@ superMixtures[node] = new Set<Class>()..add(node); supertypes[node] = new Set<Class>()..add(node); if (node.supertype != null) { - buildSuperTypeSets(node.supertype.classNode); - superclasses[node].addAll(superclasses[node.supertype.classNode]); - superMixtures[node].addAll(superMixtures[node.supertype.classNode]); - supertypes[node].addAll(supertypes[node.supertype.classNode]); + buildSuperTypeSets(node.supertype!.classNode); + superclasses[node]!.addAll(superclasses[node.supertype!.classNode]!); + superMixtures[node]!.addAll(superMixtures[node.supertype!.classNode]!); + supertypes[node]!.addAll(supertypes[node.supertype!.classNode]!); } if (node.mixedInType != null) { - buildSuperTypeSets(node.mixedInType.classNode); - superMixtures[node].addAll(superMixtures[node.mixedInType.classNode]); - supertypes[node].addAll(supertypes[node.mixedInType.classNode]); + buildSuperTypeSets(node.mixedInType!.classNode); + superMixtures[node]!.addAll(superMixtures[node.mixedInType!.classNode]!); + supertypes[node]!.addAll(supertypes[node.mixedInType!.classNode]!); } for (var supertype in node.implementedTypes) { buildSuperTypeSets(supertype.classNode); - supertypes[node].addAll(supertypes[supertype.classNode]); + supertypes[node]!.addAll(supertypes[supertype.classNode]!); } classes.add(node); classIndex[node] = classes.length - 1; @@ -125,8 +123,8 @@ buildSuperTypeInstantiations(superclass); var substitution = Substitution.fromPairs( superclass.typeParameters, supertype.typeArguments); - supertypeInstantiations[superclass].forEach((key, type) { - supertypeInstantiations[node][key] = + supertypeInstantiations[superclass]!.forEach((key, type) { + supertypeInstantiations[node]![key] = substitution.substituteSupertype(type); }); } @@ -137,25 +135,26 @@ gettersAndCalls[node] = <Name, Member>{}; setters[node] = <Name, Member>{}; if (node.supertype != null) { - buildDispatchTable(node.supertype.classNode); - gettersAndCalls[node].addAll(gettersAndCalls[node.supertype.classNode]); - setters[node].addAll(setters[node.supertype.classNode]); + buildDispatchTable(node.supertype!.classNode); + gettersAndCalls[node]! + .addAll(gettersAndCalls[node.supertype!.classNode]!); + setters[node]!.addAll(setters[node.supertype!.classNode]!); } // Overwrite map entries with declared members. Class mixin = node.mixedInType?.classNode ?? node; for (Procedure procedure in mixin.procedures) { if (procedure.isStatic || procedure.isAbstract) continue; if (procedure.kind == ProcedureKind.Setter) { - setters[node][procedure.name] = procedure; + setters[node]![procedure.name] = procedure; } else { - gettersAndCalls[node][procedure.name] = procedure; + gettersAndCalls[node]![procedure.name] = procedure; } } for (Field field in mixin.fields) { if (field.isStatic) continue; - gettersAndCalls[node][field.name] = field; + gettersAndCalls[node]![field.name] = field; if (!field.isFinal) { - setters[node][field.name] = field; + setters[node]![field.name] = field; } } } @@ -163,7 +162,7 @@ void mergeMaps( Map<Name, List<Member>> source, Map<Name, List<Member>> destination) { for (var name in source.keys) { - destination.putIfAbsent(name, () => <Member>[]).addAll(source[name]); + destination.putIfAbsent(name, () => <Member>[]).addAll(source[name]!); } } @@ -171,12 +170,12 @@ if (interfaceGettersAndCalls.containsKey(node)) return; interfaceGettersAndCalls[node] = <Name, List<Member>>{}; interfaceSetters[node] = <Name, List<Member>>{}; - void inheritFrom(Supertype type) { + void inheritFrom(Supertype? type) { if (type == null) return; buildInterfaceTable(type.classNode); - mergeMaps(interfaceGettersAndCalls[type.classNode], - interfaceGettersAndCalls[node]); - mergeMaps(interfaceSetters[type.classNode], interfaceSetters[node]); + mergeMaps(interfaceGettersAndCalls[type.classNode]!, + interfaceGettersAndCalls[node]!); + mergeMaps(interfaceSetters[type.classNode]!, interfaceSetters[node]!); } inheritFrom(node.supertype); @@ -186,70 +185,70 @@ for (Procedure procedure in node.mixin.procedures) { if (procedure.isStatic) continue; if (procedure.kind == ProcedureKind.Setter) { - interfaceSetters[node][procedure.name] = <Member>[procedure]; + interfaceSetters[node]![procedure.name] = <Member>[procedure]; } else { - interfaceGettersAndCalls[node][procedure.name] = <Member>[procedure]; + interfaceGettersAndCalls[node]![procedure.name] = <Member>[procedure]; } } for (Field field in node.mixin.fields) { if (field.isStatic) continue; - interfaceGettersAndCalls[node][field.name] = <Member>[field]; + interfaceGettersAndCalls[node]![field.name] = <Member>[field]; if (!field.isFinal) { - interfaceSetters[node][field.name] = <Member>[field]; + interfaceSetters[node]![field.name] = <Member>[field]; } } } bool isSubclassOf(Class subtype, Class supertype) { - return superclasses[subtype].contains(supertype); + return superclasses[subtype]!.contains(supertype); } bool isSubmixtureOf(Class subtype, Class supertype) { - return superMixtures[subtype].contains(supertype); + return superMixtures[subtype]!.contains(supertype); } bool isSubtypeOf(Class subtype, Class supertype) { - return supertypes[subtype].contains(supertype); + return supertypes[subtype]!.contains(supertype); } - Supertype getClassAsInstanceOf(Class type, Class supertype) { - return supertypeInstantiations[type][supertype]; + Supertype? getClassAsInstanceOf(Class type, Class supertype) { + return supertypeInstantiations[type]![supertype]; } - Member getDispatchTarget(Class class_, Name name, {bool setter: false}) { - return setter ? setters[class_][name] : gettersAndCalls[class_][name]; + Member? getDispatchTarget(Class class_, Name name, {bool setter: false}) { + return setter ? setters[class_]![name] : gettersAndCalls[class_]![name]; } List<Member> getDispatchTargets(Class class_, {bool setters: false}) { return setters - ? this.setters[class_].values - : gettersAndCalls[class_].values; + ? this.setters[class_]!.values.toList() + : gettersAndCalls[class_]!.values.toList(); } - Member tryFirst(List<Member> members) { - return (members == null || members.isEmpty) ? null : members[0]; + Member? tryFirst(Iterable<Member>? members) { + return (members == null || members.isEmpty) ? null : members.first; } - Member getInterfaceMember(Class class_, Name name, {bool setter: false}) { + Member? getInterfaceMember(Class class_, Name name, {bool setter: false}) { return tryFirst(getInterfaceMembersByName(class_, name, setter: setter)); } Iterable<Member> getInterfaceMembersByName(Class class_, Name name, {bool setter: false}) { var iterable = setter - ? interfaceSetters[class_][name] - : interfaceGettersAndCalls[class_][name]; + ? interfaceSetters[class_]![name] + : interfaceGettersAndCalls[class_]![name]; return iterable == null ? const <Member>[] : iterable; } List<Member> getInterfaceMembers(Class class_, {bool setters: false}) { return setters - ? interfaceSetters[class_].values.expand((x) => x) - : interfaceGettersAndCalls[class_].values.expand((x) => x); + ? interfaceSetters[class_]!.values.expand((x) => x).toList() + : interfaceGettersAndCalls[class_]!.values.expand((x) => x).toList(); } int getClassIndex(Class node) { - return classIndex[node]; + return classIndex[node]!; } List<int> getExpenseHistogram() => <int>[];
diff --git a/pkg/kernel/test/class_hierarchy_bench.dart b/pkg/kernel/test/class_hierarchy_bench.dart index 97d3dcd..f6bf037 100644 --- a/pkg/kernel/test/class_hierarchy_bench.dart +++ b/pkg/kernel/test/class_hierarchy_bench.dart
@@ -3,8 +3,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.9 - import 'package:kernel/kernel.dart'; import 'package:kernel/class_hierarchy.dart'; import 'package:kernel/core_types.dart'; @@ -61,7 +59,8 @@ int hierarchyCount = int.parse(options['cycle']); var hierarchies = <ClosedWorldClassHierarchy>[]; for (int i = 0; i < hierarchyCount; i++) { - hierarchies.add(buildHierarchy()); + // TODO(johnniwinther): This doesn't work for the [BasicClassHierarchy]. + hierarchies.add(buildHierarchy() as ClosedWorldClassHierarchy); } List<Class> classes = hierarchies.first.classes.toList(); @@ -246,13 +245,13 @@ classIds[class_] = classIds.length; } - List<int> depth = new List.filled(classes.length, null); + List<int> depth = new List.filled(classes.length, /* dummy value = */ 0); for (int i = 0; i < depth.length; ++i) { int parentDepth = 0; var classNode = classes[i]; for (var supertype in classNode.supers) { var superclass = supertype.classNode; - int index = classIds[superclass]; + int index = classIds[superclass]!; if (!(index < i)) { throw '${classNode.name}($i) extends ${superclass.name}($index)'; } @@ -264,7 +263,7 @@ List<int> depthHistogram = getHistogramOf(depth); double averageDepth = average(depth); double medianDepth = median(depth); - int totalDepth = sum(depth); + int totalDepth = sum(depth) as int; int numberOfClasses = classes.length; String expenseHistogram =
diff --git a/pkg/kernel/test/class_hierarchy_membench.dart b/pkg/kernel/test/class_hierarchy_membench.dart index 2c65048..0e6aefa 100644 --- a/pkg/kernel/test/class_hierarchy_membench.dart +++ b/pkg/kernel/test/class_hierarchy_membench.dart
@@ -3,8 +3,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.9 - import 'package:kernel/kernel.dart'; import 'package:kernel/class_hierarchy.dart'; import 'package:kernel/core_types.dart'; @@ -53,7 +51,8 @@ List<ClosedWorldClassHierarchy> keepAlive = <ClosedWorldClassHierarchy>[]; for (int i = 0; i < copyCount; ++i) { - keepAlive.add(buildHierarchy()); + // TODO(johnniwinther): This doesn't work for the [BasicClassHierarchy]. + keepAlive.add(buildHierarchy() as ClosedWorldClassHierarchy); } print('$copyCount copies built');
diff --git a/pkg/kernel/test/class_hierarchy_self_check.dart b/pkg/kernel/test/class_hierarchy_self_check.dart index 182a2b7..4cea403 100644 --- a/pkg/kernel/test/class_hierarchy_self_check.dart +++ b/pkg/kernel/test/class_hierarchy_self_check.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.9 - import 'package:kernel/kernel.dart'; import 'package:kernel/class_hierarchy.dart'; import 'package:kernel/core_types.dart'; @@ -23,7 +21,7 @@ BasicClassHierarchy basic = new BasicClassHierarchy(component); CoreTypes coreTypes = new CoreTypes(component); ClosedWorldClassHierarchy classHierarchy = - new ClassHierarchy(component, coreTypes); + new ClassHierarchy(component, coreTypes) as ClosedWorldClassHierarchy; int total = classHierarchy.numberOfClasses; int progress = 0; for (var class1 in classHierarchy.classes) { @@ -60,18 +58,18 @@ progress = 0; for (var classNode in classHierarchy.classes) { Iterable<Name> candidateNames = <Iterable<Name>>[ - basic.gettersAndCalls[classNode].keys, - basic.setters[classNode].keys, + basic.gettersAndCalls[classNode]!.keys, + basic.setters[classNode]!.keys, pickRandom(nameList, 100) ].expand((x) => x); for (Name name in candidateNames) { - Member expectedGetter = + Member? expectedGetter = basic.getDispatchTarget(classNode, name, setter: false); - Member expectedSetter = + Member? expectedSetter = basic.getDispatchTarget(classNode, name, setter: true); - Member actualGetter = + Member? actualGetter = classHierarchy.getDispatchTarget(classNode, name, setter: false); - Member actualSetter = + Member? actualSetter = classHierarchy.getDispatchTarget(classNode, name, setter: true); if (actualGetter != expectedGetter) { fail('lookupGetter($classNode, $name) returned ' @@ -90,18 +88,18 @@ progress = 0; for (var classNode in classHierarchy.classes) { Iterable<Name> candidateNames = [ - basic.interfaceGettersAndCalls[classNode].keys, - basic.interfaceSetters[classNode].keys, + basic.interfaceGettersAndCalls[classNode]!.keys, + basic.interfaceSetters[classNode]!.keys, pickRandom(nameList, 100) ].expand((x) => x); for (Name name in candidateNames) { - Member expectedGetter = + Member? expectedGetter = basic.getInterfaceMember(classNode, name, setter: false); - Member expectedSetter = + Member? expectedSetter = basic.getInterfaceMember(classNode, name, setter: true); - Member actualGetter = + Member? actualGetter = classHierarchy.getInterfaceMember(classNode, name, setter: false); - Member actualSetter = + Member? actualSetter = classHierarchy.getInterfaceMember(classNode, name, setter: true); if (actualGetter != expectedGetter) { fail('getInterfaceMember($classNode, $name) returned '
diff --git a/pkg/kernel/test/class_hierarchy_test.dart b/pkg/kernel/test/class_hierarchy_test.dart index 65b263d..f5a2bc5 100644 --- a/pkg/kernel/test/class_hierarchy_test.dart +++ b/pkg/kernel/test/class_hierarchy_test.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.9 - import "package:expect/minitest.dart"; import "package:kernel/ast.dart"; @@ -82,11 +80,11 @@ class ClosedWorldClassHierarchyTest { final Component component = createMockSdkComponent(); - CoreTypes coreTypes; + late CoreTypes coreTypes; - Library library; + late Library library; - ClassHierarchy _hierarchy; + ClassHierarchy? _hierarchy; ClosedWorldClassHierarchyTest() { coreTypes = new CoreTypes(component); @@ -335,8 +333,9 @@ /// The [TypeParameterType]s corresponding to [typeParameterNames] are /// passed to optional [extends_] and [implements_] callbacks. Class addGenericClass(String name, List<String> typeParameterNames, - {Supertype extends_(List<DartType> typeParameterTypes), - List<Supertype> implements_(List<DartType> typeParameterTypes)}) { + {Supertype Function(List<DartType> typeParameterTypes)? extends_, + List<Supertype> Function(List<DartType> typeParameterTypes)? + implements_}) { var typeParameters = typeParameterNames .map((name) => new TypeParameter( name, coreTypes.objectLegacyRawType, coreTypes.objectLegacyRawType))
diff --git a/pkg/kernel/test/class_hierarchy_test_disabled.dart b/pkg/kernel/test/class_hierarchy_test_disabled.dart index 5cba5d7..40155b0 100644 --- a/pkg/kernel/test/class_hierarchy_test_disabled.dart +++ b/pkg/kernel/test/class_hierarchy_test_disabled.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.9 - import 'package:kernel/kernel.dart'; import 'package:test/test.dart'; import 'class_hierarchy_self_check.dart';
diff --git a/pkg/kernel/test/convert_field_to_setter_getter.dart b/pkg/kernel/test/convert_field_to_setter_getter.dart index d7e7fd7..900dbf4 100644 --- a/pkg/kernel/test/convert_field_to_setter_getter.dart +++ b/pkg/kernel/test/convert_field_to_setter_getter.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.9 - import 'package:kernel/binary/ast_from_binary.dart'; import 'package:kernel/binary/ast_to_binary.dart'; import 'binary/utils.dart'; @@ -42,14 +40,14 @@ // Canonical names are now set: Verify that the field is marked as such, // canonical-name-wise. String getterCanonicalName = '${field.getterReference.canonicalName}'; - if (field.getterReference.canonicalName.parent.name != "@getters") { + if (field.getterReference.canonicalName!.parent!.name != "@getters") { throw "Expected @getters parent, but had " - "${field.getterReference.canonicalName.parent.name}"; + "${field.getterReference.canonicalName!.parent!.name}"; } - String setterCanonicalName = '${field.setterReference.canonicalName}'; - if (field.setterReference.canonicalName.parent.name != "@setters") { + String setterCanonicalName = '${field.setterReference!.canonicalName}'; + if (field.setterReference!.canonicalName!.parent!.name != "@setters") { throw "Expected @setters parent, but had " - "${field.setterReference.canonicalName.parent.name}"; + "${field.setterReference!.canonicalName!.parent!.name}"; } // Replace the field with a setter/getter pair. @@ -65,7 +63,7 @@ // a setter/getter), the reference wouldn't (because of the way `bindTo` is // implemented) actually have it's canonical name set, and serialization // wouldn't work.) - field.getterReference?.canonicalName?.unbind(); + field.getterReference.canonicalName?.unbind(); lib1.addProcedure(getter); FunctionNode setterFunction = new FunctionNode(new Block([]), @@ -82,18 +80,18 @@ List<int> writtenBytesGetterSetter = serialize(lib1, lib2); // Canonical names are now set: Verify that the getter/setter is marked as // such, canonical-name-wise. - if (getter.reference.canonicalName.parent.name != "@getters") { + if (getter.reference.canonicalName!.parent!.name != "@getters") { throw "Expected @getters parent, but had " - "${getter.reference.canonicalName.parent.name}"; + "${getter.reference.canonicalName!.parent!.name}"; } if ('${getter.reference.canonicalName}' != getterCanonicalName) { throw "Unexpected getter canonical name. " "Expected $getterCanonicalName, " "actual ${getter.reference.canonicalName}."; } - if (setter.reference.canonicalName.parent.name != "@setters") { + if (setter.reference.canonicalName!.parent!.name != "@setters") { throw "Expected @setters parent, but had " - "${setter.reference.canonicalName.parent.name}"; + "${setter.reference.canonicalName!.parent!.name}"; } if ('${setter.reference.canonicalName}' != setterCanonicalName) { throw "Unexpected setter canonical name. " @@ -110,7 +108,7 @@ fileUri: lib1Uri); // Important: Unbind any old canonical name // (nulling out the canonical name is not enough, see above). - fieldReplacement.getterReference?.canonicalName?.unbind(); + fieldReplacement.getterReference.canonicalName?.unbind(); fieldReplacement.setterReference?.canonicalName?.unbind(); lib1.addField(fieldReplacement); @@ -119,15 +117,15 @@ List<int> writtenBytesFieldNew = serialize(lib1, lib2); // Canonical names are now set: Verify that the field is marked as such, // canonical-name-wise. - if (fieldReplacement.getterReference.canonicalName.parent.name != + if (fieldReplacement.getterReference.canonicalName!.parent!.name != "@getters") { throw "Expected @getters parent, but had " - "${fieldReplacement.getterReference.canonicalName.parent.name}"; + "${fieldReplacement.getterReference.canonicalName!.parent!.name}"; } - if (fieldReplacement.setterReference.canonicalName.parent.name != + if (fieldReplacement.setterReference!.canonicalName!.parent!.name != "@setters") { throw "Expected @setters parent, but had " - "${fieldReplacement.setterReference.canonicalName.parent.name}"; + "${fieldReplacement.setterReference!.canonicalName!.parent!.name}"; } // Load the written stuff and ensure it is as expected. @@ -188,15 +186,16 @@ } Member getSetTarget(Procedure p) { - Block block = p.function.body; - ExpressionStatement getterStatement = block.statements[0]; - StaticSet staticSet = getterStatement.expression; + Block block = p.function.body as Block; + ExpressionStatement getterStatement = + block.statements[0] as ExpressionStatement; + StaticSet staticSet = getterStatement.expression as StaticSet; return staticSet.target; } Member getGetTarget(Procedure p) { - Block block = p.function.body; - ReturnStatement setterStatement = block.statements[1]; - StaticGet staticGet = setterStatement.expression; + Block block = p.function.body as Block; + ReturnStatement setterStatement = block.statements[1] as ReturnStatement; + StaticGet staticGet = setterStatement.expression as StaticGet; return staticGet.target; }
diff --git a/pkg/kernel/test/dart_type_equivalence_test.dart b/pkg/kernel/test/dart_type_equivalence_test.dart index acf4b96..41a7a01 100644 --- a/pkg/kernel/test/dart_type_equivalence_test.dart +++ b/pkg/kernel/test/dart_type_equivalence_test.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.9 - import "package:expect/expect.dart" show Expect; import 'package:kernel/ast.dart';
diff --git a/pkg/kernel/test/flatten_test.dart b/pkg/kernel/test/flatten_test.dart index 2dd50b8..2c5c656 100644 --- a/pkg/kernel/test/flatten_test.dart +++ b/pkg/kernel/test/flatten_test.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.9 - import "package:expect/expect.dart" show Expect; import 'package:kernel/ast.dart'; @@ -62,7 +60,7 @@ class Test { final String input; final String output; - final String typeParameters; + final String? typeParameters; const Test(this.input, this.output, [this.typeParameters]); }
diff --git a/pkg/kernel/test/future_value_type_test.dart b/pkg/kernel/test/future_value_type_test.dart index f256cfe..9d0e32e 100644 --- a/pkg/kernel/test/future_value_type_test.dart +++ b/pkg/kernel/test/future_value_type_test.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.9 - import "package:expect/expect.dart" show Expect; import 'package:kernel/ast.dart';
diff --git a/pkg/kernel/test/graph_test.dart b/pkg/kernel/test/graph_test.dart index 28668f6c..1dc79f9 100644 --- a/pkg/kernel/test/graph_test.dart +++ b/pkg/kernel/test/graph_test.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.md file. -// @dart = 2.9 - library kernel.test.graph_test; import 'package:expect/expect.dart' show Expect; @@ -17,7 +15,7 @@ Iterable<String> get vertices => graph.keys; - Iterable<String> neighborsOf(String vertex) => graph[vertex]; + Iterable<String> neighborsOf(String vertex) => graph[vertex]!; } void test(String expected, Map<String, List<String>> graph) {
diff --git a/pkg/kernel/test/heap_test.dart b/pkg/kernel/test/heap_test.dart index 07f5245..32b294e 100644 --- a/pkg/kernel/test/heap_test.dart +++ b/pkg/kernel/test/heap_test.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.9 - import 'package:kernel/src/heap.dart'; import 'package:test/test.dart'; @@ -36,7 +34,5 @@ } class _intHeap extends Heap<int> { - _intHeap() : super(0); - bool sortsBefore(int a, int b) => a < b; }
diff --git a/pkg/kernel/test/import_table_test.dart b/pkg/kernel/test/import_table_test.dart index 62c10f0..c64f614 100644 --- a/pkg/kernel/test/import_table_test.dart +++ b/pkg/kernel/test/import_table_test.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.9 - import 'package:kernel/import_table.dart'; main() {
diff --git a/pkg/kernel/test/legacy_erasure_test.dart b/pkg/kernel/test/legacy_erasure_test.dart index 4e14b3b..24b1a33 100644 --- a/pkg/kernel/test/legacy_erasure_test.dart +++ b/pkg/kernel/test/legacy_erasure_test.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.9 - import "package:expect/expect.dart" show Expect; import 'package:kernel/ast.dart';
diff --git a/pkg/kernel/test/load_concat_dill_keeps_source_test.dart b/pkg/kernel/test/load_concat_dill_keeps_source_test.dart index 0c2dc97..e8debc6 100644 --- a/pkg/kernel/test/load_concat_dill_keeps_source_test.dart +++ b/pkg/kernel/test/load_concat_dill_keeps_source_test.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.9 - // Test that 79cc54e51924cd5a6bdc2bd1771f2d0ee7af8899 works as intended. import 'dart:convert'; @@ -67,16 +65,16 @@ builder.readComponent(tmp); if (tmp.uriToSource[uri1] == null) throw "No data for $uri1"; if (tmp.uriToSource[uri2] == null) throw "No data for $uri2"; - if (expect1 && tmp.uriToSource[uri1].source.isEmpty) { + if (expect1 && tmp.uriToSource[uri1]!.source.isEmpty) { throw "No data for $uri1"; } - if (!expect1 && tmp.uriToSource[uri1].source.isNotEmpty) { + if (!expect1 && tmp.uriToSource[uri1]!.source.isNotEmpty) { throw "Unexpected data for $uri1"; } - if (expect2 && tmp.uriToSource[uri2].source.isEmpty) { + if (expect2 && tmp.uriToSource[uri2]!.source.isEmpty) { throw "No data data for $uri2"; } - if (!expect2 && tmp.uriToSource[uri2].source.isNotEmpty) { + if (!expect2 && tmp.uriToSource[uri2]!.source.isNotEmpty) { throw "Unexpected data for $uri2"; } }
diff --git a/pkg/kernel/test/metadata_test.dart b/pkg/kernel/test/metadata_test.dart index ed46532..16418c6 100644 --- a/pkg/kernel/test/metadata_test.dart +++ b/pkg/kernel/test/metadata_test.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.9 - import 'dart:convert'; import 'dart:io'; @@ -21,10 +19,10 @@ /// * type representing the first type parameter of its enclosing function class Metadata { final String string; - final Reference _memberRef; + final Reference? _memberRef; final DartType type; - Member get member => _memberRef?.asMember; + Member? get member => _memberRef?.asMember; Metadata.forNode(TreeNode n) : this( @@ -36,7 +34,7 @@ Metadata(this.string, this._memberRef, this.type); } -Member getMemberForMetadata(TreeNode node) { +Member? getMemberForMetadata(TreeNode node) { final parent = node.parent; if (parent == null) return null; if (parent is Member) return parent; @@ -67,7 +65,7 @@ sink.writeByteList(utf8.encode(metadata.string)); sink.writeStringReference(metadata.string); sink.writeNullAllowedCanonicalNameReference( - metadata.member?.reference?.canonicalName); + metadata.member?.reference.canonicalName); sink.writeDartType(metadata.type); } @@ -116,7 +114,7 @@ /// [shouldAnnotate] predicate. void annotate(Component p, NodePredicate shouldAnnotate) { globalDebuggingNames = new NameSystem(); - final repository = p.metadata[TestMetadataRepository.kTag]; + final repository = p.metadata[TestMetadataRepository.kTag]!; p.accept(new Visitor(shouldAnnotate, (node) { repository.mapping[node] = new Metadata.forNode(node); })); @@ -126,7 +124,7 @@ /// component matching [shouldAnnotate] predicate has correct metadata. void validate(Component p, NodePredicate shouldAnnotate) { globalDebuggingNames = new NameSystem(); - final repository = p.metadata[TestMetadataRepository.kTag]; + final repository = p.metadata[TestMetadataRepository.kTag]!; p.accept(new Visitor(shouldAnnotate, (node) { final m = repository.mapping[node]; final expected = new Metadata.forNode(node); @@ -168,7 +166,7 @@ final component = fromBinary(platformBinary); annotate(component, shouldAnnotate); validate(component, shouldAnnotate); - expect(component.metadata[TestMetadataRepository.kTag].mapping.length, + expect(component.metadata[TestMetadataRepository.kTag]!.mapping.length, greaterThan(0)); final annotatedComponentBinary = binaryTransformer(toBinary(component)); @@ -176,7 +174,7 @@ validate(annotatedComponentFromBinary, shouldAnnotate); expect( annotatedComponentFromBinary - .metadata[TestMetadataRepository.kTag].mapping.length, + .metadata[TestMetadataRepository.kTag]!.mapping.length, greaterThan(0)); }
diff --git a/pkg/kernel/test/nnbd_top_merge_test.dart b/pkg/kernel/test/nnbd_top_merge_test.dart index 7fac29a..c6255f1 100644 --- a/pkg/kernel/test/nnbd_top_merge_test.dart +++ b/pkg/kernel/test/nnbd_top_merge_test.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.9 - import "package:expect/expect.dart" show Expect; import 'package:kernel/ast.dart'; @@ -129,8 +127,8 @@ List<String> parts = input.split(' vs '); DartType aType = env.parseType(parts[0]); DartType bType = env.parseType(parts[1]); - DartType expectedOutputType1; - DartType expectedOutputType2; + DartType? expectedOutputType1; + DartType? expectedOutputType2; if (output is List) { expectedOutputType1 = env.parseType(output[0]); expectedOutputType2 = env.parseType(output[1]); @@ -138,8 +136,8 @@ expectedOutputType1 = expectedOutputType2 = env.parseType(output); } - void test(DartType a, DartType b, DartType expectedOutputType) { - DartType actualOutputType = nnbdTopMerge(env.coreTypes, a, b); + void test(DartType a, DartType b, DartType? expectedOutputType) { + DartType? actualOutputType = nnbdTopMerge(env.coreTypes, a, b); print('nnbdTopMerge($a,$b) = ' '$actualOutputType (expected=$expectedOutputType)'); Expect.equals(
diff --git a/pkg/kernel/test/non_null_test.dart b/pkg/kernel/test/non_null_test.dart index 5a3dca1..3fc2b89 100644 --- a/pkg/kernel/test/non_null_test.dart +++ b/pkg/kernel/test/non_null_test.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.9 - import "package:expect/expect.dart" show Expect; import 'package:kernel/ast.dart';
diff --git a/pkg/kernel/test/norm_test.dart b/pkg/kernel/test/norm_test.dart index 0f2cd38..0e1c9b1 100644 --- a/pkg/kernel/test/norm_test.dart +++ b/pkg/kernel/test/norm_test.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.9 - import "package:expect/expect.dart" show Expect; import 'package:kernel/ast.dart';
diff --git a/pkg/kernel/test/regression_40662_test.dart b/pkg/kernel/test/regression_40662_test.dart deleted file mode 100644 index 77eaf47..0000000 --- a/pkg/kernel/test/regression_40662_test.dart +++ /dev/null
@@ -1,18 +0,0 @@ -// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file -// for 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.9 - -// Regression test for https://github.com/dart-lang/sdk/issues/40662. - -import "package:expect/expect.dart" show Expect; - -bar(int a, List<int> b) { - Expect.equals(-1, a); - Expect.equals(-1, (b[0] - 2)); -} - -foo(int x) async => bar(x - 1, x != null ? [x + 1, x + 2, await null] : null); - -void main() async => await foo(0);
diff --git a/pkg/kernel/test/relink_test.dart b/pkg/kernel/test/relink_test.dart index 3f4c9be..47da2a9 100644 --- a/pkg/kernel/test/relink_test.dart +++ b/pkg/kernel/test/relink_test.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.9 - import 'package:kernel/binary/ast_from_binary.dart'; import 'package:kernel/binary/ast_to_binary.dart'; import 'package:kernel/src/tool/find_referenced_libraries.dart'; @@ -141,9 +139,11 @@ 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; + Block block = + component1Prime.libraries[0].procedures[0].function.body as Block; + ReturnStatement returnStatement = block.statements[0] as ReturnStatement; + StaticInvocation staticInvocation = + returnStatement.expression as StaticInvocation; Procedure target = staticInvocation.target; return target; }
diff --git a/pkg/kernel/test/round_trip.dart b/pkg/kernel/test/round_trip.dart index 3766db0..188a2a1 100644 --- a/pkg/kernel/test/round_trip.dart +++ b/pkg/kernel/test/round_trip.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.9 - library kernel.round_trip; import 'dart:io'; @@ -30,7 +28,7 @@ } } -void testRoundTrip(List<int> bytes, List<int> sdkBytes) async { +Future<void> testRoundTrip(List<int> bytes, List<int>? sdkBytes) async { var component = new Component(); if (sdkBytes != null) { var sdk = new Component(nameRoot: component.root);
diff --git a/pkg/kernel/test/round_trip_self_check.dart b/pkg/kernel/test/round_trip_self_check.dart index da2e0e1..058cef8 100644 --- a/pkg/kernel/test/round_trip_self_check.dart +++ b/pkg/kernel/test/round_trip_self_check.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.9 - library kernel.round_trip_test; import 'self_check_util.dart';
diff --git a/pkg/kernel/test/self_check_util.dart b/pkg/kernel/test/self_check_util.dart index e742142..1ebdd39 100644 --- a/pkg/kernel/test/self_check_util.dart +++ b/pkg/kernel/test/self_check_util.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.9 - import 'dart:async'; import 'package:kernel/src/tool/batch_util.dart';
diff --git a/pkg/kernel/test/serialize_bench.dart b/pkg/kernel/test/serialize_bench.dart index 0a413f9..72853ae 100644 --- a/pkg/kernel/test/serialize_bench.dart +++ b/pkg/kernel/test/serialize_bench.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.9 - import 'package:kernel/kernel.dart'; import 'dart:io';
diff --git a/pkg/kernel/test/text_serializer_from_kernel_nodes_test.dart b/pkg/kernel/test/text_serializer_from_kernel_nodes_test.dart index ddc5c9f..fbdcefa 100644 --- a/pkg/kernel/test/text_serializer_from_kernel_nodes_test.dart +++ b/pkg/kernel/test/text_serializer_from_kernel_nodes_test.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.9 - library kernel.text_serializer_from_kernel_nodes_test; import 'package:kernel/ast.dart'; @@ -25,14 +23,17 @@ final TextSerializer<T> serializer; TestCase( - {this.name, - this.node, - this.expectation, - this.serializer, - SerializationState Function() makeSerializationState, - DeserializationState Function() makeDeserializationState}) + {required this.name, + required this.node, + required this.expectation, + required this.serializer, + SerializationState Function()? makeSerializationState, + DeserializationState Function()? makeDeserializationState}) + // ignore: unnecessary_null_comparison : assert(node != null), + // ignore: unnecessary_null_comparison assert(expectation != null), + // ignore: unnecessary_null_comparison assert(serializer != null), this.makeSerializationState = makeSerializationState ?? (() => new SerializationState(new SerializationEnvironment(null))), @@ -75,12 +76,12 @@ new TestCase<Statement>( name: 'let dynamic x = 42 in let Null x^0 = null in x;', node: () { - VariableDeclaration outterLetVar = new VariableDeclaration('x', + VariableDeclaration outerLetVar = new VariableDeclaration('x', type: const DynamicType(), initializer: new IntLiteral(42)); VariableDeclaration innerLetVar = new VariableDeclaration('x', type: const NullType(), initializer: new NullLiteral()); - return new ExpressionStatement(new Let(outterLetVar, - new Let(innerLetVar, new VariableGet(outterLetVar)))); + return new ExpressionStatement(new Let(outerLetVar, + new Let(innerLetVar, new VariableGet(outerLetVar)))); }(), expectation: '' '(expr (let "x^0" () (dynamic) (int 42) ()' @@ -90,11 +91,11 @@ new TestCase<Statement>( name: 'let dynamic x = 42 in let Null x^0 = null in x^0;', node: () { - VariableDeclaration outterLetVar = new VariableDeclaration('x', + VariableDeclaration outerLetVar = new VariableDeclaration('x', type: const DynamicType(), initializer: new IntLiteral(42)); VariableDeclaration innerLetVar = new VariableDeclaration('x', type: const NullType(), initializer: new NullLiteral()); - return new ExpressionStatement(new Let(outterLetVar, + return new ExpressionStatement(new Let(outerLetVar, new Let(innerLetVar, new VariableGet(innerLetVar)))); }(), expectation: '' @@ -133,9 +134,10 @@ node: new ExpressionStatement(new StaticGet(field)), expectation: '' '(expr (get-static "package:foo/bar.dart::@getters::field"))', - makeSerializationState: () => new SerializationState(null), - makeDeserializationState: () => - new DeserializationState(null, component.root), + makeSerializationState: () => + new SerializationState(new SerializationEnvironment(null)), + makeDeserializationState: () => new DeserializationState( + new DeserializationEnvironment(null), component.root), serializer: statementSerializer); }(), () { @@ -150,9 +152,10 @@ node: new ExpressionStatement(new StaticGet(field)), expectation: '' '(expr (get-static "package:foo/bar.dart::@getters::field"))', - makeSerializationState: () => new SerializationState(null), - makeDeserializationState: () => - new DeserializationState(null, component.root), + makeSerializationState: () => + new SerializationState(new SerializationEnvironment(null)), + makeDeserializationState: () => new DeserializationState( + new DeserializationEnvironment(null), component.root), serializer: statementSerializer); }(), () { @@ -169,9 +172,10 @@ expectation: '' '(expr' ' (set-static "package:foo/bar.dart::@setters::field" (int 1)))', - makeSerializationState: () => new SerializationState(null), - makeDeserializationState: () => - new DeserializationState(null, component.root), + makeSerializationState: () => + new SerializationState(new SerializationEnvironment(null)), + makeDeserializationState: () => new DeserializationState( + new DeserializationEnvironment(null), component.root), serializer: statementSerializer); }(), () { @@ -197,9 +201,10 @@ expectation: '' '(expr (invoke-static "package:foo/bar.dart::@methods::foo"' ' () ((int 42)) ()))', - makeSerializationState: () => new SerializationState(null), - makeDeserializationState: () => - new DeserializationState(null, component.root), + makeSerializationState: () => + new SerializationState(new SerializationEnvironment(null)), + makeDeserializationState: () => new DeserializationState( + new DeserializationEnvironment(null), component.root), serializer: statementSerializer); }(), () { @@ -222,9 +227,10 @@ '(expr (invoke-const-static' ' "package:foo/bar.dart::A::@factories::foo"' ' () () ()))', - makeSerializationState: () => new SerializationState(null), - makeDeserializationState: () => - new DeserializationState(null, component.root), + makeSerializationState: () => + new SerializationState(new SerializationEnvironment(null)), + makeDeserializationState: () => new DeserializationState( + new DeserializationEnvironment(null), component.root), serializer: statementSerializer); }(), () { @@ -365,9 +371,10 @@ '(expr (invoke-constructor' ' "package:foo/bar.dart::A::@constructors::foo"' ' () () ()))', - makeSerializationState: () => new SerializationState(null), - makeDeserializationState: () => - new DeserializationState(null, component.root), + makeSerializationState: () => + new SerializationState(new SerializationEnvironment(null)), + makeDeserializationState: () => new DeserializationState( + new DeserializationEnvironment(null), component.root), serializer: statementSerializer); }(), () { @@ -387,13 +394,14 @@ '(expr (invoke-const-constructor' ' "package:foo/bar.dart::A::@constructors::foo"' ' () () ()))', - makeSerializationState: () => new SerializationState(null), - makeDeserializationState: () => - new DeserializationState(null, component.root), + makeSerializationState: () => + new SerializationState(new SerializationEnvironment(null)), + makeDeserializationState: () => new DeserializationState( + new DeserializationEnvironment(null), component.root), serializer: statementSerializer); }(), () { - TypeParameter outterParam = + TypeParameter outerParam = new TypeParameter('T', const DynamicType(), const DynamicType()); TypeParameter innerParam = new TypeParameter('T', const DynamicType(), const DynamicType()); @@ -407,9 +415,9 @@ Nullability.legacy, typeParameters: [innerParam]) ], - new TypeParameterType(outterParam, Nullability.legacy), + new TypeParameterType(outerParam, Nullability.legacy), Nullability.legacy, - typeParameters: [outterParam]))), + typeParameters: [outerParam]))), expectation: '' '(expr (type (-> ("T^0") ((dynamic)) ((dynamic)) ' '((-> ("T^1") ((dynamic)) ((dynamic)) () () () ' @@ -417,7 +425,7 @@ makeSerializationState: () => new SerializationState(new SerializationEnvironment(null)), makeDeserializationState: () => new DeserializationState( - new DeserializationEnvironment(null), null), + new DeserializationEnvironment(null), new CanonicalName.root()), serializer: statementSerializer); }(), () { @@ -444,7 +452,7 @@ makeSerializationState: () => new SerializationState(new SerializationEnvironment(null)), makeDeserializationState: () => new DeserializationState( - new DeserializationEnvironment(null), null), + new DeserializationEnvironment(null), new CanonicalName.root()), serializer: statementSerializer); }(), () { @@ -471,7 +479,7 @@ makeSerializationState: () => new SerializationState(new SerializationEnvironment(null)), makeDeserializationState: () => new DeserializationState( - new DeserializationEnvironment(null), null), + new DeserializationEnvironment(null), component.root), serializer: memberSerializer); }(), () { @@ -588,7 +596,7 @@ " but expected:\n ${testCase.expectation}"); } - TreeNode deserialized = + Node deserialized = testCase.readNode(roundTripInput, testCase.makeDeserializationState()); String roundTripOutput = testCase.writeNode(deserialized, testCase.makeSerializationState());
diff --git a/pkg/kernel/test/text_serializer_test.dart b/pkg/kernel/test/text_serializer_test.dart index 0a3f209..ff8f0506 100644 --- a/pkg/kernel/test/text_serializer_test.dart +++ b/pkg/kernel/test/text_serializer_test.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.9 - library kernel.text_serializer_test; import 'package:kernel/ast.dart'; @@ -27,7 +25,9 @@ TextIterator stream = new TextIterator(input, 0); stream.moveNext(); Expression result = expressionSerializer.readFrom( - stream, new DeserializationState(null, new CanonicalName.root())); + stream, + new DeserializationState( + new DeserializationEnvironment(null), new CanonicalName.root())); if (stream.moveNext()) { throw StateError("extra cruft in basic literal"); } @@ -36,8 +36,8 @@ String writeExpression(Expression expression) { StringBuffer buffer = new StringBuffer(); - expressionSerializer.writeTo( - buffer, expression, new SerializationState(null)); + expressionSerializer.writeTo(buffer, expression, + new SerializationState(new SerializationEnvironment(null))); return buffer.toString(); }
diff --git a/pkg/kernel/test/type_hashcode_quality.dart b/pkg/kernel/test/type_hashcode_quality.dart index f33541e..8bf1f34 100644 --- a/pkg/kernel/test/type_hashcode_quality.dart +++ b/pkg/kernel/test/type_hashcode_quality.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.9 - import 'package:kernel/kernel.dart'; import 'dart:io'; @@ -40,7 +38,7 @@ if (hash == 0) { print('Type has a hash code of zero: $node'); } - DartType existing = table[hash]; + DartType? existing = table[hash]; if (existing == null) { table[hash] = node; } else if (existing != node) {
diff --git a/pkg/kernel/test/type_hashcode_test.dart b/pkg/kernel/test/type_hashcode_test.dart index 9a16a72..8d13fe6 100644 --- a/pkg/kernel/test/type_hashcode_test.dart +++ b/pkg/kernel/test/type_hashcode_test.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.9 - import 'package:kernel/kernel.dart'; import 'type_parser.dart'; import 'package:test/test.dart'; @@ -55,11 +53,13 @@ String type1; String type2; Iterable<String> quantifiedVariables; - Map<String, String> expectedSubstitution; // Null if unification should fail. + Map<String, String?>? + expectedSubstitution; // Null if unification should fail. - TestCase.success(this.type1, this.type2, this.expectedSubstitution) { - quantifiedVariables = expectedSubstitution.keys; - } + TestCase.success( + this.type1, this.type2, Map<String, String?> expectedSubstitution) + : this.expectedSubstitution = expectedSubstitution, + this.quantifiedVariables = expectedSubstitution.keys; TestCase.fail(this.type1, this.type2, this.quantifiedVariables); @@ -68,7 +68,7 @@ String toString() => '∃ ${quantifiedVariables.join(',')}. $type1 = $type2'; } -TestCase successCase(String type1, String type2, Map<String, String> expected, +TestCase successCase(String type1, String type2, Map<String, String?> expected, {bool debug: false}) { return new TestCase.success(type1, type2, expected); }
diff --git a/pkg/kernel/test/type_parser.dart b/pkg/kernel/test/type_parser.dart index 67a4c05..52401b9 100644 --- a/pkg/kernel/test/type_parser.dart +++ b/pkg/kernel/test/type_parser.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.9 - // A very simple parser for a subset of DartTypes for use in testing type // algebra. library kernel.test.type_parser; @@ -41,14 +39,14 @@ class DartTypeParser { final String string; int index = 0; - String tokenText; + String? tokenText; final TypeEnvironment environment; final Map<String, TypeParameter> localTypeParameters = <String, TypeParameter>{}; DartTypeParser(this.string, this.environment); - TreeNode lookupType(String name) { + TreeNode? lookupType(String name) { return localTypeParameters[name] ?? environment(name); } @@ -139,8 +137,8 @@ } } - Nullability parseOptionalNullability( - [Nullability defaultNullability = Nullability.nonNullable]) { + Nullability? parseOptionalNullability( + [Nullability? defaultNullability = Nullability.nonNullable]) { int token = peekToken(); switch (token) { case Token.QuestionMark: @@ -159,23 +157,23 @@ switch (token) { case Token.Name: scanToken(); - String name = this.tokenText; + String name = this.tokenText!; if (name == 'void') return const VoidType(); if (name == 'dynamic') return const DynamicType(); var target = lookupType(name); if (target == null) { return fail('Unresolved type $name'); } else if (target is Class) { - List<DartType> typeArguments = parseOptionalTypeArgumentList(); - Nullability nullability = parseOptionalNullability(); + List<DartType>? typeArguments = parseOptionalTypeArgumentList(); + Nullability nullability = parseOptionalNullability()!; return new InterfaceType(target, nullability, typeArguments); } else if (target is Typedef) { - List<DartType> typeArguments = parseOptionalTypeArgumentList(); - Nullability nullability = parseOptionalNullability(); + List<DartType>? typeArguments = parseOptionalTypeArgumentList(); + Nullability nullability = parseOptionalNullability()!; return new TypedefType(target, nullability, typeArguments); } else if (target is TypeParameter) { - Nullability nullability = parseOptionalNullability(null); - DartType promotedBound; + Nullability? nullability = parseOptionalNullability(null); + DartType? promotedBound; switch (peekToken()) { case Token.LeftAngle: return fail('Attempt to apply type arguments to a type variable'); @@ -199,7 +197,7 @@ List<NamedType> namedParameters = <NamedType>[]; parseParameterList(parameters, namedParameters); consumeString('=>'); - Nullability nullability = parseOptionalNullability(); + Nullability nullability = parseOptionalNullability()!; var returnType = parseType(); return new FunctionType(parameters, returnType, nullability, namedParameters: namedParameters); @@ -210,7 +208,7 @@ List<NamedType> namedParameters = <NamedType>[]; parseParameterList(parameters, namedParameters); consumeString('=>'); - Nullability nullability = parseOptionalNullability(); + Nullability nullability = parseOptionalNullability()!; var returnType = parseType(); popTypeParameters(typeParameters); return new FunctionType(parameters, returnType, nullability, @@ -246,7 +244,7 @@ if (type is InterfaceType && type.typeArguments.isEmpty) { return type.classNode.name; } else if (type is TypeParameterType) { - return type.parameter.name; + return type.parameter.name!; } else { return fail('Unexpected colon after $type'); } @@ -267,12 +265,12 @@ return types; } - List<DartType> parseOptionalList(int open, int close) { + List<DartType>? parseOptionalList(int open, int close) { if (peekToken() != open) return null; return parseTypeList(open, close); } - List<DartType> parseOptionalTypeArgumentList() { + List<DartType>? parseOptionalTypeArgumentList() { return parseOptionalList(Token.LeftAngle, Token.RightAngle); } @@ -302,14 +300,14 @@ if (localTypeParameters.containsKey(typeParameter.name)) { return fail('Shadowing a type parameter is not allowed'); } - localTypeParameters[typeParameter.name] = typeParameter; + localTypeParameters[typeParameter.name!] = typeParameter; var next = peekToken(); if (next == Token.Colon) { scanToken(); typeParameter.bound = parseType(); } else { - typeParameter.bound = - new InterfaceType(lookupType('Object'), Nullability.nullable); + typeParameter.bound = new InterfaceType( + lookupType('Object') as Class, Nullability.nullable); } return typeParameter; } @@ -322,7 +320,7 @@ class LazyTypeEnvironment { final Map<String, Class> classes = <String, Class>{}; final Map<String, TypeParameter> typeParameters = <String, TypeParameter>{}; - Library dummyLibrary; + late final Library dummyLibrary; final Component component = new Component(); LazyTypeEnvironment() { @@ -360,14 +358,14 @@ for (var typeParameter in new DartTypeParser('<$typeParametersList>', lookup) .parseAndPushTypeParameterList()) { - typeParameters[typeParameter.name] = typeParameter; + typeParameters[typeParameter.name!] = typeParameter; } } DartType parse(String type) => parseDartType(type, lookup); Supertype parseSuper(String type) { - InterfaceType interfaceType = parse(type); + InterfaceType interfaceType = parse(type) as InterfaceType; return new Supertype(interfaceType.classNode, interfaceType.typeArguments); } @@ -376,9 +374,9 @@ return parse(type); } - TypeParameter getTypeParameter(String name) { + TypeParameter? getTypeParameter(String name) { if (name.length != 1) throw 'Type parameter names must have length 1'; - return lookup(name); + return lookup(name) as TypeParameter?; } }
diff --git a/pkg/kernel/test/type_parser_test.dart b/pkg/kernel/test/type_parser_test.dart index e015daa..5a2e651 100644 --- a/pkg/kernel/test/type_parser_test.dart +++ b/pkg/kernel/test/type_parser_test.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.9 - import 'package:expect/expect.dart' show Expect; import 'package:kernel/testing/type_parser.dart';
diff --git a/pkg/kernel/test/type_substitute_bounds_test.dart b/pkg/kernel/test/type_substitute_bounds_test.dart index c92d17a..ca16ac0 100644 --- a/pkg/kernel/test/type_substitute_bounds_test.dart +++ b/pkg/kernel/test/type_substitute_bounds_test.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.9 - library kernel.type_substitute_bounds_test; import 'package:kernel/kernel.dart'; @@ -45,7 +43,7 @@ String toString() { var substitution = bounds.keys.map((key) { - var bound = bounds[key]; + var bound = bounds[key]!; return '${bound.lower} <: $key <: ${bound.upper}'; }).join(','); return '$type [$substitution] <: $expected'; @@ -72,7 +70,7 @@ var upperBounds = <TypeParameter, DartType>{}; var lowerBounds = <TypeParameter, DartType>{}; testCase.bounds.forEach((String name, TypeBound bounds) { - var parameter = environment.getTypeParameter(name); + var parameter = environment.getTypeParameter(name)!; upperBounds[parameter] = environment.parse(bounds.upper); lowerBounds[parameter] = environment.parse(bounds.lower); });
diff --git a/pkg/kernel/test/type_substitution_identity_test.dart b/pkg/kernel/test/type_substitution_identity_test.dart index 99d7fe7..d8fabbd 100644 --- a/pkg/kernel/test/type_substitution_identity_test.dart +++ b/pkg/kernel/test/type_substitution_identity_test.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.9 - import 'package:kernel/kernel.dart'; import 'package:kernel/type_algebra.dart'; import 'type_parser.dart';
diff --git a/pkg/kernel/test/typedef_unalias_test.dart b/pkg/kernel/test/typedef_unalias_test.dart index aded3c3..196ac3f 100644 --- a/pkg/kernel/test/typedef_unalias_test.dart +++ b/pkg/kernel/test/typedef_unalias_test.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.9 - library kernel.typedef_unalias_test; import 'package:kernel/ast.dart';
diff --git a/pkg/kernel/test/verify_bench.dart b/pkg/kernel/test/verify_bench.dart index 6326b89..c5fc42e 100644 --- a/pkg/kernel/test/verify_bench.dart +++ b/pkg/kernel/test/verify_bench.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.9 - import 'dart:io'; import 'package:kernel/kernel.dart';
diff --git a/pkg/kernel/test/verify_self_check.dart b/pkg/kernel/test/verify_self_check.dart index bb2cd02..bc9b184 100644 --- a/pkg/kernel/test/verify_self_check.dart +++ b/pkg/kernel/test/verify_self_check.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.9 - import 'package:kernel/kernel.dart'; import 'package:kernel/verifier.dart';
diff --git a/pkg/kernel/test/verify_test.dart b/pkg/kernel/test/verify_test.dart index f1418df..3153b2e 100644 --- a/pkg/kernel/test/verify_test.dart +++ b/pkg/kernel/test/verify_test.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.9 - import 'package:kernel/ast.dart'; import 'package:kernel/text/ast_to_text.dart'; import 'package:kernel/verifier.dart'; @@ -30,7 +28,7 @@ test.addNode(VariableGet(node)); return node; }, - (Node node) => "Variable '$node' used out of scope.", + (Node? node) => "Variable '$node' used out of scope.", ); negative1Test( 'VariableSet out of scope', @@ -39,7 +37,7 @@ test.addNode(VariableSet(variable, new NullLiteral())); return variable; }, - (Node node) => "Variable '$node' used out of scope.", + (Node? node) => "Variable '$node' used out of scope.", ); negative1Test( 'Variable block scope', @@ -51,7 +49,7 @@ ])); return variable; }, - (Node node) => "Variable '$node' used out of scope.", + (Node? node) => "Variable '$node' used out of scope.", ); negative1Test( 'Variable let scope', @@ -63,7 +61,7 @@ new VariableGet(variable))); return variable; }, - (Node node) => "Variable '$node' used out of scope.", + (Node? node) => "Variable '$node' used out of scope.", ); negative1Test( 'Variable redeclared', @@ -72,7 +70,7 @@ test.addNode(Block([variable, variable])); return variable; }, - (Node node) => "Variable '$node' declared more than once.", + (Node? node) => "Variable '$node' declared more than once.", ); negative1Test( 'Member redeclared', @@ -86,7 +84,7 @@ fileUri: dummyUri)); return field; }, - (Node node) => "Member '$node' has been declared more than once.", + (Node? node) => "Member '$node' has been declared more than once.", ); negative1Test( 'Class redeclared', @@ -96,7 +94,7 @@ otherClass); // Test harness also adds otherClass to component. return test.otherClass; }, - (Node node) => "Class '$node' declared more than once.", + (Node? node) => "Class '$node' declared more than once.", ); negative1Test( 'Class type parameter redeclared', @@ -109,7 +107,7 @@ fileUri: dummyUri)); return parameter; }, - (Node node) => "Type parameter '$node' redeclared.", + (Node? node) => "Type parameter '$node' redeclared.", ); negative1Test( 'Member type parameter redeclared', @@ -124,7 +122,7 @@ return parameter; }, - (Node node) => "Type parameter '$node' redeclared.", + (Node? node) => "Type parameter '$node' redeclared.", ); negative2Test( 'Type parameter out of scope', @@ -134,7 +132,7 @@ typeArgument: new TypeParameterType(parameter, Nullability.legacy))); return [parameter, null]; }, - (Node node, Node parent) => + (Node? node, Node? parent) => "Type parameter '$node' referenced out of scope," " owner is: '$parent'.", ); @@ -146,7 +144,7 @@ TypeLiteral(new TypeParameterType(node, Nullability.legacy))); return [node, test.otherClass]; }, - (Node node, Node parent) => + (Node? node, Node? parent) => "Type parameter '$node' referenced out of scope," " owner is: '$parent'.", ); @@ -164,7 +162,7 @@ return [node, test.enclosingClass]; }, - (Node node, Node parent) => + (Node? node, Node? parent) => "Type parameter '$node' referenced from static context," " parent is: '$parent'.", ); @@ -179,7 +177,7 @@ fileUri: dummyUri)); return [node, test.enclosingClass]; }, - (Node node, Node parent) => + (Node? node, Node? parent) => "Type parameter '$node' referenced from static context," " parent is: '$parent'.", ); @@ -206,7 +204,7 @@ return [parameter, parent]; }, - (Node node, Node parent) => + (Node? node, Node? parent) => "Type parameter '$node' referenced out of scope," " owner is: '${(parent as TreeNode).parent}'.", ); @@ -218,7 +216,7 @@ test.addNode(TypeLiteral(node)); return node; }, - (Node node) => "Type $node provides 0 type arguments," + (Node? node) => "Type $node provides 0 type arguments," " but the class declares 1 parameters.", ); negative1Test( @@ -229,7 +227,7 @@ test.addNode(TypeLiteral(node)); return node; }, - (Node node) => "Type $node provides 2 type arguments," + (Node? node) => "Type $node provides 2 type arguments," " but the class declares 1 parameters.", ); negative1Test( @@ -240,7 +238,7 @@ new TypeLiteral(new InterfaceType(orphan, Nullability.legacy))); return orphan; }, - (Node node) => "Dangling reference to '$node', parent is: 'null'.", + (Node? node) => "Dangling reference to '$node', parent is: 'null'.", ); negative1Test( 'Dangling field get', @@ -249,7 +247,7 @@ test.addNode(new PropertyGet(new NullLiteral(), orphan.name, orphan)); return orphan; }, - (Node node) => "Dangling reference to '$node', parent is: 'null'.", + (Node? node) => "Dangling reference to '$node', parent is: 'null'.", ); simpleNegativeTest( 'Missing block parent pointer', @@ -299,7 +297,7 @@ StaticInvocation(method, new Arguments([new NullLiteral()]))); return method; }, - (Node node) => "StaticInvocation with incompatible arguments for" + (Node? node) => "StaticInvocation with incompatible arguments for" " '$node'.", ); negative1Test( @@ -316,7 +314,7 @@ test.addNode(StaticInvocation(method, new Arguments.empty())); return method; }, - (Node node) => "StaticInvocation with incompatible arguments for '$node'.", + (Node? node) => "StaticInvocation with incompatible arguments for '$node'.", ); negative1Test( 'StaticInvocation with unmatched named parameter', @@ -331,7 +329,7 @@ named: [new NamedExpression('p', new NullLiteral())]))); return method; }, - (Node node) => "StaticInvocation with incompatible arguments for" + (Node? node) => "StaticInvocation with incompatible arguments for" " '$node'.", ); negative1Test( @@ -348,7 +346,7 @@ test.addNode(StaticInvocation(method, new Arguments.empty())); return method; }, - (Node node) => "StaticInvocation with wrong number of type arguments for" + (Node? node) => "StaticInvocation with wrong number of type arguments for" " '$node'.", ); negative1Test( @@ -360,7 +358,7 @@ test.addNode(ConstructorInvocation(constructor, new Arguments.empty())); return constructor; }, - (Node node) => + (Node? node) => "ConstructorInvocation with wrong number of type arguments for" " '$node'.", ); @@ -433,7 +431,7 @@ test.addNode(typedef_); return typedef_; }, - (Node node) => "The typedef '$node' refers to itself", + (Node? node) => "The typedef '$node' refers to itself", ); negative1Test( 'Invalid typedef Foo = `(Foo) => void`', @@ -446,7 +444,7 @@ test.addNode(typedef_); return typedef_; }, - (Node node) => "The typedef '$node' refers to itself", + (Node? node) => "The typedef '$node' refers to itself", ); negative1Test( 'Invalid typedef Foo = `() => Foo`', @@ -457,7 +455,7 @@ test.addNode(typedef_); return typedef_; }, - (Node node) => "The typedef '$node' refers to itself", + (Node? node) => "The typedef '$node' refers to itself", ); negative1Test( 'Invalid typedef Foo = C<Foo>', @@ -468,7 +466,7 @@ test.addNode(typedef_); return typedef_; }, - (Node node) => "The typedef '$node' refers to itself", + (Node? node) => "The typedef '$node' refers to itself", ); negative1Test( 'Invalid typedefs Foo = Bar, Bar = Foo', @@ -481,7 +479,7 @@ test.enclosingLibrary.addTypedef(bar); return foo; }, - (Node foo) => "The typedef '$foo' refers to itself", + (Node? foo) => "The typedef '$foo' refers to itself", ); negative1Test( 'Invalid typedefs Foo = Bar, Bar = C<Foo>', @@ -495,7 +493,7 @@ test.enclosingLibrary.addTypedef(bar); return foo; }, - (Node foo) => "The typedef '$foo' refers to itself", + (Node? foo) => "The typedef '$foo' refers to itself", ); negative1Test( 'Invalid typedefs Foo = C<Bar>, Bar = C<Foo>', @@ -510,7 +508,7 @@ test.enclosingLibrary.addTypedef(bar); return foo; }, - (Node foo) => "The typedef '$foo' refers to itself", + (Node? foo) => "The typedef '$foo' refers to itself", ); positiveTest( 'Valid long typedefs C20 = C19 = ... = C1 = C0 = dynamic', @@ -541,7 +539,7 @@ first.type = new TypedefType(typedef_, Nullability.legacy); return firstTypedef; }, - (Node node) => "The typedef '$node' refers to itself", + (Node? node) => "The typedef '$node' refers to itself", ); positiveTest( 'Valid typedef Foo<T extends C> = C<T>', @@ -611,7 +609,7 @@ test.enclosingLibrary.addTypedef(bar); return foo; }, - (Node foo) => "The typedef '$foo' refers to itself", + (Node? foo) => "The typedef '$foo' refers to itself", ); negative1Test( 'Invalid typedef Foo<T extends Foo<dynamic> = C<T>', @@ -628,7 +626,7 @@ test.addNode(foo); return foo; }, - (Node foo) => "The typedef '$foo' refers to itself", + (Node? foo) => "The typedef '$foo' refers to itself", ); negative1Test( 'Typedef arity error', @@ -643,7 +641,7 @@ test.enclosingLibrary.addField(field); return typedefType; }, - (Node typedefType) => + (Node? typedefType) => "The typedef type $typedefType provides 0 type arguments," " but the typedef declares 1 parameters.", ); @@ -659,7 +657,7 @@ test.enclosingLibrary.addField(field); return foo; }, - (Node foo) => "Dangling reference to '$foo', parent is: 'null'", + (Node? foo) => "Dangling reference to '$foo', parent is: 'null'", ); negative1Test( 'Non-static top-level field', @@ -668,7 +666,7 @@ test.enclosingLibrary.addField(field); return null; }, - (Node node) => "The top-level field 'field' should be static", + (Node? node) => "The top-level field 'field' should be static", ); } @@ -683,21 +681,21 @@ } class TestHarness { - Component component; - Class objectClass; - Library stubLibrary; + late Component component; + late Class objectClass; + late Library stubLibrary; - TypeParameter classTypeParameter; + late TypeParameter classTypeParameter; - Library enclosingLibrary; - Class enclosingClass; - Procedure enclosingMember; + late Library enclosingLibrary; + late Class enclosingClass; + late Procedure enclosingMember; - Class otherClass; + late Class otherClass; - InterfaceType objectLegacyRawType; - InterfaceType enclosingLegacyRawType; - InterfaceType otherLegacyRawType; + late InterfaceType objectLegacyRawType; + late InterfaceType enclosingLegacyRawType; + late InterfaceType otherLegacyRawType; void addNode(TreeNode node) { if (node is Expression) { @@ -756,7 +754,7 @@ VariableDeclaration makeVariable() => new VariableDeclaration(null); - TypeParameter makeTypeParameter([String name]) { + TypeParameter makeTypeParameter([String? name]) { return new TypeParameter(name, objectLegacyRawType, const DynamicType()); } @@ -802,10 +800,10 @@ } } -negative1Test(String name, Node Function(TestHarness test) nodeProvider, - dynamic Function(Node node) matcher) { +negative1Test(String name, Node? Function(TestHarness test) nodeProvider, + dynamic Function(Node? node) matcher) { TestHarness testHarness = new TestHarness(); - Node node = nodeProvider(testHarness); + Node? node = nodeProvider(testHarness); test( name, () { @@ -818,10 +816,10 @@ ); } -negative2Test(String name, List<Node> Function(TestHarness test) nodeProvider, - dynamic Function(Node node, Node other) matcher) { +negative2Test(String name, List<Node?> Function(TestHarness test) nodeProvider, + dynamic Function(Node? node, Node? other) matcher) { TestHarness testHarness = new TestHarness(); - List<Node> nodes = nodeProvider(testHarness); + List<Node?> nodes = nodeProvider(testHarness); if (nodes.length != 2) throw "Needs exactly 2 nodes: Node and other!"; test( name,
diff --git a/pkg/kernel/tool/smoke_test_quick.dart b/pkg/kernel/tool/smoke_test_quick.dart index 6ca6e19..b5a0b9a 100644 --- a/pkg/kernel/tool/smoke_test_quick.dart +++ b/pkg/kernel/tool/smoke_test_quick.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.9 - import 'dart:io'; final String repoDir = _computeRepoDir();
diff --git a/tools/VERSION b/tools/VERSION index 69aef05..8235dad 100644 --- a/tools/VERSION +++ b/tools/VERSION
@@ -27,5 +27,5 @@ MAJOR 2 MINOR 14 PATCH 0 -PRERELEASE 356 +PRERELEASE 357 PRERELEASE_PATCH 0 \ No newline at end of file