mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
[java] better error message for type parameter outside bounds when the type parameter is not a concrete class (IDEA-353386)
GitOrigin-RevId: 6fcb1f8c2180ed319cdf7030de9c38b302e8e2d4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7b074a10b1
commit
0a8f0ae1c8
@@ -269,12 +269,16 @@ public final class GenericsHighlightUtil {
|
||||
if (!bound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) && GenericsUtil.checkNotInBounds(type, bound, referenceParameterList)) {
|
||||
PsiClass boundClass = bound instanceof PsiClassType ? ((PsiClassType)bound).resolve() : null;
|
||||
|
||||
@NonNls String messageKey = boundClass == null || referenceClass == null || referenceClass.isInterface() == boundClass.isInterface()
|
||||
? "generics.type.parameter.is.not.within.its.bound.extend"
|
||||
: "generics.type.parameter.is.not.within.its.bound.implement";
|
||||
|
||||
String description = JavaErrorBundle.message(messageKey,
|
||||
referenceClass != null ? HighlightUtil.formatClass(referenceClass) : type.getPresentableText(),
|
||||
boolean extend = boundClass == null ||
|
||||
referenceClass == null ||
|
||||
referenceClass.isInterface() == boundClass.isInterface() ||
|
||||
referenceClass instanceof PsiTypeParameter;
|
||||
String description = JavaErrorBundle.message(extend
|
||||
? "generics.type.parameter.is.not.within.its.bound.extend"
|
||||
: "generics.type.parameter.is.not.within.its.bound.implement",
|
||||
referenceClass != null
|
||||
? HighlightUtil.formatClass(referenceClass)
|
||||
: type.getPresentableText(),
|
||||
JavaHighlightUtil.formatType(bound));
|
||||
|
||||
HighlightInfo.Builder builder =
|
||||
|
||||
@@ -16,5 +16,7 @@ class Foo {
|
||||
this.<String>xyz<error descr="'xyz(java.lang.String)' in 'Foo' cannot be applied to '(java.lang.Integer)'">(Integer.valueOf("27"))</error>;
|
||||
ArrayList list = new <error descr="Method 'ArrayList()' does not have type parameters"><String></error>ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public <E> void doo(Bar<<error descr="Type parameter 'E' is not within its bound; should extend 'java.util.List'">E</error>> foo) {}
|
||||
}
|
||||
interface Bar<T extends List> {}
|
||||
|
||||
Reference in New Issue
Block a user