Is the following expected behavior or bug in Scala?
CASE 1:
class X[T1, T2]
class XExt[T1, T2] extends X[T1, T2]
class Y[T[t1] <: X[t1, _]]
class YExt extends Y[XExt]
results in Error: XExt takes two type parameters, expected: one
class YExt extends Y[XExt]
^
But the following runs ok:
class X[T1, T2]
class XExt[T1, T2] extends X[T1, T2]
class Y[T[t1, t2] <: X[t1, t2]]
class YExt extends Y[XExt]
Minimizing the number of params could simplify code like type params: type T[t1] <: X[t1, _].
CASE 2:
class X[T1, T2]
class Y[T[t1, t2] <: X[t1, t2]]
class Z[T <: Y[_]]
results in Error: _$1 takes no type parameters, expected: two
class Z[T <: Y[_]]
^
But how to avoid defining Y parameters if i do not require them? Like in:
class X[T1, T2]
class Y[T <: X[_, _]]
class Z[T <: Y[_]]
CASE 3:
trait A[T]
trait B[T[t] <: A[t]]
trait AExt extends A[Int]
trait BExt extends B[AExt]
results in Error: AExt takes no type parameters, expected: one
trait BExt extends B[AExt]
^
But why compiler requests one parameter if it's already supplied? It seems a contradiction. And how to subclass B?
That behavior is observed in IntelliJ Scala plugin and Eclipse Scala IDE. So it's probably the Scala compiler functioning.
Y[_]a nested higher kind with a constraint you need to provide the compile enough evidence that you are respecting that constraint:class Z[S[t1, t2] <: X[t1,t2], T <: Y[S]].Thas not the same bound, theTin the class and the one in the second case are two differentT, only because they have the same letter doesn't mean that they are related.