Remove redundant check for a variable being initialized after write

It's anyway is obvious for write instruction, while effectively
after optimizations we treat val with syntactic initializer
uninitialized until their immediate initiazer
This commit is contained in:
Denis Zharkov
2017-09-22 18:28:20 +03:00
parent 8eb36947ca
commit c31b5beb9e
2 changed files with 2 additions and 4 deletions
@@ -500,9 +500,7 @@ class ControlFlowInformationProvider private constructor(
// is not declared
enterInitState?.isDeclared != true && exitInitState?.isDeclared != true &&
// wasn't initialized before current instruction
enterInitState?.mayBeInitialized() != true &&
// became initialized after current instruction
exitInitState?.mayBeInitialized() == true
enterInitState?.mayBeInitialized() != true
private fun checkInitializationForCustomSetter(ctxt: VariableInitContext, expression: KtExpression): Boolean {
val variableDescriptor = ctxt.variableDescriptor
@@ -4,7 +4,7 @@ package kt897
class A() {
init {
i = 11
<!INITIALIZATION_BEFORE_DECLARATION!>i<!> = 11
}
val i : Int? = null // must be an error