mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 22:11:40 +07:00
unrelated defaults: adjust pattern in current class to super class substitution
This commit is contained in:
@@ -441,7 +441,6 @@ public class GenericsHighlightUtil {
|
||||
}
|
||||
|
||||
static HighlightInfo checkUnrelatedDefaultMethods(@NotNull PsiClass aClass,
|
||||
@NotNull Collection<HierarchicalMethodSignature> signaturesWithSupers,
|
||||
@NotNull PsiIdentifier classIdentifier) {
|
||||
final Map<MethodSignature, Set<PsiMethod>> overrideEquivalent =
|
||||
new THashMap<MethodSignature, Set<PsiMethod>>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
|
||||
@@ -454,9 +453,10 @@ public class GenericsHighlightUtil {
|
||||
subType |= supers[j].isInheritor(supers[i], true);
|
||||
}
|
||||
if (subType) continue;
|
||||
final PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, aClass, PsiSubstitutor.EMPTY);
|
||||
for (HierarchicalMethodSignature hms : superClass.getVisibleSignatures()) {
|
||||
final PsiMethod method = hms.getMethod();
|
||||
if (aClass.findMethodsBySignature(method, false).length > 0) continue;
|
||||
if (MethodSignatureUtil.findMethodBySignature(aClass, method.getSignature(superClassSubstitutor), false) != null) continue;
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass == null) continue;
|
||||
final PsiSubstitutor containingClassSubstitutor = TypeConversionUtil.getClassSubstitutor(containingClass, aClass, PsiSubstitutor.EMPTY);
|
||||
|
||||
@@ -636,7 +636,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
myHolder.add(HighlightNamesUtil.highlightClassName(aClass, identifier, colorsScheme));
|
||||
}
|
||||
if (!myHolder.hasErrorResults() && myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
myHolder.add(GenericsHighlightUtil.checkUnrelatedDefaultMethods(aClass, aClass.getVisibleSignatures(), identifier));
|
||||
myHolder.add(GenericsHighlightUtil.checkUnrelatedDefaultMethods(aClass, identifier));
|
||||
}
|
||||
|
||||
if (!myHolder.hasErrorResults()) {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
interface A<K> {
|
||||
default void replace(K v) {}
|
||||
}
|
||||
|
||||
interface B<K> extends A<K> {
|
||||
void replace(K k);
|
||||
}
|
||||
|
||||
abstract class AC<K> implements A<K> {}
|
||||
|
||||
class C<K> extends AC<K> implements B<K> {
|
||||
@Override
|
||||
public void replace(K k) {}
|
||||
}
|
||||
|
||||
<error descr="Class 'D' must either be declared abstract or implement abstract method 'replace(K)' in 'B'">class <error descr="Class 'D' must either be declared abstract or implement abstract method 'replace(K)' in 'B'">D</error><K> extends AC<K> implements B<K></error> {}
|
||||
@@ -58,6 +58,10 @@ public class Interface8MethodsHighlightingTest extends LightCodeInsightFixtureTe
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testUnrelatedDefaultsOverriddenWithConcreteMethodNonEmptySubstitutor() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testStaticMethodAccessibleBothThroughStaticImportAndInheritance() throws Exception {
|
||||
myFixture.addClass("package p; public interface Foo {" +
|
||||
" static void foo() {}" +
|
||||
|
||||
Reference in New Issue
Block a user