Scala implicits resolution mechanism is declaration order dependent?
问题 During daily Scala coding I faced an issue that Scala implicits resolution depends on declaration order. A simple example: object example extends App { trait FooTypeClass[T] { def foo: T } def bar[T](implicit tc: FooTypeClass[T]) = println(tc.foo) class A { // bar[A] doesn't compile } object A { implicit object aFoo extends FooTypeClass[A] { def foo: A = new A { override def toString = "a" } } } bar[A] } It does compile, but if I uncomment the commented line, it won't find the required