mockk icon indicating copy to clipboard operation
mockk copied to clipboard

Overload resolution ambiguity between candidates

Open savvasdalkitsis-dojo opened this issue 4 months ago • 0 comments

When i use mockk on a kmp project, I get these errors in the IDE (the tests run fine regardless)

Overload resolution ambiguity between candidates: fun <reified T : Any> slot(): CapturingSlot<T> fun <reified T> slot(): CapturingSlot<T>

Looking at the code, it looks like the jvm and common source sets define the slot method differently:

// common
inline fun <reified T : Any> slot() = MockK.useImpl {
    MockKDsl.internalSlot<T>()
}

// jvm
inline fun <reified T : Any?> slot() = MockK.useImpl {
    MockKDsl.internalSlot<T>()
}

Which seems to be the reason for the error.

savvasdalkitsis-dojo avatar Sep 09 '25 10:09 savvasdalkitsis-dojo