[atomicfu-JVM] Preparation for commonization of JVM and K/N transformers
The following updates in the JVM/IR plugin were made: * Lots of refactoring with preparation for K/N support: commonization of transformations. * Improved error handling (checks for visibility constraints, appending message about usage constraints in case of an error). * Explicit requirements for the visibility of atomic properties: to prevent leaking they should be private/internal or be members of private/internal classes. * Fixed visibility of generated properties: volatile properties are always private and atomic updaters have the same visibility as the original atomic property. * Volatile fields are generated from scratch and original atomic properties are removed. * Delegated properties support is fixed (only declaration in the same scope is allowed). * Non-inline atomic extensions are forbidden. * For top-level atomics: only one wrapper class per file (with corresponding visibility) is generated. * Bug fixes. The corresponding tickets: https://github.com/Kotlin/kotlinx-atomicfu/issues/322 KT-60528 Merge-request: KT-MR-10579 Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
private class AAA {
|
||||
private val _counter = atomic(5L)
|
||||
val counterValue: Long get() = _counter.value
|
||||
val delegateCounterValue by _counter
|
||||
val lateInitInt: AtomicInt
|
||||
val intArr: AtomicIntArray
|
||||
|
||||
// test ensures that transformation does not change the order of initialization
|
||||
init {
|
||||
lateInitInt = atomic(10)
|
||||
assertTrue(lateInitInt.compareAndSet(10, 100))
|
||||
assertEquals(100, lateInitInt.value)
|
||||
intArr = AtomicIntArray(10)
|
||||
intArr[0].value = 10
|
||||
assertTrue(intArr[0].compareAndSet(10, 100))
|
||||
intArr[1].value = 20
|
||||
}
|
||||
|
||||
init {
|
||||
assertEquals(5L, _counter.value)
|
||||
assertEquals(5L,counterValue)
|
||||
assertEquals(5L, delegateCounterValue)
|
||||
assertEquals(120, intArr[0].value + intArr[1].value)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val intClass = AAA()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user