Version 2.14.0-288.0.dev
Merge commit 'ecb6354a79d3fb717ef1e00561959e1987c1ec6b' into 'dev'
diff --git a/pkg/_fe_analyzer_shared/lib/src/testing/id_testing.dart b/pkg/_fe_analyzer_shared/lib/src/testing/id_testing.dart
index 4baea51..68ad3ab 100644
--- a/pkg/_fe_analyzer_shared/lib/src/testing/id_testing.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/testing/id_testing.dart
@@ -637,11 +637,11 @@
typedef Future<Map<String, TestResult<T>>> RunTestFunction<T>(TestData testData,
{required bool testAfterFailures,
- bool verbose,
- bool succinct,
- bool printCode,
+ required bool verbose,
+ required bool succinct,
+ required bool printCode,
Map<String, List<String>>? skipMap,
- Uri nullUri});
+ required Uri nullUri});
/// Compute the file: URI of the file located at `path`, where `path` is
/// relative to the root of the SDK repository.
diff --git a/pkg/front_end/lib/src/api_prototype/compiler_options.dart b/pkg/front_end/lib/src/api_prototype/compiler_options.dart
index 69ba280..370f581 100644
--- a/pkg/front_end/lib/src/api_prototype/compiler_options.dart
+++ b/pkg/front_end/lib/src/api_prototype/compiler_options.dart
@@ -364,7 +364,7 @@
/// Parse experimental flag arguments of the form 'flag' or 'no-flag' into a map
/// from 'flag' to `true` or `false`, respectively.
-Map<String, bool> parseExperimentalArguments(List<String>? arguments) {
+Map<String, bool> parseExperimentalArguments(Iterable<String>? arguments) {
Map<String, bool> result = {};
if (arguments != null) {
for (String argument in arguments) {
diff --git a/pkg/front_end/lib/src/api_prototype/constant_evaluator.dart b/pkg/front_end/lib/src/api_prototype/constant_evaluator.dart
index 5427e63..98dd0ab 100644
--- a/pkg/front_end/lib/src/api_prototype/constant_evaluator.dart
+++ b/pkg/front_end/lib/src/api_prototype/constant_evaluator.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 front_end.constant_evaluator;
export '../fasta/kernel/constant_evaluator.dart'
diff --git a/pkg/front_end/lib/src/api_prototype/file_system.dart b/pkg/front_end/lib/src/api_prototype/file_system.dart
index e4195c5..4d90308 100644
--- a/pkg/front_end/lib/src/api_prototype/file_system.dart
+++ b/pkg/front_end/lib/src/api_prototype/file_system.dart
@@ -104,3 +104,12 @@
@override
String toString() => 'FileSystemException(uri=$uri; message=$message)';
}
+
+class NullFileSystem implements FileSystem {
+ const NullFileSystem();
+
+ @override
+ FileSystemEntity entityForUri(Uri uri) {
+ throw new UnsupportedError('$runtimeType.entityForUri');
+ }
+}
diff --git a/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart b/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart
index 1e2a446..12614bb 100644
--- a/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart
+++ b/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.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:_fe_analyzer_shared/src/scanner/string_scanner.dart'
show StringScanner;
@@ -28,9 +26,9 @@
abstract class IncrementalKernelGenerator {
factory IncrementalKernelGenerator(CompilerOptions options, Uri entryPoint,
- [Uri initializeFromDillUri,
- bool outlineOnly,
- IncrementalSerializer incrementalSerializer]) {
+ [Uri? initializeFromDillUri,
+ bool? outlineOnly,
+ IncrementalSerializer? incrementalSerializer]) {
return new IncrementalCompiler(
new CompilerContext(
new ProcessedOptions(options: options, inputs: [entryPoint])),
@@ -45,7 +43,7 @@
/// platform will be loaded.
factory IncrementalKernelGenerator.fromComponent(
CompilerOptions options, Uri entryPoint, Component component,
- [bool outlineOnly, IncrementalSerializer incrementalSerializer]) {
+ [bool? outlineOnly, IncrementalSerializer? incrementalSerializer]) {
return new IncrementalCompiler.fromComponent(
new CompilerContext(
new ProcessedOptions(options: options, inputs: [entryPoint])),
@@ -78,11 +76,11 @@
/// Returns [CoreTypes] used during compilation.
/// Valid after [computeDelta] is called.
- CoreTypes getCoreTypes();
+ CoreTypes? getCoreTypes();
/// Returns [ClassHierarchy] used during compilation.
/// Valid after [computeDelta] is called.
- ClassHierarchy getClassHierarchy();
+ ClassHierarchy? getClassHierarchy();
/// Remove the file associated with the given file [uri] from the set of
/// valid files. This guarantees that those files will be re-read on the
@@ -132,7 +130,7 @@
/// [compileExpression] will return [null] if the library or class for
/// [enclosingNode] could not be found. Otherwise, errors are reported in the
/// normal way.
- Future<Procedure> compileExpression(
+ Future<Procedure?> compileExpression(
String expression,
Map<String, DartType> definitions,
List<TypeParameter> typeDefinitions,
diff --git a/pkg/front_end/lib/src/api_prototype/language_version.dart b/pkg/front_end/lib/src/api_prototype/language_version.dart
index bc5d353..3aa685b 100644
--- a/pkg/front_end/lib/src/api_prototype/language_version.dart
+++ b/pkg/front_end/lib/src/api_prototype/language_version.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:typed_data' show Uint8List;
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart'
@@ -42,13 +40,14 @@
// Get largest valid version / default version.
String currentSdkVersion = context.options.currentSdkVersion;
bool good = false;
- int currentSdkVersionMajor;
- int currentSdkVersionMinor;
+ late final int currentSdkVersionMajor;
+ late final int currentSdkVersionMinor;
+ // ignore: unnecessary_null_comparison
if (currentSdkVersion != null) {
List<String> dotSeparatedParts = currentSdkVersion.split(".");
if (dotSeparatedParts.length >= 2) {
- currentSdkVersionMajor = int.tryParse(dotSeparatedParts[0]);
- currentSdkVersionMinor = int.tryParse(dotSeparatedParts[1]);
+ currentSdkVersionMajor = int.parse(dotSeparatedParts[0]);
+ currentSdkVersionMinor = int.parse(dotSeparatedParts[1]);
good = true;
}
}
@@ -58,8 +57,8 @@
// Get file uri.
UriTranslator uriTranslator = await context.options.getUriTranslator();
- Uri fileUri;
- Package package;
+ Uri? fileUri;
+ Package? package;
if (uri.scheme == "package") {
fileUri = uriTranslator.translate(uri);
package = uriTranslator.getPackage(uri);
@@ -71,15 +70,16 @@
if (packageUri.scheme != 'dart' &&
packageUri.scheme != 'package' &&
package != null &&
+ // ignore: unnecessary_null_comparison
package.name != null) {
packageUri = new Uri(scheme: 'package', path: package.name);
}
// Check file content for @dart annotation.
- int major;
- int minor;
+ int? major;
+ int? minor;
if (fileUri != null) {
- List<int> rawBytes;
+ List<int>? rawBytes;
try {
FileSystem fileSystem = context.options.fileSystem;
rawBytes = await fileSystem.entityForUri(fileUri).readAsBytes();
@@ -103,32 +103,34 @@
if (major != null && minor != null) {
// Verify OK.
- if (major > currentSdkVersionMajor ||
- (major == currentSdkVersionMajor && minor > currentSdkVersionMinor)) {
+ if (major! > currentSdkVersionMajor ||
+ (major == currentSdkVersionMajor &&
+ minor! > currentSdkVersionMinor)) {
major = null;
minor = null;
}
}
if (major != null && minor != null) {
// The file decided. Return result.
- return new VersionAndPackageUri(new Version(major, minor), packageUri);
+ return new VersionAndPackageUri(new Version(major!, minor!), packageUri);
}
// Check package.
if (package != null &&
package.languageVersion != null &&
package.languageVersion is! InvalidLanguageVersion) {
- major = package.languageVersion.major;
- minor = package.languageVersion.minor;
- if (major > currentSdkVersionMajor ||
- (major == currentSdkVersionMajor && minor > currentSdkVersionMinor)) {
+ major = package.languageVersion!.major;
+ minor = package.languageVersion!.minor;
+ if (major! > currentSdkVersionMajor ||
+ (major == currentSdkVersionMajor &&
+ minor! > currentSdkVersionMinor)) {
major = null;
minor = null;
}
}
if (major != null && minor != null) {
// The package decided. Return result.
- return new VersionAndPackageUri(new Version(major, minor), packageUri);
+ return new VersionAndPackageUri(new Version(major!, minor!), packageUri);
}
// Return default.
diff --git a/pkg/front_end/lib/src/api_unstable/bazel_worker.dart b/pkg/front_end/lib/src/api_unstable/bazel_worker.dart
index 4d44607..46566f1 100644
--- a/pkg/front_end/lib/src/api_unstable/bazel_worker.dart
+++ b/pkg/front_end/lib/src/api_unstable/bazel_worker.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
-
/// API needed by `utils/front_end/summary_worker.dart`, a tool used to compute
/// summaries in build systems like bazel, pub-build, and package-build.
@@ -12,7 +10,7 @@
import 'package:front_end/src/api_prototype/compiler_options.dart';
-import 'package:kernel/kernel.dart' show Component, Library;
+import 'package:kernel/kernel.dart' show Component, Library, dummyComponent;
import 'package:kernel/target/targets.dart' show Target;
@@ -69,14 +67,14 @@
Map<Uri, List<int>> workerInputDigests,
Target target,
FileSystem fileSystem,
- Iterable<String> experiments,
+ Iterable<String>? experiments,
bool outlineOnly,
Map<String, String> environmentDefines,
{bool trackNeededDillLibraries: false,
bool verbose: false,
NnbdMode nnbdMode: NnbdMode.Weak}) async {
List<Component> outputLoadedAdditionalDills =
- new List<Component>.filled(additionalDills.length, null);
+ new List<Component>.filled(additionalDills.length, dummyComponent);
Map<ExperimentalFlag, bool> experimentalFlags = parseExperimentalFlags(
parseExperimentalArguments(experiments),
onError: (e) => throw e);
@@ -139,7 +137,7 @@
Future<CompilerResult> _compile(InitializedCompilerState compilerState,
List<Uri> inputs, DiagnosticMessageHandler diagnosticMessageHandler,
- {bool summaryOnly, bool includeOffsets: true}) {
+ {bool? summaryOnly, bool includeOffsets: true}) {
summaryOnly ??= true;
CompilerOptions options = compilerState.options;
options..onDiagnostic = diagnosticMessageHandler;
@@ -154,22 +152,22 @@
includeOffsets: includeOffsets);
}
-Future<List<int>> compileSummary(InitializedCompilerState compilerState,
+Future<List<int>?> compileSummary(InitializedCompilerState compilerState,
List<Uri> inputs, DiagnosticMessageHandler diagnosticMessageHandler,
{bool includeOffsets: false}) async {
CompilerResult result = await _compile(
compilerState, inputs, diagnosticMessageHandler,
summaryOnly: true, includeOffsets: includeOffsets);
- return result?.summary;
+ return result.summary;
}
-Future<Component> compileComponent(InitializedCompilerState compilerState,
+Future<Component?> compileComponent(InitializedCompilerState compilerState,
List<Uri> inputs, DiagnosticMessageHandler diagnosticMessageHandler) async {
CompilerResult result = await _compile(
compilerState, inputs, diagnosticMessageHandler,
summaryOnly: false);
- Component component = result?.component;
+ Component? component = result.component;
if (component != null) {
for (Library lib in component.libraries) {
if (!inputs.contains(lib.importUri)) {
diff --git a/pkg/front_end/lib/src/api_unstable/compiler_state.dart b/pkg/front_end/lib/src/api_unstable/compiler_state.dart
index 97779f8..bbf4ea9 100644
--- a/pkg/front_end/lib/src/api_unstable/compiler_state.dart
+++ b/pkg/front_end/lib/src/api_unstable/compiler_state.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 '../api_prototype/compiler_options.dart' show CompilerOptions;
import '../base/processed_options.dart' show ProcessedOptions;
@@ -16,14 +14,14 @@
class InitializedCompilerState {
final CompilerOptions options;
final ProcessedOptions processedOpts;
- final Map<Uri, WorkerInputComponent> workerInputCache;
+ final Map<Uri, WorkerInputComponent>? workerInputCache;
/// A map from library import uri to dill uri, i.e. where a library came from,
/// for all cached libraries.
- final Map<Uri, Uri> workerInputCacheLibs;
- final IncrementalCompiler incrementalCompiler;
- final Set<String> tags;
- final Map<Uri, Uri> libraryToInputDill;
+ final Map<Uri, Uri>? workerInputCacheLibs;
+ final IncrementalCompiler? incrementalCompiler;
+ final Set<String>? tags;
+ final Map<Uri, Uri>? libraryToInputDill;
InitializedCompilerState(this.options, this.processedOpts,
{this.workerInputCache,
@@ -43,7 +41,7 @@
WorkerInputComponent(this.digest, this.component);
}
-bool digestsEqual(List<int> a, List<int> b) {
+bool digestsEqual(List<int>? a, List<int>? b) {
if (a == null || b == null) return false;
if (a.length != b.length) return false;
for (int i = 0; i < a.length; i++) {
diff --git a/pkg/front_end/lib/src/api_unstable/dart2js.dart b/pkg/front_end/lib/src/api_unstable/dart2js.dart
index c9fbb930..d29d1ea 100644
--- a/pkg/front_end/lib/src/api_unstable/dart2js.dart
+++ b/pkg/front_end/lib/src/api_unstable/dart2js.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:_fe_analyzer_shared/src/messages/codes.dart'
show messageMissingMain;
@@ -25,7 +23,7 @@
import '../api_prototype/experimental_flags.dart' show ExperimentalFlag;
-import '../api_prototype/file_system.dart' show FileSystem;
+import '../api_prototype/file_system.dart' show FileSystem, NullFileSystem;
import '../api_prototype/kernel_generator.dart' show CompilerResult;
@@ -139,14 +137,14 @@
}
InitializedCompilerState initializeCompiler(
- InitializedCompilerState oldState,
+ InitializedCompilerState? oldState,
Target target,
Uri librariesSpecificationUri,
List<Uri> additionalDills,
Uri packagesFileUri,
- {Map<ExperimentalFlag, bool> explicitExperimentalFlags,
+ {required Map<ExperimentalFlag, bool> explicitExperimentalFlags,
bool verify: false,
- NnbdMode nnbdMode,
+ NnbdMode? nnbdMode,
Set<InvocationMode> invocationModes: const <InvocationMode>{},
Verbosity verbosity: Verbosity.all}) {
additionalDills.sort((a, b) => a.toString().compareTo(b.toString()));
@@ -183,7 +181,7 @@
return new InitializedCompilerState(options, processedOpts);
}
-Future<Component> compile(
+Future<Component?> compile(
InitializedCompilerState state,
bool verbose,
FileSystem fileSystem,
@@ -200,10 +198,10 @@
processedOpts.inputs.add(input);
processedOpts.clearFileSystemCache();
- CompilerResult compilerResult = await CompilerContext.runWithOptions(
+ CompilerResult? compilerResult = await CompilerContext.runWithOptions(
processedOpts, (CompilerContext context) async {
CompilerResult compilerResult = await generateKernelInternal();
- Component component = compilerResult?.component;
+ Component? component = compilerResult.component;
if (component == null) return null;
if (component.mainMethod == null) {
context.options.report(
@@ -216,7 +214,7 @@
// Remove these parameters from [options] - they are no longer needed and
// retain state from the previous compile. (http://dartbug.com/33708)
options.onDiagnostic = null;
- options.fileSystem = null;
+ options.fileSystem = const NullFileSystem();
return compilerResult?.component;
}
@@ -246,7 +244,7 @@
// is implemented correctly for patch files (Issue #33495).
bool isRedirectingFactory(ir.Procedure member) {
if (member.kind == ir.ProcedureKind.Factory) {
- Statement body = member.function.body;
+ Statement? body = member.function.body;
if (body is redirecting.RedirectingFactoryBody) return true;
if (body is ir.ExpressionStatement) {
ir.Expression expression = body.expression;
diff --git a/pkg/front_end/lib/src/api_unstable/ddc.dart b/pkg/front_end/lib/src/api_unstable/ddc.dart
index c3de146..d59fef2 100644
--- a/pkg/front_end/lib/src/api_unstable/ddc.dart
+++ b/pkg/front_end/lib/src/api_unstable/ddc.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:_fe_analyzer_shared/src/messages/diagnostic_message.dart'
show DiagnosticMessageHandler;
@@ -77,12 +75,13 @@
class DdcResult {
final Component component;
- final Component sdkSummary;
+ final Component? sdkSummary;
final List<Component> additionalDills;
final ClassHierarchy classHierarchy;
DdcResult(this.component, this.sdkSummary, this.additionalDills,
this.classHierarchy)
+ // ignore: unnecessary_null_comparison
: assert(classHierarchy != null);
Set<Library> computeLibrariesFromDill() {
@@ -94,7 +93,7 @@
}
}
if (sdkSummary != null) {
- for (Library lib in sdkSummary.libraries) {
+ for (Library lib in sdkSummary!.libraries) {
librariesFromDill.add(lib);
}
}
@@ -104,7 +103,7 @@
}
Future<InitializedCompilerState> initializeCompiler(
- InitializedCompilerState oldState,
+ InitializedCompilerState? oldState,
bool compileSdk,
Uri sdkRoot,
Uri sdkSummary,
@@ -112,10 +111,11 @@
Uri librariesSpecificationUri,
List<Uri> additionalDills,
Target target,
- {FileSystem fileSystem,
- Map<ExperimentalFlag, bool> explicitExperimentalFlags,
- Map<String, String> environmentDefines,
- NnbdMode nnbdMode}) async {
+ {FileSystem? fileSystem,
+ Map<ExperimentalFlag, bool>? explicitExperimentalFlags,
+ Map<String, String>? environmentDefines,
+ required NnbdMode nnbdMode}) async {
+ // ignore: unnecessary_null_comparison
assert(nnbdMode != null, "No NnbdMode provided.");
additionalDills.sort((a, b) => a.toString().compareTo(b.toString()));
@@ -169,11 +169,11 @@
List<Uri> additionalDills,
Map<Uri, List<int>> workerInputDigests,
Target target,
- {FileSystem fileSystem,
- Map<ExperimentalFlag, bool> explicitExperimentalFlags,
- Map<String, String> environmentDefines,
+ {FileSystem? fileSystem,
+ required Map<ExperimentalFlag, bool> explicitExperimentalFlags,
+ required Map<String, String> environmentDefines,
bool trackNeededDillLibraries: false,
- NnbdMode nnbdMode}) async {
+ required NnbdMode nnbdMode}) async {
return modular.initializeIncrementalCompiler(
oldState,
tags,
@@ -188,15 +188,14 @@
sdkRoot: sdkRoot,
fileSystem: fileSystem ?? StandardFileSystem.instance,
explicitExperimentalFlags: explicitExperimentalFlags,
- environmentDefines:
- environmentDefines ?? const <ExperimentalFlag, bool>{},
+ environmentDefines: environmentDefines,
outlineOnly: false,
omitPlatform: false,
trackNeededDillLibraries: trackNeededDillLibraries,
nnbdMode: nnbdMode);
}
-Future<DdcResult> compile(InitializedCompilerState compilerState,
+Future<DdcResult?> compile(InitializedCompilerState compilerState,
List<Uri> inputs, DiagnosticMessageHandler diagnosticMessageHandler) async {
CompilerOptions options = compilerState.options;
options..onDiagnostic = diagnosticMessageHandler;
@@ -208,12 +207,12 @@
CompilerResult compilerResult =
await generateKernel(processedOpts, includeHierarchyAndCoreTypes: true);
- Component component = compilerResult?.component;
+ Component? component = compilerResult.component;
if (component == null) return null;
// These should be cached.
- Component sdkSummary = await processedOpts.loadSdkSummary(null);
+ Component? sdkSummary = await processedOpts.loadSdkSummary(null);
List<Component> summaries = await processedOpts.loadAdditionalDills(null);
return new DdcResult(
- component, sdkSummary, summaries, compilerResult.classHierarchy);
+ component, sdkSummary, summaries, compilerResult.classHierarchy!);
}
diff --git a/pkg/front_end/lib/src/api_unstable/modular_incremental_compilation.dart b/pkg/front_end/lib/src/api_unstable/modular_incremental_compilation.dart
index 7086aad..65eceae 100644
--- a/pkg/front_end/lib/src/api_unstable/modular_incremental_compilation.dart
+++ b/pkg/front_end/lib/src/api_unstable/modular_incremental_compilation.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' show Component, CanonicalName, Library;
import 'package:kernel/target/targets.dart' show Target;
@@ -39,7 +37,7 @@
/// [outputLoadedAdditionalDills] after this call corresponds to the component
/// loaded from the `i`-th entry in [additionalDills].
Future<InitializedCompilerState> initializeIncrementalCompiler(
- InitializedCompilerState oldState,
+ InitializedCompilerState? oldState,
Set<String> tags,
List<Component> outputLoadedAdditionalDills,
Uri sdkSummary,
@@ -49,11 +47,11 @@
Map<Uri, List<int>> workerInputDigests,
Target target,
{bool compileSdk: false,
- Uri sdkRoot: null,
- FileSystem fileSystem,
- Map<ExperimentalFlag, bool> explicitExperimentalFlags,
+ Uri? sdkRoot: null,
+ required FileSystem fileSystem,
+ required Map<ExperimentalFlag, bool> explicitExperimentalFlags,
Map<String, String> environmentDefines: const {},
- bool outlineOnly,
+ bool? outlineOnly,
bool omitPlatform: false,
bool trackNeededDillLibraries: false,
bool verbose: false,
@@ -61,7 +59,7 @@
bool isRetry = false;
while (true) {
try {
- final List<int> sdkDigest = workerInputDigests[sdkSummary];
+ final List<int>? sdkDigest = workerInputDigests[sdkSummary];
if (sdkDigest == null) {
throw new StateError("Expected to get digest for $sdkSummary");
}
@@ -71,7 +69,7 @@
Map<Uri, Uri> workerInputCacheLibs =
oldState?.workerInputCacheLibs ?? new Map<Uri, Uri>();
- WorkerInputComponent cachedSdkInput = workerInputCache[sdkSummary];
+ WorkerInputComponent? cachedSdkInput = workerInputCache[sdkSummary];
IncrementalCompiler incrementalCompiler;
CompilerOptions options;
@@ -80,7 +78,7 @@
if (oldState == null ||
oldState.incrementalCompiler == null ||
oldState.options.compileSdk != compileSdk ||
- oldState.incrementalCompiler.outlineOnly != outlineOnly ||
+ oldState.incrementalCompiler!.outlineOnly != outlineOnly ||
oldState.options.nnbdMode != nnbdMode ||
!equalMaps(oldState.options.explicitExperimentalFlags,
explicitExperimentalFlags) ||
@@ -110,7 +108,7 @@
processedOpts = new ProcessedOptions(options: options);
cachedSdkInput = new WorkerInputComponent(
- sdkDigest, await processedOpts.loadSdkSummary(null));
+ sdkDigest, (await processedOpts.loadSdkSummary(null))!);
workerInputCache[sdkSummary] = cachedSdkInput;
for (Library lib in cachedSdkInput.component.libraries) {
if (workerInputCacheLibs.containsKey(lib.importUri)) {
@@ -144,7 +142,7 @@
}
// Reuse the incremental compiler, but reset as needed.
- incrementalCompiler = oldState.incrementalCompiler;
+ incrementalCompiler = oldState.incrementalCompiler!;
incrementalCompiler.invalidateAllSources();
incrementalCompiler.trackNeededDillLibraries = trackNeededDillLibraries;
options.packagesFileUri = packagesFile;
@@ -154,7 +152,7 @@
// Then read all the input summary components.
CanonicalName nameRoot = cachedSdkInput.component.root;
- Map<Uri, Uri> libraryToInputDill;
+ Map<Uri, Uri>? libraryToInputDill;
if (trackNeededDillLibraries) {
libraryToInputDill = new Map<Uri, Uri>();
}
@@ -169,8 +167,8 @@
for (int i = 0; i < additionalDills.length; i++) {
Uri summaryUri = additionalDills[i];
additionalDillsSet.add(summaryUri);
- WorkerInputComponent cachedInput = workerInputCache[summaryUri];
- List<int> digest = workerInputDigests[summaryUri];
+ WorkerInputComponent? cachedInput = workerInputCache[summaryUri];
+ List<int>? digest = workerInputDigests[summaryUri];
if (digest == null) {
throw new StateError("Expected to get digest for $summaryUri");
}
@@ -178,7 +176,7 @@
cachedInput.component.root != nameRoot ||
!digestsEqual(digest, cachedInput.digest)) {
// Remove any old libraries from workerInputCacheLibs.
- Component component = cachedInput?.component;
+ Component? component = cachedInput?.component;
if (component != null) {
for (Library lib in component.libraries) {
workerInputCacheLibs.remove(lib.importUri);
@@ -191,7 +189,7 @@
Component component = cachedInput.component;
if (trackNeededDillLibraries) {
for (Library lib in component.libraries) {
- libraryToInputDill[lib.importUri] = summaryUri;
+ libraryToInputDill![lib.importUri] = summaryUri;
}
}
component.computeCanonicalNames(); // this isn't needed, is it?
@@ -202,7 +200,7 @@
for (int i = 0; i < loadFromDillIndexes.length; i++) {
int index = loadFromDillIndexes[i];
Uri additionalDillUri = additionalDills[index];
- List<int> digest = workerInputDigests[additionalDillUri];
+ List<int>? digest = workerInputDigests[additionalDillUri];
if (digest == null) {
throw new StateError("Expected to get digest for $additionalDillUri");
}
@@ -217,7 +215,7 @@
outputLoadedAdditionalDills[index] = cachedInput.component;
for (Library lib in cachedInput.component.libraries) {
if (workerInputCacheLibs.containsKey(lib.importUri)) {
- Uri fromSummary = workerInputCacheLibs[lib.importUri];
+ Uri fromSummary = workerInputCacheLibs[lib.importUri]!;
if (additionalDillsSet.contains(fromSummary)) {
throw new StateError(
"Asked to load several summaries that contain the same "
@@ -225,7 +223,7 @@
} else {
// Library contained in old cached component. Flush that cache.
Component component =
- workerInputCache.remove(fromSummary).component;
+ workerInputCache.remove(fromSummary)!.component;
for (Library lib in component.libraries) {
workerInputCacheLibs.remove(lib.importUri);
}
@@ -235,7 +233,7 @@
}
if (trackNeededDillLibraries) {
- libraryToInputDill[lib.importUri] = additionalDillUri;
+ libraryToInputDill![lib.importUri] = additionalDillUri;
}
}
}
diff --git a/pkg/front_end/lib/src/api_unstable/vm.dart b/pkg/front_end/lib/src/api_unstable/vm.dart
index 6506633..35d7c8b 100644
--- a/pkg/front_end/lib/src/api_unstable/vm.dart
+++ b/pkg/front_end/lib/src/api_unstable/vm.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
-
export 'package:_fe_analyzer_shared/src/messages/diagnostic_message.dart'
show DiagnosticMessage, DiagnosticMessageHandler, getMessageUri;
diff --git a/pkg/front_end/lib/src/base/library_info.dart b/pkg/front_end/lib/src/base/library_info.dart
index a8186f3..ec1153a 100644
--- a/pkg/front_end/lib/src/base/library_info.dart
+++ b/pkg/front_end/lib/src/base/library_info.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 bit flag used by [LibraryInfo] indicating that a library is used by
/// dart2js.
///
@@ -19,7 +17,7 @@
/// Parse a category string in the SDK's "libraries.dart".
///
/// This declaration duplicates the declaration in the SDK's "libraries.dart".
-Category parseCategory(String name) {
+Category? parseCategory(String name) {
switch (name) {
case 'Client':
return Category.client;
@@ -59,11 +57,11 @@
/// Path to the dart2js library's *.dart file relative to the SDK's "lib"
/// directory, or null if dart2js uses the common library path defined above.
- final String dart2jsPath;
+ final String? dart2jsPath;
/// Path to the dart2js library's patch file relative to the SDK's "lib"
/// directory, or null if no dart2js patch file associated with this library.
- final String dart2jsPatchPath;
+ final String? dart2jsPatchPath;
/// True if this library is documented and should be shown to the user.
final bool documented;
@@ -98,7 +96,11 @@
List<Category> get categories {
// `''.split(',')` returns [''], not [], so we handle that case separately.
if (_categories.isEmpty) return const <Category>[];
- return _categories.split(',').map(parseCategory).toList();
+ return _categories
+ .split(',')
+ .map(parseCategory)
+ .whereType<Category>()
+ .toList();
}
/// The original "categories" String that was passed to the constructor.
@@ -123,25 +125,25 @@
1,
"Experimental",
"This library is experimental and will likely change or be removed\n"
- "in future versions.");
+ "in future versions.");
static const Maturity UNSTABLE = const Maturity(
2,
"Unstable",
"This library is in still changing and have not yet endured\n"
- "sufficient real-world testing.\n"
- "Backwards-compatibility is NOT guaranteed.");
+ "sufficient real-world testing.\n"
+ "Backwards-compatibility is NOT guaranteed.");
static const Maturity WEB_STABLE = const Maturity(
3,
"Web Stable",
"This library is tracking the DOM evolution as defined by WC3.\n"
- "Backwards-compatibility is NOT guaranteed.");
+ "Backwards-compatibility is NOT guaranteed.");
static const Maturity STABLE = const Maturity(
4,
"Stable",
"The library is stable. API backwards-compatibility is guaranteed.\n"
- "However implementation details might change.");
+ "However implementation details might change.");
static const Maturity LOCKED = const Maturity(5, "Locked",
"This library will not change except when serious bugs are encountered.");
diff --git a/pkg/front_end/lib/src/base/processed_options.dart b/pkg/front_end/lib/src/base/processed_options.dart
index a430965c..b3f9998 100644
--- a/pkg/front_end/lib/src/base/processed_options.dart
+++ b/pkg/front_end/lib/src/base/processed_options.dart
@@ -450,7 +450,7 @@
/// Get the components for each of the underlying `additionalDill`
/// provided via [CompilerOptions].
// TODO(sigmund): move, this doesn't feel like an "option".
- Future<List<Component>> loadAdditionalDills(CanonicalName nameRoot) async {
+ Future<List<Component>> loadAdditionalDills(CanonicalName? nameRoot) async {
if (_additionalDillComponents == null) {
List<Uri> uris = _raw.additionalDills;
// ignore: unnecessary_null_comparison
diff --git a/pkg/front_end/lib/src/fasta/builder_graph.dart b/pkg/front_end/lib/src/fasta/builder_graph.dart
index f6f447a..d874063 100644
--- a/pkg/front_end/lib/src/fasta/builder_graph.dart
+++ b/pkg/front_end/lib/src/fasta/builder_graph.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.builder_graph;
import 'package:kernel/kernel.dart' show LibraryDependency, LibraryPart;
@@ -30,7 +28,7 @@
Iterable<Uri> get vertices => builders.keys;
Iterable<Uri> neighborsOf(Uri vertex) sync* {
- LibraryBuilder library = builders[vertex];
+ LibraryBuilder? library = builders[vertex];
if (library == null) {
throw "Library not found: $vertex";
}
@@ -38,7 +36,7 @@
for (Import import in library.imports) {
// 'imported' can be null for fake imports, such as dart-ext:.
if (import.imported != null) {
- Uri uri = import.imported.importUri;
+ Uri uri = import.imported!.importUri;
if (builders.containsKey(uri)) {
yield uri;
}
@@ -50,7 +48,7 @@
yield uri;
}
}
- for (SourceLibraryBuilder part in library.parts) {
+ for (LibraryBuilder part in library.parts) {
Uri uri = part.importUri;
if (builders.containsKey(uri)) {
yield uri;
diff --git a/pkg/front_end/lib/src/fasta/get_dependencies.dart b/pkg/front_end/lib/src/fasta/get_dependencies.dart
index 903c1b0..78504b7 100644
--- a/pkg/front_end/lib/src/fasta/get_dependencies.dart
+++ b/pkg/front_end/lib/src/fasta/get_dependencies.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.get_dependencies;
import 'package:kernel/kernel.dart' show Component, loadComponentFromBytes;
@@ -25,11 +23,11 @@
import 'uri_translator.dart' show UriTranslator;
Future<List<Uri>> getDependencies(Uri script,
- {Uri sdk,
- Uri packages,
- Uri platform,
+ {Uri? sdk,
+ Uri? packages,
+ Uri? platform,
bool verbose: false,
- Target target}) async {
+ Target? target}) async {
CompilerOptions options = new CompilerOptions()
..target = target
..verbose = verbose
diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
index 70fdc54..cb1f2a1 100644
--- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart
+++ b/pkg/front_end/lib/src/fasta/incremental_compiler.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.incremental_compiler;
import 'dart:async' show Completer;
@@ -137,41 +135,41 @@
final bool resetTicker;
final bool outlineOnly;
bool trackNeededDillLibraries = false;
- Set<Library> neededDillLibraries;
+ Set<Library>? neededDillLibraries;
- Set<Uri> invalidatedUris = new Set<Uri>();
+ Set<Uri?> invalidatedUris = new Set<Uri?>();
- DillTarget dillLoadedData;
- List<LibraryBuilder> platformBuilders;
- Map<Uri, LibraryBuilder> userBuilders;
- final Uri initializeFromDillUri;
- Component componentToInitializeFrom;
+ DillTarget? dillLoadedData;
+ List<LibraryBuilder>? platformBuilders;
+ Map<Uri, LibraryBuilder>? userBuilders;
+ final Uri? initializeFromDillUri;
+ Component? componentToInitializeFrom;
bool initializedFromDill = false;
bool initializedIncrementalSerializer = false;
- Uri previousPackagesUri;
- Map<String, Package> previousPackagesMap;
- Map<String, Package> currentPackagesMap;
+ Uri? previousPackagesUri;
+ Map<String, Package>? previousPackagesMap;
+ Map<String, Package>? currentPackagesMap;
bool hasToCheckPackageUris = false;
final bool initializedForExpressionCompilationOnly;
bool computeDeltaRunOnce = false;
Map<Uri, List<DiagnosticMessageFromJson>> remainingComponentProblems =
new Map<Uri, List<DiagnosticMessageFromJson>>();
- List<Component> modulesToLoad;
- IncrementalSerializer incrementalSerializer;
+ List<Component>? modulesToLoad;
+ IncrementalSerializer? incrementalSerializer;
static final Uri debugExprUri =
new Uri(scheme: "org-dartlang-debug", path: "synthetic_debug_expression");
- IncrementalKernelTarget userCode;
- Set<Library> previousSourceBuilders;
+ IncrementalKernelTarget? userCode;
+ Set<Library>? previousSourceBuilders;
/// Guard against multiple computeDelta calls at the same time (possibly
/// caused by lacking awaits etc).
- Completer<dynamic> currentlyCompiling;
+ Completer<dynamic>? currentlyCompiling;
IncrementalCompiler.fromComponent(
this.context, this.componentToInitializeFrom,
- [bool outlineOnly, this.incrementalSerializer])
+ [bool? outlineOnly, this.incrementalSerializer])
: ticker = context.options.ticker,
resetTicker = true,
initializeFromDillUri = null,
@@ -182,7 +180,7 @@
IncrementalCompiler(this.context,
[this.initializeFromDillUri,
- bool outlineOnly,
+ bool? outlineOnly,
this.incrementalSerializer])
: ticker = context.options.ticker,
resetTicker = true,
@@ -194,7 +192,7 @@
IncrementalCompiler.forExpressionCompilationOnly(
this.context, this.componentToInitializeFrom,
- [bool resetTicker])
+ [bool? resetTicker])
: ticker = context.options.ticker,
this.resetTicker = resetTicker ?? true,
initializeFromDillUri = null,
@@ -204,7 +202,7 @@
enableExperimentsBasedOnEnvironment();
}
- void enableExperimentsBasedOnEnvironment({Set<String> enabledExperiments}) {
+ void enableExperimentsBasedOnEnvironment({Set<String>? enabledExperiments}) {
// Note that these are all experimental. Use at your own risk.
enabledExperiments ??= getExperimentEnvironment();
// Currently there's no live experiments.
@@ -217,9 +215,9 @@
@override
Future<Component> computeDelta(
- {List<Uri> entryPoints, bool fullComponent: false}) async {
+ {List<Uri>? entryPoints, bool fullComponent: false}) async {
while (currentlyCompiling != null) {
- await currentlyCompiling.future;
+ await currentlyCompiling!.future;
}
currentlyCompiling = new Completer();
if (resetTicker) {
@@ -238,41 +236,43 @@
await ensurePlatformAndInitialize(uriTranslator, c);
// Figure out what to keep and what to throw away.
- Set<Uri> invalidatedUris = this.invalidatedUris.toSet();
+ Set<Uri?> invalidatedUris = this.invalidatedUris.toSet();
invalidateNotKeptUserBuilders(invalidatedUris);
- ReusageResult reusedResult =
- computeReusedLibraries(invalidatedUris, uriTranslator, entryPoints);
+ ReusageResult? reusedResult =
+ computeReusedLibraries(invalidatedUris, uriTranslator, entryPoints!);
// Use the reused libraries to re-write entry-points.
if (reusedResult.arePartsUsedAsEntryPoints()) {
- for (int i = 0; i < entryPoints.length; i++) {
- Uri entryPoint = entryPoints[i];
- Uri redirect =
+ for (int i = 0; i < entryPoints!.length; i++) {
+ Uri entryPoint = entryPoints![i];
+ Uri? redirect =
reusedResult.getLibraryUriForPartUsedAsEntryPoint(entryPoint);
if (redirect != null) {
- entryPoints[i] = redirect;
+ entryPoints![i] = redirect;
}
}
}
// Experimental invalidation initialization (e.g. figure out if we can).
- ExperimentalInvalidation experimentalInvalidation =
+ ExperimentalInvalidation? experimentalInvalidation =
await initializeExperimentalInvalidation(reusedResult, c);
recordRebuildBodiesCountForTesting(
- experimentalInvalidation?.missingSources?.length ?? 0);
+ experimentalInvalidation?.missingSources.length ?? 0);
// Cleanup: After (potentially) removing builders we have stuff to cleanup
// to not leak, and we might need to re-create the dill target.
cleanupRemovedBuilders(reusedResult, uriTranslator);
recreateDillTargetIfPackageWasUpdated(uriTranslator, c);
- ClassHierarchy hierarchy = userCode?.loader?.hierarchy;
+ ClassHierarchy? hierarchy = userCode?.loader.hierarchy;
cleanupHierarchy(hierarchy, experimentalInvalidation, reusedResult);
List<LibraryBuilder> reusedLibraries = reusedResult.reusedLibraries;
reusedResult = null;
+ // TODO(jensj): Given the code below, [userCode] is assumed always to be
+ // non-null.
if (userCode != null) {
ticker.logMs("Decided to reuse ${reusedLibraries.length}"
- " of ${userCode.loader.builders.length} libraries");
+ " of ${userCode!.loader.builders.length} libraries");
}
// For modular compilation we can be asked to load components and track
@@ -283,14 +283,14 @@
// For each computeDelta call we create a new userCode object which needs
// to be setup, and in the case of experimental invalidation some of the
// builders needs to be patched up.
- KernelTarget userCodeOld = userCode;
+ IncrementalKernelTarget? userCodeOld = userCode;
setupNewUserCode(c, uriTranslator, hierarchy, reusedLibraries,
- experimentalInvalidation, entryPoints.first);
- Map<LibraryBuilder, List<LibraryBuilder>> rebuildBodiesMap =
+ experimentalInvalidation, entryPoints!.first);
+ Map<LibraryBuilder, List<LibraryBuilder>>? rebuildBodiesMap =
experimentalInvalidationCreateRebuildBodiesBuilders(
experimentalInvalidation, uriTranslator);
- entryPoints = userCode.setEntryPoints(entryPoints);
- await userCode.loader.buildOutlines();
+ entryPoints = userCode!.setEntryPoints(entryPoints!);
+ await userCode!.loader.buildOutlines();
experimentalInvalidationPatchUpScopes(
experimentalInvalidation, rebuildBodiesMap);
rebuildBodiesMap = null;
@@ -301,49 +301,51 @@
// libraries loaded from .dill files or directly from components.
// Technically, it's the combination of userCode.loader.libraries and
// dillLoadedData.loader.libraries.
- Component componentWithDill = await userCode.buildOutlines();
+ Component? componentWithDill = await userCode!.buildOutlines();
if (!outlineOnly) {
// Checkpoint: Build the actual bodies.
componentWithDill =
- await userCode.buildComponent(verify: c.options.verify);
+ await userCode!.buildComponent(verify: c.options.verify);
}
- hierarchy ??= userCode.loader.hierarchy;
+ hierarchy ??= userCode!.loader.hierarchy;
+ // ignore: unnecessary_null_comparison
if (hierarchy != null) {
- if (userCode.classHierarchyChanges != null) {
- hierarchy.applyTreeChanges([], [], userCode.classHierarchyChanges);
+ if (userCode!.classHierarchyChanges != null) {
+ hierarchy.applyTreeChanges([], [], userCode!.classHierarchyChanges!);
}
- if (userCode.classMemberChanges != null) {
- hierarchy.applyMemberChanges(userCode.classMemberChanges,
+ if (userCode!.classMemberChanges != null) {
+ hierarchy.applyMemberChanges(userCode!.classMemberChanges!,
findDescendants: true);
}
}
- recordNonFullComponentForTesting(componentWithDill);
+ recordNonFullComponentForTesting(componentWithDill!);
// Perform actual dill usage tracking.
performDillUsageTracking(hierarchy);
// If we actually got a result we can throw away the old userCode and the
// list of invalidated uris.
+ // ignore: unnecessary_null_comparison
if (componentWithDill != null) {
this.invalidatedUris.clear();
hasToCheckPackageUris = false;
- userCodeOld?.loader?.releaseAncillaryResources();
+ userCodeOld?.loader.releaseAncillaryResources();
userCodeOld = null;
}
// Compute which libraries to output and which (previous) errors/warnings
// we have to reissue. In the process do some cleanup too.
List<Library> compiledLibraries =
- new List<Library>.from(userCode.loader.libraries);
- Map<Uri, Source> uriToSource = componentWithDill?.uriToSource;
+ new List<Library>.from(userCode!.loader.libraries);
+ Map<Uri, Source> uriToSource = componentWithDill.uriToSource;
experimentalCompilationPostCompilePatchup(
experimentalInvalidation, compiledLibraries, uriToSource);
List<Library> outputLibraries =
calculateOutputLibrariesAndIssueLibraryProblems(
data.component != null || fullComponent,
compiledLibraries,
- entryPoints,
+ entryPoints!,
reusedLibraries,
hierarchy,
uriTranslator,
@@ -353,10 +355,11 @@
// If we didn't get a result, go back to the previous one so expression
// calculation has the potential to work.
+ // ignore: unnecessary_null_comparison
if (componentWithDill == null) {
- userCode.loader.builders.clear();
+ userCode!.loader.builders.clear();
userCode = userCodeOld;
- dillLoadedData.loader.currentSourceLoader = userCode.loader;
+ dillLoadedData!.loader.currentSourceLoader = userCode!.loader;
} else {
previousSourceBuilders =
await convertSourceLibraryBuildersToDill(experimentalInvalidation);
@@ -365,19 +368,21 @@
experimentalInvalidation = null;
// Output result.
- Procedure mainMethod = componentWithDill == null
+ // ignore: unnecessary_null_comparison
+ Procedure? mainMethod = componentWithDill == null
? data.component?.mainMethod
: componentWithDill.mainMethod;
- NonNullableByDefaultCompiledMode compiledMode = componentWithDill == null
+ // ignore: unnecessary_null_comparison
+ NonNullableByDefaultCompiledMode? compiledMode = componentWithDill == null
? data.component?.mode
: componentWithDill.mode;
Component result = context.options.target.configureComponent(
new Component(libraries: outputLibraries, uriToSource: uriToSource))
- ..setMainMethodAndMode(mainMethod?.reference, true, compiledMode)
+ ..setMainMethodAndMode(mainMethod?.reference, true, compiledMode!)
..problemsAsJson = problemsAsJson;
// We're now done. Allow any waiting compile to start.
- Completer<dynamic> currentlyCompilingLocal = currentlyCompiling;
+ Completer<dynamic> currentlyCompilingLocal = currentlyCompiling!;
currentlyCompiling = null;
currentlyCompilingLocal.complete();
@@ -394,22 +399,22 @@
///
/// Returns the set of Libraries that now has new (dill) builders.
Future<Set<Library>> convertSourceLibraryBuildersToDill(
- ExperimentalInvalidation experimentalInvalidation) async {
+ ExperimentalInvalidation? experimentalInvalidation) async {
bool changed = false;
Set<Library> newDillLibraryBuilders = new Set<Library>();
userBuilders ??= <Uri, LibraryBuilder>{};
- Map<LibraryBuilder, List<LibraryBuilder>> convertedLibraries;
+ Map<LibraryBuilder, List<LibraryBuilder>>? convertedLibraries;
for (MapEntry<Uri, LibraryBuilder> entry
- in userCode.loader.builders.entries) {
+ in userCode!.loader.builders.entries) {
if (entry.value is SourceLibraryBuilder) {
- SourceLibraryBuilder builder = entry.value;
+ SourceLibraryBuilder builder = entry.value as SourceLibraryBuilder;
DillLibraryBuilder dillBuilder =
- dillLoadedData.loader.appendLibrary(builder.library);
- userCode.loader.builders[entry.key] = dillBuilder;
- userBuilders[entry.key] = dillBuilder;
+ dillLoadedData!.loader.appendLibrary(builder.library);
+ userCode!.loader.builders[entry.key] = dillBuilder;
+ userBuilders![entry.key] = dillBuilder;
newDillLibraryBuilders.add(builder.library);
- if (userCode.loader.first == builder) {
- userCode.loader.first = dillBuilder;
+ if (userCode!.loader.first == builder) {
+ userCode!.loader.first = dillBuilder;
}
changed = true;
if (experimentalInvalidation != null) {
@@ -422,9 +427,9 @@
if (changed) {
// We suppress finalization errors because they have already been
// reported.
- await dillLoadedData.buildOutlines(suppressFinalizationErrors: true);
+ await dillLoadedData!.buildOutlines(suppressFinalizationErrors: true);
assert(_checkEquivalentScopes(
- userCode.loader.builders, dillLoadedData.loader.builders));
+ userCode!.loader.builders, dillLoadedData!.loader.builders));
if (experimentalInvalidation != null) {
/// If doing experimental invalidation that means that some of the old
@@ -432,17 +437,17 @@
/// source builders. Patch that up.
// Maps from old library builder to map of new content.
- Map<LibraryBuilder, Map<String, Builder>> replacementMap = {};
+ Map<LibraryBuilder, Map<String, Builder>>? replacementMap = {};
// Maps from old library builder to map of new content.
- Map<LibraryBuilder, Map<String, Builder>> replacementSettersMap = {};
+ Map<LibraryBuilder, Map<String, Builder>>? replacementSettersMap = {};
experimentalInvalidationFillReplacementMaps(
- convertedLibraries, replacementMap, replacementSettersMap);
+ convertedLibraries!, replacementMap, replacementSettersMap);
for (LibraryBuilder builder
in experimentalInvalidation.originalNotReusedLibraries) {
- DillLibraryBuilder dillBuilder = builder;
+ DillLibraryBuilder dillBuilder = builder as DillLibraryBuilder;
if (dillBuilder.isBuilt) {
dillBuilder.exportScope
.patchUpScope(replacementMap, replacementSettersMap);
@@ -460,12 +465,12 @@
replacementSettersMap = null;
}
}
- userCode.loader.buildersCreatedWithReferences.clear();
- userCode.loader.builderHierarchy.clear();
- userCode.loader.referenceFromIndex = null;
+ userCode!.loader.buildersCreatedWithReferences.clear();
+ userCode!.loader.builderHierarchy.clear();
+ userCode!.loader.referenceFromIndex = null;
convertedLibraries = null;
experimentalInvalidation = null;
- if (userBuilders.isEmpty) userBuilders = null;
+ if (userBuilders!.isEmpty) userBuilders = null;
return newDillLibraryBuilders;
}
@@ -473,7 +478,8 @@
Map<Uri, LibraryBuilder> dillLibraries) {
sourceLibraries.forEach((Uri uri, LibraryBuilder sourceLibraryBuilder) {
if (sourceLibraryBuilder is SourceLibraryBuilder) {
- DillLibraryBuilder dillLibraryBuilder = dillLibraries[uri];
+ DillLibraryBuilder dillLibraryBuilder =
+ dillLibraries[uri] as DillLibraryBuilder;
assert(
_hasEquivalentScopes(sourceLibraryBuilder, dillLibraryBuilder) ==
null,
@@ -483,14 +489,14 @@
return true;
}
- String _hasEquivalentScopes(SourceLibraryBuilder sourceLibraryBuilder,
+ String? _hasEquivalentScopes(SourceLibraryBuilder sourceLibraryBuilder,
DillLibraryBuilder dillLibraryBuilder) {
bool isEquivalent = true;
StringBuffer sb = new StringBuffer();
sb.writeln('Mismatch on ${sourceLibraryBuilder.importUri}:');
sourceLibraryBuilder.exportScope
.forEachLocalMember((String name, Builder sourceBuilder) {
- Builder dillBuilder =
+ Builder? dillBuilder =
dillLibraryBuilder.exportScope.lookupLocalMember(name, setter: false);
if (dillBuilder == null) {
if ((name == 'dynamic' || name == 'Never') &&
@@ -506,7 +512,7 @@
});
dillLibraryBuilder.exportScope
.forEachLocalMember((String name, Builder dillBuilder) {
- Builder sourceBuilder = sourceLibraryBuilder.exportScope
+ Builder? sourceBuilder = sourceLibraryBuilder.exportScope
.lookupLocalMember(name, setter: false);
if (sourceBuilder == null) {
sb.writeln('No source builder for ${name}: $dillBuilder');
@@ -515,7 +521,7 @@
});
sourceLibraryBuilder.exportScope
.forEachLocalSetter((String name, Builder sourceBuilder) {
- Builder dillBuilder =
+ Builder? dillBuilder =
dillLibraryBuilder.exportScope.lookupLocalMember(name, setter: true);
if (dillBuilder == null) {
sb.writeln('No dill builder for ${name}=: $sourceBuilder');
@@ -524,7 +530,7 @@
});
dillLibraryBuilder.exportScope
.forEachLocalSetter((String name, Builder dillBuilder) {
- Builder sourceBuilder = sourceLibraryBuilder.exportScope
+ Builder? sourceBuilder = sourceLibraryBuilder.exportScope
.lookupLocalMember(name, setter: true);
if (sourceBuilder == null) {
sourceBuilder = sourceLibraryBuilder.exportScope
@@ -561,8 +567,8 @@
reusedLibraries, hierarchy, uriTranslator, uriToSource);
allLibraries = outputLibraries.toSet();
if (!c.options.omitPlatform) {
- for (int i = 0; i < platformBuilders.length; i++) {
- Library lib = platformBuilders[i].library;
+ for (int i = 0; i < platformBuilders!.length; i++) {
+ Library lib = platformBuilders![i].library;
outputLibraries.add(lib);
}
}
@@ -591,7 +597,7 @@
/// This might be a temporary thing, but we need to figure out if the VM
/// can (always) work with only getting the actually rebuild stuff.
void experimentalCompilationPostCompilePatchup(
- ExperimentalInvalidation experimentalInvalidation,
+ ExperimentalInvalidation? experimentalInvalidation,
List<Library> compiledLibraries,
Map<Uri, Source> uriToSource) {
if (experimentalInvalidation != null) {
@@ -600,7 +606,7 @@
for (Uri uri in experimentalInvalidation.missingSources) {
// TODO(jensj): KernelTargets "link" takes some "excludeSource"
// setting into account.
- uriToSource[uri] = CompilerContext.current.uriToSource[uri];
+ uriToSource[uri] = CompilerContext.current.uriToSource[uri]!;
}
}
}
@@ -612,16 +618,16 @@
if (trackNeededDillLibraries) {
// Which dill builders were built?
neededDillLibraries = new Set<Library>();
- for (LibraryBuilder builder in dillLoadedData.loader.builders.values) {
+ for (LibraryBuilder builder in dillLoadedData!.loader.builders.values) {
if (builder is DillLibraryBuilder) {
if (builder.isBuiltAndMarked) {
- neededDillLibraries.add(builder.library);
+ neededDillLibraries!.add(builder.library);
}
}
}
updateNeededDillLibrariesWithHierarchy(
- hierarchy, userCode.loader.builderHierarchy);
+ hierarchy, userCode!.loader.builderHierarchy);
}
}
@@ -635,7 +641,7 @@
in rebuildBodiesMap.entries) {
Map<String, Builder> childReplacementMap = {};
Map<String, Builder> childReplacementSettersMap = {};
- List<LibraryBuilder> builders = rebuildBodiesMap[entry.key];
+ List<LibraryBuilder> builders = rebuildBodiesMap[entry.key]!;
replacementMap[entry.key] = childReplacementMap;
replacementSettersMap[entry.key] = childReplacementSettersMap;
for (LibraryBuilder builder in builders) {
@@ -665,7 +671,7 @@
/// references from the original [Library] for things to work.
Map<LibraryBuilder, List<LibraryBuilder>>
experimentalInvalidationCreateRebuildBodiesBuilders(
- ExperimentalInvalidation experimentalInvalidation,
+ ExperimentalInvalidation? experimentalInvalidation,
UriTranslator uriTranslator) {
// Any builder(s) in [rebuildBodies] should be semi-reused: Create source
// builders based on the underlying libraries.
@@ -674,8 +680,8 @@
new Map<LibraryBuilder, List<LibraryBuilder>>.identity();
if (experimentalInvalidation != null) {
for (LibraryBuilder library in experimentalInvalidation.rebuildBodies) {
- LibraryBuilder newBuilder = userCode.loader.read(library.importUri, -1,
- accessor: userCode.loader.first,
+ LibraryBuilder newBuilder = userCode!.loader.read(library.importUri, -1,
+ accessor: userCode!.loader.first,
fileUri: library.fileUri,
referencesFrom: library.library);
List<LibraryBuilder> builders = [newBuilder];
@@ -686,9 +692,9 @@
// over written as the library for parts are temporary "fake"
// libraries.
Uri partUri = getPartUri(library.importUri, part);
- Uri fileUri =
+ Uri? fileUri =
getPartFileUri(library.library.fileUri, part, uriTranslator);
- LibraryBuilder newPartBuilder = userCode.loader.read(partUri, -1,
+ LibraryBuilder newPartBuilder = userCode!.loader.read(partUri, -1,
accessor: library,
fileUri: fileUri,
referencesFrom: library.library,
@@ -704,7 +710,7 @@
/// the libraries we're not recompiling but should have recompiled if we
/// didn't do anything special.
void experimentalInvalidationPatchUpScopes(
- ExperimentalInvalidation experimentalInvalidation,
+ ExperimentalInvalidation? experimentalInvalidation,
Map<LibraryBuilder, List<LibraryBuilder>> rebuildBodiesMap) {
if (experimentalInvalidation != null) {
// Maps from old library builder to map of new content.
@@ -722,19 +728,19 @@
builder.clearExtensionsInScopeCache();
for (Import import in builder.imports) {
assert(import.importer == builder);
- List<LibraryBuilder> replacements =
+ List<LibraryBuilder>? replacements =
rebuildBodiesMap[import.imported];
if (replacements != null) {
import.imported = replacements.first;
}
if (import.prefixBuilder?.exportScope != null) {
- Scope scope = import.prefixBuilder?.exportScope;
+ Scope scope = import.prefixBuilder!.exportScope;
scope.patchUpScope(replacementMap, replacementSettersMap);
}
}
for (Export export in builder.exports) {
assert(export.exporter == builder);
- List<LibraryBuilder> replacements =
+ List<LibraryBuilder>? replacements =
rebuildBodiesMap[export.exported];
if (replacements != null) {
@@ -750,20 +756,20 @@
while (iterator.moveNext()) {
Builder childBuilder = iterator.current;
if (childBuilder is SourceClassBuilder) {
- TypeBuilder typeBuilder = childBuilder.supertypeBuilder;
+ TypeBuilder? typeBuilder = childBuilder.supertypeBuilder;
replaceTypeBuilder(
replacementMap, replacementSettersMap, typeBuilder);
typeBuilder = childBuilder.mixedInTypeBuilder;
replaceTypeBuilder(
replacementMap, replacementSettersMap, typeBuilder);
if (childBuilder.onTypes != null) {
- for (typeBuilder in childBuilder.onTypes) {
+ for (typeBuilder in childBuilder.onTypes!) {
replaceTypeBuilder(
replacementMap, replacementSettersMap, typeBuilder);
}
}
if (childBuilder.interfaceBuilders != null) {
- for (typeBuilder in childBuilder.interfaceBuilders) {
+ for (typeBuilder in childBuilder.interfaceBuilders!) {
replaceTypeBuilder(
replacementMap, replacementSettersMap, typeBuilder);
}
@@ -798,9 +804,9 @@
void setupNewUserCode(
CompilerContext c,
UriTranslator uriTranslator,
- ClassHierarchy hierarchy,
+ ClassHierarchy? hierarchy,
List<LibraryBuilder> reusedLibraries,
- ExperimentalInvalidation experimentalInvalidation,
+ ExperimentalInvalidation? experimentalInvalidation,
Uri firstEntryPoint) {
userCode = createIncrementalKernelTarget(
new HybridFileSystem(
@@ -808,19 +814,19 @@
new Uri(scheme: "org-dartlang-debug", path: "/")),
c.fileSystem),
false,
- dillLoadedData,
+ dillLoadedData!,
uriTranslator);
- userCode.loader.hierarchy = hierarchy;
- dillLoadedData.loader.currentSourceLoader = userCode.loader;
+ userCode!.loader.hierarchy = hierarchy;
+ dillLoadedData!.loader.currentSourceLoader = userCode!.loader;
// Re-use the libraries we've deemed re-usable.
List<bool> seenModes = [false, false, false, false];
for (LibraryBuilder library in reusedLibraries) {
seenModes[library.library.nonNullableByDefaultCompiledMode.index] = true;
- userCode.loader.builders[library.importUri] = library;
+ userCode!.loader.builders[library.importUri] = library;
if (library.importUri.scheme == "dart" &&
library.importUri.path == "core") {
- userCode.loader.coreLibrary = library;
+ userCode!.loader.coreLibrary = library;
}
}
// Check compilation mode up against what we've seen here and set
@@ -831,14 +837,14 @@
// Don't expect strong or invalid.
if (seenModes[NonNullableByDefaultCompiledMode.Strong.index] ||
seenModes[NonNullableByDefaultCompiledMode.Invalid.index]) {
- userCode.loader.hasInvalidNnbdModeLibrary = true;
+ userCode!.loader.hasInvalidNnbdModeLibrary = true;
}
break;
case NnbdMode.Strong:
// Don't expect weak or invalid.
if (seenModes[NonNullableByDefaultCompiledMode.Weak.index] ||
seenModes[NonNullableByDefaultCompiledMode.Invalid.index]) {
- userCode.loader.hasInvalidNnbdModeLibrary = true;
+ userCode!.loader.hasInvalidNnbdModeLibrary = true;
}
break;
case NnbdMode.Agnostic:
@@ -846,7 +852,7 @@
if (seenModes[NonNullableByDefaultCompiledMode.Strong.index] ||
seenModes[NonNullableByDefaultCompiledMode.Weak.index] ||
seenModes[NonNullableByDefaultCompiledMode.Invalid.index]) {
- userCode.loader.hasInvalidNnbdModeLibrary = true;
+ userCode!.loader.hasInvalidNnbdModeLibrary = true;
}
break;
}
@@ -854,7 +860,7 @@
// Don't expect strong or invalid.
if (seenModes[NonNullableByDefaultCompiledMode.Strong.index] ||
seenModes[NonNullableByDefaultCompiledMode.Invalid.index]) {
- userCode.loader.hasInvalidNnbdModeLibrary = true;
+ userCode!.loader.hasInvalidNnbdModeLibrary = true;
}
}
@@ -862,13 +868,13 @@
// correctly. If the first one is in the rebuildBodies, we have to add it
// from there first.
Uri firstEntryPointImportUri =
- userCode.getEntryPointUri(firstEntryPoint, issueProblem: false);
+ userCode!.getEntryPointUri(firstEntryPoint, issueProblem: false);
bool wasFirstSet = false;
if (experimentalInvalidation != null) {
for (LibraryBuilder library in experimentalInvalidation.rebuildBodies) {
if (library.importUri == firstEntryPointImportUri) {
- userCode.loader.read(library.importUri, -1,
- accessor: userCode.loader.first,
+ userCode!.loader.read(library.importUri, -1,
+ accessor: userCode!.loader.first,
fileUri: library.fileUri,
referencesFrom: library.library);
wasFirstSet = true;
@@ -877,26 +883,26 @@
}
}
if (!wasFirstSet) {
- userCode.loader.read(firstEntryPointImportUri, -1,
- accessor: userCode.loader.first,
+ userCode!.loader.read(firstEntryPointImportUri, -1,
+ accessor: userCode!.loader.first,
fileUri: firstEntryPointImportUri != firstEntryPoint
? firstEntryPoint
: null);
}
- if (userCode.loader.first == null &&
- userCode.loader.builders[firstEntryPointImportUri] != null) {
- userCode.loader.first =
- userCode.loader.builders[firstEntryPointImportUri];
+ if (userCode!.loader.first == null &&
+ userCode!.loader.builders[firstEntryPointImportUri] != null) {
+ userCode!.loader.first =
+ userCode!.loader.builders[firstEntryPointImportUri];
}
}
/// When tracking used libraries we mark them when we use them. To track
/// correctly we have to unmark before the next iteration to not have too much
/// marked and therefore incorrectly marked something as used when it is not.
- void resetTrackingOfUsedLibraries(ClassHierarchy hierarchy) {
+ void resetTrackingOfUsedLibraries(ClassHierarchy? hierarchy) {
if (trackNeededDillLibraries) {
// Reset dill loaders and kernel class hierarchy.
- for (LibraryBuilder builder in dillLoadedData.loader.builders.values) {
+ for (LibraryBuilder builder in dillLoadedData!.loader.builders.values) {
if (builder is DillLibraryBuilder) {
if (builder.isBuiltAndMarked) {
// Clear cached calculations in classes which upon calculation can
@@ -921,8 +927,8 @@
/// invalidating (or would normally have invalidated if we hadn't done any
/// experimental invalidation).
void cleanupHierarchy(
- ClassHierarchy hierarchy,
- ExperimentalInvalidation experimentalInvalidation,
+ ClassHierarchy? hierarchy,
+ ExperimentalInvalidation? experimentalInvalidation,
ReusageResult reusedResult) {
if (hierarchy != null) {
List<Library> removedLibraries = <Library>[];
@@ -951,19 +957,18 @@
if (hasToCheckPackageUris) {
// The package file was changed.
// Make sure the dill loader is on the same page.
- DillTarget oldDillLoadedData = dillLoadedData;
+ DillTarget oldDillLoadedData = dillLoadedData!;
dillLoadedData = new DillTarget(ticker, uriTranslator, c.options.target);
- for (DillLibraryBuilder library
- in oldDillLoadedData.loader.builders.values) {
- library.loader = dillLoadedData.loader;
- dillLoadedData.loader.builders[library.importUri] = library;
+ for (LibraryBuilder library in oldDillLoadedData.loader.builders.values) {
+ (library as DillLibraryBuilder).loader = dillLoadedData!.loader;
+ dillLoadedData!.loader.builders[library.importUri] = library;
if (library.importUri.scheme == "dart" &&
library.importUri.path == "core") {
- dillLoadedData.loader.coreLibrary = library;
+ dillLoadedData!.loader.coreLibrary = library;
}
}
- dillLoadedData.loader.first = oldDillLoadedData.loader.first;
- dillLoadedData.loader.libraries
+ dillLoadedData!.loader.first = oldDillLoadedData.loader.first;
+ dillLoadedData!.loader.libraries
.addAll(oldDillLoadedData.loader.libraries);
}
}
@@ -983,8 +988,8 @@
CompilerContext.current.uriToSource);
incrementalSerializer?.invalidate(builder.fileUri);
- LibraryBuilder dillBuilder =
- dillLoadedData.loader.builders.remove(builder.importUri);
+ LibraryBuilder? dillBuilder =
+ dillLoadedData!.loader.builders.remove(builder.importUri);
if (dillBuilder != null) {
removedDillBuilders = true;
userBuilders?.remove(builder.importUri);
@@ -1005,7 +1010,7 @@
bool _importsFfi() {
if (userBuilders == null) return false;
final Uri dartFfiUri = Uri.parse("dart:ffi");
- for (LibraryBuilder builder in userBuilders.values) {
+ for (LibraryBuilder builder in userBuilders!.values) {
Library lib = builder.library;
for (LibraryDependency dependency in lib.dependencies) {
if (dependency.targetLibrary.importUri == dartFfiUri) {
@@ -1019,11 +1024,11 @@
/// Figure out if we can (and was asked to) do experimental invalidation.
/// Note that this returns (future or) [null] if we're not doing experimental
/// invalidation.
- Future<ExperimentalInvalidation> initializeExperimentalInvalidation(
+ Future<ExperimentalInvalidation?> initializeExperimentalInvalidation(
ReusageResult reusedResult, CompilerContext c) async {
- Set<LibraryBuilder> rebuildBodies;
+ Set<LibraryBuilder>? rebuildBodies;
Set<LibraryBuilder> originalNotReusedLibraries;
- Set<Uri> missingSources;
+ Set<Uri>? missingSources;
if (!context.options.isExperimentEnabledGlobally(
ExperimentalFlag.alternativeInvalidationStrategy)) return null;
@@ -1035,7 +1040,7 @@
// rebuild the bodies.
for (LibraryBuilder builder in reusedResult.directlyInvalidated) {
if (builder.library.problemsAsJson != null) {
- assert(builder.library.problemsAsJson.isNotEmpty);
+ assert(builder.library.problemsAsJson!.isNotEmpty);
return null;
}
Iterator<Builder> iterator = builder.iterator;
@@ -1046,8 +1051,9 @@
}
}
- List<int> previousSource =
- CompilerContext.current.uriToSource[builder.fileUri].source;
+ List<int>? previousSource =
+ CompilerContext.current.uriToSource[builder.fileUri]!.source;
+ // ignore: unnecessary_null_comparison
if (previousSource == null || previousSource.isEmpty) {
return null;
}
@@ -1060,12 +1066,12 @@
/* this is effectively what the constant evaluator does */
context.options
.isExperimentEnabledGlobally(ExperimentalFlag.tripleShift));
- String before = textualOutline(previousSource, scannerConfiguration,
+ String? before = textualOutline(previousSource, scannerConfiguration,
performModelling: true);
if (before == null) {
return null;
}
- String now;
+ String? now;
FileSystemEntity entity =
c.options.fileSystem.entityForUri(builder.fileUri);
if (await entity.exists()) {
@@ -1080,7 +1086,7 @@
CompilerContext.current.uriToSource.remove(builder.fileUri);
missingSources ??= new Set<Uri>();
missingSources.add(builder.fileUri);
- LibraryBuilder partOfLibrary = builder.partOfLibrary;
+ LibraryBuilder? partOfLibrary = builder.partOfLibrary;
rebuildBodies ??= new Set<LibraryBuilder>();
if (partOfLibrary != null) {
rebuildBodies.add(partOfLibrary);
@@ -1094,7 +1100,7 @@
// we can't only recompile the changed file.
// TODO(jensj): Check for mixins in a smarter and faster way.
for (LibraryBuilder builder in reusedResult.notReusedLibraries) {
- if (missingSources.contains(builder.fileUri)) {
+ if (missingSources!.contains(builder.fileUri)) {
continue;
}
Library lib = builder.library;
@@ -1124,7 +1130,7 @@
// Alternatively (https://github.com/dart-lang/sdk/issues/45899) we might
// do something else entirely that doesn't require special handling.
if (_importsFfi()) {
- for (LibraryBuilder builder in rebuildBodies) {
+ for (LibraryBuilder builder in rebuildBodies!) {
Library lib = builder.library;
for (LibraryDependency dependency in lib.dependencies) {
Library importLibrary = dependency.targetLibrary;
@@ -1133,7 +1139,7 @@
return null;
}
for (Reference exportReference in importLibrary.additionalExports) {
- NamedNode export = exportReference.node;
+ NamedNode? export = exportReference.node;
if (export is Class) {
Class c = export;
if (c.enclosingLibrary.importUri == dartFfiUri) {
@@ -1151,16 +1157,16 @@
for (LibraryBuilder builder in reusedResult.notReusedLibraries) {
if (builder.isPart) continue;
if (builder.isPatch) continue;
- if (rebuildBodies.contains(builder)) continue;
+ if (rebuildBodies!.contains(builder)) continue;
if (!seenUris.add(builder.importUri)) continue;
reusedResult.reusedLibraries.add(builder);
originalNotReusedLibraries.add(builder);
}
reusedResult.notReusedLibraries.clear();
- reusedResult.notReusedLibraries.addAll(rebuildBodies);
+ reusedResult.notReusedLibraries.addAll(rebuildBodies!);
return new ExperimentalInvalidation(
- rebuildBodies, originalNotReusedLibraries, missingSources);
+ rebuildBodies, originalNotReusedLibraries, missingSources!);
}
/// Get UriTranslator, and figure out if the packages file was (potentially)
@@ -1208,7 +1214,7 @@
initializeFromComponent(uriTranslator, c, data);
componentToInitializeFrom = null;
} else {
- List<int> summaryBytes = await c.options.loadSdkSummaryBytes();
+ List<int>? summaryBytes = await c.options.loadSdkSummaryBytes();
bytesLength = prepareSummary(summaryBytes, uriTranslator, c, data);
if (initializeFromDillUri != null) {
try {
@@ -1225,10 +1231,10 @@
e is CompilationModeError) {
// Don't report any warning.
} else {
- Uri gzInitializedFrom;
+ Uri? gzInitializedFrom;
if (c.options.writeFileOnCrashReport) {
gzInitializedFrom = saveAsGzip(
- data.initializationBytes, "initialize_from.dill");
+ data.initializationBytes!, "initialize_from.dill");
recordTemporaryFileForTesting(gzInitializedFrom);
}
if (e is CanonicalNameError) {
@@ -1237,7 +1243,7 @@
initializeFromDillUri.toString(), gzInitializedFrom)
: templateInitializeFromDillNotSelfContainedNoDump
.withArguments(initializeFromDillUri.toString());
- dillLoadedData.loader
+ dillLoadedData!.loader
.addProblem(message, TreeNode.noOffset, 1, null);
} else {
// Unknown error: Report problem as such.
@@ -1250,7 +1256,7 @@
: templateInitializeFromDillUnknownProblemNoDump
.withArguments(
initializeFromDillUri.toString(), "$e", "$st");
- dillLoadedData.loader
+ dillLoadedData!.loader
.addProblem(message, TreeNode.noOffset, 1, null);
}
}
@@ -1261,17 +1267,17 @@
// We suppress finalization errors because they will reported via
// problemsAsJson fields (with better precision).
- await dillLoadedData.buildOutlines(suppressFinalizationErrors: true);
+ await dillLoadedData!.buildOutlines(suppressFinalizationErrors: true);
userBuilders = <Uri, LibraryBuilder>{};
platformBuilders = <LibraryBuilder>[];
- dillLoadedData.loader.builders.forEach((uri, builder) {
+ dillLoadedData!.loader.builders.forEach((uri, builder) {
if (builder.importUri.scheme == "dart") {
- platformBuilders.add(builder);
+ platformBuilders!.add(builder);
} else {
- userBuilders[uri] = builder;
+ userBuilders![uri] = builder;
}
});
- if (userBuilders.isEmpty) userBuilders = null;
+ if (userBuilders!.isEmpty) userBuilders = null;
}
data.initializationBytes = null;
return data;
@@ -1280,28 +1286,29 @@
void replaceTypeBuilder(
Map<LibraryBuilder, Map<String, Builder>> replacementMap,
Map<LibraryBuilder, Map<String, Builder>> replacementSettersMap,
- TypeBuilder typeBuilder) {
- TypeDeclarationBuilder declaration = typeBuilder?.declaration;
- Builder parent = declaration?.parent;
+ TypeBuilder? typeBuilder) {
+ TypeDeclarationBuilder? declaration = typeBuilder?.declaration;
+ Builder? parent = declaration?.parent;
if (parent == null) return;
- Map<String, Builder> childReplacementMap;
- if (declaration.isSetter) {
+ Map<String, Builder>? childReplacementMap;
+ if (declaration!.isSetter) {
childReplacementMap = replacementSettersMap[parent];
} else {
childReplacementMap = replacementMap[parent];
}
if (childReplacementMap == null) return;
- Builder replacement = childReplacementMap[declaration.name];
+ Builder replacement = childReplacementMap[declaration.name]!;
+ // ignore: unnecessary_null_comparison
assert(replacement != null, "Didn't find the replacement for $typeBuilder");
- typeBuilder.bind(replacement);
+ typeBuilder!.bind(replacement as TypeDeclarationBuilder);
}
@override
- CoreTypes getCoreTypes() => userCode?.loader?.coreTypes;
+ CoreTypes? getCoreTypes() => userCode?.loader.coreTypes;
@override
- ClassHierarchy getClassHierarchy() => userCode?.loader?.hierarchy;
+ ClassHierarchy? getClassHierarchy() => userCode?.loader.hierarchy;
/// Allows for updating the list of needed libraries.
///
@@ -1315,7 +1322,7 @@
/// (though handling of the case where all bets are off should probably still
/// live locally).
void updateNeededDillLibrariesWithHierarchy(
- ClassHierarchy hierarchy, ClassHierarchyBuilder builderHierarchy) {
+ ClassHierarchy hierarchy, ClassHierarchyBuilder? builderHierarchy) {
if (hierarchy is ClosedWorldClassHierarchy && !hierarchy.allBetsOff) {
neededDillLibraries ??= new Set<Library>();
Set<Class> classes = new Set<Class>();
@@ -1341,13 +1348,13 @@
}
}
if (c.mixedInType != null) {
- if (classes.add(c.mixedInType.classNode)) {
- worklist.add(c.mixedInType.classNode);
+ if (classes.add(c.mixedInType!.classNode)) {
+ worklist.add(c.mixedInType!.classNode);
}
}
if (c.supertype != null) {
- if (classes.add(c.supertype.classNode)) {
- worklist.add(c.supertype.classNode);
+ if (classes.add(c.supertype!.classNode)) {
+ worklist.add(c.supertype!.classNode);
}
}
}
@@ -1358,10 +1365,10 @@
Library library = c.enclosingLibrary;
// Only add if loaded from a dill file (and wasn't a 'dill' that was
// converted from source builders to dill builders).
- if (dillLoadedData.loader.builders.containsKey(library.importUri) &&
+ if (dillLoadedData!.loader.builders.containsKey(library.importUri) &&
(previousSourceBuilders == null ||
- !previousSourceBuilders.contains(library))) {
- neededDillLibraries.add(library);
+ !previousSourceBuilders!.contains(library))) {
+ neededDillLibraries!.add(library);
}
}
} else {
@@ -1369,24 +1376,24 @@
// if all bets are off: Add everything (except for the libraries we just
// converted from source builders to dill builders).
neededDillLibraries = new Set<Library>();
- for (LibraryBuilder builder in dillLoadedData.loader.builders.values) {
+ for (LibraryBuilder builder in dillLoadedData!.loader.builders.values) {
if (builder is DillLibraryBuilder &&
(previousSourceBuilders == null ||
- !previousSourceBuilders.contains(builder.library))) {
- neededDillLibraries.add(builder.library);
+ !previousSourceBuilders!.contains(builder.library))) {
+ neededDillLibraries!.add(builder.library);
}
}
}
}
/// Internal method.
- void invalidateNotKeptUserBuilders(Set<Uri> invalidatedUris) {
+ void invalidateNotKeptUserBuilders(Set<Uri?> invalidatedUris) {
if (modulesToLoad != null && userBuilders != null) {
Set<Library> loadedNotKept = new Set<Library>();
- for (LibraryBuilder builder in userBuilders.values) {
+ for (LibraryBuilder builder in userBuilders!.values) {
loadedNotKept.add(builder.library);
}
- for (Component module in modulesToLoad) {
+ for (Component module in modulesToLoad!) {
loadedNotKept.removeAll(module.libraries);
}
for (Library lib in loadedNotKept) {
@@ -1400,35 +1407,35 @@
List<LibraryBuilder> reusedLibraries) async {
if (modulesToLoad != null) {
bool loadedAnything = false;
- for (Component module in modulesToLoad) {
+ for (Component module in modulesToLoad!) {
bool usedComponent = false;
for (Library lib in module.libraries) {
- if (!dillLoadedData.loader.builders.containsKey(lib.importUri)) {
- dillLoadedData.loader.libraries.add(lib);
- dillLoadedData.addLibrary(lib);
- reusedLibraries.add(dillLoadedData.loader.read(lib.importUri, -1));
+ if (!dillLoadedData!.loader.builders.containsKey(lib.importUri)) {
+ dillLoadedData!.loader.libraries.add(lib);
+ dillLoadedData!.addLibrary(lib);
+ reusedLibraries.add(dillLoadedData!.loader.read(lib.importUri, -1));
usedComponent = true;
}
}
if (usedComponent) {
- dillLoadedData.uriToSource.addAll(module.uriToSource);
+ dillLoadedData!.uriToSource.addAll(module.uriToSource);
loadedAnything = true;
}
}
if (loadedAnything) {
// We suppress finalization errors because they will reported via
// problemsAsJson fields (with better precision).
- await dillLoadedData.buildOutlines(suppressFinalizationErrors: true);
+ await dillLoadedData!.buildOutlines(suppressFinalizationErrors: true);
userBuilders = <Uri, LibraryBuilder>{};
platformBuilders = <LibraryBuilder>[];
- dillLoadedData.loader.builders.forEach((uri, builder) {
+ dillLoadedData!.loader.builders.forEach((uri, builder) {
if (builder.importUri.scheme == "dart") {
- platformBuilders.add(builder);
+ platformBuilders!.add(builder);
} else {
- userBuilders[uri] = builder;
+ userBuilders![uri] = builder;
}
});
- if (userBuilders.isEmpty) {
+ if (userBuilders!.isEmpty) {
userBuilders = null;
}
}
@@ -1436,7 +1443,7 @@
}
}
- bool dontReissueLibraryProblemsFor(Uri uri) {
+ bool dontReissueLibraryProblemsFor(Uri? uri) {
return uri == debugExprUri;
}
@@ -1449,7 +1456,7 @@
allLibraries.removeAll(compiledLibraries);
for (Library library in allLibraries) {
if (library.problemsAsJson?.isNotEmpty == true) {
- for (String jsonString in library.problemsAsJson) {
+ for (String jsonString in library.problemsAsJson!) {
DiagnosticMessageFromJson message =
new DiagnosticMessageFromJson.fromJson(jsonString);
if (dontReissueLibraryProblemsFor(message.uri)) {
@@ -1466,12 +1473,12 @@
List<String> reissueComponentProblems(Component componentWithDill) {
// These problems have already been reported.
Set<String> issuedProblems = new Set<String>();
- if (componentWithDill?.problemsAsJson != null) {
- issuedProblems.addAll(componentWithDill.problemsAsJson);
+ if (componentWithDill.problemsAsJson != null) {
+ issuedProblems.addAll(componentWithDill.problemsAsJson!);
}
// Report old problems that wasn't reported again.
- Set<Uri> strongModeNNBDPackageOptOutUris;
+ Set<Uri>? strongModeNNBDPackageOptOutUris;
for (MapEntry<Uri, List<DiagnosticMessageFromJson>> entry
in remainingComponentProblems.entries) {
List<DiagnosticMessageFromJson> messages = entry.value;
@@ -1494,7 +1501,7 @@
// `SourceLoader.giveCombinedErrorForNonStrongLibraries` on them to issue
// a new error.
Set<LibraryBuilder> builders = {};
- SourceLoader loader = userCode.loader;
+ SourceLoader loader = userCode!.loader;
for (LibraryBuilder builder in loader.builders.values) {
if (strongModeNNBDPackageOptOutUris.contains(builder.fileUri)) {
builders.add(builder);
@@ -1502,20 +1509,20 @@
}
FormattedMessage message = loader.giveCombinedErrorForNonStrongLibraries(
builders,
- emitNonPackageErrors: false);
+ emitNonPackageErrors: false)!;
issuedProblems.add(message.toJsonString());
// The problem was issued by the call so don't re-issue it here.
}
// Save any new component-problems.
- _addProblemsAsJsonToRemainingProblems(componentWithDill?.problemsAsJson);
+ _addProblemsAsJsonToRemainingProblems(componentWithDill.problemsAsJson);
return new List<String>.from(issuedProblems);
}
/// Internal method.
- Uri getPartFileUri(
+ Uri? getPartFileUri(
Uri parentFileUri, LibraryPart part, UriTranslator uriTranslator) {
- Uri fileUri = getPartUri(parentFileUri, part);
+ Uri? fileUri = getPartUri(parentFileUri, part);
if (fileUri.scheme == "package") {
// Part was specified via package URI and the resolve above thus
// did not go as expected. Translate the package URI to get the
@@ -1537,7 +1544,7 @@
ClassHierarchy hierarchy,
UriTranslator uriTranslator,
Map<Uri, Source> uriToSource,
- [List<Library> inputLibrariesFiltered]) {
+ [List<Library>? inputLibrariesFiltered]) {
List<Library> result = <Library>[];
Map<Uri, Uri> partUriToLibraryImportUri = <Uri, Uri>{};
Map<Uri, Library> libraryMap = <Uri, Library>{};
@@ -1576,7 +1583,7 @@
worklist.add(entry);
} else {
// If the entry is a part redirect to the "main" entry.
- Uri partTranslation = partUriToLibraryImportUri[entry];
+ Uri? partTranslation = partUriToLibraryImportUri[entry];
if (partTranslation != null) {
worklist.add(partTranslation);
}
@@ -1584,7 +1591,7 @@
}
LibraryGraph graph = new LibraryGraph(libraryMap);
- Set<Uri> partsUsed = new Set<Uri>();
+ Set<Uri?> partsUsed = new Set<Uri?>();
while (worklist.isNotEmpty && potentiallyReferencedLibraries.isNotEmpty) {
Uri uri = worklist.removeLast();
if (libraryMap.containsKey(uri)) {
@@ -1592,14 +1599,14 @@
worklist.add(neighbor);
}
libraryMap.remove(uri);
- Library library = potentiallyReferencedLibraries.remove(uri);
+ Library? library = potentiallyReferencedLibraries.remove(uri);
if (library != null) {
result.add(library);
if (potentiallyReferencedInputLibraries.remove(uri) != null) {
inputLibrariesFiltered?.add(library);
}
for (LibraryPart part in library.parts) {
- Uri partFileUri =
+ Uri? partFileUri =
getPartFileUri(library.fileUri, part, uriTranslator);
partsUsed.add(partFileUri);
}
@@ -1611,11 +1618,11 @@
bool removedDillBuilders = false;
for (Uri uri in potentiallyReferencedLibraries.keys) {
if (uri.scheme == "package") continue;
- LibraryBuilder builder = userCode.loader.builders.remove(uri);
+ LibraryBuilder? builder = userCode!.loader.builders.remove(uri);
if (builder != null) {
Library lib = builder.library;
removedLibraries.add(lib);
- if (dillLoadedData.loader.builders.remove(uri) != null) {
+ if (dillLoadedData!.loader.builders.remove(uri) != null) {
removedDillBuilders = true;
}
cleanupSourcesForBuilder(null, builder, uriTranslator,
@@ -1628,7 +1635,7 @@
incrementalSerializer?.invalidate(builder.fileUri);
}
}
- hierarchy?.applyTreeChanges(removedLibraries, const [], const []);
+ hierarchy.applyTreeChanges(removedLibraries, const [], const []);
if (removedDillBuilders) {
makeDillLoaderLibrariesUpToDateWithBuildersMap();
}
@@ -1642,9 +1649,9 @@
/// in the compilation process.
/// This method syncs the [libraries] list with the data in [builders].
void makeDillLoaderLibrariesUpToDateWithBuildersMap() {
- dillLoadedData.loader.libraries.clear();
- for (LibraryBuilder builder in dillLoadedData.loader.builders.values) {
- dillLoadedData.loader.libraries.add(builder.library);
+ dillLoadedData!.loader.libraries.clear();
+ for (LibraryBuilder builder in dillLoadedData!.loader.builders.values) {
+ dillLoadedData!.loader.libraries.add(builder.library);
}
}
@@ -1654,25 +1661,25 @@
/// Those parts will not be cleaned up. This is useful when a part has been
/// "moved" to be part of another library.
void cleanupSourcesForBuilder(
- ReusageResult reusedResult,
+ ReusageResult? reusedResult,
LibraryBuilder builder,
UriTranslator uriTranslator,
Map<Uri, Source> uriToSource,
- [Map<Uri, Source> uriToSourceExtra,
- Set<Uri> partsUsed]) {
+ [Map<Uri, Source>? uriToSourceExtra,
+ Set<Uri?>? partsUsed]) {
uriToSource.remove(builder.fileUri);
uriToSourceExtra?.remove(builder.fileUri);
Library lib = builder.library;
for (LibraryPart part in lib.parts) {
- Uri partFileUri = getPartFileUri(lib.fileUri, part, uriTranslator);
+ Uri? partFileUri = getPartFileUri(lib.fileUri, part, uriTranslator);
if (partsUsed != null && partsUsed.contains(partFileUri)) continue;
// If the builders map contain the "parts" import uri, it's a real library
// (erroneously) used as a part so we don't want to remove that.
if (userCode?.loader != null) {
- Uri partImportUri = uriToSource[partFileUri]?.importUri;
+ Uri? partImportUri = uriToSource[partFileUri]?.importUri;
if (partImportUri != null &&
- userCode.loader.builders.containsKey(partImportUri)) {
+ userCode!.loader.builders.containsKey(partImportUri)) {
continue;
}
} else if (reusedResult != null) {
@@ -1702,17 +1709,17 @@
/// This is useful when a part has been "moved" to be part of another library.
void removeLibraryFromRemainingComponentProblems(
Library lib, UriTranslator uriTranslator,
- [Set<Uri> partsUsed]) {
+ [Set<Uri?>? partsUsed]) {
remainingComponentProblems.remove(lib.fileUri);
// Remove parts too.
for (LibraryPart part in lib.parts) {
- Uri partFileUri = getPartFileUri(lib.fileUri, part, uriTranslator);
+ Uri? partFileUri = getPartFileUri(lib.fileUri, part, uriTranslator);
remainingComponentProblems.remove(partFileUri);
}
}
/// Internal method.
- int prepareSummary(List<int> summaryBytes, UriTranslator uriTranslator,
+ int prepareSummary(List<int>? summaryBytes, UriTranslator uriTranslator,
CompilerContext c, IncrementalCompilerData data) {
dillLoadedData = new DillTarget(ticker, uriTranslator, c.options.target);
int bytesLength = 0;
@@ -1722,7 +1729,7 @@
ticker.logMs("Read ${c.options.sdkSummary}");
new BinaryBuilderWithMetadata(summaryBytes,
disableLazyReading: false, disableLazyClassReading: true)
- .readComponent(data.component);
+ .readComponent(data.component!);
ticker.logMs("Deserialized ${c.options.sdkSummary}");
bytesLength += summaryBytes.length;
}
@@ -1736,9 +1743,10 @@
IncrementalCompilerData data) async {
int bytesLength = 0;
FileSystemEntity entity =
- c.options.fileSystem.entityForUri(initializeFromDillUri);
+ c.options.fileSystem.entityForUri(initializeFromDillUri!);
if (await entity.exists()) {
List<int> initializationBytes = await entity.readAsBytes();
+ // ignore: unnecessary_null_comparison
if (initializationBytes != null && initializationBytes.isNotEmpty) {
ticker.logMs("Read $initializeFromDillUri");
data.initializationBytes = initializationBytes;
@@ -1748,8 +1756,8 @@
List<SubComponentView> views = new BinaryBuilderWithMetadata(
initializationBytes,
disableLazyReading: true)
- .readComponent(data.component,
- checkCanonicalNames: true, createView: true);
+ .readComponent(data.component!,
+ checkCanonicalNames: true, createView: true)!;
// Compute "output nnbd mode".
NonNullableByDefaultCompiledMode compiledMode;
@@ -1773,7 +1781,7 @@
// Check the any package-urls still point to the same file
// (e.g. the package still exists and hasn't been updated).
// Also verify NNBD settings.
- for (Library lib in data.component.libraries) {
+ for (Library lib in data.component!.libraries) {
if (lib.importUri.scheme == "package" &&
uriTranslator.translate(lib.importUri, false) != lib.fileUri) {
// Package has been removed or updated.
@@ -1811,21 +1819,21 @@
/// Internal method.
void saveComponentProblems(IncrementalCompilerData data) {
- List<String> problemsAsJson = data.component.problemsAsJson;
+ List<String>? problemsAsJson = data.component!.problemsAsJson;
_addProblemsAsJsonToRemainingProblems(problemsAsJson);
}
- void _addProblemsAsJsonToRemainingProblems(List<String> problemsAsJson) {
+ void _addProblemsAsJsonToRemainingProblems(List<String>? problemsAsJson) {
if (problemsAsJson != null) {
for (String jsonString in problemsAsJson) {
DiagnosticMessageFromJson message =
new DiagnosticMessageFromJson.fromJson(jsonString);
assert(message.uri != null ||
(message.involvedFiles != null &&
- message.involvedFiles.isNotEmpty));
+ message.involvedFiles!.isNotEmpty));
if (message.uri != null) {
List<DiagnosticMessageFromJson> messages =
- remainingComponentProblems[message.uri] ??=
+ remainingComponentProblems[message.uri!] ??=
<DiagnosticMessageFromJson>[];
messages.add(message);
}
@@ -1834,7 +1842,7 @@
// be issued as long as it's a problem. It will because of
// deduplication when we re-issue these (in reissueComponentProblems)
// only be reported once.
- for (Uri uri in message.involvedFiles) {
+ for (Uri uri in message.involvedFiles!) {
List<DiagnosticMessageFromJson> messages =
remainingComponentProblems[uri] ??=
<DiagnosticMessageFromJson>[];
@@ -1853,15 +1861,15 @@
dillLoadedData = new DillTarget(ticker, uriTranslator, c.options.target);
data.component = new Component(
- libraries: componentToInitializeFrom.libraries,
- uriToSource: componentToInitializeFrom.uriToSource)
- ..setMainMethodAndMode(componentToInitializeFrom.mainMethod?.reference,
- true, componentToInitializeFrom.mode);
+ libraries: componentToInitializeFrom!.libraries,
+ uriToSource: componentToInitializeFrom!.uriToSource)
+ ..setMainMethodAndMode(componentToInitializeFrom!.mainMethod?.reference,
+ true, componentToInitializeFrom!.mode);
saveComponentProblems(data);
bool foundDartCore = false;
- for (int i = 0; i < data.component.libraries.length; i++) {
- Library library = data.component.libraries[i];
+ for (int i = 0; i < data.component!.libraries.length; i++) {
+ Library library = data.component!.libraries[i];
if (library.importUri.scheme == "dart" &&
library.importUri.path == "core") {
foundDartCore = true;
@@ -1880,40 +1888,41 @@
/// Internal method.
void appendLibraries(IncrementalCompilerData data, int bytesLength) {
if (data.component != null) {
- dillLoadedData.loader
- .appendLibraries(data.component, byteCount: bytesLength);
+ dillLoadedData!.loader
+ .appendLibraries(data.component!, byteCount: bytesLength);
}
ticker.logMs("Appended libraries");
}
@override
- Future<Procedure> compileExpression(
+ Future<Procedure?> compileExpression(
String expression,
Map<String, DartType> definitions,
List<TypeParameter> typeDefinitions,
String syntheticProcedureName,
Uri libraryUri,
- [String className,
+ [String? className,
bool isStatic = false]) async {
assert(dillLoadedData != null && userCode != null);
return await context.runInContext((_) async {
- LibraryBuilder libraryBuilder =
- userCode.loader.read(libraryUri, -1, accessor: userCode.loader.first);
+ LibraryBuilder libraryBuilder = userCode!.loader
+ .read(libraryUri, -1, accessor: userCode!.loader.first);
ticker.logMs("Loaded library $libraryUri");
- Class cls;
+ Class? cls;
if (className != null) {
- ClassBuilder classBuilder = libraryBuilder.scopeBuilder[className];
+ ClassBuilder? classBuilder =
+ libraryBuilder.scopeBuilder[className] as ClassBuilder?;
cls = classBuilder?.cls;
if (cls == null) return null;
}
- userCode.loader.seenMessages.clear();
+ userCode!.loader.seenMessages.clear();
for (TypeParameter typeParam in typeDefinitions) {
- if (!isLegalIdentifier(typeParam.name)) {
- userCode.loader.addProblem(
+ if (!isLegalIdentifier(typeParam.name!)) {
+ userCode!.loader.addProblem(
templateIncrementalCompilerIllegalTypeParameter
.withArguments('$typeParam'),
typeParam.fileOffset,
@@ -1924,7 +1933,7 @@
}
for (String name in definitions.keys) {
if (!isLegalIdentifier(name)) {
- userCode.loader.addProblem(
+ userCode!.loader.addProblem(
templateIncrementalCompilerIllegalParameter.withArguments(name),
// TODO: pass variable declarations instead of
// parameter names for proper location detection.
@@ -1941,7 +1950,7 @@
debugExprUri,
/*packageUri*/ null,
new ImplicitLanguageVersion(libraryBuilder.library.languageVersion),
- userCode.loader,
+ userCode!.loader,
null,
scope: libraryBuilder.scope.createNestedScope("expression"),
nameOrigin: libraryBuilder,
@@ -1953,7 +1962,7 @@
in libraryBuilder.library.dependencies) {
if (!dependency.isImport) continue;
- List<Combinator> combinators;
+ List<Combinator>? combinators;
for (kernel.Combinator combinator in dependency.combinators) {
combinators ??= <Combinator>[];
@@ -1967,7 +1976,7 @@
debugLibrary.addImport(
null,
- dependency.importedLibraryReference.canonicalName.name,
+ dependency.importedLibraryReference.canonicalName!.name,
null,
dependency.name,
combinators,
@@ -1982,7 +1991,7 @@
ticker.logMs("Added imports");
}
- HybridFileSystem hfs = userCode.fileSystem;
+ HybridFileSystem hfs = userCode!.fileSystem as HybridFileSystem;
MemoryFileSystem fs = hfs.memory;
fs.entityForUri(debugExprUri).writeAsStringSync(expression);
@@ -1998,8 +2007,8 @@
cls?.fileOffset ?? libraryBuilder.library.fileOffset)
.toList());
- debugLibrary.build(userCode.loader.coreLibrary, modifyTarget: false);
- Expression compiledExpression = await userCode.loader.buildExpression(
+ debugLibrary.build(userCode!.loader.coreLibrary, modifyTarget: false);
+ Expression compiledExpression = await userCode!.loader.buildExpression(
debugLibrary, className, className != null && !isStatic, parameters);
Procedure procedure = new Procedure(
@@ -2013,21 +2022,21 @@
procedure.fileUri = debugLibrary.fileUri;
procedure.parent = className != null ? cls : libraryBuilder.library;
- userCode.uriToSource.remove(debugExprUri);
- userCode.loader.sourceBytes.remove(debugExprUri);
+ userCode!.uriToSource.remove(debugExprUri);
+ userCode!.loader.sourceBytes.remove(debugExprUri);
// Make sure the library has a canonical name.
Component c = new Component(libraries: [debugLibrary.library]);
c.computeCanonicalNames();
ticker.logMs("Built debug library");
- userCode.runProcedureTransformations(procedure);
+ userCode!.runProcedureTransformations(procedure);
return procedure;
});
}
- bool packagesEqual(Package a, Package b) {
+ bool packagesEqual(Package? a, Package? b) {
if (a == null || b == null) return false;
if (a.name != b.name) return false;
if (a.root != b.root) return false;
@@ -2038,12 +2047,12 @@
}
/// Internal method.
- ReusageResult computeReusedLibraries(Set<Uri> invalidatedUris,
+ ReusageResult computeReusedLibraries(Set<Uri?> invalidatedUris,
UriTranslator uriTranslator, List<Uri> entryPoints) {
Set<Uri> seenUris = new Set<Uri>();
List<LibraryBuilder> reusedLibraries = <LibraryBuilder>[];
- for (int i = 0; i < platformBuilders.length; i++) {
- LibraryBuilder builder = platformBuilders[i];
+ for (int i = 0; i < platformBuilders!.length; i++) {
+ LibraryBuilder builder = platformBuilders![i];
if (!seenUris.add(builder.importUri)) continue;
reusedLibraries.add(builder);
}
@@ -2056,13 +2065,13 @@
// Maps all non-platform LibraryBuilders from their import URI.
Map<Uri, LibraryBuilder> builders = <Uri, LibraryBuilder>{};
- Map<Uri, LibraryBuilder> partUriToParent = <Uri, LibraryBuilder>{};
+ Map<Uri?, LibraryBuilder> partUriToParent = <Uri, LibraryBuilder>{};
// Invalidated URIs translated back to their import URI (package:, dart:,
// etc.).
List<Uri> invalidatedImportUris = <Uri>[];
- bool isInvalidated(Uri importUri, Uri fileUri) {
+ bool isInvalidated(Uri importUri, Uri? fileUri) {
if (invalidatedUris.contains(importUri)) return true;
if (importUri != fileUri && invalidatedUris.contains(fileUri)) {
return true;
@@ -2075,9 +2084,9 @@
int firstSlash = path.indexOf('/');
String packageName = path.substring(0, firstSlash);
if (previousPackagesMap == null ||
- !packagesEqual(previousPackagesMap[packageName],
- currentPackagesMap[packageName])) {
- Uri newFileUri = uriTranslator.translate(importUri, false);
+ !packagesEqual(previousPackagesMap![packageName],
+ currentPackagesMap![packageName])) {
+ Uri? newFileUri = uriTranslator.translate(importUri, false);
if (newFileUri != fileUri) {
invalidatedBecauseOfPackageUpdate = true;
return true;
@@ -2112,7 +2121,7 @@
} else if (libraryBuilder is DillLibraryBuilder) {
for (LibraryPart part in libraryBuilder.library.parts) {
Uri partUri = getPartUri(libraryBuilder.importUri, part);
- Uri fileUri = getPartFileUri(
+ Uri? fileUri = getPartFileUri(
libraryBuilder.library.fileUri, part, uriTranslator);
partUriToParent[partUri] = libraryBuilder;
partUriToParent[fileUri] = libraryBuilder;
@@ -2133,17 +2142,17 @@
if (userCode != null) {
// userCode already contains the builders from userBuilders.
- userCode.loader.builders.forEach(addBuilderAndInvalidateUris);
+ userCode!.loader.builders.forEach(addBuilderAndInvalidateUris);
} else {
// userCode was null so we explicitly have to add the builders from
// userBuilders (which cannot be null as we checked initially that one of
// them was non-null).
- userBuilders.forEach(addBuilderAndInvalidateUris);
+ userBuilders!.forEach(addBuilderAndInvalidateUris);
}
recordInvalidatedImportUrisForTesting(invalidatedImportUris);
for (Uri uri in invalidatedImportUris) {
- directlyInvalidated.add(builders[uri]);
+ directlyInvalidated.add(builders[uri]!);
}
BuilderGraph graph = new BuilderGraph(builders);
@@ -2161,16 +2170,16 @@
List<Uri> workList = invalidatedImportUris;
while (workList.isNotEmpty) {
Uri removed = workList.removeLast();
- LibraryBuilder current = builders.remove(removed);
+ LibraryBuilder? current = builders.remove(removed);
// [current] is null if the corresponding key (URI) has already been
// removed.
if (current != null) {
- Set<Uri> s = directDependencies[current.importUri];
+ Set<Uri>? s = directDependencies[current.importUri];
if (current.importUri != removed) {
if (s == null) {
s = directDependencies[removed];
} else {
- s.addAll(directDependencies[removed]);
+ s.addAll(directDependencies[removed]!);
}
}
if (s != null) {
@@ -2201,7 +2210,7 @@
reusedLibraries);
for (Uri entryPoint in entryPoints) {
- LibraryBuilder parent = partUriToParent[entryPoint];
+ LibraryBuilder? parent = partUriToParent[entryPoint];
if (parent == null) continue;
// TODO(jensj): .contains on a list is O(n).
// It will only be done for each entry point that's a part though, i.e.
@@ -2216,17 +2225,17 @@
}
@override
- void invalidate(Uri uri) {
+ void invalidate(Uri? uri) {
invalidatedUris.add(uri);
}
@override
void invalidateAllSources() {
if (userCode != null) {
- Set<Uri> uris = new Set<Uri>.from(userCode.loader.builders.keys);
- uris.removeAll(dillLoadedData.loader.builders.keys);
+ Set<Uri> uris = new Set<Uri>.from(userCode!.loader.builders.keys);
+ uris.removeAll(dillLoadedData!.loader.builders.keys);
if (previousSourceBuilders != null) {
- for (Library library in previousSourceBuilders) {
+ for (Library library in previousSourceBuilders!) {
uris.add(library.importUri);
}
}
@@ -2326,8 +2335,8 @@
}
class IncrementalCompilerData {
- Component component = null;
- List<int> initializationBytes = null;
+ Component? component = null;
+ List<int>? initializationBytes = null;
}
class ReusageResult {
@@ -2346,9 +2355,13 @@
ReusageResult(this.notReusedLibraries, this.directlyInvalidated,
this.invalidatedBecauseOfPackageUpdate, this.reusedLibraries)
: _reusedLibrariesPartsToParentForEntryPoints = {},
+ // ignore: unnecessary_null_comparison
assert(notReusedLibraries != null),
+ // ignore: unnecessary_null_comparison
assert(directlyInvalidated != null),
+ // ignore: unnecessary_null_comparison
assert(invalidatedBecauseOfPackageUpdate != null),
+ // ignore: unnecessary_null_comparison
assert(reusedLibraries != null);
void registerLibraryUriForPartUsedAsEntryPoint(
@@ -2359,7 +2372,7 @@
bool arePartsUsedAsEntryPoints() =>
_reusedLibrariesPartsToParentForEntryPoints.isNotEmpty;
- Uri getLibraryUriForPartUsedAsEntryPoint(Uri entryPoint) =>
+ Uri? getLibraryUriForPartUsedAsEntryPoint(Uri entryPoint) =>
_reusedLibrariesPartsToParentForEntryPoints[entryPoint];
}
@@ -2370,15 +2383,18 @@
ExperimentalInvalidation(
this.rebuildBodies, this.originalNotReusedLibraries, this.missingSources)
+ // ignore: unnecessary_null_comparison
: assert(rebuildBodies != null),
+ // ignore: unnecessary_null_comparison
assert(originalNotReusedLibraries != null),
+ // ignore: unnecessary_null_comparison
assert(missingSources != null);
}
class IncrementalKernelTarget extends KernelTarget
implements ChangedStructureNotifier {
- Set<Class> classHierarchyChanges;
- Set<Class> classMemberChanges;
+ Set<Class>? classHierarchyChanges;
+ Set<Class>? classMemberChanges;
IncrementalKernelTarget(FileSystem fileSystem, bool includeComments,
DillTarget dillTarget, UriTranslator uriTranslator)
@@ -2389,12 +2405,12 @@
@override
void registerClassMemberChange(Class c) {
classMemberChanges ??= new Set<Class>();
- classMemberChanges.add(c);
+ classMemberChanges!.add(c);
}
@override
void registerClassHierarchyChange(Class cls) {
classHierarchyChanges ??= <Class>{};
- classHierarchyChanges.add(cls);
+ classHierarchyChanges!.add(cls);
}
}
diff --git a/pkg/front_end/lib/src/fasta/library_graph.dart b/pkg/front_end/lib/src/fasta/library_graph.dart
index 5b93e51..bc01000 100644
--- a/pkg/front_end/lib/src/fasta/library_graph.dart
+++ b/pkg/front_end/lib/src/fasta/library_graph.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.library_graph;
import 'package:kernel/kernel.dart'
@@ -21,7 +19,7 @@
Iterable<Uri> get vertices => libraries.keys;
Iterable<Uri> neighborsOf(Uri vertex) sync* {
- Library library = libraries[vertex];
+ Library? library = libraries[vertex];
if (library == null) {
throw "Library not found: $vertex";
}
@@ -32,6 +30,7 @@
Uri uri2 = dependency.targetLibrary.fileUri;
if (libraries.containsKey(uri1)) {
yield uri1;
+ // ignore: unnecessary_null_comparison
} else if (uri2 != null) {
if (libraries.containsKey(uri2)) {
yield uri2;
diff --git a/pkg/front_end/lib/src/fasta/source/directive_listener.dart b/pkg/front_end/lib/src/fasta/source/directive_listener.dart
index 3c29fe1..a7915a4 100644
--- a/pkg/front_end/lib/src/fasta/source/directive_listener.dart
+++ b/pkg/front_end/lib/src/fasta/source/directive_listener.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
-
/// Listener used in combination with `TopLevelParser` to extract the URIs of
/// import, part, and export directives.
library front_end.src.fasta.source.directive_listener;
@@ -29,12 +27,12 @@
final List<NamespaceDirective> exports = <NamespaceDirective>[];
/// Collects URIs that occur on any part directive.
- final Set<String> parts = new Set<String>();
+ final Set<String?> parts = new Set<String?>();
bool _inPart = false;
- String _uri;
- List<NamespaceCombinator> _combinators;
- List<String> _combinatorNames;
+ String? _uri;
+ List<NamespaceCombinator>? _combinators;
+ List<String>? _combinatorNames;
DirectiveListener();
@@ -79,12 +77,12 @@
@override
void endHide(Token hide) {
- _combinators.add(new NamespaceCombinator.hide(_combinatorNames));
+ _combinators!.add(new NamespaceCombinator.hide(_combinatorNames!));
_combinatorNames = null;
}
@override
- endImport(Token import, Token semicolon) {
+ endImport(Token? import, Token? semicolon) {
imports.add(new NamespaceDirective.import(_uri, _combinators));
_uri = null;
_combinators = null;
@@ -99,14 +97,14 @@
@override
void endShow(Token show) {
- _combinators.add(new NamespaceCombinator.show(_combinatorNames));
+ _combinators!.add(new NamespaceCombinator.show(_combinatorNames!));
_combinatorNames = null;
}
@override
void handleIdentifier(Token token, IdentifierContext context) {
if (_combinatorNames != null && context == IdentifierContext.combinator) {
- _combinatorNames.add(token.lexeme);
+ _combinatorNames!.add(token.lexeme);
}
}
@@ -133,8 +131,8 @@
class NamespaceDirective {
final bool isImport;
- final String uri;
- final List<NamespaceCombinator> combinators;
+ final String? uri;
+ final List<NamespaceCombinator>? combinators;
NamespaceDirective.export(this.uri, this.combinators) : isImport = false;
diff --git a/pkg/front_end/lib/src/fasta/util/bytes_sink.dart b/pkg/front_end/lib/src/fasta/util/bytes_sink.dart
index 4e3b61f..d945e92 100644
--- a/pkg/front_end/lib/src/fasta/util/bytes_sink.dart
+++ b/pkg/front_end/lib/src/fasta/util/bytes_sink.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;
// TODO(ahe): https://github.com/dart-lang/sdk/issues/28316
diff --git a/pkg/front_end/lib/src/fasta/util/direct_parser_ast.dart b/pkg/front_end/lib/src/fasta/util/direct_parser_ast.dart
index 424a9aa..d32f428 100644
--- a/pkg/front_end/lib/src/fasta/util/direct_parser_ast.dart
+++ b/pkg/front_end/lib/src/fasta/util/direct_parser_ast.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:typed_data' show Uint8List;
import 'dart:io' show File;
@@ -45,6 +43,7 @@
},
);
Token firstToken = scanner.tokenize();
+ // ignore: unnecessary_null_comparison
if (firstToken == null) {
throw "firstToken is null";
}
@@ -57,7 +56,7 @@
parser = new ClassMemberParser(listener);
}
parser.parseUnit(firstToken);
- return listener.data.single;
+ return listener.data.single as DirectParserASTContentCompilationUnitEnd;
}
/// Best-effort visitor for DirectParserASTContent that visits top-level entries
@@ -177,8 +176,8 @@
}
if (node is DirectParserASTContentEnumEnd) {
DirectParserASTContentEnumEnd declaration = node;
- visitEnum(
- declaration, declaration.enumKeyword, declaration.leftBrace.endGroup);
+ visitEnum(declaration, declaration.enumKeyword,
+ declaration.leftBrace.endGroup!);
return;
}
if (node is DirectParserASTContentLibraryNameEnd) {
@@ -225,7 +224,7 @@
DirectParserASTContentMetadataEnd decl = node;
// TODO(jensj): endToken is not part of the metadata! It's the first token
// of the next thing.
- visitMetadata(decl, decl.beginToken, decl.endToken.previous);
+ visitMetadata(decl, decl.beginToken, decl.endToken.previous!);
return;
}
@@ -234,16 +233,16 @@
void visitChildren(DirectParserASTContent node) {
if (node.children == null) return;
- final int numChildren = node.children.length;
+ final int numChildren = node.children!.length;
for (int i = 0; i < numChildren; i++) {
- DirectParserASTContent child = node.children[i];
+ DirectParserASTContent child = node.children![i];
accept(child);
}
}
/// Note: Implementers are NOT expected to call visitChildren on this node.
void visitImport(DirectParserASTContentImportEnd node, Token startInclusive,
- Token endInclusive) {}
+ Token? endInclusive) {}
/// Note: Implementers are NOT expected to call visitChildren on this node.
void visitExport(DirectParserASTContentExportEnd node, Token startInclusive,
@@ -360,11 +359,11 @@
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentClassOrNamedMixinApplicationPreludeBegin) {
return false;
}
- if (children.last is! DirectParserASTContentClassDeclarationEnd) {
+ if (children!.last is! DirectParserASTContentClassDeclarationEnd) {
return false;
}
@@ -373,18 +372,18 @@
DirectParserASTContentClassDeclarationEnd asClass() {
if (!isClass()) throw "Not class";
- return children.last;
+ return children!.last as DirectParserASTContentClassDeclarationEnd;
}
bool isImport() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentUncategorizedTopLevelDeclarationBegin) {
return false;
}
- if (children.last is! DirectParserASTContentImportEnd) {
+ if (children!.last is! DirectParserASTContentImportEnd) {
return false;
}
@@ -393,18 +392,18 @@
DirectParserASTContentImportEnd asImport() {
if (!isImport()) throw "Not import";
- return children.last;
+ return children!.last as DirectParserASTContentImportEnd;
}
bool isExport() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentUncategorizedTopLevelDeclarationBegin) {
return false;
}
- if (children.last is! DirectParserASTContentExportEnd) {
+ if (children!.last is! DirectParserASTContentExportEnd) {
return false;
}
@@ -413,18 +412,18 @@
DirectParserASTContentExportEnd asExport() {
if (!isExport()) throw "Not export";
- return children.last;
+ return children!.last as DirectParserASTContentExportEnd;
}
bool isEnum() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentUncategorizedTopLevelDeclarationBegin) {
return false;
}
- if (children.last is! DirectParserASTContentEnumEnd) {
+ if (children!.last is! DirectParserASTContentEnumEnd) {
return false;
}
@@ -433,18 +432,18 @@
DirectParserASTContentEnumEnd asEnum() {
if (!isEnum()) throw "Not enum";
- return children.last;
+ return children!.last as DirectParserASTContentEnumEnd;
}
bool isTypedef() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentUncategorizedTopLevelDeclarationBegin) {
return false;
}
- if (children.last is! DirectParserASTContentFunctionTypeAliasEnd) {
+ if (children!.last is! DirectParserASTContentFunctionTypeAliasEnd) {
return false;
}
@@ -453,7 +452,7 @@
DirectParserASTContentFunctionTypeAliasEnd asTypedef() {
if (!isTypedef()) throw "Not typedef";
- return children.last;
+ return children!.last as DirectParserASTContentFunctionTypeAliasEnd;
}
bool isScript() {
@@ -465,18 +464,18 @@
DirectParserASTContentScriptHandle asScript() {
if (!isScript()) throw "Not script";
- return this;
+ return this as DirectParserASTContentScriptHandle;
}
bool isExtension() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentExtensionDeclarationPreludeBegin) {
return false;
}
- if (children.last is! DirectParserASTContentExtensionDeclarationEnd) {
+ if (children!.last is! DirectParserASTContentExtensionDeclarationEnd) {
return false;
}
@@ -485,17 +484,17 @@
DirectParserASTContentExtensionDeclarationEnd asExtension() {
if (!isExtension()) throw "Not extension";
- return children.last;
+ return children!.last as DirectParserASTContentExtensionDeclarationEnd;
}
bool isInvalidTopLevelDeclaration() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first is! DirectParserASTContentTopLevelMemberBegin) {
+ if (children!.first is! DirectParserASTContentTopLevelMemberBegin) {
return false;
}
- if (children.last
+ if (children!.last
is! DirectParserASTContentInvalidTopLevelDeclarationHandle) {
return false;
}
@@ -507,11 +506,11 @@
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentUncategorizedTopLevelDeclarationBegin) {
return false;
}
- if (children.last is! DirectParserASTContentRecoverableErrorHandle) {
+ if (children!.last is! DirectParserASTContentRecoverableErrorHandle) {
return false;
}
@@ -522,11 +521,11 @@
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentUncategorizedTopLevelDeclarationBegin) {
return false;
}
- if (children.last is! DirectParserASTContentRecoverImportHandle) {
+ if (children!.last is! DirectParserASTContentRecoverImportHandle) {
return false;
}
@@ -537,11 +536,11 @@
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentClassOrNamedMixinApplicationPreludeBegin) {
return false;
}
- if (children.last is! DirectParserASTContentMixinDeclarationEnd) {
+ if (children!.last is! DirectParserASTContentMixinDeclarationEnd) {
return false;
}
@@ -550,18 +549,18 @@
DirectParserASTContentMixinDeclarationEnd asMixinDeclaration() {
if (!isMixinDeclaration()) throw "Not mixin declaration";
- return children.last;
+ return children!.last as DirectParserASTContentMixinDeclarationEnd;
}
bool isNamedMixinDeclaration() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentClassOrNamedMixinApplicationPreludeBegin) {
return false;
}
- if (children.last is! DirectParserASTContentNamedMixinApplicationEnd) {
+ if (children!.last is! DirectParserASTContentNamedMixinApplicationEnd) {
return false;
}
@@ -570,17 +569,17 @@
DirectParserASTContentNamedMixinApplicationEnd asNamedMixinDeclaration() {
if (!isNamedMixinDeclaration()) throw "Not named mixin declaration";
- return children.last;
+ return children!.last as DirectParserASTContentNamedMixinApplicationEnd;
}
bool isTopLevelMethod() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first is! DirectParserASTContentTopLevelMemberBegin) {
+ if (children!.first is! DirectParserASTContentTopLevelMemberBegin) {
return false;
}
- if (children.last is! DirectParserASTContentTopLevelMethodEnd) {
+ if (children!.last is! DirectParserASTContentTopLevelMethodEnd) {
return false;
}
@@ -589,17 +588,17 @@
DirectParserASTContentTopLevelMethodEnd asTopLevelMethod() {
if (!isTopLevelMethod()) throw "Not top level method";
- return children.last;
+ return children!.last as DirectParserASTContentTopLevelMethodEnd;
}
bool isTopLevelFields() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first is! DirectParserASTContentTopLevelMemberBegin) {
+ if (children!.first is! DirectParserASTContentTopLevelMemberBegin) {
return false;
}
- if (children.last is! DirectParserASTContentTopLevelFieldsEnd) {
+ if (children!.last is! DirectParserASTContentTopLevelFieldsEnd) {
return false;
}
@@ -608,18 +607,18 @@
DirectParserASTContentTopLevelFieldsEnd asTopLevelFields() {
if (!isTopLevelFields()) throw "Not top level fields";
- return children.last;
+ return children!.last as DirectParserASTContentTopLevelFieldsEnd;
}
bool isLibraryName() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentUncategorizedTopLevelDeclarationBegin) {
return false;
}
- if (children.last is! DirectParserASTContentLibraryNameEnd) {
+ if (children!.last is! DirectParserASTContentLibraryNameEnd) {
return false;
}
@@ -628,18 +627,18 @@
DirectParserASTContentLibraryNameEnd asLibraryName() {
if (!isLibraryName()) throw "Not library name";
- return children.last;
+ return children!.last as DirectParserASTContentLibraryNameEnd;
}
bool isPart() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentUncategorizedTopLevelDeclarationBegin) {
return false;
}
- if (children.last is! DirectParserASTContentPartEnd) {
+ if (children!.last is! DirectParserASTContentPartEnd) {
return false;
}
@@ -648,18 +647,18 @@
DirectParserASTContentPartEnd asPart() {
if (!isPart()) throw "Not part";
- return children.last;
+ return children!.last as DirectParserASTContentPartEnd;
}
bool isPartOf() {
if (this is! DirectParserASTContentTopLevelDeclarationEnd) {
return false;
}
- if (children.first
+ if (children!.first
is! DirectParserASTContentUncategorizedTopLevelDeclarationBegin) {
return false;
}
- if (children.last is! DirectParserASTContentPartOfEnd) {
+ if (children!.last is! DirectParserASTContentPartOfEnd) {
return false;
}
@@ -668,14 +667,14 @@
DirectParserASTContentPartOfEnd asPartOf() {
if (!isPartOf()) throw "Not part of";
- return children.last;
+ return children!.last as DirectParserASTContentPartOfEnd;
}
bool isMetadata() {
if (this is! DirectParserASTContentMetadataStarEnd) {
return false;
}
- if (children.first is! DirectParserASTContentMetadataStarBegin) {
+ if (children!.first is! DirectParserASTContentMetadataStarBegin) {
return false;
}
return true;
@@ -683,7 +682,7 @@
DirectParserASTContentMetadataStarEnd asMetadata() {
if (!isMetadata()) throw "Not metadata";
- return this;
+ return this as DirectParserASTContentMetadataStarEnd;
}
bool isFunctionBody() {
@@ -693,7 +692,7 @@
DirectParserASTContentBlockFunctionBodyEnd asFunctionBody() {
if (!isFunctionBody()) throw "Not function body";
- return this;
+ return this as DirectParserASTContentBlockFunctionBodyEnd;
}
List<E> recursivelyFind<E extends DirectParserASTContent>() {
@@ -709,7 +708,7 @@
return;
}
if (node.children == null) return;
- for (DirectParserASTContent child in node.children) {
+ for (DirectParserASTContent child in node.children!) {
_recursivelyFindInternal(child, result);
}
}
@@ -718,7 +717,7 @@
print("$indent${runtimeType} (${what}) "
"(${deprecatedArguments})");
if (children == null) return;
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
child.debugDumpNodeRecursively(indent: " $indent");
}
}
@@ -727,7 +726,7 @@
extension MetadataStarExtension on DirectParserASTContentMetadataStarEnd {
List<DirectParserASTContentMetadataEnd> getMetadataEntries() {
List<DirectParserASTContentMetadataEnd> result = [];
- for (DirectParserASTContent topLevel in children) {
+ for (DirectParserASTContent topLevel in children!) {
if (topLevel is! DirectParserASTContentMetadataEnd) continue;
result.add(topLevel);
}
@@ -738,36 +737,36 @@
extension CompilationUnitExtension on DirectParserASTContentCompilationUnitEnd {
List<DirectParserASTContentTopLevelDeclarationEnd> getClasses() {
List<DirectParserASTContentTopLevelDeclarationEnd> result = [];
- for (DirectParserASTContent topLevel in children) {
+ for (DirectParserASTContent topLevel in children!) {
if (!topLevel.isClass()) continue;
- result.add(topLevel);
+ result.add(topLevel as DirectParserASTContentTopLevelDeclarationEnd);
}
return result;
}
List<DirectParserASTContentTopLevelDeclarationEnd> getMixinDeclarations() {
List<DirectParserASTContentTopLevelDeclarationEnd> result = [];
- for (DirectParserASTContent topLevel in children) {
+ for (DirectParserASTContent topLevel in children!) {
if (!topLevel.isMixinDeclaration()) continue;
- result.add(topLevel);
+ result.add(topLevel as DirectParserASTContentTopLevelDeclarationEnd);
}
return result;
}
List<DirectParserASTContentImportEnd> getImports() {
List<DirectParserASTContentImportEnd> result = [];
- for (DirectParserASTContent topLevel in children) {
+ for (DirectParserASTContent topLevel in children!) {
if (!topLevel.isImport()) continue;
- result.add(topLevel.children.last);
+ result.add(topLevel.children!.last as DirectParserASTContentImportEnd);
}
return result;
}
List<DirectParserASTContentExportEnd> getExports() {
List<DirectParserASTContentExportEnd> result = [];
- for (DirectParserASTContent topLevel in children) {
+ for (DirectParserASTContent topLevel in children!) {
if (!topLevel.isExport()) continue;
- result.add(topLevel.children.last);
+ result.add(topLevel.children!.last as DirectParserASTContentExportEnd);
}
return result;
}
@@ -818,14 +817,14 @@
// }
DirectParserASTContentCompilationUnitBegin getBegin() {
- return children.first;
+ return children!.first as DirectParserASTContentCompilationUnitBegin;
}
}
extension TopLevelDeclarationExtension
on DirectParserASTContentTopLevelDeclarationEnd {
DirectParserASTContentIdentifierHandle getIdentifier() {
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentIdentifierHandle) return child;
}
throw "Not found.";
@@ -835,7 +834,7 @@
if (!isClass()) {
throw "Not a class";
}
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentClassDeclarationEnd) {
return child;
}
@@ -847,7 +846,7 @@
extension MixinDeclarationExtension
on DirectParserASTContentMixinDeclarationEnd {
DirectParserASTContentClassOrMixinBodyEnd getClassOrMixinBody() {
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentClassOrMixinBodyEnd) return child;
}
throw "Not found.";
@@ -857,21 +856,21 @@
extension ClassDeclarationExtension
on DirectParserASTContentClassDeclarationEnd {
DirectParserASTContentClassOrMixinBodyEnd getClassOrMixinBody() {
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentClassOrMixinBodyEnd) return child;
}
throw "Not found.";
}
DirectParserASTContentClassExtendsHandle getClassExtends() {
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentClassExtendsHandle) return child;
}
throw "Not found.";
}
DirectParserASTContentClassOrMixinImplementsHandle getClassImplements() {
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentClassOrMixinImplementsHandle) {
return child;
}
@@ -879,8 +878,8 @@
throw "Not found.";
}
- DirectParserASTContentClassWithClauseHandle getClassWithClause() {
- for (DirectParserASTContent child in children) {
+ DirectParserASTContentClassWithClauseHandle? getClassWithClause() {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentClassWithClauseHandle) {
return child;
}
@@ -893,7 +892,7 @@
on DirectParserASTContentClassOrMixinBodyEnd {
List<DirectParserASTContentMemberEnd> getMembers() {
List<DirectParserASTContentMemberEnd> members = [];
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentMemberEnd) {
members.add(child);
}
@@ -904,136 +903,140 @@
extension MemberExtension on DirectParserASTContentMemberEnd {
bool isClassConstructor() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentClassConstructorEnd) return true;
return false;
}
DirectParserASTContentClassConstructorEnd getClassConstructor() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentClassConstructorEnd) return child;
throw "Not found";
}
bool isClassFactoryMethod() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentClassFactoryMethodEnd) return true;
return false;
}
DirectParserASTContentClassFactoryMethodEnd getClassFactoryMethod() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentClassFactoryMethodEnd) return child;
throw "Not found";
}
bool isClassFields() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentClassFieldsEnd) return true;
return false;
}
DirectParserASTContentClassFieldsEnd getClassFields() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentClassFieldsEnd) return child;
throw "Not found";
}
bool isMixinFields() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentMixinFieldsEnd) return true;
return false;
}
DirectParserASTContentMixinFieldsEnd getMixinFields() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentMixinFieldsEnd) return child;
throw "Not found";
}
bool isMixinMethod() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentMixinMethodEnd) return true;
return false;
}
DirectParserASTContentMixinMethodEnd getMixinMethod() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentMixinMethodEnd) return child;
throw "Not found";
}
bool isMixinFactoryMethod() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentMixinFactoryMethodEnd) return true;
return false;
}
DirectParserASTContentMixinFactoryMethodEnd getMixinFactoryMethod() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentMixinFactoryMethodEnd) return child;
throw "Not found";
}
bool isMixinConstructor() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentMixinConstructorEnd) return true;
return false;
}
DirectParserASTContentMixinConstructorEnd getMixinConstructor() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentMixinConstructorEnd) return child;
throw "Not found";
}
bool isClassMethod() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentClassMethodEnd) return true;
return false;
}
DirectParserASTContentClassMethodEnd getClassMethod() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentClassMethodEnd) return child;
throw "Not found";
}
bool isClassRecoverableError() {
- DirectParserASTContent child = children[1];
+ DirectParserASTContent child = children![1];
if (child is DirectParserASTContentRecoverableErrorHandle) return true;
return false;
}
}
extension ClassFieldsExtension on DirectParserASTContentClassFieldsEnd {
- List<DirectParserASTContentIdentifierHandle> getFieldIdentifiers() {
+ List<DirectParserASTContentIdentifierHandle?> getFieldIdentifiers() {
// For now blindly assume that the last count identifiers are the names
// of the fields.
int countLeft = count;
- List<DirectParserASTContentIdentifierHandle> identifiers =
- new List<DirectParserASTContentIdentifierHandle>.filled(count, null);
- for (int i = children.length - 1; i >= 0; i--) {
- DirectParserASTContent child = children[i];
+ List<DirectParserASTContentIdentifierHandle>? identifiers;
+ for (int i = children!.length - 1; i >= 0; i--) {
+ DirectParserASTContent child = children![i];
if (child is DirectParserASTContentIdentifierHandle) {
countLeft--;
- identifiers[countLeft] = child;
+ if (identifiers == null) {
+ identifiers = new List<DirectParserASTContentIdentifierHandle>.filled(
+ count, child);
+ } else {
+ identifiers[countLeft] = child;
+ }
if (countLeft == 0) break;
}
}
if (countLeft != 0) throw "Didn't find the expected number of identifiers";
- return identifiers;
+ return identifiers ?? [];
}
- DirectParserASTContentTypeHandle getFirstType() {
- for (DirectParserASTContent child in children) {
+ DirectParserASTContentTypeHandle? getFirstType() {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentTypeHandle) return child;
}
return null;
}
- DirectParserASTContentFieldInitializerEnd getFieldInitializer() {
- for (DirectParserASTContent child in children) {
+ DirectParserASTContentFieldInitializerEnd? getFieldInitializer() {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentFieldInitializerEnd) return child;
}
return null;
@@ -1041,8 +1044,8 @@
}
extension ClassMethodExtension on DirectParserASTContentClassMethodEnd {
- DirectParserASTContentBlockFunctionBodyEnd getBlockFunctionBody() {
- for (DirectParserASTContent child in children) {
+ DirectParserASTContentBlockFunctionBodyEnd? getBlockFunctionBody() {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentBlockFunctionBodyEnd) {
return child;
}
@@ -1054,7 +1057,7 @@
extension ClassConstructorExtension
on DirectParserASTContentClassConstructorEnd {
DirectParserASTContentFormalParametersEnd getFormalParameters() {
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentFormalParametersEnd) {
return child;
}
@@ -1062,8 +1065,8 @@
throw "Not found";
}
- DirectParserASTContentInitializersEnd getInitializers() {
- for (DirectParserASTContent child in children) {
+ DirectParserASTContentInitializersEnd? getInitializers() {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentInitializersEnd) {
return child;
}
@@ -1071,8 +1074,8 @@
return null;
}
- DirectParserASTContentBlockFunctionBodyEnd getBlockFunctionBody() {
- for (DirectParserASTContent child in children) {
+ DirectParserASTContentBlockFunctionBodyEnd? getBlockFunctionBody() {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentBlockFunctionBodyEnd) {
return child;
}
@@ -1085,7 +1088,7 @@
on DirectParserASTContentFormalParametersEnd {
List<DirectParserASTContentFormalParameterEnd> getFormalParameters() {
List<DirectParserASTContentFormalParameterEnd> result = [];
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentFormalParameterEnd) {
result.add(child);
}
@@ -1093,9 +1096,9 @@
return result;
}
- DirectParserASTContentOptionalFormalParametersEnd
+ DirectParserASTContentOptionalFormalParametersEnd?
getOptionalFormalParameters() {
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentOptionalFormalParametersEnd) {
return child;
}
@@ -1106,7 +1109,7 @@
extension FormalParameterExtension on DirectParserASTContentFormalParameterEnd {
DirectParserASTContentFormalParameterBegin getBegin() {
- return children.first;
+ return children!.first as DirectParserASTContentFormalParameterBegin;
}
}
@@ -1114,7 +1117,7 @@
on DirectParserASTContentOptionalFormalParametersEnd {
List<DirectParserASTContentFormalParameterEnd> getFormalParameters() {
List<DirectParserASTContentFormalParameterEnd> result = [];
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentFormalParameterEnd) {
result.add(child);
}
@@ -1126,7 +1129,7 @@
extension InitializersExtension on DirectParserASTContentInitializersEnd {
List<DirectParserASTContentInitializerEnd> getInitializers() {
List<DirectParserASTContentInitializerEnd> result = [];
- for (DirectParserASTContent child in children) {
+ for (DirectParserASTContent child in children!) {
if (child is DirectParserASTContentInitializerEnd) {
result.add(child);
}
@@ -1135,13 +1138,13 @@
}
DirectParserASTContentInitializersBegin getBegin() {
- return children.first;
+ return children!.first as DirectParserASTContentInitializersBegin;
}
}
extension InitializerExtension on DirectParserASTContentInitializerEnd {
DirectParserASTContentInitializerBegin getBegin() {
- return children.first;
+ return children!.first as DirectParserASTContentInitializerBegin;
}
}
@@ -1188,7 +1191,7 @@
case DirectParserASTType.END:
// End should gobble up everything until the corresponding begin (which
// should be the latest begin).
- int beginIndex;
+ int? beginIndex;
for (int i = data.length - 1; i >= 0; i--) {
if (data[i].type == DirectParserASTType.BEGIN) {
beginIndex = i;
@@ -1261,7 +1264,7 @@
}
@override
- void reportVarianceModifierNotEnabled(Token variance) {
+ void reportVarianceModifierNotEnabled(Token? variance) {
throw new UnimplementedError();
}
diff --git a/pkg/front_end/lib/src/fasta/util/textual_outline.dart b/pkg/front_end/lib/src/fasta/util/textual_outline.dart
index 9af08ca..d8785df 100644
--- a/pkg/front_end/lib/src/fasta/util/textual_outline.dart
+++ b/pkg/front_end/lib/src/fasta/util/textual_outline.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:typed_data' show Uint8List;
import 'dart:io' show File;
@@ -29,9 +27,9 @@
import '../messages.dart' show Message;
abstract class _Chunk implements Comparable<_Chunk> {
- int originalPosition;
+ late int originalPosition;
- List<_MetadataChunk> metadata;
+ List<_MetadataChunk>? metadata;
void _printNormalHeaderWithMetadata(
StringBuffer sb, bool extraLine, String indent) {
@@ -47,7 +45,7 @@
void printMetadata(StringBuffer sb, String indent) {
if (metadata != null) {
- for (_MetadataChunk m in metadata) {
+ for (_MetadataChunk m in metadata!) {
m.printMetadataOn(sb, indent);
}
}
@@ -79,7 +77,7 @@
int endOfLast = fromToken.end;
Token token = fromToken;
Token afterEnd = toToken;
- if (includeToToken) afterEnd = toToken.next;
+ if (includeToToken) afterEnd = toToken.next!;
bool nextTokenIsEndGroup = false;
while (token != afterEnd) {
if (token.offset > endOfLast && !nextTokenIsEndGroup) {
@@ -91,10 +89,10 @@
if (skipContentOnEndGroupUntilToToken &&
token.endGroup != null &&
token.endGroup == toToken) {
- token = token.endGroup;
+ token = token.endGroup!;
nextTokenIsEndGroup = true;
} else {
- token = token.next;
+ token = token.next!;
nextTokenIsEndGroup = false;
}
}
@@ -164,8 +162,8 @@
int steps = 0;
while (thisToken.lexeme == otherToken.lexeme) {
if (steps++ > 10) break;
- thisToken = thisToken.next;
- otherToken = otherToken.next;
+ thisToken = thisToken.next!;
+ otherToken = otherToken.next!;
}
if (thisToken.lexeme == otherToken.lexeme) return super.compareTo(o);
return thisToken.lexeme.compareTo(otherToken.lexeme);
@@ -202,9 +200,9 @@
}
abstract class _SingleImportExportChunk extends _SortableChunk {
- final Token firstShowOrHide;
- final List<_NamespaceCombinator> combinators;
- String sortedShowAndHide;
+ final Token? firstShowOrHide;
+ final List<_NamespaceCombinator>? combinators;
+ String? sortedShowAndHide;
_SingleImportExportChunk(
Token startToken, Token endToken, this.firstShowOrHide, this.combinators)
@@ -214,9 +212,9 @@
void internalMergeAndSort(StringBuffer sb) {
assert(sb.isEmpty);
if (firstShowOrHide == null) return;
- for (int i = 0; i < combinators.length; i++) {
+ for (int i = 0; i < combinators!.length; i++) {
sb.write(" ");
- _NamespaceCombinator combinator = combinators[i];
+ _NamespaceCombinator combinator = combinators![i];
sb.write(combinator.isShow ? "show " : "hide ");
List<String> sorted = combinator.names.toList()..sort();
for (int j = 0; j < sorted.length; j++) {
@@ -233,20 +231,20 @@
if (sortedShowAndHide == null) {
return super._printOnWithoutHeaderAndMetadata(sb);
}
- printTokenRange(startToken, firstShowOrHide, sb, includeToToken: false);
+ printTokenRange(startToken, firstShowOrHide!, sb, includeToToken: false);
sb.write(sortedShowAndHide);
}
}
class _ImportChunk extends _SingleImportExportChunk {
- _ImportChunk(Token startToken, Token endToken, Token firstShowOrHide,
- List<_NamespaceCombinator> combinators)
+ _ImportChunk(Token startToken, Token endToken, Token? firstShowOrHide,
+ List<_NamespaceCombinator>? combinators)
: super(startToken, endToken, firstShowOrHide, combinators);
}
class _ExportChunk extends _SingleImportExportChunk {
- _ExportChunk(Token startToken, Token endToken, Token firstShowOrHide,
- List<_NamespaceCombinator> combinators)
+ _ExportChunk(Token startToken, Token endToken, Token? firstShowOrHide,
+ List<_NamespaceCombinator>? combinators)
: super(startToken, endToken, firstShowOrHide, combinators);
}
@@ -278,8 +276,8 @@
abstract class _ClassChunk extends _SortableChunk {
List<_Chunk> content = <_Chunk>[];
- Token headerEnd;
- Token footerStart;
+ Token? headerEnd;
+ Token? footerStart;
_ClassChunk(Token startToken, Token endToken) : super(startToken, endToken);
@@ -288,7 +286,7 @@
_printNormalHeaderWithMetadata(sb, extraLine, indent);
// Header.
- printTokenRange(startToken, headerEnd, sb);
+ printTokenRange(startToken, headerEnd!, sb);
// Content.
for (int i = 0; i < content.length; i++) {
@@ -303,7 +301,7 @@
}
sb.write(indent);
- printTokenRange(footerStart, endToken, sb);
+ printTokenRange(footerStart!, endToken, sb);
}
}
@@ -407,8 +405,8 @@
}
class _UnknownTokenBuilder {
- Token start;
- Token interimEnd;
+ Token? start;
+ Token? interimEnd;
}
class BoxedInt {
@@ -424,7 +422,7 @@
// "show A show B" could just be "show A, B".
// "show A, B, C hide A show A" would be empty.
-String textualOutline(
+String? textualOutline(
List<int> rawBytes,
ScannerConfiguration configuration, {
bool throwOnUnexpected: false,
@@ -448,6 +446,7 @@
..originalPosition = originalPosition.value++);
});
Token firstToken = scanner.tokenize();
+ // ignore: unnecessary_null_comparison
if (firstToken == null) {
if (throwOnUnexpected) throw "firstToken is null";
return null;
@@ -460,7 +459,7 @@
return null;
}
- Token nextToken = firstToken;
+ Token? nextToken = firstToken;
_UnknownTokenBuilder currentUnknown = new _UnknownTokenBuilder();
while (nextToken != null) {
if (nextToken is ErrorToken) {
@@ -489,11 +488,9 @@
}
List<_Chunk> _mergeAndSort(List<_Chunk> chunks) {
- List<_Chunk> result =
- new List<_Chunk>.filled(chunks.length, null, growable: true);
- List<_MetadataChunk> metadataChunks;
- List<_SingleImportExportChunk> importExportChunks;
- int outSize = 0;
+ List<_Chunk> result = [];
+ List<_MetadataChunk>? metadataChunks;
+ List<_SingleImportExportChunk>? importExportChunks;
StringBuffer sb = new StringBuffer();
for (_Chunk chunk in chunks) {
if (chunk is _MetadataChunk) {
@@ -514,16 +511,16 @@
importExportChunks, importExportChunks.first.originalPosition);
importExportChunk.internalMergeAndSort(sb);
sb.clear();
- result[outSize++] = importExportChunk;
+ result.add(importExportChunk);
importExportChunks = null;
}
- result[outSize++] = chunk;
+ result.add(chunk);
}
}
}
if (metadataChunks != null) {
for (_MetadataChunk metadata in metadataChunks) {
- result[outSize++] = metadata;
+ result.add(metadata);
}
}
if (importExportChunks != null) {
@@ -531,10 +528,9 @@
importExportChunks, importExportChunks.first.originalPosition);
importExportChunk.internalMergeAndSort(sb);
sb.clear();
- result[outSize++] = importExportChunk;
+ result.add(importExportChunk);
importExportChunks = null;
}
- result.length = outSize;
result.sort();
return result;
@@ -542,14 +538,14 @@
/// Parses a chunk of tokens and returns the next - unparsed - token or null
/// on error.
-Token _textualizeTokens(
+Token? _textualizeTokens(
TextualOutlineListener listener,
Token token,
_UnknownTokenBuilder currentUnknown,
List<_Chunk> parsedChunks,
BoxedInt originalPosition,
bool addMarkerForUnknownForTest) {
- _ClassChunk classChunk = listener.classStartToChunk[token];
+ _ClassChunk? classChunk = listener.classStartToChunk[token];
if (classChunk != null) {
outputUnknownChunk(currentUnknown, parsedChunks, originalPosition,
addMarkerForUnknownForTest);
@@ -558,7 +554,7 @@
listener, classChunk, originalPosition, addMarkerForUnknownForTest);
}
- _SingleImportExportChunk singleImportExport =
+ _SingleImportExportChunk? singleImportExport =
listener.importExportsStartToChunk[token];
if (singleImportExport != null) {
outputUnknownChunk(currentUnknown, parsedChunks, originalPosition,
@@ -568,7 +564,7 @@
return singleImportExport.endToken.next;
}
- _TokenChunk knownUnsortableChunk =
+ _TokenChunk? knownUnsortableChunk =
listener.unsortableElementStartToChunk[token];
if (knownUnsortableChunk != null) {
outputUnknownChunk(currentUnknown, parsedChunks, originalPosition,
@@ -578,7 +574,7 @@
return knownUnsortableChunk.endToken.next;
}
- _TokenChunk elementChunk = listener.elementStartToChunk[token];
+ _TokenChunk? elementChunk = listener.elementStartToChunk[token];
if (elementChunk != null) {
outputUnknownChunk(currentUnknown, parsedChunks, originalPosition,
addMarkerForUnknownForTest);
@@ -586,7 +582,7 @@
return elementChunk.endToken.next;
}
- _MetadataChunk metadataChunk = listener.metadataStartToChunk[token];
+ _MetadataChunk? metadataChunk = listener.metadataStartToChunk[token];
if (metadataChunk != null) {
outputUnknownChunk(currentUnknown, parsedChunks, originalPosition,
addMarkerForUnknownForTest);
@@ -610,10 +606,10 @@
Token _textualizeClass(TextualOutlineListener listener, _ClassChunk classChunk,
BoxedInt originalPosition, bool addMarkerForUnknownForTest) {
- Token token = classChunk.startToken;
+ Token? token = classChunk.startToken;
// Class header.
while (token != classChunk.endToken) {
- if (token.endGroup == classChunk.endToken) {
+ if (token!.endGroup == classChunk.endToken) {
break;
}
token = token.next;
@@ -627,11 +623,11 @@
// class C { }
// either way, output the end token right away to avoid a weird line break.
} else {
- token = token.next;
+ token = token!.next;
// "Normal" class with (possibly) content.
_UnknownTokenBuilder currentUnknown = new _UnknownTokenBuilder();
while (token != classChunk.endToken) {
- token = _textualizeTokens(listener, token, currentUnknown,
+ token = _textualizeTokens(listener, token!, currentUnknown,
classChunk.content, originalPosition, addMarkerForUnknownForTest);
}
outputUnknownChunk(currentUnknown, classChunk.content, originalPosition,
@@ -639,7 +635,7 @@
classChunk.footerStart = classChunk.endToken;
}
- return classChunk.endToken.next;
+ return classChunk.endToken.next!;
}
/// Outputs an unknown chunk if one has been started.
@@ -652,7 +648,7 @@
bool addMarkerForUnknownForTest) {
if (_currentUnknown.start == null) return;
parsedChunks.add(new _UnknownChunk(addMarkerForUnknownForTest,
- _currentUnknown.start, _currentUnknown.interimEnd)
+ _currentUnknown.start!, _currentUnknown.interimEnd!)
..originalPosition = originalPosition.value++);
_currentUnknown.start = null;
_currentUnknown.interimEnd = null;
@@ -663,14 +659,14 @@
Uint8List data = f.readAsBytesSync();
ScannerConfiguration scannerConfiguration = new ScannerConfiguration();
String outline = textualOutline(data, scannerConfiguration,
- throwOnUnexpected: true, performModelling: true);
+ throwOnUnexpected: true, performModelling: true)!;
if (args.length > 1 && args[1] == "--overwrite") {
f.writeAsStringSync(outline);
} else if (args.length > 1 && args[1] == "--benchmark") {
Stopwatch stopwatch = new Stopwatch()..start();
int numRuns = 100;
for (int i = 0; i < numRuns; i++) {
- String outline2 = textualOutline(data, scannerConfiguration,
+ String? outline2 = textualOutline(data, scannerConfiguration,
throwOnUnexpected: true, performModelling: true);
if (outline2 != outline) throw "Not the same result every time";
}
@@ -680,7 +676,7 @@
stopwatch = new Stopwatch()..start();
numRuns = 2500;
for (int i = 0; i < numRuns; i++) {
- String outline2 = textualOutline(data, scannerConfiguration,
+ String? outline2 = textualOutline(data, scannerConfiguration,
throwOnUnexpected: true, performModelling: true);
if (outline2 != outline) throw "Not the same result every time";
}
@@ -701,14 +697,14 @@
final Map<Token, _TokenChunk> unsortableElementStartToChunk = {};
@override
- void endClassMethod(Token getOrSet, Token beginToken, Token beginParam,
- Token beginInitializers, Token endToken) {
+ void endClassMethod(Token? getOrSet, Token beginToken, Token beginParam,
+ Token? beginInitializers, Token endToken) {
elementStartToChunk[beginToken] =
new _ClassMethodChunk(beginToken, endToken);
}
@override
- void endTopLevelMethod(Token beginToken, Token getOrSet, Token endToken) {
+ void endTopLevelMethod(Token beginToken, Token? getOrSet, Token endToken) {
elementStartToChunk[beginToken] =
new _TopLevelMethodChunk(beginToken, endToken);
}
@@ -727,12 +723,12 @@
@override
void endClassFields(
- Token abstractToken,
- Token externalToken,
- Token staticToken,
- Token covariantToken,
- Token lateToken,
- Token varFinalOrConst,
+ Token? abstractToken,
+ Token? externalToken,
+ Token? staticToken,
+ Token? covariantToken,
+ Token? lateToken,
+ Token? varFinalOrConst,
int count,
Token beginToken,
Token endToken) {
@@ -742,11 +738,11 @@
@override
void endTopLevelFields(
- Token externalToken,
- Token staticToken,
- Token covariantToken,
- Token lateToken,
- Token varFinalOrConst,
+ Token? externalToken,
+ Token? staticToken,
+ Token? covariantToken,
+ Token? lateToken,
+ Token? varFinalOrConst,
int count,
Token beginToken,
Token endToken) {
@@ -755,14 +751,14 @@
}
void endFunctionTypeAlias(
- Token typedefKeyword, Token equals, Token endToken) {
+ Token typedefKeyword, Token? equals, Token endToken) {
elementStartToChunk[typedefKeyword] =
new _FunctionTypeAliasChunk(typedefKeyword, endToken);
}
void endEnum(Token enumKeyword, Token leftBrace, int count) {
elementStartToChunk[enumKeyword] =
- new _EnumChunk(enumKeyword, leftBrace.endGroup);
+ new _EnumChunk(enumKeyword, leftBrace.endGroup!);
}
@override
@@ -785,10 +781,10 @@
}
@override
- void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) {
+ void endMetadata(Token beginToken, Token? periodBeforeName, Token endToken) {
// Metadata's endToken is the one *after* the actual end of the metadata.
metadataStartToChunk[beginToken] =
- new _MetadataChunk(beginToken, endToken.previous);
+ new _MetadataChunk(beginToken, endToken.previous!);
}
@override
@@ -804,7 +800,7 @@
}
@override
- void endExtensionDeclaration(Token extensionKeyword, Token typeKeyword,
+ void endExtensionDeclaration(Token extensionKeyword, Token? typeKeyword,
Token onKeyword, Token endToken) {
classStartToChunk[extensionKeyword] =
new _ExtensionDeclarationChunk(extensionKeyword, endToken);
@@ -812,14 +808,14 @@
@override
void endNamedMixinApplication(Token beginToken, Token classKeyword,
- Token equals, Token implementsKeyword, Token endToken) {
+ Token equals, Token? implementsKeyword, Token endToken) {
classStartToChunk[beginToken] =
new _NamedMixinApplicationChunk(beginToken, endToken);
}
- Token firstShowOrHide;
- List<_NamespaceCombinator> _combinators;
- List<String> _combinatorNames;
+ Token? firstShowOrHide;
+ List<_NamespaceCombinator>? _combinators;
+ List<String>? _combinatorNames;
@override
beginExport(Token export) {
@@ -845,25 +841,26 @@
@override
void endHide(Token hide) {
- _combinators.add(new _NamespaceCombinator.hide(_combinatorNames));
+ _combinators!.add(new _NamespaceCombinator.hide(_combinatorNames!));
_combinatorNames = null;
}
@override
void endShow(Token show) {
- _combinators.add(new _NamespaceCombinator.show(_combinatorNames));
+ _combinators!.add(new _NamespaceCombinator.show(_combinatorNames!));
_combinatorNames = null;
}
@override
void handleIdentifier(Token token, IdentifierContext context) {
if (_combinatorNames != null && context == IdentifierContext.combinator) {
- _combinatorNames.add(token.lexeme);
+ _combinatorNames!.add(token.lexeme);
}
}
@override
- void endImport(Token importKeyword, Token semicolon) {
+ void endImport(Token importKeyword, Token? semicolon) {
+ // ignore: unnecessary_null_comparison
if (importKeyword != null && semicolon != null) {
importExportsStartToChunk[importKeyword] = new _ImportChunk(
importKeyword, semicolon, firstShowOrHide, _combinators);
diff --git a/pkg/front_end/lib/src/testing/compiler_common.dart b/pkg/front_end/lib/src/testing/compiler_common.dart
index 5f0e775..0ee8f98 100644
--- a/pkg/front_end/lib/src/testing/compiler_common.dart
+++ b/pkg/front_end/lib/src/testing/compiler_common.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
-
/// Common compiler options and helper functions used for testing.
library front_end.testing.compiler_options_common;
@@ -32,10 +30,10 @@
/// compiles the entry whose name is [fileName].
///
/// Wraps [kernelForProgram] with some default testing options (see [setup]).
-Future<CompilerResult> compileScript(dynamic scriptOrSources,
+Future<CompilerResult?> compileScript(dynamic scriptOrSources,
{String fileName: 'main.dart',
List<String> additionalDills: const [],
- CompilerOptions options,
+ CompilerOptions? options,
bool retainDataForTesting: false,
bool requireMain: true}) async {
options ??= new CompilerOptions();
@@ -54,8 +52,9 @@
/// Generate a component for a modular compilation unit.
///
/// Wraps [kernelForModule] with some default testing options (see [setup]).
-Future<Component> compileUnit(List<String> inputs, Map<String, dynamic> sources,
- {List<String> additionalDills: const [], CompilerOptions options}) async {
+Future<Component?> compileUnit(
+ List<String> inputs, Map<String, dynamic> sources,
+ {List<String> additionalDills: const [], CompilerOptions? options}) async {
options ??= new CompilerOptions();
await setup(options, sources, additionalDills: additionalDills);
return (await kernelForModule(inputs.map(toTestUri).toList(), options))
@@ -65,9 +64,9 @@
/// Generate a summary for a modular compilation unit.
///
/// Wraps [summaryFor] with some default testing options (see [setup]).
-Future<List<int>> summarize(List<String> inputs, Map<String, dynamic> sources,
+Future<List<int>?> summarize(List<String> inputs, Map<String, dynamic> sources,
{List<String> additionalDills: const [],
- CompilerOptions options,
+ CompilerOptions? options,
bool truncate: false}) async {
options ??= new CompilerOptions();
await setup(options, sources, additionalDills: additionalDills);
diff --git a/pkg/front_end/lib/src/testing/id_testing_helper.dart b/pkg/front_end/lib/src/testing/id_testing_helper.dart
index 69fb201..084e8a7 100644
--- a/pkg/front_end/lib/src/testing/id_testing_helper.dart
+++ b/pkg/front_end/lib/src/testing/id_testing_helper.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// @dart = 2.9
-
import 'package:_fe_analyzer_shared/src/messages/severity.dart' show Severity;
import 'package:_fe_analyzer_shared/src/testing/id.dart'
show ActualData, ClassId, Id, IdKind, IdValue, MemberId, NodeId;
@@ -52,8 +50,8 @@
final String marker;
final String name;
final Map<ExperimentalFlag, bool> explicitExperimentalFlags;
- final AllowedExperimentalFlags allowedExperimentalFlags;
- final Uri librariesSpecificationUri;
+ final AllowedExperimentalFlags? allowedExperimentalFlags;
+ final Uri? librariesSpecificationUri;
// TODO(johnniwinther): Tailor support to redefine selected platform
// classes/members only.
final bool compileSdk;
@@ -89,7 +87,7 @@
InternalCompilerResult compilerResult,
Member member,
Map<Id, ActualData<T>> actualMap,
- {bool verbose}) {}
+ {bool? verbose}) {}
/// Function that computes a data mapping for [cls].
///
@@ -99,7 +97,7 @@
InternalCompilerResult compilerResult,
Class cls,
Map<Id, ActualData<T>> actualMap,
- {bool verbose}) {}
+ {bool? verbose}) {}
/// Function that computes a data mapping for [extension].
///
@@ -109,7 +107,7 @@
InternalCompilerResult compilerResult,
Extension extension,
Map<Id, ActualData<T>> actualMap,
- {bool verbose}) {}
+ {bool? verbose}) {}
/// Function that computes a data mapping for [library].
///
@@ -119,7 +117,7 @@
InternalCompilerResult compilerResult,
Library library,
Map<Id, ActualData<T>> actualMap,
- {bool verbose}) {}
+ {bool? verbose}) {}
/// Returns `true` if this data computer supports tests with compile-time
/// errors.
@@ -129,7 +127,7 @@
bool get supportsErrors => false;
/// Returns data corresponding to [error].
- T computeErrorData(TestConfig config, InternalCompilerResult compiler, Id id,
+ T? computeErrorData(TestConfig config, InternalCompilerResult compiler, Id id,
List<FormattedMessage> errors) =>
null;
@@ -155,11 +153,11 @@
int getOffsetFromId(Id id, Uri uri) {
if (id is NodeId) return id.value;
if (id is MemberId) {
- Library library = lookupLibrary(compilerResult.component, uri);
- Member member;
- int offset;
+ Library library = lookupLibrary(compilerResult.component!, uri)!;
+ Member? member;
+ int offset = -1;
if (id.className != null) {
- Class cls = lookupClass(library, id.className, required: false);
+ Class? cls = lookupClass(library, id.className!, required: false);
if (cls != null) {
member = lookupClassMember(cls, id.memberName, required: false);
if (member != null) {
@@ -180,23 +178,23 @@
}
return offset;
} else if (id is ClassId) {
- Library library = lookupLibrary(compilerResult.component, uri);
- Extension extension =
+ Library library = lookupLibrary(compilerResult.component!, uri)!;
+ Extension? extension =
lookupExtension(library, id.className, required: false);
if (extension != null) {
return extension.fileOffset;
}
- Class cls = lookupClass(library, id.className, required: false);
+ Class? cls = lookupClass(library, id.className, required: false);
return cls?.fileOffset ?? 0;
}
- return null;
+ return 0;
}
@override
void reportError(Uri uri, int offset, String message,
{bool succinct: false}) {
printMessageInLocation(
- compilerResult.component.uriToSource, uri, offset, message,
+ compilerResult.component!.uriToSource, uri, offset, message,
succinct: succinct);
}
}
@@ -210,7 +208,7 @@
@override
void report(Uri uri, int offset, String message) {
printMessageInLocation(
- compilerResult.component.uriToSource, uri, offset, message);
+ compilerResult.component!.uriToSource, uri, offset, message);
}
@override
@@ -229,12 +227,12 @@
DataComputer<T> dataComputer, List<TestConfig> testedConfigs) {
retainDataForTesting = true;
return (TestData testData,
- {bool testAfterFailures,
- bool verbose,
- bool succinct,
- bool printCode,
- Map<String, List<String>> skipMap,
- Uri nullUri}) {
+ {required bool testAfterFailures,
+ required bool verbose,
+ required bool succinct,
+ required bool printCode,
+ Map<String, List<String>>? skipMap,
+ required Uri nullUri}) {
return runTest(testData, dataComputer, testedConfigs,
testAfterFailures: testAfterFailures,
verbose: verbose,
@@ -251,15 +249,15 @@
/// Returns `true` if an error was encountered.
Future<Map<String, TestResult<T>>> runTest<T>(TestData testData,
DataComputer<T> dataComputer, List<TestConfig> testedConfigs,
- {bool testAfterFailures,
- bool verbose,
- bool succinct,
- bool printCode,
+ {required bool testAfterFailures,
+ required bool verbose,
+ required bool succinct,
+ required bool printCode,
bool forUserLibrariesOnly: true,
Iterable<Id> globalIds: const <Id>[],
- void onFailure(String message),
- Map<String, List<String>> skipMap,
- Uri nullUri}) async {
+ required void onFailure(String message),
+ Map<String, List<String>>? skipMap,
+ required Uri nullUri}) async {
for (TestConfig config in testedConfigs) {
if (!testData.expectedMaps.containsKey(config.marker)) {
throw new ArgumentError("Unexpected test marker '${config.marker}'. "
@@ -289,16 +287,16 @@
/// Returns `true` if an error was encountered.
Future<TestResult<T>> runTestForConfig<T>(
TestData testData, DataComputer<T> dataComputer, TestConfig config,
- {bool fatalErrors,
- bool verbose,
- bool succinct,
- bool printCode,
+ {required bool fatalErrors,
+ required bool verbose,
+ required bool succinct,
+ required bool printCode,
bool forUserLibrariesOnly: true,
Iterable<Id> globalIds: const <Id>[],
- void onFailure(String message),
- Uri nullUri}) async {
+ required void onFailure(String message),
+ required Uri nullUri}) async {
MemberAnnotations<IdValue> memberAnnotations =
- testData.expectedMaps[config.marker];
+ testData.expectedMaps[config.marker]!;
Iterable<Id> globalIds = memberAnnotations.globalData.keys;
CompilerOptions options = new CompilerOptions();
List<FormattedMessage> errors = [];
@@ -326,13 +324,13 @@
testData.memorySourceFiles,
options: options,
retainDataForTesting: true,
- requireMain: false);
+ requireMain: false) as InternalCompilerResult;
- Component component = compilerResult.component;
+ Component component = compilerResult.component!;
Map<Uri, Map<Id, ActualData<T>>> actualMaps = <Uri, Map<Id, ActualData<T>>>{};
Map<Id, ActualData<T>> globalData = <Id, ActualData<T>>{};
- Map<Id, ActualData<T>> actualMapForUri(Uri uri) {
+ Map<Id, ActualData<T>> actualMapForUri(Uri? uri) {
return actualMaps.putIfAbsent(uri ?? nullUri, () => <Id, ActualData<T>>{});
}
@@ -351,13 +349,14 @@
}
errorMap.forEach((Uri uri, Map<int, List<FormattedMessage>> map) {
- map.forEach((int offset, List<DiagnosticMessage> list) {
+ map.forEach((int offset, List<FormattedMessage> list) {
+ // ignore: unnecessary_null_comparison
if (offset == null || offset < 0) {
// Position errors without offset in the begin of the file.
offset = 0;
}
NodeId id = new NodeId(offset, IdKind.error);
- T data =
+ T? data =
dataComputer.computeErrorData(config, compilerResult, id, list);
if (data != null) {
Map<Id, ActualData<T>> actualMap = actualMapForUri(uri);
@@ -370,7 +369,7 @@
Map<Id, ActualData<T>> actualMapFor(TreeNode node) {
Uri uri = node is Library
? node.fileUri
- : (node is Member ? node.fileUri : node.location.file);
+ : (node is Member ? node.fileUri : node.location!.file);
return actualMaps.putIfAbsent(uri, () => <Id, ActualData<T>>{});
}
@@ -382,7 +381,7 @@
}
}
if (member.enclosingClass != null) {
- if (member.enclosingClass.isEnum) {
+ if (member.enclosingClass!.isEnum) {
if (member is Constructor ||
member.isInstanceMember ||
member.name.text == 'values') {
@@ -444,9 +443,9 @@
];
Class getGlobalClass(String className) {
- Class cls;
+ Class? cls;
for (Uri uri in globalLibraries) {
- Library library = lookupLibrary(component, uri);
+ Library? library = lookupLibrary(component, uri);
if (library != null) {
cls ??= lookupClass(library, className);
}
@@ -459,9 +458,9 @@
}
Member getGlobalMember(String memberName) {
- Member member;
+ Member? member;
for (Uri uri in globalLibraries) {
- Library library = lookupLibrary(component, uri);
+ Library? library = lookupLibrary(component, uri);
if (library != null) {
member ??= lookupLibraryMember(library, memberName);
}
@@ -475,9 +474,9 @@
for (Id id in globalIds) {
if (id is MemberId) {
- Member member;
+ Member? member;
if (id.className != null) {
- Class cls = getGlobalClass(id.className);
+ Class? cls = getGlobalClass(id.className!);
member = lookupClassMember(cls, id.memberName);
if (member == null) {
throw "Global member '${id.memberName}' not found in class $cls.";
@@ -502,15 +501,16 @@
}
void printMessageInLocation(
- Map<Uri, Source> uriToSource, Uri uri, int offset, String message,
+ Map<Uri, Source> uriToSource, Uri? uri, int offset, String message,
{bool succinct: false}) {
if (uri == null) {
print("(null uri)@$offset: $message");
} else {
- Source source = uriToSource[uri];
+ Source? source = uriToSource[uri];
if (source == null) {
print('$uri@$offset: $message');
} else {
+ // ignore: unnecessary_null_comparison
if (offset != null && offset >= 1) {
Location location = source.getLocation(uri, offset);
print('$location: $message');
diff --git a/pkg/front_end/lib/widget_cache.dart b/pkg/front_end/lib/widget_cache.dart
index 695ed83..f80f493 100644
--- a/pkg/front_end/lib/widget_cache.dart
+++ b/pkg/front_end/lib/widget_cache.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/class_hierarchy.dart';
import 'package:kernel/kernel.dart';
@@ -14,9 +12,9 @@
/// Create a [WidgetCache] from a [Component] containing the flutter
/// framework.
WidgetCache(Component fullComponent) {
- Library frameworkLibrary;
+ Library? frameworkLibrary;
for (Library library in fullComponent.libraries) {
- if (library?.importUri == _frameworkLibrary) {
+ if (library.importUri == _frameworkLibrary) {
frameworkLibrary = library;
break;
}
@@ -33,9 +31,9 @@
static const String _statefulWidgetClassName = 'StatefulWidget';
static const String _statelessWidgetClassName = 'StatelessWidget';
- Class _statelessWidget;
- Class _state;
- Class _statefulWidget;
+ Class? _statelessWidget;
+ Class? _state;
+ Class? _statefulWidget;
bool _frameworkTypesLocated = false;
static final Uri _frameworkLibrary =
@@ -58,8 +56,8 @@
/// `State` subtype.
///
/// Returns the class name if located, otherwise `null`.
- String checkSingleWidgetTypeModified(
- Component lastGoodComponent,
+ String? checkSingleWidgetTypeModified(
+ Component? lastGoodComponent,
Component partialComponent,
ClassHierarchy classHierarchy,
) {
@@ -69,7 +67,7 @@
return null;
}
Uri importUri = _invalidatedLibraries[0];
- Library library;
+ Library? library;
for (Library candidateLibrary in partialComponent.libraries) {
if (candidateLibrary.importUri == importUri) {
library = candidateLibrary;
@@ -79,9 +77,11 @@
if (library == null) {
return null;
}
- List<int> oldSource = lastGoodComponent.uriToSource[library.fileUri].source;
- List<int> newSource = partialComponent.uriToSource[library.fileUri].source;
+ List<int> oldSource =
+ lastGoodComponent.uriToSource[library.fileUri]!.source;
+ List<int> newSource = partialComponent.uriToSource[library.fileUri]!.source;
// Library was added and does not exist in the old component.
+ // ignore: unnecessary_null_comparison
if (oldSource == null) {
return null;
}
@@ -105,7 +105,7 @@
oldEndIndex -= 1;
}
- Class newClass =
+ Class? newClass =
_locateContainingClass(library, newStartIndex, newEndIndex);
if (newClass == null) {
return null;
@@ -116,7 +116,7 @@
return library.importUri == importUri;
});
- Class oldClass =
+ Class? oldClass =
_locateContainingClass(oldLibrary, oldStartIndex, oldEndIndex);
if (oldClass == null || oldClass.name != newClass.name) {
@@ -125,13 +125,13 @@
// Update the class references to stateless, stateful, and state classes.
for (Library library in classHierarchy.knownLibraries) {
- if (library?.importUri == _frameworkLibrary) {
+ if (library.importUri == _frameworkLibrary) {
_locatedClassDeclarations(library);
}
}
- if (classHierarchy.isSubclassOf(newClass, _statelessWidget) ||
- classHierarchy.isSubclassOf(newClass, _statefulWidget)) {
+ if (classHierarchy.isSubclassOf(newClass, _statelessWidget!) ||
+ classHierarchy.isSubclassOf(newClass, _statefulWidget!)) {
if (classHierarchy.isExtended(newClass) ||
classHierarchy.isUsedAsMixin(newClass)) {
return null;
@@ -143,8 +143,8 @@
// StatefulWidget that is provided as a type parameter. If the bounds are
// StatefulWidget itself, fail as that indicates the type was not
// specified.
- Supertype stateSuperType =
- classHierarchy.getClassAsInstanceOf(newClass, _state);
+ Supertype? stateSuperType =
+ classHierarchy.getClassAsInstanceOf(newClass, _state!);
if (stateSuperType != null) {
if (stateSuperType.typeArguments.length != 1) {
return null;
@@ -167,7 +167,7 @@
}
// Locate the that fully contains the edit range, or null.
- Class _locateContainingClass(
+ Class? _locateContainingClass(
Library library, int startOffset, int endOffset) {
for (Class classDeclaration in library.classes) {
if (classDeclaration.startFileOffset <= startOffset &&
diff --git a/pkg/front_end/tool/dart_doctest_impl.dart b/pkg/front_end/tool/dart_doctest_impl.dart
index 661c0563..3051c00e 100644
--- a/pkg/front_end/tool/dart_doctest_impl.dart
+++ b/pkg/front_end/tool/dart_doctest_impl.dart
@@ -764,7 +764,7 @@
new Uri(scheme: "dartdoctest", path: "tester");
DocTestIncrementalCompiler(CompilerContext context) : super(context);
- bool dontReissueLibraryProblemsFor(Uri uri) {
+ bool dontReissueLibraryProblemsFor(Uri? uri) {
return super.dontReissueLibraryProblemsFor(uri) || uri == dartDocTestUri;
}
@@ -786,10 +786,10 @@
assert(dillLoadedData != null && userCode != null);
return await context.runInContext((_) async {
- LibraryBuilder libraryBuilder =
- userCode.loader.read(libraryUri, -1, accessor: userCode.loader.first);
+ LibraryBuilder libraryBuilder = userCode!.loader
+ .read(libraryUri, -1, accessor: userCode!.loader.first);
- userCode.loader.seenMessages.clear();
+ userCode!.loader.seenMessages.clear();
_dartDocTestLibraryBuilder = libraryBuilder;
_dartDocTestCode = dartDocTestCode;
@@ -800,8 +800,8 @@
_dartDocTestLibraryBuilder = null;
_dartDocTestCode = null;
- userCode.uriToSource.remove(dartDocTestUri);
- userCode.loader.sourceBytes.remove(dartDocTestUri);
+ userCode!.uriToSource.remove(dartDocTestUri);
+ userCode!.loader.sourceBytes.remove(dartDocTestUri);
return result;
});
@@ -813,7 +813,7 @@
dartDocTestUri,
/*packageUri*/ null,
new ImplicitLanguageVersion(libraryBuilder.library.languageVersion),
- userCode.loader,
+ userCode!.loader,
null,
scope: libraryBuilder.scope.createNestedScope("dartdoctest"),
nameOrigin: libraryBuilder,
@@ -877,7 +877,7 @@
kernel.Library? referencesFrom,
bool? referenceIsPartOwner) {
if (uri == DocTestIncrementalCompiler.dartDocTestUri) {
- HybridFileSystem hfs = compiler.userCode.fileSystem as HybridFileSystem;
+ HybridFileSystem hfs = compiler.userCode!.fileSystem as HybridFileSystem;
MemoryFileSystem fs = hfs.memory;
fs
.entityForUri(DocTestIncrementalCompiler.dartDocTestUri)
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 688005a..4c7f24f 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -14080,6 +14080,12 @@
/// Non-nullable [Reference] dummy value.
final Reference dummyReference = new Reference();
+/// Non-nullable [Component] dummy value.
+///
+/// This can be used for instance as a dummy initial value for the `List.filled`
+/// constructor.
+final Component dummyComponent = new Component();
+
/// Non-nullable [Library] dummy value.
///
/// This is used as the removal sentinel in [RemovingTransformer] and can be
@@ -14290,6 +14296,7 @@
///
/// This should manually be kept up to date.
final List<TreeNode> dummyTreeNodes = [
+ dummyComponent,
dummyLibrary,
dummyLibraryDependency,
dummyCombinator,
diff --git a/runtime/docs/gc.md b/runtime/docs/gc.md
index 38bda88..7857b3d 100644
--- a/runtime/docs/gc.md
+++ b/runtime/docs/gc.md
@@ -61,7 +61,13 @@
During the sweeping phase, the collector visits each old-space object. If the mark bit is clear, the object's memory is added to a [free list](https://github.com/dart-lang/sdk/blob/master/runtime/vm/heap/freelist.h) to be used for future allocations. Otherwise the object's mark bit is cleared. If every object on some page is unreachable, the page is released to the OS.
-Note that because we do not mark new-space objects, we treat every object in new-space as a root during old-space collections. This property makes new-space and old-space collections more independent, and in particular allows a scavenge to run at the same time as concurrent marking.
+### New-Space as Roots
+
+We do not mark new-space objects, and pointers to new-space objects are ignored; instead all objects in new-space are treated as part of the root set.
+
+This has the advantage of making collections of the two spaces more independent. In particular, the concurrent marker never needs to dereference any memory in new-space, avoiding several data race issues, and avoiding the need to pause or otherwise synchronize with the concurrent marker when starting a scavenge.
+
+It has the disadvantage that no single collection will collect all garbage. An unreachable old-space object that is referenced by an unreachable new-space object will not be collected until a scavenge first collects the new-space object, and unreachable objects that have a generation-crossing cycle will not be collected until the whole subgraph is promoted into old-space. The growth policy must be careful to ensure it doesn't perform old-space collections without interleaving new-space collections, such as when the program performs mostly large allocation that go directly to old-space, or old-space can accumulate such floating garbage and grow without bound.
## Mark-Compact
diff --git a/runtime/platform/utils.h b/runtime/platform/utils.h
index a1d6b1b..98f1a1c 100644
--- a/runtime/platform/utils.h
+++ b/runtime/platform/utils.h
@@ -229,22 +229,12 @@
return value <= limit;
}
- // Check whether the magnitude of value fits in N bits. This differs from
- // IsInt(N + 1, value) only in that this returns false for the minimum value
- // of a N+1 bit two's complement value.
- //
- // Primarily used for testing whether a two's complement value can be used in
- // a place where the sign is replaced with a marker that says whether the
- // magnitude is added or subtracted, e.g., the U bit (bit 23) in some ARM7
- // instructions.
+ // Check whether the magnitude of value fits in N bits, i.e., whether an
+ // (N+1)-bit sign-magnitude representation can hold value.
template <typename T>
- static inline bool MagnitudeIsUint(intptr_t N, T value) {
+ static inline bool IsAbsoluteUint(intptr_t N, T value) {
ASSERT(N >= 1);
- if constexpr (std::is_signed<T>::value) {
- using Unsigned = typename std::make_unsigned<T>::type;
- if (value < 0) return IsUint<Unsigned>(N, -value);
- }
- return IsUint(N, value);
+ return IsInt(N + 1, value);
}
static inline int32_t Low16Bits(int32_t value) {
diff --git a/runtime/vm/compiler/assembler/assembler_arm.cc b/runtime/vm/compiler/assembler/assembler_arm.cc
index d285792..7cf8272 100644
--- a/runtime/vm/compiler/assembler/assembler_arm.cc
+++ b/runtime/vm/compiler/assembler/assembler_arm.cc
@@ -2336,20 +2336,19 @@
case kUnsignedTwoBytes:
case kWordPair: {
*offset_mask = 0xff;
- return Utils::MagnitudeIsUint(8, offset); // Addressing mode 3.
+ return Utils::IsAbsoluteUint(8, offset); // Addressing mode 3.
}
case kUnsignedByte:
case kFourBytes:
case kUnsignedFourBytes: {
*offset_mask = 0xfff;
- return Utils::MagnitudeIsUint(12, offset); // Addressing mode 2.
+ return Utils::IsAbsoluteUint(12, offset); // Addressing mode 2.
}
case kSWord:
case kDWord: {
*offset_mask = 0x3fc; // Multiple of 4.
// VFP addressing mode.
- return (Utils::MagnitudeIsUint(10, offset) &&
- Utils::IsAligned(offset, 4));
+ return (Utils::IsAbsoluteUint(10, offset) && Utils::IsAligned(offset, 4));
}
case kRegList: {
*offset_mask = 0x0;
@@ -2370,21 +2369,20 @@
case kUnsignedTwoBytes:
case kWordPair: {
*offset_mask = 0xff;
- return Utils::MagnitudeIsUint(8, offset); // Addressing mode 3.
+ return Utils::IsAbsoluteUint(8, offset); // Addressing mode 3.
}
case kByte:
case kUnsignedByte:
case kFourBytes:
case kUnsignedFourBytes: {
*offset_mask = 0xfff;
- return Utils::MagnitudeIsUint(12, offset); // Addressing mode 2.
+ return Utils::IsAbsoluteUint(12, offset); // Addressing mode 2.
}
case kSWord:
case kDWord: {
*offset_mask = 0x3fc; // Multiple of 4.
// VFP addressing mode.
- return (Utils::MagnitudeIsUint(10, offset) &&
- Utils::IsAligned(offset, 4));
+ return (Utils::IsAbsoluteUint(10, offset) && Utils::IsAligned(offset, 4));
}
case kRegList: {
*offset_mask = 0x0;
diff --git a/runtime/vm/compiler/assembler/assembler_arm.h b/runtime/vm/compiler/assembler/assembler_arm.h
index c41b62d..09162f4 100644
--- a/runtime/vm/compiler/assembler/assembler_arm.h
+++ b/runtime/vm/compiler/assembler/assembler_arm.h
@@ -238,7 +238,7 @@
}
explicit Address(Register rn, int32_t offset = 0, Mode am = Offset) {
- ASSERT(Utils::MagnitudeIsUint(12, offset));
+ ASSERT(Utils::IsAbsoluteUint(12, offset));
kind_ = Immediate;
if (offset < 0) {
encoding_ = (am ^ (1 << kUShift)) | -offset; // Flip U to adjust sign.
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc b/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
index b71c702..979db7e 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
@@ -712,7 +712,7 @@
} else {
__ add(LR, DISPATCH_TABLE_REG,
compiler::Operand(cid_reg, LSL, compiler::target::kWordSizeLog2));
- if (!Utils::MagnitudeIsUint(12, offset)) {
+ if (!Utils::IsAbsoluteUint(12, offset)) {
const intptr_t adjust = offset & -(1 << 12);
__ AddImmediate(LR, LR, adjust);
offset -= adjust;
diff --git a/runtime/vm/compiler/backend/il_arm.cc b/runtime/vm/compiler/backend/il_arm.cc
index 0c07ad2..80aaa47 100644
--- a/runtime/vm/compiler/backend/il_arm.cc
+++ b/runtime/vm/compiler/backend/il_arm.cc
@@ -1855,7 +1855,7 @@
const intptr_t base_offset =
(is_external ? 0 : (Instance::DataOffsetFor(cid) - kHeapObjectTag));
const int64_t offset = index * scale + base_offset;
- if (!Utils::MagnitudeIsUint(12, offset)) {
+ if (!Utils::IsAbsoluteUint(12, offset)) {
return false;
}
if (compiler::Address::CanHoldImmediateOffset(is_load, cid, offset)) {
diff --git a/runtime/vm/datastream.cc b/runtime/vm/datastream.cc
index 8236bf2..6d398fe 100644
--- a/runtime/vm/datastream.cc
+++ b/runtime/vm/datastream.cc
@@ -10,7 +10,8 @@
namespace dart {
void BaseWriteStream::WriteTargetWord(word value) {
- ASSERT(Utils::IsInt(compiler::target::kBitsPerWord, value));
+ ASSERT(compiler::target::kBitsPerWord == kBitsPerWord ||
+ Utils::IsAbsoluteUint(compiler::target::kBitsPerWord, value));
WriteFixed(static_cast<compiler::target::word>(value));
}
diff --git a/runtime/vm/image_snapshot.cc b/runtime/vm/image_snapshot.cc
index 715bd93..658892b 100644
--- a/runtime/vm/image_snapshot.cc
+++ b/runtime/vm/image_snapshot.cc
@@ -1207,7 +1207,8 @@
}
intptr_t AssemblyImageWriter::WriteTargetWord(word value) {
- ASSERT(Utils::IsInt(compiler::target::kBitsPerWord, value));
+ ASSERT(compiler::target::kBitsPerWord == kBitsPerWord ||
+ Utils::IsAbsoluteUint(compiler::target::kBitsPerWord, value));
// Padding is helpful for comparing the .S with --disassemble.
assembly_stream_->Printf("%s 0x%.*" Px "\n", kWordDirective,
2 * compiler::target::kWordSize, value);
diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc
index fb36cf8..af7acb1 100644
--- a/runtime/vm/object_test.cc
+++ b/runtime/vm/object_test.cc
@@ -136,7 +136,6 @@
cls.Finalize();
}
-
function_name = String::New("Foo");
function = Resolver::ResolveDynamicFunction(Z, cls, function_name);
EXPECT(function.IsNull());
@@ -4359,13 +4358,14 @@
ASSERT(strlen(json_str) < kBufferSize);
ElideJSONSubstring("classes", json_str, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"bool\","
"\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":\"@"
"Script\","
"\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core\\/bool.dart\","
- "\"_kind\":\"kernel\"},\"tokenPos\":436,\"endTokenPos\":4432},"
+ "\"_kind\":\"kernel\"}},"
"\"library\":{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\","
"\"name\":\"dart.core\",\"uri\":\"dart:core\"}}",
buffer);
@@ -4384,6 +4384,7 @@
ASSERT(strlen(json_str) < kBufferSize);
ElideJSONSubstring("classes", json_str, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Function\",\"fixedId\":true,\"id\":\"\","
"\"name\":\"toString\",\"owner\":{\"type\":\"@Class\","
@@ -4391,15 +4392,14 @@
"\"location\":{\"type\":\"SourceLocation\","
"\"script\":{\"type\":\"@Script\",\"fixedId\":true,"
"\"id\":\"\",\"uri\":\"dart:core\\/bool.dart\","
- "\"_kind\":\"kernel\"},\"tokenPos\":436,\"endTokenPos\":4432},"
+ "\"_kind\":\"kernel\"}},"
"\"library\":{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\","
"\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
"\"_kind\":\"RegularFunction\",\"static\":false,\"const\":false,"
"\"_intrinsic\":false,\"_native\":false,"
"\"location\":{\"type\":\"SourceLocation\","
"\"script\":{\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\","
- "\"uri\":\"dart:core\\/bool.dart\",\"_kind\":\"kernel\"},"
- "\"tokenPos\":4372,\"endTokenPos\":4430}}",
+ "\"uri\":\"dart:core\\/bool.dart\",\"_kind\":\"kernel\"}}}",
buffer);
}
// Library reference
@@ -4424,12 +4424,13 @@
ASSERT(strlen(json_str) < kBufferSize);
ElideJSONSubstring("classes", json_str, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Instance\",\"_vmType\":\"Bool\",\"class\":{\"type\":\"@"
"Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"bool\",\"location\":{"
"\"type\":\"SourceLocation\",\"script\":{\"type\":\"@Script\","
"\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core\\/bool.dart\",\"_"
- "kind\":\"kernel\"},\"tokenPos\":436,\"endTokenPos\":4432},\"library\":"
+ "kind\":\"kernel\"}},\"library\":"
"{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\",\"name\":\"dart."
"core\",\"uri\":\"dart:core\"}},\"identityHashCode\":0,\"kind\":"
"\"Bool\",\"fixedId\":true,\"id\":\"objects\\/bool-true\","
@@ -4446,13 +4447,14 @@
ElideJSONSubstring("classes", json_str, buffer);
ElideJSONSubstring("_Smi@", buffer, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Instance\",\"_vmType\":\"Smi\",\"class\":{\"type\":\"@"
"Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_Smi\",\"_vmName\":"
"\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":"
"\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-"
- "patch\\/integers.dart\",\"_kind\":\"kernel\"},\"tokenPos\":16466,"
- "\"endTokenPos\":24948},\"library\":{\"type\":\"@Library\",\"fixedId\":"
+ "patch\\/integers.dart\",\"_kind\":\"kernel\"}"
+ "},\"library\":{\"type\":\"@Library\",\"fixedId\":"
"true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
"\"identityHashCode\":0,\"kind\":\"Int\",\"fixedId\":true,\"id\":"
"\"objects\\/int-7\",\"valueAsString\":\"7\"}",
@@ -4469,13 +4471,14 @@
ElideJSONSubstring("objects", buffer, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
ElideJSONSubstring("_Mint@", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Instance\",\"_vmType\":\"Mint\",\"class\":{\"type\":\"@"
"Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_Mint\",\"_vmName\":"
"\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":"
"\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-"
- "patch\\/integers.dart\",\"_kind\":\"kernel\"},\"tokenPos\":25029,"
- "\"endTokenPos\":25413},\"library\":{\"type\":\"@Library\",\"fixedId\":"
+ "patch\\/integers.dart\",\"_kind\":\"kernel\"}"
+ "},\"library\":{\"type\":\"@Library\",\"fixedId\":"
"true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
"\"identityHashCode\":0,\"kind\":\"Int\",\"id\":\"\",\"valueAsString\":"
"\"-9223372036854775808\"}",
@@ -4492,13 +4495,14 @@
ElideJSONSubstring("objects", buffer, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
ElideJSONSubstring("_Double@", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Instance\",\"_vmType\":\"Double\",\"class\":{\"type\":\"@"
"Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_Double\",\"_vmName\":"
"\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":"
"\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-"
- "patch\\/double.dart\",\"_kind\":\"kernel\"},\"tokenPos\":248,"
- "\"endTokenPos\":12248},\"library\":{\"type\":\"@Library\",\"fixedId\":"
+ "patch\\/double.dart\",\"_kind\":\"kernel\"}"
+ "},\"library\":{\"type\":\"@Library\",\"fixedId\":"
"true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
"\"identityHashCode\":0,\"kind\":\"Double\",\"id\":\"\","
"\"valueAsString\":\"0.1234\"}",
@@ -4515,13 +4519,14 @@
ElideJSONSubstring("objects", buffer, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
ElideJSONSubstring("_OneByteString@", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Instance\",\"_vmType\":\"String\",\"class\":{\"type\":\"@"
"Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_OneByteString\",\"_"
"vmName\":\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{"
"\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-"
- "patch\\/string_patch.dart\",\"_kind\":\"kernel\"},\"tokenPos\":32339,"
- "\"endTokenPos\":44628},\"library\":{\"type\":\"@Library\",\"fixedId\":"
+ "patch\\/string_patch.dart\",\"_kind\":\"kernel\"}"
+ "},\"library\":{\"type\":\"@Library\",\"fixedId\":"
"true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
"\"identityHashCode\":0,\"kind\":\"String\",\"id\":\"\",\"length\":2,"
"\"valueAsString\":\"dw\"}",
@@ -4538,13 +4543,14 @@
ElideJSONSubstring("objects", buffer, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
ElideJSONSubstring("_List@", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Instance\",\"_vmType\":\"Array\",\"class\":{\"type\":\"@"
"Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_List\",\"_vmName\":"
"\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":"
"\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-"
- "patch\\/array.dart\",\"_kind\":\"kernel\"},\"tokenPos\":248,"
- "\"endTokenPos\":7758},\"library\":{\"type\":\"@Library\",\"fixedId\":"
+ "patch\\/array.dart\",\"_kind\":\"kernel\"}"
+ "},\"library\":{\"type\":\"@Library\",\"fixedId\":"
"true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
"\"identityHashCode\":0,\"kind\":\"List\",\"id\":\"\",\"length\":0}",
buffer);
@@ -4561,13 +4567,14 @@
ElideJSONSubstring("objects", buffer, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
ElideJSONSubstring("_GrowableList@", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Instance\",\"_vmType\":\"GrowableObjectArray\",\"class\":"
"{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_"
"GrowableList\",\"_vmName\":\"\",\"location\":{\"type\":"
"\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true,"
"\"id\":\"\",\"uri\":\"dart:core-patch\\/growable_array.dart\",\"_"
- "kind\":\"kernel\"},\"tokenPos\":248,\"endTokenPos\":18485},"
+ "kind\":\"kernel\"}},"
"\"library\":{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\","
"\"name\":\"dart.core\",\"uri\":\"dart:core\"}},\"identityHashCode\":0,"
"\"kind\":\"List\",\"id\":\"\",\"length\":0}",
@@ -4585,17 +4592,17 @@
ElideJSONSubstring("objects", buffer, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
ElideJSONSubstring("_InternalLinkedHashMap@", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Instance\",\"_vmType\":\"LinkedHashMap\",\"class\":{"
"\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_"
"InternalLinkedHashMap\",\"_vmName\":\"\",\"location\":{\"type\":"
"\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true,"
- "\"id\":\"\",\"uri\":\"dart:collection-patch\\/"
- "compact_hash.dart\",\"_kind\":\"kernel\"},\"tokenPos\":6399,"
- "\"endTokenPos\":6786},\"library\":{\"type\":\"@Library\",\"fixedId\":"
- "true,\"id\":\"\",\"name\":\"dart.collection\",\"uri\":\"dart:"
- "collection\"}},\"identityHashCode\":0,\"kind\":\"Map\",\"id\":\"\","
- "\"length\":0}",
+ "\"id\":\"\",\"uri\":\"dart:collection-patch\\/compact_hash.dart\",\"_"
+ "kind\":\"kernel\"}},"
+ "\"library\":{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\","
+ "\"name\":\"dart.collection\",\"uri\":\"dart:collection\"}},"
+ "\"identityHashCode\":0,\"kind\":\"Map\",\"id\":\"\",\"length\":0}",
buffer);
}
// UserTag reference
@@ -4609,13 +4616,15 @@
ElideJSONSubstring("objects", buffer, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
ElideJSONSubstring("_UserTag@", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_SUBSTRING(
"\"type\":\"@Instance\",\"_vmType\":\"UserTag\",\"class\":{\"type\":\"@"
"Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_UserTag\",\"_"
"vmName\":\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{"
"\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:"
- "developer-patch\\/profiler.dart\",\"_kind\":\"kernel\"},\"tokenPos\":"
- "414,\"endTokenPos\":628},\"library\":{\"type\":\"@Library\","
+ "developer-patch\\/"
+ "profiler.dart\",\"_kind\":\"kernel\"}},\"library\":{\"type\":\"@"
+ "Library\","
"\"fixedId\":true,\"id\":\"\",\"name\":\"dart.developer\",\"uri\":"
"\"dart:developer\"}},"
// Handle non-zero identity hash.
@@ -4639,13 +4648,14 @@
ElideJSONSubstring("objects", buffer, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
ElideJSONSubstring("_Type@", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_SUBSTRING(
"{\"type\":\"@Instance\",\"_vmType\":\"Type\",\"class\":{\"type\":\"@"
"Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_Type\",\"_vmName\":"
"\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":"
"\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-"
- "patch\\/type_patch.dart\",\"_kind\":\"kernel\"},\"tokenPos\":493,"
- "\"endTokenPos\":898},\"library\":{\"type\":\"@Library\",\"fixedId\":"
+ "patch\\/type_patch.dart\",\"_kind\":\"kernel\"}"
+ "},\"library\":{\"type\":\"@Library\",\"fixedId\":"
"true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
// Handle non-zero identity hash.
"\"identityHashCode\":",
@@ -4656,8 +4666,8 @@
"\"typeClass\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
"\"name\":\"bool\",\"location\":{\"type\":\"SourceLocation\","
"\"script\":{\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":"
- "\"dart:core\\/bool.dart\",\"_kind\":\"kernel\"},\"tokenPos\":436,"
- "\"endTokenPos\":4432},\"library\":{\"type\":\"@Library\",\"fixedId\":"
+ "\"dart:core\\/bool.dart\",\"_kind\":\"kernel\"}"
+ "},\"library\":{\"type\":\"@Library\",\"fixedId\":"
"true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
"\"name\":\"bool\"}",
buffer);
@@ -4670,12 +4680,13 @@
ASSERT(strlen(json_str) < kBufferSize);
ElideJSONSubstring("classes", json_str, buffer);
ElideJSONSubstring("libraries", buffer, buffer);
+ StripTokenPositions(buffer);
EXPECT_STREQ(
"{\"type\":\"@Instance\",\"_vmType\":\"null\",\"class\":{\"type\":\"@"
"Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"Null\",\"location\":{"
"\"type\":\"SourceLocation\",\"script\":{\"type\":\"@Script\","
"\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core\\/null.dart\",\"_"
- "kind\":\"kernel\"},\"tokenPos\":925,\"endTokenPos\":1165},\"library\":"
+ "kind\":\"kernel\"}},\"library\":"
"{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\",\"name\":\"dart."
"core\",\"uri\":\"dart:core\"}},\"kind\":\"Null\",\"fixedId\":true,"
"\"id\":\"objects\\/null\",\"valueAsString\":\"null\"}",
diff --git a/runtime/vm/unit_test.cc b/runtime/vm/unit_test.cc
index a4de697..b710b2a 100644
--- a/runtime/vm/unit_test.cc
+++ b/runtime/vm/unit_test.cc
@@ -415,50 +415,50 @@
bool finalize_classes,
bool allow_compile_errors) {
#ifndef PRODUCT
- if (strstr(script, IsolateReloadTestLibUri()) != NULL) {
- Dart_Handle result = LoadIsolateReloadTestLib();
- EXPECT_VALID(result);
- }
+ if (strstr(script, IsolateReloadTestLibUri()) != NULL) {
+ Dart_Handle result = LoadIsolateReloadTestLib();
+ EXPECT_VALID(result);
+ }
#endif // ifndef PRODUCT
- Dart_SourceFile* sourcefiles = NULL;
- intptr_t num_sources = BuildSourceFilesArray(&sourcefiles, script, lib_url);
- Dart_Handle result =
- LoadTestScriptWithDFE(num_sources, sourcefiles, resolver,
- finalize_classes, true, allow_compile_errors);
- delete[] sourcefiles;
- return result;
+ Dart_SourceFile* sourcefiles = NULL;
+ intptr_t num_sources = BuildSourceFilesArray(&sourcefiles, script, lib_url);
+ Dart_Handle result =
+ LoadTestScriptWithDFE(num_sources, sourcefiles, resolver,
+ finalize_classes, true, allow_compile_errors);
+ delete[] sourcefiles;
+ return result;
}
Dart_Handle TestCase::LoadTestLibrary(const char* lib_uri,
const char* script,
Dart_NativeEntryResolver resolver) {
- const char* prefixed_lib_uri =
- OS::SCreate(Thread::Current()->zone(), "file:///%s", lib_uri);
- Dart_SourceFile sourcefiles[] = {{prefixed_lib_uri, script}};
- const uint8_t* kernel_buffer = NULL;
- intptr_t kernel_buffer_size = 0;
- int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile);
- char* error = TestCase::CompileTestScriptWithDFE(
- sourcefiles[0].uri, sourcefiles_count, sourcefiles, &kernel_buffer,
- &kernel_buffer_size, true);
- if ((kernel_buffer == NULL) && (error != NULL)) {
- return Dart_NewApiError(error);
- }
- Dart_Handle lib =
- Dart_LoadLibraryFromKernel(kernel_buffer, kernel_buffer_size);
- EXPECT_VALID(lib);
+ const char* prefixed_lib_uri =
+ OS::SCreate(Thread::Current()->zone(), "file:///%s", lib_uri);
+ Dart_SourceFile sourcefiles[] = {{prefixed_lib_uri, script}};
+ const uint8_t* kernel_buffer = NULL;
+ intptr_t kernel_buffer_size = 0;
+ int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile);
+ char* error = TestCase::CompileTestScriptWithDFE(
+ sourcefiles[0].uri, sourcefiles_count, sourcefiles, &kernel_buffer,
+ &kernel_buffer_size, true);
+ if ((kernel_buffer == NULL) && (error != NULL)) {
+ return Dart_NewApiError(error);
+ }
+ Dart_Handle lib =
+ Dart_LoadLibraryFromKernel(kernel_buffer, kernel_buffer_size);
+ EXPECT_VALID(lib);
- // Ensure kernel buffer isn't leaked after test is run.
- AddToKernelBuffers(kernel_buffer);
+ // Ensure kernel buffer isn't leaked after test is run.
+ AddToKernelBuffers(kernel_buffer);
- // TODO(32618): Kernel doesn't correctly represent the root library.
- lib = Dart_LookupLibrary(Dart_NewStringFromCString(sourcefiles[0].uri));
- EXPECT_VALID(lib);
- Dart_Handle result = Dart_SetRootLibrary(lib);
- EXPECT_VALID(result);
+ // TODO(32618): Kernel doesn't correctly represent the root library.
+ lib = Dart_LookupLibrary(Dart_NewStringFromCString(sourcefiles[0].uri));
+ EXPECT_VALID(lib);
+ Dart_Handle result = Dart_SetRootLibrary(lib);
+ EXPECT_VALID(result);
- Dart_SetNativeResolver(lib, resolver, NULL);
- return lib;
+ Dart_SetNativeResolver(lib, resolver, NULL);
+ return lib;
}
Dart_Handle TestCase::LoadTestScriptWithDFE(int sourcefiles_count,
@@ -584,19 +584,19 @@
}
Dart_Handle TestCase::ReloadTestScript(const char* script) {
- Dart_SourceFile* sourcefiles = NULL;
- intptr_t num_files = BuildSourceFilesArray(&sourcefiles, script);
- Dart_KernelCompilationResult compilation_result =
- KernelIsolate::UpdateInMemorySources(num_files, sourcefiles);
- delete[] sourcefiles;
- if (compilation_result.status != Dart_KernelCompilationStatus_Ok) {
- Dart_Handle result = Dart_NewApiError(compilation_result.error);
- free(compilation_result.error);
- if (compilation_result.kernel != NULL) {
- free(const_cast<uint8_t*>(compilation_result.kernel));
- }
- return result;
+ Dart_SourceFile* sourcefiles = NULL;
+ intptr_t num_files = BuildSourceFilesArray(&sourcefiles, script);
+ Dart_KernelCompilationResult compilation_result =
+ KernelIsolate::UpdateInMemorySources(num_files, sourcefiles);
+ delete[] sourcefiles;
+ if (compilation_result.status != Dart_KernelCompilationStatus_Ok) {
+ Dart_Handle result = Dart_NewApiError(compilation_result.error);
+ free(compilation_result.error);
+ if (compilation_result.kernel != NULL) {
+ free(const_cast<uint8_t*>(compilation_result.kernel));
}
+ return result;
+ }
return TriggerReload(/* kernel_buffer= */ NULL, /* kernel_buffer_size= */ 0);
}
@@ -727,7 +727,10 @@
return result.IsCode();
}
-void ElideJSONSubstring(const char* prefix, const char* in, char* out) {
+void ElideJSONSubstring(const char* prefix,
+ const char* in,
+ char* out,
+ const char* postfix) {
const char* pos = strstr(in, prefix);
while (pos != NULL) {
// Copy up to pos into the output buffer.
@@ -735,8 +738,9 @@
*out++ = *in++;
}
- // Skip to the close quote.
- in += strcspn(in, "\"");
+ // Skip to the closing postfix.
+ in += strlen(prefix);
+ in += strcspn(in, postfix);
pos = strstr(in, prefix);
}
// Copy the remainder of in to out.
@@ -746,4 +750,9 @@
*out = '\0';
}
+void StripTokenPositions(char* buffer) {
+ ElideJSONSubstring(",\"tokenPos\":", buffer, buffer, ",");
+ ElideJSONSubstring(",\"endTokenPos\":", buffer, buffer, "}");
+}
+
} // namespace dart
diff --git a/runtime/vm/unit_test.h b/runtime/vm/unit_test.h
index 025f8cd..7bc9f23 100644
--- a/runtime/vm/unit_test.h
+++ b/runtime/vm/unit_test.h
@@ -676,7 +676,9 @@
} \
} while (0)
-// Elide a substring which starts with some prefix and ends with a ".
+// Elide a substring which starts with some prefix and ends with some postfix.
+//
+// Prefix is inclusive, postfix is exclusive.
//
// This is used to remove non-deterministic or fragile substrings from
// JSON output.
@@ -691,7 +693,17 @@
// out = "\"id\":\"\""
//
// WARNING: This function is not safe to use if `in` is bigger than `out`!
-void ElideJSONSubstring(const char* prefix, const char* in, char* out);
+void ElideJSONSubstring(const char* prefix,
+ const char* in,
+ char* out,
+ const char* postfix = "\"");
+
+// Elide a substrings such as ",\"tokenPos\":4372,\"endTokenPos\":4430".
+//
+// Substring to be followed by "}".
+//
+// Modifies buffer in place.
+void StripTokenPositions(char* buffer);
template <typename T>
class SetFlagScope : public ValueObject {
diff --git a/runtime/vm/utils_test.cc b/runtime/vm/utils_test.cc
index 2b0369f..ba4e296 100644
--- a/runtime/vm/utils_test.cc
+++ b/runtime/vm/utils_test.cc
@@ -290,26 +290,22 @@
EXPECT(!Utils::IsUint(32, 4294967296LL));
}
-VM_UNIT_TEST_CASE(MagnitudeIsUint) {
- EXPECT(Utils::MagnitudeIsUint(8, 16));
- EXPECT(Utils::MagnitudeIsUint(8, 0));
- EXPECT(Utils::MagnitudeIsUint(8, -128));
- EXPECT(Utils::MagnitudeIsUint(8, 255));
- EXPECT(!Utils::MagnitudeIsUint(8, 256));
- EXPECT(Utils::MagnitudeIsUint(12, 4095));
- EXPECT(Utils::MagnitudeIsUint(12, -4095));
- EXPECT(!Utils::MagnitudeIsUint(12, 4096));
- EXPECT(!Utils::MagnitudeIsUint(12, -4096));
- EXPECT(Utils::MagnitudeIsUint(16, 16));
- EXPECT(Utils::MagnitudeIsUint(16, 0));
- EXPECT(Utils::MagnitudeIsUint(16, 65535));
- EXPECT(Utils::MagnitudeIsUint(16, -32768));
- EXPECT(!Utils::MagnitudeIsUint(16, 65536));
- EXPECT(Utils::MagnitudeIsUint(32, 16LL));
- EXPECT(Utils::MagnitudeIsUint(32, 0LL));
- EXPECT(Utils::MagnitudeIsUint(32, -2147483648LL));
- EXPECT(Utils::MagnitudeIsUint(32, 4294967295LL));
- EXPECT(!Utils::MagnitudeIsUint(32, 4294967296LL));
+VM_UNIT_TEST_CASE(IsAbsoluteUint) {
+ EXPECT(Utils::IsAbsoluteUint(8, 16));
+ EXPECT(Utils::IsAbsoluteUint(8, 0));
+ EXPECT(Utils::IsAbsoluteUint(8, -128));
+ EXPECT(Utils::IsAbsoluteUint(8, 255));
+ EXPECT(!Utils::IsAbsoluteUint(8, 256));
+ EXPECT(Utils::IsAbsoluteUint(16, 16));
+ EXPECT(Utils::IsAbsoluteUint(16, 0));
+ EXPECT(Utils::IsAbsoluteUint(16, 65535));
+ EXPECT(Utils::IsAbsoluteUint(16, -32768));
+ EXPECT(!Utils::IsAbsoluteUint(16, 65536));
+ EXPECT(Utils::IsAbsoluteUint(32, 16LL));
+ EXPECT(Utils::IsAbsoluteUint(32, 0LL));
+ EXPECT(Utils::IsAbsoluteUint(32, -2147483648LL));
+ EXPECT(Utils::IsAbsoluteUint(32, 4294967295LL));
+ EXPECT(!Utils::IsAbsoluteUint(32, 4294967296LL));
}
VM_UNIT_TEST_CASE(LowBits) {
diff --git a/tools/VERSION b/tools/VERSION
index e5f179c..f206cb0 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 287
+PRERELEASE 288
PRERELEASE_PATCH 0
\ No newline at end of file