Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/annotations/Volatile.kt
T
Ilya Gorbunov e2d96da396 Introduce experimental kotlin.concurrent.Volatile annotation KT-55268, KT-55609
Use this annotation in tests to ensure it works the same at least on JVM
2022-12-23 19:07:30 +01:00

36 lines
1021 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_ANONYMOUS_PARAMETER
import kotlin.jvm.Volatile as JvmVolatile
import kotlin.concurrent.Volatile
import kotlin.properties.Delegates
@OptIn(ExperimentalStdlibApi::class)
class ConcurrentVolatile {
<!VOLATILE_ON_VALUE!>@Volatile<!> val x = 0
// ok
@Volatile var y = 1
<!VOLATILE_ON_DELEGATE!>@delegate:Volatile<!> var z: String by Delegates.observable("?") { prop, old, new -> old.hashCode() }
<!VOLATILE_ON_VALUE!>@field:Volatile<!> val w = 2
<!WRONG_ANNOTATION_TARGET!>@Volatile<!>
var noBacking: String
get() = ""
set(value) {}
}
class JvmVolatile {
<!VOLATILE_ON_VALUE!>@JvmVolatile<!> val x = 0
// ok
@JvmVolatile var y = 1
<!VOLATILE_ON_DELEGATE!>@delegate:JvmVolatile<!> var z: String by Delegates.observable("?") { prop, old, new -> old.hashCode() }
<!VOLATILE_ON_VALUE!>@field:JvmVolatile<!> val w = 2
<!WRONG_ANNOTATION_TARGET!>@JvmVolatile<!>
var noBacking: String
get() = ""
set(value) {}
}