[FIR] Distinguish stub types for builder inference and for subtyping

^KT-48110 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-08-23 16:29:52 +03:00
parent 7e6e0a3dd6
commit 0924216ed2
25 changed files with 85 additions and 848 deletions
@@ -67,7 +67,7 @@ class FirBuilderInferenceSession(
private fun ConeKotlinType.containsStubType(): Boolean {
return this.contains {
it is ConeStubType
it is ConeStubTypeForBuilderInference
}
}
@@ -262,12 +262,13 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
override fun createStubTypeForBuilderInference(typeVariable: TypeVariableMarker): StubTypeMarker {
require(typeVariable is ConeTypeVariable) { "$typeVariable should subtype of ${ConeTypeVariable::class.qualifiedName}" }
return ConeStubType(typeVariable, ConeNullability.create(typeVariable.defaultType().isMarkedNullable()))
return ConeStubTypeForBuilderInference(typeVariable, ConeNullability.create(typeVariable.defaultType().isMarkedNullable()))
}
// TODO
override fun createStubTypeForTypeVariablesInSubtyping(typeVariable: TypeVariableMarker) =
createStubTypeForBuilderInference(typeVariable)
override fun createStubTypeForTypeVariablesInSubtyping(typeVariable: TypeVariableMarker): StubTypeMarker{
require(typeVariable is ConeTypeVariable) { "$typeVariable should subtype of ${ConeTypeVariable::class.qualifiedName}" }
return ConeStubTypeForTypeVariableInSubtyping(typeVariable, ConeNullability.create(typeVariable.defaultType().isMarkedNullable()))
}
override fun KotlinTypeMarker.removeAnnotations(): KotlinTypeMarker {
require(this is ConeKotlinType)
@@ -406,15 +406,15 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
}
override fun SimpleTypeMarker.isStubType(): Boolean {
return this is ConeStubType // TODO: distinguish stub types for builder inference and for subtyping
return this is ConeStubType
}
override fun SimpleTypeMarker.isStubTypeForVariableInSubtyping(): Boolean {
return this is ConeStubType // TODO: distinguish stub types for builder inference and for subtyping
return this is ConeStubTypeForTypeVariableInSubtyping
}
override fun SimpleTypeMarker.isStubTypeForBuilderInference(): Boolean {
return this is ConeStubType // TODO: distinguish stub types for builder inference and for subtyping
return this is ConeStubTypeForBuilderInference
}
override fun intersectTypes(types: List<SimpleTypeMarker>): SimpleTypeMarker {
@@ -156,7 +156,8 @@ fun <T : ConeKotlinType> T.withNullability(
ConeNullability.UNKNOWN -> this // TODO: is that correct?
ConeNullability.NOT_NULL -> this
}
is ConeStubType -> ConeStubType(variable, nullability)
is ConeStubTypeForBuilderInference -> ConeStubTypeForBuilderInference(variable, nullability)
is ConeStubTypeForTypeVariableInSubtyping -> ConeStubTypeForTypeVariableInSubtyping(variable, nullability)
is ConeDefinitelyNotNullType -> when (nullability) {
ConeNullability.NOT_NULL -> this
ConeNullability.NULLABLE -> original.withNullability(nullability, typeContext)