Do not issue exceptions for non-captured local variables
This partly fixes KT-28192.
This commit is contained in:
+79
@@ -0,0 +1,79 @@
|
||||
package nonCapturedVariables
|
||||
|
||||
fun main() {
|
||||
val a = 5
|
||||
|
||||
inlineBlock {
|
||||
//Breakpoint!
|
||||
val b = 6
|
||||
|
||||
inlineBlock {
|
||||
//Breakpoint!
|
||||
val c = 7
|
||||
|
||||
block {
|
||||
//Breakpoint!
|
||||
val d = 8
|
||||
|
||||
inlineBlock {
|
||||
//Breakpoint!
|
||||
val e = 9
|
||||
|
||||
block {
|
||||
//Breakpoint!
|
||||
val f = 10
|
||||
|
||||
block {
|
||||
//Breakpoint!
|
||||
val g = 11
|
||||
|
||||
//Breakpoint!
|
||||
val g2 = 12
|
||||
|
||||
//Breakpoint!
|
||||
val g3 = 13
|
||||
|
||||
//Breakpoint!
|
||||
val g4 = 14
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun block(block: () -> Unit) {
|
||||
block()
|
||||
}
|
||||
|
||||
private inline fun inlineBlock(block: () -> Unit) {
|
||||
block()
|
||||
}
|
||||
|
||||
// EXPRESSION: a
|
||||
// RESULT: 5: I
|
||||
|
||||
// EXPRESSION: b
|
||||
// RESULT: 6: I
|
||||
|
||||
// EXPRESSION: c
|
||||
// RESULT: 'c' is not captured
|
||||
|
||||
// EXPRESSION: d
|
||||
// RESULT: 8: I
|
||||
|
||||
// EXPRESSION: e
|
||||
// RESULT: 'e' is not captured
|
||||
|
||||
// EXPRESSION: f
|
||||
// RESULT: 'f' is not captured
|
||||
|
||||
// EXPRESSION: e
|
||||
// RESULT: 'e' is not captured
|
||||
|
||||
// EXPRESSION: d
|
||||
// RESULT: 'd' is not captured
|
||||
|
||||
// EXPRESSION: c
|
||||
// RESULT: 'c' is not captured
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
LineBreakpoint created at nonCapturedVariables.kt:8
|
||||
LineBreakpoint created at nonCapturedVariables.kt:12
|
||||
LineBreakpoint created at nonCapturedVariables.kt:16
|
||||
LineBreakpoint created at nonCapturedVariables.kt:20
|
||||
LineBreakpoint created at nonCapturedVariables.kt:24
|
||||
LineBreakpoint created at nonCapturedVariables.kt:28
|
||||
LineBreakpoint created at nonCapturedVariables.kt:31
|
||||
LineBreakpoint created at nonCapturedVariables.kt:34
|
||||
LineBreakpoint created at nonCapturedVariables.kt:37
|
||||
Run Java
|
||||
Connected to the target VM
|
||||
nonCapturedVariables.kt:8
|
||||
Compile bytecode for a
|
||||
nonCapturedVariables.kt:12
|
||||
Compile bytecode for b
|
||||
nonCapturedVariables.kt:16
|
||||
Compile bytecode for c
|
||||
nonCapturedVariables.kt:20
|
||||
Compile bytecode for d
|
||||
nonCapturedVariables.kt:24
|
||||
Compile bytecode for e
|
||||
nonCapturedVariables.kt:28
|
||||
Compile bytecode for f
|
||||
nonCapturedVariables.kt:31
|
||||
Compile bytecode for e
|
||||
nonCapturedVariables.kt:34
|
||||
Compile bytecode for d
|
||||
nonCapturedVariables.kt:37
|
||||
Compile bytecode for c
|
||||
Disconnected from the target VM
|
||||
|
||||
Process finished with exit code 0
|
||||
+1
-1
@@ -15,4 +15,4 @@ fun foo(f: () -> Unit) {
|
||||
// PRINT_FRAME
|
||||
|
||||
// EXPRESSION: val1
|
||||
// RESULT: java.lang.AssertionError : Cannot find local variable: name = 'val1', type = int
|
||||
// RESULT: 'val1' is not captured
|
||||
+1
-1
@@ -20,7 +20,7 @@ fun foo(f: () -> Unit) {
|
||||
// PRINT_FRAME
|
||||
|
||||
// EXPRESSION: val1
|
||||
// RESULT: java.lang.AssertionError : Cannot find local variable: name = 'val1', type = int
|
||||
// RESULT: 'val1' is not captured
|
||||
frame = invoke:7, FrameLambdaNotUsedKt$main$1 {frameLambdaNotUsed}
|
||||
this = this = {frameLambdaNotUsed.FrameLambdaNotUsedKt$main$1@uniqueID}Function0<kotlin.Unit>
|
||||
field = arity: int = 0 (sp = Lambda.!EXT!)
|
||||
|
||||
Reference in New Issue
Block a user