Hi, is there any way to get the new compose genera...
# compose
j
Hi, is there any way to get the new compose generated name for a composable function in ir? The compose lowering turns my composable fun into a live literal call that I can’t find using
pluginContext
. Any thoughts on how to get a reference to that function to insert it in some places in code?
s
Is your composable a lambda? We don't change names for regular composables.
j
no its a function declaration.
@Composable fun MyFun(arg: String, arg1: String): String
if I declared it as
val MyFun = @Composable { arg:String, arg1:String -> arg }
that wouldn’t change?
s
Hm, function declaration names are not changed by live literals
j
I’m getting no static method found for MyFun(arg: String, arg1: String) when i provide the method reference found from
pluginContext.referenceFunctions
. The minute I remove the
@Composable
annotation its found. I know the lowering adds the composer and dirty flags and when I look at the transformations I see a different method name. Its okay, I may have a workaround. I wanted it to be be a composable so i could use LaunchedEffect but I have another idea to remove composables entirely
s
you should be able to find it with
MyFun(arg: String, arg1: String, $composer: Composer, $changed: Int)
I think
referenceFunctions
uses fqName, so it should find it
j
thats what I was looking for but I am not sure how to find it. I am only familiar with pluginContext.referenceFunctions and its returning the signature with two args, not the one with 4 args
s
ah, if it is a different module, you should get your original function
j
Sorry I am very ignorant on what modules are. I send the same module through all of my extension visitors.
s
Usually Gradle compilation unit, (or compiler
IrModuleFragment
) You can check if the function in the same module by checking its origin, if it has
DECLARATION_STUB
, it means that what you see is a deserialized stub, which doesn't account for IR transforms.
j
ok. I pass them all through the IrGenerationExtension
Copy code
override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) {

        InteractionAdapter(configuration, pluginContext, logger).adapt(moduleFragment)

        CaptureAdapter(configuration, pluginContext, logger).adapt(moduleFragment)
    }
I have a working solution though so its no big but its good to know that DECLARATION_STUB information
s
it is more about how Kotlin finds them, rather than how you transform the fragment, as the function you are looking for might be in another fragment 🙂
j
okay I see what you mean. Well I have a work around. Thanks for trying!