[ObjCExport] Fix interface implementing interface
KT-66380
This commit is contained in:
committed by
Space Team
parent
f18d00e6f0
commit
aaea1d6af2
+3
-2
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.backend.konan.objcexport.ObjCProtocol
|
|||||||
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCProtocolImpl
|
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCProtocolImpl
|
||||||
import org.jetbrains.kotlin.backend.konan.objcexport.toNameAttributes
|
import org.jetbrains.kotlin.backend.konan.objcexport.toNameAttributes
|
||||||
import org.jetbrains.kotlin.objcexport.analysisApiUtils.getDeclaredSuperInterfaceSymbols
|
import org.jetbrains.kotlin.objcexport.analysisApiUtils.getDeclaredSuperInterfaceSymbols
|
||||||
|
import org.jetbrains.kotlin.objcexport.analysisApiUtils.isObjCBaseCallable
|
||||||
import org.jetbrains.kotlin.objcexport.analysisApiUtils.isVisibleInObjC
|
import org.jetbrains.kotlin.objcexport.analysisApiUtils.isVisibleInObjC
|
||||||
|
|
||||||
context(KtAnalysisSession, KtObjCExportSession)
|
context(KtAnalysisSession, KtObjCExportSession)
|
||||||
@@ -24,10 +25,10 @@ fun KtClassOrObjectSymbol.translateToObjCProtocol(): ObjCProtocol? {
|
|||||||
// TODO: Check error type!
|
// TODO: Check error type!
|
||||||
val name = getObjCClassOrProtocolName()
|
val name = getObjCClassOrProtocolName()
|
||||||
|
|
||||||
val members = getDeclaredMemberScope().getCallableSymbols()
|
val members = getCallableSymbolsForObjCMemberTranslation()
|
||||||
|
.filter { it.isObjCBaseCallable() }
|
||||||
.sortedWith(StableCallableOrder)
|
.sortedWith(StableCallableOrder)
|
||||||
.mapNotNull { it.translateToObjCExportStub() }
|
.mapNotNull { it.translateToObjCExportStub() }
|
||||||
.toList()
|
|
||||||
|
|
||||||
val comment: ObjCComment? = annotationsList.translateToObjCComment()
|
val comment: ObjCComment? = annotationsList.translateToObjCComment()
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -106,11 +106,15 @@ class ObjCExportHeaderGeneratorTest(private val generator: HeaderGenerator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TodoAnalysisApi
|
|
||||||
fun `test - interfaceImplementingInterface`() {
|
fun `test - interfaceImplementingInterface`() {
|
||||||
doTest(headersTestDataDir.resolve("interfaceImplementingInterface"))
|
doTest(headersTestDataDir.resolve("interfaceImplementingInterface"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test - multipleInterfacesImplementationChain`() {
|
||||||
|
doTest(headersTestDataDir.resolve("multipleInterfacesImplementationChain"))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test - classWithObjCNameAnnotation`() {
|
fun `test - classWithObjCNameAnnotation`() {
|
||||||
doTest(headersTestDataDir.resolve("classWithObjCNameAnnotation"))
|
doTest(headersTestDataDir.resolve("classWithObjCNameAnnotation"))
|
||||||
|
|||||||
+1
-1
@@ -6,4 +6,4 @@ interface Foo {
|
|||||||
|
|
||||||
interface Bar : Foo {
|
interface Bar : Foo {
|
||||||
override fun someMethodWithCovariantOverwrite(): String = ""
|
override fun someMethodWithCovariantOverwrite(): String = ""
|
||||||
}
|
}
|
||||||
+47
@@ -0,0 +1,47 @@
|
|||||||
|
#import <Foundation/NSArray.h>
|
||||||
|
#import <Foundation/NSDictionary.h>
|
||||||
|
#import <Foundation/NSError.h>
|
||||||
|
#import <Foundation/NSObject.h>
|
||||||
|
#import <Foundation/NSSet.h>
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSValue.h>
|
||||||
|
|
||||||
|
@protocol A, B, C;
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||||
|
#pragma clang diagnostic ignored "-Wincompatible-property-type"
|
||||||
|
#pragma clang diagnostic ignored "-Wnullability"
|
||||||
|
|
||||||
|
#pragma push_macro("_Nullable_result")
|
||||||
|
#if !__has_feature(nullability_nullable_result)
|
||||||
|
#undef _Nullable_result
|
||||||
|
#define _Nullable_result _Nullable
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@protocol A
|
||||||
|
@required
|
||||||
|
- (id)funA __attribute__((swift_name("funA()")));
|
||||||
|
- (id)funAForOverride __attribute__((swift_name("funAForOverride()")));
|
||||||
|
@property (readonly) int32_t propertyA __attribute__((swift_name("propertyA")));
|
||||||
|
@property (readonly) int32_t propertyAForOverride __attribute__((swift_name("propertyAForOverride")));
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol B <A>
|
||||||
|
@required
|
||||||
|
- (void)funB __attribute__((swift_name("funB()")));
|
||||||
|
@property (readonly) BOOL propertyB __attribute__((swift_name("propertyB")));
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol C <B>
|
||||||
|
@required
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol D <C>
|
||||||
|
@required
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma pop_macro("_Nullable_result")
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
Vendored
+21
@@ -0,0 +1,21 @@
|
|||||||
|
interface A {
|
||||||
|
val propertyA: Int
|
||||||
|
val propertyAForOverride: Int
|
||||||
|
fun funA(): Any
|
||||||
|
fun funAForOverride(): Any
|
||||||
|
}
|
||||||
|
|
||||||
|
interface B : A {
|
||||||
|
val propertyB: Boolean
|
||||||
|
fun funB()
|
||||||
|
override val propertyAForOverride: Int
|
||||||
|
get() = 42
|
||||||
|
|
||||||
|
override fun funAForOverride(): String = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
interface C : B {
|
||||||
|
override fun funAForOverride(): String = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
interface D : C
|
||||||
Reference in New Issue
Block a user