Skip to content

Conversation

amishra-u
Copy link
Contributor

What's changed?

PR #5439 introduced logic to handle import ambiguity by using fully qualified names when conflicting usages are present. However, this led to regressions in cases where such conflicts only existed temporarily during multi-step recipe transformations.

Issue

When multiple recipes are applied, intermediate steps may introduce conflicting usages. But at the end might all such usage can be safely replaced to shortend names.

To handle this, updated AddImport to shorten existing fullyqualified names for the type or member for which import is being added.

Testing

Validated the fix by running all tests in the rewrite-testing-frameworks.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

Copy link
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fixes here and downstream in openrewrite/rewrite-testing-frameworks#731; great to roll forwards.

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite May 19, 2025
@timtebeek timtebeek merged commit 19ca58c into openrewrite:main May 19, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite May 19, 2025
@timtebeek timtebeek added the bug Something isn't working label May 19, 2025
@amishra-u amishra-u deleted the 5439_regression branch June 2, 2025 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants