Program: 185920
Project: 185920
Buggy source:
public TypeBinding resolveType(BlockScope scope){
  if (this.compilerAnnotation != null)   return this.resolvedType;
  this.constant=Constant.NotAConstant;
  TypeBinding typeBinding=this.type.resolveType(scope);
  if (typeBinding == null) {
    return null;
  }
  this.resolvedType=typeBinding;
  boolean isGroovyAlias=isFakeGroovyAnnotation(typeBinding);
  if (!typeBinding.isAnnotationType() && typeBinding.isValidBinding()) {
    if (isGroovyAlias) {
      this.compilerAnnotation=scope.environment().createAnnotation((ReferenceBinding)this.resolvedType,computeElementValuePairs());
    }
 else {
      scope.problemReporter().notAnnotationType(typeBinding,this.type);
    }
    return null;
  }
  ReferenceBinding annotationType=(ReferenceBinding)this.resolvedType;
  MethodBinding[] methods=annotationType.methods();
  MemberValuePair[] originalValuePairs=memberValuePairs();
  MemberValuePair valueAttribute=null;
  MemberValuePair[] pairs;
  int pairsLength=originalValuePairs.length;
  if (pairsLength > 0) {
    System.arraycopy(originalValuePairs,0,pairs=new MemberValuePair[pairsLength],0,pairsLength);
  }
 else {
    pairs=originalValuePairs;
  }
  nextMember:   for (int i=0, requiredLength=methods.length; i < requiredLength; i++) {
    MethodBinding method=methods[i];
    char[] selector=method.selector;
    boolean foundValue=false;
    nextPair:     for (int j=0; j < pairsLength; j++) {
      MemberValuePair pair=pairs[j];
      if (pair == null)       continue nextPair;
      char[] name=pair.name;
      if (CharOperation.equals(name,selector)) {
        if (valueAttribute == null && CharOperation.equals(name,TypeConstants.VALUE)) {
          valueAttribute=pair;
        }
        pair.binding=method;
        pair.resolveTypeExpecting(scope,method.returnType);
        pairs[j]=null;
        foundValue=true;
        boolean foundDuplicate=false;
        for (int k=j + 1; k < pairsLength; k++) {
          MemberValuePair otherPair=pairs[k];
          if (otherPair == null)           continue;
          if (CharOperation.equals(otherPair.name,selector)) {
            foundDuplicate=true;
            scope.problemReporter().duplicateAnnotationValue(annotationType,otherPair);
            otherPair.binding=method;
            otherPair.resolveTypeExpecting(scope,method.returnType);
            pairs[k]=null;
          }
        }
        if (foundDuplicate) {
          scope.problemReporter().duplicateAnnotationValue(annotationType,pair);
          continue nextMember;
        }
      }
    }
    if (!foundValue && (method.modifiers & ClassFileConstants.AccAnnotationDefault) == 0 && (this.bits & IsRecovered) == 0 && annotationType.isValidBinding()) {
      scope.problemReporter().missingValueForAnnotationMember(this,selector);
    }
  }
  if (!isGroovyAlias)   for (int i=0; i < pairsLength; i++) {
    if (pairs[i] != null) {
      if (annotationType.isValidBinding()) {
        scope.problemReporter().undefinedAnnotationValue(annotationType,pairs[i]);
      }
      pairs[i].resolveTypeExpecting(scope,null);
    }
  }
  this.compilerAnnotation=scope.environment().createAnnotation((ReferenceBinding)this.resolvedType,isGroovyAlias ? Binding.NO_ELEMENT_VALUE_PAIRS : computeElementValuePairs());
  long tagBits=detectStandardAnnotation(scope,annotationType,valueAttribute);
  int defaultNullness=(int)(tagBits & Binding.NullnessDefaultMASK);
  tagBits&=~Binding.NullnessDefaultMASK;
  scope.referenceCompilationUnit().recordSuppressWarnings(IrritantSet.NLS,null,this.sourceStart,this.declarationSourceEnd,scope.referenceContext());
  if (this.recipient != null) {
    int kind=this.recipient.kind();
    if (tagBits != 0 || defaultNullness != 0) {
switch (kind) {
case Binding.PACKAGE:
        ((PackageBinding)this.recipient).tagBits|=tagBits;
      break;
case Binding.TYPE:
case Binding.GENERIC_TYPE:
    SourceTypeBinding sourceType=(SourceTypeBinding)this.recipient;
  if ((tagBits & TagBits.AnnotationRepeatable) == 0 || sourceType.isAnnotationType())   sourceType.tagBits|=tagBits;
if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) {
  TypeDeclaration typeDeclaration=sourceType.scope.referenceContext;
  int start;
  if (scope.referenceCompilationUnit().types[0] == typeDeclaration) {
    start=0;
  }
 else {
    start=typeDeclaration.declarationSourceStart;
  }
  recordSuppressWarnings(scope,start,typeDeclaration.declarationSourceEnd,scope.compilerOptions().suppressWarnings);
}
sourceType.defaultNullness|=defaultNullness;
break;
case Binding.METHOD:
MethodBinding sourceMethod=(MethodBinding)this.recipient;
sourceMethod.tagBits|=tagBits;
if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) {
sourceType=(SourceTypeBinding)sourceMethod.declaringClass;
AbstractMethodDeclaration methodDeclaration=sourceType.scope.referenceContext.declarationOf(sourceMethod);
recordSuppressWarnings(scope,methodDeclaration.declarationSourceStart,methodDeclaration.declarationSourceEnd,scope.compilerOptions().suppressWarnings);
}
long nullBits=sourceMethod.tagBits & TagBits.AnnotationNullMASK;
if (nullBits == TagBits.AnnotationNullMASK) {
scope.problemReporter().contradictoryNullAnnotations(this);
sourceMethod.tagBits&=~TagBits.AnnotationNullMASK;
}
if (nullBits != 0 && sourceMethod.isConstructor()) {
if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_8) scope.problemReporter().nullAnnotationUnsupportedLocation(this);
sourceMethod.tagBits&=~TagBits.AnnotationNullMASK;
}
sourceMethod.defaultNullness|=defaultNullness;
break;
case Binding.FIELD:
FieldBinding sourceField=(FieldBinding)this.recipient;
sourceField.tagBits|=tagBits;
if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) {
sourceType=(SourceTypeBinding)sourceField.declaringClass;
FieldDeclaration fieldDeclaration=sourceType.scope.referenceContext.declarationOf(sourceField);
recordSuppressWarnings(scope,fieldDeclaration.declarationSourceStart,fieldDeclaration.declarationSourceEnd,scope.compilerOptions().suppressWarnings);
}
if ((sourceField.tagBits & TagBits.AnnotationNullMASK) == TagBits.AnnotationNullMASK) {
scope.problemReporter().contradictoryNullAnnotations(this);
sourceField.tagBits&=~TagBits.AnnotationNullMASK;
}
break;
case Binding.LOCAL:
LocalVariableBinding variable=(LocalVariableBinding)this.recipient;
variable.tagBits|=tagBits;
if ((variable.tagBits & TagBits.AnnotationNullMASK) == TagBits.AnnotationNullMASK) {
scope.problemReporter().contradictoryNullAnnotations(this);
variable.tagBits&=~TagBits.AnnotationNullMASK;
}
if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) {
LocalDeclaration localDeclaration=variable.declaration;
recordSuppressWarnings(scope,localDeclaration.declarationSourceStart,localDeclaration.declarationSourceEnd,scope.compilerOptions().suppressWarnings);
}
break;
}
}
if (kind == Binding.TYPE) {
SourceTypeBinding sourceType=(SourceTypeBinding)this.recipient;
if (CharOperation.equals(sourceType.sourceName,TypeConstants.PACKAGE_INFO_NAME)) kind=Binding.PACKAGE;
}
checkAnnotationTarget(this,scope,annotationType,kind,this.recipient,tagBits & TagBits.AnnotationNullMASK);
}
return this.resolvedType;
}

