FIR: instantiate type argument to captured type if needed

This commit is contained in:
Tianyu Geng
2021-07-21 14:11:19 -07:00
committed by TeamCityServer
parent bcf6582af7
commit cd99c35649
13 changed files with 32 additions and 36 deletions
@@ -53,14 +53,14 @@ open class TypeApproximatorConfiguration {
override val intersectionTypesInContravariantPositions: Boolean get() = true
}
abstract class AbstractCapturedTypesApproximation(val approximatedCapturedStatus: CaptureStatus) :
sealed class AbstractCapturedTypesApproximation(val approximatedCapturedStatus: CaptureStatus?) :
AllFlexibleSameValue() {
override val allFlexible: Boolean get() = true
override val errorType: Boolean get() = true
// i.e. will be approximated only approximatedCapturedStatus captured types
override fun capturedType(ctx: TypeSystemInferenceExtensionContext, type: CapturedTypeMarker): Boolean =
type.captureStatus(ctx) == approximatedCapturedStatus
approximatedCapturedStatus != null && type.captureStatus(ctx) == approximatedCapturedStatus
override val intersection: IntersectionStrategy get() = IntersectionStrategy.ALLOWED
override val typeVariable: (TypeVariableTypeConstructorMarker) -> Boolean get() = { true }
@@ -79,6 +79,11 @@ open class TypeApproximatorConfiguration {
override val intersectionTypesInContravariantPositions: Boolean get() = true
}
object TypeArgumentApproximation : AbstractCapturedTypesApproximation(null) {
override val integerLiteralType: Boolean get() = true
override val intersectionTypesInContravariantPositions: Boolean get() = true
}
object IntegerLiteralsTypesApproximation : AllFlexibleSameValue() {
override val integerLiteralType: Boolean get() = true
override val allFlexible: Boolean get() = true