[AA] include inferred types in functional exp expected type

Fixed for K2 only, k1 remains as is

^KT-62466 fixed
This commit is contained in:
Anna Kozlova
2023-10-10 11:25:47 +02:00
committed by Space Team
parent c32e7c723d
commit 1f4d985b7b
8 changed files with 57 additions and 1 deletions
@@ -184,6 +184,12 @@ public class Fe10IdeNormalAnalysisSourceModuleExpectedExpressionTypeTestGenerate
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/functionPositionalParamQualified.kt");
}
@Test
@TestMetadata("functionalTypeSubstitution.kt")
public void testFunctionalTypeSubstitution() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/functionalTypeSubstitution.kt");
}
@Test
@TestMetadata("ifCondition.kt")
public void testIfCondition() throws Exception {
@@ -223,7 +223,10 @@ internal class KtFirExpressionTypeProvider(
val callee = (firCall.calleeReference as? FirResolvedNamedReference)?.resolvedSymbol
if (callee?.fir?.origin == FirDeclarationOrigin.SamConstructor) {
return (callee.fir as FirSimpleFunction).returnTypeRef.coneType.asKtType()
val substitutor = (firCall as? FirQualifiedAccessExpression)
?.createConeSubstitutorFromTypeArguments(discardErrorTypes = true)
?: ConeSubstitutor.Empty
return substitutor.substituteOrSelf((callee.fir as FirSimpleFunction).returnTypeRef.coneType).asKtType()
}
val argumentsToParameters = firCall.argumentsToSubstitutedValueParameters(substituteWithErrorTypes = false) ?: return null
@@ -184,6 +184,12 @@ public class FirIdeDependentAnalysisSourceModuleExpectedExpressionTypeTestGenera
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/functionPositionalParamQualified.kt");
}
@Test
@TestMetadata("functionalTypeSubstitution.kt")
public void testFunctionalTypeSubstitution() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/functionalTypeSubstitution.kt");
}
@Test
@TestMetadata("ifCondition.kt")
public void testIfCondition() throws Exception {
@@ -184,6 +184,12 @@ public class FirIdeNormalAnalysisSourceModuleExpectedExpressionTypeTestGenerated
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/functionPositionalParamQualified.kt");
}
@Test
@TestMetadata("functionalTypeSubstitution.kt")
public void testFunctionalTypeSubstitution() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/functionalTypeSubstitution.kt");
}
@Test
@TestMetadata("ifCondition.kt")
public void testIfCondition() throws Exception {
@@ -184,6 +184,12 @@ public class FirStandaloneNormalAnalysisSourceModuleExpectedExpressionTypeTestGe
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/functionPositionalParamQualified.kt");
}
@Test
@TestMetadata("functionalTypeSubstitution.kt")
public void testFunctionalTypeSubstitution() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/functionalTypeSubstitution.kt");
}
@Test
@TestMetadata("ifCondition.kt")
public void testIfCondition() throws Exception {
@@ -0,0 +1,11 @@
expression: {
s: String -> 0
}
expected type: KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtTypeParameterType:
annotationsList: []
type: T
]
type: java/lang/Comparable<T>
@@ -0,0 +1,7 @@
fun <K> test(f: java.lang.Comparable<K>) {}
fun f() {
test(java.lang.Comparable {<caret>
s: String -> 0
})
}
@@ -0,0 +1,11 @@
expression: {
s: String -> 0
}
expected type: KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtFlexibleType:
annotationsList: []
type: kotlin/String!
]
type: java/lang/Comparable<kotlin/String!>