Skip to content

Commit

Permalink
Allow imports nested in packagings to shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Sep 4, 2024
1 parent 8527a9b commit 7918c0a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/ContextOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ object ContextOps:
}

def packageContext(tree: untpd.PackageDef, pkg: Symbol): Context = inContext(ctx) {
if (pkg.is(Package)) ctx.fresh.setOwner(pkg.moduleClass).setTree(tree)
if (pkg.is(Package)) ctx.fresh.setOwner(pkg.moduleClass).setTree(tree).setNewScope
else ctx
}
end ContextOps
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class Namer { typer: Typer =>
def recur(stat: Tree): Context = stat match {
case pcl: PackageDef =>
val pkg = createPackageSymbol(pcl.pid)
index(pcl.stats)(using ctx.fresh.setOwner(pkg.moduleClass))
index(pcl.stats)(using ctx.packageContext(pcl, pkg))
invalidateCompanions(pkg, Trees.flatten(pcl.stats map expanded))
setDocstring(pkg, stat)
ctx
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i21405.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package o { class IO }
package p { class IO }
import o._
package q {
import p._
class D extends IO
}

0 comments on commit 7918c0a

Please sign in to comment.