Created
July 11, 2010 17:39
-
-
Save ohsitab/471701 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の探索には優先順位はない? | |
abstract class M[T] { def s: String } | |
object M { implicit object MA extends M[A] { def s = "M" } } | |
class A | |
object A { implicit object MA extends M[A] { def s = "A" } } | |
def f[T: M](t: T) = implicitly[M[T]].s | |
f(new A) // error: ambiguous implicit values | |
// 当然、スコープに直接定義されてる場合はそちらが優先される | |
implicit object MA extends M[A] { def s = "scope" } | |
f(new A) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment