Skip to content

Commit

Permalink
Fill in some nullability annotations.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174203849
  • Loading branch information
tbreisacher authored and brad4d committed Nov 2, 2017
1 parent 1e5e45d commit ab1eb56
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/com/google/javascript/jscomp/OptimizeParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.BitSet;
import java.util.List;
import java.util.Map.Entry;
import javax.annotation.Nullable;

/**
* Optimize function calls and function signatures.
Expand Down Expand Up @@ -711,16 +712,15 @@ private void optimizeCallSite(List<Parameter> parameters, Node target) {
if (p.shouldRemove()) {
eliminateCallTargetArgAt(target, index);

if (mayMutateArgs && !mayMutateGlobalsOrThrow &&
if (mayMutateArgs && !mayMutateGlobalsOrThrow
// We want to cover both global-state arguments, and
// expressions that might throw exceptions.
// We're deliberately conservative here b/c it's
// difficult to test all the edge cases.
!NodeUtil.isImmutableValue(p.getArg())) {
&& !NodeUtil.isImmutableValue(p.getArg())) {
mayMutateGlobalsOrThrow = true;
call.setSideEffectFlags(
new Node.SideEffectFlags(call.getSideEffectFlags())
.setMutatesGlobalState());
new Node.SideEffectFlags(call.getSideEffectFlags()).setMutatesGlobalState());
}
}
}
Expand Down Expand Up @@ -776,7 +776,7 @@ public boolean canBeSideEffected() {
* @param varName The name of the variable.
* @param value The initial value of the variable.
*/
private void addVariableToFunction(Node function, Node varName, Node value) {
private void addVariableToFunction(Node function, @Nullable Node varName, Node value) {
Preconditions.checkArgument(function.isFunction(), "Expected function, got: %s", function);

Node block = NodeUtil.getFunctionBody(function);
Expand Down Expand Up @@ -823,6 +823,7 @@ private void eliminateParamsAfter(Node fnNode, Node argNode) {
* @param definitionFinder The definition and use sites index.
* @return The Node of the argument removed.
*/
@Nullable
private Node eliminateFunctionParamAt(Node function, int argIndex) {
checkArgument(function.isFunction(), "Node must be a function.");
Node formalParamNode = NodeUtil.getArgumentForFunction(function, argIndex);
Expand Down

0 comments on commit ab1eb56

Please sign in to comment.