mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-120636 Wrong "enum cannot be instantiated"
This commit is contained in:
+1
-1
@@ -715,7 +715,7 @@ public class GenericsHighlightUtil {
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkEnumInstantiation(PsiNewExpression expression, PsiClass aClass) {
|
||||
if (aClass != null && aClass.isEnum()) {
|
||||
if (aClass != null && aClass.isEnum() && expression.getArrayDimensions().length == 0 && expression.getArrayInitializer() == null) {
|
||||
String description = JavaErrorMessages.message("enum.types.cannot.be.instantiated");
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create();
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import java.util.*;
|
||||
public class MyEnum {
|
||||
|
||||
enum Test {A,B}
|
||||
|
||||
public static Test[] accepted1() {
|
||||
List<Test> list = new ArrayList<Test>();
|
||||
return list.toArray(new Test[list.size()]);
|
||||
}
|
||||
|
||||
public static Test[] accepted2() {
|
||||
return new Test[]{};
|
||||
}
|
||||
|
||||
Test t = <error descr="Enum types cannot be instantiated">new Test()</error>;
|
||||
}
|
||||
+1
@@ -61,4 +61,5 @@ public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testUnhandledExceptions() { doTest(true, false); }
|
||||
public void testUnhandledExceptionsValueOf() { doTest(true, false); }
|
||||
public void testUnsupportedFeatures7() { doTest(false, false); }
|
||||
public void testEnumInitializers() { doTest(false, false); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user