Program: 19301
Project: 19301
Buggy source:
private void createSummary(NTIScope fn){
  Node fnRoot=fn.getRoot();
  checkArgument(!fnRoot.isFromExterns());
  FunctionTypeBuilder builder=new FunctionTypeBuilder(this.commonTypes);
  TypeEnv entryEnv=getEntryTypeEnv();
  TypeEnv exitEnv=getExitTypeEnv();
  if (exitEnv == null) {
    exitEnv=envPutType(new TypeEnv(),RETVAL_ID,BOTTOM);
  }
  DeclaredFunctionType declType=fn.getDeclaredFunctionType();
  int reqArity=declType.getRequiredArity();
  int optArity=declType.getOptionalArity();
  if (declType.isGeneric()) {
    builder.addTypeParameters(declType.getTypeParameters());
  }
  List<String> formals=fn.getFormals();
  for (int i=reqArity - 1; i >= 0; i--) {
    JSType formalType=declType.getFormalType(i);
    if (formalType != null) {
      break;
    }
    String formalName=formals.get(i);
    formalType=getTypeAfterFwd(formalName,entryEnv,exitEnv);
    if (formalType.isUnknown() || UNDEFINED.isSubtypeOf(formalType)) {
      reqArity--;
    }
 else {
      break;
    }
  }
  int i=0;
  for (  String formalName : formals) {
    JSType formalType=declType.getFormalType(i);
    if (formalType == null) {
      formalType=getTypeAfterFwd(formalName,entryEnv,exitEnv);
    }
    if (i < reqArity) {
      builder.addReqFormal(formalType);
    }
 else     if (i < optArity) {
      builder.addOptFormal(formalType);
    }
    i++;
  }
  if (declType.hasRestFormals()) {
    builder.addRestFormals(declType.getFormalType(i));
  }
  for (  String outer : fn.getOuterVars()) {
    println("String_Node_Str",outer,"String_Node_Str");
    builder.addOuterVarPrecondition(outer,envGetType(entryEnv,outer));
  }
  builder.addNominalType(declType.getNominalType());
  builder.addReceiverType(declType.getReceiverType());
  builder.addAbstract(declType.isAbstract());
  addRetTypeAndWarn(fn,exitEnv,declType,builder);
  JSType summary=commonTypes.fromFunctionType(builder.buildFunction());
  println("String_Node_Str",fn.getReadableName());
  println("String_Node_Str",summary);
  summary=changeTypeIfFunctionNamespace(fn,summary);
  summaries.put(fn,summary);
  maybeSetTypeI(fnRoot,summary);
  Node fnNameNode=NodeUtil.getNameNode(fnRoot);
  if (fnNameNode != null) {
    maybeSetTypeI(fnNameNode,summary);
  }
}

Fixed version (ground truth):
private void createSummary(NTIScope fn){
  Node fnRoot=fn.getRoot();
  checkArgument(!fnRoot.isFromExterns());
  FunctionTypeBuilder builder=new FunctionTypeBuilder(this.commonTypes);
  TypeEnv entryEnv=getEntryTypeEnv();
  TypeEnv exitEnv=getExitTypeEnv();
  DeclaredFunctionType declType=fn.getDeclaredFunctionType();
  int reqArity=declType.getRequiredArity();
  int optArity=declType.getOptionalArity();
  if (declType.isGeneric()) {
    builder.addTypeParameters(declType.getTypeParameters());
  }
  List<String> formals=fn.getFormals();
  for (int i=reqArity - 1; i >= 0; i--) {
    JSType formalType=declType.getFormalType(i);
    if (formalType != null) {
      break;
    }
    String formalName=formals.get(i);
    formalType=getTypeAfterFwd(formalName,entryEnv,exitEnv);
    if (formalType.isUnknown() || UNDEFINED.isSubtypeOf(formalType)) {
      reqArity--;
    }
 else {
      break;
    }
  }
  int i=0;
  for (  String formalName : formals) {
    JSType formalType=declType.getFormalType(i);
    if (formalType == null) {
      formalType=getTypeAfterFwd(formalName,entryEnv,exitEnv);
    }
    if (i < reqArity) {
      builder.addReqFormal(formalType);
    }
 else     if (i < optArity) {
      builder.addOptFormal(formalType);
    }
    i++;
  }
  if (declType.hasRestFormals()) {
    builder.addRestFormals(declType.getFormalType(i));
  }
  for (  String outer : fn.getOuterVars()) {
    println("String_Node_Str",outer,"String_Node_Str");
    builder.addOuterVarPrecondition(outer,envGetType(entryEnv,outer));
  }
  builder.addNominalType(declType.getNominalType());
  builder.addReceiverType(declType.getReceiverType());
  builder.addAbstract(declType.isAbstract());
  addRetTypeAndWarn(fn,exitEnv,declType,builder);
  JSType summary=commonTypes.fromFunctionType(builder.buildFunction());
  println("String_Node_Str",fn.getReadableName());
  println("String_Node_Str",summary);
  summary=changeTypeIfFunctionNamespace(fn,summary);
  summaries.put(fn,summary);
  maybeSetTypeI(fnRoot,summary);
  Node fnNameNode=NodeUtil.getNameNode(fnRoot);
  if (fnNameNode != null) {
    maybeSetTypeI(fnNameNode,summary);
  }
}