Skip to content

Fix #2856 Drop special treatment of packages in findRef #2860

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

Merged
merged 2 commits into from
Jul 13, 2017
Merged
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
11 changes: 9 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
@@ -251,9 +251,16 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
// context immediately nested in it. But for package contexts, it's
// the opposite: the last context before the package changes. This distinction
// is made so that top-level imports following a package clause are
// logically nested in that package clause.
// logically nested in that package clause. Finally, for the root package
// we switch back to the original test. This means that rop-level packages in
// the root package take priority over root imports. For instance,
// a top-level io package takes priority over scala.io.
// It would be nice if we could drop all this complication, and
// always use the second condition. Unfortunately compileStdLib breaks
// with an error on CI which I cannot replicate locally (not even
// with the exact list of files given).
val isNewDefScope =
if (curOwner is Package) curOwner ne ctx.outer.owner
if (curOwner.is(Package) && !curOwner.isRoot) curOwner ne ctx.outer.owner
else (ctx.scope ne lastCtx.scope) || (curOwner ne lastCtx.owner)

if (isNewDefScope) {
2 changes: 1 addition & 1 deletion tests/neg/i1641.scala
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ package bar { object bippy extends (Double => String) { def apply(x: Double): St
package object println { def bippy(x: Int, y: Int, z: Int) = "(Int, Int, Int)" }
object Test {
def main(args: Array[String]): Unit = {
println(bar.bippy(5.5))
println(bar.bippy(5.5)) // error
println(bar.bippy(1, 2, 3)) // error
}
}
7 changes: 7 additions & 0 deletions tests/pos/i2856.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.grpc {
trait Grpc
}
package bar {
import io.grpc.Grpc
object a extends Grpc
}