Right now my trait has an extra type T which has no real usage other than to ensure B
and R
have the same generic type.
trait GenericBuilder[T <: Any, B <: Builder[T], R <: Result[T]]
To simplify the declaration, I wonder if there is a way to eliminate T
in this case while maintaining the type strictness.
EDIT: I don't have control of the Builder
or Result
code - they are pulled in from some java artifacts outside.
If you just want to simplify that part of the declaration you could move the types into members, but then you end up having to cart around more information because you need a witness that the types are the same:
trait Builder {
type T
}
trait Result {
type T
}
trait GenericBuilder[B <: Builder, R <: Result] {
val w: B.T =:= R.T
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With