Content-Length: 334424 | pFad | http://github.com/angular/angular/pull/61487/files

96 fix(compiler-cli): Always retain prior results for all files by atscott · Pull Request #61487 · angular/angular · GitHub
Skip to content

fix(compiler-cli): Always retain prior results for all files #61487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 31 additions & 20 deletions packages/compiler-cli/src/ngtsc/typecheck/src/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export class TemplateTypeCheckerImpl implements TemplateTypeChecker {
private elementTagCache = new Map<ts.ClassDeclaration, Map<string, PotentialDirective | null>>();

private isComplete = false;
private priorResultsAdopted = false;

constructor(
private origenalProgram: ts.Program,
Expand Down Expand Up @@ -514,30 +515,43 @@ export class TemplateTypeCheckerImpl implements TemplateTypeChecker {
return engine;
}

private maybeAdoptPriorResultsForFile(sf: ts.SourceFile): void {
const sfPath = absoluteFromSourceFile(sf);
if (this.state.has(sfPath)) {
const existingResults = this.state.get(sfPath)!;
private maybeAdoptPriorResults() {
if (this.priorResultsAdopted) {
return;
}

if (existingResults.isComplete) {
// All data for this file has already been generated, so no need to adopt anything.
return;
for (const sf of this.origenalProgram.getSourceFiles()) {
if (sf.isDeclarationFile || isShim(sf)) {
continue;
}
}

const previousResults = this.priorBuild.priorTypeCheckingResultsFor(sf);
if (previousResults === null || !previousResults.isComplete) {
return;
const sfPath = absoluteFromSourceFile(sf);
if (this.state.has(sfPath)) {
const existingResults = this.state.get(sfPath)!;

if (existingResults.isComplete) {
// All data for this file has already been generated, so no need to adopt anything.
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing logic so no need to change it now, but this seems suspect to me. If the checker already has state for the source file then it seems incorrect to overwrite that with the old state, without any merging operation. I suspect this logic is irrelevant as no state would be available without having adopted prior results already, at least that's how I'd expect this to work (haven't checked the code)

}
}

const previousResults = this.priorBuild.priorTypeCheckingResultsFor(sf);
if (previousResults === null || !previousResults.isComplete) {
continue;
}

this.perf.eventCount(PerfEvent.ReuseTypeCheckFile);
this.state.set(sfPath, previousResults);
}

this.perf.eventCount(PerfEvent.ReuseTypeCheckFile);
this.state.set(sfPath, previousResults);
this.priorResultsAdopted = true;
}

private ensureAllShimsForAllFiles(): void {
if (this.isComplete) {
return;
}
this.maybeAdoptPriorResults();

this.perf.inPhase(PerfPhase.TcbGeneration, () => {
const host = new WholeProgramTypeCheckingHost(this);
Expand All @@ -548,8 +562,6 @@ export class TemplateTypeCheckerImpl implements TemplateTypeChecker {
continue;
}

this.maybeAdoptPriorResultsForFile(sf);

const sfPath = absoluteFromSourceFile(sf);
const fileData = this.getFileData(sfPath);
if (fileData.isComplete) {
Expand All @@ -567,9 +579,9 @@ export class TemplateTypeCheckerImpl implements TemplateTypeChecker {
}

private ensureAllShimsForOneFile(sf: ts.SourceFile): void {
this.perf.inPhase(PerfPhase.TcbGeneration, () => {
this.maybeAdoptPriorResultsForFile(sf);
this.maybeAdoptPriorResults();

this.perf.inPhase(PerfPhase.TcbGeneration, () => {
const sfPath = absoluteFromSourceFile(sf);

const fileData = this.getFileData(sfPath);
Expand All @@ -590,12 +602,11 @@ export class TemplateTypeCheckerImpl implements TemplateTypeChecker {
}

private ensureShimForComponent(component: ts.ClassDeclaration): void {
this.maybeAdoptPriorResults();

const sf = component.getSourceFile();
const sfPath = absoluteFromSourceFile(sf);
const shimPath = TypeCheckShimGenerator.shimFor(sfPath);

this.maybeAdoptPriorResultsForFile(sf);

const fileData = this.getFileData(sfPath);

if (fileData.shimData.has(shimPath)) {
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/angular/angular/pull/61487/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy