-
Notifications
You must be signed in to change notification settings - Fork 509
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
Using import aliases on static Java methods with reserved Kotlin keyword names trigger the Unused Import rule #937
Comments
Should be fixed by #911, you can try a snapshot |
I tried the latest snapshot (ktlint-0.39.0-SNAPSHOT) and it appears that the issue is still there. I have created a sample app that demonstrates the issue here. |
oh, interesting, thanks for the sample 👍 |
This appears not to just be a static import of java methods but using import aliases in general. I was able to easily reproduce this.
|
Problem seems not be reproducable in at least version 0.43.2. If I recall correctly we solve d a bug a while ago in which import statements were removed when sorting the imports. Please reopen, if problem pop ups again. |
Expected Behavior
Mockito contains a static Java method names when, which will be imported in Kotlin like:
Clearly, if you try to use an import alias to get rid of the
when
, for example like:Observed Behavior
When using ktlint version >= 0.38.0, the above import triggers the
no-unused-import
rule. For ktlint versions up to 0.37.2 this was working properly.Steps to Reproduce
Simply do an import alias on a Java static method (or even a variable) which is named as a reserved Kotlin keyword (has been reproduced with
Mockito.when
andorg.hamcrest.CoreMatchers.is
) and run ktlint. Note that the actual alias name given does not seem to matter.Your Environment
The text was updated successfully, but these errors were encountered: