Context: Newest IntelliJ, kotlin 2.0. Problem: Kot...
# intellij
j
Context: Newest IntelliJ, kotlin 2.0. Problem: Kotlin selects correct overloaded method, but IntelliJ selects the wrong one and shows false positive on “Type mismatch, Required: T, found: Unit”.
Copy code
import java.util.function.Supplier

open class Bar {

    fun <T> record(f: Supplier<T>): T {
        println("$f is supplier")
        return f.get()
    }

    fun record(f: Runnable): Unit {
        println("$f is Runnable")
        f.run()
    }
}

class Foo : Bar() {
    fun <T> foo(f: () -> T): T = try {
        record(f)
    } catch (e: Exception) {
        throw e
    }
}
Is this a known issue or should I create one in Youtrack?
s
Do you have the K2 IDE mode switched on?
j
No. Just enabled and the error is fixed indeed, just now I got the new one, so I need to decide which way do I prefer 🙂
😢 1