== println == fun println(obj: Any?) {} --------------------- : * NEW: magic[FAKE_INITIALIZER](obj: Any?) -> ===================== == Demo0 == class Demo0 { private val some = object { fun foo() { println(state) // Ok } } private var state: Boolean = true } --------------------- object { fun foo() { println(state) // Ok } } : NEW: r(object { fun foo() { println(state) // Ok } }) -> true : Boolean NEW: r(true) -> ===================== == foo == fun foo() { println(state) // Ok } --------------------- : Demo0 NEW: magic[IMPLICIT_RECEIVER](state) -> state : * NEW: r(state|) -> println(state) : * NEW: call(println(state), println|) -> { println(state) // Ok } : * COPY ===================== == Demo1 == class Demo1 { private val some = object { fun foo() { if (state) state = true println(state) // must be initialized } } private var state: Boolean = true } --------------------- object { fun foo() { if (state) state = true println(state) // must be initialized } } : NEW: r(object { fun foo() { if (state) state = true println(state) // must be initialized } }) -> true : Boolean NEW: r(true) -> ===================== == foo == fun foo() { if (state) state = true println(state) // must be initialized } --------------------- : Demo1 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo1 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo1 NEW: magic[IMPLICIT_RECEIVER](state) -> state : Boolean NEW: r(state|) -> true : Boolean NEW: r(true) -> state = true !: * if (state) state = true : * NEW: merge(if (state) state = true|!) -> state : * NEW: r(state|) -> println(state) : * NEW: call(println(state), println|) -> { if (state) state = true println(state) // must be initialized } : * COPY ===================== == Demo1A == class Demo1A { fun foo() { if (state) state = true println(state) // Ok } private var state: Boolean = true } --------------------- true : Boolean NEW: r(true) -> ===================== == foo == fun foo() { if (state) state = true println(state) // Ok } --------------------- : Demo1A NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo1A NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo1A NEW: magic[IMPLICIT_RECEIVER](state) -> state : Boolean NEW: r(state|) -> true : Boolean NEW: r(true) -> state = true !: * if (state) state = true : * NEW: merge(if (state) state = true|!) -> state : * NEW: r(state|) -> println(state) : * NEW: call(println(state), println|) -> { if (state) state = true println(state) // Ok } : * COPY ===================== == Demo2 == class Demo2 { private val some = object { fun foo() { if (state) state = true else state = false println(state) // OK } } private var state: Boolean = true } --------------------- object { fun foo() { if (state) state = true else state = false println(state) // OK } } : NEW: r(object { fun foo() { if (state) state = true else state = false println(state) // OK } }) -> true : Boolean NEW: r(true) -> ===================== == foo == fun foo() { if (state) state = true else state = false println(state) // OK } --------------------- : Demo2 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo2 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo2 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo2 NEW: magic[IMPLICIT_RECEIVER](state) -> state : Boolean NEW: r(state|) -> true : Boolean NEW: r(true) -> state = true !: * false : Boolean NEW: r(false) -> state = false !: * if (state) state = true else state = false : * NEW: merge(if (state) state = true else state = false|!, !) -> state : * NEW: r(state|) -> println(state) : * NEW: call(println(state), println|) -> { if (state) state = true else state = false println(state) // OK } : * COPY ===================== == Demo3 == class Demo3 { private val some = run { if (state) state = true println(state) // OK } private var state: Boolean = true } --------------------- : Demo3 NEW: magic[IMPLICIT_RECEIVER](run { if (state) state = true println(state) // OK }) -> { if (state) state = true println(state) // OK } : {<: Demo3.() -> Unit} NEW: r({ if (state) state = true println(state) // OK }) -> run { if (state) state = true println(state) // OK } : Unit NEW: call(run { if (state) state = true println(state) // OK }, run|, ) -> true : Boolean NEW: r(true) -> ===================== == anonymous_0 == { if (state) state = true println(state) // OK } --------------------- : Demo3 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo3 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo3 NEW: magic[IMPLICIT_RECEIVER](state) -> state : Boolean NEW: r(state|) -> true : Boolean NEW: r(true) -> state = true !: * if (state) state = true : * NEW: merge(if (state) state = true|!) -> state : * NEW: r(state|) -> println(state) : * NEW: call(println(state), println|) -> if (state) state = true println(state) // OK : * COPY ===================== == run == fun T.run(f: T.() -> R) = f() --------------------- : {<: T.() -> R} NEW: magic[FAKE_INITIALIZER](f: T.() -> R) -> : {<: T} NEW: magic[IMPLICIT_RECEIVER](f()) -> f : {<: (T) -> R} NEW: r(f) -> f() : {<: R} NEW: call(f(), invoke|, ) -> ===================== == exec == fun exec(f: () -> T): T = f() --------------------- : {<: () -> T} NEW: magic[FAKE_INITIALIZER](f: () -> T) -> f : {<: () -> T} NEW: r(f) -> f() : {<: T} NEW: call(f(), invoke|) -> ===================== == Demo4 == class Demo4 { private val some = exec { if (state) state = true println(state) // must be initialized } private var state: Boolean = true } --------------------- { if (state) state = true println(state) // must be initialized } : {<: () -> Unit} NEW: r({ if (state) state = true println(state) // must be initialized }) -> exec { if (state) state = true println(state) // must be initialized } : Unit NEW: call(exec { if (state) state = true println(state) // must be initialized }, exec|) -> true : Boolean NEW: r(true) -> ===================== == anonymous_1 == { if (state) state = true println(state) // must be initialized } --------------------- : Demo4 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo4 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo4 NEW: magic[IMPLICIT_RECEIVER](state) -> state : Boolean NEW: r(state|) -> true : Boolean NEW: r(true) -> state = true !: * if (state) state = true : * NEW: merge(if (state) state = true|!) -> state : * NEW: r(state|) -> println(state) : * NEW: call(println(state), println|) -> if (state) state = true println(state) // must be initialized : * COPY ===================== == Demo5 == class Demo5 { private var state: Boolean = true private val some = object { fun foo() { if (state) state = true println(state) // OK } } } --------------------- true : Boolean NEW: r(true) -> object { fun foo() { if (state) state = true println(state) // OK } } : NEW: r(object { fun foo() { if (state) state = true println(state) // OK } }) -> ===================== == foo == fun foo() { if (state) state = true println(state) // OK } --------------------- : Demo5 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo5 NEW: magic[IMPLICIT_RECEIVER](state) -> : Demo5 NEW: magic[IMPLICIT_RECEIVER](state) -> state : Boolean NEW: r(state|) -> true : Boolean NEW: r(true) -> state = true !: * if (state) state = true : * NEW: merge(if (state) state = true|!) -> state : * NEW: r(state|) -> println(state) : * NEW: call(println(state), println|) -> { if (state) state = true println(state) // OK } : * COPY =====================