openrewrite / rewrite-kotlin

Work-in-progress implementation of Kotlin language support for OpenRewrite.
Apache License 2.0
43 stars 12 forks source link

PSI association issue: type attributable labels are missing types. #539

Open traceyyoshima opened 9 months ago

traceyyoshima commented 9 months ago

Discovered by type assertions. The PSI element association includes various FIR elements, including a reference to the anonymous function. Note: this mis-mapping applies to all labels that may be type-attributed.

              fun foo(ints: List<Int>) {
                  ints.forEach {
                      if (it == 0) return@forEach
                      print(it)
                  }
              }
traceyyoshima commented 9 months ago

Note: This may be simpler using the IR. There isn't a PSI element associated with the FIR elements label field since the PSI on the label is the labeled element.

              fun foo(ints: List<Int>) {
                  ints.forEach {
                      if (it == 0) return@forEach // The PSI element on the FIR's label to `forEach` is the `forEach` a select of `ints`.
                      print(it)
                  }
              }