[FIR] Fix nullability of types produced by ConeRawScopeSubstitutor
#KT-66067 Fixed
This commit is contained in:
committed by
Space Team
parent
b6a6b12f0f
commit
5bca945d05
+2
-2
@@ -281,7 +281,7 @@ class ConeRawScopeSubstitutor(
|
||||
return when {
|
||||
type is ConeTypeParameterType -> {
|
||||
substituteOrSelf(
|
||||
listOf(type.lookupTag.symbol).getProjectionsForRawType(useSiteSession)[0] as ConeKotlinType
|
||||
listOf(type.lookupTag.symbol).getProjectionsForRawType(useSiteSession, makeNullable = type.isNullable)[0]
|
||||
)
|
||||
}
|
||||
type is ConeClassLikeType && type.typeArguments.isNotEmpty() -> {
|
||||
@@ -296,7 +296,7 @@ class ConeRawScopeSubstitutor(
|
||||
|
||||
val firClass = type.fullyExpandedType(useSiteSession).lookupTag.toFirRegularClassSymbol(useSiteSession) ?: return null
|
||||
ConeRawType.create(
|
||||
type.withArguments(firClass.typeParameterSymbols.getProjectionsForRawType(useSiteSession)),
|
||||
type.withArguments(firClass.typeParameterSymbols.getProjectionsForRawType(useSiteSession, makeNullable = type.isNullable)),
|
||||
type.replaceArgumentsWithStarProjections()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.fir.utils.exceptions.withConeTypeEntry
|
||||
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.applyIf
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.butIf
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
||||
@@ -688,12 +689,12 @@ fun List<FirTypeParameterSymbol>.eraseToUpperBoundsAssociated(
|
||||
}
|
||||
}
|
||||
|
||||
fun List<FirTypeParameterSymbol>.getProjectionsForRawType(session: FirSession): Array<ConeTypeProjection> {
|
||||
fun List<FirTypeParameterSymbol>.getProjectionsForRawType(session: FirSession, makeNullable: Boolean): Array<ConeKotlinType> {
|
||||
val cache = mutableMapOf<FirTypeParameter, ConeKotlinType>()
|
||||
return Array(size) { index ->
|
||||
this[index].fir.eraseToUpperBound(
|
||||
session, cache, mode = EraseUpperBoundMode.FOR_RAW_TYPE_ERASURE
|
||||
)
|
||||
).applyIf(makeNullable) { withNullability(ConeNullability.NULLABLE, session.typeContext) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user