[FIR] Fix processing calls on unstable smartcasts with check not null call
This commit is contained in:
committed by
TeamCityServer
parent
1a3841d66d
commit
7d8a8d543f
+11
-6
@@ -126,9 +126,14 @@ object CheckDispatchReceiver : ResolutionStage() {
|
||||
val isCandidateFromUnstableSmartcast =
|
||||
(candidate.originScope as? FirUnstableSmartcastTypeScope)?.isSymbolFromUnstableSmartcast(candidate.symbol) == true
|
||||
|
||||
if (explicitReceiverExpression is FirExpressionWithSmartcast &&
|
||||
!explicitReceiverExpression.isStable &&
|
||||
(isCandidateFromUnstableSmartcast || (isReceiverNullable && !explicitReceiverExpression.smartcastType.canBeNull))
|
||||
val smartcastedReceiver = when (explicitReceiverExpression) {
|
||||
is FirCheckNotNullCall -> explicitReceiverExpression.argument
|
||||
else -> explicitReceiverExpression
|
||||
} as? FirExpressionWithSmartcast
|
||||
|
||||
if (smartcastedReceiver != null &&
|
||||
!smartcastedReceiver.isStable &&
|
||||
(isCandidateFromUnstableSmartcast || (isReceiverNullable && !smartcastedReceiver.smartcastType.canBeNull))
|
||||
) {
|
||||
val dispatchReceiverType = (candidate.symbol as? FirCallableSymbol<*>)?.dispatchReceiverType?.let {
|
||||
context.session.typeApproximator.approximateToSuperType(
|
||||
@@ -137,12 +142,12 @@ object CheckDispatchReceiver : ResolutionStage() {
|
||||
) ?: it
|
||||
}
|
||||
val targetType =
|
||||
dispatchReceiverType ?: explicitReceiverExpression.smartcastType.coneType
|
||||
dispatchReceiverType ?: smartcastedReceiver.smartcastType.coneType
|
||||
sink.yieldDiagnostic(
|
||||
UnstableSmartCast(
|
||||
explicitReceiverExpression,
|
||||
smartcastedReceiver,
|
||||
targetType,
|
||||
context.session.typeContext.isTypeMismatchDueToNullability(explicitReceiverExpression.originalType.coneType, targetType)
|
||||
context.session.typeContext.isTypeMismatchDueToNullability(smartcastedReceiver.originalType.coneType, targetType)
|
||||
)
|
||||
)
|
||||
} else if (isReceiverNullable) {
|
||||
|
||||
Reference in New Issue
Block a user