Skip to content

Commit

Permalink
Allow imports nested in packagings to shadow (scala#21539)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand authored Nov 6, 2024
2 parents 14c15b4 + 905cbd1 commit 7f141a9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ class CompletionTest {

@Test def importAnnotationAfterImport : Unit =
code"""import java.lang.annotation; import annot${m1}"""
.completion(("annotation", Module, "scala.annotation"))
.completion(("annotation", Module, "java.lang.annotation"))

@Test def completeTemplateConstrArgType: Unit = {
code"""import scala.concurrent.Future
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 7f141a9

Please sign in to comment.