If you're trying to reuse the same
T
generic type argument defined in your class, remove the second definition of
T
in the function:
fun start(): NeedsTag1<T, StartedTimer> {
Because what you have right now, and I think you have not noticed, is:
class Timer1<T : TagValue>(
//...
fun <U : TagValue> start(): NeedsTag1<U, StartedTimer> {
where
T
and
U
are not the same types. Calling it with the same name won't do what you expect here.
I assume, by the nature of the error, that NeedsTag1 needs a tag of the same type passed as the first generic type argument (
U
in my example), so if this is true, you need to pass a
Tag<U>
to the constructor. However, your
tag
value of the class is of type
Tag<T>
!