commonMain.co.touchlab.skie.phases.kir.CreateKirConstructorsPhase.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-compiler-linker-plugin-kgp_1.8.20 Show documentation
Show all versions of kotlin-compiler-linker-plugin-kgp_1.8.20 Show documentation
Kotlin compiler plugin that improves Swift interface of a Kotlin Multiplatform framework.
The newest version!
@file:Suppress("invisible_reference", "invisible_member")
package co.touchlab.skie.phases.kir
import co.touchlab.skie.kir.element.KirClass
import co.touchlab.skie.kir.element.KirConstructor
import co.touchlab.skie.kir.type.translation.withTypeParameterScope
import co.touchlab.skie.phases.KirPhase
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
internal class CreateKirConstructorsPhase(
context: KirPhase.Context,
) : BaseCreateRegularKirFunctionPhase(context, supportsConstructors = true) {
override fun visitConstructor(descriptor: ConstructorDescriptor, kirClass: KirClass) {
val originalDescriptor = descriptor.original
val methodBridge = mapper.bridgeMethod(originalDescriptor)
val constructor = KirConstructor(
kotlinName = descriptor.name.asString(),
kotlinSignature = descriptor.signature,
objCSelector = namer.getSelector(descriptor),
swiftName = namer.getSwiftName(descriptor),
owner = kirClass,
errorHandlingStrategy = methodBridge.returnBridge.errorHandlingStrategy,
deprecationLevel = descriptor.kirDeprecationLevel,
configuration = descriptorConfigurationProvider.getConfiguration(descriptor),
)
descriptorKirProvider.registerCallableDeclaration(constructor, descriptor)
kirClass.withTypeParameterScope {
createValueParameters(constructor, originalDescriptor, methodBridge)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy