Skip to content

Fix #7525: Allow static methods having body in JavaParser #7534

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

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ object JavaParsers {
val vparams = formalParams()
if (!isVoid) rtpt = optArrayBrackets(rtpt)
optThrows()
val bodyOk = !inInterface || (mods.is(Flags.DefaultMethod))
val bodyOk = !inInterface || mods.is(Flags.DefaultMethod) || mods.is(Flags.JavaStatic)
val body =
if (bodyOk && in.token == LBRACE)
methodBody()
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/i7525/Interface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Test static methods in interface can also have body.

public interface Interface {
static void s() {}
}