Question regarding the analysis phase and the `rec...
# pattern-matching
m
Question regarding the analysis phase and the
record
function from the bindingcontext: Would
record
end up creating a new node? Also wondering how I would delete/replace nodes from here? Or would the analysis phase be used mainly for suppressing the IntelliJ errors?
r
record will assign to the Kt expression
_
or any other a type which currently is null right before analysis completes and it will let you get through to IR codegen
👍🏻 1
m
Would I just be assigning an existing kotlin type? Or create a new type to represent
_
? I guess what I'm trying to say is would I rewrite the offending node
_
during this time or just assign it a type and rewrite after analysis for IR codegen?
For example (may be wrong!):
Copy code
Analysis
   |
   v
Change _ to valid type
   |
   v
Desugar _ to something valid prior to IR codegen
   |
   v
IR Codegen
vs:
Copy code
Analysis
   |
   v
Change _ to valid type
   |
   v
IR Codegen
   |
   v
Desugar _ to something valid during IR codegen (IR transformation?)
I think the latter is the correct answer. After looking at https://github.com/arrow-kt/arrow-meta/blob/master/compiler-plugin/src/main/kotlin/arrow/meta/dsl/codegen/ir/IrSyntax.kt I think I'm understanding more. So yes, analysis is just to get intellij to behave, then I can apply tree transform in the IR codegen phase using the functions in
IrSyntax
Sorry, still wrapping my head around how the phases relate to each other. 😬
r
no worries, that makes sense
you would be obtaining the type from the Person constructor first arg and using that type on record
that will record _ as String
then in codegen you will replace those
m
Ah thanks!. OK. I guess I'm getting this after all 🙂 I'm hoping to try that out tonight or tomorrow.
👍 1