[FIR] Add checker for uninitialized properties
This commit is contained in:
+2
-2
@@ -44,7 +44,7 @@ fun threeLevelsReturnNoInitialization(x: Int?): Int? {
|
||||
// Possible to report unreachable here
|
||||
y = 54
|
||||
}
|
||||
return y.inc()
|
||||
return <!UNINITIALIZED_VARIABLE!>y<!>.inc()
|
||||
}
|
||||
|
||||
fun threeLevelsReturnWithInitialization(x: Int?): Int? {
|
||||
@@ -82,5 +82,5 @@ fun threeLevelsReturnWithUnknown(x: Int?): Int? {
|
||||
}
|
||||
}
|
||||
}
|
||||
return y.inc()
|
||||
return <!UNINITIALIZED_VARIABLE!>y<!>.inc()
|
||||
}
|
||||
+1
-1
@@ -36,7 +36,7 @@ fun outerFinallyInitializes() {
|
||||
x = outerComputation()
|
||||
} catch (e: java.lang.Exception) {
|
||||
// can catch exception thrown by the inner, so x can be not initialized
|
||||
x.inc()
|
||||
<!UNINITIALIZED_VARIABLE!>x<!>.inc()
|
||||
log()
|
||||
} finally {
|
||||
// Possible reassignment (e.g. if everything finished)
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ fun innerTryCatchInitializes() {
|
||||
// Can get here if innerComputation() threw an exception that wasn't catched by the inner catch (x is not initialized)
|
||||
// OR if outerComputation() threw an exception (x is initialized because we reach outer computation only when inner finished ok)
|
||||
// So, x=I? here
|
||||
x.inc()
|
||||
<!UNINITIALIZED_VARIABLE!>x<!>.inc()
|
||||
|
||||
// Potential reasignment
|
||||
x = 42
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ fun withLabeledReturn() {
|
||||
y = 42
|
||||
}
|
||||
|
||||
println(y)
|
||||
println(<!UNINITIALIZED_VARIABLE!>y<!>)
|
||||
println(x)
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -33,7 +33,7 @@ fun exitOnlyThroughLocalReturns(b: Boolean) {
|
||||
}
|
||||
|
||||
x.inc()
|
||||
s.length
|
||||
<!UNINITIALIZED_VARIABLE!>s<!>.length
|
||||
}
|
||||
|
||||
fun exitOnlyThroughNonLocalReturns(b: Boolean?) {
|
||||
@@ -49,7 +49,7 @@ fun exitOnlyThroughNonLocalReturns(b: Boolean?) {
|
||||
x = 54
|
||||
}
|
||||
|
||||
if (x == 42) {
|
||||
if (<!UNINITIALIZED_VARIABLE!>x<!> == 42) {
|
||||
return
|
||||
}
|
||||
else {
|
||||
@@ -59,8 +59,8 @@ fun exitOnlyThroughNonLocalReturns(b: Boolean?) {
|
||||
}
|
||||
}
|
||||
|
||||
x.inc()
|
||||
s.length
|
||||
<!UNINITIALIZED_VARIABLE!>x<!>.inc()
|
||||
<!UNINITIALIZED_VARIABLE!>s<!>.length
|
||||
}
|
||||
|
||||
fun nonLocalReturnAndOrdinaryExit(b: Boolean) {
|
||||
|
||||
+1
-1
@@ -44,5 +44,5 @@ fun catchThrowIfNotCalled() {
|
||||
} catch (ignored: java.lang.IllegalArgumentException) { }
|
||||
|
||||
// x *isn't* initialized here!
|
||||
println(x)
|
||||
println(<!UNINITIALIZED_VARIABLE!>x<!>)
|
||||
}
|
||||
Vendored
+1
-1
@@ -22,7 +22,7 @@ fun tryCatchInlined() {
|
||||
x.inc()
|
||||
}
|
||||
catch (e: java.lang.Exception) {
|
||||
x.inc()
|
||||
<!UNINITIALIZED_VARIABLE!>x<!>.inc()
|
||||
}
|
||||
}
|
||||
x = 42
|
||||
|
||||
Reference in New Issue
Block a user