Files
kotlin-fork/idea/jvm-debugger/jvm-debugger-test/testData/stepping/stepOver/stepOverWhenWithInline.kt
T
Mads Ager 78483930bc [JVM_IR] Fix offsets in constant propagation optimization.
Loads of temporary variables that contain constants are replaced
with a copy of the constant. This avoids locals loads and stores.
However, the copy of the constant needs to have the offset of
the load and not of the original constant.

Fixes KT-41963.
2020-09-22 19:12:06 +02:00

92 lines
2.9 KiB
Kotlin
Vendored

package stepOverWhenWithInline
fun main(args: Array<String>) {
//Breakpoint!
val prop = 1 // 1
// Break after second
val a = when { // 4
1 > 2 -> foo { test(1) } // 2
2 > 1 -> foo { test(1) } // 3
else -> foo { test(1) }
}
val b = when { // 8
1 > 2 -> { // 5
foo { test(1) }
}
2 > 1 -> { // 6
foo { test(1) } // 7
}
else -> {
foo { test(1) }
}
}
val c = when { // 11
foo { test(1) } > 2 -> 1 // 9
2 > foo { test(1) } -> 2 // 10
else -> foo { test(1) }
}
// When with expression
val a1 = when(1) { // 12 14
2 -> foo { test(1) }
1 -> foo { test(1) } // 13
else -> foo { test(1) }
}
val b1 = when(1) { // 15 17
2 -> {
foo { test(1) }
}
1 -> {
foo { test(1) } // 16
}
else -> {
foo { test(1) }
}
}
// Break after first
val c1 = when(1) { // 18 20
foo { test(1) } -> 1 // 19
foo { test(2) } -> 2
else -> foo { test(1) }
}
val a2 = when { // 22
2 > 1 -> foo { test(1) } // 21
1 > 2 -> foo { test(1) }
else -> foo { test(1) }
}
val b2 = when { // 25
2 > 1 -> { // 23
foo { test(1) } // 24
}
1 > 2 -> {
foo { test(1) }
}
else -> {
foo { test(1) }
}
}
val c2 = when { // 27
2 > foo { test(1) } -> 2 // 26
foo { test(1) } > 2 -> 1
else -> foo { test(1) }
}
} // 28
inline fun foo(f: () -> Int): Int {
val a = 1
return f()
}
fun test(i: Int) = i
// STEP_OVER: 36
// JVM_IR and JVM backends have different heuristics for when to use a table switch.
// This results is minor differences in step over behavior.