Code with Misuse: |
class TightenTypes.CreateScope {
private Collection<Action> getImplicitActionsFromCall(
Node n, JSType recvType) {
Node receiver = n.getFirstChild();
if (recvType instanceof UnionType) {
List<Action> actions = Lists.newArrayList();
for (JSType alt : ((UnionType) recvType).getAlternates()) {
actions.addAll(getImplicitActionsFromCall(n, alt));
}
return actions;
} else if (!(recvType instanceof FunctionType)) {
return Lists.<Action>newArrayList();
}
ObjectType objType = ObjectType.cast(
getJSType(receiver.getFirstChild())
.restrictByNotNullOrUndefined());
String prop = receiver.getLastChild().getString();
if (objType != null &&
(objType.isPropertyInExterns(prop)) &&
((FunctionType) recvType).getParameters() != null) {
List<Action> actions = Lists.newArrayList();
// Look for a function type in the argument list.
Iterator<Node> paramIter =
((FunctionType) recvType).getParameters().iterator();
Iterator<Node> argumentIter = n.children().iterator();
argumentIter.next(); // Skip the function name.
while (paramIter.hasNext() && argumentIter.hasNext()) {
Node arg = argumentIter.next();
Node param = paramIter.next();
if (arg.getJSType() instanceof FunctionType) {
actions.addAll(getImplicitActionsFromArgument(
arg,
((FunctionType) arg.getJSType()).getTypeOfThis(),
param.getJSType()));
}
}
return actions;
}
return Lists.<Action>newArrayList();
}
}
|