FIR: store in ARGUMENT_TYPE_MISMATCH whether it's due to nullability
This commit is contained in:
committed by
Ilya Kirillov
parent
cceb7197a5
commit
9106ae4f5f
@@ -375,10 +375,18 @@ private fun checkApplicabilityForArgumentType(
|
||||
return type
|
||||
}
|
||||
|
||||
// Reaching here means argument types mismatch, and we want to record whether it's due to the nullability by checking a subtype
|
||||
// relation with nullable expected type.
|
||||
val isMismatchDueToNullability = AbstractTypeChecker.isSubtypeOf(
|
||||
context.session.typeContext,
|
||||
argumentType,
|
||||
actualExpectedType.withNullability(ConeNullability.NULLABLE, context.session.typeContext)
|
||||
)
|
||||
return ArgumentTypeMismatch(
|
||||
tryGetConeTypeThatCompatibleWithKtType(actualExpectedType),
|
||||
tryGetConeTypeThatCompatibleWithKtType(argumentType),
|
||||
argument
|
||||
argument,
|
||||
isMismatchDueToNullability
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -93,7 +93,8 @@ sealed class UnstableSmartCast(
|
||||
class ArgumentTypeMismatch(
|
||||
val expectedType: ConeKotlinType,
|
||||
val actualType: ConeKotlinType,
|
||||
val argument: FirExpression
|
||||
val argument: FirExpression,
|
||||
val isMismatchDueToNullability: Boolean,
|
||||
) : ResolutionDiagnostic(INAPPLICABLE)
|
||||
|
||||
class NullForNotNullType(
|
||||
|
||||
Reference in New Issue
Block a user