Hi all, Prior to 1.3.71 there was a member `descri...
# compiler
i
Hi all, Prior to 1.3.71 there was a member
descriptor
, which would return the resolved call at the call-site. It has been removed ever since in this PR and was wondering if someone knows a way to go from IrCall -> CallableMemberDescriptor in the IrPhase. In my use case I can’t access the psiElement at call-site only the one in the symbol from the original declaration, which is not resolved - regarding type arguments etc. that is:
Copy code
{ expression: IrCall -> expression.symbol.owner.descriptor.original.findPsi()
} // returns the PsiElement
but
Copy code
{ expression: IrCall-> BindingTraceContext.createTraceableBindingTrace().bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, expression.symbol.owner.descriptor.original.findPsi()) } // returns always null
prior to 1.3.71 one would only need to do:
Copy code
{ expression: IrCall -> expression.descriptor } // returns CallableMemberDescriptor, which is fully resolved
Any help is very welcome 😄
i
What you need the descriptor for? If you need information about callee, you can use
symbol.owner
.
i
Thanks for the response 🙂 I am looking for the substituted FunctionDescriptor.
symbol.owner
only gives me the unsubstituted version as far as I see it in the debugger. But I might be missing the API that resolves that. I haven’t found it
u
We’re moving away from
DeclarationDescriptor
in IR backends and are planning to remove access to it entirely. It’s a legacy API, not very suitable for the kind of tasks required in the backend. For your task, I’d recommend you to look at
IrTypeSubstitutor
and its usages, maybe there’s something helpful. Alternatively, you can perform the substitution manually yourself, since the
IrCall
should have all the necessary information
i
Thank you @udalov I found an alternative that resolves it
@udalov I do have an issue in IR, for synthetic members. This was one invariant for Ir prior to 1.4.0 https://github.com/JetBrains/kotlin/blob/48ae76ac286b9efd9cf08d0145f7ca1543dc282b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/symbols/impl/IrSymbolBase.kt#L31, which was changed to this, It boil down that I need to change the
SimpleFunctionDescriptor
in IR to an
WrappedSimplFunctionDescriptor
, but the problem is if I try to do that in SyntheticResolution I need the SymbolTable and the associated IrFunction, from that descriptor, which I don’t have in that Phase. And within the IrPhase I don’t seem to find the right endpoint to change it
The code snippet I am trying to compile adds SyntheticMembers to Types. The problem comes, when I am using those members, it doesn’t comply with the new Invariant in 1.4.0, where SimpleFunctions have to be wrapped, though
I can send in the code if you have time.