Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeUtils.findOverridenMethod] Skip found methods with default access and not same package #3603

Merged

Conversation

joteri
Copy link
Contributor

@joteri joteri commented Oct 4, 2023

What's changed?

What's your motivation?

Fixes #3599

Anything in particular you'd like reviewers to focus on?

Since it is an utility method that is invoked from different scenarios check if this change can affect any other behaviors.

Anyone you would like to review specifically?

@timtebeek

Have you considered any alternatives or workarounds?

Checklist

  • I've added unit tests to cover both positive and negative cases
  • It seems affected method is being invoked from another unit tests already so specific test was not added.
  • Should add a specific unit test for MissingOverrideAnnotation recipe to verify this bugfix.
  • I've added the license header to any new files through ./gradlew licenseFormat
  • no new files were added
  • I've used the IntelliJ IDEA auto-formatter on affected files

@knutwannheden
Copy link
Contributor

It would be very nice if we could get a unit test for this. Something like this:

    @Test
    void packagePrivateMethodOverride() {
        rewriteRun(
          java("..."),
          java("...",
            spec -> spec.afterRecipe(cu -> {
                assertThat(...);
            })
          )
        );
    }

Copy link
Contributor

@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 a lot for this fix! I've reduced the visibility on the new method you added, just to limit the public API we'd need to support going forward.

@timtebeek
Copy link
Contributor

Thanks for getting this started @joteri ! I've added a test and pushed a small change such that there's less negations in the code. Hope you agree!

@timtebeek timtebeek merged commit 8c8c9ad into openrewrite:main Oct 10, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

TypeUtils.findOverriddenMethod misidentifies package scoped method from class in different package
3 participants