AA: fix expected type for lambda with explicit label

This commit is contained in:
Jinseong Jeon
2022-10-13 22:51:33 -07:00
committed by Ilya Kirillov
parent b29309478e
commit 14213ddad2
10 changed files with 67 additions and 3 deletions
@@ -161,7 +161,12 @@ class KtFe10ExpressionTypeProvider(
override fun getExpectedType(expression: PsiElement): KtType? {
val ktExpression = expression.getParentOfType<KtExpression>(false) ?: return null
val parentExpression = ktExpression.parent
val parentExpression = if (ktExpression.parent is KtLabeledExpression) {
// lambda -> labeled expression -> lambda argument (value argument)
ktExpression.parent.parent
} else {
ktExpression.parent
}
// Unwrap specific expressions
when (ktExpression) {
@@ -238,6 +238,18 @@ public class Fe10IdeNormalAnalysisSourceModuleExpectedExpressionTypeTestGenerate
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samWithExplicitTypeFromProperty.kt");
}
@Test
@TestMetadata("samWithReturnToExplicitLabel.kt")
public void testSamWithReturnToExplicitLabel() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samWithReturnToExplicitLabel.kt");
}
@Test
@TestMetadata("samWithReturnToImplicitLabel.kt")
public void testSamWithReturnToImplicitLabel() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expectedExpressionType/samWithReturnToImplicitLabel.kt");
}
@Test
@TestMetadata("samWithTypeCast.kt")
public void testSamWithTypeCast() throws Exception {