bug icon indicating copy to clipboard operation
bug copied to clipboard

Implicit search does not guide type inference to find a supertype

Open scabug opened this issue 10 years ago • 1 comments

trait R[T]

case class A(i: Int)

object A {

  implicit object RA extends R[A]

}

class B(i: Int) extends A(i)

def foo[T, TT >: T](x : T)(implicit ev: R[TT]) = 0

println(foo(new B(1))) // infers T  and TT as B and fails to find implicit R[B]

It seems that TT is inferred before getting to the implicit parameter block in spite of not being mentioned in the first parameter block.

Related SO question: http://stackoverflow.com/questions/28509637/implicit-search-does-not-guide-type-inference-to-find-a-supertype-in-scala

scabug avatar Feb 21 '15 16:02 scabug

Imported From: https://issues.scala-lang.org/browse/SI-9169?orig=1 Reporter: Jonathan Chayat (jchayat) Affected Versions: 2.10.4, 2.11.5

scabug avatar Feb 21 '15 16:02 scabug