Skip to content

Commit a92652c

Browse files
committed
Fix #2856 Drop special treatment of packages in findRef
This aligns behavior with scalac.
1 parent f14e289 commit a92652c

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

+1-13
Original file line numberDiff line numberDiff line change
@@ -243,20 +243,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
243243
if (ctx.scope == null) previous
244244
else {
245245
var result: Type = NoType
246-
247246
val curOwner = ctx.owner
248-
249-
// Can this scope contain new definitions? This is usually the first
250-
// context where either the scope or the owner changes wrt the
251-
// context immediately nested in it. But for package contexts, it's
252-
// the opposite: the last context before the package changes. This distinction
253-
// is made so that top-level imports following a package clause are
254-
// logically nested in that package clause.
255-
val isNewDefScope =
256-
if (curOwner is Package) curOwner ne ctx.outer.owner
257-
else (ctx.scope ne lastCtx.scope) || (curOwner ne lastCtx.owner)
258-
259-
if (isNewDefScope) {
247+
if ((ctx.scope ne lastCtx.scope) || (curOwner ne lastCtx.owner)) {
260248
val defDenot = ctx.denotNamed(name)
261249
if (qualifies(defDenot)) {
262250
val found =

tests/neg/i1641.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package bar { object bippy extends (Double => String) { def apply(x: Double): St
22
package object println { def bippy(x: Int, y: Int, z: Int) = "(Int, Int, Int)" }
33
object Test {
44
def main(args: Array[String]): Unit = {
5-
println(bar.bippy(5.5))
5+
println(bar.bippy(5.5)) // error
66
println(bar.bippy(1, 2, 3)) // error
77
}
88
}

tests/pos/i2856.scala

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.grpc {
2+
trait Grpc
3+
}
4+
package bar {
5+
import io.grpc.Grpc
6+
object a extends Grpc
7+
}

0 commit comments

Comments
 (0)