Skip to content

Commit b35033d

Browse files
authored
Merge pull request #79 from scala/backport-lts-3.3-21539
Backport "Allow imports nested in packagings to shadow" to 3.3 LTS
2 parents e7e3c47 + 0bfc21f commit b35033d

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
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

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

Lines changed: 1 addition & 1 deletion
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

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)