-
Notifications
You must be signed in to change notification settings - Fork 288
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
base: main
Are you sure you want to change the base?
Conversation
b1cb281
to
70f3355
Compare
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. |
@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 |
0d23625
to
41c1be9
Compare
|
||
protected fun protectedStringMethod(): String = "taco" | ||
|
||
public fun publicStringMethod(): String = "taco" |
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.
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.
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 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 { |
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.
What are "access monitors"?
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.
hey! access modifiers are the set of internal, private, public, protected. based that nomenclature off this comment
// Access. |
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.
Ah, I see! The code says "access monitors", which looks like a typo!
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.
even if your comment asking what are 'access monitors', my brain still read that as access modifiers 🙃 whoops! fixed the typo
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.
Happens to me all the time! No worries & thanks for fixing.
kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt
Outdated
Show resolved
Hide resolved
eac3b24
to
617f5a8
Compare
closes #1301
docs/changelog.md
has been updated if applicable.