[analyzer] Move all constructor error reporting to _InstanceCreationEvaluator.evaluate

Pull the error handling outwards to _InstanceCreationEvaluator.evaluate. All errors in const constructors should point to the location of the actual exception and provide more context.

Change-Id: Iafcf46182fab698f5546c63780de6dd9a605a51b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/318802
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
index dbba539..83aa3ae 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
@@ -429,13 +429,13 @@
     writeTestPackageConfig(meta: true);
     await resolveTestCode(r'''
 class C {
-  const C([C c]);
+  const C([C? c]);
 }
 var c = C(C());
 ''');
     await assertHasFix(r'''
 class C {
-  const C([C c]);
+  const C([C? c]);
 }
 var c = const C(C());
 ''');
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index d1c720d..d468ac1 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -2354,8 +2354,6 @@
 
   final LibraryElementImpl _library;
 
-  final ErrorReporter _errorReporter;
-
   final BooleanErrorListener _externalErrorListener = BooleanErrorListener();
 
   /// An error reporter for errors determined while computing values for field
@@ -2408,7 +2406,6 @@
   _InstanceCreationEvaluator._(
     this._evaluationEngine,
     this._declaredVariables,
-    this._errorReporter,
     this._library,
     this._errorNode,
     this._constructor,
@@ -2439,9 +2436,6 @@
     var argumentCount = arguments.length;
     if (_constructor.name == "fromEnvironment") {
       if (!_checkFromEnvironmentArguments(arguments, definingType)) {
-        // TODO(kallentu): Don't report error here.
-        _errorReporter.reportErrorForNode(
-            CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, _errorNode);
         return InvalidConstant(
             _errorNode, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
       }
@@ -2474,9 +2468,6 @@
         definingClass == typeProvider.symbolElement &&
         argumentCount == 1) {
       if (!_checkSymbolArguments(arguments, isNullSafe: isNullSafe)) {
-        // TODO(kallentu): Don't report error here.
-        _errorReporter.reportErrorForNode(
-            CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, _errorNode);
         return InvalidConstant(
             _errorNode, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
       }
@@ -2522,24 +2513,6 @@
         superName: evaluationResult.superName,
         superArguments: evaluationResult.superArguments);
     if (error != null) {
-      final formattedMessage =
-          formatList(error.errorCode.problemMessage, error.arguments);
-      final contextMessage = DiagnosticMessageImpl(
-        filePath: _library.source.fullName,
-        length: error.node.length,
-        message: "The exception is '$formattedMessage' and occurs here.",
-        offset: error.node.offset,
-        url: null,
-      );
-
-      // TODO(kallentu): When removing all on-site reporting, move this error
-      // to [_InstanceCreationEvaluator.evaluate] and provide context for all
-      // constructor related errors.
-      _errorReporter.reportErrorForNode(
-          CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
-          _errorNode,
-          [],
-          [...error.contextMessages, contextMessage]);
       return error;
     }
 
@@ -2598,11 +2571,6 @@
         // Match the value and the type.
         var fieldType = FieldMember.from(field, _constructor.returnType).type;
         if (!typeSystem.runtimeTypeMatch(fieldValue, fieldType)) {
-          // TODO(kallentu): Don't report error here.
-          _errorReporter.reportErrorForNode(
-              CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
-              _errorNode,
-              [fieldValue.type, field.name, fieldType]);
           return InvalidConstant(_errorNode,
               CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
               arguments: [fieldValue.type, field.name, fieldType]);
@@ -2673,11 +2641,8 @@
           case DartObjectImpl():
             final fieldName = initializer.fieldName.name;
             if (_fieldMap.containsKey(fieldName)) {
-              // TODO(kallentu): Don't report error here.
-              _errorReporter.reportErrorForNode(
-                  CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, _errorNode);
               return _InitializersEvaluationResult(
-                  InvalidConstant(_errorNode,
+                  InvalidConstant(initializerExpression,
                       CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION),
                   evaluationIsComplete: true);
             }
@@ -2686,14 +2651,9 @@
             if (getter != null) {
               final field = getter.variable;
               if (!typeSystem.runtimeTypeMatch(evaluationResult, field.type)) {
-                // TODO(kallentu): Don't report error here.
-                _errorReporter.reportErrorForNode(
-                    CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
-                    _errorNode,
-                    [evaluationResult.type, fieldName, field.type]);
                 return _InitializersEvaluationResult(
                     InvalidConstant(
-                        _errorNode,
+                        initializerExpression,
                         CompileTimeErrorCode
                             .CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
                         arguments: [
@@ -2705,13 +2665,7 @@
               }
             }
           case InvalidConstant():
-            // TODO(kallentu): Report the specific error we got with context of
-            // the current constructor instead of this broad error code.
-            _errorReporter.reportErrorForNode(
-                CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, _errorNode);
-            return _InitializersEvaluationResult(
-                InvalidConstant(_errorNode,
-                    CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION),
+            return _InitializersEvaluationResult(evaluationResult,
                 evaluationIsComplete: true);
         }
       } else if (initializer is SuperConstructorInvocation) {
@@ -2737,14 +2691,6 @@
               _initializerVisitor,
               _externalErrorReporter,
               invocation: _invocation);
-          if (result is InvalidConstant) {
-            // TODO(kallentu): Report a better error here with context from the
-            // other error reported.
-            _errorReporter.reportErrorForNode(
-                CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, _errorNode);
-            result = InvalidConstant(
-                _errorNode, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
-          }
           return _InitializersEvaluationResult(result,
               evaluationIsComplete: true);
         }
@@ -2755,18 +2701,12 @@
           case DartObjectImpl():
             if (!evaluationConstant.isBool ||
                 evaluationConstant.toBoolValue() == false) {
-              // TODO(kallentu): Don't report error here.
-              _errorReporter.reportErrorForNode(
-                  CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, _errorNode);
               return _InitializersEvaluationResult(
                   InvalidConstant(initializer,
                       CompileTimeErrorCode.CONST_EVAL_ASSERTION_FAILURE),
                   evaluationIsComplete: true);
             }
           case InvalidConstant():
-            // TODO(kallentu): Don't report error here.
-            _errorReporter.reportErrorForNode(
-                CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, _errorNode);
             return _InitializersEvaluationResult(evaluationConstant,
                 evaluationIsComplete: true);
         }
@@ -2823,11 +2763,6 @@
       if (argumentValue != null) {
         if (!argumentValue.isInvalid &&
             !typeSystem.runtimeTypeMatch(argumentValue, parameter.type)) {
-          _errorReporter.reportErrorForNode(
-            CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
-            errorTarget,
-            [argumentValue.type, parameter.type],
-          );
           return InvalidConstant(errorTarget,
               CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
               arguments: [argumentValue.type, parameter.type]);
@@ -2842,11 +2777,6 @@
               // the field.
               if (!argumentValue.isInvalid &&
                   !typeSystem.runtimeTypeMatch(argumentValue, fieldType)) {
-                _errorReporter.reportErrorForNode(
-                  CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
-                  errorTarget,
-                  [argumentValue.type, fieldType],
-                );
                 return InvalidConstant(errorTarget,
                     CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
                     arguments: [argumentValue.type, fieldType]);
@@ -2854,9 +2784,6 @@
             }
             final fieldName = field.name;
             if (_fieldMap.containsKey(fieldName)) {
-              // TODO(kallentu): Don't report errors here.
-              _errorReporter.reportErrorForNode(
-                  CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, _errorNode);
               return InvalidConstant(
                   _errorNode, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
             }
@@ -3045,13 +2972,12 @@
     );
 
     constructor = _followConstantRedirectionChain(constructor);
-
+    final errorNode = evaluationEngine.configuration.errorNode(node);
     final evaluator = _InstanceCreationEvaluator._(
       evaluationEngine,
       declaredVariables,
-      errorReporter,
       library,
-      evaluationEngine.configuration.errorNode(node),
+      errorNode,
       constructor,
       typeArguments,
       namedNodes: namedNodes,
@@ -3060,15 +2986,34 @@
       invocation: invocation,
     );
 
+    Constant constant;
     if (constructor.isFactory) {
       // We couldn't find a non-factory constructor.
       // See if it's because we reached an external const factory constructor
       // that we can emulate.
-      return evaluator.evaluateFactoryConstructorCall(arguments,
+      constant = evaluator.evaluateFactoryConstructorCall(arguments,
           isNullSafe: isNullSafe);
     } else {
-      return evaluator.evaluateGenerativeConstructorCall(arguments);
+      constant = evaluator.evaluateGenerativeConstructorCall(arguments);
     }
+    if (constant is InvalidConstant) {
+      final formattedMessage =
+          formatList(constant.errorCode.problemMessage, constant.arguments);
+      final contextMessage = DiagnosticMessageImpl(
+        filePath: library.source.fullName,
+        length: constant.node.length,
+        message: "The exception is '$formattedMessage' and occurs here.",
+        offset: constant.node.offset,
+        url: null,
+      );
+      errorReporter.reportErrorForNode(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        errorNode,
+        [],
+        [...constant.contextMessages, contextMessage],
+      );
+    }
+    return constant;
   }
 
   /// Attempt to follow the chain of factory redirections until a constructor is
diff --git a/pkg/analyzer/test/src/dart/constant/evaluation_test.dart b/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
index 5558f3f0..44b36cd 100644
--- a/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
+++ b/pkg/analyzer/test/src/dart/constant/evaluation_test.dart
@@ -2847,7 +2847,12 @@
 
 const b = B('');
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 128, 5),
+      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 128, 5,
+          contextMessages: [
+            ExpectedContextMessage(testFile.path, 105, 8,
+                text:
+                    "The exception is 'Invalid constant value.' and occurs here."),
+          ]),
     ]);
   }
 
@@ -3156,7 +3161,16 @@
 const a = const A(null);
 ''', [
       error(WarningCode.UNNECESSARY_TYPE_CHECK_FALSE, 31, 9),
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 56, 13),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        56,
+        13,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 24, 17,
+              text:
+                  "The exception is 'The assertion in this constant expression failed.' and occurs here."),
+        ],
+      ),
       error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 64, 4),
     ]);
   }
@@ -3169,7 +3183,16 @@
 
 const a = const A<int?>();
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 60, 15),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        60,
+        15,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 27, 18,
+              text:
+                  "The exception is 'The assertion in this constant expression failed.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -3198,7 +3221,16 @@
 }
 const c = const A(E.a);
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 73, 12),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        73,
+        12,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 43, 16,
+              text:
+                  "The exception is 'The assertion in this constant expression failed.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -3377,7 +3409,16 @@
 const a = const A<int>();
 ''', [
       error(CompileTimeErrorCode.INVALID_CONSTANT, 62, 1),
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 77, 14),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        77,
+        14,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 62, 1,
+              text:
+                  "The exception is 'Invalid constant value.' and occurs here."),
+        ],
+      ),
     ]);
     final result = _topLevelVar('a');
     _assertNull(result);
