When constructing new FIR, how would you emit `thi...
# compiler
c
When constructing new FIR, how would you emit
this@R|/MyClass|.R|/MyClass.bar| = R|<local>/value|
? I'm assuming it's through
buildVariableAssignment
, but I can't figure out what builders to wire into the LValue and RValue.
The full class is:
Copy code
public final class MyClass : R|kotlin/Any| {
        public constructor(): R|MyClass| {
            super<R|kotlin/Any|>()
        }

        public final var bar: R|kotlin/String| = String(MADBAGIC)
            public get(): R|kotlin/String|
            public set(value: R|kotlin/String|): R|kotlin/Unit|

        public final fun setBar(value: R|kotlin/String|): R|kotlin/Unit| {
            this@R|/MyClass|.R|/MyClass.bar| = R|<local>/value|
        }

    }
I'm trying to build the body of that
setBar
function.
buildPropertyAccessExpression
seems like it's the right one, maybe? But the usage is all over the place, seemingly encompassing not just class-bound properties but also local variable access, and I don't know the implications of
buildResolvedNamedReference
that a lot of the usages use.
j
You do not need to do that on FIR but on IR
c
I'd like to do it in FIR if possible, since it's significantly less brittle for my purposes
j
In general, any body should be completed on IR, so I haven't tried to do that in FIR
c
If I delay it to IR, I need a metadata annotation to get the raw name of the property I'm trying to access, instead of being able to access it directly
Alright so it looks like buildPropertyAccessExpression is the right one for the RHS, but using it on the LHS makes it try to access a static prop instead of an instance prop Or maybe it's the
buildResolvedNamedReference
that's doing it...
j
If I delay it to IR, I need a metadata annotation to get the raw name of the property I'm trying to access, instead of being able to access it directly
Not sure why, on IR you can even find all files and find any declaration by name if you want
c
Basically, I'm generating a
setBar
method for a property
bar
. (It's a fallback for general setter overloading.) The problem is that both
bar
and
Bar
will create the method
setBar
, and if they both exist, it'll cause all kinds of conflicts if it's resolved by name only. Plus considering how many other locale things are in the mix, I want to avoid referencing by name at all if possible.
Actually, that means I really need to use Kotlin's style of
set-{name}
in general for the overloaded setters