fa4a4e56f3
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com> #KT-1179
53 lines
1.3 KiB
Kotlin
Vendored
53 lines
1.3 KiB
Kotlin
Vendored
// CHECK_BYTECODE_LISTING
|
|
// FIR_IDENTICAL
|
|
// WITH_STDLIB
|
|
// TARGET_BACKEND: JVM_IR
|
|
// LANGUAGE: +ValueClasses
|
|
|
|
@JvmInline
|
|
value class DPoint(val x: Double, val y: Double) {
|
|
init {
|
|
counter++
|
|
}
|
|
companion object {
|
|
@JvmStatic
|
|
var counter: Int = 0
|
|
}
|
|
}
|
|
|
|
fun ifExpr() = if (DPoint(0.0, 1.0).x > 0.0) DPoint(2.0, 3.0) else DPoint(4.0, 5.0)
|
|
|
|
fun whenExpr() = when {
|
|
DPoint(6.0, 7.0).x > 0.0 -> DPoint(8.0, 9.0)
|
|
DPoint(10.0, 11.0).x > 0.0 -> DPoint(12.0, 13.0)
|
|
else -> DPoint(14.0, 15.0)
|
|
}
|
|
|
|
fun ifBody() {
|
|
if (DPoint(0.0, 1.0).x > 0.0) DPoint(2.0, 3.0) else DPoint(4.0, 5.0)
|
|
val x = if (DPoint(0.0, 1.0).x > 0.0) DPoint(2.0, 3.0) else DPoint(4.0, 5.0)
|
|
require(x == DPoint(4.0, 5.0))
|
|
}
|
|
|
|
fun whenBody() {
|
|
when {
|
|
DPoint(6.0, 7.0).x > 0.0 -> DPoint(8.0, 9.0)
|
|
DPoint(10.0, 11.0).x > 0.0 -> DPoint(12.0, 13.0)
|
|
else -> DPoint(14.0, 15.0)
|
|
}
|
|
val x = when {
|
|
DPoint(6.0, 7.0).x > 0.0 -> DPoint(8.0, 9.0)
|
|
DPoint(10.0, 11.0).x > 0.0 -> DPoint(12.0, 13.0)
|
|
else -> DPoint(14.0, 15.0)
|
|
}
|
|
require(x == DPoint(8.0, 9.0))
|
|
}
|
|
|
|
fun box(): String {
|
|
ifBody()
|
|
whenBody()
|
|
require(ifExpr() == DPoint(4.0, 5.0))
|
|
require(whenExpr() == DPoint(8.0, 9.0))
|
|
require(DPoint.counter == 5 + 5 + 2 + 1 + 2 + 1)
|
|
return "OK"
|
|
} |