I'm having a problem with implicit conversion in the following code:
trait A {
def send(s: String): String = {
println(s)
s
}
}
object X {
implicit def toB(a: A): B = new B(a)
class B(a: A) {
def <<(s: String): String = a send s
}
}
object Y {
implicit def toB(a: A): B = new B(a)
class B(a: A) {
}
}
object Test extends App {
import X._
import Y._
val a: A = new A {}
a << "Test"
}
The last statement in Test causes compile error:
error: value << is not a member of A
a << "Test"
However if I remove import Y._ from Test, it compiles fine.
Note that in the real code both X.B and Y.B are part of Scala DSL for a Java library and I'd like to be able to use both in the same compilation unit.