K2: fix signature computation for Objective-C constructors

This commit is contained in:
Svyatoslav Scherbina
2023-01-12 18:46:01 +01:00
committed by Space Team
parent 676d65e71c
commit 623e7317bb
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.IrBasedClassConstructorDescriptor
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.types.classOrNull
import org.jetbrains.kotlin.ir.types.getPublicSignature
@@ -272,6 +273,12 @@ fun IrConstructor.getObjCInitMethod(): IrSimpleFunction? {
}
fun ConstructorDescriptor.getObjCInitMethod(): FunctionDescriptor? {
if (this is IrBasedClassConstructorDescriptor) {
// E.g. in case of K2.
// The constructedClass has empty member scope, so we have to delegate to IR to find the init method.
return this.owner.getObjCInitMethod()?.descriptor
}
return this.annotations.findAnnotation(objCConstructorFqName)?.let {
val initSelector = it.getAnnotationStringValue("initSelector")
val memberScope = constructedClass.unsubstitutedMemberScope