== myRun == inline fun myRun(block: () -> T): T { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } --------------------- L0: 1 INIT: in: {} out: {} v(block: () -> T) INIT: in: {} out: {} magic[FAKE_INITIALIZER](block: () -> T) -> INIT: in: {} out: {} w(block|) INIT: in: {} out: {} 2 mark({ contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() }) INIT: in: {} out: {} mark({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) }) jmp?(L2) d({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) }) L2 [after local declaration]: r({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) }) -> mark(contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }) call(contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }, contract|) -> r(block) -> mark(block()) call(block(), invoke|) -> ret(*|) L1 L1: 1 error: sink: USE: in: {} out: {} ===================== == anonymous_0 == { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } --------------------- L3: 3 INIT: in: {} out: {} 4 mark(callsInPlace(block, InvocationKind.EXACTLY_ONCE)) magic[IMPLICIT_RECEIVER](callsInPlace(block, InvocationKind.EXACTLY_ONCE)) -> r(block) -> mark(InvocationKind.EXACTLY_ONCE) r(EXACTLY_ONCE) -> mark(callsInPlace(block, InvocationKind.EXACTLY_ONCE)) call(callsInPlace(block, InvocationKind.EXACTLY_ONCE), callsInPlace|, , ) -> L4: 3 error: sink: USE: in: {} out: {} ===================== == innerComputation == fun innerComputation(): Int = 42 --------------------- L0: 1 INIT: in: {} out: {} r(42) -> ret(*|) L1 L1: error: sink: USE: in: {} out: {} ===================== == outerComputation == fun outerComputation(): Int = 52 --------------------- L0: 1 INIT: in: {} out: {} r(52) -> ret(*|) L1 L1: error: sink: USE: in: {} out: {} ===================== == log == fun log() = Unit --------------------- L0: 1 INIT: in: {} out: {} r(Unit) -> ret(*|) L1 L1: error: sink: USE: in: {} out: {} ===================== == outerFinallyInitializes == fun outerFinallyInitializes() { val x: Int try { myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 } // Definite reassignment here, cause can get here only if myRun finished x = outerComputation() } catch (e: java.lang.Exception) { // can catch exception thrown by the inner, so x can be not initialized log() } finally { // Possible reassignment (e.g. if everything finished) x = 42 } // Properly initialized x.inc() } --------------------- L0: 1 INIT: in: {} out: {} USE: in: {} out: {} 2 mark({ val x: Int try { myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 } // Definite reassignment here, cause can get here only if myRun finished x = outerComputation() } catch (e: java.lang.Exception) { // can catch exception thrown by the inner, so x can be not initialized log() } finally { // Possible reassignment (e.g. if everything finished) x = 42 } // Properly initialized x.inc() }) v(val x: Int) INIT: in: {} out: {x=D} mark(try { myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 } // Definite reassignment here, cause can get here only if myRun finished x = outerComputation() } catch (e: java.lang.Exception) { // can catch exception thrown by the inner, so x can be not initialized log() } finally { // Possible reassignment (e.g. if everything finished) x = 42 }) INIT: in: {x=D} out: {x=D} jmp?(L2) jmp?(L3) 3 mark({ myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 } // Definite reassignment here, cause can get here only if myRun finished x = outerComputation() }) mark({ try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 }) r({ try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 }) -> mark(myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 }) call(myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 }, myRun|) -> L4 [before inlined declaration]: inlined({ try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 }) INIT: in: {x=ID} out: {x=ID} L5 [after inlined declaration]: mark(outerComputation()) call(outerComputation(), outerComputation) -> w(x|) 2 jmp?(L2) jmp?(L3) jmp(L10) L2 [onException]: 3 v(e: java.lang.Exception) INIT: in: {x=I?D} out: {x=I?D} magic[FAKE_INITIALIZER](e: java.lang.Exception) -> INIT: in: {x=I?D} out: {x=I?D} w(e|) INIT: in: {x=I?D} out: {x=I?D} 4 mark({ // can catch exception thrown by the inner, so x can be not initialized log() }) INIT: in: {x=I?D} out: {x=I?D} mark(log()) call(log(), log) -> 3 jmp(L10) L10 [afterCatches]: 2 jmp(L11) USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} L3 [onExceptionToFinallyBlock]: L12 [start finally]: 3 mark({ // Possible reassignment (e.g. if everything finished) x = 42 }) r(42) -> USE: in: {x=ONLY_WRITTEN_NEVER_READ} out: {x=ONLY_WRITTEN_NEVER_READ} w(x|) INIT: in: {x=I?D} out: {x=ID} USE: in: {} out: {x=ONLY_WRITTEN_NEVER_READ} L13 [finish finally]: 2 jmp(error) INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {} L11 [skipFinallyToErrorBlock]: L14 [copy of L3, onExceptionToFinallyBlock]: 3 mark({ // Possible reassignment (e.g. if everything finished) x = 42 }) INIT: in: {x=I?D} out: {x=I?D} r(42) -> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} w(x|) INIT: in: {x=I?D} out: {x=ID} USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ} 2 merge(try { myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 } // Definite reassignment here, cause can get here only if myRun finished x = outerComputation() } catch (e: java.lang.Exception) { // can catch exception thrown by the inner, so x can be not initialized log() } finally { // Possible reassignment (e.g. if everything finished) x = 42 }|!, ) -> INIT: in: {x=ID} out: {x=ID} mark(x.inc()) USE: in: {x=READ} out: {x=READ} r(x) -> USE: in: {} out: {x=READ} mark(inc()) call(inc(), inc|) -> L1: 1 INIT: in: {} out: {} error: sink: USE: in: {} out: {} ===================== == inlined anonymous_1 == { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 } --------------------- L6: 4 INIT: in: {x=D} out: {x=D} 5 mark(try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42) mark(try { x = innerComputation() } catch (e: java.lang.Exception) { log() }) jmp?(L8) 6 mark({ x = innerComputation() }) mark(innerComputation()) call(innerComputation(), innerComputation) -> w(x|) INIT: in: {x=D} out: {x=ID} 5 jmp?(L8) INIT: in: {x=ID} out: {x=ID} jmp(L9) L8 [onException]: 6 v(e: java.lang.Exception) INIT: in: {x=I?D} out: {x=I?D} magic[FAKE_INITIALIZER](e: java.lang.Exception) -> INIT: in: {x=I?D} out: {x=I?D} w(e|) INIT: in: {x=I?D} out: {x=I?D} 7 mark({ log() }) INIT: in: {x=I?D} out: {x=I?D} mark(log()) call(log(), log) -> 6 jmp(L9) L9 [afterCatches]: 5 merge(try { x = innerComputation() } catch (e: java.lang.Exception) { log() }|!, ) -> r(42) -> w(x|) INIT: in: {x=I?D} out: {x=ID} L7: 4 INIT: in: {x=ID} out: {x=ID} USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} error: - sink: INIT: in: {x=ID} out: {x=ID} USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} ===================== == innerFinalltInitializes == fun innerFinalltInitializes() { val x: Int try { myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } } // Properly initialized x.inc() } catch (e: java.lang.Exception) { log() } // Still can be non-initialized (e.g. if x.inc() threw an exception) x.inc() } --------------------- L0: 1 INIT: in: {} out: {} USE: in: {} out: {} 2 mark({ val x: Int try { myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } } // Properly initialized x.inc() } catch (e: java.lang.Exception) { log() } // Still can be non-initialized (e.g. if x.inc() threw an exception) x.inc() }) v(val x: Int) INIT: in: {} out: {x=D} mark(try { myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } } // Properly initialized x.inc() } catch (e: java.lang.Exception) { log() }) INIT: in: {x=D} out: {x=D} jmp?(L2) USE: in: {x=READ} out: {x=READ} 3 mark({ myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } } // Properly initialized x.inc() }) mark({ try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } }) r({ try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } }) -> mark(myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } }) call(myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } }, myRun|) -> L3 [before inlined declaration]: inlined({ try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } }) INIT: in: {x=ID} out: {x=ID} USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} L4 [after inlined declaration]: mark(x.inc()) r(x) -> mark(inc()) call(inc(), inc|) -> 2 jmp?(L2) jmp(L14) L2 [onException]: 3 v(e: java.lang.Exception) INIT: in: {x=I?D} out: {x=I?D} magic[FAKE_INITIALIZER](e: java.lang.Exception) -> INIT: in: {x=I?D} out: {x=I?D} w(e|) INIT: in: {x=I?D} out: {x=I?D} 4 mark({ log() }) INIT: in: {x=I?D} out: {x=I?D} mark(log()) call(log(), log) -> 3 jmp(L14) L14 [afterCatches]: 2 merge(try { myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } } // Properly initialized x.inc() } catch (e: java.lang.Exception) { log() }|, ) -> mark(x.inc()) USE: in: {x=READ} out: {x=READ} r(x) -> USE: in: {} out: {x=READ} mark(inc()) call(inc(), inc|) -> L1: 1 INIT: in: {} out: {} error: sink: USE: in: {} out: {} ===================== == inlined anonymous_2 == { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } } --------------------- L5: 4 INIT: in: {x=D} out: {x=D} 5 mark(try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 }) mark(try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 }) jmp?(L7) jmp?(L8) 6 mark({ innerComputation() }) mark(innerComputation()) call(innerComputation(), innerComputation) -> 5 jmp?(L7) jmp?(L8) jmp(L9) L7 [onException]: 6 v(e: java.lang.Exception) INIT: in: {x=D} out: {x=D} magic[FAKE_INITIALIZER](e: java.lang.Exception) -> INIT: in: {x=D} out: {x=D} w(e|) INIT: in: {x=D} out: {x=D} 7 mark({ log() }) INIT: in: {x=D} out: {x=D} mark(log()) call(log(), log) -> 6 jmp(L9) L9 [afterCatches]: 5 jmp(L10) L8 [onExceptionToFinallyBlock]: L11 [start finally]: 6 mark({ x = 42 }) r(42) -> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} w(x|) INIT: in: {x=D} out: {x=ID} USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ} L12 [finish finally]: 5 jmp(error) INIT: in: {x=ID} out: {x=ID} USE: in: {x=READ} out: {x=READ} L10 [skipFinallyToErrorBlock]: L13 [copy of L8, onExceptionToFinallyBlock]: 6 mark({ x = 42 }) INIT: in: {x=D} out: {x=D} r(42) -> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} w(x|) INIT: in: {x=D} out: {x=ID} USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ} 5 merge(try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 }|, ) -> INIT: in: {x=ID} out: {x=ID} 4 ret(*|) L6 L6: error: sink: USE: in: {x=READ} out: {x=READ} =====================