== Direction == enum class Direction { NORTH, SOUTH, WEST, EAST } --------------------- L0: 1 INIT: in: {} out: {} v(NORTH,) INIT: in: {} out: {NORTH=D} magic[FAKE_INITIALIZER](NORTH,) -> INIT: in: {NORTH=D} out: {NORTH=D} w(NORTH|) INIT: in: {NORTH=D} out: {NORTH=ID} v(SOUTH,) INIT: in: {NORTH=ID} out: {NORTH=ID, SOUTH=D} magic[FAKE_INITIALIZER](SOUTH,) -> INIT: in: {NORTH=ID, SOUTH=D} out: {NORTH=ID, SOUTH=D} w(SOUTH|) INIT: in: {NORTH=ID, SOUTH=D} out: {NORTH=ID, SOUTH=ID} v(WEST,) INIT: in: {NORTH=ID, SOUTH=ID} out: {NORTH=ID, SOUTH=ID, WEST=D} magic[FAKE_INITIALIZER](WEST,) -> INIT: in: {NORTH=ID, SOUTH=ID, WEST=D} out: {NORTH=ID, SOUTH=ID, WEST=D} w(WEST|) INIT: in: {NORTH=ID, SOUTH=ID, WEST=D} out: {NORTH=ID, SOUTH=ID, WEST=ID} v(EAST) INIT: in: {NORTH=ID, SOUTH=ID, WEST=ID} out: {EAST=D, NORTH=ID, SOUTH=ID, WEST=ID} magic[FAKE_INITIALIZER](EAST) -> INIT: in: {EAST=D, NORTH=ID, SOUTH=ID, WEST=ID} out: {EAST=D, NORTH=ID, SOUTH=ID, WEST=ID} w(EAST|) INIT: in: {EAST=D, NORTH=ID, SOUTH=ID, WEST=ID} out: {EAST=ID, NORTH=ID, SOUTH=ID, WEST=ID} L1: INIT: in: {EAST=ID, NORTH=ID, SOUTH=ID, WEST=ID} out: {EAST=ID, NORTH=ID, SOUTH=ID, WEST=ID} error: INIT: in: {} out: {} sink: INIT: in: {EAST=I?, NORTH=I?, SOUTH=I?, WEST=I?} out: {EAST=I?, NORTH=I?, SOUTH=I?, WEST=I?} USE: in: {} out: {} ===================== == foo == fun foo(dir: Direction): Int { val res: Int when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 } return res } --------------------- L0: 1 INIT: in: {} out: {} v(dir: Direction) INIT: in: {} out: {} magic[FAKE_INITIALIZER](dir: Direction) -> INIT: in: {} out: {} w(dir|) INIT: in: {} out: {} USE: in: {} out: {} 2 mark({ val res: Int when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 } return res }) INIT: in: {} out: {} v(val res: Int) INIT: in: {} out: {res=D} mark(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) INIT: in: {res=D} out: {res=D} r(dir) -> mark(Direction.NORTH -> res = 1) mark(Direction.NORTH) mark(Direction.NORTH) r(NORTH) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.NORTH|, ) -> jmp?(L4|) USE: in: {res=READ} out: {res=READ} L3 ['when' entry body]: r(1) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} w(res|) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} jmp(L2) INIT: in: {res=ID} out: {res=ID} L4 [next 'when' entry]: mark(Direction.SOUTH -> res = 2) INIT: in: {res=D} out: {res=D} mark(Direction.SOUTH) mark(Direction.SOUTH) r(SOUTH) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.SOUTH|, ) -> jmp?(L6|) USE: in: {res=READ} out: {res=READ} L5 ['when' entry body]: r(2) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} w(res|) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} jmp(L2) INIT: in: {res=ID} out: {res=ID} L6 [next 'when' entry]: mark(Direction.WEST -> res = 3) INIT: in: {res=D} out: {res=D} mark(Direction.WEST) mark(Direction.WEST) r(WEST) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.WEST|, ) -> jmp?(L8|) USE: in: {res=READ} out: {res=READ} L7 ['when' entry body]: r(3) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} w(res|) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} jmp(L2) INIT: in: {res=ID} out: {res=ID} L8 [next 'when' entry]: mark(Direction.EAST -> res = 4) INIT: in: {res=D} out: {res=D} mark(Direction.EAST) mark(Direction.EAST) r(EAST) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.EAST|, ) -> jmp?(L10|) USE: in: {res=READ} out: {res=READ} L9 ['when' entry body]: r(4) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} w(res|) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} jmp(L2) INIT: in: {res=ID} out: {res=ID} L10 [next 'when' entry]: magic[EXHAUSTIVE_WHEN_ELSE](when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) -> INIT: in: {res=D} out: {res=IED} L2 [after 'when' expression]: merge(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }|!, !, !, !) -> INIT: in: {res=ID} out: {res=ID} USE: in: {res=READ} out: {res=READ} r(res) -> USE: in: {} out: {res=READ} ret(*|) L1 L1: 1 INIT: in: {} out: {} error: sink: USE: in: {} out: {} =====================