Allow nested private methods

This commit is contained in:
Andreas Dangel
2017-09-22 13:33:08 +02:00
parent cfa4b5b85c
commit 722b2b1657
2 changed files with 8 additions and 3 deletions

View File

@ -1359,11 +1359,11 @@ void TypeDeclaration():
void ClassOrInterfaceDeclaration(int modifiers):
{
Token t = null;
jjtThis.setModifiers(modifiers);
Token t = null;
jjtThis.setModifiers(modifiers);
inInterface = false;
}
{
( /* See note about this optional final modifier in BlockStatement */
["final"|"abstract"] "class" | "interface" { jjtThis.setInterface(); inInterface = true; } )
t=<IDENTIFIER> { jjtThis.setImage(t.image); }

View File

@ -218,6 +218,11 @@ public class JDKVersionTest {
parseJava18("public class Foo { private void bar() { } }");
}
@Test
public final void testNestedPrivateMethods() {
parseJava18("public interface Baz { public static class Foo { private void bar() { } } }");
}
@Test
public final void jdk9PrivateInterfaceMethods() {
parseJava9(loadSource("jdk9_private_interface_methods.java"));