Version 2.12.0-149.0.dev

Merge commit '4ef857e5d8fcfd9826844ea3ad075dc6fa4a8e5d' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index 4d2ff12..82342fd 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -55,8 +55,6 @@
   AnalysisContextImpl analysisContext;
   LinkedElementFactory elementFactory;
 
-  Set<LibraryCycle> loadedBundles = Set<LibraryCycle>.identity();
-
   LibraryContext({
     @required this.testView,
     @required AnalysisSessionImpl session,
@@ -112,7 +110,10 @@
     var thisLoadLogBuffer = StringBuffer();
 
     void loadBundle(LibraryCycle cycle, String debugPrefix) {
-      if (!loadedBundles.add(cycle)) return;
+      if (cycle.libraries.isEmpty ||
+          elementFactory.hasLibrary(cycle.libraries.first.uriStr)) {
+        return;
+      }
 
       thisLoadLogBuffer.writeln('$debugPrefix$cycle');
 
@@ -193,9 +194,6 @@
                   buffer.writeln('[cycle: $cycle]');
                   buffer.writeln();
 
-                  buffer.writeln('[loadedBundles: ${loadedBundles.toList()}]');
-                  buffer.writeln();
-
                   buffer.writeln('Bundles loaded in this load2() invocation:');
                   buffer.writeln(thisLoadLogBuffer);
                   buffer.writeln();
diff --git a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
index 729e32c..b92ebe9 100644
--- a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
@@ -381,6 +381,10 @@
     return library.exports;
   }
 
+  bool hasLibrary(String uriStr) {
+    return libraryReaders[uriStr] != null;
+  }
+
   bool isLibraryUri(String uriStr) {
     var libraryContext = libraryReaders[uriStr];
     return !libraryContext.hasPartOfDirective;
diff --git a/pkg/analyzer/pubspec.yaml b/pkg/analyzer/pubspec.yaml
index 7c09d2c..197a044 100644
--- a/pkg/analyzer/pubspec.yaml
+++ b/pkg/analyzer/pubspec.yaml
@@ -13,7 +13,7 @@
   collection: ^1.10.1
   convert: ^2.0.0
   crypto: ^2.0.0
-  glob: ^1.0.3
+  glob: '>=1.0.3 <3.0.0'
   meta: ^1.2.3
   package_config: ^1.0.0
   path: ^1.0.0
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index d225f1a..8703b9d 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -57,7 +57,6 @@
   bool withSyntheticFields = false,
   bool withTypes = false,
   bool withTypeParameterVariance = false,
-  bool annotateNullability = false,
 }) {
   var writer = _ElementWriter(
     selfUriStr: '${library.source.uri}',
@@ -70,7 +69,6 @@
     withSyntheticFields: withSyntheticFields,
     withTypes: withTypes,
     withTypeParameterVariance: withTypeParameterVariance,
-    annotateNullability: annotateNullability,
   );
   writer.writeLibraryElement(library);
 
@@ -140,7 +138,6 @@
   final bool withSyntheticFields;
   final bool withTypes;
   final bool withTypeParameterVariance;
-  final bool annotateNullability;
   final StringBuffer buffer = StringBuffer();
 
   String indent = '';
@@ -156,7 +153,6 @@
     this.withSyntheticFields = false,
     this.withTypes = false,
     this.withTypeParameterVariance,
-    this.annotateNullability = false,
   });
 
   bool isDynamicType(DartType type) => type is DynamicTypeImpl;
@@ -1176,7 +1172,7 @@
 
   String _typeStr(DartType type) {
     return type?.getDisplayString(
-      withNullability: annotateNullability,
+      withNullability: true,
     );
   }
 
@@ -1216,7 +1212,7 @@
         selfUriStr: selfUriStr,
         sink: buffer,
         indent: indent,
-        withNullability: annotateNullability,
+        withNullability: true,
       ),
     );
   }
diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
index aab0156..1627018 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
@@ -122,7 +122,7 @@
   }
 
   void setUp() {
-    featureSet = FeatureSets.beforeNullSafe;
+    featureSet = FeatureSets.nullSafe;
   }
 
   void _addLibraryUnits(
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index f3e7722..66e02fa 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -927,7 +927,6 @@
   }
 
   test_class_field_const_late() async {
-    featureSet = FeatureSets.nullSafe;
     var library =
         await checkLibrary('class C { static late const int i = 0; }');
     checkElementText(library, r'''
@@ -947,7 +946,6 @@
   }
 
   test_class_field_implicit_type_late() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('class C { late var x; }');
     checkElementText(library, r'''
 class C {
@@ -966,7 +964,6 @@
   }
 
   test_class_field_static_late() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('class C { static late int i; }');
     checkElementText(library, r'''
 class C {
@@ -986,7 +983,6 @@
   }
 
   test_class_fields_late() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 class C {
   late int foo;
@@ -1005,7 +1001,6 @@
   }
 
   test_class_fields_late_final() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 class C {
   late final int foo;
@@ -1024,7 +1019,6 @@
   }
 
   test_class_fields_late_final_initialized() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 class C {
   late final int foo = 0;
@@ -1379,7 +1373,18 @@
 class C<T extends void Function(T)> {}
 ''');
     checkElementText(library, r'''
-notSimplyBounded class C<T extends void Function(T) = void Function(Null)> {
+notSimplyBounded class C<T extends void Function(T) = void Function(Never)> {
+}
+''');
+  }
+
+  test_class_notSimplyBounded_function_typed_bound_complex_via_parameter_type_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
+    var library = await checkLibrary('''
+class C<T extends void Function(T)> {}
+''');
+    checkElementText(library, r'''
+notSimplyBounded class C<T extends void Function(T*)* = void Function(Null*)*> {
 }
 ''');
   }
@@ -1469,35 +1474,27 @@
   }
 
   test_class_ref_nullability_none() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 class C {}
 C c;
 ''');
-    checkElementText(
-        library,
-        '''
+    checkElementText(library, '''
 class C {
 }
 C c;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_class_ref_nullability_question() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 class C {}
 C? c;
 ''');
-    checkElementText(
-        library,
-        '''
+    checkElementText(library, '''
 class C {
 }
 C? c;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_class_ref_nullability_star() async {
@@ -1506,14 +1503,11 @@
 class C {}
 C c;
 ''');
-    checkElementText(
-        library,
-        '''
+    checkElementText(library, '''
 class C {
 }
 C* c;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_class_setter_abstract() async {
@@ -1781,6 +1775,7 @@
   }
 
   test_class_typeParameters_defaultType_functionTypeAlias_contravariant_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
     var library = await checkLibrary(r'''
 typedef F<X> = void Function(X);
 
@@ -1789,15 +1784,14 @@
     checkElementText(
         library,
         r'''
-typedef F<contravariant X> = void Function(X );
-notSimplyBounded class A<covariant X extends void Function(X) = void Function(Null)> {
+typedef F<contravariant X> = void Function(X* );
+notSimplyBounded class A<covariant X extends void Function(X*)* = void Function(Null*)*> {
 }
 ''',
         withTypeParameterVariance: true);
   }
 
   test_class_typeParameters_defaultType_functionTypeAlias_contravariant_nullSafe() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 typedef F<X> = void Function(X);
 
@@ -1830,7 +1824,6 @@
   }
 
   test_class_typeParameters_defaultType_functionTypeAlias_invariant_nullSafe() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 typedef F<X> = X Function(X);
 
@@ -1847,17 +1840,17 @@
   }
 
   test_class_typeParameters_defaultType_genericFunctionType_both_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
     var library = await checkLibrary(r'''
 class A<X extends X Function(X)> {}
 ''');
     checkElementText(library, r'''
-notSimplyBounded class A<X extends X Function(X) = dynamic Function(Null)> {
+notSimplyBounded class A<X extends X* Function(X*)* = dynamic Function(Null*)*> {
 }
 ''');
   }
 
   test_class_typeParameters_defaultType_genericFunctionType_both_nullSafe() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 class A<X extends X Function(X)> {}
 ''');
@@ -1868,17 +1861,17 @@
   }
 
   test_class_typeParameters_defaultType_genericFunctionType_contravariant_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
     var library = await checkLibrary(r'''
 class A<X extends void Function(X)> {}
 ''');
     checkElementText(library, r'''
-notSimplyBounded class A<X extends void Function(X) = void Function(Null)> {
+notSimplyBounded class A<X extends void Function(X*)* = void Function(Null*)*> {
 }
 ''');
   }
 
   test_class_typeParameters_defaultType_genericFunctionType_contravariant_nullSafe() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 class A<X extends void Function(X)> {}
 ''');
