Skip to content

Commit

Permalink
Run the extra smart name removal in advanced mode of the open-source …
Browse files Browse the repository at this point in the history
…compiler.

Fixes one of the examples in issue #2249.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=146174486
  • Loading branch information
dimvar authored and blickly committed Feb 1, 2017
1 parent 89609f0 commit ecc937a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/com/google/javascript/jscomp/CompilationLevel.java
Expand Up @@ -175,6 +175,7 @@ private static void applyFullCompilationOptions(CompilerOptions options) {
options.setCheckGlobalThisLevel(CheckLevel.WARNING);
options.setRewriteFunctionExpressions(false);
options.setSmartNameRemoval(true);
options.setExtraSmartNameRemoval(true);
options.setInlineConstantVars(true);
options.setInlineFunctions(Reach.ALL);
options.setAssumeClosuresOnlyCaptureReferences(false);
Expand Down
16 changes: 16 additions & 0 deletions test/com/google/javascript/jscomp/IntegrationTest.java
Expand Up @@ -269,6 +269,21 @@ public void testBug31301233() {
test(options, source, ConstParamCheck.CONST_NOT_ASSIGNED_STRING_LITERAL_ERROR);
}

public void testAdvancedModeIncludesExtraSmartNameRemoval() {
CompilerOptions options = new CompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
test(
options,
LINE_JOINER.join(
"(function() {",
" /** @constructor} */",
" function Bar() {}",
" var y = Bar;",
" new y();",
"})();"),
"");
}

public void testBug2410122() {
CompilerOptions options = createCompilerOptions();
options.setGenerateExports(true);
Expand Down Expand Up @@ -1600,6 +1615,7 @@ public void testClassWithGettersIsRemoved() {
options.setLanguageIn(LanguageMode.ECMASCRIPT6);
options.setLanguageOut(LanguageMode.ECMASCRIPT5);
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
options.setExtraSmartNameRemoval(false);
test(options, code, expected);
}

Expand Down

0 comments on commit ecc937a

Please sign in to comment.