@@ -3510,7 +3551,16 @@
 }
 const a = const A(1);
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 71, 10),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        71,
+        10,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 31, 26,
+              text:
+                  "The exception is 'The assertion in this constant expression failed.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -3521,7 +3571,16 @@
 }
 const a = const A();
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 56, 9),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        56,
+        9,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 23, 19,
+              text:
+                  "The exception is 'The assertion in this constant expression failed.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -3558,7 +3617,16 @@
 }
 const a = const A(0);
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 55, 10),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        55,
+        10,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 28, 13,
+              text:
+                  "The exception is 'The assertion in this constant expression failed.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
diff --git a/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart b/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart
index 79951f3..32ed834 100644
--- a/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart
@@ -6,6 +6,7 @@
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../generated/test_support.dart';
 import '../dart/resolution/context_collection_resolution.dart';
 
 main() {
@@ -51,6 +52,28 @@
     ]);
   }
 
+  test_const() async {
+    await assertErrorsInCode('''
+class A {
+  const A(String p);
+}
+main() {
+  const A(42);
+}''', [
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        44,
+        11,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 52, 2,
+              text:
+                  "The exception is 'A value of type 'int' can't be assigned to a parameter of type 'String' in a const constructor.' and occurs here."),
+        ],
+      ),
+      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 52, 2),
+    ]);
+  }
+
   test_downcast() async {
     await assertErrorsInCode(r'''
 m() {
@@ -93,7 +116,16 @@
 }
 ''', [
       error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 13, 1),
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 13, 1),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        11,
+        4,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 13, 1,
+              text:
+                  "The exception is 'A value of type 'int' can't be assigned to a parameter of type 'String' in a const constructor.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -318,19 +350,6 @@
     ]);
   }
 
