== 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: {} ===================== == someComputation == fun someComputation(): Int = 42 --------------------- L0: 1 INIT: in: {} out: {} r(42) -> ret(*|) L1 L1: error: sink: USE: in: {} out: {} ===================== == tryCatchInlined == fun tryCatchInlined() { val x: Int myRun { try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() } } // I? x.inc() } --------------------- L0: 1 INIT: in: {} out: {} USE: in: {} out: {} 2 mark({ val x: Int myRun { try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() } } // I? x.inc() }) v(val x: Int) INIT: in: {} out: {x=D} mark({ try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() } }) INIT: in: {x=D} out: {x=D} r({ try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() } }) -> mark(myRun { try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() } }) call(myRun { try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() } }, myRun|) -> L2 [before inlined declaration]: inlined({ try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() } }) INIT: in: {x=I?D} out: {x=I?D} L3 [after inlined declaration]: 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 = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() } } --------------------- L4: 3 INIT: in: {x=D} out: {x=D} 4 mark(try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() }) mark(try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() }) jmp?(L6) USE: in: {x=READ} out: {x=READ} 5 mark({ x = someComputation() x.inc() }) mark(someComputation()) call(someComputation(), someComputation) -> 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} mark(x.inc()) INIT: in: {x=ID} out: {x=ID} r(x) -> mark(inc()) call(inc(), inc|) -> 4 jmp?(L6) jmp(L7) L6 [onException]: 5 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} 6 mark({ // I? x.inc() }) INIT: in: {x=I?D} out: {x=I?D} mark(x.inc()) r(x) -> mark(inc()) call(inc(), inc|) -> 5 jmp(L7) L7 [afterCatches]: 4 merge(try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // I? x.inc() }|, ) -> 3 ret(*|) L5 L5: USE: in: {x=READ} out: {x=READ} error: - sink: INIT: in: {x=I?D} out: {x=I?D} USE: in: {x=READ} out: {x=READ} ===================== == possibleReassignmentInTryCatch == fun possibleReassignmentInTryCatch() { val x: Int myRun { x = 42 try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() } // Initialized x.inc() } // Initialized x.inc() } --------------------- L0: 1 INIT: in: {} out: {} USE: in: {} out: {} 2 mark({ val x: Int myRun { x = 42 try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() } // Initialized x.inc() } // Initialized x.inc() }) v(val x: Int) INIT: in: {} out: {x=D} mark({ x = 42 try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() } // Initialized x.inc() }) INIT: in: {x=D} out: {x=D} r({ x = 42 try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() } // Initialized x.inc() }) -> mark(myRun { x = 42 try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() } // Initialized x.inc() }) call(myRun { x = 42 try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() } // Initialized x.inc() }, myRun|) -> L2 [before inlined declaration]: inlined({ x = 42 try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() } // Initialized x.inc() }) INIT: in: {x=ID} out: {x=ID} USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} L3 [after inlined declaration]: 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 == { x = 42 try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() } // Initialized x.inc() } --------------------- L4: 3 INIT: in: {x=D} out: {x=D} 4 mark(x = 42 try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() } // Initialized x.inc()) r(42) -> w(x|) INIT: in: {x=D} out: {x=ID} mark(try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() }) INIT: in: {x=ID} out: {x=ID} jmp?(L6) 5 mark({ x = someComputation() x.inc() }) mark(someComputation()) call(someComputation(), someComputation) -> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} w(x|) USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ} mark(x.inc()) r(x) -> mark(inc()) call(inc(), inc|) -> 4 jmp?(L6) jmp(L7) USE: in: {x=READ} out: {x=READ} L6 [onException]: 5 v(e: java.lang.Exception) INIT: in: {x=ID} out: {x=ID} magic[FAKE_INITIALIZER](e: java.lang.Exception) -> INIT: in: {x=ID} out: {x=ID} w(e|) INIT: in: {x=ID} out: {x=ID} 6 mark({ // Possible reassignment x = 42 x.inc() }) INIT: in: {x=ID} out: {x=ID} r(42) -> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} w(x|) USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ} mark(x.inc()) r(x) -> mark(inc()) call(inc(), inc|) -> 5 jmp(L7) L7 [afterCatches]: 4 merge(try { x = someComputation() x.inc() } catch (e: java.lang.Exception) { // Possible reassignment x = 42 x.inc() }|, ) -> mark(x.inc()) r(x) -> mark(inc()) call(inc(), inc|) -> 3 ret(*|) L5 L5: USE: in: {x=READ} out: {x=READ} error: - sink: INIT: in: {x=ID} out: {x=ID} USE: in: {x=READ} out: {x=READ} ===================== == tryCatchOuter == fun tryCatchOuter() { var x: Int try { myRun { x = someComputation() x.inc() } } catch (e: java.lang.UnsupportedOperationException) { myRun { x = 42 } } catch (e: java.lang.Exception) { // do nothing } // I? because we can leave with last catch-clause which doesn't initialize x x.inc() } --------------------- L0: 1 INIT: in: {} out: {} USE: in: {} out: {} 2 mark({ var x: Int try { myRun { x = someComputation() x.inc() } } catch (e: java.lang.UnsupportedOperationException) { myRun { x = 42 } } catch (e: java.lang.Exception) { // do nothing } // I? because we can leave with last catch-clause which doesn't initialize x x.inc() }) v(var x: Int) INIT: in: {} out: {x=D} mark(try { myRun { x = someComputation() x.inc() } } catch (e: java.lang.UnsupportedOperationException) { myRun { x = 42 } } catch (e: java.lang.Exception) { // do nothing }) INIT: in: {x=D} out: {x=D} jmp?(L2) USE: in: {x=READ} out: {x=READ} 3 mark({ myRun { x = someComputation() x.inc() } }) mark({ x = someComputation() x.inc() }) r({ x = someComputation() x.inc() }) -> mark(myRun { x = someComputation() x.inc() }) call(myRun { x = someComputation() x.inc() }, myRun|) -> L3 [before inlined declaration]: inlined({ x = someComputation() x.inc() }) INIT: in: {x=ID} out: {x=ID} USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} L4 [after inlined declaration]: 2 jmp?(L2) jmp(L7) L2 [onException]: jmp?(L8) INIT: in: {x=I?D} out: {x=I?D} USE: in: {x=READ} out: {x=READ} 3 v(e: java.lang.UnsupportedOperationException) INIT: in: {x=I?D} out: {x=I?D} magic[FAKE_INITIALIZER](e: java.lang.UnsupportedOperationException) -> INIT: in: {x=I?D} out: {x=I?D} w(e|) INIT: in: {x=I?D} out: {x=I?D} 4 mark({ myRun { x = 42 } }) INIT: in: {x=I?D} out: {x=I?D} mark({ x = 42 }) r({ x = 42 }) -> mark(myRun { x = 42 }) call(myRun { x = 42 }, myRun|) -> L9 [before inlined declaration]: inlined({ x = 42 }) INIT: in: {x=ID} out: {x=ID} USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} L10 [after inlined declaration]: 3 jmp(L7) L8 [catch 0]: 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({ // do nothing }) INIT: in: {x=I?D} out: {x=I?D} read (Unit) 3 jmp(L7) L7 [afterCatches]: 2 merge(try { myRun { x = someComputation() x.inc() } } catch (e: java.lang.UnsupportedOperationException) { myRun { x = 42 } } catch (e: java.lang.Exception) { // do nothing }|, , !) -> 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_3 == { x = someComputation() x.inc() } --------------------- L5: 4 INIT: in: {x=D} out: {x=D} 5 mark(x = someComputation() x.inc()) mark(someComputation()) call(someComputation(), someComputation) -> 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} mark(x.inc()) INIT: in: {x=ID} out: {x=ID} r(x) -> mark(inc()) call(inc(), inc|) -> 4 ret(*|) L6 L6: USE: in: {x=READ} out: {x=READ} error: - sink: INIT: in: {x=ID} out: {x=ID} USE: in: {x=READ} out: {x=READ} ===================== == inlined anonymous_4 == { x = 42 } --------------------- L11: 5 INIT: in: {x=I?D} out: {x=I?D} 6 mark(x = 42) 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} L12: 5 INIT: in: {x=ID} out: {x=ID} USE: in: {x=READ} out: {x=READ} error: - sink: INIT: in: {x=ID} out: {x=ID} USE: in: {x=READ} out: {x=READ} =====================