Version 2.12.0-127.0.dev

Merge commit '56cf16887c95620e1a9fefd6eb8658c1752402d8' into 'dev'
diff --git a/pkg/analysis_server/test/src/services/correction/fix/change_to_test.dart b/pkg/analysis_server/test/src/services/correction/fix/change_to_test.dart
index 5a1107c..e3e581b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/change_to_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/change_to_test.dart
@@ -3,7 +3,6 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -127,9 +126,7 @@
   c.Future v = null;
   print(v);
 }
-''', errorFilter: (error) {
-      return error.errorCode == CompileTimeErrorCode.UNDEFINED_CLASS;
-    });
+''');
   }
 
   Future<void> test_class_with() async {
@@ -180,9 +177,7 @@
   c.main();
 }
 ''');
-    await assertNoFix(errorFilter: (error) {
-      return error.errorCode == CompileTimeErrorCode.UNDEFINED_FUNCTION;
-    });
+    await assertNoFix();
   }
 
   Future<void> test_function_thisLibrary() async {
diff --git a/pkg/analyzer/lib/src/error/imports_verifier.dart b/pkg/analyzer/lib/src/error/imports_verifier.dart
index 713b451..198ee09 100644
--- a/pkg/analyzer/lib/src/error/imports_verifier.dart
+++ b/pkg/analyzer/lib/src/error/imports_verifier.dart
@@ -417,6 +417,13 @@
       // Find import directives using namespaces.
       for (var importDirective in _prefixElementMap[prefix] ?? []) {
         Namespace namespace = _computeNamespace(importDirective);
+        if (elements.isEmpty) {
+          // [prefix] and [elements] were added to [usedElements.prefixMap] but
+          // [elements] is empty, so the prefix was referenced incorrectly.
+          // Another diagnostic about the prefix reference is reported, and we
+          // shouldn't confuse by also reporting an unused prefix.
+          _unusedImports.remove(importDirective);
+        }
         for (var element in elements) {
           if (namespace?.getPrefixed(prefix.name, element.name) != null) {
             _unusedImports.remove(importDirective);
diff --git a/pkg/analyzer/test/generated/error_suppression_test.dart b/pkg/analyzer/test/generated/error_suppression_test.dart
index 87797c5..07a3c23 100644
--- a/pkg/analyzer/test/generated/error_suppression_test.dart
+++ b/pkg/analyzer/test/generated/error_suppression_test.dart
@@ -271,9 +271,7 @@
 // ignore: undefined_prefixed_name
 f() => c.g;
 ''',
-      [
-        error(HintCode.UNUSED_IMPORT, 7, 17),
-      ],
+      [],
     );
   }
 }
diff --git a/pkg/analyzer/test/src/dart/resolution/assignment_test.dart b/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
index 5a97135..d07c1ac 100644
--- a/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
@@ -1533,7 +1533,6 @@
   x = 2;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 11),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 37, 1),
     ]);
 
diff --git a/pkg/analyzer/test/src/dart/resolution/import_prefix_test.dart b/pkg/analyzer/test/src/dart/resolution/import_prefix_test.dart
index 362da76..66c665f 100644
--- a/pkg/analyzer/test/src/dart/resolution/import_prefix_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/import_prefix_test.dart
@@ -24,7 +24,6 @@
   p; // use
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 12),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 38, 1),
     ]);
 
@@ -41,7 +40,6 @@
   for (var x in p) {}
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 12),
       error(HintCode.UNUSED_LOCAL_VARIABLE, 47, 1),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 52, 1),
     ]);
@@ -66,7 +64,6 @@
   var x = new C(p);
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 12),
       error(HintCode.UNUSED_LOCAL_VARIABLE, 66, 1),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 76, 1),
     ]);
diff --git a/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart b/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
index 92450fb..bdd82f2 100644
--- a/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
@@ -779,7 +779,6 @@
   foo();
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 11),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 39, 3),
     ]);
     _assertInvalidInvocation(
@@ -808,7 +807,6 @@
   math.foo(0);
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 11),
       error(CompileTimeErrorCode.UNDEFINED_FUNCTION, 45, 3),
     ]);
     _assertUnresolvedMethodInvocation('foo(0);');
@@ -1789,7 +1787,6 @@
   math();
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 11),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 40, 4),
     ]);
     assertElement(findNode.simple('math()'), findElement.prefix('math'));
