Use the same writeType() for elements as for AST.

Change-Id: Ia29e9c86cbb34d0a92c76ca390927c1ca6661d34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236443
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 4fda1a5..869a97a 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -243,12 +243,6 @@
     return components.join(';');
   }
 
-  String? _typeStr(DartType? type) {
-    return type?.getDisplayString(
-      withNullability: true,
-    );
-  }
-
   void _withIndent(void Function() f) {
     var savedIndent = indent;
     indent = '$savedIndent  ';
@@ -296,7 +290,7 @@
       var supertype = e.supertype;
       if (supertype != null &&
           (supertype.element.name != 'Object' || e.mixins.isNotEmpty)) {
-        _writeType(supertype, name: 'supertype');
+        _writeType('supertype', supertype);
       }
 
       if (e.isMixin) {
@@ -304,15 +298,11 @@
         if (superclassConstraints.isEmpty) {
           throw StateError('At least Object is expected.');
         }
-        _writeElements<DartType>(
-          'superclassConstraints',
-          superclassConstraints,
-          _writeType,
-        );
+        _writeTypeList('superclassConstraints', superclassConstraints);
       }
 
-      _writeElements<DartType>('mixins', e.mixins, _writeType);
-      _writeElements<DartType>('interfaces', e.interfaces, _writeType);
+      _writeTypeList('mixins', e.mixins);
+      _writeTypeList('interfaces', e.interfaces);
 
       _writeElements('fields', e.fields, _writePropertyInducingElement);
 
@@ -484,7 +474,7 @@
       _writeMetadata(e);
       _writeCodeRange(e);
       _writeTypeParameterElements(e.typeParameters);
-      _writeType(e.extendedType, name: 'extendedType');
+      _writeType('extendedType', e.extendedType);
     });
 
     _withIndent(() {
@@ -522,7 +512,7 @@
       _writeCodeRange(e);
       _writeTypeParameterElements(e.typeParameters);
       _writeParameterElements(e.parameters);
-      _writeType(e.returnType, name: 'returnType');
+      _writeType('returnType', e.returnType);
     });
 
     _assertNonSyntheticElementSelf(e);
@@ -597,7 +587,7 @@
 
       _writeTypeParameterElements(e.typeParameters);
       _writeParameterElements(e.parameters);
-      _writeType(e.returnType, name: 'returnType');
+      _writeType('returnType', e.returnType);
       _writeNonSyntheticElement(e);
     });
 
@@ -672,7 +662,7 @@
     });
 
     _withIndent(() {
-      _writeType(e.type, name: 'type');
+      _writeType('type', e.type);
       _writeMetadata(e);
       _writeCodeRange(e);
       _writeTypeParameterElements(e.typeParameters);
@@ -741,7 +731,7 @@
 
       expect(e.typeParameters, isEmpty);
       _writeParameterElements(e.parameters);
-      _writeType(e.returnType, name: 'returnType');
+      _writeType('returnType', e.returnType);
       _writeNonSyntheticElement(e);
     });
   }
@@ -783,7 +773,7 @@
       _writeMetadata(e);
       _writeCodeRange(e);
       _writeTypeInferenceError(e);
-      _writeType(e.type, name: 'type');
+      _writeType('type', e.type);
       _writeConstantInitializer(e);
       _writeNonSyntheticElement(e);
     });
@@ -800,26 +790,8 @@
     }
   }
 
-  void _writeType(DartType type, {String? name}) {
-    var typeStr = _typeStr(type);
-    if (name != null) {
-      _writelnWithIndent('$name: $typeStr');
-    } else {
-      _writelnWithIndent('$typeStr');
-    }
-
-    var alias = type.alias;
-    if (alias != null) {
-      _withIndent(() {
-        _createAstPrinter().writeElement('aliasElement', alias.element);
-
-        _writeElements<DartType>(
-          'aliasArguments',
-          alias.typeArguments,
-          _writeType,
-        );
-      });
-    }
+  void _writeType(String name, DartType type) {
+    _createAstPrinter().writeType(type, name: name);
   }
 
   void _writeTypeAliasElement(TypeAliasElement e) {
@@ -838,7 +810,7 @@
       _writeTypeParameterElements(e.typeParameters);
 
       var aliasedType = e.aliasedType;
-      _writeType(aliasedType, name: 'aliasedType');
+      _writeType('aliasedType', aliasedType);
       // TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
       // TODO(scheglov) Remove it when we stop providing it everywhere.
       if (aliasedType is FunctionType) {
@@ -851,7 +823,7 @@
         _withIndent(() {
           _writeTypeParameterElements(aliasedElement.typeParameters);
           _writeParameterElements(aliasedElement.parameters);
-          _writeType(aliasedElement.returnType, name: 'returnType');
+          _writeType('returnType', aliasedElement.returnType);
         });
       }
     });
