Determine type without passing generic

Viewed 35

I have a class that gets extended and takes a generic type which itself takes a type:

abstract class BaseClass<T : BaseT<U : BaseU>>

Of course the code above, while it shows the structure of generics passed, is invalid, so I have to write it like this:

abstract class BaseClass<T : BaseT<U>, U : BaseU>

This means I have to write out both types:

class MyClass : BaseClass<MyT, MyU>()

Since MyT declares a type for BaseT to use, is there any way to get the type of U from T without being so verbose? I would like to just write BaseClass<MyT> and have it figure out that since class MyT : BaseT<MyU> it should expect the associated subtype of U, for any subtype of BaseT. Am I overthinking this? Is the correct answer just "write both generics in and stop complaining"?

0 Answers
Related