Initial OverloadingConflictResolver abstraction from KotlinTypes
This commit is contained in:
@@ -21,6 +21,8 @@ import org.jetbrains.kotlin.types.model.CaptureStatus
|
||||
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
import kotlin.math.max
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
override fun TypeConstructorMarker.isDenotable(): Boolean {
|
||||
@@ -463,6 +465,11 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
require(this is IntegerLiteralTypeConstructor, this::errorMessage)
|
||||
return this.getApproximatedType().unwrap()
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.isPrimitiveType(): Boolean {
|
||||
require(this is KotlinType, this::errorMessage)
|
||||
return KotlinBuiltIns.isPrimitiveType(this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasNoInferInternal(type: UnwrappedType): Boolean {
|
||||
@@ -520,3 +527,18 @@ fun Variance.convertVariance(): TypeVariance {
|
||||
Variance.OUT_VARIANCE -> TypeVariance.OUT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
|
||||
@UseExperimental(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"
|
||||
}
|
||||
}
|
||||
@@ -199,6 +199,8 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
|
||||
fun KotlinTypeMarker.lowerBoundIfFlexible(): SimpleTypeMarker = this.asFlexibleType()?.lowerBound() ?: this.asSimpleType()!!
|
||||
fun KotlinTypeMarker.upperBoundIfFlexible(): SimpleTypeMarker = this.asFlexibleType()?.upperBound() ?: this.asSimpleType()!!
|
||||
|
||||
fun KotlinTypeMarker.isFlexible(): Boolean = asFlexibleType() != null
|
||||
|
||||
fun KotlinTypeMarker.isDynamic(): Boolean = asFlexibleType()?.asDynamicType() != null
|
||||
fun KotlinTypeMarker.isDefinitelyNotNullType(): Boolean = asSimpleType()?.asDefinitelyNotNullType() != null
|
||||
|
||||
@@ -261,6 +263,8 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
|
||||
fun KotlinTypeMarker.isSimpleType() = asSimpleType() != null
|
||||
|
||||
fun prepareType(type: KotlinTypeMarker): KotlinTypeMarker
|
||||
|
||||
fun SimpleTypeMarker.isPrimitiveType(): Boolean
|
||||
}
|
||||
|
||||
enum class CaptureStatus {
|
||||
|
||||
Reference in New Issue
Block a user