Skip to content

Commit 3cb4944

Browse files
concavelenzcopybara-github
authored andcommitted
Make CompilerOptions#setRemoveUnusedPrototypePropertiesInExterns a noop in preparation for removing the associated functionality.
PiperOrigin-RevId: 322445084
1 parent c054400 commit 3cb4944

File tree

7 files changed

+4
-60
lines changed

7 files changed

+4
-60
lines changed

src/com/google/javascript/jscomp/CompilationLevel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ private static void applyFullCompilationOptions(CompilerOptions options) {
174174
options.setReserveRawExports(true);
175175
options.setRenamingPolicy(VariableRenamingPolicy.ALL, PropertyRenamingPolicy.ALL_UNQUOTED);
176176
options.setRemoveUnusedPrototypeProperties(true);
177-
options.setRemoveUnusedPrototypePropertiesInExterns(false);
178177
options.setRemoveUnusedClassProperties(true);
179178
options.setCollapseAnonymousFunctions(true);
180179
options.setCollapsePropertiesLevel(PropertyCollapseLevel.ALL);

src/com/google/javascript/jscomp/CompilerOptions.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,6 @@ public enum ExtractPrototypeMemberDeclarationsMode {
504504
/** Removes unused member prototypes */
505505
public boolean removeUnusedPrototypeProperties;
506506

507-
/** Tells AnalyzePrototypeProperties it can remove externed props. */
508-
public boolean removeUnusedPrototypePropertiesInExterns;
509-
510507
/** Removes unused member properties */
511508
public boolean removeUnusedClassProperties;
512509

@@ -1373,7 +1370,6 @@ public CompilerOptions() {
13731370
extractPrototypeMemberDeclarations =
13741371
ExtractPrototypeMemberDeclarationsMode.OFF;
13751372
removeUnusedPrototypeProperties = false;
1376-
removeUnusedPrototypePropertiesInExterns = false;
13771373
removeUnusedClassProperties = false;
13781374
removeUnusedVars = false;
13791375
removeUnusedLocalVars = false;
@@ -2301,9 +2297,8 @@ public void setRemoveUnusedPrototypeProperties(boolean enabled) {
23012297
this.inlineGetters = enabled;
23022298
}
23032299

2304-
public void setRemoveUnusedPrototypePropertiesInExterns(boolean enabled) {
2305-
this.removeUnusedPrototypePropertiesInExterns = enabled;
2306-
}
2300+
@Deprecated
2301+
public void setRemoveUnusedPrototypePropertiesInExterns(boolean enabled) {}
23072302

23082303
public void setCollapseVariableDeclarations(boolean enabled) {
23092304
this.collapseVariableDeclarations = enabled;
@@ -3085,9 +3080,6 @@ public String toString() {
30853080
.add("removeUnusedConstructorProperties", removeUnusedConstructorProperties)
30863081
.add("removeUnusedLocalVars", removeUnusedLocalVars)
30873082
.add("removeUnusedPrototypeProperties", removeUnusedPrototypeProperties)
3088-
.add(
3089-
"removeUnusedPrototypePropertiesInExterns",
3090-
removeUnusedPrototypePropertiesInExterns)
30913083
.add("removeUnusedVars", removeUnusedVars)
30923084
.add(
30933085
"renamePrefixNamespaceAssumeCrossChunkNames",

src/com/google/javascript/jscomp/CompilerOptionsPreprocessor.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ static void preprocess(CompilerOptions options) {
3838
"Cannot check use of goog.getCssName because of empty blacklist.");
3939
}
4040

41-
if (options.removeUnusedPrototypePropertiesInExterns
42-
&& !options.removeUnusedPrototypeProperties) {
43-
throw new InvalidOptionsException(
44-
"remove_unused_prototype_props_in_externs requires "
45-
+ "remove_unused_prototype_props to be turned on.");
46-
}
47-
4841
if (options.getInlineFunctionsLevel() == CompilerOptions.Reach.NONE
4942
&& options.maxFunctionSizeAfterInlining
5043
!= CompilerOptions.UNLIMITED_FUN_SIZE_AFTER_INLINING) {
@@ -60,13 +53,6 @@ static void preprocess(CompilerOptions options) {
6053
options.setAmbiguateProperties(false);
6154
options.setDisambiguateProperties(false);
6255
}
63-
64-
if (options.removeUnusedPrototypePropertiesInExterns
65-
&& options.exportLocalPropertyDefinitions) {
66-
throw new InvalidOptionsException(
67-
"remove_unused_prototype_props_in_externs "
68-
+ "and export_local_property_definitions cannot be used together.");
69-
}
7056
}
7157

7258
/** Exception to indicate incompatible options in the CompilerOptions. */

src/com/google/javascript/jscomp/DefaultPassConfig.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,8 +2420,7 @@ public void process(Node externs, Node root) {
24202420
.removeGlobals(options.removeUnusedVars)
24212421
.preserveFunctionExpressionNames(preserveAnonymousFunctionNames)
24222422
.removeUnusedPrototypeProperties(options.removeUnusedPrototypeProperties)
2423-
.allowRemovalOfExternProperties(
2424-
options.removeUnusedPrototypePropertiesInExterns)
2423+
.allowRemovalOfExternProperties(false)
24252424
.removeUnusedThisProperties(options.isRemoveUnusedClassProperties())
24262425
.removeUnusedObjectDefinePropertiesDefinitions(
24272426
options.isRemoveUnusedClassProperties())
@@ -2462,9 +2461,7 @@ public void process(Node externs, Node root) {
24622461
new CrossChunkMethodMotion(
24632462
compiler,
24642463
compiler.getCrossModuleIdGenerator(),
2465-
// Only move properties in externs if we're not treating
2466-
// them as exports.
2467-
options.removeUnusedPrototypePropertiesInExterns,
2464+
/* canModifyExterns= */ false, // remove this
24682465
options.crossChunkCodeMotionNoStubMethods))
24692466
.setFeatureSetForOptimizations()
24702467
.build();

src/com/google/javascript/jscomp/debugger/common/CompilationParam.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -708,19 +708,6 @@ public boolean isApplied(CompilerOptions options) {
708708
}
709709
},
710710

711-
/** Tells AnalyzePrototypeProperties it can remove externed props. */
712-
REMOVE_UNUSED_PROTOTYPE_PROPERTIES_IN_EXTERNS(ParamGroup.OPTIMIZATION) {
713-
@Override
714-
public void apply(CompilerOptions options, boolean value) {
715-
options.setRemoveUnusedPrototypePropertiesInExterns(value);
716-
}
717-
718-
@Override
719-
public boolean isApplied(CompilerOptions options) {
720-
return options.removeUnusedPrototypePropertiesInExterns;
721-
}
722-
},
723-
724711
/** Removes unused variables */
725712
REMOVE_UNUSED_VARIABLES(ParamGroup.OPTIMIZATION) {
726713
@Override

test/com/google/javascript/jscomp/integration/AdvancedOptimizationsIntegrationTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,8 +1275,6 @@ public void testExports() {
12751275
WarningLevel warnings = WarningLevel.DEFAULT;
12761276
warnings.setOptionsForWarningLevel(options);
12771277

1278-
options.setRemoveUnusedPrototypePropertiesInExterns(true);
1279-
12801278
String code =
12811279
""
12821280
+ "/** @constructor */ var X = function() {"
@@ -1285,11 +1283,6 @@ public void testExports() {
12851283
+ "/** @export */ this.abc = 1;};\n"
12861284
+ "alert(new X().abc + new Y().abc);";
12871285

1288-
// no export enabled, property name not preserved
1289-
test(options, code,
1290-
"alert((new function(){this.a = 1}).a + " +
1291-
"(new function(){this.a = 1}).a);");
1292-
12931286
options.setGenerateExports(true);
12941287

12951288
// exports enabled, but not local exports
@@ -1298,7 +1291,6 @@ public void testExports() {
12981291
assertThat(lastCompiler.getErrors()).hasSize(1);
12991292

13001293
options.setExportLocalPropertyDefinitions(true);
1301-
options.setRemoveUnusedPrototypePropertiesInExterns(false);
13021294

13031295
// property name preserved due to export
13041296
test(options, code,

test/com/google/javascript/jscomp/integration/IntegrationTest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3437,15 +3437,6 @@ public void testIssue787() {
34373437
test(options, code, result);
34383438
}
34393439

3440-
@Test
3441-
public void testRmUnusedProtoPropsInExternsUsage() {
3442-
CompilerOptions options = new CompilerOptions();
3443-
options.setRemoveUnusedPrototypePropertiesInExterns(true);
3444-
options.setRemoveUnusedPrototypeProperties(false);
3445-
assertThrows(
3446-
CompilerOptionsPreprocessor.InvalidOptionsException.class, () -> test(options, "", ""));
3447-
}
3448-
34493440
@Test
34503441
public void testMaxFunSizeAfterInliningUsage() {
34513442
CompilerOptions options = new CompilerOptions();

0 commit comments

Comments
 (0)