Skip to content

Commit

Permalink
Factor out the part that enables the old type checker, so that it can be
Browse files Browse the repository at this point in the history
enabled by NTI later in the compilation.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123432813
  • Loading branch information
dimvar authored and blickly committed May 27, 2016
1 parent fa0d314 commit 4a21a1a
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/com/google/javascript/jscomp/DefaultPassConfig.java
Expand Up @@ -202,6 +202,25 @@ protected List<PassFactory> getWhitespaceOnlyPasses() {
return passes;
}

private void addOldTypeCheckerPasses(
List<PassFactory> checks, CompilerOptions options) {
if (options.checkTypes || options.inferTypes) {
checks.add(resolveTypes);
checks.add(inferTypes);
if (options.checkTypes) {
checks.add(checkTypes);
} else {
checks.add(inferJsDocInfo);
}

// We assume that only clients who don't run optimizations will try to
// query the typed scope creator after the compile job.
if (!options.preservesDetailedSourceInfo()) {
checks.add(clearTypedScopePass);
}
}
}

@Override
protected List<PassFactory> getChecks() {
List<PassFactory> checks = new ArrayList<>();
Expand Down Expand Up @@ -359,20 +378,14 @@ protected List<PassFactory> getChecks() {

checks.add(inlineTypeAliases);

if (options.checkTypes || options.inferTypes) {
checks.add(resolveTypes);
checks.add(inferTypes);
if (options.checkTypes) {
checks.add(checkTypes);
} else {
checks.add(inferJsDocInfo);
}
if (!options.getNewTypeInference()) {
addOldTypeCheckerPasses(checks, options);
}

// We assume that only IDE-mode clients will try to query the
// typed scope creator after the compile job.
if (!options.preservesDetailedSourceInfo()) {
checks.add(clearTypedScopePass);
}
// NOTE(dimvar): This will move later into the checks as we convert checks
// to handle types from the new type inference
if (options.getNewTypeInference()) {
addOldTypeCheckerPasses(checks, options);
}

if (options.generateExportsAfterTypeChecking && options.generateExports) {
Expand Down

0 comments on commit 4a21a1a

Please sign in to comment.