Buggy code:
public class CompilationUnitScope extends Scope { public LookupEnvironment environment ; public CompilationUnitDeclaration referenceContext ; public char [ ] [ ] currentPackageName ; public PackageBinding fPackage ; public ImportBinding [ ] imports ; public HashtableOfObject typeOrPackageCache ; public SourceTypeBinding [ ] topLevelTypes ; private CompoundNameVector qualifiedReferences ; private SimpleNameVector simpleNameReferences ; private ObjectVector referencedTypes ; private ObjectVector referencedSuperTypes ; HashtableOfType constantPoolNameUsage ; private int captureID = 1 ; public CompilationUnitScope ( CompilationUnitDeclaration unit , LookupEnvironment environment ) { } void buildFieldsAndMethods ( ) { } void buildTypeBindings ( AccessRestriction accessRestriction ) { } void checkAndSetImports ( ) { } void checkParameterizedTypes ( ) { } public char [ ] computeConstantPoolName ( LocalTypeBinding localType ) { } void connectTypeHierarchy ( ) { } void faultInImports ( ) { } public void faultInTypes ( ) { } public Binding findImport ( char [ ] [ ] compoundName , boolean findStaticImports , boolean onDemand ) { } private Binding findImport ( char [ ] [ ] compoundName , int length ) { recordQualifiedReference ( compoundName ) ; Binding binding = environment . getTopLevelPackage ( compoundName [ 0 ] ) ; int i = 1 ; foundNothingOrType : if ( binding != null ) { PackageBinding packageBinding = ( ( PackageBinding ) ( binding ) ) ; while ( i < length ) { binding = packageBinding . getTypeOrPackage ( compoundName [ ( i ++ ) ] ) ; if ( ( binding == null ) || ( ! ( binding . isValidBinding ( ) ) ) ) { binding = null ; break foundNothingOrType ; } if ( ! ( binding instanceof PackageBinding ) ) break foundNothingOrType ; packageBinding = ( ( PackageBinding ) ( binding ) ) ; } return packageBinding ; } ReferenceBinding type ; if ( binding == null ) { if ( ( ( environment . defaultPackage ) == null ) || ( ( compilerOptions ( ) . complianceLevel ) >= ( ClassFileConstants . JDK1_4 ) ) ) return new ProblemReferenceBinding ( CharOperation . subarray ( compoundName , 0 , i ) , null , ProblemReasons . NotFound ) ; type = findType ( compoundName [ 0 ] , environment . defaultPackage , environment . defaultPackage ) ; if ( ( type == null ) || ( ! ( type . isValidBinding ( ) ) ) ) return new ProblemReferenceBinding ( CharOperation . subarray ( compoundName , 0 , i ) , null , ProblemReasons . NotFound ) ; i = 1 ; } else { type = ( ( ReferenceBinding ) ( binding ) ) ; } while ( i < length ) { <START_BUG> type = ( ( ReferenceBinding ) ( environment . convertToRawType ( type ) ) ) ; <END_BUG> if ( ! ( type . canBeSeenBy ( fPackage ) ) ) return new ProblemReferenceBinding ( CharOperation . subarray ( compoundName , 0 , i ) , type , ProblemReasons . NotVisible ) ; char [ ] name = compoundName [ ( i ++ ) ] ; type = type . getMemberType ( name ) ; if ( type == null ) return new ProblemReferenceBinding ( CharOperation . subarray ( compoundName , 0 , i ) , null , ProblemReasons . NotFound ) ; } if ( ! ( type . canBeSeenBy ( fPackage ) ) ) return new ProblemReferenceBinding ( compoundName , type , ProblemReasons . NotVisible ) ; return type ; } private Binding findSingleImport ( char [ ] [ ] compoundName , boolean findStaticImports ) { } private Binding findSingleStaticImport ( char [ ] [ ] compoundName ) { } MethodBinding findStaticMethod ( ReferenceBinding currentType , char [ ] selector ) { } ImportBinding [ ] getDefaultImports ( ) { } public final Binding getImport ( char [ ] [ ] compoundName , boolean onDemand , boolean isStaticImport ) { } public int nextCaptureID ( ) { } public ProblemReporter problemReporter ( ) { } void recordQualifiedReference ( char [ ] [ ] qualifiedName ) { } void recordReference ( char [ ] [ ] qualifiedEnclosingName , char [ ] simpleName ) { } void recordReference ( ReferenceBinding type , char [ ] simpleName ) { } void recordSimpleReference ( char [ ] simpleName ) { } void recordSuperTypeReference ( TypeBinding type ) { } public void recordTypeConversion ( TypeBinding superType , TypeBinding subType ) { } void recordTypeReference ( TypeBinding type ) { } void recordTypeReferences ( TypeBinding [ ] types ) { } Binding resolveSingleImport ( ImportBinding importBinding ) { } public void storeDependencyInfo ( ) { } public String toString ( ) { } private ReferenceBinding typeToRecord ( TypeBinding type ) { } public void verifyMethods ( MethodVerifier verifier ) { } }

Fix:
type = ( ( ReferenceBinding ) ( environment . convertToRawType ( type , false ) ) ) ;