Skip to content

Commit 9a41716

Browse files
committed
Tweak package name exeptions
1 parent 68b7b75 commit 9a41716

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2855,7 +2855,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
28552855
val pkg = pid1.symbol
28562856
pid1 match
28572857
case pid1: RefTree if pkg.is(Package) =>
2858-
if ctx.owner != defn.EmptyPackageClass then
2858+
if ctx.owner != defn.RootClass // valid top-level "package _root_"
2859+
&& ctx.owner != defn.EmptyPackageClass // valid "package _root_" after parser's "package <empty>" wrapper
2860+
then
28592861
checkNonRootName(pid1.name, pid1.span)
28602862
inContext(ctx.packageContext(tree, pkg)) {
28612863
// If it exists, complete the class containing the top-level definitions

0 commit comments

Comments
 (0)