Created
May 13, 2018 17:23
-
-
Save seraphr/818d789375cc2d9086972ece1054745f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > 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