Move requireOrDescribe to :core:compiler.common
This commit is contained in:
@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.types.model
|
||||
|
||||
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
interface KotlinTypeMarker
|
||||
interface TypeArgumentMarker
|
||||
@@ -363,3 +365,16 @@ inline fun TypeArgumentListMarker.all(
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun requireOrDescribe(condition: Boolean, value: Any?) {
|
||||
contract {
|
||||
returns() implies condition
|
||||
}
|
||||
require(condition) {
|
||||
val typeInfo = if (value != null) {
|
||||
", type = '${value::class}'"
|
||||
} else ""
|
||||
"Unexpected: value = '$value'$typeInfo"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,16 +711,3 @@ private inline fun Any.errorMessage(): String {
|
||||
private fun errorSupportedOnlyInTypeInference(): Nothing {
|
||||
error("supported only in type inference context")
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun requireOrDescribe(condition: Boolean, value: Any?) {
|
||||
contract {
|
||||
returns() implies condition
|
||||
}
|
||||
require(condition) {
|
||||
val typeInfo = if (value != null) {
|
||||
", type = '${value::class}'"
|
||||
} else ""
|
||||
"Unexpected: value = '$value'$typeInfo"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user