mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Do not store nulls for captured variables going out of scope
These values can't be read after going out of scope. JVM implementation can take care of such object references on its own. Ref objects for captured variables are not different from any other objects stored in local variables, so there's really no reason to nullify these references explicitly. #KT-18478 Fixed Target versions 1.1.4
This commit is contained in:
14
compiler/testData/codegen/bytecodeText/doNotStoreNullsForCapturedVars.kt
vendored
Normal file
14
compiler/testData/codegen/bytecodeText/doNotStoreNullsForCapturedVars.kt
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
fun runNoInline(block: ()-> Unit): Unit {
|
||||
block()
|
||||
}
|
||||
|
||||
fun use(x: Int) {}
|
||||
|
||||
fun test(): Unit {
|
||||
var x = 0
|
||||
runNoInline {
|
||||
use(x)
|
||||
}
|
||||
}
|
||||
|
||||
// 0 ACONST_NULL
|
||||
Reference in New Issue
Block a user