From 115b1c6b6e114da403f952ac01c912425c43d954 Mon Sep 17 00:00:00 2001 From: pyos Date: Tue, 16 Apr 2019 12:22:07 +0200 Subject: [PATCH] JVM_IR: force materialization of non-transparent block results --- .../jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 7cfad910b6f..11950049d6f 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -220,7 +220,8 @@ class ExpressionCodegen( if (expression.isTransparentScope) return super.visitBlock(expression, data) val info = data.create() - return super.visitBlock(expression, info).apply { + // Force materialization to avoid reading from out-of-scope variables. + return super.visitBlock(expression, info).materialized.apply { writeLocalVariablesInTable(info) } }