Skip to content

Instantly share code, notes, and snippets.

@rafaeldff
Forked from retronym/chained-implicits.scala
Created April 28, 2010 14:40
Show Gist options
  • Save rafaeldff/382226 to your computer and use it in GitHub Desktop.
Save rafaeldff/382226 to your computer and use it in GitHub Desktop.
class T {
val t = "T"
}
class U
class V
object T {
implicit def UToT[UU <% U](u: UU) = new T
}
object U {
implicit def VToU[VV <% V](v: VV) = new U
}
object V {
implicit def StringToV(s: String) = new V
}
object Test {
import T._
import U._
import V._
"": T
// compiles to:
// (T.UToT[java.lang.String]("")({
// ((v: java.lang.String) => U.VToU[java.lang.String](v)({
// ((s: String) => V.StringToV(s))
// }))
// }): T)
"".t // this also triggers the conversion.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment