I am having a hard time understanding an error related to "could not find value for implicits" error. Here is a minimal example to highlight the error.
sealed trait BehaviourA
final case object A1 extends BehaviourA
final case object A2 extends BehaviourA
sealed trait BehaviourB
final case object B1 extends BehaviourB
final case object B2 extends BehaviourB
trait factory[O<:BehaviourA, R<:BehaviourB]{ ... }
// Define an implicit value for each combination of the two behaviours
object factory {
implicit val behaviour1 = new factory[A1, B1] { ... }
... (one for each Ai, Bj)
}
object genElement {
import factory._
def apply[O <: BehaviourA, R<:BehaviourB](...)(implicit c: factory[O, R])
}
When I try to call it from another method, however, it complains about no value found for implicit c in the genExample.
def callerMtd[T<:BehaviourA](){
genElement[T, B1](...)
}
or
def callerMtd[T<:BehaviourA, R<:BehaviourB](){
genElement[T, R](...)
}
If I call them directly like below, it is fine. Why can't I use type parameters in the caller method?
def callerMtd(){
genElement[A1, B2](...)
}