Skip to content

Commit 7f141a9

Browse files
authored
Allow imports nested in packagings to shadow (scala#21539)
2 parents 14c15b4 + 905cbd1 commit 7f141a9

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

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

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

language-server/test/dotty/tools/languageserver/CompletionTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ class CompletionTest {
987987

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

992992
@Test def completeTemplateConstrArgType: Unit = {
993993
code"""import scala.concurrent.Future

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)