JVM IR: do not generate invokeinterface hashCode if smart cast is present

#KT-45008 Fixed
This commit is contained in:
Alexander Udalov
2021-02-18 13:19:27 +01:00
parent 56854a8b1a
commit 56f9e3360f
5 changed files with 35 additions and 1 deletions
@@ -0,0 +1,16 @@
interface I
class A : I {
fun f1(other: Any?): Int =
if (other is I) other.hashCode() else 0
inline fun <reified T : I> f2(other: Any): Int =
if (other is T) other.hashCode() else 0
fun f3() {
f2<A>(A())
}
}
// 3 INVOKEVIRTUAL java/lang/Object.hashCode \(\)I
// 0 INVOKEINTERFACE