Skip to content

Commit

Permalink
[NTI] Do a null check to avoid a crash related to loose function types.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135169906
  • Loading branch information
dimvar authored and blickly committed Oct 5, 2016
1 parent b0d588d commit 8cd75a3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/com/google/javascript/jscomp/NewTypeInference.java
Expand Up @@ -3196,7 +3196,14 @@ private EnvTypePair analyzeLooseCallNodeFwd(
// Unsound if the arguments and callee have interacting side effects
EnvTypePair calleePair = analyzeExprFwd(
callee, tmpEnv, commonTypes.topFunction(), looseFunctionType);
JSType result = calleePair.type.getFunTypeIfSingletonObj().getReturnType();
FunctionType calleeType = calleePair.type.getFunTypeIfSingletonObj();
if (calleeType == null) {
// TODO(dimvar): There is no unit test for this. We have only seen it
// happen in large programs. Normally, calleeType shouldn't be null.
// Revisit later to find cause.
return new EnvTypePair(calleePair.env, requiredType);
}
JSType result = calleeType.getReturnType();
return new EnvTypePair(calleePair.env,
isImpreciseType(result) ? requiredType : result);
}
Expand Down

0 comments on commit 8cd75a3

Please sign in to comment.