Files
kotlin-fork/compiler/testData/ir/interpreter/helpers/Standard.kt
T
Ilya Gorbunov 7ab2f1493c Add error() function to interpreter test helper sources
To compile standard library code that uses error()
2022-06-28 00:08:07 +00:00

46 lines
988 B
Kotlin
Vendored

package kotlin
import kotlin.*
public inline fun <R> run(block: () -> R): R {
return block()
}
public inline fun <T, R> T.run(block: T.() -> R): R {
return block()
}
public inline fun <T, R> with(receiver: T, block: T.() -> R): R {
return receiver.block()
}
public inline fun <T> T.apply(block: T.() -> Unit): T {
block()
return this
}
public inline fun <T> T.also(block: (T) -> Unit): T {
block(this)
return this
}
public inline fun <T, R> T.let(block: (T) -> R): R {
return block(this)
}
public inline fun <T> T.takeIf(predicate: (T) -> Boolean): T? {
return if (predicate(this)) this else null
}
public inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? {
return if (!predicate(this)) this else null
}
public inline fun repeat(times: Int, action: (Int) -> Unit) {
for (index in 0 until times) {
action(index)
}
}
public inline fun error(message: Any): Nothing = throw IllegalStateException(message.toString())