@@ -876,6 +848,10 @@
     }
   }
 
+  void _writeTypeList(String name, List<DartType> types) {
+    _createAstPrinter().writeTypeList(name, types);
+  }
+
   void _writeTypeParameterElement(TypeParameterElement e) {
     e as TypeParameterElementImpl;
 
@@ -889,12 +865,12 @@
 
       var bound = e.bound;
       if (bound != null) {
-        _writeType(bound, name: 'bound');
+        _writeType('bound', bound);
       }
 
       var defaultType = e.defaultType;
       if (defaultType != null) {
-        _writeType(defaultType, name: 'defaultType');
+        _writeType('defaultType', defaultType);
       }
 
       _writeMetadata(e);
diff --git a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
index 053898c..e0617b5 100644
--- a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
+++ b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
@@ -1285,6 +1285,40 @@
     _writeElement(name, element);
   }
 
+  void writeType(DartType? type, {String? name}) {
+    _sink.write(_indent);
+
+    if (name != null) {
+      _sink.write('$name: ');
+    }
+
+    if (type != null) {
+      var typeStr = _typeStr(type);
+      _writeln(typeStr);
+
+      var alias = type.alias;
+      if (alias != null) {
+        _withIndent(() {
+          _writeElement('alias', alias.element);
+          _withIndent(() {
+            _writeTypeList('typeArguments', alias.typeArguments);
+          });
+        });
+      }
+    } else {
+      _writeln('null');
+    }
+  }
+
+  void writeTypeList(String name, List<DartType>? types) {
+    if (types != null && types.isNotEmpty) {
+      _writelnWithIndent(name);
+      _withIndent(() {
+        types.forEach(writeType);
+      });
+    }
+  }
+
   /// Check that children entities of the [node] link to each other.
   void _checkChildrenEntitiesLinking(AstNode node) {
     Token? lastEnd;
@@ -1333,7 +1367,7 @@
     return '{$entriesStr}';
   }
 
