Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt26858.kt
T
2021-10-11 12:09:52 +03:00

25 lines
710 B
Kotlin
Vendored

// WITH_RUNTIME
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
@kotlin.jvm.JvmInline
value class Direction(private val direction: Int) {
fun dx() = dx[direction]
fun dy() = dy[direction]
companion object {
private val dx = intArrayOf(0, 1, 0, -1)
private val dy = intArrayOf(-1, 0, 1, 0)
}
}
fun box(): String {
val dirs = arrayOf(Direction(0), Direction(1), Direction(2), Direction(3))
val expectedDx = intArrayOf(0, 1, 0, -1)
val expectedDy = intArrayOf(-1, 0, 1, 0)
for (i in 0 .. 3) {
if (dirs[i].dx() != expectedDx[i]) throw AssertionError()
if (dirs[i].dy() != expectedDy[i]) throw AssertionError()
}
return "OK"
}