Skip to content

Commit 413bceb

Browse files
committed
Fix to asSeenFrom for package object members
Like TypeAssigner, asSeenFrom needs to insert a package object if the prefix is a package but the class enclosing the type is not.
1 parent 9bc3bb2 commit 413bceb

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ trait TypeOps { this: Context =>
2222
case SuperType(thispre, _) => thispre
2323
case _ => pre
2424
}
25+
else if ((pre.termSymbol is Package) && !(thiscls is Package))
26+
toPrefix(pre.select(nme.PACKAGE), cls, thiscls)
2527
else
2628
toPrefix(pre.baseTypeRef(cls).normalizedPrefix, cls.owner, thiscls)
2729
}

tests/pos/i0239.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package p {
2+
class C[A] {
3+
implicit def foo: M[A] = ???
4+
}
5+
6+
object `package` extends C[String]
7+
8+
object test0 {
9+
def compute[A](implicit m: M[A]): A = ???
10+
val v = compute
11+
val v1: String = v
12+
}
13+
}
14+
15+
trait M[A]
16+
17+
object test1 {
18+
19+
def compute[A](implicit m: M[A]): A = ???
20+
21+
import p._
22+
val v = compute
23+
val v1: String = v
24+
}

0 commit comments

Comments
 (0)