Rework frozen lazy to explicitly prevent cyclic garbage. (#1894)
This commit is contained in:
@@ -724,6 +724,12 @@ task lazy0(type: RunKonanTest) {
|
||||
source = "runtime/workers/lazy0.kt"
|
||||
}
|
||||
|
||||
task lazy1(type: RunKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // Need exceptions.
|
||||
goldValue = "OK\n"
|
||||
source = "runtime/workers/lazy1.kt"
|
||||
}
|
||||
|
||||
task enumIdentity(type: RunKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // Workers need pthreads.
|
||||
goldValue = "true\n"
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package runtime.workers.lazy1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlin.native.worker.*
|
||||
|
||||
class Leak {
|
||||
val leak by lazy { this }
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
for (i in 1..100)
|
||||
Leak().freeze().leak
|
||||
}
|
||||
println("OK")
|
||||
}
|
||||
Reference in New Issue
Block a user