Version 2.13.0-173.0.dev
Merge commit '7f54fc96e5e73cf07c95a6273f32b08b277bb781' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
index ee8b5c1..c50558f 100644
--- a/pkg/analyzer/lib/src/dart/error/hint_codes.dart
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
@@ -19,6 +19,58 @@
* 0: the name of the actual argument type
* 1: the name of the expected function return type
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an invocation of
+ // `Future.catchError` has an argument that is a function whose parameters
+ // aren't compatible with the arguments that will be passed to the function
+ // when it's invoked. The static type of the first argument to `catchError`
+ // is just `Function`, even though the function that is passed in is expected
+ // to have either a single parameter of type `Object` or two parameters of
+ // type `Object` and `StackTrace`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the closure being
+ // passed to `catchError` doesn't take any parameters, but the function is
+ // required to take at least one parameter:
+ //
+ // ```dart
+ // void f(Future<int> f) {
+ // f.catchError([!() => 0!]);
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the closure being
+ // passed to `catchError` takes three parameters, but it can't have more than
+ // two required parameters:
+ //
+ // ```dart
+ // void f(Future<int> f) {
+ // f.catchError([!(one, two, three) => 0!]);
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because even though the closure
+ // being passed to `catchError` takes one parameter, the closure doesn't have
+ // a type that is compatible with `Object`:
+ //
+ // ```dart
+ // void f(Future<int> f) {
+ // f.catchError([!(String error) => 0!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the function being passed to `catchError` so that it has either one
+ // or two required parameters, and the parameters have the required types:
+ //
+ // ```dart
+ // void f(Future<int> f) {
+ // f.catchError((Object error) => 0);
+ // }
+ // ```
static const HintCode ARGUMENT_TYPE_NOT_ASSIGNABLE_TO_ERROR_HANDLER =
HintCode(
'ARGUMENT_TYPE_NOT_ASSIGNABLE_TO_ERROR_HANDLER',
@@ -1764,6 +1816,55 @@
* 0: the return type as declared in the return statement
* 1: the expected return type as defined by the type of the Future
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an invocation of
+ // `Future.catchError` has an argument whose return type isn't compatible with
+ // the type returned by the instance of `Future`. At runtime, the method
+ // `catchError` attempts to return the value from the callback as the result
+ // of the future, which results in another exception being thrown.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `future` is declared to
+ // return an `int` while `callback` is declared to return a `String`, and
+ // `String` isn't a subtype of `int`:
+ //
+ // ```dart
+ // void f(Future<int> future, String Function(dynamic, StackTrace) callback) {
+ // future.catchError([!callback!]);
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the closure being
+ // passed to `catchError` returns an `int` while `future` is declared to
+ // return a `String`:
+ //
+ // ```dart
+ // void f(Future<String> future) {
+ // future.catchError((error, stackTrace) => [!3!]);
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the instance of `Future` is declared correctly, then change the callback
+ // to match:
+ //
+ // ```dart
+ // void f(Future<int> future, int Function(dynamic, StackTrace) callback) {
+ // future.catchError(callback);
+ // }
+ // ```
+ //
+ // If the declaration of the instance of `Future` is wrong, then change it to
+ // match the callback:
+ //
+ // ```dart
+ // void f(Future<String> future, String Function(dynamic, StackTrace) callback) {
+ // future.catchError(callback);
+ // }
+ // ```
static const HintCode RETURN_OF_INVALID_TYPE_FROM_CATCH_ERROR = HintCode(
'INVALID_RETURN_TYPE_FOR_CATCH_ERROR',
"A value of type '{0}' can't be returned by the 'onError' handler "
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index 6218be8..dc70d3e 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -1629,20 +1629,46 @@
'COULD_NOT_INFER', "Couldn't infer type parameter '{0}'.{1}");
/**
- * 10.10 Superinterfaces: It is a compile-time error if a class `C` has two
- * superinterfaces that are different instantiations of the same generic
- * class. For example, a class may not have both `List<int>` and `List<num>`
- * as superinterfaces.
- *
* 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}' cannot implement both '{1}' and '{2}' because the "
+ "The class '{0}' can't implement both '{1}' and '{2}' because the "
"type arguments are different.");
/**
@@ -1924,21 +1950,83 @@
);
/**
- * 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.
- *
* 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',
- "Constant constructor can't call non-constant super constructor of "
- "'{0}'.",
- correction: "Try calling a const constructor in the superclass, or "
- "removing the keyword 'const' from the constructor.");
+ "A constant constructor can't call a non-constant super constructor "
+ "of '{0}'.",
+ correction: "Try calling a constant constructor in the superclass, "
+ "or removing the keyword 'const' from the constructor.");
/**
* No parameters.
@@ -1992,8 +2080,48 @@
hasPublishedDocs: true);
/**
- * 12.12.2 Const: It is a compile-time error if <i>T</i> is a deferred type.
+ * 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'.",
correction: "Try using 'new' to create the instance, or "
@@ -2134,18 +2262,53 @@
hasPublishedDocs: true);
/**
- * 5 Variables: A constant variable must be initialized to a compile-time
- * constant or a compile-time error occurs.
- *
- * 12.1 Constants: A qualified reference to a static constant variable that is
- * not qualified by a deferred prefix.
+ * 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 "
- "initialized a const variable.",
+ "Constant values from a deferred library can't be used to initialize "
+ "a 'const' variable.",
correction:
"Try initializing the variable without referencing members of "
"the deferred library, or changing the import to not be "
@@ -2195,18 +2358,62 @@
hasPublishedDocs: true);
/**
- * 12.8 Maps: It is a compile-time error if the key of an entry in a constant
- * map literal is an instance of a class that implements the operator
- * <i>==</i> unless the key is a string or integer.
- *
* 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 constant map entry key expression type '{0}' can't override "
- "the == operator.",
+ "The type of a key in a constant map can't override the '==' "
+ "operator, but the class '{0}' does.",
correction: "Try using a different value for the key, or "
"removing the keyword 'const' from the map.");
@@ -2244,11 +2451,59 @@
* 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 constant set element type '{0}' can't override "
- "the == operator.",
+ "The type of an element in a constant set can't override the '==' "
+ "operator, but the type '{0}' does.",
correction: "Try using a different value for the element, or "
"removing the keyword 'const' from the set.");
@@ -2651,9 +2906,82 @@
/**
* 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",
+ "Imports of deferred libraries must hide all extensions.",
correction:
"Try adding either a show combinator listing the names you need "
"to reference or a hide combinator listing all of the "
@@ -3253,14 +3581,47 @@
hasPublishedDocs: true);
/**
- * 7.9 Superclasses: It is a compile-time error if the extends clause of a
- * class <i>C</i> includes a deferred type expression.
- *
- * Parameters:
- * 0: the name of the type that cannot be extended
- *
- * See [IMPLEMENTS_DEFERRED_CLASS], and [MIXIN_DEFERRED_CLASS].
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a type (class or mixin) is a
+ // subtype of a class from a library being imported using a deferred import.
+ // The supertypes of a type must be compiled at the same time as the type, and
+ // classes from deferred libraries aren't compiled until the library is
+ // loaded.
+ //
+ // 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 the class `A`:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // class A {}
+ // ```
+ //
+ // The following code produces this diagnostic because the superclass of `B`
+ // is declared in a deferred library:
+ //
+ // ```dart
+ // import 'a.dart' deferred as a;
+ //
+ // class B extends [!a.A!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to create a subtype of a type from the deferred library, then
+ // remove the `deferred` keyword:
+ //
+ // ```dart
+ // import 'a.dart' as a;
+ //
+ // class B extends a.A {}
+ // ```
static const CompileTimeErrorCode EXTENDS_DEFERRED_CLASS =
CompileTimeErrorCode(
'SUBTYPE_OF_DEFERRED_CLASS', "Classes can't extend deferred classes.",
@@ -4478,19 +4839,58 @@
);
/**
- * 17.6.2 For-in. It the iterable expression does not implement Iterable with
- * a type argument that can be assigned to the for-in variable's type, this
- * warning is reported.
- *
* Parameters:
* 0: The type of the iterable expression.
* 1: The sequence type -- Iterable for `for` or Stream for `await for`.
* 2: The loop variable type.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the `Iterable` or `Stream` in a
+ // for-in loop has an element type that can't be assigned to the loop
+ // variable.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `<String>[]` has an
+ // element type of `String`, and `String` can't be assigned to the type of `e`
+ // (`int`):
+ //
+ // ```dart
+ // void f() {
+ // for (int e in [!<String>[]!]) {
+ // print(e);
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type of the loop variable is correct, then update the type of the
+ // iterable:
+ //
+ // ```dart
+ // void f() {
+ // for (int e in <int>[]) {
+ // print(e);
+ // }
+ // }
+ // ```
+ //
+ // If the type of the iterable is correct, then update the type of the loop
+ // variable:
+ //
+ // ```dart
+ // void f() {
+ // for (String e in <String>[]) {
+ // print(e);
+ // }
+ // }
+ // ```
static const CompileTimeErrorCode FOR_IN_OF_INVALID_ELEMENT_TYPE =
CompileTimeErrorCode(
'FOR_IN_OF_INVALID_ELEMENT_TYPE',
- "The type '{0}' used in the 'for' loop must implement {1} with a "
+ "The type '{0}' used in the 'for' loop must implement '{1}' with a "
"type argument that can be assigned to '{2}'.");
/**
@@ -4532,9 +4932,46 @@
"The type '{0}' used in the 'for' loop must implement {1}.",
hasPublishedDocs: true);
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the loop variable declared in a
+ // for-in loop is declared to be a `const`. The variable can't be a `const`
+ // because the value can't be computed at compile time.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the loop variable `x`
+ // is declared to be a `const`:
+ //
+ // ```dart
+ // void f() {
+ // for ([!const!] x in [0, 1, 2]) {
+ // print(x);
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If there's a type annotation, then remove the `const` modifier from the
+ // declaration.
+ //
+ // If there's no type, then replace the `const` modifier with `final`, `var`,
+ // or a type annotation:
+ //
+ // ```dart
+ // void f() {
+ // for (final x in [0, 1, 2]) {
+ // print(x);
+ // }
+ // }
+ // ```
static const CompileTimeErrorCode FOR_IN_WITH_CONST_VARIABLE =
CompileTimeErrorCode('FOR_IN_WITH_CONST_VARIABLE',
- "A for-in loop-variable can't be 'const'.",
+ "A for-in loop variable can't be a 'const'.",
correction: "Try removing the 'const' modifier from the variable, or "
"use a different variable.");
@@ -4775,11 +5212,7 @@
hasPublishedDocs: true);
/**
- * 7.10 Superinterfaces: It is a compile-time error if the implements clause
- * of a class <i>C</i> specifies a malformed type or deferred type as a
- * superinterface.
- *
- * See [EXTENDS_DEFERRED_CLASS], and [MIXIN_DEFERRED_CLASS].
+ * No parameters.
*/
static const CompileTimeErrorCode IMPLEMENTS_DEFERRED_CLASS =
CompileTimeErrorCode('SUBTYPE_OF_DEFERRED_CLASS',
@@ -5491,9 +5924,37 @@
hasPublishedDocs: true);
/**
- * Enum proposal: It is also a compile-time error to explicitly instantiate an
- * enum via 'new' or 'const' or to access its private fields.
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an enum is instantiated. It's
+ // invalid to create an instance of an enum by invoking a constructor; only
+ // the instances named in the declaration of the enum can exist.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the enum `E` is being
+ // instantiated:
+ //
+ // ```dart
+ // enum E {a}
+ //
+ // var e = [!E!]();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you intend to use an instance of the enum, then reference one of the
+ // constants defined in the enum:
+ //
+ // ```dart
+ // enum E {a}
+ //
+ // var e = E.a;
+ // ```
+ //
+ // If you intend to use an instance of a class, then use the name of that class in place of the name of the enum.
static const CompileTimeErrorCode INSTANTIATE_ENUM = CompileTimeErrorCode(
'INSTANTIATE_ENUM', "Enums can't be instantiated.",
correction: "Try using one of the defined constants.");
@@ -5637,14 +6098,50 @@
hasPublishedDocs: true);
/**
- * 15 Metadata: Metadata consists of a series of annotations, each of which
- * begin with the character @, followed by a constant expression that must be
- * either a reference to a compile-time constant variable, or a call to a
- * constant constructor.
- *
- * 12.1 Constants: A qualified reference to a static constant variable that is
- * not qualified by a deferred prefix.
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a constant from a library that
+ // is imported using a deferred import is used as an annotation. Annotations
+ // are evaluated at compile time, and constants 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 constant `pi` is
+ // being used as an annotation when the library `dart:math` is imported as
+ // `deferred`:
+ //
+ // ```dart
+ // import 'dart:math' deferred as math;
+ //
+ // @[!math.pi!]
+ // void f() {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to reference the constant as an annotation, then remove the
+ // keyword `deferred` from the import:
+ //
+ // ```dart
+ // import 'dart:math' as math;
+ //
+ // @math.pi
+ // void f() {}
+ // ```
+ //
+ // If you can use a different constant as an annotation, then replace the
+ // annotation with a different constant:
+ //
+ // ```dart
+ // @deprecated
+ // void f() {}
+ // ```
static const CompileTimeErrorCode INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY =
CompileTimeErrorCode(
'INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY',
@@ -5942,6 +6439,86 @@
* These parameters must be kept in sync with those of
* [CompileTimeErrorCode.INVALID_OVERRIDE].
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when all of the following are true:
+ //
+ // - A class defines an abstract member.
+ // - There is a concrete implementation of that member in a superclass.
+ // - The concrete implementation isn't a valid implementation of the abstract
+ // method.
+ //
+ // The concrete implementation can be invalid because of incompatibilities in
+ // either the return type, the types of parameters, or the type variables.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the method `A.add` has
+ // a parameter of type `int`, and the overriding method `B.add` has a
+ // corresponding parameter of type `num`:
+ //
+ // ```dart
+ // class A {
+ // int add(int a) => a;
+ // }
+ // class [!B!] extends A {
+ // int add(num a);
+ // }
+ // ```
+ //
+ // This is a problem because in an invocation of `B.add` like the following:
+ //
+ // ```dart
+ // void f(B b) {
+ // b.add(3.4);
+ // }
+ // ```
+ //
+ // `B.add` is expecting to be able to take, for example, a `double`, but when
+ // the method `A.add` is executed (because it's the only concrete
+ // implementation of `add`), a runtime exception will be thrown because a
+ // `double` can't be assigned to a parameter of type `int`.
+ //
+ // #### Common fixes
+ //
+ // If the method in the subclass can conform to the implementation in the
+ // superclass, then change the declaration in the subclass (or remove it if
+ // it's the same):
+ //
+ // ```dart
+ // class A {
+ // int add(int a) => a;
+ // }
+ // class B extends A {
+ // int add(int a);
+ // }
+ // ```
+ //
+ // If the method in the superclass can be generalized to be a valid
+ // implementation of the method in the subclass, then change the superclass
+ // method:
+ //
+ // ```dart
+ // class A {
+ // int add(num a) => a.floor();
+ // }
+ // class B extends A {
+ // int add(num a);
+ // }
+ // ```
+ //
+ // If neither the method in the superclass nor the method in the subclass can
+ // be changed, then provide a concrete implementation of the method in the
+ // subclass:
+ //
+ // ```dart
+ // class A {
+ // int add(int a) => a;
+ // }
+ // class B extends A {
+ // int add(num a) => a.floor();
+ // }
+ // ```
static const CompileTimeErrorCode INVALID_IMPLEMENTATION_OVERRIDE =
CompileTimeErrorCode(
'INVALID_IMPLEMENTATION_OVERRIDE',
@@ -7030,9 +7607,21 @@
"expression.",
correction: "Try adding the keyword 'const' before the literal.");
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when either the Dart or Flutter SDK
+ // isn’t installed correctly, and, as a result, one of the `dart:` libraries
+ // can't be found.
+ //
+ // #### Common fixes
+ //
+ // Reinstall the Dart or Flutter SDK.
static const CompileTimeErrorCode MISSING_DART_LIBRARY = CompileTimeErrorCode(
'MISSING_DART_LIBRARY', "Required library '{0}' is missing.",
- correction: "Check your Dart SDK installation for completeness.");
+ correction: "Re-install the Dart or Flutter SDK.");
/**
* No parameters.
@@ -7156,13 +7745,76 @@
"concrete member in the class has type '{2}'.");
/**
- * It's a compile-time error to apply a mixin containing super-invocations to
- * a class that doesn't have a concrete implementation of the super-invoked
- * members compatible with the super-constraint interface.
- *
* Parameters:
* 0: the display name of the member without a concrete implementation
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a [mixin application][] contains
+ // an invocation of a member from its superclass, and there's no concrete
+ // member of that name in the mixin application's superclass.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the mixin `M` contains
+ // the invocation `super.m()`, and the class `A`, which is the superclass of
+ // the [mixin application][] `A+M`, doesn't define a concrete implementation
+ // of `m`:
+ //
+ // ```dart
+ // abstract class A {
+ // void m();
+ // }
+ //
+ // mixin M on A {
+ // void bar() {
+ // super.m();
+ // }
+ // }
+ //
+ // abstract class B extends A with [!M!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you intended to apply the mixin `M` to a different class, one that has a
+ // concrete implementation of `m`, then change the superclass of `B` to that
+ // class:
+ //
+ // ```dart
+ // abstract class A {
+ // void m();
+ // }
+ //
+ // mixin M on A {
+ // void bar() {
+ // super.m();
+ // }
+ // }
+ //
+ // class C implements A {
+ // void m() {}
+ // }
+ //
+ // abstract class B extends C with M {}
+ // ```
+ //
+ // If you need to make `B` a subclass of `A`, then add a concrete
+ // implementation of `m` in `A`:
+ //
+ // ```dart
+ // abstract class A {
+ // void m() {}
+ // }
+ //
+ // mixin M on A {
+ // void bar() {
+ // super.m();
+ // }
+ // }
+ //
+ // abstract class B extends A with M {}
+ // ```
static const CompileTimeErrorCode
MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER = CompileTimeErrorCode(
'MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER',
@@ -7207,13 +7859,7 @@
'MIXIN_DECLARES_CONSTRUCTOR', "Mixins can't declare constructors.");
/**
- * 9.1 Mixin Application: It is a compile-time error if the with clause of a
- * mixin application <i>C</i> includes a deferred type expression.
- *
- * Parameters:
- * 0: the name of the type that cannot be extended
- *
- * See [EXTENDS_DEFERRED_CLASS], and [IMPLEMENTS_DEFERRED_CLASS].
+ * No parameters.
*/
static const CompileTimeErrorCode MIXIN_DEFERRED_CLASS = CompileTimeErrorCode(
'SUBTYPE_OF_DEFERRED_CLASS', "Classes can't mixin deferred classes.",
@@ -7255,8 +7901,27 @@
"other than Object.");
/**
- * A mixin declaration introduces a mixin and an interface, but not a class.
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a mixin is instantiated.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the mixin `M` is being
+ // instantiated:
+ //
+ // ```dart
+ // mixin M {}
+ //
+ // var m = [!M!]();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you intend to use an instance of a class, then use the name of that
+ // class in place of the name of the mixin.
static const CompileTimeErrorCode MIXIN_INSTANTIATE = CompileTimeErrorCode(
'MIXIN_INSTANTIATE', "Mixins can't be instantiated.");
@@ -8060,19 +8725,87 @@
hasPublishedDocs: true);
/**
- * 13.9 Switch: Given a switch statement of the form <i>switch (e) {
- * label<sub>11</sub> … label<sub>1j1</sub> case e<sub>1</sub>:
- * s<sub>1</sub> … label<sub>n1</sub> … label<sub>njn</sub> case
- * e<sub>n</sub>: s<sub>n</sub> default: s<sub>n+1</sub>}</i> or the form
- * <i>switch (e) { label<sub>11</sub> … label<sub>1j1</sub> case
- * e<sub>1</sub>: s<sub>1</sub> … label<sub>n1</sub> …
- * label<sub>njn</sub> case e<sub>n</sub>: s<sub>n</sub>}</i>, it is a
- * compile-time error if the expressions <i>e<sub>k</sub></i> are not
- * compile-time constants, for all <i>1 <= k <= n</i>.
- *
- * 12.1 Constants: A qualified reference to a static constant variable that is
- * not qualified by a deferred prefix.
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the expression in a case clause
+ // references a constant from a library that is imported using a deferred
+ // import. In order for switch statements to be compiled efficiently, the
+ // constants referenced in case clauses need to be available at compile time,
+ // and constants 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 the constant `zero`:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // const zero = 0;
+ // ```
+ //
+ // The following code produces this diagnostic because the library `a.dart` is
+ // imported using a `deferred` import, and the constant `a.zero`, declared in
+ // the imported library, is used in a case clause:
+ //
+ // ```dart
+ // import 'a.dart' deferred as a;
+ //
+ // void f(int x) {
+ // switch (x) {
+ // case [!a.zero!]:
+ // // ...
+ // break;
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to reference the constant from the imported library, then
+ // remove the `deferred` keyword:
+ //
+ // ```dart
+ // import 'a.dart' as a;
+ //
+ // void f(int x) {
+ // switch (x) {
+ // case a.zero:
+ // // ...
+ // break;
+ // }
+ // }
+ // ```
+ //
+ // If you need to reference the constant from the imported library and also
+ // need the imported library to be deferred, then rewrite the switch statement
+ // as a sequence of `if` statements:
+ //
+ // ```dart
+ // import 'a.dart' deferred as a;
+ //
+ // void f(int x) {
+ // if (x == a.zero) {
+ // // ...
+ // }
+ // }
+ // ```
+ //
+ // If you don't need to reference the constant, then replace the case
+ // expression:
+ //
+ // ```dart
+ // void f(int x) {
+ // switch (x) {
+ // case 0:
+ // // ...
+ // break;
+ // }
+ // }
+ // ```
static const CompileTimeErrorCode
NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY = CompileTimeErrorCode(
'NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY',
@@ -8130,12 +8863,53 @@
hasPublishedDocs: true);
/**
- * 6.2.2 Optional Formals: It is a compile-time error if the default value of
- * an optional parameter is not a compile-time constant.
- *
- * 12.1 Constants: A qualified reference to a static constant variable that is
- * not qualified by a deferred prefix.
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the default value of an optional
+ // parameter uses a constant from a library imported using a deferred import.
+ // Default values need to be available at compile time, and constants 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 the constant `zero`:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // const zero = 0;
+ // ```
+ //
+ // The following code produces this diagnostic because `zero` is declared in a
+ // library imported using a deferred import:
+ //
+ // ```dart
+ // import 'a.dart' deferred as a;
+ //
+ // void f({int x = [!a.zero!]}) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to reference the constant from the imported library, then
+ // remove the `deferred` keyword:
+ //
+ // ```dart
+ // import 'a.dart' as a;
+ //
+ // void f({int x = a.zero}) {}
+ // ```
+ //
+ // If you don't need to reference the constant, then replace the default
+ // value:
+ //
+ // ```dart
+ // void f({int x = 0}) {}
+ // ```
static const CompileTimeErrorCode
NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY = CompileTimeErrorCode(
'NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY',
@@ -8192,18 +8966,71 @@
hasPublishedDocs: true);
/**
- * 12.6 Lists: It is a compile time error if an element of a constant list
- * literal is not a compile-time constant.
- *
- * 12.1 Constants: A qualified reference to a static constant variable that is
- * not qualified by a deferred prefix.
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a collection literal that is
+ // either explicitly (because it's prefixed by the `const` keyword) or
+ // implicitly (because it appears in a [constant context][]) a constant
+ // contains a value that is declared in 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
+ //
+ // Given a file (`a.dart`) that defines the constant `zero`:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // const zero = 0;
+ // ```
+ //
+ // The following code produces this diagnostic because the constant list
+ // literal contains `a.zero`, which is imported using a `deferred` import:
+ //
+ // ```dart
+ // import 'a.dart' deferred as a;
+ //
+ // var l = const [[!a.zero!]];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the collection literal isn't required to be constant, then remove the
+ // `const` keyword:
+ //
+ // ```dart
+ // import 'a.dart' deferred as a;
+ //
+ // var l = [a.zero];
+ // ```
+ //
+ // If the collection is required to be constant and the imported constant must
+ // be referenced, then remove the keyword `deferred` from the import:
+ //
+ // ```dart
+ // import 'a.dart' as a;
+ //
+ // var l = const [a.zero];
+ // ```
+ //
+ // If you don't need to reference the constant, then replace it with a
+ // suitable value:
+ //
+ // ```dart
+ // var l = const [0];
+ // ```
static const CompileTimeErrorCode
NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY = CompileTimeErrorCode(
'COLLECTION_ELEMENT_FROM_DEFERRED_LIBRARY',
"Constant values from a deferred library can't be used as values in "
- "a 'const' list.",
- correction: "Try removing the keyword 'const' from the list literal.",
+ "a 'const' list literal.",
+ correction: "Try removing the keyword 'const' from the list literal "
+ "or removing the keyword 'deferred' from the import.",
uniqueName: 'NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY');
/**
@@ -8296,18 +9123,16 @@
hasPublishedDocs: true);
/**
- * 12.7 Maps: It is a compile time error if either a key or a value of an
- * entry in a constant map literal is not a compile-time constant.
- *
- * 12.1 Constants: A qualified reference to a static constant variable that is
- * not qualified by a deferred prefix.
+ * No parameters.
*/
static const CompileTimeErrorCode NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY =
CompileTimeErrorCode(
'COLLECTION_ELEMENT_FROM_DEFERRED_LIBRARY',
"Constant values from a deferred library can't be used as keys in a "
- "const map literal.",
- correction: "Try removing the keyword 'const' from the map literal.",
+ "'const' map literal.",
+ correction:
+ "Try removing the keyword 'const' from the map literal or removing "
+ "the keyword 'deferred' from the import.",
uniqueName: 'NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY');
/**
@@ -8350,18 +9175,16 @@
hasPublishedDocs: true);
/**
- * 12.7 Maps: It is a compile time error if either a key or a value of an
- * entry in a constant map literal is not a compile-time constant.
- *
- * 12.1 Constants: A qualified reference to a static constant variable that is
- * not qualified by a deferred prefix.
+ * No parameters.
*/
static const CompileTimeErrorCode
NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY = CompileTimeErrorCode(
'COLLECTION_ELEMENT_FROM_DEFERRED_LIBRARY',
"Constant values from a deferred library can't be used as values in "
- "a const map literal.",
- correction: "Try removing the keyword 'const' from the map literal.",
+ "a 'const' map literal.",
+ correction:
+ "Try removing the keyword 'const' from the map literal or removing "
+ "the keyword 'deferred' from the import.",
uniqueName: 'NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY');
/**
@@ -10441,12 +11264,17 @@
'RETURN_WITHOUT_VALUE', "The return value is missing after 'return'.",
hasPublishedDocs: true);
+ /**
+ * No parameters.
+ */
static const CompileTimeErrorCode SET_ELEMENT_FROM_DEFERRED_LIBRARY =
CompileTimeErrorCode(
'COLLECTION_ELEMENT_FROM_DEFERRED_LIBRARY',
"Constant values from a deferred library can't be used as values in "
- "a const set.",
- correction: "Try making the deferred import non-deferred.",
+ "a 'const' set literal.",
+ correction:
+ "Try removing the keyword 'const' from the set literal or removing "
+ "the keyword 'deferred' from the import.",
uniqueName: 'SET_ELEMENT_FROM_DEFERRED_LIBRARY');
/**
@@ -10813,17 +11641,49 @@
"another typedef.");
/**
- * 15.1 Static Types: It is a static warning to use a deferred type in a type
- * annotation.
- *
* Parameters:
* 0: the name of the type that is deferred and being used in a type
* annotation
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the type annotation is in a
+ // variable declaration, or the type used in a cast (`as`) or type test (`is`)
+ // is a type declared in a library that is imported using a deferred import.
+ // These types are required to be available at compile time, but aren't.
+ //
+ // 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 type of the
+ // parameter `f` is imported from a deferred library:
+ //
+ // ```dart
+ // import 'dart:io' deferred as io;
+ //
+ // void f([!io.File!] f) {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to reference the imported type, then remove the `deferred`
+ // keyword:
+ //
+ // ```dart
+ // import 'dart:io' as io;
+ //
+ // void f(io.File f) {}
+ // ```
+ //
+ // If the import is required to be deferred and there's another type that is
+ // appropriate, then use that type in place of the type from the deferred
+ // library.
static const CompileTimeErrorCode TYPE_ANNOTATION_DEFERRED_CLASS =
CompileTimeErrorCode(
'TYPE_ANNOTATION_DEFERRED_CLASS',
- "The deferred type '{0}' can't be used in a declaration, cast or "
+ "The deferred type '{0}' can't be used in a declaration, cast, or "
"type test.",
correction: "Try using a different type, or "
"changing the import to not be deferred.");
diff --git a/pkg/analyzer/test/verify_diagnostics_test.dart b/pkg/analyzer/test/verify_diagnostics_test.dart
index 34f18aa..f99f600 100644
--- a/pkg/analyzer/test/verify_diagnostics_test.dart
+++ b/pkg/analyzer/test/verify_diagnostics_test.dart
@@ -38,6 +38,12 @@
'CompileTimeErrorCode.AMBIGUOUS_IMPORT',
// Produces two diagnostics when it should only produce one.
'CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE',
+ // Produces two diagnostics when it should only produce one.
+ 'CompileTimeErrorCode.CONST_DEFERRED_CLASS',
+ // Has code in the example section that needs to be skipped (because it's
+ // part of the explanitory text not part of the example), but there's
+ // currently no way to do that.
+ 'CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE',
// Produces two diagnostics when it should only produce one. We could get
// rid of the invalid error by adding a declaration of a top-level variable
// (such as `JSBool b;`), but that would complicate the example.
@@ -46,6 +52,8 @@
'CompileTimeErrorCode.INVALID_URI',
// Produces two diagnostics when it should only produce one.
'CompileTimeErrorCode.INVALID_USE_OF_NULL_VALUE',
+ // No example, by design.
+ 'CompileTimeErrorCode.MISSING_DART_LIBRARY',
// Produces two diagnostics when it should only produce one.
'CompileTimeErrorCode.NON_SYNC_FACTORY',
// Need a way to make auxiliary files that (a) are not included in the
diff --git a/pkg/analyzer/tool/diagnostics/diagnostics.md b/pkg/analyzer/tool/diagnostics/diagnostics.md
index 39761ec..9c462d5 100644
--- a/pkg/analyzer/tool/diagnostics/diagnostics.md
+++ b/pkg/analyzer/tool/diagnostics/diagnostics.md
@@ -19,11 +19,13 @@
* [constant context][]
* [definite assignment][]
+* [mixin application][]
* [override inference][]
* [potentially non-nullable][]
[constant context]: #constant-context
[definite assignment]: #definite-assignment
+[mixin application]: #mixin-application
[override inference]: #override-inference
[potentially non-nullable]: #potentially-non-nullable
@@ -154,6 +156,40 @@
[definiteAssignmentSpec](https://github.com/dart-lang/language/blob/master/resources/type-system/flow-analysis.md)
+### Mixin Application
+
+A _mixin application_ is the class created when a mixin is applied to a class.
+For example, consider the following declarations:
+
+```dart
+class A {}
+
+mixin M {}
+
+class B extends A with M {}
+```
+
+The class `B` is a subclass of the mixin application of `M` to `A`, sometimes
+nomenclated as `A+M`. The class `A+M` is a subclass of `A` and has members that
+are copied from `M`.
+
+You can give an actual name to a mixin application by defining it as:
+
+```dart
+class A {}
+
+mixin M {}
+
+class A_M = A with M;
+```
+
+Given this declaration of `A_M`, the following declaration of `B` is equivalent
+to the declaration of `B` in the original example:
+
+```dart
+class B extends A_M {}
+```
+
### Override inference
Override inference is the process by which any missing types in a method
@@ -667,6 +703,64 @@
String g(num y) => f(y as String);
{% endprettify %}
+### argument_type_not_assignable_to_error_handler
+
+_The argument type '{0}' can't be assigned to the parameter type '{1}
+Function(Object)' or '{1} Function(Object, StackTrace)'._
+
+#### Description
+
+The analyzer produces this diagnostic when an invocation of
+`Future.catchError` has an argument that is a function whose parameters
+aren't compatible with the arguments that will be passed to the function
+when it's invoked. The static type of the first argument to `catchError`
+is just `Function`, even though the function that is passed in is expected
+to have either a single parameter of type `Object` or two parameters of
+type `Object` and `StackTrace`.
+
+#### Example
+
+The following code produces this diagnostic because the closure being
+passed to `catchError` doesn't take any parameters, but the function is
+required to take at least one parameter:
+
+{% prettify dart tag=pre+code %}
+void f(Future<int> f) {
+ f.catchError([!() => 0!]);
+}
+{% endprettify %}
+
+The following code produces this diagnostic because the closure being
+passed to `catchError` takes three parameters, but it can't have more than
+two required parameters:
+
+{% prettify dart tag=pre+code %}
+void f(Future<int> f) {
+ f.catchError([!(one, two, three) => 0!]);
+}
+{% endprettify %}
+
+The following code produces this diagnostic because even though the closure
+being passed to `catchError` takes one parameter, the closure doesn't have
+a type that is compatible with `Object`:
+
+{% prettify dart tag=pre+code %}
+void f(Future<int> f) {
+ f.catchError([!(String error) => 0!]);
+}
+{% endprettify %}
+
+#### Common fixes
+
+Change the function being passed to `catchError` so that it has either one
+or two required parameters, and the parameters have the required types:
+
+{% prettify dart tag=pre+code %}
+void f(Future<int> f) {
+ f.catchError((Object error) => 0);
+}
+{% endprettify %}
+
### assert_in_redirecting_constructor
_A redirecting constructor can't have an 'assert' initializer._
@@ -1503,6 +1597,76 @@
int y = x as int;
{% endprettify %}
+### collection_element_from_deferred_library
+
+_Constant values from a deferred library can't be used as keys in a 'const' map
+literal._
+
+_Constant values from a deferred library can't be used as values in a 'const'
+list literal._
+
+_Constant values from a deferred library can't be used as values in a 'const'
+map literal._
+
+_Constant values from a deferred library can't be used as values in a 'const'
+set literal._
+
+#### Description
+
+The analyzer produces this diagnostic when a collection literal that is
+either explicitly (because it's prefixed by the `const` keyword) or
+implicitly (because it appears in a [constant context][]) a constant
+contains a value that is declared in 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
+
+Given a file (`a.dart`) that defines the constant `zero`:
+
+{% prettify dart tag=pre+code %}
+const zero = 0;
+{% endprettify %}
+
+The following code produces this diagnostic because the constant list
+literal contains `a.zero`, which is imported using a `deferred` import:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' deferred as a;
+
+var l = const [[!a.zero!]];
+{% endprettify %}
+
+#### Common fixes
+
+If the collection literal isn't required to be constant, then remove the
+`const` keyword:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' deferred as a;
+
+var l = [a.zero];
+{% endprettify %}
+
+If the collection is required to be constant and the imported constant must
+be referenced, then remove the keyword `deferred` from the import:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' as a;
+
+var l = const [a.zero];
+{% endprettify %}
+
+If you don't need to reference the constant, then replace it with a
+suitable value:
+
+{% prettify dart tag=pre+code %}
+var l = const [0];
+{% endprettify %}
+
### concrete_class_with_abstract_member
_'{0}' must have a method body because '{1}' isn't abstract._
@@ -1544,6 +1708,43 @@
}
{% endprettify %}
+### conflicting_generic_interfaces
+
+_The class '{0}' can't implement both '{1}' and '{2}' because the type arguments
+are different._
+
+#### 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:
+
+{% prettify dart tag=pre+code %}
+class I<T> {}
+class A implements I<int> {}
+class B implements I<String> {}
+[!class C extends A implements B {}!]
+{% endprettify %}
+
+#### 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:
+
+{% prettify dart tag=pre+code %}
+class I<T> {}
+class A<S> implements I<S> {}
+class B implements I<String> {}
+class C extends A<String> implements B {}
+{% endprettify %}
+
### const_constructor_param_type_mismatch
_A value of type '{0}' can't be assigned to a parameter of type '{1}' in a const
@@ -1636,6 +1837,78 @@
}
{% endprettify %}
+### const_constructor_with_non_const_super
+
+_A constant constructor can't call a non-constant super constructor of '{0}'._
+
+#### 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:
+
+{% prettify dart tag=pre+code %}
+class A {
+ const A();
+ A.nonConst();
+}
+
+class B extends A {
+ const B() : [!super.nonConst()!];
+}
+{% endprettify %}
+
+#### 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:
+
+{% prettify dart tag=pre+code %}
+class A {
+ const A();
+ A.nonConst();
+}
+
+class B extends A {
+ const B() : super();
+}
+{% endprettify %}
+
+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:
+
+{% prettify dart tag=pre+code %}
+class A {
+ const A();
+ const A.nonConst();
+}
+
+class B extends A {
+ const B() : super.nonConst();
+}
+{% endprettify %}
+
+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:
+
+{% prettify dart tag=pre+code %}
+class A {
+ const A();
+ A.nonConst();
+}
+
+class B extends A {
+ B() : super.nonConst();
+}
+{% endprettify %}
+
### const_constructor_with_non_final_field
_Can't define a const constructor for a class with non-final fields._
@@ -1682,6 +1955,51 @@
}
{% endprettify %}
+### const_deferred_class
+
+_Deferred classes can't be created with 'const'._
+
+#### 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:
+
+{% prettify dart tag=pre+code %}
+import 'dart:convert' deferred as convert;
+
+const json2 = [!convert.JsonCodec()!];
+{% endprettify %}
+
+#### Common fixes
+
+If the object isn't required to be a constant, then change the code so that
+a non-constant instance is created:
+
+{% prettify dart tag=pre+code %}
+import 'dart:convert' deferred as convert;
+
+final json2 = convert.JsonCodec();
+{% endprettify %}
+
+If the object must be a constant, then remove `deferred` from the import
+directive:
+
+{% prettify dart tag=pre+code %}
+import 'dart:convert' as convert;
+
+const json2 = convert.JsonCodec();
+{% endprettify %}
+
### const_initialized_with_non_constant_value
_Const variables must be initialized with a constant value._
@@ -1720,6 +2038,51 @@
final y = x;
{% endprettify %}
+### const_initialized_with_non_constant_value_from_deferred_library
+
+_Constant values from a deferred library can't be used to initialize a 'const'
+variable._
+
+#### 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:
+
+{% prettify dart tag=pre+code %}
+import 'dart:math' deferred as math;
+
+const pi = [!math.pi!];
+{% endprettify %}
+
+#### Common fixes
+
+If you need to reference the value of the constant from the imported
+library, then remove the keyword `deferred`:
+
+{% prettify dart tag=pre+code %}
+import 'dart:math' as math;
+
+const pi = math.pi;
+{% endprettify %}
+
+If you don't need to reference the imported constant, then remove the
+reference:
+
+{% prettify dart tag=pre+code %}
+const pi = 3.14;
+{% endprettify %}
+
### const_instance_field
_Only static fields can be declared as const._
@@ -1759,6 +2122,60 @@
}
{% endprettify %}
+### 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._
+
+#### 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 `==`:
+
+{% prettify dart tag=pre+code %}
+class C {
+ const C();
+
+ bool operator ==(Object other) => true;
+}
+
+const map = {[!C()!] : 0};
+{% endprettify %}
+
+#### Common fixes
+
+If you can remove the implementation of `==` from the class, then do so:
+
+{% prettify dart tag=pre+code %}
+class C {
+ const C();
+}
+
+const map = {C() : 0};
+{% endprettify %}
+
+If you can't remove the implementation of `==` from the class, then make
+the map be non-constant:
+
+{% prettify dart tag=pre+code %}
+class C {
+ const C();
+
+ bool operator ==(Object other) => true;
+}
+
+final map = {C() : 0};
+{% endprettify %}
+
### const_not_initialized
_The constant '{0}' must be initialized._
@@ -1784,6 +2201,60 @@
const c = 'c';
{% endprettify %}
+### 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._
+
+#### 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 `==`:
+
+{% prettify dart tag=pre+code %}
+class C {
+ const C();
+
+ bool operator ==(Object other) => true;
+}
+
+const set = {[!C()!]};
+{% endprettify %}
+
+#### Common fixes
+
+If you can remove the implementation of `==` from the class, then do so:
+
+{% prettify dart tag=pre+code %}
+class C {
+ const C();
+}
+
+const set = {C()};
+{% endprettify %}
+
+If you can't remove the implementation of `==` from the class, then make
+the set be non-constant:
+
+{% prettify dart tag=pre+code %}
+class C {
+ const C();
+
+ bool operator ==(Object other) => true;
+}
+
+final set = {C()};
+{% endprettify %}
+
### const_spread_expected_list_or_set
_A list or a set is expected in this spread._
@@ -2372,6 +2843,83 @@
}
{% endprettify %}
+### deferred_import_of_extension
+
+_Imports of deferred libraries must hide all extensions._
+
+#### 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:
+
+{% prettify dart tag=pre+code %}
+class C {}
+
+extension E on String {
+ int get size => length;
+}
+{% endprettify %}
+
+The following code produces this diagnostic because the named extension is
+visible to the library:
+
+{% prettify dart tag=pre+code %}
+import [!'a.dart'!] deferred as a;
+
+void f() {
+ a.C();
+}
+{% endprettify %}
+
+#### 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:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' deferred as a show C;
+
+void f() {
+ a.C();
+}
+{% endprettify %}
+
+Adding a `hide` clause would look like this:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' deferred as a hide E;
+
+void f() {
+ a.C();
+}
+{% endprettify %}
+
+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`:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' as a;
+
+void f() {
+ a.C();
+}
+{% endprettify %}
+
### definitely_unassigned_late_local_variable
_The late local variable '{0}' is definitely unassigned at this point._
@@ -4176,6 +4724,55 @@
}
{% endprettify %}
+### for_in_of_invalid_element_type
+
+_The type '{0}' used in the 'for' loop must implement '{1}' with a type argument
+that can be assigned to '{2}'._
+
+#### Description
+
+The analyzer produces this diagnostic when the `Iterable` or `Stream` in a
+for-in loop has an element type that can't be assigned to the loop
+variable.
+
+#### Example
+
+The following code produces this diagnostic because `<String>[]` has an
+element type of `String`, and `String` can't be assigned to the type of `e`
+(`int`):
+
+{% prettify dart tag=pre+code %}
+void f() {
+ for (int e in [!<String>[]!]) {
+ print(e);
+ }
+}
+{% endprettify %}
+
+#### Common fixes
+
+If the type of the loop variable is correct, then update the type of the
+iterable:
+
+{% prettify dart tag=pre+code %}
+void f() {
+ for (int e in <int>[]) {
+ print(e);
+ }
+}
+{% endprettify %}
+
+If the type of the iterable is correct, then update the type of the loop
+variable:
+
+{% prettify dart tag=pre+code %}
+void f() {
+ for (String e in <String>[]) {
+ print(e);
+ }
+}
+{% endprettify %}
+
### for_in_of_invalid_type
_The type '{0}' used in the 'for' loop must implement {1}._
@@ -4210,6 +4807,45 @@
}
{% endprettify %}
+### for_in_with_const_variable
+
+_A for-in loop variable can't be a 'const'._
+
+#### Description
+
+The analyzer produces this diagnostic when the loop variable declared in a
+for-in loop is declared to be a `const`. The variable can't be a `const`
+because the value can't be computed at compile time.
+
+#### Example
+
+The following code produces this diagnostic because the loop variable `x`
+is declared to be a `const`:
+
+{% prettify dart tag=pre+code %}
+void f() {
+ for ([!const!] x in [0, 1, 2]) {
+ print(x);
+ }
+}
+{% endprettify %}
+
+#### Common fixes
+
+If there's a type annotation, then remove the `const` modifier from the
+declaration.
+
+If there's no type, then replace the `const` modifier with `final`, `var`,
+or a type annotation:
+
+{% prettify dart tag=pre+code %}
+void f() {
+ for (final x in [0, 1, 2]) {
+ print(x);
+ }
+}
+{% endprettify %}
+
### getter_not_subtype_setter_types
_The return type of getter '{0}' is '{1}' which isn't a subtype of the type
@@ -4873,6 +5509,40 @@
If there's a concrete subclass of the abstract class that can be used, then
create an instance of the concrete subclass.
+### instantiate_enum
+
+_Enums can't be instantiated._
+
+#### Description
+
+The analyzer produces this diagnostic when an enum is instantiated. It's
+invalid to create an instance of an enum by invoking a constructor; only
+the instances named in the declaration of the enum can exist.
+
+#### Example
+
+The following code produces this diagnostic because the enum `E` is being
+instantiated:
+
+{% prettify dart tag=pre+code %}
+enum E {a}
+
+var e = [!E!]();
+{% endprettify %}
+
+#### Common fixes
+
+If you intend to use an instance of the enum, then reference one of the
+constants defined in the enum:
+
+{% prettify dart tag=pre+code %}
+enum E {a}
+
+var e = E.a;
+{% endprettify %}
+
+If you intend to use an instance of a class, then use the name of that class in place of the name of the enum.
+
### integer_literal_out_of_range
_The integer literal {0} can't be represented in 64 bits._
@@ -4973,6 +5643,53 @@
}
{% endprettify %}
+### invalid_annotation_from_deferred_library
+
+_Constant values from a deferred library can't be used as annotations._
+
+#### Description
+
+The analyzer produces this diagnostic when a constant from a library that
+is imported using a deferred import is used as an annotation. Annotations
+are evaluated at compile time, and constants 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 constant `pi` is
+being used as an annotation when the library `dart:math` is imported as
+`deferred`:
+
+{% prettify dart tag=pre+code %}
+import 'dart:math' deferred as math;
+
+@[!math.pi!]
+void f() {}
+{% endprettify %}
+
+#### Common fixes
+
+If you need to reference the constant as an annotation, then remove the
+keyword `deferred` from the import:
+
+{% prettify dart tag=pre+code %}
+import 'dart:math' as math;
+
+@math.pi
+void f() {}
+{% endprettify %}
+
+If you can use a different constant as an annotation, then replace the
+annotation with a different constant:
+
+{% prettify dart tag=pre+code %}
+@deprecated
+void f() {}
+{% endprettify %}
+
### invalid_assignment
_A value of type '{0}' can't be assigned to a variable of type '{1}'._
@@ -5127,6 +5844,91 @@
}
{% endprettify %}
+### invalid_implementation_override
+
+_'{1}.{0}' ('{2}') isn't a valid concrete implementation of '{3}.{0}' ('{4}')._
+
+#### Description
+
+The analyzer produces this diagnostic when all of the following are true:
+
+- A class defines an abstract member.
+- There is a concrete implementation of that member in a superclass.
+- The concrete implementation isn't a valid implementation of the abstract
+ method.
+
+The concrete implementation can be invalid because of incompatibilities in
+either the return type, the types of parameters, or the type variables.
+
+#### Example
+
+The following code produces this diagnostic because the method `A.add` has
+a parameter of type `int`, and the overriding method `B.add` has a
+corresponding parameter of type `num`:
+
+{% prettify dart tag=pre+code %}
+class A {
+ int add(int a) => a;
+}
+class [!B!] extends A {
+ int add(num a);
+}
+{% endprettify %}
+
+This is a problem because in an invocation of `B.add` like the following:
+
+{% prettify dart tag=pre+code %}
+void f(B b) {
+ b.add(3.4);
+}
+{% endprettify %}
+
+`B.add` is expecting to be able to take, for example, a `double`, but when
+the method `A.add` is executed (because it's the only concrete
+implementation of `add`), a runtime exception will be thrown because a
+`double` can't be assigned to a parameter of type `int`.
+
+#### Common fixes
+
+If the method in the subclass can conform to the implementation in the
+superclass, then change the declaration in the subclass (or remove it if
+it's the same):
+
+{% prettify dart tag=pre+code %}
+class A {
+ int add(int a) => a;
+}
+class B extends A {
+ int add(int a);
+}
+{% endprettify %}
+
+If the method in the superclass can be generalized to be a valid
+implementation of the method in the subclass, then change the superclass
+method:
+
+{% prettify dart tag=pre+code %}
+class A {
+ int add(num a) => a.floor();
+}
+class B extends A {
+ int add(num a);
+}
+{% endprettify %}
+
+If neither the method in the superclass nor the method in the subclass can
+be changed, then provide a concrete implementation of the method in the
+subclass:
+
+{% prettify dart tag=pre+code %}
+class A {
+ int add(int a) => a;
+}
+class B extends A {
+ int add(num a) => a.floor();
+}
+{% endprettify %}
+
### invalid_inline_function_type
_Inline function types can't be used for parameters in a generic function type._
@@ -5382,6 +6184,64 @@
class C {}
{% endprettify %}
+### invalid_return_type_for_catch_error
+
+_A value of type '{0}' can't be returned by the 'onError' handler because it
+must be assignable to '{1}'._
+
+_The return type '{0}' isn't assignable to '{1}', as required by
+'Future.catchError'._
+
+#### Description
+
+The analyzer produces this diagnostic when an invocation of
+`Future.catchError` has an argument whose return type isn't compatible with
+the type returned by the instance of `Future`. At runtime, the method
+`catchError` attempts to return the value from the callback as the result
+of the future, which results in another exception being thrown.
+
+#### Example
+
+The following code produces this diagnostic because `future` is declared to
+return an `int` while `callback` is declared to return a `String`, and
+`String` isn't a subtype of `int`:
+
+{% prettify dart tag=pre+code %}
+void f(Future<int> future, String Function(dynamic, StackTrace) callback) {
+ future.catchError([!callback!]);
+}
+{% endprettify %}
+
+The following code produces this diagnostic because the closure being
+passed to `catchError` returns an `int` while `future` is declared to
+return a `String`:
+
+{% prettify dart tag=pre+code %}
+void f(Future<String> future) {
+ future.catchError((error, stackTrace) => [!3!]);
+}
+{% endprettify %}
+
+#### Common fixes
+
+If the instance of `Future` is declared correctly, then change the callback
+to match:
+
+{% prettify dart tag=pre+code %}
+void f(Future<int> future, int Function(dynamic, StackTrace) callback) {
+ future.catchError(callback);
+}
+{% endprettify %}
+
+If the declaration of the instance of `Future` is wrong, then change it to
+match the callback:
+
+{% prettify dart tag=pre+code %}
+void f(Future<String> future, String Function(dynamic, StackTrace) callback) {
+ future.catchError(callback);
+}
+{% endprettify %}
+
### invalid_super_invocation
_The superclass call must be last in an initializer list: '{0}'._
@@ -6218,6 +7078,20 @@
var m = <String, int>{'a' : 2};
{% endprettify %}
+### missing_dart_library
+
+_Required library '{0}' is missing._
+
+#### Description
+
+The analyzer produces this diagnostic when either the Dart or Flutter SDK
+isn’t installed correctly, and, as a result, one of the `dart:` libraries
+can't be found.
+
+#### Common fixes
+
+Reinstall the Dart or Flutter SDK.
+
### missing_default_value_for_parameter
_The parameter '{0}' can't have a value of 'null' because of its type, but the
@@ -6435,6 +7309,103 @@
Add a `return` statement that makes the return value explicit, even if
`null` is the appropriate value.
+### mixin_application_no_concrete_super_invoked_member
+
+_The class doesn't have a concrete implementation of the super-invoked member
+'{0}'._
+
+#### Description
+
+The analyzer produces this diagnostic when a [mixin application][] contains
+an invocation of a member from its superclass, and there's no concrete
+member of that name in the mixin application's superclass.
+
+#### Example
+
+The following code produces this diagnostic because the mixin `M` contains
+the invocation `super.m()`, and the class `A`, which is the superclass of
+the [mixin application][] `A+M`, doesn't define a concrete implementation
+of `m`:
+
+{% prettify dart tag=pre+code %}
+abstract class A {
+ void m();
+}
+
+mixin M on A {
+ void bar() {
+ super.m();
+ }
+}
+
+abstract class B extends A with [!M!] {}
+{% endprettify %}
+
+#### Common fixes
+
+If you intended to apply the mixin `M` to a different class, one that has a
+concrete implementation of `m`, then change the superclass of `B` to that
+class:
+
+{% prettify dart tag=pre+code %}
+abstract class A {
+ void m();
+}
+
+mixin M on A {
+ void bar() {
+ super.m();
+ }
+}
+
+class C implements A {
+ void m() {}
+}
+
+abstract class B extends C with M {}
+{% endprettify %}
+
+If you need to make `B` a subclass of `A`, then add a concrete
+implementation of `m` in `A`:
+
+{% prettify dart tag=pre+code %}
+abstract class A {
+ void m() {}
+}
+
+mixin M on A {
+ void bar() {
+ super.m();
+ }
+}
+
+abstract class B extends A with M {}
+{% endprettify %}
+
+### mixin_instantiate
+
+_Mixins can't be instantiated._
+
+#### Description
+
+The analyzer produces this diagnostic when a mixin is instantiated.
+
+#### Example
+
+The following code produces this diagnostic because the mixin `M` is being
+instantiated:
+
+{% prettify dart tag=pre+code %}
+mixin M {}
+
+var m = [!M!]();
+{% endprettify %}
+
+#### Common fixes
+
+If you intend to use an instance of a class, then use the name of that
+class in place of the name of the mixin.
+
### mixin_of_non_class
_Classes can only mix in mixins and classes._
@@ -6955,6 +7926,89 @@
}
{% endprettify %}
+### non_constant_case_expression_from_deferred_library
+
+_Constant values from a deferred library can't be used as a case expression._
+
+#### Description
+
+The analyzer produces this diagnostic when the expression in a case clause
+references a constant from a library that is imported using a deferred
+import. In order for switch statements to be compiled efficiently, the
+constants referenced in case clauses need to be available at compile time,
+and constants 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 the constant `zero`:
+
+{% prettify dart tag=pre+code %}
+const zero = 0;
+{% endprettify %}
+
+The following code produces this diagnostic because the library `a.dart` is
+imported using a `deferred` import, and the constant `a.zero`, declared in
+the imported library, is used in a case clause:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' deferred as a;
+
+void f(int x) {
+ switch (x) {
+ case [!a.zero!]:
+ // ...
+ break;
+ }
+}
+{% endprettify %}
+
+#### Common fixes
+
+If you need to reference the constant from the imported library, then
+remove the `deferred` keyword:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' as a;
+
+void f(int x) {
+ switch (x) {
+ case a.zero:
+ // ...
+ break;
+ }
+}
+{% endprettify %}
+
+If you need to reference the constant from the imported library and also
+need the imported library to be deferred, then rewrite the switch statement
+as a sequence of `if` statements:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' deferred as a;
+
+void f(int x) {
+ if (x == a.zero) {
+ // ...
+ }
+}
+{% endprettify %}
+
+If you don't need to reference the constant, then replace the case
+expression:
+
+{% prettify dart tag=pre+code %}
+void f(int x) {
+ switch (x) {
+ case 0:
+ // ...
+ break;
+ }
+}
+{% endprettify %}
+
### non_constant_default_value
_The default value of an optional parameter must be constant._
@@ -6996,6 +8050,56 @@
}
{% endprettify %}
+### non_constant_default_value_from_deferred_library
+
+_Constant values from a deferred library can't be used as a default parameter
+value._
+
+#### Description
+
+The analyzer produces this diagnostic when the default value of an optional
+parameter uses a constant from a library imported using a deferred import.
+Default values need to be available at compile time, and constants 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 the constant `zero`:
+
+{% prettify dart tag=pre+code %}
+const zero = 0;
+{% endprettify %}
+
+The following code produces this diagnostic because `zero` is declared in a
+library imported using a deferred import:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' deferred as a;
+
+void f({int x = [!a.zero!]}) {}
+{% endprettify %}
+
+#### Common fixes
+
+If you need to reference the constant from the imported library, then
+remove the `deferred` keyword:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' as a;
+
+void f({int x = a.zero}) {}
+{% endprettify %}
+
+If you don't need to reference the constant, then replace the default
+value:
+
+{% prettify dart tag=pre+code %}
+void f({int x = 0}) {}
+{% endprettify %}
+
### non_constant_list_element
_The values in a const list literal must be constants._
@@ -9532,6 +10636,53 @@
int f(C c) => c.b;
{% endprettify %}
+### subtype_of_deferred_class
+
+_Classes and mixins can't implement deferred classes._
+
+_Classes can't extend deferred classes._
+
+_Classes can't mixin deferred classes._
+
+#### Description
+
+The analyzer produces this diagnostic when a type (class or mixin) is a
+subtype of a class from a library being imported using a deferred import.
+The supertypes of a type must be compiled at the same time as the type, and
+classes from deferred libraries aren't compiled until the library is
+loaded.
+
+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 the class `A`:
+
+{% prettify dart tag=pre+code %}
+class A {}
+{% endprettify %}
+
+The following code produces this diagnostic because the superclass of `B`
+is declared in a deferred library:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' deferred as a;
+
+class B extends [!a.A!] {}
+{% endprettify %}
+
+#### Common fixes
+
+If you need to create a subtype of a type from the deferred library, then
+remove the `deferred` keyword:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' as a;
+
+class B extends a.A {}
+{% endprettify %}
+
### subtype_of_disallowed_type
_''{0}' can't be used as a superclass constraint._
@@ -9767,6 +10918,46 @@
}
{% endprettify %}
+### type_annotation_deferred_class
+
+_The deferred type '{0}' can't be used in a declaration, cast, or type test._
+
+#### Description
+
+The analyzer produces this diagnostic when the type annotation is in a
+variable declaration, or the type used in a cast (`as`) or type test (`is`)
+is a type declared in a library that is imported using a deferred import.
+These types are required to be available at compile time, but aren't.
+
+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 type of the
+parameter `f` is imported from a deferred library:
+
+{% prettify dart tag=pre+code %}
+import 'dart:io' deferred as io;
+
+void f([!io.File!] f) {}
+{% endprettify %}
+
+#### Common fixes
+
+If you need to reference the imported type, then remove the `deferred`
+keyword:
+
+{% prettify dart tag=pre+code %}
+import 'dart:io' as io;
+
+void f(io.File f) {}
+{% endprettify %}
+
+If the import is required to be deferred and there's another type that is
+appropriate, then use that type in place of the type from the deferred
+library.
+
### type_argument_not_matching_bounds
_'{0}' doesn't conform to the bound '{2}' of the type parameter '{1}'._
diff --git a/pkg/analyzer/tool/diagnostics/generate.dart b/pkg/analyzer/tool/diagnostics/generate.dart
index 1680135..5f8db9e 100644
--- a/pkg/analyzer/tool/diagnostics/generate.dart
+++ b/pkg/analyzer/tool/diagnostics/generate.dart
@@ -410,11 +410,13 @@
* [constant context][]
* [definite assignment][]
+* [mixin application][]
* [override inference][]
* [potentially non-nullable][]
[constant context]: #constant-context
[definite assignment]: #definite-assignment
+[mixin application]: #mixin-application
[override inference]: #override-inference
[potentially non-nullable]: #potentially-non-nullable
@@ -545,6 +547,40 @@
[definiteAssignmentSpec](https://github.com/dart-lang/language/blob/master/resources/type-system/flow-analysis.md)
+### Mixin Application
+
+A _mixin application_ is the class created when a mixin is applied to a class.
+For example, consider the following declarations:
+
+```dart
+class A {}
+
+mixin M {}
+
+class B extends A with M {}
+```
+
+The class `B` is a subclass of the mixin application of `M` to `A`, sometimes
+nomenclated as `A+M`. The class `A+M` is a subclass of `A` and has members that
+are copied from `M`.
+
+You can give an actual name to a mixin application by defining it as:
+
+```dart
+class A {}
+
+mixin M {}
+
+class A_M = A with M;
+```
+
+Given this declaration of `A_M`, the following declaration of `B` is equivalent
+to the declaration of `B` in the original example:
+
+```dart
+class B extends A_M {}
+```
+
### Override inference
Override inference is the process by which any missing types in a method
diff --git a/tools/VERSION b/tools/VERSION
index 46449c0..8bf87db 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 13
PATCH 0
-PRERELEASE 172
+PRERELEASE 173
PRERELEASE_PATCH 0
\ No newline at end of file