marcelo
10/20/2018, 2:01 AMtag
within my start
method saying:
Required:
Tag<T#1 (type parameter of com.revl.metrics.Timer1.start)>
Found:
Tag<T#2 (type parameter of com.revl.metrics.Timer1)>
karelpeeters
10/20/2018, 7:36 AMskneko
10/20/2018, 10:47 AMT
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>
!