Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse concrete private interface methods in Java #12393

Closed
lrytz opened this issue May 12, 2021 · 3 comments · Fixed by scala/scala#9748
Closed

Parse concrete private interface methods in Java #12393

lrytz opened this issue May 12, 2021 · 3 comments · Fixed by scala/scala#9748

Comments

@lrytz
Copy link
Member

lrytz commented May 12, 2021

Java 9+ allows concrete private interface methods, but the scalac parser doesn't accept them

$> scalac B.java
B.java:2: error: `;` expected but `{` found.
  private void foo() { return; }
                     ^
1 error
@lrytz lrytz changed the title Parse concrete private methods in Java Parse concrete private interface methods in Java May 12, 2021
@SethTisue SethTisue added this to the Backlog milestone May 12, 2021
@magnolia-k
Copy link

src/compiler/scala/tools/nsc/javac/JavaParsers.scala should be modified as follows

--- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
@@ -597,7 +597,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
           val vparams = formalParams()
           if (!isVoid) rtpt = optArrayBrackets(rtpt)
           optThrows()
-          val isConcreteInterfaceMethod = !inInterface || (mods hasFlag Flags.JAVA_DEFAULTMETHOD) || (mods hasFlag Flags.STATIC)
+          val isConcreteInterfaceMethod = !inInterface || (mods hasFlag Flags.JAVA_DEFAULTMETHOD) || (mods hasFlag Flags.STATIC) || (mods hasFlag Flags.PRIVATE)
           val bodyOk = !(mods1 hasFlag Flags.DEFERRED) && isConcreteInterfaceMethod
           val body =
             if (bodyOk && in.token == LBRACE) {

@jxnu-liguobin
Copy link
Member

@dengziming You can get it. 🌜 moyuzai

@dengziming
Copy link

I will check this since I am a newbie 🤝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants