Skip to content

Commit fc53719

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents cc54ef1 + 255c15b commit fc53719

27 files changed

+343
-133
lines changed

externs/browser/html5.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3766,7 +3766,8 @@ XMLHttpRequest.prototype.response;
37663766
* refreshPolicy: string,
37673767
* signRequestData: string,
37683768
* includeTimestampHeader: boolean,
3769-
* additionalSignedHeaders: !Array<string>
3769+
* additionalSignedHeaders: (!Array<string>|undefined),
3770+
* additionalSigningData: (string|undefined)
37703771
* }}
37713772
* @see https://docs.google.com/document/d/1qUjtKgA7nMv9YGMhi0xWKEojkSITKzGLdIcZgoz6ZkI
37723773
*/

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/ControlFlowAnalysis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ private void handleFor(Node forNode) {
450450
// The edge that transfer control to the beginning of the loop body.
451451
createEdge(forNode, Branch.ON_TRUE, computeFallThrough(body));
452452
// The edge to end of the loop.
453-
if (!cond.isEmpty()) {
453+
if (!cond.isEmpty() && !cond.isTrue()) {
454454
createEdge(forNode, Branch.ON_FALSE, computeFollowNode(forNode, this));
455455
}
456456
// The end of the body will have a unconditional branch to our iter

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/ExpressionDecomposer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void maybeExposeExpression(Node expression) {
128128
* <p>This method should not be called from outside of this class. Instead call {@link
129129
* #maybeExposeExpression(Node)}.
130130
*/
131-
void exposeExpression(Node expression) {
131+
private void exposeExpression(Node expression) {
132132
Node expressionRoot = findExpressionRoot(expression);
133133
checkNotNull(expressionRoot);
134134
checkState(NodeUtil.isStatement(expressionRoot), expressionRoot);

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

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ private void collect(JSModule module, Scope scope, Node n) {
444444
type = getValueType(n.getFirstChild());
445445
break;
446446
case NAME:
447+
case GETPROP:
447448
// TODO(b/127505242): CAST parents may indicate a set.
448449
// This may be a variable get or set.
449450
switch (parent.getToken()) {
@@ -492,7 +493,9 @@ private void collect(JSModule module, Scope scope, Node n) {
492493
case ITER_REST:
493494
case OBJECT_REST:
494495
// This may be a set.
495-
if (NodeUtil.isLhsByDestructuring(n)) {
496+
// TODO(b/120303257): this should extend to qnames too, but doing
497+
// so causes invalid output. Covered in CollapsePropertiesTest
498+
if (n.isName() && NodeUtil.isLhsByDestructuring(n)) {
496499
isSet = true;
497500
type = NameType.OTHER;
498501
}
@@ -506,42 +509,12 @@ private void collect(JSModule module, Scope scope, Node n) {
506509
type = NameType.OTHER;
507510
}
508511
}
509-
name = n.getString();
510-
break;
511-
case GETPROP:
512-
// TODO(b/117673791): Merge this case with NAME case to fix.
513-
// TODO(b/120303257): Merging this case with the NAME case makes this a breaking bug.
514-
// TODO(b/127505242): CAST parents may indicate a set.
515-
// This may be a namespaced name get or set.
516-
if (parent != null) {
517-
switch (parent.getToken()) {
518-
case ASSIGN:
519-
if (parent.getFirstChild() == n) {
520-
isSet = true;
521-
type = getValueType(n.getNext());
522-
}
523-
break;
524-
case GETPROP:
525-
// This is nested in another getprop. Return and only create a Ref for the outermost
526-
// getprop in the chain.
527-
return;
528-
case INC:
529-
case DEC:
530-
case ITER_SPREAD:
531-
case OBJECT_SPREAD:
532-
break; // isSet = false, type = OTHER.
533-
default:
534-
if (NodeUtil.isAssignmentOp(parent) && parent.getFirstChild() == n) {
535-
isSet = true;
536-
type = NameType.OTHER;
537-
}
538-
}
539-
}
540512
if (!n.isQualifiedName()) {
541513
return;
542514
}
543515
name = n.getQualifiedName();
544516
break;
517+
545518
case CALL:
546519
if (isObjectHasOwnPropertyCall(n)) {
547520
String qname = n.getFirstFirstChild().getQualifiedName();

src/com/google/javascript/jscomp/colors/Color.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ public interface Color {
2525

2626
boolean isUnion();
2727

28+
boolean isObject();
29+
2830
ImmutableCollection<Color> getAlternates();
2931
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2020 The Closure Compiler Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.javascript.jscomp.colors;
18+
19+
import com.google.auto.value.AutoValue;
20+
import com.google.common.collect.ImmutableCollection;
21+
22+
/**
23+
* A user-defined object type. For now each type is defined by a unique class name and file source.
24+
*/
25+
@AutoValue
26+
public abstract class ObjectColor implements Color {
27+
28+
public static ObjectColor create(String className, String fileName) {
29+
return new AutoValue_ObjectColor(className, fileName);
30+
}
31+
32+
@Override
33+
public boolean isPrimitive() {
34+
return false;
35+
}
36+
37+
@Override
38+
public boolean isUnion() {
39+
return false;
40+
}
41+
42+
@Override
43+
public boolean isObject() {
44+
return true;
45+
}
46+
47+
@Override
48+
public ImmutableCollection<Color> getAlternates() {
49+
throw new UnsupportedOperationException();
50+
}
51+
52+
public abstract String getClassName();
53+
54+
public abstract String getFilename();
55+
}

0 commit comments

Comments
 (0)