https://kotlinlang.org logo
Title
n

natario1

07/31/2022, 3:02 PM
How do you reference another function (or wrap it in a lambda) in IR? I have a
fun hello(who: String) = "Hello, $who!"
as a
IrSimpleFunction
. I need to pass this to a fun
process(function: (String) -> String)
, but I’m confused as to how to pass my function as a value argument to another. To be clear, in source code I’d do process(::hello) or process { hello(it) }.
s

shikasd

08/01/2022, 11:52 AM
You can take a look at
IrFunctionReference
, which backs up
::hello
syntax iirc
t

Tóth István Zoltán

08/03/2022, 1:50 AM
What I usually do is to write it in Kotlin and use
IrModuleFragment.dump()
how the IR looks like. From there it is usually easy to find the IR calls to build the given part.
n

natario1

08/03/2022, 9:18 AM
Thanks a lot guys. dump is super useful. I also went a long way by just looking at autocompletion, e.g.
ir*
functions in declaration builder, or ir factory. For some reason function references are not advertised there though