From eee59cb23c607de39886556f20ad3a3845e6711b Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Tue, 8 May 2018 02:51:45 +0300 Subject: [PATCH] Fix deserialization of inline functions from inline classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes: CompileKotlinAgainstInlineKotlinTestGenerated$InlineClasses.testInlineFunctionInsideInlineClassesBox  Consider the following binary dependency: inline class UInt(val u: Int) { inline fun foo() {} } Now, if we want to inline function `foo`, we have to load it from bytes as ASM method and to do this we should know the container of this function. Note that because of inline class, actual signature of this function would be `foo(I)` and it will be stored in UInt$Erased class, not `UInt` --- .../kotlin/codegen/state/KotlinTypeMapper.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java index 8e03a95c0e6..130136b0c7c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java @@ -309,10 +309,21 @@ public class KotlinTypeMapper { ClassId classId = DescriptorUtilsKt.getClassId(classDescriptor); assert classId != null : "Deserialized class should have a ClassId: " + classDescriptor; + String nestedClass; if (isInterface(classDescriptor)) { + nestedClass = JvmAbi.DEFAULT_IMPLS_SUFFIX; + } + else if (classDescriptor.isInline()) { + nestedClass = JvmAbi.ERASED_INLINE_CLASS_SUFFIX; + } + else { + nestedClass = null; + } + + if (nestedClass != null) { FqName relativeClassName = classId.getRelativeClassName(); //TODO test nested trait fun inlining - String defaultImplsClassName = relativeClassName.shortName().asString() + JvmAbi.DEFAULT_IMPLS_SUFFIX; + String defaultImplsClassName = relativeClassName.shortName().asString() + nestedClass; return new ClassId(classId.getPackageFqName(), Name.identifier(defaultImplsClassName)); }