Version 2.18.0-155.0.dev

Merge commit '40ad7aee40a82aba55a6a9481b9421c6785c9a2b' into 'dev'
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index ddd0e28..02535d9 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -5934,48 +5934,39 @@
       }
 
       variable.type = function.computeFunctionType(libraryBuilder.nonNullable);
-      if (isFunctionExpression) {
-        Expression? oldInitializer = variable.initializer;
-        variable.initializer = new FunctionExpression(function)
-          ..parent = variable
-          ..fileOffset = formals.charOffset;
-        exitLocalScope();
-        // This is matched by the call to [beginNode] in [enterFunction].
-        typeInferrer.assignedVariables.endNode(variable.initializer!,
-            isClosureOrLateVariableInitializer: true);
-        Expression expression = new NamedFunctionExpressionJudgment(variable);
-        if (oldInitializer != null) {
-          // This must have been a compile-time error.
-          Expression error = oldInitializer;
-          assert(isErroneousNode(error));
-          int offset = expression.fileOffset;
-          push(new Let(
-              new VariableDeclaration.forValue(error)..fileOffset = offset,
-              expression)
-            ..fileOffset = offset);
-        } else {
-          push(expression);
-        }
-      } else {
-        declaration.function = function;
-        function.parent = declaration;
-        if (variable.initializer != null) {
-          // This must have been a compile-time error.
-          assert(isErroneousNode(variable.initializer!));
 
-          push(forest
-              .createBlock(declaration.fileOffset, noLocation, <Statement>[
-            forest.createExpressionStatement(
-                offsetForToken(token), variable.initializer!),
-            declaration
-          ]));
-          variable.initializer = null;
-        } else {
-          push(declaration);
-        }
-        // This is matched by the call to [beginNode] in [enterFunction].
-        typeInferrer.assignedVariables
-            .endNode(declaration, isClosureOrLateVariableInitializer: true);
+      declaration.function = function;
+      function.parent = declaration;
+      Statement statement;
+      if (variable.initializer != null) {
+        // This must have been a compile-time error.
+        assert(isErroneousNode(variable.initializer!));
+
+        statement =
+            forest.createBlock(declaration.fileOffset, noLocation, <Statement>[
+          forest.createExpressionStatement(
+              offsetForToken(token), variable.initializer!),
+          declaration
+        ]);
+        variable.initializer = null;
+      } else {
+        statement = declaration;
+      }
+      // This is matched by the call to [beginNode] in [enterFunction].
+      typeInferrer.assignedVariables
+          .endNode(declaration, isClosureOrLateVariableInitializer: true);
+      if (isFunctionExpression) {
+        // This is an error case. An expression is expected but we got a
+        // function declaration instead. We wrap it in a [BlockExpression].
+        exitLocalScope();
+        push(new BlockExpression(
+            forest.createBlock(declaration.fileOffset, noLocation, [statement]),
+            buildProblem(fasta.messageNamedFunctionExpression,
+                declaration.fileOffset, noLength,
+                // Error has already been reported by the parser.
+                suppressMessage: true)));
+      } else {
+        push(statement);
       }
     } else {
       unhandled("${declaration.runtimeType}", "pushNamedFunction",
diff --git a/pkg/front_end/lib/src/fasta/kernel/forest.dart b/pkg/front_end/lib/src/fasta/kernel/forest.dart
index 8593b65..16a32f9 100644
--- a/pkg/front_end/lib/src/fasta/kernel/forest.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/forest.dart
@@ -366,7 +366,7 @@
 
   /// Return a representation of a block of [statements] at the given
   /// [fileOffset].
-  Statement createBlock(
+  Block createBlock(
       int fileOffset, int fileEndOffset, List<Statement> statements) {
     // ignore: unnecessary_null_comparison
     assert(fileOffset != null);
diff --git a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
index 71ba7f6..75dff4b 100644
--- a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
@@ -108,7 +108,19 @@
   @override
   ExpressionInferenceResult visitBlockExpression(
       BlockExpression node, DartType typeContext) {
-    return _unhandledExpression(node, typeContext);
+    // This is only used for error cases. The spec doesn't use this and
+    // therefore doesn't specify the type context for the subterms.
+    if (!inferrer.isTopLevel) {
+      StatementInferenceResult bodyResult = inferrer.inferStatement(node.body);
+      if (bodyResult.hasChanged) {
+        node.body = (bodyResult.statement as Block)..parent = node;
+      }
+    }
+    ExpressionInferenceResult valueResult = inferrer.inferExpression(
+        node.value, const UnknownType(), true,
+        isVoidAllowed: true);
+    node.value = valueResult.expression..parent = node;
+    return new ExpressionInferenceResult(valueResult.inferredType, node);
   }
 
   @override
@@ -2930,16 +2942,6 @@
         isImplicitCall: true);
   }
 
-  ExpressionInferenceResult visitNamedFunctionExpressionJudgment(
-      NamedFunctionExpressionJudgment node, DartType typeContext) {
-    ExpressionInferenceResult initializerResult =
-        inferrer.inferExpression(node.variable.initializer!, typeContext, true);
-    node.variable.initializer = initializerResult.expression
-      ..parent = node.variable;
-    node.variable.type = initializerResult.inferredType;
-    return new ExpressionInferenceResult(initializerResult.inferredType, node);
-  }
-
   @override
   ExpressionInferenceResult visitNot(Not node, DartType typeContext) {
     InterfaceType boolType =
diff --git a/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart b/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
index 01e408e..56d562f 100644
--- a/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
@@ -1226,32 +1226,6 @@
   }
 }
 
-/// Concrete shadow object representing a named function expression.
-///
-/// Named function expressions are not legal in Dart, but they are accepted by
-/// the parser and BodyBuilder for error recovery purposes.
-///
-/// A named function expression of the form `f() { ... }` is represented as the
-/// kernel expression:
-///
-///     let f = () { ... } in f
-class NamedFunctionExpressionJudgment extends Let
-    implements ExpressionJudgment {
-  NamedFunctionExpressionJudgment(VariableDeclaration variable)
-      : super(variable, new VariableGet(variable));
-
-  @override
-  ExpressionInferenceResult acceptInference(
-      InferenceVisitor visitor, DartType typeContext) {
-    return visitor.visitNamedFunctionExpressionJudgment(this, typeContext);
-  }
-
-  @override
-  String toString() {
-    return "NamedFunctionExpressionJudgment(${toStringInternal()})";
-  }
-}
-
 /// Internal expression representing a null-aware method invocation.
 ///
 /// A null-aware method invocation of the form `a?.b(...)` is encoded as:
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index bb6d2ee..4ab6e5a 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -2364,7 +2364,8 @@
     if (libraryFeatures.namedArgumentsAnywhere.isEnabled &&
         arguments.argumentsOriginalOrder != null &&
         hoistedExpressions == null &&
-        !isTopLevel) {
+        !isTopLevel &&
+        !isConst) {
       hoistedExpressions = localHoistedExpressions = <VariableDeclaration>[];
     }
 
diff --git a/pkg/front_end/test/text_representation/internal_ast_text_representation_test.dart b/pkg/front_end/test/text_representation/internal_ast_text_representation_test.dart
index a1d7543..857b3a1 100644
--- a/pkg/front_end/test/text_representation/internal_ast_text_representation_test.dart
+++ b/pkg/front_end/test/text_representation/internal_ast_text_representation_test.dart
@@ -64,7 +64,6 @@
     _testInternalPropertyGet();
     _testInternalPropertySet();
     _testExpressionInvocation();
-    _testNamedFunctionExpressionJudgment();
     _testNullAwareMethodInvocation();
     _testNullAwarePropertyGet();
     _testNullAwarePropertySet();
@@ -589,15 +588,6 @@
 0<void, dynamic>(1, foo: 2, bar: 3)''');
 }
 
-void _testNamedFunctionExpressionJudgment() {
-  testExpression(
-      new NamedFunctionExpressionJudgment(new VariableDeclarationImpl('foo',
-          initializer:
-              new FunctionExpression(new FunctionNode(new Block([]))))),
-      '''
-let dynamic foo = dynamic () {} in foo''');
-}
-
 void _testNullAwareMethodInvocation() {
   VariableDeclarationImpl variable =
       new VariableDeclarationImpl.forValue(new IntLiteral(0));
diff --git a/pkg/front_end/test/utils/kernel_chain.dart b/pkg/front_end/test/utils/kernel_chain.dart
index 3457bb1..93beea1 100644
--- a/pkg/front_end/test/utils/kernel_chain.dart
+++ b/pkg/front_end/test/utils/kernel_chain.dart
@@ -7,8 +7,6 @@
 import 'dart:async';
 import 'dart:io' show Directory, File, IOSink, Platform;
 
-import 'dart:typed_data' show Uint8List;
-
 import 'package:_fe_analyzer_shared/src/util/relativize.dart'
     show isWindows, relativizeUri;
 
@@ -454,51 +452,38 @@
         writeToFile = false;
       }
     }
-
-    Sink<List<int>> sink;
-    String writeMessage;
-    if (writeToFile && !skipVm) {
-      Directory tmp = await Directory.systemTemp.createTemp();
-      Uri uri = tmp.uri.resolve("generated.dill");
-      File generated = new File.fromUri(uri);
-      sink = generated.openWrite();
-      result = new ComponentResult(
-          result.description,
-          result.component,
-          result.userLibraries,
-          result.compilationSetup,
-          result.sourceTarget,
-          uri);
-      writeMessage = "Wrote component to `${generated.path}`";
-    } else {
-      sink = new DevNullSink();
-      writeMessage = "Wrote component to /dev/null";
-    }
+    ByteSink sink = new ByteSink();
+    bool good = false;
     try {
       // TODO(johnniwinther,jensj): Avoid serializing the sdk.
       new BinaryPrinter(sink).writeComponentFile(component);
+      good = true;
     } catch (e, s) {
       return fail(result, e, s);
     } finally {
-      print(writeMessage);
-      if (sink is IOSink) {
-        await sink.close();
+      if (good && writeToFile && !skipVm) {
+        Directory tmp = await Directory.systemTemp.createTemp();
+        Uri uri = tmp.uri.resolve("generated.dill");
+        File generated = new File.fromUri(uri);
+        IOSink ioSink = generated.openWrite();
+        ioSink.add(sink.builder.takeBytes());
+        await ioSink.close();
+        result = new ComponentResult(
+            result.description,
+            result.component,
+            result.userLibraries,
+            result.compilationSetup,
+            result.sourceTarget,
+            uri);
+        print("Wrote component to `${generated.path}`.");
       } else {
-        sink.close();
+        print("Wrote component to memory.");
       }
     }
     return pass(result);
   }
 }
 
-class DevNullSink<T> extends Sink<T> {
-  @override
-  void add(T data) {}
-
-  @override
-  void close() {}
-}
-
 class ReadDill extends Step<Uri, Uri, ChainContext> {
   const ReadDill();
 
@@ -516,32 +501,6 @@
   }
 }
 
-class BytesCollector implements Sink<List<int>> {
-  final List<List<int>> lists = <List<int>>[];
-
-  int length = 0;
-
-  @override
-  void add(List<int> data) {
-    lists.add(data);
-    length += data.length;
-  }
-
-  Uint8List collect() {
-    Uint8List result = new Uint8List(length);
-    int offset = 0;
-    for (List<int> list in lists) {
-      result.setRange(offset, offset += list.length, list);
-    }
-    lists.clear();
-    length = 0;
-    return result;
-  }
-
-  @override
-  void close() {}
-}
-
 Future<String> runDiff(Uri expected, String actual) async {
   if (Platform.isWindows) {
     // TODO(johnniwinther): Work-around for Windows. For some reason piping
diff --git a/pkg/front_end/testcases/enhanced_enums/named_arguments_anywhere/redirecting_constructor.dart.weak.outline.expect b/pkg/front_end/testcases/enhanced_enums/named_arguments_anywhere/redirecting_constructor.dart.weak.outline.expect
index 336105f..0870c9a 100644
--- a/pkg/front_end/testcases/enhanced_enums/named_arguments_anywhere/redirecting_constructor.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/enhanced_enums/named_arguments_anywhere/redirecting_constructor.dart.weak.outline.expect
@@ -6,8 +6,8 @@
   static const field core::List<self::C> values = const <self::C>[self::C::a, self::C::b, self::C::c, self::C::d, self::C::e, self::C::f];
   final field core::String log;
   static const field self::C a = const self::C::•(0, "a", 1, 2, z: 3);
-  static const field self::C b = let final core::int #t1 = 1 in let final core::String #t2 = "b" in let final core::int #t3 = 3 in const self::C::•(#t1, #t2, 1, 2, z: #t3);
-  static const field self::C c = let final core::int #t4 = 2 in let final core::String #t5 = "c" in let final core::int #t6 = 1 in let final core::int #t7 = 3 in const self::C::•(#t4, #t5, #t6, 2, z: #t7);
+  static const field self::C b = const self::C::•(1, "b", 1, 2, z: 3);
+  static const field self::C c = const self::C::•(2, "c", 1, 2, z: 3);
   static const field self::C d = const self::C::named1(3, "d", 1, 2, 3);
   static const field self::C e = const self::C::named2(4, "e", 1, 2, 3);
   static const field self::C f = const self::C::named3(5, "f", 1, 2, 3);
@@ -18,10 +18,10 @@
     : this self::C::•(#index, #name, x, y, z: z)
     ;
   const constructor named2(core::int #index, core::String #name, core::int x, core::int y, core::int z) → self::C
-    : final core::int #t8 = #index, final core::String #t9 = #name, final core::int #t10 = x, final core::int #t11 = z, this self::C::•(#t8, #t9, #t10, y, z: #t11)
+    : final core::int #t1 = #index, final core::String #t2 = #name, final core::int #t3 = x, final core::int #t4 = z, this self::C::•(#t1, #t2, #t3, y, z: #t4)
     ;
   const constructor named3(core::int #index, core::String #name, core::int x, core::int y, core::int z) → self::C
-    : final core::int #t12 = #index, final core::String #t13 = #name, final core::int #t14 = z, this self::C::•(#t12, #t13, x, y, z: #t14)
+    : final core::int #t5 = #index, final core::String #t6 = #name, final core::int #t7 = z, this self::C::•(#t5, #t6, x, y, z: #t7)
     ;
   method toString() → core::String
     return "C.${this.{core::_Enum::_name}{core::String}}";
@@ -35,8 +35,8 @@
 Extra constant evaluation status:
 Evaluated: ListLiteral @ org-dartlang-testcase:///redirecting_constructor.dart:5:6 -> ListConstant(const <C*>[const C{C.log: "x=1, y=2, z=3", _Enum.index: 0, _Enum._name: "a"}, const C{C.log: "x=1, y=2, z=3", _Enum.index: 1, _Enum._name: "b"}, const C{C.log: "x=1, y=2, z=3", _Enum.index: 2, _Enum._name: "c"}, const C{C.log: "x=1, y=2, z=3", _Enum.index: 3, _Enum._name: "d"}, const C{C.log: "x=1, y=2, z=3", _Enum.index: 4, _Enum._name: "e"}, const C{C.log: "x=1, y=2, z=3", _Enum.index: 5, _Enum._name: "f"}])
 Evaluated: ConstructorInvocation @ org-dartlang-testcase:///redirecting_constructor.dart:6:3 -> InstanceConstant(const C{C.log: "x=1, y=2, z=3", _Enum.index: 0, _Enum._name: "a"})
-Evaluated: Let @ org-dartlang-testcase:///redirecting_constructor.dart:7:3 -> InstanceConstant(const C{C.log: "x=1, y=2, z=3", _Enum.index: 1, _Enum._name: "b"})
-Evaluated: Let @ org-dartlang-testcase:///redirecting_constructor.dart:8:3 -> InstanceConstant(const C{C.log: "x=1, y=2, z=3", _Enum.index: 2, _Enum._name: "c"})
+Evaluated: ConstructorInvocation @ org-dartlang-testcase:///redirecting_constructor.dart:7:3 -> InstanceConstant(const C{C.log: "x=1, y=2, z=3", _Enum.index: 1, _Enum._name: "b"})
+Evaluated: ConstructorInvocation @ org-dartlang-testcase:///redirecting_constructor.dart:8:3 -> InstanceConstant(const C{C.log: "x=1, y=2, z=3", _Enum.index: 2, _Enum._name: "c"})
 Evaluated: ConstructorInvocation @ org-dartlang-testcase:///redirecting_constructor.dart:9:3 -> InstanceConstant(const C{C.log: "x=1, y=2, z=3", _Enum.index: 3, _Enum._name: "d"})
 Evaluated: ConstructorInvocation @ org-dartlang-testcase:///redirecting_constructor.dart:10:3 -> InstanceConstant(const C{C.log: "x=1, y=2, z=3", _Enum.index: 4, _Enum._name: "e"})
 Evaluated: ConstructorInvocation @ org-dartlang-testcase:///redirecting_constructor.dart:11:3 -> InstanceConstant(const C{C.log: "x=1, y=2, z=3", _Enum.index: 5, _Enum._name: "f"})
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression.dart b/pkg/front_end/testcases/general/illegal_named_function_expression.dart
index ac09db3..5289ab2 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression.dart
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression.dart
@@ -2,7 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-main() {
+test() {
   var x = void f<T>(T t) {};
   print(x.runtimeType);
   print(void g<T>(T t) {});
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.textual_outline.expect b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.textual_outline.expect
index bae895a..a9f9e5f 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.textual_outline.expect
@@ -1 +1 @@
-main() {}
+test() {}
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.textual_outline_modelled.expect
index bae895a..a9f9e5f 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.textual_outline_modelled.expect
@@ -1 +1 @@
-main() {}
+test() {}
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.expect b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.expect
index 812ba6f..9f8e706 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.expect
@@ -13,8 +13,16 @@
 import self as self;
 import "dart:core" as core;
 
-static method main() → dynamic {
-  <T extends core::Object? = dynamic>(T%) → Null x = let final <T extends core::Object? = dynamic>(T%) → Null f = <T extends core::Object? = dynamic>(T% t) → Null {} in f;
+static method test() → dynamic {
+  invalid-type x = block {
+    function f<T extends core::Object? = dynamic>(T% t) → void {}
+  } =>invalid-expression "pkg/front_end/testcases/general/illegal_named_function_expression.dart:6:11: Error: A function expression can't have a name.
+  var x = void f<T>(T t) {};
+          ^";
   core::print(x.{core::Object::runtimeType}{core::Type});
-  core::print(let final <T extends core::Object? = dynamic>(T%) → Null g = <T extends core::Object? = dynamic>(T% t) → Null {} in g);
+  core::print( block {
+    function g<T extends core::Object? = dynamic>(T% t) → void {}
+  } =>invalid-expression "pkg/front_end/testcases/general/illegal_named_function_expression.dart:8:9: Error: A function expression can't have a name.
+  print(void g<T>(T t) {});
+        ^");
 }
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.modular.expect b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.modular.expect
index 812ba6f..9f8e706 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.modular.expect
@@ -13,8 +13,16 @@
 import self as self;
 import "dart:core" as core;
 
-static method main() → dynamic {
-  <T extends core::Object? = dynamic>(T%) → Null x = let final <T extends core::Object? = dynamic>(T%) → Null f = <T extends core::Object? = dynamic>(T% t) → Null {} in f;
+static method test() → dynamic {
+  invalid-type x = block {
+    function f<T extends core::Object? = dynamic>(T% t) → void {}
+  } =>invalid-expression "pkg/front_end/testcases/general/illegal_named_function_expression.dart:6:11: Error: A function expression can't have a name.
+  var x = void f<T>(T t) {};
+          ^";
   core::print(x.{core::Object::runtimeType}{core::Type});
-  core::print(let final <T extends core::Object? = dynamic>(T%) → Null g = <T extends core::Object? = dynamic>(T% t) → Null {} in g);
+  core::print( block {
+    function g<T extends core::Object? = dynamic>(T% t) → void {}
+  } =>invalid-expression "pkg/front_end/testcases/general/illegal_named_function_expression.dart:8:9: Error: A function expression can't have a name.
+  print(void g<T>(T t) {});
+        ^");
 }
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.outline.expect b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.outline.expect
index e2cba6b..eef3152 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.outline.expect
@@ -1,5 +1,5 @@
 library /*isNonNullableByDefault*/;
 import self as self;
 
-static method main() → dynamic
+static method test() → dynamic
   ;
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.transformed.expect b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.transformed.expect
index 812ba6f..9f8e706 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression.dart.weak.transformed.expect
@@ -13,8 +13,16 @@
 import self as self;
 import "dart:core" as core;
 
-static method main() → dynamic {
-  <T extends core::Object? = dynamic>(T%) → Null x = let final <T extends core::Object? = dynamic>(T%) → Null f = <T extends core::Object? = dynamic>(T% t) → Null {} in f;
+static method test() → dynamic {
+  invalid-type x = block {
+    function f<T extends core::Object? = dynamic>(T% t) → void {}
+  } =>invalid-expression "pkg/front_end/testcases/general/illegal_named_function_expression.dart:6:11: Error: A function expression can't have a name.
+  var x = void f<T>(T t) {};
+          ^";
   core::print(x.{core::Object::runtimeType}{core::Type});
-  core::print(let final <T extends core::Object? = dynamic>(T%) → Null g = <T extends core::Object? = dynamic>(T% t) → Null {} in g);
+  core::print( block {
+    function g<T extends core::Object? = dynamic>(T% t) → void {}
+  } =>invalid-expression "pkg/front_end/testcases/general/illegal_named_function_expression.dart:8:9: Error: A function expression can't have a name.
+  print(void g<T>(T t) {});
+        ^");
 }
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart
index 2b3df38..1cdbbe0 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart
@@ -2,7 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-main() {
+test() {
   void f() {}
   print(void f() {});
 }
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.textual_outline.expect b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.textual_outline.expect
index bae895a..a9f9e5f 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.textual_outline.expect
@@ -1 +1 @@
-main() {}
+test() {}
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.textual_outline_modelled.expect
index bae895a..a9f9e5f 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.textual_outline_modelled.expect
@@ -1 +1 @@
-main() {}
+test() {}
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.expect b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.expect
index 470f8b7..a87651f 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.expect
@@ -9,7 +9,11 @@
 import self as self;
 import "dart:core" as core;
 
-static method main() → dynamic {
+static method test() → dynamic {
   function f() → void {}
-  core::print(let final () → Null f = () → Null {} in f);
+  core::print( block {
+    function f() → void {}
+  } =>invalid-expression "pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart:7:9: Error: A function expression can't have a name.
+  print(void f() {});
+        ^");
 }
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.modular.expect b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.modular.expect
index 470f8b7..a87651f 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.modular.expect
@@ -9,7 +9,11 @@
 import self as self;
 import "dart:core" as core;
 
-static method main() → dynamic {
+static method test() → dynamic {
   function f() → void {}
-  core::print(let final () → Null f = () → Null {} in f);
+  core::print( block {
+    function f() → void {}
+  } =>invalid-expression "pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart:7:9: Error: A function expression can't have a name.
+  print(void f() {});
+        ^");
 }
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.outline.expect b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.outline.expect
index e2cba6b..eef3152 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.outline.expect
@@ -1,5 +1,5 @@
 library /*isNonNullableByDefault*/;
 import self as self;
 
-static method main() → dynamic
+static method test() → dynamic
   ;
diff --git a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.transformed.expect b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.transformed.expect
index 470f8b7..a87651f 100644
--- a/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart.weak.transformed.expect
@@ -9,7 +9,11 @@
 import self as self;
 import "dart:core" as core;
 
-static method main() → dynamic {
+static method test() → dynamic {
   function f() → void {}
-  core::print(let final () → Null f = () → Null {} in f);
+  core::print( block {
+    function f() → void {}
+  } =>invalid-expression "pkg/front_end/testcases/general/illegal_named_function_expression_scope.dart:7:9: Error: A function expression can't have a name.
+  print(void f() {});
+        ^");
 }
diff --git a/pkg/front_end/testcases/general/issue49087.dart b/pkg/front_end/testcases/general/issue49087.dart
new file mode 100644
index 0000000..0073bb9
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49087.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A {
+  const A(int x, {String? y});
+  const factory A.redir(int x, {String? y}) = A;
+}
+
+test1() => const A(y: "foo", 0);
+test2() => const A.redir(y: "foo", 0);
+
+main() {}
diff --git a/pkg/front_end/testcases/general/issue49087.dart.textual_outline.expect b/pkg/front_end/testcases/general/issue49087.dart.textual_outline.expect
new file mode 100644
index 0000000..b783d52
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49087.dart.textual_outline.expect
@@ -0,0 +1,8 @@
+class A {
+  const A(int x, {String? y});
+  const factory A.redir(int x, {String? y}) = A;
+}
+
+test1() => const A(y: "foo", 0);
+test2() => const A.redir(y: "foo", 0);
+main() {}
diff --git a/pkg/front_end/testcases/general/issue49087.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/issue49087.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..2239f30
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49087.dart.textual_outline_modelled.expect
@@ -0,0 +1,8 @@
+class A {
+  const A(int x, {String? y});
+  const factory A.redir(int x, {String? y}) = A;
+}
+
+main() {}
+test1() => const A(y: "foo", 0);
+test2() => const A.redir(y: "foo", 0);
diff --git a/pkg/front_end/testcases/general/issue49087.dart.weak.expect b/pkg/front_end/testcases/general/issue49087.dart.weak.expect
new file mode 100644
index 0000000..0664156
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49087.dart.weak.expect
@@ -0,0 +1,29 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object /*hasConstConstructor*/  {
+  static final field dynamic _redirecting# = <dynamic>[#C1]/*isLegacy*/;
+  const constructor •(core::int x, {core::String? y = #C2}) → self::A
+    : super core::Object::•()
+    ;
+  static factory redir(core::int x, {core::String? y = #C2}) → self::A
+    return new self::A::•(x, y: y);
+}
+static method test1() → dynamic
+  return #C3;
+static method test2() → dynamic
+  return #C3;
+static method main() → dynamic {}
+
+constants  {
+  #C1 = constructor-tearoff self::A::redir
+  #C2 = null
+  #C3 = self::A {}
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///issue49087.dart:
+- A. (from org-dartlang-testcase:///issue49087.dart:6:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/general/issue49087.dart.weak.modular.expect b/pkg/front_end/testcases/general/issue49087.dart.weak.modular.expect
new file mode 100644
index 0000000..0664156
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49087.dart.weak.modular.expect
@@ -0,0 +1,29 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object /*hasConstConstructor*/  {
+  static final field dynamic _redirecting# = <dynamic>[#C1]/*isLegacy*/;
+  const constructor •(core::int x, {core::String? y = #C2}) → self::A
+    : super core::Object::•()
+    ;
+  static factory redir(core::int x, {core::String? y = #C2}) → self::A
+    return new self::A::•(x, y: y);
+}
+static method test1() → dynamic
+  return #C3;
+static method test2() → dynamic
+  return #C3;
+static method main() → dynamic {}
+
+constants  {
+  #C1 = constructor-tearoff self::A::redir
+  #C2 = null
+  #C3 = self::A {}
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///issue49087.dart:
+- A. (from org-dartlang-testcase:///issue49087.dart:6:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/general/issue49087.dart.weak.outline.expect b/pkg/front_end/testcases/general/issue49087.dart.weak.outline.expect
new file mode 100644
index 0000000..b574977
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49087.dart.weak.outline.expect
@@ -0,0 +1,23 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object /*hasConstConstructor*/  {
+  static final field dynamic _redirecting# = <dynamic>[self::A::redir]/*isLegacy*/;
+  const constructor •(core::int x, {core::String? y = null}) → self::A
+    : super core::Object::•()
+    ;
+  static factory redir(core::int x, {core::String? y = null}) → self::A
+    return new self::A::•(x, y: y);
+}
+static method test1() → dynamic
+  ;
+static method test2() → dynamic
+  ;
+static method main() → dynamic
+  ;
+
+
+Extra constant evaluation status:
+Evaluated: ConstructorTearOff @ org-dartlang-testcase:///issue49087.dart:5:7 -> ConstructorTearOffConstant(A.redir)
+Extra constant evaluation: evaluated: 5, effectively constant: 1
diff --git a/pkg/front_end/testcases/general/issue49087.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue49087.dart.weak.transformed.expect
new file mode 100644
index 0000000..0664156
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49087.dart.weak.transformed.expect
@@ -0,0 +1,29 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object /*hasConstConstructor*/  {
+  static final field dynamic _redirecting# = <dynamic>[#C1]/*isLegacy*/;
+  const constructor •(core::int x, {core::String? y = #C2}) → self::A
+    : super core::Object::•()
+    ;
+  static factory redir(core::int x, {core::String? y = #C2}) → self::A
+    return new self::A::•(x, y: y);
+}
+static method test1() → dynamic
+  return #C3;
+static method test2() → dynamic
+  return #C3;
+static method main() → dynamic {}
+
+constants  {
+  #C1 = constructor-tearoff self::A::redir
+  #C2 = null
+  #C3 = self::A {}
+}
+
+
+Constructor coverage from constants:
+org-dartlang-testcase:///issue49087.dart:
+- A. (from org-dartlang-testcase:///issue49087.dart:6:9)
+- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
diff --git a/pkg/front_end/testcases/general/issue49122.dart b/pkg/front_end/testcases/general/issue49122.dart
new file mode 100644
index 0000000..63a9199
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49122.dart
@@ -0,0 +1,9 @@
+// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+test(x) => x();
+
+void test2() {
+  test(bar() { print(bar); });
+}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/general/issue49122.dart.textual_outline.expect b/pkg/front_end/testcases/general/issue49122.dart.textual_outline.expect
new file mode 100644
index 0000000..65ffcb2
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49122.dart.textual_outline.expect
@@ -0,0 +1,2 @@
+test(x) => x();
+void test2() {}
diff --git a/pkg/front_end/testcases/general/issue49122.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/issue49122.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..65ffcb2
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49122.dart.textual_outline_modelled.expect
@@ -0,0 +1,2 @@
+test(x) => x();
+void test2() {}
diff --git a/pkg/front_end/testcases/general/issue49122.dart.weak.expect b/pkg/front_end/testcases/general/issue49122.dart.weak.expect
new file mode 100644
index 0000000..88cc020
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49122.dart.weak.expect
@@ -0,0 +1,22 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue49122.dart:8:8: Error: A function expression can't have a name.
+//   test(bar() { print(bar); });
+//        ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+static method test(dynamic x) → dynamic
+  return x{dynamic}.call();
+static method test2() → void {
+  self::test( block {
+    function bar() → Null {
+      core::print(bar);
+    }
+  } =>invalid-expression "pkg/front_end/testcases/general/issue49122.dart:8:8: Error: A function expression can't have a name.
+  test(bar() { print(bar); });
+       ^");
+}
diff --git a/pkg/front_end/testcases/general/issue49122.dart.weak.modular.expect b/pkg/front_end/testcases/general/issue49122.dart.weak.modular.expect
new file mode 100644
index 0000000..88cc020
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49122.dart.weak.modular.expect
@@ -0,0 +1,22 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue49122.dart:8:8: Error: A function expression can't have a name.
+//   test(bar() { print(bar); });
+//        ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+static method test(dynamic x) → dynamic
+  return x{dynamic}.call();
+static method test2() → void {
+  self::test( block {
+    function bar() → Null {
+      core::print(bar);
+    }
+  } =>invalid-expression "pkg/front_end/testcases/general/issue49122.dart:8:8: Error: A function expression can't have a name.
+  test(bar() { print(bar); });
+       ^");
+}
diff --git a/pkg/front_end/testcases/general/issue49122.dart.weak.outline.expect b/pkg/front_end/testcases/general/issue49122.dart.weak.outline.expect
new file mode 100644
index 0000000..3bfe9f1
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49122.dart.weak.outline.expect
@@ -0,0 +1,7 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+
+static method test(dynamic x) → dynamic
+  ;
+static method test2() → void
+  ;
diff --git a/pkg/front_end/testcases/general/issue49122.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue49122.dart.weak.transformed.expect
new file mode 100644
index 0000000..88cc020
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue49122.dart.weak.transformed.expect
@@ -0,0 +1,22 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue49122.dart:8:8: Error: A function expression can't have a name.
+//   test(bar() { print(bar); });
+//        ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+static method test(dynamic x) → dynamic
+  return x{dynamic}.call();
+static method test2() → void {
+  self::test( block {
+    function bar() → Null {
+      core::print(bar);
+    }
+  } =>invalid-expression "pkg/front_end/testcases/general/issue49122.dart:8:8: Error: A function expression can't have a name.
+  test(bar() { print(bar); });
+       ^");
+}
diff --git a/pkg/front_end/testcases/general/named_function_scope.dart.weak.expect b/pkg/front_end/testcases/general/named_function_scope.dart.weak.expect
index 18cd85e..f36f2ea 100644
--- a/pkg/front_end/testcases/general/named_function_scope.dart.weak.expect
+++ b/pkg/front_end/testcases/general/named_function_scope.dart.weak.expect
@@ -81,6 +81,11 @@
 //     void T(T t) {}
 //            ^
 //
+// pkg/front_end/testcases/general/named_function_scope.dart:41:13: Error: A non-null value must be returned since the return type 'T' doesn't allow null.
+//  - 'T' is from 'pkg/front_end/testcases/general/named_function_scope.dart'.
+//     var x = T T() {};
+//             ^
+//
 import self as self;
 import "dart:core" as core;
 
@@ -105,7 +110,11 @@
   }
   {
     self::T t;
-    () → Null x = let final () → Null T = () → Null {} in T;
+    invalid-type x = block {
+      function T() → Null {}
+    } =>invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:26:13: Error: A function expression can't have a name.
+    var x = T() {};
+            ^";
   }
   {
     self::V v;
@@ -120,9 +129,21 @@
         ^" in null;
   }
   {
-    () → Null x = let final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:15: Error: Can't declare 'T' because it was already used in this scope.
+    invalid-type x = block {
+      {
+        invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:15: Error: Can't declare 'T' because it was already used in this scope.
     var x = T T() {};
-              ^" in let final () → Null T = () → Null {} in T;
+              ^";
+        function T() → self::T {
+          return invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:13: Error: A non-null value must be returned since the return type 'T' doesn't allow null.
+ - 'T' is from 'pkg/front_end/testcases/general/named_function_scope.dart'.
+    var x = T T() {};
+            ^" in null;
+        }
+      }
+    } =>invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:13: Error: A function expression can't have a name.
+    var x = T T() {};
+            ^";
   }
   {
     self::V V = invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:47:7: Error: Can't declare 'V' because it was already used in this scope.
@@ -130,9 +151,16 @@
       ^";
   }
   {
-    <T extends core::Object? = dynamic>() → Null x = let final dynamic #t2 = invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:52:13: Error: 'T' is already declared in this scope.
+    invalid-type x = block {
+      {
+        invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:52:13: Error: 'T' is already declared in this scope.
     var x = T<T>() {};
-            ^" in let final <T extends core::Object? = dynamic>() → Null T = <T extends core::Object? = dynamic>() → Null {} in T;
+            ^";
+        function T<T extends core::Object? = dynamic>() → Null {}
+      }
+    } =>invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:52:13: Error: A function expression can't have a name.
+    var x = T<T>() {};
+            ^";
   }
   {
     self::T t;
diff --git a/pkg/front_end/testcases/general/named_function_scope.dart.weak.modular.expect b/pkg/front_end/testcases/general/named_function_scope.dart.weak.modular.expect
index 18cd85e..f36f2ea 100644
--- a/pkg/front_end/testcases/general/named_function_scope.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/general/named_function_scope.dart.weak.modular.expect
@@ -81,6 +81,11 @@
 //     void T(T t) {}
 //            ^
 //
+// pkg/front_end/testcases/general/named_function_scope.dart:41:13: Error: A non-null value must be returned since the return type 'T' doesn't allow null.
+//  - 'T' is from 'pkg/front_end/testcases/general/named_function_scope.dart'.
+//     var x = T T() {};
+//             ^
+//
 import self as self;
 import "dart:core" as core;
 
@@ -105,7 +110,11 @@
   }
   {
     self::T t;
-    () → Null x = let final () → Null T = () → Null {} in T;
+    invalid-type x = block {
+      function T() → Null {}
+    } =>invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:26:13: Error: A function expression can't have a name.
+    var x = T() {};
+            ^";
   }
   {
     self::V v;
@@ -120,9 +129,21 @@
         ^" in null;
   }
   {
-    () → Null x = let final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:15: Error: Can't declare 'T' because it was already used in this scope.
+    invalid-type x = block {
+      {
+        invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:15: Error: Can't declare 'T' because it was already used in this scope.
     var x = T T() {};
-              ^" in let final () → Null T = () → Null {} in T;
+              ^";
+        function T() → self::T {
+          return invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:13: Error: A non-null value must be returned since the return type 'T' doesn't allow null.
+ - 'T' is from 'pkg/front_end/testcases/general/named_function_scope.dart'.
+    var x = T T() {};
+            ^" in null;
+        }
+      }
+    } =>invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:13: Error: A function expression can't have a name.
+    var x = T T() {};
+            ^";
   }
   {
     self::V V = invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:47:7: Error: Can't declare 'V' because it was already used in this scope.
@@ -130,9 +151,16 @@
       ^";
   }
   {
-    <T extends core::Object? = dynamic>() → Null x = let final dynamic #t2 = invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:52:13: Error: 'T' is already declared in this scope.
+    invalid-type x = block {
+      {
+        invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:52:13: Error: 'T' is already declared in this scope.
     var x = T<T>() {};
-            ^" in let final <T extends core::Object? = dynamic>() → Null T = <T extends core::Object? = dynamic>() → Null {} in T;
+            ^";
+        function T<T extends core::Object? = dynamic>() → Null {}
+      }
+    } =>invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:52:13: Error: A function expression can't have a name.
+    var x = T<T>() {};
+            ^";
   }
   {
     self::T t;
diff --git a/pkg/front_end/testcases/general/named_function_scope.dart.weak.transformed.expect b/pkg/front_end/testcases/general/named_function_scope.dart.weak.transformed.expect
index b2b67d2..f36f2ea 100644
--- a/pkg/front_end/testcases/general/named_function_scope.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/named_function_scope.dart.weak.transformed.expect
@@ -81,6 +81,11 @@
 //     void T(T t) {}
 //            ^
 //
+// pkg/front_end/testcases/general/named_function_scope.dart:41:13: Error: A non-null value must be returned since the return type 'T' doesn't allow null.
+//  - 'T' is from 'pkg/front_end/testcases/general/named_function_scope.dart'.
+//     var x = T T() {};
+//             ^
+//
 import self as self;
 import "dart:core" as core;
 
@@ -105,7 +110,11 @@
   }
   {
     self::T t;
-    () → Null x = let final () → Null T = () → Null {} in T;
+    invalid-type x = block {
+      function T() → Null {}
+    } =>invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:26:13: Error: A function expression can't have a name.
+    var x = T() {};
+            ^";
   }
   {
     self::V v;
@@ -120,9 +129,21 @@
         ^" in null;
   }
   {
-    () → Null x = let final invalid-type #t1 = invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:15: Error: Can't declare 'T' because it was already used in this scope.
+    invalid-type x = block {
+      {
+        invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:15: Error: Can't declare 'T' because it was already used in this scope.
     var x = T T() {};
-              ^" in let final () → Null T = () → Null {} in T;
+              ^";
+        function T() → self::T {
+          return invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:13: Error: A non-null value must be returned since the return type 'T' doesn't allow null.
+ - 'T' is from 'pkg/front_end/testcases/general/named_function_scope.dart'.
+    var x = T T() {};
+            ^" in null;
+        }
+      }
+    } =>invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:41:13: Error: A function expression can't have a name.
+    var x = T T() {};
+            ^";
   }
   {
     self::V V = invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:47:7: Error: Can't declare 'V' because it was already used in this scope.
@@ -130,9 +151,16 @@
       ^";
   }
   {
-    <T extends core::Object? = dynamic>() → Null x = let final invalid-type #t2 = invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:52:13: Error: 'T' is already declared in this scope.
+    invalid-type x = block {
+      {
+        invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:52:13: Error: 'T' is already declared in this scope.
     var x = T<T>() {};
-            ^" in let final <T extends core::Object? = dynamic>() → Null T = <T extends core::Object? = dynamic>() → Null {} in T;
+            ^";
+        function T<T extends core::Object? = dynamic>() → Null {}
+      }
+    } =>invalid-expression "pkg/front_end/testcases/general/named_function_scope.dart:52:13: Error: A function expression can't have a name.
+    var x = T<T>() {};
+            ^";
   }
   {
     self::T t;
diff --git a/pkg/front_end/testcases/regress/issue_29937.dart b/pkg/front_end/testcases/regress/issue_29937.dart
index fcbb92c..77e2f5c 100644
--- a/pkg/front_end/testcases/regress/issue_29937.dart
+++ b/pkg/front_end/testcases/regress/issue_29937.dart
@@ -2,6 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-main() {
+test() {
   [f() {}];
 }
diff --git a/pkg/front_end/testcases/regress/issue_29937.dart.textual_outline.expect b/pkg/front_end/testcases/regress/issue_29937.dart.textual_outline.expect
index bae895a..a9f9e5f 100644
--- a/pkg/front_end/testcases/regress/issue_29937.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/regress/issue_29937.dart.textual_outline.expect
@@ -1 +1 @@
-main() {}
+test() {}
diff --git a/pkg/front_end/testcases/regress/issue_29937.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/regress/issue_29937.dart.textual_outline_modelled.expect
index bae895a..a9f9e5f 100644
--- a/pkg/front_end/testcases/regress/issue_29937.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/regress/issue_29937.dart.textual_outline_modelled.expect
@@ -1 +1 @@
-main() {}
+test() {}
diff --git a/pkg/front_end/testcases/regress/issue_29937.dart.weak.expect b/pkg/front_end/testcases/regress/issue_29937.dart.weak.expect
index 2df04ab..e57bd11 100644
--- a/pkg/front_end/testcases/regress/issue_29937.dart.weak.expect
+++ b/pkg/front_end/testcases/regress/issue_29937.dart.weak.expect
@@ -8,6 +8,10 @@
 //
 import self as self;
 
-static method main() → dynamic {
-  <() → Null>[let final () → Null f = () → Null {} in f];
+static method test() → dynamic {
+  <dynamic>[ block {
+    function f() → Null {}
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29937.dart:6:4: Error: A function expression can't have a name.
+  [f() {}];
+   ^"];
 }
diff --git a/pkg/front_end/testcases/regress/issue_29937.dart.weak.modular.expect b/pkg/front_end/testcases/regress/issue_29937.dart.weak.modular.expect
index 2df04ab..e57bd11 100644
--- a/pkg/front_end/testcases/regress/issue_29937.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/regress/issue_29937.dart.weak.modular.expect
@@ -8,6 +8,10 @@
 //
 import self as self;
 
-static method main() → dynamic {
-  <() → Null>[let final () → Null f = () → Null {} in f];
+static method test() → dynamic {
+  <dynamic>[ block {
+    function f() → Null {}
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29937.dart:6:4: Error: A function expression can't have a name.
+  [f() {}];
+   ^"];
 }
diff --git a/pkg/front_end/testcases/regress/issue_29937.dart.weak.outline.expect b/pkg/front_end/testcases/regress/issue_29937.dart.weak.outline.expect
index e2cba6b..eef3152 100644
--- a/pkg/front_end/testcases/regress/issue_29937.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/regress/issue_29937.dart.weak.outline.expect
@@ -1,5 +1,5 @@
 library /*isNonNullableByDefault*/;
 import self as self;
 
-static method main() → dynamic
+static method test() → dynamic
   ;
diff --git a/pkg/front_end/testcases/regress/issue_29937.dart.weak.transformed.expect b/pkg/front_end/testcases/regress/issue_29937.dart.weak.transformed.expect
index 860524d..bb94983 100644
--- a/pkg/front_end/testcases/regress/issue_29937.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/regress/issue_29937.dart.weak.transformed.expect
@@ -9,6 +9,10 @@
 import self as self;
 import "dart:core" as core;
 
-static method main() → dynamic {
-  core::_GrowableList::_literal1<() → Null>(let final () → Null f = () → Null {} in f);
+static method test() → dynamic {
+  core::_GrowableList::_literal1<dynamic>( block {
+    function f() → Null {}
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29937.dart:6:4: Error: A function expression can't have a name.
+  [f() {}];
+   ^");
 }
diff --git a/pkg/front_end/testcases/regress/issue_29942.dart.weak.expect b/pkg/front_end/testcases/regress/issue_29942.dart.weak.expect
index 1bb672f..1a0399f 100644
--- a/pkg/front_end/testcases/regress/issue_29942.dart.weak.expect
+++ b/pkg/front_end/testcases/regress/issue_29942.dart.weak.expect
@@ -15,4 +15,9 @@
 
 static method main() → dynamic {}
 static method f() → dynamic
-  return let final () → Null h = () → Null => null in h;
+  return block {
+    function h() → Null
+      return null;
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29942.dart:10:1: Error: A function expression can't have a name.
+h() => null;
+^";
diff --git a/pkg/front_end/testcases/regress/issue_29942.dart.weak.modular.expect b/pkg/front_end/testcases/regress/issue_29942.dart.weak.modular.expect
index 1bb672f..1a0399f 100644
--- a/pkg/front_end/testcases/regress/issue_29942.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/regress/issue_29942.dart.weak.modular.expect
@@ -15,4 +15,9 @@
 
 static method main() → dynamic {}
 static method f() → dynamic
-  return let final () → Null h = () → Null => null in h;
+  return block {
+    function h() → Null
+      return null;
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29942.dart:10:1: Error: A function expression can't have a name.
+h() => null;
+^";
diff --git a/pkg/front_end/testcases/regress/issue_29942.dart.weak.transformed.expect b/pkg/front_end/testcases/regress/issue_29942.dart.weak.transformed.expect
index 1bb672f..1a0399f 100644
--- a/pkg/front_end/testcases/regress/issue_29942.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/regress/issue_29942.dart.weak.transformed.expect
@@ -15,4 +15,9 @@
 
 static method main() → dynamic {}
 static method f() → dynamic
-  return let final () → Null h = () → Null => null in h;
+  return block {
+    function h() → Null
+      return null;
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29942.dart:10:1: Error: A function expression can't have a name.
+h() => null;
+^";
diff --git a/pkg/front_end/testcases/regress/issue_29978.dart b/pkg/front_end/testcases/regress/issue_29978.dart
index 997d9aa..166837f 100644
--- a/pkg/front_end/testcases/regress/issue_29978.dart
+++ b/pkg/front_end/testcases/regress/issue_29978.dart
@@ -4,6 +4,6 @@
 
 foo(a, b) => null;
 
-main() {
+test() {
   foo(null, f() {});
 }
diff --git a/pkg/front_end/testcases/regress/issue_29978.dart.textual_outline.expect b/pkg/front_end/testcases/regress/issue_29978.dart.textual_outline.expect
index 2a44271..1c673d5 100644
--- a/pkg/front_end/testcases/regress/issue_29978.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/regress/issue_29978.dart.textual_outline.expect
@@ -1,2 +1,2 @@
 foo(a, b) => null;
-main() {}
+test() {}
diff --git a/pkg/front_end/testcases/regress/issue_29978.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/regress/issue_29978.dart.textual_outline_modelled.expect
index 2a44271..1c673d5 100644
--- a/pkg/front_end/testcases/regress/issue_29978.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/regress/issue_29978.dart.textual_outline_modelled.expect
@@ -1,2 +1,2 @@
 foo(a, b) => null;
-main() {}
+test() {}
diff --git a/pkg/front_end/testcases/regress/issue_29978.dart.weak.expect b/pkg/front_end/testcases/regress/issue_29978.dart.weak.expect
index 34a58b5..4871133 100644
--- a/pkg/front_end/testcases/regress/issue_29978.dart.weak.expect
+++ b/pkg/front_end/testcases/regress/issue_29978.dart.weak.expect
@@ -10,6 +10,10 @@
 
 static method foo(dynamic a, dynamic b) → dynamic
   return null;
-static method main() → dynamic {
-  self::foo(null, let final () → Null f = () → Null {} in f);
+static method test() → dynamic {
+  self::foo(null, block {
+    function f() → Null {}
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29978.dart:8:13: Error: A function expression can't have a name.
+  foo(null, f() {});
+            ^");
 }
diff --git a/pkg/front_end/testcases/regress/issue_29978.dart.weak.modular.expect b/pkg/front_end/testcases/regress/issue_29978.dart.weak.modular.expect
index 34a58b5..4871133 100644
--- a/pkg/front_end/testcases/regress/issue_29978.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/regress/issue_29978.dart.weak.modular.expect
@@ -10,6 +10,10 @@
 
 static method foo(dynamic a, dynamic b) → dynamic
   return null;
-static method main() → dynamic {
-  self::foo(null, let final () → Null f = () → Null {} in f);
+static method test() → dynamic {
+  self::foo(null, block {
+    function f() → Null {}
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29978.dart:8:13: Error: A function expression can't have a name.
+  foo(null, f() {});
+            ^");
 }
diff --git a/pkg/front_end/testcases/regress/issue_29978.dart.weak.outline.expect b/pkg/front_end/testcases/regress/issue_29978.dart.weak.outline.expect
index 8884d25..58140d5 100644
--- a/pkg/front_end/testcases/regress/issue_29978.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/regress/issue_29978.dart.weak.outline.expect
@@ -3,5 +3,5 @@
 
 static method foo(dynamic a, dynamic b) → dynamic
   ;
-static method main() → dynamic
+static method test() → dynamic
   ;
diff --git a/pkg/front_end/testcases/regress/issue_29978.dart.weak.transformed.expect b/pkg/front_end/testcases/regress/issue_29978.dart.weak.transformed.expect
index 34a58b5..4871133 100644
--- a/pkg/front_end/testcases/regress/issue_29978.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/regress/issue_29978.dart.weak.transformed.expect
@@ -10,6 +10,10 @@
 
 static method foo(dynamic a, dynamic b) → dynamic
   return null;
-static method main() → dynamic {
-  self::foo(null, let final () → Null f = () → Null {} in f);
+static method test() → dynamic {
+  self::foo(null, block {
+    function f() → Null {}
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29978.dart:8:13: Error: A function expression can't have a name.
+  foo(null, f() {});
+            ^");
 }
diff --git a/pkg/front_end/testcases/regress/issue_29979.dart b/pkg/front_end/testcases/regress/issue_29979.dart
index c6bfd12..70b39d7 100644
--- a/pkg/front_end/testcases/regress/issue_29979.dart
+++ b/pkg/front_end/testcases/regress/issue_29979.dart
@@ -2,6 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-main() {
+test() {
   (f() {})();
 }
diff --git a/pkg/front_end/testcases/regress/issue_29979.dart.textual_outline.expect b/pkg/front_end/testcases/regress/issue_29979.dart.textual_outline.expect
index bae895a..a9f9e5f 100644
--- a/pkg/front_end/testcases/regress/issue_29979.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/regress/issue_29979.dart.textual_outline.expect
@@ -1 +1 @@
-main() {}
+test() {}
diff --git a/pkg/front_end/testcases/regress/issue_29979.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/regress/issue_29979.dart.textual_outline_modelled.expect
index bae895a..a9f9e5f 100644
--- a/pkg/front_end/testcases/regress/issue_29979.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/regress/issue_29979.dart.textual_outline_modelled.expect
@@ -1 +1 @@
-main() {}
+test() {}
diff --git a/pkg/front_end/testcases/regress/issue_29979.dart.weak.expect b/pkg/front_end/testcases/regress/issue_29979.dart.weak.expect
index 453aa64..dcd451c 100644
--- a/pkg/front_end/testcases/regress/issue_29979.dart.weak.expect
+++ b/pkg/front_end/testcases/regress/issue_29979.dart.weak.expect
@@ -8,6 +8,10 @@
 //
 import self as self;
 
-static method main() → dynamic {
-  (let final () → Null f = () → Null {} in f)(){() → Null};
+static method test() → dynamic {
+  ( block {
+    function f() → Null {}
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29979.dart:6:4: Error: A function expression can't have a name.
+  (f() {})();
+   ^"){dynamic}.call();
 }
diff --git a/pkg/front_end/testcases/regress/issue_29979.dart.weak.modular.expect b/pkg/front_end/testcases/regress/issue_29979.dart.weak.modular.expect
index 453aa64..dcd451c 100644
--- a/pkg/front_end/testcases/regress/issue_29979.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/regress/issue_29979.dart.weak.modular.expect
@@ -8,6 +8,10 @@
 //
 import self as self;
 
-static method main() → dynamic {
-  (let final () → Null f = () → Null {} in f)(){() → Null};
+static method test() → dynamic {
+  ( block {
+    function f() → Null {}
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29979.dart:6:4: Error: A function expression can't have a name.
+  (f() {})();
+   ^"){dynamic}.call();
 }
diff --git a/pkg/front_end/testcases/regress/issue_29979.dart.weak.outline.expect b/pkg/front_end/testcases/regress/issue_29979.dart.weak.outline.expect
index e2cba6b..eef3152 100644
--- a/pkg/front_end/testcases/regress/issue_29979.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/regress/issue_29979.dart.weak.outline.expect
@@ -1,5 +1,5 @@
 library /*isNonNullableByDefault*/;
 import self as self;
 
-static method main() → dynamic
+static method test() → dynamic
   ;
diff --git a/pkg/front_end/testcases/regress/issue_29979.dart.weak.transformed.expect b/pkg/front_end/testcases/regress/issue_29979.dart.weak.transformed.expect
index 453aa64..dcd451c 100644
--- a/pkg/front_end/testcases/regress/issue_29979.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/regress/issue_29979.dart.weak.transformed.expect
@@ -8,6 +8,10 @@
 //
 import self as self;
 
-static method main() → dynamic {
-  (let final () → Null f = () → Null {} in f)(){() → Null};
+static method test() → dynamic {
+  ( block {
+    function f() → Null {}
+  } =>invalid-expression "pkg/front_end/testcases/regress/issue_29979.dart:6:4: Error: A function expression can't have a name.
+  (f() {})();
+   ^"){dynamic}.call();
 }
diff --git a/pkg/vm/lib/transformations/ffi/finalizable.dart b/pkg/vm/lib/transformations/ffi/finalizable.dart
index 84b1469..4fe96f3 100644
--- a/pkg/vm/lib/transformations/ffi/finalizable.dart
+++ b/pkg/vm/lib/transformations/ffi/finalizable.dart
@@ -220,14 +220,15 @@
 
   @override
   TreeNode visitVariableDeclaration(VariableDeclaration node) {
+    node = super.visitVariableDeclaration(node) as VariableDeclaration;
     if (_currentScope == null) {
       // Global variable.
-      return super.visitVariableDeclaration(node);
+      return node;
     }
     if (_isFinalizable(node.type)) {
       _currentScope!.addDeclaration(node);
     }
-    return super.visitVariableDeclaration(node);
+    return node;
   }
 
   @override
diff --git a/pkg/vm/testcases/transformations/ffi/regress_49075.dart b/pkg/vm/testcases/transformations/ffi/regress_49075.dart
new file mode 100644
index 0000000..0046fd8
--- /dev/null
+++ b/pkg/vm/testcases/transformations/ffi/regress_49075.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:ffi';
+
+Future<void> main(List<String> arguments) async {
+  // ignore: unused_local_variable
+  final myFinalizable = await MyFinalizable();
+}
+
+class MyFinalizable implements Finalizable {
+  MyFinalizable();
+}
diff --git a/pkg/vm/testcases/transformations/ffi/regress_49075.dart.expect b/pkg/vm/testcases/transformations/ffi/regress_49075.dart.expect
new file mode 100644
index 0000000..2974867
--- /dev/null
+++ b/pkg/vm/testcases/transformations/ffi/regress_49075.dart.expect
@@ -0,0 +1,45 @@
+library #lib /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+import "dart:ffi" as ffi;
+import "dart:_internal" as _in;
+import "dart:async" as asy;
+
+import "dart:ffi";
+
+class MyFinalizable extends core::Object implements ffi::Finalizable {
+  constructor •() → self::MyFinalizable
+    : super core::Object::•() {
+    ;
+    _in::reachabilityFence(this);
+  }
+}
+static method main(core::List<core::String> arguments) → asy::Future<void> /* futureValueType= void */ /* originally async */ {
+  final asy::_Future<void> :async_future = new asy::_Future::•<void>();
+  core::bool* :is_sync = false;
+  void :return_value;
+  (dynamic) → dynamic :async_op_then;
+  (core::Object, core::StackTrace) → dynamic :async_op_error;
+  core::int :await_jump_var = 0;
+  dynamic :await_ctx_var;
+  dynamic :saved_try_context_var0;
+  function :async_op(dynamic :result_or_exception, dynamic :stack_trace) → dynamic yielding 
+    try {
+      #L1:
+      {
+        [yield] let dynamic #t1 = asy::_awaitHelper(new self::MyFinalizable::•(), :async_op_then, :async_op_error) in null;
+        final self::MyFinalizable myFinalizable = _in::unsafeCast<self::MyFinalizable>(:result_or_exception);
+        _in::reachabilityFence(myFinalizable);
+      }
+      asy::_completeWithNoFutureOnAsyncReturn(:async_future, :return_value, :is_sync);
+      return;
+    }
+    on dynamic catch(dynamic exception, core::StackTrace stack_trace) {
+      asy::_completeOnAsyncError(:async_future, exception, stack_trace, :is_sync);
+    }
+  :async_op_then = asy::_asyncThenWrapperHelper(:async_op);
+  :async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
+  :async_op(null, null){() → dynamic};
+  :is_sync = true;
+  return :async_future;
+}
diff --git a/tools/VERSION b/tools/VERSION
index cd48429..f0ba236 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 18
 PATCH 0
-PRERELEASE 154
+PRERELEASE 155
 PRERELEASE_PATCH 0
\ No newline at end of file