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

omit more permissive modifiers on restricted visibility types #1881

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

j-roskopf
Copy link

closes #1301

  • docs/changelog.md has been updated if applicable.
  • CLA signed.

@JakeWharton
Copy link
Collaborator

I would like to see the tests cover more cases. Basically four classes with each of the four visibilities, each having four functions or properties with the four visibilities. I'm sure many of the cases are covered implicitly in other tests, but having one that actually covers all the cases specific to this functionality would be nice.

@j-roskopf
Copy link
Author

j-roskopf commented Apr 12, 2024

@JakeWharton Updated tests to add better coverage for the matrix you mentioned. I added tests to cover 5 classes (public, private, protected, internal, unspecified) with properties + functions over the same 5


protected fun protectedStringMethod(): String = "taco"

public fun publicStringMethod(): String = "taco"
Copy link
Collaborator

Choose a reason for hiding this comment

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

A bunch of these tests seem incorrect with the goal. In my original bug there's a private class showing that the public modifier isn't needed.

Copy link
Author

Choose a reason for hiding this comment

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

I wanted to verify that if any access modifier was specified, it was respected and added to the property / function even if the contain class was private / internal / protected / unspecified / public. So I added a matrix of those 5 each containing a function across the same 5, with the main change in behavior being that where the class is private / internal / protected, unspecifiedStringMethod has no access modifier specified in the source code because no modifier was specified through kotlin poet.

please let me know if i'm way off base!


// public always being an implicit modifier in addition to whatever we inherited.
// we don't want to throw away the implicit modifier we inherited
val implicitModifierContainsAtLeastTwoAccessMonitors = implicitModifiers.count {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are "access monitors"?

Copy link
Author

Choose a reason for hiding this comment

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

hey! access modifiers are the set of internal, private, public, protected. based that nomenclature off this comment

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I see! The code says "access monitors", which looks like a typo!

Copy link
Author

Choose a reason for hiding this comment

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

even if your comment asking what are 'access monitors', my brain still read that as access modifiers 🙃 whoops! fixed the typo

Copy link
Collaborator

Choose a reason for hiding this comment

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

Happens to me all the time! No worries & thanks for fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Omit more permissive modifiers on restricted visibility types
3 participants