javascriptkotlinkotlin-jsreificationkotlin-reified-type-parameters

How Kotlin type reification works on kotlin-js?


On JVM reified types provide a work around for the type erasure.

Why does reification work in the same manner on kotlin-js? (i.e only with inline functions).

Why not all types reify-able?


Solution

  • While there are very minor and subtle differences in behavior on different platform we still should keep in mind that overall behavior should be very similar. That said, certain limitation the JVM platform imposes on us can be in theory omitted / ignored on Kotlin/JS but that would mean that actually Kotlin/JS would be a different language (compared to "just" Kotlin) following different set of specs.

    This will make things extremely confusing and will render code less portable. In other words this won't end well.

    I feel your pain, for instance, sometimes I'm very annoyed not being able to smartcast on a properties from different module, but there's a price for being a full-fledged multiplatform solution.