openrewrite / rewrite-kotlin

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

Issue with change type on an annotation with a use site target #576

Closed rogerpeckham-toast closed 9 months ago

rogerpeckham-toast commented 9 months ago

What version of OpenRewrite are you using?

I am using

How are you running OpenRewrite?

I am using the Gradle plugin to run ChangeType recipes.

What is the smallest, simplest way to reproduce the problem?

I have created the test here. The test is a change type recipe for an annotation class that is used with a use site target. When run the import is not added for the new Target annotation.

After stepping through the code I am starting to believe that for some reason the AddImport visitor is not actually causing the issue because when the type is changed the underlying type in use isn't changed. To explain using the annotations from the linked test, it doesn't add an import for the Target annotation because it thinks that the Target annotation added actually has the type a.b.Original.

Are you interested in contributing a fix to OpenRewrite?

If I figure out the source of this issue I might be able to fix it but there is a good chance I will not be able to fix it.

knutwannheden commented 9 months ago

This has now been fixed and will be included in the next release. You can expect a new release within the next two weeks. In the mean time you can use snapshot builds, which should already be available.