bug
bug copied to clipboard
track values of implicit vals when types depend on it
https://gist.github.com/2943283
class Indirection[T](implicit val c: CompanionProvider[T]) {
def indirect: c.CompanionT = c.provide
}
// error: value foo is not a member of _1.c.CompanionT
new Indirection[Foo].indirect.foo
this doesn't work because new Indirection[Foo]: Indirection[Foo],
i.e., there's no information about the implicit value that was inferred for c in the type of the target of the selection of indirect
Imported From: https://issues.scala-lang.org/browse/SI-6139?orig=1 Reporter: @adriaanm
@retronym said: An example from the mailing lists:
sealed trait EntityRef {
type RefId
}
trait ProductRef extends EntityRef {
type RefId = Boolean
}
object SomeAction {
implicit def rootRef2Id[T <: EntityRef](ref: T): ref.RefId = ???
def handle(c: ProductRef) {
locally(c: Boolean)
}
}
Implicit search approximates the type of `rootRef2Id` as `(?) => ?#RefId`. This happens here in Implicits.scala [1].
I have added this example to SI-6139 [2]. It is unlikely we'll touch this in 2.11, so you might need to pursue a different approach.
-jason
It compiles in Scala 3.5.1.