import kotlinx.atomicfu.* import kotlin.test.* class LockTest { private val inProgressLock = atomic(false) fun testLock() { var result = "" if (inProgressLock.tryAcquire()) { result = "OK" } assertEquals("OK", result) } } // This function will be removed by transformer @Suppress("NOTHING_TO_INLINE") private inline fun AtomicBoolean.tryAcquire(): Boolean = compareAndSet(false, true) // This function is here to test if the Kotlin metadata still consistent after transform // It is used in ReflectionTest, DO NOT REMOVE @Suppress("UNUSED_PARAMETER") fun String.reflectionTest(mapParam: Map): List = error("no impl") fun box(): String { val testClass = LockTest() testClass.testLock() return "OK" }