Fixed version (ground truth):
public TypeBinding resolveType(BlockScope scope){
  if (this.compilerAnnotation != null)   return this.resolvedType;
  this.constant=Constant.NotAConstant;
  TypeBinding typeBinding=this.type.resolveType(scope);
  if (typeBinding == null) {
    return null;
  }
  this.resolvedType=typeBinding;
  boolean isGroovyAlias=isFakeGroovyAnnotation(typeBinding);
  if (!typeBinding.isAnnotationType() && typeBinding.isValidBinding()) {
    if (isGroovyAlias) {
      this.compilerAnnotation=scope.environment().createAnnotation((ReferenceBinding)this.resolvedType,Binding.NO_ELEMENT_VALUE_PAIRS);
    }
 else {
      scope.problemReporter().notAnnotationType(typeBinding,this.type);
    }
    return null;
  }
  ReferenceBinding annotationType=(ReferenceBinding)this.resolvedType;
  MethodBinding[] methods=annotationType.methods();
  MemberValuePair[] originalValuePairs=memberValuePairs();
  MemberValuePair valueAttribute=null;
  MemberValuePair[] pairs;
  int pairsLength=originalValuePairs.length;
  if (pairsLength > 0) {
    System.arraycopy(originalValuePairs,0,pairs=new MemberValuePair[pairsLength],0,pairsLength);
  }
 else {
    pairs=originalValuePairs;
  }
  nextMember:   for (int i=0, requiredLength=methods.length; i < requiredLength; i++) {
    MethodBinding method=methods[i];
    char[] selector=method.selector;
    boolean foundValue=false;
    nextPair:     for (int j=0; j < pairsLength; j++) {
      MemberValuePair pair=pairs[j];
      if (pair == null)       continue nextPair;
      char[] name=pair.name;
      if (CharOperation.equals(name,selector)) {
        if (valueAttribute == null && CharOperation.equals(name,TypeConstants.VALUE)) {
          valueAttribute=pair;
        }
        pair.binding=method;
        pair.resolveTypeExpecting(scope,method.returnType);
        pairs[j]=null;
        foundValue=true;
        boolean foundDuplicate=false;
        for (int k=j + 1; k < pairsLength; k++) {
          MemberValuePair otherPair=pairs[k];
          if (otherPair == null)           continue;
          if (CharOperation.equals(otherPair.name,selector)) {
            foundDuplicate=true;
            scope.problemReporter().duplicateAnnotationValue(annotationType,otherPair);
            otherPair.binding=method;
            otherPair.resolveTypeExpecting(scope,method.returnType);
            pairs[k]=null;
          }
        }
        if (foundDuplicate) {
          scope.problemReporter().duplicateAnnotationValue(annotationType,pair);
          continue nextMember;
        }
      }
    }
    if (!foundValue && (method.modifiers & ClassFileConstants.AccAnnotationDefault) == 0 && (this.bits & IsRecovered) == 0 && annotationType.isValidBinding()) {
      scope.problemReporter().missingValueForAnnotationMember(this,selector);
    }
  }
  if (!isGroovyAlias)   for (int i=0; i < pairsLength; i++) {
    if (pairs[i] != null) {
      if (annotationType.isValidBinding()) {
        scope.problemReporter().undefinedAnnotationValue(annotationType,pairs[i]);
      }
      pairs[i].resolveTypeExpecting(scope,null);
    }
  }
  this.compilerAnnotation=scope.environment().createAnnotation((ReferenceBinding)this.resolvedType,isGroovyAlias ? Binding.NO_ELEMENT_VALUE_PAIRS : computeElementValuePairs());
  long tagBits=detectStandardAnnotation(scope,annotationType,valueAttribute);
  int defaultNullness=(int)(tagBits & Binding.NullnessDefaultMASK);
  tagBits&=~Binding.NullnessDefaultMASK;
  scope.referenceCompilationUnit().recordSuppressWarnings(IrritantSet.NLS,null,this.sourceStart,this.declarationSourceEnd,scope.referenceContext());
  if (this.recipient != null) {
    int kind=this.recipient.kind();
    if (tagBits != 0 || defaultNullness != 0) {
switch (kind) {
case Binding.PACKAGE:
        ((PackageBinding)this.recipient).tagBits|=tagBits;
      break;
case Binding.TYPE:
case Binding.GENERIC_TYPE:
    SourceTypeBinding sourceType=(SourceTypeBinding)this.recipient;
  if ((tagBits & TagBits.AnnotationRepeatable) == 0 || sourceType.isAnnotationType())   sourceType.tagBits|=tagBits;
if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) {
  TypeDeclaration typeDeclaration=sourceType.scope.referenceContext;
  int start;
  if (scope.referenceCompilationUnit().types[0] == typeDeclaration) {
    start=0;
  }
 else {
    start=typeDeclaration.declarationSourceStart;
  }
  recordSuppressWarnings(scope,start,typeDeclaration.declarationSourceEnd,scope.compilerOptions().suppressWarnings);
}
sourceType.defaultNullness|=defaultNullness;
break;
case Binding.METHOD:
MethodBinding sourceMethod=(MethodBinding)this.recipient;
sourceMethod.tagBits|=tagBits;
if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) {
sourceType=(SourceTypeBinding)sourceMethod.declaringClass;
AbstractMethodDeclaration methodDeclaration=sourceType.scope.referenceContext.declarationOf(sourceMethod);
recordSuppressWarnings(scope,methodDeclaration.declarationSourceStart,methodDeclaration.declarationSourceEnd,scope.compilerOptions().suppressWarnings);
}
long nullBits=sourceMethod.tagBits & TagBits.AnnotationNullMASK;
if (nullBits == TagBits.AnnotationNullMASK) {
scope.problemReporter().contradictoryNullAnnotations(this);
sourceMethod.tagBits&=~TagBits.AnnotationNullMASK;
}
if (nullBits != 0 && sourceMethod.isConstructor()) {
if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_8) scope.problemReporter().nullAnnotationUnsupportedLocation(this);
sourceMethod.tagBits&=~TagBits.AnnotationNullMASK;
}
sourceMethod.defaultNullness|=defaultNullness;
break;
case Binding.FIELD:
FieldBinding sourceField=(FieldBinding)this.recipient;
sourceField.tagBits|=tagBits;
if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) {
sourceType=(SourceTypeBinding)sourceField.declaringClass;
FieldDeclaration fieldDeclaration=sourceType.scope.referenceContext.declarationOf(sourceField);
recordSuppressWarnings(scope,fieldDeclaration.declarationSourceStart,fieldDeclaration.declarationSourceEnd,scope.compilerOptions().suppressWarnings);
}
if ((sourceField.tagBits & TagBits.AnnotationNullMASK) == TagBits.AnnotationNullMASK) {
scope.problemReporter().contradictoryNullAnnotations(this);
sourceField.tagBits&=~TagBits.AnnotationNullMASK;
}
break;
case Binding.LOCAL:
LocalVariableBinding variable=(LocalVariableBinding)this.recipient;
variable.tagBits|=tagBits;
if ((variable.tagBits & TagBits.AnnotationNullMASK) == TagBits.AnnotationNullMASK) {
scope.problemReporter().contradictoryNullAnnotations(this);
variable.tagBits&=~TagBits.AnnotationNullMASK;
}
if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) {
LocalDeclaration localDeclaration=variable.declaration;
recordSuppressWarnings(scope,localDeclaration.declarationSourceStart,localDeclaration.declarationSourceEnd,scope.compilerOptions().suppressWarnings);
}
break;
}
}
if (kind == Binding.TYPE) {
SourceTypeBinding sourceType=(SourceTypeBinding)this.recipient;
if (CharOperation.equals(sourceType.sourceName,TypeConstants.PACKAGE_INFO_NAME)) kind=Binding.PACKAGE;
}
checkAnnotationTarget(this,scope,annotationType,kind,this.recipient,tagBits & TagBits.AnnotationNullMASK);
}
return this.resolvedType;
}