-  String? _typeStr(DartType type) {
+  String _typeStr(DartType type) {
     return type.getDisplayString(withNullability: true);
   }
 
@@ -1534,32 +1568,13 @@
 
   void _writeType(String name, DartType? type) {
     if (_withResolution) {
-      if (type != null) {
-        var typeStr = _typeStr(type);
-        _writelnWithIndent('$name: $typeStr');
-
-        var alias = type.alias;
-        if (alias != null) {
-          _withIndent(() {
-            _writeElement('alias', alias.element);
-            _writeTypeList('typeArguments', alias.typeArguments);
-          });
-        }
-      } else {
-        _writelnWithIndent('$name: null');
-      }
+      writeType(type, name: name);
     }
   }
 
   void _writeTypeList(String name, List<DartType>? types) {
-    if (types != null && types.isNotEmpty) {
-      _writelnWithIndent(name);
-      _withIndent(() {
-        for (var type in types) {
-          var typeStr = _typeStr(type);
-          _writelnWithIndent('$typeStr');
-        }
-      });
+    if (_withResolution) {
+      writeTypeList(name, types);
     }
   }
 
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index df79258..d4e691d 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -1993,10 +1993,10 @@
           covariant U @96
             defaultType: dynamic
         supertype: C<U, T>
-          aliasElement: self::@typeAlias::A
-          aliasArguments
-            U
-            T
+          alias: self::@typeAlias::A
+            typeArguments
+              U
+              T
         constructors
           named @121
             periodOffset: 120
@@ -6412,13 +6412,13 @@
         typeParameters
           covariant X @42
             bound: void Function(X*)*
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                X*
+              alias: self::@typeAlias::F
+                typeArguments
+                  X*
             defaultType: void Function(Null*)*
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                Null*
+              alias: self::@typeAlias::F
+                typeArguments
+                  Null*
         constructors
           synthetic @-1
     typeAliases
@@ -6449,13 +6449,13 @@
         typeParameters
           covariant X @42
             bound: void Function(X)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                X
+              alias: self::@typeAlias::F
+                typeArguments
+                  X
             defaultType: void Function(Never)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                Never
+              alias: self::@typeAlias::F
+                typeArguments
+                  Never
         constructors
           synthetic @-1
     typeAliases
@@ -6486,13 +6486,13 @@
         typeParameters
           covariant X @38
             bound: X Function()
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                X
+              alias: self::@typeAlias::F
+                typeArguments
+                  X
             defaultType: dynamic Function()
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                dynamic
+              alias: self::@typeAlias::F
+                typeArguments
+                  dynamic
         constructors
           synthetic @-1
     typeAliases
@@ -6520,13 +6520,13 @@
         typeParameters
           covariant X @39
             bound: X Function(X)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                X
+              alias: self::@typeAlias::F
+                typeArguments
+                  X
             defaultType: dynamic Function(dynamic)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                dynamic
+              alias: self::@typeAlias::F
+                typeArguments
+                  dynamic
         constructors
           synthetic @-1
     typeAliases
@@ -6557,13 +6557,13 @@
         typeParameters
           covariant X @39
             bound: X Function(X)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                X
+              alias: self::@typeAlias::F
+                typeArguments
+                  X
             defaultType: dynamic Function(dynamic)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                dynamic
+              alias: self::@typeAlias::F
+                typeArguments
+                  dynamic
         constructors
           synthetic @-1
     typeAliases
@@ -6704,13 +6704,13 @@
         typeParameters
           covariant X @48
             bound: List<void Function(X)>
-              aliasElement: self::@typeAlias::A
-              aliasArguments
-                X
+              alias: self::@typeAlias::A
+                typeArguments
+                  X
             defaultType: List<void Function(Never)>
-              aliasElement: self::@typeAlias::A
-              aliasArguments
-                Never
+              alias: self::@typeAlias::A
+                typeArguments
+                  Never
         constructors
           synthetic @-1
     typeAliases
@@ -6736,13 +6736,13 @@
         typeParameters
           covariant X @37
             bound: Map<X, int>
-              aliasElement: self::@typeAlias::A
-              aliasArguments
-                X
+              alias: self::@typeAlias::A
+                typeArguments
+                  X
             defaultType: Map<dynamic, int>
-              aliasElement: self::@typeAlias::A
-              aliasArguments
-                dynamic
+              alias: self::@typeAlias::A
+                typeArguments
+                  dynamic
         constructors
           synthetic @-1
     typeAliases
@@ -16087,17 +16087,17 @@
         fields
           final f @71
             type: void Function(dynamic)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                dynamic
+              alias: self::@typeAlias::F
+                typeArguments
+                  dynamic
         constructors
           const @82
             parameters
               optionalNamed final this.f @90
                 type: void Function(dynamic)
-                  aliasElement: self::@typeAlias::F
-                  aliasArguments
-                    dynamic
+                  alias: self::@typeAlias::F
+                    typeArguments
+                      dynamic
                 constantInitializer
                   FunctionReference
                     function: SimpleIdentifier
@@ -16111,9 +16111,9 @@
         accessors
           synthetic get f @-1
             returnType: void Function(dynamic)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                dynamic
+              alias: self::@typeAlias::F
+                typeArguments
+                  dynamic
     typeAliases
       functionTypeAliasBased F @13
         typeParameters
@@ -16243,9 +16243,9 @@
         parameters
           optionalPositional compare @22
             type: int* Function(dynamic, dynamic)*
-              aliasElement: dart:core::@typeAlias::Comparator
-              aliasArguments
-                dynamic
+              alias: dart:core::@typeAlias::Comparator
+                typeArguments
+                  dynamic
             constantInitializer
               PrefixedIdentifier
                 prefix: SimpleIdentifier
@@ -19716,7 +19716,7 @@
         parameters
           requiredPositional f @25
             type: dynamic Function(int)
-              aliasElement: self::@typeAlias::F
+              alias: self::@typeAlias::F
         returnType: dynamic
 ''');
   }
@@ -20741,9 +20741,9 @@
         aliasedType: void Function(T) Function()
         aliasedElement: GenericFunctionTypeElement
           returnType: void Function(T)
-            aliasElement: self::@typeAlias::F1
-            aliasArguments
-              T
+            alias: self::@typeAlias::F1
+              typeArguments
+                T
 ''');
   }
 
