commonMain.co.touchlab.skie.kir.type.translation.KirTypeTranslatorUtilityScope.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.9.20 Show documentation
Show all versions of kotlin-compiler-linker-plugin-kgp_1.9.20 Show documentation
Kotlin compiler plugin that improves Swift interface of a Kotlin Multiplatform framework.
The newest version!
package co.touchlab.skie.kir.type.translation
import co.touchlab.skie.kir.type.KirType
import co.touchlab.skie.kir.type.NonNullReferenceKirType
import co.touchlab.skie.kir.type.NullableReferenceKirType
import co.touchlab.skie.kir.type.OirBasedKirType
import co.touchlab.skie.kir.type.ReferenceKirType
import co.touchlab.skie.kir.type.SpecialOirKirType
import co.touchlab.skie.oir.type.OirType
import co.touchlab.skie.oir.type.SpecialReferenceOirType
import org.jetbrains.kotlin.backend.konan.binaryRepresentationIsNullable
import org.jetbrains.kotlin.types.KotlinType
abstract class KirTypeTranslatorUtilityScope {
protected fun NonNullReferenceKirType.withNullabilityOf(kotlinType: KotlinType): ReferenceKirType =
this.withNullabilityOf(kotlinType.binaryRepresentationIsNullable())
protected fun NonNullReferenceKirType.withNullabilityOf(nullable: Boolean): ReferenceKirType =
if (nullable) {
NullableReferenceKirType(this)
} else {
this
}
protected fun OirType.toKirType(): KirType =
OirBasedKirType(this)
protected fun SpecialReferenceOirType.toKirType(): SpecialOirKirType =
SpecialOirKirType(this)
}