FIR: Add separate type constructor to stub types

This commit is contained in:
Simon Ogorodnik
2021-11-14 15:31:54 +03:00
committed by teamcity
parent 2e01377ce0
commit 196be93d42
9 changed files with 24 additions and 15 deletions
@@ -322,7 +322,11 @@ fun ConeIntersectionType.mapTypes(func: (ConeKotlinType) -> ConeKotlinType): Con
return ConeIntersectionType(intersectedTypes.map(func), alternativeType?.let(func))
}
sealed class ConeStubType(val variable: ConeTypeVariable, override val nullability: ConeNullability) : StubTypeMarker, ConeSimpleKotlinType() {
data class ConeStubTypeConstructor(val variable: ConeTypeVariable, val isTypeVariableInSubtyping: Boolean) : TypeConstructorMarker
sealed class ConeStubType(val constructor: ConeStubTypeConstructor, override val nullability: ConeNullability) : StubTypeMarker,
ConeSimpleKotlinType() {
override val typeArguments: Array<out ConeTypeProjection>
get() = emptyArray()
@@ -335,7 +339,7 @@ sealed class ConeStubType(val variable: ConeTypeVariable, override val nullabili
other as ConeStubType
if (variable != other.variable) return false
if (constructor != other.constructor) return false
if (nullability != other.nullability) return false
return true
@@ -343,14 +347,16 @@ sealed class ConeStubType(val variable: ConeTypeVariable, override val nullabili
override fun hashCode(): Int {
var result = 0
result = 31 * result + variable.hashCode()
result = 31 * result + constructor.hashCode()
result = 31 * result + nullability.hashCode()
return result
}
}
class ConeStubTypeForBuilderInference(variable: ConeTypeVariable, nullability: ConeNullability) : ConeStubType(variable, nullability)
class ConeStubTypeForTypeVariableInSubtyping(variable: ConeTypeVariable, nullability: ConeNullability) : ConeStubType(variable, nullability)
open class ConeStubTypeForBuilderInference(variable: ConeTypeVariable, nullability: ConeNullability) :
ConeStubType(ConeStubTypeConstructor(variable, isTypeVariableInSubtyping = false), nullability)
class ConeStubTypeForTypeVariableInSubtyping(variable: ConeTypeVariable, nullability: ConeNullability) :
ConeStubType(ConeStubTypeConstructor(variable, isTypeVariableInSubtyping = true), nullability)
open class ConeTypeVariable(name: String, originalTypeParameter: TypeParameterMarker? = null) : TypeVariableMarker {
val typeConstructor = ConeTypeVariableTypeConstructor(name, originalTypeParameter)
@@ -46,8 +46,8 @@ fun ConeKotlinType.render(): String {
postfix = ")"
)
}
is ConeStubTypeForBuilderInference -> "${renderAttributes()}Stub (builder inference): $variable"
is ConeStubType -> "${renderAttributes()}Stub (subtyping): $variable"
is ConeStubTypeForBuilderInference -> "${renderAttributes()}Stub (builder inference): ${constructor.variable}"
is ConeStubType -> "${renderAttributes()}Stub (subtyping): ${constructor.variable}"
is ConeIntegerLiteralType -> "${renderAttributes()}ILT: $value"
} + nullabilitySuffix
}