@@ -20763,9 +20763,9 @@
         aliasedType: void Function(T) Function()
         aliasedElement: GenericFunctionTypeElement
           returnType: void Function(T)
-            aliasElement: self::@typeAlias::F1
-            aliasArguments
-              T
+            alias: self::@typeAlias::F1
+              typeArguments
+                T
       functionTypeAliasBased F1 @36
         typeParameters
           contravariant T @39
@@ -20838,9 +20838,9 @@
         aliasedType: T Function() Function()
         aliasedElement: GenericFunctionTypeElement
           returnType: T Function()
-            aliasElement: self::@typeAlias::F1
-            aliasArguments
-              T
+            alias: self::@typeAlias::F1
+              typeArguments
+                T
 ''');
   }
 
@@ -20872,9 +20872,9 @@
           parameters
             requiredPositional a @50
               type: void Function(T)
-                aliasElement: self::@typeAlias::F1
-                aliasArguments
-                  T
+                alias: self::@typeAlias::F1
+                  typeArguments
+                    T
           returnType: void
 ''');
   }
@@ -20926,9 +20926,9 @@
             requiredPositional a @41
               type: T
           returnType: T Function()
-            aliasElement: self::@typeAlias::F1
-            aliasArguments
-              T
+            alias: self::@typeAlias::F1
+              typeArguments
+                T
 ''');
   }
 
@@ -21823,9 +21823,9 @@
           parameters
             requiredPositional @-1
               type: V1 Function()
-                aliasElement: self::@typeAlias::F2
-                aliasArguments
-                  V1
+                alias: self::@typeAlias::F2
+                  typeArguments
+                    V1
           returnType: dynamic
       F2 @43
         typeParameters
@@ -22663,9 +22663,9 @@
             parameters
               requiredPositional f @65
                 type: D<V, U> Function<U>()
-                  aliasElement: self::@typeAlias::F
-                  aliasArguments
-                    V
+                  alias: self::@typeAlias::F
+                    typeArguments
+                      V
       class D @77
         typeParameters
           covariant T @79
@@ -22740,7 +22740,7 @@
             parameters
               requiredPositional f @54
                 type: D<T> Function<T>()
-                  aliasElement: self::@typeAlias::F
+                  alias: self::@typeAlias::F
       class D @66
         typeParameters
           covariant T @68
@@ -23284,31 +23284,31 @@
         fields
           v @49
             type: int Function(String)
-              aliasElement: self::@typeAlias::F
+              alias: self::@typeAlias::F
         constructors
           synthetic @-1
             superConstructor: self::@class::D::@constructor::•
         accessors
           synthetic get v @-1
             returnType: int Function(String)
-              aliasElement: self::@typeAlias::F
+              alias: self::@typeAlias::F
           synthetic set v @-1
             parameters
               requiredPositional _v @-1
                 type: int Function(String)
-                  aliasElement: self::@typeAlias::F
+                  alias: self::@typeAlias::F
             returnType: void
       abstract class D @69
         fields
           synthetic v @-1
             type: int Function(String)
-              aliasElement: self::@typeAlias::F
+              alias: self::@typeAlias::F
         constructors
           synthetic @-1
         accessors
           abstract get v @79
             returnType: int Function(String)
-              aliasElement: self::@typeAlias::F
+              alias: self::@typeAlias::F
     typeAliases
       functionTypeAliasBased F @12
         aliasedType: int Function(String)
@@ -23507,7 +23507,7 @@
         parameters
           requiredPositional f @37
             type: void Function(int Function(String))
-              aliasElement: self::@typeAlias::F
+              alias: self::@typeAlias::F
         returnType: dynamic
 ''');
   }
@@ -24551,9 +24551,9 @@
         methods
           f @31
             returnType: O Function(O)
-              aliasElement: a.dart::@typeAlias::F
-              aliasArguments
-                O
+              alias: a.dart::@typeAlias::F
+                typeArguments
+                  O
 ''');
   }
 
@@ -24580,22 +24580,22 @@
     topLevelVariables
       static f @33
         type: dynamic Function(num)
-          aliasElement: self::@typeAlias::F
-          aliasArguments
-            num
+          alias: self::@typeAlias::F
+            typeArguments
+              num
     accessors
       synthetic static get f @-1
         returnType: dynamic Function(num)
-          aliasElement: self::@typeAlias::F
-          aliasArguments
-            num
+          alias: self::@typeAlias::F
+            typeArguments
+              num
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function(num)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                num
+              alias: self::@typeAlias::F
+                typeArguments
+                  num
         returnType: void
 ''');
   }
