~ WIP
diff --git a/compiler/fir/analysis-tests/testData/resolve/cast.fir.txt b/compiler/fir/analysis-tests/testData/resolve/cast.fir.txt
index c428a52..1e39d4d 100644
--- a/compiler/fir/analysis-tests/testData/resolve/cast.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/cast.fir.txt
@@ -18,7 +18,7 @@
     }
 
         public get(): R|(kotlin/String) -> kotlin/Boolean|
-    public final val hError: R|(ERROR CLASS: Cannot infer type for parameter <unused var>) -> ERROR CLASS: Cannot infer type variable TypeVariable(_L)| = fun <anonymous>(<unused var>: <ERROR TYPE REF: Cannot infer type for parameter <unused var>>): <ERROR TYPE REF: Cannot infer type variable TypeVariable(_L)> <inline=NoInline>  {
+    public final val hError: R|(ERROR CLASS: Cannot infer type for parameter <unused var>) -> ERROR CLASS: Cannot infer type variable TypeVariable(_L)| = ERROR_EXPR(CS errors: _synthetic/ACCEPT_SPECIFIC_TYPE_CALL)fun <anonymous>(<unused var>: <ERROR TYPE REF: Cannot infer type for parameter <unused var>>): <ERROR TYPE REF: Cannot infer type variable TypeVariable(_L)> <inline=NoInline>  {
         ^ Boolean(true)
     }
 
diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.dot
index 55eddee..40c2e10 100644
--- a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.dot
+++ b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdas.dot
@@ -150,35 +150,43 @@
                 subgraph cluster_17 {
                     color=blue
                     51 [label="Enter block"];
-                    52 [label="Exit anonymous function expression"];
-                    53 [label="Variable declaration: lval lambda: R|() -> kotlin/Int|"];
-                    54 [label="Exit block"];
+                    subgraph cluster_18 {
+                        color=blue
+                        52 [label="Function call arguments enter"];
+                        53 [label="Anonymous function capture"];
+                        54 [label="Postponed enter to lambda"];
+                        subgraph cluster_19 {
+                            color=blue
+                            55 [label="Enter function <anonymous>" style="filled" fillcolor=red];
+                            subgraph cluster_20 {
+                                color=blue
+                                56 [label="Enter block"];
+                                subgraph cluster_21 {
+                                    color=blue
+                                    57 [label="Function call arguments enter"];
+                                    58 [label="Access variable R|<local>/x|"];
+                                    59 [label="Smart cast: R|<local>/x|"];
+                                    60 [label="Function call arguments exit"];
+                                }
+                                61 [label="Function call enter: R|<local>/x|.R|kotlin/Int.inc|()"];
+                                62 [label="Function call exit: R|<local>/x|.R|kotlin/Int.inc|()" style="filled" fillcolor=yellow];
+                                63 [label="Exit block"];
+                            }
+                            64 [label="Exit function <anonymous>" style="filled" fillcolor=red];
+                        }
+                        65 [label="Function call arguments exit"];
+                    }
+                    66 [label="Postponed exit from lambda"];
+                    67 [label="Function call exit: R|_synthetic/ACCEPT_SPECIFIC_TYPE_CALL|(...)" style="filled" fillcolor=yellow];
+                    68 [label="Variable declaration: lval lambda: R|() -> kotlin/Int|"];
+                    69 [label="Exit block"];
                 }
-                55 [label="Exit when branch result"];
-                56 [label="Exit when"];
+                70 [label="Exit when branch result"];
+                71 [label="Exit when"];
             }
-            57 [label="Exit block"];
+            72 [label="Exit block"];
         }
-        58 [label="Exit function test_2" style="filled" fillcolor=red];
-    }
-    subgraph cluster_18 {
-        color=blue
-        59 [label="Enter function <anonymous>" style="filled" fillcolor=red];
-        subgraph cluster_19 {
-            color=blue
-            60 [label="Enter block"];
-            subgraph cluster_20 {
-                color=blue
-                61 [label="Function call arguments enter"];
-                62 [label="Access variable R|<local>/x|"];
-                63 [label="Smart cast: R|<local>/x|"];
-                64 [label="Function call arguments exit"];
-            }
-            65 [label="Function call enter: R|<local>/x|.R|kotlin/Int.inc|()"];
-            66 [label="Function call exit: R|<local>/x|.R|kotlin/Int.inc|()" style="filled" fillcolor=yellow];
-            67 [label="Exit block"];
-        }
-        68 [label="Exit function <anonymous>" style="filled" fillcolor=red];
+        73 [label="Exit function test_2" style="filled" fillcolor=red];
     }
     42 -> {43};
     43 -> {44};
@@ -187,182 +195,188 @@
     46 -> {47};
     47 -> {48};
     48 -> {49 50};
-    49 -> {56};
+    49 -> {71};
     50 -> {51};
     51 -> {52};
-    52 -> {53 59};
-    52 -> {59} [style=dashed];
+    52 -> {53};
     53 -> {54};
-    54 -> {55};
+    53 -> {55} [color=green label="CapturedByValue"];
+    54 -> {55 65 66};
+    54 -> {55} [style=dashed];
     55 -> {56};
     56 -> {57};
     57 -> {58};
+    58 -> {59};
     59 -> {60};
     60 -> {61};
     61 -> {62};
     62 -> {63};
     63 -> {64};
-    64 -> {65};
-    65 -> {66};
-    66 -> {67};
+    65 -> {67};
+    66 -> {67} [label="Postponed"];
     67 -> {68};
