openrewrite / rewrite-kotlin

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

PSI association issue: The type on destruct variable names is incorrect. #535

Open traceyyoshima opened 6 months ago

traceyyoshima commented 6 months ago

The type on _ and adapter will be destruct instead of the defined variables. This likely only requires a slight revision to the parser visitor to call type on the correct elements. The issue occurs in visitDestructuringDeclarationEntry through createIdentifier and the PsiElementAssociation#primary method. IntelliJ assigns the correct types as String, so the information must be available but might occur in the IR instead of the FIR.

              fun foo(choices: List<Pair<String, String>>, peekedHeader: Regex) {
                  for ((_, adapter) in choices) {
                      if (adapter.matches(peekedHeader)) {
                          print("1")
                      }
                  }
              }