From c90c3e4bf5390b78cd6ef93ea191a77bc8169dcb Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Wed, 6 Sep 2017 17:25:41 +0300 Subject: [PATCH] Add hack to make JS coercion compatible with older versions of stdlib --- .../jetbrains/kotlin/js/inline/FunctionReader.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt index ecb3dda1e65..8603df06d2e 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt @@ -191,8 +191,17 @@ class FunctionReader( private fun readFunctionFromSource(descriptor: CallableDescriptor, info: ModuleInfo): FunctionWithWrapper? { val source = info.fileContent - val tag = Namer.getFunctionTag(descriptor, config) - val index = source.indexOf(tag) + var tag = Namer.getFunctionTag(descriptor, config) + val tagForModule = tag + var index = source.indexOf(tag) + + // Hack for compatibility with old versions of stdlib + // TODO: remove in 1.2 + if (index < 0 && tag == "kotlin.untypedCharArrayF") { + tag = "kotlin.charArrayF" + index = source.indexOf(tag) + } + if (index < 0) return null // + 1 for closing quote @@ -218,7 +227,7 @@ class FunctionReader( else { FunctionWithWrapper(functionExpr, null) } - val moduleReference = moduleNameMap[tag]?.deepCopy() ?: currentModuleName.makeRef() + val moduleReference = moduleNameMap[tagForModule]?.deepCopy() ?: currentModuleName.makeRef() val wrapperStatements = wrapper?.statements?.filter { it !is JsReturn } val sourceMap = info.sourceMap