Rework frozen lazy to explicitly prevent cyclic garbage. (#1894)

This commit is contained in:
Nikolay Igotti
2018-08-17 17:47:35 +03:00
committed by GitHub
parent 562057cf69
commit 66767ec3fd
5 changed files with 165 additions and 33 deletions
+6
View File
@@ -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")
}