stupid question maybe, but given this function ```...
# getting-started
m
stupid question maybe, but given this function
Copy code
fun <T : Number> test(n1: T, n2: T){ ... }
is it possible to make this illegal (one is int, other is double):
Copy code
test(3, 3.0)
but this should be legal (both are int)
Copy code
test(3, 4)
s
😬
Copy code
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
fun <T : Number> test(n1: @kotlin.internal.Exact T, n2: @kotlin.internal.Exact T) { ... }
âž• 1
(the ugly suppression is because the
@Exact
annotation isn’t supposed to be accessible/usable by us mere mortals)
m
ah yes that 'fixes' it on the call side
but sadly, apparantly I needed more:
Copy code
if(n1 is Int){
        n2 // should now also be inferred to be Int but is still a T
    }