From ed1c9e970a982f3b962aeda8570f160dd8220a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sat, 29 Jan 2022 19:04:32 +0100 Subject: [PATCH] Fix parsing bug --- pmd-java/etc/grammar/Java.jjt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 6909756d54..b09d15258d 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1734,14 +1734,15 @@ void InstanceOfExpression() #void: LOOKAHEAD(1) ("instanceof" ( - LOOKAHEAD(1, "(" | "final" | "@") PrimaryPattern() - | LOOKAHEAD(1) AnnotatedRefType() [ VariableDeclaratorId() #TypePattern(2) ] + + AnnotatedRefType() [ VariableDeclaratorId() #TypePattern(2) ] + | PrimaryPattern() ) { jjtThis.setOp(BinaryOp.INSTANCEOF); AbstractJavaNode top = jjtree.popNode(); if (top instanceof ASTPattern) { - if (top instanceof ASTTypePattern) { + if (top instanceof ASTTypePattern && !(top.getChild(0) instanceof ASTModifierList)) { insertEmptyModifierListWithAnnotations(top, (AbstractJavaNode) top.getChild(0)); } top = new ASTPatternExpression((ASTPattern) top);