Fix some corner cases found in jdk12 sources
This commit is contained in:
@ -2521,14 +2521,13 @@ void PrimaryPrefix() #void :
|
|||||||
// This describes the cases where the PrimaryPrefix may fall
|
// This describes the cases where the PrimaryPrefix may fall
|
||||||
// into PrimaryStep2. Notice that type arguments is still possible,
|
// into PrimaryStep2. Notice that type arguments is still possible,
|
||||||
// as well as annotations ("@") before an annotated array type.
|
// as well as annotations ("@") before an annotated array type.
|
||||||
// If we are in an explicit constructor invocation, then super or
|
// If we are in an explicit constructor invocation, then super is disallowed.
|
||||||
// this are disallowed.
|
|
||||||
private void Step2Lahead() #void:
|
private void Step2Lahead() #void:
|
||||||
{}
|
{}
|
||||||
{
|
{
|
||||||
"::" | "(" | "@" | "[" | TypeArguments()
|
"::" | "(" | "@" | "[" | TypeArguments()
|
||||||
| LOOKAHEAD({!inExplicitConstructorInvoc}) "."
|
| LOOKAHEAD({!inExplicitConstructorInvoc}) "."
|
||||||
| LOOKAHEAD({inExplicitConstructorInvoc}) "." ("class" | <IDENTIFIER> | TypeArguments() <IDENTIFIER> | "new") // not super or this in this case
|
| LOOKAHEAD({inExplicitConstructorInvoc}) "." ("class" | <IDENTIFIER> | TypeArguments() <IDENTIFIER> | "new" | "this") // not super in this case
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SuffixLAhead() #void:
|
private void SuffixLAhead() #void:
|
||||||
@ -2548,8 +2547,8 @@ private void SuffixLAhead() #void:
|
|||||||
void PrimaryStep2() #void:
|
void PrimaryStep2() #void:
|
||||||
{}
|
{}
|
||||||
{
|
{
|
||||||
// Can't be followed by array dims, because it would raise an error for generic array creation
|
// If the class is a parameterised type, then we can only expect a method reference
|
||||||
{forceTypeContext();} TypeArguments() {injectTop();} ( "." ClassTypeSegment() )* MethodReference()
|
{forceTypeContext();} TypeArguments() {injectTop();} ( "." ClassTypeSegment() )* [ Dims() #ArrayType(2) ] MethodReference()
|
||||||
| MethodReference()
|
| MethodReference()
|
||||||
| ArgumentList() #MethodCall(2)
|
| ArgumentList() #MethodCall(2)
|
||||||
| "." (
|
| "." (
|
||||||
|
@ -41,7 +41,9 @@ public enum BinaryOp {
|
|||||||
|
|
||||||
// shift
|
// shift
|
||||||
LEFT_SHIFT("<<"),
|
LEFT_SHIFT("<<"),
|
||||||
|
/** Token {@code >> } */
|
||||||
RIGHT_SHIFT(">>"),
|
RIGHT_SHIFT(">>"),
|
||||||
|
/** Token {@code >>>} */
|
||||||
UNSIGNED_RIGHT_SHIFT(">>>"),
|
UNSIGNED_RIGHT_SHIFT(">>>"),
|
||||||
|
|
||||||
// additive
|
// additive
|
||||||
|
@ -147,6 +147,24 @@ class ASTExplicitConstructorInvocationTest : ParserTestSpec({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"public TabbedPaneLayout() { MetalTabbedPaneUI.this.super(); }" should matchDeclaration<ASTConstructorDeclaration> {
|
||||||
|
|
||||||
|
child<ASTFormalParameters> { }
|
||||||
|
|
||||||
|
child<ASTExplicitConstructorInvocation> {
|
||||||
|
it::isThis shouldBe false
|
||||||
|
it::isSuper shouldBe true
|
||||||
|
it::isQualified shouldBe true
|
||||||
|
it::getExplicitTypeArguments shouldBe null
|
||||||
|
it::getArgumentCount shouldBe 0
|
||||||
|
|
||||||
|
it::getLhsExpression shouldBe child<ASTThisExpression>(ignoreChildren = true) { }
|
||||||
|
|
||||||
|
|
||||||
|
it::getArgumentsList shouldBe child { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// An explicit constructor invocation statement in a constructor body may not refer to any instance
|
// An explicit constructor invocation statement in a constructor body may not refer to any instance
|
||||||
// variables or instance methods or inner classes declared in this class or any superclass, or use
|
// variables or instance methods or inner classes declared in this class or any superclass, or use
|
||||||
// this or super in any expression; otherwise, a compile-time error occurs.
|
// this or super in any expression; otherwise, a compile-time error occurs.
|
||||||
|
@ -165,6 +165,23 @@ class ASTMethodReferenceTest : ParserTestSpec({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Class<?>[]::new" should parseAs {
|
||||||
|
constructorRef {
|
||||||
|
it::getTypeArguments shouldBe null
|
||||||
|
|
||||||
|
arrayType {
|
||||||
|
classType("Class") {
|
||||||
|
typeArgList {
|
||||||
|
child<ASTWildcardType> { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it::getDimensions shouldBe child {
|
||||||
|
arrayDim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
"ArrayList::<String>new" should parseAs {
|
"ArrayList::<String>new" should parseAs {
|
||||||
constructorRef {
|
constructorRef {
|
||||||
val lhs = classType("ArrayList")
|
val lhs = classType("ArrayList")
|
||||||
|
@ -36,6 +36,19 @@ class ASTShiftExpressionTest : ParserTestSpec({
|
|||||||
child<ASTNumericLiteral> {}
|
child<ASTNumericLiteral> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"i < width >> 1" should matchExpr<ASTRelationalExpression> {
|
||||||
|
it::getOp shouldBe BinaryOp.LE
|
||||||
|
|
||||||
|
variableRef("i")
|
||||||
|
|
||||||
|
child<ASTShiftExpression> {
|
||||||
|
it::getOp shouldBe BinaryOp.RIGHT_SHIFT
|
||||||
|
|
||||||
|
variableRef("width")
|
||||||
|
int(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parserTest("Changing operators should push a new node") {
|
parserTest("Changing operators should push a new node") {
|
||||||
|
Reference in New Issue
Block a user