Buggy code:
if ( typeOrPackageCache != null ) { Binding binding = ( ( Binding ) ( typeOrPackageCache . get ( name ) ) ) ; if ( binding != null ) { if ( binding instanceof ImportBinding ) { ImportReference importReference = ( ( ImportBinding ) ( binding ) ) . reference ; if ( importReference != null ) importReference . used = true ; typeOrPackageCache . put ( name , ( binding = ( ( ImportBinding ) ( binding ) ) . resolvedImport ) ) ; } if ( ( foundType != null ) && ( ( binding . problemId ( ) ) != ( ProblemReasons . Ambiguous ) ) ) return foundType ; return binding ; } } if ( ( mask & ( Binding . TYPE ) ) != 0 ) { ImportBinding [ ] imports = unitScope . imports ; if ( ( imports != null ) && ( typeOrPackageCache == null ) ) { for ( int i = 0 , length = imports . length ; i < length ; i ++ ) { ImportBinding typeImport = imports [ i ] ; if ( ! ( typeImport . onDemand ) ) { if ( CharOperation . equals ( typeImport . compoundName [ ( ( typeImport . compoundName . length ) - 1 ) ] , name ) ) { Binding resolvedImport = unitScope . resolveSingleImport ( typeImport ) ; if ( ( resolvedImport != null ) && ( resolvedImport instanceof TypeBinding ) ) { ImportReference importReference = typeImport . reference ; if ( importReference != null ) importReference . used = true ; return resolvedImport ; } } } } } PackageBinding currentPackage = unitScope . fPackage ; unitScope . recordReference ( currentPackage . compoundName , name ) ; Binding binding = currentPackage . getTypeOrPackage ( name ) ; if ( binding instanceof ReferenceBinding ) { if ( typeOrPackageCache != null ) typeOrPackageCache . put ( name , binding ) ; return binding ; } if ( imports != null ) { boolean foundInImport = false ; ReferenceBinding type = null ; for ( int i = 0 , length = imports . length ; i < length ; i ++ ) { ImportBinding someImport = imports [ i ] ; if ( someImport . onDemand ) { Binding resolvedImport = someImport . resolvedImport ; ReferenceBinding temp = ( resolvedImport instanceof PackageBinding ) ? findType ( name , ( ( PackageBinding ) ( resolvedImport ) ) , currentPackage ) : someImport . isStatic ( ) ? findMemberType ( name , ( ( ReferenceBinding ) ( resolvedImport ) ) ) : findDirectMemberType ( name , ( ( ReferenceBinding ) ( resolvedImport ) ) ) ; if ( temp != null ) { if ( temp . isValidBinding ( ) ) { ImportReference importReference = someImport . reference ; if ( importReference != null ) importReference . used = true ; if ( foundInImport ) { temp = new ProblemReferenceBinding ( name , ProblemReasons . Ambiguous ) ; if ( typeOrPackageCache != null ) typeOrPackageCache . put ( name , temp ) ; return temp ; } type = temp ; foundInImport = true ; } else if ( foundType == null ) { foundType = temp ; } } } } if ( type != null ) { if ( typeOrPackageCache != null ) typeOrPackageCache . put ( name , type ) ; return type ; } } } unitScope . recordSimpleReference ( name ) ; if ( ( mask & ( Binding . PACKAGE ) ) != 0 ) { PackageBinding packageBinding = unitScope . environment . getTopLevelPackage ( name ) ; if ( packageBinding != null ) { if ( typeOrPackageCache != null ) typeOrPackageCache . put ( name , packageBinding ) ; return packageBinding ; } } if ( foundType == null ) { foundType = new ProblemReferenceBinding ( name , ProblemReasons . NotFound ) ; <START_BUG> if ( typeOrPackageCache != null ) <END_BUG> typeOrPackageCache . put ( name , foundType ) ; } return foundType ; } public final Binding getTypeOrPackage ( char [ ] [ ] compoundName ) { } public static TypeBinding [ ] greaterLowerBound ( TypeBinding [ ] types ) { } public static ReferenceBinding [ ] greaterLowerBound ( ReferenceBinding [ ] types ) { } public CaseStatement innermostSwitchCase ( ) { } public boolean isBoxingCompatibleWith ( TypeBinding left , TypeBinding right ) { } public final boolean isDefinedInField ( FieldBinding field ) { } public final boolean isDefinedInMethod ( MethodBinding method ) { } public final boolean isDefinedInSameUnit ( ReferenceBinding type ) { } public final boolean isDefinedInType ( ReferenceBinding type ) { } public boolean isInsideCase ( CaseStatement caseStatement ) { } public boolean isInsideDeprecatedCode ( ) { } private TypeBinding leastContainingInvocation ( TypeBinding mec , Set invocations , List lubStack ) { } private TypeBinding leastContainingTypeArgument ( TypeBinding u , TypeBinding v , ReferenceBinding genericType , int rank , List lubStack ) { } public TypeBinding lowerUpperBound ( TypeBinding [ ] types ) { } private TypeBinding lowerUpperBound ( TypeBinding [ ] types , List lubStack ) { } public final MethodScope methodScope ( ) { } private TypeBinding [ ] minimalErasedCandidates ( TypeBinding [ ] types , Map allInvocations ) { } protected final MethodBinding mostSpecificClassMethodBinding ( MethodBinding [ ] visible , int visibleSize , InvocationSite invocationSite ) { } protected final MethodBinding mostSpecificInterfaceMethodBinding ( MethodBinding [ ] visible , int visibleSize , InvocationSite invocationSite ) { } protected final MethodBinding mostSpecificMethodBinding ( MethodBinding [ ] visible , int visibleSize , TypeBinding [ ] argumentTypes , InvocationSite invocationSite ) { } public final ClassScope outerMostClassScope ( ) { } public final MethodScope outerMostMethodScope ( ) { } protected int parameterCompatibilityLevel ( MethodBinding method , TypeBinding [ ] arguments ) { } private int parameterCompatibilityLevel ( TypeBinding arg , TypeBinding param , LookupEnvironment env ) { } public abstract ProblemReporter problemReporter ( ) { } public final CompilationUnitDeclaration referenceCompilationUnit ( ) { }

Fix:
if ( ( typeOrPackageCache != null ) && ( ( mask & ( Binding . PACKAGE ) ) != 0 ) )