FIR: Replace fir.bounds with resolvedBounds where it is appropriate

If there is a `coneType` call immediately after the `fir.bounds` call,
it means that the fully resolved type is expected, hence
`resolvedBounds` should be used
This commit is contained in:
Roman Golyshev
2022-01-12 15:12:19 +03:00
committed by teamcity
parent 939e4d1e77
commit 4418d76a0d
17 changed files with 25 additions and 25 deletions
@@ -136,7 +136,7 @@ private fun ConeTypeParameterLookupTag.findClassRepresentationThatIsSubtypeOf(
supertype: ConeKotlinType,
session: FirSession
): ConeClassLikeLookupTag? =
typeParameterSymbol.fir.bounds.map { it.coneType }.findClassRepresentationThatIsSubtypeOf(supertype, session)
typeParameterSymbol.resolvedBounds.map { it.coneType }.findClassRepresentationThatIsSubtypeOf(supertype, session)
private fun Collection<ConeKotlinType>.findClassRepresentationThatIsSubtypeOf(
supertype: ConeKotlinType,
@@ -74,7 +74,7 @@ private fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: Scope
scopeSession.getOrBuild(symbol, TYPE_PARAMETER_SCOPE_KEY) {
val intersectionType = ConeTypeIntersector.intersectTypes(
useSiteSession.typeContext,
symbol.fir.bounds.map { it.coneType }
symbol.resolvedBounds.map { it.coneType }
)
intersectionType.scope(useSiteSession, scopeSession, requiredPhase) ?: FirTypeScope.Empty
}
@@ -170,7 +170,7 @@ fun createSubstitution(
else /* StarProjection */ -> {
ConeTypeIntersector.intersectTypes(
session.typeContext,
typeParameterSymbol.fir.bounds.map { it.coneType }
typeParameterSymbol.resolvedBounds.map { it.coneType }
)
}
}
@@ -503,7 +503,7 @@ object FirFakeOverrideGenerator {
var wereChangesInTypeParameters = forceTypeParametersRecreation
for ((newTypeParameter, oldTypeParameter) in newTypeParameters.zip(member.typeParameters)) {
val original = oldTypeParameter.symbol.fir
for (boundTypeRef in original.bounds) {
for (boundTypeRef in original.symbol.resolvedBounds) {
val typeForBound = boundTypeRef.coneType
val substitutedBound = substitutor.substituteOrNull(typeForBound)
if (substitutedBound != null) {
@@ -82,8 +82,8 @@ class FirStandardOverrideChecker(private val session: FirSession) : FirAbstractO
if (isEqualTypes(substitutedOverrideType, substitutedBaseType)) return true
return overrideTypeParameter.bounds.any { bound -> isEqualTypes(bound.coneType, substitutedBaseType, substitutor) } &&
baseTypeParameter.bounds.any { bound -> isEqualTypes(bound.coneType, substitutedOverrideType, substitutor) }
return overrideTypeParameter.symbol.resolvedBounds.any { bound -> isEqualTypes(bound.coneType, substitutedBaseType, substitutor) } &&
baseTypeParameter.symbol.resolvedBounds.any { bound -> isEqualTypes(bound.coneType, substitutedOverrideType, substitutor) }
}
private fun isCompatibleTypeParameters(
@@ -94,7 +94,7 @@ class FirStandardOverrideChecker(private val session: FirSession) : FirAbstractO
if (overrideCandidate.symbol == baseDeclaration.symbol) return true
if (overrideCandidate !is FirTypeParameter || baseDeclaration !is FirTypeParameter) return false
if (overrideCandidate.bounds.size != baseDeclaration.bounds.size) return false
return overrideCandidate.bounds.zip(baseDeclaration.bounds)
return overrideCandidate.symbol.resolvedBounds.zip(baseDeclaration.symbol.resolvedBounds)
.all { (aBound, bBound) -> isEqualBound(aBound, bBound, overrideCandidate, baseDeclaration, substitutor) }
}
@@ -140,7 +140,7 @@ fun ConeKotlinType.findSubtypeOfNonSuspendFunctionalType(session: FirSession, ex
intersectedTypes.find { it.findSubtypeOfNonSuspendFunctionalType(session, expectedFunctionalType) != null }
}
is ConeTypeParameterType -> {
val bounds = lookupTag.typeParameterSymbol.fir.bounds.map { it.coneType }
val bounds = lookupTag.typeParameterSymbol.resolvedBounds.map { it.coneType }
if (bounds.any { it.isSuspendFunctionType(session) })
null
else