diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ExpectDependencyGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ExpectDependencyGenerator.kt index d7076354b89..b4141e775c4 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ExpectDependencyGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ExpectDependencyGenerator.kt @@ -13,10 +13,14 @@ import org.jetbrains.kotlin.resolve.multiplatform.findExpects // Need to create unbound symbols for expects corresponding to actuals of the currently compiled module. // This is neccessary because there is no explicit links between expects and actuals // neither in descriptors nor in IR. -fun referenceExpectsForUsedActuals(expectDescriptorToSymbol: MutableMap, symbolTable: SymbolTable, irModule: IrModuleFragment) { +fun referenceExpectsForUsedActuals( + expectDescriptorToSymbol: MutableMap, + symbolTable: SymbolTable, + irModule: IrModuleFragment +) { irModule.acceptVoid(object : IrElementVisitorVoid { - private fun T.forEachExpect(body: (DeclarationDescriptor) -> Unit) where T: IrDeclaration { + private fun T.forEachExpect(body: (DeclarationDescriptor) -> Unit) where T : IrDeclaration { this.descriptor.findExpects().forEach { body(it) } @@ -27,11 +31,11 @@ fun referenceExpectsForUsedActuals(expectDescriptorToSymbol: MutableMap + val symbol = symbolTable.referenceClass(expectDescriptor as ClassDescriptor) + expectDescriptorToSymbol[expectDescriptor] = symbol + expectDescriptor.constructors.forEach { + expectDescriptorToSymbol[it] = symbolTable.referenceConstructor(it as ClassConstructorDescriptor) } } super.visitDeclaration(declaration) @@ -39,8 +43,8 @@ fun referenceExpectsForUsedActuals(expectDescriptorToSymbol: MutableMap symbolTable.referenceClass(it) else -> error("Unexpected expect for actual type alias: $it") } - expectDescriptorToSymbol.put(it, symbol); + expectDescriptorToSymbol[it] = symbol } super.visitDeclaration(declaration)