Hi. I'm not sure if this is a Kotlin bug, but it o...
# kontributors
z
Hi. I'm not sure if this is a Kotlin bug, but it only happens in version 1.4. I'm using JUnit4 and I migrated Kotlin from 1.3.70 to 1.4.10
Copy code
class Test {
    interface Example {
        operator fun <T> get(key: String, defaultValue: T): T
    }

    class ExampleImpl : Example {
        override fun <T> get(key: String, defaultValue: T): T = when (defaultValue) {
            is Int -> defaultValue
            else -> // Debug here is recognized as'Long' on `exampleError`
                throw UnsupportedOperationException("NOT_YET_IMPLEMENT") 
        }
    }
 
    // exception occurs only in 1.4
    @Test(expected = UnsupportedOperationException::class)
    fun exampleError() {
        val example: Example = ExampleImpl()
        org.junit.Assert.assertEquals(example["key", 1], 1)
    }

    // Success
    @Test
    fun exampleSuccess() {
        val example: Example = ExampleImpl()
        junit.framework.TestCase.assertEquals(example["key", 1], 1)
    }
}
I think this is the cause TestCase.assertEquals
Copy code
public static void assertEquals(int expected, int actual)
Assert.assertEquals
Copy code
public static void assertEquals(Object expected, Object actual) // There is no part defined as int type
Is there anyone who can help?
I think I'm in the wrong order and I'll post it on youtrack