-  test_const() async {
-    await assertErrorsInCode('''
-class A {
-  const A(String p);
-}
-main() {
-  const A(42);
-}''', [
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 52, 2),
-      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 52, 2),
-    ]);
-  }
-
   test_const_super() async {
     await assertErrorsInCode('''
 class A {
diff --git a/pkg/analyzer/test/src/diagnostics/const_constructor_field_type_mismatch_test.dart b/pkg/analyzer/test/src/diagnostics/const_constructor_field_type_mismatch_test.dart
index 4213152..1bedd6a 100644
--- a/pkg/analyzer/test/src/diagnostics/const_constructor_field_type_mismatch_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_constructor_field_type_mismatch_test.dart
@@ -32,49 +32,6 @@
     );
   }
 
-  test_generic_string_int() async {
-    await assertErrorsInCode(
-      r'''
-class C<T> {
-  final T x = y;
-  const C();
-}
-const int y = 1;
-var v = const C<String>();
-''',
-      [
-        error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 27, 1),
-        error(
-            CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH, 70, 17),
-      ],
-    );
-  }
-
-  test_notGeneric_int_int() async {
-    await assertErrorsInCode(r'''
-class A {
-  const A(x) : y = x;
-  final int y;
-}
-var v = const A('foo');
-''', [
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH, 57, 14),
-    ]);
-  }
-
-  test_notGeneric_int_null() async {
-    var errors = expectedErrorsByNullability(nullable: [
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH, 57, 13),
-    ], legacy: []);
-    await assertErrorsInCode(r'''
-class A {
-  const A(x) : y = x;
-  final int y;
-}
-var v = const A(null);
-''', errors);
-  }
-
   test_notGeneric_null_forNonNullable_fromLegacy() async {
     noSoundNullSafety = false;
     newFile('$testPackageLibPath/a.dart', r'''
@@ -90,19 +47,6 @@
 ''');
   }
 
-  test_notGeneric_null_forNonNullable_fromNullSafe() async {
-    await assertErrorsInCode('''
-class C {
-  final int f;
-  const C(a) : f = a;
-}
-
-const a = const C(null);
-''', [
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH, 60, 13),
-    ]);
-  }
-
   test_notGeneric_unresolved_int() async {
     await assertErrorsInCode(r'''
 class A {
diff --git a/pkg/analyzer/test/src/diagnostics/const_constructor_param_type_mismatch_test.dart b/pkg/analyzer/test/src/diagnostics/const_constructor_param_type_mismatch_test.dart
index b1e0150..8399f42 100644
--- a/pkg/analyzer/test/src/diagnostics/const_constructor_param_type_mismatch_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_constructor_param_type_mismatch_test.dart
@@ -46,22 +46,6 @@
 ''');
   }
 
-  test_assignable_fieldFormal_typedef() async {
-    // foo has the type dynamic -> dynamic, so it is not assignable to A.f.
-    await assertErrorsInCode(r'''
-typedef String Int2String(int x);
-class A {
-  final Int2String f;
-  const A(this.f);
-}
-foo(x) => 1;
-var v = const A(foo);
-''', [
-      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 116, 3),
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 116, 3),
-    ]);
-  }
-
   test_assignable_fieldFormal_typeSubstitution() async {
     await assertNoErrorsInCode(r'''
 class A<T> {
@@ -104,32 +88,6 @@
     ]);
   }
 
-  test_enum_int_null() async {
-    await assertErrorsInCode(r'''
-const dynamic a = null;
-
-enum E {
-  v(a);
-  const E(int a);
-}
-''', [
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 38, 1),
-    ]);
-  }
-
-  test_enum_int_String() async {
-    await assertErrorsInCode(r'''
-const dynamic a = '0';
-
-enum E {
-  v(a);
-  const E(int a);
-}
-''', [
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 37, 1),
-    ]);
-  }
-
   test_int_to_double_reference_from_other_library_other_file_after() async {
     newFile('$testPackageLibPath/other.dart', '''
 import 'test.dart';
@@ -215,70 +173,6 @@
 ''');
   }
 