diff --git a/pkg/analyzer/test/src/dart/resolution/type_name_test.dart b/pkg/analyzer/test/src/dart/resolution/type_name_test.dart
index c9e0e3d..a58eac5 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_name_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_name_test.dart
@@ -198,7 +198,6 @@
   new math.A();
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 11),
       error(CompileTimeErrorCode.NEW_WITH_NON_TYPE, 49, 1),
     ]);
 
diff --git a/pkg/analyzer/test/src/diagnostics/const_with_non_type_test.dart b/pkg/analyzer/test/src/diagnostics/const_with_non_type_test.dart
index 1f14038..67edb47 100644
--- a/pkg/analyzer/test/src/diagnostics/const_with_non_type_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_with_non_type_test.dart
@@ -23,7 +23,6 @@
   const lib.A();
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 11),
       error(CompileTimeErrorCode.CONST_WITH_NON_TYPE, 50, 1),
     ]);
   }
diff --git a/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart b/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
index 6f6cb91..5313441 100644
--- a/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
@@ -118,7 +118,6 @@
 
 class C extends p.A {}
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 11),
       error(CompileTimeErrorCode.EXTENDS_NON_CLASS, 42, 3),
     ]);
   }
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_null_aware_operator_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_null_aware_operator_test.dart
index 2c89f6d..8f903e5 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_null_aware_operator_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_null_aware_operator_test.dart
@@ -260,7 +260,6 @@
   p?.x;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 8),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 31, 1),
     ]);
   }
@@ -472,7 +471,6 @@
   p?.x = 0;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 8),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 31, 1),
     ]);
   }
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
index dbc72fa..948a8dd 100644
--- a/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
@@ -158,7 +158,6 @@
 
 class C with p.M {}
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 11),
       error(CompileTimeErrorCode.MIXIN_OF_NON_CLASS, 39, 3),
     ]);
   }
diff --git a/pkg/analyzer/test/src/diagnostics/prefix_identifier_not_followed_by_dot_test.dart b/pkg/analyzer/test/src/diagnostics/prefix_identifier_not_followed_by_dot_test.dart
index 686b88b..1979034 100644
--- a/pkg/analyzer/test/src/diagnostics/prefix_identifier_not_followed_by_dot_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/prefix_identifier_not_followed_by_dot_test.dart
@@ -27,7 +27,6 @@
   }
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 46, 1),
     ]);
   }
@@ -42,7 +41,6 @@
   p += 1;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 32, 1),
     ]);
   }
@@ -59,7 +57,6 @@
   }
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 46, 1),
     ]);
   }
@@ -93,7 +90,6 @@
   p = 1;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 32, 1),
     ]);
   }
@@ -108,7 +104,6 @@
   p += 1;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 32, 1),
     ]);
   }
@@ -154,7 +149,6 @@
   return p?.x;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 39, 1),
     ]);
   }
@@ -169,7 +163,6 @@
   return p?.loadLibrary;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 48, 1),
     ]);
   }
@@ -185,7 +178,6 @@
   p?.x = null;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 32, 1),
     ]);
   }
@@ -200,7 +192,6 @@
   p?.loadLibrary = null;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 41, 1),
     ]);
   }
@@ -215,7 +206,6 @@
   return p;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 39, 1),
     ]);
   }
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_annotation_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_annotation_test.dart
index 4012199..711ac51 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_annotation_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_annotation_test.dart
@@ -52,7 +52,6 @@
 main() {
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 11),
       error(CompileTimeErrorCode.UNDEFINED_ANNOTATION, 25, 13),
     ]);
   }
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_class_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_class_test.dart
index 7c35f6a..025eb5f 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_class_test.dart
@@ -140,7 +140,6 @@
 
 p.A a;
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 11),
       error(CompileTimeErrorCode.UNDEFINED_CLASS, 26, 3),
     ]);
   }
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_prefixed_name_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_prefixed_name_test.dart
index 611ed57..87cafbf 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_prefixed_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_prefixed_name_test.dart
@@ -21,7 +21,6 @@
 import 'lib.dart' as p;
 f() => p.c;
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.UNDEFINED_PREFIXED_NAME, 33, 1),
     ]);
   }
