Skip to content

Commit 81e4fe4

Browse files
dwijnandtgodzik
authored andcommitted
Allow imports nested in packagings to shadow
[Cherry-picked af0283f]
1 parent e7e3c47 commit 81e4fe4

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/core/ContextOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ object ContextOps:
135135
}
136136

137137
def packageContext(tree: untpd.PackageDef, pkg: Symbol): Context = inContext(ctx) {
138-
if (pkg.is(Package)) ctx.fresh.setOwner(pkg.moduleClass).setTree(tree)
138+
if (pkg.is(Package)) ctx.fresh.setOwner(pkg.moduleClass).setTree(tree).setNewScope
139139
else ctx
140140
}
141141
end ContextOps

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ class Namer { typer: Typer =>
387387
def recur(stat: Tree): Context = stat match {
388388
case pcl: PackageDef =>
389389
val pkg = createPackageSymbol(pcl.pid)
390-
index(pcl.stats)(using ctx.fresh.setOwner(pkg.moduleClass))
390+
index(pcl.stats)(using ctx.packageContext(pcl, pkg))
391391
invalidateCompanions(pkg, Trees.flatten(pcl.stats map expanded))
392392
setDocstring(pkg, stat)
393393
ctx

tests/pos/i21405.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package o { class IO }
2+
package p { class IO }
3+
import o._
4+
package q {
5+
import p._
6+
class D extends IO
7+
}

0 commit comments

Comments
 (0)