TypeSystemContext: Rework raw types processing

All the current usages are about checking if the type is raw,
also in K2 it is simply incorrect to assume that only flexible types
might be raw
This commit is contained in:
Denis.Zharkov
2023-02-21 16:50:29 +01:00
committed by Space Team
parent b6e59fe8fd
commit eb09a25239
7 changed files with 10 additions and 12 deletions
@@ -113,9 +113,9 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
return this as? ConeDynamicType
}
override fun FlexibleTypeMarker.asRawType(): RawTypeMarker? {
require(this is ConeFlexibleType)
return this as? ConeRawType
override fun KotlinTypeMarker.isRawType(): Boolean {
require(this is ConeKotlinType)
return this.isRaw()
}
override fun FlexibleTypeMarker.upperBound(): SimpleTypeMarker {
@@ -54,7 +54,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
override fun FlexibleTypeMarker.asDynamicType() = this as? IrDynamicType
override fun FlexibleTypeMarker.asRawType(): RawTypeMarker? = null
override fun KotlinTypeMarker.isRawType(): Boolean = false
override fun FlexibleTypeMarker.upperBound(): SimpleTypeMarker {
return when (this) {
@@ -118,7 +118,7 @@ abstract class AbstractTypeApproximator(
is FlexibleTypeMarker -> {
if (type.isDynamic()) {
return if (conf.dynamic) null else type.bound()
} else if (type.asRawType() != null) {
} else if (type.isRawType()) {
return if (conf.rawType) null else type.bound()
}
@@ -204,7 +204,7 @@ abstract class AbstractSignatureParts<TAnnotation : Any> {
private fun KotlinTypeMarker.toIndexed(): List<TypeAndDefaultQualifiers> = with(typeSystem) {
TypeAndDefaultQualifiers(this@toIndexed, extractAndMergeDefaultQualifiers(containerDefaultTypeQualifiers), null).flattenTree {
// Enhancement of raw type arguments may enter a loop in FE1.0.
if (skipRawTypeArguments && it.type?.asFlexibleType()?.asRawType() != null) return@flattenTree null
if (skipRawTypeArguments && it.type?.isRawType() == true) return@flattenTree null
it.type?.typeConstructor()?.getParameters()?.zip(it.type.getArguments()) { parameter, arg ->
if (arg.isStarProjection()) {
@@ -62,8 +62,6 @@ interface TypeSystemCommonBackendContextForTypeMapping : TypeSystemCommonBackend
fun SimpleTypeMarker.isSuspendFunction(): Boolean
fun SimpleTypeMarker.isKClass(): Boolean
fun KotlinTypeMarker.isRawType(): Boolean
fun TypeConstructorMarker.typeWithArguments(arguments: List<KotlinTypeMarker>): SimpleTypeMarker
fun TypeConstructorMarker.typeWithArguments(vararg arguments: KotlinTypeMarker): SimpleTypeMarker {
return typeWithArguments(arguments.toList())
@@ -356,7 +356,7 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
fun KotlinTypeMarker.isUninferredParameter(): Boolean
fun FlexibleTypeMarker.asDynamicType(): DynamicTypeMarker?
fun FlexibleTypeMarker.asRawType(): RawTypeMarker?
fun KotlinTypeMarker.isRawType(): Boolean
fun FlexibleTypeMarker.upperBound(): SimpleTypeMarker
fun FlexibleTypeMarker.lowerBound(): SimpleTypeMarker
@@ -153,9 +153,9 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
return this as? DynamicType
}
override fun FlexibleTypeMarker.asRawType(): RawTypeMarker? {
require(this is FlexibleType, this::errorMessage)
return this as? RawType
override fun KotlinTypeMarker.isRawType(): Boolean {
require(this is KotlinType, this::errorMessage)
return this is RawType
}
override fun FlexibleTypeMarker.upperBound(): SimpleTypeMarker {