FIR: Make constraint injector treat stub types as type variables
This commit is contained in:
committed by
teamcity
parent
19e2409284
commit
7b8ece8758
@@ -432,6 +432,12 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
||||
return this is ConeStubTypeForBuilderInference
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.unwrapStubTypeVariableConstructor(): TypeConstructorMarker {
|
||||
if (this !is ConeStubTypeConstructor) return this
|
||||
if (this.isTypeVariableInSubtyping) return this
|
||||
return this.variable.typeConstructor
|
||||
}
|
||||
|
||||
override fun intersectTypes(types: List<SimpleTypeMarker>): SimpleTypeMarker {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return ConeTypeIntersector.intersectTypes(this as ConeInferenceContext, types as List<ConeKotlinType>) as SimpleTypeMarker
|
||||
|
||||
@@ -47,6 +47,8 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
||||
|
||||
override fun SimpleTypeMarker.isStubTypeForBuilderInference() = false
|
||||
|
||||
override fun TypeConstructorMarker.unwrapStubTypeVariableConstructor(): TypeConstructorMarker = this
|
||||
|
||||
override fun FlexibleTypeMarker.asDynamicType() = this as? IrDynamicType
|
||||
|
||||
override fun FlexibleTypeMarker.asRawType(): RawTypeMarker? = null
|
||||
|
||||
+2
-2
@@ -293,7 +293,7 @@ class ConstraintInjector(
|
||||
|
||||
// from AbstractTypeCheckerContextForConstraintSystem
|
||||
override fun isMyTypeVariable(type: SimpleTypeMarker): Boolean =
|
||||
c.allTypeVariables.containsKey(type.typeConstructor())
|
||||
c.allTypeVariables.containsKey(type.typeConstructor().unwrapStubTypeVariableConstructor())
|
||||
|
||||
override fun addUpperConstraint(typeVariable: TypeConstructorMarker, superType: KotlinTypeMarker) =
|
||||
addConstraint(typeVariable, superType, UPPER)
|
||||
@@ -326,7 +326,7 @@ class ConstraintInjector(
|
||||
kind: ConstraintKind,
|
||||
isFromNullabilityConstraint: Boolean = false
|
||||
) {
|
||||
val typeVariable = c.allTypeVariables[typeVariableConstructor]
|
||||
val typeVariable = c.allTypeVariables[typeVariableConstructor.unwrapStubTypeVariableConstructor()]
|
||||
?: error("Should by type variableConstructor: $typeVariableConstructor. ${c.allTypeVariables.values}")
|
||||
|
||||
addNewIncorporatedConstraint(
|
||||
|
||||
@@ -358,6 +358,7 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
|
||||
fun SimpleTypeMarker.isStubType(): Boolean
|
||||
fun SimpleTypeMarker.isStubTypeForVariableInSubtyping(): Boolean
|
||||
fun SimpleTypeMarker.isStubTypeForBuilderInference(): Boolean
|
||||
fun TypeConstructorMarker.unwrapStubTypeVariableConstructor(): TypeConstructorMarker
|
||||
|
||||
fun KotlinTypeMarker.asTypeArgument(): TypeArgumentMarker
|
||||
|
||||
|
||||
@@ -100,6 +100,10 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
return this is StubTypeForBuilderInference || isDefNotNullStubType<StubTypeForBuilderInference>()
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.unwrapStubTypeVariableConstructor(): TypeConstructorMarker {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun StubTypeMarker.getOriginalTypeVariable(): TypeVariableTypeConstructorMarker {
|
||||
require(this is AbstractStubType, this::errorMessage)
|
||||
return this.originalTypeVariable as TypeVariableTypeConstructorMarker
|
||||
|
||||
Reference in New Issue
Block a user