mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
TypeName.super checks for classes fixed (IDEA-150141)
This commit is contained in:
+22
-6
@@ -60,7 +60,10 @@ import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.xml.util.XmlStringUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -1548,12 +1551,25 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
//or if there exists some other direct superclass or direct superinterface of T, J, such that J is a subtype of I.
|
||||
final PsiClass classT = PsiTreeUtil.getParentOfType(expr, PsiClass.class);
|
||||
if (classT != null) {
|
||||
final PsiElement parent = expr.getParent();
|
||||
final PsiElement resolved = parent instanceof PsiReferenceExpression ? ((PsiReferenceExpression)parent).resolve() : null;
|
||||
|
||||
for (PsiClass superClass : classT.getSupers()) {
|
||||
if (superClass.isInterface() && //check spec-javac relations
|
||||
superClass.isInheritor(aClass, true)) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(qualifier)
|
||||
.descriptionAndTooltip(JavaErrorMessages.message("bad.qualifier.in.super.method.reference", format(aClass), formatClass(superClass))).create();
|
||||
if (superClass.isInheritor(aClass, true)) {
|
||||
String cause = null;
|
||||
if (superClass.isInterface()) {
|
||||
cause = "redundant interface " + format(aClass) + " is extended by ";
|
||||
}
|
||||
else if (resolved instanceof PsiMethod &&
|
||||
MethodSignatureUtil.findMethodBySuperMethod(superClass, (PsiMethod)resolved, true) != resolved) {
|
||||
cause = "method " + ((PsiMethod)resolved).getName() + " is overridden in ";
|
||||
}
|
||||
|
||||
if (cause != null) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(qualifier)
|
||||
.descriptionAndTooltip(JavaErrorMessages.message("bad.qualifier.in.super.method.reference", cause + formatClass(superClass))).create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ illegal.generic.type.for.instanceof=Illegal generic type for instanceof
|
||||
cannot.select.dot.class.from.type.variable=Cannot select from a type variable
|
||||
method.does.not.override.super=Method does not override method from its superclass
|
||||
call.to.super.is.not.allowed.in.enum.constructor=Call to super is not allowed in enum constructor
|
||||
bad.qualifier.in.super.method.reference=Bad type qualifier in default super call: redundant interface {0} is extended by {1}
|
||||
bad.qualifier.in.super.method.reference=Bad type qualifier in default super call: {0}
|
||||
vararg.not.last.parameter=Vararg parameter must be the last in the list
|
||||
modifiers.for.enum.constants=No modifiers allowed for enum constants
|
||||
generics.type.arguments.on.raw.type=Type arguments given on a raw type
|
||||
|
||||
+18
@@ -45,5 +45,23 @@ class Test {
|
||||
J.super.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class E implements I {
|
||||
public void a() {}
|
||||
}
|
||||
|
||||
class F extends E implements I {
|
||||
void bar() {
|
||||
<error descr="Bad type qualifier in default super call: method a is overridden in Test.E">I</error>.super.a();
|
||||
Runnable r = <error descr="Bad type qualifier in default super call: method a is overridden in Test.E">I</error>.super::a;
|
||||
}
|
||||
}
|
||||
|
||||
class G extends A implements I {
|
||||
void bar() {
|
||||
I.super.a();
|
||||
Runnable r = I.super::a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user