I have a complex use case of generics type which has been simplified below
trait A
class AB extends A{
val v = 10
}
trait X[T<:A]{
def request: T
}
class XY extends X[AB]{
def request = new AB()
}
class Test extends App{
/**
* X[A]
* X[AB]
* XY[A]
* XY[AB]
*/
def test[C<:A, D <: X[C]](t:Int)(input: D): Unit ={
print(input.getClass.getName)
}
implicit val req = new XY()
test(2)(req)
}
test method should support the Type scenarios defined in comment section. I'm getting the below compilation error.
Error:(33, 7) inferred type arguments [XY] do not conform to method test's type parameter bounds [D <: X[Nothing]] test(2)(req)
Is this syntactically legal? Thanks in advance.