-
-
Save echojc/750ba177f88f4e81d2d0 to your computer and use it in GitHub Desktop.
Using -Xprint:typer to see the result - looks like the typer is the one responsible for filling in implicits
This file contains 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
/* | |
$ echo 'scalacOptions += "-Xprint:typer"' > build.sbt | |
$ sbt console | |
*/ | |
// with the generic version | |
scala> class A { def foo[T](): String = ??? } | |
scala> implicit class PimpedA { def foo[T](i: String): String = ??? } | |
scala> val a = new A() | |
scala> a.foo("aoeu") | |
private[this] val res0: <error> = /*$line5.$read.$iw.$iw.*/a.foo[Nothing]("aoeu"); | |
// with the non-generic version | |
scala> class B { def foo(): String = ??? } | |
scala> implicit class PimpedB { def foo(i: String): String = ??? } | |
scala> val b = new B() | |
scala> b.foo("aoeu") | |
private[this] val res1: String = /*$line8.$read.$iw.$iw.*/PimpedB(/*$line9.$read.$iw.$iw.*/b).foo("aoeu"); | |
/* | |
It looks like the typer is the part of the compiler responsible for filling | |
in implicit conversions like this, and it's just not resolving when it's | |
the generic version. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment