Does anyone know what this means? > IllegalSt...
# compiler
n
Does anyone know what this means?
IllegalStateException: No file for io.company.product.sample/functionName|8889119292615326163[0] in module
<io.company.product:sample>
I’m trying to change value params and return type of a top level function. I’m using
irFile.transformChildrenVoid
and then
function.deepCopySavingMetadata
and then doing my changes. Compilation works, but I get the error above when linking the native binary.
s
It couldn't find the generic type of the function, I suspect (the functionName|hash[0] indicates this) Make sure you remap generic types of the function correctly as well
n
It’s a very simple function, top level
fun 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:
Copy code
(func.descriptor as FunctionDescriptorImpl).let {
    it.initialize(...)
}
It works for now, though I’m still looking for a better solution