Skip to content

Commit

Permalink
Automated rollback of 6116456
Browse files Browse the repository at this point in the history
Breaks some internal projects.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175847055
  • Loading branch information
dimvar authored and Tyler Breisacher committed Nov 15, 2017
1 parent bead661 commit da76dd3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
14 changes: 6 additions & 8 deletions src/com/google/javascript/jscomp/DefaultPassConfig.java
Expand Up @@ -183,8 +183,7 @@ protected List<PassFactory> getTranspileOnlyPasses() {
// can be removed.
if (options.needsTranspilationFrom(ES6) || options.needsTranspilationFrom(ES7)) {
TranspilationPasses.addEs6EarlyPasses(passes);
TranspilationPasses.addEs6LatePassesBeforeNti(passes);
TranspilationPasses.addEs6LatePassesAfterNti(passes);
TranspilationPasses.addEs6LatePasses(passes);
TranspilationPasses.addPostCheckPasses(passes);
if (options.rewritePolyfills) {
TranspilationPasses.addRewritePolyfillPass(passes);
Expand Down Expand Up @@ -395,9 +394,10 @@ protected List<PassFactory> getChecks() {
}

if (options.needsTranspilationFrom(ES6)) {
TranspilationPasses.addEs6LatePassesBeforeNti(checks);
if (!options.getTypeCheckEs6Natively()) {
TranspilationPasses.addEs6LatePassesAfterNti(checks);
if (options.getTypeCheckEs6Natively()) {
TranspilationPasses.addEs6PassesBeforeNTI(checks);
} else {
TranspilationPasses.addEs6LatePasses(checks);
}
}

Expand Down Expand Up @@ -437,9 +437,7 @@ protected List<PassFactory> getChecks() {
}

if (options.needsTranspilationFrom(ES6)) {
if (options.getTypeCheckEs6Natively()) {
TranspilationPasses.addEs6LatePassesAfterNti(checks);
}
TranspilationPasses.addEs6PassesAfterNTI(checks);
checks.add(setFeatureSet(options.getLanguageOut().toFeatureSet()));
}
}
Expand Down
17 changes: 14 additions & 3 deletions src/com/google/javascript/jscomp/TranspilationPasses.java
Expand Up @@ -60,24 +60,35 @@ public static void addEs6EarlyPasses(List<PassFactory> passes) {
passes.add(es6RewriteArrowFunction);
}

/** Adds all the late ES6 transpilation passes, which go after the Dart pass */
public static void addEs6LatePasses(List<PassFactory> passes) {
// TODO(b/64811685): Delete this method and use addEs6PassesBeforeNTI and addEs6PassesAfterNTI.
passes.add(es6ExtractClasses);
passes.add(es6RewriteClass);
passes.add(earlyConvertEs6ToEs3);
passes.add(lateConvertEs6ToEs3);
passes.add(rewriteBlockScopedDeclaration);
passes.add(rewriteGenerators);
}

/**
* Adds all the late ES6 transpilation passes, which go after the Dart pass
* and go before TypeChecking.
* and go before TypeChecking
*
* <p>Includes ES6 features that are best handled natively by the compiler.
* As we convert more passes to handle these features, we will be moving the
* transpilation later in the compilation, and eventually only transpiling
* when the output is lower than ES6.
*/
public static void addEs6LatePassesBeforeNti(List<PassFactory> passes) {
public static void addEs6PassesBeforeNTI(List<PassFactory> passes) {
passes.add(es6ExtractClasses);
passes.add(es6RewriteClass);
passes.add(earlyConvertEs6ToEs3);
passes.add(rewriteBlockScopedDeclaration);
}

/** Adds all transpilation passes that runs after NTI */
public static void addEs6LatePassesAfterNti(List<PassFactory> passes) {
public static void addEs6PassesAfterNTI(List<PassFactory> passes) {
passes.add(lateConvertEs6ToEs3);
passes.add(rewriteGenerators);
}
Expand Down
3 changes: 1 addition & 2 deletions test/com/google/javascript/jscomp/CompilerTestCase.java
Expand Up @@ -1786,8 +1786,7 @@ private static void transpileToEs5(AbstractCompiler compiler, Node externsRoot,
TranspilationPasses.addEs2017Passes(factories);
TranspilationPasses.addEs2016Passes(factories);
TranspilationPasses.addEs6EarlyPasses(factories);
TranspilationPasses.addEs6LatePassesBeforeNti(factories);
TranspilationPasses.addEs6LatePassesAfterNti(factories);
TranspilationPasses.addEs6LatePasses(factories);
TranspilationPasses.addRewritePolyfillPass(factories);
for (PassFactory factory : factories) {
factory.create(compiler).process(externsRoot, codeRoot);
Expand Down
Expand Up @@ -254,17 +254,17 @@ private void parseAndTypeCheck(String externs, String js) {
TranspilationPasses.addEs2017Passes(passes);
TranspilationPasses.addEs2016Passes(passes);
TranspilationPasses.addEs6EarlyPasses(passes);
TranspilationPasses.addEs6LatePassesBeforeNti(passes);
TranspilationPasses.addEs6PassesBeforeNTI(passes);
if (!compilerOptions.getTypeCheckEs6Natively()) {
TranspilationPasses.addEs6LatePassesAfterNti(passes);
TranspilationPasses.addEs6PassesAfterNTI(passes);
TranspilationPasses.addRewritePolyfillPass(passes);
}
}
passes.add(makePassFactory("GlobalTypeInfo", new GlobalTypeInfoCollector(compiler)));
passes.add(makePassFactory("NewTypeInference", new NewTypeInference(compiler)));
if (compilerOptions.needsTranspilationFrom(FeatureSet.ES6)
&& compilerOptions.getTypeCheckEs6Natively()) {
TranspilationPasses.addEs6LatePassesAfterNti(passes);
TranspilationPasses.addEs6PassesAfterNTI(passes);
TranspilationPasses.addRewritePolyfillPass(passes);
}

Expand Down
3 changes: 1 addition & 2 deletions test/com/google/javascript/jscomp/TypeCheckTest.java
Expand Up @@ -17997,8 +17997,7 @@ private TypeCheckResult parseAndTypeCheckWithScope(String externs, String js) {
TranspilationPasses.addEs2017Passes(passes);
TranspilationPasses.addEs2016Passes(passes);
TranspilationPasses.addEs6EarlyPasses(passes);
TranspilationPasses.addEs6LatePassesBeforeNti(passes);
TranspilationPasses.addEs6LatePassesAfterNti(passes);
TranspilationPasses.addEs6LatePasses(passes);
TranspilationPasses.addRewritePolyfillPass(passes);
PhaseOptimizer phaseopt = new PhaseOptimizer(compiler, null);
phaseopt.consume(passes);
Expand Down

0 comments on commit da76dd3

Please sign in to comment.