I want to trace back a receiver reference in IR to...
# compiler
y
I want to trace back a receiver reference in IR to the IrFunctionCall corresponding to the FirFunctionCall that resulted in its creation in
addNewImplicitReceivers
. Is there a simple way to do that? I'm thinking of using declaration origins, but I can't see how to easily associate that with the
FirFunctionCall
in a way that'll persist to the Ir. My use case is incredibly simple: I want a call like:
Copy code
with(foo, bar)
to result in 2 receivers added. Thus in the IR I want to add variables for
foo
and
bar
, and simply replace the receiver references to instead refer to them.
d
FIR bodies are removed from declarations after fir2ir conversion (to optimize memory consumption) and IR extensions are run after it. So you cannot go back from IR cal back to FIR. But you can try pass some information by adding some annotation to the implicit value you re generating.
y
I meant that I want to trace it to the apt IrCall. I've tried adding some information to the receiver parameter that I generate, but it always transforms to an error call regardless, so I don't get to see that information. In other words, what I see on the backend is simply an error call with an expected type. I've made that work somewhat now by keeping track in IR of what receiver types for my magical
with
function are available (and mapping them to temporary ir variables), and when I see an error call with some type, I look up the corresponding variable. I make sure the error call is correct by giving a special name to the owner of the receiver parameter. Maybe I can vary that special name I guess... It's still a lot of hoops to jump through for what should be a natural use case for the extension
d
Sorry, nothing comes to my mind which could simplify your case.