Files
Anna Kozlova 01a5ea5835 java: check enum instantiation before constructor applicability (IDEA-267280)
GitOrigin-RevId: f7f2a0ac939fd6ae08a1919335bcebd1098ff6e7
2021-04-20 19:26:09 +03:00

18 lines
457 B
Java

import java.util.*;
public class MyEnum {
enum Test {A,B}
enum Test1 {A; Test1() {}}
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>;
Test1 t1 = <error descr="Enum types cannot be instantiated">new Test1()</error>;
}