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
This commit is contained in:
Leonid Startsev
2018-12-12 17:26:01 +03:00
parent a15b47c93c
commit fdf4f02dde
@@ -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