Program: 185917
Project: 185917
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().typeMismatchError(typeBinding,scope.getJavaLangAnnotationAnnotation(),this.type,null);
    }
    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) {
      scope.problemReporter().missingValueForAnnotationMember(this,selector);
    }
  }
  if (!isGroovyAlias)   for (int i=0; i < pairsLength; i++) {
    if (pairs[i] != null) {
      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);
  scope.referenceCompilationUnit().recordSuppressWarnings(IrritantSet.NLS,null,this.sourceStart,this.declarationSourceEnd);
  if (this.recipient != null) {
    if (tagBits != 0) {
switch (this.recipient.kind()) {
case Binding.PACKAGE:
        ((PackageBinding)this.recipient).tagBits|=tagBits;
      break;
case Binding.TYPE:
case Binding.GENERIC_TYPE:
    SourceTypeBinding sourceType=(SourceTypeBinding)this.recipient;
  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);
}
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);
}
if ((sourceMethod.tagBits & TAGBITS_NULLABLE_OR_NONNULL) == TAGBITS_NULLABLE_OR_NONNULL) {
scope.problemReporter().contradictoryNullAnnotations(this);
sourceMethod.tagBits&=~TAGBITS_NULLABLE_OR_NONNULL;
}
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_NULLABLE_OR_NONNULL) == TAGBITS_NULLABLE_OR_NONNULL) {
scope.problemReporter().contradictoryNullAnnotations(this);
sourceField.tagBits&=~TAGBITS_NULLABLE_OR_NONNULL;
}
break;
case Binding.LOCAL:
LocalVariableBinding variable=(LocalVariableBinding)this.recipient;
variable.tagBits|=tagBits;
if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) {
LocalDeclaration localDeclaration=variable.declaration;
recordSuppressWarnings(scope,localDeclaration.declarationSourceStart,localDeclaration.declarationSourceEnd,scope.compilerOptions().suppressWarnings);
}
if ((variable.tagBits & TAGBITS_NULLABLE_OR_NONNULL) == TAGBITS_NULLABLE_OR_NONNULL) {
scope.problemReporter().contradictoryNullAnnotations(this);
variable.tagBits&=~TAGBITS_NULLABLE_OR_NONNULL;
}
break;
}
}
if (scope.compilationUnitScope().checkTargetCompatibility()) {
checkTargetCompatibility: {
long metaTagBits=annotationType.getAnnotationTagBits();
if ((metaTagBits & TagBits.AnnotationTargetMASK) == 0) break checkTargetCompatibility;
switch (this.recipient.kind()) {
case Binding.PACKAGE:
if ((metaTagBits & TagBits.AnnotationForPackage) != 0) break checkTargetCompatibility;
break;
case Binding.TYPE:
case Binding.GENERIC_TYPE:
if (((ReferenceBinding)this.recipient).isAnnotationType()) {
if ((metaTagBits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType)) != 0) break checkTargetCompatibility;
}
 else if ((metaTagBits & TagBits.AnnotationForType) != 0) {
break checkTargetCompatibility;
}
 else if ((metaTagBits & TagBits.AnnotationForPackage) != 0) {
if (CharOperation.equals(((ReferenceBinding)this.recipient).sourceName,TypeConstants.PACKAGE_INFO_NAME)) break checkTargetCompatibility;
}
break;
case Binding.METHOD:
if (((MethodBinding)this.recipient).isConstructor()) {
if ((metaTagBits & TagBits.AnnotationForConstructor) != 0) break checkTargetCompatibility;
}
 else if ((metaTagBits & TagBits.AnnotationForMethod) != 0) break checkTargetCompatibility;
break;
case Binding.FIELD:
if ((metaTagBits & TagBits.AnnotationForField) != 0) break checkTargetCompatibility;
break;
case Binding.LOCAL:
if ((((LocalVariableBinding)this.recipient).tagBits & TagBits.IsArgument) != 0) {
if ((metaTagBits & TagBits.AnnotationForParameter) != 0) break checkTargetCompatibility;
}
 else if ((annotationType.tagBits & TagBits.AnnotationForLocalVariable) != 0) break checkTargetCompatibility;
break;
}
scope.problemReporter().disallowedTargetForAnnotation(this);
}
}
}
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().typeMismatchError(typeBinding,scope.getJavaLangAnnotationAnnotation(),this.type,null);
    }
    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) {
      scope.problemReporter().missingValueForAnnotationMember(this,selector);
    }
  }
  if (!isGroovyAlias)   for (int i=0; i < pairsLength; i++) {
    if (pairs[i] != null) {
      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);
  scope.referenceCompilationUnit().recordSuppressWarnings(IrritantSet.NLS,null,this.sourceStart,this.declarationSourceEnd);
  if (this.recipient != null) {
    if (tagBits != 0) {
switch (this.recipient.kind()) {
case Binding.PACKAGE:
        ((PackageBinding)this.recipient).tagBits|=tagBits;
      break;
case Binding.TYPE:
case Binding.GENERIC_TYPE:
    SourceTypeBinding sourceType=(SourceTypeBinding)this.recipient;
  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);
}
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);
}
if ((sourceMethod.tagBits & TAGBITS_NULLABLE_OR_NONNULL) == TAGBITS_NULLABLE_OR_NONNULL) {
scope.problemReporter().contradictoryNullAnnotations(this);
sourceMethod.tagBits&=~TAGBITS_NULLABLE_OR_NONNULL;
}
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_NULLABLE_OR_NONNULL) == TAGBITS_NULLABLE_OR_NONNULL) {
scope.problemReporter().contradictoryNullAnnotations(this);
sourceField.tagBits&=~TAGBITS_NULLABLE_OR_NONNULL;
}
break;
case Binding.LOCAL:
LocalVariableBinding variable=(LocalVariableBinding)this.recipient;
variable.tagBits|=tagBits;
if ((tagBits & TagBits.AnnotationSuppressWarnings) != 0) {
LocalDeclaration localDeclaration=variable.declaration;
recordSuppressWarnings(scope,localDeclaration.declarationSourceStart,localDeclaration.declarationSourceEnd,scope.compilerOptions().suppressWarnings);
}
if ((variable.tagBits & TAGBITS_NULLABLE_OR_NONNULL) == TAGBITS_NULLABLE_OR_NONNULL) {
scope.problemReporter().contradictoryNullAnnotations(this);
variable.tagBits&=~TAGBITS_NULLABLE_OR_NONNULL;
}
break;
}
}
if (scope.compilationUnitScope().checkTargetCompatibility()) {
checkTargetCompatibility: {
long metaTagBits=annotationType.getAnnotationTagBits();
if ((metaTagBits & TagBits.AnnotationTargetMASK) == 0) break checkTargetCompatibility;
switch (this.recipient.kind()) {
case Binding.PACKAGE:
if ((metaTagBits & TagBits.AnnotationForPackage) != 0) break checkTargetCompatibility;
break;
case Binding.TYPE:
case Binding.GENERIC_TYPE:
if (((ReferenceBinding)this.recipient).isAnnotationType()) {
if ((metaTagBits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType)) != 0) break checkTargetCompatibility;
}
 else if ((metaTagBits & TagBits.AnnotationForType) != 0) {
break checkTargetCompatibility;
}
 else if ((metaTagBits & TagBits.AnnotationForPackage) != 0) {
if (CharOperation.equals(((ReferenceBinding)this.recipient).sourceName,TypeConstants.PACKAGE_INFO_NAME)) break checkTargetCompatibility;
}
break;
case Binding.METHOD:
if (((MethodBinding)this.recipient).isConstructor()) {
if ((metaTagBits & TagBits.AnnotationForConstructor) != 0) break checkTargetCompatibility;
}
 else if ((metaTagBits & TagBits.AnnotationForMethod) != 0) break checkTargetCompatibility;
break;
case Binding.FIELD:
if ((metaTagBits & TagBits.AnnotationForField) != 0) break checkTargetCompatibility;
break;
case Binding.LOCAL:
if ((((LocalVariableBinding)this.recipient).tagBits & TagBits.IsArgument) != 0) {
if ((metaTagBits & TagBits.AnnotationForParameter) != 0) break checkTargetCompatibility;
}
 else if ((annotationType.tagBits & TagBits.AnnotationForLocalVariable) != 0) break checkTargetCompatibility;
break;
}
scope.problemReporter().disallowedTargetForAnnotation(this);
}
}
}
return this.resolvedType;
}