Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ package org.mockito.kotlin.internal
import kotlin.coroutines.Continuation
import kotlin.coroutines.intrinsics.startCoroutineUninterceptedOrReturn
import kotlin.reflect.KFunction
import kotlin.reflect.full.memberProperties
import kotlin.reflect.jvm.jvmErasure
import kotlin.reflect.jvm.kotlinFunction
import org.mockito.internal.invocation.InterceptedInvocation
Expand Down Expand Up @@ -88,15 +87,13 @@ internal class CoroutineAwareAnswer<T> private constructor(private val delegate:
return this
}

private fun Result<*>.unboxResult(): Any? {
if (isSuccess) return getOrNull()

// In case of failure, extract the nested Failure instance and pass that on
val valueProperty = this::class.memberProperties.single { it.name == "value" }
val failure /* : kotlin.Result.Failure */ = valueProperty.call(this)

return failure
}
private fun Result<*>.unboxResult(): Any? =
if (isSuccess) {
getOrNull()
} else {
// In case of failure, unbox the nested Failure instance and pass that on
this.unboxValueClass()
}

private val InvocationOnMock.invokedKotlinFunction: KFunction<*>?
get() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ import kotlin.reflect.KClass
fun <T : Any?> Any?.toKotlinType(clazz: KClass<*>): T {
if (this == null) return null as T

if (clazz == Result::class) {
return this as T
}

if (clazz.isValue && this::class != clazz) {
return this.boxAsValueClass(clazz) as T
}
Expand Down
Loading