Files
kotlin/compiler/testData/codegen/bytecodeText/boxingOptimization/boxingAndEquals.kt
Mikhail Zarechenskiy ec9d8e580e Leave boxing for compareTo/areEqual methods for inline classes
Inline classes can override methods and thus introduce side effects
2018-07-20 11:51:34 +03:00

32 lines
644 B
Kotlin
Vendored

// !LANGUAGE: +InlineClasses
// https://youtrack.jetbrains.com/issue/KT-15871
// FILE: Test.kt
fun getAndCheckInt(a: Int, b: Int) =
getAndCheck({ a }, { b })
// @TestKt.class:
// 0 valueOf
// 0 Value
// 0 areEqual
// FILE: TestInlined.kt
fun getAndCheckInlinedInt(a: InlinedInt, b: InlinedInt) =
getAndCheck({ a }, { b })
// @TestInlinedKt.class:
// 0 valueOf
// 0 Value
// 1 areEqual
// 2 INVOKESTATIC InlinedInt\$Erased.box
// 0 INVOKEVIRTUAL InlinedInt.unbox
// FILE: Inline.kt
inline fun <T> getAndCheck(getFirst: () -> T, getSecond: () -> T) =
getFirst() == getSecond()
inline class InlinedInt(val x: Int)