diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceReader.java b/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceReader.java index e818354d8cb9..2ae12eabd2e4 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceReader.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceReader.java @@ -45,12 +45,14 @@ public class CompilerReferenceReader { } @Nullable - public TIntHashSet findReferentFileIds(@NotNull CompilerElement element, @NotNull CompilerSearchAdapter adapter) { + public TIntHashSet findReferentFileIds(@NotNull CompilerElement element, + @NotNull CompilerSearchAdapter adapter, + boolean checkBaseClassAmbiguity) { LightUsage usage = asLightUsage(element); TIntHashSet set = new TIntHashSet(); if (adapter.needOverrideElement()) { - final LightUsage[] hierarchy = getWholeHierarchy(usage.getOwner()); + final LightUsage[] hierarchy = getWholeHierarchy(usage.getOwner(), checkBaseClassAmbiguity); if (hierarchy == null) return null; for (LightUsage aClass : hierarchy) { final LightUsage overriderUsage = usage.override(aClass); @@ -116,16 +118,18 @@ public class CompilerReferenceReader { } @Nullable("return null if the class hierarchy contains ambiguous qualified names") - private LightUsage[] getWholeHierarchy(LightUsage aClass) { + private LightUsage[] getWholeHierarchy(LightUsage aClass, boolean checkBaseClassAmbiguity) { Set result = new THashSet<>(); Queue q = new Queue<>(10); q.addLast(aClass); while (!q.isEmpty()) { LightUsage curClass = q.pullFirst(); if (result.add(curClass)) { - final Collection definitionFiles = myIndex.getBackwardClassDefinitionMap().get(curClass); - if (definitionFiles.size() != 1) { - return null; + if (checkBaseClassAmbiguity || curClass != aClass) { + final Collection definitionFiles = myIndex.getBackwardClassDefinitionMap().get(curClass); + if (definitionFiles.size() != 1) { + return null; + } } final Collection subClassDefs = myIndex.getBackwardHierarchyMap().get(curClass); if (subClassDefs != null) { diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceServiceImpl.java b/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceServiceImpl.java index 6ee8a42a97ae..c70e43b10063 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceServiceImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceServiceImpl.java @@ -201,7 +201,7 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple if (myReader == null) return null; TIntHashSet referentFileIds = new TIntHashSet(); for (CompilerElement compilerElement : compilerElements) { - final TIntHashSet referents = myReader.findReferentFileIds(compilerElement, adapter); + final TIntHashSet referents = myReader.findReferentFileIds(compilerElement, adapter, place == ElementPlace.SRC); if (referents == null) return null; referentFileIds.addAll(referents.toArray()); }