[FIR] Display actual type for argument type mismatch error

Previously the argument type was being used for the actual type error
display. However, safe-call arguments are unwrapped which causes
nullable types to be displayed as non-null. Change to use the actual
type provided by the diagnostic instead of extracting the type from
the argument.

#KT-58844 Fixed
This commit is contained in:
Brian Norman
2023-06-15 08:25:22 -05:00
committed by Space Team
parent a7ff0cfc9d
commit 269dfc61c8
10 changed files with 57 additions and 3 deletions
@@ -22744,6 +22744,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/nullableTypes/inferenceFlexibleTToNullable.kt");
}
@Test
@TestMetadata("kt58844.kt")
public void testKt58844() throws Exception {
runTest("compiler/testData/diagnostics/tests/nullableTypes/kt58844.kt");
}
@Test
@TestMetadata("nullAssertOnTypeWithNullableUpperBound.kt")
public void testNullAssertOnTypeWithNullableUpperBound() throws Exception {
@@ -22750,6 +22750,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/nullableTypes/inferenceFlexibleTToNullable.kt");
}
@Test
@TestMetadata("kt58844.kt")
public void testKt58844() throws Exception {
runTest("compiler/testData/diagnostics/tests/nullableTypes/kt58844.kt");
}
@Test
@TestMetadata("nullAssertOnTypeWithNullableUpperBound.kt")
public void testNullAssertOnTypeWithNullableUpperBound() throws Exception {
@@ -223,7 +223,7 @@ private fun mapInapplicableCandidateError(
FirErrors.ARGUMENT_TYPE_MISMATCH.createOn(
rootCause.argument.source ?: source,
rootCause.expectedType.removeTypeVariableTypes(typeContext),
rootCause.argument.typeRef.coneType.removeTypeVariableTypes(typeContext),
rootCause.actualType.removeTypeVariableTypes(typeContext),
rootCause.isMismatchDueToNullability
)
}