Fix record ctor with throws
This commit is contained in:
@ -1152,9 +1152,15 @@ void RecordBody():
|
||||
void RecordBodyDeclaration() #void :
|
||||
{}
|
||||
{
|
||||
LOOKAHEAD(ClassOrInterfaceBodyDeclaration()) ClassOrInterfaceBodyDeclaration()
|
||||
LOOKAHEAD(RecordCtorLookahead()) RecordConstructorDeclaration()
|
||||
|
|
||||
RecordConstructorDeclaration()
|
||||
ClassOrInterfaceBodyDeclaration()
|
||||
}
|
||||
|
||||
private void RecordCtorLookahead() #void:
|
||||
{}
|
||||
{
|
||||
Modifiers() [ TypeParameters() ] <IDENTIFIER> ("throws" | "{")
|
||||
}
|
||||
|
||||
void RecordConstructorDeclaration():
|
||||
@ -1165,6 +1171,7 @@ void RecordConstructorDeclaration():
|
||||
modifiers = Modifiers() { jjtThis.setModifiers(modifiers); }
|
||||
[TypeParameters()]
|
||||
<IDENTIFIER> { jjtThis.setImage(token.image); }
|
||||
[ "throws" NameList() ]
|
||||
"{" ( BlockStatement() )* "}"
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@ -54,5 +55,10 @@ public class Records {
|
||||
String lastName();
|
||||
}
|
||||
public record PersonRecord(String firstName, String lastName)
|
||||
implements Person, java.io.Serializable { }
|
||||
implements Person, java.io.Serializable {
|
||||
|
||||
PersonRecord throws IOException { // compact ctor with throws list
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user