Add unavailable stub to framework for Kotlin subclass of Obj-C class
To improve discoverability of the corresponding limitation
This commit is contained in:
committed by
SvyatoslavScherbina
parent
9e3a68f835
commit
49dc267eb4
+21
-7
@@ -220,15 +220,19 @@ abstract class ObjCExportHeaderGenerator(
|
|||||||
getContributedDescriptors()
|
getContributedDescriptors()
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filterIsInstance<ClassDescriptor>()
|
.filterIsInstance<ClassDescriptor>()
|
||||||
.filter { mapper.shouldBeExposed(it) }
|
|
||||||
.forEach {
|
.forEach {
|
||||||
if (it.isInterface) {
|
if (mapper.shouldBeExposed(it)) {
|
||||||
translateInterface(it)
|
if (it.isInterface) {
|
||||||
} else {
|
translateInterface(it)
|
||||||
translateClass(it)
|
} else {
|
||||||
}
|
translateClass(it)
|
||||||
|
}
|
||||||
|
|
||||||
it.unsubstitutedMemberScope.translateClasses()
|
it.unsubstitutedMemberScope.translateClasses()
|
||||||
|
} else if (it.isKotlinObjCClass() && mapper.shouldBeVisible(it)) {
|
||||||
|
assert(!it.isInterface)
|
||||||
|
translateKotlinObjCClassAsUnavailableStub(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,6 +261,16 @@ abstract class ObjCExportHeaderGenerator(
|
|||||||
return stubs
|
return stubs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun translateKotlinObjCClassAsUnavailableStub(descriptor: ClassDescriptor) {
|
||||||
|
stubs.add(objCInterface(
|
||||||
|
namer.getClassOrProtocolName(descriptor),
|
||||||
|
descriptor = descriptor,
|
||||||
|
superClass = "NSObject",
|
||||||
|
attributes = listOf("unavailable(\"Kotlin subclass of Objective-C class can't be imported\")")
|
||||||
|
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
private fun genKotlinNumbers() {
|
private fun genKotlinNumbers() {
|
||||||
val members = buildMembers {
|
val members = buildMembers {
|
||||||
NSNumberKind.values().forEach {
|
NSNumberKind.values().forEach {
|
||||||
|
|||||||
+7
-4
@@ -54,10 +54,13 @@ internal fun ObjCExportMapper.shouldBeExposed(descriptor: CallableMemberDescript
|
|||||||
descriptor.isEffectivelyPublicApi && !descriptor.isSuspend && !descriptor.isExpect
|
descriptor.isEffectivelyPublicApi && !descriptor.isSuspend && !descriptor.isExpect
|
||||||
|
|
||||||
internal fun ObjCExportMapper.shouldBeExposed(descriptor: ClassDescriptor): Boolean =
|
internal fun ObjCExportMapper.shouldBeExposed(descriptor: ClassDescriptor): Boolean =
|
||||||
descriptor.isEffectivelyPublicApi && !descriptor.defaultType.isObjCObjectType() && when (descriptor.kind) {
|
shouldBeVisible(descriptor) && !descriptor.defaultType.isObjCObjectType()
|
||||||
ClassKind.CLASS, ClassKind.INTERFACE, ClassKind.ENUM_CLASS, ClassKind.OBJECT -> true
|
|
||||||
ClassKind.ENUM_ENTRY, ClassKind.ANNOTATION_CLASS -> false
|
internal fun ObjCExportMapper.shouldBeVisible(descriptor: ClassDescriptor): Boolean =
|
||||||
} && !descriptor.isExpect && !isSpecialMapped(descriptor) && !descriptor.isInlined()
|
descriptor.isEffectivelyPublicApi && when (descriptor.kind) {
|
||||||
|
ClassKind.CLASS, ClassKind.INTERFACE, ClassKind.ENUM_CLASS, ClassKind.OBJECT -> true
|
||||||
|
ClassKind.ENUM_ENTRY, ClassKind.ANNOTATION_CLASS -> false
|
||||||
|
} && !descriptor.isExpect && !isSpecialMapped(descriptor) && !descriptor.isInlined()
|
||||||
|
|
||||||
private fun ObjCExportMapper.isBase(descriptor: CallableMemberDescriptor): Boolean =
|
private fun ObjCExportMapper.isBase(descriptor: CallableMemberDescriptor): Boolean =
|
||||||
descriptor.overriddenDescriptors.all { !shouldBeExposed(it) }
|
descriptor.overriddenDescriptors.all { !shouldBeExposed(it) }
|
||||||
|
|||||||
Reference in New Issue
Block a user