Platform annotation

Kotlin language will be compiled for three platforms, therefore each Kotlin library may be compiled for one or multiple platform.

At this moment Kotlin library uses internal annotation to identify useful platforms, I think this a common necessity.

My proposal is to create a public annotaion @Platform (or reconsider current ones) for packages, classes or functions, like:

@Platform( JVM, JS, NATIVE )

This annotation should:

  • Show right identifier in Dokka
  • Compiler should ignore elements for different target


  • If an unannotated element uses target specific method/class (java.*, JS external) then compiler shoul auto-generate annotation
  • If an unannotated element uses annotated method/class then compiler should auto-generate annotation

We have a different solution for multiplatform projects that will not use such annotations. We’ll publish examples and documentation once it’s ready.

1 Like