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

type that is imported twice with different aliases is removed #1243

Closed
christophsturm opened this issue Oct 4, 2021 · 1 comment · Fixed by #1300
Closed

type that is imported twice with different aliases is removed #1243

christophsturm opened this issue Oct 4, 2021 · 1 comment · Fixed by #1300
Labels

Comments

@christophsturm
Copy link

Expected Behavior

i have code like this:

import a.b.Class
import a.b.c.Class as Class1
import a.b.c.Class as Class2
...

code that uses Class1
...
code that uses Class2

and while this is pretty strange its valid and works.

Observed Behavior

when i reformat that code with ktlint the second import is just removed, so the code no longer compiles.

If ktlint really wants to remove the duplicate import it should probably change all usages of Class2 to Class1 in the body of the file.

I hope this is obvious and easy to reproduce, if not i can try to create a sample project to reproduce it.

@paul-dingemans
Copy link
Collaborator

Nice find.

Ktlint should keep both imports in my opinion. Rewriting the code to eliminate one of the imports is not what people would expect from a linter.

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