Skip to content

Commit bb96612

Browse files
Merge pull request #7534 from noti0na1/master
Fix #7525: Allow static methods having body in JavaParser
2 parents 2e4e72d + d4531f0 commit bb96612

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ object JavaParsers {
521521
val vparams = formalParams()
522522
if (!isVoid) rtpt = optArrayBrackets(rtpt)
523523
optThrows()
524-
val bodyOk = !inInterface || (mods.is(Flags.DefaultMethod))
524+
val bodyOk = !inInterface || mods.isOneOf(Flags.DefaultMethod | Flags.JavaStatic)
525525
val body =
526526
if (bodyOk && in.token == LBRACE)
527527
methodBody()

tests/pos/i7525/Interface.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Test static methods in interface can also have body.
2+
3+
public interface Interface {
4+
static void s() {}
5+
}

0 commit comments

Comments
 (0)