FIR checker: report val reassignment
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
b128577508
commit
f1fa290d49
+3
-3
@@ -16,8 +16,8 @@ fun foo(a: Boolean, b: Boolean): Int {
|
||||
x = 1
|
||||
}
|
||||
when (b) {
|
||||
true -> x = 2
|
||||
false -> x = 3
|
||||
true -> <!VAL_REASSIGNMENT!>x<!> = 2
|
||||
false -> <!VAL_REASSIGNMENT!>x<!> = 3
|
||||
}
|
||||
return x
|
||||
}
|
||||
@@ -28,7 +28,7 @@ fun bar(a: Boolean, b: Boolean): Int {
|
||||
x = 1
|
||||
}
|
||||
when (b) {
|
||||
false -> x = 3
|
||||
false -> <!VAL_REASSIGNMENT!>x<!> = 3
|
||||
}
|
||||
return <!UNINITIALIZED_VARIABLE!>x<!>
|
||||
}
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -UNUSED_VALUE
|
||||
|
||||
fun foo(): Any = 42
|
||||
|
||||
fun test1(x: Any) {
|
||||
when (val y = foo()) {
|
||||
is String -> y = ""
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -UNUSED_VALUE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user