We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug Import aliases introduced to avoid name collisions may themselves introduce new name collisions.
To Reproduce
class ImportAliasTest { @Test fun `name collision`() { val dupName1 = ClassName("com.foo", "MyClass") val dupName2 = ClassName("com.bar", "FooMyClass") val dupName3 = ClassName("com.baz", "MyClass") val file = FileSpec .builder("com.sample", "Sample") .addFunction( FunSpec.builder("foo") .addStatement("%T", dupName1) .addStatement("%T", dupName2) .addStatement("%T", dupName3) .build() ) .build() assertEquals("?", file.toString()) } }
It is not clear what KotlinPoet should generate (hence "?"), but what it does generate currently is invalid:
"?"
package com.sample import com.bar.FooMyClass import com.baz.MyClass as BazMyClass import com.foo.MyClass as FooMyClass public fun foo() { com.foo.MyClass FooMyClass BazMyClass }
Expected behavior The generated code should not have any name collisions. One option might be:
package com.sample import com.bar.FooMyClass as BarFooMyClass import com.baz.MyClass as BazMyClass import com.foo.MyClass as FooMyClass public fun foo() { FooMyClass BarFooMyClass BazMyClass }
The text was updated successfully, but these errors were encountered:
We'll probably just add underscores like we do for other name collisions. Good find.
Sorry, something went wrong.
@damianw please feel free to send us a PR if you're interested!
I will take a look 👀
Successfully merging a pull request may close this issue.
Describe the bug
Import aliases introduced to avoid name collisions may themselves introduce new name collisions.
To Reproduce
It is not clear what KotlinPoet should generate (hence
"?"
), but what it does generate currently is invalid:Expected behavior
The generated code should not have any name collisions. One option might be:
The text was updated successfully, but these errors were encountered: