Correct type of CONSTRUCTOR_TEAROFFS_NOT_ENABLED code

Additionally, sort the UNUSED_RESULT_* codes.

This addresses comments in
https://dart-review.googlesource.com/c/sdk/+/209300

Change-Id: I4d3fd25703f6df59f8ad985352c87406e218b544
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index d315c84..1b7a17f 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -141,7 +141,6 @@
   CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS,
   CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR,
   CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT,
-  CompileTimeErrorCode.CONSTRUCTOR_TEAROFFS_NOT_ENABLED,
   CompileTimeErrorCode.CONTINUE_LABEL_ON_SWITCH,
   CompileTimeErrorCode.COULD_NOT_INFER,
   CompileTimeErrorCode.DEFAULT_LIST_CONSTRUCTOR,
@@ -594,6 +593,7 @@
   HintCode.SDK_VERSION_AS_EXPRESSION_IN_CONST_CONTEXT,
   HintCode.SDK_VERSION_ASYNC_EXPORTED_FROM_CORE,
   HintCode.SDK_VERSION_BOOL_OPERATOR_IN_CONST_CONTEXT,
+  HintCode.SDK_VERSION_CONSTRUCTOR_TEAROFFS,
   HintCode.SDK_VERSION_EQ_EQ_OPERATOR_IN_CONST_CONTEXT,
   HintCode.SDK_VERSION_EXTENSION_METHODS,
   HintCode.SDK_VERSION_GT_GT_GT_OPERATOR,
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
index afaad1f..24533f2 100644
--- a/pkg/analyzer/lib/src/dart/error/hint_codes.dart
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
@@ -96,37 +96,6 @@
       correction: "Replace the '.' with a '?.' in the invocation.");
 
   /**
-   * Generate a hint for method, property or function annotated with
-   * `@useResult` whose invocation is unchecked.
-   *
-   * Parameters:
-   * 0: the name of the annotated method, property or function
-   */
-  static const HintCode UNUSED_RESULT = HintCode(
-      'UNUSED_RESULT', "'{0}' should be used.",
-      correction:
-          "Try using the result by invoking a member, passing it to a function, or returning it from this function.",
-      hasPublishedDocs: false);
-
-  /**
-   * Generate a hint for method, property or function annotated with
-   * `@useResult` whose invocation is unchecked.
-   *
-   * Parameters:
-   * 0: the name of the annotated method, property or function
-   * 1: message details
-   */
-  static const HintCode UNUSED_RESULT_WITH_MESSAGE = HintCode(
-    'UNUSED_RESULT',
-    "'{0}' should be used. {1}.",
-    // todo(pq): consider passing in correction details: https://github.com/dart-lang/sdk/issues/46066
-    correction:
-        "Try using the result by invoking a member, passing it to a function, or returning it from this function.",
-    hasPublishedDocs: false,
-    uniqueName: 'HintCode.UNUSED_RESULT_WITH_MESSAGE',
-  );
-
-  /**
    * Dead code is code that is never reached, this can happen for instance if a
    * statement follows a return statement.
    *
@@ -2245,6 +2214,25 @@
       hasPublishedDocs: true);
 
   /**
+   * A constructor cannot be torn off without the 'constructor-tearoffs'
+   * language feature.
+   *
+   * There is also a [ParserError.EXPERIMENT_NOT_ENABLED] code which catches
+   * some cases of constructor tearoff features (like `List<int>.filled;`).
+   * Other constructor tearoff cases are not realized until resolution
+   * (like `List.filled;`).
+   */
+  static const HintCode SDK_VERSION_CONSTRUCTOR_TEAROFFS = HintCode(
+      'SDK_VERSION_CONSTRUCTOR_TEAROFFS',
+      "Tearing off a constructor requires the 'constructor-tearoffs' "
+          "language feature.",
+      // TODO(srawlins): Update this text to something like "Try updating
+      // your pubspec.yaml to set the minimum SDK constraint to 2.14 or
+      // higher, and running 'pub get'."
+      correction: "Try enabling the experiment by including "
+          "'--enable-experiments=constructor-tearoffs' in the 'dart' command.");
+
+  /**
    * No parameters.
    */
   // #### Description
@@ -3474,6 +3462,43 @@
       hasPublishedDocs: true);
 
   /**
+   * The result of invoking a method, property, or function annotated with
+   * `@useResult` must be used (assigned, passed to a function as an argument,
+   * or returned by a function).
+   *
+   * Parameters:
+   * 0: the name of the annotated method, property or function
+   */
+  static const HintCode UNUSED_RESULT = HintCode(
+    'UNUSED_RESULT',
+    "'{0}' should be used.",
+    correction: "Try using the result by invoking a member, passing it to a "
+        "function, or returning it from this function.",
+    hasPublishedDocs: false,
+  );
+
+  /**
+   * The result of invoking a method, property, or function annotated with
+   * `@useResult` must be used (assigned, passed to a function as an argument,
+   * or returned by a function).
+   *
+   * Parameters:
+   * 0: the name of the annotated method, property or function
+   * 1: message details
+   */
+  static const HintCode UNUSED_RESULT_WITH_MESSAGE = HintCode(
+    'UNUSED_RESULT',
+    "'{0}' should be used. {1}.",
+    // todo(pq): consider passing in correction details:
+    // https://github.com/dart-lang/sdk/issues/46066
+    correction:
+        "Try using the result by invoking a member, passing it to a function, "
+        "or returning it from this function.",
+    hasPublishedDocs: false,
+    uniqueName: 'HintCode.UNUSED_RESULT_WITH_MESSAGE',
+  );
+
+  /**
    * Parameters:
    * 0: the name that is shown but not used
    */
diff --git a/pkg/analyzer/lib/src/dart/resolver/constructor_reference_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/constructor_reference_resolver.dart
index ce1fd84..ac1868d 100644
--- a/pkg/analyzer/lib/src/dart/resolver/constructor_reference_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/constructor_reference_resolver.dart
@@ -22,7 +22,7 @@
       // Only report this if [node] has no explicit type arguments; otherwise
       // the parser has already reported an error.
       _resolver.errorReporter.reportErrorForNode(
-          CompileTimeErrorCode.CONSTRUCTOR_TEAROFFS_NOT_ENABLED, node, []);
+          HintCode.SDK_VERSION_CONSTRUCTOR_TEAROFFS, node, []);
     }
     node.constructorName.accept(_resolver);
     _inferArgumentTypes(node);
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index dce95dc..cadf3c7 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -2263,23 +2263,6 @@
               "IntegerDivisionByZeroException.");
 
   /**
-   * A constructor cannot be torn off without the 'constructor-tearoffs'
-   * language feature.
-   *
-   * There is also a [ParserError.EXPERIMENT_NOT_ENABLED] code which catches
-   * some cases of constructor tearoff features (like `List<int>.filled;`).
-   * Other constructor tearoff cases are not realized until resolution
-   * (like `List.filled;`).
-   */
-  static const CompileTimeErrorCode CONSTRUCTOR_TEAROFFS_NOT_ENABLED =
-      CompileTimeErrorCode(
-          'CONSTRUCTOR_TEAROFFS_NOT_ENABLED',
-          "Tearing off a constructor requires the 'constructor-tearoffs' "
-              "language feature.",
-          correction: "Try updating your pubspec.yaml to set the minimum SDK "
-              "constraint to 2.14 or higher, and running 'pub get'.");
-
-  /**
    * 16.12.2 Const: An expression of one of the forms !e, e1 && e2 or e1 || e2,
    * where e, e1 and e2 are constant expressions that evaluate to a boolean
    * value.
diff --git a/pkg/analyzer/test/src/dart/resolution/constructor_reference_test.dart b/pkg/analyzer/test/src/dart/resolution/constructor_reference_test.dart
index 0c94b3c..21b86f7 100644
--- a/pkg/analyzer/test/src/dart/resolution/constructor_reference_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/constructor_reference_test.dart
@@ -584,7 +584,7 @@
   A.foo;
 }
 ''', [
-      error(CompileTimeErrorCode.CONSTRUCTOR_TEAROFFS_NOT_ENABLED, 39, 5),
+      error(HintCode.SDK_VERSION_CONSTRUCTOR_TEAROFFS, 39, 5),
     ]);
 
     var classElement = findElement.class_('A');
diff --git a/tests/language/constructor/reference_test.dart b/tests/language/constructor/reference_test.dart
index 36ca27d..3755880 100644
--- a/tests/language/constructor/reference_test.dart
+++ b/tests/language/constructor/reference_test.dart
@@ -88,8 +88,6 @@
   Foo.bar.baz();
   //  ^^^
   // [cfe] Getter not found: 'bar'.
-//^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONSTRUCTOR_TEAROFFS_NOT_ENABLED
   //      ^^^
   // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
   Foo<int>();
@@ -117,8 +115,6 @@
   Foo.bar.baz<int>();
   //  ^^^
   // [cfe] Getter not found: 'bar'.
-//^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONSTRUCTOR_TEAROFFS_NOT_ENABLED
   //      ^^^
   // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
 }
diff --git a/tests/language_2/constructor/reference_test.dart b/tests/language_2/constructor/reference_test.dart
index 6dff1ad..03d4c56 100644
--- a/tests/language_2/constructor/reference_test.dart
+++ b/tests/language_2/constructor/reference_test.dart
@@ -90,8 +90,6 @@
   Foo.bar.baz();
   //  ^^^
   // [cfe] Getter not found: 'bar'.
-//^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONSTRUCTOR_TEAROFFS_NOT_ENABLED
   //      ^^^
   // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
   Foo<int>();
@@ -119,8 +117,6 @@
   Foo.bar.baz<int>();
   //  ^^^
   // [cfe] Getter not found: 'bar'.
-//^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONSTRUCTOR_TEAROFFS_NOT_ENABLED
   //      ^^^
   // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
 }