Move CONST_WITH_TYPE_PARAMETERS reporting to ConstantVerifier.

Linter also should be updated to check for this error in HasConstantErrorListener.

R=brianwilkerson@google.com

Bug: https://github.com/dart-lang/sdk/issues/33612
Change-Id: If4a2535ffe04d965bbd46b5c92679e6132bf500e
Reviewed-on: https://dart-review.googlesource.com/73283
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 9e9f3b9..030cb13 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -909,7 +909,6 @@
           _checkForConstWithNonConst(node);
           _checkForConstWithUndefinedConstructor(
               node, constructorName, typeName);
-          _checkForConstWithTypeParameters(typeName);
           _checkForConstDeferredClass(node, constructorName, typeName);
         } else {
           _checkForNewWithUndefinedConstructor(node, constructorName, typeName);
@@ -2890,35 +2889,6 @@
   }
 
   /**
-   * Verify that the given [type] does not reference any type parameters.
-   *
-   * See [CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS].
-   */
-  void _checkForConstWithTypeParameters(TypeAnnotation type) {
-    // something wrong with AST
-    if (type is! TypeName) {
-      return;
-    }
-    TypeName typeName = type;
-    Identifier name = typeName.name;
-    if (name == null) {
-      return;
-    }
-    // should not be a type parameter
-    if (name.staticElement is TypeParameterElement) {
-      _errorReporter.reportErrorForNode(
-          CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, name);
-    }
-    // check type arguments
-    TypeArgumentList typeArguments = typeName.typeArguments;
-    if (typeArguments != null) {
-      for (TypeAnnotation argument in typeArguments.arguments) {
-        _checkForConstWithTypeParameters(argument);
-      }
-    }
-  }
-
-  /**
    * Verify that if the given 'const' instance creation [expression] is being
    * invoked on the resolved constructor. The [constructorName] is the
    * constructor name, always non-`null`. The [typeName] is the name of the type
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 957c45d6..911c655 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -1604,6 +1604,9 @@
   @override
   Object visitInstanceCreationExpression(InstanceCreationExpression node) {
     if (node.isConst) {
+      TypeName typeName = node.constructorName.type;
+      _checkForConstWithTypeParameters(typeName);
+
       // We need to evaluate the constant to see if any errors occur during its
       // evaluation.
       ConstructorElement constructor = node.staticElement;
@@ -1808,6 +1811,35 @@
   }
 
   /**
+   * Verify that the given [type] does not reference any type parameters.
+   *
+   * See [CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS].
+   */
+  void _checkForConstWithTypeParameters(TypeAnnotation type) {
+    // something wrong with AST
+    if (type is! TypeName) {
+      return;
+    }
+    TypeName typeName = type;
+    Identifier name = typeName.name;
+    if (name == null) {
+      return;
+    }
+    // should not be a type parameter
+    if (name.staticElement is TypeParameterElement) {
+      _errorReporter.reportErrorForNode(
+          CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, name);
+    }
+    // check type arguments
+    TypeArgumentList typeArguments = typeName.typeArguments;
+    if (typeArguments != null) {
+      for (TypeAnnotation argument in typeArguments.arguments) {
+        _checkForConstWithTypeParameters(argument);
+      }
+    }
+  }
+
+  /**
    * @return `true` if given [Type] implements operator <i>==</i>, and it is not
    *         <i>int</i> or <i>String</i>.
    */