I have two classes:
class X[A](implicit ord: Ordering[A]) // + other irrelevant parameters
class Y[A: Ordering] extends X[A]
Given a Symbol
corresponding to Y
's implicit constructor parameter, I want to find the symbol for the parent class implicit parameter it corresponds to (if one exists).
val yOrdSym = ...
val yOrdType = yOrdSym.typeSignature
val xImplicitParams =
xSym.primaryConstructor.paramLists.flatten.
filter(xParam => xParam.isImplicit && ???)
Now I need to filter it for having the same type as well (or a supertype, but this doesn't matter for my usecase). I've tried xParam.typeSignature =:= yOrdSym.typeSignature
, which didn't work. This makes sense, because the type parameters have different owners. However, xParam.typeSignature =:= yOrdSym.typeSignatureIn(xSym.toType)
and xParam.typeSignatureIn(ySym.toType) =:= yOrdSym.typeSignature
don't work either. How to do it correctly?