FIR checker: make SMARTCAST_IMPOSSIBLE report the desired type at receiver position
Previously the smartcast type is reported. This is undesirable because usually this type is an intersection and hence not denotable.
This commit is contained in:
committed by
teamcityserver
parent
951812f130
commit
5b0ca06e95
@@ -122,14 +122,13 @@ object CheckDispatchReceiver : ResolutionStage() {
|
||||
!explicitReceiverExpression.isStable &&
|
||||
(isCandidateFromUnstableSmartcast || (isReceiverNullable && !explicitReceiverExpression.smartcastType.canBeNull))
|
||||
) {
|
||||
val targetType =
|
||||
(candidate.symbol as? FirCallableSymbol<*>)?.dispatchReceiverType ?: explicitReceiverExpression.smartcastType.coneType
|
||||
sink.yieldDiagnostic(
|
||||
UnstableSmartCast(
|
||||
explicitReceiverExpression,
|
||||
explicitReceiverExpression.smartcastType.coneType,
|
||||
context.session.typeContext.isTypeMismatchDueToNullability(
|
||||
explicitReceiverExpression.originalType.coneType,
|
||||
explicitReceiverExpression.smartcastType.coneType
|
||||
)
|
||||
targetType,
|
||||
context.session.typeContext.isTypeMismatchDueToNullability(explicitReceiverExpression.originalType.coneType, targetType)
|
||||
)
|
||||
)
|
||||
} else if (isReceiverNullable) {
|
||||
|
||||
Reference in New Issue
Block a user