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
@@ -127,7 +127,7 @@ fun ConeKotlinType.findClassRepresentation(
is ConeTypeParameterType -> lookupTag.findClassRepresentationThatIsSubtypeOf(dispatchReceiverParameterType, session)
is ConeTypeVariableType -> (this.lookupTag.originalTypeParameter as? ConeTypeParameterLookupTag)
?.findClassRepresentationThatIsSubtypeOf(dispatchReceiverParameterType, session)
is ConeStubType -> (this.variable.typeConstructor.originalTypeParameter as? ConeTypeParameterLookupTag)
is ConeStubType -> (this.constructor.variable.typeConstructor.originalTypeParameter as? ConeTypeParameterLookupTag)
?.findClassRepresentationThatIsSubtypeOf(dispatchReceiverParameterType, session)
is ConeLookupTagBasedType -> null
}
@@ -131,7 +131,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
override fun StubTypeMarker.getOriginalTypeVariable(): TypeVariableTypeConstructorMarker {
require(this is ConeStubType)
return this.variable.typeConstructor
return this.constructor.variable.typeConstructor
}
override fun KotlinTypeMarker.typeDepth() = when (this) {
@@ -144,7 +144,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
is ConeCapturedType -> constructor
is ConeTypeVariableType -> lookupTag
is ConeIntersectionType -> this
is ConeStubType -> variable.typeConstructor
is ConeStubType -> constructor
is ConeDefinitelyNotNullType -> original.typeConstructor()
is ConeIntegerLiteralType -> this
else -> error("?: $this")
@@ -244,6 +244,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
}
}
is ConeIntegerLiteralType -> 0
is ConeStubTypeConstructor -> 0
else -> unknownConstructorError()
}
}
@@ -271,6 +272,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
override fun TypeConstructorMarker.supertypes(): Collection<ConeKotlinType> {
if (this is ErrorTypeConstructor) return emptyList()
return when (this) {
is ConeStubTypeConstructor -> emptyList()
is ConeTypeVariableTypeConstructor -> emptyList()
is ConeTypeParameterLookupTag -> symbol.fir.bounds.map { it.coneType }
is ConeClassLikeLookupTag -> {
@@ -342,6 +344,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
is ConeClassLikeLookupTag,
is ConeTypeParameterLookupTag -> true
is ConeStubTypeConstructor,
is ConeCapturedTypeConstructor,
is ErrorTypeConstructor,
is ConeTypeVariableTypeConstructor,
@@ -165,8 +165,8 @@ fun <T : ConeKotlinType> T.withNullability(
ConeNullability.UNKNOWN -> this // TODO: is that correct?
ConeNullability.NOT_NULL -> this
}
is ConeStubTypeForBuilderInference -> ConeStubTypeForBuilderInference(variable, nullability)
is ConeStubTypeForTypeVariableInSubtyping -> ConeStubTypeForTypeVariableInSubtyping(variable, nullability)
is ConeStubTypeForBuilderInference -> ConeStubTypeForBuilderInference(constructor.variable, nullability)
is ConeStubTypeForTypeVariableInSubtyping -> ConeStubTypeForTypeVariableInSubtyping(constructor.variable, nullability)
is ConeDefinitelyNotNullType -> when (nullability) {
ConeNullability.NOT_NULL -> this
ConeNullability.NULLABLE -> original.withNullability(nullability, typeContext)