Skip to content

Commit

Permalink
Simplify logic for typing ASSIGN nodes in TypeCheck
Browse files Browse the repository at this point in the history
There's some existing logic that will put the rhs type on an ASSIGN node iff assign is valid, or the unknown type otherwise.

This is pointless now because we already put the rhs type on an ASSIGN unconditionally in TypeInference. This case only triggers for code that (for whatever reason) doesn't get typed during TypeInference.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=207810074
  • Loading branch information
lauraharker authored and tjgq committed Aug 10, 2018
1 parent 0cb64ac commit b996efb
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/com/google/javascript/jscomp/TypeCheck.java
Expand Up @@ -1074,7 +1074,9 @@ private void visitAssign(NodeTraversal t, Node assign) {
}
}

checkCanAssignToWithScope(t, assign, lvalue, getJSType(rvalue), "assignment");
JSType rightType = getJSType(rvalue);
checkCanAssignToWithScope(t, assign, lvalue, rightType, "assignment");
ensureTyped(assign, rightType);
}

/**
Expand Down Expand Up @@ -1115,14 +1117,9 @@ private void checkCanAssignToWithScope(
leftType = var.getType();
}
}
}
} // Fall through case for arbitrary LHS and arbitrary RHS.

// Fall through case for arbitrary LHS and arbitrary RHS.
if (validator.expectCanAssignTo(t, assign, rightType, leftType, msg)) {
ensureTyped(assign, rightType);
} else {
ensureTyped(assign);
}
validator.expectCanAssignTo(t, assign, rightType, leftType, msg);
}

private void checkPropCreation(NodeTraversal t, Node lvalue) {
Expand Down

0 comments on commit b996efb

Please sign in to comment.