bug icon indicating copy to clipboard operation
bug copied to clipboard

track values of implicit vals when types depend on it

Open scabug opened this issue 13 years ago • 3 comments

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

scabug avatar Jul 25 '12 11:07 scabug

Imported From: https://issues.scala-lang.org/browse/SI-6139?orig=1 Reporter: @adriaanm

scabug avatar Jul 25 '12 11:07 scabug

@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

scabug avatar Aug 05 '13 10:08 scabug

It compiles in Scala 3.5.1.

SethTisue avatar Oct 23 '24 20:10 SethTisue