Skip to content

Instantly share code, notes, and snippets.

@seraphr
Created May 13, 2018 17:23
Show Gist options
  • Select an option

  • Save seraphr/818d789375cc2d9086972ece1054745f to your computer and use it in GitHub Desktop.

Select an option

Save seraphr/818d789375cc2d9086972ece1054745f to your computer and use it in GitHub Desktop.
> scala -Xlog-implicits
Welcome to Scala 2.12.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_172).
Type in expressions for evaluation. Or try :help.
scala> object A {
| import scala.language.implicitConversions
| implicit val int: Int = 1
| def a[A]: A = ???
| implicit def asString[A](implicit i: Int): Long => A = _ => a[A]
|
| val s: String = 1L
| }
<console>:17: asString is not a valid implicit value for Long(1L) => String because:
type mismatch;
found : Long(1L)
required: Int
val s: String = 1L
^
<console>:17: error: type mismatch;
found : Long(1L)
required: String
val s: String = 1L
^
scala> object B {
| import scala.language.implicitConversions
| implicit val int: Int = 1
| def a[A]: A = ???
| implicit def asString[A](l: Long)(implicit i: Int): A = a[A]
|
| val s: String = 1L
| }
defined object B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment