blob: 1b03e56549ba8146c5191598c9c0c9fb4370297d [file] [log] [blame]
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// THIS FILE IS GENERATED. DO NOT EDIT.
//
// Instead modify 'pkg/analyzer/messages.yaml' and run
// 'dart pkg/analyzer/tool/messages/generate.dart' to update.
import "package:analyzer/error/error.dart";
import "package:analyzer/src/error/analyzer_error_code.dart";
// It is hard to visually separate each code's _doc comment_ from its published
// _documentation comment_ when each is written as an end-of-line comment.
// ignore_for_file: slash_for_doc_comments
class CompileTimeErrorCode extends AnalyzerErrorCode {
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a field that has the `abstract`
// modifier also has an initializer.
//
// #### Examples
//
// The following code produces this diagnostic because `f` is marked as
// `abstract` and has an initializer:
//
// ```dart
// abstract class C {
// abstract int [!f!] = 0;
// }
// ```
//
// The following code produces this diagnostic because `f` is marked as
// `abstract` and there's an initializer in the constructor:
//
// ```dart
// abstract class C {
// abstract int f;
//
// C() : [!f!] = 0;
// }
// ```
//
// #### Common fixes
//
// If the field must be abstract, then remove the initializer:
//
// ```dart
// abstract class C {
// abstract int f;
// }
// ```
//
// If the field isn't required to be abstract, then remove the keyword:
//
// ```dart
// abstract class C {
// int f = 0;
// }
// ```
static const CompileTimeErrorCode ABSTRACT_FIELD_CONSTRUCTOR_INITIALIZER =
CompileTimeErrorCode(
'ABSTRACT_FIELD_INITIALIZER',
"Abstract fields can't have initializers.",
correctionMessage:
"Try removing the field initializer or the 'abstract' keyword from the "
"field declaration.",
hasPublishedDocs: true,
uniqueName: 'ABSTRACT_FIELD_CONSTRUCTOR_INITIALIZER',
);
/**
* No parameters.
*/
static const CompileTimeErrorCode ABSTRACT_FIELD_INITIALIZER =
CompileTimeErrorCode(
'ABSTRACT_FIELD_INITIALIZER',
"Abstract fields can't have initializers.",
correctionMessage:
"Try removing the initializer or the 'abstract' keyword.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the display name for the kind of the found abstract member
* 1: the name of the member
*/
// #### Description
//
// The analyzer produces this diagnostic when an inherited member is
// referenced using `super`, but there is no concrete implementation of the
// member in the superclass chain. Abstract members can't be invoked.
//
// #### Example
//
// The following code produces this diagnostic because `B` doesn't inherit a
// concrete implementation of `a`:
//
// ```dart
// abstract class A {
// int get a;
// }
// class B extends A {
// int get a => super.[!a!];
// }
// ```
//
// #### Common fixes
//
// Remove the invocation of the abstract member, possibly replacing it with an
// invocation of a concrete member.
// TODO(brianwilkerson) This either needs to be generalized (use 'member'
// rather than '{0}') or split into multiple codes.
static const CompileTimeErrorCode ABSTRACT_SUPER_MEMBER_REFERENCE =
CompileTimeErrorCode(
'ABSTRACT_SUPER_MEMBER_REFERENCE',
"The {0} '{1}' is always abstract in the supertype.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the ambiguous element
* 1: the name of the first library in which the type is found
* 2: the name of the second library in which the type is found
*/
// #### Description
//
// The analyzer produces this diagnostic when two or more export directives
// cause the same name to be exported from multiple libraries.
//
// #### Example
//
// Given a file named `a.dart` containing
//
// ```dart
// %uri="lib/a.dart"
// class C {}
// ```
//
// And a file named `b.dart` containing
//
// ```dart
// %uri="lib/b.dart"
// class C {}
// ```
//
// The following code produces this diagnostic because the name `C` is being
// exported from both `a.dart` and `b.dart`:
//
// ```dart
// export 'a.dart';
// export [!'b.dart'!];
// ```
//
// #### Common fixes
//
// If none of the names in one of the libraries needs to be exported, then
// remove the unnecessary export directives:
//
// ```dart
// export 'a.dart';
// ```
//
// If all of the export directives are needed, then hide the name in all
// except one of the directives:
//
// ```dart
// export 'a.dart';
// export 'b.dart' hide C;
// ```
static const CompileTimeErrorCode AMBIGUOUS_EXPORT = CompileTimeErrorCode(
'AMBIGUOUS_EXPORT',
"The name '{0}' is defined in the libraries '{1}' and '{2}'.",
correctionMessage:
"Try removing the export of one of the libraries, or explicitly hiding "
"the name in one of the export directives.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the member
* 1: the names of the declaring extensions
*/
// #### Description
//
// When code refers to a member of an object (for example, `o.m()` or `o.m` or
// `o[i]`) where the static type of `o` doesn't declare the member (`m` or
// `[]`, for example), then the analyzer tries to find the member in an
// extension. For example, if the member is `m`, then the analyzer looks for
// extensions that declare a member named `m` and have an extended type that
// the static type of `o` can be assigned to. When there's more than one such
// extension in scope, the extension whose extended type is most specific is
// selected.
//
// The analyzer produces this diagnostic when none of the extensions has an
// extended type that's more specific than the extended types of all of the
// other extensions, making the reference to the member ambiguous.
//
// #### Example
//
// The following code produces this diagnostic because there's no way to
// choose between the member in `E1` and the member in `E2`:
//
// ```dart
// extension E1 on String {
// int get charCount => 1;
// }
//
// extension E2 on String {
// int get charCount => 2;
// }
//
// void f(String s) {
// print(s.[!charCount!]);
// }
// ```
//
// #### Common fixes
//
// If you don't need both extensions, then you can delete or hide one of them.
//
// If you need both, then explicitly select the one you want to use by using
// an extension override:
//
// ```dart
// extension E1 on String {
// int get charCount => length;
// }
//
// extension E2 on String {
// int get charCount => length;
// }
//
// void f(String s) {
// print(E2(s).charCount);
// }
// ```
static const CompileTimeErrorCode AMBIGUOUS_EXTENSION_MEMBER_ACCESS =
CompileTimeErrorCode(
'AMBIGUOUS_EXTENSION_MEMBER_ACCESS',
"A member named '{0}' is defined in {1}, and none are more specific.",
correctionMessage:
"Try using an extension override to specify the extension you want to "
"be chosen.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the ambiguous type
* 1: the name of the first library that the type is found
* 2: the name of the second library that the type is found
*/
// #### Description
//
// The analyzer produces this diagnostic when a name is referenced that is
// declared in two or more imported libraries.
//
// #### Example
//
// Given a library (`a.dart`) that defines a class (`C` in this example):
//
// ```dart
// %uri="lib/a.dart"
// class A {}
// class C {}
// ```
//
// And a library (`b.dart`) that defines a different class with the same name:
//
// ```dart
// %uri="lib/b.dart"
// class B {}
// class C {}
// ```
//
// The following code produces this diagnostic:
//
// ```dart
// import 'a.dart';
// import 'b.dart';
//
// void f([!C!] c1, [!C!] c2) {}
// ```
//
// #### Common fixes
//
// If any of the libraries aren't needed, then remove the import directives
// for them:
//
// ```dart
// import 'a.dart';
//
// void f(C c1, C c2) {}
// ```
//
// If the name is still defined by more than one library, then add a `hide`
// clause to the import directives for all except one library:
//
// ```dart
// import 'a.dart' hide C;
// import 'b.dart';
//
// void f(C c1, C c2) {}
// ```
//
// If you must be able to reference more than one of these types, then add a
// prefix to each of the import directives, and qualify the references with
// the appropriate prefix:
//
// ```dart
// import 'a.dart' as a;
// import 'b.dart' as b;
//
// void f(a.C c1, b.C c2) {}
// ```
static const CompileTimeErrorCode AMBIGUOUS_IMPORT = CompileTimeErrorCode(
'AMBIGUOUS_IMPORT',
"The name '{0}' is defined in the libraries {1}.",
correctionMessage:
"Try using 'as prefix' for one of the import directives, or hiding the "
"name from all but one of the imports.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// Because map and set literals use the same delimiters (`{` and `}`), the
// analyzer looks at the type arguments and the elements to determine which
// kind of literal you meant. When there are no type arguments, then the
// analyzer uses the types of the elements. If all of the elements are literal
// map entries and all of the spread operators are spreading a `Map` then it's
// a `Map`. If none of the elements are literal map entries and all of the
// spread operators are spreading an `Iterable`, then it's a `Set`. If neither
// of those is true then it's ambiguous.
//
// The analyzer produces this diagnostic when at least one element is a
// literal map entry or a spread operator spreading a `Map`, and at least one
// element is neither of these, making it impossible for the analyzer to
// determine whether you are writing a map literal or a set literal.
//
// #### Example
//
// The following code produces this diagnostic:
//
// ```dart
// union(Map<String, String> a, List<String> b, Map<String, String> c) =>
// [!{...a, ...b, ...c}!];
// ```
//
// The list `b` can only be spread into a set, and the maps `a` and `c` can
// only be spread into a map, and the literal can't be both.
//
// #### Common fixes
//
// There are two common ways to fix this problem. The first is to remove all
// of the spread elements of one kind or another, so that the elements are
// consistent. In this case, that likely means removing the list and deciding
// what to do about the now unused parameter:
//
// ```dart
// union(Map<String, String> a, List<String> b, Map<String, String> c) =>
// {...a, ...c};
// ```
//
// The second fix is to change the elements of one kind into elements that are
// consistent with the other elements. For example, you can add the elements
// of the list as keys that map to themselves:
//
// ```dart
// union(Map<String, String> a, List<String> b, Map<String, String> c) =>
// {...a, for (String s in b) s: s, ...c};
// ```
static const CompileTimeErrorCode AMBIGUOUS_SET_OR_MAP_LITERAL_BOTH =
CompileTimeErrorCode(
'AMBIGUOUS_SET_OR_MAP_LITERAL_BOTH',
"The literal can't be either a map or a set because it contains at least "
"one literal map entry or a spread operator spreading a 'Map', and at "
"least one element which is neither of these.",
correctionMessage:
"Try removing or changing some of the elements so that all of the "
"elements are consistent.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// Because map and set literals use the same delimiters (`{` and `}`), the
// analyzer looks at the type arguments and the elements to determine which
// kind of literal you meant. When there are no type arguments and all of the
// elements are spread elements (which are allowed in both kinds of literals)
// then the analyzer uses the types of the expressions that are being spread.
// If all of the expressions have the type `Iterable`, then it's a set
// literal; if they all have the type `Map`, then it's a map literal.
//
// This diagnostic is produced when none of the expressions being spread have
// a type that allows the analyzer to decide whether you were writing a map
// literal or a set literal.
//
// #### Example
//
// The following code produces this diagnostic:
//
// ```dart
// union(a, b) => [!{...a, ...b}!];
// ```
//
// The problem occurs because there are no type arguments, and there is no
// information about the type of either `a` or `b`.
//
// #### Common fixes
//
// There are three common ways to fix this problem. The first is to add type
// arguments to the literal. For example, if the literal is intended to be a
// map literal, you might write something like this:
//
// ```dart
// union(a, b) => <String, String>{...a, ...b};
// ```
//
// The second fix is to add type information so that the expressions have
// either the type `Iterable` or the type `Map`. You can add an explicit cast
// or, in this case, add types to the declarations of the two parameters:
//
// ```dart
// union(List<int> a, List<int> b) => {...a, ...b};
// ```
//
// The third fix is to add context information. In this case, that means
// adding a return type to the function:
//
// ```dart
// Set<String> union(a, b) => {...a, ...b};
// ```
//
// In other cases, you might add a type somewhere else. For example, say the
// original code looks like this:
//
// ```dart
// union(a, b) {
// var x = [!{...a, ...b}!];
// return x;
// }
// ```
//
// You might add a type annotation on `x`, like this:
//
// ```dart
// union(a, b) {
// Map<String, String> x = {...a, ...b};
// return x;
// }
// ```
static const CompileTimeErrorCode AMBIGUOUS_SET_OR_MAP_LITERAL_EITHER =
CompileTimeErrorCode(
'AMBIGUOUS_SET_OR_MAP_LITERAL_EITHER',
"This literal must be either a map or a set, but the elements don't have "
"enough information for type inference to work.",
correctionMessage:
"Try adding type arguments to the literal (one for sets, two for "
"maps).",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the actual argument type
* 1: the name of the expected type
*/
// #### Description
//
// The analyzer produces this diagnostic when the static type of an argument
// can't be assigned to the static type of the corresponding parameter.
//
// #### Example
//
// The following code produces this diagnostic because a `num` can't be
// assigned to a `String`:
//
// ```dart
// %language=2.9
// String f(String x) => x;
// String g(num y) => f([!y!]);
// ```
//
// #### Common fixes
//
// If possible, rewrite the code so that the static type is assignable. In the
// example above you might be able to change the type of the parameter `y`:
//
// ```dart
// %language=2.9
// String f(String x) => x;
// String g(String y) => f(y);
// ```
//
// If that fix isn't possible, then add code to handle the case where the
// argument value isn't the required type. One approach is to coerce other
// types to the required type:
//
// ```dart
// %language=2.9
// String f(String x) => x;
// String g(num y) => f(y.toString());
// ```
//
// Another approach is to add explicit type tests and fallback code:
//
// ```dart
// %language=2.9
// String f(String x) => x;
// String g(num y) => f(y is String ? y : '');
// ```
//
// If you believe that the runtime type of the argument will always be the
// same as the static type of the parameter, and you're willing to risk having
// an exception thrown at runtime if you're wrong, then add an explicit cast:
//
// ```dart
// String f(String x) => x;
// String g(num y) => f(y as String);
// ```
static const CompileTimeErrorCode ARGUMENT_TYPE_NOT_ASSIGNABLE =
CompileTimeErrorCode(
'ARGUMENT_TYPE_NOT_ASSIGNABLE',
"The argument type '{0}' can't be assigned to the parameter type '{1}'.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a redirecting constructor (a
// constructor that redirects to another constructor in the same class) has an
// assert in the initializer list.
//
// #### Example
//
// The following code produces this diagnostic because the unnamed constructor
// is a redirecting constructor and also has an assert in the initializer
// list:
//
// ```dart
// class C {
// C(int x) : [!assert(x > 0)!], this.name();
// C.name() {}
// }
// ```
//
// #### Common fixes
//
// If the assert isn't needed, then remove it:
//
// ```dart
// class C {
// C(int x) : this.name();
// C.name() {}
// }
// ```
//
// If the assert is needed, then convert the constructor into a factory
// constructor:
//
// ```dart
// class C {
// factory C(int x) {
// assert(x > 0);
// return C.name();
// }
// C.name() {}
// }
// ```
static const CompileTimeErrorCode ASSERT_IN_REDIRECTING_CONSTRUCTOR =
CompileTimeErrorCode(
'ASSERT_IN_REDIRECTING_CONSTRUCTOR',
"A redirecting constructor can't have an 'assert' initializer.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when it finds an assignment to a
// top-level variable, a static field, or a local variable that has the
// `const` modifier. The value of a compile-time constant can't be changed at
// runtime.
//
// #### Example
//
// The following code produces this diagnostic because `c` is being assigned a
// value even though it has the `const` modifier:
//
// ```dart
// const c = 0;
//
// void f() {
// [!c!] = 1;
// print(c);
// }
// ```
//
// #### Common fixes
//
// If the variable must be assignable, then remove the `const` modifier:
//
// ```dart
// var c = 0;
//
// void f() {
// c = 1;
// print(c);
// }
// ```
//
// If the constant shouldn't be changed, then either remove the assignment or
// use a local variable in place of references to the constant:
//
// ```dart
// const c = 0;
//
// void f() {
// var v = 1;
// print(v);
// }
// ```
static const CompileTimeErrorCode ASSIGNMENT_TO_CONST = CompileTimeErrorCode(
'ASSIGNMENT_TO_CONST',
"Constant variables can't be assigned a value.",
correctionMessage:
"Try removing the assignment, or remove the modifier 'const' from the "
"variable.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the final variable
*/
// #### Description
//
// The analyzer produces this diagnostic when it finds an invocation of a
// setter, but there's no setter because the field with the same name was
// declared to be `final` or `const`.
//
// #### Example
//
// The following code produces this diagnostic because `v` is final:
//
// ```dart
// class C {
// final v = 0;
// }
//
// f(C c) {
// c.[!v!] = 1;
// }
// ```
//
// #### Common fixes
//
// If you need to be able to set the value of the field, then remove the
// modifier `final` from the field:
//
// ```dart
// class C {
// int v = 0;
// }
//
// f(C c) {
// c.v = 1;
// }
// ```
static const CompileTimeErrorCode ASSIGNMENT_TO_FINAL = CompileTimeErrorCode(
'ASSIGNMENT_TO_FINAL',
"'{0}' can't be used as a setter because it's final.",
correctionMessage:
"Try finding a different setter, or making '{0}' non-final.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a local variable that was
// declared to be final is assigned after it was initialized.
//
// #### Example
//
// The following code produces this diagnostic because `x` is final, so it
// can't have a value assigned to it after it was initialized:
//
// ```dart
// void f() {
// final x = 0;
// [!x!] = 3;
// print(x);
// }
// ```
//
// #### Common fixes
//
// Remove the keyword `final`, and replace it with `var` if there's no type
// annotation:
//
// ```dart
// void f() {
// var x = 0;
// x = 3;
// print(x);
// }
// ```
static const CompileTimeErrorCode ASSIGNMENT_TO_FINAL_LOCAL =
CompileTimeErrorCode(
'ASSIGNMENT_TO_FINAL_LOCAL',
"The final variable '{0}' can only be set once.",
correctionMessage: "Try making '{0}' non-final.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a reference to a setter is
// found; there is no setter defined for the type; but there is a getter
// defined with the same name.
//
// #### Example
//
// The following code produces this diagnostic because there is no setter
// named `x` in `C`, but there is a getter named `x`:
//
// ```dart
// class C {
// int get x => 0;
// set y(int p) {}
// }
//
// void f(C c) {
// c.[!x!] = 1;
// }
// ```
//
// #### Common fixes
//
// If you want to invoke an existing setter, then correct the name:
//
// ```dart
// class C {
// int get x => 0;
// set y(int p) {}
// }
//
// void f(C c) {
// c.y = 1;
// }
// ```
//
// If you want to invoke the setter but it just doesn't exist yet, then
// declare it:
//
// ```dart
// class C {
// int get x => 0;
// set x(int p) {}
// set y(int p) {}
// }
//
// void f(C c) {
// c.x = 1;
// }
// ```
static const CompileTimeErrorCode ASSIGNMENT_TO_FINAL_NO_SETTER =
CompileTimeErrorCode(
'ASSIGNMENT_TO_FINAL_NO_SETTER',
"There isn’t a setter named '{0}' in class '{1}'.",
correctionMessage:
"Try correcting the name to reference an existing setter, or declare "
"the setter.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when the name of a function appears
// on the left-hand side of an assignment expression.
//
// #### Example
//
// The following code produces this diagnostic because the assignment to the
// function `f` is invalid:
//
// ```dart
// void f() {}
//
// void g() {
// [!f!] = () {};
// }
// ```
//
// #### Common fixes
//
// If the right-hand side should be assigned to something else, such as a
// local variable, then change the left-hand side:
//
// ```dart
// void f() {}
//
// void g() {
// var x = () {};
// print(x);
// }
// ```
//
// If the intent is to change the implementation of the function, then define
// a function-valued variable instead of a function:
//
// ```dart
// void Function() f = () {};
//
// void g() {
// f = () {};
// }
// ```
static const CompileTimeErrorCode ASSIGNMENT_TO_FUNCTION =
CompileTimeErrorCode(
'ASSIGNMENT_TO_FUNCTION',
"Functions can't be assigned a value.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when the target of an assignment is a
// method.
//
// #### Example
//
// The following code produces this diagnostic because `f` can't be assigned a
// value because it's a method:
//
// ```dart
// class C {
// void f() {}
//
// void g() {
// [!f!] = null;
// }
// }
// ```
//
// #### Common fixes
//
// Rewrite the code so that there isn't an assignment to a method.
static const CompileTimeErrorCode ASSIGNMENT_TO_METHOD = CompileTimeErrorCode(
'ASSIGNMENT_TO_METHOD',
"Methods can't be assigned a value.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when the name of a type name appears
// on the left-hand side of an assignment expression.
//
// #### Example
//
// The following code produces this diagnostic because the assignment to the
// class `C` is invalid:
//
// ```dart
// class C {}
//
// void f() {
// [!C!] = null;
// }
// ```
//
// #### Common fixes
//
// If the right-hand side should be assigned to something else, such as a
// local variable, then change the left-hand side:
//
// ```dart
// void f() {}
//
// void g() {
// var c = null;
// print(c);
// }
// ```
static const CompileTimeErrorCode ASSIGNMENT_TO_TYPE = CompileTimeErrorCode(
'ASSIGNMENT_TO_TYPE',
"Types can't be assigned a value.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when an async for-in loop is found in
// a function or method whose body isn't marked as being either `async` or
// `async*`.
//
// #### Example
//
// The following code produces this diagnostic because the body of `f` isn't
// marked as being either `async` or `async*`, but `f` contains an async
// for-in loop:
//
// ```dart
// void f(list) {
// await for (var e [!in!] list) {
// print(e);
// }
// }
// ```
//
// #### Common fixes
//
// If the function should return a `Future`, then mark the body with `async`:
//
// ```dart
// Future<void> f(list) async {
// await for (var e in list) {
// print(e);
// }
// }
// ```
//
// If the function should return a `Stream` of values, then mark the body with
// `async*`:
//
// ```dart
// Stream<void> f(list) async* {
// await for (var e in list) {
// print(e);
// }
// }
// ```
//
// If the function should be synchronous, then remove the `await` before the
// loop:
//
// ```dart
// void f(list) {
// for (var e in list) {
// print(e);
// }
// }
// ```
static const CompileTimeErrorCode ASYNC_FOR_IN_WRONG_CONTEXT =
CompileTimeErrorCode(
'ASYNC_FOR_IN_WRONG_CONTEXT',
"The async for-in loop can only be used in an async function.",
correctionMessage:
"Try marking the function body with either 'async' or 'async*', or "
"removing the 'await' before the for-in loop.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a local variable that has the
// `late` modifier uses an `await` expression in the initializer.
//
// #### Example
//
// The following code produces this diagnostic because an `await` expression
// is used in the initializer for `v`, a local variable that is marked `late`:
//
// ```dart
// Future<int> f() async {
// late var v = [!await!] 42;
// return v;
// }
// ```
//
// #### Common fixes
//
// If the initializer can be rewritten to not use `await`, then rewrite it:
//
// ```dart
// Future<int> f() async {
// late var v = 42;
// return v;
// }
// ```
//
// If the initializer can't be rewritten, then remove the `late` modifier:
//
// ```dart
// Future<int> f() async {
// var v = await 42;
// return v;
// }
// ```
static const CompileTimeErrorCode AWAIT_IN_LATE_LOCAL_VARIABLE_INITIALIZER =
CompileTimeErrorCode(
'AWAIT_IN_LATE_LOCAL_VARIABLE_INITIALIZER',
"The 'await' expression can't be used in a 'late' local variable's "
"initializer.",
correctionMessage:
"Try removing the 'late' modifier, or rewriting the initializer "
"without using the 'await' expression.",
hasPublishedDocs: true,
);
/**
* 16.30 Await Expressions: It is a compile-time error if the function
* immediately enclosing _a_ is not declared asynchronous. (Where _a_ is the
* await expression.)
*/
static const CompileTimeErrorCode AWAIT_IN_WRONG_CONTEXT =
CompileTimeErrorCode(
'AWAIT_IN_WRONG_CONTEXT',
"The await expression can only be used in an async function.",
correctionMessage:
"Try marking the function body with either 'async' or 'async*'.",
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a method or function has a
// return type that's [potentially non-nullable][] but would implicitly return
// `null` if control reached the end of the function.
//
// #### Examples
//
// The following code produces this diagnostic because the method `m` has an
// implicit return of `null` inserted at the end of the method, but the method
// is declared to not return `null`:
//
// ```dart
// class C {
// int [!m!](int t) {
// print(t);
// }
// }
// ```
//
// The following code produces this diagnostic because the method `m` has an
// implicit return of `null` inserted at the end of the method, but because
// the class `C` can be instantiated with a non-nullable type argument, the
// method is effectively declared to not return `null`:
//
// ```dart
// class C<T> {
// T [!m!](T t) {
// print(t);
// }
// }
// ```
//
// #### Common fixes
//
// If there's a reasonable value that can be returned, then add a `return`
// statement at the end of the method:
//
// ```dart
// class C<T> {
// T m(T t) {
// print(t);
// return t;
// }
// }
// ```
//
// If the method won't reach the implicit return, then add a `throw` at the
// end of the method:
//
// ```dart
// class C<T> {
// T m(T t) {
// print(t);
// throw '';
// }
// }
// ```
//
// If the method intentionally returns `null` at the end, then add an
// explicit return of `null` at the end of the method and change the
// return type so that it's valid to return `null`:
//
// ```dart
// class C<T> {
// T? m(T t) {
// print(t);
// return null;
// }
// }
// ```
static const CompileTimeErrorCode BODY_MIGHT_COMPLETE_NORMALLY =
CompileTimeErrorCode(
'BODY_MIGHT_COMPLETE_NORMALLY',
"The body might complete normally, causing 'null' to be returned, but the "
"return type, '{0}', is a potentially non-nullable type.",
correctionMessage:
"Try adding either a return or a throw statement at the end.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a break in a case clause inside
// a switch statement has a label that is associated with another case clause.
//
// #### Example
//
// The following code produces this diagnostic because the label `l` is
// associated with the case clause for `0`:
//
// ```dart
// void f(int i) {
// switch (i) {
// l: case 0:
// break;
// case 1:
// break [!l!];
// }
// }
// ```
//
// #### Common fixes
//
// If the intent is to transfer control to the statement after the switch,
// then remove the label from the break statement:
//
// ```dart
// void f(int i) {
// switch (i) {
// case 0:
// break;
// case 1:
// break;
// }
// }
// ```
//
// If the intent is to transfer control to a different case block, then use
// `continue` rather than `break`:
//
// ```dart
// void f(int i) {
// switch (i) {
// l: case 0:
// break;
// case 1:
// continue l;
// }
// }
// ```
static const CompileTimeErrorCode BREAK_LABEL_ON_SWITCH_MEMBER =
CompileTimeErrorCode(
'BREAK_LABEL_ON_SWITCH_MEMBER',
"A break label resolves to the 'case' or 'default' statement.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the built-in identifier that is being used
*/
// #### Description
//
// The analyzer produces this diagnostic when the name used in the declaration
// of a class, extension, mixin, typedef, type parameter, or import prefix is
// a built-in identifier. Built-in identifiers can’t be used to name any of
// these kinds of declarations.
//
// #### Example
//
// The following code produces this diagnostic because `mixin` is a built-in
// identifier:
//
// ```dart
// extension [!mixin!] on int {}
// ```
//
// #### Common fixes
//
// Choose a different name for the declaration.
static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_EXTENSION_NAME =
CompileTimeErrorCode(
'BUILT_IN_IDENTIFIER_IN_DECLARATION',
"The built-in identifier '{0}' can't be used as an extension name.",
correctionMessage: "Try choosing a different name for the extension.",
hasPublishedDocs: true,
uniqueName: 'BUILT_IN_IDENTIFIER_AS_EXTENSION_NAME',
);
/**
* Parameters:
* 0: the built-in identifier that is being used
*/
static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_PREFIX_NAME =
CompileTimeErrorCode(
'BUILT_IN_IDENTIFIER_IN_DECLARATION',
"The built-in identifier '{0}' can't be used as a prefix name.",
correctionMessage: "Try choosing a different name for the prefix.",
hasPublishedDocs: true,
uniqueName: 'BUILT_IN_IDENTIFIER_AS_PREFIX_NAME',
);
/**
* Parameters:
* 0: the built-in identifier that is being used
*/
// #### Description
//
// The analyzer produces this diagnostic when a built-in identifier is used
// where a type name is expected.
//
// #### Example
//
// The following code produces this diagnostic because `import` can't be used
// as a type because it's a built-in identifier:
//
// ```dart
// [!import!]<int> x;
// ```
//
// #### Common fixes
//
// Replace the built-in identifier with the name of a valid type:
//
// ```dart
// List<int> x;
// ```
static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPE =
CompileTimeErrorCode(
'BUILT_IN_IDENTIFIER_AS_TYPE',
"The built-in identifier '{0}' can't be used as a type.",
correctionMessage: "Try correcting the name to match an existing type.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the built-in identifier that is being used
*/
static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME =
CompileTimeErrorCode(
'BUILT_IN_IDENTIFIER_IN_DECLARATION',
"The built-in identifier '{0}' can't be used as a typedef name.",
correctionMessage: "Try choosing a different name for the typedef.",
hasPublishedDocs: true,
uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME',
);
/**
* Parameters:
* 0: the built-in identifier that is being used
*/
static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPE_NAME =
CompileTimeErrorCode(
'BUILT_IN_IDENTIFIER_IN_DECLARATION',
"The built-in identifier '{0}' can't be used as a type name.",
correctionMessage: "Try choosing a different name for the type.",
hasPublishedDocs: true,
uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPE_NAME',
);
/**
* Parameters:
* 0: the built-in identifier that is being used
*/
static const CompileTimeErrorCode BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME =
CompileTimeErrorCode(
'BUILT_IN_IDENTIFIER_IN_DECLARATION',
"The built-in identifier '{0}' can't be used as a type parameter name.",
correctionMessage: "Try choosing a different name for the type parameter.",
hasPublishedDocs: true,
uniqueName: 'BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME',
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when the last statement in a `case`
// block isn't one of the required terminators: `break`, `continue`,
// `rethrow`, `return`, or `throw`.
//
// #### Example
//
// The following code produces this diagnostic because the `case` block ends
// with an assignment:
//
// ```dart
// %language=2.9
// void f(int x) {
// switch (x) {
// [!case!] 0:
// x += 2;
// default:
// x += 1;
// }
// }
// ```
//
// #### Common fixes
//
// Add one of the required terminators:
//
// ```dart
// %language=2.9
// void f(int x) {
// switch (x) {
// case 0:
// x += 2;
// break;
// default:
// x += 1;
// }
// }
// ```
static const CompileTimeErrorCode CASE_BLOCK_NOT_TERMINATED =
CompileTimeErrorCode(
'CASE_BLOCK_NOT_TERMINATED',
"The last statement of the 'case' should be 'break', 'continue', "
"'rethrow', 'return', or 'throw'.",
correctionMessage: "Try adding one of the required statements.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the this of the switch case expression
*/
// #### Description
//
// The analyzer produces this diagnostic when the type of the expression
// following the keyword `case` has an implementation of the `==` operator
// other than the one in `Object`.
//
// #### Example
//
// The following code produces this diagnostic because the expression
// following the keyword `case` (`C(0)`) has the type `C`, and the class `C`
// overrides the `==` operator:
//
// ```dart
// class C {
// final int value;
//
// const C(this.value);
//
// bool operator ==(Object other) {
// return false;
// }
// }
//
// void f(C c) {
// switch (c) {
// case [!C(0)!]:
// break;
// }
// }
// ```
//
// #### Common fixes
//
// If there isn't a strong reason not to do so, then rewrite the code to use
// an if-else structure:
//
// ```dart
// class C {
// final int value;
//
// const C(this.value);
//
// bool operator ==(Object other) {
// return false;
// }
// }
//
// void f(C c) {
// if (c == C(0)) {
// // ...
// }
// }
// ```
//
// If you can't rewrite the switch statement and the implementation of `==`
// isn't necessary, then remove it:
//
// ```dart
// class C {
// final int value;
//
// const C(this.value);
// }
//
// void f(C c) {
// switch (c) {
// case C(0):
// break;
// }
// }
// ```
//
// If you can't rewrite the switch statement and you can't remove the
// definition of `==`, then find some other value that can be used to control
// the switch:
//
// ```dart
// class C {
// final int value;
//
// const C(this.value);
//
// bool operator ==(Object other) {
// return false;
// }
// }
//
// void f(C c) {
// switch (c.value) {
// case 0:
// break;
// }
// }
// ```
static const CompileTimeErrorCode CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS =
CompileTimeErrorCode(
'CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS',
"The switch case expression type '{0}' can't override the '==' operator.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the type of the case expression
* 1: the type of the switch expression
*/
// #### Description
//
// The analyzer produces this diagnostic when the expression following `case`
// in a `switch` statement has a static type that isn't a subtype of the
// static type of the expression following `switch`.
//
// #### Example
//
// The following code produces this diagnostic because `1` is an `int`, which
// isn't a subtype of `String` (the type of `s`):
//
// ```dart
// void f(String s) {
// switch (s) {
// case [!1!]:
// break;
// }
// }
// ```
//
// #### Common fixes
//
// If the value of the `case` expression is wrong, then change the `case`
// expression so that it has the required type:
//
// ```dart
// void f(String s) {
// switch (s) {
// case '1':
// break;
// }
// }
// ```
//
// If the value of the `case` expression is correct, then change the `switch`
// expression to have the required type:
//
// ```dart
// void f(int s) {
// switch (s) {
// case 1:
// break;
// }
// }
// ```
static const CompileTimeErrorCode
CASE_EXPRESSION_TYPE_IS_NOT_SWITCH_EXPRESSION_SUBTYPE =
CompileTimeErrorCode(
'CASE_EXPRESSION_TYPE_IS_NOT_SWITCH_EXPRESSION_SUBTYPE',
"The switch case expression type '{0}' must be a subtype of the switch "
"expression type '{1}'.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when the name following the `as` in a
// cast expression is defined to be something other than a type.
//
// #### Example
//
// The following code produces this diagnostic because `x` is a variable, not
// a type:
//
// ```dart
// num x = 0;
// int y = x as [!x!];
// ```
//
// #### Common fixes
//
// Replace the name with the name of a type:
//
// ```dart
// num x = 0;
// int y = x as int;
// ```
static const CompileTimeErrorCode CAST_TO_NON_TYPE = CompileTimeErrorCode(
'CAST_TO_NON_TYPE',
"The name '{0}' isn't a type, so it can't be used in an 'as' expression.",
correctionMessage:
"Try changing the name to the name of an existing type, or creating a "
"type with the name '{0}'.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the member
*/
static const CompileTimeErrorCode
CLASS_INSTANTIATION_ACCESS_TO_INSTANCE_MEMBER = CompileTimeErrorCode(
'CLASS_INSTANTIATION_ACCESS_TO_MEMBER',
"The instance member '{0}' can't be accessed on a class instantiation.",
correctionMessage:
"Try changing the member name to the name of a constructor.",
uniqueName: 'CLASS_INSTANTIATION_ACCESS_TO_INSTANCE_MEMBER',
);
/**
* Parameters:
* 0: the name of the member
*/
static const CompileTimeErrorCode
CLASS_INSTANTIATION_ACCESS_TO_STATIC_MEMBER = CompileTimeErrorCode(
'CLASS_INSTANTIATION_ACCESS_TO_MEMBER',
"The static member '{0}' can't be accessed on a class instantiation.",
correctionMessage:
"Try removing the type arguments from the class name, or changing the "
"member name to the name of a constructor.",
uniqueName: 'CLASS_INSTANTIATION_ACCESS_TO_STATIC_MEMBER',
);
/**
* Parameters:
* 0: the name of the member
*/
static const CompileTimeErrorCode
CLASS_INSTANTIATION_ACCESS_TO_UNKNOWN_MEMBER = CompileTimeErrorCode(
'CLASS_INSTANTIATION_ACCESS_TO_MEMBER',
"The class '{0} doesn't have a constructor named '{1}.",
correctionMessage:
"Try invoking a different constructor, or defining a constructor named "
"'{1}'.",
uniqueName: 'CLASS_INSTANTIATION_ACCESS_TO_UNKNOWN_MEMBER',
);
static const CompileTimeErrorCode CONCRETE_CLASS_HAS_ENUM_SUPERINTERFACE =
CompileTimeErrorCode(
'CONCRETE_CLASS_HAS_ENUM_SUPERINTERFACE',
"Concrete classes can't have 'Enum' as a superinterface.",
correctionMessage:
"Try specifying a different interface, or remove it from the list.",
);
/**
* Parameters:
* 0: the name of the abstract method
* 1: the name of the enclosing class
*/
// #### Description
//
// The analyzer produces this diagnostic when a member of a concrete class is
// found that doesn't have a concrete implementation. Concrete classes aren't
// allowed to contain abstract members.
//
// #### Example
//
// The following code produces this diagnostic because `m` is an abstract
// method but `C` isn't an abstract class:
//
// ```dart
// class C {
// [!void m();!]
// }
// ```
//
// #### Common fixes
//
// If it's valid to create instances of the class, provide an implementation
// for the member:
//
// ```dart
// class C {
// void m() {}
// }
// ```
//
// If it isn't valid to create instances of the class, mark the class as being
// abstract:
//
// ```dart
// abstract class C {
// void m();
// }
// ```
static const CompileTimeErrorCode CONCRETE_CLASS_WITH_ABSTRACT_MEMBER =
CompileTimeErrorCode(
'CONCRETE_CLASS_WITH_ABSTRACT_MEMBER',
"'{0}' must have a method body because '{1}' isn't abstract.",
correctionMessage: "Try making '{1}' abstract, or adding a body to '{0}'.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the constructor and field
*/
// #### Description
//
// The analyzer produces this diagnostic when a named constructor and either a
// static method or static field have the same name. Both are accessed using
// the name of the class, so having the same name makes the reference
// ambiguous.
//
// #### Examples
//
// The following code produces this diagnostic because the static field `foo`
// and the named constructor `foo` have the same name:
//
// ```dart
// class C {
// C.[!foo!]();
// static int foo = 0;
// }
// ```
//
// The following code produces this diagnostic because the static method `foo`
// and the named constructor `foo` have the same name:
//
// ```dart
// class C {
// C.[!foo!]();
// static void foo() {}
// }
// ```
//
// #### Common fixes
//
// Rename either the member or the constructor.
static const CompileTimeErrorCode CONFLICTING_CONSTRUCTOR_AND_STATIC_FIELD =
CompileTimeErrorCode(
'CONFLICTING_CONSTRUCTOR_AND_STATIC_MEMBER',
"'{0}' can't be used to name both a constructor and a static field in this "
"class.",
correctionMessage: "Try renaming either the constructor or the field.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_CONSTRUCTOR_AND_STATIC_FIELD',
);
/**
* Parameters:
* 0: the name of the constructor and getter
*/
static const CompileTimeErrorCode CONFLICTING_CONSTRUCTOR_AND_STATIC_GETTER =
CompileTimeErrorCode(
'CONFLICTING_CONSTRUCTOR_AND_STATIC_MEMBER',
"'{0}' can't be used to name both a constructor and a static getter in "
"this class.",
correctionMessage: "Try renaming either the constructor or the getter.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_CONSTRUCTOR_AND_STATIC_GETTER',
);
/**
* Parameters:
* 0: the name of the constructor
*/
static const CompileTimeErrorCode CONFLICTING_CONSTRUCTOR_AND_STATIC_METHOD =
CompileTimeErrorCode(
'CONFLICTING_CONSTRUCTOR_AND_STATIC_MEMBER',
"'{0}' can't be used to name both a constructor and a static method in "
"this class.",
correctionMessage: "Try renaming either the constructor or the method.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_CONSTRUCTOR_AND_STATIC_METHOD',
);
/**
* Parameters:
* 0: the name of the constructor and setter
*/
static const CompileTimeErrorCode CONFLICTING_CONSTRUCTOR_AND_STATIC_SETTER =
CompileTimeErrorCode(
'CONFLICTING_CONSTRUCTOR_AND_STATIC_MEMBER',
"'{0}' can't be used to name both a constructor and a static setter in "
"this class.",
correctionMessage: "Try renaming either the constructor or the setter.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_CONSTRUCTOR_AND_STATIC_SETTER',
);
/**
* 10.11 Class Member Conflicts: Let `C` be a class. It is a compile-time
* error if `C` declares a getter or a setter with basename `n`, and has a
* method named `n`.
*
* Parameters:
* 0: the name of the class defining the conflicting field
* 1: the name of the conflicting field
* 2: the name of the class defining the method with which the field conflicts
*/
static const CompileTimeErrorCode CONFLICTING_FIELD_AND_METHOD =
CompileTimeErrorCode(
'CONFLICTING_FIELD_AND_METHOD',
"Class '{0}' can't define field '{1}' and have method '{2}.{1}' with the "
"same name.",
correctionMessage:
"Try converting the getter to a method, or renaming the field to a "
"name that doesn't conflict.",
);
/**
* Parameters:
* 0: the name of the class implementing the conflicting interface
* 1: the first conflicting type
* 2: the second conflicting type
*/
// #### Description
//
// The analyzer produces this diagnostic when a class attempts to implement a
// generic interface multiple times, and the values of the type arguments
// aren't the same.
//
// #### Example
//
// The following code produces this diagnostic because `C` is defined to
// implement both `I<int>` (because it extends `A`) and `I<String>` (because
// it implements`B`), but `int` and `String` aren't the same type:
//
// ```dart
// class I<T> {}
// class A implements I<int> {}
// class B implements I<String> {}
// class [!C!] extends A implements B {}
// ```
//
// #### Common fixes
//
// Rework the type hierarchy to avoid this situation. For example, you might
// make one or both of the inherited types generic so that `C` can specify the
// same type for both type arguments:
//
// ```dart
// class I<T> {}
// class A<S> implements I<S> {}
// class B implements I<String> {}
// class C extends A<String> implements B {}
// ```
static const CompileTimeErrorCode CONFLICTING_GENERIC_INTERFACES =
CompileTimeErrorCode(
'CONFLICTING_GENERIC_INTERFACES',
"The class '{0}' can't implement both '{1}' and '{2}' because the type "
"arguments are different.",
hasPublishedDocs: true,
);
/**
* 10.11 Class Member Conflicts: Let `C` be a class. It is a compile-time
* error if `C` declares a method named `n`, and has a getter or a setter
* with basename `n`.
*
* Parameters:
* 0: the name of the class defining the conflicting method
* 1: the name of the conflicting method
* 2: the name of the class defining the field with which the method conflicts
*/
static const CompileTimeErrorCode CONFLICTING_METHOD_AND_FIELD =
CompileTimeErrorCode(
'CONFLICTING_METHOD_AND_FIELD',
"Class '{0}' can't define method '{1}' and have field '{2}.{1}' with the "
"same name.",
correctionMessage:
"Try converting the method to a getter, or renaming the method to a "
"name that doesn't conflict.",
);
/**
* 10.11 Class Member Conflicts: Let `C` be a class. It is a compile-time
* error if `C` declares a static member with basename `n`, and has an
* instance member with basename `n`.
*
* Parameters:
* 0: the name of the class defining the conflicting member
* 1: the name of the conflicting static member
* 2: the name of the class defining the field with which the method conflicts
*/
static const CompileTimeErrorCode CONFLICTING_STATIC_AND_INSTANCE =
CompileTimeErrorCode(
'CONFLICTING_STATIC_AND_INSTANCE',
"Class '{0}' can't define static member '{1}' and have instance member "
"'{2}.{1}' with the same name.",
correctionMessage:
"Try renaming the member to a name that doesn't conflict.",
);
/**
* Parameters:
* 0: the name of the type variable
*/
// #### Description
//
// The analyzer produces this diagnostic when a class, mixin, or extension
// declaration declares a type parameter with the same name as the class,
// mixin, or extension that declares it.
//
// #### Example
//
// The following code produces this diagnostic because the type parameter `C`
// has the same name as the class `C` of which it's a part:
//
// ```dart
// class C<[!C!]> {}
// ```
//
// #### Common fixes
//
// Rename either the type parameter, or the class, mixin, or extension:
//
// ```dart
// class C<T> {}
// ```
static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_CLASS =
CompileTimeErrorCode(
'CONFLICTING_TYPE_VARIABLE_AND_CONTAINER',
"'{0}' can't be used to name both a type variable and the class in which "
"the type variable is defined.",
correctionMessage: "Try renaming either the type variable or the class.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_TYPE_VARIABLE_AND_CLASS',
);
/**
* Parameters:
* 0: the name of the type variable
*/
static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_ENUM =
CompileTimeErrorCode(
'CONFLICTING_TYPE_VARIABLE_AND_CONTAINER',
"'{0}' can't be used to name both a type variable and the enum in which "
"the type variable is defined.",
correctionMessage: "Try renaming either the type variable or the enum.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_TYPE_VARIABLE_AND_ENUM',
);
/**
* Parameters:
* 0: the name of the type variable
*/
static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_EXTENSION =
CompileTimeErrorCode(
'CONFLICTING_TYPE_VARIABLE_AND_CONTAINER',
"'{0}' can't be used to name both a type variable and the extension in "
"which the type variable is defined.",
correctionMessage:
"Try renaming either the type variable or the extension.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_TYPE_VARIABLE_AND_EXTENSION',
);
/**
* Parameters:
* 0: the name of the type variable
*/
// #### Description
//
// The analyzer produces this diagnostic when a class, mixin, or extension
// declaration declares a type parameter with the same name as one of the
// members of the class, mixin, or extension that declares it.
//
// #### Example
//
// The following code produces this diagnostic because the type parameter `T`
// has the same name as the field `T`:
//
// ```dart
// class C<[!T!]> {
// int T = 0;
// }
// ```
//
// #### Common fixes
//
// Rename either the type parameter or the member with which it conflicts:
//
// ```dart
// class C<T> {
// int total = 0;
// }
// ```
static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_MEMBER_CLASS =
CompileTimeErrorCode(
'CONFLICTING_TYPE_VARIABLE_AND_MEMBER',
"'{0}' can't be used to name both a type variable and a member in this "
"class.",
correctionMessage: "Try renaming either the type variable or the member.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_TYPE_VARIABLE_AND_MEMBER_CLASS',
);
/**
* Parameters:
* 0: the name of the type variable
*/
static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_MEMBER_ENUM =
CompileTimeErrorCode(
'CONFLICTING_TYPE_VARIABLE_AND_MEMBER',
"'{0}' can't be used to name both a type variable and a member in this "
"enum.",
correctionMessage: "Try renaming either the type variable or the member.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_TYPE_VARIABLE_AND_MEMBER_ENUM',
);
/**
* Parameters:
* 0: the name of the type variable
*/
static const CompileTimeErrorCode
CONFLICTING_TYPE_VARIABLE_AND_MEMBER_EXTENSION = CompileTimeErrorCode(
'CONFLICTING_TYPE_VARIABLE_AND_MEMBER',
"'{0}' can't be used to name both a type variable and a member in this "
"extension.",
correctionMessage: "Try renaming either the type variable or the member.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_TYPE_VARIABLE_AND_MEMBER_EXTENSION',
);
/**
* Parameters:
* 0: the name of the type variable
*/
static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_MEMBER_MIXIN =
CompileTimeErrorCode(
'CONFLICTING_TYPE_VARIABLE_AND_MEMBER',
"'{0}' can't be used to name both a type variable and a member in this "
"mixin.",
correctionMessage: "Try renaming either the type variable or the member.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_TYPE_VARIABLE_AND_MEMBER_MIXIN',
);
/**
* Parameters:
* 0: the name of the type variable
*/
static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_MIXIN =
CompileTimeErrorCode(
'CONFLICTING_TYPE_VARIABLE_AND_CONTAINER',
"'{0}' can't be used to name both a type variable and the mixin in which "
"the type variable is defined.",
correctionMessage: "Try renaming either the type variable or the mixin.",
hasPublishedDocs: true,
uniqueName: 'CONFLICTING_TYPE_VARIABLE_AND_MIXIN',
);
/**
* 16.12.2 Const: It is a compile-time error if evaluation of a constant
* object results in an uncaught exception being thrown.
*/
static const CompileTimeErrorCode CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH =
CompileTimeErrorCode(
'CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH',
"In a const constructor, a value of type '{0}' can't be assigned to the "
"field '{1}', which has type '{2}'.",
correctionMessage: "Try using a subtype, or removing the keyword 'const'.",
);
/**
* Parameters:
* 0: the type of the runtime value of the argument
* 1: the static type of the parameter
*/
// #### Description
//
// The analyzer produces this diagnostic when the runtime type of a constant
// value can't be assigned to the static type of a constant constructor's
// parameter.
//
// #### Example
//
// The following code produces this diagnostic because the runtime type of `i`
// is `int`, which can't be assigned to the static type of `s`:
//
// ```dart
// class C {
// final String s;
//
// const C(this.s);
// }
//
// const dynamic i = 0;
//
// void f() {
// const C([!i!]);
// }
// ```
//
// #### Common fixes
//
// Pass a value of the correct type to the constructor:
//
// ```dart
// class C {
// final String s;
//
// const C(this.s);
// }
//
// const dynamic i = 0;
//
// void f() {
// const C('$i');
// }
// ```
static const CompileTimeErrorCode CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH =
CompileTimeErrorCode(
'CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH',
"A value of type '{0}' can't be assigned to a parameter of type '{1}' in a "
"const constructor.",
correctionMessage: "Try using a subtype, or removing the keyword 'const'.",
hasPublishedDocs: true,
);
/**
* 16.12.2 Const: It is a compile-time error if evaluation of a constant
* object results in an uncaught exception being thrown.
*/
static const CompileTimeErrorCode CONST_CONSTRUCTOR_THROWS_EXCEPTION =
CompileTimeErrorCode(
'CONST_CONSTRUCTOR_THROWS_EXCEPTION',
"Const constructors can't throw exceptions.",
correctionMessage:
"Try removing the throw statement, or removing the keyword 'const'.",
);
/**
* Parameters:
* 0: the name of the field
*/
// #### Description
//
// The analyzer produces this diagnostic when a constructor has the keyword
// `const`, but a field in the class is initialized to a non-constant value.
//
// #### Example
//
// The following code produces this diagnostic because the field `s` is
// initialized to a non-constant value:
//
// ```dart
// class C {
// final String s = 3.toString();
// [!const!] C();
// }
// ```
//
// #### Common fixes
//
// If the field can be initialized to a constant value, then change the
// initializer to a constant expression:
//
// ```dart
// class C {
// final String s = '3';
// const C();
// }
// ```
//
// If the field can't be initialized to a constant value, then remove the
// keyword `const` from the constructor:
//
// ```dart
// class C {
// final String s = 3.toString();
// C();
// }
// ```
static const CompileTimeErrorCode
CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST =
CompileTimeErrorCode(
'CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST',
"Can't define the 'const' constructor because the field '{0}' is "
"initialized with a non-constant value.",
correctionMessage:
"Try initializing the field to a constant value, or removing the "
"keyword 'const' from the constructor.",
hasPublishedDocs: true,
);
/**
* 7.6.3 Constant Constructors: The superinitializer that appears, explicitly
* or implicitly, in the initializer list of a constant constructor must
* specify a constant constructor of the superclass of the immediately
* enclosing class or a compile-time error occurs.
*
* 12.1 Mixin Application: For each generative constructor named ... an
* implicitly declared constructor named ... is declared. If Sq is a
* generative const constructor, and M does not declare any fields, Cq is
* also a const constructor.
*
* Parameters:
* 0: the name of the instance field.
*/
static const CompileTimeErrorCode CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELD =
CompileTimeErrorCode(
'CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELD',
"This constructor can't be declared 'const' because a mixin adds the "
"instance field: {0}.",
correctionMessage:
"Try removing the 'const' keyword or removing the 'with' clause from "
"the class declaration, or removing the field from the mixin class.",
);
/**
* 7.6.3 Constant Constructors: The superinitializer that appears, explicitly
* or implicitly, in the initializer list of a constant constructor must
* specify a constant constructor of the superclass of the immediately
* enclosing class or a compile-time error occurs.
*
* 12.1 Mixin Application: For each generative constructor named ... an
* implicitly declared constructor named ... is declared. If Sq is a
* generative const constructor, and M does not declare any fields, Cq is
* also a const constructor.
*
* Parameters:
* 0: the names of the instance fields.
*/
static const CompileTimeErrorCode CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELDS =
CompileTimeErrorCode(
'CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELD',
"This constructor can't be declared 'const' because the mixins add the "
"instance fields: {0}.",
correctionMessage:
"Try removing the 'const' keyword or removing the 'with' clause from "
"the class declaration, or removing the fields from the mixin classes.",
uniqueName: 'CONST_CONSTRUCTOR_WITH_MIXIN_WITH_FIELDS',
);
/**
* Parameters:
* 0: the name of the superclass
*/
// #### Description
//
// The analyzer produces this diagnostic when a constructor that is marked as
// `const` invokes a constructor from its superclass that isn't marked as
// `const`.
//
// #### Example
//
// The following code produces this diagnostic because the `const` constructor
// in `B` invokes the constructor `nonConst` from the class `A`, and the
// superclass constructor isn't a `const` constructor:
//
// ```dart
// class A {
// const A();
// A.nonConst();
// }
//
// class B extends A {
// const B() : [!super.nonConst()!];
// }
// ```
//
// #### Common fixes
//
// If it isn't essential to invoke the superclass constructor that is
// currently being invoked, then invoke a constant constructor from the
// superclass:
//
// ```dart
// class A {
// const A();
// A.nonConst();
// }
//
// class B extends A {
// const B() : super();
// }
// ```
//
// If it's essential that the current constructor be invoked and if you can
// modify it, then add `const` to the constructor in the superclass:
//
// ```dart
// class A {
// const A();
// const A.nonConst();
// }
//
// class B extends A {
// const B() : super.nonConst();
// }
// ```
//
// If it's essential that the current constructor be invoked and you can't
// modify it, then remove `const` from the constructor in the subclass:
//
// ```dart
// class A {
// const A();
// A.nonConst();
// }
//
// class B extends A {
// B() : super.nonConst();
// }
// ```
static const CompileTimeErrorCode CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER =
CompileTimeErrorCode(
'CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER',
"A constant constructor can't call a non-constant super constructor of "
"'{0}'.",
correctionMessage:
"Try calling a constant constructor in the superclass, or removing the "
"keyword 'const' from the constructor.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a constructor is marked as a
// const constructor, but the constructor is defined in a class that has at
// least one non-final instance field (either directly or by inheritance).
//
// #### Example
//
// The following code produces this diagnostic because the field `x` isn't
// final:
//
// ```dart
// class C {
// int x;
//
// const [!C!](this.x);
// }
// ```
//
// #### Common fixes
//
// If it's possible to mark all of the fields as final, then do so:
//
// ```dart
// class C {
// final int x;
//
// const C(this.x);
// }
// ```
//
// If it isn't possible to mark all of the fields as final, then remove the
// keyword `const` from the constructor:
//
// ```dart
// class C {
// int x;
//
// C(this.x);
// }
// ```
static const CompileTimeErrorCode CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD =
CompileTimeErrorCode(
'CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD',
"Can't define a const constructor for a class with non-final fields.",
correctionMessage:
"Try making all of the fields final, or removing the keyword 'const' "
"from the constructor.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a class from a library that is
// imported using a deferred import is used to create a `const` object.
// Constants are evaluated at compile time, and classes from deferred
// libraries aren't available at compile time.
//
// For more information, see the language tour's coverage of
// [deferred loading](https://dart.dev/guides/language/language-tour#lazily-loading-a-library).
//
// #### Example
//
// The following code produces this diagnostic because it attempts to create a
// `const` instance of a class from a deferred library:
//
// ```dart
// import 'dart:convert' deferred as convert;
//
// const json2 = [!convert.JsonCodec()!];
// ```
//
// #### Common fixes
//
// If the object isn't required to be a constant, then change the code so that
// a non-constant instance is created:
//
// ```dart
// import 'dart:convert' deferred as convert;
//
// final json2 = convert.JsonCodec();
// ```
//
// If the object must be a constant, then remove `deferred` from the import
// directive:
//
// ```dart
// import 'dart:convert' as convert;
//
// const json2 = convert.JsonCodec();
// ```
static const CompileTimeErrorCode CONST_DEFERRED_CLASS = CompileTimeErrorCode(
'CONST_DEFERRED_CLASS',
"Deferred classes can't be created with 'const'.",
correctionMessage:
"Try using 'new' to create the instance, or changing the import to not "
"be deferred.",
hasPublishedDocs: true,
);
/**
* 16.12.2 Const: It is a compile-time error if evaluation of a constant
* object results in an uncaught exception being thrown.
*/
static const CompileTimeErrorCode CONST_EVAL_THROWS_EXCEPTION =
CompileTimeErrorCode(
'CONST_EVAL_THROWS_EXCEPTION',
"Evaluation of this constant expression throws an exception.",
);
/**
* 16.12.2 Const: It is a compile-time error if evaluation of a constant
* object results in an uncaught exception being thrown.
*/
static const CompileTimeErrorCode CONST_EVAL_THROWS_IDBZE =
CompileTimeErrorCode(
'CONST_EVAL_THROWS_IDBZE',
"Evaluation of this constant expression throws an "
"IntegerDivisionByZeroException.",
);
/**
* 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.
*/
static const CompileTimeErrorCode CONST_EVAL_TYPE_BOOL = CompileTimeErrorCode(
'CONST_EVAL_TYPE_BOOL',
"In constant expressions, operands of this operator must be of type "
"'bool'.",
);
/**
* 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.
*/
static const CompileTimeErrorCode CONST_EVAL_TYPE_BOOL_INT =
CompileTimeErrorCode(
'CONST_EVAL_TYPE_BOOL_INT',
"In constant expressions, operands of this operator must be of type 'bool' "
"or 'int'.",
);
/**
* 16.12.2 Const: An expression of one of the forms e1 == e2 or e1 != e2 where
* e1 and e2 are constant expressions that evaluate to a numeric, string or
* boolean value or to null.
*/
static const CompileTimeErrorCode CONST_EVAL_TYPE_BOOL_NUM_STRING =
CompileTimeErrorCode(
'CONST_EVAL_TYPE_BOOL_NUM_STRING',
"In constant expressions, operands of this operator must be of type "
"'bool', 'num', 'String' or 'null'.",
);
/**
* 16.12.2 Const: An expression of one of the forms ~e, e1 ^ e2, e1 & e2,
* e1 | e2, e1 >> e2 or e1 << e2, where e, e1 and e2 are constant expressions
* that evaluate to an integer value or to null.
*/
static const CompileTimeErrorCode CONST_EVAL_TYPE_INT = CompileTimeErrorCode(
'CONST_EVAL_TYPE_INT',
"In constant expressions, operands of this operator must be of type 'int'.",
);
/**
* 16.12.2 Const: An expression of one of the forms e, e1 + e2, e1 - e2, e1
* e2, e1 / e2, e1 ~/ e2, e1 > e2, e1 < e2, e1 >= e2, e1 <= e2 or e1 % e2,
* where e, e1 and e2 are constant expressions that evaluate to a numeric
* value or to null.
*/
static const CompileTimeErrorCode CONST_EVAL_TYPE_NUM = CompileTimeErrorCode(
'CONST_EVAL_TYPE_NUM',
"In constant expressions, operands of this operator must be of type 'num'.",
);
static const CompileTimeErrorCode CONST_EVAL_TYPE_TYPE = CompileTimeErrorCode(
'CONST_EVAL_TYPE_TYPE',
"In constant expressions, operands of this operator must be of type "
"'Type'.",
);
/**
* Parameters:
* 0: the name of the type of the initializer expression
* 1: the name of the type of the field
*/
static const CompileTimeErrorCode CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE =
CompileTimeErrorCode(
'FIELD_INITIALIZER_NOT_ASSIGNABLE',
"The initializer type '{0}' can't be assigned to the field type '{1}' in a "
"const constructor.",
correctionMessage: "Try using a subtype, or removing the 'const' keyword",
hasPublishedDocs: true,
uniqueName: 'CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE',
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a value that isn't statically
// known to be a constant is assigned to a variable that's declared to be a
// `const` variable.
//
// #### Example
//
// The following code produces this diagnostic because `x` isn't declared to
// be `const`:
//
// ```dart
// var x = 0;
// const y = [!x!];
// ```
//
// #### Common fixes
//
// If the value being assigned can be declared to be `const`, then change the
// declaration:
//
// ```dart
// const x = 0;
// const y = x;
// ```
//
// If the value can't be declared to be `const`, then remove the `const`
// modifier from the variable, possibly using `final` in its place:
//
// ```dart
// var x = 0;
// final y = x;
// ```
static const CompileTimeErrorCode CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE =
CompileTimeErrorCode(
'CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE',
"Const variables must be initialized with a constant value.",
correctionMessage:
"Try changing the initializer to be a constant expression.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a `const` variable is
// initialized using a `const` variable from a library that is imported using
// a deferred import. Constants are evaluated at compile time, and values from
// deferred libraries aren't available at compile time.
//
// For more information, see the language tour's coverage of
// [deferred loading](https://dart.dev/guides/language/language-tour#lazily-loading-a-library).
//
// #### Example
//
// The following code produces this diagnostic because the variable `pi` is
// being initialized using the constant `math.pi` from the library
// `dart:math`, and `dart:math` is imported as a deferred library:
//
// ```dart
// import 'dart:math' deferred as math;
//
// const pi = [!math.pi!];
// ```
//
// #### Common fixes
//
// If you need to reference the value of the constant from the imported
// library, then remove the keyword `deferred`:
//
// ```dart
// import 'dart:math' as math;
//
// const pi = math.pi;
// ```
//
// If you don't need to reference the imported constant, then remove the
// reference:
//
// ```dart
// const pi = 3.14;
// ```
static const CompileTimeErrorCode
CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY =
CompileTimeErrorCode(
'CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY',
"Constant values from a deferred library can't be used to initialize a "
"'const' variable.",
correctionMessage:
"Try initializing the variable without referencing members of the "
"deferred library, or changing the import to not be deferred.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when an instance field is marked as
// being const.
//
// #### Example
//
// The following code produces this diagnostic because `f` is an instance
// field:
//
// ```dart
// class C {
// [!const!] int f = 3;
// }
// ```
//
// #### Common fixes
//
// If the field needs to be an instance field, then remove the keyword
// `const`, or replace it with `final`:
//
// ```dart
// class C {
// final int f = 3;
// }
// ```
//
// If the field really should be a const field, then make it a static field:
//
// ```dart
// class C {
// static const int f = 3;
// }
// ```
static const CompileTimeErrorCode CONST_INSTANCE_FIELD = CompileTimeErrorCode(
'CONST_INSTANCE_FIELD',
"Only static fields can be declared as const.",
correctionMessage:
"Try declaring the field as final, or adding the keyword 'static'.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the type of the entry's key
*/
// #### Description
//
// The analyzer produces this diagnostic when the class of object used as a
// key in a constant map literal implements the `==` operator. The
// implementation of constant maps uses the `==` operator, so any
// implementation other than the one inherited from `Object` requires
// executing arbitrary code at compile time, which isn't supported.
//
// #### Example
//
// The following code produces this diagnostic because the constant map
// contains a key whose type is `C`, and the class `C` overrides the
// implementation of `==`:
//
// ```dart
// class C {
// const C();
//
// bool operator ==(Object other) => true;
// }
//
// const map = {[!C()!] : 0};
// ```
//
// #### Common fixes
//
// If you can remove the implementation of `==` from the class, then do so:
//
// ```dart
// class C {
// const C();
// }
//
// const map = {C() : 0};
// ```
//
// If you can't remove the implementation of `==` from the class, then make
// the map be non-constant:
//
// ```dart
// class C {
// const C();
//
// bool operator ==(Object other) => true;
// }
//
// final map = {C() : 0};
// ```
static const CompileTimeErrorCode
CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS = CompileTimeErrorCode(
'CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS',
"The type of a key in a constant map can't override the '==' operator, but "
"the class '{0}' does.",
correctionMessage:
"Try using a different value for the key, or removing the keyword "
"'const' from the map.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the uninitialized final variable
*/
// #### Description
//
// The analyzer produces this diagnostic when a variable that is declared to
// be a constant doesn't have an initializer.
//
// #### Example
//
// The following code produces this diagnostic because `c` isn't initialized:
//
// ```dart
// const [!c!];
// ```
//
// #### Common fixes
//
// Add an initializer:
//
// ```dart
// const c = 'c';
// ```
static const CompileTimeErrorCode CONST_NOT_INITIALIZED =
CompileTimeErrorCode(
'CONST_NOT_INITIALIZED',
"The constant '{0}' must be initialized.",
correctionMessage: "Try adding an initialization to the declaration.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the type of the element
*/
// #### Description
//
// The analyzer produces this diagnostic when the class of object used as an
// element in a constant set literal implements the `==` operator. The
// implementation of constant sets uses the `==` operator, so any
// implementation other than the one inherited from `Object` requires
// executing arbitrary code at compile time, which isn't supported.
//
// #### Example
//
// The following code produces this diagnostic because the constant set
// contains an element whose type is `C`, and the class `C` overrides the
// implementation of `==`:
//
// ```dart
// class C {
// const C();
//
// bool operator ==(Object other) => true;
// }
//
// const set = {[!C()!]};
// ```
//
// #### Common fixes
//
// If you can remove the implementation of `==` from the class, then do so:
//
// ```dart
// class C {
// const C();
// }
//
// const set = {C()};
// ```
//
// If you can't remove the implementation of `==` from the class, then make
// the set be non-constant:
//
// ```dart
// class C {
// const C();
//
// bool operator ==(Object other) => true;
// }
//
// final set = {C()};
// ```
static const CompileTimeErrorCode CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS =
CompileTimeErrorCode(
'CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS',
"The type of an element in a constant set can't override the '==' "
"operator, but the type '{0}' does.",
correctionMessage:
"Try using a different value for the element, or removing the keyword "
"'const' from the set.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when the expression of a spread
// operator in a constant list or set evaluates to something other than a list
// or a set.
//
// #### Example
//
// The following code produces this diagnostic because the value of `list1` is
// `null`, which is neither a list nor a set:
//
// ```dart
// %language=2.9
// const List<int> list1 = null;
// const List<int> list2 = [...[!list1!]];
// ```
//
// #### Common fixes
//
// Change the expression to something that evaluates to either a constant list
// or a constant set:
//
// ```dart
// %language=2.9
// const List<int> list1 = [];
// const List<int> list2 = [...list1];
// ```
static const CompileTimeErrorCode CONST_SPREAD_EXPECTED_LIST_OR_SET =
CompileTimeErrorCode(
'CONST_SPREAD_EXPECTED_LIST_OR_SET',
"A list or a set is expected in this spread.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when the expression of a spread
// operator in a constant map evaluates to something other than a map.
//
// #### Example
//
// The following code produces this diagnostic because the value of `map1` is
// `null`, which isn't a map:
//
// ```dart
// %language=2.9
// const Map<String, int> map1 = null;
// const Map<String, int> map2 = {...[!map1!]};
// ```
//
// #### Common fixes
//
// Change the expression to something that evaluates to a constant map:
//
// ```dart
// %language=2.9
// const Map<String, int> map1 = {};
// const Map<String, int> map2 = {...map1};
// ```
static const CompileTimeErrorCode CONST_SPREAD_EXPECTED_MAP =
CompileTimeErrorCode(
'CONST_SPREAD_EXPECTED_MAP',
"A map is expected in this spread.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when the keyword `const` is used to
// invoke a constructor that isn't marked with `const`.
//
// #### Example
//
// The following code produces this diagnostic because the constructor in `A`
// isn't a const constructor:
//
// ```dart
// class A {
// A();
// }
//
// A f() => [!const!] A();
// ```
//
// #### Common fixes
//
// If it's desirable and possible to make the class a constant class (by
// making all of the fields of the class, including inherited fields, final),
// then add the keyword `const` to the constructor:
//
// ```dart
// class A {
// const A();
// }
//
// A f() => const A();
// ```
//
// Otherwise, remove the keyword `const`:
//
// ```dart
// class A {
// A();
// }
//
// A f() => A();
// ```
static const CompileTimeErrorCode CONST_WITH_NON_CONST = CompileTimeErrorCode(
'CONST_WITH_NON_CONST',
"The constructor being called isn't a const constructor.",
correctionMessage: "Try removing 'const' from the constructor invocation.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a const constructor is invoked
// with an argument that isn't a constant expression.
//
// #### Example
//
// The following code produces this diagnostic because `i` isn't a constant:
//
// ```dart
// class C {
// final int i;
// const C(this.i);
// }
// C f(int i) => const C([!i!]);
// ```
//
// #### Common fixes
//
// Either make all of the arguments constant expressions, or remove the
// `const` keyword to use the non-constant form of the constructor:
//
// ```dart
// class C {
// final int i;
// const C(this.i);
// }
// C f(int i) => C(i);
// ```
static const CompileTimeErrorCode CONST_WITH_NON_CONSTANT_ARGUMENT =
CompileTimeErrorCode(
'CONST_WITH_NON_CONSTANT_ARGUMENT',
"Arguments of a constant creation must be constant expressions.",
correctionMessage:
"Try making the argument a valid constant, or use 'new' to call the "
"constructor.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the non-type element
*/
static const CompileTimeErrorCode CONST_WITH_NON_TYPE = CompileTimeErrorCode(
'CREATION_WITH_NON_TYPE',
"The name '{0}' isn't a class.",
correctionMessage: "Try correcting the name to match an existing class.",
hasPublishedDocs: true,
isUnresolvedIdentifier: true,
uniqueName: 'CONST_WITH_NON_TYPE',
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a type parameter is used as a
// type argument in a `const` invocation of a constructor. This isn't allowed
// because the value of the type parameter (the actual type that will be used
// at runtime) can't be known at compile time.
//
// #### Example
//
// The following code produces this diagnostic because the type parameter `T`
// is being used as a type argument when creating a constant:
//
// ```dart
// class C<T> {
// const C();
// }
//
// C<T> newC<T>() => const C<[!T!]>();
// ```
//
// #### Common fixes
//
// If the type that will be used for the type parameter can be known at
// compile time, then remove the use of the type parameter:
//
// ```dart
// class C<T> {
// const C();
// }
//
// C<int> newC() => const C<int>();
// ```
//
// If the type that will be used for the type parameter can't be known until
// runtime, then remove the keyword `const`:
//
// ```dart
// class C<T> {
// const C();
// }
//
// C<T> newC<T>() => C<T>();
// ```
static const CompileTimeErrorCode CONST_WITH_TYPE_PARAMETERS =
CompileTimeErrorCode(
'CONST_WITH_TYPE_PARAMETERS',
"A constant creation can't use a type parameter as a type argument.",
correctionMessage:
"Try replacing the type parameter with a different type.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
static const CompileTimeErrorCode
CONST_WITH_TYPE_PARAMETERS_CONSTRUCTOR_TEAROFF = CompileTimeErrorCode(
'CONST_WITH_TYPE_PARAMETERS',
"A constant constructor tearoff can't use a type parameter as a type "
"argument.",
correctionMessage:
"Try replacing the type parameter with a different type.",
hasPublishedDocs: true,
uniqueName: 'CONST_WITH_TYPE_PARAMETERS_CONSTRUCTOR_TEAROFF',
);
/**
* No parameters.
*/
static const CompileTimeErrorCode
CONST_WITH_TYPE_PARAMETERS_FUNCTION_TEAROFF = CompileTimeErrorCode(
'CONST_WITH_TYPE_PARAMETERS',
"A constant function tearoff can't use a type parameter as a type "
"argument.",
correctionMessage:
"Try replacing the type parameter with a different type.",
hasPublishedDocs: true,
uniqueName: 'CONST_WITH_TYPE_PARAMETERS_FUNCTION_TEAROFF',
);
/**
* 16.12.2 Const: It is a compile-time error if <i>T.id</i> is not the name of
* a constant constructor declared by the type <i>T</i>.
*
* Parameters:
* 0: the name of the type
* 1: the name of the requested constant constructor
*/
static const CompileTimeErrorCode CONST_WITH_UNDEFINED_CONSTRUCTOR =
CompileTimeErrorCode(
'CONST_WITH_UNDEFINED_CONSTRUCTOR',
"The class '{0}' doesn't have a constant constructor '{1}'.",
correctionMessage: "Try calling a different constructor.",
);
/**
* 16.12.2 Const: It is a compile-time error if <i>T.id</i> is not the name of
* a constant constructor declared by the type <i>T</i>.
*
* Parameters:
* 0: the name of the type
*/
static const CompileTimeErrorCode CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT =
CompileTimeErrorCode(
'CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT',
"The class '{0}' doesn't have an unnamed constant constructor.",
correctionMessage: "Try calling a different constructor.",
);
static const CompileTimeErrorCode CONTINUE_LABEL_ON_SWITCH =
CompileTimeErrorCode(
'CONTINUE_LABEL_ON_SWITCH',
"A continue label resolves to switch, must be loop or switch member",
);
/**
* Parameters:
* 0: the name of the type parameter
* 1: detail text explaining why the type could not be inferred
*/
static const CompileTimeErrorCode COULD_NOT_INFER = CompileTimeErrorCode(
'COULD_NOT_INFER',
"Couldn't infer type parameter '{0}'.{1}",
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when it finds a use of the default
// constructor for the class `List` in code that has opted in to null safety.
//
// #### Example
//
// Assuming the following code is opted in to null safety, it produces this
// diagnostic because it uses the default `List` constructor:
//
// ```dart
// var l = [!List<int>!]();
// ```
//
// #### Common fixes
//
// If no initial size is provided, then convert the code to use a list
// literal:
//
// ```dart
// var l = <int>[];
// ```
//
// If an initial size needs to be provided and there is a single reasonable
// initial value for the elements, then use `List.filled`:
//
// ```dart
// var l = List.filled(3, 0);
// ```
//
// If an initial size needs to be provided but each element needs to be
// computed, then use `List.generate`:
//
// ```dart
// var l = List.generate(3, (i) => i);
// ```
static const CompileTimeErrorCode DEFAULT_LIST_CONSTRUCTOR =
CompileTimeErrorCode(
'DEFAULT_LIST_CONSTRUCTOR',
"The default 'List' constructor isn't available when null safety is "
"enabled.",
correctionMessage:
"Try using a list literal, 'List.filled' or 'List.generate'.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a factory constructor that
// redirects to another constructor specifies a default value for an optional
// parameter.
//
// #### Example
//
// The following code produces this diagnostic because the factory constructor
// in `A` has a default value for the optional parameter `x`:
//
// ```dart
// class A {
// factory A([int [!x!] = 0]) = B;
// }
//
// class B implements A {
// B([int x = 1]) {}
// }
// ```
//
// #### Common fixes
//
// Remove the default value from the factory constructor:
//
// ```dart
// class A {
// factory A([int x]) = B;
// }
//
// class B implements A {
// B([int x = 1]) {}
// }
// ```
//
// Note that this fix might change the value used when the optional parameter
// is omitted. If that happens, and if that change is a problem, then consider
// making the optional parameter a required parameter in the factory method:
//
// ```dart
// class A {
// factory A(int x) = B;
// }
//
// class B implements A {
// B([int x = 1]) {}
// }
// ```
static const CompileTimeErrorCode
DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR = CompileTimeErrorCode(
'DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR',
"Default values aren't allowed in factory constructors that redirect to "
"another constructor.",
correctionMessage: "Try removing the default value.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a named parameter has both the
// `required` modifier and a default value. If the parameter is required, then
// a value for the parameter is always provided at the call sites, so the
// default value can never be used.
//
// #### Example
//
// The following code generates this diagnostic:
//
// ```dart
// void log({required String [!message!] = 'no message'}) {}
// ```
//
// #### Common fixes
//
// If the parameter is really required, then remove the default value:
//
// ```dart
// void log({required String message}) {}
// ```
//
// If the parameter isn't always required, then remove the `required`
// modifier:
//
// ```dart
// void log({String message = 'no message'}) {}
// ```
static const CompileTimeErrorCode DEFAULT_VALUE_ON_REQUIRED_PARAMETER =
CompileTimeErrorCode(
'DEFAULT_VALUE_ON_REQUIRED_PARAMETER',
"Required named parameters can't have a default value.",
correctionMessage:
"Try removing either the default value or the 'required' modifier.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a library that is imported using
// a deferred import declares an extension that is visible in the importing
// library. Extension methods are resolved at compile time, and extensions
// from deferred libraries aren't available at compile time.
//
// For more information, see the language tour's coverage of
// [deferred loading](https://dart.dev/guides/language/language-tour#lazily-loading-a-library).
//
// #### Example
//
// Given a file (`a.dart`) that defines a named extension:
//
// ```dart
// %uri="lib/a.dart"
// class C {}
//
// extension E on String {
// int get size => length;
// }
// ```
//
// The following code produces this diagnostic because the named extension is
// visible to the library:
//
// ```dart
// import [!'a.dart'!] deferred as a;
//
// void f() {
// a.C();
// }
// ```
//
// #### Common fixes
//
// If the library must be imported as `deferred`, then either add a `show`
// clause listing the names being referenced or add a `hide` clause listing
// all of the named extensions. Adding a `show` clause would look like this:
//
// ```dart
// import 'a.dart' deferred as a show C;
//
// void f() {
// a.C();
// }
// ```
//
// Adding a `hide` clause would look like this:
//
// ```dart
// import 'a.dart' deferred as a hide E;
//
// void f() {
// a.C();
// }
// ```
//
// With the first fix, the benefit is that if new extensions are added to the
// imported library, then the extensions won't cause a diagnostic to be
// generated.
//
// If the library doesn't need to be imported as `deferred`, or if you need to
// make use of the extension method declared in it, then remove the keyword
// `deferred`:
//
// ```dart
// import 'a.dart' as a;
//
// void f() {
// a.C();
// }
// ```
static const CompileTimeErrorCode DEFERRED_IMPORT_OF_EXTENSION =
CompileTimeErrorCode(
'DEFERRED_IMPORT_OF_EXTENSION',
"Imports of deferred libraries must hide all extensions.",
correctionMessage:
"Try adding either a show combinator listing the names you need to "
"reference or a hide combinator listing all of the extensions.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the variable that is invalid
*/
// #### Description
//
// The analyzer produces this diagnostic when [definite assignment][] analysis
// shows that a local variable that's marked as `late` is read before being
// assigned.
//
// #### Example
//
// The following code produces this diagnostic because `x` wasn't assigned a
// value before being read:
//
// ```dart
// void f(bool b) {
// late int x;
// print([!x!]);
// }
// ```
//
// #### Common fixes
//
// Assign a value to the variable before reading from it:
//
// ```dart
// void f(bool b) {
// late int x;
// x = b ? 1 : 0;
// print(x);
// }
// ```
static const CompileTimeErrorCode DEFINITELY_UNASSIGNED_LATE_LOCAL_VARIABLE =
CompileTimeErrorCode(
'DEFINITELY_UNASSIGNED_LATE_LOCAL_VARIABLE',
"The late local variable '{0}' is definitely unassigned at this point.",
correctionMessage:
"Ensure that it is assigned on necessary execution paths.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
static const CompileTimeErrorCode DISALLOWED_TYPE_INSTANTIATION_EXPRESSION =
CompileTimeErrorCode(
'DISALLOWED_TYPE_INSTANTIATION_EXPRESSION',
"Only a generic type, generic function, generic instance method, or "
"generic constructor can be type instantiated.",
correctionMessage:
"Try instantiating the type(s) of a generic type, generic function, "
"generic instance method, or generic constructor.",
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a class declares more than one
// unnamed constructor or when it declares more than one constructor with the
// same name.
//
// #### Examples
//
// The following code produces this diagnostic because there are two
// declarations for the unnamed constructor:
//
// ```dart
// class C {
// C();
//
// [!C!]();
// }
// ```
//
// The following code produces this diagnostic because there are two
// declarations for the constructor named `m`:
//
// ```dart
// class C {
// C.m();
//
// [!C.m!]();
// }
// ```
//
// #### Common fixes
//
// If there are multiple unnamed constructors and all of the constructors are
// needed, then give all of them, or all except one of them, a name:
//
// ```dart
// class C {
// C();
//
// C.n();
// }
// ```
//
// If there are multiple unnamed constructors and all except one of them are
// unneeded, then remove the constructors that aren't needed:
//
// ```dart
// class C {
// C();
// }
// ```
//
// If there are multiple named constructors and all of the constructors are
// needed, then rename all except one of them:
//
// ```dart
// class C {
// C.m();
//
// C.n();
// }
// ```
//
// If there are multiple named constructors and all except one of them are
// unneeded, then remove the constructorsthat aren't needed:
//
// ```dart
// class C {
// C.m();
// }
// ```
static const CompileTimeErrorCode DUPLICATE_CONSTRUCTOR_DEFAULT =
CompileTimeErrorCode(
'DUPLICATE_CONSTRUCTOR',
"The unnamed constructor is already defined.",
correctionMessage: "Try giving one of the constructors a name.",
hasPublishedDocs: true,
uniqueName: 'DUPLICATE_CONSTRUCTOR_DEFAULT',
);
/**
* Parameters:
* 0: the name of the duplicate entity
*/
static const CompileTimeErrorCode DUPLICATE_CONSTRUCTOR_NAME =
CompileTimeErrorCode(
'DUPLICATE_CONSTRUCTOR',
"The constructor with name '{0}' is already defined.",
correctionMessage: "Try renaming one of the constructors.",
hasPublishedDocs: true,
uniqueName: 'DUPLICATE_CONSTRUCTOR_NAME',
);
/**
* Parameters:
* 0: the name of the duplicate entity
*/
// #### Description
//
// The analyzer produces this diagnostic when a name is declared, and there is
// a previous declaration with the same name in the same scope.
//
// #### Example
//
// The following code produces this diagnostic because the name `x` is
// declared twice:
//
// ```dart
// int x = 0;
// int [!x!] = 1;
// ```
//
// #### Common fixes
//
// Choose a different name for one of the declarations.
//
// ```dart
// int x = 0;
// int y = 1;
// ```
static const CompileTimeErrorCode DUPLICATE_DEFINITION = CompileTimeErrorCode(
'DUPLICATE_DEFINITION',
"The name '{0}' is already defined.",
correctionMessage: "Try renaming one of the declarations.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the field
*/
// #### Description
//
// The analyzer produces this diagnostic when there's more than one
// initializing formal parameter for the same field in a constructor's
// parameter list. It isn't useful to assign a value that will immediately be
// overwritten.
//
// #### Example
//
// The following code produces this diagnostic because `this.f` appears twice
// in the parameter list:
//
// ```dart
// class C {
// int f;
//
// C(this.f, this.[!f!]) {}
// }
// ```
//
// #### Common fixes
//
// Remove one of the initializing formal parameters:
//
// ```dart
// class C {
// int f;
//
// C(this.f) {}
// }
// ```
static const CompileTimeErrorCode DUPLICATE_FIELD_FORMAL_PARAMETER =
CompileTimeErrorCode(
'DUPLICATE_FIELD_FORMAL_PARAMETER',
"The field '{0}' can't be initialized by multiple parameters in the same "
"constructor.",
correctionMessage:
"Try removing one of the parameters, or using different fields.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the name of the parameter that was duplicated
*/
// #### Description
//
// The analyzer produces this diagnostic when an invocation has two or more
// named arguments that have the same name.
//
// #### Example
//
// The following code produces this diagnostic because there are two arguments
// with the name `a`:
//
// ```dart
// %language=2.9
// void f(C c) {
// c.m(a: 0, [!a!]: 1);
// }
//
// class C {
// void m({int a, int b}) {}
// }
// ```
//
// #### Common fixes
//
// If one of the arguments should have a different name, then change the name:
//
// ```dart
// %language=2.9
// void f(C c) {
// c.m(a: 0, b: 1);
// }
//
// class C {
// void m({int a, int b}) {}
// }
// ```
//
// If one of the arguments is wrong, then remove it:
//
// ```dart
// %language=2.9
// void f(C c) {
// c.m(a: 1);
// }
//
// class C {
// void m({int a, int b}) {}
// }
// ```
static const CompileTimeErrorCode DUPLICATE_NAMED_ARGUMENT =
CompileTimeErrorCode(
'DUPLICATE_NAMED_ARGUMENT',
"The argument for the named parameter '{0}' was already specified.",
correctionMessage:
"Try removing one of the named arguments, or correcting one of the "
"names to reference a different named parameter.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the URI of the duplicate part
*/
// #### Description
//
// The analyzer produces this diagnostic when a single file is referenced in
// multiple part directives.
//
// #### Example
//
// Given a file named `part.dart` containing
//
// ```dart
// %uri="lib/part.dart"
// part of lib;
// ```
//
// The following code produces this diagnostic because the file `part.dart` is
// included multiple times:
//
// ```dart
// library lib;
//
// part 'part.dart';
// part [!'part.dart'!];
// ```
//
// #### Common fixes
//
// Remove all except the first of the duplicated part directives:
//
// ```dart
// library lib;
//
// part 'part.dart';
// ```
static const CompileTimeErrorCode DUPLICATE_PART = CompileTimeErrorCode(
'DUPLICATE_PART',
"The library already contains a part with the URI '{0}'.",
correctionMessage:
"Try removing all except one of the duplicated part directives.",
hasPublishedDocs: true,
);
static const CompileTimeErrorCode ENUM_CONSTANT_SAME_NAME_AS_ENCLOSING =
CompileTimeErrorCode(
'ENUM_CONSTANT_SAME_NAME_AS_ENCLOSING',
"The name of the enum constant can't be the same as the enum's name.",
correctionMessage: "Try renaming the constant.",
);
static const CompileTimeErrorCode ENUM_CONSTANT_WITH_NON_CONST_CONSTRUCTOR =
CompileTimeErrorCode(
'ENUM_CONSTANT_WITH_NON_CONST_CONSTRUCTOR',
"The invoked constructor isn't a const constructor.",
correctionMessage: "Try invoking a const generative constructor.",
);
static const CompileTimeErrorCode
ENUM_INSTANTIATED_TO_BOUNDS_IS_NOT_WELL_BOUNDED = CompileTimeErrorCode(
'ENUM_INSTANTIATED_TO_BOUNDS_IS_NOT_WELL_BOUNDED',
"The result of instantiating the enum to bounds is not well-bounded.",
correctionMessage: "Try using different bounds for type parameters.",
);
static const CompileTimeErrorCode ENUM_MIXIN_WITH_INSTANCE_VARIABLE =
CompileTimeErrorCode(
'ENUM_MIXIN_WITH_INSTANCE_VARIABLE',
"Mixins applied to enums can't have instance variables.",
correctionMessage: "Try replacing the instance variables with getters.",
);
/**
* Parameters:
* 0: the name of the abstract method
* 1: the name of the enclosing enum
*/
static const CompileTimeErrorCode ENUM_WITH_ABSTRACT_MEMBER =
CompileTimeErrorCode(
'ENUM_WITH_ABSTRACT_MEMBER',
"'{0}' must have a method body because '{1}' is an enum.",
correctionMessage: "Try adding a body to '{0}'.",
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when two elements in a constant set
// literal have the same value. The set can only contain each value once,
// which means that one of the values is unnecessary.
//
// #### Example
//
// The following code produces this diagnostic because the string `'a'` is
// specified twice:
//
// ```dart
// const Set<String> set = {'a', [!'a'!]};
// ```
//
// #### Common fixes
//
// Remove one of the duplicate values:
//
// ```dart
// const Set<String> set = {'a'};
// ```
//
// Note that literal sets preserve the order of their elements, so the choice
// of which element to remove might affect the order in which elements are
// returned by an iterator.
static const CompileTimeErrorCode EQUAL_ELEMENTS_IN_CONST_SET =
CompileTimeErrorCode(
'EQUAL_ELEMENTS_IN_CONST_SET',
"Two elements in a constant set literal can't be equal.",
correctionMessage: "Change or remove the duplicate element.",
hasPublishedDocs: true,
);
/**
* No parameters.
*/
// #### Description
//
// The analyzer produces this diagnostic when a key in a constant map is the
// same as a previous key in the same map. If two keys are the same, then the
// second value would overwrite the first value, which makes having both pairs
// pointless.
//
// #### Example
//
// The following code produces this diagnostic because the key `1` is used
// twice:
//
// ```dart
// const map = <int, String>{1: 'a', 2: 'b', [!1!]: 'c', 4: 'd'};
// ```
//
// #### Common fixes
//
// If both entries should be included in the map, then change one of the keys
// to be different:
//
// ```dart
// const map = <int, String>{1: 'a', 2: 'b', 3: 'c', 4: 'd'};
// ```
//
// If only one of the entries is needed, then remove the one that isn't
// needed:
//
// ```dart
// const map = <int, String>{1: 'a', 2: 'b', 4: 'd'};
// ```
//
// Note that literal maps preserve the order of their entries, so the choice
// of which entry to remove might affect the order in which keys and values
// are returned by an iterator.
static const CompileTimeErrorCode EQUAL_KEYS_IN_CONST_MAP =
CompileTimeErrorCode(
'EQUAL_KEYS_IN_CONST_MAP',
"Two keys in a constant map literal can't be equal.",
correctionMessage: "Change or remove the duplicate key.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the number of provided type arguments
*/
// #### Description
//
// The analyzer produces this diagnostic when a list literal has more than one
// type argument.
//
// #### Example
//
// The following code produces this diagnostic because the list literal has
// two type arguments when it can have at most one:
//
// ```dart
// var l = [!<int, int>!][];
// ```
//
// #### Common fixes
//
// Remove all except one of the type arguments:
//
// ```dart
// var l = <int>[];
// ```
static const CompileTimeErrorCode EXPECTED_ONE_LIST_TYPE_ARGUMENTS =
CompileTimeErrorCode(
'EXPECTED_ONE_LIST_TYPE_ARGUMENTS',
"List literals require one type argument or none, but {0} found.",
correctionMessage: "Try adjusting the number of type arguments.",
hasPublishedDocs: true,
);
/**
* Parameters:
* 0: the number of provided type arguments
*/
// #### Description
//
// The analyzer produces this diagnostic when a set literal has more than one
// type argument.
//
// #### Example
//
// The following code produces this diagnostic because the set literal has
// three type arguments when it can have at most one:
//
// ```dart
// var s = [!<int, String, int>!]{0, 'a', 1};
// ```
//
// #### Common fixes
//
// Remove all except one of the type arguments:
//
// ```dart
// var s = <int>{0, 1};
// ```
static const CompileTimeErrorCode EXPECTED_ONE_SET_TYPE_ARGUMENTS =
CompileTimeErrorCode(
'EXPECTED_ONE_SET_TYPE_ARGUMENTS',
"Set literals require one type argument or none, but {0} were found.",
correctionMessage: "Try adjusting the number of type arguments.",