Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[K/N] KT-62984: Support @Composable annotation hidden from C export #5375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.backend.konan.descriptors.getPackageFragments
import org.jetbrains.kotlin.backend.konan.driver.phases.PsiToIrContext
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotated
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.util.referenceFunction
Expand Down Expand Up @@ -51,11 +52,19 @@ private enum class Direction {
C_TO_KOTLIN
}

private val hiddenFromObjCAnnotation = FqName("kotlin.native.HiddenFromObjC")

private fun hasHiddenAnnotation(descriptor: Annotated): Boolean {
return descriptor.annotations.hasAnnotation(hiddenFromObjCAnnotation)
}

private fun isExportedFunction(descriptor: FunctionDescriptor): Boolean {
if (!descriptor.isEffectivelyPublicApi || !descriptor.kind.isReal || descriptor.isExpect)
return false
if (descriptor.isSuspend)
return false
if (hasHiddenAnnotation(descriptor))
return false
return !descriptor.typeParameters.any()
}

Expand All @@ -70,6 +79,7 @@ private fun isExportedClass(descriptor: ClassDescriptor): Boolean {
if (!descriptor.declaredTypeParameters.isEmpty()) return false
// Do not export inline classes for now. TODO: add proper support.
if (descriptor.isInlined()) return false
if (hasHiddenAnnotation(descriptor)) return false

return true
}
Expand Down