Skip to content

Commit 7918c0a

Browse files
committed
Allow imports nested in packagings to shadow
1 parent 8527a9b commit 7918c0a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Diff for: compiler/src/dotty/tools/dotc/core/ContextOps.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ object ContextOps:
132132
}
133133

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

Diff for: compiler/src/dotty/tools/dotc/typer/Namer.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ class Namer { typer: Typer =>
395395
def recur(stat: Tree): Context = stat match {
396396
case pcl: PackageDef =>
397397
val pkg = createPackageSymbol(pcl.pid)
398-
index(pcl.stats)(using ctx.fresh.setOwner(pkg.moduleClass))
398+
index(pcl.stats)(using ctx.packageContext(pcl, pkg))
399399
invalidateCompanions(pkg, Trees.flatten(pcl.stats map expanded))
400400
setDocstring(pkg, stat)
401401
ctx

Diff for: tests/pos/i21405.scala

+7
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)