[FE] Substitute erased type parameters as covariant
This commit is contained in:
committed by
teamcity
parent
4293b546ba
commit
54f0794ce3
@@ -19,7 +19,6 @@ import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator.commonSuperType
|
||||
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||
import org.jetbrains.kotlin.types.AbstractTypeRefiner
|
||||
import org.jetbrains.kotlin.types.TypeCheckerState
|
||||
@@ -389,7 +388,21 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
||||
val typeParameterErasureMap = this.extractTypeParameters()
|
||||
.map { (it as ConeTypeParameterLookupTag).typeParameterSymbol }
|
||||
.eraseToUpperBoundsAssociated(session, intersectUpperBounds = true, eraseRecursively = true)
|
||||
return ConeSubstitutorByMap(typeParameterErasureMap, session).safeSubstitute(this)
|
||||
val substitutor by lazy { ConeSubstitutorByMap(typeParameterErasureMap, session) }
|
||||
val typeWithErasedTypeParameters = if (argumentsCount() != 0) {
|
||||
replaceArgumentsDeeply {
|
||||
val type = it.getType()
|
||||
val typeParameter =
|
||||
(type.typeConstructor().getTypeParameterClassifier() as? ConeTypeParameterLookupTag)?.typeParameterSymbol
|
||||
if (typeParameter != null) {
|
||||
createTypeArgument(substitutor.safeSubstitute(type), TypeVariance.OUT)
|
||||
} else it
|
||||
}
|
||||
} else if (typeConstructor().isTypeParameterTypeConstructor()) {
|
||||
substitutor.safeSubstitute(this)
|
||||
} else this
|
||||
|
||||
return typeWithErasedTypeParameters
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.isTypeParameterTypeConstructor(): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user