@@ -131,6 +131,7 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
131131 Uri packagesFile,
132132 Uri librariesSpecificationUri,
133133 List <Uri > inputSummaries,
134+ Map <Uri , List <int >> workerInputDigests,
134135 Target target,
135136 {FileSystem fileSystem,
136137 Map <ExperimentalFlag , bool > experiments}) async {
@@ -143,12 +144,18 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
143144
144145 Map <Uri , WorkerInputComponent > workerInputCache =
145146 oldState? .workerInputCache ?? new Map <Uri , WorkerInputComponent >();
147+ var sdkDigest = workerInputDigests[sdkSummary];
148+ if (sdkDigest == null ) {
149+ throw new StateError ("Expected to get sdk digest at $cachedSdkInput " );
150+ }
151+
146152 cachedSdkInput = workerInputCache[sdkSummary];
147153
148154 if (oldState == null ||
149155 oldState.incrementalCompiler == null ||
150156 oldState.options.compileSdk != compileSdk ||
151- cachedSdkInput == null ) {
157+ cachedSdkInput == null ||
158+ ! digestsEqual (cachedSdkInput.digest, sdkDigest)) {
152159 // No previous state.
153160 options = new CompilerOptions ()
154161 ..compileSdk = compileSdk
@@ -166,8 +173,8 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
166173
167174 processedOpts = new ProcessedOptions (options: options);
168175
169- cachedSdkInput = new WorkerInputComponent (null /* not compared anyway */ ,
170- await processedOpts.loadSdkSummary (null ));
176+ cachedSdkInput = new WorkerInputComponent (
177+ sdkDigest, await processedOpts.loadSdkSummary (null ));
171178 workerInputCache[sdkSummary] = cachedSdkInput;
172179 incrementalCompiler = new IncrementalCompiler .fromComponent (
173180 new CompilerContext (processedOpts), cachedSdkInput.component);
@@ -207,10 +214,13 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
207214 for (int i = 0 ; i < inputSummaries.length; i++ ) {
208215 Uri inputSummary = inputSummaries[i];
209216 WorkerInputComponent cachedInput = workerInputCache[inputSummary];
217+ var digest = workerInputDigests[inputSummary];
218+ if (digest == null ) {
219+ throw new StateError ("Expected to get digest for $inputSummary " );
220+ }
210221 if (cachedInput == null ||
211222 cachedInput.component.root != nameRoot ||
212- ! digestsEqual (await fileSystem.entityForUri (inputSummary).readAsBytes (),
213- cachedInput.digest)) {
223+ ! digestsEqual (digest, cachedInput.digest)) {
214224 loadFromDillIndexes.add (i);
215225 } else {
216226 // Need to reset cached components so they are usable again.
@@ -226,11 +236,15 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
226236 for (int i = 0 ; i < loadFromDillIndexes.length; i++ ) {
227237 int index = loadFromDillIndexes[i];
228238 Uri summary = inputSummaries[index];
229- List <int > data = await fileSystem.entityForUri (summary).readAsBytes ();
239+ List <int > digest = workerInputDigests[summary];
240+ if (digest == null ) {
241+ throw new StateError ("Expected to get digest for $summary " );
242+ }
243+ var bytes = await fileSystem.entityForUri (summary).readAsBytes ();
230244 WorkerInputComponent cachedInput = WorkerInputComponent (
231- data ,
245+ digest ,
232246 await compilerState.processedOpts
233- .loadComponent (data , nameRoot, alwaysCreateNewNamedNodes: true ));
247+ .loadComponent (bytes , nameRoot, alwaysCreateNewNamedNodes: true ));
234248 workerInputCache[summary] = cachedInput;
235249 doneInputSummaries[index] = cachedInput.component;
236250 }
0 commit comments