8310314: Misplaced "unnamed classes are a preview feature and are disabled by default" error
Reviewed-by: jlaskey
This commit is contained in:
parent
96a7db7b3c
commit
79069c5e74
src/jdk.compiler/share/classes/com/sun/tools/javac/parser
test/langtools/tools/javac/unnamedclass
@ -3995,6 +3995,7 @@ public class JavacParser implements Parser {
|
||||
}
|
||||
|
||||
if (isTopLevelMethodOrField) {
|
||||
checkSourceLevel(token.pos, Feature.UNNAMED_CLASSES);
|
||||
defs.appendList(topLevelMethodOrFieldDeclaration(mods));
|
||||
isUnnamedClass = true;
|
||||
} else {
|
||||
@ -4025,8 +4026,6 @@ public class JavacParser implements Parser {
|
||||
|
||||
// Restructure top level to be an unnamed class.
|
||||
private List<JCTree> constructUnnamedClass(List<JCTree> origDefs) {
|
||||
checkSourceLevel(Feature.UNNAMED_CLASSES);
|
||||
|
||||
ListBuffer<JCTree> topDefs = new ListBuffer<>();
|
||||
ListBuffer<JCTree> defs = new ListBuffer<>();
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8310314
|
||||
* @summary Ensure proper error position for the "unnamed classes not supported" error
|
||||
* @compile/fail/ref=SourceLevelErrorPosition.out -XDrawDiagnostics SourceLevelErrorPosition.java
|
||||
*/
|
||||
class Nested {}
|
||||
void main() {
|
||||
System.err.println("");
|
||||
}
|
||||
void test() {
|
||||
System.err.println("");
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
SourceLevelErrorPosition.java:8:1: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.unnamed.classes)
|
||||
1 error
|
Loading…
x
Reference in New Issue
Block a user