[K/N] Make cinterop include unused Objective-C forward declarations
Previously, when an Objective-C library had an unused Objective-C forward declaration (`@class` or `@protocol`), cinterop tool didn't include it into the resulting klib at all. This led to a subtle bug (KT-64105). One Obj-C library has unused Obj-C forward declaration, and another one depends on the first and uses this forward declaration, e.g. as a function result type. When building the first cinterop klib, this forward declaration is not added to `includedForwardDeclarations` in the klib manifest (the compiler uses this property to decide whether to synthesize the corresponding class). When building the second cinterop klib, the forward declaration is not added to its manifest either, because it is located in the dependency (and therefore should've been included there). As a result, the forward declaration is included nowhere, and any attempt to use it in Kotlin fails, including calling the function from the second lib. This commit fixes this bug by including even unused Objective-C forward declarations, which is consistent with any other kind of declarations and seems more natural. ^KT-64105 Fixed
This commit is contained in:
committed by
Space Team
parent
59142b3051
commit
2e5a9b1416
+10
@@ -936,6 +936,11 @@ public open class NativeIndexImpl(val library: NativeLibrary, val verbose: Boole
|
||||
|
||||
CXIdxEntity_ObjCClass -> if (cursor.kind != CXCursorKind.CXCursor_ObjCClassRef /* not a forward declaration */) {
|
||||
indexObjCClass(cursor)
|
||||
} else {
|
||||
// It is a class reference. To get the declaration cursor, we can use clang_getCursorReferenced.
|
||||
// If there is a real declaration besides this forward declaration, the function will automatically
|
||||
// resolve it.
|
||||
indexObjCClass(clang_getCursorReferenced(cursor))
|
||||
}
|
||||
|
||||
CXIdxEntity_ObjCCategory -> {
|
||||
@@ -946,6 +951,11 @@ public open class NativeIndexImpl(val library: NativeLibrary, val verbose: Boole
|
||||
|
||||
CXIdxEntity_ObjCProtocol -> if (cursor.kind != CXCursorKind.CXCursor_ObjCProtocolRef /* not a forward declaration */) {
|
||||
indexObjCProtocol(cursor)
|
||||
} else {
|
||||
// It is a protocol reference. To get the declaration cursor, we can use clang_getCursorReferenced.
|
||||
// If there is a real declaration besides this forward declaration, the function will automatically
|
||||
// resolve it.
|
||||
indexObjCProtocol(clang_getCursorReferenced(cursor))
|
||||
}
|
||||
|
||||
CXIdxEntity_ObjCProperty -> {
|
||||
|
||||
Reference in New Issue
Block a user