IR: check absence of extension receiver in isMethodOfAny

Otherwise extension methods named toString/equals/hashCode were
generated incorrectly on JVM IR, which could result in
AbstractMethodError at runtime.

 #KT-45963 Fixed
This commit is contained in:
Alexander Udalov
2021-04-09 21:53:06 +02:00
parent 98d31a1813
commit ea22f4b681
10 changed files with 69 additions and 3 deletions
@@ -0,0 +1,19 @@
interface AssertDSL {
infix fun Any?.equals(other: Any?) {
if (this != other) throw AssertionError("$this != $other")
}
fun Any?.toString(): String = ""
fun Any?.hashCode(): Int = 0
}
class C(val x: Int) : AssertDSL
fun C.test(): String {
x equals 42
null.toString()
null.hashCode()
return "OK"
}
fun box(): String = C(42).test()