Skip to content

Ruby: Two fixes for private methods #10504

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

Merged
merged 3 commits into from
Sep 22, 2022
Merged

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Sep 21, 2022

  1. ModuleBase::get(A)Method did not work for methods directly annotated with private.
  2. Call graph construction did not take into account that private methods can be overridden.

Commit-by-commit review is suggested.

I sampled a couple of new call graph edges for each project, and they all looked legit.

@github-actions github-actions bot added the Ruby label Sep 21, 2022
@hvitved hvitved force-pushed the ruby/private-methods branch from b394408 to 61e9c6f Compare September 21, 2022 12:08
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Sep 22, 2022
@hvitved hvitved marked this pull request as ready for review September 22, 2022 07:20
@hvitved hvitved requested a review from a team as a code owner September 22, 2022 07:20
* end
* end
* ```
*
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this distinction important? Both m and nested are instance methods of M. The only difference is that nested only exists after m has been called at leas once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was not clear to me whether such conditional methods (being conditional on other methods being called) should now be included. I thought it would be safer to not include them in this PR, and then we can reconsider later (in fact, I already have a PR lined up with some call graph tests for nested methods).

Copy link
Contributor

Choose a reason for hiding this comment

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

True, but you are including conditional methods like:

if rails.version < 6
   def x; end
end

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with excluding nested method for now. Just wanted to make sure it was for the right reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but you are including conditional methods like

Indeed. Let's add all nested methods in a follow-up PR.

Copy link
Contributor

@aibaars aibaars left a comment

Choose a reason for hiding this comment

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

Looks good to me. One question about "nested" methods,

@hvitved hvitved merged commit ac59484 into github:main Sep 22, 2022
@hvitved hvitved deleted the ruby/private-methods branch September 22, 2022 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Ruby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants