Created
July 11, 2010 17:23
-
-
Save ohsitab/471693 to your computer and use it in GitHub Desktop.
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
// implicit parameter の探索 | |
class SM[T] | |
object SM { implicit object MA2 extends M[A2] } | |
class M[T] extends SM[T] | |
object M { implicit object MA extends M[A] } | |
class A | |
class A2 | |
class B | |
object B { | |
implicit object MB extends M[B] | |
implicit object MB2 extends M[B2] | |
} | |
class B2 extends B | |
class C | |
class F { | |
def f[T: M](t: T) = "ok" | |
} | |
object F { implicit object MC extends M[C] } | |
val f = new F | |
f.f(new A) | |
f.f(new A2) | |
f.f(new B) | |
f.f(new B2) | |
f.f(new C) // error | |
///////////////////////////////// | |
object D { | |
class E[T] | |
object E { implicit object EB extends E[B] } | |
implicit object EC extends E[C] | |
} | |
def df[T: D.E](t: T) = "ok" | |
df(new A) // error | |
df(new B) | |
df(new C) // なぜかこちらでも通る |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment