diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/DeepCopyIrTreeWithDescriptors.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/DeepCopyIrTreeWithDescriptors.kt index 7c4789271a3..9f76c576905 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/DeepCopyIrTreeWithDescriptors.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/DeepCopyIrTreeWithDescriptors.kt @@ -5,8 +5,6 @@ package org.jetbrains.kotlin.backend.common.lower.inline -import org.jetbrains.kotlin.ir.util.DescriptorsToIrRemapper -import org.jetbrains.kotlin.ir.util.WrappedDescriptorPatcher import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer @@ -37,9 +35,6 @@ internal class DeepCopyIrTreeWithSymbolsForInliner( // Copy IR. val result = irElement.transform(copier, data = null) - // Bind newly created IR with wrapped descriptors. - result.acceptVoid(WrappedDescriptorPatcher) - result.patchDeclarationParents(parent) return result } @@ -133,7 +128,7 @@ internal class DeepCopyIrTreeWithSymbolsForInliner( } } - private val symbolRemapper = SymbolRemapperImpl(DescriptorsToIrRemapper) + private val symbolRemapper = SymbolRemapperImpl(NullDescriptorsRemapper) private val typeRemapper = InlinerTypeRemapper(symbolRemapper, typeArguments) private val copier = object : DeepCopyIrTreeWithSymbols(symbolRemapper, typeRemapper, InlinerSymbolRenamer()) { private fun IrType.remapTypeAndErase() = typeRemapper.remapTypeAndOptionallyErase(this, erase = true) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/DeepCopyIrTreeWithSymbolsForFakeOverrides.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/DeepCopyIrTreeWithSymbolsForFakeOverrides.kt index 900d01cd71c..fbb17c200f8 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/DeepCopyIrTreeWithSymbolsForFakeOverrides.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/DeepCopyIrTreeWithSymbolsForFakeOverrides.kt @@ -5,8 +5,6 @@ package org.jetbrains.kotlin.ir.overrides -import org.jetbrains.kotlin.ir.util.DescriptorsToIrRemapper -import org.jetbrains.kotlin.ir.util.WrappedDescriptorPatcher import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer @@ -30,9 +28,6 @@ class DeepCopyIrTreeWithSymbolsForFakeOverrides(typeArguments: Map WrappedPropertyGetterDescriptor() - is PropertySetterDescriptor -> WrappedPropertySetterDescriptor() - else -> WrappedSimpleFunctionDescriptor() - } - - override fun remapDeclaredProperty(descriptor: PropertyDescriptor) = - WrappedPropertyDescriptor() - - override fun remapDeclaredTypeParameter(descriptor: TypeParameterDescriptor) = - WrappedTypeParameterDescriptor() - - override fun remapDeclaredVariable(descriptor: VariableDescriptor) = - WrappedVariableDescriptor() - - override fun remapDeclaredValueParameter(descriptor: ParameterDescriptor): ParameterDescriptor = - if (descriptor is ReceiverParameterDescriptor) - WrappedReceiverParameterDescriptor() - else - WrappedValueParameterDescriptor() -} - -@OptIn(ObsoleteDescriptorBasedAPI::class) -object WrappedDescriptorPatcher : IrElementVisitorVoid { - override fun visitElement(element: IrElement) { - element.acceptChildrenVoid(this) - } - - override fun visitClass(declaration: IrClass) { - (declaration.descriptor as? WrappedClassDescriptor)?.bind(declaration) - declaration.acceptChildrenVoid(this) - } - - override fun visitConstructor(declaration: IrConstructor) { - (declaration.descriptor as? WrappedClassConstructorDescriptor)?.bind(declaration) - declaration.acceptChildrenVoid(this) - } - - override fun visitEnumEntry(declaration: IrEnumEntry) { - (declaration.descriptor as? WrappedClassDescriptor)?.bind( - declaration.correspondingClass ?: declaration.parentAsClass - ) - declaration.acceptChildrenVoid(this) - } - - override fun visitField(declaration: IrField) { - (declaration.descriptor as? WrappedFieldDescriptor)?.bind(declaration) - declaration.acceptChildrenVoid(this) - } - - override fun visitProperty(declaration: IrProperty) { - (declaration.descriptor as? WrappedPropertyDescriptor)?.bind(declaration) - declaration.acceptChildrenVoid(this) - } - - override fun visitFunction(declaration: IrFunction) { - (declaration.descriptor as? WrappedSimpleFunctionDescriptor)?.bind(declaration as IrSimpleFunction) - declaration.acceptChildrenVoid(this) - } - - override fun visitValueParameter(declaration: IrValueParameter) { - (declaration.descriptor as? WrappedValueParameterDescriptor)?.bind(declaration) - (declaration.descriptor as? WrappedReceiverParameterDescriptor)?.bind(declaration) - declaration.acceptChildrenVoid(this) - } - - override fun visitTypeParameter(declaration: IrTypeParameter) { - (declaration.descriptor as? WrappedTypeParameterDescriptor)?.bind(declaration) - declaration.acceptChildrenVoid(this) - } - - override fun visitVariable(declaration: IrVariable) { - (declaration.descriptor as? WrappedVariableDescriptor)?.bind(declaration) - declaration.acceptChildrenVoid(this) - } -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/NullDescriptorsRemapper.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/NullDescriptorsRemapper.kt new file mode 100644 index 00000000000..013e8334090 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/NullDescriptorsRemapper.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.ir.util + +import org.jetbrains.kotlin.descriptors.* + +object NullDescriptorsRemapper : DescriptorsRemapper { + override fun remapDeclaredClass(descriptor: ClassDescriptor): ClassDescriptor? = null + override fun remapDeclaredConstructor(descriptor: ClassConstructorDescriptor): ClassConstructorDescriptor? = null + override fun remapDeclaredEnumEntry(descriptor: ClassDescriptor): ClassDescriptor? = null + override fun remapDeclaredField(descriptor: PropertyDescriptor): PropertyDescriptor? = null + override fun remapDeclaredSimpleFunction(descriptor: FunctionDescriptor): FunctionDescriptor? = null + override fun remapDeclaredProperty(descriptor: PropertyDescriptor): PropertyDescriptor? = null + override fun remapDeclaredTypeParameter(descriptor: TypeParameterDescriptor): TypeParameterDescriptor? = null + override fun remapDeclaredVariable(descriptor: VariableDescriptor): VariableDescriptor? = null + override fun remapDeclaredValueParameter(descriptor: ParameterDescriptor): ParameterDescriptor? = null +} \ No newline at end of file