diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot index 7105ff9abaf..00b06f406f3 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot @@ -114,7 +114,7 @@ digraph plusAssignWithLambdaInRhs_kt { 44 [label="Postponed exit from lambda"]; 45 [label="Function call: R|/A.A|(...)" style="filled" fillcolor=yellow]; 46 [label="Jump: ^postpone R|/A.A|( = A@fun (resolve: R|(T) -> kotlin/Unit|): R|kotlin/Unit| { - R|/queue|.R|kotlin/collections/plusAssign| kotlin/Unit|>(A@fun (): R|kotlin/Unit| { + R|/queue|.R|kotlin/collections/plusAssign| kotlin/Unit|>(fun (): R|kotlin/Unit| { R|/resolve|.R|SubstitutionOverride|(R|/computation|.R|SubstitutionOverride|()) } ) diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.fir.txt index fc35d7979d2..6b5a6a201ff 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.fir.txt @@ -18,7 +18,7 @@ FILE: plusAssignWithLambdaInRhs.kt public final fun postpone(computation: R|() -> T|): R|A| { lval queue: R|kotlin/collections/MutableList>| = R|kotlin/collections/mutableListOf| kotlin/Unit|>() ^postpone R|/A.A|( = A@fun (resolve: R|(T) -> kotlin/Unit|): R|kotlin/Unit| { - R|/queue|.R|kotlin/collections/plusAssign| kotlin/Unit|>(A@fun (): R|kotlin/Unit| { + R|/queue|.R|kotlin/collections/plusAssign| kotlin/Unit|>(fun (): R|kotlin/Unit| { R|/resolve|.R|SubstitutionOverride|(R|/computation|.R|SubstitutionOverride|()) } ) diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt index db1941d3dd0..7307802fbca 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt @@ -267,6 +267,8 @@ class ExpressionsConverter( val operationToken = operationTokenName.getOperationSymbol() if (operationToken == IDENTIFIER) { context.calleeNamesForLambda += operationTokenName.nameAsSafeName() + } else { + context.calleeNamesForLambda += null } val rightArgAsFir = @@ -277,10 +279,8 @@ class ExpressionsConverter( val leftArgAsFir = getAsFirExpression(leftArgNode, "No left operand") - if (operationToken == IDENTIFIER) { - // No need for the callee name since arguments are already generated - context.calleeNamesForLambda.removeLast() - } + // No need for the callee name since arguments are already generated + context.calleeNamesForLambda.removeLast() when (operationToken) { ELVIS -> diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index d9a0c912825..d6e7c7dbe79 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -2380,15 +2380,15 @@ open class RawFirBuilder( if (operationToken == IDENTIFIER) { context.calleeNamesForLambda += expression.operationReference.getReferencedNameAsName() + } else { + context.calleeNamesForLambda += null } val leftArgument = expression.left.toFirExpression("No left operand") val rightArgument = expression.right.toFirExpression("No right operand") - if (operationToken == IDENTIFIER) { - // No need for the callee name since arguments are already generated - context.calleeNamesForLambda.removeLast() - } + // No need for the callee name since arguments are already generated + context.calleeNamesForLambda.removeLast() val source = expression.toFirSourceElement() diff --git a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/Context.kt b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/Context.kt index 9c20a389ae2..3bf866e534d 100644 --- a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/Context.kt +++ b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/Context.kt @@ -28,7 +28,7 @@ class Context { val currentClassId get() = ClassId(packageFqName, className, inLocalContext) val firFunctionTargets = mutableListOf() - val calleeNamesForLambda = mutableListOf() + val calleeNamesForLambda = mutableListOf() @PrivateForInline val _firLabels = mutableListOf() diff --git a/compiler/testData/diagnostics/tests/labels/labelToOuterLambda.fir.kt b/compiler/testData/diagnostics/tests/labels/labelToOuterLambda.fir.kt deleted file mode 100644 index 2d129f322d8..00000000000 --- a/compiler/testData/diagnostics/tests/labels/labelToOuterLambda.fir.kt +++ /dev/null @@ -1,13 +0,0 @@ -// ISSUE: KT-57880 - -fun outerLambda(action: String.() -> Unit) {} -var lambda: Int.() -> Unit = {} -fun consume(arg: String) {} - -fun main() { - outerLambda { - lambda = { - consume(this@outerLambda) - } - } -} diff --git a/compiler/testData/diagnostics/tests/labels/labelToOuterLambda.kt b/compiler/testData/diagnostics/tests/labels/labelToOuterLambda.kt index 2d29bf1935f..c9c6b56abe1 100644 --- a/compiler/testData/diagnostics/tests/labels/labelToOuterLambda.kt +++ b/compiler/testData/diagnostics/tests/labels/labelToOuterLambda.kt @@ -1,8 +1,10 @@ +// FIR_IDENTICAL // ISSUE: KT-57880 fun outerLambda(action: String.() -> Unit) {} var lambda: Int.() -> Unit = {} fun consume(arg: String) {} +fun consumeInt(arg: Int) {} fun main() { outerLambda { @@ -10,4 +12,10 @@ fun main() { consume(this@outerLambda) } } + + outerLambda { + lambda = innerLambda@{ + consumeInt(this@innerLambda) + } + } }