@@ -1899,7 +1892,6 @@
   }
 
   test_class_typeParameters_defaultType_genericFunctionType_covariant_nullSafe() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 class A<X extends X Function()> {}
 ''');
@@ -2714,7 +2706,6 @@
   }
 
   test_compilationUnit_nnbd_disabled_via_dart_directive() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 // @dart=2.2
 ''');
@@ -2728,13 +2719,11 @@
   }
 
   test_compilationUnit_nnbd_enabled() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('');
     expect(library.isNonNullableByDefault, isTrue);
   }
 
   test_const_asExpression() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 const num a = 0;
 const b = a as int;
@@ -2748,7 +2737,6 @@
   }
 
   test_const_assignmentExpression() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 const a = 0;
 const b = (a += 1);
@@ -2781,13 +2769,11 @@
         writeType: dynamic
       staticType: int
 ''',
-      annotateNullability: true,
       withFullyResolvedAst: true,
     );
   }
 
   test_const_cascadeExpression() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 const a = 0..isEven..abs();
 ''');
@@ -2819,7 +2805,6 @@
         literal: 0
         staticType: int
 ''',
-      annotateNullability: true,
       withFullyResolvedAst: true,
     );
   }
@@ -2897,7 +2882,6 @@
   }
 
   test_const_indexExpression() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 const a = [0];
 const b = 0;
@@ -2935,7 +2919,6 @@
         staticType: List<int>
         token: a
 ''',
-      annotateNullability: true,
       withFullyResolvedAst: true,
     );
   }
@@ -3403,7 +3386,6 @@
   }
 
   test_const_isExpression() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 const a = 0;
 const b = a is int;
@@ -3691,7 +3673,6 @@
   }
 
   test_const_methodInvocation() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 T f<T>(T a) => a;
 const b = f<int>(0);
@@ -3723,7 +3704,6 @@
             type: int
 T f(T a) {}
 ''',
-      annotateNullability: true,
       withFullyResolvedAst: true,
     );
   }
@@ -3800,7 +3780,6 @@
   }
 
   test_const_postfixExpression_increment() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 const a = 0;
 const b = a++;
@@ -3828,13 +3807,11 @@
       writeElement: self::@getter::a
       writeType: dynamic
 ''',
-      annotateNullability: true,
       withFullyResolvedAst: true,
     );
   }
 
   test_const_postfixExpression_nullCheck() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 const int? a = 0;
 const b = a!;
@@ -3858,13 +3835,11 @@
       staticElement: <null>
       staticType: int
 ''',
-      annotateNullability: true,
       withFullyResolvedAst: true,
     );
   }
 
   test_const_prefixExpression_increment() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 const a = 0;
 const b = ++a;
@@ -3892,7 +3867,6 @@
       writeElement: self::@getter::a
       writeType: dynamic
 ''',
-      annotateNullability: true,
       withFullyResolvedAst: true,
     );
   }
@@ -4459,7 +4433,6 @@
   }
 
   test_const_topLevel_nullSafe_nullAware_propertyAccess() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 const String? a = '';
 
@@ -4469,8 +4442,8 @@
 ''');
     // TODO(scheglov) include fully resolved AST, when types with suffixes
     checkElementText(library, r'''
-const String a = '';
-const List<int> b = [
+const String? a = '';
+const List<int?> b = [
         a/*location: test.dart;a?*/.
         length/*location: dart:core;String;length?*/];
 ''');
@@ -4528,6 +4501,16 @@
 const c = throw 42;
 ''');
     checkElementText(library, r'''
+const Never c = throw 42;
+''');
+  }
+
+  test_const_topLevel_throw_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
+    var library = await checkLibrary(r'''
+const c = throw 42;
+''');
+    checkElementText(library, r'''
 const dynamic c = throw 42;
 ''');
   }
