natario1
08/04/2022, 9:04 AMIllegalStateException: No file for io.company.product.sample/functionName|8889119292615326163[0] in moduleI’m trying to change value params and return type of a top level function. I’m using<io.company.product:sample>
irFile.transformChildrenVoid
and then function.deepCopySavingMetadata
and then doing my changes. Compilation works, but I get the error above when linking the native binary.shikasd
08/04/2022, 11:36 AMnatario1
08/04/2022, 11:59 AMfun functionName() = Unit
with no generics…
I might be completely wrong, but I came to the following conclusion - since the function is public (it has CName, it has IdSignature, symbol.isPublicApi is true), it is added to the SymbolTable
class by the frontend. So even if I remove it from the ir tree (by transform APIs or even just file.declarations.remove(func)), it’s not really removed and the linker will complain later on.
The consequence of this would be that you can’t replace/remove a “public API” symbol. For my purpose, I gave up on deep copy and I am modifying the function in place. This creates another error (mangler complains that ir representation and FunctionDescriptor do not match), but I could work around that by also modifying the descriptor, which is probably very illegal:
(func.descriptor as FunctionDescriptorImpl).let {
it.initialize(...)
}
It works for now, though I’m still looking for a better solution