run.smt.ktest.util.lambda.overloaded.kt Maven / Gradle / Ivy
package run.smt.ktest.util.lambda
class SingleArgumentLambda internal constructor(private val original: (T?) -> R) {
operator fun invoke(param: T) = original(param)
operator fun invoke() = original(null)
}
class DualArgumentLambda internal constructor(private val original: (A?, B?) -> R) {
operator fun invoke() = original(null, null)
operator fun invoke(a: A) = original(a, null)
operator fun invoke(a: A?, b: B) = original(a, b)
}
fun ((T?) -> R).overloaded() = SingleArgumentLambda(this)
fun ((A?, B?) -> R).overloaded() = DualArgumentLambda(this)