Skip to content

Commit

Permalink
Remove DefaultPassConfig logic for doing NTI on partially transpiled …
Browse files Browse the repository at this point in the history
…code

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188263951
  • Loading branch information
brad4d authored and lauraharker committed Mar 9, 2018
1 parent 900e214 commit 65880b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 34 deletions.
35 changes: 5 additions & 30 deletions src/com/google/javascript/jscomp/DefaultPassConfig.java
Expand Up @@ -383,21 +383,15 @@ protected List<PassFactory> getChecks() {
TranspilationPasses.addEs2017Passes(checks);
}

if (options.needsTranspilationFrom(ES7) && !options.getTypeCheckEs6Natively()) {
if (options.needsTranspilationFrom(ES7)) {
TranspilationPasses.addEs2016Passes(checks);
}

if (options.needsTranspilationFrom(ES6)) {
checks.add(es6ExternsCheck);
TranspilationPasses.addEs6EarlyPasses(checks);
}

if (options.needsTranspilationFrom(ES6)) {
if (options.getTypeCheckEs6Natively()) {
TranspilationPasses.addEs6PassesBeforeNTI(checks);
} else {
TranspilationPasses.addEs6LatePasses(checks);
}
// TODO(bradfordcsmith): Combine early and late passes into a single method.
TranspilationPasses.addEs6LatePasses(checks);
}

if (options.rewritePolyfills && !options.checksOnly) {
Expand All @@ -412,23 +406,6 @@ protected List<PassFactory> getChecks() {
checks.add(convertStaticInheritance);
}

// End of ES6 transpilation passes before NTI.

if (options.getTypeCheckEs6Natively()) {
if (!options.skipNonTranspilationPasses) {
checks.add(createEmptyPass(PassNames.BEFORE_TYPE_CHECKING));
addNewTypeCheckerPasses(checks, options);
}

if (options.needsTranspilationFrom(ES7)) {
TranspilationPasses.addEs2016Passes(checks);
}

if (options.needsTranspilationFrom(ES6)) {
TranspilationPasses.addEs6PassesAfterNTI(checks);
}
}

if (!options.skipNonTranspilationPasses) {
addNonTranspilationCheckPasses(checks);
}
Expand Down Expand Up @@ -466,10 +443,8 @@ protected List<PassFactory> getChecks() {
}

private void addNonTranspilationCheckPasses(List<PassFactory> checks) {
if (!options.getTypeCheckEs6Natively()) {
checks.add(createEmptyPass(PassNames.BEFORE_TYPE_CHECKING));
addNewTypeCheckerPasses(checks, options);
}
checks.add(createEmptyPass(PassNames.BEFORE_TYPE_CHECKING));
addNewTypeCheckerPasses(checks, options);

if (!options.getNewTypeInference()) {
addOldTypeCheckerPasses(checks, options);
Expand Down
19 changes: 15 additions & 4 deletions test/com/google/javascript/jscomp/TranspileAfterNTITest.java
Expand Up @@ -28,6 +28,13 @@

/**
* Integration tests that check types of nodes are correct after running transpilation after NTI.
*
* TODO(b/72551201): Remove this entire test class once NTI is completely removed.
*
* Some of the test cases are already disabled, because we've removed the logic from
* DefaultPassConfig that allows for running NTI before (some parts of) transpilation.
* They aren't deleted, because they may serve as good models for test cases on OTI as we update it
* to understand the language features tested here.
*/
public final class TranspileAfterNTITest extends IntegrationTestCase {

Expand Down Expand Up @@ -139,7 +146,8 @@ public void testMemberFunctionDef() {
assertType(s.getFirstFirstChild().getTypeI()).toStringIsEqualTo("function(number): string");
}

public void testComputedProp1() {
// See class javadoc for why this is disabled.
public void disabledTestComputedProp1() {
Node root =
typeInfoCheckAndGetRoot(
LINE_JOINER.join(
Expand Down Expand Up @@ -175,7 +183,8 @@ public void testComputedProp1() {
assertType(firstName.getTypeI()).isString();
}

public void testComputedProp2() {
// See class javadoc for why this is disabled.
public void disabledTestComputedProp2() {
Node root =
typeInfoCheckAndGetRoot(
"var i = 1; var obj = {'a': i , [i + 1]: 1};",
Expand Down Expand Up @@ -329,7 +338,8 @@ public void testTemplateString() {
assertType(template.getFirstFirstChild().getSecondChild().getTypeI()).isNumber();
}

public void testTaggedTemplate1() {
// See class javadoc for why this is disabled.
public void disabledTestTaggedTemplate1() {
Node root =
typeInfoCheckAndGetRoot(
LINE_JOINER.join(
Expand Down Expand Up @@ -370,7 +380,8 @@ public void testTaggedTemplate1() {
assertType(s.getFirstFirstChild().getChildAtIndex(2).getTypeI()).isNumber();
}

public void testTaggedTemplate2() {
// See class javadoc for why this is disabled.
public void disabledTestTaggedTemplate2() {
Node root =
typeInfoCheckAndGetRoot(
LINE_JOINER.join(
Expand Down

0 comments on commit 65880b8

Please sign in to comment.