Here is the code that compiles in 2.11 but does not work 2.12 :
object Main extends App { implicit val c: Configured[String] = new Configured[String] { def apply(v: CfgValue): Option[String] = None } val a = Configured[String] } sealed trait CfgValue { def convertTo[A:Configured]: Option[A] = implicitly[Configured[A]].apply(this) } trait Configured[A] { def apply(v: CfgValue): Option[A] } object Configured { def apply[A:Configured]: Configured[A] = implicitly[Configured[A]] def apply[A](f: CfgValue => Option[A]): Configured[A] = new Configured[A] { def apply(v: CfgValue) = f(v) } }
Failure in 2.12 s:
[error] /tmp/rendererKzypu6fJSu/src/main/scala/test.scala:7: ambiguous reference to overloaded definition, [error] both method apply in object Configured of type (f: CfgValue => Option[String])Configured[String] [error] and method apply in object Configured of type (implicit evidence$2: Configured[String])Configured[String] [error] match expected type ? [error] val a = Configured[String] [error]
After implicit expansion, etc. two method signatures
def apply[A](f: CfgValue => Option[A]): Configured[A] def apply[A](implicit f: Configured[A]): Configured[A]
After SAM, they:
def apply[A](f: CfgValue => Option[A]): Configured[A] def apply[A](implicit f: CfgValue => Option[A]): Configured[A]
Any way to save signatures for 2.12?
source share