From bf419bc243a0b0df2bfd209018af74cfb601f9e4 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Thu, 25 Jun 2020 16:50:01 +0300 Subject: [PATCH] Compute correct signature for fake override properties with type parameters --- .../backend/common/overrides/FakeOverrides.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/overrides/FakeOverrides.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/overrides/FakeOverrides.kt index 50860fad7ec..29f4cee9e81 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/overrides/FakeOverrides.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/overrides/FakeOverrides.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.ir.descriptors.WrappedPropertyDescriptor import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrSymbol +import org.jetbrains.kotlin.ir.symbols.impl.IrPropertySymbolImpl import org.jetbrains.kotlin.ir.types.IrSimpleType import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.IrTypeProjection @@ -132,6 +133,22 @@ class FakeOverrideBuilder( } private fun linkPropertyFakeOverride(declaration: IrFakeOverridePropertyImpl) { + // To compute a signature for a property with type parameters, + // we must have its accessor's correspondingProperty pointing to the property's symbol. + // See IrMangleComputer.mangleTypeParameterReference() for details. + // But to create and link that symbol we should already have the signature computed. + // To break this loop we use temp symbol in correspondingProperty. + + val tempSymbol = IrPropertySymbolImpl(WrappedPropertyDescriptor()).also { + it.bind(declaration) + } + declaration.getter?.let { + it.correspondingPropertySymbol = tempSymbol + } + declaration.setter?.let { + it.correspondingPropertySymbol = tempSymbol + } + val signature = signaturer.composePublicIdSignature(declaration) symbolTable.declarePropertyFromLinker(WrappedPropertyDescriptor(), signature) {