Imagine I had some function that takes a String explicitly and an T implicitly:
object SomeNamespace {
def myFunction(arg: String)(implicit t: T)
}
And I had a superclass which provides the T
trait TProvider {
val t: T = ...
}
And in a subclass I use extends TProvider and try to use the function
class Child extends TProvider {
SomeNamespace.myFunction("somestring")
}
I would get an error "could not find implicit value for parameter t". My workaround is to reassign the superclass val to a new implicit one in the subclass like:
implicit val subclassImplicitT = t
and that works ... but is kind of ugly. Is there some better way to "implicitify" a variable?
myFunction
defined? InChild
orTProvider
? – adrice727