[ObjCExport] Support mapping of ObjCObject types to id
^KT-65167
This commit is contained in:
committed by
Space Team
parent
3cd20bd7b0
commit
2bf7bbb6c1
+5
-3
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.objcexport.analysisApiUtils.getInlineTargetTypeOrNull
|
||||
import org.jetbrains.kotlin.objcexport.analysisApiUtils.isError
|
||||
import org.jetbrains.kotlin.objcexport.analysisApiUtils.isObjCObjectType
|
||||
import org.jetbrains.kotlin.objcexport.analysisApiUtils.objCErrorType
|
||||
|
||||
|
||||
@@ -23,9 +24,6 @@ import org.jetbrains.kotlin.objcexport.analysisApiUtils.objCErrorType
|
||||
*/
|
||||
context(KtAnalysisSession, KtObjCExportSession)
|
||||
internal fun KtType.translateToObjCType(typeBridge: TypeBridge): ObjCType {
|
||||
|
||||
//if (!this.isObjCObjectType()) return null //TODO implement isObjCObjectType
|
||||
|
||||
return when (typeBridge) {
|
||||
is ReferenceBridge -> this.translateToObjCReferenceType()
|
||||
is BlockPointerBridge -> this.translateToObjCFunctionType(typeBridge)
|
||||
@@ -87,6 +85,10 @@ private fun KtType.mapToReferenceTypeIgnoringNullability(): ObjCNonNullReference
|
||||
return ObjCIdType
|
||||
}
|
||||
|
||||
if (isObjCObjectType()) {
|
||||
return ObjCIdType
|
||||
}
|
||||
|
||||
/* Check if inline type represents 'regular' inline class */
|
||||
run check@{
|
||||
if (classId == null) return@check
|
||||
|
||||
+14
@@ -457,6 +457,20 @@ class ObjCExportTypeTranslationTest(
|
||||
assertEquals("id -> void", header.renderTypesOfSymbol("foo"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test - ObjCObject types`() {
|
||||
val header = header(
|
||||
"""
|
||||
class A: kotlinx.cinterop.ObjCObject
|
||||
val foo : A get() = A
|
||||
val bar: kotlinx.cinterop.ObjCObject
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
assertEquals("id", header.renderTypesOfSymbol("foo"))
|
||||
assertEquals("id", header.renderTypesOfSymbol("bar"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test - unresolved error type`() {
|
||||
val header = header(
|
||||
|
||||
Reference in New Issue
Block a user