@@ -24665,22 +24665,22 @@
     topLevelVariables
       static f @49
         type: S Function<S>(num)
-          aliasElement: self::@typeAlias::F
-          aliasArguments
-            num
+          alias: self::@typeAlias::F
+            typeArguments
+              num
     accessors
       synthetic static get f @-1
         returnType: S Function<S>(num)
-          aliasElement: self::@typeAlias::F
-          aliasArguments
-            num
+          alias: self::@typeAlias::F
+            typeArguments
+              num
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: S Function<S>(num)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                num
+              alias: self::@typeAlias::F
+                typeArguments
+                  num
         returnType: void
 ''');
   }
@@ -33416,7 +33416,7 @@
         type: E
       static f @49
         type: dynamic Function()
-          aliasElement: self::@typeAlias::F
+          alias: self::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -33434,12 +33434,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: self::@typeAlias::F
+          alias: self::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: self::@typeAlias::F
+              alias: self::@typeAlias::F
         returnType: void
 ''');
   }
@@ -33460,7 +33460,7 @@
         type: E
       static f @38
         type: dynamic Function()
-          aliasElement: self::@typeAlias::F
+          alias: self::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -33478,12 +33478,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: self::@typeAlias::F
+          alias: self::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: self::@typeAlias::F
+              alias: self::@typeAlias::F
         returnType: void
   parts
     a.dart
@@ -33604,7 +33604,7 @@
           type: E
         static f @23
           type: dynamic Function()
-            aliasElement: self::@typeAlias::F
+            alias: self::@typeAlias::F
       accessors
         synthetic static get c @-1
           returnType: C
@@ -33622,12 +33622,12 @@
           returnType: void
         synthetic static get f @-1
           returnType: dynamic Function()
-            aliasElement: self::@typeAlias::F
+            alias: self::@typeAlias::F
         synthetic static set f @-1
           parameters
             requiredPositional _f @-1
               type: dynamic Function()
-                aliasElement: self::@typeAlias::F
+                alias: self::@typeAlias::F
           returnType: void
 ''');
   }
@@ -33700,7 +33700,7 @@
           type: E
         static f @23
           type: dynamic Function()
-            aliasElement: self::@typeAlias::F
+            alias: self::@typeAlias::F
       accessors
         synthetic static get c @-1
           returnType: C
@@ -33718,12 +33718,12 @@
           returnType: void
         synthetic static get f @-1
           returnType: dynamic Function()
-            aliasElement: self::@typeAlias::F
+            alias: self::@typeAlias::F
         synthetic static set f @-1
           parameters
             requiredPositional _f @-1
               type: dynamic Function()
-                aliasElement: self::@typeAlias::F
+                alias: self::@typeAlias::F
           returnType: void
 ''');
   }
@@ -33794,7 +33794,7 @@
           type: E
         static f @60
           type: dynamic Function()
-            aliasElement: self::@typeAlias::F
+            alias: self::@typeAlias::F
       accessors
         synthetic static get c @-1
           returnType: C
@@ -33812,12 +33812,12 @@
           returnType: void
         synthetic static get f @-1
           returnType: dynamic Function()
-            aliasElement: self::@typeAlias::F
+            alias: self::@typeAlias::F
         synthetic static set f @-1
           parameters
             requiredPositional _f @-1
               type: dynamic Function()
-                aliasElement: self::@typeAlias::F
+                alias: self::@typeAlias::F
           returnType: void
 ''');
   }
@@ -33974,7 +33974,7 @@
         type: E
       static f @29
         type: dynamic Function()
-          aliasElement: a.dart::@typeAlias::F
+          alias: a.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -33992,12 +33992,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: a.dart::@typeAlias::F
+          alias: a.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: a.dart::@typeAlias::F
+              alias: a.dart::@typeAlias::F
         returnType: void
 ''');
   }
@@ -34018,7 +34018,7 @@
         type: E
       static f @29
         type: dynamic Function()
