I am new to Scala and implicit conversions.
I am working with an existing scala library over which I have no control. Lets consider a class R from the library.
abstract class R {
}
object R {
implicit def RFunctions[K, V](r: R[(K, V)]) (implicit kt: ClassTag[K],vt: ClassTag[V], ord: Ordering[K] = null): RFunctions[K, V] = { new RFunctions(r) }
}
I am extending the class R to override almost all of its behavior. But this new class is a Java class. Let's call this A.
class A extends R {
}
Problem is, at some point in my control flow, the control jumps to the implicit declaration for R and ends up using RFunctions class for any functionality.
The methods which are present in RFunctions are also implemented in my extended class A. I do not understand how I can bypass or avoid the implicit conversion.
Any ideas would be appreciated.
Extend
abstract class R
withabstract class Rbis
in Scala, and in companionobject Rbis
define the implicit functions you need (they will be called before the ones inR
in our case), then in java you extendRbis
.