Version 2.14.0-165.0.dev

Merge commit '2242843b97b36e0ea0fddfdb47f24686f8931452' into 'dev'
diff --git a/pkg/analyzer/lib/src/summary2/function_type_builder.dart b/pkg/analyzer/lib/src/summary2/function_type_builder.dart
index faeefe2..f59a117 100644
--- a/pkg/analyzer/lib/src/summary2/function_type_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/function_type_builder.dart
@@ -11,6 +11,7 @@
 import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/type.dart';
+import 'package:analyzer/src/dart/element/type_algebra.dart';
 import 'package:analyzer/src/dart/element/type_visitor.dart';
 import 'package:analyzer/src/summary2/type_builder.dart';
 
@@ -34,7 +35,7 @@
   ///
   /// When [build] is called, the type is built, stored into this field,
   /// and set for the [node].
-  DartType? _type;
+  FunctionType? _type;
 
   FunctionTypeBuilder(
     this.typeFormals,
@@ -74,8 +75,9 @@
 
   @override
   DartType build() {
-    if (_type != null) {
-      return _type!;
+    var type = _type;
+    if (type != null) {
+      return type;
     }
 
     for (var typeParameter in typeFormals) {
@@ -91,18 +93,19 @@
     }
 
     var builtReturnType = _buildType(returnType);
-    _type = FunctionTypeImpl(
+    type = FunctionTypeImpl(
       typeFormals: typeFormals,
       parameters: parameters,
       returnType: builtReturnType,
       nullabilitySuffix: nullabilitySuffix,
     );
 
-    if (node != null) {
-      node?.type = _type;
-    }
+    var fresh = getFreshTypeParameters(typeFormals);
+    type = fresh.applyToFunctionType(type) as FunctionTypeImpl;
 
-    return _type!;
+    _type = type;
+    node?.type = type;
+    return type;
   }
 
   @override
diff --git a/tools/VERSION b/tools/VERSION
index c387783..e162905 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 14
 PATCH 0
-PRERELEASE 164
+PRERELEASE 165
 PRERELEASE_PATCH 0
\ No newline at end of file