AA FIR: handle smartcasted arg when building call's argument mapping

^KTIJ-25112 Fixed
This commit is contained in:
Jinseong Jeon
2023-04-06 23:52:28 -07:00
committed by Ilya Kirillov
parent 86540bdbb4
commit fbe558a0de
8 changed files with 112 additions and 0 deletions
@@ -1272,9 +1272,11 @@ internal class KtFirCallResolver(
}
private fun FirExpression.findSourceKtExpressionForCallArgument(): KtExpression? {
// For smart-casted expression, refer to the source of the original expression
// For spread, named, and lambda arguments, the source is the KtValueArgument.
// For other arguments (including array indices), the source is the KtExpression.
return when (this) {
is FirSmartCastExpression -> originalExpression.realPsi as? KtExpression
is FirNamedArgumentExpression, is FirSpreadArgumentExpression, is FirLambdaArgumentExpression ->
realPsi.safeAs<KtValueArgument>()?.getArgumentExpression()
else -> realPsi as? KtExpression
@@ -784,6 +784,18 @@ public class FirIdeNormalAnalysisSourceModuleResolveCallTestGenerated extends Ab
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/smartCastImplicitExtensionReceiver.kt");
}
@Test
@TestMetadata("smartCastedArg.kt")
public void testSmartCastedArg() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/smartCastedArg.kt");
}
@Test
@TestMetadata("smartCastedNonNullArg.kt")
public void testSmartCastedNonNullArg() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/smartCastedNonNullArg.kt");
}
@Test
@TestMetadata("substituteOverrideResolution.kt")
public void testSubstituteOverrideResolution() throws Exception {