Fix stepping for inline functions inside when, if, try

This commit is contained in:
Natalia Ukhorskaya
2015-09-16 15:38:36 +03:00
parent e92f14e49c
commit 33b5e6b255
15 changed files with 512 additions and 17 deletions
@@ -0,0 +1,47 @@
package stepOverIfWithInline
fun main(args: Array<String>) {
//Breakpoint!
val prop = 1
// False with braces
val a = if (1 > 2) {
foo { test(1) }
}
else {
foo { test(1) }
}
// False without braces
val b = if (1 > 2)
foo { test(1) }
else
foo { test(1) }
// One line
val c = if (1 > 2) foo { test(1) } else foo { test(1) }
// Else on next line, false
val d = if (1 > 2) foo { test(1) }
else foo { test(1) }
// Else on next line, true
val e = if (1 < 2) foo { test(1) }
else foo { test(1) }
// Inline function call in condition
val f = if (foo { test(1) } > 2) {
foo { test(1) }
}
else {
foo { test(1) }
}
}
inline fun foo(f: () -> Int): Int {
val a = 1
return f()
}
fun test(i: Int) = 1
// STEP_OVER: 30
@@ -0,0 +1,22 @@
package stepOverInlineFunctionInReturn
fun main(args: Array<String>) {
f()
}
fun f(): Int {
//Breakpoint!
val a = 1
return foo {
test(2)
}
}
inline fun foo(f: () -> Int): Int {
val a = 1
return f()
}
fun test(i: Int) = 1
// STEP_OVER: 4
@@ -27,6 +27,8 @@ fun main(args: Array<String>) {
})
val b = foo { test(1) }
foo(fun (){ test(1) })
}
inline fun foo(f: () -> Unit) {
@@ -47,4 +49,4 @@ class A {
fun test(i: Int) = 1
// STEP_OVER: 11
// STEP_OVER: 13
@@ -0,0 +1,54 @@
package stepOverTryCatchWithInline
fun main(args: Array<String>) {
try {
bar()
}
catch(e: Exception) {
val a = 1
}
}
fun bar() {
//Breakpoint!
val prop = 1
// Try
try {
foo { test(1) }
}
catch(e: Exception) {
foo { test(1) }
}
// Many catch clauses
try {
throw IllegalStateException()
}
catch(e: IllegalStateException) {
foo { test(1) }
}
catch(e: Exception) {
foo { test(1) }
}
// exception in lambda
try {
foo { throw IllegalStateException() }
}
catch(e: Exception) {
foo { test(1) }
}
// Exception without catch
foo { throw IllegalStateException() }
val prop2 = 1
}
inline fun foo(f: () -> Int): Int {
val a = 1
return f()
}
fun test(i: Int) = 1
// STEP_OVER: 30
@@ -0,0 +1,23 @@
package stepOverWhenInReturn
fun main(args: Array<String>) {
whenInReturn()
}
fun whenInReturn(): Int {
val a = 1
//Breakpoint!
return when(a) {
1 -> foo { 1 }
else -> 3
}
}
inline fun foo(f: () -> Int): Int {
val a = 1
return f()
}
fun test(i: Int) = 1
// STEP_OVER: 6
@@ -0,0 +1,89 @@
package stepOverWhenWithInline
fun main(args: Array<String>) {
//Breakpoint!
val prop = 1
// Break after second
val a = when {
1 > 2 -> foo { test(1) }
2 > 1 -> foo { test(1) }
else -> foo { test(1) }
}
val b = when {
1 > 2 -> {
foo { test(1) }
}
2 > 1 -> {
foo { test(1) }
}
else -> {
foo { test(1) }
}
}
val c = when {
foo { test(1) } > 2 -> 1
2 > foo { test(1) } -> 2
else -> foo { test(1) }
}
// When with expression
val a1 = when(prop) {
2 -> foo { test(1) }
1 -> foo { test(1) }
else -> foo { test(1) }
}
val b1 = when(prop) {
2 -> {
foo { test(1) }
}
1 -> {
foo { test(1) }
}
else -> {
foo { test(1) }
}
}
// Break after first
val c1 = when(prop) {
foo { test(1) } -> 1
foo { test(2) } -> 2
else -> foo { test(1) }
}
val a2 = when {
2 > 1 -> foo { test(1) }
1 > 2 -> foo { test(1) }
else -> foo { test(1) }
}
val b2 = when {
2 > 1 -> {
foo { test(1) }
}
1 > 2 -> {
foo { test(1) }
}
else -> {
foo { test(1) }
}
}
val c2 = when {
2 > foo { test(1) } -> 2
foo { test(1) } > 2 -> 1
else -> foo { test(1) }
}
}
inline fun foo(f: () -> Int): Int {
val a = 1
return f()
}
fun test(i: Int) = i
// STEP_OVER: 50