Skip to content
Permalink
Browse files

8235149: javac parser is too aggressive on ambiguous expressions usin…

…g identifier: record

Reviewed-by: mcimadamore
  • Loading branch information
Vicente Romero
Vicente Romero committed Jan 27, 2020
1 parent e5a99b2 commit 64288e1e762aef8e8e9a22bdbd2c3d8aa14a095a
@@ -4023,7 +4023,7 @@ JCTree enumeratorDeclaration(Name enumName) {
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 void testOnlyOneFieldRef() throws Exception {
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 @@ private void assertAttributeNotPresent(Attributes attributes, Class<? extends At
@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);
}

0 comments on commit 64288e1

Please sign in to comment.