All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.mokkery.plugin.ir.IrProperty.kt Maven / Gradle / Ivy

Go to download

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)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy