FIR checker: add convention check for ++ and +=, etc

This commit is contained in:
Tianyu Geng
2021-08-09 18:46:08 -07:00
committed by TeamCityServer
parent 68e7476765
commit 64ebddcbc6
14 changed files with 128 additions and 23 deletions
+8 -8
View File
@@ -35,12 +35,12 @@ class UnitIncDec() {
fun testUnitIncDec() {
var x = UnitIncDec()
<!RESULT_TYPE_MISMATCH!>x++<!>
<!RESULT_TYPE_MISMATCH!>++x<!>
<!RESULT_TYPE_MISMATCH!>x--<!>
<!RESULT_TYPE_MISMATCH!>--x<!>
x = <!RESULT_TYPE_MISMATCH!>x++<!>
x = <!RESULT_TYPE_MISMATCH!>x--<!>
x = <!RESULT_TYPE_MISMATCH!>++x<!>
x = <!RESULT_TYPE_MISMATCH!>--x<!>
x<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>++<!>
<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>++<!>x
x<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>--<!>
<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>--<!>x
x = x<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>++<!>
x = x<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>--<!>
x = <!INC_DEC_SHOULD_NOT_RETURN_UNIT!>++<!>x
x = <!INC_DEC_SHOULD_NOT_RETURN_UNIT!>--<!>x
}
@@ -29,7 +29,7 @@ class Test()
fun test()
{
val control = Control()
control.MouseMoved += { it.X } // here
control.MouseMoved <!ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT!>+=<!> { it.X } // here
control.MouseMoved.plusAssign( { it.X } ) // ok
}
}
}
@@ -20,9 +20,9 @@ class B() {
fun main() {
var c = B()
c += B()
c *= B()
c /= B()
c -= B()
c %= B()
}
c <!ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT!>+=<!> B()
c <!ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT!>*=<!> B()
c <!ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT!>/=<!> B()
c <!ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT!>-=<!> B()
c <!ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT!>%=<!> B()
}
@@ -4,7 +4,7 @@ class IncDec {
fun foo(): IncDec {
var x = IncDec()
x = <!RESULT_TYPE_MISMATCH!>x++<!>
<!RESULT_TYPE_MISMATCH!>x++<!>
x = x<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>++<!>
x<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>++<!>
return x
}