-  test_notAssignable_fieldFormal_optional() async {
-    await assertErrorsInCode(r'''
-class A {
-  final int x;
-  const A([this.x = 'foo']);
-}
-var v = const A();
-''', [
-      error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 45, 5),
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 64, 9),
-    ]);
-  }
-
-  test_notAssignable_fieldFormal_supertype() async {
-    await assertErrorsInCode(r'''
-class A {
-  const A();
-}
-class B extends A {
-  const B();
-}
-class C {
-  final B b;
-  const C(this.b);
-}
-const A u = const A();
-var v = const C(u);
-''', [
-      // TODO(srawlins): It would be best to report only the first one.
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 143, 1),
-      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 143, 1),
-    ]);
-  }
-
-  test_notAssignable_fieldFormal_typedef() async {
-    // foo has type String -> int, so it is not assignable to A.f
-    // (A.f requires it to be int -> String).
-    await assertErrorsInCode(r'''
-typedef String Int2String(int x);
-class A {
-  final Int2String f;
-  const A(this.f);
-}
-int foo(String x) => 1;
-var v = const A(foo);
-''', [
-      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 127, 3),
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 127, 3),
-    ]);
-  }
-
-  test_notAssignable_fieldFormal_unrelated() async {
-    await assertErrorsInCode(r'''
-class A {
-  final int x;
-  const A(this.x);
-}
-var v = const A('foo');
-''', [
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 62, 5),
-      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 62, 5),
-    ]);
-  }
-
   test_notAssignable_fieldFormal_unresolved() async {
     await assertErrorsInCode(r'''
 class A {
@@ -291,30 +185,6 @@
     ]);
   }
 
-  test_notAssignable_typeSubstitution() async {
-    await assertErrorsInCode(r'''
-class A<T> {
-  const A(T x);
-}
-var v = const A<int>('foo');
-''', [
-      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 52, 5),
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 52, 5),
-    ]);
-  }
-
-  test_notAssignable_unrelated() async {
-    await assertErrorsInCode(r'''
-class A {
-  const A(int x);
-}
-var v = const A('foo');
-''', [
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 46, 5),
-      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 46, 5),
-    ]);
-  }
-
   test_superFormalParameter_explicit() async {
     await assertNoErrorsInCode(r'''
 class A {
diff --git a/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart b/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart
index 0459d14..f0701dc 100644
--- a/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart
@@ -11,12 +11,324 @@
 
 main() {
   defineReflectiveSuite(() {
+    defineReflectiveTests(ConstConstructorFieldTypeMismatchContextTest);
+    defineReflectiveTests(ConstConstructorParamTypeMismatchContextTest);
     defineReflectiveTests(ConstEvalThrowsExceptionTest);
     defineReflectiveTests(ConstEvalThrowsExceptionWithoutNullSafetyTest);
   });
 }
 
 @reflectiveTest
+class ConstConstructorFieldTypeMismatchContextTest
+    extends PubPackageResolutionTest {
+  test_generic_string_int() async {
+    await assertErrorsInCode(
+      r'''
+class C<T> {
+  final T x = y;
+  const C();
+}
+const int y = 1;
+var v = const C<String>();
+''',
+      [
+        error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 27, 1),
+        error(
+          CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+          70,
+          17,
+          contextMessages: [
+            ExpectedContextMessage(testFile.path, 70, 17,
+                text:
+                    "The exception is 'In a const constructor, a value of type 'int' can't be assigned to the field 'x', which has type 'String'.' and occurs here."),
+          ],
+        ),
+      ],
+    );
+  }
+
+  test_notGeneric_int_int() async {
+    await assertErrorsInCode(r'''
+class A {
+  const A(x) : y = x;
+  final int y;
+}
+var v = const A('foo');
+''', [
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        57,
+        14,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 29, 1,
+              text:
+                  "The exception is 'In a const constructor, a value of type 'String' can't be assigned to the field 'y', which has type 'int'.' and occurs here."),
+        ],
+      ),
+    ]);
+  }
+
+  test_notGeneric_int_null() async {
+    var errors = expectedErrorsByNullability(nullable: [
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        57,
+        13,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 29, 1,
+              text:
+                  "The exception is 'In a const constructor, a value of type 'Null' can't be assigned to the field 'y', which has type 'int'.' and occurs here."),
+        ],
+      ),
+    ], legacy: []);
+    await assertErrorsInCode(r'''
+class A {
+  const A(x) : y = x;
+  final int y;
+}
+var v = const A(null);
+''', errors);
+  }
+
+  test_notGeneric_null_forNonNullable_fromNullSafe() async {
+    await assertErrorsInCode('''
+class C {
+  final int f;
+  const C(a) : f = a;
+}
+
+const a = const C(null);
+''', [
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        60,
+        13,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 44, 1,
+              text:
+                  "The exception is 'In a const constructor, a value of type 'Null' can't be assigned to the field 'f', which has type 'int'.' and occurs here."),
+        ],
+      ),
+    ]);
+  }
+}
+
+@reflectiveTest
+class ConstConstructorParamTypeMismatchContextTest
+    extends PubPackageResolutionTest {
+  test_assignable_fieldFormal_typedef() async {
+    // foo has the type dynamic -> dynamic, so it is not assignable to A.f.
+    await assertErrorsInCode(r'''
+typedef String Int2String(int x);
+class A {
+  final Int2String f;
+  const A(this.f);
+}
+foo(x) => 1;
+var v = const A(foo);
+''', [
+      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 116, 3),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        108,
+        12,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 116, 3,
+              text:
+                  "The exception is 'A value of type 'dynamic Function(dynamic)' can't be assigned to a parameter of type 'String Function(int)' in a const constructor.' and occurs here."),
+        ],
+      ),
+    ]);
+  }
+
+  test_enum_int_null() async {
+    await assertErrorsInCode(r'''
+const dynamic a = null;
+
+enum E {
+  v(a);
+  const E(int a);
+}
+''', [
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        36,
+        4,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 38, 1,
+              text:
+                  "The exception is 'A value of type 'Null' can't be assigned to a parameter of type 'int' in a const constructor.' and occurs here."),
+        ],
+      ),
+    ]);
+  }
+
+  test_enum_int_String() async {
+    await assertErrorsInCode(r'''
+const dynamic a = '0';
+
+enum E {
+  v(a);
+  const E(int a);
+}
+''', [
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        35,
+        4,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 37, 1,
+              text:
+                  "The exception is 'A value of type 'String' can't be assigned to a parameter of type 'int' in a const constructor.' and occurs here."),
+        ],
+      ),
+    ]);
+  }
+
+  test_notAssignable_fieldFormal_optional() async {
+    await assertErrorsInCode(r'''
+class A {
+  final int x;
+  const A([this.x = 'foo']);
+}
+var v = const A();
+''', [
+      error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 45, 5),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        64,
+        9,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 64, 9,
+              text:
+                  "The exception is 'A value of type 'String' can't be assigned to a parameter of type 'int' in a const constructor.' and occurs here."),
+        ],
+      ),
+    ]);
+  }
+
+  test_notAssignable_fieldFormal_supertype() async {
+    await assertErrorsInCode(r'''
+class A {
+  const A();
+}
+class B extends A {
+  const B();
+}
+class C {
+  final B b;
+  const C(this.b);
+}
+const A u = const A();
+var v = const C(u);
+''', [
+      // TODO(srawlins): It would be best to report only the first one.
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        135,
+        10,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 143, 1,
+              text:
+                  "The exception is 'A value of type 'A' can't be assigned to a parameter of type 'B' in a const constructor.' and occurs here."),
+        ],
+      ),
+      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 143, 1),
+    ]);
+  }
+
+  test_notAssignable_fieldFormal_typedef() async {
+    // foo has type String -> int, so it is not assignable to A.f
+    // (A.f requires it to be int -> String).
+    await assertErrorsInCode(r'''
+typedef String Int2String(int x);
+class A {
+  final Int2String f;
+  const A(this.f);
+}
+int foo(String x) => 1;
+var v = const A(foo);
+''', [
+      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 127, 3),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        119,
+        12,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 127, 3,
+              text:
+                  "The exception is 'A value of type 'int Function(String)' can't be assigned to a parameter of type 'String Function(int)' in a const constructor.' and occurs here."),
+        ],
+      ),
+    ]);
+  }
+
+  test_notAssignable_fieldFormal_unrelated() async {
+    await assertErrorsInCode(r'''
+class A {
+  final int x;
+  const A(this.x);
+}
+var v = const A('foo');
+''', [
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        54,
+        14,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 62, 5,
+              text:
+                  "The exception is 'A value of type 'String' can't be assigned to a parameter of type 'int' in a const constructor.' and occurs here."),
+        ],
+      ),
+      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 62, 5),
+    ]);
+  }
+
+  test_notAssignable_typeSubstitution() async {
+    await assertErrorsInCode(r'''
+class A<T> {
+  const A(T x);
+}
+var v = const A<int>('foo');
+''', [
+      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 52, 5),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        39,
+        19,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 52, 5,
+              text:
+                  "The exception is 'A value of type 'String' can't be assigned to a parameter of type 'int' in a const constructor.' and occurs here."),
+        ],
+      ),
+    ]);
+  }
+
+  test_notAssignable_unrelated() async {
+    await assertErrorsInCode(r'''
+class A {
+  const A(int x);
+}
+var v = const A('foo');
+''', [
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        38,
+        14,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 46, 5,
+              text:
+                  "The exception is 'A value of type 'String' can't be assigned to a parameter of type 'int' in a const constructor.' and occurs here."),
+        ],
+      ),
+      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 46, 5),
+    ]);
+  }
+}
+
+@reflectiveTest
 class ConstEvalThrowsExceptionTest extends PubPackageResolutionTest
     with ConstEvalThrowsExceptionTestCases {
   test_asExpression_typeParameter() async {
@@ -32,8 +344,26 @@
   const C<int>(null);
 }
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 92, 19),
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 115, 18),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        92,
+        19,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 51, 6,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        115,
+        18,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 51, 6,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -50,8 +380,26 @@
   const C<int>(null);
 }
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 104, 21),
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 129, 18),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        104,
+        21,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 51, 12,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        129,
+        18,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 51, 12,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -63,7 +411,61 @@
   const E({int? x}) : x = x as int;
 }
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 11, 3),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        11,
+        3,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 57, 8,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
+    ]);
+  }
+
+  test_invalid_constructorFieldInitializer_fromSeparateLibrary() async {
+    newFile('$testPackageLibPath/lib.dart', r'''
+class A<T> {
+  final int f;
+  const A() : f = T.foo;
+}
+''');
+    await assertErrorsInCode(r'''
+import 'lib.dart';
+const a = const A();
+''', [
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        29,
+        9,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 46, 5,
+              text:
+                  "The exception is 'Invalid constant value.' and occurs here."),
+        ],
+      ),
+    ]);
+  }
+
+  test_redirectingConstructor_paramTypeMismatch() async {
+    await assertErrorsInCode(r'''
+class A {
+  const A.a1(x) : this.a2(x);
+  const A.a2(String x);
+}
+var v = const A.a1(0);
+''', [
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        74,
+        13,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 36, 1,
+              text:
+                  "The exception is 'A value of type 'int' can't be assigned to a parameter of type 'String' in a const constructor.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -104,7 +506,16 @@
 }
 var v = const A(3, 2);
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 61, 13),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        61,
+        13,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 36, 13,
+              text:
+                  "The exception is 'The assertion in this constant expression failed.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -243,7 +654,16 @@
           CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION,
           39,
           1),
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 56, 9),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        56,
+        9,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 43, 1,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -264,7 +684,16 @@
           CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR,
           40,
           1),
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 54, 10),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        54,
+        10,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 54, 10,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
@@ -286,9 +715,27 @@
 var b1 = const bool.fromEnvironment(1);
 var b2 = const bool.fromEnvironment('x', defaultValue: 1);
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 9, 29),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        9,
+        29,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 9, 29,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
       error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 36, 1),
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 49, 48),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        49,
+        48,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 49, 48,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
       error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 95, 1),
     ]);
   }
