Closed
Description
Compiler version
3.4.0-RC4
Minimized code
// TpeAnnot.java
package lib;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
public @interface TpeAnnot {}
// TpeAnnotated.java
package lib;
public class TpeAnnotated {
private static <T> T unimplemented() {
return null;
}
public class C {
public class D {}
}
public static int @TpeAnnot [] g() { return unimplemented(); } // error
public static int @TpeAnnot [][] h() { return unimplemented(); } // error
public static int[] @TpeAnnot [] i() { return unimplemented(); } // error
public static C.@TpeAnnot D foo2() { return unimplemented(); } // error
}
Output
these errors do not appear all at the same time, but by commenting out the appropriate lines of one error to reveal another one.
-- Error: TpeAnnotated.java:11:20 ----------------------------------------------
11 | public static int @TpeAnnot [] g() { return unimplemented(); } // error
| ^^^
| identifier expected but @ found.
-- Error: TpeAnnotated.java:13:20 ----------------------------------------------
13 | public static int @TpeAnnot [][] h() { return unimplemented(); } // error
| ^^^
| identifier expected but @ found.
-- Error: TpeAnnotated.java:15:22 ----------------------------------------------
15 | public static int[] @TpeAnnot [] i() { return unimplemented(); } // error
| ^^^
| identifier expected but @ found.
-- Error: TpeAnnotated.java:23:18 ----------------------------------------------
23 | public static C.@TpeAnnot D foo2() { return unimplemented(); } // error
| ^
| identifier expected but @ found.
-- Error: TpeAnnotated.java:26:0 -----------------------------------------------
26 |}
|^
|identifier expected but '}' found.
2 errors found
Expectation
This is valid java accepted by Javac, see JLS 4.11. Note that this fails to parse in Scala 2.13 also