Created
November 7, 2010 21:18
-
-
Save lopex/666857 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
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