AA: expected type for expression passed to vararg

This commit is contained in:
Jinseong Jeon
2022-12-14 15:58:10 -08:00
committed by Yan Zhulanow
parent 4f8dad3e4b
commit 4beb55179b
12 changed files with 114 additions and 3 deletions
@@ -167,7 +167,11 @@ internal class KtFirExpressionTypeProvider(
arg.psi == argumentExpression
}
}?.value ?: return null
return firParameterForExpression.returnTypeRef.coneType.asKtType()
val coneType = firParameterForExpression.returnTypeRef.coneType
return if (firParameterForExpression.isVararg)
coneType.varargElementType().asKtType()
else
coneType.asKtType()
}
private fun PsiElement.getFunctionCallAsWithThisAsParameter(): KtCallWithArgument? {
@@ -232,6 +232,24 @@ public class FirIdeDependentAnalysisSourceModuleExpectedExpressionTypeTestGenera
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samAsReturn.kt");
}
@Test
@TestMetadata("samReferenceAsArgument.kt")
public void testSamReferenceAsArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samReferenceAsArgument.kt");
}
@Test
@TestMetadata("samReferenceAsVararg.kt")
public void testSamReferenceAsVararg() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samReferenceAsVararg.kt");
}
@Test
@TestMetadata("samReferenceWithTypeCast.kt")
public void testSamReferenceWithTypeCast() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samReferenceWithTypeCast.kt");
}
@Test
@TestMetadata("samWithExplicitTypeFromProperty.kt")
public void testSamWithExplicitTypeFromProperty() throws Exception {
@@ -232,6 +232,24 @@ public class FirIdeNormalAnalysisSourceModuleExpectedExpressionTypeTestGenerated
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samAsReturn.kt");
}
@Test
@TestMetadata("samReferenceAsArgument.kt")
public void testSamReferenceAsArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samReferenceAsArgument.kt");
}
@Test
@TestMetadata("samReferenceAsVararg.kt")
public void testSamReferenceAsVararg() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samReferenceAsVararg.kt");
}
@Test
@TestMetadata("samReferenceWithTypeCast.kt")
public void testSamReferenceWithTypeCast() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samReferenceWithTypeCast.kt");
}
@Test
@TestMetadata("samWithExplicitTypeFromProperty.kt")
public void testSamWithExplicitTypeFromProperty() throws Exception {