-
-    subgraph cluster_21 {
-        color=red
-        69 [label="Enter function getInt" style="filled" fillcolor=red];
-        subgraph cluster_22 {
-            color=blue
-            70 [label="Enter block"];
-            subgraph cluster_23 {
-                color=blue
-                71 [label="Function call arguments enter"];
-                72 [label="Function call arguments exit"];
-            }
-            73 [label="Function call enter: R?C|kotlin/Function0.invoke|()"];
-            74 [label="Function call exit: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
-            75 [label="Const: Int(1)"];
-            76 [label="Jump: ^getInt Int(1)"];
-            77 [label="Stub" style="filled" fillcolor=gray];
-            78 [label="Exit block" style="filled" fillcolor=gray];
-        }
-        79 [label="Exit function getInt" style="filled" fillcolor=red];
-    }
+    68 -> {69};
     69 -> {70};
     70 -> {71};
     71 -> {72};
     72 -> {73};
-    73 -> {74};
+
+    subgraph cluster_22 {
+        color=red
+        74 [label="Enter function getInt" style="filled" fillcolor=red];
+        subgraph cluster_23 {
+            color=blue
+            75 [label="Enter block"];
+            subgraph cluster_24 {
+                color=blue
+                76 [label="Function call arguments enter"];
+                77 [label="Function call arguments exit"];
+            }
+            78 [label="Function call enter: R?C|kotlin/Function0.invoke|()"];
+            79 [label="Function call exit: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
+            80 [label="Const: Int(1)"];
+            81 [label="Jump: ^getInt Int(1)"];
+            82 [label="Stub" style="filled" fillcolor=gray];
+            83 [label="Exit block" style="filled" fillcolor=gray];
+        }
+        84 [label="Exit function getInt" style="filled" fillcolor=red];
+    }
     74 -> {75};
     75 -> {76};
-    76 -> {79};
-    76 -> {77} [style=dotted];
-    77 -> {78} [style=dotted];
-    78 -> {79} [style=dotted];
+    76 -> {77};
+    77 -> {78};
+    78 -> {79};
+    79 -> {80};
+    80 -> {81};
+    81 -> {84};
+    81 -> {82} [style=dotted];
+    82 -> {83} [style=dotted];
+    83 -> {84} [style=dotted];
 
-    subgraph cluster_24 {
+    subgraph cluster_25 {
         color=red
-        80 [label="Enter function test_3" style="filled" fillcolor=red];
-        subgraph cluster_25 {
+        85 [label="Enter function test_3" style="filled" fillcolor=red];
+        subgraph cluster_26 {
             color=blue
-            81 [label="Enter block"];
-            subgraph cluster_26 {
+            86 [label="Enter block"];
+            subgraph cluster_27 {
                 color=blue
-                82 [label="Function call arguments enter"];
-                83 [label="Anonymous function capture"];
-                84 [label="Postponed enter to lambda"];
-                subgraph cluster_27 {
+                87 [label="Function call arguments enter"];
+                88 [label="Anonymous function capture"];
+                89 [label="Postponed enter to lambda"];
+                subgraph cluster_28 {
                     color=blue
-                    85 [label="Enter function <anonymous>" style="filled" fillcolor=red];
-                    subgraph cluster_28 {
+                    90 [label="Enter function <anonymous>" style="filled" fillcolor=red];
+                    subgraph cluster_29 {
                         color=blue
-                        86 [label="Enter block"];
-                        87 [label="Const: Int(1)"];
-                        88 [label="Jump: ^test_3 Int(1)"];
-                        89 [label="Stub" style="filled" fillcolor=gray];
-                        90 [label="Exit block" style="filled" fillcolor=gray];
+                        91 [label="Enter block"];
+                        92 [label="Const: Int(1)"];
+                        93 [label="Jump: ^test_3 Int(1)"];
+                        94 [label="Stub" style="filled" fillcolor=gray];
+                        95 [label="Exit block" style="filled" fillcolor=gray];
                     }
-                    91 [label="Exit function <anonymous>" style="filled" fillcolor=gray];
+                    96 [label="Exit function <anonymous>" style="filled" fillcolor=gray];
                 }
-                92 [label="Function call arguments exit"];
+                97 [label="Function call arguments exit"];
             }
-            93 [label="Function call enter: R|/getInt|(...)"];
-            94 [label="Postponed exit from lambda"];
-            95 [label="Function call exit: R|/getInt|(...)" style="filled" fillcolor=yellow];
-            96 [label="Jump: ^test_3 R|/getInt|(<L> = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN>  {
+            98 [label="Function call enter: R|/getInt|(...)"];
+            99 [label="Postponed exit from lambda"];
+            100 [label="Function call exit: R|/getInt|(...)" style="filled" fillcolor=yellow];
+            101 [label="Jump: ^test_3 R|/getInt|(<L> = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN>  {
     ^test_3 Int(1)
 }
 )"];
-            97 [label="Stub" style="filled" fillcolor=gray];
-            98 [label="Exit block" style="filled" fillcolor=gray];
+            102 [label="Stub" style="filled" fillcolor=gray];
+            103 [label="Exit block" style="filled" fillcolor=gray];
         }
-        99 [label="Exit function test_3" style="filled" fillcolor=red];
+        104 [label="Exit function test_3" style="filled" fillcolor=red];
     }
-    80 -> {81};
-    81 -> {82};
-    82 -> {83};
-    83 -> {84};
-    83 -> {85} [color=green style=dotted label="CapturedByValue"];
-    84 -> {85 92 94};
-    84 -> {85} [style=dashed];
     85 -> {86};
     86 -> {87};
     87 -> {88};
-    88 -> {99};
-    88 -> {89} [style=dotted];
-    89 -> {90} [style=dotted];
-    90 -> {91} [style=dotted];
-    91 -> {94} [style=dotted];
+    88 -> {89};
+    88 -> {90} [color=green style=dotted label="CapturedByValue"];
+    89 -> {90 97 99};
+    89 -> {90} [style=dashed];
+    90 -> {91};
+    91 -> {92};
     92 -> {93};
-    93 -> {95};
-    94 -> {84} [color=green style=dashed];
-    94 -> {95} [label="Postponed"];
-    95 -> {96};
-    96 -> {99};
-    96 -> {97} [style=dotted];
-    97 -> {98} [style=dotted];
-    98 -> {99} [style=dotted];
+    93 -> {104};
+    93 -> {94} [style=dotted];
+    94 -> {95} [style=dotted];
+    95 -> {96} [style=dotted];
+    96 -> {99} [style=dotted];
+    97 -> {98};
+    98 -> {100};
+    99 -> {89} [color=green style=dashed];
+    99 -> {100} [label="Postponed"];
+    100 -> {101};
+    101 -> {104};
+    101 -> {102} [style=dotted];
+    102 -> {103} [style=dotted];
+    103 -> {104} [style=dotted];
 
-    subgraph cluster_29 {
+    subgraph cluster_30 {
         color=red
-        100 [label="Enter function test_4" style="filled" fillcolor=red];
-        subgraph cluster_30 {
+        105 [label="Enter function test_4" style="filled" fillcolor=red];
+        subgraph cluster_31 {
             color=blue
-            101 [label="Enter block"];
-            subgraph cluster_31 {
+            106 [label="Enter block"];
+            subgraph cluster_32 {
                 color=blue
-                102 [label="Function call arguments enter"];
-                103 [label="Anonymous function capture"];
-                104 [label="Postponed enter to lambda"];
-                subgraph cluster_32 {
+                107 [label="Function call arguments enter"];
+                108 [label="Anonymous function capture"];
+                109 [label="Postponed enter to lambda"];
+                subgraph cluster_33 {
                     color=blue
-                    105 [label="Enter function <anonymous>" style="filled" fillcolor=red];
-                    subgraph cluster_33 {
+                    110 [label="Enter function <anonymous>" style="filled" fillcolor=red];
+                    subgraph cluster_34 {
                         color=blue
-                        106 [label="Enter block"];
-                        107 [label="Const: Int(1)"];
-                        108 [label="Jump: ^test_4 Int(1)"];
-                        109 [label="Stub" style="filled" fillcolor=gray];
-                        110 [label="Exit block" style="filled" fillcolor=gray];
+                        111 [label="Enter block"];
+                        112 [label="Const: Int(1)"];
+                        113 [label="Jump: ^test_4 Int(1)"];
+                        114 [label="Stub" style="filled" fillcolor=gray];
+                        115 [label="Exit block" style="filled" fillcolor=gray];
                     }
-                    111 [label="Exit function <anonymous>" style="filled" fillcolor=gray];
+                    116 [label="Exit function <anonymous>" style="filled" fillcolor=gray];
                 }
-                112 [label="Function call arguments exit"];
+                117 [label="Function call arguments exit"];
             }
-            113 [label="Function call enter: R|/getInt|(...)"];
-            114 [label="Postponed exit from lambda"];
-            115 [label="Function call exit: R|/getInt|(...)" style="filled" fillcolor=yellow];
-            116 [label="Jump: ^test_4 R|/getInt|(getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN>  {
+            118 [label="Function call enter: R|/getInt|(...)"];
+            119 [label="Postponed exit from lambda"];
+            120 [label="Function call exit: R|/getInt|(...)" style="filled" fillcolor=yellow];
+            121 [label="Jump: ^test_4 R|/getInt|(getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN>  {
     ^test_4 Int(1)
 }
 )"];
-            117 [label="Stub" style="filled" fillcolor=gray];
-            118 [label="Exit block" style="filled" fillcolor=gray];
+            122 [label="Stub" style="filled" fillcolor=gray];
+            123 [label="Exit block" style="filled" fillcolor=gray];
         }
-        119 [label="Exit function test_4" style="filled" fillcolor=red];
+        124 [label="Exit function test_4" style="filled" fillcolor=red];
     }
-    100 -> {101};
-    101 -> {102};
-    102 -> {103};
-    103 -> {104};
-    103 -> {105} [color=green style=dotted label="CapturedByValue"];
-    104 -> {105 112 114};
-    104 -> {105} [style=dashed];
     105 -> {106};
     106 -> {107};
     107 -> {108};
-    108 -> {119};
-    108 -> {109} [style=dotted];
-    109 -> {110} [style=dotted];
-    110 -> {111} [style=dotted];
-    111 -> {114} [style=dotted];
+    108 -> {109};
+    108 -> {110} [color=green style=dotted label="CapturedByValue"];
+    109 -> {110 117 119};
+    109 -> {110} [style=dashed];
+    110 -> {111};
+    111 -> {112};
     112 -> {113};
-    113 -> {115};
-    114 -> {104} [color=green style=dashed];
-    114 -> {115} [label="Postponed"];
-    115 -> {116};
-    116 -> {119};
-    116 -> {117} [style=dotted];
-    117 -> {118} [style=dotted];
-    118 -> {119} [style=dotted];
+    113 -> {124};
+    113 -> {114} [style=dotted];
+    114 -> {115} [style=dotted];
+    115 -> {116} [style=dotted];
+    116 -> {119} [style=dotted];
+    117 -> {118};
+    118 -> {120};
+    119 -> {109} [color=green style=dashed];
+    119 -> {120} [label="Postponed"];
+    120 -> {121};
+    121 -> {124};
+    121 -> {122} [style=dotted];
+    122 -> {123} [style=dotted];
+    123 -> {124} [style=dotted];
 
 }
diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/recursiveProblemWithSyntaxError.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/recursiveProblemWithSyntaxError.fir.txt
index ae2acee..4baa070 100644
--- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/recursiveProblemWithSyntaxError.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/recursiveProblemWithSyntaxError.fir.txt
@@ -1,8 +1,8 @@
 FILE: recursiveProblemWithSyntaxError.kt
-    public final val foo: <ERROR TYPE REF: Unresolved name: bar> = bar@fun <anonymous>(): <ERROR TYPE REF: Unresolved name: bar> <inline=NoInline>  {
+    public final val foo: <ERROR TYPE REF: Unresolved name: bar> = ERROR_EXPR(Inapplicable(INAPPLICABLE): _synthetic/ACCEPT_SPECIFIC_TYPE_CALL)bar@fun <anonymous>(): <ERROR TYPE REF: Unresolved name: bar> <inline=NoInline>  {
         ^ <Unresolved name: bar>#
     }
-    .R|SubstitutionOverride<kotlin/Function0.invoke: <ERROR TYPE REF: Unresolved name: bar>><Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): kotlin/Function0.invoke>#|(ERROR_EXPR(Argument is absent)).<Unresolved name: bar>#(<Call has no callee>#(<L> = <Call has no callee>@fun <anonymous>(): <ERROR TYPE REF: cycle> <inline=NoInline>  {
+    .R|SubstitutionOverride<kotlin/Function0.invoke: <ERROR TYPE REF: Unresolved name: bar>><Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): kotlin/Function0.invoke>#|(ERROR_EXPR(Argument is absent)).<Unresolved name: bar>#(<Call has no callee>#(ERROR_EXPR(Inapplicable(INAPPLICABLE): _synthetic/ACCEPT_SPECIFIC_TYPE_CALL)<L> = <Call has no callee>@fun <anonymous>(): <ERROR TYPE REF: cycle> <inline=NoInline>  {
         ^ R|/foo|
     }
     ))
diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.fir.txt
index d47f770..7959a7b 100644
--- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.fir.txt
@@ -13,7 +13,7 @@
         public final fun act(): R|kotlin/Unit| {
             <Super cannot be a callee>#()
             <Unresolved name: invoke>#()
-            <Super cannot be a callee>#(<L> = <Super cannot be a callee>@fun <anonymous>(): <ERROR TYPE REF: Unresolved name: println> <inline=NoInline>  {
+            <Super cannot be a callee>#(ERROR_EXPR(Inapplicable(INAPPLICABLE): _synthetic/ACCEPT_SPECIFIC_TYPE_CALL)<L> = <Super cannot be a callee>@fun <anonymous>(): <ERROR TYPE REF: Unresolved name: println> <inline=NoInline>  {
                 ^ <Unresolved name: println>#(ERROR_EXPR(Incorrect character: 'weird'))
             }
             )
diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/incorrectGenericLambdaProperty.fir.txt b/compiler/fir/analysis-tests/testData/resolve/problems/incorrectGenericLambdaProperty.fir.txt
index 24064ad..dddf688 100644
--- a/compiler/fir/analysis-tests/testData/resolve/problems/incorrectGenericLambdaProperty.fir.txt
+++ b/compiler/fir/analysis-tests/testData/resolve/problems/incorrectGenericLambdaProperty.fir.txt
@@ -1,6 +1,6 @@
 FILE: incorrectGenericLambdaProperty.kt
     public final fun main(args: R|kotlin/Array<kotlin/String>|): R|kotlin/Unit| {
-        lval <T> passIt: R|(ERROR CLASS: Cannot infer type for parameter <destruct>) -> ERROR CLASS: Symbol not found for T| = fun <anonymous>(<destruct>: <ERROR TYPE REF: Cannot infer type for parameter <destruct>>): <ERROR TYPE REF: Symbol not found for T> <inline=NoInline>  {
+        lval <T> passIt: R|(ERROR CLASS: Cannot infer type for parameter <destruct>) -> ERROR CLASS: Symbol not found for T| = ERROR_EXPR(CS errors: _synthetic/ACCEPT_SPECIFIC_TYPE_CALL)fun <anonymous>(<destruct>: <ERROR TYPE REF: Cannot infer type for parameter <destruct>>): <ERROR TYPE REF: Symbol not found for T> <inline=NoInline>  {
             lval t: <ERROR TYPE REF: Symbol not found for T> = R|<local>/<destruct>|.<Unresolved name: component1>#()
             ^  {
                 R|<local>/t|
diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt
index 7d3de7f..0cbc21c 100644
--- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt
+++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt
@@ -170,7 +170,10 @@
 
     is ConeDestructuringDeclarationsOnTopLevel -> null // TODO Currently a parsing error. Would be better to report here instead KT-58563
     is ConeCannotInferTypeParameterType -> FirErrors.CANNOT_INFER_PARAMETER_TYPE.createOn(source)
-    is ConeCannotInferValueParameterType -> FirErrors.CANNOT_INFER_PARAMETER_TYPE.createOn(source)
+    is ConeCannotInferValueParameterType -> when {
+        isTopLevelLambda -> FirErrors.VALUE_PARAMETER_WITHOUT_EXPLICIT_TYPE.createOn(source)
+        else -> FirErrors.CANNOT_INFER_PARAMETER_TYPE.createOn(source)
+    }
     is ConeCannotInferReceiverParameterType -> FirErrors.CANNOT_INFER_PARAMETER_TYPE.createOn(source)
     is ConeTypeVariableTypeIsNotInferred -> FirErrors.INFERENCE_ERROR.createOn(callOrAssignmentSource ?: source)
     is ConeInstanceAccessBeforeSuperCall -> FirErrors.INSTANCE_ACCESS_BEFORE_SUPER_CALL.createOn(source, this.target)
diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeResolutionAtoms.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeResolutionAtoms.kt
index e6b7f85..688f124 100644
--- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeResolutionAtoms.kt
+++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeResolutionAtoms.kt
@@ -79,7 +79,10 @@
         private fun createRawAtom(expression: FirExpression?, allowUnresolvedExpression: Boolean): ConeResolutionAtom? {
             return when (expression) {
                 null -> null
-                is FirAnonymousFunctionExpression -> ConeResolutionAtomWithPostponedChild(expression)
+                is FirAnonymousFunctionExpression -> when {
+                    expression.isResolved -> ConeSimpleLeafResolutionAtom(expression, allowUnresolvedExpression)
+                    else -> ConeResolutionAtomWithPostponedChild(expression)
+                }
                 is FirCallableReferenceAccess -> when {
                     expression.isResolved -> ConeSimpleLeafResolutionAtom(expression, allowUnresolvedExpression)
                     else -> ConeResolutionAtomWithPostponedChild(expression)
diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt
index f45f07f..fb525b6 100644
--- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt
+++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt
@@ -44,9 +44,12 @@
 import org.jetbrains.kotlin.resolve.calls.inference.addEqualityConstraintIfCompatible
 import org.jetbrains.kotlin.resolve.calls.inference.addSubtypeConstraintIfCompatible
 import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
+import org.jetbrains.kotlin.resolve.calls.inference.buildCurrentSubstitutor
 import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
 import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
 import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
+import org.jetbrains.kotlin.types.model.KotlinTypeMarker
+import org.jetbrains.kotlin.types.model.TypeConstructorMarker
 import org.jetbrains.kotlin.types.model.safeSubstitute
 import org.jetbrains.kotlin.utils.addToStdlib.runIf
 
@@ -126,13 +129,35 @@
 
                 inferenceSession.processPartiallyResolvedCall(call, resolutionMode, completionMode)
 
-                call
+                if (candidate.isSyntheticCallForTopLevelLambda()) {
+                    val storage = candidate.system.currentStorage()
+
+                    val fixingNotInferredVariables: Map<TypeConstructorMarker, KotlinTypeMarker> = buildMap {
+                        if (storage.notFixedTypeVariables.isEmpty()) return@buildMap
+
+                        for (typeConstructor in storage.allTypeVariables.keys.toList().drop(storage.outerSystemVariablesPrefixSize)) {
+                            if (typeConstructor !in storage.notFixedTypeVariables) continue
+                            put(typeConstructor, session.typeContext.createUninferredType(typeConstructor))
+                        }
+                    }
+
+                    val finalSubstitutor = storage
+                        .buildCurrentSubstitutor(session.typeContext, emptyMap()) as ConeSubstitutor
+                    call.transformSingle(
+                        createCompletionResultsWriter(finalSubstitutor),
+                        null
+                    )
+                } else {
+                    call
+                }
             }
 
             ConstraintSystemCompletionMode.UNTIL_FIRST_LAMBDA -> throw IllegalStateException()
         }
     }
 
+    private fun Candidate.isSyntheticCallForTopLevelLambda(): Boolean = callInfo.callSite is FirAnonymousFunctionExpression
+
     private fun checkStorageConstraintsAfterFullCompletion(storage: ConstraintStorage) {
         // Fast path for sake of optimization
         if (storage.notFixedTypeVariables.isEmpty()) return
@@ -351,7 +376,7 @@
                         this.name = name
                         symbol = FirValueParameterSymbol(name)
                         returnTypeRef =
-                            itType.approximateLambdaInputType(symbol, withPCLASession).toFirResolvedTypeRef(
+                            itType.approximateLambdaInputType(symbol, withPCLASession, candidate).toFirResolvedTypeRef(
                                 lambdaAtom.anonymousFunction.source?.fakeElement(KtFakeSourceElementKind.ItLambdaParameter)
                             )
                         defaultValue = null
@@ -371,7 +396,7 @@
                 receiverType == null -> lambda.replaceReceiverParameter(null)
                 !lambdaAtom.coerceFirstParameterToExtensionReceiver -> {
                     lambda.receiverParameter?.apply {
-                        val type = receiverType.approximateLambdaInputType(valueParameter = null, withPCLASession)
+                        val type = receiverType.approximateLambdaInputType(valueParameter = null, withPCLASession, candidate)
                         val source =
                             source?.fakeElement(KtFakeSourceElementKind.LambdaReceiver)
                                 ?: lambda.source?.fakeElement(KtFakeSourceElementKind.LambdaReceiver)
@@ -393,7 +418,7 @@
                             name = SpecialNames.UNDERSCORE_FOR_UNUSED_VAR
                             symbol = FirValueParameterSymbol(name)
                             returnTypeRef = contextParameterType
-                                .approximateLambdaInputType(symbol, withPCLASession)
+                                .approximateLambdaInputType(symbol, withPCLASession, candidate)
                                 .toFirResolvedTypeRef(lambdaAtom.anonymousFunction.source?.fakeElement(KtFakeSourceElementKind.LambdaContextParameter))
                             valueParameterKind = if (session.languageVersionSettings.supportsFeature(LanguageFeature.ContextParameters)) {
                                 FirValueParameterKind.ContextParameter
@@ -428,7 +453,7 @@
                     )
                     return@forEachIndexed
                 }
-                val newReturnType = theParameters[index].approximateLambdaInputType(parameter.symbol, withPCLASession)
+                val newReturnType = theParameters[index].approximateLambdaInputType(parameter.symbol, withPCLASession, candidate)
                 val newReturnTypeRef = if (parameter.returnTypeRef is FirImplicitTypeRef) {
                     newReturnType.toFirResolvedTypeRef(parameter.source?.fakeElement(KtFakeSourceElementKind.ImplicitReturnTypeOfLambdaValueParameter))
                 } else parameter.returnTypeRef.resolvedTypeFromPrototype(newReturnType)
@@ -515,12 +540,15 @@
     private fun ConeKotlinType.approximateLambdaInputType(
         valueParameter: FirValueParameterSymbol?,
         isRootLambdaForPCLASession: Boolean,
+        containingCandidate: Candidate,
     ): ConeKotlinType {
         // We only run lambda completion from ConstraintSystemCompletionContext.analyzeRemainingNotAnalyzedPostponedArgument when they are
         // left uninferred.
         // Currently, we use stub types for builder inference, so CANNOT_INFER_PARAMETER_TYPE is the only possible result here.
         if (useErrorTypeInsteadOfTypeVariableForParameterType(isReceiver = valueParameter == null, isRootLambdaForPCLASession)) {
-            val diagnostic = valueParameter?.let(::ConeCannotInferValueParameterType) ?: ConeCannotInferReceiverParameterType()
+            val diagnostic = valueParameter?.let {
+                ConeCannotInferValueParameterType(it, isTopLevelLambda = containingCandidate.isSyntheticCallForTopLevelLambda())
+            } ?: ConeCannotInferReceiverParameterType()
             return ConeErrorType(diagnostic)
         }
 
diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt
index 6c688d8b..8903fd2 100644
--- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt
+++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt
@@ -22,19 +22,18 @@
 import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter
 import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
 import org.jetbrains.kotlin.fir.declarations.utils.addDefaultBoundIfNecessary
+import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
 import org.jetbrains.kotlin.fir.expressions.*
 import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList
 import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall
 import org.jetbrains.kotlin.fir.moduleData
-import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
-import org.jetbrains.kotlin.fir.references.FirReference
-import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference
+import org.jetbrains.kotlin.fir.references.*
 import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference
 import org.jetbrains.kotlin.fir.references.builder.buildResolvedErrorReference
 import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
 import org.jetbrains.kotlin.fir.references.impl.FirStubReference
-import org.jetbrains.kotlin.fir.references.isError
 import org.jetbrains.kotlin.fir.resolve.*
+import org.jetbrains.kotlin.fir.resolve.calls.ArgumentTypeMismatch
 import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticFunctionSymbol
 import org.jetbrains.kotlin.fir.resolve.calls.ResolutionContext
 import org.jetbrains.kotlin.fir.resolve.calls.candidate.*
@@ -56,9 +55,11 @@
 import org.jetbrains.kotlin.name.CallableId
 import org.jetbrains.kotlin.name.Name
 import org.jetbrains.kotlin.resolve.ArrayFqNames
+import org.jetbrains.kotlin.resolve.calls.inference.buildCurrentSubstitutor
 import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
 import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
 import org.jetbrains.kotlin.types.Variance
+import org.jetbrains.kotlin.types.model.safeSubstitute
 
 class FirSyntheticCallGenerator(
     private val components: BodyResolveComponents
@@ -245,6 +246,70 @@
             .firstOrNull() // TODO: it should be single() after KTIJ-26465 is fixed
     }
 
+    fun resolveAnonymousFunctionExpressionWithSyntheticOuterCall(
+        anonymousFunctionExpression: FirAnonymousFunctionExpression,
+        expectedTypeData: ResolutionMode.WithExpectedType?,
+        context: ResolutionContext,
+    ): FirExpression {
+        val argumentList = buildUnaryArgumentList(anonymousFunctionExpression)
+
+        val reference = generateCalleeReferenceToFunctionWithExpectedTypeForArgument(
+            anonymousFunctionExpression,
+            argumentList,
+            expectedTypeData?.expectedType,
+            context,
+        )
+
+        val fakeCall = buildFunctionCall {
+            calleeReference = reference
+            this.argumentList = argumentList
+        }
+
+        components.dataFlowAnalyzer.enterCallArguments(fakeCall, argumentList.arguments)
+        components.dataFlowAnalyzer.enterAnonymousFunctionExpression(anonymousFunctionExpression)
+        components.dataFlowAnalyzer.exitCallArguments()
+
+        val resultingCall = components.callCompleter.completeCall(fakeCall, ResolutionMode.ContextIndependent)
+
+        components.dataFlowAnalyzer.exitFunctionCall(fakeCall, callCompleted = true)
+
+        val resolvedArgument = resultingCall.arguments[0]
+
+        (resultingCall.calleeReference as? FirResolvedErrorReference)?.let {
+            if (expectedTypeData?.expectedTypeMismatchIsReportedInChecker != true || it.diagnostic.actualTypeIfMismatch(anonymousFunctionExpression) == null) {
+                return buildErrorExpression(
+                    anonymousFunctionExpression.source?.fakeElement(KtFakeSourceElementKind.ErrorExpressionForTopLevelLambda),
+                    it.diagnostic,
+                    resolvedArgument
+                )
+            }
+        }
+
+        return resolvedArgument
+    }
+
+    private fun ConeDiagnostic.actualTypeIfMismatch(
+        anonymousFunctionExpression: FirAnonymousFunctionExpression
+    ): ConeKotlinType? {
+        if (this !is ConeInapplicableCandidateError) return null
+        val argumentTypeMismatch = candidate.diagnostics.singleOrNull() as? ArgumentTypeMismatch ?: return null
+
+        if (argumentTypeMismatch.argument == anonymousFunctionExpression) {
+            val candidate = candidate as Candidate
+            val storage = if (candidate.usedOuterCs) candidate.system.currentStorage() else candidate.system.asReadOnlyStorage()
+            val substitutor = storage.buildCurrentSubstitutor(components.session.typeContext, emptyMap())
+
+            anonymousFunctionExpression.anonymousFunction.replaceTypeRef(
+                anonymousFunctionExpression.anonymousFunction.typeRef.withReplacedConeType(
+                    substitutor.safeSubstitute(components.session.typeContext, argumentTypeMismatch.actualType) as ConeKotlinType
+                )
+            )
+
+            return argumentTypeMismatch.actualType
+        }
+        return null
+    }
+
     fun resolveCallableReferenceWithSyntheticOuterCall(
         callableReferenceAccess: FirCallableReferenceAccess,
         expectedType: ConeKotlinType?,
diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt
index 8cb6697..256dca8 100644
--- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt
+++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt
@@ -169,7 +169,7 @@
 
                 context.forPropertyInitializer {
                     if (!initializerIsAlreadyResolved) {
-                        val resolutionMode = withExpectedType(returnTypeRefBeforeResolve)
+                        val resolutionMode = withExpectedType(returnTypeRefBeforeResolve, expectedTypeMismatchIsReportedInChecker = true)
                         property.transformReturnTypeRef(transformer, resolutionMode)
                             .transformInitializer(transformer, resolutionMode)
                             .replaceBodyResolveState(FirPropertyBodyResolveState.INITIALIZER_RESOLVED)
@@ -1129,7 +1129,7 @@
                 anonymousFunctionExpression // return the same instance
             }
             is ResolutionMode.WithExpectedType -> {
-                transformTopLevelAnonymousFunctionExpression(anonymousFunctionExpression, data.expectedType)
+                transformTopLevelAnonymousFunctionExpression(anonymousFunctionExpression, data)
             }
 
 
@@ -1155,11 +1155,24 @@
      */
     private fun transformTopLevelAnonymousFunctionExpression(
         anonymousFunctionExpression: FirAnonymousFunctionExpression,
-        expectedType: ConeKotlinType?,
-    ): FirStatement = anonymousFunctionExpression.also {
-        it.replaceAnonymousFunction(transformTopLevelAnonymousFunctionInObsoleteWay(anonymousFunctionExpression, expectedType))
+        expectedTypeData: ResolutionMode.WithExpectedType?,
+    ): FirStatement = when {
+        session.languageVersionSettings.supportsFeature(LanguageFeature.ResolveTopLevelLambdasAsSyntheticCallArgument) ->
+            components.syntheticCallGenerator.resolveAnonymousFunctionExpressionWithSyntheticOuterCall(
+                anonymousFunctionExpression, expectedTypeData, resolutionContext
+            )
+        else -> {
+            @OptIn(OnlyForDefaultLanguageFeatureDisabled::class) // ResolveTopLevelLambdasAsSyntheticCallArgument
+            val updatedAnonymousFunction = transformTopLevelAnonymousFunctionInObsoleteWay(
+                anonymousFunctionExpression, expectedTypeData?.expectedType
+            )
+            anonymousFunctionExpression.replaceAnonymousFunction(updatedAnonymousFunction)
+
+            anonymousFunctionExpression
+        }
     }
 
+    @OnlyForDefaultLanguageFeatureDisabled(LanguageFeature.ResolveTopLevelLambdasAsSyntheticCallArgument)
     private fun transformTopLevelAnonymousFunctionInObsoleteWay(
         anonymousFunctionExpression: FirAnonymousFunctionExpression,
         expectedType: ConeKotlinType?
@@ -1253,6 +1266,37 @@
         )
     }
 
+    @OnlyForDefaultLanguageFeatureDisabled(LanguageFeature.ResolveTopLevelLambdasAsSyntheticCallArgument)
+    private object ImplicitToErrorTypeTransformer : FirTransformer<Any?>() {
+        override fun <E : FirElement> transformElement(element: E, data: Any?): E {
+            return element
+        }
+
+        override fun transformValueParameter(
+            valueParameter: FirValueParameter,
+            data: Any?
+        ): FirStatement =
+            whileAnalysing(valueParameter.moduleData.session, valueParameter) {
+                if (valueParameter.returnTypeRef is FirImplicitTypeRef) {
+                    valueParameter.replaceReturnTypeRef(
+                        valueParameter.returnTypeRef.resolvedTypeFromPrototype(
+                            ConeErrorType(
+                                ConeSimpleDiagnostic(
+                                    "No type for parameter",
+                                    DiagnosticKind.ValueParameterWithNoTypeAnnotation
+                                )
+                            ),
+                            fallbackSource = valueParameter.source?.fakeElement(
+                                KtFakeSourceElementKind.ImplicitReturnTypeOfLambdaValueParameter,
+                            ),
+                        )
+                    )
+                }
+                return valueParameter
+            }
+    }
+
+    @OnlyForDefaultLanguageFeatureDisabled(LanguageFeature.ResolveTopLevelLambdasAsSyntheticCallArgument)
     private fun obtainValueParametersFromResolvedLambdaAtom(
         resolvedLambdaAtom: ConeResolvedLambdaAtom,
         lambda: FirAnonymousFunction,
@@ -1290,6 +1334,7 @@
         }
     }
 
+    @OnlyForDefaultLanguageFeatureDisabled(LanguageFeature.ResolveTopLevelLambdasAsSyntheticCallArgument)
     private fun obtainValueParametersFromExpectedType(
         expectedType: ConeKotlinType?,
         lambda: FirAnonymousFunction
@@ -1305,6 +1350,7 @@
         return obtainValueParametersFromExpectedParameterTypes(parameterTypes, lambda)
     }
 
+    @OnlyForDefaultLanguageFeatureDisabled(LanguageFeature.ResolveTopLevelLambdasAsSyntheticCallArgument)
     private fun obtainValueParametersFromExpectedParameterTypes(
         expectedTypeParameterTypes: List<ConeKotlinType>,
         lambda: FirAnonymousFunction
@@ -1476,34 +1522,6 @@
         }
     }
 
-    private object ImplicitToErrorTypeTransformer : FirTransformer<Any?>() {
-        override fun <E : FirElement> transformElement(element: E, data: Any?): E {
-            return element
-        }
-
-        override fun transformValueParameter(
-            valueParameter: FirValueParameter,
-            data: Any?
-        ): FirStatement =
-            whileAnalysing(valueParameter.moduleData.session, valueParameter) {
-                if (valueParameter.returnTypeRef is FirImplicitTypeRef) {
-                    valueParameter.replaceReturnTypeRef(
-                        valueParameter.returnTypeRef.resolvedTypeFromPrototype(
-                            ConeErrorType(
-                                ConeSimpleDiagnostic(
-                                    "No type for parameter",
-                                    DiagnosticKind.ValueParameterWithNoTypeAnnotation
-                                )
-                            ),
-                            fallbackSource = valueParameter.source?.fakeElement(
-                                KtFakeSourceElementKind.ImplicitReturnTypeOfLambdaValueParameter,
-                            ),
-                        )
-                    )
-                }
-                return valueParameter
-            }
-    }
 
     private val FirVariable.initializerResolved: Boolean
         get() {
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/annotations.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/annotations.kt
index 812cbee..6de4e20 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/annotations.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/annotations.kt
@@ -5,6 +5,8 @@
 
 package org.jetbrains.kotlin.fir
 
+import org.jetbrains.kotlin.config.LanguageFeature
+
 /**
  * [NoMutableState] annotation means that annotated class has no mutable state
  *   and it's safe to use it concurrent environment (e.g. as session component)
@@ -36,3 +38,11 @@
 @RequiresOptIn
 annotation class SessionConfiguration
 
+/**
+ * Declarations that are only being used in case some default language features are disabled: mostly likely due to using not the latest
+ * language version.
+ *
+ * Let's try to have a convention to use a relevant language feature name as a side comment.
+ */
+@RequiresOptIn
+annotation class OnlyForDefaultLanguageFeatureDisabled(val languageFeature: LanguageFeature)
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt
index ab99bae..b12352a 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt
@@ -40,7 +40,8 @@
 
 class ConeCannotInferValueParameterType(
     val valueParameter: FirValueParameterSymbol,
-    override val reason: String = "Cannot infer type for parameter ${valueParameter.name}"
+    override val reason: String = "Cannot infer type for parameter ${valueParameter.name}",
+    val isTopLevelLambda: Boolean = false,
 ) : ConeCannotInferType()
 
 class ConeCannotInferReceiverParameterType(
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirErrorExpressionRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirErrorExpressionRenderer.kt
index fea41be..ed65a2f 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirErrorExpressionRenderer.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirErrorExpressionRenderer.kt
@@ -5,6 +5,7 @@
 
 package org.jetbrains.kotlin.fir.renderer
 
+import org.jetbrains.kotlin.KtFakeSourceElementKind
 import org.jetbrains.kotlin.fir.expressions.FirErrorExpression
 
 abstract class FirErrorExpressionRenderer {
@@ -17,6 +18,11 @@
 class FirErrorExpressionOnlyErrorRenderer : FirErrorExpressionRenderer() {
     override fun renderErrorExpression(errorExpression: FirErrorExpression) {
         printer.print("ERROR_EXPR(${errorExpression.diagnostic.reason})")
+        errorExpression.expression?.let {
+            if (errorExpression.source?.kind == KtFakeSourceElementKind.ErrorExpressionForTopLevelLambda) {
+                it.accept(components.visitor)
+            }
+        }
     }
 }
 
diff --git a/compiler/frontend.common/src/org/jetbrains/kotlin/KtSourceElement.kt b/compiler/frontend.common/src/org/jetbrains/kotlin/KtSourceElement.kt
index fd09373..1fc0e32 100644
--- a/compiler/frontend.common/src/org/jetbrains/kotlin/KtSourceElement.kt
+++ b/compiler/frontend.common/src/org/jetbrains/kotlin/KtSourceElement.kt
@@ -504,6 +504,12 @@
      * For plugin-generated things
      */
     object PluginGenerated : KtFakeSourceElementKind()
+
+    /**
+     * To store some diagnostic for erroneously resolved top-level lambda
+     * See [org.jetbrains.kotlin.config.LanguageFeature.ResolveTopLevelLambdasAsSyntheticCallArgument] and its usages
+     */
+    object ErrorExpressionForTopLevelLambda : KtFakeSourceElementKind()
 }
 
 sealed class AbstractKtSourceElement {
diff --git a/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt b/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt
index 50fcf7c..9ebae20 100644
--- a/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt
+++ b/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt
@@ -173,31 +173,31 @@
 }
 
 fun testFunctionLiterals() {
-    val endsWithVarDeclaration : () -> Boolean = <!INITIALIZER_TYPE_MISMATCH!>{
-        val x = 2
-    }<!>
+    val endsWithVarDeclaration : () -> Boolean = {
+        <!RETURN_TYPE_MISMATCH!>val x = 2<!>
+    }
 
-    val endsWithAssignment: () -> Int = <!INITIALIZER_TYPE_MISMATCH!>{
+    val endsWithAssignment: () -> Int = {
+        var x = 1
+        <!RETURN_TYPE_MISMATCH!>x = 333<!>
+    }
+
+    val endsWithReAssignment: () -> Int = {
+        var x = 1
+        <!RETURN_TYPE_MISMATCH!>x += 333<!>
+    }
+
+    val endsWithFunDeclaration : () -> String = {
         var x = 1
         x = 333
-    }<!>
+        <!RETURN_TYPE_MISMATCH!>fun meow() : Unit {}<!>
+    }
 
-    val endsWithReAssignment: () -> Int = <!INITIALIZER_TYPE_MISMATCH!>{
-        var x = 1
-        x += 333
-    }<!>
-
-    val endsWithFunDeclaration : () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
+    val endsWithObjectDeclaration : () -> Int = {
         var x = 1
         x = 333
-        fun meow() : Unit {}
-    }<!>
-
-    val endsWithObjectDeclaration : () -> Int = <!INITIALIZER_TYPE_MISMATCH!>{
-        var x = 1
-        x = 333
-        <!LOCAL_OBJECT_NOT_ALLOWED!>object A<!> {}
-    }<!>
+        <!RETURN_TYPE_MISMATCH!><!LOCAL_OBJECT_NOT_ALLOWED!>object A<!> {}<!>
+    }
 
     val expectedUnitReturnType1: () -> Unit = {
         val x = 1
diff --git a/compiler/testData/diagnostics/tests/declarationChecks/ScalaLikeNamedFun.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/ScalaLikeNamedFun.fir.kt
index 05a6a14..53e2957 100644
--- a/compiler/testData/diagnostics/tests/declarationChecks/ScalaLikeNamedFun.fir.kt
+++ b/compiler/testData/diagnostics/tests/declarationChecks/ScalaLikeNamedFun.fir.kt
@@ -4,16 +4,16 @@
 
 fun test1(): Int = <!RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
 fun test2(): Int = <!RETURN_TYPE_MISMATCH!>{ 1 }<!>
-val test3: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
-val test4: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH!>{ 1 }<!>
+val test3: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
+val test4: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>{ 1 }<!>
 fun test5(): Int { return <!RETURN_TYPE_MISMATCH!>{ 1 }<!> }
 fun test6(): Int = <!RETURN_TYPE_MISMATCH!>fun (): Int = 1<!>
 
 fun outer() {
     fun test1(): Int = <!RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
     fun test2(): Int = <!RETURN_TYPE_MISMATCH!>{ 1 }<!>
-    val test3: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
-    val test4: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH!>{ 1 }<!>
+    val test3: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
+    val test4: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>{ 1 }<!>
     fun test5(): Int { return <!RETURN_TYPE_MISMATCH!>{ 1 }<!> }
     fun test6(): Int = <!RETURN_TYPE_MISMATCH!>fun (): Int = 1<!>
 }
@@ -21,16 +21,16 @@
 class Outer {
     fun test1(): Int = <!RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
     fun test2(): Int = <!RETURN_TYPE_MISMATCH!>{ 1 }<!>
-    val test3: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
-    val test4: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH!>{ 1 }<!>
+    val test3: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
+    val test4: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>{ 1 }<!>
     fun test5(): Int { return <!RETURN_TYPE_MISMATCH!>{ 1 }<!> }
     fun test6(): Int = <!RETURN_TYPE_MISMATCH!>fun (): Int = 1<!>
 
     class Nested {
         fun test1(): Int = <!RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
         fun test2(): Int = <!RETURN_TYPE_MISMATCH!>{ 1 }<!>
-        val test3: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
-        val test4: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH!>{ 1 }<!>
+        val test3: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>{ <!RETURN_NOT_ALLOWED!>return<!> 1 }<!>
+        val test4: () -> Int = fun (): Int = <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>{ 1 }<!>
         fun test5(): Int { return <!RETURN_TYPE_MISMATCH!>{ 1 }<!> }
         fun test6(): Int = <!RETURN_TYPE_MISMATCH!>fun (): Int = 1<!>
     }
diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/deprecated.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/deprecated.fir.kt
index 60e8bbf..b8510b1 100644
--- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/deprecated.fir.kt
+++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/deprecated.fir.kt
@@ -45,7 +45,7 @@
     val x: <!CONTEXT_RECEIVERS_DEPRECATED!>context<!>(A) () -> Unit = body
     val y = body
     val z: suspend <!CONTEXT_RECEIVERS_DEPRECATED!>context<!>(A) B.() -> Unit = {}
-    val w: (<!CONTEXT_RECEIVERS_DEPRECATED!>context<!>(Int) () -> Unit, <!CONTEXT_RECEIVERS_DEPRECATED!>context<!>(Int) () -> Unit) -> (<!CONTEXT_RECEIVERS_DEPRECATED!>context<!>(Int) () -> Unit) = <!CONTEXT_RECEIVERS_DEPRECATED!>{ a, b -> { } }<!>
+    val w: (<!CONTEXT_RECEIVERS_DEPRECATED!>context<!>(Int) () -> Unit, <!CONTEXT_RECEIVERS_DEPRECATED!>context<!>(Int) () -> Unit) -> (<!CONTEXT_RECEIVERS_DEPRECATED!>context<!>(Int) () -> Unit) = { a, b -> { } }
     return {}
 }
 
diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/ReturnTypeCheck.fir.kt b/compiler/testData/diagnostics/tests/functionAsExpression/ReturnTypeCheck.fir.kt
index 1b7149e..a50ac5d 100644
--- a/compiler/testData/diagnostics/tests/functionAsExpression/ReturnTypeCheck.fir.kt
+++ b/compiler/testData/diagnostics/tests/functionAsExpression/ReturnTypeCheck.fir.kt
@@ -3,8 +3,8 @@
     if (a == 1) return "4"
     when (a) {
         5 -> return "2"
-        3 -> return <!NULL_FOR_NONNULL_TYPE!>null<!>
-        2 -> return <!RETURN_TYPE_MISMATCH!>2<!>
+        3 -> return <!NULL_FOR_NONNULL_TYPE, NULL_FOR_NONNULL_TYPE!>null<!>
+        2 -> return <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>2<!>
     }
     return ""
 }
@@ -13,7 +13,7 @@
     if (a == 1) return@l "4"
     when (a) {
         5 -> return@l "2"
-        3 -> return@l <!RETURN_TYPE_MISMATCH!>null<!>
+        3 -> return@l <!NULL_FOR_NONNULL_TYPE!>null<!>
         2 -> return@l <!RETURN_TYPE_MISMATCH!>2<!>
     }
     return@l ""
diff --git a/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.fir.kt
index 222c025..47504ce 100644
--- a/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.fir.kt
+++ b/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.fir.kt
@@ -4,11 +4,11 @@
 
     val a: () -> Unit = { bar += 4 }
 
-    val b: () -> Int = <!INITIALIZER_TYPE_MISMATCH!>{ bar = 4 }<!>
+    val b: () -> Int = { <!RETURN_TYPE_MISMATCH!>bar = 4<!> }
 
-    val c: () -> <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>UNRESOLVED<!> = { bal[2] = 3 }
+    val c: () -> <!UNRESOLVED_REFERENCE!>UNRESOLVED<!> = { bal[2] = 3 }
 
-    val d: () -> Int = <!INITIALIZER_TYPE_MISMATCH!>{ bar += 4 }<!>
+    val d: () -> Int = { <!RETURN_TYPE_MISMATCH!>bar += 4<!> }
 
     val e: Unit = run { bar += 4 }
 
diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElseWithExplicitType.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElseWithExplicitType.fir.kt
index cd0abe9..905868a 100644
--- a/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElseWithExplicitType.fir.kt
+++ b/compiler/testData/diagnostics/tests/functionLiterals/return/IfWithoutElseWithExplicitType.fir.kt
@@ -6,7 +6,7 @@
 }
 
 val b: () -> Unit = l@ {
-    if (flag) return@l <!RETURN_TYPE_MISMATCH!>4<!>
+    if (flag) return@l <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>4<!>
 }
 
 val c: () -> Any = l@ {
@@ -18,6 +18,6 @@
     5
 }
 
-val e: () -> Int = <!INITIALIZER_TYPE_MISMATCH!>l@ {
-    if (flag) 4
-}<!>
+val e: () -> Int = l@ {
+    <!RETURN_TYPE_MISMATCH!>if (flag) 4<!>
+}
diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/kt66512.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/kt66512.fir.kt
index 10ba818..bd1cc47 100644
--- a/compiler/testData/diagnostics/tests/functionLiterals/return/kt66512.fir.kt
+++ b/compiler/testData/diagnostics/tests/functionLiterals/return/kt66512.fir.kt
@@ -9,7 +9,7 @@
 // ================= Lambdas assigned to a variable =================
 
 val expectedMyUnitExplicitReturnString: () -> MyUnit = l@ {
-    return@l <!RETURN_TYPE_MISMATCH!>""<!>
+    return@l <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>""<!>
 }
 
 // ============== Lambdas passed as function argument ===============
diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/kt66534.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/kt66534.fir.kt
index 79bf1ac..2cf8bbb 100644
--- a/compiler/testData/diagnostics/tests/functionLiterals/return/kt66534.fir.kt
+++ b/compiler/testData/diagnostics/tests/functionLiterals/return/kt66534.fir.kt
@@ -67,7 +67,7 @@
 
 fun expectedFlexibleUnitExplicitReturnString() {
     A.foo = l@ {
-        return@l <!RETURN_TYPE_MISMATCH!>""<!>
+        return@l <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>""<!>
     }
 }
 
diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/unresolvedReferenceInReturnBlock.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/unresolvedReferenceInReturnBlock.fir.kt
index 5b81054..a419cc7 100644
--- a/compiler/testData/diagnostics/tests/functionLiterals/return/unresolvedReferenceInReturnBlock.fir.kt
+++ b/compiler/testData/diagnostics/tests/functionLiterals/return/unresolvedReferenceInReturnBlock.fir.kt
@@ -1,10 +1,10 @@
 // RUN_PIPELINE_TILL: FRONTEND
-val a = l@ <!UNRESOLVED_REFERENCE!>{
+val a = l@ {
     return@l <!UNRESOLVED_REFERENCE!>r<!>
-}<!>
+}
 
 val b = l@ {
     if ("" == "OK") return@l
 
     return@l <!UNRESOLVED_REFERENCE!>r<!>
-}
\ No newline at end of file
+}
diff --git a/compiler/testData/diagnostics/tests/functionTypeInitializerTypeMismatch.fir.kt b/compiler/testData/diagnostics/tests/functionTypeInitializerTypeMismatch.fir.kt
index 831fd3a..9f64536 100644
--- a/compiler/testData/diagnostics/tests/functionTypeInitializerTypeMismatch.fir.kt
+++ b/compiler/testData/diagnostics/tests/functionTypeInitializerTypeMismatch.fir.kt
@@ -1,14 +1,6 @@
 // RUN_PIPELINE_TILL: FRONTEND
 // RENDER_DIAGNOSTICS_MESSAGES
 
-val f1: () -> Int = { <!RETURN_TYPE_MISMATCH("Int; String")!>""<!> }
-val f2: () -> Int = l@ {
-    return@l <!RETURN_TYPE_MISMATCH("Int; String")!>""<!>
-}
-val f3: () -> Int = l@ {
-    if (true) return@l 4
-    return@l <!RETURN_TYPE_MISMATCH("Int; String")!>""<!>
-}
 val f5: () -> Int = <!INITIALIZER_TYPE_MISMATCH("Function0<Int>; Function1<ERROR CLASS: Cannot infer type for parameter it, String>")!>{ <!CANNOT_INFER_PARAMETER_TYPE!>it<!> -> "" }<!>
 val f6: () -> Int = <!INITIALIZER_TYPE_MISMATCH("Function0<Int>; Function1<Any, String>")!>{ it: Any -> "" }<!>
 val f7: () -> Int = {  -> <!RETURN_TYPE_MISMATCH("Int; String")!>""<!> }
@@ -16,7 +8,7 @@
 val f9: String = <!INITIALIZER_TYPE_MISMATCH("String; Function0<String>")!>{  -> "" }<!>
 val f10: Function0<Int> = {  -> <!RETURN_TYPE_MISMATCH("Int; String")!>""<!> }
 val f11: Function0<<!REDUNDANT_PROJECTION("Function0<out Int>")!>out<!> Int> = {  -> <!RETURN_TYPE_MISMATCH("Int; String")!>""<!> }
-val f12: Function0<<!CONFLICTING_PROJECTION("Function0<in Int>")!>in<!> Int> = {  -> "" }
+val f12: Function0<<!CONFLICTING_PROJECTION("Function0<in Int>")!>in<!> Int> = {  -> <!RETURN_TYPE_MISMATCH("Int; String")!>""<!> }
 val f13: Function0<*> = {  -> "" }
 val f14: Function<Int> = {  -> <!RETURN_TYPE_MISMATCH("Int; String")!>""<!> }
 val f15: Function<Int> = { <!RETURN_TYPE_MISMATCH("Int; String")!>""<!> }
diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithExpectedType.fir.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithExpectedType.fir.kt
index 2c57d19..4fd739b 100644
--- a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithExpectedType.fir.kt
+++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithExpectedType.fir.kt
@@ -13,7 +13,7 @@
 
 val b: () -> Unit = l@{
     // Error, coercion can't be applied at this position!
-    if (true) return@l <!RETURN_TYPE_MISMATCH!>"hello"<!>
+    if (true) return@l <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>"hello"<!>
 
     // However, this is OK, because here coercion is applied
     "hello"
diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithoutExpectedType.fir.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithoutExpectedType.fir.kt
index 98c2713..838d55e 100644
--- a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithoutExpectedType.fir.kt
+++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionWithoutExpectedType.fir.kt
@@ -11,8 +11,8 @@
         return@l
     }
 
-    val c = l@<!CANNOT_INFER_PARAMETER_TYPE!>{
+    val c = l@{
         // Error: block doesn't have an expected type, so call can't be inferred!
         return@l <!CANNOT_INFER_PARAMETER_TYPE, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>materialize<!>()
-    }<!>
+    }
 }
diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/noCoercion.fir.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/noCoercion.fir.kt
index 8f88d85..2414791 100644
--- a/compiler/testData/diagnostics/tests/inference/coercionToUnit/noCoercion.fir.kt
+++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/noCoercion.fir.kt
@@ -10,9 +10,9 @@
 }
 
 fun noCoercionBlockHasExplicitType() {
-    val b: () -> Int = <!INITIALIZER_TYPE_MISMATCH!>{
-        if (true) 42
-    }<!>
+    val b: () -> Int = {
+        <!RETURN_TYPE_MISMATCH!>if (true) 42<!>
+    }
 }
 
 fun noCoercionBlockHasExplicitReturn() {
diff --git a/compiler/testData/diagnostics/tests/inference/constraints/wrongExpectedTypeForWhen.fir.kt b/compiler/testData/diagnostics/tests/inference/constraints/wrongExpectedTypeForWhen.fir.kt
index 4c8fb5e..9f7dbeb 100644
--- a/compiler/testData/diagnostics/tests/inference/constraints/wrongExpectedTypeForWhen.fir.kt
+++ b/compiler/testData/diagnostics/tests/inference/constraints/wrongExpectedTypeForWhen.fir.kt
@@ -1,6 +1,6 @@
 // RUN_PIPELINE_TILL: FRONTEND
 fun foo() {
-    var f: Int = <!INITIALIZER_TYPE_MISMATCH!>if (true) <!ARGUMENT_TYPE_MISMATCH!>{ x: Long ->  }<!> else { x: Long ->  }<!>
+    var f: Int = <!INITIALIZER_TYPE_MISMATCH!>if (true) <!ARGUMENT_TYPE_MISMATCH!>{ x: Long ->  }<!> else <!ARGUMENT_TYPE_MISMATCH!>{ x: Long ->  }<!><!>
 }
 
 class A {
diff --git a/compiler/testData/diagnostics/tests/inference/pcla/forceLambdaCompletionFromReturnStatement/earlyReturn.fir.kt b/compiler/testData/diagnostics/tests/inference/pcla/forceLambdaCompletionFromReturnStatement/earlyReturn.fir.kt
index a744731..856c0e4 100644
--- a/compiler/testData/diagnostics/tests/inference/pcla/forceLambdaCompletionFromReturnStatement/earlyReturn.fir.kt
+++ b/compiler/testData/diagnostics/tests/inference/pcla/forceLambdaCompletionFromReturnStatement/earlyReturn.fir.kt
@@ -8,9 +8,9 @@
 fun main(b: Boolean) {
     build { container ->
         if (b) {
-            return@build <!UNRESOLVED_REFERENCE!>{ <!VALUE_PARAMETER_WITHOUT_EXPLICIT_TYPE!>arg<!> ->
-                arg.<!UNRESOLVED_REFERENCE!>length<!>
-            }<!>
+            return@build { arg ->
+                arg.length
+            }
         }
         container.consume({ arg: String -> })
     }
diff --git a/compiler/testData/diagnostics/tests/inference/pcla/specialCallsWithLambdas.fir.kt b/compiler/testData/diagnostics/tests/inference/pcla/specialCallsWithLambdas.fir.kt
index 1dd79da..744791a3e 100644
--- a/compiler/testData/diagnostics/tests/inference/pcla/specialCallsWithLambdas.fir.kt
+++ b/compiler/testData/diagnostics/tests/inference/pcla/specialCallsWithLambdas.fir.kt
@@ -176,7 +176,7 @@
 
 fun poll84(): Flow<String> {
     return flow {
-        val inv = {<!RETURN_TYPE_MISMATCH!>{1}<!>} in setOf({{1f}})
+        val inv = {{<!RETURN_TYPE_MISMATCH!>1<!>}} in setOf({{1f}})
         <!UNRESOLVED_REFERENCE!>inv<!>()
     }
 }
diff --git a/compiler/testData/diagnostics/tests/inference/recursiveLocalFuns/recursiveLambda.fir.kt b/compiler/testData/diagnostics/tests/inference/recursiveLocalFuns/recursiveLambda.fir.kt
index 5054697..4ac450f 100644
--- a/compiler/testData/diagnostics/tests/inference/recursiveLocalFuns/recursiveLambda.fir.kt
+++ b/compiler/testData/diagnostics/tests/inference/recursiveLocalFuns/recursiveLambda.fir.kt
@@ -1,6 +1,6 @@
 // RUN_PIPELINE_TILL: FRONTEND
 fun foo() {
-    fun bar() = <!RECURSION_IN_IMPLICIT_TYPES!>{
+    fun bar() = {
         <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar()<!>
-    }<!>
+    }
 }
diff --git a/compiler/testData/diagnostics/tests/inference/reportingImprovements/ErrorTypeAsGenericParameter.fir.kt b/compiler/testData/diagnostics/tests/inference/reportingImprovements/ErrorTypeAsGenericParameter.fir.kt
index 1e0fec5..382a41b 100644
--- a/compiler/testData/diagnostics/tests/inference/reportingImprovements/ErrorTypeAsGenericParameter.fir.kt
+++ b/compiler/testData/diagnostics/tests/inference/reportingImprovements/ErrorTypeAsGenericParameter.fir.kt
@@ -4,6 +4,6 @@
 fun <T, R, S> foo(block: (T)-> R, second: (T)-> S) = block
 
 fun main() {
-    val fff = <!UNRESOLVED_REFERENCE!>{ x: Int -> <!UNRESOLVED_REFERENCE!>aaa<!> }<!>
+    val fff = { x: Int -> <!UNRESOLVED_REFERENCE!>aaa<!> }
     <!CANNOT_INFER_PARAMETER_TYPE, CANNOT_INFER_PARAMETER_TYPE, CANNOT_INFER_PARAMETER_TYPE!>foo<!>(<!ARGUMENT_TYPE_MISMATCH!>fff<!>, { <!CANNOT_INFER_PARAMETER_TYPE!>x<!> -> x + 1 })
 }
diff --git a/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt b/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt
index d5154ad..ff9f53a 100644
--- a/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt
+++ b/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt
@@ -47,7 +47,7 @@
     val x1cp = foo<Int, context(<!UNRESOLVED_REFERENCE!>_<!>) () -> Unit> { <!CANNOT_INFER_PARAMETER_TYPE!>{ "" }<!> }
     val x2 = foo<Int, (Int) -> <!UNRESOLVED_REFERENCE!>_<!>> { <!UNRESOLVED_REFERENCE!>{ it }<!> }
     val x3 = foo<Int, ((<!UNRESOLVED_REFERENCE!>_<!>)) -> <!UNRESOLVED_REFERENCE!>_<!>> { <!CANNOT_INFER_PARAMETER_TYPE!>{ it }<!> }
-    val x4 = <!CANNOT_INFER_PARAMETER_TYPE, CANNOT_INFER_PARAMETER_TYPE, FUNCTION_CALL_EXPECTED!>foo<!><!UNRESOLVED_REFERENCE!><<!>Int<!SYNTAX!>, _ -> Float><!> { <!UNRESOLVED_REFERENCE!>{ <!UNRESOLVED_REFERENCE!>it<!> }<!> }
+    val x4 = <!CANNOT_INFER_PARAMETER_TYPE, CANNOT_INFER_PARAMETER_TYPE, FUNCTION_CALL_EXPECTED!>foo<!><!UNRESOLVED_REFERENCE!><<!>Int<!SYNTAX!>, _ -> Float><!> <!CANNOT_INFER_PARAMETER_TYPE!>{ { <!UNRESOLVED_REFERENCE!>it<!> } }<!>
     val x5 = foo<Int, Foo<(<!UNRESOLVED_REFERENCE!>_<!>) -> Float>> { <!ARGUMENT_TYPE_MISMATCH!>{ it }<!> }
     val x6 = foo<Int, Foo<(<!UNRESOLVED_REFERENCE!>_<!>) -> <!UNRESOLVED_REFERENCE!>_<!>>> { <!ARGUMENT_TYPE_MISMATCH!>{ it }<!> }
     val x7 = foo<Int, Foo<(Int) -> <!UNRESOLVED_REFERENCE!>_<!>>> { <!ARGUMENT_TYPE_MISMATCH!>{ it }<!> }
diff --git a/compiler/testData/diagnostics/tests/regressions/kt235.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt235.fir.kt
index 73c85fa..a390148 100644
--- a/compiler/testData/diagnostics/tests/regressions/kt235.fir.kt
+++ b/compiler/testData/diagnostics/tests/regressions/kt235.fir.kt
@@ -5,29 +5,29 @@
 
 fun main() {
     val array = MyArray()
-    val f: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
-        array[2] = 23 //error: Type mismatch: inferred type is Int (!!!) but String was expected
-    }<!>
-    val g: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
+    val f: () -> String = {
+        <!RETURN_TYPE_MISMATCH!>array[2] = 23<!> //error: Type mismatch: inferred type is Int (!!!) but String was expected
+    }
+    val g: () -> String = {
         var x = 1
-        x += 2  //no error, but it should be here
-    }<!>
-    val h: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
+        <!RETURN_TYPE_MISMATCH!>x += 2<!>  //no error, but it should be here
+    }
+    val h: () -> String = {
         var x = 1
-        x = 2  //the same
-    }<!>
+        <!RETURN_TYPE_MISMATCH!>x = 2<!>  //the same
+    }
     val array1 = MyArray1()
-    val i: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
-        array1[2] = 23
-    }<!>
+    val i: () -> String = {
+        <!RETURN_TYPE_MISMATCH!>array1[2] = 23<!>
+    }
 
-    val fi: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
-        array[2] = 23
-    }<!>
-    val gi: () -> String = <!INITIALIZER_TYPE_MISMATCH!>{
+    val fi: () -> String = {
+        <!RETURN_TYPE_MISMATCH!>array[2] = 23<!>
+    }
+    val gi: () -> String = {
         var x = 1
-        x += 21
-    }<!>
+        <!RETURN_TYPE_MISMATCH!>x += 21<!>
+    }
 
     var m: MyNumber = MyNumber()
     val a: () -> MyNumber = {
diff --git a/compiler/testData/diagnostics/tests/resolve/newLineLambda.fir.kt b/compiler/testData/diagnostics/tests/resolve/newLineLambda.fir.kt
index 5773198..058beec 100644
--- a/compiler/testData/diagnostics/tests/resolve/newLineLambda.fir.kt
+++ b/compiler/testData/diagnostics/tests/resolve/newLineLambda.fir.kt
@@ -112,7 +112,7 @@
 
 fun f1(): (() -> Unit) -> (() -> Unit) -> Unit {
     return <!RETURN_TYPE_MISMATCH!>{ l1 ->
-        l1()
-        <!TOO_MANY_ARGUMENTS!>{ <!CANNOT_INFER_PARAMETER_TYPE!>l2<!> -> <!UNRESOLVED_REFERENCE!>l2<!>() }<!>
+        <!RETURN_TYPE_MISMATCH!>l1()
+        <!TOO_MANY_ARGUMENTS!>{ <!CANNOT_INFER_PARAMETER_TYPE!>l2<!> -> <!UNRESOLVED_REFERENCE!>l2<!>() }<!><!>
     }<!>
 }
diff --git a/compiler/testData/diagnostics/tests/when/kt47922.fir.kt b/compiler/testData/diagnostics/tests/when/kt47922.fir.kt
index ca9f054..42a2f54 100644
--- a/compiler/testData/diagnostics/tests/when/kt47922.fir.kt
+++ b/compiler/testData/diagnostics/tests/when/kt47922.fir.kt
@@ -13,10 +13,10 @@
 
 sealed class ToState
 
-val sealedTest: SealedBase.() -> ToState? = <!INITIALIZER_TYPE_MISMATCH!>{
-    <!NO_ELSE_IN_WHEN!>when<!>(this) {}
-}<!>
+val sealedTest: SealedBase.() -> ToState? = {
+    <!RETURN_TYPE_MISMATCH!><!NO_ELSE_IN_WHEN!>when<!>(this) {}<!>
+}
 
-val nonSealedTest: NonSealedBase.() -> ToState? = <!INITIALIZER_TYPE_MISMATCH!>{
-    when(this) {}
-}<!>
+val nonSealedTest: NonSealedBase.() -> ToState? = {
+    <!RETURN_TYPE_MISMATCH!>when(this) {}<!>
+}
diff --git a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/nullableUnitLiteral.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/nullableUnitLiteral.fir.kt
index 1047927..f65a443 100644
--- a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/nullableUnitLiteral.fir.kt
+++ b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/nullableUnitLiteral.fir.kt
@@ -4,8 +4,8 @@
 fun test() {
     val closeable: java.io.Closeable? = null
     val closeF = fun() { closeable?.close() }
-    val closeFB = fun(): Unit = <!RETURN_TYPE_MISMATCH!>closeable?.close()<!>
-    val closeFR = fun() { return <!RETURN_TYPE_MISMATCH!>closeable?.close()<!> }
+    val closeFB = fun(): Unit = <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>closeable?.close()<!>
+    val closeFR = fun() { return <!RETURN_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>closeable?.close()<!> }
     val closeL = { closeable?.close() }
     val closeLR = label@ { return@label closeable?.close() }
 }
diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt
index c92a921..f117096 100644
--- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt
+++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt
@@ -378,6 +378,8 @@
     AnnotationDefaultTargetMigrationWarning(KOTLIN_2_2, kind = BUG_FIX), // KT-73255, KT-73494
     AllowDnnTypeOverridingFlexibleType(KOTLIN_2_2, kind = OTHER), // KT-74049
 
+    ResolveTopLevelLambdasAsSyntheticCallArgument(KOTLIN_2_1), // KT-67869
+
     // 2.3
 
     ForbidCompanionInLocalInnerClass(KOTLIN_2_3, kind = BUG_FIX),
diff --git a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt
index ec540af..d9dadc0 100644
--- a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt
+++ b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt
@@ -229,7 +229,7 @@
 
     fun TypeConstructorMarker.isFinalClassConstructor(): Boolean
 
-    fun TypeVariableMarker.freshTypeConstructor(): TypeConstructorMarker
+    fun TypeVariableMarker./**/freshTypeConstructor(): TypeConstructorMarker
 
     fun CapturedTypeMarker.typeConstructorProjection(): TypeArgumentMarker
     fun CapturedTypeMarker.typeParameter(): TypeParameterMarker?