mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
IDEA-115789 an interface inheriting a default method and an abstract method
This commit is contained in:
@@ -510,20 +510,32 @@ public class GenericsHighlightUtil {
|
||||
final PsiClass superContainingClass = superMethod.getContainingClass();
|
||||
if (containingClass != null && superContainingClass != null && !InheritanceUtil
|
||||
.isInheritorOrSelf(containingClass, superContainingClass, true)) {
|
||||
if (superMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
|
||||
final String inheritUnrelatedDefaultsMessage = HighlightUtil.formatClass(aClass) + " inherits unrelated defaults for " +
|
||||
JavaHighlightUtil.formatMethod(method) + " from types " + HighlightUtil.formatClass(containingClass) +
|
||||
" and " + HighlightUtil.formatClass(superContainingClass);
|
||||
return HighlightInfo
|
||||
.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(inheritUnrelatedDefaultsMessage).create();
|
||||
}
|
||||
if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
final boolean isDefault = superMethod.hasModifierProperty(PsiModifier.DEFAULT);
|
||||
if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT) && !isDefault) {
|
||||
final String message = JavaErrorMessages.message(
|
||||
aClass instanceof PsiEnumConstantInitializer ? "enum.constant.should.implement.method" : "class.must.be.abstract",
|
||||
HighlightUtil.formatClass(superContainingClass),
|
||||
JavaHighlightUtil.formatMethod(superMethod),
|
||||
HighlightUtil.formatClass(superContainingClass, false));
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(message).create();
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(classIdentifier).descriptionAndTooltip(message)
|
||||
.create();
|
||||
}
|
||||
|
||||
if (isDefault || superMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
final String message = isDefault
|
||||
? " inherits unrelated defaults for "
|
||||
: " inherits abstract and default for ";
|
||||
final String inheritUnrelatedDefaultsMessage = HighlightUtil.formatClass(aClass) +
|
||||
message +
|
||||
JavaHighlightUtil.formatMethod(method) +
|
||||
" from types " +
|
||||
HighlightUtil.formatClass(containingClass) +
|
||||
" and " +
|
||||
HighlightUtil.formatClass(superContainingClass);
|
||||
return HighlightInfo
|
||||
.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(inheritUnrelatedDefaultsMessage)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,17 @@ interface SecondParent {
|
||||
|
||||
class <error descr="Class 'SecondParent' must either be declared abstract or implement abstract method 'doSomething()' in 'SecondParent'">FirstSon</error> implements FirstParent, SecondParent {}
|
||||
|
||||
<error descr="Class 'SecondSon' must either be declared abstract or implement abstract method 'doSomething()' in 'SecondParent'">class SecondSon implements SecondParent, FirstParent</error> {}
|
||||
<error descr="Class 'SecondSon' must either be declared abstract or implement abstract method 'doSomething()' in 'SecondParent'">class SecondSon implements SecondParent, FirstParent</error> {}
|
||||
|
||||
interface A {
|
||||
default int foo() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
interface B {
|
||||
abstract int foo();
|
||||
}
|
||||
|
||||
interface <error descr="C inherits abstract and default for foo() from types A and B">C</error> extends A, B {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user