dev.mokkery.plugin.ir.IrProperty.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mokkery-plugin Show documentation
Show all versions of mokkery-plugin Show documentation
Mokkery is a mocking library for Kotlin Multiplatform, easy to use, boilerplate-free and compiler plugin driven.
The newest version!
package dev.mokkery.plugin.ir
import org.jetbrains.kotlin.ir.builders.declarations.IrFunctionBuilder
import org.jetbrains.kotlin.ir.builders.declarations.buildFun
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.util.isOverridable
import org.jetbrains.kotlin.name.Name
inline fun IrProperty.addSetter(
builder: IrFunctionBuilder.() -> Unit = {}
): IrSimpleFunction {
val setter = factory.buildFun(builder = {
name = Name.special("")
builder()
})
[email protected] = setter
setter.correspondingPropertySymbol = [email protected]
setter.parent = [email protected]
return setter
}
val IrProperty.isOverridable: Boolean
get() = (getter?.isOverridable ?: true) && (setter?.isOverridable ?: true)