[K/N] Fix KT-58839
Do not export extensions of classes that are hidden from the generated Objective-C API. Merge-request: KT-MR-10330 Merged-by: Sergey Bogolepov <sergey.bogolepov@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
c0ce37a271
commit
89be94f123
+5
-1
@@ -1204,7 +1204,11 @@ abstract class ObjCExportHeaderGenerator internal constructor(
|
||||
.forEach {
|
||||
val classDescriptor = mapper.getClassIfCategory(it)
|
||||
if (classDescriptor != null) {
|
||||
extensions.getOrPut(classDescriptor, { mutableListOf() }) += it
|
||||
// If a class is hidden from Objective-C API then it is meaningless
|
||||
// to export its extensions.
|
||||
if (!classDescriptor.isHiddenFromObjC()) {
|
||||
extensions.getOrPut(classDescriptor, { mutableListOf() }) += it
|
||||
}
|
||||
} else {
|
||||
topLevel.getOrPut(it.findSourceFile(), { mutableListOf() }) += it
|
||||
}
|
||||
|
||||
+5
-1
@@ -182,7 +182,11 @@ internal class ObjCExportLazyImpl(
|
||||
if ((it is KtFunction || it is KtProperty) && it.isPublic && !it.hasExpectModifier()) {
|
||||
val classDescriptor = getClassIfExtension(it)
|
||||
if (classDescriptor != null) {
|
||||
extensions.getOrPut(classDescriptor, { mutableListOf() }) += it
|
||||
// If a class is hidden from Objective-C API then it is meaningless
|
||||
// to export its extensions.
|
||||
if (!classDescriptor.isHiddenFromObjC()) {
|
||||
extensions.getOrPut(classDescriptor, { mutableListOf() }) += it
|
||||
}
|
||||
} else {
|
||||
topLevel += it
|
||||
}
|
||||
|
||||
@@ -756,6 +756,7 @@ __attribute__((swift_name("WrapperOverUnavailable")))
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("HiddenfromobjcKt")))
|
||||
@interface KtHiddenfromobjcKt : KtBase
|
||||
+ (id)doSomethingMeaningless:(NSString *)receiver another:(id)another __attribute__((swift_name("doSomethingMeaningless(_:another:)")));
|
||||
+ (id)useOfUnavailableClassParam:(id)param __attribute__((swift_name("useOfUnavailableClass(param:)")));
|
||||
+ (id _Nullable)useOfNullableUnavailableClassParam:(id _Nullable)param __attribute__((swift_name("useOfNullableUnavailableClass(param:)")));
|
||||
+ (id)produceUnavailable __attribute__((swift_name("produceUnavailable()")));
|
||||
|
||||
@@ -756,6 +756,7 @@ __attribute__((swift_name("WrapperOverUnavailable")))
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("HiddenfromobjcKt")))
|
||||
@interface KtHiddenfromobjcKt : KtBase
|
||||
+ (id)doSomethingMeaningless:(NSString *)receiver another:(id)another __attribute__((swift_name("doSomethingMeaningless(_:another:)")));
|
||||
+ (id)useOfUnavailableClassParam:(id)param __attribute__((swift_name("useOfUnavailableClass(param:)")));
|
||||
+ (id _Nullable)useOfNullableUnavailableClassParam:(id _Nullable)param __attribute__((swift_name("useOfNullableUnavailableClass(param:)")));
|
||||
+ (id)produceUnavailable __attribute__((swift_name("produceUnavailable()")));
|
||||
|
||||
@@ -756,6 +756,7 @@ __attribute__((swift_name("WrapperOverUnavailable")))
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("HiddenfromobjcKt")))
|
||||
@interface KtHiddenfromobjcKt : KtBase
|
||||
+ (id)doSomethingMeaningless:(NSString *)receiver another:(id)another __attribute__((swift_name("doSomethingMeaningless(_:another:)")));
|
||||
+ (id)useOfUnavailableClassParam:(id)param __attribute__((swift_name("useOfUnavailableClass(param:)")));
|
||||
+ (id _Nullable)useOfNullableUnavailableClassParam:(id _Nullable)param __attribute__((swift_name("useOfNullableUnavailableClass(param:)")));
|
||||
+ (id)produceUnavailable __attribute__((swift_name("produceUnavailable()")));
|
||||
|
||||
@@ -11,6 +11,15 @@ import kotlin.experimental.ExperimentalObjCRefinement
|
||||
@HiddenFromObjC
|
||||
data class ClassNotAvailableInSwift(val param: String)
|
||||
|
||||
// KT-58839
|
||||
fun ClassNotAvailableInSwift.doSomethingMeaningless(another: ClassNotAvailableInSwift): ClassNotAvailableInSwift {
|
||||
return ClassNotAvailableInSwift(this.param + another.param)
|
||||
}
|
||||
|
||||
fun String.doSomethingMeaningless(another: ClassNotAvailableInSwift): ClassNotAvailableInSwift {
|
||||
return ClassNotAvailableInSwift(this + another.param)
|
||||
}
|
||||
|
||||
// Check that inner and nested classes are hidden if enclosing class is hidden
|
||||
@OptIn(ExperimentalObjCRefinement::class)
|
||||
@HiddenFromObjC
|
||||
|
||||
Reference in New Issue
Block a user