[FIR] Remove FirLambdaArgumentExpression
It's not really necessary if the information about if the lambda was a trailing lambda can be directly saved in FirAnonymousFunctionExpression. Removing the FIR node uncovered a couple of bugs (UNINITIALIZED_ENUM_ENTRY, ERROR_IN_CONTRACT_DESCRIPTION) that were caused by assuming that a lambda is always a trailing lambda. #KT-66124
This commit is contained in:
committed by
Space Team
parent
1a5fa8d3f6
commit
03fc0fd381
+3
-1
@@ -1350,8 +1350,10 @@ internal class KtFirCallResolver(
|
||||
expression.realPsi as? KtExpression
|
||||
is FirSmartCastExpression ->
|
||||
originalExpression.realPsi as? KtExpression
|
||||
is FirNamedArgumentExpression, is FirSpreadArgumentExpression, is FirLambdaArgumentExpression ->
|
||||
is FirNamedArgumentExpression, is FirSpreadArgumentExpression ->
|
||||
realPsi.safeAs<KtValueArgument>()?.getArgumentExpression()
|
||||
is FirAnonymousFunctionExpression ->
|
||||
realPsi?.parent as? KtLabeledExpression ?: realPsi as? KtExpression
|
||||
else -> realPsi as? KtExpression
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ internal class KtFirExpressionTypeProvider(
|
||||
argumentsToParameters.entries.firstOrNull { (arg, _) ->
|
||||
when (arg) {
|
||||
// TODO: better to utilize. See `createArgumentMapping` in [KtFirCallResolver]
|
||||
is FirLambdaArgumentExpression, is FirNamedArgumentExpression, is FirSpreadArgumentExpression ->
|
||||
is FirNamedArgumentExpression, is FirSpreadArgumentExpression ->
|
||||
arg.psi == argumentExpression.parent
|
||||
else ->
|
||||
arg.psi == argumentExpression
|
||||
|
||||
+1
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.psi.KtFunction
|
||||
import org.jetbrains.kotlin.psi.KtIfExpression
|
||||
import org.jetbrains.kotlin.psi.KtImportDirective
|
||||
import org.jetbrains.kotlin.psi.KtLabelReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||
|
||||
+2
-1
@@ -59,6 +59,7 @@ import org.jetbrains.kotlin.psi.KtFunction
|
||||
import org.jetbrains.kotlin.psi.KtIfExpression
|
||||
import org.jetbrains.kotlin.psi.KtImportDirective
|
||||
import org.jetbrains.kotlin.psi.KtLabelReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||
@@ -1417,7 +1418,7 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
val actualType: KtType
|
||||
}
|
||||
|
||||
interface ManyLambdaExpressionArguments : KtFirDiagnostic<KtValueArgument> {
|
||||
interface ManyLambdaExpressionArguments : KtFirDiagnostic<KtLambdaExpression> {
|
||||
override val diagnosticClass get() = ManyLambdaExpressionArguments::class
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -60,6 +60,7 @@ import org.jetbrains.kotlin.psi.KtFunction
|
||||
import org.jetbrains.kotlin.psi.KtIfExpression
|
||||
import org.jetbrains.kotlin.psi.KtImportDirective
|
||||
import org.jetbrains.kotlin.psi.KtLabelReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||
@@ -1702,7 +1703,7 @@ internal class ResultTypeMismatchImpl(
|
||||
internal class ManyLambdaExpressionArgumentsImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtValueArgument>(firDiagnostic, token), KtFirDiagnostic.ManyLambdaExpressionArguments
|
||||
) : KtAbstractFirDiagnostic<KtLambdaExpression>(firDiagnostic, token), KtFirDiagnostic.ManyLambdaExpressionArguments
|
||||
|
||||
internal class NewInferenceNoInformationForParameterImpl(
|
||||
override val name: String,
|
||||
|
||||
+12
@@ -658,6 +658,18 @@ public class FirIdeNormalAnalysisSourceModuleResolveCallTestGenerated extends Ab
|
||||
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/kotlinPropertySetter_unqualified.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labeledLambda.kt")
|
||||
public void testLabeledLambda() {
|
||||
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/labeledLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labeledLambdaInsideParentheses.kt")
|
||||
public void testLabeledLambdaInsideParentheses() {
|
||||
runTest("analysis/analysis-api/testData/components/callResolver/resolveCall/labeledLambdaInsideParentheses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberFunctionCallWithTypeArgument.kt")
|
||||
public void testMemberFunctionCallWithTypeArgument() {
|
||||
|
||||
Reference in New Issue
Block a user