You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the smallest, simplest way to reproduce the problem?
publicclassChangeTypeTestimplementsRewriteTest {
@Overridepublicvoiddefaults(RecipeSpecspec) {
spec.recipe(
newChangeType("javax.annotation.Nonnull", "org.checkerframework.checker.nullness.qual.NonNull", null));
}
@TestvoidconflictingImports() {
// language=javarewriteRun(
// dissabling validation to avoid the 'Identifier type is missing or malformed' error. I couldn't add// the lombok dependency to the test.spec -> spec.typeValidationOptions(TypeValidation.none()),
java(
""" import lombok.NonNull; import javax.annotation.Nonnull; import org.immutables.value.Value; @Value.Immutable @Value.Style(passAnnotations = Nonnull.class) public interface ConflictingImports { private void lombokMethod(@NonNull final String lombokNonNull){} } """,
""" import lombok.NonNull; import org.immutables.value.Value; @Value.Immutable @Value.Style(passAnnotations = org.checkerframework.checker.nullness.qual.NonNull.class) public interface ConflictingImports { private void lombokMethod(@NonNull final String lombokNonNull){} } """));
}
}
What did you expect to see?
If where is already a class imported with the same name in the original code (lombok.NonNull in the example), the recipe should fully-qualified the new Type included (org.checkerframework.checker.nullness.qual.NonNull).
What did you see instead?
I'm seeing two imports for the same name type, from different packages.
Lets see if we can resolve both of those in that same PR.
This issue seems separate enough from the ambiguous static imports that it warrants a separate PR, I've added the example provided in a draft PR as seen above :)
What version of OpenRewrite are you using?
I am using
How are you running OpenRewrite?
What is the smallest, simplest way to reproduce the problem?
What did you expect to see?
If where is already a class imported with the same name in the original code (lombok.NonNull in the example), the recipe should fully-qualified the new Type included (org.checkerframework.checker.nullness.qual.NonNull).
What did you see instead?
I'm seeing two imports for the same name type, from different packages.
What is the full stack trace of any errors you encountered?
expected:
but was:
Extra information, slack thread about this issue:
https://rewriteoss.slack.com/archives/C01A843MWG5/p1723733741135269?thread_ts=1723658700.585459&cid=C01A843MWG5
Are you interested in contributing a fix to OpenRewrite?
Not at this moment. Maybe in the future.
The text was updated successfully, but these errors were encountered: