Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow imports nested in packagings to shadow #21539

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading