mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: more clear error message on generic class literal (IDEA-306263)
GitOrigin-RevId: d8d2cd5941a288e663fd6918c3e379b669553967
This commit is contained in:
committed by
intellij-monorepo-bot
parent
024ceb251c
commit
f7a5a1cb22
+10
-2
@@ -1061,8 +1061,16 @@ public final class GenericsHighlightUtil {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(operand).descriptionAndTooltip(description);
|
||||
}
|
||||
if (type.getParameters().length > 0) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(operand).descriptionAndTooltip(
|
||||
JavaErrorBundle.message("cannot.select.from.parameterized.type"));
|
||||
final HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(operand).descriptionAndTooltip(
|
||||
JavaErrorBundle.message("cannot.select.from.parameterized.type"));
|
||||
final PsiJavaCodeReferenceElement referenceElement = operand.getInnermostComponentReferenceElement();
|
||||
if (referenceElement != null) {
|
||||
final PsiReferenceParameterList parameterList = referenceElement.getParameterList();
|
||||
if (parameterList != null) {
|
||||
info.registerFix(QUICK_FIX_FACTORY.createDeleteFix(parameterList), null, null, null, null);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ illegal.generic.type.for.instanceof=Illegal generic type for instanceof
|
||||
unsafe.cast.in.instanceof=''{0}'' cannot be safely cast to ''{1}''
|
||||
instanceof.pattern.supertype=Pattern type ''{0}'' is a supertype of expression type ''{1}''
|
||||
instanceof.pattern.equals=Pattern type ''{0}'' is the same as expression type
|
||||
cannot.select.dot.class.from.type.variable=Cannot select from a type variable
|
||||
cannot.select.dot.class.from.type.variable=Cannot access class object of a type parameter
|
||||
method.does.not.override.super=Method does not override method from its superclass
|
||||
static.method.cannot.be.annotated.with.override=Static methods cannot be annotated with @Override
|
||||
call.to.super.is.not.allowed.in.enum.constructor=Call to super is not allowed in enum constructor
|
||||
@@ -518,7 +518,7 @@ qualified.class.reference.not.allowed.in.qualified.new=Qualified class reference
|
||||
actual.type.argument.contradict.inferred.type=Actual type argument and inferred type contradict each other
|
||||
default.method.overrides.object.member=Default method ''{0}'' overrides a member of ''java.lang.Object''
|
||||
two.methods.are.inherited.with.same.signature=Methods {0} from {1} and {2} from {3} are inherited with the same signature
|
||||
cannot.select.from.parameterized.type=Cannot select from parameterized type
|
||||
cannot.select.from.parameterized.type=Cannot access class object of parameterized type
|
||||
safevarargs.not.allowed.non.final.instance.methods=@SafeVarargs is not allowed on non-final instance methods
|
||||
safevarargs.not.suppress.potentially.unsafe.operations=@SafeVarargs do not suppress potentially unsafe operations
|
||||
safevarargs.not.applicable.for.reifiable.types=@SafeVarargs is not applicable for reifiable types
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
class E<T> {
|
||||
Class<T[]> o = <error descr="Cannot select from a type variable">T[]</error>.class;
|
||||
Class<T[]> o = <error descr="Cannot access class object of a type parameter">T[]</error>.class;
|
||||
}
|
||||
|
||||
class MyClass<T> {
|
||||
Class<T[]> getTs() {
|
||||
return <error descr="Cannot select from a type variable">T[]</error>.class;
|
||||
return <error descr="Cannot access class object of a type parameter">T[]</error>.class;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+5
-5
@@ -88,7 +88,7 @@ class myAList<T> extends mylist<T> {
|
||||
|
||||
Class<T> foo (Class<T> clazz) {
|
||||
Class<String> clazz1 = (Class<String>)clazz; //Should be unchecked warning
|
||||
return <error descr="Cannot select from a type variable">T</error>.class;
|
||||
return <error descr="Cannot access class object of a type parameter">T</error>.class;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,11 +130,11 @@ abstract class GenericTest99<E extends Enum<E>> {
|
||||
|
||||
class ClassLiteral<T> {
|
||||
{
|
||||
Object c1 = <error descr="Cannot select from a type variable">T</error>.class;
|
||||
Object c2 = <error descr="Cannot select from a type variable">T[]</error>.class;
|
||||
Object c1 = <error descr="Cannot access class object of a type parameter">T</error>.class;
|
||||
Object c2 = <error descr="Cannot access class object of a type parameter">T[]</error>.class;
|
||||
|
||||
Object c3 = <error descr="Cannot select from parameterized type">List<String></error>.class;
|
||||
Object c4 = <error descr="Cannot select from parameterized type">List<String>[]</error>.class;
|
||||
Object c3 = <error descr="Cannot access class object of parameterized type">List<String></error>.class;
|
||||
Object c4 = <error descr="Cannot access class object of parameterized type">List<String>[]</error>.class;
|
||||
Object c5 = List[].class;
|
||||
Object c6 = List.class;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
class E<T> {
|
||||
Class<T[]> o = <error descr="Cannot select from a type variable">T[]</error>.class;
|
||||
Class<T[]> o = <error descr="Cannot access class object of a type parameter">T[]</error>.class;
|
||||
}
|
||||
|
||||
class MyClass<T> {
|
||||
Class<T[]> getTs() {
|
||||
return <error descr="Cannot select from a type variable">T[]</error>.class;
|
||||
return <error descr="Cannot access class object of a type parameter">T[]</error>.class;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+5
-5
@@ -88,7 +88,7 @@ class myAList<T> extends mylist<T> {
|
||||
|
||||
Class<T> foo (Class<T> clazz) {
|
||||
Class<String> clazz1 = (Class<String>)clazz; //Should be unchecked warning
|
||||
return <error descr="Cannot select from a type variable">T</error>.class;
|
||||
return <error descr="Cannot access class object of a type parameter">T</error>.class;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,11 +130,11 @@ abstract class GenericTest99<E extends Enum<E>> {
|
||||
|
||||
class ClassLiteral<T> {
|
||||
{
|
||||
Object c1 = <error descr="Cannot select from a type variable">T</error>.class;
|
||||
Object c2 = <error descr="Cannot select from a type variable">T[]</error>.class;
|
||||
Object c1 = <error descr="Cannot access class object of a type parameter">T</error>.class;
|
||||
Object c2 = <error descr="Cannot access class object of a type parameter">T[]</error>.class;
|
||||
|
||||
Object c3 = <error descr="Cannot select from parameterized type">List<String></error>.class;
|
||||
Object c4 = <error descr="Cannot select from parameterized type">List<String>[]</error>.class;
|
||||
Object c3 = <error descr="Cannot access class object of parameterized type">List<String></error>.class;
|
||||
Object c4 = <error descr="Cannot access class object of parameterized type">List<String>[]</error>.class;
|
||||
Object c5 = List[].class;
|
||||
Object c6 = List.class;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user