From 4b6d65e7b2ee827e3f7f3ee62731ebda537958f5 Mon Sep 17 00:00:00 2001 From: bradfordcsmith Date: Tue, 20 Nov 2018 10:11:11 -0800 Subject: [PATCH] Move async function transpilation after all checks. See https://github.com/google/closure-compiler/issues/2540 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=222265244 --- .../jscomp/TranspilationPasses.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/com/google/javascript/jscomp/TranspilationPasses.java b/src/com/google/javascript/jscomp/TranspilationPasses.java index 1c5adaead73..02826d3086c 100644 --- a/src/com/google/javascript/jscomp/TranspilationPasses.java +++ b/src/com/google/javascript/jscomp/TranspilationPasses.java @@ -86,15 +86,6 @@ static void addPreTypecheckTranspilationPasses( passes.add(rewriteObjectSpread); } - if (options.needsTranspilationFrom(ES8)) { - // Trailing commas in parameter lists are flagged as present by the parser, - // but never actually represented in the AST. - // The only thing we need to do is mark them as not present in the AST. - passes.add( - createFeatureRemovalPass( - "markTrailingCommasInParameterListsRemoved", Feature.TRAILING_COMMA_IN_PARAM_LIST)); - passes.add(rewriteAsyncFunctions); - } if (options.needsTranspilationFrom(ES6) && doEs6ExternsCheck) { passes.add(es6ExternsCheck); } @@ -111,6 +102,16 @@ public static void addEs6RewriteImportPathPass(List passes) { /** Adds transpilation passes that should run after all checks are done. */ public static void addPostCheckTranspilationPasses( List passes, CompilerOptions options) { + if (options.needsTranspilationFrom(ES8)) { + // Trailing commas in parameter lists are flagged as present by the parser, + // but never actually represented in the AST. + // The only thing we need to do is mark them as not present in the AST. + passes.add( + createFeatureRemovalPass( + "markTrailingCommasInParameterListsRemoved", Feature.TRAILING_COMMA_IN_PARAM_LIST)); + passes.add(rewriteAsyncFunctions); + } + if (options.needsTranspilationFrom(ES7)) { passes.add(rewriteExponentialOperator); }