Buggy code:
public class CompilationUnitScope extends Scope { public LookupEnvironment environment ; public CompilationUnitDeclaration referenceContext ; public char [ ] [ ] currentPackageName ; public PackageBinding fPackage ; public ImportBinding [ ] imports ; public SourceTypeBinding [ ] topLevelTypes ; private CompoundNameVector qualifiedReferences ; private SimpleNameVector simpleNameReferences ; private ObjectVector referencedTypes ; private ObjectVector namespaceDependencies ; private ObjectVector typeDependencies ; public CompilationUnitScope ( CompilationUnitDeclaration unit , LookupEnvironment environment ) { } public void addNamespaceReference ( PackageBinding packageBinding ) { } public void addTypeReference ( TypeBinding type ) { } public void addTypeReferences ( TypeBinding [ ] types ) { } void buildFieldsAndMethods ( ) { } void buildTypeBindings ( ) { topLevelTypes = new SourceTypeBinding [ 0 ] ; if ( ( referenceContext . compilationResult . compilationUnit ) != null ) { char [ ] [ ] expectedPackageName = referenceContext . compilationResult . compilationUnit . getPackageName ( ) ; if ( ( expectedPackageName != null ) && ( ! ( CharOperation . equals ( currentPackageName , expectedPackageName ) ) ) ) { problemReporter ( ) . packageIsNotExpectedPackage ( referenceContext ) ; currentPackageName = ( ( expectedPackageName . length ) == 0 ) ? NoCharChar : expectedPackageName ; } } if ( ( currentPackageName ) == ( NoCharChar ) ) { if ( ( fPackage = environment . defaultPackage ) == null ) { problemReporter ( ) . mustSpecifyPackage ( referenceContext ) ; return ; } } else { if ( ( fPackage = environment . createPackage ( currentPackageName ) ) == null ) { problemReporter ( ) . packageCollidesWithType ( referenceContext ) ; return ; } recordQualifiedReference ( currentPackageName ) ; } TypeDeclaration [ ] types = referenceContext . types ; int typeLength = ( types == null ) ? 0 : types . length ; topLevelTypes = new SourceTypeBinding [ typeLength ] ; int count = 0 ; nextType : for ( int i = 0 ; i < typeLength ; i ++ ) { TypeDeclaration typeDecl = types [ i ] ; ReferenceBinding typeBinding = fPackage . getType0 ( typeDecl . name ) ; <START_BUG> recordReference ( currentPackageName , typeDecl . name ) ; <END_BUG> if ( ( typeBinding != null ) && ( ! ( typeBinding instanceof UnresolvedReferenceBinding ) ) ) { problemReporter ( ) . duplicateTypes ( referenceContext , typeDecl ) ; continue nextType ; } boolean packageExists = ( ( currentPackageName ) == ( NoCharChar ) ) ? ( environment . getTopLevelPackage ( typeDecl . name ) ) != null : ( ( fPackage . getPackage0 ( typeDecl . name ) ) != null ) || ( environment . isPackage ( currentPackageName , typeDecl . name ) ) ; if ( packageExists ) { problemReporter ( ) . typeCollidesWithPackage ( referenceContext , typeDecl ) ; continue nextType ; } if ( ( ( typeDecl . modifiers ) & ( AccPublic ) ) != 0 ) { char [ ] mainTypeName ; if ( ( ( mainTypeName = referenceContext . getMainTypeName ( ) ) != null ) && ( ! ( CharOperation . equals ( mainTypeName , typeDecl . name ) ) ) ) { problemReporter ( ) . publicClassMustMatchFileName ( referenceContext , typeDecl ) ; continue nextType ; } } ClassScope child = new ClassScope ( this , typeDecl ) ; topLevelTypes [ ( count ++ ) ] = child . buildType ( null , fPackage ) ; } if ( count != ( topLevelTypes . length ) ) System . arraycopy ( topLevelTypes , 0 , ( topLevelTypes = new SourceTypeBinding [ count ] ) , 0 , count ) ; } void checkAndSetImports ( ) { } void connectTypeHierarchy ( ) { } void faultInImports ( ) { } public void faultInTypes ( ) { } private Binding findOnDemandImport ( char [ ] [ ] compoundName ) { } private Binding findSingleTypeImport ( char [ ] [ ] compoundName ) { } public ProblemReporter problemReporter ( ) { } void recordQualifiedReference ( char [ ] [ ] qualifiedName ) { } void recordReference ( char [ ] [ ] qualifiedEnclosingName , char [ ] simpleName ) { } void recordSimpleReference ( char [ ] simpleName ) { } void recordTypeReference ( TypeBinding type ) { } void recordTypeReferences ( TypeBinding [ ] types ) { } Binding resolveSingleTypeImport ( ImportBinding importBinding ) { } public void storeDependencyInfo ( ) { } public String toString ( ) { } public void verifyMethods ( MethodVerifier verifier ) { } }

Fix:
recordSimpleReference ( typeDecl . name ) ;