openrewrite / rewrite-kotlin

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

Unlikely to occur -- Using `ChangeType` with escaped names will result in correct types. #502

Open traceyyoshima opened 11 months ago

traceyyoshima commented 11 months ago

This likely applies to any recipe that updates a name that is escapable such as ChangeMethodName.

    @Test
    void changeToEscapedImport() {
        rewriteRun(
          spec -> spec.recipe(new ChangeType("a.b.Original", "x.y.`Target`", true)),
          kotlin(
            """
              package a.b
              class Original
              """),
          kotlin(
            """
              import a.b.Original

              class A {
                  val type : Original = Original()
              }
              """,
            """
              import x.y.`Target`

              class A {
                  val type : `Target` = `Target`()
              }
              """
          )
        );
    }