Skip to content

Instantly share code, notes, and snippets.

@lopex
Created November 7, 2010 21:18
Show Gist options
  • Save lopex/666857 to your computer and use it in GitHub Desktop.
Save lopex/666857 to your computer and use it in GitHub Desktop.
object cbfx2 {
trait X[K, L]
trait A[T] {
def foo[L](i: L)(implicit a: X[T, L]) = null
}
class B[T] extends A[T]
object B {
implicit def foo[T, L]: X[T, L] = {println("B");null}
implicit def foo2[T]: X[T, Int] = {println("B Int");null}
}
class C extends B[C]
object C {
implicit def foo[L]: X[C, String] = {println("C");null}
}
class K { def foo(implicit k: Int) = null }
object K { implicit def foo = 0}
def main(args: Array[String]) {
import K._
val k = new K
k.foo
val b = new B[B[Int]]
b.foo("a")
b.foo(3)
val c = new C
c.foo(3)
c.foo("dd")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment