Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

"Unused import" incorrectly triggered if import is used implicitly #40

Closed
xenomachina opened this issue May 22, 2017 · 2 comments
Closed

Comments

@xenomachina
Copy link

Suppose I have an extension method that adds an iterator to some type:

operator fun <T> Foo<T>?.iterator() {
    ...
}

In another package, I want to iterate using this in a for loop:

import com.example.foo.iterator
...
val foo : Foo = ...

for (x in foo) {
    ...
}

With the import the code compiles and works, but ktlint fails with an "Unused import" error.

Without the import, the Kotlin compiler fails with "Error:(...) Kotlin: For-loop range must have an 'iterator()' method").

This probably happens with other operator extension functions that are called implicitly, though I haven't tested.

@shyiko
Copy link
Collaborator

shyiko commented May 22, 2017

@xenomachina Thank you. I'll take care of it after work.

@shyiko
Copy link
Collaborator

shyiko commented May 23, 2017

Fixed in 0.6.2 🎉

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants