Program: 27682
Project: 27682
Buggy source:
public boolean isSubtypeOf(FunctionType other){
  if (other.isTopFunction() || other.isQmarkFunction() || this.isQmarkFunction()) {
    return true;
  }
  if (isTopFunction()) {
    return false;
  }
  Preconditions.checkState(!isLoose && !other.isLoose);
  if (this.isGeneric()) {
    return true;
  }
  if (requiredFormals.size() > other.requiredFormals.size()) {
    return false;
  }
  int otherMaxTotalArity=other.requiredFormals.size() + other.optionalFormals.size();
  for (int i=0; i < otherMaxTotalArity; i++) {
    JSType thisFormal=getFormalType(i);
    JSType otherFormal=other.getFormalType(i);
    if (thisFormal != null && !thisFormal.isUnknown() && !otherFormal.isUnknown() && !otherFormal.isSubtypeOf(thisFormal)) {
      return false;
    }
  }
  if (other.restFormals != null) {
    int thisMaxTotalArity=this.requiredFormals.size() + this.optionalFormals.size();
    if (this.restFormals != null) {
      thisMaxTotalArity++;
    }
    for (int i=otherMaxTotalArity; i < thisMaxTotalArity; i++) {
      JSType thisFormal=getFormalType(i);
      JSType otherFormal=other.getFormalType(i);
      if (thisFormal != null && !thisFormal.isUnknown() && !otherFormal.isUnknown() && !otherFormal.isSubtypeOf(thisFormal)) {
        return false;
      }
    }
  }
  if (nominalType == null && other.nominalType != null || nominalType != null && other.nominalType == null || nominalType != null && other.nominalType != null && !nominalType.isSubclassOf(other.nominalType)) {
    return false;
  }
  if (receiverType != null && other.receiverType == null || receiverType != null && other.receiverType != null && !receiverType.isSubclassOf(other.receiverType)) {
    return false;
  }
  return returnType.isUnknown() || other.returnType.isUnknown() || returnType.isSubtypeOf(other.returnType);
}

Fixed version (ground truth):
public boolean isSubtypeOf(FunctionType other){
  if (other.isTopFunction() || other.isQmarkFunction() || this.isQmarkFunction()) {
    return true;
  }
  if (isTopFunction()) {
    return false;
  }
  Preconditions.checkState(!isLoose && !other.isLoose);
  if (this.isGeneric()) {
    if (this.equals(other)) {
      return true;
    }
    return instantiateGenericsWithUnknown(this).isSubtypeOf(other);
  }
  if (requiredFormals.size() > other.requiredFormals.size()) {
    return false;
  }
  int otherMaxTotalArity=other.requiredFormals.size() + other.optionalFormals.size();
  for (int i=0; i < otherMaxTotalArity; i++) {
    JSType thisFormal=getFormalType(i);
    JSType otherFormal=other.getFormalType(i);
    if (thisFormal != null && !thisFormal.isUnknown() && !otherFormal.isUnknown() && !otherFormal.isSubtypeOf(thisFormal)) {
      return false;
    }
  }
  if (other.restFormals != null) {
    int thisMaxTotalArity=this.requiredFormals.size() + this.optionalFormals.size();
    if (this.restFormals != null) {
      thisMaxTotalArity++;
    }
    for (int i=otherMaxTotalArity; i < thisMaxTotalArity; i++) {
      JSType thisFormal=getFormalType(i);
      JSType otherFormal=other.getFormalType(i);
      if (thisFormal != null && !thisFormal.isUnknown() && !otherFormal.isUnknown() && !otherFormal.isSubtypeOf(thisFormal)) {
        return false;
      }
    }
  }
  if (nominalType == null && other.nominalType != null || nominalType != null && other.nominalType == null || nominalType != null && other.nominalType != null && !nominalType.isSubclassOf(other.nominalType)) {
    return false;
  }
  if (receiverType != null && other.receiverType == null || receiverType != null && other.receiverType != null && !receiverType.isSubclassOf(other.receiverType)) {
    return false;
  }
  return returnType.isUnknown() || other.returnType.isUnknown() || returnType.isSubtypeOf(other.returnType);
}