Fixes #793 [java] Parser error with private method in nested classes in interfaces

This commit is contained in:
Andreas Dangel
2017-12-20 22:37:49 +01:00
parent ef41c71870
commit 64b862eef9
5 changed files with 49 additions and 3 deletions

View File

@ -1,4 +1,7 @@
/**
* Fixes #793 [java] Parser error with private method in nested classes in interfaces
* Andreas Dangel 12/2017
*====================================================================
* Add support for Java 9 changes:
* Private interface methods are only allowed with java9.
* A single underscore "_" is an invalid identifier in java9.
@ -340,6 +343,7 @@ public class JavaParser {
* Keeps track whether we are dealing with an interface or not. Needed since the tree is
* is not fully constructed yet, when we check for private interface methods.
* The flag is updated, if entering ClassOrInterfaceDeclaration and reset when leaving.
* The flag is also reset, if entering a anonymous inner class.
*/
private boolean inInterface = false;
private void checkForBadPrivateInterfaceMethod(ASTMethodDeclaration node) {
@ -2009,7 +2013,7 @@ void AllocationExpression():
(
ArrayDimsAndInits()
|
Arguments() [ ClassOrInterfaceBody() ]
Arguments() [ {inInterface = false;} ClassOrInterfaceBody() ]
)
)
{ checkForBadAnonymousDiamondUsage(); }