Buggy code:
public class NameLookup { public static final int ACCEPT_CLASSES = 2 ; public static final int ACCEPT_INTERFACES = 4 ; protected IPackageFragmentRoot [ ] fPackageFragmentRoots = null ; protected Map fPackageFragments ; protected SingleTypeRequestor fgSingleTypeRequestor = new SingleTypeRequestor ( ) ; protected JavaElementRequestor fgJavaElementRequestor = new JavaElementRequestor ( ) ; protected IWorkspace workspace ; protected HashMap unitsToLookInside = null ; public NameLookup ( IJavaProject project ) throws JavaModelException { } protected boolean acceptType ( IType type , int acceptFlags ) { } private void configureFromProject ( IJavaProject project ) throws JavaModelException { } private void findAllTypes ( String prefix , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { } public ICompilationUnit findCompilationUnit ( String qualifiedTypeName ) { } public IPackageFragment findPackageFragment ( IPath path ) { } public IPackageFragment [ ] findPackageFragments ( String name , boolean partialMatch ) { } public IType findType ( String typeName , String packageName , boolean partialMatch , int acceptFlags ) { } private IPackageFragment [ ] getPackageFragmentsInRoots ( IPackageFragmentRoot [ ] roots , IJavaProject project ) { } public IType findType ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags ) { } public IType findType ( String name , boolean partialMatch , int acceptFlags ) { } protected boolean nameMatches ( String searchName , IJavaElement element , boolean partialMatch ) { } public void seekPackageFragments ( String name , boolean partialMatch , IJavaElementRequestor requestor ) { } public void seekTypes ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { } protected void seekTypesInBinaryPackage ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { } protected void seekTypesInSourcePackage ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { ICompilationUnit [ ] compilationUnits = null ; try { compilationUnits = pkg . getCompilationUnits ( ) ; } catch ( JavaModelException npe ) { return ; } int length = compilationUnits . length ; String matchName = name ; int index = name . indexOf ( '$' ) ; boolean potentialMemberType = false ; String potentialMatchName = null ; if ( index != ( - 1 ) ) { potentialMatchName = name . substring ( 0 , index ) ; potentialMemberType = true ; } String unitName = ( partialMatch ) ? matchName . toLowerCase ( ) : matchName + ".java" ; String potentialUnitName = null ; if ( potentialMemberType ) { potentialUnitName = ( partialMatch ) ? potentialMatchName . toLowerCase ( ) : potentialMatchName + ".java" ; } for ( int i = 0 ; i < length ; i ++ ) { if ( requestor . isCanceled ( ) ) return ; ICompilationUnit compilationUnit = compilationUnits [ i ] ; ICompilationUnit unitToLookInside = null ; if ( ( this . unitsToLookInside ) != null ) { unitToLookInside = ( ( ICompilationUnit ) ( this . unitsToLookInside . get ( compilationUnit ) ) ) ; if ( unitToLookInside != null ) { compilationUnit = unitToLookInside ; } } <START_BUG> if ( ( unitToLookInside != null ) || ( nameMatches ( unitName , compilationUnit , partialMatch ) ) ) { <END_BUG> IType [ ] types = null ; try { types = compilationUnit . getTypes ( ) ; } catch ( JavaModelException npe ) { continue ; } int typeLength = types . length ; for ( int j = 0 ; j < typeLength ; j ++ ) { if ( requestor . isCanceled ( ) ) return ; IType type = types [ j ] ; if ( nameMatches ( matchName , type , partialMatch ) ) { if ( acceptType ( type , acceptFlags ) ) requestor . acceptType ( type ) ; } } } else if ( potentialMemberType && ( nameMatches ( potentialUnitName , compilationUnit , partialMatch ) ) ) { IType [ ] types = null ; try { types = compilationUnit . getTypes ( ) ; } catch ( JavaModelException npe ) { continue ; } int typeLength = types . length ; for ( int j = 0 ; j < typeLength ; j ++ ) { if ( requestor . isCanceled ( ) ) return ; IType type = types [ j ] ; if ( nameMatches ( potentialMatchName , type , partialMatch ) ) { seekQualifiedMemberTypes ( name . substring ( ( index + 1 ) , name . length ( ) ) , type , partialMatch , requestor , acceptFlags ) ; } } } } } public void setUnitsToLookInside ( IWorkingCopy [ ] unitsToLookInside ) { } protected void seekQualifiedMemberTypes ( String qualifiedName , IType type , boolean partialMatch , IJavaElementRequestor requestor , int acceptFlags ) { } }

Fix:
if ( ( ( unitToLookInside != null ) && ( ! potentialMemberType ) ) || ( nameMatches ( unitName , compilationUnit , partialMatch ) ) ) {