-          aliasElement: b.dart::@typeAlias::F
+          alias: b.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34036,12 +34036,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: b.dart::@typeAlias::F
+          alias: b.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: b.dart::@typeAlias::F
+              alias: b.dart::@typeAlias::F
         returnType: void
 ''');
   }
@@ -34063,7 +34063,7 @@
         type: E
       static f @29
         type: dynamic Function()
-          aliasElement: c.dart::@typeAlias::F
+          alias: c.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34081,12 +34081,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: c.dart::@typeAlias::F
+          alias: c.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: c.dart::@typeAlias::F
+              alias: c.dart::@typeAlias::F
         returnType: void
 ''');
   }
@@ -34108,7 +34108,7 @@
         type: E
       static f @31
         type: dynamic Function()
-          aliasElement: c.dart::@typeAlias::F
+          alias: c.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34126,12 +34126,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: c.dart::@typeAlias::F
+          alias: c.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: c.dart::@typeAlias::F
+              alias: c.dart::@typeAlias::F
         returnType: void
 ''');
   }
@@ -34152,7 +34152,7 @@
         type: E
       static f @31
         type: dynamic Function()
-          aliasElement: b.dart::@typeAlias::F
+          alias: b.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34170,12 +34170,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: b.dart::@typeAlias::F
+          alias: b.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: b.dart::@typeAlias::F
+              alias: b.dart::@typeAlias::F
         returnType: void
 ''');
   }
@@ -34196,7 +34196,7 @@
         type: E
       static f @29
         type: dynamic Function()
-          aliasElement: a.dart::@typeAlias::F
+          alias: a.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34214,12 +34214,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: a.dart::@typeAlias::F
+          alias: a.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: a.dart::@typeAlias::F
+              alias: a.dart::@typeAlias::F
         returnType: void
 ''');
   }
@@ -34273,7 +34273,7 @@
         type: E
       static f @31
         type: dynamic Function()
-          aliasElement: b.dart::@typeAlias::F
+          alias: b.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34291,12 +34291,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: b.dart::@typeAlias::F
+          alias: b.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: b.dart::@typeAlias::F
+              alias: b.dart::@typeAlias::F
         returnType: void
 ''');
   }
@@ -34316,7 +34316,7 @@
         type: E
       static f @29
         type: dynamic Function()
-          aliasElement: a.dart::@typeAlias::F
+          alias: a.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34334,12 +34334,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: a.dart::@typeAlias::F
+          alias: a.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: a.dart::@typeAlias::F
+              alias: a.dart::@typeAlias::F
         returnType: void
 ''');
   }
@@ -34357,16 +34357,16 @@
     topLevelVariables
       static f @15
         type: dynamic Function()
-          aliasElement: self::@typeAlias::F
+          alias: self::@typeAlias::F
     accessors
       synthetic static get f @-1
         returnType: dynamic Function()
-          aliasElement: self::@typeAlias::F
+          alias: self::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              aliasElement: self::@typeAlias::F
+              alias: self::@typeAlias::F
         returnType: void
 ''');
   }
@@ -34393,25 +34393,25 @@
     topLevelVariables
       static f @39
         type: String Function(int)
-          aliasElement: self::@typeAlias::F
-          aliasArguments
-            int
-            String
+          alias: self::@typeAlias::F
+            typeArguments
+              int
+              String
     accessors
       synthetic static get f @-1
         returnType: String Function(int)
-          aliasElement: self::@typeAlias::F
-          aliasArguments
-            int
-            String
+          alias: self::@typeAlias::F
+            typeArguments
+              int
+              String
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: String Function(int)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                int
-                String
+              alias: self::@typeAlias::F
+                typeArguments
+                  int
+                  String
         returnType: void
 ''');
   }
@@ -34437,25 +34437,25 @@
     topLevelVariables
       static f @26
         type: dynamic Function(dynamic)
-          aliasElement: self::@typeAlias::F
-          aliasArguments
-            dynamic
-            dynamic
+          alias: self::@typeAlias::F
+            typeArguments
+              dynamic
+              dynamic
     accessors
       synthetic static get f @-1
         returnType: dynamic Function(dynamic)
-          aliasElement: self::@typeAlias::F
-          aliasArguments
-            dynamic
-            dynamic
+          alias: self::@typeAlias::F
+            typeArguments
+              dynamic
+              dynamic
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function(dynamic)
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                dynamic
-                dynamic
+              alias: self::@typeAlias::F
+                typeArguments
+                  dynamic
+                  dynamic
         returnType: void
 ''');
   }
