From ea8ade0852b81f82c10ff58dcc3b8254c880fcce Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Tue, 12 Nov 2019 16:17:44 +0300 Subject: [PATCH] [JS] Refactor and comment for typeOf fix --- .../codegen/box/reflection/typeOf/js/typeOfReifiedUnit.kt | 3 ++- .../org/jetbrains/kotlin/js/inline/clean/substituteKTypes.kt | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/testData/codegen/box/reflection/typeOf/js/typeOfReifiedUnit.kt b/compiler/testData/codegen/box/reflection/typeOf/js/typeOfReifiedUnit.kt index 774a4013415..65fc5d63129 100644 --- a/compiler/testData/codegen/box/reflection/typeOf/js/typeOfReifiedUnit.kt +++ b/compiler/testData/codegen/box/reflection/typeOf/js/typeOfReifiedUnit.kt @@ -5,8 +5,9 @@ import kotlin.reflect.typeOf +var x: Int = 1 fun sideEffects() { - println("Side effect") + x++ } inline fun foo(): String { diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/substituteKTypes.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/substituteKTypes.kt index d3267f95d73..f8a28b05362 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/substituteKTypes.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/substituteKTypes.kt @@ -26,7 +26,10 @@ fun substituteKTypes(root: JsNode) { visitor.accept(root) } -// Get KType from expression or from staticRef of referenced name +// Get KType from expression or from staticRef of referenced name. +// kType metadata is set on jsClass expressions. +// There can be a chain of local variables from jsClass to its usage. +// This methods uses staticRef to find the original expression with kType metadata. fun getTransitiveKType(e: JsExpression): JsExpression? { return when { e.kType != null ->