FIR checkers: report VAL_REASSIGNMENT for assignment operators
Currently VAL_REASSIGNMENT are only reported on direct assignments. Reassignments in the form of, for example, `+=` are reported as `VARIABLE_EXPECTED`, which differs from FE1.0.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
b87a943efd
commit
fc8d0e3ee0
Vendored
+5
-5
@@ -89,18 +89,18 @@ fun t3() {
|
||||
|
||||
fun t4() {
|
||||
val x = 1
|
||||
<!VARIABLE_EXPECTED!>x<!> += 2
|
||||
<!VAL_REASSIGNMENT!>x<!> += 2
|
||||
val y = 3
|
||||
<!VARIABLE_EXPECTED!>y<!> *= 4
|
||||
<!VAL_REASSIGNMENT!>y<!> *= 4
|
||||
var z = 5
|
||||
z -= y
|
||||
}
|
||||
|
||||
fun t5() {
|
||||
for (i in 0..2) {
|
||||
<!VARIABLE_EXPECTED!>i<!> += 1
|
||||
<!VAL_REASSIGNMENT!>i<!> += 1
|
||||
fun t5() {
|
||||
<!VARIABLE_EXPECTED!>i<!> += 3
|
||||
<!VAL_REASSIGNMENT!>i<!> += 3
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ class LocalValsVsProperties(val a: Int, w: Int) : Open(a, w) {
|
||||
var xx = w
|
||||
var yy : Int
|
||||
init {
|
||||
<!VARIABLE_EXPECTED!>w<!> += 1
|
||||
<!VAL_REASSIGNMENT!>w<!> += 1
|
||||
yy = w
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -68,16 +68,16 @@ class Test1 {
|
||||
|
||||
init {
|
||||
inlineMe {
|
||||
<!VARIABLE_EXPECTED!>a<!> += "allowed"
|
||||
<!VAL_REASSIGNMENT!>a<!> += "allowed"
|
||||
}
|
||||
crossinlineMe {
|
||||
<!VARIABLE_EXPECTED!>b<!> += "not allowed"
|
||||
<!VAL_REASSIGNMENT!>b<!> += "not allowed"
|
||||
}
|
||||
noinlineMe {
|
||||
<!VARIABLE_EXPECTED!>c<!> += "not allowed"
|
||||
<!VAL_REASSIGNMENT!>c<!> += "not allowed"
|
||||
}
|
||||
notinline {
|
||||
<!VARIABLE_EXPECTED!>d<!> += "not allowed"
|
||||
<!VAL_REASSIGNMENT!>d<!> += "not allowed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ fun box() : String {
|
||||
if (c1 != 1) {
|
||||
return "2"
|
||||
}
|
||||
<!VARIABLE_EXPECTED!>a<!> *= 3 // a = a * 3, shouldn't be able to do this on val
|
||||
<!VAL_REASSIGNMENT!>a<!> *= 3 // a = a * 3, shouldn't be able to do this on val
|
||||
if (c0 != 2) {
|
||||
return "3"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user