-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Nowarn extension matching nonpublic member #21825
Conversation
Possibly, a |
val memberIsPublic = (member.symbol.flags & AccessFlags).isEmpty && !member.symbol.privateWithin.exists | ||
memberIsPublic && { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be member.symbol.isPublic
but we can also be more precise and check for accessibility (untested):
val memberIsPublic = (member.symbol.flags & AccessFlags).isEmpty && !member.symbol.privateWithin.exists | |
memberIsPublic && { | |
val memberIsAccessible = member.symbol.isAccessibleFrom(target) | |
memberIsAccessible && { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take another look during daylight, as my first swing was during interrupted sleep. I think the use case is an arbitrary use site, so that is the reason to require isPublic. I'll reconsider after coffee.
Backports #21825 to the 3.6.3. PR submitted by the release tooling.
Fixes #21816
Consider only public members when checking if an extension method actually extends.
A use site lint would be more thorough, when an extension is in scope but unused because of a visible matching member.