@@ -300,7 +747,16 @@
     await assertErrorsInCode('''
 var b = const bool.fromEnvironment('x', defaultValue: 1);
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 8, 48),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        8,
+        48,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 8, 48,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
       error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 54, 1),
     ]);
   }
@@ -319,45 +775,36 @@
 ''');
   }
 
-  test_invalid_constructorFieldInitializer_fromSeparateLibrary() async {
-    newFile('$testPackageLibPath/lib.dart', r'''
-class A<T> {
-  final int f;
-  const A() : f = T.foo;
-}
-''');
-    await assertErrorsInCode(r'''
-import 'lib.dart';
-const a = const A();
-''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 29, 9),
-    ]);
-  }
-
-  test_redirectingConstructor_paramTypeMismatch() async {
-    await assertErrorsInCode(r'''
-class A {
-  const A.a1(x) : this.a2(x);
-  const A.a2(String x);
-}
-var v = const A.a1(0);
-''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 74, 13),
-    ]);
-  }
-
   test_symbolConstructor_nonStringArgument() async {
     await assertErrorsInCode(r'''
 var s2 = const Symbol(3);
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 9, 15),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        9,
+        15,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 9, 15,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
       error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 22, 1),
     ]);
   }
 
   test_symbolConstructor_string_digit() async {
     var expectedErrors = expectedErrorsByNullability(nullable: [], legacy: [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 8, 17),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        8,
+        17,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 8, 17,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
     ]);
     await assertErrorsInCode(r'''
 var s = const Symbol('3');
@@ -366,7 +813,16 @@
 
   test_symbolConstructor_string_underscore() async {
     var expectedErrors = expectedErrorsByNullability(nullable: [], legacy: [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 8, 17),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        8,
+        17,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 8, 17,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
     ]);
     await assertErrorsInCode(r'''
 var s = const Symbol('_');
diff --git a/pkg/analyzer/test/src/diagnostics/field_initialized_by_multiple_initializers_test.dart b/pkg/analyzer/test/src/diagnostics/field_initialized_by_multiple_initializers_test.dart
index d766eac..f18ff4f 100644
--- a/pkg/analyzer/test/src/diagnostics/field_initialized_by_multiple_initializers_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/field_initialized_by_multiple_initializers_test.dart
@@ -5,6 +5,7 @@
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../generated/test_support.dart';
 import '../dart/resolution/context_collection_resolution.dart';
 
 main() {
@@ -84,7 +85,16 @@
   const E() : x = 0, x = 1;
 }
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 11, 1),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        11,
+        1,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 54, 1,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
       error(CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, 50,
           1),
     ]);
diff --git a/pkg/analyzer/test/src/diagnostics/field_initialized_in_initializer_and_declaration_test.dart b/pkg/analyzer/test/src/diagnostics/field_initialized_in_initializer_and_declaration_test.dart
index 9bf6c15..ccc96cd 100644
--- a/pkg/analyzer/test/src/diagnostics/field_initialized_in_initializer_and_declaration_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/field_initialized_in_initializer_and_declaration_test.dart
@@ -5,6 +5,7 @@
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../generated/test_support.dart';
 import '../dart/resolution/context_collection_resolution.dart';
 
 main() {
@@ -38,7 +39,16 @@
   const E() : x = 1;
 }
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 11, 1),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        11,
+        1,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 51, 1,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
       error(
           CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION,
           47,
diff --git a/pkg/analyzer/test/src/diagnostics/field_initialized_in_parameter_and_initializer_test.dart b/pkg/analyzer/test/src/diagnostics/field_initialized_in_parameter_and_initializer_test.dart
index ced1bc9..5eb8292 100644
--- a/pkg/analyzer/test/src/diagnostics/field_initialized_in_parameter_and_initializer_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/field_initialized_in_parameter_and_initializer_test.dart
@@ -5,6 +5,7 @@
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../generated/test_support.dart';
 import '../dart/resolution/context_collection_resolution.dart';
 
 main() {
@@ -36,7 +37,16 @@
   const E(this.x) : x = 1;
 }
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 11, 4),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        11,
+        4,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 56, 1,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
       error(CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER,
           52, 1),
     ]);
diff --git a/pkg/analyzer/test/src/diagnostics/field_initializer_not_assignable_test.dart b/pkg/analyzer/test/src/diagnostics/field_initializer_not_assignable_test.dart
index eb14c4f..9b8b7a7 100644
--- a/pkg/analyzer/test/src/diagnostics/field_initializer_not_assignable_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/field_initializer_not_assignable_test.dart
@@ -5,6 +5,7 @@
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../generated/test_support.dart';
 import '../dart/resolution/context_collection_resolution.dart';
 
 main() {
@@ -61,7 +62,16 @@
   const E() : x = '';
 }
 ''', [
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH, 11, 1),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        11,
+        1,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 47, 2,
+              text:
+                  "The exception is 'In a const constructor, a value of type 'String' can't be assigned to the field 'x', which has type 'int'.' and occurs here."),
+        ],
+      ),
       error(CompileTimeErrorCode.FIELD_INITIALIZER_NOT_ASSIGNABLE, 47, 2),
       error(CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE, 47, 2),
     ]);
