Permalink
Browse files

SI-6225 Fix import of inherited package object implicits

The prefix in the ImplicitInfo must be com.acme.`package`.type,
rather than com.acme.
  • Loading branch information...
1 parent 6537d79 commit 451cab967a332773c2027ada7553d5d59c0dc4b1 @retronym retronym committed Feb 8, 2013
Showing with 28 additions and 1 deletion.
  1. +8 −1 src/compiler/scala/tools/nsc/typechecker/Contexts.scala
  2. +20 −0 test/files/pos/t6225.scala
@@ -644,7 +644,14 @@ trait Contexts { self: Analyzer =>
new ImplicitInfo(sym.name, pre, sym)
private def collectImplicitImports(imp: ImportInfo): List[ImplicitInfo] = {
- val pre = imp.qual.tpe
+ val qual = imp.qual
+
+ val pre =
+ if (qual.tpe.typeSymbol.isPackageClass)
+ // SI-6225 important if the imported symbol is inherited by the the package object.
+ singleType(qual.tpe, qual.tpe member nme.PACKAGE)
+ else
+ qual.tpe
def collect(sels: List[ImportSelector]): List[ImplicitInfo] = sels match {
case List() =>
List()
View
@@ -0,0 +1,20 @@
+
+package library.x {
+ class X {
+ class Foo
+ implicit val foo: Foo = new Foo
+ }
+}
+package library {
+ package object y extends library.x.X
+}
+
+object ko {
+ import library.y.{Foo, foo}
+ implicitly[Foo]
+}
+
+object ko2 {
+ import library.y._
+ implicitly[Foo]
+}

0 comments on commit 451cab9

Please sign in to comment.