Native: represent ExperimentalForeignApi in cinterop's Stub IR

cinterop tool should add ExperimentalForeignApi to all generated
declarations by default. This commit supports this annotation in
cinterop intermediate representation -- Stub IR.

^KT-58362
This commit is contained in:
Svyatoslav Scherbina
2023-07-05 15:54:24 +02:00
committed by Space Team
parent 7ca0cb1077
commit d118844b17
4 changed files with 7 additions and 1 deletions
@@ -224,6 +224,8 @@ object KotlinTypes {
val cValue by InteropClassifier
val experimentalForeignApi by InteropClassifier
private open class ClassifierAtPackage(val pkg: String) {
operator fun getValue(thisRef: KotlinTypes, property: KProperty<*>): Classifier =
Classifier.topLevel(pkg, property.name.replaceFirstChar(Char::uppercaseChar))
@@ -264,6 +264,8 @@ sealed class AnnotationStub(val classifier: Classifier) {
class CEnumVarTypeSize(val size: Int) :
AnnotationStub(Classifier.topLevel(cinteropInternalPackage, "CEnumVarTypeSize"))
object ExperimentalForeignApi : AnnotationStub(KotlinTypes.experimentalForeignApi)
private companion object {
val cCallClassifier = Classifier.topLevel(cinteropInternalPackage, "CCall")
@@ -444,6 +444,7 @@ private class MappingExtensions(
)
is AnnotationStub.CStruct.CPlusPlusClass -> emptyMap()
is AnnotationStub.CStruct.ManagedType -> emptyMap()
is AnnotationStub.ExperimentalForeignApi -> emptyMap()
}
return KmAnnotation(classifier.fqNameSerialized, args)
}
@@ -4,7 +4,6 @@
*/
package org.jetbrains.kotlin.native.interop.gen
import kotlinx.cinterop.ExperimentalForeignApi
import org.jetbrains.kotlin.native.interop.gen.jvm.KotlinPlatform
import org.jetbrains.kotlin.native.interop.indexer.*
import org.jetbrains.kotlin.utils.addIfNotNull
@@ -506,6 +505,8 @@ class StubIrTextEmitter(
"@Deprecated(${annotationStub.message.quoteAsKotlinLiteral()}, " +
"ReplaceWith(${annotationStub.replaceWith.quoteAsKotlinLiteral()}), " +
"DeprecationLevel.${annotationStub.level.name})"
is AnnotationStub.ExperimentalForeignApi ->
"@${KotlinTypes.experimentalForeignApi.topLevelName}"
is AnnotationStub.CEnumEntryAlias,
is AnnotationStub.CEnumVarTypeSize,
is AnnotationStub.CStruct.MemberAt,