Buggy code:
public class NameLookup implements SuffixConstants { public static class Answer { public IType type ; AccessRestriction restriction ; Answer ( IType type , AccessRestriction restriction ) { } public boolean ignoreIfBetter ( ) { } public boolean isBetter ( NameLookup . Answer otherAnswer ) { } } public static final int ACCEPT_CLASSES = ASTNode . Bit2 ; public static final int ACCEPT_INTERFACES = ASTNode . Bit3 ; public static final int ACCEPT_ENUMS = ASTNode . Bit4 ; public static final int ACCEPT_ANNOTATIONS = ASTNode . Bit5 ; public static final int ACCEPT_ALL = ( ( ( NameLookup . ACCEPT_CLASSES ) | ( NameLookup . ACCEPT_INTERFACES ) ) | ( NameLookup . ACCEPT_ENUMS ) ) | ( NameLookup . ACCEPT_ANNOTATIONS ) ; public static boolean VERBOSE = false ; private static final IType [ ] NO_TYPES = new IType [ ] { } ; protected IPackageFragmentRoot [ ] packageFragmentRoots ; protected HashtableOfArrayToObject packageFragments ; protected HashtableOfArrayToObject isPackageCache ; protected Map rootToResolvedEntries ; protected HashMap typesInWorkingCopies ; public long timeSpentInSeekTypesInSourcePackage = 0 ; public long timeSpentInSeekTypesInBinaryPackage = 0 ; public NameLookup ( IPackageFragmentRoot [ ] packageFragmentRoots , HashtableOfArrayToObject packageFragments , HashtableOfArrayToObject isPackage , ICompilationUnit [ ] workingCopies , Map rootToResolvedEntries ) { } protected boolean acceptType ( IType type , int acceptFlags , boolean isSourceType ) { } private void findAllTypes ( String prefix , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { } public ICompilationUnit findCompilationUnit ( String qualifiedTypeName ) { } private ICompilationUnit findCompilationUnit ( String [ ] pkgName , String cuName , PackageFragmentRoot root ) { } public IPackageFragment findPackageFragment ( IPath path ) { } public IPackageFragment [ ] findPackageFragments ( String name , boolean partialMatch ) { } private IType findSecondaryType ( String packageName , String typeName , IJavaProject project , boolean waitForIndexes , IProgressMonitor monitor ) { } public NameLookup . Answer findType ( String typeName , String packageName , boolean partialMatch , int acceptFlags , boolean checkRestrictions ) { } public NameLookup . Answer findType ( String typeName , String packageName , boolean partialMatch , int acceptFlags , boolean considerSecondaryTypes , boolean waitForIndexes , boolean checkRestrictions , IProgressMonitor monitor ) { } private AccessRestriction getViolatedRestriction ( String typeName , String packageName , IType type , AccessRestriction accessRestriction ) { } public IType findType ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags , boolean considerSecondaryTypes ) { } public IType findType ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags ) { } public IType findType ( String name , boolean partialMatch , int acceptFlags ) { } public NameLookup . Answer findType ( String name , boolean partialMatch , int acceptFlags , boolean checkRestrictions ) { } public NameLookup . Answer findType ( String name , boolean partialMatch , int acceptFlags , boolean considerSecondaryTypes , boolean waitForIndexes , boolean checkRestrictions , IProgressMonitor monitor ) { } private IType getMemberType ( IType type , String name , int dot ) { } public boolean isPackage ( String [ ] pkgName ) { } protected boolean nameMatches ( String searchName , IJavaElement element , boolean partialMatch ) { } protected boolean nameMatches ( String searchName , ICompilationUnit cu , 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 , int firstDot , boolean partialMatch , String topLevelTypeName , int acceptFlags , IJavaElementRequestor requestor ) { long start = - 1 ; if ( NameLookup . VERBOSE ) start = System . currentTimeMillis ( ) ; try { if ( ! partialMatch ) { try { IJavaElement [ ] compilationUnits = pkg . getChildren ( ) ; for ( int i = 0 , length = compilationUnits . length ; i < length ; i ++ ) { if ( requestor . isCanceled ( ) ) return ; IJavaElement cu = compilationUnits [ i ] ; String cuName = cu . getElementName ( ) ; int lastDot = cuName . lastIndexOf ( '.' ) ; <START_BUG> if ( ! ( topLevelTypeName . equals ( cuName . substring ( 0 , lastDot ) ) ) ) <END_BUG> continue ; IType type = ( ( ICompilationUnit ) ( cu ) ) . getType ( topLevelTypeName ) ; type = getMemberType ( type , name , firstDot ) ; if ( acceptType ( type , acceptFlags , true ) ) { requestor . acceptType ( type ) ; break ; } } } catch ( JavaModelException e ) { } } else { try { String cuPrefix = ( firstDot == ( - 1 ) ) ? name : name . substring ( 0 , firstDot ) ; IJavaElement [ ] compilationUnits = pkg . getChildren ( ) ; for ( int i = 0 , length = compilationUnits . length ; i < length ; i ++ ) { if ( requestor . isCanceled ( ) ) return ; IJavaElement cu = compilationUnits [ i ] ; if ( ! ( cu . getElementName ( ) . toLowerCase ( ) . startsWith ( cuPrefix ) ) ) continue ; try { IType [ ] types = ( ( ICompilationUnit ) ( cu ) ) . getTypes ( ) ; for ( int j = 0 , typeLength = types . length ; j < typeLength ; j ++ ) seekTypesInTopLevelType ( name , firstDot , types [ j ] , requestor , acceptFlags ) ; } catch ( JavaModelException e ) { } } } catch ( JavaModelException e ) { } } } finally { if ( NameLookup . VERBOSE ) this . timeSpentInSeekTypesInSourcePackage += ( System . currentTimeMillis ( ) ) - start ; } }

Fix:
if ( ( lastDot != ( topLevelTypeName . length ( ) ) ) || ( ! ( topLevelTypeName . regionMatches ( 0 , cuName , 0 , lastDot ) ) ) )