"Unused import" incorrectly triggered if import is used implicitly
xenomachina opened this issue · 2 comments
xenomachina commented
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 commented
@xenomachina Thank you. I'll take care of it after work.
shyiko commented
Fixed in 0.6.2 🎉