Program: 27269
Project: 27269
Buggy source:
private EnvTypePair analyzeCallNewBwd(Node expr,TypeEnv outEnv,JSType requiredType){
  Preconditions.checkArgument(expr.isNew() || expr.isCall());
  Node callee=expr.getFirstChild();
  EnvTypePair pair=analyzeExprBwd(callee,outEnv,commonTypes.topFunction());
  TypeEnv envAfterCallee=pair.env;
  FunctionType funType=pair.type.getFunType();
  if (funType == null) {
    return analyzeCallNodeArgumentsBwd(expr,envAfterCallee);
  }
 else   if (funType.isLoose()) {
    return analyzeLooseCallNodeBwd(expr,envAfterCallee,requiredType);
  }
 else   if (expr.isCall() && funType.isSomeConstructorOrInterface() || expr.isNew() && !funType.isSomeConstructorOrInterface()) {
    return analyzeCallNodeArgumentsBwd(expr,envAfterCallee);
  }
 else   if (funType.isTopFunction()) {
    return analyzeCallNodeArgumentsBwd(expr,envAfterCallee);
  }
  if (callee.isName() && !funType.isGeneric() && expr.isCall()) {
    createDeferredCheckBwd(expr,requiredType);
  }
  int numArgs=expr.getChildCount() - 1;
  if (numArgs < funType.getMinArity() || numArgs > funType.getMaxArity()) {
    return analyzeCallNodeArgumentsBwd(expr,envAfterCallee);
  }
  if (funType.isGeneric()) {
    Map<String,JSType> typeMap=calcTypeInstantiationBwd(expr,funType,envAfterCallee);
    funType=funType.instantiateGenerics(typeMap);
  }
  TypeEnv tmpEnv=envAfterCallee;
  Node target=expr.getFirstChild();
  int i=expr.getChildCount() - 1;
  for (Node arg=expr.getLastChild(); arg != target; arg=arg.getPrevious()) {
    i--;
    JSType formalType=funType.getFormalType(i);
    if (formalType.isBottom()) {
      formalType=UNKNOWN;
    }
    tmpEnv=analyzeExprBwd(arg,tmpEnv,formalType).env;
  }
  JSType retType=expr.isNew() ? funType.getThisType() : funType.getReturnType();
  return new EnvTypePair(tmpEnv,retType);
}

Fixed version (ground truth):
private EnvTypePair analyzeCallNewBwd(Node expr,TypeEnv outEnv,JSType requiredType){
  Preconditions.checkArgument(expr.isNew() || expr.isCall());
  Node callee=expr.getFirstChild();
  EnvTypePair pair=analyzeExprBwd(callee,outEnv,commonTypes.topFunction());
  TypeEnv envAfterCallee=pair.env;
  FunctionType funType=pair.type.getFunType();
  if (funType == null) {
    return analyzeCallNodeArgumentsBwd(expr,envAfterCallee);
  }
 else   if (funType.isLoose()) {
    return analyzeLooseCallNodeBwd(expr,envAfterCallee,requiredType);
  }
 else   if ((expr.isCall() && funType.isSomeConstructorOrInterface()) || (expr.isNew() && !funType.isSomeConstructorOrInterface())) {
    return analyzeCallNodeArgumentsBwd(expr,envAfterCallee);
  }
 else   if (funType.isTopFunction()) {
    return analyzeCallNodeArgumentsBwd(expr,envAfterCallee);
  }
  if (callee.isName() && !funType.isGeneric() && expr.isCall()) {
    createDeferredCheckBwd(expr,requiredType);
  }
  int numArgs=expr.getChildCount() - 1;
  if (numArgs < funType.getMinArity() || numArgs > funType.getMaxArity()) {
    return analyzeCallNodeArgumentsBwd(expr,envAfterCallee);
  }
  if (funType.isGeneric()) {
    Map<String,JSType> typeMap=calcTypeInstantiationBwd(expr,funType,envAfterCallee);
    funType=funType.instantiateGenerics(typeMap);
  }
  TypeEnv tmpEnv=envAfterCallee;
  Node target=expr.getFirstChild();
  int i=expr.getChildCount() - 1;
  for (Node arg=expr.getLastChild(); arg != target; arg=arg.getPrevious()) {
    i--;
    JSType formalType=funType.getFormalType(i);
    if (formalType.isBottom()) {
      formalType=UNKNOWN;
    }
    tmpEnv=analyzeExprBwd(arg,tmpEnv,formalType).env;
  }
  JSType retType=expr.isNew() ? funType.getThisType() : funType.getReturnType();
  return new EnvTypePair(tmpEnv,retType);
}