8235149: javac parser is too aggressive on ambiguous expressions using identifier: record
Reviewed-by: mcimadamore
This commit is contained in:
parent
e5a99b29f1
commit
64288e1e76
@ -4023,7 +4023,7 @@ public class JavacParser implements Parser {
|
||||
int pos = token.pos;
|
||||
JCModifiers mods = modifiersOpt();
|
||||
if (token.kind == CLASS ||
|
||||
isRecordStart() ||
|
||||
allowRecords && isRecordStart() ||
|
||||
token.kind == INTERFACE ||
|
||||
token.kind == ENUM) {
|
||||
return List.of(classOrRecordOrInterfaceOrEnumDeclaration(mods, dc));
|
||||
|
@ -625,6 +625,19 @@ public class RecordCompilationTests extends CompilationTestCase {
|
||||
Assert.check(numberOfFieldRefs == 1);
|
||||
}
|
||||
|
||||
public void testAcceptRecordId() {
|
||||
String[] testOptions = {/* no options */};
|
||||
setCompileOptions(testOptions);
|
||||
assertOKWithWarning("compiler.warn.restricted.type.not.allowed.preview",
|
||||
"class R {\n" +
|
||||
" record RR(int i) {\n" +
|
||||
" return null;\n" +
|
||||
" }\n" +
|
||||
" class record {}\n" +
|
||||
"}");
|
||||
setCompileOptions(PREVIEW_OPTIONS);
|
||||
}
|
||||
|
||||
public void testAnnos() throws Exception {
|
||||
String srcTemplate =
|
||||
"""
|
||||
@ -861,14 +874,12 @@ public class RecordCompilationTests extends CompilationTestCase {
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
targets = processingEnv.getOptions().get("targets");
|
||||
System.out.println("targets------------------------------------------------- " + targets);
|
||||
for (TypeElement te : annotations) {
|
||||
if (te.toString().equals("Anno")) {
|
||||
checkElements(te, roundEnv, targets);
|
||||
if (targets.contains("TYPE_USE")) {
|
||||
Element element = processingEnv.getElementUtils().getTypeElement("R");
|
||||
numberOfTypeAnnotations = 0;
|
||||
System.out.println("element found --------------------------------- " + element);
|
||||
checkTypeAnnotations(element);
|
||||
Assert.check(numberOfTypeAnnotations == 4);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user