Hi, I've updated Mockk to the latest, also updated...
# mockk
e
Hi, I've updated Mockk to the latest, also updated Kotlin to 2.0.0, and now here's my issue:
Copy code
interface X<T: Comparable<T>> {
    fun get(): T
}

@Test
fun `test x`() {
    val x = mockk<X<Int>>()
    
    every { x.get() } returns 1 # fails
    every { x.get().hint(Int::class) } returns 1 # fails

    val result = x.get()

    result shouldBe 1

    verify(exactly = 1) {
        x.get()
    }
}

# workaround:
interface TypedX : X<Int>

@Test
fun `test x`() {
    val x = mockk<TypedX>()
    
    every { x.get() } returns 1 # passes

    val result = x.get()

    result shouldBe 1

    verify(exactly = 1) {
        x.get()
    }
}
The error I get:
Copy code
Class cast exception happened.
Probably type information was erased.
In this case use `hint` before call to specify exact return type of a method.

io.mockk.MockKException: Class cast exception happened.
Probably type information was erased.
In this case use `hint` before call to specify exact return type of a method.

Caused by: java.lang.ClassCastException: class io.mockk.renamed.java.lang.Number$Subclass3 cannot be cast to class java.lang.Comparable (io.mockk.renamed.java.lang.Number$Subclass3 is in unnamed module of loader 'app'; java.lang.Comparable is in module java.base of loader 'bootstrap')
...
176 Views