@@ -34572,9 +34572,9 @@
         aliasedType: void Function(T) Function()
         aliasedElement: GenericFunctionTypeElement
           returnType: void Function(T)
-            aliasElement: self::@typeAlias::F1
-            aliasArguments
-              T
+            alias: self::@typeAlias::F1
+              typeArguments
+                T
 ''');
   }
 
@@ -34637,9 +34637,9 @@
         aliasedType: T Function() Function()
         aliasedElement: GenericFunctionTypeElement
           returnType: T Function()
-            aliasElement: self::@typeAlias::F1
-            aliasArguments
-              T
+            alias: self::@typeAlias::F1
+              typeArguments
+                T
 ''');
   }
 
@@ -34671,9 +34671,9 @@
           parameters
             requiredPositional @-1
               type: void Function(T)
-                aliasElement: self::@typeAlias::F1
-                aliasArguments
-                  T
+                alias: self::@typeAlias::F1
+                  typeArguments
+                    T
           returnType: void
 ''');
   }
@@ -34726,7 +34726,7 @@
           parameters
             requiredPositional @-1
               type: void Function()
-                aliasElement: self::@typeAlias::F
+                alias: self::@typeAlias::F
           returnType: void
 ''');
   }
@@ -34778,9 +34778,9 @@
             requiredPositional @-1
               type: T
           returnType: T Function()
-            aliasElement: self::@typeAlias::F1
-            aliasArguments
-              T
+            alias: self::@typeAlias::F1
+              typeArguments
+                T
 ''');
   }
 
@@ -34927,24 +34927,24 @@
         fields
           f @58
             type: int Function<T>(T)
-              aliasElement: self::@typeAlias::Foo
-              aliasArguments
-                int
+              alias: self::@typeAlias::Foo
+                typeArguments
+                  int
         constructors
           synthetic @-1
         accessors
           synthetic get f @-1
             returnType: int Function<T>(T)
-              aliasElement: self::@typeAlias::Foo
-              aliasArguments
-                int
+              alias: self::@typeAlias::Foo
+                typeArguments
+                  int
           synthetic set f @-1
             parameters
               requiredPositional _f @-1
                 type: int Function<T>(T)
-                  aliasElement: self::@typeAlias::Foo
-                  aliasArguments
-                    int
+                  alias: self::@typeAlias::Foo
+                    typeArguments
+                      int
             returnType: void
     typeAliases
       Foo @8
@@ -35638,15 +35638,15 @@
         parameters
           requiredPositional a @71
             type: void Function()
-              aliasElement: self::@typeAlias::A1
+              alias: self::@typeAlias::A1
         returnType: void
       f2 @82
         parameters
           requiredPositional a @93
             type: int Function()
-              aliasElement: self::@typeAlias::A2
-              aliasArguments
-                int
+              alias: self::@typeAlias::A2
+                typeArguments
+                  int
         returnType: void
 ''');
   }
@@ -35677,16 +35677,16 @@
         parameters
           requiredPositional a @65
             type: List<int>
-              aliasElement: self::@typeAlias::A1
+              alias: self::@typeAlias::A1
         returnType: void
       f2 @76
         parameters
           requiredPositional a @95
             type: Map<int, String>
-              aliasElement: self::@typeAlias::A2
-              aliasArguments
-                int
-                String
+              alias: self::@typeAlias::A2
+                typeArguments
+                  int
+                  String
         returnType: void
 ''');
   }
@@ -35733,9 +35733,9 @@
         parameters
           requiredPositional a @33
             type: U
-              aliasElement: self::@typeAlias::A
-              aliasArguments
-                U
+              alias: self::@typeAlias::A
+                typeArguments
+                  U
         returnType: void
 ''');
   }
@@ -35777,9 +35777,9 @@
       class B @49
         interfaces
           A<int, String>
-            aliasElement: self::@typeAlias::X
-            aliasArguments
-              String
+            alias: self::@typeAlias::X
+              typeArguments
+                String
         constructors
           synthetic @-1
     typeAliases
@@ -35858,9 +35858,9 @@
         interfaces
           B
           A<int?>
-            aliasElement: self::@typeAlias::X
-            aliasArguments
-              int
+            alias: self::@typeAlias::X
+              typeArguments
+                int
           C
         constructors
           synthetic @-1
@@ -35993,7 +35993,7 @@
         supertype: Object
         mixins
           A<int>
