commonMain.co.touchlab.skie.kir.irbuilder.impl.namespace.BaseDeserializedNamespace.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.irbuilder.impl.namespace
import co.touchlab.skie.compilerinject.reflection.reflectedBy
import co.touchlab.skie.compilerinject.reflection.reflectors.DeserializedMemberScopeReflector
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
import org.jetbrains.kotlin.resolve.scopes.MemberScope
abstract class BaseDeserializedNamespace : BaseNamespace() {
protected fun MemberScope.addFunctionDescriptorToImpl(functionDescriptor: SimpleFunctionDescriptor) {
val reflectedMemberScope = this.reflectedBy()
val impl = reflectedMemberScope.reflectedImpl
val functionName = functionDescriptor.name
impl.functionNames.add(functionName)
val cache = impl.reflectedFunctions.cache
cache[functionName] = listOf(functionDescriptor) + (cache[functionName] ?: emptyList())
}
}