Program: 27481
Project: 27481
Buggy source:
private DeclaredFunctionType getFunTypeFromTypicalFunctionJsdoc(JSDocInfo jsdoc,String functionName,Node funNode,RawNominalType constructorType,RawNominalType ownerType,DeclaredTypeRegistry registry,FunctionTypeBuilder builder,boolean ignoreJsdoc){
  Preconditions.checkArgument(!ignoreJsdoc || jsdoc == null);
  Preconditions.checkArgument(!ignoreJsdoc || funNode.isFunction());
  ImmutableList<String> typeParameters=ImmutableList.of();
  Node parent=funNode.getParent();
  if (jsdoc != null) {
    typeParameters=jsdoc.getTemplateTypeNames();
    if (!typeParameters.isEmpty()) {
      if (parent.isSetterDef() || parent.isGetterDef()) {
        ignoreJsdoc=true;
        jsdoc=null;
        warn("String_Node_Str",funNode);
      }
 else {
        builder.addTypeParameters(typeParameters);
      }
    }
  }
  if (ownerType != null) {
    ImmutableList.Builder<String> paramsBuilder=new ImmutableList.Builder<>();
    paramsBuilder.addAll(typeParameters);
    paramsBuilder.addAll(ownerType.getTypeParameters());
    typeParameters=paramsBuilder.build();
  }
  fillInFormalParameterTypes(jsdoc,funNode,typeParameters,registry,builder,ignoreJsdoc);
  fillInReturnType(jsdoc,funNode,parent,typeParameters,registry,builder,ignoreJsdoc);
  if (jsdoc == null) {
    return builder.buildDeclaration();
  }
  NominalType parentClass=getMaybeParentClass(jsdoc,functionName,funNode,typeParameters,registry);
  ImmutableSet<NominalType> implementedIntfs=getImplementedInterfaces(jsdoc,registry,typeParameters);
  if (constructorType == null && jsdoc.isConstructorOrInterface()) {
    return builder.buildDeclaration();
  }
 else   if (jsdoc.isConstructor()) {
    handleConstructorAnnotation(functionName,funNode,constructorType,parentClass,implementedIntfs,registry,builder);
  }
 else   if (jsdoc.isInterface()) {
    handleInterfaceAnnotation(jsdoc,functionName,funNode,constructorType,implementedIntfs,typeParameters,registry,builder);
  }
 else   if (!implementedIntfs.isEmpty()) {
    warnings.add(JSError.make(funNode,IMPLEMENTS_WITHOUT_CONSTRUCTOR,functionName));
  }
  if (jsdoc.hasThisType() && ownerType == null) {
    Node thisRoot=jsdoc.getThisType().getRoot();
    Preconditions.checkState(thisRoot.getType() == Token.BANG);
    Node thisNode=thisRoot.getFirstChild();
    JSType thisType=getMaybeTypeFromComment(thisNode,registry,typeParameters);
    if (thisType != null) {
      thisType=thisType.removeType(JSType.NULL);
    }
    NominalType nt=thisType == null ? null : thisType.getNominalTypeIfSingletonObj();
    NominalType builtinObject=registry.getCommonTypes().getObjectType();
    builder.addReceiverType(nt == null ? builtinObject : nt);
  }
  return builder.buildDeclaration();
}

Fixed version (ground truth):
private DeclaredFunctionType getFunTypeFromTypicalFunctionJsdoc(JSDocInfo jsdoc,String functionName,Node funNode,RawNominalType constructorType,RawNominalType ownerType,DeclaredTypeRegistry registry,FunctionTypeBuilder builder,boolean ignoreJsdoc){
  Preconditions.checkArgument(!ignoreJsdoc || jsdoc == null);
  Preconditions.checkArgument(!ignoreJsdoc || funNode.isFunction());
  ImmutableList<String> typeParameters=ImmutableList.of();
  Node parent=funNode.getParent();
  if (jsdoc != null) {
    typeParameters=jsdoc.getTemplateTypeNames();
    if (typeParameters.isEmpty()) {
      typeParameters=jsdoc.getTypeTransformations().keySet().asList();
    }
    if (!typeParameters.isEmpty()) {
      if (parent.isSetterDef() || parent.isGetterDef()) {
        ignoreJsdoc=true;
        jsdoc=null;
        warn("String_Node_Str",funNode);
      }
 else {
        builder.addTypeParameters(typeParameters);
      }
    }
  }
  if (ownerType != null) {
    ImmutableList.Builder<String> paramsBuilder=new ImmutableList.Builder<>();
    paramsBuilder.addAll(typeParameters);
    paramsBuilder.addAll(ownerType.getTypeParameters());
    typeParameters=paramsBuilder.build();
  }
  fillInFormalParameterTypes(jsdoc,funNode,typeParameters,registry,builder,ignoreJsdoc);
  fillInReturnType(jsdoc,funNode,parent,typeParameters,registry,builder,ignoreJsdoc);
  if (jsdoc == null) {
    return builder.buildDeclaration();
  }
  NominalType parentClass=getMaybeParentClass(jsdoc,functionName,funNode,typeParameters,registry);
  ImmutableSet<NominalType> implementedIntfs=getImplementedInterfaces(jsdoc,registry,typeParameters);
  if (constructorType == null && jsdoc.isConstructorOrInterface()) {
    return builder.buildDeclaration();
  }
 else   if (jsdoc.isConstructor()) {
    handleConstructorAnnotation(functionName,funNode,constructorType,parentClass,implementedIntfs,registry,builder);
  }
 else   if (jsdoc.isInterface()) {
    handleInterfaceAnnotation(jsdoc,functionName,funNode,constructorType,implementedIntfs,typeParameters,registry,builder);
  }
 else   if (!implementedIntfs.isEmpty()) {
    warnings.add(JSError.make(funNode,IMPLEMENTS_WITHOUT_CONSTRUCTOR,functionName));
  }
  if (jsdoc.hasThisType() && ownerType == null) {
    Node thisRoot=jsdoc.getThisType().getRoot();
    Preconditions.checkState(thisRoot.getType() == Token.BANG);
    Node thisNode=thisRoot.getFirstChild();
    JSType thisType=getMaybeTypeFromComment(thisNode,registry,typeParameters);
    if (thisType != null) {
      thisType=thisType.removeType(JSType.NULL);
    }
    NominalType nt=thisType == null ? null : thisType.getNominalTypeIfSingletonObj();
    NominalType builtinObject=registry.getCommonTypes().getObjectType();
    builder.addReceiverType(nt == null ? builtinObject : nt);
  }
  return builder.buildDeclaration();
}