-            aliasElement: self::@typeAlias::X
+            alias: self::@typeAlias::X
         constructors
           synthetic @-1
     typeAliases
@@ -36067,7 +36067,7 @@
         mixins
           M1
           A<int?>
-            aliasElement: self::@typeAlias::X
+            alias: self::@typeAlias::X
           M2
         constructors
           synthetic @-1
@@ -36124,7 +36124,7 @@
           synthetic @-1
       class B @40
         supertype: A<int>
-          aliasElement: self::@typeAlias::X
+          alias: self::@typeAlias::X
         constructors
           synthetic @-1
             superConstructor: ConstructorMember
@@ -36154,9 +36154,9 @@
           synthetic @-1
       class B @38
         supertype: A<int>
-          aliasElement: self::@typeAlias::X
-          aliasArguments
-            A<int>
+          alias: self::@typeAlias::X
+            typeArguments
+              A<int>
         constructors
           synthetic @-1
             superConstructor: ConstructorMember
@@ -36232,7 +36232,7 @@
           synthetic @-1
       class D @41
         supertype: A<int?>
-          aliasElement: self::@typeAlias::X
+          alias: self::@typeAlias::X
         constructors
           synthetic @-1
             superConstructor: ConstructorMember
@@ -36321,7 +36321,7 @@
         parameters
           requiredPositional a @26
             type: dynamic Function()
-              aliasElement: self::@typeAlias::A
+              alias: self::@typeAlias::A
         returnType: void
 ''');
   }
@@ -36342,7 +36342,7 @@
         parameters
           requiredPositional a @26
             type: int
-              aliasElement: self::@typeAlias::A
+              alias: self::@typeAlias::A
         returnType: void
 ''');
   }
@@ -36366,7 +36366,7 @@
         parameters
           requiredPositional a @41
             type: List<int*>*
-              aliasElement: a.dart::@typeAlias::A
+              alias: a.dart::@typeAlias::A
         returnType: void
 ''');
   }
@@ -36387,7 +36387,7 @@
         parameters
           requiredPositional a @27
             type: int?
-              aliasElement: self::@typeAlias::A
+              alias: self::@typeAlias::A
         returnType: void
 ''');
   }
@@ -36411,9 +36411,9 @@
         parameters
           requiredPositional a @45
             type: Map<int, String>
-              aliasElement: self::@typeAlias::A
-              aliasArguments
-                String
+              alias: self::@typeAlias::A
+                typeArguments
+                  String
         returnType: void
 ''');
   }
@@ -36483,9 +36483,9 @@
         parameters
           requiredPositional a @49
             type: int
-              aliasElement: self::@typeAlias::A
-              aliasArguments
-                int
+              alias: self::@typeAlias::A
+                typeArguments
+                  int
         returnType: void
 ''');
   }
@@ -36515,9 +36515,9 @@
         parameters
           requiredPositional a @50
             type: int?
-              aliasElement: self::@typeAlias::A
-              aliasArguments
-                int
+              alias: self::@typeAlias::A
+                typeArguments
+                  int
         returnType: void
 ''');
   }
diff --git a/pkg/analyzer/test/src/summary/top_level_inference_test.dart b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
index 3974511..5cc3ab8 100644
--- a/pkg/analyzer/test/src/summary/top_level_inference_test.dart
+++ b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
@@ -4689,9 +4689,9 @@
         fields
           synthetic x @-1
             type: dynamic Function()
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                T
+              alias: self::@typeAlias::F
+                typeArguments
+                  T
           synthetic y @-1
             type: List<dynamic Function()>
         constructors
@@ -4699,9 +4699,9 @@
         accessors
           get x @41
             returnType: dynamic Function()
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                T
+              alias: self::@typeAlias::F
+                typeArguments
+                  T
           get y @69
             returnType: List<dynamic Function()>
       class B @89
@@ -4709,9 +4709,9 @@
         fields
           synthetic x @-1
             type: dynamic Function()
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                int
+              alias: self::@typeAlias::F
+                typeArguments
+                  int
           synthetic y @-1
             type: List<dynamic Function()>
         constructors
@@ -4722,9 +4722,9 @@
         accessors
           get x @114
             returnType: dynamic Function()
-              aliasElement: self::@typeAlias::F
-              aliasArguments
-                int
+              alias: self::@typeAlias::F
+                typeArguments
+                  int
           get y @131
             returnType: List<dynamic Function()>
     typeAliases