36 lines
738 B
Kotlin
Vendored
36 lines
738 B
Kotlin
Vendored
// WITH_STDLIB
|
|
// WORKS_WHEN_VALUE_CLASS
|
|
// LANGUAGE: +ValueClasses
|
|
|
|
OPTIONAL_JVM_INLINE_ANNOTATION
|
|
value class Z(val int: Int)
|
|
|
|
OPTIONAL_JVM_INLINE_ANNOTATION
|
|
value class L(val long: Long)
|
|
|
|
OPTIONAL_JVM_INLINE_ANNOTATION
|
|
value class Str(val string: String)
|
|
|
|
OPTIONAL_JVM_INLINE_ANNOTATION
|
|
value class Obj(val obj: Any)
|
|
|
|
fun box(): String {
|
|
var xz = Z(0)
|
|
var xl = L(0L)
|
|
var xs = Str("")
|
|
var xo = Obj("")
|
|
|
|
run {
|
|
xz = Z(42)
|
|
xl = L(1234L)
|
|
xs = Str("abc")
|
|
xo = Obj("def")
|
|
}
|
|
|
|
if (xz.int != 42) throw AssertionError()
|
|
if (xl.long != 1234L) throw AssertionError()
|
|
if (xs.string != "abc") throw AssertionError()
|
|
if (xo.obj != "def") throw AssertionError()
|
|
|
|
return "OK"
|
|
} |