Debugger: Show captured outer this in lambdas (Variables view) (KT-30220)

This commit is contained in:
Yan Zhulanow
2019-03-05 01:06:59 +03:00
parent 723f8df23e
commit ba0989801a
10 changed files with 270 additions and 13 deletions
@@ -0,0 +1,22 @@
package lambdaFun1
fun foo() {
block {
//Breakpoint!
val a = 5
}
}
fun <T> block(block: () -> T): T {
return block()
}
fun main() {
foo()
}
// PRINT_FRAME
// SHOW_KOTLIN_VARIABLES
// EXPRESSION: this
// RESULT: 'this' is not defined in this context
@@ -0,0 +1,8 @@
LineBreakpoint created at lambdaFun1.kt:6
Run Java
Connected to the target VM
lambdaFun1.kt:6
frame = invoke:6, LambdaFun1Kt$foo$1 {lambdaFun1}
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,24 @@
package lambdaFun2
class Foo {
fun foo() {
block {
//Breakpoint!
val a = this@Foo
}
}
}
fun <T> block(block: () -> T): T {
return block()
}
fun main() {
Foo().foo()
}
// PRINT_FRAME
// SHOW_KOTLIN_VARIABLES
// EXPRESSION: this
// RESULT: instance of lambdaFun2.Foo(id=ID): LlambdaFun2/Foo;
@@ -0,0 +1,11 @@
LineBreakpoint created at lambdaFun2.kt:7
Run Java
Connected to the target VM
lambdaFun2.kt:7
Compile bytecode for this
frame = invoke:7, Foo$foo$1 {lambdaFun2}
unknown = this = {lambdaFun2.Foo@uniqueID}
- Class has no fields
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,24 @@
package lambdaFun3
object Foo {
fun foo() {
block {
//Breakpoint!
val a = this@Foo
}
}
}
fun <T> block(block: () -> T): T {
return block()
}
fun main() {
Foo.foo()
}
// PRINT_FRAME
// SHOW_KOTLIN_VARIABLES
// EXPRESSION: this
// RESULT: instance of lambdaFun3.Foo(id=ID): LlambdaFun3/Foo;
@@ -0,0 +1,9 @@
LineBreakpoint created at lambdaFun3.kt:7
Run Java
Connected to the target VM
lambdaFun3.kt:7
Compile bytecode for this
frame = invoke:7, Foo$foo$1 {lambdaFun3}
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,29 @@
package lambdaFun4
interface Foo {
fun foo() {
block {
with ("abc") {
//Breakpoint!
val a = this@Foo
}
}
}
}
fun <T> block(block: () -> T): T {
return block()
}
fun main() {
(object : Foo {}).foo()
}
// PRINT_FRAME
// SHOW_KOTLIN_VARIABLES
// EXPRESSION: this
// RESULT: "abc": Ljava/lang/String;
// EXPRESSION: this@Foo
// RESULT: instance of lambdaFun4.LambdaFun4Kt$main$1(id=ID): LlambdaFun4/LambdaFun4Kt$main$1;
@@ -0,0 +1,18 @@
LineBreakpoint created at lambdaFun4.kt:8
Run Java
Connected to the target VM
lambdaFun4.kt:8
Compile bytecode for this
Compile bytecode for this@Foo
frame = invoke:8, Foo$foo$1 {lambdaFun4}
unknown = this (anonymous fun) = {lambdaFun4.LambdaFun4Kt$main$1@uniqueID}
- Class has no fields
local = this: java.lang.String = abc (sp = null)
field = value: char[] = {char[3]@uniqueID} (sp = String.!EXT!)
element = 0 = 'a' 97
element = 1 = 'b' 98
element = 2 = 'c' 99
field = hash: int = 0 (sp = String.!EXT!)
Disconnected from the target VM
Process finished with exit code 0