FIR: Implement captured type substitution
This commit is contained in:
committed by
teamcity
parent
476a7727da
commit
61ea65906c
+19
-1
@@ -61,7 +61,7 @@ abstract class AbstractConeSubstitutor(private val typeContext: ConeTypeContext)
|
||||
if (it.lowerBound == it.upperBound) it.lowerBound
|
||||
else it
|
||||
}
|
||||
is ConeCapturedType -> return null
|
||||
is ConeCapturedType -> return substituteCapturedType()
|
||||
is ConeDefinitelyNotNullType -> this.substituteOriginal()
|
||||
is ConeIntersectionType -> this.substituteIntersectedTypes()
|
||||
is ConeStubType -> return null
|
||||
@@ -69,6 +69,24 @@ abstract class AbstractConeSubstitutor(private val typeContext: ConeTypeContext)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ConeCapturedType.substituteCapturedType(): ConeCapturedType? {
|
||||
val innerType = this.lowerType ?: this.constructor.projection.type
|
||||
val substitutedInnerType = substituteOrNull(innerType) ?: return null
|
||||
if (substitutedInnerType is ConeCapturedType) return substitutedInnerType
|
||||
val substitutedSuperTypes =
|
||||
this.constructor.supertypes?.map { substituteOrSelf(it) }
|
||||
|
||||
return ConeCapturedType(
|
||||
captureStatus,
|
||||
constructor = ConeCapturedTypeConstructor(
|
||||
wrapProjection(constructor.projection, substitutedInnerType),
|
||||
substitutedSuperTypes,
|
||||
typeParameterMarker = constructor.typeParameterMarker
|
||||
),
|
||||
lowerType = if (lowerType != null) substitutedInnerType else null
|
||||
)
|
||||
}
|
||||
|
||||
private fun ConeIntersectionType.substituteIntersectedTypes(): ConeIntersectionType? {
|
||||
val substitutedTypes = ArrayList<ConeKotlinType>(intersectedTypes.size)
|
||||
var somethingIsSubstituted = false
|
||||
|
||||
Reference in New Issue
Block a user