Type promotion requires current function body.

So, wee set one when resolving constructor initializers, even if it
is empty.

R=brianwilkerson@google.com

Change-Id: Ia63e60ed40bbf7e9c7f681acbce9548cc03bca65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101486
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 94b83c9..e115b57 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -3887,6 +3887,11 @@
     // TODO(brianwilkerson) Remove this method.
   }
 
+  /// Set the enclosing function body when partial AST is resolved.
+  void prepareCurrentFunctionBody(FunctionBody body) {
+    _currentFunctionBody = body;
+  }
+
   /// Set information about enclosing declarations.
   void prepareEnclosingDeclarations({
     ClassElement enclosingClassElement,
diff --git a/pkg/analyzer/lib/src/summary2/ast_resolver.dart b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
index 1771231..a98c541 100644
--- a/pkg/analyzer/lib/src/summary2/ast_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
@@ -22,6 +22,7 @@
     AstNode node, {
     ClassElement enclosingClassElement,
     ExecutableElement enclosingExecutableElement,
+    FunctionBody enclosingFunctionBody,
   }) {
     var featureSet = node.thisOrAncestorOfType<CompilationUnit>().featureSet;
     var source = _FakeSource();
@@ -51,6 +52,9 @@
       enclosingClassElement: enclosingClassElement,
       enclosingExecutableElement: enclosingExecutableElement,
     );
+    if (enclosingFunctionBody != null) {
+      resolverVisitor.prepareCurrentFunctionBody(enclosingFunctionBody);
+    }
 
     node.accept(resolverVisitor);
   }
diff --git a/pkg/analyzer/lib/src/summary2/constructor_initializer_resolver.dart b/pkg/analyzer/lib/src/summary2/constructor_initializer_resolver.dart
index fbb7919..dd7dd8e 100644
--- a/pkg/analyzer/lib/src/summary2/constructor_initializer_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/constructor_initializer_resolver.dart
@@ -46,6 +46,9 @@
 
     _astResolver = AstResolver(_linker, _libraryElement, initializerScope);
 
+    FunctionBodyImpl body = _constructorNode.body;
+    body.localVariableInfo = LocalVariableInfo();
+
     _initializers();
     _redirectedConstructor();
   }
@@ -64,6 +67,7 @@
         initializer,
         enclosingClassElement: _classElement,
         enclosingExecutableElement: _constructorElement,
+        enclosingFunctionBody: _constructorNode.body,
       );
     }
   }