From d91453fb7a582982df6e445c82e7994f2acaae4d Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 11 Oct 2019 07:30:53 +0300 Subject: [PATCH] Do not preprocess apiVersionIsAtLeast calls inlined into kotlin package If such call were to be inlined into an inline function in kotlin package, it would be expanded there preventing the further expansion in client code. --- .../src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt index 91e9bbd4555..aeb1805fe7f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt @@ -355,7 +355,10 @@ abstract class InlineCodegen( val caller = codegen.context.functionDescriptor if (!caller.isInline) return false val callerPackage = DescriptorUtils.getParentOfType(caller, PackageFragmentDescriptor::class.java) ?: return false - return callerPackage.fqName.asString().startsWith("kotlin.") + return callerPackage.fqName.asString().let { + // package either equals to 'kotlin' or starts with 'kotlin.' + it.startsWith("kotlin") && (it.length <= 6 || it[6] == '.') + } } private fun generateClosuresBodies() {