diff --git a/pkg/analyzer/test/src/diagnostics/field_initializing_formal_not_assignable_test.dart b/pkg/analyzer/test/src/diagnostics/field_initializing_formal_not_assignable_test.dart
index 7f098e3..14ef39d 100644
--- a/pkg/analyzer/test/src/diagnostics/field_initializing_formal_not_assignable_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/field_initializing_formal_not_assignable_test.dart
@@ -5,6 +5,7 @@
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../generated/test_support.dart';
 import '../dart/resolution/context_collection_resolution.dart';
 
 main() {
@@ -61,7 +62,16 @@
   const E(String this.x);
 }
 ''', [
-      error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 13, 2),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        11,
+        5,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 13, 2,
+              text:
+                  "The exception is 'A value of type 'String' can't be assigned to a parameter of type 'int' in a const constructor.' and occurs here."),
+        ],
+      ),
       error(CompileTimeErrorCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE, 43,
           13),
     ]);
diff --git a/pkg/analyzer/test/src/diagnostics/final_initialized_in_declaration_and_constructor_test.dart b/pkg/analyzer/test/src/diagnostics/final_initialized_in_declaration_and_constructor_test.dart
index d7a4b8e..6cf7eab 100644
--- a/pkg/analyzer/test/src/diagnostics/final_initialized_in_declaration_and_constructor_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/final_initialized_in_declaration_and_constructor_test.dart
@@ -5,6 +5,7 @@
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../generated/test_support.dart';
 import '../dart/resolution/context_collection_resolution.dart';
 
 main() {
@@ -38,7 +39,16 @@
   const E(this.x);
 }
 ''', [
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 11, 4),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        11,
+        4,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 11, 4,
+              text:
+                  "The exception is 'Evaluation of this constant expression throws an exception.' and occurs here."),
+        ],
+      ),
       error(
           CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR,
           47,
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_constant_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_constant_test.dart
index 3c82fb4..be92622 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_constant_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_constant_test.dart
@@ -5,6 +5,7 @@
 import 'package:analyzer/src/error/codes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../generated/test_support.dart';
 import '../dart/resolution/context_collection_resolution.dart';
 
 main() {
@@ -190,7 +191,16 @@
 var b = const B();
 ''', [
       error(CompileTimeErrorCode.INVALID_CONSTANT, 47, 7),
-      error(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, 77, 9),
+      error(
+        CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+        77,
+        9,
+        contextMessages: [
+          ExpectedContextMessage(testFile.path, 47, 7,
+              text:
+                  "The exception is 'Invalid constant value.' and occurs here."),
+        ],
+      ),
     ]);
   }
 
diff --git a/tests/language/compile_time_constant/static2_test.dart b/tests/language/compile_time_constant/static2_test.dart
index 5222a1a..fba42eb 100644
--- a/tests/language/compile_time_constant/static2_test.dart
+++ b/tests/language/compile_time_constant/static2_test.dart
@@ -29,25 +29,27 @@
 
 const a1 = const A.a1();
 //         ^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 const a2 = const A.a2('foo');
+//         ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                    ^^^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
 // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
 const a3 = const A.a3();
 //         ^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 const a4 = const A.a4('foo');
-//                    ^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+//         ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 const a5 = const A.a5('foo');
 //         ^^^^^^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 const a6 = const A.a6('foo');
+//         ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                    ^^^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
 // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
 
 main() {
diff --git a/tests/language/compile_time_constant/static3_test.dart b/tests/language/compile_time_constant/static3_test.dart
index 6179815..6cde168 100644
--- a/tests/language/compile_time_constant/static3_test.dart
+++ b/tests/language/compile_time_constant/static3_test.dart
@@ -29,25 +29,27 @@
 
 var a1 = const A.a1();
 //       ^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 var a2 = const A.a2('foo');
+//       ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                  ^^^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
 // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
 var a3 = const A.a3();
 //       ^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 var a4 = const A.a4('foo');
-//                  ^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+//       ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 var a5 = const A.a5('foo');
 //       ^^^^^^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 var a6 = const A.a6('foo');
+//       ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                  ^^^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
 // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
 
 main() {
diff --git a/tests/language/const/constructor3_test.dart b/tests/language/const/constructor3_test.dart
index 8ec85e0..fd7acda 100644
--- a/tests/language/const/constructor3_test.dart
+++ b/tests/language/const/constructor3_test.dart
@@ -14,11 +14,11 @@
 const intValue = 0;
 const c = const C(0.0);
 const d = const C(intValue);
-//                ^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
-// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
+//        ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                ^^^^^^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
 const e = const D(0.0);
 const f = const D(intValue);
 //        ^^^^^^^^^^^^^^^^^
diff --git a/tests/language/type/check_const_function_typedef2_test.dart b/tests/language/type/check_const_function_typedef2_test.dart
index 33ffd6a..c4ced7c 100644
--- a/tests/language/type/check_const_function_typedef2_test.dart
+++ b/tests/language/type/check_const_function_typedef2_test.dart
@@ -16,9 +16,10 @@
 int foo(String x) => 499;
 
 const a = const A(foo);
+//        ^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                ^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
 // [cfe] The argument type 'int Function(String)' can't be assigned to the parameter type 'String Function(int)'.
 
 main() {
diff --git a/tests/language_2/compile_time_constant/static2_test.dart b/tests/language_2/compile_time_constant/static2_test.dart
index 7fdf6199..2c301f1 100644
--- a/tests/language_2/compile_time_constant/static2_test.dart
+++ b/tests/language_2/compile_time_constant/static2_test.dart
@@ -31,25 +31,27 @@
 
 const a1 = const A.a1();
 //         ^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 const a2 = const A.a2('foo');
+//         ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                    ^^^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
 // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
 const a3 = const A.a3();
 //         ^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 const a4 = const A.a4('foo');
-//                    ^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+//         ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 const a5 = const A.a5('foo');
 //         ^^^^^^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 const a6 = const A.a6('foo');
+//         ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                    ^^^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
 // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
 
 main() {
diff --git a/tests/language_2/compile_time_constant/static3_test.dart b/tests/language_2/compile_time_constant/static3_test.dart
index a8a4599..b90632b 100644
--- a/tests/language_2/compile_time_constant/static3_test.dart
+++ b/tests/language_2/compile_time_constant/static3_test.dart
@@ -31,25 +31,27 @@
 
 var a1 = const A.a1();
 //       ^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 var a2 = const A.a2('foo');
+//       ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                  ^^^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
 // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
 var a3 = const A.a3();
 //       ^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 var a4 = const A.a4('foo');
-//                  ^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
+//       ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 var a5 = const A.a5('foo');
 //       ^^^^^^^^^^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 var a6 = const A.a6('foo');
+//       ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                  ^^^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
 // [cfe] The argument type 'String' can't be assigned to the parameter type 'int'.
 
 main() {
diff --git a/tests/language_2/const/constructor3_test.dart b/tests/language_2/const/constructor3_test.dart
index 592dcdb..94fe5b8 100644
--- a/tests/language_2/const/constructor3_test.dart
+++ b/tests/language_2/const/constructor3_test.dart
@@ -16,11 +16,11 @@
 const intValue = 0;
 const c = const C(0.0);
 const d = const C(intValue);
-//                ^^^^^^^^
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
-// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
+//        ^^^^^^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                ^^^^^^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
+// [cfe] The argument type 'int' can't be assigned to the parameter type 'double'.
 const e = const D(0.0);
 const f = const D(intValue);
 //        ^^^^^^^^^^^^^^^^^
diff --git a/tests/language_2/type/check_const_function_typedef2_test.dart b/tests/language_2/type/check_const_function_typedef2_test.dart
index bea07a0..2c3e1a9 100644
--- a/tests/language_2/type/check_const_function_typedef2_test.dart
+++ b/tests/language_2/type/check_const_function_typedef2_test.dart
@@ -18,9 +18,10 @@
 int foo(String x) => 499;
 
 const a = const A(foo);
+//        ^^^^^^^^^^^^
+// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
 //                ^^^
 // [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
-// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH
 // [cfe] The argument type 'int Function(String)' can't be assigned to the parameter type 'String Function(int)'.
 
 main() {