Fix specialization of equality comparison calls for inline classes

Receiver of equals() call should be checked instead of argument

^KT-57261: Fixed
This commit is contained in:
vladislav.grechko
2023-03-10 18:15:09 +01:00
committed by teamcity
parent 8039e30bbd
commit 35dfcb61bb
5 changed files with 54 additions and 18 deletions
+19
View File
@@ -0,0 +1,19 @@
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses
OPTIONAL_JVM_INLINE_ANNOTATION
value class Ic(val x: Int)
fun box(): String {
val strAsAny : Any = "a"
if ("a".equals(Ic(1))) return "Fail 1"
if (strAsAny.equals(Ic(1))) return "Fail 2"
if (Ic(1).equals("a")) return "Fail 3"
if (Ic(1).equals(strAsAny)) return "Fail 4"
return "OK"
}