mattmoore
03/11/2021, 4:31 PM_
and here’s where I’m at so far.
I’ve started moving pattern matching back to generalized case
expression as the resolution starting-point. From there it will check to see the context it’s in (where
expression, if
expression, etc…) and then do the tree transform later in IR.
However, with 1.4 of the Kotlin compiler, after I’ve suppressed the “unresolved” errors, I’m now receiving a “unbound symbols not allowed” error. Tracing this back I see this is where a check is done for context.symbolTable.allUnbound
https://github.com/JetBrains/kotlin/blob/v1.4.10/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/Psi2IrTranslator.kt#L96
What would be the appropriate way to bind _
to another semantically valid symbol? I’m already using BindingContext
to do a record
(which then shows up in the binding context). Since the file above is called Psi2IrTranslator
and the function is generateModuleFragment
I’m guessing I need to either generate IR or map this to the IR that for the semantically valid symbols that I’m attempting to reference with _
.
In this scenario, I want the symbol _
to be bound to a KtNameReferenceExpression
, as it would refer to a data class argument.raulraja
03/11/2021, 6:31 PMIrExpression
associated to _
to a symbol in IR with the PluginContextraulraja
03/11/2021, 6:33 PMraulraja
03/11/2021, 6:34 PMmattmoore
03/13/2021, 10:57 AM_
. Is this done by creating a new descriptor and then recording that call in the binding trace? Or would this be done at the time IRCodegen
runs?
If IRCodegen
is where I'd need to generate the IR to then point to, the allUnbound
check doesn't finish until analysis phase finishes and then goes to IRCodegen
- or at least I think that's the way it works - my mental model might be wrong though.
Hopefully that makes sense. My code on this so far is in quite a mess while commenting out and experimenting with new changes, but here's the original code Andrei Shikov committed a while back that I'm looking at as a starting guide to understanding where next to go: https://github.com/mattmoore/arrow-meta/blob/pattern-matching/compiler-plugin/src/[…]plugins/patternMatching/phases/analysis/CapturedCallResolver.ktraulraja
03/15/2021, 9:23 AMobject _
or similar val _ : Nothing get() = ...
quoted so it’s a valid identifier and it’s already bound.
2. Instead bind it yourself by creating a IrFunctionSymbol or similar and then using PluginContext.referenceFunction
or similar methods to bind it yourself as they do in the thread.