Simplify implementation of TypeSystemCommonSuperTypesContext.typeDepth
This commit is contained in:
+2
-16
@@ -91,7 +91,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext,
|
||||
|| this is ConeTypeParameterType
|
||||
}
|
||||
|
||||
fun ConeKotlinType.typeDepthSimple(): Int {
|
||||
override fun SimpleTypeMarker.typeDepth(): Int {
|
||||
require(this is ConeKotlinType)
|
||||
// if (this is TypeUtils.SpecialType) return 0 // TODO: WTF?
|
||||
|
||||
val maxInArguments = this.typeArguments.asSequence().map {
|
||||
@@ -101,21 +102,6 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext,
|
||||
return maxInArguments + 1
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.typeDepth(): Int {
|
||||
require(this is ConeKotlinType)
|
||||
return this.typeDepthSimple()
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.typeDepth(): Int {
|
||||
require(this is ConeKotlinType) {
|
||||
"Incorrect type of class ${this::class.java}: $this"
|
||||
}
|
||||
return when (this) {
|
||||
is ConeFlexibleType -> Math.max(lowerBound.typeDepthSimple(), upperBound.typeDepthSimple())
|
||||
else -> typeDepthSimple()
|
||||
}
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.contains(predicate: (KotlinTypeMarker) -> Boolean): Boolean {
|
||||
return this.containsInternal(predicate)
|
||||
}
|
||||
|
||||
@@ -217,8 +217,6 @@ interface IrTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
|
||||
override fun SimpleTypeMarker.typeDepth() = 2
|
||||
|
||||
override fun KotlinTypeMarker.typeDepth() = if (this is IrStarProjection) 1 else 0
|
||||
|
||||
override fun findCommonIntegerLiteralTypesSuperType(explicitSupertypes: List<SimpleTypeMarker>): SimpleTypeMarker? =
|
||||
irBuiltIns.intType as IrSimpleType
|
||||
|
||||
|
||||
Reference in New Issue
Block a user