Hello! Working on a compiler plugin and one thing ...
# compiler
m
Hello! Working on a compiler plugin and one thing I need to do is handle an arbitrary symbol
_
that is syntactically valid, but change the semantics in a specific context. So instead of treating
_
as an unused param, for example, I want it to have a different meaning under the rules of the plugin. 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 that already exists elsewhere? I’ve tried using the
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 symbol that I’m attempting to reference with
_
. In this scenario, I am attempting to have
_
refer to an existing
KtNameReferenceExpression
.