Skip to content

Commit

Permalink
IR Inliner: Tests for non-leaking backing fields of local properties
Browse files Browse the repository at this point in the history
^KT-71137 Fixed
  • Loading branch information
ddolovov authored and qodana-bot committed Sep 5, 2024
1 parent fb4b1ad commit 4e03d54
Show file tree
Hide file tree
Showing 31 changed files with 522 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ public class OK
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.<set-o>(<set-?> = "O")
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
local class <no name provided>
public fun run()
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.<get-o>()
internal inline fun initializeAndReadOK(): String
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<set-o>($this = this, <set-?> = "O")
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
local class <no name provided>
public fun run()
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-o>($this = this)
/* ACCESSOR declaration */ internal /* static */ fun access$<get-o>($this: OK): String
/* TARGET use-site */ $this.<get-o>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ public class OK
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.<set-o>(<set-?> = "O")
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
local class <no name provided>
public fun run()
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.<get-o>()
internal inline fun initializeAndReadOK(): String
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<set-o>($this = this, <set-?> = "O")
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
local class <no name provided>
public fun run()
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-o>($this = this)
/* ACCESSOR declaration */ public /* static */ fun access$<get-o>($this: OK): String
/* TARGET use-site */ $this.<get-o>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ class OK {
x = "X"
if (!::x.isInitialized) throw Error("Property 'x' is not initialized")

if (::y.isInitialized) throw Error("Property 'y' already initialized")
y = "Y"
if (!::y.isInitialized) throw Error("Property 'y' is not initialized")

return x + y
object {
fun run() {
if (::y.isInitialized) throw Error("Property 'y' already initialized")
y = "Y"
if (!::y.isInitialized) throw Error("Property 'y' is not initialized")
}
}
val local = object {
lateinit var xy: String
}

if (local::xy.isInitialized) throw Error("Property 'xy' already initialized")
local.xy = x + y
if (!local::xy.isInitialized) throw Error("Property 'xy' is not initialized")

return local.xy
}

internal fun initializeAndReadXY(): String = doInitializeAndReadXY()
Expand All @@ -25,11 +36,23 @@ class OK {
o = "O"
if (!::o.isInitialized) throw Error("Property 'o' is not initialized")

if (::k.isInitialized) throw Error("Property 'k' already initialized")
k = "K"
if (!::k.isInitialized) throw Error("Property 'k' is not initialized")
object {
fun run() {
if (::k.isInitialized) throw Error("Property 'k' already initialized")
k = "K"
if (!::k.isInitialized) throw Error("Property 'k' is not initialized")
}
}.run()

val local = object {
lateinit var ok: String
}

if (local::ok.isInitialized) throw Error("Property 'ok' already initialized")
local.ok = o + k
if (!local::ok.isInitialized) throw Error("Property 'ok' is not initialized")

return o + k
return local.ok
}

internal inline fun initializeAndReadOK(): String = doInitializeAndReadOK()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ public class OK
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.<set-o>(<set-?> = "O")
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
local class <no name provided>
public fun run()
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.<get-o>()
internal inline fun initializeAndReadOK(): String
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<set-o>($this = this, <set-?> = "O")
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
local class <no name provided>
public fun run()
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-o>($this = this)
/* ACCESSOR declaration */ internal /* static */ fun access$<get-o>($this: OK): String
/* TARGET use-site */ $this.<get-o>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ public class OK
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.<set-o>(<set-?> = "O")
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
local class <no name provided>
public fun run()
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.<get-o>()
internal inline fun initializeAndReadOK(): String
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<set-o>($this = this, <set-?> = "O")
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
local class <no name provided>
public fun run()
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-o>($this = this)
/* ACCESSOR declaration */ public /* static */ fun access$<get-o>($this: OK): String
/* TARGET use-site */ $this.<get-o>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ class OK {
x = "X"
if (!::x.isInitialized) throw Error("Property 'x' is not initialized")

if (::y.isInitialized) throw Error("Property 'y' already initialized")
y = "Y"
if (!::y.isInitialized) throw Error("Property 'y' is not initialized")
object {
fun run() {
if (::y.isInitialized) throw Error("Property 'y' already initialized")
y = "Y"
if (!::y.isInitialized) throw Error("Property 'y' is not initialized")
}
}
val local = object {
lateinit var xy: String
}

return x + y
if (local::xy.isInitialized) throw Error("Property 'xy' already initialized")
local.xy = x + y
if (!local::xy.isInitialized) throw Error("Property 'xy' is not initialized")

return local.xy
}

internal fun initializeAndReadXY(): String = doInitializeAndReadXY()
Expand All @@ -26,11 +37,23 @@ class OK {
o = "O"
if (!::o.isInitialized) throw Error("Property 'o' is not initialized")

if (::k.isInitialized) throw Error("Property 'k' already initialized")
k = "K"
if (!::k.isInitialized) throw Error("Property 'k' is not initialized")
object {
fun run() {
if (::k.isInitialized) throw Error("Property 'k' already initialized")
k = "K"
if (!::k.isInitialized) throw Error("Property 'k' is not initialized")
}
}.run()

val local = object {
lateinit var ok: String
}

if (local::ok.isInitialized) throw Error("Property 'ok' already initialized")
local.ok = o + k
if (!local::ok.isInitialized) throw Error("Property 'ok' is not initialized")

return o + k
return local.ok
}

