grammars-v4 icon indicating copy to clipboard operation
grammars-v4 copied to clipboard

Potential bug in Java grammar

Open mike-lischke opened this issue 3 years ago • 0 comments
trafficstars

I'm currently using this Java grammar in a project and found something which I believe is a bug. Look at these interface method rules:

interfaceMethodDeclaration
    : interfaceMethodModifier* (typeTypeOrVoid | typeParameters annotation* typeTypeOrVoid)
      IDENTIFIER formalParameters ('[' ']')* (THROWS qualifiedNameList)? methodBody
    ;

genericInterfaceMethodDeclaration
    : typeParameters interfaceMethodDeclaration
    ;

As you can see the generic interface method decl uses the normal one. However, looking closer you can see that interfaceMethodDeclaration actually also parses type parameters (so it's actually generic too).

However genericInterfaceMethodDeclaration also parses type parameters, allowing so 2 sets of parameters, which is wrong IMO. But since I'm not so fluent in Java, it could be I'm wrong here.

mike-lischke avatar Dec 25 '21 12:12 mike-lischke