[ddc] Fix google3 null safety migration break
The code path exercised here is used in google3 and expects
a list of preallocated size.
Change-Id: I807603a8bddb1bfead8f3377df4a6252949a8c3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249545
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index fd18c76..becb100 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -265,12 +265,15 @@
var compileSdk = argResults['compile-sdk'] == true;
var oldCompilerState = compilerState;
- var doneAdditionalDills = <Component>[];
- fe.IncrementalCompiler? incrementalCompiler;
- fe.WorkerInputComponent? cachedSdkInput;
var recordUsedInputs = argResults['used-inputs-file'] != null;
var additionalDills = summaryModules.keys.toList();
+ fe.DdcResult? result;
+ // TODO(jmesserly): is there a cleaner way to do this?
+ //
+ // Ideally we'd manage our own batch compilation caching rather than rely on
+ // `initializeCompiler`. Also we should be able to pass down Components for
+ // SDK and summaries.
if (!useIncrementalCompiler) {
compilerState = fe.initializeCompiler(
oldCompilerState,
@@ -288,6 +291,7 @@
environmentDefines: declaredVariables,
nnbdMode:
options.soundNullSafety ? fe.NnbdMode.Strong : fe.NnbdMode.Weak);
+ result = await fe.compile(compilerState, inputs, diagnosticMessageHandler);
} else {
// If digests weren't given and if not in worker mode, create fake data and
// ensure we don't have a previous state (as that wouldn't be safe with
@@ -303,6 +307,8 @@
inputDigests[uri] = const [0];
}
}
+ var doneAdditionalDills =
+ List.filled(summaryModules.length, dummyComponent);
compilerState = await fe.initializeIncrementalCompiler(
oldCompilerState,
{
@@ -327,29 +333,17 @@
trackNeededDillLibraries: recordUsedInputs,
nnbdMode:
options.soundNullSafety ? fe.NnbdMode.Strong : fe.NnbdMode.Weak);
- incrementalCompiler = compilerState.incrementalCompiler;
- cachedSdkInput =
+ var incrementalCompiler = compilerState.incrementalCompiler!;
+ var cachedSdkInput =
compilerState.workerInputCache![sourcePathToUri(sdkSummaryPath)];
- }
-
- // TODO(jmesserly): is there a cleaner way to do this?
- //
- // Ideally we'd manage our own batch compilation caching rather than rely on
- // `initializeCompiler`. Also we should be able to pass down Components for
- // SDK and summaries.
- //
- fe.DdcResult? result;
- if (!useIncrementalCompiler) {
- result = await fe.compile(compilerState, inputs, diagnosticMessageHandler);
- } else {
compilerState.options.onDiagnostic = diagnosticMessageHandler;
- var incrementalCompilerResult = await incrementalCompiler!.computeDelta(
+ var incrementalCompilerResult = await incrementalCompiler.computeDelta(
entryPoints: inputs,
fullComponent: true,
trackNeededDillLibraries: recordUsedInputs);
result = fe.DdcResult(
incrementalCompilerResult.component,
- cachedSdkInput!.component,
+ cachedSdkInput?.component,
doneAdditionalDills,
incrementalCompilerResult.classHierarchy!,
incrementalCompilerResult.neededDillLibraries);