Leave boxing for compareTo/areEqual methods for inline classes

Inline classes can override methods and thus introduce side effects
This commit is contained in:
Mikhail Zarechenskiy
2018-07-20 03:05:11 +03:00
parent 4e7718bfff
commit ec9d8e580e
10 changed files with 58 additions and 7 deletions
@@ -0,0 +1,17 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
inline class Foo(val x: Int) : Comparable<Foo> {
override fun compareTo(other: Foo): Int {
return 10
}
}
fun box(): String {
val f1 = Foo(42)
val ff1: Comparable<Foo> = f1
if (ff1.compareTo(f1) != 10) return "Fail"
return "OK"
}