Generate correct linenumber for the debugger to see the return value

of suspend function.

 #KT-20322 Fixed
This commit is contained in:
Ilmir Usmanov
2018-09-20 19:53:40 +03:00
parent 9bf55d81ca
commit 1777849ff3
14 changed files with 277 additions and 32 deletions
@@ -0,0 +1,32 @@
package anyUpdateInvokeStatic
import kotlin.sequences.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit>{
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resumeWith(result: Result<Unit>) {
result.getOrThrow()
}
})
}
object A {
@JvmStatic var s: Any? = "aabb"
}
fun main(args: Array<String>) {
builder {
A.s = strChanger(A.s)
//Breakpoint!
println(A.s) // (1)
}
}
suspend fun strChanger(str: Any?): Any? = (str as String).filter { it !in "a" }
// EXPRESSION: A.s
// RESULT: "bb": Ljava/lang/String;
@@ -0,0 +1,9 @@
LineBreakpoint created at anyUpdateInvokeStatic.kt:25
Run Java
Connected to the target VM
anyUpdateInvokeStatic.kt:25
Compile bytecode for A.s
Disconnected from the target VM
Process finished with exit code 0
bb
@@ -0,0 +1,29 @@
package anyUpdateVariable
import kotlin.sequences.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit>{
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resumeWith(result: Result<Unit>) {
result.getOrThrow()
}
})
}
fun main(args: Array<String>) {
builder {
var s:Any? = "aabb"
s = strChanger(s)
//Breakpoint!
println(s) // (1)
}
}
suspend fun strChanger(str: Any?): Any? = (str as String).filter { it !in "a" }
// EXPRESSION: s
// RESULT: "bb": Ljava/lang/String;
@@ -0,0 +1,9 @@
LineBreakpoint created at anyUpdateVariable.kt:22
Run Java
Connected to the target VM
anyUpdateVariable.kt:22
Compile bytecode for s
Disconnected from the target VM
Process finished with exit code 0
bb
@@ -0,0 +1,32 @@
package stringUpdateInvokeStatic
import kotlin.sequences.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit>{
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resumeWith(result: Result<Unit>) {
result.getOrThrow()
}
})
}
object A {
@JvmStatic var s: String = "aabb"
}
fun main(args: Array<String>) {
builder {
A.s = strChanger(A.s)
//Breakpoint!
println(A.s) // (1)
}
}
suspend fun strChanger(str: String): String = str.filter { it !in "a" }
// EXPRESSION: A.s
// RESULT: "bb": Ljava/lang/String;
@@ -0,0 +1,9 @@
LineBreakpoint created at stringUpdateInvokeStatic.kt:25
Run Java
Connected to the target VM
stringUpdateInvokeStatic.kt:25
Compile bytecode for A.s
Disconnected from the target VM
Process finished with exit code 0
bb
@@ -0,0 +1,31 @@
package stringUpdateInvokeVirtual
import kotlin.sequences.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit>{
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resumeWith(result: Result<Unit>) {
result.getOrThrow()
}
})
}
class A(var s: String)
fun main(args: Array<String>) {
builder {
var a = A("aabb")
a.s = strChanger(a.s)
//Breakpoint!
println(a.s) // (1)
}
}
suspend fun strChanger(str: String): String = str.filter { it !in "a" }
// EXPRESSION: a.s
// RESULT: "bb": Ljava/lang/String;
@@ -0,0 +1,9 @@
LineBreakpoint created at stringUpdateInvokeVirtual.kt:24
Run Java
Connected to the target VM
stringUpdateInvokeVirtual.kt:24
Compile bytecode for a.s
Disconnected from the target VM
Process finished with exit code 0
bb
@@ -0,0 +1,31 @@
package stringUpdatePutField
import kotlin.sequences.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit>{
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resumeWith(result: Result<Unit>) {
result.getOrThrow()
}
})
}
class A(@JvmField var s: String)
fun main(args: Array<String>) {
builder {
var a = A("aabb")
a.s = strChanger(a.s)
//Breakpoint!
println(a.s) // (1)
}
}
suspend fun strChanger(str: String): String = str.filter { it !in "a" }
// EXPRESSION: a.s
// RESULT: "bb": Ljava/lang/String;
@@ -0,0 +1,9 @@
LineBreakpoint created at stringUpdatePutField.kt:24
Run Java
Connected to the target VM
stringUpdatePutField.kt:24
Compile bytecode for a.s
Disconnected from the target VM
Process finished with exit code 0
bb
@@ -0,0 +1,29 @@
package stringUpdateVariable
import kotlin.sequences.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit>{
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resumeWith(result: Result<Unit>) {
result.getOrThrow()
}
})
}
fun main(args: Array<String>) {
builder {
var s = "aabb"
s = strChanger(s)
//Breakpoint!
println(s) // (1)
}
}
suspend fun strChanger(str: String): String = str.filter { it !in "a" }
// EXPRESSION: s
// RESULT: "bb": Ljava/lang/String;
@@ -0,0 +1,9 @@
LineBreakpoint created at stringUpdateVariable.kt:22
Run Java
Connected to the target VM
stringUpdateVariable.kt:22
Compile bytecode for s
Disconnected from the target VM
Process finished with exit code 0
bb