Skip to content

Commit ce0e25c

Browse files
authored
Merge pull request #13378 from griggt/fix-13310
Fix #13310: Parse empty Java compilation units as EmptyTree
2 parents 9e06f24 + fbea0ff commit ce0e25c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,9 @@ object JavaParsers {
10131013
}
10141014
val unit = atSpan(start) { PackageDef(pkg, buf.toList) }
10151015
accept(EOF)
1016-
unit
1016+
unit match
1017+
case PackageDef(Ident(nme.EMPTY_PACKAGE), Nil) => EmptyTree
1018+
case _ => unit
10171019
}
10181020
}
10191021

tests/pos/i13310.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// The entire contents of this file is intentionally commented out
2+
// public class i13310 {}

0 commit comments

Comments
 (0)