@@ -34,7 +33,6 @@
   p.c = 0;
 }
 ''', [
-      error(HintCode.UNUSED_IMPORT, 7, 10),
       error(CompileTimeErrorCode.UNDEFINED_PREFIXED_NAME, 34, 1),
     ]);
   }
diff --git a/pkg/analyzer/test/verify_diagnostics_test.dart b/pkg/analyzer/test/verify_diagnostics_test.dart
index b057f27..af40e72 100644
--- a/pkg/analyzer/test/verify_diagnostics_test.dart
+++ b/pkg/analyzer/test/verify_diagnostics_test.dart
@@ -49,9 +49,6 @@
     // Need a way to make auxiliary files that (a) are not included in the
     // generated docs or (b) can be made persistent for fixes.
     'CompileTimeErrorCode.PART_OF_NON_PART',
-    // Need to avoid reporting an unused import with a prefix, when the prefix
-    // is only referenced in an invalid way.
-    'CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT',
     // Produces the diagnostic HintCode.UNUSED_LOCAL_VARIABLE when it shouldn't.
     'CompileTimeErrorCode.UNDEFINED_IDENTIFIER_AWAIT',
     // The code has been replaced but is not yet removed.
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index af026e3..08b4b51 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -1450,6 +1450,7 @@
 class List<E> extends Iterable<E> {
   factory List() => null;
   factory List.unmodifiable(elements) => null;
+  factory List.empty({bool growable = false}) => null;
   factory List.filled(int length, E fill, {bool growable = false}) => null;
   factory List.generate(int length, E generator(int index),
       {bool growable = true}) => null;
@@ -1461,12 +1462,14 @@
 
 class _GrowableList<E> {
   factory _GrowableList() => null;
+  factory _GrowableList.empty() => null;
   factory _GrowableList.filled() => null;
   factory _GrowableList.generate(int length, E generator(int index)) => null;
 }
 
 class _List<E> {
   factory _List() => null;
+  factory _List.empty() => null;
   factory _List.filled() => null;
   factory _List.generate(int length, E generator(int index)) => null;
 }
diff --git a/pkg/vm/lib/transformations/specializer/list_factory_specializer.dart b/pkg/vm/lib/transformations/specializer/list_factory_specializer.dart
index 38e5913..672d618 100644
--- a/pkg/vm/lib/transformations/specializer/list_factory_specializer.dart
+++ b/pkg/vm/lib/transformations/specializer/list_factory_specializer.dart
@@ -13,6 +13,9 @@
 ///
 /// new List() => new _GrowableList(0)
 /// new List(n) => new _List(n)
+/// new List.empty() => new _List.empty()
+/// new List.empty(growable: false) => new _List.empty()
+/// new List.empty(growable: true) => new _GrowableList.empty()
 /// new List.filled(n, null, growable: true) => new _GrowableList(n)
 /// new List.filled(n, x, growable: true) => new _GrowableList.filled(n, x)
 /// new List.filled(n, null) => new _List(n)
@@ -22,44 +25,57 @@
 ///
 class ListFactorySpecializer extends BaseSpecializer {
   final Procedure _defaultListFactory;
+  final Procedure _listEmptyFactory;
   final Procedure _listFilledFactory;
   final Procedure _listGenerateFactory;
   final Procedure _growableListFactory;
+  final Procedure _growableListEmptyFactory;
   final Procedure _growableListFilledFactory;
   final Procedure _growableListGenerateFactory;
   final Procedure _fixedListFactory;
+  final Procedure _fixedListEmptyFactory;
   final Procedure _fixedListFilledFactory;
   final Procedure _fixedListGenerateFactory;
 
   ListFactorySpecializer(CoreTypes coreTypes)
       : _defaultListFactory =
             coreTypes.index.getMember('dart:core', 'List', ''),
+        _listEmptyFactory =
+            coreTypes.index.getMember('dart:core', 'List', 'empty'),
         _listFilledFactory =
             coreTypes.index.getMember('dart:core', 'List', 'filled'),
         _listGenerateFactory =
             coreTypes.index.getMember('dart:core', 'List', 'generate'),
         _growableListFactory =
             coreTypes.index.getMember('dart:core', '_GrowableList', ''),
+        _growableListEmptyFactory =
+            coreTypes.index.getMember('dart:core', '_GrowableList', 'empty'),
         _growableListFilledFactory =
             coreTypes.index.getMember('dart:core', '_GrowableList', 'filled'),
         _growableListGenerateFactory =
             coreTypes.index.getMember('dart:core', '_GrowableList', 'generate'),
         _fixedListFactory = coreTypes.index.getMember('dart:core', '_List', ''),
+        _fixedListEmptyFactory =
+            coreTypes.index.getMember('dart:core', '_List', 'empty'),
         _fixedListFilledFactory =
             coreTypes.index.getMember('dart:core', '_List', 'filled'),
         _fixedListGenerateFactory =
             coreTypes.index.getMember('dart:core', '_List', 'generate') {
     assert(_defaultListFactory.isFactory);
+    assert(_listEmptyFactory.isFactory);
     assert(_listFilledFactory.isFactory);
     assert(_listGenerateFactory.isFactory);
     assert(_growableListFactory.isFactory);
+    assert(_growableListEmptyFactory.isFactory);
     assert(_growableListFilledFactory.isFactory);
     assert(_growableListGenerateFactory.isFactory);
     assert(_fixedListFactory.isFactory);
+    assert(_fixedListEmptyFactory.isFactory);
     assert(_fixedListFilledFactory.isFactory);
     assert(_fixedListGenerateFactory.isFactory);
     transformers.addAll({
       _defaultListFactory: transformDefaultFactory,
+      _listEmptyFactory: transformListEmptyFactory,
       _listFilledFactory: transformListFilledFactory,
       _listGenerateFactory: transformListGeneratorFactory,
     });
@@ -77,6 +93,24 @@
     }
   }
 
+  TreeNode transformListEmptyFactory(StaticInvocation node) {
+    final args = node.arguments;
+    assert(args.positional.length == 0);
+    final bool growable = _getConstantOptionalArgument(args, 'growable', false);
+    if (growable == null) {
+      return node;
+    }
+    if (growable) {
+      return StaticInvocation(
+          _growableListEmptyFactory, Arguments([], types: args.types))
+        ..fileOffset = node.fileOffset;
+    } else {
+      return StaticInvocation(
+          _fixedListEmptyFactory, Arguments([], types: args.types))
+        ..fileOffset = node.fileOffset;
+    }
+  }
+
   TreeNode transformListFilledFactory(StaticInvocation node) {
     final args = node.arguments;
     assert(args.positional.length == 2);
diff --git a/sdk/lib/_internal/vm/lib/array.dart b/sdk/lib/_internal/vm/lib/array.dart
index 99e04aa..90a6fda 100644
--- a/sdk/lib/_internal/vm/lib/array.dart
+++ b/sdk/lib/_internal/vm/lib/array.dart
@@ -12,6 +12,11 @@
   @pragma("vm:prefer-inline")
   factory _List(length) native "List_allocate";
 
+  // Specialization of List.empty constructor for growable == false.
+  // Used by pkg/vm/lib/transformations/list_factory_specializer.dart.
+  @pragma("vm:prefer-inline")
+  factory _List.empty() => _List<E>(0);
+
   // Specialization of List.filled constructor for growable == false.
   // Used by pkg/vm/lib/transformations/list_factory_specializer.dart.
   factory _List.filled(int length, E fill) {
diff --git a/sdk/lib/_internal/vm/lib/growable_array.dart b/sdk/lib/_internal/vm/lib/growable_array.dart
index 865b874..059454e 100644
--- a/sdk/lib/_internal/vm/lib/growable_array.dart
+++ b/sdk/lib/_internal/vm/lib/growable_array.dart
@@ -107,6 +107,11 @@
     return new _GrowableList<T>._withData(data);
   }
 
+  // Specialization of List.empty constructor for growable == true.
+  // Used by pkg/vm/lib/transformations/list_factory_specializer.dart.
+  @pragma("vm:prefer-inline")
+  factory _GrowableList.empty() => _GrowableList(0);
+
   // Specialization of List.filled constructor for growable == true.
   // Used by pkg/vm/lib/transformations/list_factory_specializer.dart.
   factory _GrowableList.filled(int length, T fill) {
diff --git a/tools/VERSION b/tools/VERSION
index ef0ab58..c02a7f6 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 12
 PATCH 0
-PRERELEASE 126
+PRERELEASE 127
 PRERELEASE_PATCH 0
\ No newline at end of file