FIR: store in ARGUMENT_TYPE_MISMATCH whether it's due to nullability

This commit is contained in:
Tianyu Geng
2021-04-30 20:48:09 +02:00
committed by Ilya Kirillov
parent cceb7197a5
commit 9106ae4f5f
9 changed files with 20 additions and 5 deletions
@@ -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
)
}
@@ -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(