4 ms·
Due to limitations of JVM itself, reified generics in Kotlin is limited to a very narrow usecase. Basically functions that get inlined. So it's not "true" reif
by V-2 4y ago
Due to limitations of JVM itself, reified generics in Kotlin is limited to a very narrow usecase. Basically functions that get inlined.
So it's not "true" reified generics as in C#.
You can't go "if (T is Whatever)" and put it in your SomeClass<T>.
This is not Kotlin's fault, just legacy of Java with which it has to put up in order to maintain full interoperability.
- imtringued 4y agoCeylon had reified generics though.
- rad_gruchalski 4y agoFor reference: it's type erasure.
- V-2 4y agoYes, exactly. T always becomes Object in runtime, type information is physically gone.
- kaba0 4y agoNot quite true, one pedantic point of mine is that it may be a concrete class if that was marked as T’s superclass, the other is less nitpicky, generic information is actually available at the component itself, so plenty of tools can use it in certain circumstances.