Support new scheme of compilation of OptionalExpectation annotations

Instead of generating these annotation classes as package-private on
JVM, serialize their metadata to the .kotlin_module file, and load it
when compiling dependent multiplatform modules.

The problem with generating them as package-private was that
kotlin-stdlib for JVM would end up declaring symbols from other
platforms, which would include some annotations from package
kotlin.native. But using that package is discouraged by some tools
because it has a Java keyword in its name. In particular, jlink refused
to work with such artifact altogether (KT-21266).

 #KT-38652 Fixed
This commit is contained in:
Alexander Udalov
2019-12-17 17:43:42 +01:00
committed by Alexander Udalov
parent 63e355d979
commit 012ffa2993
42 changed files with 1469 additions and 145 deletions

View File

@@ -8,7 +8,6 @@ Cleaning output files:
End of files
Cleaning output files:
out/production/pJvm/FKt.class
out/production/pJvm/SharedImmutable.class
End of files
Compiling files:
c/src/f.kt

View File

@@ -0,0 +1,7 @@
c [sourceSetHolder]
pJvm [compilationAndSourceSetHolder, jvm]
pJvm -> c [include]
pJs [compilationAndSourceSetHolder, js]
pJs -> c [include]

View File

@@ -0,0 +1,24 @@
================ Step #1 =================
Building c
Building pJs
Cleaning output files:
out/production/pJs/pJs.js
out/production/pJs/pJs.meta.js
out/production/pJs/pJs/root-package.kjsm
End of files
Compiling files:
c/src/usage.kt
End of files
Exit code: OK
------------------------------------------
Building pJvm
Cleaning output files:
out/production/pJvm/META-INF/pJvm.kotlin_module
out/production/pJvm/Usage.class
End of files
Compiling files:
c/src/usage.kt
End of files
Exit code: OK
------------------------------------------

View File

@@ -0,0 +1,3 @@
@OptIn(ExperimentalMultiplatform::class)
@OptionalExpectation
expect annotation class Optional(val value: String)

View File

@@ -0,0 +1,2 @@
@Optional("1")
class Usage

View File

@@ -0,0 +1,2 @@
@Optional("2")
class Usage