internal inline fun initializeAndReadOK(): String = doInitializeAndReadOK()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ public class OK
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.<set-o>(<set-?> = "O")
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
local class <no name provided>
public fun run()
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.<get-o>()
internal inline fun initializeAndReadOK(): String
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<set-o>($this = this, <set-?> = "O")
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
local class <no name provided>
public fun run()
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-o>($this = this)
/* ACCESSOR declaration */ internal /* static */ fun access$<get-o>($this: OK): String
/* TARGET use-site */ $this.<get-o>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ public class OK
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.<set-o>(<set-?> = "O")
/* TARGET use-site */ <this>.#o
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
local class <no name provided>
public fun run()
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.#k
/* TARGET use-site */ <this>.<get-o>()
internal inline fun initializeAndReadOK(): String
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<set-o>($this = this, <set-?> = "O")
/* ACCESSOR use-site */ access$<get-o>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
local class <no name provided>
public fun run()
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-k>$p($this = this)
/* ACCESSOR use-site */ access$<get-o>($this = this)
/* ACCESSOR declaration */ public /* static */ fun access$<get-o>($this: OK): String
/* TARGET use-site */ $this.<get-o>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@ class OK {
x = "X"
if (!::x.isInitialized) throw Error("Property 'x' is not initialized")

if (::y.isInitialized) throw Error("Property 'y' already initialized")
y = "Y"
if (!::y.isInitialized) throw Error("Property 'y' is not initialized")

return x + y
object {
fun run() {
if (::y.isInitialized) throw Error("Property 'y' already initialized")
y = "Y"
if (!::y.isInitialized) throw Error("Property 'y' is not initialized")
}
}
val local = object {
lateinit var xy: String
}

if (local::xy.isInitialized) throw Error("Property 'xy' already initialized")
local.xy = x + y
if (!local::xy.isInitialized) throw Error("Property 'xy' is not initialized")

return local.xy
}

internal fun initializeAndReadXY(): String = doInitializeAndReadXY()
Expand All @@ -24,11 +35,23 @@ class OK {
o = "O"
if (!::o.isInitialized) throw Error("Property 'o' is not initialized")

if (::k.isInitialized) throw Error("Property 'k' already initialized")
k = "K"
if (!::k.isInitialized) throw Error("Property 'k' is not initialized")
object {
fun run() {
if (::k.isInitialized) throw Error("Property 'k' already initialized")
k = "K"
if (!::k.isInitialized) throw Error("Property 'k' is not initialized")
}
}.run()

val local = object {
lateinit var ok: String
}

if (local::ok.isInitialized) throw Error("Property 'ok' already initialized")
local.ok = o + k
if (!local::ok.isInitialized) throw Error("Property 'ok' is not initialized")

return o + k
return local.ok
}

internal inline fun initializeAndReadOK(): String = doInitializeAndReadOK()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ private inline fun doInitializeAndReadOK(): String
/* TARGET use-site */ #o
/* TARGET use-site */ <set-o>(<set-?> = "O")
/* TARGET use-site */ #o
/* TARGET use-site */ #k
/* TARGET use-site */ #k
local class <no name provided>
public fun run()
/* TARGET use-site */ #k
/* TARGET use-site */ #k
/* TARGET use-site */ <get-o>()
internal inline fun initializeAndReadOK(): String
/* ACCESSOR use-site */ access$<get-o>$p$tOKKt()
/* ACCESSOR use-site */ access$<set-o>$tOKKt(<set-?> = "O")
/* ACCESSOR use-site */ access$<get-o>$p$tOKKt()
/* ACCESSOR use-site */ access$<get-k>$p$tOKKt()
/* ACCESSOR use-site */ access$<get-k>$p$tOKKt()
local class <no name provided>
public fun run()
/* ACCESSOR use-site */ access$<get-k>$p$tOKKt()
/* ACCESSOR use-site */ access$<get-k>$p$tOKKt()
/* ACCESSOR use-site */ access$<get-o>$tOKKt()
/* ACCESSOR declaration */ internal fun access$<get-o>$tOKKt(): String
/* TARGET use-site */ <get-o>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ private inline fun doInitializeAndReadOK(): String
/* TARGET use-site */ #o
/* TARGET use-site */ <set-o>(<set-?> = "O")
/* TARGET use-site */ #o
/* TARGET use-site */ #k
/* TARGET use-site */ #k
local class <no name provided>
public fun run()
/* TARGET use-site */ #k
/* TARGET use-site */ #k
/* TARGET use-site */ <get-o>()
internal inline fun initializeAndReadOK(): String
/* ACCESSOR use-site */ access$<get-o>$p$tOKKt()
/* ACCESSOR use-site */ access$<set-o>$tOKKt(<set-?> = "O")
/* ACCESSOR use-site */ access$<get-o>$p$tOKKt()
/* ACCESSOR use-site */ access$<get-k>$p$tOKKt()
/* ACCESSOR use-site */ access$<get-k>$p$tOKKt()
local class <no name provided>
public fun run()
/* ACCESSOR use-site */ access$<get-k>$p$tOKKt()
/* ACCESSOR use-site */ access$<get-k>$p$tOKKt()
/* ACCESSOR use-site */ access$<get-o>$tOKKt()
/* ACCESSOR declaration */ public fun access$<get-o>$tOKKt(): String
/* TARGET use-site */ <get-o>()
Expand Down
Loading

0 comments on commit 4e03d54

Please sign in to comment.