@@ -5526,7 +5509,6 @@
   }
 
   test_defaultValue_eliminateTypeParameters() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 class A<T> {
   const X({List<T> a = const []});
@@ -5543,6 +5525,7 @@
   }
 
   test_defaultValue_eliminateTypeParameters_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
     var library = await checkLibrary('''
 class A<T> {
   const X({List<T> a = const []});
@@ -5552,7 +5535,7 @@
         library,
         r'''
 class A<T> {
-  dynamic X({List<T> a: const /*typeArgs=Null*/[]});
+  dynamic X({List<T*>* a: const /*typeArgs=Null**/[]});
 }
 ''',
         withTypes: true);
@@ -5658,7 +5641,7 @@
   const B();
 }
 class C<T> {
-  const C([B<T> b = const /*typeArgs=Null*/
+  const C([B<T> b = const /*typeArgs=Never*/
         B/*location: test.dart;B*/()]);
 }
 ''',
@@ -5684,7 +5667,58 @@
   const B();
 }
 class C<T> implements A<Iterable<T>> {
-  const C([A<T> a = const /*typeArgs=Null*/
+  const C([A<T> a = const /*typeArgs=Never*/
+        B/*location: test.dart;B*/()]);
+}
+''',
+        withTypes: true);
+  }
+
+  test_defaultValue_refersToGenericClass_constructor2_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
+    var library = await checkLibrary('''
+abstract class A<T> {}
+class B<T> implements A<T> {
+  const B();
+}
+class C<T> implements A<Iterable<T>> {
+  const C([A<T> a = const B()]);
+}
+''');
+    checkElementText(
+        library,
+        r'''
+abstract class A<T> {
+}
+class B<T> implements A<T*>* {
+  const B();
+}
+class C<T> implements A<Iterable<T*>*>* {
+  const C([A<T*>* a = const /*typeArgs=Null**/
+        B/*location: test.dart;B*/()]);
+}
+''',
+        withTypes: true);
+  }
+
+  test_defaultValue_refersToGenericClass_constructor_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
+    var library = await checkLibrary('''
+class B<T> {
+  const B();
+}
+class C<T> {
+  const C([B<T> b = const B()]);
+}
+''');
+    checkElementText(
+        library,
+        r'''
+class B<T> {
+  const B();
+}
+class C<T> {
+  const C([B<T*>* b = const /*typeArgs=Null**/
         B/*location: test.dart;B*/()]);
 }
 ''',
@@ -5704,7 +5738,7 @@
 class B<T> {
   const B();
 }
-void foo<T>([B<T> b = const /*typeArgs=Null*/
+void foo<T>([B<T> b = const /*typeArgs=Never*/
         B/*location: test.dart;B*/()]) {}
 ''',
         withTypes: true);
@@ -5726,7 +5760,7 @@
   const B();
 }
 class C {
-  void foo<T>([B<T> b = const /*typeArgs=Null*/
+  void foo<T>([B<T> b = const /*typeArgs=Never*/
         B/*location: test.dart;B*/()]) {}
 }
 ''',
@@ -5749,7 +5783,7 @@
   const B();
 }
 class C<E1> {
-  void foo<E2>([B<E1, E2> b = const /*typeArgs=Null,Null*/
+  void foo<E2>([B<E1, E2> b = const /*typeArgs=Never,Never*/
         B/*location: test.dart;B*/()]) {}
 }
 ''',
@@ -5772,7 +5806,7 @@
   const B();
 }
 class C<T> {
-  void foo([B<T> b = const /*typeArgs=Null*/
+  void foo([B<T> b = const /*typeArgs=Never*/
         B/*location: test.dart;B*/()]) {}
 }
 ''',
@@ -6532,7 +6566,6 @@
   }
 
   test_field_abstract() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 abstract class C {
   abstract int i;
@@ -6576,7 +6609,6 @@
   }
 
   test_field_external() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 abstract class C {
   external int i;
@@ -6817,26 +6849,20 @@
   }
 
   test_field_type_inferred_Never() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 class C {
   var a = throw 42;
 }
 ''');
 
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 class C {
   Never a;
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_field_type_inferred_nonNullify() async {
-    featureSet = FeatureSets.nullSafe;
-
     addSource('/a.dart', '''
 // @dart = 2.7
 var a = 0;
@@ -6849,15 +6875,12 @@
 }
 ''');
 
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'a.dart';
 class C {
   int b;
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_field_typed() async {
@@ -7147,7 +7170,7 @@
     var unit = library.definingCompilationUnit;
     var type = unit.topLevelVariables[0].type as FunctionType;
     expect(type.element.enclosingElement, same(unit.functionTypeAliases[0]));
-    _assertTypeStrings(type.typeArguments, ['int*']);
+    _assertTypeStrings(type.typeArguments, ['int']);
   }
 
   test_functionTypeAlias_typeParameters_variance_contravariant() async {
@@ -7330,29 +7353,21 @@
   }
 
   test_generic_function_type_nullability_none() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 void Function() f;
 ''');
-    checkElementText(
-        library,
-        '''
+    checkElementText(library, '''
 void Function() f;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_generic_function_type_nullability_question() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 void Function()? f;
 ''');
-    checkElementText(
-        library,
-        '''
+    checkElementText(library, '''
 void Function()? f;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_generic_function_type_nullability_star() async {
@@ -7360,12 +7375,9 @@
     var library = await checkLibrary('''
 void Function() f;
 ''');
-    checkElementText(
-        library,
-        '''
+    checkElementText(library, '''
 void Function()* f;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_generic_gClass_gMethodStatic() async {
@@ -8209,7 +8221,6 @@
   }
 
   test_inferred_type_functionExpressionInvocation_oppositeOrder() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 class A {
   static final foo = bar(1.2);
@@ -8258,67 +8269,51 @@
   }
 
   test_inferred_type_nullability_class_ref_none() async {
-    featureSet = FeatureSets.nullSafe;
     addSource('/a.dart', 'int f() => 0;');
     var library = await checkLibrary('''
 import 'a.dart';
 var x = f();
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'a.dart';
 int x;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_inferred_type_nullability_class_ref_question() async {
-    featureSet = FeatureSets.nullSafe;
     addSource('/a.dart', 'int? f() => 0;');
     var library = await checkLibrary('''
 import 'a.dart';
 var x = f();
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'a.dart';
 int? x;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_inferred_type_nullability_function_type_none() async {
-    featureSet = FeatureSets.nullSafe;
     addSource('/a.dart', 'void Function() f() => () {};');
     var library = await checkLibrary('''
 import 'a.dart';
 var x = f();
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'a.dart';
 void Function() x;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_inferred_type_nullability_function_type_question() async {
-    featureSet = FeatureSets.nullSafe;
     addSource('/a.dart', 'void Function()? f() => () {};');
     var library = await checkLibrary('''
 import 'a.dart';
 var x = f();
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'a.dart';
 void Function()? x;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_inferred_type_refers_to_bound_type_param() async {
@@ -8631,6 +8626,7 @@
   }
 
   test_instanceInference_operator_equal_legacy_from_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
     addLibrarySource('/legacy.dart', r'''
 // @dart = 2.7
 class LegacyDefault {
@@ -8655,9 +8651,7 @@
   bool operator==(other) => false;
 }
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'legacy.dart';
 class X1 extends LegacyDefault* {
   bool* ==(dynamic other) {}
@@ -8668,12 +8662,10 @@
 class X3 extends LegacyInt* {
   bool* ==(int* other) {}
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_instanceInference_operator_equal_legacy_from_legacy_nullSafe() async {
-    featureSet = FeatureSets.nullSafe;
     addLibrarySource('/legacy.dart', r'''
 // @dart = 2.7
 class LegacyDefault {
@@ -8711,9 +8703,7 @@
   bool operator==(other) => false;
 }
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'legacy.dart';
 import 'nullSafe.dart';
 class X1 extends LegacyDefault* implements NullSafeDefault* {
@@ -8725,12 +8715,10 @@
 class X3 extends LegacyInt* implements NullSafeInt* {
   bool* ==(int* other) {}
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_instanceInference_operator_equal_nullSafe_from_nullSafe() async {
-    featureSet = FeatureSets.nullSafe;
     addLibrarySource('/nullSafe.dart', r'''
 class NullSafeDefault {
   bool operator==(other) => false;
@@ -8754,9 +8742,7 @@
   bool operator==(other) => false;
 }
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'nullSafe.dart';
 class X1 extends NullSafeDefault {
   bool ==(Object other) {}
@@ -8767,8 +8753,7 @@
 class X3 extends NullSafeInt {
   bool ==(int other) {}
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_instantiateToBounds_boundRefersToEarlierTypeArgument() async {
@@ -8796,10 +8781,31 @@
 notSimplyBounded class C<T extends C<T> = C<dynamic>> {
 }
 class B {
-  C<C<dynamic>> c3;
+  C<C<Object?>> c3;
 }
 C<C<dynamic>> c;
-C<C<dynamic>> c2;
+C<C<Object?>> c2;
+''');
+  }
+
+  test_instantiateToBounds_boundRefersToItself_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
+    var library = await checkLibrary('''
+class C<T extends C<T>> {}
+C c;
+var c2 = new C();
+class B {
+  var c3 = new C();
+}
+''');
+    checkElementText(library, r'''
+notSimplyBounded class C<T extends C<T*>* = C<dynamic>*> {
+}
+class B {
+  C<C<dynamic>*>* c3;
+}
+C<C<dynamic>*>* c;
+C<C<dynamic>*>* c2;
 ''');
   }
 
@@ -10349,14 +10355,13 @@
   }
 
   test_mixin_inference_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
     var library = await checkLibrary(r'''
 class A<T> {}
 mixin M<U> on A<U> {}
 class B extends A<int> with M {}
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 class A<T> {
 }
 class B extends A<int*>* with M<int*>* {
@@ -10364,20 +10369,16 @@
 }
 mixin M<U> on A<U*>* {
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_mixin_inference_nullSafety() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 class A<T> {}
 mixin M<U> on A<U> {}
 class B extends A<int> with M {}
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 class A<T> {
 }
 class B extends A<int> with M<int> {
@@ -10385,12 +10386,10 @@
 }
 mixin M<U> on A<U> {
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_mixin_inference_nullSafety2() async {
-    featureSet = FeatureSets.nullSafe;
     addLibrarySource('/a.dart', r'''
 class A<T> {}
 
@@ -10403,19 +10402,15 @@
 
 class D extends A<int> with B<int>, C {}
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'a.dart';
 class D extends A<int*>* with B<int*>*, C<int*>* {
   synthetic D();
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_mixin_inference_nullSafety_mixed_inOrder() async {
-    featureSet = FeatureSets.nullSafe;
     addLibrarySource('/a.dart', r'''
 class A<T> {}
 mixin M<U> on A<U> {}
@@ -10425,20 +10420,16 @@
 import 'a.dart';
 class B extends A<int> with M {}
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'a.dart';
 class B extends A<int*>* with M<int*>* {
   synthetic B();
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   @FailingTest(reason: 'Out-of-order inference is not specified yet')
   test_mixin_inference_nullSafety_mixed_outOfOrder() async {
-    featureSet = FeatureSets.nullSafe;
     addLibrarySource('/a.dart', r'''
 // @dart = 2.8
 class A<T> {}
@@ -10449,15 +10440,12 @@
 
 class B extends A<int> with M {}
 ''');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'a.dart';
 class B extends A<int> with M<int> {
   synthetic B();
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_mixin_method_namedAsConstraint() async {
@@ -11262,7 +11250,6 @@
   }
 
   test_top_level_variable_external() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 external int i;
 ''');
@@ -11551,57 +11538,42 @@
   test_type_never_disableNnbd() async {
     featureSet = FeatureSets.beforeNullSafe;
     var library = await checkLibrary('Never d;');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 Null* d;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_type_never_enableNnbd() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('Never d;');
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 Never d;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_type_param_ref_nullability_none() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 class C<T> {
   T t;
 }
 ''');
-    checkElementText(
-        library,
-        '''
+    checkElementText(library, '''
 class C<T> {
   T t;
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_type_param_ref_nullability_question() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('''
 class C<T> {
   T? t;
 }
 ''');
-    checkElementText(
-        library,
-        '''
+    checkElementText(library, '''
 class C<T> {
   T? t;
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_type_param_ref_nullability_star() async {
@@ -11611,14 +11583,11 @@
   T t;
 }
 ''');
-    checkElementText(
-        library,
-        '''
+    checkElementText(library, '''
 class C<T> {
   T* t;
 }
-''',
-        annotateNullability: true);
+''');
   }
 
   test_type_reference_lib_to_lib() async {
@@ -12091,7 +12060,6 @@
   }
 
   test_typedef_nonFunction_using_interface_disabled() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 typedef A = int;
 void f(A a) {}
@@ -12354,14 +12322,30 @@
   test_typedef_type_parameters_f_bound_complex() async {
     var library = await checkLibrary('typedef U F<T extends List<U>, U>(T t);');
     checkElementText(library, r'''
-notSimplyBounded typedef F<T extends List<U> = List<Null>, U> = U Function(T t);
+notSimplyBounded typedef F<T extends List<U> = List<Never>, U> = U Function(T t);
+''');
+  }
+
+  test_typedef_type_parameters_f_bound_complex_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
+    var library = await checkLibrary('typedef U F<T extends List<U>, U>(T t);');
+    checkElementText(library, r'''
+notSimplyBounded typedef F<T extends List<U*>* = List<Null*>*, U> = U* Function(T* t);
 ''');
   }
 
   test_typedef_type_parameters_f_bound_simple() async {
     var library = await checkLibrary('typedef U F<T extends U, U>(T t);');
     checkElementText(library, r'''
-notSimplyBounded typedef F<T extends U = Null, U> = U Function(T t);
+notSimplyBounded typedef F<T extends U = Never, U> = U Function(T t);
+''');
+  }
+
+  test_typedef_type_parameters_f_bound_simple_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
+    var library = await checkLibrary('typedef U F<T extends U, U>(T t);');
+    checkElementText(library, r'''
+notSimplyBounded typedef F<T extends U* = Null*, U> = U* Function(T* t);
 ''');
   }
 
@@ -12369,7 +12353,16 @@
     var library =
         await checkLibrary('typedef F<T extends U, U> = U Function(T t);');
     checkElementText(library, r'''
-notSimplyBounded typedef F<T extends U = Null, U> = U Function(T t);
+notSimplyBounded typedef F<T extends U = Never, U> = U Function(T t);
+''');
+  }
+
+  test_typedef_type_parameters_f_bound_simple_new_syntax_legacy() async {
+    featureSet = FeatureSets.beforeNullSafe;
+    var library =
+        await checkLibrary('typedef F<T extends U, U> = U Function(T t);');
+    checkElementText(library, r'''
+notSimplyBounded typedef F<T extends U* = Null*, U> = U* Function(T* t);
 ''');
   }
 
@@ -12661,7 +12654,6 @@
   }
 
   test_variable_const_late() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('late const int i = 0;');
     checkElementText(library, r'''
 late const int i = 0;
@@ -12762,7 +12754,7 @@
     expect(variable, isNotNull);
     expect(variable.isFinal, isTrue);
     expect(variable.getter, same(getter));
-    expect('${variable.type}', 'int*');
+    expect('${variable.type}', 'int');
     expect(variable, same(_elementOfDefiningUnit(library, '@field', 'x')));
   }
 
@@ -12827,7 +12819,6 @@
   }
 
   test_variable_late() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('late int x = 0;');
     checkElementText(
         library,
@@ -12840,7 +12831,6 @@
   }
 
   test_variable_late_final() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('late final int x;');
     checkElementText(
         library,
@@ -12853,7 +12843,6 @@
   }
 
   test_variable_late_final_initialized() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary('late final int x = 0;');
     checkElementText(
         library,
@@ -12934,17 +12923,13 @@
   }
 
   test_variable_type_inferred_Never() async {
-    featureSet = FeatureSets.nullSafe;
     var library = await checkLibrary(r'''
 var a = throw 42;
 ''');
 
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 Never a;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_variable_type_inferred_noInitializer() async {
@@ -12958,8 +12943,6 @@
   }
 
   test_variable_type_inferred_nonNullify() async {
-    featureSet = FeatureSets.nullSafe;
-
     addSource('/a.dart', '''
 // @dart = 2.7
 var a = 0;
@@ -12970,13 +12953,10 @@
 var b = a;
 ''');
 
-    checkElementText(
-        library,
-        r'''
+    checkElementText(library, r'''
 import 'a.dart';
 int b;
-''',
-        annotateNullability: true);
+''');
   }
 
   test_variableInitializer_contextType_after_astRewrite() async {
@@ -13024,7 +13004,7 @@
   }
 
   void _assertTypeStr(DartType type, String expected) {
-    var typeStr = type.getDisplayString(withNullability: false);
+    var typeStr = type.getDisplayString(withNullability: true);
     expect(typeStr, expected);
   }
 
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 4038ead..11b223e 100644
--- a/pkg/analyzer/test/src/summary/top_level_inference_test.dart
+++ b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
@@ -2176,13 +2176,13 @@
 ''');
     checkElementText(library, r'''
 abstract class A {
-  int foo(int x);
+  int* foo(int* x);
 }
 abstract class B {
-  double foo(int x);
+  double* foo(int* x);
 }
-abstract class C implements A, B {
-  Null foo/*error: overrideNoCombinedSuperSignature*/(dynamic x);
+abstract class C implements A*, B* {
+  Null* foo/*error: overrideNoCombinedSuperSignature*/(dynamic x);
 }
 ''');
   }
diff --git a/runtime/platform/text_buffer.cc b/runtime/platform/text_buffer.cc
index 104fe76..2a3b80f 100644
--- a/runtime/platform/text_buffer.cc
+++ b/runtime/platform/text_buffer.cc
@@ -14,10 +14,18 @@
 intptr_t BaseTextBuffer::Printf(const char* format, ...) {
   va_list args;
   va_start(args, format);
+  intptr_t len = VPrintf(format, args);
+  va_end(args);
+  return len;
+}
+
+intptr_t BaseTextBuffer::VPrintf(const char* format, va_list args) {
+  va_list args1;
+  va_copy(args1, args);
   intptr_t remaining = capacity_ - length_;
   ASSERT(remaining >= 0);
-  intptr_t len = Utils::VSNPrint(buffer_ + length_, remaining, format, args);
-  va_end(args);
+  intptr_t len = Utils::VSNPrint(buffer_ + length_, remaining, format, args1);
+  va_end(args1);
   if (len >= remaining) {
     if (!EnsureCapacity(len)) {
       length_ = capacity_ - 1;
@@ -27,7 +35,7 @@
     remaining = capacity_ - length_;
     ASSERT(remaining > len);
     va_list args2;
-    va_start(args2, format);
+    va_copy(args2, args);
     intptr_t len2 =
         Utils::VSNPrint(buffer_ + length_, remaining, format, args2);
     va_end(args2);
diff --git a/runtime/platform/text_buffer.h b/runtime/platform/text_buffer.h
index c44d955..78f8e4f 100644
--- a/runtime/platform/text_buffer.h
+++ b/runtime/platform/text_buffer.h
@@ -20,6 +20,7 @@
   virtual ~BaseTextBuffer() {}
 
   intptr_t Printf(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
+  intptr_t VPrintf(const char* format, va_list args);
   void AddChar(char ch);
   void EscapeAndAddUTF16CodeUnit(uint16_t cu);
   void EscapeAndAddCodeUnit(uint32_t cu);
diff --git a/runtime/vm/compiler/aot/precompiler_tracer.cc b/runtime/vm/compiler/aot/precompiler_tracer.cc
index fcb56b2..96dfbda 100644
--- a/runtime/vm/compiler/aot/precompiler_tracer.cc
+++ b/runtime/vm/compiler/aot/precompiler_tracer.cc
@@ -32,6 +32,7 @@
 PrecompilerTracer::PrecompilerTracer(Precompiler* precompiler, void* stream)
     : zone_(Thread::Current()->zone()),
       precompiler_(precompiler),
+      buffer_(1024),
       stream_(stream),
       strings_(HashTables::New<StringTable>(1024)),
       entities_(HashTables::New<EntityTable>(1024)),
@@ -46,6 +47,11 @@
   Write(",");
   WriteStringTable();
   Write("}\n");
+
+  const intptr_t output_length = buffer_.length();
+  char* output = buffer_.Steal();
+  Dart::file_write_callback()(output, output_length, stream_);
+  free(output);
   Dart::file_close_callback()(stream_);
 
   strings_.Release();
diff --git a/runtime/vm/compiler/aot/precompiler_tracer.h b/runtime/vm/compiler/aot/precompiler_tracer.h
index b654457..3e315bd 100644
--- a/runtime/vm/compiler/aot/precompiler_tracer.h
+++ b/runtime/vm/compiler/aot/precompiler_tracer.h
@@ -119,8 +119,7 @@
   void Write(const char* format, ...) PRINTF_ATTRIBUTE(2, 3) {
     va_list va;
     va_start(va, format);
-    const char* line = OS::VSCreate(zone_, format, va);
-    Dart::file_write_callback()(line, strlen(line), stream_);
+    buffer_.VPrintf(format, va);
     va_end(va);
   }
 
@@ -131,6 +130,7 @@
 
   Zone* zone_;
   Precompiler* precompiler_;
+  TextBuffer buffer_;
   void* stream_;
   StringTable strings_;
   EntityTable entities_;
diff --git a/tools/VERSION b/tools/VERSION
index 7cf65c7..583b5c1 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 12
 PATCH 0
-PRERELEASE 148
+PRERELEASE 149
 PRERELEASE_PATCH 0
\ No newline at end of file