Inferring type of generic implicit parameter from return type

前端 未结 1 421

Say I have a simple class like this

abstract class Foo {
  implicit val impInt: Int = 42
  def f[A]()(implicit a: A): A
  val f2: Int = f()
}
1条回答
  •  遥遥无期
    2020-12-18 04:00

    There must be something wrong with the way ordering instances are generated, as the code below works. I'd report a bug.

    case object types {
      implicit def buh[X]: List[X] = List()
    }
    abstract class Foo {
    
      import types._
    
      def f[A]()(implicit l: List[A]): A
      val f2: Int = f()
    }
    

    0 讨论(0)
提交回复
热议问题