Fix mutation attempts for primitive globals. (#3796)
This commit is contained in:
+1
-1
@@ -1600,7 +1600,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
val globalAddress = context.llvmDeclarations.forStaticField(value.symbol.owner).storageAddressAccess.getAddress(
|
||||
functionGenerationContext
|
||||
)
|
||||
if (context.config.threadsAreAllowed && value.symbol.owner.isMainOnlyNonPrimitive)
|
||||
if (context.config.threadsAreAllowed && value.symbol.owner.storageKind == FieldStorageKind.MAIN_THREAD)
|
||||
functionGenerationContext.checkMainThread(currentCodeContext.exceptionHandler)
|
||||
if (value.symbol.owner.storageKind == FieldStorageKind.SHARED)
|
||||
functionGenerationContext.freeze(valueToAssign, currentCodeContext.exceptionHandler)
|
||||
|
||||
@@ -9,14 +9,30 @@ import kotlin.test.*
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val worker = Worker.start()
|
||||
val future = worker.execute(TransferMode.SAFE, { 42 }) {
|
||||
input -> input.toString()
|
||||
@Test fun runTest1() {
|
||||
withWorker {
|
||||
val future = execute(TransferMode.SAFE, { 42 }) { input ->
|
||||
input.toString()
|
||||
}
|
||||
future.consume { result ->
|
||||
println("Got $result")
|
||||
}
|
||||
}
|
||||
future.consume {
|
||||
result -> println("Got $result")
|
||||
}
|
||||
worker.requestTermination().result
|
||||
println("OK")
|
||||
}
|
||||
|
||||
var int1 = 1
|
||||
val int2 = 77
|
||||
|
||||
@Test fun runTest2() {
|
||||
int1++
|
||||
withWorker {
|
||||
executeAfter(0, {
|
||||
assertFailsWith<IncorrectDereferenceException> {
|
||||
int1++
|
||||
}
|
||||
assertEquals(2, int1)
|
||||
assertEquals(77, int2)
|
||||
}.freeze())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user