Why are inline function generic types not always reified?


#1

Congrats on M10!

One thing I did not understand from your blog post (though I am certain there is a good reason) is why reified generic types have to be marked as such, after the technique was advertised as being low cost/free because it only works for inlined functions. This seems like a rather exotic and complicated annotation to understand - “reified” is not even a word that most programmers have ever encountered. Can the compiler not just DWIM here?


#2

A normal type parameter or even a generic type like List<String> can not be passed as an argument to a reified type parameter, so if we made all type parameters of inline functions reified, most collection utilities that are inlined now, would become virtually useless on complex inputs. On the other hand, a rather modest fraction of functions (mostly those concerned with introspection of some sort: reflection and/or is-checks and casts) need this, so "reified" burdens rather few users, mostly library/framework writers.


#3

I haven't seen 'reified' myself until Kotlin. It would be good to explain what it is in a paragraph in the documentation. I'm still not quite certain, is it just a generic that the type information is kept at runtime?

In M10 I seem to only be able to use reified generics in inline functions, and no longer in classes. Or rather, that’s the case with the JVM, it seems to not have made it to the JS compiler yet.