commonMain.co.touchlab.skie.kir.type.translation.SupportedFlow+fromKotlinType.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.SupportedFlow
import co.touchlab.skie.kir.type.SupportedFlow.values
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.types.KotlinType
fun SupportedFlow.Companion.from(type: KotlinType): SupportedFlow? =
(type.constructor.declarationDescriptor as? ClassDescriptor)?.let { from(it) }
private fun from(classDescriptor: ClassDescriptor): SupportedFlow? {
val classFqName = classDescriptor.fqNameSafe.asString()
return values().firstOrNull { it.coroutinesFlowFqName == classFqName }
}