From fdf4f02dde7ce405c6f630bff9bb1d90704caa8e Mon Sep 17 00:00:00 2001 From: Leonid Startsev Date: Wed, 12 Dec 2018 17:26:01 +0300 Subject: [PATCH] Declare real external symbols for overriden by synthetic function instead of unbound Unbound symbols were throwing an exception on attempt to analyze them in the other parts of compiler and are generally incorrect --- .../compiler/backend/ir/GeneratorHelpers.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt index 4f88c56a8c8..787a2597000 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt @@ -56,11 +56,16 @@ interface IrBuilderExtension { val BackendContext.localSymbolTable: SymbolTable + private fun IrClass.declareSimpleFunctionWithExternalOverrides(descriptor: FunctionDescriptor): IrSimpleFunction { + return compilerContext.localSymbolTable.declareSimpleFunction(startOffset, endOffset, SERIALIZABLE_PLUGIN_ORIGIN, descriptor).also {f -> + descriptor.overriddenDescriptors.mapTo(f.overriddenSymbols) { + compilerContext.externalSymbols.referenceSimpleFunction(it.original) + } + } + } + fun IrClass.contributeFunction(descriptor: FunctionDescriptor, fromStubs: Boolean = false, bodyGen: IrBlockBodyBuilder.(IrFunction) -> Unit) { - val f: IrSimpleFunction = if (!fromStubs) compilerContext.localSymbolTable.declareSimpleFunctionWithOverrides( - this.startOffset, - this.endOffset, - SERIALIZABLE_PLUGIN_ORIGIN, + val f: IrSimpleFunction = if (!fromStubs) declareSimpleFunctionWithExternalOverrides( descriptor ) else compilerContext.externalSymbols.referenceSimpleFunction(descriptor).owner f.parent = this