FirForLoopChecker: report also OPERATOR_MODIFIER if appropriate + minor
This commits checks iterator/hasNext/next functions whether they are declared as operator or not. Also, it changes logic of hasNext/next error reporting, now we're able to report errors about both these functions.
This commit is contained in:
+28
-1
@@ -111,4 +111,31 @@ fun test2() {
|
||||
Anc() + Anc()
|
||||
Anc() <!OPERATOR_MODIFIER_REQUIRED!>-<!> Anc()
|
||||
Anc2() + Anc2()
|
||||
}
|
||||
}
|
||||
|
||||
fun Int.iterator(): MyIntIterator = null!!
|
||||
|
||||
operator fun Double.iterator(): MyDoubleIterator = null!!
|
||||
|
||||
operator fun Boolean.iterator(): MyBooleanIterator = null!!
|
||||
|
||||
interface MyIntIterator {
|
||||
operator fun hasNext(): Boolean
|
||||
operator fun next(): Int
|
||||
}
|
||||
|
||||
interface MyDoubleIterator {
|
||||
operator fun hasNext(): Boolean
|
||||
fun next(): Double
|
||||
}
|
||||
|
||||
interface MyBooleanIterator {
|
||||
fun hasNext(): Boolean
|
||||
operator fun next(): Boolean
|
||||
}
|
||||
|
||||
fun test3(i: Int, d: Double, b: Boolean) {
|
||||
for (element in <!OPERATOR_MODIFIER_REQUIRED!>i<!>) {}
|
||||
for (element in <!OPERATOR_MODIFIER_REQUIRED!>d<!>) {}
|
||||
for (element in <!OPERATOR_MODIFIER_REQUIRED!>b<!>) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user