-
Notifications
You must be signed in to change notification settings - Fork 289
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
Prevent aliased imports from colliding with existing imports #2052
base: main
Are you sure you want to change the base?
Conversation
714cbdb
to
ce2fbfe
Compare
kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt
Outdated
Show resolved
Hide resolved
ce2fbfe
to
a4d5afe
Compare
a4d5afe
to
6e3f114
Compare
Will wait for others to check it out later this week, or next. It's an off week for everyone (or it should be). |
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.
Looks good! Left a couple improvement suggestions, they're largely cosmetic since the the top priority is the correctness of generated aliases, but if you have the appetite for it - would be great to land them before merging!
kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt
Outdated
Show resolved
Hide resolved
kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Egor Andreevich <[email protected]>
Fixes #2046.
The simplest solution seemed to be to also check against currently-imported names when generating import aliases -- if a name is already imported, use more segments. This introduced the possibility that we might run out of segments though, which I handled by appending underscores if we reach that condition.
docs/changelog.md
has been updated if applicable