From 4c4ab1f226f52625810a10dd408a04da107a27b0 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Tue, 21 Nov 2017 13:23:33 +0300 Subject: [PATCH] =?UTF-8?q?Fixed=20bug=20in=20DeepCopyIrTreeWithDescriptor?= =?UTF-8?q?s=20A=20class=E2=80=99s=20interfaces=20were=20forgotten=20to=20?= =?UTF-8?q?be=20copied=20during=20copying=20of=20a=20class=20descriptor.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt index fe13a8c81e2..cc6d5cf522f 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DeepCopyIrTreeWithDescriptors.kt @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassOrAny +import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.TypeUtils @@ -347,6 +348,8 @@ class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescriptor, val oldSuperClass = oldDescriptor.getSuperClassOrAny() val newSuperClass = descriptorSubstituteMap.getOrDefault(oldSuperClass, oldSuperClass) as ClassDescriptor + val oldInterfaces = oldDescriptor.getSuperInterfaces() + val newInterfaces = oldInterfaces.map { descriptorSubstituteMap.getOrDefault(it, it) as ClassDescriptor } val oldContainingDeclaration = oldDescriptor.containingDeclaration val newContainingDeclaration = descriptorSubstituteMap.getOrDefault(oldContainingDeclaration, oldContainingDeclaration) val newName = if (DescriptorUtils.isAnonymousObject(oldDescriptor)) // Anonymous objects are identified by their name. @@ -358,7 +361,7 @@ class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescriptor, /* name = */ newName, /* modality = */ oldDescriptor.modality, /* kind = */ oldDescriptor.kind, - /* supertypes = */ listOf(newSuperClass.defaultType), + /* supertypes = */ listOf(newSuperClass.defaultType) + newInterfaces.map { it.defaultType }, /* source = */ oldDescriptor.source, /* isExternal = */ oldDescriptor.isExternal )